]> Creatis software - bbtkGEditor.git/commitdiff
The creation of a panel which enables the user to set in a basic way the values of...
authorcorredor <>
Wed, 28 Apr 2010 13:24:57 +0000 (13:24 +0000)
committercorredor <>
Wed, 28 Apr 2010 13:24:57 +0000 (13:24 +0000)
15 files changed:
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h

index cffd4b8a6ffc61c9b13a2a32445f235875d24adf..f35cda172d483c4e08a45fe2fae2e09c065fccfb 100644 (file)
@@ -163,7 +163,13 @@ namespace bbtk
        }
 
        //=========================================================================
-       
+
+       void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
+       {
+               _inputs[pos]->setValue(value);
+       }
+
+       //=========================================================================     
 
 
 }  // EO namespace bbtk
index 000950c93a474d250142468763fa4bd321aa788d..c766dba08a26d75bcad5c949dd9213d80010ac24 100644 (file)
@@ -88,6 +88,8 @@ namespace bbtk
                std::vector<GPortModel*> getInputPorts();
                std::vector<GPortModel*> getOutputPorts();
 
+               void setValueToInputPort(int pos,std::string value);
+
        private:
 
                //Private Attributes
index 161efa7cc303f5f6df0f4e7e632c77c6640fc508..d866736e5f5a3d944a7cb6498a56369be273e404 100644 (file)
@@ -47,6 +47,8 @@ namespace bbtk
                _portType=-1;
                _posInBox=0;
                _isConnected=false;
+               _value="";
+               _isValueSet=false;
        }
 
        //=========================================================================
@@ -112,13 +114,18 @@ namespace bbtk
                temp+=" Type:";
                temp+=_bbtkType;
                temp+=" Box:";
-               temp+=_parentBox->getBBTKType();                
+               temp+=_parentBox->getBBTKType();
                if(_portType==GOUTPUTPORT)
                {
                        temp+=" [Output Port]";
                }
                else if(_portType==GINPUTPORT)
                {
+                       if(isValueSet())
+                       {
+                               temp+=" Value:";
+                               temp+=_value;
+                       }
                        temp+=" [Input Port]";
                }
 
@@ -146,6 +153,38 @@ namespace bbtk
                _isConnected=value;
        }
 
+       //=========================================================================
+
+       void GPortModel::setValue(std::string value)
+       {
+               _value = value;
+               if(_value=="")
+               {
+                       _isValueSet=false;
+               }
+               else
+               {
+                       _isValueSet=true;
+               }
+               notifyObservers(_objectId);
+       }
+
+       //=========================================================================
+       
+       std::string GPortModel::getValue()
+       {
+               return _value;
+       }
+
+       //=========================================================================
+
+       bool GPortModel::isValueSet()
+       {
+               return _isValueSet;
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index 0ee17f14891610a88348a3bd73475aadeadf0b6a..5d12b911e2a18392b0ec96d87429de17b45fdac4 100644 (file)
@@ -76,6 +76,9 @@ namespace bbtk
                virtual std::string getStatusText();
                bool isConnected();
                void setConnected(bool value);
+               bool isValueSet();
+               void setValue(std::string value);
+               std::string getValue();
 
        private:
 
@@ -86,6 +89,8 @@ namespace bbtk
                int _portType;
                int _posInBox;
                bool _isConnected;
+               std::string _value;
+               bool _isValueSet;
 
                //Private Methods
 
index 0d3c8260df25cb6c28f4f5ddaf9b174b414ac604..0494e705b1c4868e5ef6b227dc08f939132439ee 100644 (file)
@@ -70,6 +70,7 @@ namespace bbtk
        const int FIN_CREATION_CONTOUR= 203;
        const int ADD_TO_SELECTED = 204;
        const int DRAG_OBJECTS = 205;
+       const int EDIT_BLACKBOX = 206;
        
        
        //// COLORS (object_state_(R|G|B))
index c4efe5605d986f87da642f9bbcd499ea122c47e3..8107b8ec6bd48d4e10e30b8e3325b7953b9c9864 100644 (file)
@@ -197,19 +197,21 @@ namespace bbtk
 
        void wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc)
        {
-               createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
+               GPortController* portController = createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
+               blackBox->addInputPort((GPortModel*)portController->getModel());
        }
 
        //=========================================================================
 
        void wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
        {
-               createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
+               GPortController* portController = createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
+               blackBox->addOutputPort((GPortModel*)portController->getModel());
        }
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBlackBoxModel *blackBox)
+       GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBlackBoxModel *blackBox)
        {
                int type = GPORT;
 
@@ -244,6 +246,8 @@ namespace bbtk
                int newId = _controllers.size();
                controller->setId(newId);
                _controllers[newId] = controller;
+
+               return (GPortController*)controller;
        }
 
        //=========================================================================
@@ -436,6 +440,22 @@ namespace bbtk
                                        cont->SetActive(true);                                                          
                                }
                        }
+                       else if(command == EDIT_BLACKBOX)
+                       {
+                               GObjectController* cont = _controllers[idController];
+
+                               for (int i=0; i<_selectedObjects.size(); i++)
+                               {
+                                       int id = _selectedObjects[i];
+                                       GObjectController* cont = _controllers[id];
+                                       cont->getView()->setState(NOTHING_HAPPENS);
+                               }
+                               _selectedObjects.clear();
+
+                               GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel();
+                               _parent->editBlackBox(bbmodel);
+
+                       }
                }
        }
 
