Commit eaec2a03 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

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

parents 73d0cc98 aa1f3ac3
......@@ -13,11 +13,8 @@
// Code:
#include "dtkVisualizationDecoratorScalarColorMap.h"
#include "dtkVisualizationDecoratorWithClut_p.h"
#include "dtkVisualizationMetaType.h"
#include "dtkVisualizationView2D.h"
#include <dtkLog>
......
......@@ -13,11 +13,8 @@
// Code:
#include "dtkVisualizationDecoratorVolume.h"
#include "dtkVisualizationDecoratorWithClut_p.h"
#include "dtkVisualizationMetaType.h"
#include "dtkVisualizationView2D.h"
#include <dtkLog>
......@@ -47,6 +44,7 @@
#include <vtkSmartPointer.h>
#include <vtkSmartVolumeMapper.h>
#include <vtkTextProperty.h>
#include <vtkTransform.h>
#include <vtkTransformFilter.h>
#include <vtkTransformPolyDataFilter.h>
#include <vtkVolumeProperty.h>
......@@ -70,6 +68,7 @@ public:
vtkSmartPointer<vtkAxesActor> axes;
vtkSmartPointer<vtkOrientationMarkerWidget> marker;
vtkSmartPointer<vtkCellDataToPointData> c2p_filter;
vtkSmartPointer<vtkTransform> transform;
public:
QCheckBox *show_actor_cb = nullptr;
......@@ -86,6 +85,8 @@ public slots:
dtkVisualizationDecoratorVolume::dtkVisualizationDecoratorVolume(void): dtkVisualizationDecoratorWithClut(), d(new dtkVisualizationDecoratorVolumePrivate())
{
d->transform = vtkSmartPointer<vtkTransform>::New();
d->c2p_filter = vtkSmartPointer<vtkCellDataToPointData>::New();
d->mapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
d->mapper->SetRequestedRenderMode(vtkSmartVolumeMapper::DefaultRenderMode);
......@@ -100,6 +101,7 @@ dtkVisualizationDecoratorVolume::dtkVisualizationDecoratorVolume(void): dtkVisua
d->outline_contour_actor->SetMapper(d->outline_contour_mapper);
d->outline_contour_actor->GetProperty()->SetColor(1, 0, 0);
d->outline_contour_actor->SetVisibility(1);
d->outline_contour_actor->SetUserTransform(d->transform);
d->volume_property = vtkSmartPointer<vtkVolumeProperty>::New();
d->volume_property->SetInterpolationTypeToLinear();
......@@ -112,6 +114,7 @@ dtkVisualizationDecoratorVolume::dtkVisualizationDecoratorVolume(void): dtkVisua
d->volume = vtkSmartPointer<vtkVolume>::New();
d->volume->SetMapper(d->mapper);
d->volume->SetProperty(d->volume_property);
d->volume->SetUserTransform(d->transform);
d->cube_axes_actor = vtkSmartPointer<vtkCubeAxesActor>::New();
......@@ -239,6 +242,7 @@ void dtkVisualizationDecoratorVolume::setCanvas(dtkVisualizationCanvas *canvas)
d->marker->SetEnabled(d->show_axes_cb->checkState() == Qt::Checked);
}
d->cube_axes_actor->SetCamera(d_func()->view->renderer()->GetActiveCamera());
d->cube_axes_actor->SetBounds(d_func()->view->renderer()->ComputeVisiblePropBounds());
d_func()->enableScalarBar();
}
......@@ -287,6 +291,8 @@ void dtkVisualizationDecoratorVolume::restoreSettings(void)
d->show_cube_axes_cb->blockSignals(true);
d->show_cube_axes_cb->setChecked(show_cube_axes);
d->show_cube_axes_cb->blockSignals(false);
this->scale(1,1,3);
}
......@@ -318,6 +324,8 @@ void dtkVisualizationDecoratorVolume::setColorMap(const QMap<double, QColor>& ne
double max = range[1];
double mid = (min + max) / 2.0;
qDebug() << Q_FUNC_INFO;
d->volume_property->SetColor(d_func()->color_function);
d->opacity_transfer_function->RemoveAllPoints();
......@@ -328,7 +336,34 @@ void dtkVisualizationDecoratorVolume::setColorMap(const QMap<double, QColor>& ne
d->volume_property->Modified();
d->mapper->Modified();
d->volume->Update();
// d->volume->Update();
}
void dtkVisualizationDecoratorVolume::setAlphaMap(const QMap<double, double>& map)
{
qDebug() << Q_FUNC_INFO;
d->opacity_transfer_function->RemoveAllPoints();
foreach(double value, map.keys()) {
d->opacity_transfer_function->AddPoint(value, map[value]);
d->opacity_transfer_function->AddPoint(value, map[value]);
d->opacity_transfer_function->AddPoint(value, map[value]);
}
d->opacity_transfer_function->Modified();
d->volume_property->Modified();
d->mapper->Modified();
// d->volume->Update();
}
// /////////////////////////////////////////////////////////////////////////////
// TODO: Factorise upwards
// /////////////////////////////////////////////////////////////////////////////
void dtkVisualizationDecoratorVolume::scale(qreal x, qreal y, qreal z)
{
d->transform->Scale(x, y, z);
}
//
......
......@@ -31,14 +31,20 @@ public:
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
protected:
public:
bool setCurrentFieldName(const QString&) override;
public:
void setColorMap(const QMap<double, QColor>&) override;
void setAlphaMap(const QMap<double, double>&);
public:
void setVisibility(bool) override;
void restoreSettings(void) override;
public:
void scale(qreal x, qreal y, qreal z);
protected:
class dtkVisualizationDecoratorVolumePrivate *d = nullptr;
};
......
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