Commit c5566d09 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

Merge branch 'feature/stream-tracer-widgets' into feature/vtk-native

parents b3643e8f 4db817d3
......@@ -301,11 +301,11 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
dtkVisualizationDecoratorInfo *decorator_info = new dtkVisualizationDecoratorInfo;
dtkVisualizationDecoratorAxes *decorator_axes = new dtkVisualizationDecoratorAxes;
dtkVisualizationDecoratorDelaunay2D *decorator_delaunay_2D = new dtkVisualizationDecoratorDelaunay2D;
dtkVisualizationDecoratorPoints *decorator_points = new dtkVisualizationDecoratorPoints;
dtkVisualizationDecoratorScalarColorMap *decorator_scalar_colormap = new dtkVisualizationDecoratorScalarColorMap;
dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs;
dtkVisualizationDecoratorScalarIsolines *decorator_scalar_isolines = new dtkVisualizationDecoratorScalarIsolines;
//dtkVisualizationDecoratorDelaunay2D *decorator_delaunay_2D = new dtkVisualizationDecoratorDelaunay2D;
//dtkVisualizationDecoratorPoints *decorator_points = new dtkVisualizationDecoratorPoints;
dtkVisualizationDecoratorSurfaceColor *decorator_surface_color = new dtkVisualizationDecoratorSurfaceColor;
//dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs;
dtkVisualizationDecoratorIsocontours *decorator_isocontours = new dtkVisualizationDecoratorIsocontours;
dtkVisualizationDecoratorSlices *decorator_slices = new dtkVisualizationDecoratorSlices;
dtkVisualizationDecoratorSnapshot *decorator_snapshot = new dtkVisualizationDecoratorSnapshot;
dtkVisualizationDecoratorVectorGlyphs *decorator_vector_glyphs = new dtkVisualizationDecoratorVectorGlyphs;
......@@ -315,11 +315,11 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
dtkVisualizationDecoratorVolume *decorator_volume = new dtkVisualizationDecoratorVolume;
QList<dtkVisualizationDecorator *> decorators;
decorators << decorator_points
<< decorator_delaunay_2D
<< decorator_scalar_colormap
<< decorator_scalar_isolines
<< decorator_scalar_glyphs
decorators //<< decorator_points
//<< decorator_delaunay_2D
<< decorator_surface_color
<< decorator_isocontours
//<< decorator_scalar_glyphs
<< decorator_vector_glyphs
<< decorator_vector_curved_glyphs
<< decorator_vector_streamlines
......
......@@ -33,20 +33,20 @@ set(${PROJECT_NAME}_HEADERS
dtkVisualizationDecoratorClutEditorBase.h
dtkVisualizationDecoratorClutEditorSimple
dtkVisualizationDecoratorClutEditorSimple.h
dtkVisualizationDecoratorSurfaceColor
dtkVisualizationDecoratorSurfaceColor.h
dtkVisualizationDecoratorCollection
dtkVisualizationDecoratorCollection.h
dtkVisualizationDecoratorDelaunay2D
dtkVisualizationDecoratorDelaunay2D.h
dtkVisualizationDecoratorInfo
dtkVisualizationDecoratorInfo.h
dtkVisualizationDecoratorIsocontours
dtkVisualizationDecoratorIsocontours.h
dtkVisualizationDecoratorPoints
dtkVisualizationDecoratorPoints.h
dtkVisualizationDecoratorScalarColorMap
dtkVisualizationDecoratorScalarColorMap.h
dtkVisualizationDecoratorScalarGlyphs
dtkVisualizationDecoratorScalarGlyphs.h
dtkVisualizationDecoratorScalarIsolines
dtkVisualizationDecoratorScalarIsolines.h
dtkVisualizationDecoratorSlices
dtkVisualizationDecoratorSlices.h
dtkVisualizationDecoratorSnapshot
......@@ -99,13 +99,13 @@ set(${PROJECT_NAME}_SOURCES
dtkVisualizationDecoratorAxes.cpp
dtkVisualizationDecoratorClutEditor.cpp
dtkVisualizationDecoratorClutEditorSimple.cpp
dtkVisualizationDecoratorSurfaceColor.cpp
dtkVisualizationDecoratorCollection.cpp
dtkVisualizationDecoratorDelaunay2D.cpp
dtkVisualizationDecoratorInfo.cpp
dtkVisualizationDecoratorIsocontours.cpp
dtkVisualizationDecoratorPoints.cpp
dtkVisualizationDecoratorScalarColorMap.cpp
dtkVisualizationDecoratorScalarGlyphs.cpp
dtkVisualizationDecoratorScalarIsolines.cpp
dtkVisualizationDecoratorSlices.cpp
dtkVisualizationDecoratorSnapshot.cpp
dtkVisualizationDecoratorVectorCurvedGlyphs.cpp
......
......@@ -5,12 +5,12 @@
#include "dtkVisualizationDecoratorClutEditor.h"
#include "dtkVisualizationDecoratorClutEditorBase.h"
#include "dtkVisualizationDecoratorClutEditorSimple.h"
#include "dtkVisualizationDecoratorSurfaceColor.h"
#include "dtkVisualizationDecoratorCollection.h"
#include "dtkVisualizationDecoratorDelaunay2D.h"
#include "dtkVisualizationDecoratorInfo.h"
#include "dtkVisualizationDecoratorIsocontours.h"
#include "dtkVisualizationDecoratorPoints.h"
#include "dtkVisualizationDecoratorScalarColorMap.h"
#include "dtkVisualizationDecoratorScalarIsolines.h"
#include "dtkVisualizationDecoratorScalarGlyphs.h"
#include "dtkVisualizationDecoratorSlices.h"
#include "dtkVisualizationDecoratorSnapshot.h"
......
#include "dtkVisualizationDecoratorIsocontours.h"
......@@ -12,13 +12,15 @@
// Code:
#include "dtkVisualizationDecoratorScalarIsolines.h"
#include "dtkVisualizationDecoratorIsocontours.h"
#include "dtkVisualizationDecoratorWithClut_p.h"
#include "dtkVisualizationCanvas.h"
#include "dtkVisualizationMetaType.h"
#include "dtkVisualizationView2D.h"
#include <dtkVisualizationWidgets/dtkVisualizationWidgetsCategory>
#include <dtkLog>
#include <QtGui>
......@@ -41,10 +43,10 @@
#include <vtkSmartPointer.h>
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecoratorScalarIsolinesPrivate declaration
// dtkVisualizationDecoratorIsocontoursPrivate declaration
// ///////////////////////////////////////////////////////////////////
class dtkVisualizationDecoratorScalarIsolinesPrivate
class dtkVisualizationDecoratorIsocontoursPrivate
{
public:
vtkSmartPointer<vtkActor> actor;
......@@ -58,18 +60,54 @@ public:
int default_isolines_count = 10;
public:
QCheckBox *show_actor_cb = nullptr;
QSpinBox *isolines_counts_sb = nullptr;
QDoubleSpinBox *isolines_width_sb = nullptr;
QSlider *opacity_slider = nullptr;
QDoubleSpinBox *opacity_val_sp = nullptr;
public:
QHash<QString, std::size_t> isolines_counts;
public:
bool dirty = true;
bool dirty_range = true;
};
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecoratorScalarIsolines implementation
void dtkVisualizationDecoratorIsocontours::updateContours(void)
{
if (!d_func()->show_actor_cb->isChecked()) {
return;
}
auto field_name = d_func()->current_field_name;
if (field_name.isEmpty() || !d_func()->dataset) {
return;
}
auto&& isoline_range = d_func()->ranges[field_name];
auto count = d->isolines_counts[field_name];
d->isolines_counts_sb->blockSignals(true);
d->isolines_counts_sb->setValue(count);
d->isolines_counts_sb->blockSignals(false);
d->isolines->GenerateValues(count, isoline_range[0], isoline_range[1]);
d->isolines->Modified();
d->mapper->Modified();
d->actor->Modified();
}
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecoratorIsocontours implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorScalarIsolinesPrivate())
dtkVisualizationDecoratorIsocontours::dtkVisualizationDecoratorIsocontours(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorIsocontoursPrivate())
{
d->isolines = vtkSmartPointer<vtkContourFilter>::New();
......@@ -86,16 +124,25 @@ dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines
//////////
// Inspectors creation and setup
d->show_actor_cb = new QCheckBox;
d->isolines_counts_sb = new QSpinBox;
d->isolines_counts_sb->setObjectName("Count");
d->isolines_counts_sb->setValue(10);
d->isolines_counts_sb->setMaximum(10000);
d->isolines_counts_sb->setKeyboardTracking(false);
d->isolines_width_sb = new QDoubleSpinBox;
d->isolines_width_sb->setObjectName("Contour Width");
d->isolines_width_sb->setValue(1);
d->isolines_width_sb->setMinimum(0.1);
d->isolines_width_sb->setMaximum(10);
d->isolines_width_sb->setDecimals(1);
d->isolines_width_sb->setSingleStep(0.1);
d->isolines_width_sb->setKeyboardTracking(false);
//////////
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
connect(d_func()->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
this->saveSettings("visibility",state == Qt::Checked);
this->setVisibility(state == Qt::Checked);
this->draw();
......@@ -104,73 +151,70 @@ dtkVisualizationDecoratorScalarIsolines::dtkVisualizationDecoratorScalarIsolines
connect(d->isolines_counts_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value) {
this->saveSettings("isolines_count", value);
this->setCurrentIsolinesCount(value);
this->touch();
this->draw();
});
this->setObjectName("Scalar Isolines");
d->show_actor_cb->setObjectName("Display");
d->isolines_counts_sb->setObjectName("Count");
connect(d->isolines_width_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] (double value) {
this->saveSettings("isolines_line_width", value);
d->actor->GetProperty()->SetLineWidth(value);
d->actor->Modified();
this->draw();
});
this->setObjectName("Isocontours");
QWidget *param_box = new dtkVisualizationWidgetsCategory("Isocontours", {
d->isolines_counts_sb
});
d_func()->inspectors << d->show_actor_cb << d->isolines_counts_sb;
QWidget *styling_box = new dtkVisualizationWidgetsCategory("Styling", {
d->isolines_width_sb,
d_func()->opacity_widget
});
d_func()->inspectors << param_box << styling_box;
}
dtkVisualizationDecoratorScalarIsolines::~dtkVisualizationDecoratorScalarIsolines(void)
dtkVisualizationDecoratorIsocontours::~dtkVisualizationDecoratorIsocontours(void)
{
dtkVisualizationDecoratorScalarIsolines::unsetCanvas();
dtkVisualizationDecoratorIsocontours::unsetCanvas();
delete d;
d = nullptr;
}
void dtkVisualizationDecoratorScalarIsolines::restoreSettings(void)
void dtkVisualizationDecoratorIsocontours::restoreSettings(void)
{
QString name = this->objectName();
if (name.isEmpty())
return;
dtkVisualizationDecoratorWithClut::restoreSettings();
d->actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setCheckState(d_func()->default_visibility ? Qt::Checked : Qt::Unchecked);
d->show_actor_cb->blockSignals(false);
QSettings settings;
settings.beginGroup("canvas");
d->default_isolines_count = settings.value(name+"_isolines_count", 10).toInt();
settings.endGroup();
this->setCurrentIsolinesCount(d->default_isolines_count);
this->touch();
this->draw();
d->dirty_range = !d_func()->original_range;
}
void dtkVisualizationDecoratorScalarIsolines::touch(void)
void dtkVisualizationDecoratorIsocontours::touchRange(void)
{
dtkVisualizationDecoratorWithClut::touch();
if (!d->show_actor_cb->isChecked()) {
return;
// We first need to update the range of the current field.
dtkVisualizationDecoratorWithClut::touchRange();
// Then we update the contours when necessary
if (d->dirty || (d->dirty_range != d_func()->original_range)) {
this->updateContours();
d->dirty_range = d_func()->original_range;
d->dirty = false;
}
auto field_name = d_func()->current_field_name;
if (field_name.isEmpty() || !d_func()->dataset)
return;
auto&& isoline_range = d_func()->ranges[field_name];
auto count = d->isolines_counts[field_name];
d->isolines_counts_sb->blockSignals(true);
d->isolines_counts_sb->setValue(count);
d->isolines_counts_sb->blockSignals(false);
d->isolines->GenerateValues(count, isoline_range[0], isoline_range[1]);
d->isolines->Modified();
}
void dtkVisualizationDecoratorScalarIsolines::setData(const QVariant& data)
void dtkVisualizationDecoratorIsocontours::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
......@@ -181,6 +225,8 @@ void dtkVisualizationDecoratorScalarIsolines::setData(const QVariant& data)
d_func()->clear();
d_func()->retrieveScalarPoints(dataset);
d_func()->retrieveScalarCells(dataset);
d_func()->retrieveVectorPoints(dataset);
d_func()->retrieveVectorCells(dataset);
if (!this->isDecorating()) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet has no field to decorate. Nothing is done.";
......@@ -189,29 +235,29 @@ void dtkVisualizationDecoratorScalarIsolines::setData(const QVariant& data)
}
d_func()->dataset = dataset;
this->restoreSettings();
d->c2p_filter->SetInputData(dataset);
d_func()->sortEligibleFields();
d->isolines_counts.clear();
for (auto field_name : d_func()->eligible_field_names) {
d->isolines_counts[field_name] = d->default_isolines_count;
}
this->setCurrentFieldName(d_func()->current_field_name);
d->isolines->Modified();
d->mapper->Modified();
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if(this->canvas()) {
if (this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
}
d_func()->enableScalarBar();
}
void dtkVisualizationDecoratorScalarIsolines::setCanvas(dtkVisualizationCanvas *canvas)
void dtkVisualizationDecoratorIsocontours::setCanvas(dtkVisualizationCanvas *canvas)
{
this->unsetCanvas();
......@@ -221,14 +267,14 @@ void dtkVisualizationDecoratorScalarIsolines::setCanvas(dtkVisualizationCanvas *
return;
}
if(d->isolines->GetInput()) {
if (d->isolines->GetInput()) {
d_func()->view->renderer()->AddActor(d->actor);
}
d_func()->enableScalarBar();
}
void dtkVisualizationDecoratorScalarIsolines::unsetCanvas(void)
void dtkVisualizationDecoratorIsocontours::unsetCanvas(void)
{
if (d_func()->view) {
d_func()->view->renderer()->RemoveActor(d->actor);
......@@ -239,29 +285,27 @@ void dtkVisualizationDecoratorScalarIsolines::unsetCanvas(void)
d_func()->view = nullptr;
}
void dtkVisualizationDecoratorScalarIsolines::setVisibility(bool b)
void dtkVisualizationDecoratorIsocontours::setVisibility(bool b)
{
d->isolines_counts_sb->setEnabled(b);
dtkVisualizationDecoratorWithClut::setVisibility(b);
d->actor->SetVisibility(b);
}
void dtkVisualizationDecoratorScalarIsolines::setCurrentRange(double min, double max)
void dtkVisualizationDecoratorIsocontours::setOpacity(double opacity)
{
if (d_func()->current_field_name.isEmpty()) {
qWarning() << Q_FUNC_INFO << "Field not selected";
return;
}
if (min >= max) {
qWarning() << Q_FUNC_INFO << " min >= max : " << min << max;
return;
}
d->actor->GetProperty()->SetOpacity(opacity);
d->actor->Modified();
}
void dtkVisualizationDecoratorIsocontours::setCurrentRange(double min, double max)
{
dtkVisualizationDecoratorWithClut::setCurrentRange(min, max);
d->dirty = true;
}
void dtkVisualizationDecoratorScalarIsolines::setCurrentIsolinesCount(std::size_t count)
void dtkVisualizationDecoratorIsocontours::setCurrentIsolinesCount(std::size_t count)
{
QString& field_name = d_func()->current_field_name;
if (field_name.isEmpty()) {
......@@ -271,10 +315,10 @@ void dtkVisualizationDecoratorScalarIsolines::setCurrentIsolinesCount(std::size_
}
d->isolines_counts[field_name] = count;
this->touch();
d->dirty = true;
}
bool dtkVisualizationDecoratorScalarIsolines::setCurrentFieldName(const QString& field_name)
bool dtkVisualizationDecoratorIsocontours::setCurrentFieldName(const QString& field_name)
{
if (field_name.isEmpty()) {
dtkWarn() << Q_FUNC_INFO << "Field name is empty, nothing is done.";
......@@ -292,6 +336,8 @@ bool dtkVisualizationDecoratorScalarIsolines::setCurrentFieldName(const QString&
return false;
}
d->dirty = true;
using Support = dtkVisualizationDecoratorWithClut::Support;
int support = d_func()->supports[field_name];
if(support == Support::Point) {
......@@ -308,7 +354,7 @@ bool dtkVisualizationDecoratorScalarIsolines::setCurrentFieldName(const QString&
return dtkVisualizationDecoratorWithClut::setCurrentFieldName(field_name);
}
void dtkVisualizationDecoratorScalarIsolines::setColorMap(const QMap<double, QColor>& new_colormap)
void dtkVisualizationDecoratorIsocontours::setColorMap(const QMap<double, QColor>& new_colormap)
{
dtkVisualizationDecoratorWithClut::setColorMap(new_colormap);
......@@ -317,20 +363,7 @@ void dtkVisualizationDecoratorScalarIsolines::setColorMap(const QMap<double, QCo
auto&& range = d_func()->ranges[d_func()->current_field_name];
d->mapper->SetScalarRange(range[0], range[1]);
d->mapper->Modified();
//set opacity
// 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();
}
//
// dtkVisualizationDecoratorScalarIsolines.cpp ends here
// dtkVisualizationDecoratorIsocontours.cpp ends here
......@@ -18,26 +18,27 @@
#include "dtkVisualizationDecoratorWithClut.h"
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorScalarIsolines : public dtkVisualizationDecoratorWithClut
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorIsocontours : public dtkVisualizationDecoratorWithClut
{
Q_OBJECT
public:
dtkVisualizationDecoratorScalarIsolines(void);
~dtkVisualizationDecoratorScalarIsolines(void);
dtkVisualizationDecoratorIsocontours(void);
~dtkVisualizationDecoratorIsocontours(void);
public:
void touch(void) override;
protected:
void touchRange(void) override;
public:
void setData(const QVariant&) override;
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
void unsetCanvas(void) override;
protected:
void restoreSettings(void) override;
void setCurrentRange(double, double) override;
bool setCurrentFieldName(const QString&) override;
bool setCurrentFieldName(const QString&) override;
void setColorMap(const QMap<double, QColor>&) override;
void setOpacity(double) override;
public:
void setVisibility(bool) override;
......@@ -46,8 +47,11 @@ public:
void setCurrentIsolinesCount(std::size_t);
protected:
class dtkVisualizationDecoratorScalarIsolinesPrivate *d = nullptr;
void updateContours(void);
protected:
class dtkVisualizationDecoratorIsocontoursPrivate *d = nullptr;
};
//
// dtkVisualizationDecoratorScalarIsolines.h ends here
// dtkVisualizationDecoratorIsocontours.h ends here
#include "dtkVisualizationDecoratorScalarColorMap.h"
\ No newline at end of file
......@@ -15,11 +15,11 @@
#include "dtkVisualizationDecoratorScalarGlyphs.h"
#include "dtkVisualizationDecoratorWithClut_p.h"
#include "dtkVisualizationMetaType.h"
#include "dtkVisualizationView2D.h"
#include <dtkVisualizationWidgetsCategory.h>
#include <dtkLog>
#include <QtGui>
......@@ -66,7 +66,6 @@ public:
vtkSmartPointer<vtkCellCenters> cell_centers;
public:
QCheckBox *show_actor_cb = nullptr;
QDoubleSpinBox *glyphs_size_sb = nullptr;
QComboBox *glyphs_source_cb = nullptr;
......@@ -130,18 +129,15 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(voi
d->actor->SetMapper(d->mapper);
//////////
// Inspectors creation
// Inspectors
d->show_actor_cb = new QCheckBox;
d->glyphs_size_sb = new QDoubleSpinBox;
d->glyphs_source_cb = new QComboBox;
//////////
// Inspectors setup
d->glyphs_size_sb->setObjectName("Glyphs Size");
d->glyphs_size_sb->setMaximum(1000);
d->glyphs_size_sb->setKeyboardTracking(false);
d->glyphs_source_cb = new QComboBox;
d->glyphs_source_cb->setObjectName("Source Shape");
d->glyphs_source_cb->addItem("Arrow");
d->glyphs_source_cb->addItem("Cube");
d->glyphs_source_cb->addItem("Cylinder");
......@@ -151,7 +147,7 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(voi
//////////
// Inspectors connections
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
connect(d_func()->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) {
this->saveSettings("visibility",state == Qt::Checked);
this->setVisibility(state == Qt::Checked);
this->draw();
......@@ -191,11 +187,13 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(voi
});
this->setObjectName("Scalar Glyphs");
d->show_actor_cb->setObjectName("Display");
d->glyphs_size_sb->setObjectName("Glyphs Size");
d->glyphs_source_cb->setObjectName("Source Shape");
d_func()->inspectors << d->show_actor_cb << d->glyphs_size_sb << d->glyphs_source_cb;
QWidget *styling_box = new dtkVisualizationWidgetsCategory("Styling", {
d->glyphs_size_sb,
d->glyphs_source_cb
});