]> Creatis software - bbtkGEditor.git/commitdiff
More actions added. Delete is now well done and the connection has to be created...
authorcorredor <>
Mon, 3 May 2010 13:25:25 +0000 (13:25 +0000)
committercorredor <>
Mon, 3 May 2010 13:25:25 +0000 (13:25 +0000)
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx

index 95f1b15e8d0bc96e3cef9cce381f4e8ee66f9f48..4b722db4889a55ad029ef170183d0e97deced97a 100644 (file)
@@ -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
index 65426a70131e8bcea2ee2cb0b8285458723ba9bf..fde5eeefd9fffa32104fc67c306a620d452b3c4c 100644 (file)
@@ -76,6 +76,7 @@ namespace bbtk
                GPortModel* getEndPort();               
                manualContourModel* getManualContourModel();
                void updateStartEndPoints();
+               void disconnectConnection();
                
        private:
 
index d866736e5f5a3d944a7cb6498a56369be273e404..fa208106e601938876cc21b4f7fb467c6fb7dec3 100644 (file)
@@ -151,6 +151,7 @@ namespace bbtk
        void GPortModel::setConnected(bool value)
        {
                _isConnected=value;
+               notifyObservers(_objectId);
        }
 
        //=========================================================================
index 77da812bdd22ef2b73ce6aadc0f0b39db3733761..cab3936f7976ff5f98d0e03977c28e1a31aa6af1 100644 (file)
@@ -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<int, GObjectController*>::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<int, GObjectController*>::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<GPortModel*> inputs = bbmod->getInputPorts();
                        
+                       bool boxConnected = false;
+
+                       // Add box input controllers to be removed
                        for(int i = 0;i<inputs.size();i++)
                        {
-                               controllersToRemove.push_back(inputs[i]->getObjectId());                                
+                               controllersToRemove.push_back(inputs[i]->getObjectId());
+                               if(inputs[i]->isConnected())
+                               {
+                                       boxConnected = true;
+                               }
                        }
 
                        std::vector<GPortModel*> outputs = bbmod->getOutputPorts();
 
+                       // Add box output controllers to be removed
                        for(int i = 0;i<outputs.size();i++)
                        {
                                controllersToRemove.push_back(outputs[i]->getObjectId());
+                               if(outputs[i]->isConnected())
+                               {
+                                       boxConnected = true;
+                               }
+                       }
+
+                       // Add connection controllers to be removed
+                       std::map<int, GObjectController*>::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());
                }
 
index a189fffddfc65168558cefd96736ed8a32a644c7..172aaf75a54f55e7c2d31519828e73f5407d670c 100644 (file)
@@ -122,9 +122,6 @@ namespace bbtk
 
                wxGEditorTabPanel *_parent;
 
-               // Last controller created
-               int _idLastController;
-
                // Id of the manager, the same of the panel
                int _idManager;
 
index cfdaa31c9517f4a210637b9e4277976d13a5f2db..93e06fa2fe1eec7e4595764be469d77281f2db6f 100644 (file)
@@ -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());
                }
                        
index 3f97b7c2a4433fee6af03b7b5833c1018e670664..30468e790f1772abddcc34c8b95e33cf04b5e560 100644 (file)
@@ -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
 
index bc3308b8e80ad06ac26022cecee1548d5199f811..0d72239b9c1b46f32d47342eedf66e2ef5bdc380 100644 (file)
@@ -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
index ccbc264993b68fd6b5be0951989fd0146f7c0307..915ffc8cd2215636465397459c148a8265040cef 100644 (file)
@@ -77,7 +77,7 @@ namespace bbtk
                int getId();
                void setId(int id);
                
-               void removeFromScene();
+               virtual void removeFromScene();
 
        private:
 
index ea40403b04a47ffc5115bd07cbde665ae21c743f..71ae3dff5a6a99083420aa90ed5c5971e20cbf4c 100644 (file)
@@ -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\" ";
index b2c470147e3301f10f0b906bcf7d35d5780660b5..a6af50463259997f3ff631769dc3c370e0983cec 100644 (file)
@@ -81,8 +81,8 @@ namespace bbtk
                for(int i = 0;i<lstInputs.size();i++)
                {
                        GPortModel* port = lstInputs[i];
-                       wxStaticText *lblName = new wxStaticText(this, -1, std2wx(port->getBBTKName()),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);