From: Eduardo DAVILA Date: Thu, 19 Jan 2017 14:12:53 +0000 (+0100) Subject: #3057 bbGEditor Feature New Normal - optimizing of vtk actors management (input... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;ds=sidebyside;h=8e6a8a638f2b03db8e34234b6e02d71cda913f9d;p=bbtkGEditor.git #3057 bbGEditor Feature New Normal - optimizing of vtk actors management (input output port) faster refresh --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx index cb7b911..d924c66 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx @@ -80,7 +80,6 @@ namespace bbtk void GBoxModel::setInicPoint(double& x, double& y, double& z) { GObjectModel::setInicPoint(x,y,z); - double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT; setFinalPoint(xFin,yFin,z); } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index 5d82cbf..c9d9e70 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -132,6 +132,42 @@ namespace bbtk updatePorts(); + +// update position for one Actor that represents all InputPorts + GPortModel *portModel; + GBoxModel *boxModel =(GBoxModel*)_model; + int numberOfTriangles = boxModel->getNumInputPorts(); + for (int i=0;igetInputPort(i); + portModel->getInicPoint( xInic , yInic , zInic ) ; + portModel->getFinalPoint( xFin , yFin , zFin ) ; + // RaC In the actual version, zInic=zFin=GPOSITION_Z + _TrianglesInputsPts->SetPoint(i*3+0, xInic , yInic , zInic ); + _TrianglesInputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2 , yFin , zInic ); + _TrianglesInputsPts->SetPoint(i*3+2, xFin , yInic , zFin ); + } + _TrianglesInputsPolyMapper->Modified( ) ; + +// update position for one Actor that represents all OutputPorts + numberOfTriangles = boxModel->getNumOutputPorts(); + for (int i=0;igetOutputPort(i); + portModel->getInicPoint( xInic , yInic , zInic ) ; + portModel->getFinalPoint( xFin , yFin , zFin ) ; + // RaC In the actual version, zInic=zFin=GPOSITION_Z + _TrianglesOutputsPts->SetPoint(i*3+0, xInic , yInic , zInic ); + _TrianglesOutputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2 , yFin , zInic ); + _TrianglesOutputsPts->SetPoint(i*3+2, xFin , yInic , zFin ); + } + _TrianglesOutputsPolyMapper->Modified( ) ; + + + +// update position for one Actor that represents all OutputPorts + + _borderPolyMapper->Modified(); _fillPolyMapper->Modified(); //----------- @@ -188,34 +224,80 @@ namespace bbtk ///************************* FILL ************************* - vtkCellArray *strip = vtkCellArray::New(); vtkPolyData *pdFill = vtkPolyData::New(); _fillPolyMapper = vtkPolyDataMapper::New(); _fillObjectActor = vtkActor::New(); - // RaC In the actual version, zInic=zFin=GPOSITION_Z - strip->InsertNextCell(5); strip->InsertCellPoint(0); strip->InsertCellPoint(1); strip->InsertCellPoint(2); strip->InsertCellPoint(0); strip->InsertCellPoint(3); - pdFill->SetPoints( _pts ); pdFill->SetStrips( strip ); - _fillPolyMapper->SetInput(pdFill); _fillObjectActor->SetMapper(_fillPolyMapper); _fillPolyMapper->Modified(); - ///************************* FILL ************************* + +//EED2017 + ///************************* Inputs Fill (triangles) ************************* + GBoxModel* boxModel =(GBoxModel*)_model; + int numberOfTriangles = boxModel->getNumInputPorts(); + _TrianglesInputsPts = vtkPoints::New(); + _TrianglesInputsPts->SetNumberOfPoints( 3*numberOfTriangles ); + vtkCellArray *stripTrianglesInputs = vtkCellArray::New(); + vtkPolyData *pdTrianglesInputs = vtkPolyData::New(); + _TrianglesInputsPolyMapper = vtkPolyDataMapper::New(); + _TrianglesInputsActor = vtkActor::New(); + // RaC In the actual version, zInic=zFin=GPOSITION_Z + for (int i=0 ; iInsertNextCell( 3 ); + stripTrianglesInputs->InsertCellPoint(i*3+0); + stripTrianglesInputs->InsertCellPoint(i*3+1); + stripTrianglesInputs->InsertCellPoint(i*3+2); + } + pdTrianglesInputs->SetPoints( _TrianglesInputsPts ); + pdTrianglesInputs->SetStrips( stripTrianglesInputs ); + _TrianglesInputsPolyMapper->SetInput( pdTrianglesInputs ); + _TrianglesInputsActor->SetMapper(_TrianglesInputsPolyMapper); + _TrianglesInputsPolyMapper->Modified(); + ///************************* Inputs Fill (triangles) ************************* + + ///************************* Outputs Fill (triangles) ************************* +// GBoxModel* boxModel =(GBoxModel*)_model; + numberOfTriangles = boxModel->getNumOutputPorts(); + _TrianglesOutputsPts = vtkPoints::New(); + _TrianglesOutputsPts->SetNumberOfPoints( 3*numberOfTriangles ); + vtkCellArray *stripTrianglesOutputs = vtkCellArray::New(); + vtkPolyData *pdTrianglesOutputs = vtkPolyData::New(); + _TrianglesOutputsPolyMapper = vtkPolyDataMapper::New(); + _TrianglesOutputsActor = vtkActor::New(); + // RaC In the actual version, zInic=zFin=GPOSITION_Z + for (int i=0 ; iInsertNextCell( 3 ); + stripTrianglesOutputs->InsertCellPoint(i*3+0); + stripTrianglesOutputs->InsertCellPoint(i*3+1); + stripTrianglesOutputs->InsertCellPoint(i*3+2); + } + pdTrianglesOutputs->SetPoints( _TrianglesOutputsPts ); + pdTrianglesOutputs->SetStrips( stripTrianglesOutputs ); + _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs ); + _TrianglesOutputsActor->SetMapper(_TrianglesOutputsPolyMapper); + _TrianglesOutputsPolyMapper->Modified(); + ///************************* Inputs Fill (triangles) ************************* + + + //------------ - _boxTextActor = vtkTextActor3D::New(); - vtkTextProperty *prop = vtkTextProperty::New(); + _boxTextActor = vtkTextActor3D::New(); + vtkTextProperty *prop = vtkTextProperty::New(); prop->BoldOn(); prop->SetFontFamilyToArial(); _boxTextActor->GetTextProperty()->BoldOn(); @@ -238,14 +320,21 @@ namespace bbtk _baseView->GetRenderer()->AddActor(_borderObjectActor); vtkGObjectView::addVtkActors(); _baseView->GetRenderer()->AddActor(_boxTextActor); + + _baseView->GetRenderer()->AddActor(_TrianglesInputsActor); + _baseView->GetRenderer()->AddActor(_TrianglesOutputsActor); + + } //========================================================================= void vtkGBlackBoxView::removeVtkActors()//virtual { - _baseView->GetRenderer()->RemoveActor(_borderObjectActor); _baseView->GetRenderer()->RemoveActor(_boxTextActor); + _baseView->GetRenderer()->RemoveActor(_borderObjectActor); + _baseView->GetRenderer()->RemoveActor(_TrianglesInputsActor); + _baseView->GetRenderer()->RemoveActor(_TrianglesOutputsActor); vtkGObjectView::removeVtkActors(); } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h index 9d59471..5005261 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h @@ -111,7 +111,18 @@ namespace bbtk private: //Private Attributes - vtkTextActor3D* _boxTextActor; + vtkTextActor3D *_boxTextActor; + + // Input Triangles + vtkPoints *_TrianglesInputsPts; + vtkPolyDataMapper *_TrianglesInputsPolyMapper; + vtkActor *_TrianglesInputsActor; + + // Output Triangles + vtkPoints *_TrianglesOutputsPts; + vtkPolyDataMapper *_TrianglesOutputsPolyMapper; + vtkActor *_TrianglesOutputsActor; + //Private Methods void updatePositionTextActor(double xInic, double yInic, double zInic); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index 50ca906..abd696c 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -129,7 +129,7 @@ namespace bbtk void vtkGObjectView::addVtkActors()//virtual { _baseView->GetRenderer()->AddActor(_fillObjectActor); - _baseView->GetRenderer()->Render(); +//EED2017 _baseView->GetRenderer()->Render(); } //========================================================================= @@ -137,7 +137,7 @@ namespace bbtk void vtkGObjectView::removeVtkActors()//virtual { _baseView->GetRenderer()->RemoveActor(_fillObjectActor); - _baseView->GetRenderer()->Render(); +//EED2017 _baseView->GetRenderer()->Render(); } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h index 9124a20..5022143 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h @@ -122,6 +122,11 @@ namespace bbtk virtual void removeFromScene(); virtual void update(int idController,int command); + +//protected + virtual void createVtkObjects(); + virtual void addVtkActors(); + private: @@ -152,8 +157,6 @@ namespace bbtk int _state; //Protected Methods - virtual void createVtkObjects(); - virtual void addVtkActors(); virtual void removeVtkActors(); virtual void updateColors(); }; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index c7ee91f..b0ef338 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -77,25 +77,19 @@ namespace bbtk { //========================================================================= - void vtkGPortView::update( int idController , int command ) { - + void vtkGPortView::update( int idController , int command ) +{ updateColors( ) ; double xInic , yInic , zInic , xFin , yFin , zFin ; - _model->getInicPoint( xInic , yInic , zInic ) ; _model->getFinalPoint( xFin , yFin , zFin ) ; - // RaC In the actual version, zInic=zFin=GPOSITION_Z - double mid = ( xInic + xFin ) / 2 ; - _pts->SetPoint( 0 , xInic , yInic , zInic ) ; _pts->SetPoint( 1 , mid , yFin , zInic ) ; _pts->SetPoint( 2 , xFin , yInic , zFin ) ; - _fillPolyMapper->Modified( ) ; - //----------- setRefreshWaiting( ) ; } @@ -104,8 +98,6 @@ namespace bbtk { void vtkGPortView::createVtkObjects( ) //virtual { - _pts = vtkPoints::New( ) ; - _pts->SetNumberOfPoints( 3 ) ; double xInic , yInic , zInic , xFin , yFin , zFin ; @@ -120,6 +112,9 @@ namespace bbtk { //EED _pts->SetPoint(1, mid, yFin, zInic ); //EED _pts->SetPoint(2, xFin, yInic, zFin ); + _pts = vtkPoints::New( ) ; + _pts->SetNumberOfPoints( 3 ) ; + _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ; _pts->SetPoint( 1 , mid , yFin , zInic ) ; _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index c53529c..1376327 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -1090,6 +1090,7 @@ void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fi } _tabsMgr->addNewTab( crea::std2wx(fileName) ); _tabsMgr->loadDiagram(inputStream, filePathName); + _tabsMgr->saveTempActualDiagram("load diagram"); GetToolBar()->EnableTool(ID_UNDO, false); GetToolBar()->EnableTool(ID_UNDO, false); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 599a262..95a2454 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -280,6 +280,7 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std //EED 15 oct 2012 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType); + Package::Pointer k; std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc; try{ @@ -332,7 +333,6 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std std::map descriptorInMap = descriptor->GetInputDescriptorMap(); std::map::iterator itInput; - int i = 0; for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput) { BlackBoxInputDescriptor *desc = itInput->second; @@ -344,7 +344,6 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std std::map descriptorOutMap = descriptor->GetOutputDescriptorMap(); std::map::iterator itOutput; - i = 0; for (itOutput = descriptorOutMap.begin(); itOutput != descriptorOutMap.end(); ++itOutput) { @@ -357,6 +356,7 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std //(NOTE: Refresh is only made by the view) view->setModel(model); view->setBaseView(_baseView); + view->initVtkObjects(); //Associates the controller with the correspondent model and view @@ -526,7 +526,11 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam //(NOTE: Refresh is only made by the view) view->setModel(model); view->setBaseView(_baseView); - view->initVtkObjects(); + +//EED017 view->initVtkObjects(); + view->createVtkObjects(); +// view->addVtkActors(); + //Associates the controller with the correspondent model and view controller->setModelAndView(model, view); @@ -536,6 +540,7 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam addObjectController(controller); return (GPortController*) controller; + } //========================================================================= @@ -570,7 +575,8 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort) * JGRR AND CM * Width increased from 2 to 3, it simplifies line handling and spline control :P * @param WidthLine - */ + */ + //EED2017 manContourView->SetWidthLine( 3 ) ; manContourView->SetShowText(false); @@ -2182,7 +2188,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) std::istringstream is(result); is >> numBoxes; - for (int i = 0; i < numBoxes; i++) { + for (int i = 0; i < numBoxes; i++) + { //---------- getCleanLine(inputStream, line);//BOX getCleanLine(inputStream, line);//package:type:name @@ -2254,7 +2261,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) bool boxExecutable = false; - if (isExec == "TRUE") { + if (isExec == "TRUE") + { boxExecutable = true; } @@ -2311,7 +2319,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) isCons >> numConns; - for (int i = 0; i < numConns; i++) { + for (int i = 0; i < numConns; i++) + { //---------- getCleanLine(inputStream, line);//CONNECTION getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName @@ -2327,7 +2336,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(NULL, delims); std::string nameEndPort(result); - int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort); if (version != "1.0") { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 4bad668..000b62e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -136,8 +136,8 @@ namespace bbtk virtual bool OnLeftButtonUp(); virtual bool OnRightButtonUp(); virtual bool OnLeftDClick(); - virtual bool OnMiddleButtonDown(); ///JLGR 21-05-2012 - virtual bool OnMiddleButtonUp(); ///JLGR 21-05-2012 + virtual bool OnMiddleButtonDown(); ///JLGR 21-05-2012 + virtual bool OnMiddleButtonUp(); ///JLGR 21-05-2012 //------- int createGBlackBox(int x, int y, std::string packageName, std::string boxType ); @@ -189,8 +189,8 @@ namespace bbtk //Add a map of object controllers void addObjects(std::map objectsMap); - /// Duplicates Objects to current a diagram - void DuplicateObjects(std::map objectsMap);///JLGR 21-05-2012 + /// Duplicates Objects to current a diagram + void DuplicateObjects(std::map objectsMap);///JLGR 21-05-2012 //------- // Makes a BlackBox Executable @@ -259,8 +259,8 @@ namespace bbtk std::string _Author; std::string _Category; std::string _Description; - std::string _MessageKind; - std::string _MessageLevel; + std::string _MessageKind; + std::string _MessageLevel; //wxPanel that uses the manager wxGEditorTabPanel *_parent; @@ -294,11 +294,11 @@ namespace bbtk int _contLastId; vtkTextActor3D *_textActor; - std::string _bugTextActor_text; - int _bugTextActor_status; + std::string _bugTextActor_text; + int _bugTextActor_status; - vtkPoints *_pts; - vtkActor *_fillObjectActor; + vtkPoints *_pts; + vtkActor *_fillObjectActor; vtkDataSetMapper *_aPolygonMapper; Factory::Pointer _bbtkfactory;