GBlackBoxController.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 Program:   bbtk
00003 Module:    $RCSfile: GBlackBoxController.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/23 10:54:02 $
00006 Version:   $Revision: 1.14 $
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 "GBlackBoxController.h"
00038 
00039 #ifdef _DEBUG
00040 #define new DEBUG_NEW
00041 #endif
00042 namespace bbtk
00043 {
00044 
00045 
00046         //=========================================================================
00047         GBlackBoxController::GBlackBoxController()
00048         {
00049 
00050         }
00051 
00052         //=========================================================================
00053         GBlackBoxController::~GBlackBoxController()
00054         {
00055         }
00056         //=========================================================================
00057 
00058         bool GBlackBoxController::OnMouseMove()
00059         {
00060 
00061                 if ( _vtkInteractorStyleBaseView!=NULL)
00062                 {
00063                         int X,Y;
00064                         wxVTKRenderWindowInteractor *_wxVTKiren;
00065                         _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
00066                         _wxVTKiren->GetEventPosition( X , Y );
00067 
00068                         int state  = _view->getState();
00069 
00070                         //Evaluate new state
00071 
00072                         if(state == NOTHING_HAPPENS)
00073                         {
00074                                 if(_view->isPointInside(X,Y))
00075                                 {
00076                                         _view->setState(HIGHLIGHTED);
00077                                 }
00078                                                 return true; // to avoid to redraw all if nothing
00079                         } // state
00080 
00081                         if( state==HIGHLIGHTED)
00082                         {
00083                                 if(!_view->isPointInside(X,Y))
00084                                 {
00085                                         _view->setState(NOTHING_HAPPENS);
00086                                 }
00087                         } // state
00088 
00089 
00090                         if ((state==DRAG) && (_isLeftClickDown==true) )
00091                         {
00092                             _objHasBeenMoved=true;
00093                         } // state
00094 
00095                         _model->notifyObservers(getId());
00096 
00097                 }
00098                 return true;
00099         }
00100 
00101         //=========================================================================
00102 
00103         bool GBlackBoxController::OnLeftButtonDown()
00104         {
00105                 _objHasBeenMoved = false;
00106                 _isLeftClickDown = true;
00107         bool ok=true;
00108                 
00109                 int X,Y;
00110                 wxVTKRenderWindowInteractor *_wxVTKiren;
00111                 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
00112                 _wxVTKiren->GetEventPosition( X , Y );
00113                 
00114                 
00115                 
00116                 int state  = _view->getState();
00117                 //Evaluate new state
00118                 
00119                 if(_view->isPointInside(X,Y))
00120                 
00121 //              if(state == HIGHLIGHTED)
00122 //EED3oct2010           if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
00123                 {
00124                     ok=false;
00125                         _view->setState(SELECTED);
00126                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
00127                 }
00128                 
00129       
00130                 int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
00131                 int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
00132                 ctrlkey = ctrlkey + shiftkey;
00133                 
00134                 
00135                 if ( (state==DRAG) && (ctrlkey==1) &&  (_view->isPointInside(X,Y)==true) )
00136                 {
00137                         _view->setState(NOTHING_HAPPENS);
00138                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
00139                 }
00140 
00141                 return ok;
00142         }
00143 
00144         //=========================================================================
00145 
00146         bool GBlackBoxController::OnLeftButtonUp()
00147         {
00148         _isLeftClickDown    = false;
00149                 int state           = _view->getState();
00150 
00151                 //Evaluate new state
00152 
00153 //EED Borrame
00154 //              int X,Y;
00155 //              wxVTKRenderWindowInteractor *wxVTKiren;
00156 //              wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
00157 //              wxVTKiren->GetEventPosition(X,Y);
00158 //              if(_isLeftClickDown)
00159 //              {
00160 //                      _isLeftClickDown=false;
00161 //                      if(_view->isPointInside(X,Y))
00162 //                      {
00163                                 // It is supposed that I'm always inside even if the box is in drag
00164 //                              _view->setState(SELECTED);
00165 //                              _model->notifyObservers(getId());
00166 //                      }
00167 //              }
00168 
00169 
00170 
00171                 int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
00172                 int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
00173                 ctrlkey = ctrlkey + shiftkey;
00174                 
00175                 
00176                 if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
00177                 {
00178                         _view->setState(NOTHING_HAPPENS);
00179                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
00180                 }
00181 
00182 
00183 
00184                 return true;
00185 
00186         }
00187 
00188         //=========================================================================
00189 
00190         bool GBlackBoxController::OnRightButtonUp()
00191         {
00192                 return true;
00193         }
00194 
00195         //=========================================================================
00196 
00197         bool GBlackBoxController::OnMiddleButtonDown()
00198         {
00199                 int X,Y;
00200                 wxVTKRenderWindowInteractor *wxVTKiren;
00201                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
00202                 wxVTKiren->GetEventPosition(X,Y);
00203 
00204 //              int state  = _view->getState();
00205 
00206                 //Evaluate new state
00207                 if(_view->isPointInside(X,Y))
00208                 {
00209                         GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
00210                         _view->setState(HIGHLIGHTED);
00211                         if(bbmodel->isExecutable())
00212                         {
00213                                 bbmodel->setExecutable(false);
00214                         }
00215                         else
00216                         {
00217                                 bbmodel->setExecutable(true);
00218                         }
00219                         bbmodel->notifyObservers(getId());
00220                 }
00221 
00222                 return true;
00223         }
00224 
00225         //=========================================================================
00226 
00227 }  // EO namespace bbtk
00228 
00229 // EOF
00230 

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