manualConnectorContourController.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002 Program:   bbtk
00003 Module:    $RCSfile: manualConnectorContourController.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2010/05/07 14:30:37 $
00006 Version:   $Revision: 1.4 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00037 #include "manualConnectorContourController.h"
00038 
00039 namespace bbtk
00040 {
00041 
00042 
00043         //=========================================================================
00044         manualConnectorContourController::manualConnectorContourController()
00045         {               
00046         }
00047 
00048         //=========================================================================
00049         
00050         manualConnectorContourController::~manualConnectorContourController()
00051         {
00052         }
00053 
00054         //=========================================================================
00055 
00056         void manualConnectorContourController::MouseMove(int x, int y) // virtual
00057         {
00058                 int z=GetZ();
00059                 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
00060                 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
00061                 if (GetState()==1){     SetPoint( _bakIdPoint , x , y ,z); }
00062                 if (GetState()==5){     SetPoint( _bakIdPoint , x , y ,z); }
00063                 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
00064                 {
00065                         //GetManualViewBaseContour()->MoveContour(x,y,z);
00066                 }
00067                 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
00068                         GetManualViewBaseContour()->Refresh();
00069                         this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00070                 }
00071                 if (!IsEditable())
00072                 {
00073                         GetManualViewBaseContour()->RemoveControlPoints();
00074                         GetManualViewBaseContour()->Refresh();
00075                         this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00076                 }
00077 
00078         }
00079 
00080         //=========================================================================
00081 
00082         void manualConnectorContourController::MouseClickRight(int x, int y)
00083         {
00084                 SetCompleteCreation( true );
00085                 SetKeyBoardMoving( false );
00086                 GetManualContourModel()->SetCloseContour(false);
00087 
00088                 SetEditable( false );
00089                 SetPosibleToMove( false );
00090                 SetState(0);
00091                 
00092         }
00093 
00094         //=========================================================================
00095 
00096         void manualConnectorContourController::MouseClickLeft(int x, int y)
00097         {
00098 
00099                 bool ok = false;
00100                 int z   = GetZ();
00101                 int size= GetManualViewBaseContour()->GetNumberOfPoints();
00102 
00103                 // Insert a Control Point with shift+ClickLeft
00104                 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
00105                 if( IsEditable() )
00106                 {
00107                         if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
00108                         {
00109                                 ok=true;
00110                                 InsertPoint(x,y,z);
00111                                 size++;
00112                         }
00113                         // Start to Insert Control Points with ClickLeft (Empty contour)
00114                         if ((GetState()==0) && (size==0) && (_easyCreation==true) )
00115                         {
00116                                 ok=true;
00117                                 SetState(1);
00118                                 GetManualContourModel()->SetCloseContour(false);
00119                                 AddPoint(x,y,z);
00120                         }
00121 
00122                         // RaC Just create 2 points
00123                         if ((GetState()==1) && (_easyCreation==true) && GetNumberOfPointsManualContour()==2)
00124                         {
00125                                 ok=true;
00126                                 endContourCreation();
00127                         }
00128 
00129                         // Continue to Insert Control Points with ClickLeft (After being empty the contour)
00130                         if ((GetState()==1) && (_easyCreation==true) )
00131                         {
00132                                 ok=true;
00133                                 AddPoint(x,y,z);
00134                                 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
00135                         }
00136 
00137                         // Insert Control Points IF Contour si Selected
00138                         if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
00139                         {
00140                                 ok=true;
00141                                 InsertPoint(x,y,z);
00142                                 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00143                                 SetState(6);
00144                         }
00145                         // Chose id of Control Point to be move
00146                         if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
00147                         {
00148                                 ok=true;
00149                                 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00150                                 if(_bakIdPoint!=0 && _bakIdPoint!=GetManualViewBaseContour()->GetNumberOfPoints()-1)
00151                                 {
00152                                         SetState(5);
00153                                 }
00154                         }
00155                         // If nothing selected _state=7
00156                         if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
00157                         {
00158                                 //ok=true;
00159                                 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00160                                 SetState(7);
00161                         }
00162                 }else{
00163                         SetPosibleToMove( true );
00164                         GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
00165                 } // IsEditable
00166                 
00167                 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
00168                 {
00169                         SetMoving( true );
00170                         ok=true;
00171                         GetManualViewBaseContour()->InitMove(x,y,z);
00172                         SetState(6);
00173                 }
00174                 if (ok==true)
00175                 {
00176                         GetManualViewBaseContour()->Refresh();
00177                 }
00178         }
00179         
00180         //=========================================================================
00181         
00182         void manualConnectorContourController::endContourCreation()
00183         {
00184                 SetCompleteCreation( true );
00185                 SetKeyBoardMoving( false );
00186                 GetManualContourModel()->SetCloseContour(false);
00187 
00188                 SetEditable( false );
00189                 SetPosibleToMove( false );
00190                 SetState(0);
00191         }
00192 
00193 
00194         //=========================================================================
00195 
00196 }  // EO namespace bbtk
00197 
00198 // EOF
00199 

Generated on Thu May 31 15:12:19 2012 for bbtkGEditor by  doxygen 1.5.7.1