Commit 5583a91f authored by LACROIX Romain's avatar LACROIX Romain

Bugfix: changes in the widget controls would move the seed, but would not...

Bugfix: changes in the widget controls would move the seed, but would not update the streams. This is now fixed.
parent b676601c
......@@ -59,6 +59,15 @@ public:
source_sphere->GetPolyData(source_data);
stream_tracer->SetSourceData(source_data);
stream_tracer->Modified();
vtkSphereWidget2 *source_sphere_widget = reinterpret_cast<vtkSphereWidget2*>(caller);
vtkSphereRepresentation *sphere_representation = vtkSphereRepresentation::SafeDownCast(source_sphere_widget->GetRepresentation());
radius->setValue(sphere_representation->GetRadius());
double pos[3];
sphere_representation->GetCenter(pos);
pos_x->setValue(pos[0]);
pos_y->setValue(pos[1]);
pos_z->setValue(pos[2]);
}
};
......@@ -66,6 +75,10 @@ public:
vtkSmartPointer<vtkPolyData> source_data;
vtkSmartPointer<vtkSphereRepresentation> source_sphere;
vtkSmartPointer<vtkStreamTracer> stream_tracer;
dtkVisualizationWidgetsScalarControl *pos_x = nullptr;
dtkVisualizationWidgetsScalarControl *pos_y = nullptr;
dtkVisualizationWidgetsScalarControl *pos_z = nullptr;
dtkVisualizationWidgetsScalarControl *radius = nullptr;
};
class dtkVisualizationDecoratorStreamTracerLineObserver : public vtkCommand
......@@ -261,6 +274,10 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
seed_pos1_z->setObjectName("Position Z");
dtkVisualizationWidgetsScalarControl *seed_radius = new dtkVisualizationWidgetsScalarPositiveControl(1);
seed_radius->setObjectName("Radius");
d->source_sphere_observer->pos_x = seed_pos1_x;
d->source_sphere_observer->pos_y = seed_pos1_y;
d->source_sphere_observer->pos_z = seed_pos1_z;
d->source_sphere_observer->radius = seed_radius;
//////////
// Inspectors connections
......@@ -342,6 +359,7 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
seed_widget == seed_pos1_y ? 1 :
seed_widget == seed_pos1_z ? 2 :
3;
connect(seed_widget, QOverload<double>::of(&dtkVisualizationWidgetsScalarControl::valueChanged), [=] (double val)
{
if (axis == 3) // radius
......@@ -353,6 +371,14 @@ dtkVisualizationDecoratorVectorStreamTracer::dtkVisualizationDecoratorVectorStre
pos[axis] = val;
d->source_sphere->SetCenter(pos);
}
vtkSmartPointer<vtkPolyData> data = vtkSmartPointer<vtkPolyData>::New();
d->source_sphere->GetPolyData(data);
d->streamtracer->SetSourceData(data);
d->streamtracer->Modified();
this->draw();
});
}
......
......@@ -48,6 +48,12 @@ dtkVisualizationWidgetsScalarControl::dtkVisualizationWidgetsScalarControl(doubl
});
}
void dtkVisualizationWidgetsScalarControl::setValue(double value)
{
spbox->setValue(value);
}
dtkVisualizationWidgetsScalarPositiveControl::dtkVisualizationWidgetsScalarPositiveControl(double reset, QWidget *parent) : dtkVisualizationWidgetsScalarControl(reset, parent)
{
spbox->setMinimum(0);
......
......@@ -20,12 +20,12 @@ class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsScalarControl : publ
public:
dtkVisualizationWidgetsScalarControl(double reset = 0, QWidget *parent = nullptr);
void setValue(double value);
signals:
void valueChanged(double);
protected:
// TODO move in private d-pointer (and remove forward declarations above)
// TODO show pos+radius or pos1+pos2 depending on sphere/line
// TODO plug other direction : with observers
QDoubleSpinBox *spbox = nullptr;
QPushButton *breset = nullptr;
double reset_value = 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