Commit d5587841 authored by CABEL Tristan's avatar CABEL Tristan

Merge branch 'feature/isolines' into 'develop'

Feature/isolines

See merge request !9
parents 93fa40a6 810456ef
......@@ -18,9 +18,10 @@
#include <dtkCore>
#include <dtkVisualization/dtkVisualizationView3D>
#include <dtkVisualization/dtkVisualizationDecoratorScalarColorMap>
#include <dtkVisualization/dtkVisualizationDecoratorScalarIsoline>
#include <dtkVisualization/dtkVisualizationDecoratorScalarGlyphs>
#include <dtkVisualization/dtkVisualizationDecoratorScalarIsolines>
#include <dtkVisualization/dtkVisualizationView3D>
#include <dtkVisualization/dtkVisualizationVTKReader>
......@@ -31,10 +32,11 @@
#include <dtkWidgets/dtkWidgetsOverlayRope>
#include <dtkWidgets/dtkWidgetsOverlayPane>
#include <dtkWidgets/dtkWidgetsOverlayPaneItem>
#include <vtkDataSet.h>
#include <vtkUnstructuredGrid.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkUnstructuredGrid.h>
#include <vtkXMLUnstructuredGridReader.h>
// ///////////////////////////////////////////////////////////////////
......@@ -157,11 +159,15 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
decorator_scalar_color_map->setCanvas(view_3d);
decorator_scalar_color_map->setData(data);
dtkVisualizationDecoratorScalarIsoline *decorator_scalar_isoline = new dtkVisualizationDecoratorScalarIsoline;
decorator_scalar_isoline->setCanvas(view_3d);
decorator_scalar_isoline->setData(data);
dtkVisualizationDecoratorScalarIsolines *decorator_scalar_isolines = new dtkVisualizationDecoratorScalarIsolines;
decorator_scalar_isolines->setCanvas(view_3d);
decorator_scalar_isolines->setData(data);
dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs;
decorator_scalar_glyphs->setCanvas(view_3d);
decorator_scalar_glyphs->setData(data);
(*decorator_scalar_color_map) << decorator_scalar_isoline;
*((*decorator_scalar_color_map) << decorator_scalar_isolines) << decorator_scalar_glyphs;
decorator_scalar_color_map->render();
}
......
......@@ -26,8 +26,10 @@ set(${PROJECT_NAME}_HEADERS
dtkVisualizationDecorator.h
dtkVisualizationDecoratorScalarColorMap
dtkVisualizationDecoratorScalarColorMap.h
dtkVisualizationDecoratorScalarIsoline
dtkVisualizationDecoratorScalarIsoline.h
dtkVisualizationDecoratorScalarGlyphs
dtkVisualizationDecoratorScalarGlyphs.h
dtkVisualizationDecoratorScalarIsolines
dtkVisualizationDecoratorScalarIsolines.h
dtkVisualizationPlot2D
dtkVisualizationPlot2D.h
dtkVisualizationPlot3D
......@@ -53,7 +55,8 @@ set(${PROJECT_NAME}_SOURCES
dtkVisualizationCanvas.cpp
dtkVisualizationDecorator.cpp
dtkVisualizationDecoratorScalarColorMap.cpp
dtkVisualizationDecoratorScalarIsoline.cpp
dtkVisualizationDecoratorScalarGlyphs.cpp
dtkVisualizationDecoratorScalarIsolines.cpp
dtkVisualizationPlot2D.cpp
dtkVisualizationPlot3D.cpp
dtkVisualizationVTKReader.cpp
......
#include "dtkVisualizationCanvas.h"
#include "dtkVisualizationDecorator.h"
#include "dtkVisualizationDecoratorScalarColorMap.h"
#include "dtkVisualizationDecoratorScalarIsoline.h"
#include "dtkVisualizationDecoratorScalarIsolines.h"
#include "dtkVisualizationDecoratorScalarGlyphs.h"
#include "dtkVisualizationPlot2D.h"
#include "dtkVisualizationPlot3D.h"
#include "dtkVisualizationVTKReader.h"
......
......@@ -63,6 +63,7 @@ void dtkVisualizationDecorator::drawAndForward(void)
if (d->next) {
d->next->drawAndForward();
} else {
if(!this->canvas()) return;
this->canvas()->renderer()->ResetCamera();
this->canvas()->renderer()->GetRenderWindow()->Render();
}
......@@ -78,6 +79,11 @@ void dtkVisualizationDecorator::setCanvas(dtkVisualizationCanvas *c)
d->canvas = c;
}
void dtkVisualizationDecorator::unsetCanvas(void)
{
d->canvas = nullptr;
}
QVariant dtkVisualizationDecorator::data(void) const
{
return d->data;
......
......@@ -42,7 +42,9 @@ public slots:
public:
virtual void setData(const QVariant&);
virtual void setCanvas(dtkVisualizationCanvas *);
virtual void unsetCanvas(void);
public:
QVariant data(void) const;
dtkVisualizationCanvas *canvas(void) const;
......
......@@ -233,13 +233,28 @@ void dtkVisualizationDecoratorScalarColorMap::setCanvas(dtkVisualizationCanvas *
dtkWidgetsOverlayPane *canvas_pane = canvas->overlay();
canvas_pane->setBound(500);
QCheckBox *show_cb = new QCheckBox;
dtkVisualizationWidgetsClutEditor *clut_editor = new dtkVisualizationWidgetsClutEditor;
QWidget *model_widget = new QWidget;
QFormLayout *form_layout = new QFormLayout(model_widget);
form_layout->addRow("Display", show_cb);
dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem;
pane_item->setTitle("Scalar Color Map");
pane_item->addWidget(model_widget);
pane_item->addWidget(clut_editor);
canvas_pane->addWidget(pane_item);
show_cb->setCheckState(Qt::Checked);
// show_cb connections
connect(show_cb, &QCheckBox::stateChanged, [=] (int state) {
if(state == Qt::Checked) this->show();
else this->hide();
});
// clut_editor connections
connect(this, &dtkVisualizationDecoratorScalarColorMap::currentRangeChanged, [=] (double min, double max) {
clut_editor->blockSignals(true);
clut_editor->setRange(min, max);
......@@ -255,10 +270,44 @@ void dtkVisualizationDecoratorScalarColorMap::setCanvas(dtkVisualizationCanvas *
connect(clut_editor, &dtkVisualizationWidgetsClutEditor::updated, [=] () {
this->blockSignals(true);
this->setCurrentColorTransferFunction(reinterpret_cast<vtkColorTransferFunction *>(clut_editor->colorTransferFunction()));
this->setCurrentOpacityTransferFunction(reinterpret_cast<vtkPiecewiseFunction *>(clut_editor->opacityTransferFunction()));
this->blockSignals(false);
});
}
void dtkVisualizationDecoratorScalarColorMap::unsetCanvas(void)
{
dtkVisualizationCanvas *canvas = this->canvas();
dtkVisualizationView2D *old = dynamic_cast<dtkVisualizationView2D *>(canvas);
if (old) {
old->renderer()->RemoveActor(d->actor);
}
dtkVisualizationView2D *view = dynamic_cast<dtkVisualizationView2D *>(canvas);
if (!view) {
qWarning() << Q_FUNC_INFO << "View 2D or view 3D expected as canvas. Canvas is reset to nullptr.";
dtkVisualizationDecorator::setCanvas(nullptr);
return;
}
}
void dtkVisualizationDecoratorScalarColorMap::show(void) {
d->actor->SetVisibility(true);
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
}
}
void dtkVisualizationDecoratorScalarColorMap::hide(void) {
d->actor->SetVisibility(false);
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
}
}
QStringList dtkVisualizationDecoratorScalarColorMap::eligibleFieldNames(void)
{
return d->eligible_field_names;
......@@ -363,7 +412,17 @@ void dtkVisualizationDecoratorScalarColorMap::setCurrentOpacityTransferFunction(
d->opacity_functions[d->current_field_name] = opacity_function;
//Need to be implemented, probably requires modifying the lut...
int size = opacity_function->GetSize();
double val[4];
double opacity_min = 1.;
for(std::size_t i = 0; i < size; ++i) {
opacity_function->GetNodeValue(i, val);
if(val[1] < opacity_min) opacity_min = val[1];
}
d->actor->GetProperty()->SetOpacity(opacity_min);
d->actor->Modified();
if (this->canvas() && this->canvas()->interactor()) {
this->canvas()->interactor()->Render();
......
......@@ -32,12 +32,14 @@ public:
dtkVisualizationDecoratorScalarColorMap(void);
~dtkVisualizationDecoratorScalarColorMap(void);
protected:
void draw(void) override;
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
public:
void show(void);
void hide(void);
public:
QStringList eligibleFieldNames(void);
......@@ -50,7 +52,7 @@ public:
bool setCurrentFieldName(const QString&);
void setCurrentColorTransferFunction(vtkSmartPointer<vtkColorTransferFunction>);
void setCurrentOpacityTransferFunction(vtkSmartPointer<vtkPiecewiseFunction>);
void setCurrentRange(double min, double max);
void setCurrentRange(double, double);
signals:
void currentFieldNameChanged(const QString&);
......@@ -58,7 +60,10 @@ signals:
void currentOpacityFunctionChanged(vtkPiecewiseFunction *);
void currentRangeChanged(double, double);
private:
protected:
void draw(void) override;
protected:
class dtkVisualizationDecoratorScalarColorMapPrivate *d;
};
......
#include "dtkVisualizationDecoratorScalarGlyphs.h"
\ No newline at end of file
This diff is collapsed.
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <dtkVisualizationExport>
#include <QtCore>
#include "dtkVisualizationDecorator.h"
#include <vtkSmartPointer.h>
#include <vtkColorTransferFunction.h>
#include <vtkPiecewiseFunction.h>
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecoratorScalarGlyphs declaration
// ///////////////////////////////////////////////////////////////////
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarGlyphs : public dtkVisualizationDecorator
{
Q_OBJECT
public:
dtkVisualizationDecoratorScalarGlyphs(void);
~dtkVisualizationDecoratorScalarGlyphs(void);
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
public:
void show(void);
void hide(void);
public:
QStringList eligibleFieldNames(void);
QString currentFieldName(void);
QPair<double, double> currentRange(void);
vtkSmartPointer<vtkColorTransferFunction> currentColorTransferFunction(void);
vtkSmartPointer<vtkPiecewiseFunction> currentOpacityTransferFunction(void);
public:
bool setCurrentFieldName(const QString&);
void setCurrentColorTransferFunction(vtkSmartPointer<vtkColorTransferFunction>);
void setCurrentOpacityTransferFunction(vtkSmartPointer<vtkPiecewiseFunction>);
void setCurrentRange(double, double);
void setCurrentGlyphsSize(double);
void setCurrentGlyphsSource(const QString&);
signals:
void currentFieldNameChanged(const QString&);
void currentColorTransferFunctionChanged(vtkColorTransferFunction *);
void currentOpacityFunctionChanged(vtkPiecewiseFunction *);
void currentRangeChanged(double, double);
void currentGlyphsSizeChanged(double);
void currentGlyphsSourceChanged(const QString&);
protected:
void draw(void) override;
protected:
class dtkVisualizationDecoratorScalarGlyphsPrivate *d = nullptr;
};
//
// dtkVisualizationDecoratorScalarGlyphs.h ends here
#include "dtkVisualizationDecoratorScalarIsoline.h"
#include "dtkVisualizationDecoratorScalarIsolines.h"
......@@ -25,22 +25,24 @@
#include <vtkPiecewiseFunction.h>
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecoratorScalarIsoline declaration
// dtkVisualizationDecoratorScalarIsolines declaration
// ///////////////////////////////////////////////////////////////////
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarIsoline : public dtkVisualizationDecorator
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarIsolines : public dtkVisualizationDecorator
{
Q_OBJECT
public:
dtkVisualizationDecoratorScalarIsoline(void);
~dtkVisualizationDecoratorScalarIsoline(void);
dtkVisualizationDecoratorScalarIsolines(void);
~dtkVisualizationDecoratorScalarIsolines(void);
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
protected:
void draw(void) override;
public:
void show(void);
void hide(void);
public:
QStringList eligibleFieldNames(void);
......@@ -53,17 +55,24 @@ public:
bool setCurrentFieldName(const QString&);
void setCurrentColorTransferFunction(vtkSmartPointer<vtkColorTransferFunction>);
void setCurrentOpacityTransferFunction(vtkSmartPointer<vtkPiecewiseFunction>);
void setCurrentRange(double min, double max);
void setCurrentRange(double, double);
void setCurrentIsolinesRange(double, double);
void setCurrentIsolinesCount(std::size_t);
signals:
void currentFieldNameChanged(const QString&);
void currentColorTransferFunctionChanged(vtkColorTransferFunction *);
void currentOpacityFunctionChanged(vtkPiecewiseFunction *);
void currentRangeChanged(double, double);
void currentIsolinesRangeChanged(double, double);
void currentIsolinesCountChanged(std::size_t);
protected:
void draw(void) override;
protected:
class dtkVisualizationDecoratorScalarIsolinePrivate *d = nullptr;
class dtkVisualizationDecoratorScalarIsolinesPrivate *d = nullptr;
};
//
// dtkVisualizationDecoratorScalarIsoline.h ends here
// dtkVisualizationDecoratorScalarIsolines.h ends here
......@@ -560,9 +560,6 @@ void dtkVisualizationWidgetsClutEditorScene::mouseDoubleClickEvent(QGraphicsScen
void dtkVisualizationWidgetsClutEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if(!this->sceneRect().adjusted(0.0, 50.0, 0.0, 0.0).contains(event->scenePos()))
return;
QPointF delta = event->scenePos() - event->lastScenePos();
for(QGraphicsItem *item : this->selectedItems()) {
......@@ -904,8 +901,6 @@ void dtkVisualizationWidgetsClutEditor::importClut(const QString& clut)
d->table->update();
d->button_log->setChecked(log);
this->onApply();
}
......@@ -1034,8 +1029,6 @@ void dtkVisualizationWidgetsClutEditor::importClut(void)
d->table->update();
d->button_log->setChecked(log);
this->onApply();
}
void dtkVisualizationWidgetsClutEditor::exportClut(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment