Commit efff1344 authored by LE BRETON Come's avatar LE BRETON Come

Merge branch 'release/2.6.2'

parents 1ef67f35 596b1b26
# Change Log:
# 2.6.2 09-Feb-2019
- better internal handling of ViewHybrid
- provides API to hide 2D and 3D buttons
# 2.6.1 07-Feb-2019
- fix bottom left and right widget insertion in ViewHybrid
......
......@@ -24,7 +24,7 @@ project(dtkVisualization)
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 6)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION_PATCH 2)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -179,26 +179,6 @@ dtkVisualizationViewHybridPrivate::dtkVisualizationViewHybridPrivate(QWidget *pa
this->sync = new dtkVisualizationViewOverlay(fa::unlock, "", this);
this->sync->toggle(false);
vtkImageData *dummy = vtkImageData::New();
dummy->SetDimensions(1, 1, 1);
dummy->SetSpacing(1, 1, 1);
dummy->AllocateScalars(VTK_UNSIGNED_CHAR,4);
for (int i = 0; i < 3; i++) {
double color[3] = { 0, 0, 0 }; color[i] = 1;
planeWidget[i] = vtkSmartPointer<vtkImagePlaneWidget>::New();
planeWidget[i]->SetInteractor(this->GetInteractor());
planeWidget[i]->SetInputData(dummy);
planeWidget[i]->SetPlaneOrientation(i);
planeWidget[i]->RestrictPlaneToVolumeOn();
planeWidget[i]->GetPlaneProperty()->SetColor(color);
planeWidget[i]->SetLeftButtonAction(vtkImagePlaneWidget::VTK_SLICE_MOTION_ACTION);
planeWidget[i]->SetMarginSizeX(0);
planeWidget[i]->SetMarginSizeY(0);
}
// ///////////////////////////////////////////////////////////////////
connect(this->sync, &dtkVisualizationViewOverlay::iconClicked, [=] () {
......@@ -318,10 +298,11 @@ void dtkVisualizationViewHybridPrivate::addImageActors(vtkImageData *image)
image->GetPointData()->GetScalars()->GetRange(bounds);
vtkColorTransferFunction *color_function = nullptr;
if(this->clut_editor) {
this->clut_editor->setRange(bounds[0], bounds[1]);
color_function = static_cast<vtkColorTransferFunction*>(this->clut_editor->colorTransferFunction());
if(!color_function)
color_function = vtkColorTransferFunction::New();
} else {
color_function = vtkColorTransferFunction::New();
}
......@@ -343,7 +324,7 @@ void dtkVisualizationViewHybridPrivate::addImageActors(vtkImageData *image)
this->c_z = this->z/2;
if(!this->image_color) this->image_color = vtkSmartPointer<vtkImageMapToColors>::New();
// this->image_color->SetLookupTable(color_function);
this->image_color->SetLookupTable(color_function);
this->image_color->SetOutputFormatToRGBA();
this->image_color->SetInputData(image);
this->image_color->Update();
......@@ -354,10 +335,22 @@ void dtkVisualizationViewHybridPrivate::addImageActors(vtkImageData *image)
int imageDims[3]; image->GetDimensions(imageDims);
for(int i = 0; i < 3; i++) {
if(!this->planeWidget[i])
this->planeWidget[i] = vtkSmartPointer<vtkImagePlaneWidget>::New();
double color[3] = { 0, 0, 0 }; color[i] = 1;
this->planeWidget[i]->SetInteractor(this->GetInteractor());
this->planeWidget[i]->SetInputData(image);
this->planeWidget[i]->SetPlaneOrientation(i);
this->planeWidget[i]->RestrictPlaneToVolumeOn();
this->planeWidget[i]->GetPlaneProperty()->SetColor(color);
this->planeWidget[i]->SetLeftButtonAction(vtkImagePlaneWidget::VTK_SLICE_MOTION_ACTION);
this->planeWidget[i]->SetMarginSizeX(0);
this->planeWidget[i]->SetMarginSizeY(0);
this->planeWidget[i]->SetSliceIndex(imageDims[i]/2);
this->planeWidget[i]->DisplayTextOn();
this->planeWidget[i]->InteractionOn();
}
if (this->renderer2D_XY->isToggled()) {
......@@ -412,7 +405,7 @@ void dtkVisualizationViewHybridPrivate::addImageActors(vtkImageData *image)
vtkSmartPointer<vtkVolumeProperty> property = vtkSmartPointer<vtkVolumeProperty>::New();
property->SetScalarOpacity(opacity);
// property->SetColor(color_function);
property->SetColor(color_function);
property->ShadeOff();
property->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
......@@ -425,8 +418,6 @@ void dtkVisualizationViewHybridPrivate::addImageActors(vtkImageData *image)
this->renderer2D->ResetCamera();
this->renderer3D->ResetCamera();
// this->actors->update();
this->update();
}
......@@ -443,7 +434,7 @@ dtkVisualizationViewHybrid::dtkVisualizationViewHybrid(QWidget *parent) : dtkWid
connect(d->renderer2D_YZ, SIGNAL(iconClicked()), this, SLOT(switchTo2DYZ()));
d->slice_slider = new QSlider(this);
d->slice_slider->setObjectName("prout");
d->slice_slider->setObjectName("Slider");
d->slice_slider->setOrientation(Qt::Vertical);
d->slice_slider->setMinimum(0);
d->slice_slider->setMaximum(1);
......@@ -778,8 +769,6 @@ void dtkVisualizationViewHybrid::unlink(dtkVisualizationViewHybrid *other)
void dtkVisualizationViewHybrid::update(void)
{
// d->actors->update();
bool enabled = d->GetInteractor()->GetEnabled();
if(!enabled)
......@@ -793,14 +782,9 @@ void dtkVisualizationViewHybrid::update(void)
void dtkVisualizationViewHybrid::switchTo3D(void)
{
if (d->renderer3D_button->isToggled()) return;
d->renderer2D_button->toggle(false);
d->renderer2D_button->setEnabled(true);
d->renderer3D_button->toggle(true);
d->renderer3D_button->setEnabled(false);
d->renderer2D_button->toggle(false);
d->renderer2D_XY->setVisible(false);
d->renderer2D_XZ->setVisible(false);
d->renderer2D_YZ->setVisible(false);
......@@ -817,13 +801,13 @@ void dtkVisualizationViewHybrid::switchTo3D(void)
d->slice_slider->setEnabled(false);
d->planeWidget[0]->Off();
d->planeWidget[1]->Off();
d->planeWidget[2]->Off();
if(d->planeWidget[0]) d->planeWidget[0]->Off();
if(d->planeWidget[1]) d->planeWidget[1]->Off();
if(d->planeWidget[2]) d->planeWidget[2]->Off();
d->planeWidget[0]->On();
d->planeWidget[1]->On();
d->planeWidget[2]->On();
if(d->planeWidget[0]) d->planeWidget[0]->On();
if(d->planeWidget[1]) d->planeWidget[1]->On();
if(d->planeWidget[2]) d->planeWidget[2]->On();
this->render();
......@@ -832,14 +816,9 @@ void dtkVisualizationViewHybrid::switchTo3D(void)
void dtkVisualizationViewHybrid::switchTo2D(void)
{
if (d->renderer2D_button->isToggled()) return;
d->renderer2D_button->toggle(true);
d->renderer2D_button->setEnabled(false);
d->renderer3D_button->toggle(false);
d->renderer3D_button->setEnabled(true);
d->renderer2D_button->toggle(true);
d->renderer2D_XY->setVisible(true);
d->renderer2D_XZ->setVisible(true);
d->renderer2D_YZ->setVisible(true);
......@@ -855,29 +834,29 @@ void dtkVisualizationViewHybrid::switchTo2D(void)
d->slice_slider->setEnabled(true);
d->planeWidget[0]->Off();
d->planeWidget[1]->Off();
d->planeWidget[2]->Off();
if(d->planeWidget[0]) d->planeWidget[0]->Off();
if(d->planeWidget[1]) d->planeWidget[1]->Off();
if(d->planeWidget[2]) d->planeWidget[2]->Off();
if (d->renderer2D_XY->isToggled()) {
if(d->viewer) d->viewer->SetSlice(d->c_z);
d->planeWidget[0]->On();
d->planeWidget[1]->On();
d->planeWidget[2]->Off();
if(d->planeWidget[0]) d->planeWidget[0]->On();
if(d->planeWidget[1]) d->planeWidget[1]->On();
if(d->planeWidget[2]) d->planeWidget[2]->Off();
}
if (d->renderer2D_XZ->isToggled()) {
if(d->viewer) d->viewer->SetSlice(d->c_y);
d->planeWidget[0]->On();
d->planeWidget[1]->Off();
d->planeWidget[2]->On();
if(d->planeWidget[0]) d->planeWidget[0]->On();
if(d->planeWidget[1]) d->planeWidget[1]->Off();
if(d->planeWidget[2]) d->planeWidget[2]->On();
}
if (d->renderer2D_YZ->isToggled()) {
if(d->viewer) d->viewer->SetSlice(d->c_x);
d->planeWidget[0]->Off();
d->planeWidget[1]->On();
d->planeWidget[2]->On();
if(d->planeWidget[0]) d->planeWidget[0]->Off();
if(d->planeWidget[1]) d->planeWidget[1]->On();
if(d->planeWidget[2]) d->planeWidget[2]->On();
}
this->render();
......@@ -897,9 +876,9 @@ void dtkVisualizationViewHybrid::switchTo2DXY(void)
if(d->viewer) d->viewer->SetSlice(d->c_z);
d->planeWidget[0]->On();
d->planeWidget[1]->On();
d->planeWidget[2]->Off();
if(d->planeWidget[0]) d->planeWidget[0]->On();
if(d->planeWidget[1]) d->planeWidget[1]->On();
if(d->planeWidget[2]) d->planeWidget[2]->Off();
d->slice_slider->blockSignals(true);
d->slice_slider->setMaximum(d->z);
......@@ -921,9 +900,9 @@ void dtkVisualizationViewHybrid::switchTo2DXZ(void)
if(d->viewer) d->viewer->SetSlice(d->c_y);
d->planeWidget[0]->On();
d->planeWidget[1]->Off();
d->planeWidget[2]->On();
if(d->planeWidget[0]) d->planeWidget[0]->On();
if(d->planeWidget[1]) d->planeWidget[1]->Off();
if(d->planeWidget[2]) d->planeWidget[2]->On();
d->slice_slider->blockSignals(true);
d->slice_slider->setMaximum(d->y);
......@@ -945,9 +924,9 @@ void dtkVisualizationViewHybrid::switchTo2DYZ(void)
if(d->viewer) d->viewer->SetSlice(d->c_x);
d->planeWidget[0]->Off();
d->planeWidget[1]->On();
d->planeWidget[2]->On();
if(d->planeWidget[0]) d->planeWidget[0]->Off();
if(d->planeWidget[1]) d->planeWidget[1]->On();
if(d->planeWidget[2]) d->planeWidget[2]->On();
d->slice_slider->blockSignals(true);
d->slice_slider->setMaximum(d->x);
......@@ -962,17 +941,17 @@ void dtkVisualizationViewHybrid::sliceChange(int value)
if (d->viewer) d->viewer->SetSlice(value);
if (d->renderer2D_XY->isToggled()) {
d->planeWidget[2]->SetSliceIndex(value);
if(d->planeWidget[2]) d->planeWidget[2]->SetSliceIndex(value);
d->c_z = value;
}
if (d->renderer2D_XZ->isToggled()) {
d->planeWidget[1]->SetSliceIndex(value);
if(d->planeWidget[1]) d->planeWidget[1]->SetSliceIndex(value);
d->c_y = value;
}
if (d->renderer2D_YZ->isToggled()) {
d->planeWidget[0]->SetSliceIndex(value);
if(d->planeWidget[0]) d->planeWidget[0]->SetSliceIndex(value);
d->c_x = value;
}
......@@ -1062,6 +1041,16 @@ dtkVisualizationViewOverlay *dtkVisualizationViewHybrid::renderer2DYZ(void)
return d->renderer2D_YZ;
}
dtkVisualizationViewOverlay *dtkVisualizationViewHybrid::renderer2DButton(void)
{
return d->renderer2D_button;
}
dtkVisualizationViewOverlay *dtkVisualizationViewHybrid::renderer3DButton(void)
{
return d->renderer3D_button;
}
// ///////////////////////////////////////////////////////////////////
#include "dtkVisualizationViewHybrid.moc"
......
......@@ -119,6 +119,8 @@ protected:
dtkVisualizationViewOverlay *renderer2DXY(void);
dtkVisualizationViewOverlay *renderer2DXZ(void);
dtkVisualizationViewOverlay *renderer2DYZ(void);
dtkVisualizationViewOverlay *renderer2DButton(void);
dtkVisualizationViewOverlay *renderer3DButton(void);
private:
class dtkVisualizationViewHybridPrivate *d;
......
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