Commit d0e1f83a authored by CABEL Tristan's avatar CABEL Tristan

Merge branch 'release/2.22.0'

parents 1c735a42 43f981f1
Pipeline #140873 passed with stage
in 0 seconds
# Change Log:
# 2.22.0 28-Apr-2020
- decoratorClipper can hide all decorator of a collection
# 2.21.0 08-Apr-2020
- new GUI behavior for DecoratorWithClut (auto/manual mode)
- enhance scalar bar positioning (addScalarBar takes ScalarBarWidget)
......
......@@ -23,7 +23,7 @@ project(dtkVisualization)
## ###################################################################
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 21)
set(${PROJECT_NAME}_VERSION_MINOR 22)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -344,6 +344,9 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
//delete dec;
}
}
if(decorator_clipper->isDecorating())
decorator_clipper->setCollection(&d->collection);
//decorators.clear();
d->collection.setCanvas(canvas);
......
......@@ -34,7 +34,6 @@
int main(int argc, char **argv)
{
dtk::core::registerParameters();
dtk::widgets::initialize();
dtk::visualization::initialize();
dtkThemesEngine::instance()->apply();
......
......@@ -17,7 +17,7 @@ channels:
dependencies:
- qt >=5.9.0
- vtk=8.2.0
- dtk-widgets >=2.17.0, <2.18
- dtk-widgets >=2.22.2, <2.23
- gst-plugins-good
- gst-libav
......
......@@ -19,7 +19,7 @@ channels:
dependencies:
- qt >=5.9.0
- vtk=8.2.0
- dtk-widgets >=2.19.0
- dtk-widgets >=2.22.2
#
# dtk-visualization.yaml ends here
......@@ -42,14 +42,14 @@ requirements:
- {{ cdt('libxxf86vm') }} # [linux]
host:
- qt >=5.9.0
- dtk-widgets >=2.12.0
- dtk-widgets >=2.22.2
- dtk-themes >=2.1.0,<2.2
- vtk=8.2.0
run:
- vtk=8.2.0
- qt >=5.9.0
- dtk-widgets >=2.12.0
- dtk-widgets >=2.22.2
- dtk-themes >=2.1.0,<2.2
- gst-plugins-good # [linux]
- gst-libav # [linux]
......
......@@ -27,10 +27,26 @@ namespace dtk { namespace visualization {
DTK_DEFINE_CONCEPT(dtkVisualizationDecorator, decorator, dtk::visualization);
} }
class dtkVisualizationDecoratorPrivate
{
public:
bool is_visible = true;
};
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecorator implementation
// ///////////////////////////////////////////////////////////////////
dtkVisualizationDecorator::dtkVisualizationDecorator(): d(new dtkVisualizationDecoratorPrivate)
{
}
dtkVisualizationDecorator::~dtkVisualizationDecorator()
{
delete d;
d = nullptr;
}
void dtkVisualizationDecorator::draw(void)
{
if (this->canvas()) {
......@@ -46,6 +62,16 @@ void dtkVisualizationDecorator::saveSettings(const QString & name, const QVarian
settings.endGroup();
}
bool dtkVisualizationDecorator::isVisible()
{
return d->is_visible;
}
void dtkVisualizationDecorator::setVisibility(bool visible)
{
d->is_visible = visible;
}
void dtkVisualizationDecorator::show(void)
{
this->setVisibility(true);
......
......@@ -25,10 +25,26 @@ class dtkVisualizationCanvas;
class vtkTransform;
class QWidget;
class dtkVisualizationDecoratorPrivate;
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationDecorator declaration
// ///////////////////////////////////////////////////////////////////
/**
* # Inputs of the decorator
* ## Stand-alone decorator
* The instances use two inputs:
* - the data to decorate. \sa dtkVisualisationDecorator::setData ;
* - the internal parameters of how to decorate.
* ## Linked decorators
* Allow a decorator to get the data from the processing of another one.
* As an example: decorate the outputs of dtkVisualizationDecoratorClipper, so
* that the linked decorators are only decorating the non-clipped part of the scene.
* \sa dtkVisualisationDecorator::setInputConnection
* \sa dtkVisualisationDecorator::outputPort
*
*/
class DTKVISUALIZATION_EXPORT dtkVisualizationDecorator : public QObject
{
Q_OBJECT
......@@ -37,8 +53,8 @@ public:
using Connection = vtkAlgorithmOutput;
public:
dtkVisualizationDecorator(void) = default;
~dtkVisualizationDecorator(void) = default;
dtkVisualizationDecorator(void);
~dtkVisualizationDecorator(void);
public:
virtual void touch(void) = 0;
......@@ -56,7 +72,12 @@ protected:
virtual void restoreSettings(void) {};
public:
virtual void setVisibility(bool visible) = 0;
virtual bool isVisible();
/**
* Makes the decorator visible or not.
* @param visible Whether the decorator has to be visible.
*/
virtual void setVisibility(bool visible);
virtual bool isDecorating(void) = 0;
......@@ -75,6 +96,9 @@ public:
public:
virtual void setInputConnection(Connection *);
virtual Connection *outputPort(void);
private:
dtkVisualizationDecoratorPrivate *d;
};
// ///////////////////////////////////////////////////////////////////
......
......@@ -202,6 +202,7 @@ void dtkVisualizationDecoratorAxes::unsetCanvas(void)
void dtkVisualizationDecoratorAxes::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
d->cube_axes_actor->SetVisibility(visible);
}
......
......@@ -18,6 +18,11 @@ public:
public:
QList<QWidget *> inspectors;
public:
//collection containing this decorator
dtkVisualizationDecoratorCollection *collection = nullptr;
QList<dtkVisualizationDecorator *> hidden_decorators;
public:
vtkSmartPointer<vtkPlane> plane = nullptr;
vtkSmartPointer<vtkDataSet> data = nullptr;
......@@ -26,7 +31,8 @@ public:
vtkSmartPointer<vtkUnstructuredGridAlgorithm> current_clipper = nullptr;
QList<dtkVisualizationDecorator *> output_decorators;
QRadioButton *button_none = nullptr;
QRadioButton *button_novisu = nullptr;
QRadioButton *button_noclip = nullptr;
QRadioButton *button_clip = nullptr;
QRadioButton *button_extract = nullptr;
......@@ -90,16 +96,25 @@ dtkVisualizationDecoratorClipper::dtkVisualizationDecoratorClipper(void): d(new
d->inspectors << box;
box->setStyleSheet("QGroupBox{background-color:transparent; border-color:transparent; margin: 0; padding: 0; spacing: 0}");
d->button_none = new QRadioButton("None");
d->button_novisu = new QRadioButton("None");
d->button_noclip = new QRadioButton("No Clipping");
d->button_clip = new QRadioButton("Clip");
d->button_clip->setToolTip("Clipping can be very CPU-intensive. \"Extract cells\" should be preferred when performance is poor.");
d->button_extract = new QRadioButton("Extract cells");
d->button_extract->setToolTip("Provide a coarser-grain clipping algorithm than \"Clip\"");
layout->addWidget(d->button_none);
layout->addWidget(d->button_novisu);
layout->addWidget(d->button_noclip);
layout->addWidget(d->button_clip);
layout->addWidget(d->button_extract);
auto update_current_clipper = [=] (vtkSmartPointer<vtkUnstructuredGridAlgorithm> chosen_clipper) {
if(!d->hidden_decorators.isEmpty()) {
for(auto dec : d->hidden_decorators) {
dec->setVisibility(true);
}
}
d->hidden_decorators.clear();
d->current_clipper = chosen_clipper;
const bool clipping = chosen_clipper != nullptr;
if (clipping) {
......@@ -125,10 +140,27 @@ dtkVisualizationDecoratorClipper::dtkVisualizationDecoratorClipper(void): d(new
}
};
d->button_none->setChecked(true);
d->button_noclip->setChecked(true);
d->widget->SetEnabled(false);
connect(d->button_none, &QRadioButton::released, [=] () {
connect(d->button_novisu, &QRadioButton::released, [=] () {
d->hidden_decorators.clear();
if(d->collection) {
for(auto *dec : *d->collection) {
if(dec->isVisible()) {
d->hidden_decorators << dec;
dec->setVisibility(false);
}
}
} else {
d->hidden_decorators << this;
this->setVisibility(false);
}
if(this->canvas())
this->draw();
});
connect(d->button_noclip, &QRadioButton::released, [=] () {
update_current_clipper(nullptr);
});
connect(d->button_clip, &QRadioButton::released, [=] () {
......@@ -146,6 +178,11 @@ dtkVisualizationDecoratorClipper::~dtkVisualizationDecoratorClipper(void)
delete d; d = nullptr;
}
void dtkVisualizationDecoratorClipper::setCollection(dtkVisualizationDecoratorCollection *coll)
{
d->collection = coll;
}
void dtkVisualizationDecoratorClipper::restoreSettings(void)
{
QSettings settings;
......@@ -156,7 +193,7 @@ void dtkVisualizationDecoratorClipper::restoreSettings(void)
QRadioButton *saved_button =
saved_clipper == "Clip" ? d->button_clip :
saved_clipper == "Extract" ? d->button_extract :
d->button_none;
d->button_noclip;
saved_button->setChecked(true);
emit saved_button->released();
......@@ -259,6 +296,7 @@ void dtkVisualizationDecoratorClipper::unsetCanvas(void)
void dtkVisualizationDecoratorClipper::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
d->widget->SetEnabled(visible && (d->current_clipper != nullptr));
for (auto *output_decorator: d->output_decorators) {
output_decorator->setVisibility(visible);
......
......@@ -21,6 +21,7 @@ protected:
public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void setCollection(dtkVisualizationDecoratorCollection *);
void unsetCanvas(void) override;
public:
......
......@@ -244,6 +244,7 @@ void dtkVisualizationDecoratorDelaunay2D::unsetCanvas(void)
void dtkVisualizationDecoratorDelaunay2D::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
d->actor->SetVisibility(visible);
d->show_actor_cb->blockSignals(true);
......
......@@ -166,6 +166,7 @@ bool dtkVisualizationDecoratorInfo::isDecorating(void)
void dtkVisualizationDecoratorInfo::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
for (QWidget * w: d->inspectors) {
w->setVisible(visible);
}
......
......@@ -215,6 +215,7 @@ void dtkVisualizationDecoratorPoints::unsetCanvas(void)
void dtkVisualizationDecoratorPoints::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
d->actor->SetVisibility(visible);
d->show_actor_cb->blockSignals(true);
......
......@@ -128,8 +128,9 @@ QVariant dtkVisualizationDecoratorSnapshot::data(void) const
return QVariant();
}
void dtkVisualizationDecoratorSnapshot::setVisibility(bool)
void dtkVisualizationDecoratorSnapshot::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
}
dtkVisualizationCanvas *dtkVisualizationDecoratorSnapshot::canvas(void) const
......
......@@ -130,7 +130,8 @@ dtkVisualizationDecoratorVertexEdge::dtkVisualizationDecoratorVertexEdge(void) :
<< d->vertex_indicator;
connect(d->edge_indicator, &dtkVisualizationWidgetsVertexEdgesControls::toggled,
[=](bool checked) {
[=](bool checked)
{
if (checked && !d->is_edges_initialized) {
d->initializeEdges();
}
......@@ -343,17 +344,16 @@ void dtkVisualizationDecoratorVertexEdge::unsetCanvas(void)
void dtkVisualizationDecoratorVertexEdge::setVisibility(bool visible)
{
d->edges_actor->SetVisibility(visible);
d->edge_indicator->setActive(visible);
dtkVisualizationDecorator::setVisibility(visible);
if (visible && !d->is_edges_initialized) {
d->initializeEdges();
}
d->edges_actor->SetVisibility(visible && d->edge_indicator->isActive());
d->vertex_actor->SetVisibility(visible);
d->vertex_indicator->setActive(visible);
if (visible && !d->is_vertex_initialized) {
d->initializeVertex();
}
d->vertex_actor->SetVisibility(visible && d->vertex_indicator->isActive());
}
QVariant dtkVisualizationDecoratorVertexEdge::data(void) const
......
......@@ -662,6 +662,7 @@ void dtkVisualizationDecoratorWithClut::touchColorMap(void)
void dtkVisualizationDecoratorWithClut::setVisibility(bool visible)
{
dtkVisualizationDecorator::setVisibility(visible);
d->show_scalar_bar->setEnabled(visible);
d->scalar_bar->SetVisibility(visible &&
d->show_scalar_bar->isChecked() &&
......
......@@ -86,6 +86,11 @@ dtkVisualizationWidgetsVertexEdgesControls::dtkVisualizationWidgetsVertexEdgesCo
setActive(d->enabled_button->isChecked());
}
bool dtkVisualizationWidgetsVertexEdgesControls::isActive(void)
{
return d->enabled_button->isChecked();
}
void dtkVisualizationWidgetsVertexEdgesControls::setActive(bool checked)
{
d->enabled_button->blockSignals(true);
......
......@@ -14,6 +14,8 @@ Q_OBJECT
public:
dtkVisualizationWidgetsVertexEdgesControls(QWidget *parent = nullptr);
/** Whether the decoration is active */
bool isActive(void);
void setActive(bool checked);
void setColor(const QColor& color);
......
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