GBlackBoxController.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00071
00072 if(state == NOTHING_HAPPENS)
00073 {
00074 if(_view->isPointInside(X,Y))
00075 {
00076 _view->setState(HIGHLIGHTED);
00077 }
00078 return true;
00079 }
00080
00081 if( state==HIGHLIGHTED)
00082 {
00083 if(!_view->isPointInside(X,Y))
00084 {
00085 _view->setState(NOTHING_HAPPENS);
00086 }
00087 }
00088
00089
00090 if ((state==DRAG) && (_isLeftClickDown==true) )
00091 {
00092 _objHasBeenMoved=true;
00093 }
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
00118
00119 if(_view->isPointInside(X,Y))
00120
00121
00122
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
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
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
00205
00206
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 }
00228
00229
00230