X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FwxVtkSceneManager.cxx;h=960cdad62c69741d83f8cc1861af317851a26dab;hb=d209561c0b0ab22fd5b060dc0529c9a316b504d9;hp=bc9e4b53033c649d7a2ce7250bfdd11ae6e4487f;hpb=40f10d74bf1374ff15b4c70409616ea4ee9564c7;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index bc9e4b5..960cdad 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -1,3 +1,28 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Santé) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ + /*========================================================================= Program: bbtk Module: $RCSfile$ @@ -40,21 +65,36 @@ namespace bbtk { -//========================================================================= -wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, - wxVtk3DBaseView *baseView, int idManager) { - _cbName = "ComplexBoxName"; - _cbPackageName = "PackageName"; - _Author = "Author ??"; - _Category = ""; - _Description = "Description ??"; +#define POORT_MAX_LINE_SIZE_INTERPRETER 1500 - _parent = parent; - _numBoxes = 0; - _idManager = idManager; - _baseView = baseView; - _startDragging = false; - _isComplexBox = false; +//========================================================================= + +// EED 15 oct 2012 wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory) + + +wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory) +{ + + + _cbName = "ComplexBoxName"; + _cbPackageName = "PackageName"; + _Author = "Author ??"; + _Category = ""; + _Description = "Description ??"; + _MessageKind = "-"; + _MessageLevel = "-"; + + _bugTextActor_text = "void"; + _bugTextActor_status = 0; + + _parent = parent; + _numBoxes = 0; + _idManager = idManager; + _baseView = baseView; + _bbtkfactory = bbtkfactory; + + _startDragging = false; + _isComplexBox = false; if (_baseView != NULL) { //EED02JUIN2010 @@ -70,77 +110,68 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, registerController(this); } - _idConnectionInCreation = -1; - _contLastId = 0; + _idConnectionInCreation = -1; + _contLastId = 0; } //========================================================================= -void wxVtkSceneManager::disconnectDrop() { - printf("EED %p ~wxVtkSceneManager::disconnectDrop()\n", this); +void wxVtkSceneManager::disconnectDrop() +{ //EED02JUIN2010 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL); // _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget( new tmpClasswxTextDropTarget() ); } //========================================================================= -wxVtkSceneManager::~wxVtkSceneManager() { +wxVtkSceneManager::~wxVtkSceneManager() +{ //FCY memory leaks - printf("EED %p ~wxVtkSceneManager() START\n", this); disconnectDrop(); delete _baseView; - printf("EED %p ~wxVtkSceneManager() END\n", this); } //========================================================================= -void wxVtkSceneManager::configureBaseView() { - printf("EED wxVtkSceneManager::configureBaseView 0\n"); - vtkInteractorStyleBaseView2D *interactorstylebaseview = - vtkInteractorStyleBaseView2D::New(); - +void wxVtkSceneManager::configureBaseView() +{ + vtkInteractorStyleBaseView2D *interactorstylebaseview = vtkInteractorStyleBaseView2D::New(); _baseView->SetInteractorStyleBaseView(interactorstylebaseview); - // Important to activate the 2D interaction system - wxVTKRenderWindowInteractor *iren = - _baseView->GetWxVTKRenderWindowInteractor(); + crea::wxVTKRenderWindowInteractor *iren = _baseView->GetWxVTKRenderWindowInteractor(); interactorstylebaseview->SetInteractor(iren); iren->SetInteractorStyle(interactorstylebaseview); interactorstylebaseview->SetwxVtkBaseView(_baseView); - _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn(); _baseView->GetRenderer()->ResetCamera(-100, 100, -100, 100, -1000, 1000); - _baseView->GetRenderer()->GetActiveCamera()->Zoom(10); - - + _baseView->GetRenderer()->GetActiveCamera()->Zoom(20); _baseView->GetRenderer()->SetBackground(0.9, 0.9, 0.9); _baseView->GetRenderer()->GradientBackgroundOn(); - // Actos Port_Text _textActor = vtkTextActor3D::New(); +// _textActor = vtkTextActor::New(); _textActor->SetPosition(-9999, -9999, GPOSITION_Z); _textActor->SetInput(""); - _textActor->GetTextProperty()->SetFontSize(60); +//EED 2022-01-16 +// _textActor->GetTextProperty()->SetFontSize(60); + _textActor->GetTextProperty()->SetFontSize(40); _textActor->GetTextProperty()->BoldOn(); - _textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R, PORTTEXT_NH_G, - PORTTEXT_NH_B); - + _textActor->GetTextProperty()->SetFontFamilyToArial(); + _textActor->GetTextProperty()->ShadowOff(); + _textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R, PORTTEXT_NH_G,PORTTEXT_NH_B); _baseView->GetRenderer()->AddActor(_textActor); - // Actor Fill_Port_Text - //------------ - double xInic = 0; - double yInic = 0; - double zInic = GPOSITION_Z; - - vtkPolygon *aPolygon = vtkPolygon::New(); - _fillObjectActor = vtkActor::New(); - - _pts = vtkPoints::New(); - - double w = 100, h = 10, b = h / 15, t = 3; + double xInic = 0; + double yInic = 0; + double zInic = GPOSITION_Z; + vtkPolygon *aPolygon = vtkPolygon::New(); + _fillObjectActor = vtkActor::New(); + _pts = vtkPoints::New(); + +/* + double w = 100, h = 10, b = h / 15, t = 3; _pts->SetNumberOfPoints(21); _pts->InsertPoint(0, xInic + w * 0.33 - t / 2, yInic, zInic); _pts->InsertPoint(1, xInic + w * 0.33, yInic - t, zInic); @@ -167,27 +198,44 @@ void wxVtkSceneManager::configureBaseView() { _pts->InsertPoint(18, xInic + b * 1, yInic + b * 2, zInic); _pts->InsertPoint(19, xInic + b * 2, yInic + b * 1, zInic); _pts->InsertPoint(20, xInic + b * 4, yInic + b * 0, zInic); - - aPolygon->GetPointIds()->SetNumberOfIds(21); - for (int i = 0; i < 21; i++) { + aPolygon->GetPointIds()->SetNumberOfIds(21); + for (int i = 0; i < 21; i++) { + { + aPolygon->GetPointIds()->SetId(i, i); + } +*/ + + double w = BOX_WIDTH, h = BOX_HEIGHT, t = PORT_HEIGHT; + _pts->SetNumberOfPoints(7); + _pts->InsertPoint(0, xInic + t/2.0 , yInic + t , zInic ); + _pts->InsertPoint(1, xInic + w , yInic + t , zInic ); + _pts->InsertPoint(2, xInic + w , yInic + t + h , zInic ); + _pts->InsertPoint(3, xInic - t*1.5 , yInic + t + h , zInic ); + _pts->InsertPoint(4, xInic - t*1.5 , yInic + t , zInic ); + _pts->InsertPoint(5, xInic - t/2 , yInic + t , zInic ); + _pts->InsertPoint(6, xInic , yInic , zInic ); + aPolygon->GetPointIds()->SetNumberOfIds(8); + for (int i = 0; i < 8; i++) + { aPolygon->GetPointIds()->SetId(i, i); + if (i==7) aPolygon->GetPointIds()->SetId(i, 0); } - vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New(); aPolygonGrid->Allocate(1, 1); - aPolygonGrid->InsertNextCell(aPolygon->GetCellType(), - aPolygon->GetPointIds()); + aPolygonGrid->InsertNextCell(aPolygon->GetCellType(),aPolygon->GetPointIds()); aPolygonGrid->SetPoints(_pts); _aPolygonMapper = vtkDataSetMapper::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _aPolygonMapper->SetInput(aPolygonGrid); +#else + _aPolygonMapper->SetInputData(aPolygonGrid); +#endif _fillObjectActor->SetMapper(_aPolygonMapper); - _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R, PORTFILL_NH_G, - PORTFILL_NH_B); + _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R, PORTFILL_NH_G,PORTFILL_NH_B); _fillObjectActor->GetProperty()->SetOpacity(0); _aPolygonMapper->Modified(); - _baseView->GetRenderer()->AddActor(_fillObjectActor); - printf("EED wxVtkSceneManager::configureBaseView 1\n"); } //========================================================================= @@ -232,31 +280,40 @@ void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn, //========================================================================= -int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, - std::string boxType) { - _worldState = NOTHING_HAPPENS; - //EED int windowWidth = _baseView->GetRenWin()->GetSize()[0]; - int windowHeight = _baseView->GetRenWin()->GetSize()[1]; +int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std::string boxType) +{ + _worldState = NOTHING_HAPPENS; + int windowHeight = _baseView->GetRenWin()->GetSize()[1]; + int type = GBLACKBOX; + //Create the MVC Objects + GBlackBoxModel *model = (GBlackBoxModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); - int type = GBLACKBOX; +//EED 15 oct 2012 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType); + - //Create the MVC Objects + Package::Pointer k; + std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc; + try{ + k = _bbtkfactory->GetPackage(packageName); + mapDesc = k->GetDescriptorMap(); + }catch(Exception e){ + printf("EED. ERROR!: Exception in wxVtkSceneManager::createGBlackBox for package %s, NOT EXIST\n", packageName.c_str()); + } - GBlackBoxModel - *model = - (GBlackBoxModel*) GObjectsMVCFactory::getInstance()->createGObjectModel( - type); - vtkGObjectView *view = - GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = - GObjectsMVCFactory::getInstance()->createGObjectController(type); - - BlackBoxDescriptor::Pointer descriptor = - GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor( - packageName, boxType); - if (descriptor == NULL){ + BlackBoxDescriptor::Pointer descriptor; + try{ + descriptor = mapDesc[boxType]; + }catch(Exception e){ + printf("EED. ERROR!: Exception in wxVtkSceneManager::createGBlackBox for box %s of package %s, NOT EXIST\n", boxType.c_str(),packageName.c_str()); + } + + if (descriptor == NULL) + { printf("SCP: ERROR in wxVtkSceneManager::createGBlackBox, box %s probably does not exist.\n", boxType.c_str()); - } + } + //Prepares the initial model //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height @@ -284,15 +341,28 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, 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++; } @@ -300,27 +370,21 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::map descriptorOutMap = 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; @@ -337,14 +401,9 @@ int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName) { //Create the MVC Objects - GComplexBoxPortModel - *model = - (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel( - type); - vtkGObjectView *view = - GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = - GObjectsMVCFactory::getInstance()->createGObjectController(type); + GComplexBoxPortModel *model = (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); //Prepares the initial model @@ -395,14 +454,9 @@ int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) { //Create the MVC Objects - GComplexBoxPortModel - *model = - (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel( - type); - vtkGObjectView *view = - GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController *controller = - GObjectsMVCFactory::getInstance()->createGObjectController(type); + GComplexBoxPortModel *model = (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); //Prepares the initial model @@ -445,69 +499,73 @@ 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(); } //========================================================================= -GPortController* wxVtkSceneManager::createGPort(int portType, - std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posInBox, - GBoxModel *blackBox) { +GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posInBox,GBoxModel *blackBox) +{ 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); - view->initVtkObjects(); +//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; } //========================================================================= -int wxVtkSceneManager::createGConnector(GPortModel* startPort) { +int wxVtkSceneManager::createGConnector(GPortModel* startPort) +{ int type = GCONNECTOR; manualConnectorContourController *manContourControl = new manualConnectorContourController(); @@ -530,13 +588,19 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort) { manContourView->SetColorEditContour(0.5, 0.5, 0.5); manContourView->SetColorSelectContour(1, 0.8, 0); + + /** * JGRR AND CM * Width increased from 2 to 3, it simplifies line handling and spline control :P * @param WidthLine - */ - manContourView->SetWidthLine( 3 ) ; - manContourView->SetShowText(false); + */ + //EED2017 +// manContourView->SetWidthLine( 3 ) ; +//EED 2022-01-16 + manContourView->SetWidthLine( 1 ) ; + + manContourView->SetShowText(false); manContourControl->SetModelView(manContourModel, manContourView); @@ -581,41 +645,44 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort) { //========================================================================= -void wxVtkSceneManager::registerController(InteractorStyleMaracas *param) { - vtkInteractorStyleBaseView - * baseViewControlManager = - (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView(); +void wxVtkSceneManager::registerController(InteractorStyleMaracas *param) +{ + vtkInteractorStyleBaseView * baseViewControlManager = (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView(); baseViewControlManager->AddInteractorStyleMaracas(param); } //========================================================================= -void wxVtkSceneManager::unregisterController(InteractorStyleMaracas *param) { - vtkInteractorStyleBaseView - * baseViewControlManager = - (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView(); +void wxVtkSceneManager::unregisterController(InteractorStyleMaracas *param) +{ + vtkInteractorStyleBaseView *baseViewControlManager = (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView(); baseViewControlManager->RemoveInteractorStyleMaracas(param); } //========================================================================= -vtkRenderer* wxVtkSceneManager::getRenderer() { +vtkRenderer* wxVtkSceneManager::getRenderer() +{ return _baseView->GetRenderer(); } //========================================================================= -vtkRenderWindow* wxVtkSceneManager::getRenderWindow() { +vtkRenderWindow* wxVtkSceneManager::getRenderWindow() +{ return _baseView->GetRenWin(); } //========================================================================= //========================================================================= -int wxVtkSceneManager::GetIndexInSelected(int idControler) { +int wxVtkSceneManager::GetIndexInSelected(int idControler) +{ int index = -1; - for (int i = 0; i < (int) _selectedObjects.size(); i++) { - if (_selectedObjects[i] == idControler) { + for (int i = 0; i < (int) _selectedObjects.size(); i++) + { + if (_selectedObjects[i] == idControler) + { index = i; break; } @@ -626,18 +693,21 @@ int wxVtkSceneManager::GetIndexInSelected(int idControler) { void wxVtkSceneManager::update(int idController, int command) { - if (command != NO_COMMAND) { - if (command == ADD_TO_SELECTED) { - if (GetIndexInSelected(idController) == -1) { + if (command != NO_COMMAND) + { + if (command == ADD_TO_SELECTED) + { + if (GetIndexInSelected(idController) == -1) + { _selectedObjects.push_back(idController); } } else if (command == REMOVE_FROM_SELECTED) { int index = GetIndexInSelected(idController); - if (index >= 0) { + if (index >= 0) + { _selectedObjects.erase(_selectedObjects.begin() + index); } } else if (command == INIT_CREATION_CONTOUR) { - // JGRR & CM WH typedef std::map::iterator TIterator ; TIterator iter ; @@ -663,10 +733,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 @@ -677,11 +747,14 @@ void wxVtkSceneManager::update(int idController, int command) { // The last one is the controller of the connector std::map::iterator it2; - for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { + for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) + { GObjectController *cont = it2->second; - if (cont->getGObjectType() == GPORT) { + if (cont->getGObjectType() == GPORT) + { GPortModel* port = (GPortModel*) cont->getModel(); - if (port->getPortType() == GINPUTPORT) { + if (port->getPortType() == GINPUTPORT) + { cont->SetActive(true); } else { cont->getView()->setState(NOTHING_HAPPENS); @@ -703,7 +776,8 @@ void wxVtkSceneManager::update(int idController, int command) { GConnectorModel *modelContour = (GConnectorModel*) cont->getModel(); GObjectController *finPort = _controllers[idController]; - if (finPort->getGObjectType() == GPORT) { + if (finPort->getGObjectType() == GPORT) + { GPortModel* modelPort = (GPortModel*) finPort->getModel(); modelContour->setEndPort(modelPort); @@ -724,7 +798,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); - } } @@ -738,7 +811,8 @@ void wxVtkSceneManager::update(int idController, int command) { std::map::iterator it2; - for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { + for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) + { GObjectController *cont = it2->second; if (cont->getView() != NULL) { cont->getView()->setState(NOTHING_HAPPENS); @@ -759,8 +833,8 @@ bool wxVtkSceneManager::OnMouseMove() { int X, Y; bool okStatusMessage = false; - bool okPortMessage = false; - wxVTKRenderWindowInteractor *wxVTKiren; + bool okPortMessage = false; + crea::wxVTKRenderWindowInteractor *wxVTKiren; wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X, Y); @@ -801,7 +875,7 @@ bool wxVtkSceneManager::OnMouseMove() if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION )) { // EO JGRR & CM - okStatusMessage = true; + okStatusMessage = true; updateStatusBar(desc->getStatusText()); if (type == GBLACKBOX) { @@ -811,32 +885,51 @@ bool wxVtkSceneManager::OnMouseMove() if (type == GPORT) { // PortText - okPortMessage = true; - py = py + 5; - _textActor->SetInput(desc->getStatusText().c_str()); - _textActor->SetScale(0.1); - _textActor->SetPosition(px - 25, py + 1, pz + 2); - - // FillPortText - px = px - 33; - //py = py; - _fillObjectActor->SetScale(1); - _fillObjectActor->GetProperty()->SetOpacity(0.50); - _fillObjectActor->SetPosition(px, py, 1); - _aPolygonMapper->Modified(); - } // if GPORT + if ( ( _bugTextActor_text==desc->getStatusText() ) || (_bugTextActor_status==0) ) + { + _bugTextActor_status = 1; + okPortMessage = true; +//EED 2022-01-16 +// py = py + 5; +// _textActor->SetScale(0.1); +// py = py + 5*0.5; + _textActor->SetScale(0.05,0.05,1); + + std::string tmp = desc->getStatusText()+"\n"; + _textActor->SetInput( tmp.c_str() ); +// _textActor->SetPosition(px - 25, py + 1, pz + 2); +// _textActor->SetPosition(px , py-PORT_HEIGHT/4 , pz + 2); + _textActor->SetPosition(px , py-PORT_HEIGHT , pz + 2); + _textActor->Modified(); + // FillPortText +//EED 2022-01-16 +// px = px - 33; + _fillObjectActor->SetScale(1); +// px = px - 33*0.7; +// _fillObjectActor->SetScale(0.7,0.5,1); + _fillObjectActor->GetProperty()->SetOpacity(0.75); + _fillObjectActor->SetPosition( px, py + PORT_HEIGHT/2.0 , 1); + _aPolygonMapper->Modified(); + } else { + _bugTextActor_status= 2; + } // _bugTextActor_tex + _bugTextActor_text = desc->getStatusText(); - } // for controllers it - } + } // if GPORT + } //if state + } // for controllers it } if (okStatusMessage == false) { updateStatusBar(""); } - if (okPortMessage == false) + if ((okPortMessage == false) || (_bugTextActor_status== 2 ) ) { + _bugTextActor_status = 0; _textActor->SetScale(0.0001); + _textActor->SetInput("a\n"); + _textActor->Modified(); _fillObjectActor->SetScale(0.0001); } return true; @@ -953,8 +1046,10 @@ void wxVtkSceneManager::CancelConnection() //========================================================================= -bool wxVtkSceneManager::OnRightButtonUp() { - if (_worldState == INIT_CREATION_CONTOUR) { +bool wxVtkSceneManager::OnRightButtonUp() +{ + if (_worldState == INIT_CREATION_CONTOUR) + { CancelConnection(); } UnSelectBlackBoxes(); @@ -986,7 +1081,7 @@ bool wxVtkSceneManager::OnMiddleButtonUp() { GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() { GObjectController *result = NULL; int X, Y; - wxVTKRenderWindowInteractor *wxVTKiren; + crea::wxVTKRenderWindowInteractor *wxVTKiren; wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X, Y); @@ -1024,47 +1119,6 @@ bool wxVtkSceneManager::OnLeftDClick() { UnSelectBlackBoxes(); _parent->editBlackBox((GBlackBoxModel*) cont->getModel()); } - - /*EED Borrame - - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X,Y); - - std::map::iterator it; - - bool clickOnObject = false; - - for(it = _controllers.begin(); it != _controllers.end() && clickOnObject==false; ++it) - { - GObjectController *cont = it->second; - int type = cont->getGObjectType(); - - if(cont->getView()->isPointInside(X,Y)) - { - if(type==GBLACKBOX) - { - for (int i=0; i< (int)_selectedObjects.size(); i++) - { - int id = _selectedObjects[i]; - GObjectController* control = _controllers[id]; - control->getView()->setState(NOTHING_HAPPENS); - } - _selectedObjects.clear(); - - GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel(); - _parent->editBlackBox(bbmodel); - } - clickOnObject = true; - } - } - - if(clickOnObject==false) - { - //_parent->editDiagramParameters(this); - } - */ return true; } @@ -1079,8 +1133,21 @@ bool wxVtkSceneManager::OnChar() // KeyCode 127 : Delete Key // KeyCode 8 : Backspace Key + + + if (keyCode == 8 || keyCode == 127 || keyCode == 27) + { + if (_worldState == INIT_CREATION_CONTOUR) + { + CancelConnection(); + UnSelectBlackBoxes(); + } + } + + if (keyCode == 8 || keyCode == 127) { + for (int i = 0; i < (int) _selectedObjects.size(); i++) { int id = _selectedObjects[i]; @@ -1096,13 +1163,9 @@ bool wxVtkSceneManager::OnChar() _parent->saveTempandUpdate("delete object"); }// if keyCode - /// Duplicate -#ifdef MACOSX - if((keyCode==0) && (ctrlkey==1)) { -#else + // Duplicate ctrlkey+=keyCode; if(ctrlkey==5){ -#endif if(_selectedObjects.size()){ std::cout<<"objects to copy :"; for(int i=0;i<_selectedObjects.size();i++) @@ -1281,6 +1344,7 @@ bool wxVtkSceneManager::MakeBoxExecutable() { //========================================================================= std::string wxVtkSceneManager::getDiagramBBS(bool wln) { + std::cout << "wxVtkSceneManager::getDiagramBBS" << std::endl; bool existsExec = false; std::vector packages; @@ -1338,7 +1402,7 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) { script += "\n"; //ups2 - + script += LineNumber(wln, lnNmbr); script += "author \""; script += _Author; @@ -1363,9 +1427,10 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) { script += LineNumber(wln, lnNmbr); script += "new "; int id = boxes[i]; - GObjectController *control = _controllers[id]; - GBlackBoxModel *model = (GBlackBoxModel*) control->getModel(); + GObjectController *control = _controllers[id]; + GBlackBoxModel *model = (GBlackBoxModel*) control->getModel(); + script += model->getBBTKPackage()+":"; script += model->getBBTKType(); script += " "; script += model->getBBTKName(); @@ -1394,39 +1459,86 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) { script += LineNumber(wln, lnNmbr); script += "\n"; + + std::string complexInputs=""; + for (i = 0; i < (int) connections.size(); i++) { - script += LineNumber(wln, lnNmbr); - script += "connect "; - int id = connections[i]; - GObjectController *control = _controllers[id]; - GConnectorModel *model = (GConnectorModel*) control->getModel(); + //script += LineNumber(wln, lnNmbr); + //script += "connect "; + int id = connections[i]; + GObjectController *control = _controllers[id]; + GConnectorModel *model = (GConnectorModel*) control->getModel(); - //Start Connection info - GPortModel *start = model->getStartPort(); - script += start->getParentBox()->getBBTKName(); - script += "."; - script += start->getBBTKName(); - script += " "; + //Connection info + GPortModel *start = model->getStartPort(); + GBoxModel *startBox = start->getParentBox(); - //End Connection info GPortModel *end = model->getEndPort(); - script += end->getParentBox()->getBBTKName(); - script += "."; - script += end->getBBTKName(); + GBoxModel *endBox = end->getParentBox(); + + if (startBox->getGObjectType() == GCOMPLEXINPUTPORT) + { + complexInputs += "input "; + complexInputs += startBox->getBBTKName(); + + complexInputs += " "; + complexInputs += endBox->getBBTKName(); + complexInputs += "."; + complexInputs += end->getBBTKName(); + + complexInputs += " "; + complexInputs += "\" \""; + complexInputs += "\n"; + } + else + { + script += LineNumber(wln, lnNmbr); + script += "connect "; + script += startBox->getBBTKName(); + script += "."; + script += start->getBBTKName(); + + script += " "; + + //End Connection info + script += endBox->getBBTKName(); + script += "."; + script += end->getBBTKName(); + + script += "\n"; + } + + script += LineNumber(wln, lnNmbr); script += "\n"; } script += LineNumber(wln, lnNmbr); script += "\n"; + + script += LineNumber(wln, lnNmbr); + script += "\n"; + + script += LineNumber(wln, lnNmbr); + script += "# Complex input ports\n"; + script += complexInputs; + + if((_MessageKind!="-")&&(_MessageLevel!="-")){ + script += LineNumber(wln, lnNmbr); + script += "message "; + script += _MessageKind; + script += " "; + script += _MessageLevel; + script += "\n"; + } + for (i = 0; i < (int) execBoxes.size(); i++) { script += LineNumber(wln, lnNmbr); script += "exec "; int id = execBoxes[i]; GObjectController *control = _controllers[id]; GBlackBoxModel *model = (GBlackBoxModel*) control->getModel(); - script += model->getBBTKName(); script += "\n"; } @@ -1439,6 +1551,7 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) { //========================================================================= std::string wxVtkSceneManager::saveComplexBoxBBS() { + std::cout<<"wxVtkSceneManager::saveComplexBoxBBS"< packages; std::vector boxes; std::vector connections; @@ -1512,6 +1625,7 @@ std::string wxVtkSceneManager::saveComplexBoxBBS() { GObjectController *control = _controllers[id]; GBlackBoxModel *model = (GBlackBoxModel*) control->getModel(); + script += model->getBBTKPackage()+":"; script += model->getBBTKType(); script += " "; script += model->getBBTKName(); @@ -1596,8 +1710,26 @@ std::string wxVtkSceneManager::saveComplexBoxBBS() { } script += "\n"; + script += "# Complex input ports\n"; + script += complexInputs; - for (i = 0; i < (int) execBoxes.size(); i++) { + script += "\n"; + script += "# Complex output ports\n"; + script += complexOutputs; + + script += "\n"; + + if((_MessageKind!="-")&&(_MessageLevel!="-")) + { + script += "message "; + script += _MessageKind; + script += " "; + script += _MessageLevel; + script += "\n"; + } + + for (i = 0; i < (int) execBoxes.size(); i++) + { script += "exec "; int id = execBoxes[i]; GObjectController *control = _controllers[id]; @@ -1607,14 +1739,6 @@ std::string wxVtkSceneManager::saveComplexBoxBBS() { script += "\n"; } - script += "\n"; - script += "# Complex input ports\n"; - script += complexInputs; - - script += "\n"; - script += "# Complex output ports\n"; - script += complexOutputs; - script += "\n"; script += "endefine"; script += "\n"; @@ -1643,23 +1767,45 @@ void wxVtkSceneManager::refresh() { } //========================================================================= -void wxVtkSceneManager::refreshScene() { +void wxVtkSceneManager::refreshScene() +{ _baseView->RefreshView(); } //========================================================================= -void wxVtkSceneManager::centerView() { +void wxVtkSceneManager::centerView() +{ + double bb[6]; + _baseView->GetRenderer()->ComputeVisiblePropBounds(bb); + double temp[3]; _baseView->GetRenderer()->GetActiveCamera()->GetFocalPoint(temp); _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0, 0, temp[2]); _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp); _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0, 0, temp[2]); + + _baseView->GetRenderer()->ResetCamera(); + _baseView->GetRenderer()->ResetCameraClippingRange(); + +/* + double tt=_baseView->GetRenderer()->GetNearClippingPlaneTolerance(); + printf("EED wxVtkSceneManager::centerView() tolerance=%f\n",tt); + double cr1,cr2; + _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2); + printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2); + _baseView->GetRenderer()->GetActiveCamera()->SetClippingRange(0.01,100000); + _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2); + printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2); +*/ + + _baseView->GetRenderer()->Render(); } //========================================================================= -void wxVtkSceneManager::saveDiagram(std::string &content) { +void wxVtkSceneManager::saveDiagram(std::string &content) +{ char buffer[50]; content += "CATEGORY:"; @@ -1687,6 +1833,8 @@ void wxVtkSceneManager::saveDiagram(std::string &content) { content += GetCbPackageName(); content += "\n"; + /* CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest + * External inputs are possible for applications and complex boxes //Print info complex input ports std::vector inputs = getComplexInputPorts(); int insize = inputs.size(); @@ -1700,6 +1848,7 @@ void wxVtkSceneManager::saveDiagram(std::string &content) { GObjectController *cont = _controllers[id]; cont->getModel()->save(content); } + */ //Print info complex output ports std::vector outputs = getComplexOutputPorts(); @@ -1719,6 +1868,21 @@ void wxVtkSceneManager::saveDiagram(std::string &content) { content += "FALSE\n"; } + // CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest + // External inputs are possible for applications and complex boxes + std::vector inputs = getComplexInputPorts(); + int insize = inputs.size(); + content += "COMPLEXINPUTS:"; + sprintf(buffer, "%d", insize); + content += buffer; + content += "\n"; + + for (int i = 0; i < insize; i++) { + int id = inputs[i]; + GObjectController *cont = _controllers[id]; + cont->getModel()->save(content); + } + //Print boxes std::vector boxes = getBlackBoxes(); int bsize = boxes.size(); @@ -1726,10 +1890,17 @@ void wxVtkSceneManager::saveDiagram(std::string &content) { sprintf(buffer, "%d", bsize); content += buffer; content += "\n"; - + for (int i = 0; i < bsize; i++) { int id = boxes[i]; +// std::cout<<"id "<getStatusText()<getModel()->getBBTKType()<getModel()->getBBTKType();//CFT +// std::cout<<"nname: "<getModel()->getBBTKName()<getModel()->getGObjectType()<getModel()->save(content); } @@ -1771,6 +1942,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) std::string line = ""; char delims[] = ":"; char *result = NULL; + char poort[POORT_MAX_LINE_SIZE_INTERPRETER]; getCleanLine(inputStream, line); @@ -1792,6 +1964,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) if (line == "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file") { version = line.substr(18, 3); } + if (line == "# - BBTKGEditor v 1.4 BBG BlackBox Diagram file") { + version = line.substr(18, 3); + } + if (line == "# - BBTKGEditor v 1.5 BBG BlackBox Diagram file") { + version = line.substr(18, 3); + } } else if (line == "APP_START") { start = true; break; @@ -1799,7 +1977,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) } - if (start) { + if (start) + { if ((version != "1.0") && (version != "1.1")) { getCleanLine(inputStream, line);//CATEGORY: @@ -1832,10 +2011,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(NULL, delims); std::string isComplexBox(result); - if (isComplexBox == "TRUE") { + if (isComplexBox == "TRUE") + { _isComplexBox = true; - if ((version != "1.0") && (version != "1.1")) { + if ((version != "1.0") && (version != "1.1")) + { getCleanLine(inputStream, line);//COMPLEXNAME: char complexboxnameTmp[255]; strcpy(complexboxnameTmp, line.c_str()); @@ -1849,26 +2030,83 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(packagenameTmp, delims); result = strtok(NULL, delims); SetCbPackageName(result); - } + } // if version !1.0 !1.1 + + if(version < "1.4") + { + //----------------------- + //- COMPLEX INPUT PORTS + //----------------------- + getCleanLine(inputStream, line);//COMPLEXINPUTS:num + char inputs[30]; + strcpy(inputs, line.c_str()); + result = strtok(inputs, delims); + result = strtok(NULL, delims); + + int numInputs; + std::istringstream inps(result); + inps >> numInputs; + + for (int i = 0; i < numInputs; i++) + { + //---------- + getCleanLine(inputStream, line);//COMPLEX_PORT + getCleanLine(inputStream, line);//name + std::string inputPortName(line); + + //---------- + getCleanLine(inputStream, line);//xInic:yInic:zInic + char coord[80]; + strcpy(coord, line.c_str()); + result = strtok(coord, delims);//xInic + std::string xInic(result); + result = strtok(NULL, delims);//yInic + std::string yInic(result); + result = strtok(NULL, delims);//zInic + std::string zInic(result); + + double xIn, yIn, zIn; + std::istringstream xSt(xInic); + xSt >> xIn; + std::istringstream ySt(yInic); + ySt >> yIn; + std::istringstream zSt(zInic); + zSt >> zIn; + + if (version<="1.2") + { + if (zIn==900) zIn=GPOSITION_Z; + } // if version <=1.2 + + getCleanLine(inputStream, line);//FIN_COMPLEX_PORT + + configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn); + + } // for input complex box + } // if version < 1.4 + + //----------------------- - //- COMPLEX INPUT PORTS + //- COMPLEX OUTPUT PORTS //----------------------- - getCleanLine(inputStream, line);//COMPLEXINPUTS:num - char inputs[30]; - strcpy(inputs, line.c_str()); - result = strtok(inputs, delims); + + getCleanLine(inputStream, line);//COMPLEXOUTPUTS:num + char outputs[30]; + strcpy(outputs, line.c_str()); + result = strtok(outputs, delims); result = strtok(NULL, delims); - int numInputs; - std::istringstream inps(result); - inps >> numInputs; + int numOutputs; + std::istringstream outps(result); + outps >> numOutputs; - for (int i = 0; i < numInputs; i++) { + for (int i = 0; i < numOutputs; i++) + { //---------- getCleanLine(inputStream, line);//COMPLEX_PORT getCleanLine(inputStream, line);//name - std::string inputPortName(line); + std::string outputPortName(line); //---------- getCleanLine(inputStream, line);//xInic:yInic:zInic @@ -1893,35 +2131,42 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { if (zIn==900) zIn=GPOSITION_Z; } - - getCleanLine(inputStream, line);//FIN_COMPLEX_PORT +//EED 2022-01-16 + if (version<="1.4") + { + xIn = xIn*0.70; + yIn = yIn*0.30; + } - configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn); + getCleanLine(inputStream, line);//FIN_COMPLEX_PORT - } // for input complex box + configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn); + } // for output complex box + } // if isComplexBox + + // RaC2012 2nd Hackfest + if(version >= "1.4") + { //----------------------- - //- COMPLEX OUTPUT PORTS + //- EXTERNAL INPUT PORTS //----------------------- - - getCleanLine(inputStream, line);//COMPLEXOUTPUTS:num - char outputs[30]; - strcpy(outputs, line.c_str()); - result = strtok(outputs, delims); + getCleanLine(inputStream, line);//COMPLEXINPUTS:num + char inputs[30]; + strcpy(inputs, line.c_str()); + result = strtok(inputs, delims); result = strtok(NULL, delims); - int numOutputs; - std::istringstream outps(result); - outps >> numOutputs; + int numInputs; + std::istringstream inps(result); + inps >> numInputs; - for (int i = 0; i < numOutputs; i++) { - //---------- + for (int i = 0; i < numInputs; i++) + { getCleanLine(inputStream, line);//COMPLEX_PORT getCleanLine(inputStream, line);//name - std::string outputPortName(line); - - //---------- + std::string inputPortName(line); getCleanLine(inputStream, line);//xInic:yInic:zInic char coord[80]; strcpy(coord, line.c_str()); @@ -1931,7 +2176,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) std::string yInic(result); result = strtok(NULL, delims);//zInic std::string zInic(result); - double xIn, yIn, zIn; std::istringstream xSt(xInic); xSt >> xIn; @@ -1939,19 +2183,20 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) ySt >> yIn; std::istringstream zSt(zInic); zSt >> zIn; - if (version<="1.2") { if (zIn==900) zIn=GPOSITION_Z; } - +//EED 2022-01-16 + if (version<="1.4") + { + xIn = xIn*0.70; + yIn = yIn*0.30; + } getCleanLine(inputStream, line);//FIN_COMPLEX_PORT - - configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn); - - } // for output complex box - - } // complex box + configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn); + } // for external input + } // if(version >= "1.4") //---------- getCleanLine(inputStream, line);//BOXES:num @@ -1964,7 +2209,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 @@ -1977,6 +2223,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(NULL, delims);//name std::string name(result); + getCleanLine(inputStream, line);//ISEXEC:TRUE|FALSE char exec[15]; strcpy(exec, line.c_str()); @@ -1994,7 +2241,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) std::string yInic(result); result = strtok(NULL, delims);//zInic std::string zInic(result); - double xIn, yIn, zIn; std::istringstream xSt(xInic); xSt >> xIn; @@ -2003,13 +2249,16 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) std::istringstream zSt(zInic); zSt >> zIn; - if (version<="1.2") { if (zIn==900) zIn=GPOSITION_Z; } - - +//EED 2022-01-16 + if (version<="1.4") + { + xIn = xIn*0.70; + yIn = yIn*0.30; + } //---------- getCleanLine(inputStream, line);//xEnd:yEnd:zEnd strcpy(coord, line.c_str()); @@ -2032,10 +2281,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { if (zEn==900) zEn=GPOSITION_Z; } - +//EED 2022-01-16 + yEn = yIn-BOX_HEIGHT; bool boxExecutable = false; - if (isExec == "TRUE") { + if (isExec == "TRUE") + { boxExecutable = true; } @@ -2048,17 +2299,28 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) //---------- getCleanLine(inputStream, line);//PORT o FIN_BOX std::string port = line.substr(0, 4); - while (port == "PORT") { + while (port == "PORT") + { getCleanLine(inputStream, line);//name:value - char poort[150]; + if (line.length()>=POORT_MAX_LINE_SIZE_INTERPRETER-1) + { + line=line.substr(0, POORT_MAX_LINE_SIZE_INTERPRETER-1); + } + strcpy(poort, line.c_str()); result = strtok(poort, delims);//name std::string name(result); + + //EED 16 oct 2012 Adding at the end character " if necesary in the value definition result = strtok(NULL, delims);//value + if (( result[0]=='"' ) && ( result[ strlen(result)-1 ]!='"' ) ) + { + std::string tmpString=" "; + tmpString[0]=34; // character " + strcat(result,tmpString.c_str()); + } std::string value(result); - bbmod->setValueToInput(name, value); - getCleanLine(inputStream, line);//PORT o FIN_BOX port = line.substr(0, 4); } // while @@ -2073,17 +2335,16 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) strcpy(conns, line.c_str()); result = strtok(conns, delims); result = strtok(NULL, delims); - int numConns; std::istringstream isCons(result); 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 - char connec[200]; strcpy(connec, line.c_str()); result = strtok(connec, delims); @@ -2094,28 +2355,23 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) std::string nameEndBox(result); result = strtok(NULL, delims); std::string nameEndPort(result); - int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort); - if (version != "1.0") { //Readding control points of the manualContour - GConnectorController *tempp = (GConnectorController*) _controllers[idCon]; - GConnectorModel *conMod = (GConnectorModel*) tempp->getModel(); - vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView(); + GConnectorController *tempp = (GConnectorController*) _controllers[idCon]; + GConnectorModel *conMod = (GConnectorModel*) tempp->getModel(); + vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView(); getCleanLine(inputStream, line); //NumberOfControlPoints:## strcpy(conns, line.c_str()); result = strtok(conns, delims); result = strtok(NULL, delims); - int numberOfControlPoints; std::istringstream isCons(result); isCons >> numberOfControlPoints; - for (int ii = 0; ii < numberOfControlPoints; ii++) { getCleanLine(inputStream, line); //XX:YY:ZZ char connec[200]; strcpy(connec, line.c_str()); - double px, py, pz; result = strtok(connec, delims); std::istringstream isPointX(result); @@ -2126,28 +2382,30 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(NULL, delims); std::istringstream isPointZ(result); isPointZ >> pz; - if (version<="1.2") { if (pz==900) pz=GPOSITION_Z; } - +//EED 2022-01-16 + if (version<="1.4") + { + px = px*0.70; + py = py*0.30; + } conMod->getManualContourModel()->InsertPoint_id(ii + 1, px, py, pz); conView->getManualContourView()->AddPoint(); } - }// version !=1.0 - + }// if version !=1.0 } // for numConns - - } // start - + } // if start } //========================================================================= //========================================================================= void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput, - std::string portName, double xIn, double yIn, double zIn) { + std::string portName, double xIn, double yIn, double zIn) +{ int idPort; if (inputoutput == true) { idPort = createGComplexBoxInputPort(portName); @@ -2163,7 +2421,8 @@ void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput, //========================================================================= -GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) { +GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) +{ int j; int idB; GBoxModel *bMod; @@ -2172,31 +2431,39 @@ GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) { for (j = 0; j < (int) lstB.size(); j++) { idB = lstB[j]; bMod = (GBoxModel*) _controllers[idB]->getModel(); - if (_controllers[idB]->getModel()->getBBTKName() == boxname) { + if (_controllers[idB]->getModel()->getBBTKName() == boxname) + { boxModel = bMod; } } // for - if ((_isComplexBox) && (boxModel == NULL)) { + + + if (boxModel == NULL) { std::vector lstInputs = getComplexInputPorts(); for (j = 0; j < (int) lstInputs.size(); j++) { idB = lstInputs[j]; bMod = (GBoxModel*) _controllers[idB]->getModel(); - if (_controllers[idB]->getModel()->getBBTKName() == boxname) { + if (_controllers[idB]->getModel()->getBBTKName() == boxname) + { boxModel = bMod; } } // for + if(_isComplexBox) + { std::vector lstOutputs = getComplexOutputPorts(); for (j = 0; j < (int) lstOutputs.size(); j++) { int idB = lstOutputs[j]; bMod = (GBoxModel*) _controllers[idB]->getModel(); - if (_controllers[idB]->getModel()->getBBTKName() == boxname) { + if (_controllers[idB]->getModel()->getBBTKName() == boxname) + { boxModel = bMod; } } // for + } - } // complex box + } // inputs/outputs return boxModel; } @@ -2213,23 +2480,32 @@ int wxVtkSceneManager::configGConnetion(std::string nameStartBox, GPortModel *endP = NULL; boxModel = findGBox(nameStartBox); + if(boxModel == NULL) + { + printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str()); + } if (boxModel != NULL) { startP = boxModel->getOutputPort(nameStartPort); if(startP == NULL){ - printf("SCP: ERROR in wxVtkSceneManager::configGConnetion start port %s is null. Port name is probably wrong.\n", nameStartPort.c_str()); + printf("SCP: ERROR in wxVtkSceneManager::configGConnetion start port is null. Port name is probably wrong. Start>%s::%s End>%s::%s\n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str() ); } } boxModel = findGBox(nameEndBox); + if(boxModel == NULL) + { + printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str()); + } if (boxModel != NULL) { endP = boxModel->getInputPort(nameEndPort); if(endP == NULL){ - printf("SCP: ERROR in wxVtkSceneManager::configGConnetion end port %s is null. Port name is probably wrong\n", nameStartPort.c_str(), nameEndPort.c_str()); + printf("SCP: ERROR in wxVtkSceneManager::configGConnetion end port is null. Port name is probably wrong. Start>%s::%s End>%s::%s \n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str()); } } //ups2 int idCon = createGConnector(startP); + _worldState = NOTHING_HAPPENS; GConnectorController *tempp = (GConnectorController*) _controllers[idCon]; @@ -2339,25 +2615,23 @@ int wxVtkSceneManager::addObjectController(GObjectController* objController) { //========================================================================= -void wxVtkSceneManager::DuplicateObjects(std::map objectsMap) { - +void wxVtkSceneManager::DuplicateObjects(std::map objectsMap) +{ std::map oldIdNewIdBoxes; std::vector connections; - std::vector newBoxesID; - std::map::iterator it; - for (it = objectsMap.begin(); it != objectsMap.end(); ++it) { + for (it = objectsMap.begin(); it != objectsMap.end(); ++it) + { GObjectController *cont = it->second; int type = cont->getGObjectType(); - - if (type == GBLACKBOX) { + if (type == GBLACKBOX) + { // Copy black box double xInic, yInic, zInic; GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel(); copyBox->getInicPoint(xInic, yInic, zInic); - int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), - copyBox->getBBTKType()); + int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), copyBox->getBBTKType()); int idcB = copyBox->getObjectId(); oldIdNewIdBoxes[idcB] = idBox; @@ -2365,21 +2639,27 @@ void wxVtkSceneManager::DuplicateObjects(std::map objec GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel(); newbox->setInicPoint(xInic, yInic, zInic); int num = newbox->getNumInputPorts(); - for (int j = 0; j < num; j++) { + for (int j = 0; j < num; j++) + { newbox->setValueToInputPort(j, copyBox->getValueInputPort(j)); - } - newbox->move(xInic + 20, yInic + 20, zInic); + } // if j + +// EED 2022-01-16 +// newbox->move(xInic + 20, yInic + 20, zInic); + newbox->move(xInic + 14, yInic + 6, zInic); + newbox->notifyObservers(_idManager); newBoxesID.push_back(newbox->getObjectId()); } else if (type == GCONNECTOR) { int idCon = cont->getId(); connections.push_back(idCon); - } + } // if type - } + } // for it - for (int i = 0; i < (int) connections.size(); i++) { + for (int i = 0; i < (int) connections.size(); i++) + { int objId = connections[i]; GObjectController *cont = objectsMap[objId]; GConnectorModel* connectModel = (GConnectorModel*) cont->getModel(); @@ -2414,23 +2694,23 @@ void wxVtkSceneManager::DuplicateObjects(std::map objec tempp->endContourCreation(); conMod->setEndPort(newEndPort); conView->updateStartEndPoints(); - } + } // for i /// the new selected boxes are the duplicate ones UnSelectBlackBoxes(); - for (int i = 0; i < newBoxesID.size(); i++) { + for (int i = 0; i < newBoxesID.size(); i++) + { _selectedObjects.push_back(newBoxesID.at(i)); - } + } // for i - for (int i = 0; i < (int) _selectedObjects.size(); i++) { + for (int i = 0; i < (int) _selectedObjects.size(); i++) + { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; - cont->getView()->setState(SELECTED); cont->getModel()->notifyObservers(_idManager); - - } + } // for i } @@ -2494,8 +2774,7 @@ void wxVtkSceneManager::addObjects(std::map objectsMap) double xInic, yInic, zInic; GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel(); copyBox->getInicPoint(xInic, yInic, zInic); - int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), - copyBox->getBBTKType()); + int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(),copyBox->getBBTKType()); int idcB = copyBox->getObjectId(); oldIdNewIdBoxes[idcB] = idBox; @@ -2503,9 +2782,10 @@ void wxVtkSceneManager::addObjects(std::map objectsMap) GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel(); newbox->setInicPoint(xInic, yInic, zInic); int num = newbox->getNumInputPorts(); - for (int j = 0; j < num; j++) { + for (int j = 0; j < num; j++) + { newbox->setValueToInputPort(j, copyBox->getValueInputPort(j)); - } + }// for j newbox->notifyObservers(_idManager); } else if (type == GCONNECTOR) { int idCon = cont->getId(); @@ -2705,7 +2985,6 @@ std::string wxVtkSceneManager::GetCategory() { //========================================================================= void wxVtkSceneManager::SetDescription(std::string description) { _Description = description; - std::cout<<"Description:"<<_Description< wxVtkSceneManager::GetExternalInputsNames() +{ + + std::vector< std::string> extInputs; + std::map::iterator it; + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + if (cont->getGObjectType() == GCOMPLEXINPUTPORT) + { + extInputs.push_back(cont->getModel()->getBBTKName()); + } + } + return extInputs; +} + +//========================================================================= + + void wxVtkSceneManager::printAll(int com , int sta ){