@@ -708,6 +728,8 @@ namespace bbtk
                                script+="\n";
                        }
 
+                       script+="load std\n";
+
                        for(i = 0; i<boxes.size();i++)
                        {
                                script+="new ";
@@ -719,6 +741,23 @@ namespace bbtk
                                script+=" ";
                                script+=model->getBBTKName();
                                script+="\n";
+
+                               std::vector<GPortModel*> inputs = model->getInputPorts();
+                               for(int j = 0; j<inputs.size();j++)
+                               {
+                                       GPortModel* inputPort = inputs[j];
+                                       if(inputPort->isValueSet())
+                                       {
+                                               script+="set ";
+                                               script+=model->getBBTKName();
+                                               script+=".";
+                                               script+=inputPort->getBBTKName();
+                                               script+=" ";
+                                               script+=inputPort->getValue();
+                                               script+="\n";
+                                       }
+                               }
+
                        }
 
                        for(i = 0; i<connections.size();i++)
index 5079fdc643307eea8b63b620d23987292a53999d..7efbe0038add1b853ce42f04e158abe5caea5918 100644 (file)
@@ -90,7 +90,7 @@ namespace bbtk
 
                void configureBaseView();
                void createGBlackBox(int x, int y,std::string packageName, std::string boxType);
-               void createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBlackBoxModel *blackBox);
+               GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBlackBoxModel *blackBox);
                void createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc);
                void createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
                void createGConnector(GPortModel* startPort);
index b8d884e12b7e8b3664e32ba3780f03594ff667d9..64092751ea809949e320afba7f9b0528253ba2b0 100644 (file)
@@ -134,7 +134,18 @@ namespace bbtk
        
        bool GBlackBoxController::OnLeftDClick()
        {
-               
+               int X,Y;
+               wxVTKRenderWindowInteractor *wxVTKiren;
+               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+               wxVTKiren->GetEventPosition(X,Y);
+
+               int state  = _view->getState();
+
+               //Evaluate new state
+               if(_view->isPointInside(X,Y))
+               {
+                       _model->notifyObservers(getId(),EDIT_BLACKBOX);
+               }
                return true;
        }
        
index 97a89586b32ac5bbb75ecd7bba22a2c1ec7cff9e..6633e1fe3bcff3c876dd21532838958ca049de83 100644 (file)
@@ -161,7 +161,11 @@ namespace bbtk
                        {
                                _fillObjectActor->GetProperty()->SetColor(0.2,0.2,0.2);
                        }
-                       else
+                       else if(portm->isValueSet())
+                       {
+                               _fillObjectActor->GetProperty()->SetColor(0.5,0.2,0.2);
+                       }
+                       else 
                        {
                                _fillObjectActor->GetProperty()->SetColor(0.6,0.6,0.6);
                        }
index bea7df0f96c42e0b36e4405c92f0b3e81192ab22..816e884350c2dc710aa948b777f98e1e4bf619ea 100644 (file)
@@ -278,6 +278,14 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel)
+       {
+               wxEditionDialog* dialog = new wxEditionDialog(this,bbmodel);
+               dialog->Show();
+       }
+
+       //=========================================================================
+
        void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus)
        {
                SetStatusText(_T(textStatus));
index d0044ff408117de1582a850164d3b28ddb68862e..e31d87349a698061dd6c09f703a10b3460ea8494 100644 (file)
@@ -46,6 +46,7 @@
 //Includes same project
 #include "wxTabPanelsManager.h"
 #include "wxPropertiesPanel.h"
+#include "wxEditionDialog.h"
 #include "C:\RaC\CREATIS\bbtkGEditor\data\icons\wxart_new.xpm"
 
 //Includes creaMaracasVisu
@@ -95,6 +96,8 @@ namespace bbtk
                void updateStatusBar(std::string textStatus);
                void executeActualDiagram();
 
+               void editBlackBox(GBlackBoxModel *bbmodel);
+
                void RegenerateAll();
                void DoRegeneratePackageDoc(const std::string& pack);   
                void DoRegenerateBoxesLists();
index 494aa2a75b3afdd89948d438594dccb57c538bbb..5995ea2a9efa248796f8256b78f0b9366fe9fa4b 100644 (file)
@@ -127,6 +127,13 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel)
+       {
+               _panelsManager->editBlackBox(bbmodel);
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index 507408421157e153629242e7e5613d9b63834148..184714c0ec38dd29bde34aa080f1ec2b01f543a7 100644 (file)
@@ -82,6 +82,7 @@ namespace bbtk
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
                std::string getDiagramScript();
+               void editBlackBox(GBlackBoxModel *bbmodel);
                
        private:
 
index a8d966ad04659bfc2d73a684bb4042206206c170..6410671cc80638dec9ba68bd06144e0ba2de7b16 100644 (file)
@@ -103,6 +103,13 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
+       {
+               _parent->editBlackBox(bbmodel);
+       }
+
+       //=========================================================================
+
 
 
 }  // EO namespace bbtk
index 4b5c3beb7ec3e1ba51f0a5d631a85c0cf89e1350..0b168a6080dc88d65f4d83c2eaa7a87f06bc99b7 100644 (file)
@@ -75,6 +75,7 @@ namespace bbtk
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
                std::string getActualDiagramScript();
+               void editBlackBox(GBlackBoxModel *bbmodel);
                
 
        private: