]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3DContour.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualView3DContour.cpp
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "manualView3DContour.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 manualView3DContour::manualView3DContour()
32 {
33 }
34 // ----------------------------------------------------------------------------
35 manualView3DContour::~manualView3DContour()
36 {
37 }
38
39 // ----------------------------------------------------------------------------
40 manualView3DContour * manualView3DContour :: Clone()
41 {
42         manualView3DContour * clone = new manualView3DContour();
43         CopyAttributesTo(clone);
44         return clone;
45 }
46
47 // ---------------------------------------------------------------------------
48 void manualView3DContour::CopyAttributesTo( manualView3DContour * cloneObject)
49 {
50         // Fathers object
51         manualViewContour::CopyAttributesTo(cloneObject);
52
53         cloneObject->SetDimensions ( _w , _h , _d );
54 }
55 // ----------------------------------------------------------------------------
56 void manualView3DContour::SetDimensions(int w, int h, int d)
57 {
58         _w = w;
59         _h = h;
60         _d = d;
61 }
62 // ----------------------------------------------------------------------------
63 void manualView3DContour::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)
64 {
65         X = _vtkmprbasedata->GetX();
66         Y = _vtkmprbasedata->GetY();
67         Z = _vtkmprbasedata->GetZ();
68 }
69 // ----------------------------------------------------------------------------
70 void manualView3DContour::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
71 {
72         _vtkmprbasedata = vtkmprbasedata;
73 }
74 // ----------------------------------------------------------------------------
75 int manualView3DContour::GetIdPoint2(int x, int y)
76 {
77         int id = -1;
78         double p[3],pA[3],pB[3];
79
80         double pickPoint[ 3 ], cameraPos[ 3 ];
81         vtkPointPicker* picker = vtkPointPicker::New( );
82         vtkRenderer *pRenderer = this->GetWxVtkBaseView()->GetRenderer();
83         picker->Pick( x, y, 0.0, pRenderer );
84         pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
85         picker->GetPickPosition( pickPoint );
86         picker->Delete( );
87
88         UtilVtk3DGeometriSelection utilVtk3Dgeometriselection;
89         utilVtk3Dgeometriselection.SetDimentions(_w,_h,_d);
90
91         if( utilVtk3Dgeometriselection.FindCubePointsFromPoints( pA, pB, pickPoint, cameraPos )  )
92         {
93                 double dist,distMin=999999999;
94                 int i,size=this->_manContModel->GetSizeLstPoints();
95                 for (i=0;i<size;i++)
96                 {
97                         manualPoint *mp = this->_manContModel->GetManualPoint(i);
98                         p[0] = mp->GetX();
99                         p[1] = mp->GetY();
100                         p[2] = mp->GetZ();
101                         dist=utilVtk3Dgeometriselection.DistanceMinPointToLine(p,pA,pB);
102                         if ( (dist<=2*GetRange()) && (dist<distMin) )
103                         {
104                                 distMin = dist;
105                                 id              = i;
106                         }
107                 }
108         }
109         return id;
110 }
111 // ----------------------------------------------------------------------------
112 int manualView3DContour::SelectPosiblePoint ( int x, int y, int z )// virtual
113 {
114         SelectAllPossibleSelected(false);
115         int id=GetIdPoint2(x,y);
116         if (id!=-1)
117         {
118                 SetPointPosibleSelected(id,true);
119         }
120         return id;
121 }
122