34 #include <vtkAssemblyNode.h>
35 #include <vtkAssemblyPath.h>
36 #include <vtkCallbackCommand.h>
37 #include <vtkCamera.h>
38 #include <vtkCellArray.h>
39 #include <vtkCellPicker.h>
40 #include <vtkAreaPicker.h>
41 #include <vtkDoubleArray.h>
42 #include <vtkFloatArray.h>
44 #include <vtkObjectFactory.h>
45 #include <vtkPlanes.h>
46 #include <vtkPoints.h>
47 #include <vtkPolyData.h>
48 #include <vtkPolyDataMapper.h>
49 #include <vtkDataSetMapper.h>
50 #include <vtkMapper.h>
51 #include <vtkUnstructuredGrid.h>
52 #include <vtkDataSetMapper.h>
53 #include <vtkProperty.h>
54 #include <vtkRenderWindowInteractor.h>
55 #include <vtkRenderer.h>
56 #include <vtkRendererCollection.h>
57 #include <vtkRenderWindow.h>
58 #include <vtkSphereSource.h>
59 #include <vtkTransform.h>
60 #include <vtkGlyph3D.h>
61 #include <vtkSmartPointer.h>
62 #include <vtkTransform.h>
63 #include <vtkCursor3D.h>
64 #include <vtkProp3DCollection.h>
66 #include <vtkPropAssembly.h>
67 #include <vtkCollectionIterator.h>
68 #include <vtkCommand.h>
70 #include <vtkRenderWindow.h>
72 #include <vtkDistanceToCamera.h>
73 #include <vtkArrowSource.h>
74 #include <vtkPointSource.h>
78 class axlControlPointsWidgetPrivate
83 vtkPolyDataMapper **CpMapper;
84 vtkDataSetMapper ** CpMapper3D;
85 vtkSphereSource **CpSphere;
87 vtkActor *CpCurrentActor;
88 int CpCurrentActorIndex;
90 vtkCellPicker *CpCursorPicker;
91 vtkAreaPicker *CpRectanglePicker;
93 vtkProperty *CpHandleProperty;
94 vtkProperty *CpSelectedHandleProperty;
95 dtkAbstractData *CpSpline;
97 vtkAssemblyNode *CpCurrentAssemblyNode;
99 vtkActorCollection *CpActorCollection;
104 double radiusScaleCps;
111 vtkCellArray *CpCellAray;
112 vtkPolyData *CpPolyData;
113 vtkPolyDataMapper *CpPolyDataMapper;
114 vtkUnstructuredGrid *CpUnstructuredGrid;
115 vtkDataSetMapper *CpDataSetMapper;
116 vtkActor *CpPolyDataActor;
119 vtkPolyDataMapper *CpCursorPolyDataMapper;
120 vtkActor *CpCursorActor;
124 ~axlControlPointsWidgetPrivate()
128 CpCellAray->Delete();
129 CpPolyData->Delete();
130 CpUnstructuredGrid->Delete();
132 CpPolyDataMapper->Delete();
134 CpPolyDataActor->Delete();
135 CpCursorPicker->Delete();
136 CpRectanglePicker->Delete();
138 CpActorCollection->InitTraversal();
139 vtkObject * o = CpActorCollection->GetNextItem();
143 CpSphere[k]->Delete();
144 CpActor[k]->Delete();
148 o = CpActorCollection->GetNextItem();
151 CpActorCollection->Delete();
168 d->CpCursorPolyDataMapper = vtkPolyDataMapper::New();
169 d->CpCursorActor = vtkActor::New();
170 d->CpCursorActor->VisibilityOff();
171 d->CpCursorActor->SetMapper(d->CpCursorPolyDataMapper);
183 d->XStartPosition =-1;
184 d->YStartPosition =-1;
198 d->CpSpline = spline;
200 d->radiusScaleCps = 1.15;
203 d->numCps = spl->countControlPoints();
207 d->numCps = spl->countControlPoints();
211 d->numCps = spl->countControlPoints();
215 d->numCps = spl->countControlPoints();
221 d->CpCurrentActor = NULL;
224 d->CpPoints = vtkPoints::New();
225 d->CpCellAray = vtkCellArray::New();
226 d->CpPolyData = vtkPolyData::New();
227 d->CpUnstructuredGrid = vtkUnstructuredGrid::New();
230 d->CpPolyDataMapper = vtkPolyDataMapper::New();
231 #if (VTK_MAJOR_VERSION <= 5)
232 d->CpPolyDataMapper->SetInput(d->CpPolyData);
234 d->CpPolyDataMapper->SetInputData(d->CpPolyData);
236 d->CpDataSetMapper = vtkDataSetMapper::New();
237 #if (VTK_MAJOR_VERSION <= 5)
238 d->CpDataSetMapper->SetInput(d->CpUnstructuredGrid);
240 d->CpDataSetMapper->SetInputData(d->CpUnstructuredGrid);
242 d->CpPolyDataActor = vtkActor::New();
243 if(dynamic_cast<axlAbstractVolumeBSpline*> (d->CpSpline))
245 d->CpPolyDataActor->SetMapper(d->CpDataSetMapper);
247 d->CpPolyDataActor->SetMapper(d->CpPolyDataMapper);
249 d->CpPolyDataActor->SetPickable(0);
252 d->CpCursorPicker = vtkCellPicker::New();
253 d->CpRectanglePicker = vtkAreaPicker::New();
255 this->Interactor->SetPicker(d->CpRectanglePicker);
258 double bounds[6];this->Prop3D->GetBounds(bounds);
259 double side = qAbs(bounds[1]-bounds[0]);
260 side += qAbs(bounds[3]-bounds[2]);
261 side += qAbs(bounds[5]-bounds[4]);
268 d->CpMapper =
new vtkPolyDataMapper *[splineCurve->numCoefs()];
269 d->CpSphere =
new vtkSphereSource *[splineCurve->numCoefs()];
270 d->CpActor =
new vtkActor *[splineCurve->numCoefs()];
271 d->CpActorCollection = vtkActorCollection::New();
273 side = (((splineCurve->size()*d->radiusScaleCps)>side) ? (splineCurve->size()*d->radiusScaleCps):side);
275 for (
int i = 0; i < splineCurve->numCoefs(); i++)
278 axlPoint pointCourant = splineCurve->getCoef(i + 1);
279 d->CpPoints->InsertNextPoint(pointCourant.
x(), pointCourant.
y(), pointCourant.
z());
282 d->CpMapper[i] = vtkPolyDataMapper::New();
283 d->CpSphere[i] =vtkSphereSource::New();
284 d->CpSphere[i]->SetPhiResolution(15);
285 d->CpSphere[i]->SetThetaResolution(15);
286 d->CpSphere[i]->SetRadius(side);
287 d->CpSphere[i]->SetCenter(d->CpPoints->GetPoint(i));
288 #if (VTK_MAJOR_VERSION <= 5)
289 d->CpMapper[i]->SetInput( d->CpSphere[i]->GetOutput());
291 d->CpMapper[i]->SetInputData( d->CpSphere[i]->GetOutput());
293 d->CpActor[i] = vtkActor::New();
294 d->CpActor[i]->SetMapper(d->CpMapper[i]);
295 d->CpActor[i]->VisibilityOn();
297 d->CpSphere[i]->Modified();
298 d->CpSphere[i]->Update();
340 d->CpActorCollection->AddItem(d->CpActor[i]);
354 for(
int i = 0; i < splineCurve->numCoefs() - 1; i++)
356 if(splineCurve->connectionsAreDefined()){
357 QList<int> connections = splineCurve->getControlPointConnection(i);
358 foreach(
int value, connections){
359 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
360 currentline->GetPointIds()->SetId(0, i);
361 currentline->GetPointIds()->SetId(1, value);
362 d->CpCellAray->InsertNextCell(currentline);
365 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
366 currentline->GetPointIds()->SetId(0, i);
367 currentline->GetPointIds()->SetId(1, i + 1);
368 d->CpCellAray->InsertNextCell(currentline);
373 d->CpPolyData->SetPoints(d->CpPoints);
374 d->CpPolyData->SetLines(d->CpCellAray);
379 d->CpMapper =
new vtkPolyDataMapper *[d->numCps];
380 d->CpSphere =
new vtkSphereSource *[d->numCps];
381 d->CpActor =
new vtkActor *[d->numCps];
382 d->CpActorCollection = vtkActorCollection::New();
414 side = (splineSurface->size()>side ? splineSurface->size():side);
417 for(
int i = 0; i < d->numCps; i++)
420 axlPoint pointCourant = splineSurface->getCoef(i+1);
421 d->CpPoints->InsertNextPoint(pointCourant.
x(), pointCourant.
y(), pointCourant.
z());
424 d->CpMapper[i] = vtkPolyDataMapper::New();
425 d->CpSphere[i] =vtkSphereSource::New();
426 d->CpSphere[i]->SetPhiResolution(15);
427 d->CpSphere[i]->SetThetaResolution(15);
428 d->CpSphere[i]->SetRadius(side);
429 d->CpSphere[i]->SetCenter(d->CpPoints->GetPoint(i));
430 #if (VTK_MAJOR_VERSION <= 5)
431 d->CpMapper[i]->SetInput( d->CpSphere[i]->GetOutput());
433 d->CpMapper[i]->SetInputData( d->CpSphere[i]->GetOutput());
435 d->CpActor[i] = vtkActor::New();
436 d->CpActor[i]->SetMapper(d->CpMapper[i]);
437 d->CpActor[i]->VisibilityOn();
440 d->CpCursorPicker->SetTolerance(0.001);
442 d->CpSphere[i]->Modified();
443 d->CpSphere[i]->Update();
487 d->CpActorCollection->AddItem(d->CpActor[i]);
491 if(!splineSurface->connectionsAreDefined()){
493 int nbCoeffs_u = splineSurface->countControlPoints_u();
495 for(
int i = 0; i < splineSurface->countControlPoints_v() - 1; i++)
498 for(
int j = 0; j < nbCoeffs_u - 1; j++)
500 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
501 currentline->GetPointIds()->SetId(0, i * nbCoeffs_u + j);
502 currentline->GetPointIds()->SetId(1, i * nbCoeffs_u + j + 1);
504 vtkSmartPointer<vtkLine> currentline2 = vtkSmartPointer<vtkLine>::New();
505 currentline2->GetPointIds()->SetId(0, i * nbCoeffs_u + j);
506 currentline2->GetPointIds()->SetId(1, (i + 1) * nbCoeffs_u + j);
508 d->CpCellAray->InsertNextCell(currentline);
509 d->CpCellAray->InsertNextCell(currentline2);
513 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
514 currentline->GetPointIds()->SetId(0, i * nbCoeffs_u + nbCoeffs_u - 1);
515 currentline->GetPointIds()->SetId(1,(i + 1) * nbCoeffs_u + nbCoeffs_u - 1);
516 d->CpCellAray->InsertNextCell(currentline);
520 for(
int i = 0; i < nbCoeffs_u - 1; i++)
522 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
523 currentline->GetPointIds()->SetId(0, (splineSurface->countControlPoints_v() - 1) * nbCoeffs_u + i);
524 currentline->GetPointIds()->SetId(1, (splineSurface->countControlPoints_v() - 1) * nbCoeffs_u + i + 1);
525 d->CpCellAray->InsertNextCell(currentline);
530 for(
int i = 0 ; i < d->numCps; i++){
531 QList<int> connection = splineSurface->getControlPointConnection(i);
532 foreach(
int value, connection){
533 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
534 currentline->GetPointIds()->SetId(0, i);
535 currentline->GetPointIds()->SetId(1, value);
536 d->CpCellAray->InsertNextCell(currentline);
542 d->CpPolyData->SetPoints(d->CpPoints);
543 d->CpPolyData->SetLines(d->CpCellAray);
548 if(
axlShapeBSpline *splineShape =dynamic_cast<axlShapeBSpline *>(d->CpSpline))
550 d->CpMapper =
new vtkPolyDataMapper *[d->numCps];
551 d->CpSphere =
new vtkSphereSource *[d->numCps];
552 d->CpActor =
new vtkActor *[d->numCps];
553 d->CpActorCollection = vtkActorCollection::New();
556 for(
int i = 0; i < d->numCps; i++)
559 axlPoint pointCourant = splineShape->getCoef(i+1);
560 d->CpPoints->InsertNextPoint(pointCourant.
x(), pointCourant.
y(), pointCourant.
z());
563 d->CpMapper[i]= vtkPolyDataMapper::New();
564 d->CpSphere[i]= vtkSphereSource::New();
565 d->CpSphere[i]->SetPhiResolution(15);
566 d->CpSphere[i]->SetThetaResolution(15);
567 d->CpSphere[i]->SetRadius(side);
568 d->CpSphere[i]->SetCenter(d->CpPoints->GetPoint(i));
569 #if (VTK_MAJOR_VERSION <= 5)
570 d->CpMapper[i]->SetInput( d->CpSphere[i]->GetOutput());
572 d->CpMapper[i]->SetInputData( d->CpSphere[i]->GetOutput());
574 d->CpActor[i] = vtkActor::New();
575 d->CpActor[i]->SetMapper(d->CpMapper[i]);
576 d->CpActor[i]->VisibilityOn();
579 d->CpCursorPicker->SetTolerance(0.001);
581 d->CpSphere[i]->Modified();
582 d->CpSphere[i]->Update();
584 d->CpActorCollection->AddItem(d->CpActor[i]);
588 if(!splineShape->connectionsAreDefined()){
590 int nbCoeffs_u = splineShape->countControlPoints_u();
592 for(
int i = 0; i < splineShape->countControlPoints_v() - 1; i++)
595 for(
int j = 0; j < nbCoeffs_u - 1; j++)
597 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
598 currentline->GetPointIds()->SetId(0, i * nbCoeffs_u + j);
599 currentline->GetPointIds()->SetId(1, i * nbCoeffs_u + j + 1);
601 vtkSmartPointer<vtkLine> currentline2 = vtkSmartPointer<vtkLine>::New();
602 currentline2->GetPointIds()->SetId(0, i * nbCoeffs_u + j);
603 currentline2->GetPointIds()->SetId(1, (i + 1) * nbCoeffs_u + j);
605 d->CpCellAray->InsertNextCell(currentline);
606 d->CpCellAray->InsertNextCell(currentline2);
610 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
611 currentline->GetPointIds()->SetId(0, i * nbCoeffs_u + nbCoeffs_u - 1);
612 currentline->GetPointIds()->SetId(1,(i + 1) * nbCoeffs_u + nbCoeffs_u - 1);
613 d->CpCellAray->InsertNextCell(currentline);
617 for(
int i = 0; i < nbCoeffs_u - 1; i++)
619 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
620 currentline->GetPointIds()->SetId(0, (splineShape->countControlPoints_v() - 1) * nbCoeffs_u + i);
621 currentline->GetPointIds()->SetId(1, (splineShape->countControlPoints_v() - 1) * nbCoeffs_u + i + 1);
622 d->CpCellAray->InsertNextCell(currentline);
627 for(
int i = 0 ; i < d->numCps; i++){
628 QList<int> connection = splineShape->getControlPointConnection(i);
629 foreach(
int value, connection){
630 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
631 currentline->GetPointIds()->SetId(0, i);
632 currentline->GetPointIds()->SetId(1, value);
633 d->CpCellAray->InsertNextCell(currentline);
639 d->CpPolyData->SetPoints(d->CpPoints);
640 d->CpPolyData->SetLines(d->CpCellAray);
647 d->CpMapper3D =
new vtkDataSetMapper *[d->numCps];
648 d->CpSphere =
new vtkSphereSource *[d->numCps];
649 d->CpActor =
new vtkActor *[d->numCps];
650 d->CpActorCollection = vtkActorCollection::New();
684 side = (splineVolume->size()>side ? splineVolume->size():side);
686 for(
int k = 0; k < d->numCps; k++)
689 axlPoint pointCourant = splineVolume->getCoef(k+1);
690 d->CpPoints->InsertNextPoint(pointCourant.
x(), pointCourant.
y(), pointCourant.
z());
693 d->CpMapper3D[k] = vtkDataSetMapper::New();
694 d->CpSphere[k ] =vtkSphereSource::New();
695 d->CpSphere[k ]->SetPhiResolution(15);
696 d->CpSphere[k ]->SetThetaResolution(15);
697 d->CpSphere[k ]->SetRadius(side);
698 d->CpSphere[k ]->SetCenter(d->CpPoints->GetPoint(k));
699 #if (VTK_MAJOR_VERSION <= 5)
700 d->CpMapper3D[k]->SetInput( d->CpSphere[k]->GetOutput());
702 d->CpMapper3D[k]->SetInputData( d->CpSphere[k]->GetOutput());
704 d->CpActor[k] = vtkActor::New();
705 d->CpActor[k]->SetMapper(d->CpMapper3D[k]);
706 d->CpActor[k]->VisibilityOn();
707 d->CpCursorPicker->SetTolerance(0.001);
709 d->CpSphere[k]->Modified();
710 d->CpSphere[k]->Update();
753 d->CpActorCollection->AddItem(d->CpActor[k]);
756 if(!splineVolume->connectionsAreDefined()){
758 int nbCoeffs_u = splineVolume->countControlPoints_u();
759 int nbCoeffs_v = splineVolume->countControlPoints_v();
760 int nbCoeffs_w = splineVolume->countControlPoints_w();
762 for(
int k = 0; k < nbCoeffs_w - 1; k++)
764 for(
int i = 0; i < nbCoeffs_v - 1; i++)
766 for(
int j = 0; j < nbCoeffs_u - 1; j++)
768 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
769 currentline->GetPointIds()->SetId(0, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + j);
770 currentline->GetPointIds()->SetId(1, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + j+1);
772 vtkSmartPointer<vtkLine> currentline2 = vtkSmartPointer<vtkLine>::New();
773 currentline2->GetPointIds()->SetId(0, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + j);
774 currentline2->GetPointIds()->SetId(1, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + j+ nbCoeffs_u);
776 vtkSmartPointer<vtkLine> currentline3 = vtkSmartPointer<vtkLine>::New();
777 currentline3->GetPointIds()->SetId(0, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + j);
778 currentline3->GetPointIds()->SetId(1, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + j + nbCoeffs_u* nbCoeffs_v);
780 d->CpCellAray->InsertNextCell(currentline);
781 d->CpCellAray->InsertNextCell(currentline2);
782 d->CpCellAray->InsertNextCell(currentline3);
786 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
787 currentline->GetPointIds()->SetId(0, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + nbCoeffs_u - 1);
788 currentline->GetPointIds()->SetId(1,k *nbCoeffs_u *nbCoeffs_v + (i+1) * nbCoeffs_u + nbCoeffs_u - 1);
790 vtkSmartPointer<vtkLine> currentline2 = vtkSmartPointer<vtkLine>::New();
791 currentline2->GetPointIds()->SetId(0, k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + nbCoeffs_u - 1 );
792 currentline2->GetPointIds()->SetId(1,k *nbCoeffs_u *nbCoeffs_v + i * nbCoeffs_u + nbCoeffs_u - 1+ nbCoeffs_u* nbCoeffs_v);
794 d->CpCellAray->InsertNextCell(currentline);
795 d->CpCellAray->InsertNextCell(currentline2);
799 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
800 currentline->GetPointIds()->SetId(0, k *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v - 1) * nbCoeffs_u + nbCoeffs_u - 1 );
801 currentline->GetPointIds()->SetId(1,(k+1) *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v - 1) * nbCoeffs_u + nbCoeffs_u - 1);
802 d->CpCellAray->InsertNextCell(currentline);
806 for(
int j = 0; j < nbCoeffs_v - 1; j++)
808 for(
int i = 0; i < nbCoeffs_u - 1; i++)
810 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
811 currentline->GetPointIds()->SetId(0, ( (nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + j * nbCoeffs_u + i));
812 currentline->GetPointIds()->SetId(1, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + j * nbCoeffs_u + i +1));
814 vtkSmartPointer<vtkLine> currentline2 = vtkSmartPointer<vtkLine>::New();
815 currentline2->GetPointIds()->SetId(0, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + j * nbCoeffs_u + i));
816 currentline2->GetPointIds()->SetId(1, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + (j+1) * nbCoeffs_u + i));
818 d->CpCellAray->InsertNextCell(currentline);
819 d->CpCellAray->InsertNextCell(currentline2);
822 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
823 currentline->GetPointIds()->SetId(0, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + j * nbCoeffs_u + nbCoeffs_u -1));
824 currentline->GetPointIds()->SetId(1, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + (j+1) * nbCoeffs_u + nbCoeffs_u -1));
826 d->CpCellAray->InsertNextCell(currentline);
830 for(
int i = 0; i < nbCoeffs_u - 1; i++)
832 for(
int k = 0; k < nbCoeffs_w - 1; k++)
834 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
835 currentline->GetPointIds()->SetId(0, ( k *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v -1) * nbCoeffs_u + i));
836 currentline->GetPointIds()->SetId(1, (k *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v -1) * nbCoeffs_u + i+1));
838 vtkSmartPointer<vtkLine> currentline2 = vtkSmartPointer<vtkLine>::New();
839 currentline2->GetPointIds()->SetId(0, (k *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v -1) * nbCoeffs_u + i));
840 currentline2->GetPointIds()->SetId(1, ((k+1) *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v -1) * nbCoeffs_u + i));
842 d->CpCellAray->InsertNextCell(currentline);
843 d->CpCellAray->InsertNextCell(currentline2);
846 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
847 currentline->GetPointIds()->SetId(0, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v -1) * nbCoeffs_u + i));
848 currentline->GetPointIds()->SetId(1, ((nbCoeffs_w -1 ) *nbCoeffs_u *nbCoeffs_v + (nbCoeffs_v -1) * nbCoeffs_u + i+1));
850 d->CpCellAray->InsertNextCell(currentline);
854 for(
int i = 0 ; i < d->numCps; i++){
855 QList<int> connection = splineVolume->getControlPointConnection(i);
856 foreach(
int value, connection){
857 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
858 currentline->GetPointIds()->SetId(0, i);
859 currentline->GetPointIds()->SetId(1, value);
860 d->CpCellAray->InsertNextCell(currentline);
866 d->CpUnstructuredGrid->SetPoints(d->CpPoints);
867 d->CpUnstructuredGrid->SetCells(VTK_LINE, d->CpCellAray);
873 for (
int i=0; i< d->numCps; i++)
875 d->CpActor[i]->SetProperty(d->CpHandleProperty);
881 return d->CpPolyDataActor;
886 return d->CpActorCollection;
892 if ( ! this->Interactor )
894 vtkErrorMacro(<<
"The interactor must be set prior to enabling/disabling widget");
900 vtkDebugMacro(<<
"Enabling widget");
907 if ( ! this->CurrentRenderer )
909 this->SetCurrentRenderer(this->Interactor->FindPokedRenderer(
910 this->Interactor->GetLastEventPosition()[0],
911 this->Interactor->GetLastEventPosition()[1]));
912 if (this->CurrentRenderer == NULL)
921 vtkRenderWindowInteractor *i = this->Interactor;
922 i->AddObserver(vtkCommand::MouseMoveEvent, this->EventCallbackCommand,
924 i->AddObserver(vtkCommand::LeftButtonPressEvent,
925 this->EventCallbackCommand, this->Priority);
926 i->AddObserver(vtkCommand::LeftButtonReleaseEvent,
927 this->EventCallbackCommand, this->Priority);
929 for (
int i=0; i< d->numCps; i++)
931 d->CpActor[i]->SetVisibility(
true);
934 d->CpPolyDataActor->SetVisibility(
true);
935 d->CpCurrentActorIndex =-1;
936 d->XStartPosition =-1;
937 d->YStartPosition =-1;
940 this->InvokeEvent(vtkCommand::EnableEvent,NULL);
945 vtkDebugMacro(<<
"Disabling widget");
947 if ( ! this->Enabled )
955 this->Interactor->RemoveObserver(this->EventCallbackCommand);
958 for (
int i=0; i<d->numCps; i++)
960 d->CpActor[i]->SetVisibility(
false);
963 d->CpPolyDataActor->SetVisibility(
false);
965 d->CpCurrentActorIndex =-1;
966 d->XStartPosition =-1;
967 d->YStartPosition =-1;
969 this->InvokeEvent(vtkCommand::DisableEvent,NULL);
970 this->SetCurrentRenderer(NULL);
973 this->Interactor->Render();
978 double bounds[6];this->Prop3D->GetBounds(bounds);
979 double side = qAbs(bounds[1]-bounds[0]);
980 side += qAbs(bounds[3]-bounds[2]);
981 side += qAbs(bounds[5]-bounds[4]);
985 if(dynamic_cast<axlAbstractCurveBSpline *>(d->CpSpline))
986 side = ((cpSize*d->radiusScaleCps)>side ? (cpSize*d->radiusScaleCps):side);
988 side = (cpSize>side ? cpSize:side);
990 for(
int i = 0 ; i < d->numCps; i++){
991 d->CpSphere[i]->SetRadius(side);
993 d->CpSphere[i]->Modified();
994 d->CpSphere[i]->Update();
1005 vtkActor *currentActor =
static_cast<vtkActor *
>(prop);
1011 for (
int i=0; i<d->numCps; i++)
1013 if ( currentActor == d->CpActor[i] )
1015 currentActor->SetProperty(d->CpSelectedHandleProperty);
1016 d->CpCursorPicker->GetPickPosition(this->LastPickPosition);
1017 d->CpRectanglePicker->GetPickPosition(this->LastPickPosition);
1047 case vtkCommand::LeftButtonPressEvent:
1050 case vtkCommand::LeftButtonReleaseEvent:
1051 self->OnLeftButtonUp();
1053 case vtkCommand::MouseMoveEvent:
1054 self->OnMouseMove();
1062 double bounds[6], center[3];
1064 this->AdjustBounds(bds, bounds, center);
1068 this->InitialBounds[i] = bounds[i];
1071 this->InitialLength = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
1072 (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
1073 (bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
1078 this->Superclass::PrintSelf(os,indent);
1081 #define VTK_AVERAGE(a,b,c) \
1082 c[0] = (a[0] + b[0])/2.0; \
1083 c[1] = (a[1] + b[1])/2.0; \
1084 c[2] = (a[2] + b[2])/2.0;
1091 int X = this->Interactor->GetEventPosition()[0];
1092 int Y = this->Interactor->GetEventPosition()[1];
1096 if (!this->CurrentRenderer || !this->CurrentRenderer->IsInViewport(X, Y))
1102 d->XStartPosition = X;
1103 d->YStartPosition = Y;
1105 vtkAssemblyPath *path = NULL;
1106 d->CpCursorPicker->Pick(X, Y, 0.0, this->CurrentRenderer);
1108 path = d->CpCursorPicker->GetPath();
1113 d->CpCurrentActorIndex=this->
HighlightHandle(path->GetLastNode()->GetViewProp());
1114 d->CpCurrentAssemblyNode = path->GetLastNode();
1115 d->CpCursorPicker->GetPickPosition(this->LastPickPosition);
1117 if( d->CpCurrentActorIndex == -1)
1132 this->EventCallbackCommand->SetAbortFlag(1);
1133 this->StartInteraction();
1141 splineCurve->selectIndex(d->CpCurrentActorIndex);
1144 splineSurface->selectIndex(d->CpCurrentActorIndex);
1148 splineVolume->selectIndex(d->CpCurrentActorIndex);
1150 else if (
axlShapeBSpline *splineSurface = dynamic_cast<axlShapeBSpline *>(d->CpSpline)) {
1151 splineSurface->selectIndex(d->CpCurrentActorIndex);
1158 int X = this->Interactor->GetEventPosition()[0];
1159 int Y = this->Interactor->GetEventPosition()[1];
1162 if (!this->CurrentRenderer || !this->CurrentRenderer->IsInViewport(X, Y))
1194 this->EventCallbackCommand->SetAbortFlag(0);
1195 this->EndInteraction();
1196 this->InvokeEvent(vtkCommand::EndInteractionEvent, NULL);
1209 int X = this->Interactor->GetEventPosition()[0];
1210 int Y = this->Interactor->GetEventPosition()[1];
1214 double focalPoint[4], pickPoint[4], prevPickPoint[4], motionVector[4];
1217 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
1224 this->ComputeWorldToDisplay(this->LastPickPosition[0], this->LastPickPosition[1], this->LastPickPosition[2], focalPoint);
1226 this->ComputeDisplayToWorld(
double(this->Interactor->GetLastEventPosition()[0]),
double(this->Interactor->GetLastEventPosition()[1]),
1228 this->ComputeDisplayToWorld(
double(X),
double(Y), z, pickPoint);
1229 for(
int i=0;i<4;i++)
1231 motionVector[i]=pickPoint[i]-prevPickPoint[i];
1234 vtkMatrix4x4 *motion = vtkMatrix4x4::New();
1236 if(d->CpCurrentAssemblyNode)
1237 motion->DeepCopy(d->CpCurrentAssemblyNode->GetMatrix());
1245 double *newMotion = motion->MultiplyDoublePoint(motionVector);
1246 double newPosition[4];
1247 for(
int j = 0; j < 4; j++)
1249 newPosition[j]=d->CpPoints->GetPoint(d->CpCurrentActorIndex)[j]+newMotion[j];
1251 d->CpPoints->SetPoint(d->CpCurrentActorIndex, newPosition[0], newPosition[1], newPosition[2]);
1252 d->CpPoints->Modified();
1253 d->CpSphere[d->CpCurrentActorIndex]->SetCenter(d->CpPoints->GetPoint(d->CpCurrentActorIndex));
1254 d->CpSphere[d->CpCurrentActorIndex]->Update();
1255 d->CpSphere[d->CpCurrentActorIndex]->Modified();
1257 splineCurve->setCoef(d->CpCurrentActorIndex + 1,newPosition);
1264 double *newMotion = motion->MultiplyDoublePoint(motionVector);
1265 double newPosition[4];
1266 for(
int j = 0 ;j < 4; j++)
1268 newPosition[j]=d->CpPoints->GetPoint(d->CpCurrentActorIndex)[j]+newMotion[j];
1270 d->CpPoints->SetPoint(d->CpCurrentActorIndex, newPosition[0], newPosition[1], newPosition[2]);
1271 d->CpPoints->Modified();
1272 d->CpSphere[d->CpCurrentActorIndex]->SetCenter(d->CpPoints->GetPoint(d->CpCurrentActorIndex));
1273 d->CpSphere[d->CpCurrentActorIndex]->Update();
1274 d->CpSphere[d->CpCurrentActorIndex]->Modified();
1276 splineSurface->setCoef(d->CpCurrentActorIndex + 1,newPosition);
1279 if(
axlShapeBSpline *splineShape = dynamic_cast<axlShapeBSpline *>(d->CpSpline))
1282 double *newMotion = motion->MultiplyDoublePoint(motionVector);
1283 double newPosition[4];
1284 for(
int j = 0 ;j < 4; j++)
1286 newPosition[j]=d->CpPoints->GetPoint(d->CpCurrentActorIndex)[j]+newMotion[j];
1288 d->CpPoints->SetPoint(d->CpCurrentActorIndex, newPosition[0], newPosition[1], newPosition[2]);
1289 d->CpPoints->Modified();
1290 d->CpSphere[d->CpCurrentActorIndex]->SetCenter(d->CpPoints->GetPoint(d->CpCurrentActorIndex));
1291 d->CpSphere[d->CpCurrentActorIndex]->Update();
1292 d->CpSphere[d->CpCurrentActorIndex]->Modified();
1294 splineShape->setCoef(d->CpCurrentActorIndex + 1,newPosition);
1300 double *newMotion = motion->MultiplyDoublePoint(motionVector);
1301 double newPosition[4];
1302 for(
int j = 0 ;j < 4; j++)
1304 newPosition[j]=d->CpPoints->GetPoint(d->CpCurrentActorIndex)[j]+newMotion[j];
1306 d->CpPoints->SetPoint(d->CpCurrentActorIndex, newPosition[0], newPosition[1], newPosition[2]);
1307 d->CpPoints->Modified();
1308 d->CpSphere[d->CpCurrentActorIndex]->SetCenter(d->CpPoints->GetPoint(d->CpCurrentActorIndex));
1309 d->CpSphere[d->CpCurrentActorIndex]->Update();
1310 d->CpSphere[d->CpCurrentActorIndex]->Modified();
1312 splineVolume->setCoef(d->CpCurrentActorIndex + 1,newPosition);
1322 this->EventCallbackCommand->SetAbortFlag(1);
1323 this->InvokeEvent(vtkCommand::InteractionEvent,NULL);
1324 this->Interactor->Render();
1330 d->CpHandleProperty = vtkProperty::New();
1331 d->CpHandleProperty->SetColor(1,1,1);
1333 d->CpSelectedHandleProperty = vtkProperty::New();
1334 d->CpSelectedHandleProperty->SetColor(1,0,0);
Class axlPoint defines 3D points.
Class axlShapeBSpline defines a set of boundary curves (Edges) and bspline surface patches (Face)...