Commit 934ec15a authored by Pierre Fernique's avatar Pierre Fernique

Merge branch 'develop' of https://gitlab.inria.fr/dtk/dtk-visualization into...

Merge branch 'develop' of https://gitlab.inria.fr/dtk/dtk-visualization into feature/separe_points_from_cells
parents 914b197f 6dd8a558
...@@ -162,6 +162,7 @@ void dtkVisualizationViewer::importDataSet(const QString& path) ...@@ -162,6 +162,7 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
dtkVisualizationDecoratorScalarIsolines *decorator_scalar_isolines = new dtkVisualizationDecoratorScalarIsolines; dtkVisualizationDecoratorScalarIsolines *decorator_scalar_isolines = new dtkVisualizationDecoratorScalarIsolines;
dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs; dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs;
decorator_clut_editor->setName("my clut editor");
//chain all decorators //chain all decorators
*decorator_clut_editor << *decorator_scalar_isolines << *decorator_scalar_glyphs << *decorator_scalar_color_map ; *decorator_clut_editor << *decorator_scalar_isolines << *decorator_scalar_glyphs << *decorator_scalar_color_map ;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
class dtkVisualizationDecoratorPrivate class dtkVisualizationDecoratorPrivate
{ {
public: public:
QString name;
QVariant data; QVariant data;
dtkVisualizationCanvas *canvas = nullptr; dtkVisualizationCanvas *canvas = nullptr;
dtkVisualizationDecorator *previous = nullptr; dtkVisualizationDecorator *previous = nullptr;
...@@ -37,9 +38,9 @@ public: ...@@ -37,9 +38,9 @@ public:
// dtkVisualizationDecorator implementation // dtkVisualizationDecorator implementation
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
dtkVisualizationDecorator::dtkVisualizationDecorator(void) : d(new dtkVisualizationDecoratorPrivate) dtkVisualizationDecorator::dtkVisualizationDecorator(const QString &name) : d(new dtkVisualizationDecoratorPrivate)
{ {
d->name = name;
} }
dtkVisualizationDecorator::~dtkVisualizationDecorator(void) dtkVisualizationDecorator::~dtkVisualizationDecorator(void)
...@@ -96,6 +97,16 @@ void dtkVisualizationDecorator::unsetCanvas(void) ...@@ -96,6 +97,16 @@ void dtkVisualizationDecorator::unsetCanvas(void)
d->canvas = nullptr; d->canvas = nullptr;
} }
void dtkVisualizationDecorator::setName(const QString &name)
{
d->name = name;
}
const QString &dtkVisualizationDecorator::name(void)
{
return d->name;
}
QVariant dtkVisualizationDecorator::data(void) const QVariant dtkVisualizationDecorator::data(void) const
{ {
return d->data; return d->data;
......
...@@ -36,7 +36,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecorator : public QObject ...@@ -36,7 +36,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecorator : public QObject
Q_OBJECT Q_OBJECT
public: public:
dtkVisualizationDecorator(void); dtkVisualizationDecorator(const QString& name = "");
~dtkVisualizationDecorator(void); ~dtkVisualizationDecorator(void);
public slots: public slots:
...@@ -47,6 +47,10 @@ public: ...@@ -47,6 +47,10 @@ public:
virtual void setCanvas(dtkVisualizationCanvas *); virtual void setCanvas(dtkVisualizationCanvas *);
virtual void unsetCanvas(void); virtual void unsetCanvas(void);
public:
void setName(const QString& name);
const QString& name(void);
public: public:
QVariant data(void) const; QVariant data(void) const;
dtkVisualizationCanvas *canvas(void) const; dtkVisualizationCanvas *canvas(void) const;
......
...@@ -78,8 +78,11 @@ public: ...@@ -78,8 +78,11 @@ public:
// dtkVisualizationDecoratorClutEditor implementation // dtkVisualizationDecoratorClutEditor implementation
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorClutEditor::dtkVisualizationDecoratorClutEditor(void): d(new dtkVisualizationDecoratorClutEditorPrivate()) dtkVisualizationDecoratorClutEditor::dtkVisualizationDecoratorClutEditor(const QString& name): dtkVisualizationDecorator("clut Editor"), d(new dtkVisualizationDecoratorClutEditorPrivate())
{ {
if(!name.isEmpty())
this->setName(name);
d->scalar_bar = vtkSmartPointer<vtkScalarBarActor>::New(); d->scalar_bar = vtkSmartPointer<vtkScalarBarActor>::New();
d->scalar_bar->SetWidth(0.08); d->scalar_bar->SetWidth(0.08);
d->scalar_bar->SetHeight(0.6); d->scalar_bar->SetHeight(0.6);
...@@ -310,7 +313,7 @@ void dtkVisualizationDecoratorClutEditor::setCanvas(dtkVisualizationCanvas *canv ...@@ -310,7 +313,7 @@ void dtkVisualizationDecoratorClutEditor::setCanvas(dtkVisualizationCanvas *canv
dtkVisualizationWidgetsClutEditor *clut_editor = new dtkVisualizationWidgetsClutEditor; dtkVisualizationWidgetsClutEditor *clut_editor = new dtkVisualizationWidgetsClutEditor;
dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem; dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem;
pane_item->setTitle("Clut Editor"); pane_item->setTitle(this->name());
pane_item->addWidget(widget_bar_and_fields); pane_item->addWidget(widget_bar_and_fields);
pane_item->addWidget(clut_editor); pane_item->addWidget(clut_editor);
pane_item->addWidget(range_widget); pane_item->addWidget(range_widget);
......
...@@ -29,7 +29,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorClutEditor : public dtkVi ...@@ -29,7 +29,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorClutEditor : public dtkVi
Q_OBJECT Q_OBJECT
public: public:
dtkVisualizationDecoratorClutEditor(void); dtkVisualizationDecoratorClutEditor(const QString& name="");
~dtkVisualizationDecoratorClutEditor(void); ~dtkVisualizationDecoratorClutEditor(void);
public: public:
......
...@@ -76,8 +76,11 @@ public: ...@@ -76,8 +76,11 @@ public:
// dtkVisualizationDecoratorScalarColorMap implementation // dtkVisualizationDecoratorScalarColorMap implementation
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarColorMap::dtkVisualizationDecoratorScalarColorMap(void): d(new dtkVisualizationDecoratorScalarColorMapPrivate()) dtkVisualizationDecoratorScalarColorMap::dtkVisualizationDecoratorScalarColorMap(const QString& name): dtkVisualizationDecorator("Scalar Color Map"), d(new dtkVisualizationDecoratorScalarColorMapPrivate())
{ {
if(!name.isEmpty())
this->setName(name);
d->mapper = vtkSmartPointer<vtkDataSetMapper>::New(); d->mapper = vtkSmartPointer<vtkDataSetMapper>::New();
d->mapper->SetColorModeToMapScalars(); d->mapper->SetColorModeToMapScalars();
d->mapper->SetScalarVisibility(true); d->mapper->SetScalarVisibility(true);
...@@ -204,7 +207,7 @@ void dtkVisualizationDecoratorScalarColorMap::setCanvas(dtkVisualizationCanvas * ...@@ -204,7 +207,7 @@ void dtkVisualizationDecoratorScalarColorMap::setCanvas(dtkVisualizationCanvas *
form_layout->addRow("Field", d->fields_box); form_layout->addRow("Field", d->fields_box);
dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem; dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem;
pane_item->setTitle("Scalar Color Map"); pane_item->setTitle(this->name());
pane_item->addWidget(model_widget); pane_item->addWidget(model_widget);
canvas_pane->addWidget(pane_item); canvas_pane->addWidget(pane_item);
......
...@@ -29,7 +29,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarColorMap : public d ...@@ -29,7 +29,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarColorMap : public d
Q_OBJECT Q_OBJECT
public: public:
dtkVisualizationDecoratorScalarColorMap(void); dtkVisualizationDecoratorScalarColorMap(const QString& name="");
~dtkVisualizationDecoratorScalarColorMap(void); ~dtkVisualizationDecoratorScalarColorMap(void);
public: public:
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <vtkPointData.h> #include <vtkPointData.h>
#include <vtkPolyDataMapper.h> #include <vtkPolyDataMapper.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkRegularPolygonSource.h>
#include <vtkRendererCollection.h> #include <vtkRendererCollection.h>
#include <vtkRenderWindow.h> #include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h> #include <vtkRenderWindowInteractor.h>
...@@ -78,6 +79,7 @@ public: ...@@ -78,6 +79,7 @@ public:
vtkSmartPointer<vtkCylinderSource> source_cylinder; vtkSmartPointer<vtkCylinderSource> source_cylinder;
vtkSmartPointer<vtkSphereSource> source_sphere; vtkSmartPointer<vtkSphereSource> source_sphere;
vtkSmartPointer<vtkGlyph3D> glyphs; vtkSmartPointer<vtkGlyph3D> glyphs;
vtkSmartPointer<vtkRegularPolygonSource> source_polygon;
public: public:
QHash<QString, double> glyphs_sizes; QHash<QString, double> glyphs_sizes;
...@@ -91,8 +93,11 @@ public: ...@@ -91,8 +93,11 @@ public:
// dtkVisualizationDecoratorScalarGlyphs implementation // dtkVisualizationDecoratorScalarGlyphs implementation
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(void): d(new dtkVisualizationDecoratorScalarGlyphsPrivate()) dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(const QString& name): dtkVisualizationDecorator("Scalar Glyphs"), d(new dtkVisualizationDecoratorScalarGlyphsPrivate())
{ {
if(!name.isEmpty())
this->setName(name);
d->source_arrow = vtkSmartPointer<vtkArrowSource>::New(); d->source_arrow = vtkSmartPointer<vtkArrowSource>::New();
d->source_cube = vtkSmartPointer<vtkCubeSource>::New(); d->source_cube = vtkSmartPointer<vtkCubeSource>::New();
...@@ -103,6 +108,8 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(voi ...@@ -103,6 +108,8 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(voi
d->source_sphere->SetThetaResolution(12.); d->source_sphere->SetThetaResolution(12.);
d->source_sphere->SetPhiResolution(12.); d->source_sphere->SetPhiResolution(12.);
d->source_polygon = vtkSmartPointer<vtkRegularPolygonSource>::New();
d->glyphs = vtkSmartPointer<vtkGlyph3D>::New(); d->glyphs = vtkSmartPointer<vtkGlyph3D>::New();
d->glyphs->SetScaleModeToDataScalingOff(); d->glyphs->SetScaleModeToDataScalingOff();
d->glyphs->SetColorModeToColorByScalar(); d->glyphs->SetColorModeToColorByScalar();
...@@ -237,6 +244,7 @@ void dtkVisualizationDecoratorScalarGlyphs::setCanvas(dtkVisualizationCanvas *ca ...@@ -237,6 +244,7 @@ void dtkVisualizationDecoratorScalarGlyphs::setCanvas(dtkVisualizationCanvas *ca
glyphs_source_cb->addItem("Cube"); glyphs_source_cb->addItem("Cube");
glyphs_source_cb->addItem("Cylinder"); glyphs_source_cb->addItem("Cylinder");
glyphs_source_cb->addItem("Sphere"); glyphs_source_cb->addItem("Sphere");
glyphs_source_cb->addItem("Polygon");
QWidget *model_widget = new QWidget; QWidget *model_widget = new QWidget;
QFormLayout *form_layout = new QFormLayout(model_widget); QFormLayout *form_layout = new QFormLayout(model_widget);
...@@ -246,7 +254,7 @@ void dtkVisualizationDecoratorScalarGlyphs::setCanvas(dtkVisualizationCanvas *ca ...@@ -246,7 +254,7 @@ void dtkVisualizationDecoratorScalarGlyphs::setCanvas(dtkVisualizationCanvas *ca
form_layout->addRow("Source", glyphs_source_cb); form_layout->addRow("Source", glyphs_source_cb);
dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem; dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem;
pane_item->setTitle("Scalar Glyphs"); pane_item->setTitle(this->name());
pane_item->addWidget(model_widget); pane_item->addWidget(model_widget);
canvas_pane->addWidget(pane_item); canvas_pane->addWidget(pane_item);
...@@ -460,6 +468,10 @@ bool dtkVisualizationDecoratorScalarGlyphs::setCurrentFieldName(const QString& s ...@@ -460,6 +468,10 @@ bool dtkVisualizationDecoratorScalarGlyphs::setCurrentFieldName(const QString& s
d->source_sphere->SetRadius(glyphs_size); d->source_sphere->SetRadius(glyphs_size);
d->source_sphere->Modified(); d->source_sphere->Modified();
d->glyphs->SetSourceConnection(d->source_sphere->GetOutputPort()); d->glyphs->SetSourceConnection(d->source_sphere->GetOutputPort());
} else if (glyphs_source == "Polygon") {
d->source_polygon->SetRadius(glyphs_size);
d->source_polygon->Modified();
d->glyphs->SetSourceConnection(d->source_polygon->GetOutputPort());
} }
d->glyphs->Modified(); d->glyphs->Modified();
...@@ -503,6 +515,9 @@ void dtkVisualizationDecoratorScalarGlyphs::setCurrentGlyphsSize(double size) ...@@ -503,6 +515,9 @@ void dtkVisualizationDecoratorScalarGlyphs::setCurrentGlyphsSize(double size)
} else if (source == "Sphere") { } else if (source == "Sphere") {
d->source_sphere->SetRadius(size); d->source_sphere->SetRadius(size);
d->source_sphere->Modified(); d->source_sphere->Modified();
} else if (source == "Polygon") {
d->source_polygon->SetRadius(size);
d->source_polygon->Modified();
} }
d->glyphs->Modified(); d->glyphs->Modified();
...@@ -531,8 +546,12 @@ void dtkVisualizationDecoratorScalarGlyphs::setCurrentGlyphsSource(const QString ...@@ -531,8 +546,12 @@ void dtkVisualizationDecoratorScalarGlyphs::setCurrentGlyphsSource(const QString
d->glyphs->SetSourceConnection(d->source_cylinder->GetOutputPort()); d->glyphs->SetSourceConnection(d->source_cylinder->GetOutputPort());
} else if (source == "Sphere") { } else if (source == "Sphere") {
d->glyphs->SetSourceConnection(d->source_sphere->GetOutputPort()); d->glyphs->SetSourceConnection(d->source_sphere->GetOutputPort());
} else if (source == "Polygon") {
d->glyphs->SetSourceConnection(d->source_polygon->GetOutputPort());
} }
d->glyphs_sources[d->current_field_name]= source;
d->glyphs->Modified(); d->glyphs->Modified();
d->mapper->Modified(); d->mapper->Modified();
d->actor->Modified(); d->actor->Modified();
......
...@@ -32,7 +32,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarGlyphs : public dtk ...@@ -32,7 +32,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarGlyphs : public dtk
{ {
Q_OBJECT Q_OBJECT
public: public:
dtkVisualizationDecoratorScalarGlyphs(void); dtkVisualizationDecoratorScalarGlyphs(const QString& name="");
~dtkVisualizationDecoratorScalarGlyphs(void); ~dtkVisualizationDecoratorScalarGlyphs(void);
public: public:
......
...@@ -85,8 +85,10 @@ public: ...@@ -85,8 +85,10 @@ public:
// dtkVisualizationDecoratorScalarIsolines implementation // dtkVisualizationDecoratorScalarIsolines implementation
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines(void): d(new dtkVisualizationDecoratorScalarIsolinesPrivate()) dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines(const QString &name): dtkVisualizationDecorator("Scalar Isolines"), d(new dtkVisualizationDecoratorScalarIsolinesPrivate())
{ {
if(!name.isEmpty())
this->setName(name);
d->isolines = vtkSmartPointer<vtkContourFilter>::New(); d->isolines = vtkSmartPointer<vtkContourFilter>::New();
...@@ -228,7 +230,7 @@ void dtkVisualizationDecoratorScalarIsolines::setCanvas(dtkVisualizationCanvas * ...@@ -228,7 +230,7 @@ void dtkVisualizationDecoratorScalarIsolines::setCanvas(dtkVisualizationCanvas *
form_layout->addRow("Max", isolines_max_sb); form_layout->addRow("Max", isolines_max_sb);
dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem; dtkWidgetsOverlayPaneItem *pane_item = new dtkWidgetsOverlayPaneItem;
pane_item->setTitle("Scalar Isolines"); pane_item->setTitle(this->name());
pane_item->addWidget(model_widget); pane_item->addWidget(model_widget);
canvas_pane->addWidget(pane_item); canvas_pane->addWidget(pane_item);
......
...@@ -32,7 +32,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarIsolines : public d ...@@ -32,7 +32,7 @@ class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarIsolines : public d
{ {
Q_OBJECT Q_OBJECT
public: public:
dtkVisualizationDecoratorScalarIsolines(void); dtkVisualizationDecoratorScalarIsolines(const QString& name="");
~dtkVisualizationDecoratorScalarIsolines(void); ~dtkVisualizationDecoratorScalarIsolines(void);
public: public:
......
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