Commit 404d3554 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

Merge branch 'develop' into feature/vtk-native

parents 1c0174cf 45d930bc
...@@ -301,7 +301,7 @@ void dtkVisualizationViewer::importDataSet(const QString& path) ...@@ -301,7 +301,7 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
dtkVisualizationDecoratorInfo *decorator_info = new dtkVisualizationDecoratorInfo; dtkVisualizationDecoratorInfo *decorator_info = new dtkVisualizationDecoratorInfo;
dtkVisualizationDecoratorAxes *decorator_axes = new dtkVisualizationDecoratorAxes; dtkVisualizationDecoratorAxes *decorator_axes = new dtkVisualizationDecoratorAxes;
//dtkVisualizationDecoratorDelaunay2D *decorator_delaunay_2D = new dtkVisualizationDecoratorDelaunay2D; dtkVisualizationDecoratorDelaunay2D *decorator_delaunay_2D = new dtkVisualizationDecoratorDelaunay2D;
//dtkVisualizationDecoratorPoints *decorator_points = new dtkVisualizationDecoratorPoints; //dtkVisualizationDecoratorPoints *decorator_points = new dtkVisualizationDecoratorPoints;
dtkVisualizationDecoratorSurfaceColor *decorator_surface_color = new dtkVisualizationDecoratorSurfaceColor; dtkVisualizationDecoratorSurfaceColor *decorator_surface_color = new dtkVisualizationDecoratorSurfaceColor;
//dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs; //dtkVisualizationDecoratorScalarGlyphs *decorator_scalar_glyphs = new dtkVisualizationDecoratorScalarGlyphs;
...@@ -316,7 +316,7 @@ void dtkVisualizationViewer::importDataSet(const QString& path) ...@@ -316,7 +316,7 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
QList<dtkVisualizationDecorator *> decorators; QList<dtkVisualizationDecorator *> decorators;
decorators //<< decorator_points decorators //<< decorator_points
//<< decorator_delaunay_2D << decorator_delaunay_2D
<< decorator_surface_color << decorator_surface_color
<< decorator_isocontours << decorator_isocontours
//<< decorator_scalar_glyphs //<< decorator_scalar_glyphs
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include "dtkVisualizationMetaType.h" #include "dtkVisualizationMetaType.h"
#include "dtkVisualizationView2D.h" #include "dtkVisualizationView2D.h"
#include <dtkVisualizationWidgets/dtkVisualizationWidgetsCategory>
#include <dtkVisualizationWidgets/dtkVisualizationWidgetsColorDialog>
#include <dtkLog> #include <dtkLog>
#include <QtGui> #include <QtGui>
...@@ -56,10 +59,11 @@ public: ...@@ -56,10 +59,11 @@ public:
public: public:
bool default_visibility; bool default_visibility;
QColor default_color = QColor();
public: public:
QCheckBox *show_actor_cb = nullptr; QCheckBox *show_actor_cb = nullptr;
QPushButton *color_button = nullptr; dtkVisualizationWidgetsColorDialog *col_dialog = nullptr;
QDoubleSpinBox *opacity_spinbox = nullptr; QDoubleSpinBox *opacity_spinbox = nullptr;
public: public:
...@@ -91,43 +95,59 @@ dtkVisualizationDecoratorDelaunay2D::dtkVisualizationDecoratorDelaunay2D(void): ...@@ -91,43 +95,59 @@ dtkVisualizationDecoratorDelaunay2D::dtkVisualizationDecoratorDelaunay2D(void):
d->actor->SetMapper(d->mapper); d->actor->SetMapper(d->mapper);
d->actor->SetVisibility(d->default_visibility); d->actor->SetVisibility(d->default_visibility);
d->actor->GetProperty()->SetPointSize(30); d->actor->GetProperty()->SetPointSize(30);
d->actor->GetProperty()->SetColor(0.5,0.5,0.5); d->actor->GetProperty()->SetColor(d->default_color.red(),
d->default_color.green(),
d->default_color.blue());
////////// //////////
// Inspectors creation // Inspectors creation
d->color_button = new QPushButton("Color"); d->col_dialog = new dtkVisualizationWidgetsColorDialog;
d->opacity_spinbox = new QDoubleSpinBox; d->col_dialog->setObjectName("Color");
d->show_actor_cb = new QCheckBox;
d->opacity_spinbox = new QDoubleSpinBox;
d->opacity_spinbox->setObjectName("Opacity"); d->opacity_spinbox->setObjectName("Opacity");
d->opacity_spinbox->setRange(0, 1); d->opacity_spinbox->setRange(0, 1);
d->opacity_spinbox->setDecimals(2); d->opacity_spinbox->setDecimals(2);
d->opacity_spinbox->setSingleStep(0.01); d->opacity_spinbox->setSingleStep(0.01);
d->opacity_spinbox->setValue(1.); d->opacity_spinbox->setValue(1.);
d->show_actor_cb = new QCheckBox;
d->show_actor_cb->setObjectName("Display"); d->show_actor_cb->setObjectName("Display");
d->show_actor_cb->setChecked(d->default_visibility); d->show_actor_cb->setChecked(d->default_visibility);
////////// //////////
// Inspectors connections // Inspectors connections
connect(d->color_button, &QPushButton::released, [=] (void) { connect(d->col_dialog, &dtkVisualizationWidgetsColorDialog::colorChanged, [=] (QColor c)
double *vtk_color = d->actor->GetProperty()->GetColor(); {
QColor qt_color = QColor(vtk_color[0], vtk_color[1], vtk_color[2]); if (c.isValid()) {
qt_color = QColorDialog::getColor(qt_color, d->color_button); this->saveSettings("color", c);
this->setColor(qt_color); d->actor->GetProperty()->SetColor(c.red(), c.green(), c.blue());
this->draw();
}
}); });
connect(d->opacity_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &dtkVisualizationDecoratorDelaunay2D::setOpacity); connect(d->opacity_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] (double opacity)
{
this->saveSettings("opacity", opacity);
d->actor->GetProperty()->SetOpacity(opacity);
this->draw();
});
connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state) { connect(d->show_actor_cb, &QCheckBox::stateChanged, [=] (int state)
this->saveSettings("visibility",state == Qt::Checked); {
this->setVisibility(state == Qt::Checked); this->saveSettings("visibility",state == Qt::Checked);
this->draw(); this->setVisibility(state == Qt::Checked);
this->draw();
});
auto styling_box = new dtkVisualizationWidgetsCategory("Styling", {
d->col_dialog,
d->opacity_spinbox
}); });
d->inspectors << d->color_button << d->opacity_spinbox << d->show_actor_cb; d->inspectors << d->show_actor_cb << styling_box;
} }
dtkVisualizationDecoratorDelaunay2D::~dtkVisualizationDecoratorDelaunay2D(void) dtkVisualizationDecoratorDelaunay2D::~dtkVisualizationDecoratorDelaunay2D(void)
...@@ -147,7 +167,13 @@ void dtkVisualizationDecoratorDelaunay2D::restoreSettings(void) ...@@ -147,7 +167,13 @@ void dtkVisualizationDecoratorDelaunay2D::restoreSettings(void)
QSettings settings; QSettings settings;
settings.beginGroup("canvas"); settings.beginGroup("canvas");
d->default_visibility = settings.value(name+"_visibility", false).toBool(); d->default_visibility = settings.value(name+"_visibility", false).toBool();
d->default_color = QColor(settings.value(name+"_color", "").toString());
double opacity = settings.value(name+"_opacity", 1.0).toDouble();
settings.endGroup(); settings.endGroup();
this->setVisibility(d->default_visibility);
this->setColor(d->default_color);
this->setOpacity(opacity);
} }
void dtkVisualizationDecoratorDelaunay2D::touch(void) void dtkVisualizationDecoratorDelaunay2D::touch(void)
...@@ -229,7 +255,9 @@ void dtkVisualizationDecoratorDelaunay2D::setColor(const QColor& color) ...@@ -229,7 +255,9 @@ void dtkVisualizationDecoratorDelaunay2D::setColor(const QColor& color)
{ {
d->actor->GetProperty()->SetColor(color.red(), color.green(), color.blue()); d->actor->GetProperty()->SetColor(color.red(), color.green(), color.blue());
this->draw(); d->col_dialog->blockSignals(true);
d->col_dialog->setColor(d->default_color);
d->col_dialog->blockSignals(false);
} }
void dtkVisualizationDecoratorDelaunay2D::setOpacity(const double& alpha) void dtkVisualizationDecoratorDelaunay2D::setOpacity(const double& alpha)
...@@ -239,8 +267,6 @@ void dtkVisualizationDecoratorDelaunay2D::setOpacity(const double& alpha) ...@@ -239,8 +267,6 @@ void dtkVisualizationDecoratorDelaunay2D::setOpacity(const double& alpha)
d->opacity_spinbox->blockSignals(true); d->opacity_spinbox->blockSignals(true);
d->opacity_spinbox->setValue(alpha); d->opacity_spinbox->setValue(alpha);
d->opacity_spinbox->blockSignals(false); d->opacity_spinbox->blockSignals(false);
this->draw();
} }
QVariant dtkVisualizationDecoratorDelaunay2D::data(void) const QVariant dtkVisualizationDecoratorDelaunay2D::data(void) const
......
...@@ -78,10 +78,6 @@ public: ...@@ -78,10 +78,6 @@ public:
void dtkVisualizationDecoratorIsocontours::updateContours(void) void dtkVisualizationDecoratorIsocontours::updateContours(void)
{ {
if (!d_func()->show_actor_cb->isChecked()) {
return;
}
auto field_name = d_func()->current_field_name; auto field_name = d_func()->current_field_name;
if (field_name.isEmpty() || !d_func()->dataset) { if (field_name.isEmpty() || !d_func()->dataset) {
...@@ -142,25 +138,28 @@ dtkVisualizationDecoratorIsocontours::dtkVisualizationDecoratorIsocontours(void) ...@@ -142,25 +138,28 @@ dtkVisualizationDecoratorIsocontours::dtkVisualizationDecoratorIsocontours(void)
////////// //////////
// Inspectors connections // Inspectors connections
connect(d_func()->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->saveSettings("visibility", state == Qt::Checked);
this->draw(); this->setVisibility(state == Qt::Checked);
}); this->draw();
});
connect(d->isolines_counts_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value) {
this->saveSettings("isolines_count", value); connect(d->isolines_counts_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value)
this->setCurrentIsolinesCount(value); {
this->touch(); this->saveSettings("isolines_count", value);
this->draw(); this->setCurrentIsolinesCount(value);
}); this->touch();
this->draw();
connect(d->isolines_width_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] (double value) { });
this->saveSettings("isolines_line_width", value);
d->actor->GetProperty()->SetLineWidth(value); connect(d->isolines_width_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=] (double value)
d->actor->Modified(); {
this->draw(); this->saveSettings("isolines_line_width", value);
}); d->actor->GetProperty()->SetLineWidth(value);
d->actor->Modified();
this->draw();
});
this->setObjectName("Isocontours"); this->setObjectName("Isocontours");
......
...@@ -109,6 +109,7 @@ dtkVisualizationDecoratorVectorGlyphs::dtkVisualizationDecoratorVectorGlyphs(voi ...@@ -109,6 +109,7 @@ dtkVisualizationDecoratorVectorGlyphs::dtkVisualizationDecoratorVectorGlyphs(voi
{ {
this->saveSettings("scaling_mode", component_id); this->saveSettings("scaling_mode", component_id);
this->touch(); this->touch();
this->draw();
}); });
connect(d->glyphs_stride_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value) connect(d->glyphs_stride_sb, QOverload<int>::of(&QSpinBox::valueChanged), [=] (int value)
......
...@@ -647,10 +647,12 @@ void dtkVisualizationDecoratorVectorStreamTracer::setVisibility(bool visible) ...@@ -647,10 +647,12 @@ void dtkVisualizationDecoratorVectorStreamTracer::setVisibility(bool visible)
{ {
dtkVisualizationDecoratorWithClut::setVisibility(visible); dtkVisualizationDecoratorWithClut::setVisibility(visible);
d->actor->SetVisibility(visible); d->actor->SetVisibility(visible);
if (d->cb_seed_type->currentText() == "Sphere") { if (d->cb_show_seed->isChecked()) {
d->source_sphere_widget->SetEnabled(visible); if (d->cb_seed_type->currentText() == "Sphere") {
} else { d->source_sphere_widget->SetEnabled(visible);
d->source_line_widget->SetEnabled(visible); } else {
d->source_line_widget->SetEnabled(visible);
}
} }
} }
......
...@@ -69,6 +69,7 @@ protected: ...@@ -69,6 +69,7 @@ protected:
virtual void setOpacity(double); virtual void setOpacity(double);
protected: protected:
friend class dtkVisualizationDecoratorWithClutPrivate;
class dtkVisualizationDecoratorWithClutPrivate *d; class dtkVisualizationDecoratorWithClutPrivate *d;
dtkVisualizationDecoratorWithClutPrivate *d_func(void); dtkVisualizationDecoratorWithClutPrivate *d_func(void);
const dtkVisualizationDecoratorWithClutPrivate *d_func(void) const; const dtkVisualizationDecoratorWithClutPrivate *d_func(void) const;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <array> #include <array>
class dtkVisualizationView2D; class dtkVisualizationView2D;
class dtkVisualizationWidgetsColorDialog;
class dtkVisualizationWidgetsColorMapEditor; class dtkVisualizationWidgetsColorMapEditor;
class QCheckBox; class QCheckBox;
...@@ -35,6 +36,7 @@ class QSlider; ...@@ -35,6 +36,7 @@ class QSlider;
class vtkColorTransferFunction; class vtkColorTransferFunction;
class vtkDataSet; class vtkDataSet;
class vtkDataSetAttributes; class vtkDataSetAttributes;
class vtkLookupTable;
class vtkPiecewiseFunction; class vtkPiecewiseFunction;
class vtkPiecewiseFunction; class vtkPiecewiseFunction;
class vtkScalarBarActor; class vtkScalarBarActor;
...@@ -42,6 +44,9 @@ class vtkTransform; ...@@ -42,6 +44,9 @@ class vtkTransform;
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorWithClutPrivate class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorWithClutPrivate
{ {
public:
class dtkVisualizationDecoratorWithClut *q = nullptr;
public: public:
enum Support { enum Support {
Unknown = 0, Unknown = 0,
...@@ -68,19 +73,21 @@ public: ...@@ -68,19 +73,21 @@ public:
QComboBox *fields_box = nullptr; QComboBox *fields_box = nullptr;
QComboBox *field_components = nullptr; QComboBox *field_components = nullptr;
QWidget *range_widget = nullptr;
QPushButton *reset_range = nullptr; QPushButton *reset_range = nullptr;
QLineEdit *min_range = nullptr; QLineEdit *min_range = nullptr;
QLineEdit *max_range = nullptr; QLineEdit *max_range = nullptr;
bool original_range = true; bool original_range = true;
QCheckBox *show_scalar_bar = nullptr; QCheckBox *show_scalar_bar = nullptr;
QCheckBox *show_actor_cb = nullptr; QCheckBox *show_actor_cb = nullptr;
public:
QWidget *opacity_widget = nullptr; QWidget *opacity_widget = nullptr;
QSlider *opacity_slider = nullptr; QSlider *opacity_slider = nullptr;
QDoubleSpinBox *opacity_val_sp = nullptr; QDoubleSpinBox *opacity_val_sp = nullptr;
public: dtkVisualizationWidgetsColorDialog *col_dialog = nullptr;
dtkVisualizationWidgetsColorMapEditor *colormap_editor = nullptr; dtkVisualizationWidgetsColorMapEditor *colormap_editor = nullptr;
public: public:
...@@ -95,8 +102,8 @@ public: ...@@ -95,8 +102,8 @@ public:
public: public:
vtkSmartPointer<vtkColorTransferFunction> color_function; vtkSmartPointer<vtkColorTransferFunction> color_function;
vtkSmartPointer<vtkPiecewiseFunction> opacity; vtkSmartPointer<vtkPiecewiseFunction> opacity;
vtkSmartPointer<vtkTransform> transform; vtkSmartPointer<vtkTransform> transform;
vtkSmartPointer<vtkScalarBarActor> scalar_bar; vtkSmartPointer<vtkScalarBarActor> scalar_bar;
......
...@@ -24,6 +24,8 @@ set(${PROJECT_NAME}_HEADERS ...@@ -24,6 +24,8 @@ set(${PROJECT_NAME}_HEADERS
dtkVisualizationWidgetsActorList.h dtkVisualizationWidgetsActorList.h
dtkVisualizationWidgetsClutEditor dtkVisualizationWidgetsClutEditor
dtkVisualizationWidgetsClutEditor.h dtkVisualizationWidgetsClutEditor.h
dtkVisualizationWidgetsColorDialog
dtkVisualizationWidgetsColorDialog.h
dtkVisualizationWidgetsColorMapEditor dtkVisualizationWidgetsColorMapEditor
dtkVisualizationWidgetsColorMapEditor.h dtkVisualizationWidgetsColorMapEditor.h
dtkVisualizationWidgetsFieldScalar dtkVisualizationWidgetsFieldScalar
...@@ -39,6 +41,7 @@ set(${PROJECT_NAME}_HEADERS ...@@ -39,6 +41,7 @@ set(${PROJECT_NAME}_HEADERS
set(${PROJECT_NAME}_SOURCES set(${PROJECT_NAME}_SOURCES
dtkVisualizationWidgetsActorList.cpp dtkVisualizationWidgetsActorList.cpp
dtkVisualizationWidgetsClutEditor.cpp dtkVisualizationWidgetsClutEditor.cpp
dtkVisualizationWidgetsColorDialog.cpp
dtkVisualizationWidgetsColorMapEditor.cpp dtkVisualizationWidgetsColorMapEditor.cpp
dtkVisualizationWidgetsFieldScalar.cpp dtkVisualizationWidgetsFieldScalar.cpp
dtkVisualizationWidgetsSliceControls.cpp dtkVisualizationWidgetsSliceControls.cpp
......
#include "dtkVisualizationWidgetsCategory.h"
#include "dtkVisualizationWidgetsClutEditor.h" #include "dtkVisualizationWidgetsClutEditor.h"
#include "dtkVisualizationWidgetsColorDialog.h"
#include "dtkVisualizationWidgetsSliceControls.h" #include "dtkVisualizationWidgetsSliceControls.h"
#include "dtkVisualizationWidgetsVideoControls.h" #include "dtkVisualizationWidgetsVideoControls.h"
#include "dtkVisualizationWidgetsColorDialog.h"
// dtkVisualizationWidgetsColorDialog.cpp
//
#include "dtkVisualizationWidgetsColorDialog.h"
#include <dtkFonts/dtkFontAwesome>
#include <QtGui>
#include <QtWidgets>
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
class dtkVisualizationWidgetsColorDialogPrivate
{
public:
QLineEdit *line_edit = nullptr;
QPushButton *color_button = nullptr;
QPushButton *dialog_button = nullptr;
};
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
dtkVisualizationWidgetsColorDialog::dtkVisualizationWidgetsColorDialog(QWidget *parent) : QWidget(parent), d(new dtkVisualizationWidgetsColorDialogPrivate)
{
d->line_edit = new QLineEdit;
d->color_button = new QPushButton;
d->dialog_button = new QPushButton;
QHBoxLayout *h_layout = new QHBoxLayout;
h_layout->setAlignment(Qt::AlignLeft);
h_layout->setContentsMargins(0,0,0,0);
h_layout->addWidget(d->line_edit);
h_layout->addWidget(d->color_button);
h_layout->addWidget(d->dialog_button);
this->setLayout(h_layout);
d->line_edit->setMaxLength(7);
d->line_edit->setAlignment(Qt::AlignRight);
d->line_edit->setReadOnly(true);
d->color_button->setEnabled(false);
d->dialog_button->setIcon(dtkFontAwesome::instance()->icon(fa::adjust));
d->dialog_button->setToolTip("Select Color");
connect(d->dialog_button, &QPushButton::released, [=] (void)
{
this->setColor(QColorDialog::getColor(this->currentColor(), d->dialog_button));
});
}
dtkVisualizationWidgetsColorDialog::~dtkVisualizationWidgetsColorDialog(void)
{
delete d;
}
void dtkVisualizationWidgetsColorDialog::setColor(const QColor& c)
{
if (c.isValid()) {
d->line_edit->blockSignals(true);
d->line_edit->setText(c.name());
d->line_edit->blockSignals(false);
d->color_button->setStyleSheet(QString("QPushButton { background-color: %1; }").arg(c.name()));
}
emit this->colorChanged(c);
}
QColor dtkVisualizationWidgetsColorDialog::currentColor(void) const
{
return QColor(d->line_edit->text());
}
//
// dtkVisualizationWidgetsColorDialog.cpp ends here
// dtkVisualizationWidgetsColorDialog.h
//
#pragma once
#include <dtkVisualizationWidgetsExport>
#include <QtWidgets/QWidget>
// /////////////////////////////////////////////////////////////////
// dtkVisualizationWidgetsColorDialog
// /////////////////////////////////////////////////////////////////
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsColorDialog : public QWidget
{
Q_OBJECT
public:
dtkVisualizationWidgetsColorDialog(QWidget * = nullptr);
~dtkVisualizationWidgetsColorDialog(void);
public:
void setColor(const QColor&);
QColor currentColor(void) const;
signals:
void colorChanged(QColor);
private:
class dtkVisualizationWidgetsColorDialogPrivate *d;
};
//
// dtkVisualizationWidgetsColorDialogdtkVisualizationWidgetsColorDialog.h ends here
...@@ -293,9 +293,7 @@ void dtkVisualizationWidgetsVideoControls::mousePressEvent(QMouseEvent *event) ...@@ -293,9 +293,7 @@ void dtkVisualizationWidgetsVideoControls::mousePressEvent(QMouseEvent *event)
double percent = (event->pos().x() - d->progress_bar->x())/ (double)size ; double percent = (event->pos().x() - d->progress_bar->x())/ (double)size ;
int frame_index = std::round(percent * d->progress_bar->maximum() + (1.0-percent) * d->progress_bar->minimum()); int frame_index = std::round(percent * d->progress_bar->maximum() + (1.0-percent) * d->progress_bar->minimum());
emit seekTo(frame_index); emit seekTo(frame_index);
event->ignore(); event->accept();
QFrame::mousePressEvent(event);
} }
#include "dtkVisualizationWidgetsVideoControls.moc" #include "dtkVisualizationWidgetsVideoControls.moc"
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