00001 /*========================================================================= 00002 Program: bbtk 00003 Module: $RCSfile: GBoxController.cxx,v $ 00004 Language: C++ 00005 Date: $Date: 2012/05/22 15:13:36 $ 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 "GBoxController.h" 00038 00039 #ifdef _DEBUG 00040 #define new DEBUG_NEW 00041 #endif 00042 namespace bbtk 00043 { 00044 00045 00046 //========================================================================= 00047 GBoxController::GBoxController() 00048 { 00049 00050 } 00051 00052 //========================================================================= 00053 GBoxController::~GBoxController() 00054 { 00055 } 00056 //========================================================================= 00057 00058 bool GBoxController::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 } 00079 if( state==HIGHLIGHTED) 00080 { 00081 if(!_view->isPointInside(X,Y)) 00082 { 00083 _view->setState(NOTHING_HAPPENS); 00084 } 00085 } 00086 00087 _model->notifyObservers(getId()); 00088 00089 } 00090 return true; 00091 } 00092 00093 //========================================================================= 00094 00095 bool GBoxController::OnLeftButtonDown() 00096 { 00097 bool ok=true; 00098 printf("EED GBoxController::OnLeftButtonDown \n"); 00099 int state = _view->getState(); 00100 00101 //Evaluate new state 00102 if(state == HIGHLIGHTED) 00103 { 00104 ok=false; 00105 _isLeftClickDown=true; 00106 _view->setState(SELECTED); 00107 _model->notifyObservers(getId(),ADD_TO_SELECTED); 00108 } 00109 return ok; 00110 00111 } 00112 00113 //========================================================================= 00114 00115 bool GBoxController::OnLeftButtonUp() 00116 { 00117 int X,Y; 00118 wxVTKRenderWindowInteractor *wxVTKiren; 00119 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); 00120 wxVTKiren->GetEventPosition(X,Y); 00121 00122 int state = _view->getState(); 00123 //Evaluate new state 00124 if(_isLeftClickDown) 00125 { 00126 _isLeftClickDown=false; 00127 if(_view->isPointInside(X,Y)) 00128 { 00129 // It is supposed that I'm always inside even if the box is in drag 00130 _view->setState(SELECTED); 00131 _model->notifyObservers(getId()); 00132 } 00133 } 00134 return true; 00135 00136 } 00137 00138 //========================================================================= 00139 00140 bool GBoxController::OnRightButtonUp() 00141 { 00142 return true; 00143 } 00144 00145 //========================================================================= 00146 00147 bool GBoxController::OnMiddleButtonDown() 00148 { 00149 return true; 00150 } 00151 00152 //========================================================================= 00153 00154 } // EO namespace bbtk 00155 00156 // EOF 00157