Commit 71753a63 authored by WINTZ Julien's avatar WINTZ Julien

Updating volume decorator.

parent 0e9e1f21
......@@ -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);
......@@ -112,6 +113,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->actor = vtkSmartPointer<vtkAssembly>::New();
d->actor->AddPart(d->volume);
......@@ -290,5 +292,30 @@ void dtkVisualizationDecoratorVolume::setColorMap(const QMap<double, QColor>& ne
d->volume->Update();
}
void dtkVisualizationDecoratorVolume::setAlphaMap(const QMap<double, double>& map)
{
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);
}
//
// dtkVisualizationDecoratorVolume.cpp ends here
......@@ -33,12 +33,18 @@ public:
protected:
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