From: Eduardo DAVILA Date: Tue, 20 Sep 2022 14:08:26 +0000 (+0200) Subject: #3252Select mechanism of boxes X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d85b4a21b4e3544ff4e1a89a77af9de2aaaee158;p=bbtkGEditor.git #3252Select mechanism of boxes --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx index e4b77ad..70c7ed4 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx @@ -137,7 +137,6 @@ namespace bbtk } //========================================================================= - bool GObjectModel::isPointInside(double x,double y, double z)//virtual { if(x>=_xInic && x<=_xFin && y<=_yInic && y>=_yFin) @@ -150,8 +149,20 @@ namespace bbtk } } - //========================================================================= + //========================================================================= + bool GObjectModel::isBoxInsideRectangle(double x1,double y1, double z1,double x2,double y2, double z2)//virtual + { + if(_xInic>x1 && _xInicx1 && _xFiny1 && _yInicy1 && _yFinGetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); _wxVTKiren->GetEventPosition( X , Y ); - int state = _view->getState(); - //Evaluate new state - if(state == NOTHING_HAPPENS) { if(_view->isPointInside(X,Y)) @@ -102,7 +99,6 @@ namespace bbtk } return true; // to avoid to redraw all if nothing } // state - if( state==HIGHLIGHTED) { if(!_view->isPointInside(X,Y)) @@ -110,67 +106,57 @@ namespace bbtk _view->setState(NOTHING_HAPPENS); } } // state - - - if ((state==DRAG) && (_isLeftClickDown==true) ) - { - _objHasBeenMoved=true; - } // state - +// if ((state==DRAG) && (_isLeftClickDown==true) ) +// { +// _objHasBeenMoved=true; +// } // state _model->notifyObservers(getId()); - } return true; } +*/ //========================================================================= +/* bool GBlackBoxController::OnLeftButtonDown() { - _objHasBeenMoved = false; +// _objHasBeenMoved = false; _isLeftClickDown = true; bool ok=true; - int X,Y; crea::wxVTKRenderWindowInteractor *_wxVTKiren; _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); _wxVTKiren->GetEventPosition( X , Y ); - - - int state = _view->getState(); //Evaluate new state - if(_view->isPointInside(X,Y)) - -// if(state == HIGHLIGHTED) -//EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) ) - - if(state == SELECTED) - { - _view->setState(NOTHING_HAPPENS); - _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); - } else { - ok=false; - _view->setState(SELECTED); - _model->notifyObservers(getId(),ADD_TO_SELECTED); - } - - + { + // if(state == HIGHLIGHTED) + //EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) ) + if(state == SELECTED) + { + _view->setState(NOTHING_HAPPENS); + _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); + } else { + ok=false; + _view->setState(SELECTED); + _model->notifyObservers(getId(),ADD_TO_SELECTED); + } + } // EED 2022-09-16 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey(); int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); ctrlkey = ctrlkey + shiftkey; - - if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) ) { _view->setState(NOTHING_HAPPENS); _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); } - return ok; } +*/ +/* //========================================================================= bool GBlackBoxController::OnLeftButtonUp() { @@ -187,6 +173,7 @@ namespace bbtk // } return true; } +*/ //========================================================================= bool GBlackBoxController::OnRightButtonUp() diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h index c7a3a01..4d41f75 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h @@ -79,43 +79,27 @@ Version: $Revision$ //Includes std #include - namespace bbtk { - class GBlackBoxController : public GBoxController { - public: - //Constructors GBlackBoxController(); ~GBlackBoxController(); - //Public methods - - - private: - //Attributes - bool _objHasBeenMoved; - +// bool _objHasBeenMoved; //Private Methods - protected: - // Methods from InteractorStyleMaracas - virtual bool OnMouseMove(); - virtual bool OnLeftButtonDown(); - virtual bool OnLeftButtonUp(); +// virtual bool OnMouseMove(); +// virtual bool OnLeftButtonDown(); +// virtual bool OnLeftButtonUp(); virtual bool OnMiddleButtonDown(); virtual bool OnRightButtonUp(); - - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx index ad8024d..ba87c38 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx @@ -80,20 +80,17 @@ namespace bbtk } //========================================================================= +/* bool GBoxController::OnMouseMove() { - if ( _vtkInteractorStyleBaseView!=NULL) { int X,Y; crea::wxVTKRenderWindowInteractor *_wxVTKiren; _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); _wxVTKiren->GetEventPosition( X , Y ); - int state = _view->getState(); - //Evaluate new state - if(state == NOTHING_HAPPENS) { if(_view->isPointInside(X,Y)) @@ -108,31 +105,107 @@ namespace bbtk _view->setState(NOTHING_HAPPENS); } } - _model->notifyObservers(getId()); - } return true; } + */ + +//========================================================================= +bool GBoxController::OnMouseMove() +{ + if ( _vtkInteractorStyleBaseView!=NULL) + { + int X,Y; + crea::wxVTKRenderWindowInteractor *_wxVTKiren; + _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + _wxVTKiren->GetEventPosition( X , Y ); + int state = _view->getState(); + //Evaluate new state + if(state == NOTHING_HAPPENS) + { + if(_view->isPointInside(X,Y)) + { + _view->setState(HIGHLIGHTED); + } + return true; // to avoid to redraw all if nothing + } // state + if( state==HIGHLIGHTED) + { + if(!_view->isPointInside(X,Y)) + { + _view->setState(NOTHING_HAPPENS); + } + } // state +// if ((state==DRAG) && (_isLeftClickDown==true) ) +// { +// _objHasBeenMoved=true; +// } // state + _model->notifyObservers(getId()); + } + return true; +} + + + + //========================================================================= +/* bool GBoxController::OnLeftButtonDown() { bool ok=true; int state = _view->getState(); - //Evaluate new state if(state == HIGHLIGHTED) { - ok=false; - _isLeftClickDown=true; + ok = false; + _isLeftClickDown = true; _view->setState(SELECTED); _model->notifyObservers(getId(),ADD_TO_SELECTED); } return ok; - } +*/ + +bool GBoxController::OnLeftButtonDown() +{ +// _objHasBeenMoved = false; + _isLeftClickDown = true; + bool ok=true; + int X,Y; + crea::wxVTKRenderWindowInteractor *_wxVTKiren; + _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + _wxVTKiren->GetEventPosition( X , Y ); + int state = _view->getState(); + //Evaluate new state + if(_view->isPointInside(X,Y)) + { +// if(state == HIGHLIGHTED) +//EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) ) + if(state == SELECTED) + { + _view->setState(NOTHING_HAPPENS); + _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); + } else { + ok=false; + _view->setState(SELECTED); + _model->notifyObservers(getId(),ADD_TO_SELECTED); + } + } // EED 2022-09-16 + int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey(); + int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); + ctrlkey = ctrlkey + shiftkey; + if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) ) + { + _view->setState(NOTHING_HAPPENS); + _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); + } + return ok; +} + + //========================================================================= @@ -143,6 +216,7 @@ namespace bbtk wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X,Y); + /* int state = _view->getState(); //Evaluate new state if(_isLeftClickDown) @@ -155,6 +229,7 @@ namespace bbtk _model->notifyObservers(getId()); } } +*/ return true; } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx index 19994d9..55f011c 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx @@ -87,36 +87,44 @@ namespace bbtk //========================================================================= - bool GObjectController::OnMouseMove( ) { + bool GObjectController::OnMouseMove( ) + { int X , Y ; crea::wxVTKRenderWindowInteractor *_wxVTKiren ; _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView( )->GetWxVTKRenderWindowInteractor( ) ; _wxVTKiren->GetEventPosition( X , Y ) ; int state = _view->getState( ) ; - //Evaluate new state - if ( state == NOTHING_HAPPENS ) { - if ( _view->isPointInside( X , Y ) ) { + if ( state == NOTHING_HAPPENS ) + { + if ( _view->isPointInside( X , Y ) ) + { _view->setState( HIGHLIGHTED ) ; } } - if ( state == HIGHLIGHTED ) { - if ( !_view->isPointInside( X , Y ) ) { + if ( state == HIGHLIGHTED ) + { + if ( !_view->isPointInside( X , Y ) ) + { _view->setState( NOTHING_HAPPENS ) ; } } // JGRR & CM WH - if ( state == POSSIBLE_CONNECTION ) { - if ( _view->isPointInside( X , Y ) ) { + if ( state == POSSIBLE_CONNECTION ) + { + if ( _view->isPointInside( X , Y ) ) + { _view->setState( SELECTED_POSSIBLE_CONNECTION ) ; } } - if ( state == SELECTED_POSSIBLE_CONNECTION ) { - if ( !_view->isPointInside( X , Y ) ) { + if ( state == SELECTED_POSSIBLE_CONNECTION ) + { + if ( !_view->isPointInside( X , Y ) ) + { _view->setState( POSSIBLE_CONNECTION ) ; } } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index d9d784e..d7306b7 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -140,6 +140,18 @@ namespace bbtk return _model->isPointInside(xx,yy,zz); } + //========================================================================= + bool vtkGObjectView::isBoxInsideRectangle(int X1,int Y1, int X2, int Y2) //virtual + { + // RaC In the actual version, always z=GPOSITION_Z + double xx1=X1,yy1=Y1,zz1=GPOSITION_Z; + _baseView->TransCoordScreenToWorld(xx1,yy1,zz1); + double xx2=X2,yy2=Y2,zz2=GPOSITION_Z; + _baseView->TransCoordScreenToWorld(xx2,yy2,zz2); + + return _model->isBoxInsideRectangle(xx1,yy1,zz1, xx2,yy2,zz2 ); + } + //========================================================================= void vtkGObjectView::moveObject(int X,int Y) //virtual { diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h index 5b096af..0ad4976 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h @@ -106,6 +106,8 @@ namespace bbtk // Method to force a vtk refresh to the list of controllers of the wxVtkBaseView void setRefreshWaiting(); virtual bool isPointInside(int X,int Y); + virtual bool isBoxInsideRectangle(int X1,int Y1, int X2, int Y2) ; + virtual void moveObject(int X, int Y); virtual void removeFromScene(); virtual void update(int idController,int command); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index a75362f..34125b6 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -160,8 +160,8 @@ namespace bbtk result = strtok( NULL, delims ); boxType += result; */ - printf("EED wxGEditorTabPanel::OnDropText <%s> length %d %d \n", stdData.c_str(), stdData.length(), data.Len() ); - printf("EED wxGEditorTabPanel::OnDropText <%s> wxString\n",(const char*)data.mb_str() ); +// printf("EED wxGEditorTabPanel::OnDropText <%s> length %d %d \n", stdData.c_str(), stdData.length(), data.Len() ); +// printf("EED wxGEditorTabPanel::OnDropText <%s> wxString\n",(const char*)data.mb_str() ); if ( _panelsManager->TryToOpenScriptApplication(packageName,boxType) == false ) { _sceneManager->createGBlackBox(x,y,packageName, boxType); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index e839044..1d8dc29 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -110,6 +110,11 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView } _idConnectionInCreation = -1; _contLastId = 0; + + selectRegionX1 = -1; + selectRegionY1 = -1; + selectRegionX2 = -1; + selectRegionY2 = -1; } //========================================================================= @@ -251,29 +256,28 @@ std::string wxVtkSceneManager::generateANewNameForABox() { //========================================================================= -std::string wxVtkSceneManager::findANewNameForABox() { +std::string wxVtkSceneManager::findANewNameForABox() +{ std::string boxname = generateANewNameForABox(); - - while (boxExist(boxname) == true) { + while (boxExist(boxname) == true) + { boxname = generateANewNameForABox(); } // while - return boxname; } //========================================================================= void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable, double xEn, - double yEn, double zEn) { + double yEn, double zEn) +{ GObjectController *cont = _controllers[idBox]; GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel(); bbmod->setBBTKName(name); bbmod->setInicPoint(xIn, yIn, zIn); bbmod->setFinalPoint(xEn, yEn, zEn); bbmod->setExecutable(boxExecutable); - bbmod->notifyObservers(_idManager); - } //========================================================================= @@ -831,16 +835,19 @@ bool wxVtkSceneManager::OnMouseMove() { int X, Y; bool okStatusMessage = false; - bool okPortMessage = false; + bool okPortMessage = false; crea::wxVTKRenderWindowInteractor *wxVTKiren; wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X, Y); - if (_worldState == DRAG_OBJECTS) { - for (int i = 0; i < (int) _selectedObjects.size(); i++) { + if (_worldState == DRAG_OBJECTS) + { + for (int i = 0; i < (int) _selectedObjects.size(); i++) + { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; - if (_startDragging) { + if (_startDragging) + { cont->getView()->setStartDragging(true); } cont->getView()->moveObject(X, Y); @@ -850,20 +857,23 @@ bool wxVtkSceneManager::OnMouseMove() std::map::iterator it; - for (it = _controllers.begin(); it != _controllers.end(); ++it) { + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { GObjectController *desc = it->second; - if (desc->getGObjectType() == GCONNECTOR) { + if (desc->getGObjectType() == GCONNECTOR) + { vtkGConnectorView* vconn = (vtkGConnectorView*) desc->getView(); vconn->updateStartEndPoints(); - } - } + } // if + } // for _startDragging = false; } else if (_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR) { std::map::iterator it; double px, py, pz; - for (it = _controllers.begin(); it != _controllers.end(); ++it) { + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { GObjectController *desc = it->second; int type = desc->getGObjectType(); int state = desc->getView()->getState(); @@ -912,12 +922,55 @@ bool wxVtkSceneManager::OnMouseMove() _bugTextActor_status= 2; } // _bugTextActor_tex _bugTextActor_text = desc->getStatusText(); - } // if GPORT - } //if state + } // if state } // for controllers it - } - if (okStatusMessage == false) + } else if (_worldState == SELECTING_BOXES ) { + + + int sX1,sX2,sY1,sY2; + if (X::iterator it; + GObjectController *desc; + int type; + int state; + int id; + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { + desc = it->second; + type = desc->getGObjectType(); + state = desc->getView()->getState(); + + if ( (type==GBLACKBOX) || (type==GCOMPLEXINPUTPORT) || (type==GCOMPLEXOUTPUTPORT) ) + { + if ( desc->getView()->isBoxInsideRectangle( sX1 , sY1,sX2 , sY2 ) ) + { + desc->getView()->setState(SELECTED); + id = desc->getModel()->getObjectId(); + desc->getModel()->notifyObservers( id , ADD_TO_SELECTED ); + } + } // if type == 1 + } // for + + + } // if _worldState + + if (okStatusMessage == false) { updateStatusBar(""); } @@ -961,42 +1014,49 @@ bool wxVtkSceneManager::OnLeftButtonDown() } // if } // for - if (isOverPort == false) { CancelConnection(); UnSelectBlackBoxes(); } // isOverPort - - } else { //_worldState - - _worldState = DRAG_OBJECTS; - _startDragging = true; - - int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey(); - int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); - ctrlkey = ctrlkey + shiftkey; - - GObjectController *cont = GetGBlackBoxControlerPointedByMouse(); - - if (cont != NULL) { + _startDragging = true; + int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey(); + int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); + ctrlkey = ctrlkey + shiftkey; + GObjectController *cont = GetGBoxControlerPointedByMouse(); + if (cont != NULL) + { + _worldState = DRAG_OBJECTS; int state = cont->getView()->getState(); - if ((ctrlkey == 0) && (state == HIGHLIGHTED)) { + if ((ctrlkey == 0) && (state == HIGHLIGHTED)) + { UnSelectBlackBoxes(); - } + } // if ctrlkey state } else { UnSelectBlackBoxes(); // EED 12/07/2012 - } - for (int i = 0; i < (int) _selectedObjects.size(); i++) { - int id = _selectedObjects[i]; - GObjectController *cont = _controllers[id]; - cont->getView()->setState(DRAG); - cont->getModel()->notifyObservers(_idManager); - } // for - } // if _selectedObjects.size - + _worldState = SELECTING_BOXES; + } // if cont + + if (_worldState==SELECTING_BOXES) + { + crea::wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(selectRegionX1, selectRegionY1); + } // if _worldState SELECTING_BOXES + + if (_worldState==DRAG_OBJECTS) + { + for (int i = 0; i < (int) _selectedObjects.size(); i++) + { + int id = _selectedObjects[i]; + GObjectController *cont = _controllers[id]; + cont->getView()->setState(DRAG); + cont->getModel()->notifyObservers(_idManager); + } // for + } // if _worldState DRAG_OBJECTS + } // if _selectedObjects.size return true; } @@ -1004,10 +1064,11 @@ bool wxVtkSceneManager::OnLeftButtonDown() bool wxVtkSceneManager::OnLeftButtonUp() { - if (_worldState == DRAG_OBJECTS) { + if ( (_worldState == DRAG_OBJECTS) || (_worldState == SELECTING_BOXES) ) + { _worldState = NOTHING_HAPPENS; - - for (int i = 0; i < (int) _selectedObjects.size(); i++) { + for (int i = 0; i < (int) _selectedObjects.size(); i++) + { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; cont->getView()->setState(SELECTED); @@ -1043,7 +1104,6 @@ void wxVtkSceneManager::CancelConnection() } //========================================================================= - bool wxVtkSceneManager::OnRightButtonUp() { if (_worldState == INIT_CREATION_CONTOUR) @@ -1055,43 +1115,37 @@ bool wxVtkSceneManager::OnRightButtonUp() } ///JLGR 21-05-2012 - -bool wxVtkSceneManager::OnMiddleButtonDown() { - - +//========================================================================= +bool wxVtkSceneManager::OnMiddleButtonDown() +{ this->_vtkInteractorStyleBaseView->StartPan(); - return true; - } - -bool wxVtkSceneManager::OnMiddleButtonUp() { - +} +//========================================================================= +bool wxVtkSceneManager::OnMiddleButtonUp() +{ this->_vtkInteractorStyleBaseView->EndPan(); - - return true; - } - +} //========================================================================= - -GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() { +GObjectController *wxVtkSceneManager::GetGBoxControlerPointedByMouse() +{ GObjectController *result = NULL; int X, Y; crea::wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren - = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X, Y); - std::map::iterator it; - - for (it = _controllers.begin(); it != _controllers.end(); ++it) { + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { GObjectController *cont = it->second; int type = cont->getGObjectType(); - - if (cont->getView()->isPointInside(X, Y) == true) { - if (type == GBLACKBOX) { + if (cont->getView()->isPointInside(X, Y) == true) + { + if ( (type == GBLACKBOX) || (type == GCOMPLEXINPUTPORT) || (type == GCOMPLEXOUTPUTPORT)) + { result = cont; } // if type } // if isPointInside @@ -1100,8 +1154,10 @@ GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() { } //========================================================================= -void wxVtkSceneManager::UnSelectBlackBoxes() { - for (int i = 0; i < (int) _selectedObjects.size(); i++) { +void wxVtkSceneManager::UnSelectBlackBoxes() +{ + for (int i = 0; i < (int) _selectedObjects.size(); i++) + { int id = _selectedObjects[i]; GObjectController* control = _controllers[id]; control->getView()->setState(NOTHING_HAPPENS); @@ -1111,41 +1167,40 @@ void wxVtkSceneManager::UnSelectBlackBoxes() { } //========================================================================= -bool wxVtkSceneManager::OnLeftDClick() { - GObjectController *cont = GetGBlackBoxControlerPointedByMouse(); - if (cont != NULL) { - UnSelectBlackBoxes(); - _parent->editBlackBox((GBlackBoxModel*) cont->getModel()); - } +bool wxVtkSceneManager::OnLeftDClick() +{ + GObjectController *cont = GetGBoxControlerPointedByMouse(); + if (cont != NULL) + { + int type = cont->getGObjectType(); + if (type==GBLACKBOX) + { + UnSelectBlackBoxes(); + _parent->editBlackBox((GBlackBoxModel*) cont->getModel()); + } // if type + } // if cont return true; } //========================================================================= - bool wxVtkSceneManager::OnChar() { bool ok=false; bool oktmp; char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode(); - int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); - + int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); // KeyCode 127 : Delete Key // KeyCode 8 : Backspace Key - - if (keyCode == 8 || keyCode == 127 || keyCode == 27) { if (_worldState == INIT_CREATION_CONTOUR) { CancelConnection(); - UnSelectBlackBoxes(); - } + UnSelectBlackBoxes(); + } // if _worldState } - - if (keyCode == 8 || keyCode == 127) { - for (int i = 0; i < (int) _selectedObjects.size(); i++) { int id = _selectedObjects[i]; @@ -1160,7 +1215,6 @@ bool wxVtkSceneManager::OnChar() if (ok) _selectedObjects.clear(); _parent->saveTempandUpdate("delete object"); }// if keyCode - // Duplicate ctrlkey+=keyCode; if(ctrlkey==5){ @@ -1174,28 +1228,26 @@ bool wxVtkSceneManager::OnChar() }else{ std::cout<<"No objects to copy\n"; } // _selectedObjects.size - } // ctrlkey 5 - + } // ctrlkey 5 return true; } //========================================================================= - -void wxVtkSceneManager::AddControlerToBeRemove( - std::vector *controllersToRemove, int id) { - +void wxVtkSceneManager::AddControlerToBeRemove( std::vector *controllersToRemove, int id) +{ int i; bool ok = true; - for (i = 0; i < (int) controllersToRemove->size(); i++) { - if (id == (*controllersToRemove)[i]) { + for (i = 0; i < (int) controllersToRemove->size(); i++) + { + if (id == (*controllersToRemove)[i]) + { ok = false; - } - } - - if (ok == true) { + } // if id + } // for i + if (ok == true) + { controllersToRemove->push_back(id); - } - + } //if ok } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index c5cb8cb..be2519e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -290,8 +290,14 @@ namespace bbtk std::string LineNumber(bool withLineNumber, int &value); int GetIndexInSelected(int idControler); void UnSelectBlackBoxes(); - GObjectController *GetGBlackBoxControlerPointedByMouse(); + GObjectController *GetGBoxControlerPointedByMouse(); void CancelConnection(); + + int selectRegionX1; + int selectRegionY1; + int selectRegionX2; + int selectRegionY2; + protected: };