]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3DContour.cpp
aa003292c0eab8a2ce5788a998b8634636d0e827
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualView3DContour.cpp
1 #include "manualView3DContour.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6 manualView3DContour::manualView3DContour()
7 {
8 }
9 // ----------------------------------------------------------------------------
10 manualView3DContour::~manualView3DContour()
11 {
12 }
13
14 // ----------------------------------------------------------------------------
15 manualView3DContour * manualView3DContour :: Clone()
16 {
17         manualView3DContour * clone = new manualView3DContour();
18         CopyAttributesTo(clone);
19         return clone;
20 }
21
22 // ---------------------------------------------------------------------------
23 void manualView3DContour::CopyAttributesTo( manualView3DContour * cloneObject)
24 {
25         // Fathers object
26         manualViewContour::CopyAttributesTo(cloneObject);
27
28         cloneObject->SetDimensions ( _w , _h , _d );
29 }
30 // ----------------------------------------------------------------------------
31 void manualView3DContour::SetDimensions(int w, int h, int d)
32 {
33         _w = w;
34         _h = h;
35         _d = d;
36 }
37 // ----------------------------------------------------------------------------
38 void manualView3DContour::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type)
39 {
40         X = _vtkmprbasedata->GetX();
41         Y = _vtkmprbasedata->GetY();
42         Z = _vtkmprbasedata->GetZ();
43 }
44 // ----------------------------------------------------------------------------
45 void manualView3DContour::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
46 {
47         _vtkmprbasedata = vtkmprbasedata;
48 }
49 // ----------------------------------------------------------------------------
50 int manualView3DContour::GetIdPoint2(int x, int y)
51 {
52         int id = -1;
53         double p[3],pA[3],pB[3];
54
55         double pickPoint[ 3 ], cameraPos[ 3 ];
56         vtkPointPicker* picker = vtkPointPicker::New( );
57         vtkRenderer *pRenderer = this->GetWxVtkBaseView()->GetRenderer();
58         picker->Pick( x, y, 0.0, pRenderer );
59         pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
60         picker->GetPickPosition( pickPoint );
61         picker->Delete( );
62
63         UtilVtk3DGeometriSelection utilVtk3Dgeometriselection;
64         utilVtk3Dgeometriselection.SetDimentions(_w,_h,_d);
65
66         if( utilVtk3Dgeometriselection.FindCubePointsFromPoints( pA, pB, pickPoint, cameraPos )  )
67         {
68                 double dist,distMin=999999999;
69                 int i,size=this->_manContModel->GetSizeLstPoints();
70                 for (i=0;i<size;i++)
71                 {
72                         manualPoint *mp = this->_manContModel->GetManualPoint(i);
73                         p[0] = mp->GetX();
74                         p[1] = mp->GetY();
75                         p[2] = mp->GetZ();
76                         dist=utilVtk3Dgeometriselection.DistanceMinPointToLine(p,pA,pB);
77                         if ( (dist<=2*GetRange()) && (dist<distMin) )
78                         {
79                                 distMin = dist;
80                                 id              = i;
81                         }
82                 }
83         }
84         return id;
85 }
86 // ----------------------------------------------------------------------------
87 int manualView3DContour::SelectPosiblePoint ( int x, int y, int z )// virtual
88 {
89         SelectAllPossibleSelected(false);
90         int id=GetIdPoint2(x,y);
91         if (id!=-1)
92         {
93                 SetPointPosibleSelected(id,true);
94         }
95         return id;
96 }
97