Commit 73d0cc98 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

add axes and cube_axes actor

parent 0e9e1f21
......@@ -113,37 +113,39 @@ dtkVisualizationDecoratorVolume::dtkVisualizationDecoratorVolume(void): dtkVisua
d->volume->SetMapper(d->mapper);
d->volume->SetProperty(d->volume_property);
d->cube_axes_actor = vtkSmartPointer<vtkCubeAxesActor>::New();
d->cube_axes_actor->GetTitleTextProperty(0)->SetColor(0.8, 0.0, 0.0);
d->cube_axes_actor->GetLabelTextProperty(0)->SetColor(0.8, 0.0, 0.0);
d->cube_axes_actor->GetXAxesLinesProperty()->SetColor(0.2, 0.2, 0.2);
d->cube_axes_actor->GetTitleTextProperty(1)->SetColor(0.0, 0.5, 0.0);
d->cube_axes_actor->GetLabelTextProperty(1)->SetColor(0.0, 0.5, 0.0);
d->cube_axes_actor->GetYAxesLinesProperty()->SetColor(0.2, 0.2, 0.2);
d->cube_axes_actor->GetTitleTextProperty(2)->SetColor(0.0, 0.5, 1.0);
d->cube_axes_actor->GetLabelTextProperty(2)->SetColor(0.0, 0.5, 1.0);
d->cube_axes_actor->GetZAxesLinesProperty()->SetColor(0.2, 0.2, 0.2);
d->cube_axes_actor->XAxisMinorTickVisibilityOff();
d->cube_axes_actor->YAxisMinorTickVisibilityOff();
d->cube_axes_actor->ZAxisMinorTickVisibilityOff();
d->actor = vtkSmartPointer<vtkAssembly>::New();
d->actor->AddPart(d->volume);
d->actor->AddPart(d->outline_contour_actor);
d->actor->AddPart(d->cube_axes_actor);
d->axes = vtkAxesActor::New();
d->axes->SetConeRadius(0.3);
d->axes->SetCylinderRadius(0.005);
d->axes->SetAxisLabels(true);
// d->cube_axes_actor = vtkSmartPointer<vtkCubeAxesActor>::New();
// d->cube_axes_actor->GetTitleTextProperty(0)->SetColor(0.8, 0.0, 0.0);
// d->cube_axes_actor->GetLabelTextProperty(0)->SetColor(0.8, 0.0, 0.0);
// d->cube_axes_actor->GetXAxesLinesProperty()->SetColor(0.2, 0.2, 0.2);
// d->cube_axes_actor->GetTitleTextProperty(1)->SetColor(0.0, 0.5, 0.0);
// d->cube_axes_actor->GetLabelTextProperty(1)->SetColor(0.0, 0.5, 0.0);
// d->cube_axes_actor->GetYAxesLinesProperty()->SetColor(0.2, 0.2, 0.2);
// d->cube_axes_actor->GetTitleTextProperty(2)->SetColor(0.0, 0.5, 1.0);
// d->cube_axes_actor->GetLabelTextProperty(2)->SetColor(0.0, 0.5, 1.0);
// d->cube_axes_actor->GetZAxesLinesProperty()->SetColor(0.2, 0.2, 0.2);
// d->cube_axes_actor->XAxisMinorTickVisibilityOff();
// d->cube_axes_actor->YAxisMinorTickVisibilityOff();
// d->cube_axes_actor->ZAxisMinorTickVisibilityOff();
// d->axes = vtkAxesActor::New();
// d->axes->SetConeRadius(0.3);
// d->axes->SetCylinderRadius(0.005);
// d->axes->SetAxisLabels(true);
// d->marker = vtkOrientationMarkerWidget::New();
// d->marker->SetOutlineColor(0.9300, 0.5700, 0.1300);
// d->marker->SetOrientationMarker(d->axes);
// d->marker->SetInteractor(d_func()->view->renderer()->GetRenderWindow()->GetInteractor());
// d->marker->SetViewport(0.0, 0.0, 0.25, 0.25);
// d->marker->SetEnabled(1);
d->show_actor_cb = new QCheckBox;
d->marker = vtkOrientationMarkerWidget::New();
d->marker->SetOutlineColor(0.9300, 0.5700, 0.1300);
d->marker->SetOrientationMarker(d->axes);
d->marker->SetViewport(0.0, 0.0, 0.25, 0.25);
d->show_actor_cb = new QCheckBox;
d->show_axes_cb = new QCheckBox;
d->show_cube_axes_cb = new QCheckBox;
//////////
// Inspectors connections
......@@ -154,10 +156,24 @@ dtkVisualizationDecoratorVolume::dtkVisualizationDecoratorVolume(void): dtkVisua
this->draw();
});
connect(d->show_axes_cb, &QCheckBox::stateChanged, [=] (int state) {
this->saveSettings("show_axes", state == Qt::Checked);
d->marker->SetEnabled(state == Qt::Checked);
this->draw();
});
connect(d->show_cube_axes_cb, &QCheckBox::stateChanged, [=] (int state) {
this->saveSettings("show_cube_axes", state == Qt::Checked);
d->cube_axes_actor->SetVisibility(state == Qt::Checked);
this->draw();
});
this->setObjectName("Volume");
d->show_actor_cb->setObjectName("Display");
d->show_axes_cb->setObjectName("Display Orientation");
d->show_cube_axes_cb->setObjectName("Display Cube Axes");
d_func()->inspectors << d->show_actor_cb;
d_func()->inspectors << d->show_actor_cb << d->show_axes_cb << d->show_cube_axes_cb;
}
dtkVisualizationDecoratorVolume::~dtkVisualizationDecoratorVolume(void)
......@@ -188,13 +204,15 @@ void dtkVisualizationDecoratorVolume::setData(const QVariant& data)
d_func()->dataset = dataset;
this->restoreSettings();
d->c2p_filter->SetInputData(d_func()->dataset);
d->mapper->SetInputData(d_func()->dataset);
d->outline_contour->SetInputData(d_func()->dataset);
d->c2p_filter->SetInputData(dataset);
d->mapper->SetInputData(dataset);
d->outline_contour->SetInputData(dataset);
d->cube_axes_actor->SetBounds(dataset->GetBounds());
d_func()->sortEligibleFields();
if (this->canvas()) {
d->marker->SetEnabled(d->show_axes_cb->checkState() == Qt::Checked);
this->canvas()->renderer()->AddActor(d->actor);
}
......@@ -213,9 +231,14 @@ void dtkVisualizationDecoratorVolume::setCanvas(dtkVisualizationCanvas *canvas)
qWarning() << Q_FUNC_INFO << "View 2D or view 3D expected as canvas. Canvas is reset to nullptr.";
return;
}
d->marker->SetInteractor(d_func()->view->renderer()->GetRenderWindow()->GetInteractor());
if (d->mapper->GetInput()) {
d_func()->view->renderer()->AddActor(d->actor);
d->marker->SetEnabled(d->show_axes_cb->checkState() == Qt::Checked);
}
d->cube_axes_actor->SetCamera(d_func()->view->renderer()->GetActiveCamera());
d_func()->enableScalarBar();
}
......@@ -239,12 +262,31 @@ void dtkVisualizationDecoratorVolume::setVisibility(bool visible)
void dtkVisualizationDecoratorVolume::restoreSettings(void)
{
QString name = this->objectName();
if (name.isEmpty())
return;
dtkVisualizationDecoratorWithClut::restoreSettings();
QSettings settings;
settings.beginGroup("canvas");
bool show_axes = settings.value(name+"_show_axes", true).toBool();
bool show_cube_axes = settings.value(name+"_show_cube_axes", true).toBool();
settings.endGroup();
d->actor->SetVisibility(d_func()->default_visibility);
d->show_actor_cb->blockSignals(true);
d->show_actor_cb->setChecked(d_func()->default_visibility);
d->show_actor_cb->blockSignals(false);
d->show_axes_cb->blockSignals(true);
d->show_axes_cb->setChecked(show_axes);
d->show_axes_cb->blockSignals(false);
d->cube_axes_actor->SetVisibility(show_cube_axes);
d->show_cube_axes_cb->blockSignals(true);
d->show_cube_axes_cb->setChecked(show_cube_axes);
d->show_cube_axes_cb->blockSignals(false);
}
......@@ -275,7 +317,6 @@ void dtkVisualizationDecoratorVolume::setColorMap(const QMap<double, QColor>& ne
double min = range[0];
double max = range[1];
double mid = (min + max) / 2.0;
qDebug() << min << max << mid ;
d->volume_property->SetColor(d_func()->color_function);
......
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