2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 * This software is governed by the CeCILL-B license under French law and
40 * abiding by the rules of distribution of free software. You can use,
41 * modify and/ or redistribute the software under the terms of the CeCILL-B
42 * license as circulated by CEA, CNRS and INRIA at the following URL
43 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 * or in the file LICENSE.txt.
46 * As a counterpart to the access to the source code and rights to copy,
47 * modify and redistribute granted by the license, users are provided only
48 * with a limited warranty and the software's author, the holder of the
49 * economic rights, and the successive licensors have only limited
52 * The fact that you are presently reading this means that you have had
53 * knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
58 * \brief Class bbtk::wxVtkSceneManager .
61 #include "wxVtkSceneManager.h"
63 #include <vtkPolygon.h>
64 #include <vtkUnstructuredGrid.h>
68 #define POORT_MAX_LINE_SIZE_INTERPRETER 1500
70 //=========================================================================
72 // EED 15 oct 2012 wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory)
75 wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory)
77 _cbName = "ComplexBoxName";
78 _cbPackageName = "PackageName";
79 _Author = "Author ??";
82 _Description = "Description ??";
86 _bugTextActor_text = "void";
87 _bugTextActor_status = 0;
91 _idManager = idManager;
93 _bbtkfactory = bbtkfactory;
95 _startDragging = false;
96 _isComplexBox = false;
98 if (_baseView != NULL) {
101 "RaC-EED 21-06-2010 %p wxVtkSceneManager::wxVtkSceneManager If you comment this line, the drag and drop functionnality is not initialized.\n",
104 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent);
108 _worldState = NOTHING_HAPPENS;
109 registerController(this);
112 _idConnectionInCreation = -1;
121 //=========================================================================
123 void wxVtkSceneManager::disconnectDrop()
125 //EED02JUIN2010 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
126 // _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget( new tmpClasswxTextDropTarget() );
129 //=========================================================================
131 wxVtkSceneManager::~wxVtkSceneManager()
138 //=========================================================================
140 void wxVtkSceneManager::configureBaseView()
142 vtkInteractorStyleBaseView2D *interactorstylebaseview = vtkInteractorStyleBaseView2D::New();
143 _baseView->SetInteractorStyleBaseView(interactorstylebaseview);
144 // Important to activate the 2D interaction system
145 crea::wxVTKRenderWindowInteractor *iren = _baseView->GetWxVTKRenderWindowInteractor();
146 interactorstylebaseview->SetInteractor(iren);
147 iren->SetInteractorStyle(interactorstylebaseview);
148 interactorstylebaseview->SetwxVtkBaseView(_baseView);
149 _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
150 _baseView->GetRenderer()->ResetCamera(-100, 100, -100, 100, -1000, 1000);
151 _baseView->GetRenderer()->GetActiveCamera()->Zoom(20);
152 _baseView->GetRenderer()->SetBackground(0.9, 0.9, 0.9);
153 _baseView->GetRenderer()->GradientBackgroundOn();
155 _textActor = vtkTextActor3D::New();
156 // _textActor = vtkTextActor::New();
157 _textActor->SetPosition(-9999, -9999, GPOSITION_Z);
158 _textActor->SetInput("<void>");
160 // _textActor->GetTextProperty()->SetFontSize(60);
161 _textActor->GetTextProperty()->SetFontSize(40);
162 _textActor->GetTextProperty()->BoldOn();
163 _textActor->GetTextProperty()->SetFontFamilyToArial();
164 _textActor->GetTextProperty()->ShadowOff();
165 _textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R, PORTTEXT_NH_G,PORTTEXT_NH_B);
166 _baseView->GetRenderer()->AddActor(_textActor);
167 // Actor Fill_Port_Text
171 double zInic = GPOSITION_Z;
172 vtkPolygon *aPolygon = vtkPolygon::New();
173 _fillObjectActor = vtkActor::New();
174 _pts = vtkPoints::New();
177 double w = 100, h = 10, b = h / 15, t = 3;
178 _pts->SetNumberOfPoints(21);
179 _pts->InsertPoint(0, xInic + w * 0.33 - t / 2, yInic, zInic);
180 _pts->InsertPoint(1, xInic + w * 0.33, yInic - t, zInic);
181 _pts->InsertPoint(2, xInic + w * 0.33 + t / 2, yInic, zInic);
182 _pts->InsertPoint(3, xInic + w * 0.33 + t / 2, yInic, zInic);
183 _pts->InsertPoint(4, xInic + w - b * 4, yInic + b * 0, zInic);
185 _pts->InsertPoint(5, xInic + w - b * 4, yInic + b * 0, zInic);
186 _pts->InsertPoint(6, xInic + w - b * 2, yInic + b * 1, zInic);
187 _pts->InsertPoint(7, xInic + w - b * 1, yInic + b * 2, zInic);
188 _pts->InsertPoint(8, xInic + w - b * 0, yInic + b * 4, zInic);
190 _pts->InsertPoint(9, xInic + w - b * 0, yInic + h - b * 4, zInic);
191 _pts->InsertPoint(10, xInic + w - b * 1, yInic + h - b * 2, zInic);
192 _pts->InsertPoint(11, xInic + w - b * 2, yInic + h - b * 1, zInic);
193 _pts->InsertPoint(12, xInic + w - b * 4, yInic + h - b * 0, zInic);
195 _pts->InsertPoint(13, xInic + b * 4, yInic + h - b * 0, zInic);
196 _pts->InsertPoint(14, xInic + b * 2, yInic + h - b * 1, zInic);
197 _pts->InsertPoint(15, xInic + b * 1, yInic + h - b * 2, zInic);
198 _pts->InsertPoint(16, xInic + b * 0, yInic + h - b * 4, zInic);
200 _pts->InsertPoint(17, xInic + b * 0, yInic + b * 4, zInic);
201 _pts->InsertPoint(18, xInic + b * 1, yInic + b * 2, zInic);
202 _pts->InsertPoint(19, xInic + b * 2, yInic + b * 1, zInic);
203 _pts->InsertPoint(20, xInic + b * 4, yInic + b * 0, zInic);
204 aPolygon->GetPointIds()->SetNumberOfIds(21);
205 for (int i = 0; i < 21; i++) {
207 aPolygon->GetPointIds()->SetId(i, i);
211 double w = BOX_WIDTH, h = BOX_HEIGHT, t = PORT_HEIGHT;
212 _pts->SetNumberOfPoints(7);
213 _pts->InsertPoint(0, xInic + t/2.0 , yInic + t , zInic );
214 _pts->InsertPoint(1, xInic + w , yInic + t , zInic );
215 _pts->InsertPoint(2, xInic + w , yInic + t + h , zInic );
216 _pts->InsertPoint(3, xInic - t*1.5 , yInic + t + h , zInic );
217 _pts->InsertPoint(4, xInic - t*1.5 , yInic + t , zInic );
218 _pts->InsertPoint(5, xInic - t/2 , yInic + t , zInic );
219 _pts->InsertPoint(6, xInic , yInic , zInic );
220 aPolygon->GetPointIds()->SetNumberOfIds(8);
221 for (int i = 0; i < 8; i++)
223 aPolygon->GetPointIds()->SetId(i, i);
224 if (i==7) aPolygon->GetPointIds()->SetId(i, 0);
226 vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New();
227 aPolygonGrid->Allocate(1, 1);
228 aPolygonGrid->InsertNextCell(aPolygon->GetCellType(),aPolygon->GetPointIds());
229 aPolygonGrid->SetPoints(_pts);
230 _aPolygonMapper = vtkDataSetMapper::New();
231 //EED 2017-01-01 Migration VTK7
232 #if VTK_MAJOR_VERSION <= 5
233 _aPolygonMapper->SetInput(aPolygonGrid);
235 _aPolygonMapper->SetInputData(aPolygonGrid);
237 _fillObjectActor->SetMapper(_aPolygonMapper);
238 _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R, PORTFILL_NH_G,PORTFILL_NH_B);
239 _fillObjectActor->GetProperty()->SetOpacity(0);
240 _aPolygonMapper->Modified();
241 _baseView->GetRenderer()->AddActor(_fillObjectActor);
245 //=========================================================================
247 std::string wxVtkSceneManager::generateANewNameForABox() {
248 std::stringstream boxname;
249 if (_numBoxes < 10) {
250 boxname << "Box0" << _numBoxes;
252 boxname << "Box" << _numBoxes;
255 return boxname.str();
258 //=========================================================================
260 std::string wxVtkSceneManager::findANewNameForABox()
262 std::string boxname = generateANewNameForABox();
263 while (boxExist(boxname) == true)
265 boxname = generateANewNameForABox();
270 //=========================================================================
271 void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn,
272 double zIn, std::string name, bool boxExecutable, double xEn,
273 double yEn, double zEn)
275 GObjectController *cont = _controllers[idBox];
276 GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel();
277 bbmod->setBBTKName(name);
278 bbmod->setInicPoint(xIn, yIn, zIn);
279 bbmod->setFinalPoint(xEn, yEn, zEn);
280 bbmod->setExecutable(boxExecutable);
281 bbmod->notifyObservers(_idManager);
284 //=========================================================================
286 int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std::string boxType)
288 _worldState = NOTHING_HAPPENS;
289 int windowHeight = _baseView->GetRenWin()->GetSize()[1];
290 int type = GBLACKBOX;
291 //Create the MVC Objects
292 GBlackBoxModel *model = (GBlackBoxModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
293 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
294 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
296 //EED 15 oct 2012 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
300 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
302 k = _bbtkfactory->GetPackage(packageName);
303 mapDesc = k->GetDescriptorMap();
305 printf("EED. ERROR!: Exception in wxVtkSceneManager::createGBlackBox for package %s, NOT EXIST\n", packageName.c_str());
308 BlackBoxDescriptor::Pointer descriptor;
310 descriptor = mapDesc[boxType];
312 printf("EED. ERROR!: Exception in wxVtkSceneManager::createGBlackBox for box %s of package %s, NOT EXIST\n", boxType.c_str(),packageName.c_str());
315 if (descriptor == NULL)
317 printf("SCP: ERROR in wxVtkSceneManager::createGBlackBox, box %s probably does not exist.\n", boxType.c_str());
320 //Prepares the initial model
321 //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height
324 double yy = windowHeight - y;
326 //z value is not important yet, because it is only used a parallel projection
327 double zz = GPOSITION_Z;
328 _baseView->TransCoordScreenToWorld(xx, yy, zz);
329 model->setInicPoint(xx, yy, zz);
331 std::stringstream stream;
333 std::string newBoxName;
334 newBoxName = findANewNameForABox();
336 stream << newBoxName;
338 std::string arraystring = stream.str();
340 model->setBBTKName(arraystring);
341 model->setBBTKType(boxType);
342 model->setBBTKPackage(packageName);
344 model->addObserver(view);
345 model->addObserver(this);
348 //EED2017 change order
349 //Associates the view with the correspondent renderer and the model.
350 //(NOTE: Refresh is only made by the view)
351 view->setModel(model);
352 view->setBaseView(_baseView);
354 //Associates the controller with the correspondent model and view
355 controller->setModelAndView(model, view);
358 //Iterate and create the input ports
359 std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap =
360 descriptor->GetInputDescriptorMap();
361 std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
363 for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
365 BlackBoxInputDescriptor *desc = itInput->second;
367 // createGInputPort(GINPUTPORT, i, model, desc);
368 createGInputPort(GINPUTPORT, i, controller, desc);
372 //Iterate and create the output ports
373 std::map<std::string, BlackBoxOutputDescriptor*> descriptorOutMap =
374 descriptor->GetOutputDescriptorMap();
375 std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
377 for (itOutput = descriptorOutMap.begin(); itOutput!= descriptorOutMap.end(); ++itOutput)
379 BlackBoxOutputDescriptor *desc = itOutput->second;
381 // createGOutputPort(GOUTPUTPORT, i, model, desc);
382 createGOutputPort(GOUTPUTPORT, i, controller, desc);
386 //EED2017 change order
387 view->initVtkObjects();
389 //Resgiter change to the observers of the actual model
390 model->notifyObservers(_idManager);
391 int newId = addObjectController(controller);
397 //=========================================================================
399 int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName) {
400 //EED int windowWidth=_baseView->GetRenWin()->GetSize()[0];
401 int windowHeight = _baseView->GetRenWin()->GetSize()[1];
403 int type = GCOMPLEXINPUTPORT;
405 //Create the MVC Objects
407 GComplexBoxPortModel *model = (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
408 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
409 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
411 //Prepares the initial model
414 double yy = windowHeight - 5;
416 //z value is not important yet, because it is only used a parallel projection
417 double zz = GPOSITION_Z;
419 _baseView->TransCoordScreenToWorld(xx, yy, zz);
420 model->setInicPoint(xx, yy, zz);
422 model->setBBTKName(inputName);
423 model->setBBTKType("ComplexInputPort");
424 model->setComplexPortType(type);
426 model->addObserver(view);
427 model->addObserver(this);
429 //create the output port
430 GPortController* portController = createGPort(GOUTPUTPORT, inputName,
431 "ComplexOutputPortType","ComplexOutputPortDescriopton", 0, model);
432 model->addOutputPort((GPortModel*) portController->getModel());
434 //Associates the view with the correspondent renderer and the model.
435 //(NOTE: Refresh is only made by the view)
436 view->setModel(model);
437 view->setBaseView(_baseView);
438 view->initVtkObjects();
440 //Associates the controller with the correspondent model and view
441 controller->setModelAndView(model, view);
443 //Resgiter change to the observers of the actual model
444 model->notifyObservers(_idManager);
446 int newId = addObjectController(controller);
450 //=========================================================================
452 int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) {
453 //EED int windowWidth=_baseView->GetRenWin()->GetSize()[0];
454 int windowHeight = _baseView->GetRenWin()->GetSize()[1];
456 int type = GCOMPLEXOUTPUTPORT;
458 //Create the MVC Objects
460 GComplexBoxPortModel *model = (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
461 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
462 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
464 //Prepares the initial model
467 double yy = windowHeight - 5;
469 //z value is not important yet, because it is only used a parallel projection
470 double zz = GPOSITION_Z;
472 _baseView->TransCoordScreenToWorld(xx, yy, zz);
473 model->setInicPoint(xx, yy, zz);
475 model->setBBTKName(outputName);
476 model->setBBTKType("ComplexOutputPort");
477 model->setComplexPortType(type);
479 model->addObserver(view);
480 model->addObserver(this);
482 //create the output port
483 GPortController* portController = createGPort(GINPUTPORT, outputName,
484 "ComplexInputPort","ComplexInputPortDescription", 0, model);
485 model->addInputPort((GPortModel*) portController->getModel());
487 //Associates the view with the correspondent renderer and the model.
488 //(NOTE: Refresh is only made by the view)
489 view->setModel(model);
490 view->setBaseView(_baseView);
491 view->initVtkObjects();
493 //Associates the controller with the correspondent model and view
494 controller->setModelAndView(model, view);
496 //Resgiter change to the observers of the actual model
497 model->notifyObservers(_idManager);
499 int newId = addObjectController(controller);
503 //=========================================================================
506 //int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc)
507 int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GObjectController *gBoxControler, BlackBoxInputDescriptor *desc)
509 GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel();
510 GPortController* portController = createGPort(portType, desc->GetName(),
511 desc->GetTypeName(), desc->GetDescription(), posinBox, blackBox);
512 blackBox->addInputPort( (GPortModel*)portController->getModel() );
514 vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView();
515 vtkgboxView->addInputPort( (vtkGPortView*)portController->getView() );
517 return portController->getId();
520 //=========================================================================
523 //int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
524 int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxOutputDescriptor *desc)
526 GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel();
527 GPortController* portController = createGPort(portType, desc->GetName(),
528 desc->GetTypeName(),desc->GetDescription(), posinBox, blackBox);
529 blackBox->addOutputPort((GPortModel*) portController->getModel());
531 vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView();
532 vtkgboxView->addOutputPort( (vtkGPortView*)portController->getView() );
534 return portController->getId();
537 //=========================================================================
539 GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posInBox,GBoxModel *blackBox)
543 //Create the MVC Objects
544 GPortModel *model = (GPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
545 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
546 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
547 model->registerInBox(blackBox, portType, posInBox);
548 model->setBBTKType(bbtkType);
549 model->setBBTKName(bbtkName);
550 model->setBBTKDescription(bbtkDescription);
551 model->addObserver(view);
552 model->addObserver(this);
553 //Associates the view with the correspondent renderer and the model.
554 //(NOTE: Refresh is only made by the view)
555 view->setModel(model);
556 view->setBaseView(_baseView);
557 //EED017 view->initVtkObjects();
558 view->createVtkObjects();
559 // view->addVtkActors();
561 //Associates the controller with the correspondent model and view
562 controller->setModelAndView(model, view);
563 model->notifyObservers(_idManager);
564 addObjectController(controller);
565 return (GPortController*) controller;
568 //=========================================================================
570 int wxVtkSceneManager::createGConnector(GPortModel* startPort)
572 int type = GCONNECTOR;
574 manualConnectorContourController *manContourControl = new manualConnectorContourController();
575 manualConnectorContourView *manContourView = new manualConnectorContourView();
576 manualContourModel *manContourModel = new manualContourModel();
577 GConnectorController *connectorcontroller = new GConnectorController();
578 GConnectorModel *connectorModel = new GConnectorModel();
579 vtkGConnectorView *connectorView = new vtkGConnectorView();
580 connectorModel->setGObjectType(type);
582 manContourModel->SetCloseContour(false);
583 connectorModel->setStartPort(startPort);
585 manContourView->SetModel(manContourModel);
586 manContourView->SetWxVtkBaseView(_baseView);
587 manContourView->SetRange(0.5);
588 manContourView->SetZ(GPOSITION_Z);
590 manContourView->SetColorNormalContour(0, 0, 1);
591 manContourView->SetColorEditContour(0.5, 0.5, 0.5);
592 manContourView->SetColorSelectContour(1, 0.8, 0);
598 * Width increased from 2 to 3, it simplifies line handling and spline control :P
602 // manContourView->SetWidthLine( 3 ) ;
604 manContourView->SetWidthLine( 1 ) ;
606 manContourView->SetShowText(false);
608 manContourControl->SetModelView(manContourModel, manContourView);
610 manContourControl->CreateNewManualContour();
614 connectorModel->getInicPoint(x, y, z);
617 manContourControl->SetState(1);
618 manContourModel->SetCloseContour(false);
620 manContourModel->AddPoint(x, y, z);
621 manContourView->AddPoint();
623 manContourModel->AddPoint(x, y, z);
624 manContourView->AddPoint();
626 int bak = manContourControl->GetNumberOfPointsManualContour() - 1;
627 manContourControl->_bakIdPoint = bak;
629 manContourControl->SetMoving(false);
631 connectorcontroller->setModelAndView(connectorModel, connectorView);
633 int newId = addObjectController(connectorcontroller);
635 connectorcontroller->setManualContourController(manContourControl);
636 connectorModel->setManualContourModel(manContourModel);
637 connectorView->setManualContourView(manContourView);
638 connectorView->setModel(connectorModel);
639 connectorView->setBaseView(_baseView);
641 connectorModel->addObserver(connectorView);
642 connectorModel->addObserver(this);
644 // manContourView->Refresh();
649 //=========================================================================
651 void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
653 vtkInteractorStyleBaseView * baseViewControlManager = (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView();
654 baseViewControlManager->AddInteractorStyleMaracas(param);
657 //=========================================================================
659 void wxVtkSceneManager::unregisterController(InteractorStyleMaracas *param)
661 vtkInteractorStyleBaseView *baseViewControlManager = (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView();
662 baseViewControlManager->RemoveInteractorStyleMaracas(param);
665 //=========================================================================
667 vtkRenderer* wxVtkSceneManager::getRenderer()
669 return _baseView->GetRenderer();
672 //=========================================================================
674 vtkRenderWindow* wxVtkSceneManager::getRenderWindow()
676 return _baseView->GetRenWin();
678 //=========================================================================
681 //=========================================================================
682 int wxVtkSceneManager::GetIndexInSelected(int idControler)
685 for (int i = 0; i < (int) _selectedObjects.size(); i++)
687 if (_selectedObjects[i] == idControler)
695 //=========================================================================
697 void wxVtkSceneManager::update(int idController, int command) {
699 if (command != NO_COMMAND)
701 if (command == ADD_TO_SELECTED)
703 if (GetIndexInSelected(idController) == -1)
705 _selectedObjects.push_back(idController);
707 } else if (command == REMOVE_FROM_SELECTED) {
708 int index = GetIndexInSelected(idController);
711 _selectedObjects.erase(_selectedObjects.begin() + index);
713 } else if (command == INIT_CREATION_CONTOUR) {
715 typedef std::map<int , GObjectController*>::iterator TIterator ;
718 // Find current item in the controller
719 iter = _controllers.find( idController ) ;
720 iter_end = _controllers.end( ) ;
722 if ( iter != iter_end ) {
723 GObjectController* gobjc = iter->second ;
725 std::string bbtkType = gobjc->getModel( )->getBBTKType( ) ;
726 // And if the item is a port
727 if ( gobjc->getModel( )->getGObjectType( ) == GPORT ) {
728 TIterator c_it = _controllers.begin( ) ;
729 // Go through all componets
730 for ( c_it ; c_it != iter_end ; c_it++ ) {
731 GObjectController* obc = c_it->second ;
732 int obc_type = obc->getModel( )->getGObjectType( ) ;
733 std::string obc_bbtkType = obc->getModel( )->getBBTKType( ) ;
734 // if the component is a port and the type is the same of that selected
735 if ( ( obc_type == GPORT ) && ( obc_bbtkType == bbtkType ) ) {
737 obc->getView( )->setState( POSSIBLE_CONNECTION ) ;
738 //obc->getView( )->setState( HIGHLIGHTED ) ;
746 _worldState = INIT_CREATION_CONTOUR;
747 GObjectController* cont = _controllers[idController];
748 GPortModel* startOutputPort = (GPortModel*) cont->getModel();
750 // The last one is the controller of the connector
751 std::map<int, GObjectController*>::iterator it2;
753 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
755 GObjectController *cont = it2->second;
756 if (cont->getGObjectType() == GPORT)
758 GPortModel* port = (GPortModel*) cont->getModel();
759 if (port->getPortType() == GINPUTPORT)
761 cont->SetActive(true);
763 cont->getView()->setState(NOTHING_HAPPENS);
764 cont->getModel()->notifyObservers(_idManager);
765 cont->SetActive(false);
768 cont->getView()->setState(NOTHING_HAPPENS);
769 cont->getModel()->notifyObservers(_idManager);
770 cont->SetActive(false);
773 _selectedObjects.clear();
774 _idConnectionInCreation = createGConnector(startOutputPort);
775 } else if (command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR) {
776 _worldState = NOTHING_HAPPENS;
777 //int id = _controllers.size()-1;
778 GObjectController *cont = _controllers[_idConnectionInCreation];
779 GConnectorModel *modelContour = (GConnectorModel*) cont->getModel();
780 GObjectController *finPort = _controllers[idController];
782 if (finPort->getGObjectType() == GPORT)
784 GPortModel* modelPort = (GPortModel*) finPort->getModel();
785 modelContour->setEndPort(modelPort);
788 typedef std::map<int, GObjectController*>::iterator TIterator;
789 TIterator c_it = _controllers.begin();
790 TIterator iter_end = _controllers.end();
791 // Go through all componets
792 for (c_it; c_it != iter_end; c_it++) {
793 GObjectController* obc = c_it->second;
794 int obc_type = obc->getModel()->getGObjectType();
795 int obc_state = obc->getView()->getState();
796 // if the component is a port and the type is the same of that selected
797 if ((obc_type == GPORT) && (obc_state == POSSIBLE_CONNECTION)) {
798 // Return element to neutral state if not selected
799 obc->getView()->setState(NOTHING_HAPPENS);
801 if ((obc_type == GPORT) && (obc_state == SELECTED_POSSIBLE_CONNECTION)) {
802 // Change element to connected state
803 obc->getView()->setState(HIGHLIGHTED);
809 _parent->saveTempandUpdate("create connection");
812 manualConnectorContourController *manCont = ((GConnectorController*) cont)->getManualContourController();
813 manualConnectorContourView *connView = (manualConnectorContourView*) manCont->GetManualViewBaseContour();
815 std::map<int, GObjectController*>::iterator it2;
817 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
819 GObjectController *cont = it2->second;
820 if (cont->getView() != NULL) {
821 cont->getView()->setState(NOTHING_HAPPENS);
822 cont->getModel()->notifyObservers(_idManager);
824 cont->SetActive(true);
833 //=========================================================================
835 bool wxVtkSceneManager::OnMouseMove()
838 bool okStatusMessage = false;
839 bool okPortMessage = false;
840 crea::wxVTKRenderWindowInteractor *wxVTKiren;
841 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
842 wxVTKiren->GetEventPosition(X, Y);
844 if (_worldState == DRAG_OBJECTS)
846 for (int i = 0; i < (int) _selectedObjects.size(); i++)
848 int id = _selectedObjects[i];
849 GObjectController* cont = _controllers[id];
852 cont->getView()->setStartDragging(true);
854 cont->getView()->moveObject(X, Y);
855 cont->getView()->setState(DRAG);
856 cont->getModel()->notifyObservers(_idManager);
859 std::map<int, GObjectController*>::iterator it;
861 for (it = _controllers.begin(); it != _controllers.end(); ++it)
863 GObjectController *desc = it->second;
864 if (desc->getGObjectType() == GCONNECTOR)
866 vtkGConnectorView* vconn = (vtkGConnectorView*) desc->getView();
867 vconn->updateStartEndPoints();
871 _startDragging = false;
873 } else if (_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR) {
874 std::map<int, GObjectController*>::iterator it;
876 for (it = _controllers.begin(); it != _controllers.end(); ++it)
878 GObjectController *desc = it->second;
879 int type = desc->getGObjectType();
880 int state = desc->getView()->getState();
881 desc->getModel()->getCenter(px, py, pz);
884 if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION ))
887 okStatusMessage = true;
888 updateStatusBar(desc->getStatusText());
889 if (type == GBLACKBOX)
891 GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel();
892 _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType());
897 if ( ( _bugTextActor_text==desc->getStatusText() ) || (_bugTextActor_status==0) )
899 _bugTextActor_status = 1;
900 okPortMessage = true;
903 // _textActor->SetScale(0.1);
905 _textActor->SetScale(0.05,0.05,1);
907 std::string tmp = desc->getStatusText()+"\n";
908 _textActor->SetInput( tmp.c_str() );
909 // _textActor->SetPosition(px - 25, py + 1, pz + 2);
910 // _textActor->SetPosition(px , py-PORT_HEIGHT/4 , pz + 2);
911 _textActor->SetPosition(px , py-PORT_HEIGHT , pz + 2);
912 _textActor->Modified();
916 _fillObjectActor->SetScale(1);
918 // _fillObjectActor->SetScale(0.7,0.5,1);
919 _fillObjectActor->GetProperty()->SetOpacity(0.75);
920 _fillObjectActor->SetPosition( px, py + PORT_HEIGHT/2.0 , 1);
921 _aPolygonMapper->Modified();
923 _bugTextActor_status= 2;
924 } // _bugTextActor_tex
925 _bugTextActor_text = desc->getStatusText();
928 } // for controllers it
929 } else if (_worldState == SELECTING_BOXES ) {
933 if (X<selectRegionX1)
935 sX1=X; sX2=selectRegionX1;
937 sX1=selectRegionX1; sX2=X;
940 if (Y<selectRegionY1)
942 sY1=Y; sY2=selectRegionY1;
944 sY1=selectRegionY1; sY2=Y;
947 UnSelectBlackBoxes();
949 std::map<int, GObjectController*>::iterator it;
950 GObjectController *desc;
954 for (it = _controllers.begin(); it != _controllers.end(); ++it)
957 type = desc->getGObjectType();
958 state = desc->getView()->getState();
960 if ( (type==GBLACKBOX) || (type==GCOMPLEXINPUTPORT) || (type==GCOMPLEXOUTPUTPORT) )
962 if ( desc->getView()->isBoxInsideRectangle( sX1 , sY1,sX2 , sY2 ) )
964 desc->getView()->setState(SELECTED);
965 id = desc->getModel()->getObjectId();
966 desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
974 if (okStatusMessage == false)
979 if ((okPortMessage == false) || (_bugTextActor_status== 2 ) )
981 _bugTextActor_status = 0;
982 _textActor->SetScale(0.0001);
983 _textActor->SetInput("a\n");
984 _textActor->Modified();
985 _fillObjectActor->SetScale(0.0001);
990 //=========================================================================
992 bool wxVtkSceneManager::OnLeftButtonDown()
994 if (_worldState == INIT_CREATION_CONTOUR)
996 bool isOverPort = false;
997 std::map<int, GObjectController*>::iterator it;
998 for (it = _controllers.begin(); it != _controllers.end() && isOverPort== false; ++it)
1000 GObjectController *desc = it->second;
1001 if (desc->getGObjectType() == GPORT)
1003 GPortModel *portmod = (GPortModel*) desc->getModel();
1004 vtkGObjectView *portView = desc->getView();
1005 if (portmod->getPortType() == GINPUTPORT && portView->getState() == HIGHLIGHTED)
1010 if ( portmod->getPortType( ) == GINPUTPORT && portView->getState( ) == SELECTED_POSSIBLE_CONNECTION ) {
1012 portView->setState( HIGHLIGHTED);
1018 if (isOverPort == false)
1021 UnSelectBlackBoxes();
1023 } else { //_worldState
1024 _startDragging = true;
1025 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
1026 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
1027 ctrlkey = ctrlkey + shiftkey;
1028 GObjectController *cont = GetGBoxControlerPointedByMouse();
1031 _worldState = DRAG_OBJECTS;
1032 int state = cont->getView()->getState();
1033 if ((ctrlkey == 0) && (state == HIGHLIGHTED))
1035 UnSelectBlackBoxes();
1036 } // if ctrlkey state
1038 UnSelectBlackBoxes(); // EED 12/07/2012
1039 _worldState = SELECTING_BOXES;
1042 if (_worldState==SELECTING_BOXES)
1044 crea::wxVTKRenderWindowInteractor *wxVTKiren;
1045 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
1046 wxVTKiren->GetEventPosition(selectRegionX1, selectRegionY1);
1047 } // if _worldState SELECTING_BOXES
1049 if (_worldState==DRAG_OBJECTS)
1051 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1053 int id = _selectedObjects[i];
1054 GObjectController *cont = _controllers[id];
1055 cont->getView()->setState(DRAG);
1056 cont->getModel()->notifyObservers(_idManager);
1058 } // if _worldState DRAG_OBJECTS
1060 } // if _selectedObjects.size
1064 //=========================================================================
1066 bool wxVtkSceneManager::OnLeftButtonUp()
1068 if ( (_worldState == DRAG_OBJECTS) || (_worldState == SELECTING_BOXES) )
1070 _worldState = NOTHING_HAPPENS;
1071 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1073 int id = _selectedObjects[i];
1074 GObjectController* cont = _controllers[id];
1075 cont->getView()->setState(SELECTED);
1076 cont->getModel()->notifyObservers(_idManager);
1082 //=========================================================================
1083 void wxVtkSceneManager::CancelConnection()
1085 if (_worldState == INIT_CREATION_CONTOUR)
1087 _worldState = NOTHING_HAPPENS;
1088 //int lastId = _controllers.size()-1;
1090 GConnectorController *connector =
1091 (GConnectorController*) _controllers[_idConnectionInCreation];
1092 connector->removeFromScene();
1093 unregisterController(connector);
1094 _controllers.erase(_idConnectionInCreation);
1096 std::map<int, GObjectController*>::iterator it;
1097 for (it = _controllers.begin(); it != _controllers.end(); ++it)
1099 GObjectController *desc = it->second;
1100 desc->SetActive(true);
1101 desc->getView()->setState(NOTHING_HAPPENS);
1102 desc->getModel()->notifyObservers(_idManager);
1107 //=========================================================================
1108 bool wxVtkSceneManager::OnRightButtonUp()
1110 if (_worldState == INIT_CREATION_CONTOUR)
1114 UnSelectBlackBoxes();
1119 //=========================================================================
1120 bool wxVtkSceneManager::OnMiddleButtonDown()
1122 this->_vtkInteractorStyleBaseView->StartPan();
1126 //=========================================================================
1127 bool wxVtkSceneManager::OnMiddleButtonUp()
1129 this->_vtkInteractorStyleBaseView->EndPan();
1133 //=========================================================================
1134 GObjectController *wxVtkSceneManager::GetGBoxControlerPointedByMouse()
1136 GObjectController *result = NULL;
1138 crea::wxVTKRenderWindowInteractor *wxVTKiren;
1139 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
1140 wxVTKiren->GetEventPosition(X, Y);
1141 std::map<int, GObjectController*>::iterator it;
1142 for (it = _controllers.begin(); it != _controllers.end(); ++it)
1144 GObjectController *cont = it->second;
1145 int type = cont->getGObjectType();
1146 if (cont->getView()->isPointInside(X, Y) == true)
1148 if ( (type == GBLACKBOX) || (type == GCOMPLEXINPUTPORT) || (type == GCOMPLEXOUTPUTPORT))
1152 } // if isPointInside
1157 //=========================================================================
1158 void wxVtkSceneManager::UnSelectBlackBoxes()
1160 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1162 int id = _selectedObjects[i];
1163 GObjectController* control = _controllers[id];
1164 control->getView()->setState(NOTHING_HAPPENS);
1165 control->getModel()->notifyObservers(_idManager);
1166 }// for _selectedObjects
1167 _selectedObjects.clear();
1170 //=========================================================================
1171 bool wxVtkSceneManager::OnLeftDClick()
1173 GObjectController *cont = GetGBoxControlerPointedByMouse();
1176 int type = cont->getGObjectType();
1177 if (type==GBLACKBOX)
1179 UnSelectBlackBoxes();
1180 _parent->editBlackBox((GBlackBoxModel*) cont->getModel());
1186 //=========================================================================
1187 bool wxVtkSceneManager::OnChar()
1191 char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
1192 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
1193 // KeyCode 127 : Delete Key
1194 // KeyCode 8 : Backspace Key
1195 if (keyCode == 8 || keyCode == 127 || keyCode == 27)
1197 if (_worldState == INIT_CREATION_CONTOUR)
1200 UnSelectBlackBoxes();
1203 if (keyCode == 8 || keyCode == 127)
1205 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1207 int id = _selectedObjects[i];
1208 std::map<int, GObjectController*>::iterator it;
1209 it = _controllers.find(id);
1210 if (it != _controllers.end())
1212 oktmp = deleteObject(id);
1215 }// for selected objects
1216 if (ok) _selectedObjects.clear();
1217 _parent->saveTempandUpdate("delete object");
1222 if(_selectedObjects.size()){
1223 std::cout<<"objects to copy :";
1224 for(int i=0;i<_selectedObjects.size();i++)
1226 std::cout<<_selectedObjects.at(i)<<" ";
1228 DuplicateObjects(getSelectedObjects());
1230 std::cout<<"No objects to copy\n";
1231 } // _selectedObjects.size
1236 //=========================================================================
1237 void wxVtkSceneManager::AddControlerToBeRemove( std::vector<int> *controllersToRemove, int id)
1241 for (i = 0; i < (int) controllersToRemove->size(); i++)
1243 if (id == (*controllersToRemove)[i])
1250 controllersToRemove->push_back(id);
1254 //=========================================================================
1256 bool wxVtkSceneManager::deleteObject(int id)
1259 GObjectController *control = _controllers[id];
1260 std::vector<int> controllersToRemove;
1261 if (control->getGObjectType() == GBLACKBOX || control->getGObjectType()
1262 == GCOMPLEXINPUTPORT || control->getGObjectType()
1263 == GCOMPLEXOUTPUTPORT) {
1264 GBoxModel *bbmod = (GBoxModel*) control->getModel();
1265 std::vector<GPortModel*> inputs = bbmod->getInputPorts();
1267 bool boxConnected = false;
1269 // Add box input controllers to be removed
1270 for (int i = 0; i < (int) inputs.size(); i++) {
1271 AddControlerToBeRemove(&controllersToRemove, inputs[i]->getObjectId());
1272 if (inputs[i]->isConnected()) {
1273 boxConnected = true;
1277 std::vector<GPortModel*> outputs = bbmod->getOutputPorts();
1279 // Add box output controllers to be removed
1280 for (int i = 0; i < (int) outputs.size(); i++) {
1281 AddControlerToBeRemove(&controllersToRemove, outputs[i]->getObjectId());
1282 if (outputs[i]->isConnected()) {
1283 boxConnected = true;
1287 // Add connection controllers to be removed
1288 std::map<int, GObjectController*>::iterator it;
1289 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1290 GObjectController *cont = it->second;
1291 int type = cont->getGObjectType();
1292 if (type == GCONNECTOR) {
1293 GConnectorModel *conMod = (GConnectorModel*) cont->getModel();
1294 if (conMod->getStartPort() != NULL && conMod->getStartPort()->getParentBox()->getObjectId() == bbmod->getObjectId())
1296 AddControlerToBeRemove(&controllersToRemove,conMod->getObjectId());
1298 if (conMod->getEndPort() != NULL && conMod->getEndPort()->getParentBox()->getObjectId() == bbmod->getObjectId())
1300 AddControlerToBeRemove(&controllersToRemove,conMod->getObjectId());
1305 // Add box controller to be removed
1306 AddControlerToBeRemove(&controllersToRemove, bbmod->getObjectId());
1307 } else if (control->getGObjectType() == GCONNECTOR) {
1308 GConnectorController *gconnectorcontroler = (GConnectorController*)control;
1309 if (gconnectorcontroler->getManualContourController()->IsEditable()==false)
1311 GConnectorModel *conMod = (GConnectorModel*) control->getModel();
1312 AddControlerToBeRemove(&controllersToRemove, conMod->getObjectId());
1314 gconnectorcontroler->getManualContourController()->OnChar();
1319 std::map<int, GObjectController*>::iterator it;
1321 for (int i = 0; i < (int) controllersToRemove.size(); i++) {
1322 int key = controllersToRemove[i];
1323 it = _controllers.find(key);
1324 GObjectController *cont = _controllers[key];
1326 cont->removeFromScene();
1327 unregisterController((InteractorStyleMaracas*) cont);
1328 _controllers.erase(it);
1336 //=========================================================================
1338 void wxVtkSceneManager::displayBlackBoxInfo(std::string packageName,
1339 std::string boxName) {
1340 _parent->displayBlackBoxInfo(packageName, boxName);
1343 //=========================================================================
1345 void wxVtkSceneManager::updateStatusBar(std::string textStatus) {
1346 _parent->updateStatusBar(textStatus);
1349 //=========================================================================
1350 std::string wxVtkSceneManager::LineNumber(bool withLineNumber, int &value) {
1351 std::string result = "";
1352 if (withLineNumber == true) {
1354 stringstream StrStream;
1356 std::string strValue = StrStream.str();
1359 } else if (value < 100) {
1363 result += strValue + ": ";
1367 //=========================================================================
1369 bool wxVtkSceneManager::MakeBoxExecutable() {
1370 std::map<int, GObjectController*> selected = getSelectedObjects();
1371 if( selected.empty() )
1374 std::map<int, GObjectController*>::iterator it;
1375 for (it = selected.begin(); it != selected.end(); ++it) {
1376 GObjectController* lastSelected = it->second;
1378 vtkGObjectView* view = (vtkGObjectView*) lastSelected->getView();
1379 GBlackBoxModel *bbmodel =
1380 (GBlackBoxModel*) lastSelected->getModel();
1381 view->setState(HIGHLIGHTED);
1382 if (bbmodel->isExecutable()) {
1383 bbmodel->setExecutable(false);
1385 bbmodel->setExecutable(true);
1387 bbmodel->notifyObservers(lastSelected->getId());
1395 //=========================================================================
1397 std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
1398 std::cout << "wxVtkSceneManager::getDiagramBBS" << std::endl;
1399 bool existsExec = false;
1401 std::vector<std::string> packages;
1402 std::vector<int> boxes;
1403 std::vector<int> connections;
1404 std::vector<int> execBoxes;
1406 std::map<int, GObjectController*>::iterator it;
1408 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1409 GObjectController *desc = it->second;
1410 int type = desc->getGObjectType();
1412 if (type == GBLACKBOX) {
1413 GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel();
1415 std::string pkg = mod->getBBTKPackage();
1416 bool existsPkg = false;
1417 for (int t = 0; t < (int) packages.size() && existsPkg == false; t++) {
1418 if (packages[t] == pkg) {
1423 packages.push_back(pkg);
1426 boxes.push_back(it->first);
1427 if (mod->isExecutable()) {
1428 execBoxes.push_back(it->first);
1431 } else if (type == GCONNECTOR) {
1432 connections.push_back(it->first);
1437 std::string script = "";
1438 script += LineNumber(wln, lnNmbr) + "# BBTK GEditor Script\n";
1439 script += LineNumber(wln, lnNmbr) + "# ----------------------\n";
1440 script += LineNumber(wln, lnNmbr) + "\n";
1442 script += LineNumber(wln, lnNmbr) + "include std\n"; // EED
1443 script += LineNumber(wln, lnNmbr) + "include itkvtk\n"; // EED
1445 for (i = 0; i < (int) packages.size(); i++) {
1446 script += LineNumber(wln, lnNmbr);
1447 script += "include ";
1448 script += packages[i];
1452 script += LineNumber(wln, lnNmbr);
1457 script += LineNumber(wln, lnNmbr);
1458 script += "author \"";
1462 script += LineNumber(wln, lnNmbr);
1463 script += "description \"";
1464 script += _Description;
1467 script += LineNumber(wln, lnNmbr);
1468 script += "category \"";
1469 script += _Category;
1472 script += LineNumber(wln, lnNmbr);
1475 // script+="include std\n"; // JPR
1477 for (i = 0; i < (int) boxes.size(); i++) {
1478 script += LineNumber(wln, lnNmbr);
1481 GObjectController *control = _controllers[id];
1482 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1484 script += model->getBBTKPackage()+":";
1485 script += model->getBBTKType();
1487 script += model->getBBTKName();
1490 std::vector<GPortModel*> inputs = model->getInputPorts();
1491 for (int j = 0; j < (int) inputs.size(); j++) {
1492 GPortModel* inputPort = inputs[j];
1493 if (inputPort->isValueSet()) {
1494 script += LineNumber(wln, lnNmbr);
1496 script += model->getBBTKName();
1498 script += inputPort->getBBTKName();
1500 script += inputPort->getValue();
1505 script += LineNumber(wln, lnNmbr);
1510 script += LineNumber(wln, lnNmbr);
1514 std::string complexInputs="";
1516 for (i = 0; i < (int) connections.size(); i++) {
1517 //script += LineNumber(wln, lnNmbr);
1518 //script += "connect ";
1519 int id = connections[i];
1520 GObjectController *control = _controllers[id];
1521 GConnectorModel *model = (GConnectorModel*) control->getModel();
1525 GPortModel *start = model->getStartPort();
1526 GBoxModel *startBox = start->getParentBox();
1528 GPortModel *end = model->getEndPort();
1529 GBoxModel *endBox = end->getParentBox();
1531 if (startBox->getGObjectType() == GCOMPLEXINPUTPORT)
1533 complexInputs += "input ";
1534 complexInputs += startBox->getBBTKName();
1536 complexInputs += " ";
1537 complexInputs += endBox->getBBTKName();
1538 complexInputs += ".";
1539 complexInputs += end->getBBTKName();
1541 complexInputs += " ";
1542 complexInputs += "\" \"";
1544 complexInputs += "\n";
1548 script += LineNumber(wln, lnNmbr);
1549 script += "connect ";
1550 script += startBox->getBBTKName();
1552 script += start->getBBTKName();
1556 //End Connection info
1557 script += endBox->getBBTKName();
1559 script += end->getBBTKName();
1564 script += LineNumber(wln, lnNmbr);
1568 script += LineNumber(wln, lnNmbr);
1571 script += LineNumber(wln, lnNmbr);
1574 script += LineNumber(wln, lnNmbr);
1575 script += "# Complex input ports\n";
1576 script += complexInputs;
1578 if((_MessageKind!="-")&&(_MessageLevel!="-")){
1579 script += LineNumber(wln, lnNmbr);
1580 script += "message ";
1581 script += _MessageKind;
1583 script += _MessageLevel;
1587 for (i = 0; i < (int) execBoxes.size(); i++) {
1588 script += LineNumber(wln, lnNmbr);
1590 int id = execBoxes[i];
1591 GObjectController *control = _controllers[id];
1592 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1593 script += model->getBBTKName();
1602 //=========================================================================
1604 std::string wxVtkSceneManager::saveComplexBoxBBS() {
1605 std::vector<std::string> packages;
1606 std::vector<int> boxes;
1607 std::vector<int> connections;
1608 std::vector<int> execBoxes;
1610 std::map<int, GObjectController*>::iterator it;
1612 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1613 GObjectController *desc = it->second;
1614 int type = desc->getGObjectType();
1616 if (type == GBLACKBOX) {
1617 GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel();
1619 std::string pkg = mod->getBBTKPackage();
1620 bool existsPkg = false;
1621 for (int t = 0; t < (int) packages.size() && existsPkg == false; t++) {
1622 if (packages[t] == pkg) {
1627 packages.push_back(pkg);
1630 boxes.push_back(it->first);
1631 if (mod->isExecutable()) {
1632 execBoxes.push_back(it->first);
1634 } else if (type == GCONNECTOR) {
1635 connections.push_back(it->first);
1639 std::string script = "";
1641 script += "include std\n"; // EED
1642 script += "include itkvtk\n"; // EED
1644 for (i = 0; i < (int) packages.size(); i++) {
1645 script += "include ";
1646 script += packages[i];
1651 // Definition of a complex box
1652 script += "define ";
1653 script += _cbName + " " + _cbPackageName;
1657 script += "author \"";
1661 script += "description \"";
1662 script += _Description;
1666 script += "category \"";
1667 script += _Category;
1672 for (i = 0; i < (int) boxes.size(); i++) {
1675 GObjectController *control = _controllers[id];
1676 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1678 script += model->getBBTKPackage()+":";
1679 script += model->getBBTKType();
1681 script += model->getBBTKName();
1684 std::vector<GPortModel*> inputs = model->getInputPorts();
1685 for (int j = 0; j < (int) inputs.size(); j++) {
1686 GPortModel* inputPort = inputs[j];
1687 if (inputPort->isValueSet()) {
1689 script += model->getBBTKName();
1691 script += inputPort->getBBTKName();
1693 script += inputPort->getValue();
1701 // Create connections in the script. If the connection is made with a complex port, it is created the input or output
1703 std::string complexInputs = "";
1704 std::string complexOutputs = "";
1707 for (i = 0; i < (int) connections.size(); i++) {
1708 int id = connections[i];
1709 GObjectController *control = _controllers[id];
1710 GConnectorModel *model = (GConnectorModel*) control->getModel();
1713 GPortModel *start = model->getStartPort();
1714 GBoxModel *startBox = start->getParentBox();
1716 GPortModel *end = model->getEndPort();
1717 GBoxModel *endBox = end->getParentBox();
1719 if (startBox->getGObjectType() == GCOMPLEXINPUTPORT) {
1720 complexInputs += "input ";
1721 complexInputs += startBox->getBBTKName();
1723 complexInputs += " ";
1724 complexInputs += endBox->getBBTKName();
1725 complexInputs += ".";
1726 complexInputs += end->getBBTKName();
1728 complexInputs += " ";
1729 complexInputs += "\" \"";
1731 complexInputs += "\n";
1732 } else if (endBox->getGObjectType() == GCOMPLEXOUTPUTPORT) {
1733 complexOutputs += "output ";
1734 complexOutputs += endBox->getBBTKName();
1736 complexOutputs += " ";
1737 complexOutputs += startBox->getBBTKName();
1738 complexOutputs += ".";
1739 complexOutputs += start->getBBTKName();
1741 complexOutputs += " ";
1742 complexOutputs += "\" \"";
1744 complexOutputs += "\n";
1746 script += "connect ";
1747 script += startBox->getBBTKName();
1749 script += start->getBBTKName();
1753 //End Connection info
1754 script += endBox->getBBTKName();
1756 script += end->getBBTKName();
1763 script += "# Complex input ports\n";
1764 script += complexInputs;
1767 script += "# Complex output ports\n";
1768 script += complexOutputs;
1772 if((_MessageKind!="-")&&(_MessageLevel!="-"))
1774 script += "message ";
1775 script += _MessageKind;
1777 script += _MessageLevel;
1781 for (i = 0; i < (int) execBoxes.size(); i++)
1784 int id = execBoxes[i];
1785 GObjectController *control = _controllers[id];
1786 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1788 script += model->getBBTKName();
1793 script += "endefine";
1799 //=========================================================================
1801 void wxVtkSceneManager::deleteAllBoxes() {
1802 std::map<int, GObjectController*>::iterator it;
1803 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1804 GObjectController *cont = it->second;
1805 cont->removeFromScene();
1806 unregisterController((InteractorStyleMaracas*) cont);
1808 _selectedObjects.clear();
1809 _controllers.clear();
1812 //=========================================================================
1815 void wxVtkSceneManager::refresh() {
1816 _baseView->Refresh();
1818 //=========================================================================
1820 void wxVtkSceneManager::refreshScene()
1822 _baseView->RefreshView();
1825 //=========================================================================
1827 void wxVtkSceneManager::centerView()
1830 _baseView->GetRenderer()->ComputeVisiblePropBounds(bb);
1833 _baseView->GetRenderer()->GetActiveCamera()->GetFocalPoint(temp);
1834 _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0, 0, temp[2]);
1835 _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp);
1836 _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0, 0, temp[2]);
1838 _baseView->GetRenderer()->ResetCamera();
1839 _baseView->GetRenderer()->ResetCameraClippingRange();
1842 double tt=_baseView->GetRenderer()->GetNearClippingPlaneTolerance();
1843 printf("EED wxVtkSceneManager::centerView() tolerance=%f\n",tt);
1845 _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
1846 printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2);
1847 _baseView->GetRenderer()->GetActiveCamera()->SetClippingRange(0.01,100000);
1848 _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
1849 printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2);
1852 _baseView->GetRenderer()->Render();
1855 //=========================================================================
1857 void wxVtkSceneManager::saveDiagram(std::string &content)
1861 content += "CATEGORY:";
1862 content += GetCategory();
1865 content += "DESCRIPTION:";
1866 content += GetDescription();
1869 content += "AUTHOR:";
1870 content += GetAuthor();
1873 content += "EXPORTFORMAT:";
1874 sprintf(buffer, "%d", GetExportFormat()) ;
1878 //Print info IF COMPLEX BOX
1879 content += "COMPLEXBOX:";
1880 if (_isComplexBox) {
1881 content += "TRUE\n";
1883 content += "COMPLEXBOXNAME:";
1884 content += GetCbName();
1887 content += "PACKAGENAME:";
1888 content += GetCbPackageName();
1891 /* CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
1892 * External inputs are possible for applications and complex boxes
1893 //Print info complex input ports
1894 std::vector<int> inputs = getComplexInputPorts();
1895 int insize = inputs.size();
1896 content += "COMPLEXINPUTS:";
1897 sprintf(buffer, "%d", insize);
1901 for (int i = 0; i < insize; i++) {
1903 GObjectController *cont = _controllers[id];
1904 cont->getModel()->save(content);
1908 //Print info complex output ports
1909 std::vector<int> outputs = getComplexOutputPorts();
1910 int outsize = outputs.size();
1911 content += "COMPLEXOUTPUTS:";
1912 sprintf(buffer, "%d", outsize);
1916 for (int i = 0; i < outsize; i++) {
1917 int id = outputs[i];
1918 GObjectController *cont = _controllers[id];
1919 cont->getModel()->save(content);
1926 content += "FALSE\n";
1930 // CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
1931 // External inputs are possible for applications and complex boxes
1932 std::vector<int> inputs = getComplexInputPorts();
1933 int insize = inputs.size();
1934 content += "COMPLEXINPUTS:";
1935 sprintf(buffer, "%d", insize);
1939 for (int i = 0; i < insize; i++) {
1941 GObjectController *cont = _controllers[id];
1942 cont->getModel()->save(content);
1946 std::vector<int> boxes = getBlackBoxes();
1947 int bsize = boxes.size();
1948 content += "BOXES:";
1949 sprintf(buffer, "%d", bsize);
1953 for (int i = 0; i < bsize; i++) {
1955 // std::cout<<"id "<<id<<std::endl;//CFT
1956 GObjectController *cont = _controllers[id];
1957 // std::cout<<"nombre: "<<cont->getStatusText()<<std::endl;//CFT
1958 // std::cout<<"tipo: "<<cont->getModel()->getBBTKType()<<std::endl;//CFT
1959 // //boxesDiagram[i] = cont->getModel()->getBBTKType();//CFT
1960 // std::cout<<"nname: "<<cont->getModel()->getBBTKName()<<std::endl;//CFT
1961 // std::cout<<"categorie: "<<GetCategory()<<std::endl;//CFT
1962 // std::cout<<"type: "<<cont->getModel()->getGObjectType()<<std::endl;//CFT
1963 cont->getModel()->save(content);
1967 std::vector<int> connections = getConnections();
1968 int csize = connections.size();
1969 content += "CONNECTIONS:";
1970 sprintf(buffer, "%d", csize);
1974 for (int i = 0; i < csize; i++) {
1975 int id = connections[i];
1976 GObjectController *cont = _controllers[id];
1977 cont->getModel()->save(content);
1982 //=========================================================================
1983 void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &line)
1985 getline(inputStream, line,'\n');
1986 int size = line.length();
1989 if ( line[ size-1 ]==13 )
1991 line.erase(size-1,1);
1996 //=========================================================================
1997 void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
2000 std::string version = "<void>";
2001 std::string line = "";
2002 char delims[] = ":";
2003 char *result = NULL;
2004 char poort[POORT_MAX_LINE_SIZE_INTERPRETER];
2006 getCleanLine(inputStream, line);
2009 while (!inputStream.eof()) {
2010 if (line == "" || line[0] == '#') {
2012 getCleanLine(inputStream, line);
2014 if (line == "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file") {
2015 version = line.substr(18, 3);
2017 if (line == "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file") {
2018 version = line.substr(18, 3);
2020 if (line == "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file") {
2021 version = line.substr(18, 3);
2023 if (line == "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file") {
2024 version = line.substr(18, 3);
2026 if (line == "# - BBTKGEditor v 1.4 BBG BlackBox Diagram file") {
2027 version = line.substr(18, 3);
2029 if (line == "# - BBTKGEditor v 1.5 BBG BlackBox Diagram file") {
2030 version = line.substr(18, 3);
2032 if (line == "# - BBTKGEditor v 1.6 BBG BlackBox Diagram file") {
2033 version = line.substr(18, 3);
2035 } else if (line == "APP_START") {
2045 if ((version != "1.0") && (version != "1.1")) {
2046 getCleanLine(inputStream, line);//CATEGORY:<category of the box>
2047 char categoryTmp[30];
2048 strcpy(categoryTmp, line.c_str());
2049 result = strtok(categoryTmp, delims);
2050 result = strtok(NULL, delims);
2051 SetCategory(result);
2053 getCleanLine(inputStream, line);//DESCRIPTION:<description of the box>
2054 char descriptionTmp[1024];
2055 strcpy(descriptionTmp, line.c_str());
2056 result = strtok(descriptionTmp, delims);
2057 result = strtok(NULL, delims);
2058 SetDescription(result);
2060 getCleanLine(inputStream, line);//AUTHOR:<author>
2061 char authorTmp[255];
2062 strcpy(authorTmp, line.c_str());
2063 result = strtok(authorTmp, delims);
2064 result = strtok(NULL, delims);
2067 if(version >= "1.6")
2069 getCleanLine(inputStream, line);//EXPORTFORMAT:<0:bbs 1:ALL 2:bbs,Python 3:bbs,JavaScript>
2070 char authorTmp[255];
2071 strcpy(authorTmp, line.c_str());
2072 result = strtok(authorTmp, delims);
2073 result = strtok(NULL, delims);
2074 int exportformatTMP;
2075 std::istringstream inps(result);
2076 inps >> exportformatTMP;
2077 SetExportFormat( exportformatTMP );
2083 getCleanLine(inputStream, line);//COMPLEX_BOX:TRUE|FALSE
2084 char complexTmp[30];
2085 strcpy(complexTmp, line.c_str());
2086 result = strtok(complexTmp, delims);
2087 result = strtok(NULL, delims);
2088 std::string isComplexBox(result);
2090 if (isComplexBox == "TRUE")
2092 _isComplexBox = true;
2094 if ((version != "1.0") && (version != "1.1"))
2096 getCleanLine(inputStream, line);//COMPLEXNAME:<name of the complex box>
2097 char complexboxnameTmp[255];
2098 strcpy(complexboxnameTmp, line.c_str());
2099 result = strtok(complexboxnameTmp, delims);
2100 result = strtok(NULL, delims);
2103 getCleanLine(inputStream, line);//PACKAGENAME:<name of the package of the box>
2104 char packagenameTmp[255];
2105 strcpy(packagenameTmp, line.c_str());
2106 result = strtok(packagenameTmp, delims);
2107 result = strtok(NULL, delims);
2108 SetCbPackageName(result);
2109 } // if version !1.0 !1.1
2113 //-----------------------
2114 //- COMPLEX INPUT PORTS
2115 //-----------------------
2116 getCleanLine(inputStream, line);//COMPLEXINPUTS:num
2118 strcpy(inputs, line.c_str());
2119 result = strtok(inputs, delims);
2120 result = strtok(NULL, delims);
2123 std::istringstream inps(result);
2126 for (int i = 0; i < numInputs; i++)
2129 getCleanLine(inputStream, line);//COMPLEX_PORT
2130 getCleanLine(inputStream, line);//name
2131 std::string inputPortName(line);
2134 getCleanLine(inputStream, line);//xInic:yInic:zInic
2136 strcpy(coord, line.c_str());
2137 result = strtok(coord, delims);//xInic
2138 std::string xInic(result);
2139 result = strtok(NULL, delims);//yInic
2140 std::string yInic(result);
2141 result = strtok(NULL, delims);//zInic
2142 std::string zInic(result);
2144 double xIn, yIn, zIn;
2145 std::istringstream xSt(xInic);
2147 std::istringstream ySt(yInic);
2149 std::istringstream zSt(zInic);
2154 if (zIn==900) zIn=GPOSITION_Z;
2155 } // if version <=1.2
2157 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2159 configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
2161 } // for input complex box
2162 } // if version < 1.4
2166 //-----------------------
2167 //- COMPLEX OUTPUT PORTS
2168 //-----------------------
2170 getCleanLine(inputStream, line);//COMPLEXOUTPUTS:num
2172 strcpy(outputs, line.c_str());
2173 result = strtok(outputs, delims);
2174 result = strtok(NULL, delims);
2177 std::istringstream outps(result);
2178 outps >> numOutputs;
2180 for (int i = 0; i < numOutputs; i++)
2183 getCleanLine(inputStream, line);//COMPLEX_PORT
2184 getCleanLine(inputStream, line);//name
2185 std::string outputPortName(line);
2188 getCleanLine(inputStream, line);//xInic:yInic:zInic
2190 strcpy(coord, line.c_str());
2191 result = strtok(coord, delims);//xInic
2192 std::string xInic(result);
2193 result = strtok(NULL, delims);//yInic
2194 std::string yInic(result);
2195 result = strtok(NULL, delims);//zInic
2196 std::string zInic(result);
2198 double xIn, yIn, zIn;
2199 std::istringstream xSt(xInic);
2201 std::istringstream ySt(yInic);
2203 std::istringstream zSt(zInic);
2208 if (zIn==900) zIn=GPOSITION_Z;
2217 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2219 configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn);
2221 } // for output complex box
2222 } // if isComplexBox
2225 // RaC2012 2nd Hackfest
2226 if(version >= "1.4")
2228 //-----------------------
2229 //- EXTERNAL INPUT PORTS
2230 //-----------------------
2231 getCleanLine(inputStream, line);//COMPLEXINPUTS:num
2233 strcpy(inputs, line.c_str());
2234 result = strtok(inputs, delims);
2235 result = strtok(NULL, delims);
2238 std::istringstream inps(result);
2241 for (int i = 0; i < numInputs; i++)
2243 getCleanLine(inputStream, line);//COMPLEX_PORT
2244 getCleanLine(inputStream, line);//name
2245 std::string inputPortName(line);
2246 getCleanLine(inputStream, line);//xInic:yInic:zInic
2248 strcpy(coord, line.c_str());
2249 result = strtok(coord, delims);//xInic
2250 std::string xInic(result);
2251 result = strtok(NULL, delims);//yInic
2252 std::string yInic(result);
2253 result = strtok(NULL, delims);//zInic
2254 std::string zInic(result);
2255 double xIn, yIn, zIn;
2256 std::istringstream xSt(xInic);
2258 std::istringstream ySt(yInic);
2260 std::istringstream zSt(zInic);
2264 if (zIn==900) zIn=GPOSITION_Z;
2272 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2273 configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
2274 } // for external input
2275 } // if(version >= "1.4")
2278 getCleanLine(inputStream, line);//BOXES:num
2280 strcpy(boxes, line.c_str());
2281 result = strtok(boxes, delims);
2282 result = strtok(NULL, delims);
2285 std::istringstream is(result);
2288 for (int i = 0; i < numBoxes; i++)
2291 getCleanLine(inputStream, line);//BOX
2292 getCleanLine(inputStream, line);//package:type:name
2294 strcpy(box, line.c_str());
2295 result = strtok(box, delims);//package
2296 std::string package(result);
2297 result = strtok(NULL, delims);//type
2298 std::string type(result);
2299 result = strtok(NULL, delims);//name
2300 std::string name(result);
2303 getCleanLine(inputStream, line);//ISEXEC:TRUE|FALSE
2305 strcpy(exec, line.c_str());
2306 result = strtok(exec, delims);//ISEXEC
2307 result = strtok(NULL, delims);//TRUE|FALSE
2308 std::string isExec(result);
2311 getCleanLine(inputStream, line);//xInic:yInic:zInic
2313 strcpy(coord, line.c_str());
2314 result = strtok(coord, delims);//xInic
2315 std::string xInic(result);
2316 result = strtok(NULL, delims);//yInic
2317 std::string yInic(result);
2318 result = strtok(NULL, delims);//zInic
2319 std::string zInic(result);
2320 double xIn, yIn, zIn;
2321 std::istringstream xSt(xInic);
2323 std::istringstream ySt(yInic);
2325 std::istringstream zSt(zInic);
2330 if (zIn==900) zIn=GPOSITION_Z;
2339 getCleanLine(inputStream, line);//xEnd:yEnd:zEnd
2340 strcpy(coord, line.c_str());
2341 result = strtok(coord, delims);//xEnd
2342 std::string xEnd(result);
2343 result = strtok(NULL, delims);//yEnd
2344 std::string yEnd(result);
2345 result = strtok(NULL, delims);//zEnd
2346 std::string zEnd(result);
2348 double xEn, yEn, zEn;
2349 std::istringstream xEt(xEnd);
2351 std::istringstream yEt(yEnd);
2353 std::istringstream zEt(zEnd);
2358 if (zEn==900) zEn=GPOSITION_Z;
2361 yEn = yIn-BOX_HEIGHT;
2363 bool boxExecutable = false;
2364 if (isExec == "TRUE")
2366 boxExecutable = true;
2369 int idBox = createGBlackBox(xIn, yIn, package, type);
2370 configGBlackBox(idBox, xIn, yIn, zIn, name, boxExecutable, xEn, yEn, zEn);
2372 GObjectController *cont = _controllers[idBox];
2373 GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel();
2376 getCleanLine(inputStream, line);//PORT o FIN_BOX
2377 std::string port = line.substr(0, 4);
2378 while (port == "PORT")
2380 getCleanLine(inputStream, line);//name:value
2381 if (line.length()>=POORT_MAX_LINE_SIZE_INTERPRETER-1)
2383 line=line.substr(0, POORT_MAX_LINE_SIZE_INTERPRETER-1);
2386 strcpy(poort, line.c_str());
2387 result = strtok(poort, delims);//name
2388 std::string name(result);
2390 //EED 16 oct 2012 Adding at the end character " if necesary in the value definition
2391 result = strtok(NULL, delims);//value
2392 if (( result[0]=='"' ) && ( result[ strlen(result)-1 ]!='"' ) )
2394 std::string tmpString=" ";
2395 tmpString[0]=34; // character "
2396 strcat(result,tmpString.c_str());
2398 std::string value(result);
2399 bbmod->setValueToInput(name, value);
2400 getCleanLine(inputStream, line);//PORT o FIN_BOX
2401 port = line.substr(0, 4);
2404 //EED bbmod->notifyObservers(_idManager);
2409 getCleanLine(inputStream, line);//CONNECTIONS:num
2411 strcpy(conns, line.c_str());
2412 result = strtok(conns, delims);
2413 result = strtok(NULL, delims);
2415 std::istringstream isCons(result);
2419 for (int i = 0; i < numConns; i++)
2422 getCleanLine(inputStream, line);//CONNECTION
2423 getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName
2425 strcpy(connec, line.c_str());
2426 result = strtok(connec, delims);
2427 std::string nameStartBox(result);
2428 result = strtok(NULL, delims);
2429 std::string nameStartPort(result);
2430 result = strtok(NULL, delims);
2431 std::string nameEndBox(result);
2432 result = strtok(NULL, delims);
2433 std::string nameEndPort(result);
2434 int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort);
2435 if (version != "1.0") {
2436 //Readding control points of the manualContour
2437 GConnectorController *tempp = (GConnectorController*) _controllers[idCon];
2438 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2439 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2440 getCleanLine(inputStream, line); //NumberOfControlPoints:##
2441 strcpy(conns, line.c_str());
2442 result = strtok(conns, delims);
2443 result = strtok(NULL, delims);
2444 int numberOfControlPoints;
2445 std::istringstream isCons(result);
2446 isCons >> numberOfControlPoints;
2447 for (int ii = 0; ii < numberOfControlPoints; ii++) {
2448 getCleanLine(inputStream, line); //XX:YY:ZZ
2450 strcpy(connec, line.c_str());
2452 result = strtok(connec, delims);
2453 std::istringstream isPointX(result);
2455 result = strtok(NULL, delims);
2456 std::istringstream isPointY(result);
2458 result = strtok(NULL, delims);
2459 std::istringstream isPointZ(result);
2463 if (pz==900) pz=GPOSITION_Z;
2471 conMod->getManualContourModel()->InsertPoint_id(ii + 1, px, py, pz);
2472 conView->getManualContourView()->AddPoint();
2474 }// if version !=1.0
2478 //=========================================================================
2481 //=========================================================================
2482 void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput,
2483 std::string portName, double xIn, double yIn, double zIn)
2486 if (inputoutput == true) {
2487 idPort = createGComplexBoxInputPort(portName);
2489 idPort = createGComplexBoxOutputPort(portName);
2491 GObjectController *cont = _controllers[idPort];
2492 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2493 cbmod->setInicPoint(xIn, yIn, zIn);
2494 cbmod->notifyObservers(_idManager);
2496 //=========================================================================
2499 //=========================================================================
2500 GBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
2505 GBoxModel *boxModel = NULL;
2506 std::vector<int> lstB = getBlackBoxes();
2507 for (j = 0; j < (int) lstB.size(); j++) {
2509 bMod = (GBoxModel*) _controllers[idB]->getModel();
2510 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2518 if (boxModel == NULL) {
2519 std::vector<int> lstInputs = getComplexInputPorts();
2520 for (j = 0; j < (int) lstInputs.size(); j++) {
2522 bMod = (GBoxModel*) _controllers[idB]->getModel();
2523 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2531 std::vector<int> lstOutputs = getComplexOutputPorts();
2532 for (j = 0; j < (int) lstOutputs.size(); j++) {
2533 int idB = lstOutputs[j];
2534 bMod = (GBoxModel*) _controllers[idB]->getModel();
2535 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2547 //=========================================================================
2550 int wxVtkSceneManager::configGConnetion(std::string nameStartBox,
2551 std::string nameStartPort, std::string nameEndBox,
2552 std::string nameEndPort) {
2554 GBoxModel *boxModel;
2555 GPortModel *startP = NULL;
2556 GPortModel *endP = NULL;
2558 boxModel = findGBox(nameStartBox);
2559 if(boxModel == NULL)
2561 printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str());
2563 if (boxModel != NULL) {
2564 startP = boxModel->getOutputPort(nameStartPort);
2566 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() );
2570 boxModel = findGBox(nameEndBox);
2571 if(boxModel == NULL)
2573 printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str());
2575 if (boxModel != NULL) {
2576 endP = boxModel->getInputPort(nameEndPort);
2578 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());
2583 int idCon = createGConnector(startP);
2585 _worldState = NOTHING_HAPPENS;
2586 GConnectorController *tempp = (GConnectorController*) _controllers[idCon];
2588 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2589 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2590 tempp->endContourCreation();
2591 conMod->setEndPort(endP);
2592 conView->updateStartEndPoints();
2596 //=========================================================================
2598 bool wxVtkSceneManager::boxExist(std::string boxname) {
2600 std::map<int, GObjectController*>::iterator it;
2601 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2602 GObjectController *cont = it->second;
2603 if (cont->getModel()->getBBTKName() == boxname) {
2610 //=========================================================================
2612 std::vector<int> wxVtkSceneManager::getBlackBoxes() {
2613 std::vector<int> vect;
2614 std::map<int, GObjectController*>::iterator it;
2615 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2616 GObjectController *cont = it->second;
2617 if (cont->getGObjectType() == GBLACKBOX) {
2618 vect.push_back(cont->getId());
2624 //=========================================================================
2626 std::vector<int> wxVtkSceneManager::getComplexInputPorts() {
2627 std::vector<int> vect;
2628 std::map<int, GObjectController*>::iterator it;
2629 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2630 GObjectController *cont = it->second;
2631 if (cont->getGObjectType() == GCOMPLEXINPUTPORT) {
2632 vect.push_back(cont->getId());
2638 //=========================================================================
2640 std::vector<int> wxVtkSceneManager::getComplexOutputPorts() {
2641 std::vector<int> vect;
2642 std::map<int, GObjectController*>::iterator it;
2643 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2644 GObjectController *cont = it->second;
2645 if (cont->getGObjectType() == GCOMPLEXOUTPUTPORT) {
2646 vect.push_back(cont->getId());
2652 //=========================================================================
2654 std::vector<int> wxVtkSceneManager::getConnections() {
2655 std::vector<int> vect;
2656 std::map<int, GObjectController*>::iterator it;
2657 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2658 GObjectController *cont = it->second;
2659 if (cont->getGObjectType() == GCONNECTOR) {
2660 vect.push_back(cont->getId());
2666 //=========================================================================
2668 bool wxVtkSceneManager::isComplexBox() {
2669 return _isComplexBox;
2672 //=========================================================================
2674 void wxVtkSceneManager::setComplexBox(bool val) {
2675 _isComplexBox = val;
2678 //=========================================================================
2680 int wxVtkSceneManager::addObjectController(GObjectController* objController) {
2681 //Register the controller of the new object
2682 registerController((InteractorStyleMaracas*) objController);
2683 //Add the object to the objects list
2684 int newId = _contLastId;//_controllers.size();
2685 objController->setId(newId);
2686 _controllers[newId] = objController;
2687 //std::cout << "DFCH: int wxVtkSceneManager::addObjectController(GObjectController* objController) ---- _contLastId = " << _contLastId << std::endl;
2692 //=========================================================================
2694 void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objectsMap)
2696 std::map<int, int> oldIdNewIdBoxes;
2697 std::vector<int> connections;
2698 std::vector<int> newBoxesID;
2699 std::map<int, GObjectController*>::iterator it;
2700 for (it = objectsMap.begin(); it != objectsMap.end(); ++it)
2702 GObjectController *cont = it->second;
2703 int type = cont->getGObjectType();
2704 if (type == GBLACKBOX)
2707 double xInic, yInic, zInic;
2708 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
2709 copyBox->getInicPoint(xInic, yInic, zInic);
2710 int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), copyBox->getBBTKType());
2712 int idcB = copyBox->getObjectId();
2713 oldIdNewIdBoxes[idcB] = idBox;
2714 cont = _controllers[idBox];
2715 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
2716 newbox->setInicPoint(xInic, yInic, zInic);
2717 int num = newbox->getNumInputPorts();
2718 for (int j = 0; j < num; j++)
2720 newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
2724 // newbox->move(xInic + 20, yInic + 20, zInic);
2725 newbox->move(xInic + 14, yInic + 6, zInic);
2727 newbox->notifyObservers(_idManager);
2728 newBoxesID.push_back(newbox->getObjectId());
2730 } else if (type == GCONNECTOR) {
2731 int idCon = cont->getId();
2732 connections.push_back(idCon);
2737 for (int i = 0; i < (int) connections.size(); i++)
2739 int objId = connections[i];
2740 GObjectController *cont = objectsMap[objId];
2741 GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
2743 GPortModel* startPort = connectModel->getStartPort();
2744 int startPortIndex = startPort->getPosInBox();
2745 GPortModel* endPort = connectModel->getEndPort();
2746 int endPortIndex = endPort->getPosInBox();
2748 GBlackBoxModel* startPortParentBox =
2749 (GBlackBoxModel*) startPort->getParentBox();
2750 GBlackBoxModel* endPortParentBox =
2751 (GBlackBoxModel*) endPort->getParentBox();
2753 int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
2754 int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
2756 GBlackBoxModel* newStartBox =
2757 (GBlackBoxModel*) _controllers[idNewStartBox]->getModel();
2758 GBlackBoxModel* newEndBox =
2759 (GBlackBoxModel*) _controllers[idNewEndBox]->getModel();
2761 GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
2762 GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
2764 // Creates connection
2765 int idCon = createGConnector(newStartPort);
2766 GConnectorController *tempp =
2767 (GConnectorController*) _controllers[idCon];
2768 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2769 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2770 tempp->endContourCreation();
2771 conMod->setEndPort(newEndPort);
2772 conView->updateStartEndPoints();
2775 /// the new selected boxes are the duplicate ones
2777 UnSelectBlackBoxes();
2778 for (int i = 0; i < newBoxesID.size(); i++)
2780 _selectedObjects.push_back(newBoxesID.at(i));
2783 for (int i = 0; i < (int) _selectedObjects.size(); i++)
2785 int id = _selectedObjects[i];
2786 GObjectController* cont = _controllers[id];
2787 cont->getView()->setState(SELECTED);
2788 cont->getModel()->notifyObservers(_idManager);
2793 //=========================================================================
2795 int wxVtkSceneManager::getNumSelectedObjects() {
2796 return _selectedObjects.size();
2799 //=========================================================================
2801 std::map<int, GObjectController*> wxVtkSceneManager::getSelectedObjects() {
2802 std::map<int, GObjectController*> mapSelected;
2804 std::map<int, GObjectController*>::iterator it;
2805 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2806 GObjectController *cont = it->second;
2807 if (cont->getGObjectType() == GBLACKBOX && cont->getView()->getState()
2809 mapSelected[cont->getId()] = cont;
2813 std::map<int, GObjectController*>::iterator it2;
2814 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) {
2815 GObjectController *cont = it2->second;
2816 if (cont->getGObjectType() == GCONNECTOR) {
2817 GConnectorModel* cmod = (GConnectorModel*) cont->getModel();
2818 GBoxModel* endPortParentBox = cmod->getEndPort()->getParentBox();
2819 GBoxModel* startPortParentBox =
2820 cmod->getStartPort()->getParentBox();
2822 std::map<int, GObjectController*>::iterator iterOBJ1 =
2823 mapSelected.find(startPortParentBox->getObjectId());
2824 std::map<int, GObjectController*>::iterator iterOBJ2 =
2825 mapSelected.find(endPortParentBox->getObjectId());
2827 if (iterOBJ1 != mapSelected.end() && iterOBJ2 != mapSelected.end()) {
2828 int ID = cont->getId();
2829 mapSelected[ID] = cont;
2836 //=========================================================================
2838 void wxVtkSceneManager::addObjects(std::map<int, GObjectController*> objectsMap) {
2840 std::map<int, int> oldIdNewIdBoxes;
2841 std::vector<int> connections;
2843 std::map<int, GObjectController*>::iterator it;
2844 for (it = objectsMap.begin(); it != objectsMap.end(); ++it) {
2845 GObjectController *cont = it->second;
2846 int type = cont->getGObjectType();
2848 if (type == GBLACKBOX) {
2850 double xInic, yInic, zInic;
2851 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
2852 copyBox->getInicPoint(xInic, yInic, zInic);
2853 int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(),copyBox->getBBTKType());
2855 int idcB = copyBox->getObjectId();
2856 oldIdNewIdBoxes[idcB] = idBox;
2857 cont = _controllers[idBox];
2858 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
2859 newbox->setInicPoint(xInic, yInic, zInic);
2860 int num = newbox->getNumInputPorts();
2861 for (int j = 0; j < num; j++)
2863 newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
2865 newbox->notifyObservers(_idManager);
2866 } else if (type == GCONNECTOR) {
2867 int idCon = cont->getId();
2868 connections.push_back(idCon);
2873 for (int i = 0; i < (int) connections.size(); i++) {
2874 int objId = connections[i];
2875 GObjectController *cont = objectsMap[objId];
2876 GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
2878 GPortModel* startPort = connectModel->getStartPort();
2879 int startPortIndex = startPort->getPosInBox();
2880 GPortModel* endPort = connectModel->getEndPort();
2881 int endPortIndex = endPort->getPosInBox();
2883 GBlackBoxModel* startPortParentBox =
2884 (GBlackBoxModel*) startPort->getParentBox();
2885 GBlackBoxModel* endPortParentBox =
2886 (GBlackBoxModel*) endPort->getParentBox();
2888 int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
2889 int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
2891 GBlackBoxModel* newStartBox =
2892 (GBlackBoxModel*) _controllers[idNewStartBox]->getModel();
2893 GBlackBoxModel* newEndBox =
2894 (GBlackBoxModel*) _controllers[idNewEndBox]->getModel();
2896 GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
2897 GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
2899 // Creates connection
2900 int idCon = createGConnector(newStartPort);
2901 GConnectorController *tempp =
2902 (GConnectorController*) _controllers[idCon];
2903 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2904 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2905 tempp->endContourCreation();
2906 conMod->setEndPort(newEndPort);
2907 conView->updateStartEndPoints();
2910 std::map<int, int>::iterator itIds;
2911 for (itIds = oldIdNewIdBoxes.begin(); itIds != oldIdNewIdBoxes.end(); ++itIds) {
2912 int idOld = itIds->first;
2913 int idNew = itIds->second;
2915 GBlackBoxModel* oldBox =
2916 (GBlackBoxModel*) objectsMap[idOld]->getModel();
2917 GBlackBoxModel* newBox =
2918 (GBlackBoxModel*) _controllers[idNew]->getModel();
2920 std::vector<int> oldInputConnections = oldBox->getConnectedInputs();
2921 std::vector<int> oldOutputConnections = oldBox->getConnectedOutputs();
2922 std::vector<int> newInputConnections = newBox->getConnectedInputs();
2923 std::vector<int> newOutputConnections = newBox->getConnectedOutputs();
2925 for (int k = 0; k < (int) oldInputConnections.size(); k++) {
2927 //EED int toCreate=-1;
2928 for (int l = 0; l < (int) newInputConnections.size() && !exist; l++) {
2929 if (oldInputConnections[k] == newInputConnections[l]) {
2934 if (exist == false) {
2935 //Create complex input
2936 int posInBox = oldInputConnections[k];
2937 GPortModel* inputPort = oldBox->getInputPort(posInBox);
2938 std::string inputPortName = inputPort->getBBTKName();
2939 int idInputPort = createGComplexBoxInputPort(inputPortName);
2940 GObjectController *cont = _controllers[idInputPort];
2941 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2942 double xIn, yIn, zIn;
2943 inputPort->getInicPoint(xIn, yIn, zIn);
2945 cbmod->setInicPoint(xIn, yIn, zIn);
2946 cbmod->notifyObservers(_idManager);
2948 GPortModel* inputPortEnd = newBox->getInputPort(posInBox);
2950 // Creates connection
2951 int idCon = createGConnector(cbmod->getOutputPort(0));
2952 GConnectorController *tempp =
2953 (GConnectorController*) _controllers[idCon];
2954 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2955 vtkGConnectorView *conView =
2956 (vtkGConnectorView*) tempp->getView();
2957 tempp->endContourCreation();
2958 conMod->setEndPort(inputPortEnd);
2959 conView->updateStartEndPoints();
2965 for (int k = 0; k < (int) oldOutputConnections.size(); k++) {
2967 //EED int toCreate=-1;
2968 for (int l = 0; l < (int) newOutputConnections.size() && !exist; l++) {
2969 if (oldOutputConnections[k] == newOutputConnections[l]) {
2974 if (exist == false) {
2975 //Create complex output
2976 int posInBox = oldOutputConnections[k];
2977 GPortModel* outputPort = oldBox->getOutputPort(posInBox);
2978 std::string outputPortName = outputPort->getBBTKName();
2979 int idOutputPort = createGComplexBoxOutputPort(outputPortName);
2980 GObjectController *cont = _controllers[idOutputPort];
2981 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2982 double xIn, yIn, zIn;
2983 outputPort->getInicPoint(xIn, yIn, zIn);
2985 cbmod->setInicPoint(xIn, yIn, zIn);
2986 cbmod->notifyObservers(_idManager);
2988 GPortModel* outputPortEnd = newBox->getOutputPort(posInBox);
2990 // Creates connection
2991 int idCon = createGConnector(outputPortEnd);
2992 GConnectorController *tempp =
2993 (GConnectorController*) _controllers[idCon];
2994 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2995 vtkGConnectorView *conView =
2996 (vtkGConnectorView*) tempp->getView();
2997 tempp->endContourCreation();
2998 conMod->setEndPort(cbmod->getInputPort(0));
2999 conView->updateStartEndPoints();
3009 //=========================================================================
3010 void wxVtkSceneManager::SetCbName(std::string cbName) {
3012 if (_cbName == "") {
3013 _cbName = "<complex box name>";
3017 //=========================================================================
3018 std::string wxVtkSceneManager::GetCbName() {
3022 //=========================================================================
3023 void wxVtkSceneManager::SetCbPackageName(std::string packagename) {
3024 _cbPackageName = packagename;
3025 if (_cbPackageName == "") {
3026 _cbPackageName = "<package name of the complex box>";
3030 //=========================================================================
3031 std::string wxVtkSceneManager::GetCbPackageName()
3033 return _cbPackageName;
3036 //=========================================================================
3037 void wxVtkSceneManager::SetAuthor(std::string author)
3042 _Author = "<author of the box>";
3046 //=========================================================================
3047 std::string wxVtkSceneManager::GetAuthor()
3052 //=========================================================================
3053 void wxVtkSceneManager::SetExportFormat(int exportformat)
3055 _ExportFormat = exportformat;
3058 //=========================================================================
3059 int wxVtkSceneManager::GetExportFormat()
3061 return _ExportFormat;
3064 //=========================================================================
3065 void wxVtkSceneManager::SetCategory(std::string category)
3067 _Category = category;
3068 if (_Category == "")
3070 _Category = "<category of the box>";
3074 //=========================================================================
3075 std::string wxVtkSceneManager::GetCategory()
3080 //=========================================================================
3081 void wxVtkSceneManager::SetDescription(std::string description) {
3082 _Description = description;
3083 if (_Description == "") {
3084 _Description = "<description of the box>";
3088 //=========================================================================
3089 std::string wxVtkSceneManager::GetDescription() {
3090 return _Description;
3093 //=========================================================================
3095 void wxVtkSceneManager::SetMessageKind(std::string kind) {
3096 _MessageKind = kind;
3100 //=========================================================================
3102 std::string wxVtkSceneManager::GetMessageKind(){
3103 return _MessageKind;
3106 //=========================================================================
3108 void wxVtkSceneManager::SetMessageLevel(std::string Level){
3109 _MessageLevel = Level;
3112 //=========================================================================
3114 std::string wxVtkSceneManager::GetMessageLevel(){
3115 return _MessageLevel;
3118 //=========================================================================
3120 std::vector< std::string> wxVtkSceneManager::GetExternalInputsNames()
3123 std::vector< std::string> extInputs;
3124 std::map<int, GObjectController*>::iterator it;
3125 for (it = _controllers.begin(); it != _controllers.end(); ++it)
3127 GObjectController *cont = it->second;
3128 if (cont->getGObjectType() == GCOMPLEXINPUTPORT)
3130 extInputs.push_back(cont->getModel()->getBBTKName());
3136 //=========================================================================
3137 void wxVtkSceneManager::printAll(int com , int sta )
3139 int tmpState = sta ;
3140 if ( tmpState == NOTHING_HAPPENS ) {
3141 std::cout << "CONTROLER STATE---->NOTHING_HAPPENS\n" ;
3143 if ( tmpState == HIGHLIGHTED ) {
3144 std::cout << "CONTROLER STATE---->HIGHLIGHTED\n" ;
3146 if ( tmpState == POSSIBLE_CONNECTION ) {
3147 std::cout << "CONTROLER STATE---->POSSIBLE_CONNECTION\n" ;
3149 if ( tmpState == SELECTED_POSSIBLE_CONNECTION ) {
3150 std::cout << "CONTROLER STATE---->SELECTED_POSSIBLE_CONNECTION\n" ;
3152 if ( tmpState == CLICKED ) {
3153 std::cout << "CONTROLER STATE---->CLICKED\n" ;
3155 if ( tmpState == DRAG ) {
3156 std::cout << "CONTROLER STATE---->DRAG\n" ;
3158 if ( tmpState == SELECTED ) {
3159 std::cout << "CONTROLER STATE---->SELECTED\n" ;
3161 if ( tmpState == CREATING_CONTOUR ) {
3162 std::cout << "CONTROLER STATE---->CREATING_CONTOUR\n" ;
3168 if ( command == INIT_CREATION_CONTOUR ) {
3169 std::cout << "COMMAND ----> INIT_CREATION_CONTOUR \n" ;
3171 if ( command == FIN_CREATION_CONTOUR ) {
3172 std::cout << "COMMAND ----> FIN_CREATION_CONTOUR \n" ;
3174 if ( command == ADD_TO_SELECTED ) {
3175 std::cout << "COMMAND ----> ADD_TO_SELECTED \n" ;
3177 if ( command == DRAG_OBJECTS ) {
3178 std::cout << "COMMAND ----> DRAG_OBJECTS \n" ;
3180 if ( command == EDIT_BLACKBOX ) {
3181 std::cout << "COMMAND ----> EDIT_BLACKBOX \n" ;
3183 if ( command == REMOVE_FROM_SELECTED ) {
3184 std::cout << "COMMAND ----> REMOVE_FROM_SELECTED \n" ;
3189 //=========================================================================
3191 void wxVtkSceneManager::SelectBoxWithPossibleName( std::string possibleName )
3193 UnSelectBlackBoxes();
3194 std::map<int, GObjectController*>::iterator it;
3195 GObjectController *desc;
3199 std::string possibleNameAA = possibleName;
3200 std::string boxNameBB;
3202 size = possibleNameAA.length();
3203 for (i=0;i<size;i++)
3205 if ((possibleNameAA[i]>='A')&&(possibleNameAA[i]<='Z')) { possibleNameAA[i]=possibleNameAA[i]+32; }
3207 for (it = _controllers.begin(); it != _controllers.end(); ++it)
3210 type = desc->getGObjectType();
3211 if ( type==GBLACKBOX)
3213 boxNameBB = desc->getModel()->getBBTKType() +":"+ desc->getModel()->getBBTKName();
3214 size=boxNameBB.length();
3215 for (i=0;i<size;i++)
3217 if ((boxNameBB[i]>='A')&&(boxNameBB[i]<='Z')) { boxNameBB[i]=boxNameBB[i]+32; }
3220 pos=boxNameBB.find( possibleNameAA );
3223 desc->getView()->setState(SELECTED);
3224 id = desc->getModel()->getObjectId();
3225 desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
3232 } // EO namespace bbtk