From 638f2cd85948ec10d3b30e1f68805ee0153c8813 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Mon, 3 May 2010 13:25:25 +0000 Subject: [PATCH] More actions added. Delete is now well done and the connection has to be created in the correct way .. if it doesn't happen, the connection is not drawn ... The code has to be organized --- .../GConnectorModel.cxx | 17 ++++ .../bbsKernelEditorGraphic/GConnectorModel.h | 1 + .../bbsKernelEditorGraphic/GPortModel.cxx | 1 + .../wxVtkSceneManager.cxx | 96 ++++++++++++++++++- .../wxVtkSceneManager.h | 3 - .../GBlackBoxController.cxx | 15 +-- .../GConnectorController.cxx | 13 ++- .../GConnectorController.h | 3 + .../GObjectController.h | 2 +- .../bbtkwxGUIEditorGraphicBBS.cxx | 2 +- .../wxBlackBoxEditionDialog.cxx | 7 +- 11 files changed, 140 insertions(+), 20 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx index 95f1b15..4b722db 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx @@ -135,6 +135,23 @@ namespace bbtk point->SetPoint(xCenter,yport,zCenter); } + //========================================================================= + + void GConnectorModel::disconnectConnection() + { + if(_startPort!=NULL) + { + _startPort->setConnected(false); + } + + if(_endPort!=NULL) + { + _endPort->setConnected(false); + } + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h index 65426a7..fde5eee 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h @@ -76,6 +76,7 @@ namespace bbtk GPortModel* getEndPort(); manualContourModel* getManualContourModel(); void updateStartEndPoints(); + void disconnectConnection(); private: diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx index d866736..fa20810 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx @@ -151,6 +151,7 @@ namespace bbtk void GPortModel::setConnected(bool value) { _isConnected=value; + notifyObservers(_objectId); } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 77da812..cab3936 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -47,7 +47,6 @@ namespace bbtk _numBoxes=0; _idManager=idManager; _baseView=baseView; - _idLastController=0; _startDragging=false; if( _baseView!=NULL ) @@ -515,6 +514,42 @@ namespace bbtk bool wxVtkSceneManager::OnLeftButtonDown() { + if(_worldState==INIT_CREATION_CONTOUR) + { + bool isOverPort=false; + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end() && isOverPort==false; ++it) + { + GObjectController *desc = it->second; + if(desc->getGObjectType()==GPORT) + { + GPortModel* portmod=(GPortModel*)desc->getModel(); + vtkGObjectView* portView=desc->getView(); + if(portmod->getPortType()==GINPUTPORT && portView->getState()==HIGHLIGHTED) + { + isOverPort=true; + } + } + } + + if(isOverPort==false) + { + _worldState=NOTHING_HAPPENS; + int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + connector->removeFromScene(); + unregisterController(connector); + _controllers.erase(lastId); + + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + desc->SetActive(true); + desc->getView()->setState(NOTHING_HAPPENS); + desc->getModel()->notifyObservers(_idManager); + } + } + } if(_selectedObjects.size()!=0) { @@ -558,6 +593,26 @@ namespace bbtk bool wxVtkSceneManager::OnRightButtonUp() { + if(_worldState==INIT_CREATION_CONTOUR) + { + _worldState=NOTHING_HAPPENS; + int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + connector->removeFromScene(); + unregisterController(connector); + _controllers.erase(lastId); + + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + desc->SetActive(true); + desc->getView()->setState(NOTHING_HAPPENS); + desc->getModel()->notifyObservers(_idManager); + } + } + + for (int i = 0; i < _selectedObjects.size(); i++) { int id = _selectedObjects[i]; @@ -590,9 +645,9 @@ namespace bbtk GObjectController *cont = it->second; int type = cont->getGObjectType(); - if(cont->getView()->isPointInside(X,Y)) + if(type==GBLACKBOX) { - if(type==GBLACKBOX) + if(cont->getView()->isPointInside(X,Y)) { for (int i=0; i<_selectedObjects.size(); i++) { @@ -653,18 +708,51 @@ namespace bbtk GBlackBoxModel *bbmod = (GBlackBoxModel*)control->getModel(); std::vector inputs = bbmod->getInputPorts(); + bool boxConnected = false; + + // Add box input controllers to be removed for(int i = 0;igetObjectId()); + controllersToRemove.push_back(inputs[i]->getObjectId()); + if(inputs[i]->isConnected()) + { + boxConnected = true; + } } std::vector outputs = bbmod->getOutputPorts(); + // Add box output controllers to be removed for(int i = 0;igetObjectId()); + if(outputs[i]->isConnected()) + { + boxConnected = true; + } + } + + // Add connection controllers to be removed + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + int type = cont->getGObjectType(); + if(type==GCONNECTOR) + { + GConnectorModel *conMod = (GConnectorModel*)cont->getModel(); + if(conMod->getStartPort()!=NULL && conMod->getStartPort()->getParentBox()->getObjectId() == bbmod->getObjectId()) + { + controllersToRemove.push_back(conMod->getObjectId()); + } + if(conMod->getEndPort()!=NULL && conMod->getEndPort()->getParentBox()->getObjectId() == bbmod->getObjectId()) + { + controllersToRemove.push_back(conMod->getObjectId()); + } + } } + // Add box controller to be removed controllersToRemove.push_back(bbmod->getObjectId()); } diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index a189fff..172aaf7 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -122,9 +122,6 @@ namespace bbtk wxGEditorTabPanel *_parent; - // Last controller created - int _idLastController; - // Id of the manager, the same of the panel int _idManager; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index cfdaa31..93e06fa 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -134,12 +134,6 @@ namespace bbtk bool GBlackBoxController::OnRightButtonUp() { - GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model; - if(bbmodel->isExecutable()) - { - bbmodel->setExecutable(false); - } - return true; } @@ -159,7 +153,14 @@ namespace bbtk { GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model; _view->setState(HIGHLIGHTED); - bbmodel->setExecutable(true); + if(bbmodel->isExecutable()) + { + bbmodel->setExecutable(false); + } + else + { + bbmodel->setExecutable(true); + } bbmodel->notifyObservers(getId()); } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx index 3f97b7c..30468e7 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx @@ -140,7 +140,7 @@ namespace bbtk wxVTKiren->GetEventPosition(X, Y); _controller->MouseClickRight(X,Y); - + } return true; } @@ -188,6 +188,17 @@ namespace bbtk } //========================================================================= + + void GConnectorController::removeFromScene() + { + GConnectorModel *conMod = (GConnectorModel*)_model; + conMod->disconnectConnection(); + + _controller->SetEditable(true); + _controller->DeleteContour(); + } + + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h index bc3308b..0d72239 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h @@ -44,6 +44,7 @@ Version: $Revision$ #define __GConnectorController_h__ //Includes same project +#include "GConnectorModel.h" #include "GObjectController.h" #include "manualConnectorContourView.h" #include "manualConnectorContourController.h" @@ -79,6 +80,8 @@ namespace bbtk manualConnectorContourController* getManualContourController(); void setManualContourController(manualConnectorContourController* controller); + virtual void removeFromScene(); + private: //Attributes diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h index ccbc264..915ffc8 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h @@ -77,7 +77,7 @@ namespace bbtk int getId(); void setId(int id); - void removeFromScene(); + virtual void removeFromScene(); private: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index ea40403..71ae3df 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -317,7 +317,7 @@ namespace bbtk #endif //command += ConfigurationFile::GetInstance().Get_bin_path(); - command +="C:/RaC/CREATIS/bbtkBIN/RelWithDebInfo//"; + command +="C:/temp/bbtkBIN/RelWithDebInfo//"; #ifdef MACOSX command += separator + "bbi.app/Contents/MacOS/bbi\" "; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx index b2c4701..a6af504 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx @@ -81,8 +81,8 @@ namespace bbtk for(int i = 0;igetBBTKName()),wxDefaultPosition,wxSize(100,20)); - wxStaticText *lblType = new wxStaticText(this, -1, std2wx(port->getBBTKType()),wxDefaultPosition,wxSize(230,20)); + wxStaticText *lblName = new wxStaticText(this, -1, std2wx(port->getBBTKName()),wxDefaultPosition,wxSize(100,25)); + wxStaticText *lblType = new wxStaticText(this, -1, std2wx(port->getBBTKType()),wxDefaultPosition,wxSize(250,25)); wxTextCtrl *txtValue = new wxTextCtrl(this, -1, _T(""),wxDefaultPosition,wxSize(90,25)); if(port->getValue()!="") @@ -100,10 +100,11 @@ namespace bbtk _lstNames.push_back(lblName); _lstTypes.push_back(lblType); _lstValues.push_back(txtValue); - + sizer->Add(lblName,1,wxEXPAND,5); sizer->Add(lblType,1,wxCENTRE|wxEXPAND,5); sizer->Add(txtValue,1,wxEXPAND,5); + } wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL); -- 2.45.1