From 511369e67cf26244fc8768a727a03f42ff42865f Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Sun, 9 Apr 2017 10:20:30 +0200 Subject: [PATCH] #3084 bbGEditor Bug New Normal - Color refresh for inputs and outputs --- .../bbsKernelEditorGraphic/GBoxModel.cxx | 19 ---- .../bbsKernelEditorGraphic/GBoxModel.h | 9 -- .../bbsKernelEditorGraphic/GPortModel.h | 12 --- .../bbsVtkGUIEditorGraphic/GBoxController.h | 18 +--- .../GConnectorController.h | 18 ---- .../GObjectController.h | 30 +------ .../bbsVtkGUIEditorGraphic/GPortController.h | 14 --- .../vtkGBlackBoxView.cxx | 3 + .../bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h | 17 +--- .../bbsVtkGUIEditorGraphic/vtkGBoxView.cxx | 88 ++++++++++++------ .../bbsVtkGUIEditorGraphic/vtkGBoxView.h | 39 ++++---- .../vtkGConnectorView.h | 12 --- .../bbsVtkGUIEditorGraphic/vtkGObjectView.cxx | 18 ---- .../bbsVtkGUIEditorGraphic/vtkGObjectView.h | 36 +------- .../bbsVtkGUIEditorGraphic/vtkGPortView.cxx | 44 +++++---- .../bbsVtkGUIEditorGraphic/vtkGPortView.h | 13 +-- .../bbtkwxGUIEditorGraphicBBS.cxx | 14 ++- .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 7 +- .../wxTabPanelsManager.cxx | 1 - .../wxVtkSceneManager.cxx | 89 ++++++++++--------- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 40 +++------ 21 files changed, 180 insertions(+), 361 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx index d924c66..b8c4e4e 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx @@ -64,19 +64,16 @@ Version: $Revision$ namespace bbtk { //========================================================================= - GBoxModel::GBoxModel() { } //========================================================================= - GBoxModel::~GBoxModel() { } //========================================================================= - void GBoxModel::setInicPoint(double& x, double& y, double& z) { GObjectModel::setInicPoint(x,y,z); @@ -85,56 +82,47 @@ namespace bbtk } //========================================================================= - void GBoxModel::addInputPort(GPortModel *inputport) { _inputs.push_back(inputport); } //========================================================================= - void GBoxModel::addOutputPort(GPortModel *outputport) { _outputs.push_back(outputport); } //========================================================================= - int GBoxModel::getNumInputPorts() { return _inputs.size(); } //========================================================================= - int GBoxModel::getNumOutputPorts() { return _outputs.size(); } //========================================================================= - void GBoxModel::move(double xx,double yy,double zz) { setInicPoint(xx,yy,zz); - //Refresh inputs position int i; for(i=0;i<(int)_inputs.size();i++) { _inputs[i]->updatePortPosition(); } - //Refresh outputs position for(i=0;i<(int)_outputs.size();i++) { _outputs[i]->updatePortPosition(); } - } //========================================================================= - std::string GBoxModel::getStatusText() { std::string temp = ""; @@ -143,21 +131,18 @@ namespace bbtk } //========================================================================= - std::vector GBoxModel::getInputPorts() { return _inputs; } //========================================================================= - std::vector GBoxModel::getOutputPorts() { return _outputs; } //========================================================================= - void GBoxModel::save(std::string &content) { content+="\n"; @@ -165,7 +150,6 @@ namespace bbtk //========================================================================= - GPortModel* GBoxModel::getInputPort(std::string name) { for(int i = 0; i<(int)_inputs.size();i++) @@ -179,7 +163,6 @@ namespace bbtk } //========================================================================= - GPortModel* GBoxModel::getOutputPort(std::string name) { for(int i = 0; i<(int)_outputs.size();i++) @@ -193,12 +176,10 @@ namespace bbtk } //========================================================================= - GPortModel* GBoxModel::getInputPort(int pos) { return _inputs[pos]; } - //========================================================================= GPortModel* GBoxModel::getOutputPort(int pos) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.h index 63d2ed5..3133252 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.h @@ -121,25 +121,16 @@ namespace bbtk // Updates the position and finally the view of inputs and outputs void updatePorts(); - void addColons(std::string &text); void removeColons(std::string &text); - private: - //Private Attributes - - //Private Methods - protected: //Protected Attributes - std::vector _inputs; std::vector _outputs; - //Protected methods - }; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h index 5021593..ed995fc 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h @@ -122,32 +122,20 @@ namespace bbtk virtual std::string getStatusText(); virtual void save(std::string &content); - private: - //Private Attributes - GBoxModel *_parentBox; - // Port type (INPUT/OUTPUT) int _portType; - // The position of the port in the box int _posInBox; - bool _isConnected; - std::string _value; bool _isValueSet; - //Private Methods - protected: //Protected methods - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.h index 9372d5a..156cdd8 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.h @@ -79,42 +79,26 @@ Version: $Revision$ //Includes std #include - namespace bbtk { - class GBoxController : public GObjectController { - public: - //Constructors GBoxController(); - ~GBoxController(); - + ~GBoxController(); //Public methods - - - private: - //Attributes - //Private Methods - protected: - // Methods from InteractorStyleMaracas virtual bool OnMouseMove(); virtual bool OnLeftButtonDown(); virtual bool OnLeftButtonUp(); virtual bool OnMiddleButtonDown(); virtual bool OnRightButtonUp(); - - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h index 511d74a..c3562cc 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h @@ -80,22 +80,15 @@ Version: $Revision$ //Includes std #include - - namespace bbtk { - class GConnectorController : public GObjectController { - public: - //Constructors GConnectorController(); ~GConnectorController(); - //Public methods - // Methods from InteractorStyleMaracas virtual bool OnMouseMove(); virtual bool OnLeftButtonDown(); @@ -105,31 +98,20 @@ namespace bbtk virtual bool OnRightButtonUp(); virtual bool OnMiddleButtonDown(); virtual bool OnMiddleButtonUp(); - // Implementation of the creaMaracasVisu controller manualConnectorContourController* getManualContourController(); void setManualContourController(manualConnectorContourController* controller); - virtual void removeFromScene(); - // Reports the end in the contour creation void endContourCreation(); - private: - //Attributes - // Implementation of the creaMaracasVisu contour (manualContourControler) controller manualConnectorContourController* _controller; - //Private Methods - protected: //Protected methods - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h index fed4a54..ff37a2f 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h @@ -81,63 +81,39 @@ Version: $Revision$ #include namespace bbtk { - class GObjectController : public InteractorStyleMaracas { public: - //Constructors GObjectController( ); ~ GObjectController( ); - //Public methods - void setModelAndView( GObjectModel* model, vtkGObjectView* view ); - // Same type of the saved in the model of the graphical objects int getGObjectType( ); - - GObjectModel* getModel( ); + GObjectModel* getModel( ); vtkGObjectView* getView( ); - std::string getStatusText( ); - // Same ObjectID from the model int getId( ); void setId( int id ); - virtual void removeFromScene( ); - private: - //Attributes - - - //Private Methods - protected: - //Protected Attributes - - GObjectModel *_model; - vtkGObjectView *_view; - + GObjectModel *_model; + vtkGObjectView *_view; bool _isLeftClickDown; - //Protected Methods - // Methods from InteractorStyleMaracas virtual bool OnMouseMove( ); virtual bool OnLeftButtonDown( ); virtual bool OnLeftButtonUp( ); virtual bool OnLeftDClick( ); virtual bool OnMiddleButtonDown( ); - virtual void moveObject( int X, int Y ); - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h index a1b2976..2243200 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h @@ -80,36 +80,22 @@ Version: $Revision$ //Includes std #include - namespace bbtk { - class GPortController : public GObjectController { - public: - //Constructors GPortController(); ~GPortController(); - //Public methods - virtual bool OnLeftButtonDown(); virtual bool OnLeftButtonUp(); - private: - //Attributes - - //Private Methods - protected: - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index 97e98f4..c5effa8 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -286,6 +286,9 @@ namespace bbtk _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B); _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_SELECTED_R,BOXTEXT_SELECTED_G,BOXTEXT_SELECTED_B); } + + updateColorsPorts(); + } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h index 4bd437d..538ef7e 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h @@ -89,49 +89,34 @@ Version: $Revision$ #include "vtkTextActor3D.h" #include "vtkTextProperty.h" - //Includes std #include - namespace bbtk { - class vtkGBlackBoxView : public vtkGBoxView { - public: - //Constructors vtkGBlackBoxView(); ~vtkGBlackBoxView(); - //Public methods - private: - //Private Attributes vtkTextActor3D *_boxTextActor; - //Private Methods void updatePositionTextActor(double xInic, double yInic, double zInic); - protected: - //Protected Attributes - //Protected Methods virtual void addVtkActors(); virtual void removeVtkActors(); virtual void createVtkObjects(); - virtual void update(int idController,int command); virtual void updateColors(); virtual void update_X_Fin(); - + protected: }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx index 24db98a..a8789d7 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx @@ -108,13 +108,6 @@ namespace bbtk _TrianglesInputsPts = vtkPoints::New(); _TrianglesInputsPts->SetNumberOfPoints( 3*numberOfTriangles ); -//EED 2017-03-02 -// if (numberOfTriangles>0) -// { -// _TrianglesInputsPts->SetPoint(0, -1000, -1000, -1000 ); -// _TrianglesInputsPts->SetPoint(1, 1000, 1000, 1000 ); -// } - vtkCellArray *stripTrianglesInputs = vtkCellArray::New(); vtkPolyData *pdTrianglesInputs = vtkPolyData::New(); _TrianglesInputsPolyMapper = vtkPolyDataMapper::New(); @@ -129,17 +122,17 @@ namespace bbtk } // Create cell data - vtkUnsignedCharArray *cellDataInputTriangles = vtkUnsignedCharArray::New(); - cellDataInputTriangles->SetNumberOfComponents(3); - cellDataInputTriangles->SetNumberOfTuples(numberOfTriangles); + _cellDataInputTriangles = vtkUnsignedCharArray::New(); + _cellDataInputTriangles->SetNumberOfComponents(3); + _cellDataInputTriangles->SetNumberOfTuples(numberOfTriangles); for (int i = 0; i < numberOfTriangles; i++) { rgb[0] = 100; rgb[1] = 100; rgb[2] = 100; - cellDataInputTriangles->SetTuple(i, rgb); + _cellDataInputTriangles->SetTuple(i, rgb); } // for colors - pdTrianglesInputs->GetCellData()->SetScalars(cellDataInputTriangles); + pdTrianglesInputs->GetCellData()->SetScalars( _cellDataInputTriangles ); pdTrianglesInputs->SetPoints( _TrianglesInputsPts ); pdTrianglesInputs->SetStrips( stripTrianglesInputs ); @@ -148,7 +141,6 @@ namespace bbtk _TrianglesInputsPolyMapper->Modified(); - ///************************* Inputs Fill (triangles) ************************* ///************************* Outputs Fill (triangles) ************************* @@ -156,13 +148,6 @@ namespace bbtk _TrianglesOutputsPts = vtkPoints::New(); _TrianglesOutputsPts->SetNumberOfPoints( 3*numberOfTriangles ); -//EED 2017-03-02 -// if (numberOfTriangles>0) -// { -// _TrianglesOutputsPts->SetPoint(0, -1000, -1000, -1000 ); -// _TrianglesOutputsPts->SetPoint(1, 1000, 1000, 1000 ); -// } - vtkCellArray *stripTrianglesOutputs = vtkCellArray::New(); vtkPolyData *pdTrianglesOutputs = vtkPolyData::New(); _TrianglesOutputsPolyMapper = vtkPolyDataMapper::New(); @@ -176,17 +161,17 @@ namespace bbtk stripTrianglesOutputs->InsertCellPoint(i*3+2); } // for // Create cell data - vtkUnsignedCharArray *cellDataOutputTriangle = vtkUnsignedCharArray::New(); - cellDataOutputTriangle->SetNumberOfComponents(3); - cellDataOutputTriangle->SetNumberOfTuples(numberOfTriangles); + _cellDataOutputTriangles = vtkUnsignedCharArray::New(); + _cellDataOutputTriangles->SetNumberOfComponents(3); + _cellDataOutputTriangles->SetNumberOfTuples(numberOfTriangles); for (int i = 0; i < numberOfTriangles; i++) { rgb[0] = 000; rgb[1] = 255; rgb[2] = 255; - cellDataOutputTriangle->SetTuple(i, rgb); + _cellDataOutputTriangles->SetTuple(i, rgb); } // for colors - pdTrianglesOutputs->GetCellData()->SetScalars(cellDataOutputTriangle); + pdTrianglesOutputs->GetCellData()->SetScalars( _cellDataOutputTriangles ); pdTrianglesOutputs->SetPoints( _TrianglesOutputsPts ); pdTrianglesOutputs->SetStrips( stripTrianglesOutputs ); _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs ); @@ -289,6 +274,7 @@ namespace bbtk void vtkGBoxView::updateColors() { + printf("EED vtkGBoxView::updateColors\n"); _fillObjectActor->GetProperty()->SetAmbient(0.6); if(_state==NOTHING_HAPPENS) @@ -315,24 +301,57 @@ namespace bbtk // _borderObjectActor->GetProperty()->SetLineWidth(2); // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B); _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B); - } + } // if state box + + updateColorsPorts(); } + //========================================================================= + void vtkGBoxView::updateColorsPorts() + { + // Input ports + float rgb[3]; + vtkGPortView *portView; + GBoxModel *boxModel = (GBoxModel*)_model; + int numberOfTriangles = boxModel->getNumInputPorts(); + for (int i=0 ; igetColors(rgb); + rgb[0]=rgb[0]*255; + rgb[1]=rgb[1]*255; + rgb[2]=rgb[2]*255; + _cellDataInputTriangles->SetTuple(i, rgb); + } // for + numberOfTriangles = boxModel->getNumOutputPorts(); + for (int i=0 ; igetColors(rgb); + rgb[0]=rgb[0]*255; + rgb[1]=rgb[1]*255; + rgb[2]=rgb[2]*255; + _cellDataOutputTriangles->SetTuple(i, rgb); + } // for + } + + + //========================================================================= void vtkGBoxView::updatePorts() { double xInic, yInic,zInic,xFin, yFin,zFin; - GBoxModel* boxModel =(GBoxModel*)_model; + GBoxModel* boxModel = (GBoxModel*)_model; boxModel->updatePorts(); // update position for one Actor that represents all InputPorts - GPortModel *portModel; + GPortModel *portModel; int numberOfTriangles = boxModel->getNumInputPorts(); for (int i=0;igetInputPort(i); + portModel = boxModel->getInputPort(i); portModel->getInicPoint( xInic , yInic , zInic ) ; portModel->getFinalPoint( xFin , yFin , zFin ) ; // RaC In the actual version, zInic=zFin=GPOSITION_Z @@ -363,6 +382,17 @@ namespace bbtk } //========================================================================= + void vtkGBoxView::addInputPort(vtkGPortView *inputport) + { + _inputsG.push_back(inputport); + } + + //========================================================================= + void vtkGBoxView::addOutputPort(vtkGPortView *outputport) + { + _outputsG.push_back(outputport); + } + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.h index df91361..66fd90d 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.h @@ -73,6 +73,7 @@ Version: $Revision$ //Includes same project #include "GlobalConstants.h" #include "vtkGObjectView.h" +#include "vtkGPortView.h" #include "GBoxModel.h" //Includes creaMaracasVisu @@ -90,56 +91,48 @@ Version: $Revision$ #include "vtkTextActor3D.h" #include "vtkTextProperty.h" - //Includes std #include - namespace bbtk { - class vtkGBoxView : public vtkGObjectView { - public: - //Constructors vtkGBoxView(); ~vtkGBoxView(); - //Public methods - + void addInputPort(vtkGPortView *inputport); + void addOutputPort(vtkGPortView *outputport); private: - //Private Attributes - // Input Triangles - vtkPoints *_TrianglesInputsPts; - vtkPolyDataMapper *_TrianglesInputsPolyMapper; - vtkActor *_TrianglesInputsActor; + vtkPoints *_TrianglesInputsPts; + vtkPolyDataMapper *_TrianglesInputsPolyMapper; + vtkActor *_TrianglesInputsActor; + vtkUnsignedCharArray *_cellDataInputTriangles; // input output port colors Color // Output Triangles - vtkPoints *_TrianglesOutputsPts; - vtkPolyDataMapper *_TrianglesOutputsPolyMapper; - vtkActor *_TrianglesOutputsActor; - + vtkPoints *_TrianglesOutputsPts; + vtkPolyDataMapper *_TrianglesOutputsPolyMapper; + vtkActor *_TrianglesOutputsActor; + vtkUnsignedCharArray *_cellDataOutputTriangles; // input output port colors Color //Private Methods - protected: - //Protected Attributes - + //Protected Attributes + std::vector _inputsG; + std::vector _outputsG; //Protected Methods virtual void addVtkActors(); virtual void removeVtkActors(); virtual void createVtkObjects(); - void createVtkInputOutputPorts(); - + void createVtkInputOutputPorts(); virtual void update(int idController,int command); virtual void updateColors(); + void updateColorsPorts(); void updatePorts(); }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.h index 30a58c6..7a86b3d 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.h @@ -80,37 +80,25 @@ Version: $Revision$ //Includes std #include - namespace bbtk { - class vtkGConnectorView : public vtkGObjectView { - public: - //Constructors vtkGConnectorView(); ~vtkGConnectorView(); - //Public methods void setManualContourView(manualViewContour* viewContour); manualViewContour* getManualContourView(); void updateStartEndPoints(); - private: - //Attributes manualViewContour* manViewContour; - //Private Methods - protected: //Protected methods - }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index 3427deb..d9d784e 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -65,7 +65,6 @@ Version: $Revision$ namespace bbtk { - //========================================================================= vtkGObjectView::vtkGObjectView() { @@ -82,28 +81,24 @@ namespace bbtk { } //========================================================================= - void vtkGObjectView::update(int idController,int command)//virtual { //virtual } //========================================================================= - void vtkGObjectView::setModel(GObjectModel *model) { _model = model; } //========================================================================= - void vtkGObjectView::setBaseView(wxVtkBaseView* baseView) { _baseView = baseView; } //========================================================================= - void vtkGObjectView::initVtkObjects() { createVtkObjects(); @@ -111,21 +106,18 @@ namespace bbtk } //========================================================================= - void vtkGObjectView::createVtkObjects() //virtual { //virtual } //========================================================================= - void vtkGObjectView::updateColors() //virtual { //virtual } //========================================================================= - void vtkGObjectView::addVtkActors()//virtual { _baseView->GetRenderer()->AddActor(_fillObjectActor); @@ -133,7 +125,6 @@ namespace bbtk } //========================================================================= - void vtkGObjectView::removeVtkActors()//virtual { _baseView->GetRenderer()->RemoveActor(_fillObjectActor); @@ -141,7 +132,6 @@ namespace bbtk } //========================================================================= - bool vtkGObjectView::isPointInside(int X,int Y) //virtual { // RaC In the actual version, always z=GPOSITION_Z @@ -151,10 +141,8 @@ namespace bbtk } //========================================================================= - void vtkGObjectView::moveObject(int X,int Y) //virtual { - // RaC In the actual version, always z=GPOSITION_Z double xx=X,yy=Y,zz=GPOSITION_Z; _baseView->TransCoordScreenToWorld(xx,yy,zz); @@ -168,11 +156,9 @@ namespace bbtk dragDifY=yy-yInic; } _model->move(xx-dragDifX,yy-dragDifY,zz); - } //========================================================================= - void vtkGObjectView::setStartDragging(bool param) { _isStartDragging=param; @@ -181,28 +167,24 @@ namespace bbtk } //========================================================================= - void vtkGObjectView::setState(int state) { _state = state; } //========================================================================= - int vtkGObjectView::getState() { return _state; } //========================================================================= - void vtkGObjectView::setRefreshWaiting() { ((vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView())->SetRefresh_waiting(); } //========================================================================= - void vtkGObjectView::removeFromScene() { removeVtkActors(); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h index 13a12ab..5b096af 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h @@ -85,83 +85,55 @@ Version: $Revision$ #include "vtkPolyDataMapper.h" #include "vtkActor.h" - //Includes std #include - namespace bbtk { - class vtkGObjectView : public Observer { - public: - //Constructors vtkGObjectView(); ~vtkGObjectView(); - //Public methods - void setModel(GObjectModel *model); void setBaseView(wxVtkBaseView* baseView); void initVtkObjects(); - void setStartDragging(bool param); - void setState(int state); int getState(); - // Method to force a vtk refresh to the list of controllers of the wxVtkBaseView void setRefreshWaiting(); - virtual bool isPointInside(int X,int Y); virtual void moveObject(int X, int Y); - virtual void removeFromScene(); - virtual void update(int idController,int command); - //protected virtual void createVtkObjects(); virtual void addVtkActors(); - - private: - //Private Attributes - bool _isStartDragging; - + bool _isStartDragging; //Makes a difference between the first point clicked and the new position, in order to move the selected objects - double dragDifX; - double dragDifY; - - + double dragDifX; + double dragDifY; //Private Methods - protected: - //Protected Attributes - wxVtkBaseView * _baseView; GObjectModel * _model; // vtkActor * _borderObjectActor; vtkActor * _fillObjectActor; vtkPolyDataMapper * _fillPolyMapper; // vtkPolyDataMapper * _borderPolyMapper; - vtkPoints *_pts; - // State of the object (See GlobalConstants.h) - int _state; - + int _state; //Protected Methods virtual void removeVtkActors(); virtual void updateColors(); }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index bffe953..cd2332f 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -123,10 +123,10 @@ namespace bbtk { ///************************* FILL ************************* - vtkCellArray *strip = vtkCellArray::New( ) ; - vtkPolyData *pdFill = vtkPolyData::New( ) ; - _fillPolyMapper = vtkPolyDataMapper::New( ) ; - _fillObjectActor = vtkActor::New( ) ; + vtkCellArray *strip = vtkCellArray::New( ) ; + vtkPolyData *pdFill = vtkPolyData::New( ) ; + _fillPolyMapper = vtkPolyDataMapper::New( ) ; + _fillObjectActor = vtkActor::New( ) ; // RaC In the actual version, zInic=zFin=GPOSITION_Z @@ -151,29 +151,37 @@ namespace bbtk { //========================================================================= - void vtkGPortView::updateColors( ) { - _fillObjectActor->GetProperty( )->SetColor( 0.45 , 0.45 , 0.45 ) ; + void vtkGPortView::updateColors( ) + { +//EED2017-04-08 + float rgb[3]; + getColors(rgb); + _fillObjectActor->GetProperty( )->SetColor( rgb[0] , rgb[1] , rgb[2] ) ; + } + + //========================================================================= +//EED2017-04-08 + void vtkGPortView::getColors(float* rgb) + { + rgb[0]=0.45; rgb[1]=0.45; rgb[2]=0.45; if ( _state == POSSIBLE_CONNECTION ) { - _fillObjectActor->GetProperty( )->SetColor( 1 , 1 , 0 ) ; + rgb[0]=1; rgb[1]=1; rgb[2]=0; } else if ( _state == SELECTED_POSSIBLE_CONNECTION ) { - _fillObjectActor->GetProperty( )->SetColor( 0 , 1 , 0 ) ; + rgb[0]=0; rgb[1]=1; rgb[2]=0; } else if ( _state == HIGHLIGHTED ) { - _fillObjectActor->GetProperty( )->SetColor( 0 , 0 , 1 ) ; + rgb[0]=0; rgb[1]=0; rgb[2]=1; } else { GPortModel* portm = ( GPortModel* ) _model ; if ( portm->isConnected( ) ) { - _fillObjectActor->GetProperty( )->SetColor( 0.15 , 0.15 , 0.15 ) ; + rgb[0]=0.15; rgb[1]=0.15; rgb[2]=0.15; } else if ( portm->isValueSet( ) ) { - _fillObjectActor->GetProperty( )->SetColor( 0.55 , 0.25 , 0.25 ) ; + rgb[0]=0.55; rgb[1]=0.25; rgb[2]=0.25; } else { - _fillObjectActor->GetProperty( )->SetColor( 0.45 , 0.45 , 0.45 ) ; - } - } - } - - //========================================================================= - + rgb[0]=0.45; rgb[1]=0.45; rgb[2]=0.45; + } // if portm + } // if _state + } } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.h index 854a1ae..f24c8a5 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.h @@ -86,37 +86,30 @@ Version: $Revision$ #include "vtkRenderer.h" #include "vtkCellArray.h" - //Includes std #include - namespace bbtk { - class vtkGPortView : public vtkGObjectView { - public: //Constructors vtkGPortView(); - ~vtkGPortView(); - + ~vtkGPortView(); //Public methods virtual void update(int idController,int command); + void getColors(float* rgb); + private: //Private Attributes - //Private Methods - protected: //Protected Attributes //Protected Methods virtual void createVtkObjects(); virtual void updateColors(); }; - - } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 1376327..8d57977 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -111,18 +111,14 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) } //========================================================================= -wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() { - - printf("EED %p ~wxGUIEditorGraphicBBS()\n", this); - +wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() +{ //EED02JUIN2010 delete _tabsMgr; - _frameAUIMgr->UnInit(); // FCY memory leaks delete _frameAUIMgr; delete _notebook; delete _tabsMgr; - } //========================================================================= @@ -1017,12 +1013,14 @@ void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event) //========================================================================= -void wxGUIEditorGraphicBBS::refreshGUIControls() { +void wxGUIEditorGraphicBBS::refreshGUIControls() +{ std::string stundo; std::string stredo; //RaC2012 2ndHackFest Next line seems weird ... To keep in mind for other devels wxToolBar* toolbar = GetToolBar(); - if (_tabsMgr->isActualDiagramComplexBox()) { + if (_tabsMgr->isActualDiagramComplexBox()) + { toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true); //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); RaC2012 2nd HackFest toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 9415e26..464c705 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -183,18 +183,17 @@ namespace bbtk void SetAuthor(std::string author); void SetCategory(std::string category); void SetDescription(std::string description); - void SetMessageKind(std::string kind); + void SetMessageKind(std::string kind); void SetMessageLevel(std::string level); //Getters std::string GetFullPath( ); std::string GetFileName( ); - std::string GetCbName(); std::string GetCbPackageName(); std::string GetAuthor(); std::string GetDescription(); std::string GetCategory(); - std::string GetMessageKind(); + std::string GetMessageKind(); std::string GetMessageLevel(); //========================================================================= @@ -204,14 +203,12 @@ namespace bbtk std::vector::iterator _actualdo; // actual position on modifications vector std::vector sstates; // represents string of each modification of the tab. Maxixum size 100!! std::vector::iterator _sactualdo; // actual position onstring modifications vector - int _id; wxAuiManager *_panelAUIMgr; wxVtkSceneManager *_sceneManager; wxTabPanelsManager *_panelsManager; std::string _fullPath; std::string _fileName; - protected: Factory::Pointer _bbtkfactory; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 9e6fa15..351551e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -257,7 +257,6 @@ namespace bbtk void wxTabPanelsManager::VerifyLastTabPanel() { -printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() ); if (this->_notebook->GetPageCount()==0) { this->_actual=NULL; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 002e589..731585d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -116,7 +116,6 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView void wxVtkSceneManager::disconnectDrop() { - printf("EED %p ~wxVtkSceneManager::disconnectDrop()\n", this); //EED02JUIN2010 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL); // _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget( new tmpClasswxTextDropTarget() ); } @@ -126,10 +125,8 @@ void wxVtkSceneManager::disconnectDrop() wxVtkSceneManager::~wxVtkSceneManager() { //FCY memory leaks - printf("EED %p ~wxVtkSceneManager() START\n", this); disconnectDrop(); delete _baseView; - printf("EED %p ~wxVtkSceneManager() END\n", this); } //========================================================================= @@ -329,14 +326,28 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std model->addObserver(view); model->addObserver(this); + +//EED2017 change order + //Associates the view with the correspondent renderer and the model. + //(NOTE: Refresh is only made by the view) + view->setModel(model); + view->setBaseView(_baseView); + + //Associates the controller with the correspondent model and view + controller->setModelAndView(model, view); + + //Iterate and create the input ports std::map descriptorInMap = descriptor->GetInputDescriptorMap(); std::map::iterator itInput; int i = 0; - for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput) { + for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput) + { BlackBoxInputDescriptor *desc = itInput->second; - createGInputPort(GINPUTPORT, i, model, desc); +//EED2017-04-07 +// createGInputPort(GINPUTPORT, i, model, desc); + createGInputPort(GINPUTPORT, i, controller, desc); i++; } @@ -345,26 +356,20 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std descriptor->GetOutputDescriptorMap(); std::map::iterator itOutput; i = 0; - for (itOutput = descriptorOutMap.begin(); itOutput - != descriptorOutMap.end(); ++itOutput) { + for (itOutput = descriptorOutMap.begin(); itOutput!= descriptorOutMap.end(); ++itOutput) + { BlackBoxOutputDescriptor *desc = itOutput->second; - createGOutputPort(GOUTPUTPORT, i, model, desc); +//EED2017-04-07 +// createGOutputPort(GOUTPUTPORT, i, model, desc); + createGOutputPort(GOUTPUTPORT, i, controller, desc); i++; } - //Associates the view with the correspondent renderer and the model. - //(NOTE: Refresh is only made by the view) - view->setModel(model); - view->setBaseView(_baseView); - +//EED2017 change order view->initVtkObjects(); - //Associates the controller with the correspondent model and view - controller->setModelAndView(model, view); - //Resgiter change to the observers of the actual model model->notifyObservers(_idManager); - int newId = addObjectController(controller); return newId; @@ -479,21 +484,35 @@ int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) { //========================================================================= -int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc) +//EED2017-04-08 +//int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc) +int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GObjectController *gBoxControler, BlackBoxInputDescriptor *desc) { + GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel(); GPortController* portController = createGPort(portType, desc->GetName(), desc->GetTypeName(), desc->GetDescription(), posinBox, blackBox); - blackBox->addInputPort((GPortModel*) portController->getModel()); + blackBox->addInputPort( (GPortModel*)portController->getModel() ); + + vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView(); + vtkgboxView->addInputPort( (vtkGPortView*)portController->getView() ); + return portController->getId(); } //========================================================================= -int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc) +//EED2017-04-08 +//int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc) +int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxOutputDescriptor *desc) { + GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel(); GPortController* portController = createGPort(portType, desc->GetName(), desc->GetTypeName(),desc->GetDescription(), posinBox, blackBox); blackBox->addOutputPort((GPortModel*) portController->getModel()); + + vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView(); + vtkgboxView->addOutputPort( (vtkGPortView*)portController->getView() ); + return portController->getId(); } @@ -504,43 +523,28 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam int type = GPORT; //Create the MVC Objects - GPortModel - *model = - (GPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel( - type); - vtkGObjectView *view = - GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = - GObjectsMVCFactory::getInstance()->createGObjectController(type); - + GPortModel *model = (GPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); model->registerInBox(blackBox, portType, posInBox); - model->setBBTKType(bbtkType); model->setBBTKName(bbtkName); model->setBBTKDescription(bbtkDescription); - model->addObserver(view); model->addObserver(this); - //Associates the view with the correspondent renderer and the model. //(NOTE: Refresh is only made by the view) view->setModel(model); view->setBaseView(_baseView); - //EED017 view->initVtkObjects(); view->createVtkObjects(); // view->addVtkActors(); - //Associates the controller with the correspondent model and view controller->setModelAndView(model, view); - model->notifyObservers(_idManager); - addObjectController(controller); - return (GPortController*) controller; - } //========================================================================= @@ -711,10 +715,10 @@ void wxVtkSceneManager::update(int idController, int command) { // Highliht element obc->getView( )->setState( POSSIBLE_CONNECTION ) ; //obc->getView( )->setState( HIGHLIGHTED ) ; - } - } - } - } + } // if obc_type + } // for c_it + } // if + } // if iter // EO JGRR & CM WH @@ -776,7 +780,6 @@ void wxVtkSceneManager::update(int idController, int command) { if ((obc_type == GPORT) && (obc_state == SELECTED_POSSIBLE_CONNECTION)) { // Change element to connected state obc->getView()->setState(HIGHLIGHTED); - } } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 000b62e..c5cb8cb 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -144,8 +144,13 @@ namespace bbtk int createGComplexBoxInputPort(std::string inputName); int createGComplexBoxOutputPort(std::string outputName); GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posinBox,GBoxModel *blackBox); - int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc); - int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc); + +//EED2017-04-07 +// int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc); +// int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc); + int createGInputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxInputDescriptor *desc); + int createGOutputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxOutputDescriptor *desc); + int createGConnector(GPortModel* startPort); void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn); @@ -229,15 +234,14 @@ namespace bbtk void SetAuthor(std::string author); void SetCategory(std::string category); void SetDescription(std::string description); - void SetMessageKind(std::string kind); - void SetMessageLevel(std::string Level); - + void SetMessageKind(std::string kind); + void SetMessageLevel(std::string Level); std::string GetCbName(); std::string GetCbPackageName(); std::string GetAuthor(); std::string GetCategory(); std::string GetDescription(); - std::string GetMessageKind(); + std::string GetMessageKind(); std::string GetMessageLevel(); // RaC2012 2nd HackFest @@ -245,15 +249,10 @@ namespace bbtk // Get names of all external inputs std::vector< std::string> GetExternalInputsNames(); void getCleanLine(std::stringstream &inputStream, std::string &line); - // JGRR & CM void printAll( int com, int sta ); - - std::vector boxesDiagram;//CFT - private: - std::string _cbName; std::string _cbPackageName; std::string _Author; @@ -261,58 +260,39 @@ namespace bbtk std::string _Description; std::string _MessageKind; std::string _MessageLevel; - //wxPanel that uses the manager wxGEditorTabPanel *_parent; - // Id of the manager, the same of the panel int _idManager; - // Boxes number in the scene int _numBoxes; - // StartDragging bool _startDragging; - // creaMaracasVisu viewer wxVtk3DBaseView *_baseView; - // State of the 3D Scene or the virtual world int _worldState; - //Map of id - objectController std::map _controllers; - //Saves the id's of the selected objects in the controllers map std::vector _selectedObjects; - //Is the diagram in state complex box bool _isComplexBox; - int _idConnectionInCreation; - int _contLastId; - vtkTextActor3D *_textActor; std::string _bugTextActor_text; int _bugTextActor_status; - vtkPoints *_pts; vtkActor *_fillObjectActor; vtkDataSetMapper *_aPolygonMapper; - Factory::Pointer _bbtkfactory; - - std::string LineNumber(bool withLineNumber, int &value); int GetIndexInSelected(int idControler); void UnSelectBlackBoxes(); GObjectController *GetGBlackBoxControlerPointedByMouse(); void CancelConnection(); - - protected: - }; -- 2.45.0