X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FwxVtkSceneManager.cxx;h=78ece891bb13c29bcdf5cd1ba7c2fc752074978e;hb=50851761f4216d932217db8e8fe56dd5aac6b0fb;hp=daa6327c157cceea4e7cd481750fa60fa7654e82;hpb=eaf825847b9ac4bd762deafa59a7df1c2ceba433;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index daa6327..78ece89 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -41,32 +41,32 @@ namespace bbtk //========================================================================= - wxVtkSceneManager::wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView,int idManager) + wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager) { + _parent = parent; _numBoxes=0; _idManager=idManager; _baseView=baseView; _idLastController=0; + _startDragging=false; if( _baseView!=NULL ) { - _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(parent); - registerController(this); + _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent); configureBaseView(); _worldState=NOTHING_HAPPENS; + registerController(this); } - } - //========================================================================= void wxVtkSceneManager::disconnectDrop() { _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL); - } + } //========================================================================= @@ -141,6 +141,7 @@ namespace bbtk model->setBBTKName(arraystring); model->setBBTKType(boxName); + model->setBBTKPackage(packageName); model->addObserver(view); model->addObserver(this); @@ -300,6 +301,7 @@ namespace bbtk connectorcontroller->setManualContourController(manContourControl); connectorModel->setManualContourModel(manContourModel); connectorView->setManualContourView(manContourView); + connectorView->setModel(connectorModel); connectorcontroller->setModelAndView(connectorModel,connectorView); int newId = _controllers.size(); @@ -333,6 +335,58 @@ namespace bbtk bool wxVtkSceneManager::OnMouseMove() { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + + if(_worldState == DRAG_OBJECTS) + { + for (int i=0; i<_selectedObjects.size(); i++) + { + int id = _selectedObjects[i]; + GObjectController* cont = _controllers[id]; + if(_startDragging) + { + cont->getView()->setStartDragging(true); + } + cont->getView()->moveObject(X,Y); + cont->getView()->setState(DRAG); + cont->getModel()->notifyObservers(_idManager); + } + + std::map::iterator it; + + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + if(desc->getGObjectType()==GCONNECTOR) + { + GConnectorView* vconn = (GConnectorView*)desc->getView(); + vconn->updateStartEndPoints(); + } + } + + _startDragging=false; + + } + else if(_worldState == NOTHING_HAPPENS) + { + std::map::iterator it; + + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + if(desc->getGObjectType()==GBLACKBOX && desc->getView()->getState() == HIGHLIGHTED) + { + GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel(); + _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType()); + } + } + } + + return true; } @@ -340,71 +394,167 @@ namespace bbtk void wxVtkSceneManager::update(int idController,int command) { - - if(command == INIT_CREATION_CONTOUR) - { - GObjectController* cont = _controllers[idController]; - GPortModel* startOutputPort = (GPortModel*)cont->getModel(); - createGConnector(startOutputPort); - - // The last one is the controller of the connector - for(int i=0;i<_controllers.size()-1;i++) + if(command != NO_COMMAND) + { + if(command == ADD_TO_SELECTED) { - GObjectController* cont = _controllers[i]; - if(cont->getGObjectType() == GPORT ) + GObjectController* cont = _controllers[idController]; + + bool foundID=false; + for (int i=0; i<_selectedObjects.size() && foundID==false; i++) { - GPortModel* port = (GPortModel*)cont->getModel(); - if(port->getPortType()==GINPUTPORT) + int id = _selectedObjects[i]; + if(id==idController) { - cont->SetActive(true); + foundID = true; + } + } + if(!foundID) + { + int id = idController; + _selectedObjects.push_back(id); + } + + } + else if(command == INIT_CREATION_CONTOUR) + { + _worldState = INIT_CREATION_CONTOUR; + GObjectController* cont = _controllers[idController]; + GPortModel* startOutputPort = (GPortModel*)cont->getModel(); + + + // The last one is the controller of the connector + for(int i=0;i<_controllers.size();i++) + { + GObjectController* cont = _controllers[i]; + if(cont->getGObjectType() == GPORT ) + { + GPortModel* port = (GPortModel*)cont->getModel(); + if(port->getPortType()==GINPUTPORT) + { + cont->SetActive(true); + } + else + { + cont->getView()->setState(NOTHING_HAPPENS); + cont->getModel()->notifyObservers(_idManager); + cont->SetActive(false); + } } else { cont->getView()->setState(NOTHING_HAPPENS); + cont->getModel()->notifyObservers(_idManager); cont->SetActive(false); - } + } } - else + + _selectedObjects.clear(); + + createGConnector(startOutputPort); + + } + else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR) + { + _worldState = NOTHING_HAPPENS; + int id = _controllers.size()-1; + GObjectController* cont = _controllers[id]; + GConnectorModel* modelContour = (GConnectorModel*)cont->getModel(); + + GObjectController* finPort = _controllers[idController]; + if(finPort->getGObjectType() == GPORT) + { + GPortModel* modelPort = (GPortModel*)finPort->getModel(); + modelContour->setEndPort(modelPort); + } + + manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController(); + manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour(); + connView->Refresh(); + + for(int i=0;i<_controllers.size();i++) { - cont->getView()->setState(NOTHING_HAPPENS); - cont->SetActive(false); - } + GObjectController* cont = _controllers[i]; + if(cont->getView()!=NULL) + { + cont->getView()->setState(NOTHING_HAPPENS); + cont->getModel()->notifyObservers(_idManager); + } + cont->SetActive(true); + } } - _worldState = CREATING_CONTOUR; } - else if(command == FIN_CREATION_CONTOUR && _worldState == CREATING_CONTOUR) + } + + //========================================================================= + + + bool wxVtkSceneManager::OnLeftButtonDown() + { + + if(_selectedObjects.size()!=0) { - - _worldState = NOTHING_HAPPENS; - int id = _controllers.size()-1; - GObjectController* cont = _controllers[id]; - GConnectorModel* modelContour = (GConnectorModel*)cont->getModel(); + _worldState = DRAG_OBJECTS; + _startDragging = true; - GObjectController* finPort = _controllers[idController]; - if(finPort->getGObjectType() == GPORT) + for (int i = 0; i < _selectedObjects.size(); i++) { - GPortModel* modelPort = (GPortModel*)finPort->getModel(); - modelContour->setEndPort(modelPort); - } + int id = _selectedObjects[i]; + GObjectController* cont = _controllers[id]; + cont->getView()->setState(DRAG); + cont->getModel()->notifyObservers(_idManager); + } + } + + + + return true; + } - manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController(); - manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour(); - connView->Refresh(); + //========================================================================= + + bool wxVtkSceneManager::OnLeftButtonUp() + { + if(_worldState == DRAG_OBJECTS) + { + _worldState = NOTHING_HAPPENS; - for(int i=0;i<_controllers.size();i++) + for (int i = 0; i < _selectedObjects.size(); i++) { - GObjectController* cont = _controllers[i]; - if(cont->getView()!=NULL) - { - cont->getView()->setState(NOTHING_HAPPENS); - } - cont->SetActive(true); + int id = _selectedObjects[i]; + GObjectController* cont = _controllers[id]; + cont->getView()->setState(SELECTED); + cont->getModel()->notifyObservers(_idManager); } } + return true; + } + + //========================================================================= + + bool wxVtkSceneManager::OnRightButtonUp() + { + for (int i = 0; i < _selectedObjects.size(); i++) + { + int id = _selectedObjects[i]; + GObjectController* cont = _controllers[id]; + cont->SetActive(true); + cont->getView()->setState(NOTHING_HAPPENS); + cont->getModel()->notifyObservers(_idManager); + } + + _selectedObjects.clear(); + + return true; } //========================================================================= + void wxVtkSceneManager::displayBlackBoxInfo(std::string packageName, std::string boxName) + { + _parent->displayBlackBoxInfo(packageName,boxName); + } + } // EO namespace bbtk // EOF