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 ??";
81 _Description = "Description ??";
85 _bugTextActor_text = "void";
86 _bugTextActor_status = 0;
90 _idManager = idManager;
92 _bbtkfactory = bbtkfactory;
94 _startDragging = false;
95 _isComplexBox = false;
97 if (_baseView != NULL) {
100 "RaC-EED 21-06-2010 %p wxVtkSceneManager::wxVtkSceneManager If you comment this line, the drag and drop functionnality is not initialized.\n",
103 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent);
107 _worldState = NOTHING_HAPPENS;
108 registerController(this);
111 _idConnectionInCreation = -1;
120 //=========================================================================
122 void wxVtkSceneManager::disconnectDrop()
124 //EED02JUIN2010 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
125 // _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget( new tmpClasswxTextDropTarget() );
128 //=========================================================================
130 wxVtkSceneManager::~wxVtkSceneManager()
137 //=========================================================================
139 void wxVtkSceneManager::configureBaseView()
141 vtkInteractorStyleBaseView2D *interactorstylebaseview = vtkInteractorStyleBaseView2D::New();
142 _baseView->SetInteractorStyleBaseView(interactorstylebaseview);
143 // Important to activate the 2D interaction system
144 crea::wxVTKRenderWindowInteractor *iren = _baseView->GetWxVTKRenderWindowInteractor();
145 interactorstylebaseview->SetInteractor(iren);
146 iren->SetInteractorStyle(interactorstylebaseview);
147 interactorstylebaseview->SetwxVtkBaseView(_baseView);
148 _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
149 _baseView->GetRenderer()->ResetCamera(-100, 100, -100, 100, -1000, 1000);
150 _baseView->GetRenderer()->GetActiveCamera()->Zoom(20);
151 _baseView->GetRenderer()->SetBackground(0.9, 0.9, 0.9);
152 _baseView->GetRenderer()->GradientBackgroundOn();
154 _textActor = vtkTextActor3D::New();
155 // _textActor = vtkTextActor::New();
156 _textActor->SetPosition(-9999, -9999, GPOSITION_Z);
157 _textActor->SetInput("<void>");
159 // _textActor->GetTextProperty()->SetFontSize(60);
160 _textActor->GetTextProperty()->SetFontSize(40);
161 _textActor->GetTextProperty()->BoldOn();
162 _textActor->GetTextProperty()->SetFontFamilyToArial();
163 _textActor->GetTextProperty()->ShadowOff();
164 _textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R, PORTTEXT_NH_G,PORTTEXT_NH_B);
165 _baseView->GetRenderer()->AddActor(_textActor);
166 // Actor Fill_Port_Text
170 double zInic = GPOSITION_Z;
171 vtkPolygon *aPolygon = vtkPolygon::New();
172 _fillObjectActor = vtkActor::New();
173 _pts = vtkPoints::New();
176 double w = 100, h = 10, b = h / 15, t = 3;
177 _pts->SetNumberOfPoints(21);
178 _pts->InsertPoint(0, xInic + w * 0.33 - t / 2, yInic, zInic);
179 _pts->InsertPoint(1, xInic + w * 0.33, yInic - t, zInic);
180 _pts->InsertPoint(2, xInic + w * 0.33 + t / 2, yInic, zInic);
181 _pts->InsertPoint(3, xInic + w * 0.33 + t / 2, yInic, zInic);
182 _pts->InsertPoint(4, xInic + w - b * 4, yInic + b * 0, zInic);
184 _pts->InsertPoint(5, xInic + w - b * 4, yInic + b * 0, zInic);
185 _pts->InsertPoint(6, xInic + w - b * 2, yInic + b * 1, zInic);
186 _pts->InsertPoint(7, xInic + w - b * 1, yInic + b * 2, zInic);
187 _pts->InsertPoint(8, xInic + w - b * 0, yInic + b * 4, zInic);
189 _pts->InsertPoint(9, xInic + w - b * 0, yInic + h - b * 4, zInic);
190 _pts->InsertPoint(10, xInic + w - b * 1, yInic + h - b * 2, zInic);
191 _pts->InsertPoint(11, xInic + w - b * 2, yInic + h - b * 1, zInic);
192 _pts->InsertPoint(12, xInic + w - b * 4, yInic + h - b * 0, zInic);
194 _pts->InsertPoint(13, xInic + b * 4, yInic + h - b * 0, zInic);
195 _pts->InsertPoint(14, xInic + b * 2, yInic + h - b * 1, zInic);
196 _pts->InsertPoint(15, xInic + b * 1, yInic + h - b * 2, zInic);
197 _pts->InsertPoint(16, xInic + b * 0, yInic + h - b * 4, zInic);
199 _pts->InsertPoint(17, xInic + b * 0, yInic + b * 4, zInic);
200 _pts->InsertPoint(18, xInic + b * 1, yInic + b * 2, zInic);
201 _pts->InsertPoint(19, xInic + b * 2, yInic + b * 1, zInic);
202 _pts->InsertPoint(20, xInic + b * 4, yInic + b * 0, zInic);
203 aPolygon->GetPointIds()->SetNumberOfIds(21);
204 for (int i = 0; i < 21; i++) {
206 aPolygon->GetPointIds()->SetId(i, i);
210 double w = BOX_WIDTH, h = BOX_HEIGHT, t = PORT_HEIGHT;
211 _pts->SetNumberOfPoints(7);
212 _pts->InsertPoint(0, xInic + t/2.0 , yInic + t , zInic );
213 _pts->InsertPoint(1, xInic + w , yInic + t , zInic );
214 _pts->InsertPoint(2, xInic + w , yInic + t + h , zInic );
215 _pts->InsertPoint(3, xInic - t*1.5 , yInic + t + h , zInic );
216 _pts->InsertPoint(4, xInic - t*1.5 , yInic + t , zInic );
217 _pts->InsertPoint(5, xInic - t/2 , yInic + t , zInic );
218 _pts->InsertPoint(6, xInic , yInic , zInic );
219 aPolygon->GetPointIds()->SetNumberOfIds(8);
220 for (int i = 0; i < 8; i++)
222 aPolygon->GetPointIds()->SetId(i, i);
223 if (i==7) aPolygon->GetPointIds()->SetId(i, 0);
225 vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New();
226 aPolygonGrid->Allocate(1, 1);
227 aPolygonGrid->InsertNextCell(aPolygon->GetCellType(),aPolygon->GetPointIds());
228 aPolygonGrid->SetPoints(_pts);
229 _aPolygonMapper = vtkDataSetMapper::New();
230 //EED 2017-01-01 Migration VTK7
231 #if VTK_MAJOR_VERSION <= 5
232 _aPolygonMapper->SetInput(aPolygonGrid);
234 _aPolygonMapper->SetInputData(aPolygonGrid);
236 _fillObjectActor->SetMapper(_aPolygonMapper);
237 _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R, PORTFILL_NH_G,PORTFILL_NH_B);
238 _fillObjectActor->GetProperty()->SetOpacity(0);
239 _aPolygonMapper->Modified();
240 _baseView->GetRenderer()->AddActor(_fillObjectActor);
244 //=========================================================================
246 std::string wxVtkSceneManager::generateANewNameForABox() {
247 std::stringstream boxname;
248 if (_numBoxes < 10) {
249 boxname << "Box0" << _numBoxes;
251 boxname << "Box" << _numBoxes;
254 return boxname.str();
257 //=========================================================================
259 std::string wxVtkSceneManager::findANewNameForABox()
261 std::string boxname = generateANewNameForABox();
262 while (boxExist(boxname) == true)
264 boxname = generateANewNameForABox();
269 //=========================================================================
270 void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn,
271 double zIn, std::string name, bool boxExecutable, double xEn,
272 double yEn, double zEn)
274 GObjectController *cont = _controllers[idBox];
275 GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel();
276 bbmod->setBBTKName(name);
277 bbmod->setInicPoint(xIn, yIn, zIn);
278 bbmod->setFinalPoint(xEn, yEn, zEn);
279 bbmod->setExecutable(boxExecutable);
280 bbmod->notifyObservers(_idManager);
283 //=========================================================================
285 int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std::string boxType)
287 _worldState = NOTHING_HAPPENS;
288 int windowHeight = _baseView->GetRenWin()->GetSize()[1];
289 int type = GBLACKBOX;
290 //Create the MVC Objects
291 GBlackBoxModel *model = (GBlackBoxModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
292 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
293 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
295 //EED 15 oct 2012 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
299 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
301 k = _bbtkfactory->GetPackage(packageName);
302 mapDesc = k->GetDescriptorMap();
304 printf("EED. ERROR!: Exception in wxVtkSceneManager::createGBlackBox for package %s, NOT EXIST\n", packageName.c_str());
307 BlackBoxDescriptor::Pointer descriptor;
309 descriptor = mapDesc[boxType];
311 printf("EED. ERROR!: Exception in wxVtkSceneManager::createGBlackBox for box %s of package %s, NOT EXIST\n", boxType.c_str(),packageName.c_str());
314 if (descriptor == NULL)
316 printf("SCP: ERROR in wxVtkSceneManager::createGBlackBox, box %s probably does not exist.\n", boxType.c_str());
319 //Prepares the initial model
320 //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height
323 double yy = windowHeight - y;
325 //z value is not important yet, because it is only used a parallel projection
326 double zz = GPOSITION_Z;
327 _baseView->TransCoordScreenToWorld(xx, yy, zz);
328 model->setInicPoint(xx, yy, zz);
330 std::stringstream stream;
332 std::string newBoxName;
333 newBoxName = findANewNameForABox();
335 stream << newBoxName;
337 std::string arraystring = stream.str();
339 model->setBBTKName(arraystring);
340 model->setBBTKType(boxType);
341 model->setBBTKPackage(packageName);
343 model->addObserver(view);
344 model->addObserver(this);
347 //EED2017 change order
348 //Associates the view with the correspondent renderer and the model.
349 //(NOTE: Refresh is only made by the view)
350 view->setModel(model);
351 view->setBaseView(_baseView);
353 //Associates the controller with the correspondent model and view
354 controller->setModelAndView(model, view);
357 //Iterate and create the input ports
358 std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap =
359 descriptor->GetInputDescriptorMap();
360 std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
362 for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
364 BlackBoxInputDescriptor *desc = itInput->second;
366 // createGInputPort(GINPUTPORT, i, model, desc);
367 createGInputPort(GINPUTPORT, i, controller, desc);
371 //Iterate and create the output ports
372 std::map<std::string, BlackBoxOutputDescriptor*> descriptorOutMap =
373 descriptor->GetOutputDescriptorMap();
374 std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
376 for (itOutput = descriptorOutMap.begin(); itOutput!= descriptorOutMap.end(); ++itOutput)
378 BlackBoxOutputDescriptor *desc = itOutput->second;
380 // createGOutputPort(GOUTPUTPORT, i, model, desc);
381 createGOutputPort(GOUTPUTPORT, i, controller, desc);
385 //EED2017 change order
386 view->initVtkObjects();
388 //Resgiter change to the observers of the actual model
389 model->notifyObservers(_idManager);
390 int newId = addObjectController(controller);
396 //=========================================================================
398 int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName) {
399 //EED int windowWidth=_baseView->GetRenWin()->GetSize()[0];
400 int windowHeight = _baseView->GetRenWin()->GetSize()[1];
402 int type = GCOMPLEXINPUTPORT;
404 //Create the MVC Objects
406 GComplexBoxPortModel *model = (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
407 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
408 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
410 //Prepares the initial model
413 double yy = windowHeight - 5;
415 //z value is not important yet, because it is only used a parallel projection
416 double zz = GPOSITION_Z;
418 _baseView->TransCoordScreenToWorld(xx, yy, zz);
419 model->setInicPoint(xx, yy, zz);
421 model->setBBTKName(inputName);
422 model->setBBTKType("ComplexInputPort");
423 model->setComplexPortType(type);
425 model->addObserver(view);
426 model->addObserver(this);
428 //create the output port
429 GPortController* portController = createGPort(GOUTPUTPORT, inputName,
430 "ComplexOutputPortType","ComplexOutputPortDescriopton", 0, model);
431 model->addOutputPort((GPortModel*) portController->getModel());
433 //Associates the view with the correspondent renderer and the model.
434 //(NOTE: Refresh is only made by the view)
435 view->setModel(model);
436 view->setBaseView(_baseView);
437 view->initVtkObjects();
439 //Associates the controller with the correspondent model and view
440 controller->setModelAndView(model, view);
442 //Resgiter change to the observers of the actual model
443 model->notifyObservers(_idManager);
445 int newId = addObjectController(controller);
449 //=========================================================================
451 int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) {
452 //EED int windowWidth=_baseView->GetRenWin()->GetSize()[0];
453 int windowHeight = _baseView->GetRenWin()->GetSize()[1];
455 int type = GCOMPLEXOUTPUTPORT;
457 //Create the MVC Objects
459 GComplexBoxPortModel *model = (GComplexBoxPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
460 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
461 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
463 //Prepares the initial model
466 double yy = windowHeight - 5;
468 //z value is not important yet, because it is only used a parallel projection
469 double zz = GPOSITION_Z;
471 _baseView->TransCoordScreenToWorld(xx, yy, zz);
472 model->setInicPoint(xx, yy, zz);
474 model->setBBTKName(outputName);
475 model->setBBTKType("ComplexOutputPort");
476 model->setComplexPortType(type);
478 model->addObserver(view);
479 model->addObserver(this);
481 //create the output port
482 GPortController* portController = createGPort(GINPUTPORT, outputName,
483 "ComplexInputPort","ComplexInputPortDescription", 0, model);
484 model->addInputPort((GPortModel*) portController->getModel());
486 //Associates the view with the correspondent renderer and the model.
487 //(NOTE: Refresh is only made by the view)
488 view->setModel(model);
489 view->setBaseView(_baseView);
490 view->initVtkObjects();
492 //Associates the controller with the correspondent model and view
493 controller->setModelAndView(model, view);
495 //Resgiter change to the observers of the actual model
496 model->notifyObservers(_idManager);
498 int newId = addObjectController(controller);
502 //=========================================================================
505 //int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc)
506 int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GObjectController *gBoxControler, BlackBoxInputDescriptor *desc)
508 GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel();
509 GPortController* portController = createGPort(portType, desc->GetName(),
510 desc->GetTypeName(), desc->GetDescription(), posinBox, blackBox);
511 blackBox->addInputPort( (GPortModel*)portController->getModel() );
513 vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView();
514 vtkgboxView->addInputPort( (vtkGPortView*)portController->getView() );
516 return portController->getId();
519 //=========================================================================
522 //int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
523 int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxOutputDescriptor *desc)
525 GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel();
526 GPortController* portController = createGPort(portType, desc->GetName(),
527 desc->GetTypeName(),desc->GetDescription(), posinBox, blackBox);
528 blackBox->addOutputPort((GPortModel*) portController->getModel());
530 vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView();
531 vtkgboxView->addOutputPort( (vtkGPortView*)portController->getView() );
533 return portController->getId();
536 //=========================================================================
538 GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posInBox,GBoxModel *blackBox)
542 //Create the MVC Objects
543 GPortModel *model = (GPortModel*) GObjectsMVCFactory::getInstance()->createGObjectModel(type);
544 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
545 GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
546 model->registerInBox(blackBox, portType, posInBox);
547 model->setBBTKType(bbtkType);
548 model->setBBTKName(bbtkName);
549 model->setBBTKDescription(bbtkDescription);
550 model->addObserver(view);
551 model->addObserver(this);
552 //Associates the view with the correspondent renderer and the model.
553 //(NOTE: Refresh is only made by the view)
554 view->setModel(model);
555 view->setBaseView(_baseView);
556 //EED017 view->initVtkObjects();
557 view->createVtkObjects();
558 // view->addVtkActors();
560 //Associates the controller with the correspondent model and view
561 controller->setModelAndView(model, view);
562 model->notifyObservers(_idManager);
563 addObjectController(controller);
564 return (GPortController*) controller;
567 //=========================================================================
569 int wxVtkSceneManager::createGConnector(GPortModel* startPort)
571 int type = GCONNECTOR;
573 manualConnectorContourController *manContourControl = new manualConnectorContourController();
574 manualConnectorContourView *manContourView = new manualConnectorContourView();
575 manualContourModel *manContourModel = new manualContourModel();
576 GConnectorController *connectorcontroller = new GConnectorController();
577 GConnectorModel *connectorModel = new GConnectorModel();
578 vtkGConnectorView *connectorView = new vtkGConnectorView();
579 connectorModel->setGObjectType(type);
581 manContourModel->SetCloseContour(false);
582 connectorModel->setStartPort(startPort);
584 manContourView->SetModel(manContourModel);
585 manContourView->SetWxVtkBaseView(_baseView);
586 manContourView->SetRange(0.5);
587 manContourView->SetZ(GPOSITION_Z);
589 manContourView->SetColorNormalContour(0, 0, 1);
590 manContourView->SetColorEditContour(0.5, 0.5, 0.5);
591 manContourView->SetColorSelectContour(1, 0.8, 0);
597 * Width increased from 2 to 3, it simplifies line handling and spline control :P
601 // manContourView->SetWidthLine( 3 ) ;
603 manContourView->SetWidthLine( 1 ) ;
605 manContourView->SetShowText(false);
607 manContourControl->SetModelView(manContourModel, manContourView);
609 manContourControl->CreateNewManualContour();
613 connectorModel->getInicPoint(x, y, z);
616 manContourControl->SetState(1);
617 manContourModel->SetCloseContour(false);
619 manContourModel->AddPoint(x, y, z);
620 manContourView->AddPoint();
622 manContourModel->AddPoint(x, y, z);
623 manContourView->AddPoint();
625 int bak = manContourControl->GetNumberOfPointsManualContour() - 1;
626 manContourControl->_bakIdPoint = bak;
628 manContourControl->SetMoving(false);
630 connectorcontroller->setModelAndView(connectorModel, connectorView);
632 int newId = addObjectController(connectorcontroller);
634 connectorcontroller->setManualContourController(manContourControl);
635 connectorModel->setManualContourModel(manContourModel);
636 connectorView->setManualContourView(manContourView);
637 connectorView->setModel(connectorModel);
638 connectorView->setBaseView(_baseView);
640 connectorModel->addObserver(connectorView);
641 connectorModel->addObserver(this);
643 // manContourView->Refresh();
648 //=========================================================================
650 void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
652 vtkInteractorStyleBaseView * baseViewControlManager = (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView();
653 baseViewControlManager->AddInteractorStyleMaracas(param);
656 //=========================================================================
658 void wxVtkSceneManager::unregisterController(InteractorStyleMaracas *param)
660 vtkInteractorStyleBaseView *baseViewControlManager = (vtkInteractorStyleBaseView*) _baseView->GetInteractorStyleBaseView();
661 baseViewControlManager->RemoveInteractorStyleMaracas(param);
664 //=========================================================================
666 vtkRenderer* wxVtkSceneManager::getRenderer()
668 return _baseView->GetRenderer();
671 //=========================================================================
673 vtkRenderWindow* wxVtkSceneManager::getRenderWindow()
675 return _baseView->GetRenWin();
677 //=========================================================================
680 //=========================================================================
681 int wxVtkSceneManager::GetIndexInSelected(int idControler)
684 for (int i = 0; i < (int) _selectedObjects.size(); i++)
686 if (_selectedObjects[i] == idControler)
694 //=========================================================================
696 void wxVtkSceneManager::update(int idController, int command) {
698 if (command != NO_COMMAND)
700 if (command == ADD_TO_SELECTED)
702 if (GetIndexInSelected(idController) == -1)
704 _selectedObjects.push_back(idController);
706 } else if (command == REMOVE_FROM_SELECTED) {
707 int index = GetIndexInSelected(idController);
710 _selectedObjects.erase(_selectedObjects.begin() + index);
712 } else if (command == INIT_CREATION_CONTOUR) {
714 typedef std::map<int , GObjectController*>::iterator TIterator ;
717 // Find current item in the controller
718 iter = _controllers.find( idController ) ;
719 iter_end = _controllers.end( ) ;
721 if ( iter != iter_end ) {
722 GObjectController* gobjc = iter->second ;
724 std::string bbtkType = gobjc->getModel( )->getBBTKType( ) ;
725 // And if the item is a port
726 if ( gobjc->getModel( )->getGObjectType( ) == GPORT ) {
727 TIterator c_it = _controllers.begin( ) ;
728 // Go through all componets
729 for ( c_it ; c_it != iter_end ; c_it++ ) {
730 GObjectController* obc = c_it->second ;
731 int obc_type = obc->getModel( )->getGObjectType( ) ;
732 std::string obc_bbtkType = obc->getModel( )->getBBTKType( ) ;
733 // if the component is a port and the type is the same of that selected
734 if ( ( obc_type == GPORT ) && ( obc_bbtkType == bbtkType ) ) {
736 obc->getView( )->setState( POSSIBLE_CONNECTION ) ;
737 //obc->getView( )->setState( HIGHLIGHTED ) ;
745 _worldState = INIT_CREATION_CONTOUR;
746 GObjectController* cont = _controllers[idController];
747 GPortModel* startOutputPort = (GPortModel*) cont->getModel();
749 // The last one is the controller of the connector
750 std::map<int, GObjectController*>::iterator it2;
752 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
754 GObjectController *cont = it2->second;
755 if (cont->getGObjectType() == GPORT)
757 GPortModel* port = (GPortModel*) cont->getModel();
758 if (port->getPortType() == GINPUTPORT)
760 cont->SetActive(true);
762 cont->getView()->setState(NOTHING_HAPPENS);
763 cont->getModel()->notifyObservers(_idManager);
764 cont->SetActive(false);
767 cont->getView()->setState(NOTHING_HAPPENS);
768 cont->getModel()->notifyObservers(_idManager);
769 cont->SetActive(false);
772 _selectedObjects.clear();
773 _idConnectionInCreation = createGConnector(startOutputPort);
774 } else if (command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR) {
775 _worldState = NOTHING_HAPPENS;
776 //int id = _controllers.size()-1;
777 GObjectController *cont = _controllers[_idConnectionInCreation];
778 GConnectorModel *modelContour = (GConnectorModel*) cont->getModel();
779 GObjectController *finPort = _controllers[idController];
781 if (finPort->getGObjectType() == GPORT)
783 GPortModel* modelPort = (GPortModel*) finPort->getModel();
784 modelContour->setEndPort(modelPort);
787 typedef std::map<int, GObjectController*>::iterator TIterator;
788 TIterator c_it = _controllers.begin();
789 TIterator iter_end = _controllers.end();
790 // Go through all componets
791 for (c_it; c_it != iter_end; c_it++) {
792 GObjectController* obc = c_it->second;
793 int obc_type = obc->getModel()->getGObjectType();
794 int obc_state = obc->getView()->getState();
795 // if the component is a port and the type is the same of that selected
796 if ((obc_type == GPORT) && (obc_state == POSSIBLE_CONNECTION)) {
797 // Return element to neutral state if not selected
798 obc->getView()->setState(NOTHING_HAPPENS);
800 if ((obc_type == GPORT) && (obc_state == SELECTED_POSSIBLE_CONNECTION)) {
801 // Change element to connected state
802 obc->getView()->setState(HIGHLIGHTED);
808 _parent->saveTempandUpdate("create connection");
811 manualConnectorContourController *manCont = ((GConnectorController*) cont)->getManualContourController();
812 manualConnectorContourView *connView = (manualConnectorContourView*) manCont->GetManualViewBaseContour();
814 std::map<int, GObjectController*>::iterator it2;
816 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
818 GObjectController *cont = it2->second;
819 if (cont->getView() != NULL) {
820 cont->getView()->setState(NOTHING_HAPPENS);
821 cont->getModel()->notifyObservers(_idManager);
823 cont->SetActive(true);
832 //=========================================================================
834 bool wxVtkSceneManager::OnMouseMove()
837 bool okStatusMessage = false;
838 bool okPortMessage = false;
839 crea::wxVTKRenderWindowInteractor *wxVTKiren;
840 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
841 wxVTKiren->GetEventPosition(X, Y);
843 if (_worldState == DRAG_OBJECTS)
845 for (int i = 0; i < (int) _selectedObjects.size(); i++)
847 int id = _selectedObjects[i];
848 GObjectController* cont = _controllers[id];
851 cont->getView()->setStartDragging(true);
853 cont->getView()->moveObject(X, Y);
854 cont->getView()->setState(DRAG);
855 cont->getModel()->notifyObservers(_idManager);
858 std::map<int, GObjectController*>::iterator it;
860 for (it = _controllers.begin(); it != _controllers.end(); ++it)
862 GObjectController *desc = it->second;
863 if (desc->getGObjectType() == GCONNECTOR)
865 vtkGConnectorView* vconn = (vtkGConnectorView*) desc->getView();
866 vconn->updateStartEndPoints();
870 _startDragging = false;
872 } else if (_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR) {
873 std::map<int, GObjectController*>::iterator it;
875 for (it = _controllers.begin(); it != _controllers.end(); ++it)
877 GObjectController *desc = it->second;
878 int type = desc->getGObjectType();
879 int state = desc->getView()->getState();
880 desc->getModel()->getCenter(px, py, pz);
883 if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION ))
886 okStatusMessage = true;
887 updateStatusBar(desc->getStatusText());
888 if (type == GBLACKBOX)
890 GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel();
891 _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType());
896 if ( ( _bugTextActor_text==desc->getStatusText() ) || (_bugTextActor_status==0) )
898 _bugTextActor_status = 1;
899 okPortMessage = true;
902 // _textActor->SetScale(0.1);
904 _textActor->SetScale(0.05,0.05,1);
906 std::string tmp = desc->getStatusText()+"\n";
907 _textActor->SetInput( tmp.c_str() );
908 // _textActor->SetPosition(px - 25, py + 1, pz + 2);
909 // _textActor->SetPosition(px , py-PORT_HEIGHT/4 , pz + 2);
910 _textActor->SetPosition(px , py-PORT_HEIGHT , pz + 2);
911 _textActor->Modified();
915 _fillObjectActor->SetScale(1);
917 // _fillObjectActor->SetScale(0.7,0.5,1);
918 _fillObjectActor->GetProperty()->SetOpacity(0.75);
919 _fillObjectActor->SetPosition( px, py + PORT_HEIGHT/2.0 , 1);
920 _aPolygonMapper->Modified();
922 _bugTextActor_status= 2;
923 } // _bugTextActor_tex
924 _bugTextActor_text = desc->getStatusText();
927 } // for controllers it
928 } else if (_worldState == SELECTING_BOXES ) {
932 if (X<selectRegionX1)
934 sX1=X; sX2=selectRegionX1;
936 sX1=selectRegionX1; sX2=X;
939 if (Y<selectRegionY1)
941 sY1=Y; sY2=selectRegionY1;
943 sY1=selectRegionY1; sY2=Y;
946 UnSelectBlackBoxes();
948 std::map<int, GObjectController*>::iterator it;
949 GObjectController *desc;
953 for (it = _controllers.begin(); it != _controllers.end(); ++it)
956 type = desc->getGObjectType();
957 state = desc->getView()->getState();
959 if ( (type==GBLACKBOX) || (type==GCOMPLEXINPUTPORT) || (type==GCOMPLEXOUTPUTPORT) )
961 if ( desc->getView()->isBoxInsideRectangle( sX1 , sY1,sX2 , sY2 ) )
963 desc->getView()->setState(SELECTED);
964 id = desc->getModel()->getObjectId();
965 desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
973 if (okStatusMessage == false)
978 if ((okPortMessage == false) || (_bugTextActor_status== 2 ) )
980 _bugTextActor_status = 0;
981 _textActor->SetScale(0.0001);
982 _textActor->SetInput("a\n");
983 _textActor->Modified();
984 _fillObjectActor->SetScale(0.0001);
989 //=========================================================================
991 bool wxVtkSceneManager::OnLeftButtonDown()
993 if (_worldState == INIT_CREATION_CONTOUR)
995 bool isOverPort = false;
996 std::map<int, GObjectController*>::iterator it;
997 for (it = _controllers.begin(); it != _controllers.end() && isOverPort== false; ++it)
999 GObjectController *desc = it->second;
1000 if (desc->getGObjectType() == GPORT)
1002 GPortModel *portmod = (GPortModel*) desc->getModel();
1003 vtkGObjectView *portView = desc->getView();
1004 if (portmod->getPortType() == GINPUTPORT && portView->getState() == HIGHLIGHTED)
1009 if ( portmod->getPortType( ) == GINPUTPORT && portView->getState( ) == SELECTED_POSSIBLE_CONNECTION ) {
1011 portView->setState( HIGHLIGHTED);
1017 if (isOverPort == false)
1020 UnSelectBlackBoxes();
1022 } else { //_worldState
1023 _startDragging = true;
1024 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
1025 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
1026 ctrlkey = ctrlkey + shiftkey;
1027 GObjectController *cont = GetGBoxControlerPointedByMouse();
1030 _worldState = DRAG_OBJECTS;
1031 int state = cont->getView()->getState();
1032 if ((ctrlkey == 0) && (state == HIGHLIGHTED))
1034 UnSelectBlackBoxes();
1035 } // if ctrlkey state
1037 UnSelectBlackBoxes(); // EED 12/07/2012
1038 _worldState = SELECTING_BOXES;
1041 if (_worldState==SELECTING_BOXES)
1043 crea::wxVTKRenderWindowInteractor *wxVTKiren;
1044 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
1045 wxVTKiren->GetEventPosition(selectRegionX1, selectRegionY1);
1046 } // if _worldState SELECTING_BOXES
1048 if (_worldState==DRAG_OBJECTS)
1050 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1052 int id = _selectedObjects[i];
1053 GObjectController *cont = _controllers[id];
1054 cont->getView()->setState(DRAG);
1055 cont->getModel()->notifyObservers(_idManager);
1057 } // if _worldState DRAG_OBJECTS
1059 } // if _selectedObjects.size
1063 //=========================================================================
1065 bool wxVtkSceneManager::OnLeftButtonUp()
1067 if ( (_worldState == DRAG_OBJECTS) || (_worldState == SELECTING_BOXES) )
1069 _worldState = NOTHING_HAPPENS;
1070 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1072 int id = _selectedObjects[i];
1073 GObjectController* cont = _controllers[id];
1074 cont->getView()->setState(SELECTED);
1075 cont->getModel()->notifyObservers(_idManager);
1081 //=========================================================================
1082 void wxVtkSceneManager::CancelConnection()
1084 if (_worldState == INIT_CREATION_CONTOUR)
1086 _worldState = NOTHING_HAPPENS;
1087 //int lastId = _controllers.size()-1;
1089 GConnectorController *connector =
1090 (GConnectorController*) _controllers[_idConnectionInCreation];
1091 connector->removeFromScene();
1092 unregisterController(connector);
1093 _controllers.erase(_idConnectionInCreation);
1095 std::map<int, GObjectController*>::iterator it;
1096 for (it = _controllers.begin(); it != _controllers.end(); ++it)
1098 GObjectController *desc = it->second;
1099 desc->SetActive(true);
1100 desc->getView()->setState(NOTHING_HAPPENS);
1101 desc->getModel()->notifyObservers(_idManager);
1106 //=========================================================================
1107 bool wxVtkSceneManager::OnRightButtonUp()
1109 if (_worldState == INIT_CREATION_CONTOUR)
1113 UnSelectBlackBoxes();
1118 //=========================================================================
1119 bool wxVtkSceneManager::OnMiddleButtonDown()
1121 this->_vtkInteractorStyleBaseView->StartPan();
1125 //=========================================================================
1126 bool wxVtkSceneManager::OnMiddleButtonUp()
1128 this->_vtkInteractorStyleBaseView->EndPan();
1132 //=========================================================================
1133 GObjectController *wxVtkSceneManager::GetGBoxControlerPointedByMouse()
1135 GObjectController *result = NULL;
1137 crea::wxVTKRenderWindowInteractor *wxVTKiren;
1138 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
1139 wxVTKiren->GetEventPosition(X, Y);
1140 std::map<int, GObjectController*>::iterator it;
1141 for (it = _controllers.begin(); it != _controllers.end(); ++it)
1143 GObjectController *cont = it->second;
1144 int type = cont->getGObjectType();
1145 if (cont->getView()->isPointInside(X, Y) == true)
1147 if ( (type == GBLACKBOX) || (type == GCOMPLEXINPUTPORT) || (type == GCOMPLEXOUTPUTPORT))
1151 } // if isPointInside
1156 //=========================================================================
1157 void wxVtkSceneManager::UnSelectBlackBoxes()
1159 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1161 int id = _selectedObjects[i];
1162 GObjectController* control = _controllers[id];
1163 control->getView()->setState(NOTHING_HAPPENS);
1164 control->getModel()->notifyObservers(_idManager);
1165 }// for _selectedObjects
1166 _selectedObjects.clear();
1169 //=========================================================================
1170 bool wxVtkSceneManager::OnLeftDClick()
1172 GObjectController *cont = GetGBoxControlerPointedByMouse();
1175 int type = cont->getGObjectType();
1176 if (type==GBLACKBOX)
1178 UnSelectBlackBoxes();
1179 _parent->editBlackBox((GBlackBoxModel*) cont->getModel());
1185 //=========================================================================
1186 bool wxVtkSceneManager::OnChar()
1190 char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
1191 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
1192 // KeyCode 127 : Delete Key
1193 // KeyCode 8 : Backspace Key
1194 if (keyCode == 8 || keyCode == 127 || keyCode == 27)
1196 if (_worldState == INIT_CREATION_CONTOUR)
1199 UnSelectBlackBoxes();
1202 if (keyCode == 8 || keyCode == 127)
1204 for (int i = 0; i < (int) _selectedObjects.size(); i++)
1206 int id = _selectedObjects[i];
1207 std::map<int, GObjectController*>::iterator it;
1208 it = _controllers.find(id);
1209 if (it != _controllers.end())
1211 oktmp = deleteObject(id);
1214 }// for selected objects
1215 if (ok) _selectedObjects.clear();
1216 _parent->saveTempandUpdate("delete object");
1221 if(_selectedObjects.size()){
1222 std::cout<<"objects to copy :";
1223 for(int i=0;i<_selectedObjects.size();i++)
1225 std::cout<<_selectedObjects.at(i)<<" ";
1227 DuplicateObjects(getSelectedObjects());
1229 std::cout<<"No objects to copy\n";
1230 } // _selectedObjects.size
1235 //=========================================================================
1236 void wxVtkSceneManager::AddControlerToBeRemove( std::vector<int> *controllersToRemove, int id)
1240 for (i = 0; i < (int) controllersToRemove->size(); i++)
1242 if (id == (*controllersToRemove)[i])
1249 controllersToRemove->push_back(id);
1253 //=========================================================================
1255 bool wxVtkSceneManager::deleteObject(int id)
1258 GObjectController *control = _controllers[id];
1259 std::vector<int> controllersToRemove;
1260 if (control->getGObjectType() == GBLACKBOX || control->getGObjectType()
1261 == GCOMPLEXINPUTPORT || control->getGObjectType()
1262 == GCOMPLEXOUTPUTPORT) {
1263 GBoxModel *bbmod = (GBoxModel*) control->getModel();
1264 std::vector<GPortModel*> inputs = bbmod->getInputPorts();
1266 bool boxConnected = false;
1268 // Add box input controllers to be removed
1269 for (int i = 0; i < (int) inputs.size(); i++) {
1270 AddControlerToBeRemove(&controllersToRemove, inputs[i]->getObjectId());
1271 if (inputs[i]->isConnected()) {
1272 boxConnected = true;
1276 std::vector<GPortModel*> outputs = bbmod->getOutputPorts();
1278 // Add box output controllers to be removed
1279 for (int i = 0; i < (int) outputs.size(); i++) {
1280 AddControlerToBeRemove(&controllersToRemove, outputs[i]->getObjectId());
1281 if (outputs[i]->isConnected()) {
1282 boxConnected = true;
1286 // Add connection controllers to be removed
1287 std::map<int, GObjectController*>::iterator it;
1288 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1289 GObjectController *cont = it->second;
1290 int type = cont->getGObjectType();
1291 if (type == GCONNECTOR) {
1292 GConnectorModel *conMod = (GConnectorModel*) cont->getModel();
1293 if (conMod->getStartPort() != NULL && conMod->getStartPort()->getParentBox()->getObjectId() == bbmod->getObjectId())
1295 AddControlerToBeRemove(&controllersToRemove,conMod->getObjectId());
1297 if (conMod->getEndPort() != NULL && conMod->getEndPort()->getParentBox()->getObjectId() == bbmod->getObjectId())
1299 AddControlerToBeRemove(&controllersToRemove,conMod->getObjectId());
1304 // Add box controller to be removed
1305 AddControlerToBeRemove(&controllersToRemove, bbmod->getObjectId());
1306 } else if (control->getGObjectType() == GCONNECTOR) {
1307 GConnectorController *gconnectorcontroler = (GConnectorController*)control;
1308 if (gconnectorcontroler->getManualContourController()->IsEditable()==false)
1310 GConnectorModel *conMod = (GConnectorModel*) control->getModel();
1311 AddControlerToBeRemove(&controllersToRemove, conMod->getObjectId());
1313 gconnectorcontroler->getManualContourController()->OnChar();
1318 std::map<int, GObjectController*>::iterator it;
1320 for (int i = 0; i < (int) controllersToRemove.size(); i++) {
1321 int key = controllersToRemove[i];
1322 it = _controllers.find(key);
1323 GObjectController *cont = _controllers[key];
1325 cont->removeFromScene();
1326 unregisterController((InteractorStyleMaracas*) cont);
1327 _controllers.erase(it);
1335 //=========================================================================
1337 void wxVtkSceneManager::displayBlackBoxInfo(std::string packageName,
1338 std::string boxName) {
1339 _parent->displayBlackBoxInfo(packageName, boxName);
1342 //=========================================================================
1344 void wxVtkSceneManager::updateStatusBar(std::string textStatus) {
1345 _parent->updateStatusBar(textStatus);
1348 //=========================================================================
1349 std::string wxVtkSceneManager::LineNumber(bool withLineNumber, int &value) {
1350 std::string result = "";
1351 if (withLineNumber == true) {
1353 stringstream StrStream;
1355 std::string strValue = StrStream.str();
1358 } else if (value < 100) {
1362 result += strValue + ": ";
1366 //=========================================================================
1368 bool wxVtkSceneManager::MakeBoxExecutable() {
1369 std::map<int, GObjectController*> selected = getSelectedObjects();
1370 if( selected.empty() )
1373 std::map<int, GObjectController*>::iterator it;
1374 for (it = selected.begin(); it != selected.end(); ++it) {
1375 GObjectController* lastSelected = it->second;
1377 vtkGObjectView* view = (vtkGObjectView*) lastSelected->getView();
1378 GBlackBoxModel *bbmodel =
1379 (GBlackBoxModel*) lastSelected->getModel();
1380 view->setState(HIGHLIGHTED);
1381 if (bbmodel->isExecutable()) {
1382 bbmodel->setExecutable(false);
1384 bbmodel->setExecutable(true);
1386 bbmodel->notifyObservers(lastSelected->getId());
1394 //=========================================================================
1396 std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
1397 std::cout << "wxVtkSceneManager::getDiagramBBS" << std::endl;
1398 bool existsExec = false;
1400 std::vector<std::string> packages;
1401 std::vector<int> boxes;
1402 std::vector<int> connections;
1403 std::vector<int> execBoxes;
1405 std::map<int, GObjectController*>::iterator it;
1407 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1408 GObjectController *desc = it->second;
1409 int type = desc->getGObjectType();
1411 if (type == GBLACKBOX) {
1412 GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel();
1414 std::string pkg = mod->getBBTKPackage();
1415 bool existsPkg = false;
1416 for (int t = 0; t < (int) packages.size() && existsPkg == false; t++) {
1417 if (packages[t] == pkg) {
1422 packages.push_back(pkg);
1425 boxes.push_back(it->first);
1426 if (mod->isExecutable()) {
1427 execBoxes.push_back(it->first);
1430 } else if (type == GCONNECTOR) {
1431 connections.push_back(it->first);
1436 std::string script = "";
1437 script += LineNumber(wln, lnNmbr) + "# BBTK GEditor Script\n";
1438 script += LineNumber(wln, lnNmbr) + "# ----------------------\n";
1439 script += LineNumber(wln, lnNmbr) + "\n";
1441 script += LineNumber(wln, lnNmbr) + "include std\n"; // EED
1442 script += LineNumber(wln, lnNmbr) + "include itkvtk\n"; // EED
1444 for (i = 0; i < (int) packages.size(); i++) {
1445 script += LineNumber(wln, lnNmbr);
1446 script += "include ";
1447 script += packages[i];
1451 script += LineNumber(wln, lnNmbr);
1456 script += LineNumber(wln, lnNmbr);
1457 script += "author \"";
1461 script += LineNumber(wln, lnNmbr);
1462 script += "description \"";
1463 script += _Description;
1466 script += LineNumber(wln, lnNmbr);
1467 script += "category \"";
1468 script += _Category;
1471 script += LineNumber(wln, lnNmbr);
1474 // script+="include std\n"; // JPR
1476 for (i = 0; i < (int) boxes.size(); i++) {
1477 script += LineNumber(wln, lnNmbr);
1480 GObjectController *control = _controllers[id];
1481 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1483 script += model->getBBTKPackage()+":";
1484 script += model->getBBTKType();
1486 script += model->getBBTKName();
1489 std::vector<GPortModel*> inputs = model->getInputPorts();
1490 for (int j = 0; j < (int) inputs.size(); j++) {
1491 GPortModel* inputPort = inputs[j];
1492 if (inputPort->isValueSet()) {
1493 script += LineNumber(wln, lnNmbr);
1495 script += model->getBBTKName();
1497 script += inputPort->getBBTKName();
1499 script += inputPort->getValue();
1504 script += LineNumber(wln, lnNmbr);
1509 script += LineNumber(wln, lnNmbr);
1513 std::string complexInputs="";
1515 for (i = 0; i < (int) connections.size(); i++) {
1516 //script += LineNumber(wln, lnNmbr);
1517 //script += "connect ";
1518 int id = connections[i];
1519 GObjectController *control = _controllers[id];
1520 GConnectorModel *model = (GConnectorModel*) control->getModel();
1524 GPortModel *start = model->getStartPort();
1525 GBoxModel *startBox = start->getParentBox();
1527 GPortModel *end = model->getEndPort();
1528 GBoxModel *endBox = end->getParentBox();
1530 if (startBox->getGObjectType() == GCOMPLEXINPUTPORT)
1532 complexInputs += "input ";
1533 complexInputs += startBox->getBBTKName();
1535 complexInputs += " ";
1536 complexInputs += endBox->getBBTKName();
1537 complexInputs += ".";
1538 complexInputs += end->getBBTKName();
1540 complexInputs += " ";
1541 complexInputs += "\" \"";
1543 complexInputs += "\n";
1547 script += LineNumber(wln, lnNmbr);
1548 script += "connect ";
1549 script += startBox->getBBTKName();
1551 script += start->getBBTKName();
1555 //End Connection info
1556 script += endBox->getBBTKName();
1558 script += end->getBBTKName();
1563 script += LineNumber(wln, lnNmbr);
1567 script += LineNumber(wln, lnNmbr);
1570 script += LineNumber(wln, lnNmbr);
1573 script += LineNumber(wln, lnNmbr);
1574 script += "# Complex input ports\n";
1575 script += complexInputs;
1577 if((_MessageKind!="-")&&(_MessageLevel!="-")){
1578 script += LineNumber(wln, lnNmbr);
1579 script += "message ";
1580 script += _MessageKind;
1582 script += _MessageLevel;
1586 for (i = 0; i < (int) execBoxes.size(); i++) {
1587 script += LineNumber(wln, lnNmbr);
1589 int id = execBoxes[i];
1590 GObjectController *control = _controllers[id];
1591 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1592 script += model->getBBTKName();
1601 //=========================================================================
1603 std::string wxVtkSceneManager::saveComplexBoxBBS() {
1604 std::vector<std::string> packages;
1605 std::vector<int> boxes;
1606 std::vector<int> connections;
1607 std::vector<int> execBoxes;
1609 std::map<int, GObjectController*>::iterator it;
1611 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1612 GObjectController *desc = it->second;
1613 int type = desc->getGObjectType();
1615 if (type == GBLACKBOX) {
1616 GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel();
1618 std::string pkg = mod->getBBTKPackage();
1619 bool existsPkg = false;
1620 for (int t = 0; t < (int) packages.size() && existsPkg == false; t++) {
1621 if (packages[t] == pkg) {
1626 packages.push_back(pkg);
1629 boxes.push_back(it->first);
1630 if (mod->isExecutable()) {
1631 execBoxes.push_back(it->first);
1633 } else if (type == GCONNECTOR) {
1634 connections.push_back(it->first);
1638 std::string script = "";
1640 script += "include std\n"; // EED
1641 script += "include itkvtk\n"; // EED
1643 for (i = 0; i < (int) packages.size(); i++) {
1644 script += "include ";
1645 script += packages[i];
1650 // Definition of a complex box
1651 script += "define ";
1652 script += _cbName + " " + _cbPackageName;
1656 script += "author \"";
1660 script += "description \"";
1661 script += _Description;
1665 script += "category \"";
1666 script += _Category;
1671 for (i = 0; i < (int) boxes.size(); i++) {
1674 GObjectController *control = _controllers[id];
1675 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1677 script += model->getBBTKPackage()+":";
1678 script += model->getBBTKType();
1680 script += model->getBBTKName();
1683 std::vector<GPortModel*> inputs = model->getInputPorts();
1684 for (int j = 0; j < (int) inputs.size(); j++) {
1685 GPortModel* inputPort = inputs[j];
1686 if (inputPort->isValueSet()) {
1688 script += model->getBBTKName();
1690 script += inputPort->getBBTKName();
1692 script += inputPort->getValue();
1700 // Create connections in the script. If the connection is made with a complex port, it is created the input or output
1702 std::string complexInputs = "";
1703 std::string complexOutputs = "";
1706 for (i = 0; i < (int) connections.size(); i++) {
1707 int id = connections[i];
1708 GObjectController *control = _controllers[id];
1709 GConnectorModel *model = (GConnectorModel*) control->getModel();
1712 GPortModel *start = model->getStartPort();
1713 GBoxModel *startBox = start->getParentBox();
1715 GPortModel *end = model->getEndPort();
1716 GBoxModel *endBox = end->getParentBox();
1718 if (startBox->getGObjectType() == GCOMPLEXINPUTPORT) {
1719 complexInputs += "input ";
1720 complexInputs += startBox->getBBTKName();
1722 complexInputs += " ";
1723 complexInputs += endBox->getBBTKName();
1724 complexInputs += ".";
1725 complexInputs += end->getBBTKName();
1727 complexInputs += " ";
1728 complexInputs += "\" \"";
1730 complexInputs += "\n";
1731 } else if (endBox->getGObjectType() == GCOMPLEXOUTPUTPORT) {
1732 complexOutputs += "output ";
1733 complexOutputs += endBox->getBBTKName();
1735 complexOutputs += " ";
1736 complexOutputs += startBox->getBBTKName();
1737 complexOutputs += ".";
1738 complexOutputs += start->getBBTKName();
1740 complexOutputs += " ";
1741 complexOutputs += "\" \"";
1743 complexOutputs += "\n";
1745 script += "connect ";
1746 script += startBox->getBBTKName();
1748 script += start->getBBTKName();
1752 //End Connection info
1753 script += endBox->getBBTKName();
1755 script += end->getBBTKName();
1762 script += "# Complex input ports\n";
1763 script += complexInputs;
1766 script += "# Complex output ports\n";
1767 script += complexOutputs;
1771 if((_MessageKind!="-")&&(_MessageLevel!="-"))
1773 script += "message ";
1774 script += _MessageKind;
1776 script += _MessageLevel;
1780 for (i = 0; i < (int) execBoxes.size(); i++)
1783 int id = execBoxes[i];
1784 GObjectController *control = _controllers[id];
1785 GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
1787 script += model->getBBTKName();
1792 script += "endefine";
1798 //=========================================================================
1800 void wxVtkSceneManager::deleteAllBoxes() {
1801 std::map<int, GObjectController*>::iterator it;
1802 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
1803 GObjectController *cont = it->second;
1804 cont->removeFromScene();
1805 unregisterController((InteractorStyleMaracas*) cont);
1807 _selectedObjects.clear();
1808 _controllers.clear();
1811 //=========================================================================
1814 void wxVtkSceneManager::refresh() {
1815 _baseView->Refresh();
1817 //=========================================================================
1819 void wxVtkSceneManager::refreshScene()
1821 _baseView->RefreshView();
1824 //=========================================================================
1826 void wxVtkSceneManager::centerView()
1829 _baseView->GetRenderer()->ComputeVisiblePropBounds(bb);
1832 _baseView->GetRenderer()->GetActiveCamera()->GetFocalPoint(temp);
1833 _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0, 0, temp[2]);
1834 _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp);
1835 _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0, 0, temp[2]);
1837 _baseView->GetRenderer()->ResetCamera();
1838 _baseView->GetRenderer()->ResetCameraClippingRange();
1841 double tt=_baseView->GetRenderer()->GetNearClippingPlaneTolerance();
1842 printf("EED wxVtkSceneManager::centerView() tolerance=%f\n",tt);
1844 _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
1845 printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2);
1846 _baseView->GetRenderer()->GetActiveCamera()->SetClippingRange(0.01,100000);
1847 _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
1848 printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2);
1851 _baseView->GetRenderer()->Render();
1854 //=========================================================================
1856 void wxVtkSceneManager::saveDiagram(std::string &content)
1860 content += "CATEGORY:";
1861 content += GetCategory();
1864 content += "DESCRIPTION:";
1865 content += GetDescription();
1868 content += "AUTHOR:";
1869 content += GetAuthor();
1872 //Print info IF COMPLEX BOX
1873 content += "COMPLEXBOX:";
1874 if (_isComplexBox) {
1875 content += "TRUE\n";
1877 content += "COMPLEXBOXNAME:";
1878 content += GetCbName();
1881 content += "PACKAGENAME:";
1882 content += GetCbPackageName();
1885 /* CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
1886 * External inputs are possible for applications and complex boxes
1887 //Print info complex input ports
1888 std::vector<int> inputs = getComplexInputPorts();
1889 int insize = inputs.size();
1890 content += "COMPLEXINPUTS:";
1891 sprintf(buffer, "%d", insize);
1895 for (int i = 0; i < insize; i++) {
1897 GObjectController *cont = _controllers[id];
1898 cont->getModel()->save(content);
1902 //Print info complex output ports
1903 std::vector<int> outputs = getComplexOutputPorts();
1904 int outsize = outputs.size();
1905 content += "COMPLEXOUTPUTS:";
1906 sprintf(buffer, "%d", outsize);
1910 for (int i = 0; i < outsize; i++) {
1911 int id = outputs[i];
1912 GObjectController *cont = _controllers[id];
1913 cont->getModel()->save(content);
1920 content += "FALSE\n";
1924 // CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
1925 // External inputs are possible for applications and complex boxes
1926 std::vector<int> inputs = getComplexInputPorts();
1927 int insize = inputs.size();
1928 content += "COMPLEXINPUTS:";
1929 sprintf(buffer, "%d", insize);
1933 for (int i = 0; i < insize; i++) {
1935 GObjectController *cont = _controllers[id];
1936 cont->getModel()->save(content);
1940 std::vector<int> boxes = getBlackBoxes();
1941 int bsize = boxes.size();
1942 content += "BOXES:";
1943 sprintf(buffer, "%d", bsize);
1947 for (int i = 0; i < bsize; i++) {
1949 // std::cout<<"id "<<id<<std::endl;//CFT
1950 GObjectController *cont = _controllers[id];
1951 // std::cout<<"nombre: "<<cont->getStatusText()<<std::endl;//CFT
1952 // std::cout<<"tipo: "<<cont->getModel()->getBBTKType()<<std::endl;//CFT
1953 // //boxesDiagram[i] = cont->getModel()->getBBTKType();//CFT
1954 // std::cout<<"nname: "<<cont->getModel()->getBBTKName()<<std::endl;//CFT
1955 // std::cout<<"categorie: "<<GetCategory()<<std::endl;//CFT
1956 // std::cout<<"type: "<<cont->getModel()->getGObjectType()<<std::endl;//CFT
1957 cont->getModel()->save(content);
1961 std::vector<int> connections = getConnections();
1962 int csize = connections.size();
1963 content += "CONNECTIONS:";
1964 sprintf(buffer, "%d", csize);
1968 for (int i = 0; i < csize; i++) {
1969 int id = connections[i];
1970 GObjectController *cont = _controllers[id];
1971 cont->getModel()->save(content);
1976 //=========================================================================
1977 void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &line)
1979 getline(inputStream, line,'\n');
1980 int size = line.length();
1983 if ( line[ size-1 ]==13 )
1985 line.erase(size-1,1);
1990 //=========================================================================
1991 void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
1994 std::string version = "<void>";
1995 std::string line = "";
1996 char delims[] = ":";
1997 char *result = NULL;
1998 char poort[POORT_MAX_LINE_SIZE_INTERPRETER];
2000 getCleanLine(inputStream, line);
2003 while (!inputStream.eof()) {
2004 if (line == "" || line[0] == '#') {
2006 getCleanLine(inputStream, line);
2008 if (line == "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file") {
2009 version = line.substr(18, 3);
2011 if (line == "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file") {
2012 version = line.substr(18, 3);
2014 if (line == "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file") {
2015 version = line.substr(18, 3);
2017 if (line == "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file") {
2018 version = line.substr(18, 3);
2020 if (line == "# - BBTKGEditor v 1.4 BBG BlackBox Diagram file") {
2021 version = line.substr(18, 3);
2023 if (line == "# - BBTKGEditor v 1.5 BBG BlackBox Diagram file") {
2024 version = line.substr(18, 3);
2026 } else if (line == "APP_START") {
2036 if ((version != "1.0") && (version != "1.1")) {
2037 getCleanLine(inputStream, line);//CATEGORY:<category of the box>
2038 char categoryTmp[30];
2039 strcpy(categoryTmp, line.c_str());
2040 result = strtok(categoryTmp, delims);
2041 result = strtok(NULL, delims);
2042 SetCategory(result);
2044 getCleanLine(inputStream, line);//DESCRIPTION:<description of the box>
2045 char descriptionTmp[1024];
2046 strcpy(descriptionTmp, line.c_str());
2047 result = strtok(descriptionTmp, delims);
2048 result = strtok(NULL, delims);
2049 SetDescription(result);
2051 getCleanLine(inputStream, line);//AUTHOR:<author>
2052 char authorTmp[255];
2053 strcpy(authorTmp, line.c_str());
2054 result = strtok(authorTmp, delims);
2055 result = strtok(NULL, delims);
2060 getCleanLine(inputStream, line);//COMPLEX_BOX:TRUE|FALSE
2061 char complexTmp[30];
2062 strcpy(complexTmp, line.c_str());
2063 result = strtok(complexTmp, delims);
2064 result = strtok(NULL, delims);
2065 std::string isComplexBox(result);
2067 if (isComplexBox == "TRUE")
2069 _isComplexBox = true;
2071 if ((version != "1.0") && (version != "1.1"))
2073 getCleanLine(inputStream, line);//COMPLEXNAME:<name of the complex box>
2074 char complexboxnameTmp[255];
2075 strcpy(complexboxnameTmp, line.c_str());
2076 result = strtok(complexboxnameTmp, delims);
2077 result = strtok(NULL, delims);
2080 getCleanLine(inputStream, line);//PACKAGENAME:<name of the package of the box>
2081 char packagenameTmp[255];
2082 strcpy(packagenameTmp, line.c_str());
2083 result = strtok(packagenameTmp, delims);
2084 result = strtok(NULL, delims);
2085 SetCbPackageName(result);
2086 } // if version !1.0 !1.1
2090 //-----------------------
2091 //- COMPLEX INPUT PORTS
2092 //-----------------------
2093 getCleanLine(inputStream, line);//COMPLEXINPUTS:num
2095 strcpy(inputs, line.c_str());
2096 result = strtok(inputs, delims);
2097 result = strtok(NULL, delims);
2100 std::istringstream inps(result);
2103 for (int i = 0; i < numInputs; i++)
2106 getCleanLine(inputStream, line);//COMPLEX_PORT
2107 getCleanLine(inputStream, line);//name
2108 std::string inputPortName(line);
2111 getCleanLine(inputStream, line);//xInic:yInic:zInic
2113 strcpy(coord, line.c_str());
2114 result = strtok(coord, delims);//xInic
2115 std::string xInic(result);
2116 result = strtok(NULL, delims);//yInic
2117 std::string yInic(result);
2118 result = strtok(NULL, delims);//zInic
2119 std::string zInic(result);
2121 double xIn, yIn, zIn;
2122 std::istringstream xSt(xInic);
2124 std::istringstream ySt(yInic);
2126 std::istringstream zSt(zInic);
2131 if (zIn==900) zIn=GPOSITION_Z;
2132 } // if version <=1.2
2134 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2136 configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
2138 } // for input complex box
2139 } // if version < 1.4
2143 //-----------------------
2144 //- COMPLEX OUTPUT PORTS
2145 //-----------------------
2147 getCleanLine(inputStream, line);//COMPLEXOUTPUTS:num
2149 strcpy(outputs, line.c_str());
2150 result = strtok(outputs, delims);
2151 result = strtok(NULL, delims);
2154 std::istringstream outps(result);
2155 outps >> numOutputs;
2157 for (int i = 0; i < numOutputs; i++)
2160 getCleanLine(inputStream, line);//COMPLEX_PORT
2161 getCleanLine(inputStream, line);//name
2162 std::string outputPortName(line);
2165 getCleanLine(inputStream, line);//xInic:yInic:zInic
2167 strcpy(coord, line.c_str());
2168 result = strtok(coord, delims);//xInic
2169 std::string xInic(result);
2170 result = strtok(NULL, delims);//yInic
2171 std::string yInic(result);
2172 result = strtok(NULL, delims);//zInic
2173 std::string zInic(result);
2175 double xIn, yIn, zIn;
2176 std::istringstream xSt(xInic);
2178 std::istringstream ySt(yInic);
2180 std::istringstream zSt(zInic);
2185 if (zIn==900) zIn=GPOSITION_Z;
2194 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2196 configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn);
2198 } // for output complex box
2199 } // if isComplexBox
2202 // RaC2012 2nd Hackfest
2203 if(version >= "1.4")
2205 //-----------------------
2206 //- EXTERNAL INPUT PORTS
2207 //-----------------------
2208 getCleanLine(inputStream, line);//COMPLEXINPUTS:num
2210 strcpy(inputs, line.c_str());
2211 result = strtok(inputs, delims);
2212 result = strtok(NULL, delims);
2215 std::istringstream inps(result);
2218 for (int i = 0; i < numInputs; i++)
2220 getCleanLine(inputStream, line);//COMPLEX_PORT
2221 getCleanLine(inputStream, line);//name
2222 std::string inputPortName(line);
2223 getCleanLine(inputStream, line);//xInic:yInic:zInic
2225 strcpy(coord, line.c_str());
2226 result = strtok(coord, delims);//xInic
2227 std::string xInic(result);
2228 result = strtok(NULL, delims);//yInic
2229 std::string yInic(result);
2230 result = strtok(NULL, delims);//zInic
2231 std::string zInic(result);
2232 double xIn, yIn, zIn;
2233 std::istringstream xSt(xInic);
2235 std::istringstream ySt(yInic);
2237 std::istringstream zSt(zInic);
2241 if (zIn==900) zIn=GPOSITION_Z;
2249 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2250 configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
2251 } // for external input
2252 } // if(version >= "1.4")
2255 getCleanLine(inputStream, line);//BOXES:num
2257 strcpy(boxes, line.c_str());
2258 result = strtok(boxes, delims);
2259 result = strtok(NULL, delims);
2262 std::istringstream is(result);
2265 for (int i = 0; i < numBoxes; i++)
2268 getCleanLine(inputStream, line);//BOX
2269 getCleanLine(inputStream, line);//package:type:name
2271 strcpy(box, line.c_str());
2272 result = strtok(box, delims);//package
2273 std::string package(result);
2274 result = strtok(NULL, delims);//type
2275 std::string type(result);
2276 result = strtok(NULL, delims);//name
2277 std::string name(result);
2280 getCleanLine(inputStream, line);//ISEXEC:TRUE|FALSE
2282 strcpy(exec, line.c_str());
2283 result = strtok(exec, delims);//ISEXEC
2284 result = strtok(NULL, delims);//TRUE|FALSE
2285 std::string isExec(result);
2288 getCleanLine(inputStream, line);//xInic:yInic:zInic
2290 strcpy(coord, line.c_str());
2291 result = strtok(coord, delims);//xInic
2292 std::string xInic(result);
2293 result = strtok(NULL, delims);//yInic
2294 std::string yInic(result);
2295 result = strtok(NULL, delims);//zInic
2296 std::string zInic(result);
2297 double xIn, yIn, zIn;
2298 std::istringstream xSt(xInic);
2300 std::istringstream ySt(yInic);
2302 std::istringstream zSt(zInic);
2307 if (zIn==900) zIn=GPOSITION_Z;
2316 getCleanLine(inputStream, line);//xEnd:yEnd:zEnd
2317 strcpy(coord, line.c_str());
2318 result = strtok(coord, delims);//xEnd
2319 std::string xEnd(result);
2320 result = strtok(NULL, delims);//yEnd
2321 std::string yEnd(result);
2322 result = strtok(NULL, delims);//zEnd
2323 std::string zEnd(result);
2325 double xEn, yEn, zEn;
2326 std::istringstream xEt(xEnd);
2328 std::istringstream yEt(yEnd);
2330 std::istringstream zEt(zEnd);
2335 if (zEn==900) zEn=GPOSITION_Z;
2338 yEn = yIn-BOX_HEIGHT;
2340 bool boxExecutable = false;
2341 if (isExec == "TRUE")
2343 boxExecutable = true;
2346 int idBox = createGBlackBox(xIn, yIn, package, type);
2347 configGBlackBox(idBox, xIn, yIn, zIn, name, boxExecutable, xEn, yEn, zEn);
2349 GObjectController *cont = _controllers[idBox];
2350 GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel();
2353 getCleanLine(inputStream, line);//PORT o FIN_BOX
2354 std::string port = line.substr(0, 4);
2355 while (port == "PORT")
2357 getCleanLine(inputStream, line);//name:value
2358 if (line.length()>=POORT_MAX_LINE_SIZE_INTERPRETER-1)
2360 line=line.substr(0, POORT_MAX_LINE_SIZE_INTERPRETER-1);
2363 strcpy(poort, line.c_str());
2364 result = strtok(poort, delims);//name
2365 std::string name(result);
2367 //EED 16 oct 2012 Adding at the end character " if necesary in the value definition
2368 result = strtok(NULL, delims);//value
2369 if (( result[0]=='"' ) && ( result[ strlen(result)-1 ]!='"' ) )
2371 std::string tmpString=" ";
2372 tmpString[0]=34; // character "
2373 strcat(result,tmpString.c_str());
2375 std::string value(result);
2376 bbmod->setValueToInput(name, value);
2377 getCleanLine(inputStream, line);//PORT o FIN_BOX
2378 port = line.substr(0, 4);
2381 //EED bbmod->notifyObservers(_idManager);
2386 getCleanLine(inputStream, line);//CONNECTIONS:num
2388 strcpy(conns, line.c_str());
2389 result = strtok(conns, delims);
2390 result = strtok(NULL, delims);
2392 std::istringstream isCons(result);
2396 for (int i = 0; i < numConns; i++)
2399 getCleanLine(inputStream, line);//CONNECTION
2400 getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName
2402 strcpy(connec, line.c_str());
2403 result = strtok(connec, delims);
2404 std::string nameStartBox(result);
2405 result = strtok(NULL, delims);
2406 std::string nameStartPort(result);
2407 result = strtok(NULL, delims);
2408 std::string nameEndBox(result);
2409 result = strtok(NULL, delims);
2410 std::string nameEndPort(result);
2411 int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort);
2412 if (version != "1.0") {
2413 //Readding control points of the manualContour
2414 GConnectorController *tempp = (GConnectorController*) _controllers[idCon];
2415 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2416 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2417 getCleanLine(inputStream, line); //NumberOfControlPoints:##
2418 strcpy(conns, line.c_str());
2419 result = strtok(conns, delims);
2420 result = strtok(NULL, delims);
2421 int numberOfControlPoints;
2422 std::istringstream isCons(result);
2423 isCons >> numberOfControlPoints;
2424 for (int ii = 0; ii < numberOfControlPoints; ii++) {
2425 getCleanLine(inputStream, line); //XX:YY:ZZ
2427 strcpy(connec, line.c_str());
2429 result = strtok(connec, delims);
2430 std::istringstream isPointX(result);
2432 result = strtok(NULL, delims);
2433 std::istringstream isPointY(result);
2435 result = strtok(NULL, delims);
2436 std::istringstream isPointZ(result);
2440 if (pz==900) pz=GPOSITION_Z;
2448 conMod->getManualContourModel()->InsertPoint_id(ii + 1, px, py, pz);
2449 conView->getManualContourView()->AddPoint();
2451 }// if version !=1.0
2455 //=========================================================================
2458 //=========================================================================
2459 void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput,
2460 std::string portName, double xIn, double yIn, double zIn)
2463 if (inputoutput == true) {
2464 idPort = createGComplexBoxInputPort(portName);
2466 idPort = createGComplexBoxOutputPort(portName);
2468 GObjectController *cont = _controllers[idPort];
2469 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2470 cbmod->setInicPoint(xIn, yIn, zIn);
2471 cbmod->notifyObservers(_idManager);
2473 //=========================================================================
2476 //=========================================================================
2477 GBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
2482 GBoxModel *boxModel = NULL;
2483 std::vector<int> lstB = getBlackBoxes();
2484 for (j = 0; j < (int) lstB.size(); j++) {
2486 bMod = (GBoxModel*) _controllers[idB]->getModel();
2487 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2495 if (boxModel == NULL) {
2496 std::vector<int> lstInputs = getComplexInputPorts();
2497 for (j = 0; j < (int) lstInputs.size(); j++) {
2499 bMod = (GBoxModel*) _controllers[idB]->getModel();
2500 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2508 std::vector<int> lstOutputs = getComplexOutputPorts();
2509 for (j = 0; j < (int) lstOutputs.size(); j++) {
2510 int idB = lstOutputs[j];
2511 bMod = (GBoxModel*) _controllers[idB]->getModel();
2512 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2524 //=========================================================================
2527 int wxVtkSceneManager::configGConnetion(std::string nameStartBox,
2528 std::string nameStartPort, std::string nameEndBox,
2529 std::string nameEndPort) {
2531 GBoxModel *boxModel;
2532 GPortModel *startP = NULL;
2533 GPortModel *endP = NULL;
2535 boxModel = findGBox(nameStartBox);
2536 if(boxModel == NULL)
2538 printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str());
2540 if (boxModel != NULL) {
2541 startP = boxModel->getOutputPort(nameStartPort);
2543 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() );
2547 boxModel = findGBox(nameEndBox);
2548 if(boxModel == NULL)
2550 printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str());
2552 if (boxModel != NULL) {
2553 endP = boxModel->getInputPort(nameEndPort);
2555 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());
2560 int idCon = createGConnector(startP);
2562 _worldState = NOTHING_HAPPENS;
2563 GConnectorController *tempp = (GConnectorController*) _controllers[idCon];
2565 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2566 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2567 tempp->endContourCreation();
2568 conMod->setEndPort(endP);
2569 conView->updateStartEndPoints();
2573 //=========================================================================
2575 bool wxVtkSceneManager::boxExist(std::string boxname) {
2577 std::map<int, GObjectController*>::iterator it;
2578 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2579 GObjectController *cont = it->second;
2580 if (cont->getModel()->getBBTKName() == boxname) {
2587 //=========================================================================
2589 std::vector<int> wxVtkSceneManager::getBlackBoxes() {
2590 std::vector<int> vect;
2591 std::map<int, GObjectController*>::iterator it;
2592 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2593 GObjectController *cont = it->second;
2594 if (cont->getGObjectType() == GBLACKBOX) {
2595 vect.push_back(cont->getId());
2601 //=========================================================================
2603 std::vector<int> wxVtkSceneManager::getComplexInputPorts() {
2604 std::vector<int> vect;
2605 std::map<int, GObjectController*>::iterator it;
2606 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2607 GObjectController *cont = it->second;
2608 if (cont->getGObjectType() == GCOMPLEXINPUTPORT) {
2609 vect.push_back(cont->getId());
2615 //=========================================================================
2617 std::vector<int> wxVtkSceneManager::getComplexOutputPorts() {
2618 std::vector<int> vect;
2619 std::map<int, GObjectController*>::iterator it;
2620 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2621 GObjectController *cont = it->second;
2622 if (cont->getGObjectType() == GCOMPLEXOUTPUTPORT) {
2623 vect.push_back(cont->getId());
2629 //=========================================================================
2631 std::vector<int> wxVtkSceneManager::getConnections() {
2632 std::vector<int> vect;
2633 std::map<int, GObjectController*>::iterator it;
2634 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2635 GObjectController *cont = it->second;
2636 if (cont->getGObjectType() == GCONNECTOR) {
2637 vect.push_back(cont->getId());
2643 //=========================================================================
2645 bool wxVtkSceneManager::isComplexBox() {
2646 return _isComplexBox;
2649 //=========================================================================
2651 void wxVtkSceneManager::setComplexBox(bool val) {
2652 _isComplexBox = val;
2655 //=========================================================================
2657 int wxVtkSceneManager::addObjectController(GObjectController* objController) {
2658 //Register the controller of the new object
2659 registerController((InteractorStyleMaracas*) objController);
2660 //Add the object to the objects list
2661 int newId = _contLastId;//_controllers.size();
2662 objController->setId(newId);
2663 _controllers[newId] = objController;
2664 //std::cout << "DFCH: int wxVtkSceneManager::addObjectController(GObjectController* objController) ---- _contLastId = " << _contLastId << std::endl;
2669 //=========================================================================
2671 void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objectsMap)
2673 std::map<int, int> oldIdNewIdBoxes;
2674 std::vector<int> connections;
2675 std::vector<int> newBoxesID;
2676 std::map<int, GObjectController*>::iterator it;
2677 for (it = objectsMap.begin(); it != objectsMap.end(); ++it)
2679 GObjectController *cont = it->second;
2680 int type = cont->getGObjectType();
2681 if (type == GBLACKBOX)
2684 double xInic, yInic, zInic;
2685 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
2686 copyBox->getInicPoint(xInic, yInic, zInic);
2687 int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), copyBox->getBBTKType());
2689 int idcB = copyBox->getObjectId();
2690 oldIdNewIdBoxes[idcB] = idBox;
2691 cont = _controllers[idBox];
2692 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
2693 newbox->setInicPoint(xInic, yInic, zInic);
2694 int num = newbox->getNumInputPorts();
2695 for (int j = 0; j < num; j++)
2697 newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
2701 // newbox->move(xInic + 20, yInic + 20, zInic);
2702 newbox->move(xInic + 14, yInic + 6, zInic);
2704 newbox->notifyObservers(_idManager);
2705 newBoxesID.push_back(newbox->getObjectId());
2707 } else if (type == GCONNECTOR) {
2708 int idCon = cont->getId();
2709 connections.push_back(idCon);
2714 for (int i = 0; i < (int) connections.size(); i++)
2716 int objId = connections[i];
2717 GObjectController *cont = objectsMap[objId];
2718 GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
2720 GPortModel* startPort = connectModel->getStartPort();
2721 int startPortIndex = startPort->getPosInBox();
2722 GPortModel* endPort = connectModel->getEndPort();
2723 int endPortIndex = endPort->getPosInBox();
2725 GBlackBoxModel* startPortParentBox =
2726 (GBlackBoxModel*) startPort->getParentBox();
2727 GBlackBoxModel* endPortParentBox =
2728 (GBlackBoxModel*) endPort->getParentBox();
2730 int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
2731 int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
2733 GBlackBoxModel* newStartBox =
2734 (GBlackBoxModel*) _controllers[idNewStartBox]->getModel();
2735 GBlackBoxModel* newEndBox =
2736 (GBlackBoxModel*) _controllers[idNewEndBox]->getModel();
2738 GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
2739 GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
2741 // Creates connection
2742 int idCon = createGConnector(newStartPort);
2743 GConnectorController *tempp =
2744 (GConnectorController*) _controllers[idCon];
2745 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2746 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2747 tempp->endContourCreation();
2748 conMod->setEndPort(newEndPort);
2749 conView->updateStartEndPoints();
2752 /// the new selected boxes are the duplicate ones
2754 UnSelectBlackBoxes();
2755 for (int i = 0; i < newBoxesID.size(); i++)
2757 _selectedObjects.push_back(newBoxesID.at(i));
2760 for (int i = 0; i < (int) _selectedObjects.size(); i++)
2762 int id = _selectedObjects[i];
2763 GObjectController* cont = _controllers[id];
2764 cont->getView()->setState(SELECTED);
2765 cont->getModel()->notifyObservers(_idManager);
2770 //=========================================================================
2772 int wxVtkSceneManager::getNumSelectedObjects() {
2773 return _selectedObjects.size();
2776 //=========================================================================
2778 std::map<int, GObjectController*> wxVtkSceneManager::getSelectedObjects() {
2779 std::map<int, GObjectController*> mapSelected;
2781 std::map<int, GObjectController*>::iterator it;
2782 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2783 GObjectController *cont = it->second;
2784 if (cont->getGObjectType() == GBLACKBOX && cont->getView()->getState()
2786 mapSelected[cont->getId()] = cont;
2790 std::map<int, GObjectController*>::iterator it2;
2791 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) {
2792 GObjectController *cont = it2->second;
2793 if (cont->getGObjectType() == GCONNECTOR) {
2794 GConnectorModel* cmod = (GConnectorModel*) cont->getModel();
2795 GBoxModel* endPortParentBox = cmod->getEndPort()->getParentBox();
2796 GBoxModel* startPortParentBox =
2797 cmod->getStartPort()->getParentBox();
2799 std::map<int, GObjectController*>::iterator iterOBJ1 =
2800 mapSelected.find(startPortParentBox->getObjectId());
2801 std::map<int, GObjectController*>::iterator iterOBJ2 =
2802 mapSelected.find(endPortParentBox->getObjectId());
2804 if (iterOBJ1 != mapSelected.end() && iterOBJ2 != mapSelected.end()) {
2805 int ID = cont->getId();
2806 mapSelected[ID] = cont;
2813 //=========================================================================
2815 void wxVtkSceneManager::addObjects(std::map<int, GObjectController*> objectsMap) {
2817 std::map<int, int> oldIdNewIdBoxes;
2818 std::vector<int> connections;
2820 std::map<int, GObjectController*>::iterator it;
2821 for (it = objectsMap.begin(); it != objectsMap.end(); ++it) {
2822 GObjectController *cont = it->second;
2823 int type = cont->getGObjectType();
2825 if (type == GBLACKBOX) {
2827 double xInic, yInic, zInic;
2828 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
2829 copyBox->getInicPoint(xInic, yInic, zInic);
2830 int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(),copyBox->getBBTKType());
2832 int idcB = copyBox->getObjectId();
2833 oldIdNewIdBoxes[idcB] = idBox;
2834 cont = _controllers[idBox];
2835 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
2836 newbox->setInicPoint(xInic, yInic, zInic);
2837 int num = newbox->getNumInputPorts();
2838 for (int j = 0; j < num; j++)
2840 newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
2842 newbox->notifyObservers(_idManager);
2843 } else if (type == GCONNECTOR) {
2844 int idCon = cont->getId();
2845 connections.push_back(idCon);
2850 for (int i = 0; i < (int) connections.size(); i++) {
2851 int objId = connections[i];
2852 GObjectController *cont = objectsMap[objId];
2853 GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
2855 GPortModel* startPort = connectModel->getStartPort();
2856 int startPortIndex = startPort->getPosInBox();
2857 GPortModel* endPort = connectModel->getEndPort();
2858 int endPortIndex = endPort->getPosInBox();
2860 GBlackBoxModel* startPortParentBox =
2861 (GBlackBoxModel*) startPort->getParentBox();
2862 GBlackBoxModel* endPortParentBox =
2863 (GBlackBoxModel*) endPort->getParentBox();
2865 int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
2866 int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
2868 GBlackBoxModel* newStartBox =
2869 (GBlackBoxModel*) _controllers[idNewStartBox]->getModel();
2870 GBlackBoxModel* newEndBox =
2871 (GBlackBoxModel*) _controllers[idNewEndBox]->getModel();
2873 GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
2874 GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
2876 // Creates connection
2877 int idCon = createGConnector(newStartPort);
2878 GConnectorController *tempp =
2879 (GConnectorController*) _controllers[idCon];
2880 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2881 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2882 tempp->endContourCreation();
2883 conMod->setEndPort(newEndPort);
2884 conView->updateStartEndPoints();
2887 std::map<int, int>::iterator itIds;
2888 for (itIds = oldIdNewIdBoxes.begin(); itIds != oldIdNewIdBoxes.end(); ++itIds) {
2889 int idOld = itIds->first;
2890 int idNew = itIds->second;
2892 GBlackBoxModel* oldBox =
2893 (GBlackBoxModel*) objectsMap[idOld]->getModel();
2894 GBlackBoxModel* newBox =
2895 (GBlackBoxModel*) _controllers[idNew]->getModel();
2897 std::vector<int> oldInputConnections = oldBox->getConnectedInputs();
2898 std::vector<int> oldOutputConnections = oldBox->getConnectedOutputs();
2899 std::vector<int> newInputConnections = newBox->getConnectedInputs();
2900 std::vector<int> newOutputConnections = newBox->getConnectedOutputs();
2902 for (int k = 0; k < (int) oldInputConnections.size(); k++) {
2904 //EED int toCreate=-1;
2905 for (int l = 0; l < (int) newInputConnections.size() && !exist; l++) {
2906 if (oldInputConnections[k] == newInputConnections[l]) {
2911 if (exist == false) {
2912 //Create complex input
2913 int posInBox = oldInputConnections[k];
2914 GPortModel* inputPort = oldBox->getInputPort(posInBox);
2915 std::string inputPortName = inputPort->getBBTKName();
2916 int idInputPort = createGComplexBoxInputPort(inputPortName);
2917 GObjectController *cont = _controllers[idInputPort];
2918 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2919 double xIn, yIn, zIn;
2920 inputPort->getInicPoint(xIn, yIn, zIn);
2922 cbmod->setInicPoint(xIn, yIn, zIn);
2923 cbmod->notifyObservers(_idManager);
2925 GPortModel* inputPortEnd = newBox->getInputPort(posInBox);
2927 // Creates connection
2928 int idCon = createGConnector(cbmod->getOutputPort(0));
2929 GConnectorController *tempp =
2930 (GConnectorController*) _controllers[idCon];
2931 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2932 vtkGConnectorView *conView =
2933 (vtkGConnectorView*) tempp->getView();
2934 tempp->endContourCreation();
2935 conMod->setEndPort(inputPortEnd);
2936 conView->updateStartEndPoints();
2942 for (int k = 0; k < (int) oldOutputConnections.size(); k++) {
2944 //EED int toCreate=-1;
2945 for (int l = 0; l < (int) newOutputConnections.size() && !exist; l++) {
2946 if (oldOutputConnections[k] == newOutputConnections[l]) {
2951 if (exist == false) {
2952 //Create complex output
2953 int posInBox = oldOutputConnections[k];
2954 GPortModel* outputPort = oldBox->getOutputPort(posInBox);
2955 std::string outputPortName = outputPort->getBBTKName();
2956 int idOutputPort = createGComplexBoxOutputPort(outputPortName);
2957 GObjectController *cont = _controllers[idOutputPort];
2958 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2959 double xIn, yIn, zIn;
2960 outputPort->getInicPoint(xIn, yIn, zIn);
2962 cbmod->setInicPoint(xIn, yIn, zIn);
2963 cbmod->notifyObservers(_idManager);
2965 GPortModel* outputPortEnd = newBox->getOutputPort(posInBox);
2967 // Creates connection
2968 int idCon = createGConnector(outputPortEnd);
2969 GConnectorController *tempp =
2970 (GConnectorController*) _controllers[idCon];
2971 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2972 vtkGConnectorView *conView =
2973 (vtkGConnectorView*) tempp->getView();
2974 tempp->endContourCreation();
2975 conMod->setEndPort(cbmod->getInputPort(0));
2976 conView->updateStartEndPoints();
2986 //=========================================================================
2987 void wxVtkSceneManager::SetCbName(std::string cbName) {
2989 if (_cbName == "") {
2990 _cbName = "<complex box name>";
2994 //=========================================================================
2995 std::string wxVtkSceneManager::GetCbName() {
2999 //=========================================================================
3000 void wxVtkSceneManager::SetCbPackageName(std::string packagename) {
3001 _cbPackageName = packagename;
3002 if (_cbPackageName == "") {
3003 _cbPackageName = "<package name of the complex box>";
3007 //=========================================================================
3008 std::string wxVtkSceneManager::GetCbPackageName() {
3009 return _cbPackageName;
3012 //=========================================================================
3013 void wxVtkSceneManager::SetAuthor(std::string author) {
3015 if (_Author == "") {
3016 _Author = "<author of the box>";
3020 //=========================================================================
3021 std::string wxVtkSceneManager::GetAuthor() {
3025 //=========================================================================
3026 void wxVtkSceneManager::SetCategory(std::string category) {
3027 _Category = category;
3028 if (_Category == "") {
3029 _Category = "<category of the box>";
3033 //=========================================================================
3034 std::string wxVtkSceneManager::GetCategory() {
3038 //=========================================================================
3039 void wxVtkSceneManager::SetDescription(std::string description) {
3040 _Description = description;
3041 if (_Description == "") {
3042 _Description = "<description of the box>";
3046 //=========================================================================
3047 std::string wxVtkSceneManager::GetDescription() {
3048 return _Description;
3051 //=========================================================================
3053 void wxVtkSceneManager::SetMessageKind(std::string kind) {
3054 _MessageKind = kind;
3058 //=========================================================================
3060 std::string wxVtkSceneManager::GetMessageKind(){
3061 return _MessageKind;
3064 //=========================================================================
3066 void wxVtkSceneManager::SetMessageLevel(std::string Level){
3067 _MessageLevel = Level;
3070 //=========================================================================
3072 std::string wxVtkSceneManager::GetMessageLevel(){
3073 return _MessageLevel;
3076 //=========================================================================
3078 std::vector< std::string> wxVtkSceneManager::GetExternalInputsNames()
3081 std::vector< std::string> extInputs;
3082 std::map<int, GObjectController*>::iterator it;
3083 for (it = _controllers.begin(); it != _controllers.end(); ++it)
3085 GObjectController *cont = it->second;
3086 if (cont->getGObjectType() == GCOMPLEXINPUTPORT)
3088 extInputs.push_back(cont->getModel()->getBBTKName());
3094 //=========================================================================
3095 void wxVtkSceneManager::printAll(int com , int sta )
3097 int tmpState = sta ;
3098 if ( tmpState == NOTHING_HAPPENS ) {
3099 std::cout << "CONTROLER STATE---->NOTHING_HAPPENS\n" ;
3101 if ( tmpState == HIGHLIGHTED ) {
3102 std::cout << "CONTROLER STATE---->HIGHLIGHTED\n" ;
3104 if ( tmpState == POSSIBLE_CONNECTION ) {
3105 std::cout << "CONTROLER STATE---->POSSIBLE_CONNECTION\n" ;
3107 if ( tmpState == SELECTED_POSSIBLE_CONNECTION ) {
3108 std::cout << "CONTROLER STATE---->SELECTED_POSSIBLE_CONNECTION\n" ;
3110 if ( tmpState == CLICKED ) {
3111 std::cout << "CONTROLER STATE---->CLICKED\n" ;
3113 if ( tmpState == DRAG ) {
3114 std::cout << "CONTROLER STATE---->DRAG\n" ;
3116 if ( tmpState == SELECTED ) {
3117 std::cout << "CONTROLER STATE---->SELECTED\n" ;
3119 if ( tmpState == CREATING_CONTOUR ) {
3120 std::cout << "CONTROLER STATE---->CREATING_CONTOUR\n" ;
3126 if ( command == INIT_CREATION_CONTOUR ) {
3127 std::cout << "COMMAND ----> INIT_CREATION_CONTOUR \n" ;
3129 if ( command == FIN_CREATION_CONTOUR ) {
3130 std::cout << "COMMAND ----> FIN_CREATION_CONTOUR \n" ;
3132 if ( command == ADD_TO_SELECTED ) {
3133 std::cout << "COMMAND ----> ADD_TO_SELECTED \n" ;
3135 if ( command == DRAG_OBJECTS ) {
3136 std::cout << "COMMAND ----> DRAG_OBJECTS \n" ;
3138 if ( command == EDIT_BLACKBOX ) {
3139 std::cout << "COMMAND ----> EDIT_BLACKBOX \n" ;
3141 if ( command == REMOVE_FROM_SELECTED ) {
3142 std::cout << "COMMAND ----> REMOVE_FROM_SELECTED \n" ;
3147 //=========================================================================
3149 void wxVtkSceneManager::SelectBoxWithPossibleName( std::string possibleName )
3151 UnSelectBlackBoxes();
3152 std::map<int, GObjectController*>::iterator it;
3153 GObjectController *desc;
3157 std::string possibleNameAA = possibleName;
3158 std::string boxNameBB;
3160 size = possibleNameAA.length();
3161 for (i=0;i<size;i++)
3163 if ((possibleNameAA[i]>='A')&&(possibleNameAA[i]<='Z')) { possibleNameAA[i]=possibleNameAA[i]+32; }
3165 for (it = _controllers.begin(); it != _controllers.end(); ++it)
3168 type = desc->getGObjectType();
3169 if ( type==GBLACKBOX)
3171 boxNameBB = desc->getModel()->getBBTKType() +":"+ desc->getModel()->getBBTKName();
3172 size=boxNameBB.length();
3173 for (i=0;i<size;i++)
3175 if ((boxNameBB[i]>='A')&&(boxNameBB[i]<='Z')) { boxNameBB[i]=boxNameBB[i]+32; }
3178 pos=boxNameBB.find( possibleNameAA );
3181 desc->getView()->setState(SELECTED);
3182 id = desc->getModel()->getObjectId();
3183 desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
3190 } // EO namespace bbtk