]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx
Feature #1771 Add licence terms for all files.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / manualConnectorContourController.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26 /*=========================================================================                                                                               
27 Program:   bbtk
28 Module:    $RCSfile$
29 Language:  C++
30 Date:      $Date$
31 Version:   $Revision$
32 =========================================================================*/
33
34 /* ---------------------------------------------------------------------
35
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
38 *
39 *  This software is governed by the CeCILL-B license under French law and 
40 *  abiding by the rules of distribution of free software. You can  use, 
41 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
42 *  license as circulated by CEA, CNRS and INRIA at the following URL 
43 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
44 *  or in the file LICENSE.txt.
45 *
46 *  As a counterpart to the access to the source code and  rights to copy,
47 *  modify and redistribute granted by the license, users are provided only
48 *  with a limited warranty  and the software's author,  the holder of the
49 *  economic rights,  and the successive licensors  have only  limited
50 *  liability. 
51 *
52 *  The fact that you are presently reading this means that you have had
53 *  knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */                                                                         
55
56 /**
57 *  \file 
58 *  \brief Class bbtk::manualConnectorContourController 
59 */
60
61
62 #include "manualConnectorContourController.h"
63
64 namespace bbtk
65 {
66
67
68         //=========================================================================
69         manualConnectorContourController::manualConnectorContourController()
70         {               
71         }
72
73         //=========================================================================
74         
75         manualConnectorContourController::~manualConnectorContourController()
76         {
77         }
78
79         //=========================================================================
80
81         void manualConnectorContourController::MouseMove(int x, int y) // virtual
82         {
83                 
84                 int z=GetZ();
85                 
86                 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
87                 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
88                 if (GetState()==1){     SetPoint( _bakIdPoint , x , y ,z); }
89                 if (GetState()==5){     SetPoint( _bakIdPoint , x , y ,z); }
90                 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
91                 {
92                         //GetManualViewBaseContour()->MoveContour(x,y,z);
93                 }
94                 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
95                         GetManualViewBaseContour()->Refresh();
96                         this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
97                 }
98                 if (!IsEditable())
99                 {
100                         GetManualViewBaseContour()->RemoveControlPoints();
101                         GetManualViewBaseContour()->Refresh();
102                         this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
103                 }
104
105         }
106
107         //=========================================================================
108
109         void manualConnectorContourController::MouseClickRight(int x, int y)
110         {
111                 SetCompleteCreation( true );
112                 SetKeyBoardMoving( false );
113                 GetManualContourModel()->SetCloseContour(false);
114
115                 SetEditable( false );
116                 SetPosibleToMove( false );
117                 SetState(0);
118                 
119         }
120
121         //=========================================================================
122
123         void manualConnectorContourController::MouseClickLeft(int x, int y)
124         {
125
126                 bool ok = false;
127                 int z=GetZ();
128                 int size= GetManualViewBaseContour()->GetNumberOfPoints();
129
130                 
131                 // Insert a Control Point with shift+ClickLeft
132                 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
133                 if( IsEditable() )
134                 {
135                         if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
136                         {
137                                 ok=true;
138                                 InsertPoint(x,y,z);
139                                 size++;
140                         }
141                         // Start to Insert Control Points with ClickLeft (Empty contour)
142                         if ((GetState()==0) && (size==0) && (_easyCreation==true) )
143                         {
144                                 ok=true;
145                                 SetState(1);
146                                 GetManualContourModel()->SetCloseContour(false);
147                                 AddPoint(x,y,z);
148                         }
149
150                         // RaC Just create 2 points
151                         if ((GetState()==1) && (_easyCreation==true) && GetNumberOfPointsManualContour()==2)
152                         {
153                                 ok=true;
154                                 endContourCreation();
155                         }
156
157                         // Continue to Insert Control Points with ClickLeft (After being empty the contour)
158                         if ((GetState()==1) && (_easyCreation==true) )
159                         {
160                                 ok=true;
161                                 AddPoint(x,y,z);
162                                 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
163                         }
164
165                         // Insert Control Points IF Contour si Selected
166                         if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
167                         {
168                                 ok=true;
169                                 InsertPoint(x,y,z);
170                                 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
171                                 SetState(6);
172                         }
173                         // Chose id of Control Point to be move
174                         if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
175                         {
176                                 ok=true;
177                                 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
178                                 if(_bakIdPoint!=0 && _bakIdPoint!=GetManualViewBaseContour()->GetNumberOfPoints()-1)
179                                 {
180                                         SetState(5);
181                                 }
182                         }
183                         // If nothing selected _state=7
184                         if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
185                         {
186                                 //ok=true;
187                                 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
188                                 SetState(7);
189                         }
190                 }else{
191                         SetPosibleToMove( true );
192                         GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
193                 } // IsEditable
194                 
195                 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
196                 {
197                         SetMoving( true );
198                         ok=true;
199                         GetManualViewBaseContour()->InitMove(x,y,z);
200                         SetState(6);
201                 }
202                 
203                 if (ok==true)
204                 {
205                         GetManualViewBaseContour()->Refresh();
206                 }// ok
207                 
208         }
209         
210         //=========================================================================
211         
212         void manualConnectorContourController::endContourCreation()
213         {
214                 SetCompleteCreation( true );
215                 SetKeyBoardMoving( false );
216                 GetManualContourModel()->SetCloseContour(false);
217
218                 SetEditable( false );
219                 SetPosibleToMove( false );
220                 SetState(0);
221         }
222
223
224         //=========================================================================
225
226 }  // EO namespace bbtk
227
228 // EOF
229