Commit 9ec3502d authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Merge branch 'feature/clut_per_data' into 'develop'

Feature/clut per data

See merge request !11
parents 206e774f 4d0ddd4f
......@@ -18,6 +18,7 @@
#include <dtkCore>
#include <dtkVisualization/dtkVisualizationDecoratorClutEditor>
#include <dtkVisualization/dtkVisualizationDecoratorScalarColorMap>
#include <dtkVisualization/dtkVisualizationDecoratorScalarGlyphs>
#include <dtkVisualization/dtkVisualizationDecoratorScalarIsolines>
......@@ -155,19 +156,18 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
vtkDataSet *dataset = dtkVisualizationVTKReader(path);
QVariant data = dtk::variantFromValue(dataset);
dtkVisualizationDecoratorScalarColorMap *decorator_scalar_color_map = new dtkVisualizationDecoratorScalarColorMap;
decorator_scalar_color_map->setCanvas(view_3d);
decorator_scalar_color_map->setData(data);
dtkVisualizationDecoratorClutEditor *decorator_clut_editor = new dtkVisualizationDecoratorClutEditor;
dtkVisualizationDecoratorScalarColorMap *decorator_scalar_color_map = new dtkVisualizationDecoratorScalarColorMap;
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_isolines) << decorator_scalar_glyphs;
//chain all decorators
*decorator_clut_editor << *decorator_scalar_isolines << *decorator_scalar_glyphs << *decorator_scalar_color_map ;
//setCanvas and setData on the first decorator
decorator_clut_editor->setCanvas(view_3d);
decorator_clut_editor->setData(data);
decorator_scalar_color_map->render();
}
......
......@@ -37,6 +37,9 @@ int main(int argc, char **argv)
qputenv("XDG_CURRENT_DESKTOP", "GNOME");
#endif
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication application(argc, argv);
application.setApplicationName("dtkVisualizationViewer");
application.setOrganizationName("inria");
......
......@@ -24,6 +24,8 @@ set(${PROJECT_NAME}_HEADERS
dtkVisualizationCanvas.h
dtkVisualizationDecorator
dtkVisualizationDecorator.h
dtkVisualizationDecoratorClutEditor
dtkVisualizationDecoratorClutEditor.h
dtkVisualizationDecoratorScalarColorMap
dtkVisualizationDecoratorScalarColorMap.h
dtkVisualizationDecoratorScalarGlyphs
......@@ -57,6 +59,7 @@ set(${PROJECT_NAME}_HEADERS
set(${PROJECT_NAME}_SOURCES
dtkVisualizationCanvas.cpp
dtkVisualizationDecorator.cpp
dtkVisualizationDecoratorClutEditor.cpp
dtkVisualizationDecoratorScalarColorMap.cpp
dtkVisualizationDecoratorScalarGlyphs.cpp
dtkVisualizationDecoratorScalarIsolines.cpp
......
#include "dtkVisualizationCanvas.h"
#include "dtkVisualizationDecoratorClutEditor.h"
#include "dtkVisualizationDecorator.h"
#include "dtkVisualizationDecoratorScalarColorMap.h"
#include "dtkVisualizationDecoratorScalarIsolines.h"
......
......@@ -72,8 +72,9 @@ dtkVisualizationCanvasPrivate::dtkVisualizationCanvasPrivate(QWidget *parent) :
this->setEnableHiDPI(true);
this->hud = new dtkWidgetsHUD(parent);
this->overlay = new dtkWidgetsOverlayPane(parent);
this->overlay->setBound(300);
this->overlay->setBound(600);
this->overlay->toggle();
connect(this->overlay, &dtkWidgetsOverlayPane::entered, [=] () {
......
......@@ -72,11 +72,17 @@ void dtkVisualizationDecorator::drawAndForward(void)
void dtkVisualizationDecorator::setData(const QVariant& v)
{
d->data = v;
if(d->next)
d->next->setData(v);
}
void dtkVisualizationDecorator::setCanvas(dtkVisualizationCanvas *c)
{
d->canvas = c;
if(d->next)
d->next->setCanvas(c);
}
void dtkVisualizationDecorator::unsetCanvas(void)
......@@ -94,19 +100,16 @@ dtkVisualizationCanvas *dtkVisualizationDecorator::canvas(void) const
return d->canvas;
}
dtkVisualizationDecorator *dtkVisualizationDecorator::operator << (dtkVisualizationDecorator *next)
dtkVisualizationDecorator &dtkVisualizationDecorator::operator << (dtkVisualizationDecorator &next)
{
if (!next) {
dtkWarn() << Q_FUNC_INFO << "Next decorator is null. Nothing is done.";
} else {
if (d->next) {
d->next->d->previous = next;
}
d->next = next;
d->next->d->previous = this;
if (d->next) {
d->next->d->previous = &next;
next.d->next = d->next;
}
return this;
d->next = &next;
d->next->d->previous = this;
return *this;
}
dtkVisualizationDecorator *dtkVisualizationDecorator::previous(void) const
......
......@@ -51,7 +51,7 @@ public:
QVariant data(void) const;
dtkVisualizationCanvas *canvas(void) const;
dtkVisualizationDecorator *operator << (dtkVisualizationDecorator *);
dtkVisualizationDecorator &operator << (dtkVisualizationDecorator &);
dtkVisualizationDecorator *previous(void) const;
dtkVisualizationDecorator *next(void) const;
......
#include "dtkVisualizationDecoratorClutEditor.h"
This diff is collapsed.
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <dtkVisualizationExport.h>
#include <QtCore>
#include "dtkVisualizationDecorator.h"
#include <vtkColorTransferFunction.h>
#include <vtkPiecewiseFunction.h>
#include <vtkSmartPointer.h>
class DTKVISUALIZATION_EXPORT dtkVisualizationDecoratorClutEditor : public dtkVisualizationDecorator
{
Q_OBJECT
public:
dtkVisualizationDecoratorClutEditor(void);
~dtkVisualizationDecoratorClutEditor(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);
signals:
void currentFieldNameChanged(const QString&);
void currentColorTransferFunctionChanged(vtkColorTransferFunction *);
void currentOpacityFunctionChanged(vtkPiecewiseFunction *);
void currentRangeChanged(double, double);
protected:
void draw(void) override;
protected:
class dtkVisualizationDecoratorClutEditorPrivate *d;
};
//
// dtkVisualizationDecoratorClutEditor.h ends here
......@@ -41,26 +41,8 @@ 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);
signals:
void currentFieldNameChanged(const QString&);
void currentColorTransferFunctionChanged(vtkColorTransferFunction *);
void currentOpacityFunctionChanged(vtkPiecewiseFunction *);
void currentRangeChanged(double, double);
protected:
bool setCurrentFieldName(const QString&);
void draw(void) override;
protected:
......
......@@ -45,29 +45,15 @@ public:
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:
bool setCurrentFieldName(const QString&);
void draw(void) override;
protected:
......
......@@ -45,29 +45,15 @@ public:
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 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:
bool setCurrentFieldName(const QString&);
void draw(void) override;
protected:
......
......@@ -90,12 +90,12 @@ qreal dtkVisualizationWidgetsClutEditorInterpolatorHSV::computeHue(double x, dou
QColor dtkVisualizationWidgetsClutEditorInterpolatorHSV::interpolate(dtkVisualizationWidgetsClutEditorVertex *vertex) const
{
if(!this->start) {
qDebug() << "No start value set for interpolation";
qWarning() << "No start value set for interpolation";
return vertex->color();
}
if(!this->stop) {
qDebug() << "No stop value set for interpolation";
qWarning() << "No stop value set for interpolation";
return vertex->color();
}
......@@ -126,12 +126,12 @@ public:
QColor dtkVisualizationWidgetsClutEditorInterpolatorRGB::interpolate(dtkVisualizationWidgetsClutEditorVertex *vertex) const
{
if(!this->start) {
qDebug() << Q_FUNC_INFO << "No start value set for interpolation";
qWarning() << Q_FUNC_INFO << "No start value set for interpolation";
return vertex->color();
}
if(!this->stop) {
qDebug() << Q_FUNC_INFO << "No stop value set for interpolation";
qWarning() << Q_FUNC_INFO << "No stop value set for interpolation";
return vertex->color();
}
......@@ -189,7 +189,7 @@ void dtkVisualizationWidgetsClutEditorHistogram::setup(const dtkVisualizationWid
for(int i = 0; i < histogram.count(); ++i) {
if (histogram.at(i) < 0) {
qDebug() << Q_FUNC_INFO << "bad value at:" << i;
qWarning() << Q_FUNC_INFO << "bad value at:" << i;
this->normalizedHistogram.append(0.0);
}
else {
......@@ -199,7 +199,7 @@ void dtkVisualizationWidgetsClutEditorHistogram::setup(const dtkVisualizationWid
}
if (max < epsilon) {
qDebug() << Q_FUNC_INFO << "histogram is null" ;
qWarning() << Q_FUNC_INFO << "histogram is null" ;
return;
}
......@@ -838,7 +838,7 @@ dtkVisualizationWidgetsClutEditor::dtkVisualizationWidgetsClutEditor(QWidget *pa
connect(d->button_color, SIGNAL(clicked()), this, SLOT(onColorChoose()));
connect(d->button_import, SIGNAL(clicked()), this, SLOT(importClut()));
connect(d->button_export, SIGNAL(clicked()), this, SLOT(exportClut()));
connect(d->button_apply, SIGNAL(clicked()), this, SLOT(onApply()));
//connect(d->button_apply, SIGNAL(clicked()), this, SLOT(onApply()));
connect(d->button_apply, SIGNAL(toggled(bool)), this, SLOT(onApply()));
connect(d->button_log, SIGNAL(toggled(bool)), this, SLOT(onApply()));
connect(d->button_presets, SIGNAL(currentTextChanged(const QString&)), this, SLOT(importClut(const QString&)));
......@@ -901,6 +901,9 @@ void dtkVisualizationWidgetsClutEditor::importClut(const QString& clut)
d->table->update();
d->button_log->setChecked(log);
if(d->button_apply->isChecked())
this->onApply();
}
......@@ -1009,8 +1012,6 @@ void dtkVisualizationWidgetsClutEditor::importClut(void)
delete vertex;
}
d->table->update();
QDomElement root = doc.documentElement();
double min = root.attribute("min").toDouble();
double max = root.attribute("max").toDouble();
......@@ -1181,21 +1182,21 @@ void dtkVisualizationWidgetsClutEditor::onColorAuto(void)
QList<QGraphicsItem *> selection = d->scene->selectedItems();
if(selection.count() != 1) {
qDebug() << Q_FUNC_INFO << "Choose only one vertex for automatic color determination";
qWarning() << Q_FUNC_INFO << "Choose only one vertex for automatic color determination";
return;
}
dtkVisualizationWidgetsClutEditorVertex *vertex = dynamic_cast<dtkVisualizationWidgetsClutEditorVertex *>(selection.first());
if(!vertex) {
qDebug() << Q_FUNC_INFO << "Choose only one vertex for automatic color determination";
qWarning() << Q_FUNC_INFO << "Choose only one vertex for automatic color determination";
return;
}
QList<dtkVisualizationWidgetsClutEditorVertex *> vertices = d->table->vertices;
if(vertices.indexOf(vertex) == 0 || vertices.indexOf(vertex) == vertices.count()-1) {
qDebug() << Q_FUNC_INFO << "Selected vertex must be surrounded by two other vertices";
qWarning() << Q_FUNC_INFO << "Selected vertex must be surrounded by two other vertices";
return;
}
......
......@@ -27,6 +27,7 @@
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsClutEditorVertex : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
public:
dtkVisualizationWidgetsClutEditorVertex(int x, int y, QColor color = Qt::yellow, QGraphicsItem *parent = 0);
......
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