28 #include <QVTKOpenGLWidget.h>
31 #include <vtkAssemblyPath.h>
32 #include <vtkCellPicker.h>
33 #include <vtkCommand.h>
34 #include <vtkGlyph3D.h>
35 #include <vtkInteractorStyleSwitch.h>
37 #include <vtkLightCollection.h>
38 #include <vtkParametricFunctionSource.h>.h>
39 #include <vtkArcSource.h>
40 #include <vtkLineWidget.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkPoints.h>
44 #include <vtkPointWidget.h>
45 #include <vtkPolyData.h>
46 #include <vtkPolyDataMapper.h>
47 #include <vtkProperty.h>
48 #include <vtkRenderer.h>
49 #include <vtkRendererCollection.h>
50 #include <vtkRenderWindow.h>
51 #include <vtkSmartPointer.h>
52 #include <vtkTransform.h>
61 virtual void Execute(vtkObject *caller,
unsigned long event,
void *) {
64 if(event == vtkCommand::InteractionEvent) {
82 double normMCH = (u.
x()*MCp.
x() + u.
y()*MCp.
y() + u.
z()*MCp.
z());
101 if(event == vtkCommand::MouseMoveEvent) {
104 vtkAssemblyPath *path;
105 vtkRenderWindow *renderWindow = interactor->GetRenderWindow();
106 vtkRendererCollection * rendererCollection = renderWindow->GetRenderers();
107 vtkRenderer *render = rendererCollection->GetFirstRenderer();
113 if (!render || !render->IsInViewport(X, Y)) {
123 for(
int j=0;j<3;j++) {
145 class axlActorCircleArcPrivate {
148 vtkArcSource *arcSource;
150 QVTKOpenGLWidget *widget;
151 vtkCellPicker *axlArcPicker;
153 vtkPointWidget *centerPointWidget;
154 vtkLineWidget *segmentWidget;
175 this->
setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
176 this->
setActor(vtkSmartPointer<vtkActor>::New());
178 d->arcSource = vtkArcSource::New();
180 d->arcSource->SetResolution(20);
183 this->
getMapper()->SetInput(d->arcSource->GetOutput());
188 if(!d->arcObserver) {
189 d->axlArcPicker = vtkCellPicker::New();
191 this->
getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->arcObserver);
192 this->
getInteractor()->AddObserver(vtkCommand::MouseMoveEvent, d->arcObserver);
194 d->arcObserver->observerDataAssembly =
this;
195 d->arcObserver->axlArcPicker = d->axlArcPicker;
196 d->arcObserver->observerData_arcSource = d->arcSource;
197 d->arcObserver->observerData_arc = d->arc;
201 QColor color = d->arc->color();
202 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
204 QString shader = d->arc->shader();
205 if(!shader.isEmpty())
211 qDebug()<<
"no axlCircleArc available";
217 if (display && d->centerPointWidget) {
221 if (!display && d->centerPointWidget) {
227 if (!d->centerPointWidget) {
228 qDebug() <<
"No actor computed for this axlActorCircleArc.";
233 d->centerPointWidget->SetEnabled(1);
234 d->segmentWidget->SetEnabled(1);
238 d->centerPointWidget->SetEnabled(0);
239 d->segmentWidget->SetEnabled(0);
245 if (!d->centerPointWidget || !d->segmentWidget) {
247 d->centerPointWidget = vtkPointWidget::New();
249 d->centerPointWidget->SetProp3D(this->
getActor());
250 d->centerPointWidget->PlaceWidget();
251 d->centerPointWidget->AllOff();
252 d->centerPointWidget->SetTranslationMode(1);
254 d->centerPointWidget->SetPosition(d->arc->center()->coordinates());
257 d->segmentWidget = vtkLineWidget::New();
259 d->segmentWidget->SetProp3D(this->
getActor());
260 d->segmentWidget->PlaceWidget();
262 d->segmentWidget->SetPoint1(d->arc->point1()->coordinates());
263 d->segmentWidget->SetPoint2(d->arc->point2()->coordinates());
267 d->centerPointWidget->AddObserver(vtkCommand::InteractionEvent, d->arcObserver);
268 d->segmentWidget->AddObserver(vtkCommand::InteractionEvent, d->arcObserver);
270 d->arcObserver->centerPointWidget = d->centerPointWidget;
271 d->arcObserver->segmentWidget = d->segmentWidget;
275 d->centerPointWidget->SetEnabled(
true);
276 d->segmentWidget->SetEnabled(
true);
281 if(d->centerPointWidget) {
282 d->centerPointWidget->RemoveAllObservers();
283 d->centerPointWidget->SetEnabled(
false);
284 d->centerPointWidget->Delete();
285 d->centerPointWidget = NULL;
288 if(d->segmentWidget) {
289 d->segmentWidget->RemoveAllObservers();
290 d->segmentWidget->SetEnabled(
false);
291 d->segmentWidget->Delete();
292 d->segmentWidget = NULL;
299 if(!d->centerPointWidget || !d->segmentWidget) {
300 qDebug() <<
"No actor computed for this axlActorBSpline.";
304 return d->centerPointWidget->GetEnabled() && d->segmentWidget->GetEnabled();
319 QColor color =
data->color();
320 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
324 }
else if(state == 1) {
329 vtkProperty *prop = this->
getActor()->GetProperty();
332 QColor color =
data->color();
333 qreal *h =
new qreal(0.0);
334 qreal *s =
new qreal(0.0);
335 qreal *l =
new qreal(0.0);
336 color.getHslF(h, s, l);
337 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
338 prop->SetColor(color.redF(), color.greenF(), color.blueF());
344 }
else if(state == 2) {
348 vtkProperty *prop = this->
getActor()->GetProperty();
350 QColor color =
data->color();
351 qreal *h =
new qreal(0.0);
352 qreal *s =
new qreal(0.0);
353 qreal *l =
new qreal(0.0);
354 color.getHslF(h, s, l);
355 color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
356 prop->SetColor(color.redF(), color.greenF(), color.blueF());
370 this->
getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->arcObserver);
371 this->
getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, d->arcObserver);
372 d->arcObserver->observerDataAssembly = NULL;
373 d->arcObserver->axlArcPicker = NULL;
374 d->arcObserver->observerData_arcSource = NULL;
375 d->arcObserver->observerData_arc = NULL;
376 d->arcObserver->axlInteractorStyle = NULL;
377 d->arcObserver->Delete();
378 d->arcObserver = NULL;
380 d->axlArcPicker->Delete();
381 d->axlArcPicker = NULL;
385 d->arcSource->Delete();
395 d->arcSource->Delete();
398 if(d->centerPointWidget && d->segmentWidget) {
400 d->centerPointWidget = NULL;
401 d->segmentWidget = NULL;
405 this->RemoveAllObservers();
407 this->
getActor()->RemoveAllObservers();
410 actorComposite->removeActorReference(
this);
423 if (d->centerPointWidget)
424 d->centerPointWidget->SetPosition(C.
coordinates());
426 if (d->segmentWidget) {
434 d->axlArcPicker = NULL;
435 d->arcObserver = NULL;
438 d->centerPointWidget = NULL;
439 d->segmentWidget = NULL;
vtkCxxRevisionMacro(axlActorCircleArc,"$Revision: 0.0.1 $")
Class axlPoint defines 3D points.
vtkLineWidget * segmentWidget
void setCircleArc(axlCircleArc *arc)
vtkArcSource * observerData_arcSource
virtual void setDisplay(bool display)
double * coordinates(void) const
Returns coordinates of this point.
axlPoint point1(void) const
void stateChanged(dtkAbstractData *data, int mode)
void modifyCenter(double *center)
void modifyPoint2(double *point2)
virtual void setState(int state)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
axlPoint center(void) const
axlCircleArc * observerData_arc
vtkPointWidget * centerPointWidget
void modifyNormal(double *normal)
bool isShowCircleArcWidget(void)
void showCircleArcWidget(bool show)
void onModeChanged(int state)
static axlActorCircleArcObserver * New(void)
void modifyPoint1(double *point1)
virtual void setShader(QString vsfile)
axlPoint point2(void) const
virtual axlAbstractActor * parent(void)
virtual void setOpacity(double opacity)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
dtkAbstractData * data(void)
axlInteractorStyleSwitch * axlInteractorStyle
void setQVTKWidget(QVTKOpenGLWidget *widget)
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
axlActorCircleArc * observerDataAssembly
vtkStandardNewMacro(axlActorCircleArc)
void setCircleArcWidget(bool arcWidget)
vtkCellPicker * axlArcPicker
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point.
virtual vtkRenderWindowInteractor * getInteractor(void)
Class axlAbstractData defines an API for all type of axel data.
void setDisplay(bool display)