]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContour3DControler.cpp
#3128 creaMaracasVisu Feature New Normal - branch changeWx28to30 compilation with...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContour3DControler.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 "manualContour3DControler.h"
27
28
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
32
33 manualContour3DControler::manualContour3DControler()
34 {
35 }
36 // ----------------------------------------------------------------------------
37 manualContour3DControler::~manualContour3DControler()
38 {
39 }
40 // ----------------------------------------------------------------------------
41 manualContour3DControler * manualContour3DControler :: Clone()  // virtual
42 {
43         manualContour3DControler * clone = new manualContour3DControler();
44         CopyAttributesTo(clone);
45         return clone;
46 }
47
48 // ---------------------------------------------------------------------------
49 void manualContour3DControler::CopyAttributesTo( manualContour3DControler * cloneObject)
50 {
51         // Fathers object
52         manualContourControler::CopyAttributesTo(cloneObject);
53
54         cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
55 }
56
57 // ----------------------------------------------------------------------------
58 bool  manualContour3DControler::OnLeftButtonDown()
59 {
60         int X,Y;
61         crea::wxVTKRenderWindowInteractor *wxVTKiren;
62         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
63         wxVTKiren->GetEventPosition(X,Y);
64         MouseClickLeft(X,Y);
65         return true;
66 }
67 // ----------------------------------------------------------------------------
68 void manualContour3DControler::ResetOrientationPlane()
69 {
70         double p[3],rp[3],rn[3];
71         p[0] = this->GetVtkMPRBaseData()->GetX(  );
72         p[1] = this->GetVtkMPRBaseData()->GetY(  );
73         p[2] = this->GetVtkMPRBaseData()->GetZ(  );
74         this->GetManualContourModel()->GetNearestPointAndNormal(p,rp,rn);
75         this->GetVtkMPRBaseData()->SetNormal(rn[0],rn[1],rn[2]);
76 }
77 // ----------------------------------------------------------------------------
78 void manualContour3DControler::MouseClickLeft(int x, int y) // virtual
79 {
80         manualView3DContour *manualview3Dcontour=(manualView3DContour*)GetManualViewBaseContour();
81         int id=manualview3Dcontour->GetIdPoint2(x,y);
82         if ( (GetState()==0) && (id!=-1) )
83         {
84                 manualPoint *mp = this->GetManualContourModel()->GetManualPoint(id);
85
86                 this->GetVtkMPRBaseData()->SetX( mp->GetX() );
87                 this->GetVtkMPRBaseData()->SetY( mp->GetY() );
88                 this->GetVtkMPRBaseData()->SetZ( mp->GetZ() );
89                 ResetOrientationPlane();
90                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
91         }
92
93
94         manualContourControler::MouseClickLeft(x,y);
95
96 }
97 // ----------------------------------------------------------------------------
98 bool manualContour3DControler::OnChar()
99 {
100         bool ok=true;
101         manualContourControler::OnChar();
102         char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
103         if (keyCode==32){
104                 ok=false;
105                 ResetOrientationPlane();
106                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
107         }
108         return ok;
109 }
110
111 // ----------------------------------------------------------------------------
112 void manualContour3DControler::SetVtkMPRBaseData (vtkMPRBaseData *vtkmprbasedata )
113 {
114         _vtkmprbasedata=vtkmprbasedata;
115 }
116 // ----------------------------------------------------------------------------
117 vtkMPRBaseData *manualContour3DControler::GetVtkMPRBaseData()
118 {
119         return _vtkmprbasedata;
120 }
121
122 // ----------------------------------------------------------------------------
123 void manualContour3DControler::InsertPoint(int x, int y, int z ) // virtual
124 {
125         manualContourControler::InsertPoint(  x,  y,  z );
126         ResetOrientationPlane();
127 }
128