From be7230c59a3a7d7aa5bfee591b35d31e5e7a93b3 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Wed, 28 Apr 2010 13:24:57 +0000 Subject: [PATCH] The creation of a panel which enables the user to set in a basic way the values of the inputs ... It works!! The std package was set by force to use the type adapters --- .../bbsKernelEditorGraphic/GBlackBoxModel.cxx | 8 +++- .../bbsKernelEditorGraphic/GBlackBoxModel.h | 2 + .../bbsKernelEditorGraphic/GPortModel.cxx | 41 ++++++++++++++++- .../bbsKernelEditorGraphic/GPortModel.h | 5 +++ .../bbsKernelEditorGraphic/GlobalConstants.h | 1 + .../wxVtkSceneManager.cxx | 45 +++++++++++++++++-- .../wxVtkSceneManager.h | 2 +- .../GBlackBoxController.cxx | 13 +++++- .../bbsVtkGUIEditorGraphic/vtkGPortView.cxx | 6 ++- .../bbtkwxGUIEditorGraphicBBS.cxx | 8 ++++ .../bbtkwxGUIEditorGraphicBBS.h | 3 ++ .../wxGEditorTabPanel.cxx | 7 +++ .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 1 + .../wxTabPanelsManager.cxx | 7 +++ .../wxTabPanelsManager.h | 1 + 15 files changed, 142 insertions(+), 8 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx index cffd4b8..f35cda1 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx @@ -163,7 +163,13 @@ namespace bbtk } //========================================================================= - + + void GBlackBoxModel::setValueToInputPort(int pos,std::string value) + { + _inputs[pos]->setValue(value); + } + + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h index 000950c..c766dba 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h @@ -88,6 +88,8 @@ namespace bbtk std::vector getInputPorts(); std::vector getOutputPorts(); + void setValueToInputPort(int pos,std::string value); + private: //Private Attributes diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx index 161efa7..d866736 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx @@ -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 diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h index 0ee17f1..5d12b91 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h @@ -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 diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 0d3c826..0494e70 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -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)) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index c4efe56..8107b8e 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -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; igetBBTKName(); script+="\n"; + + std::vector inputs = model->getInputPorts(); + for(int j = 0; jisValueSet()) + { + script+="set "; + script+=model->getBBTKName(); + script+="."; + script+=inputPort->getBBTKName(); + script+=" "; + script+=inputPort->getValue(); + script+="\n"; + } + } + } for(i = 0; iGetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + int state = _view->getState(); + + //Evaluate new state + if(_view->isPointInside(X,Y)) + { + _model->notifyObservers(getId(),EDIT_BLACKBOX); + } return true; } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index 97a8958..6633e1f 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -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); } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index bea7df0..816e884 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -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)); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index d0044ff..e31d873 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -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(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 494aa2a..5995ea2 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -127,6 +127,13 @@ namespace bbtk //========================================================================= + void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel) + { + _panelsManager->editBlackBox(bbmodel); + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 5074084..184714c 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -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: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index a8d966a..6410671 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -103,6 +103,13 @@ namespace bbtk //========================================================================= + void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel) + { + _parent->editBlackBox(bbmodel); + } + + //========================================================================= + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 4b5c3be..0b168a6 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -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: -- 2.45.1