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::cout<<"wxVtkSceneManager::saveComplexBoxBBS"<<std::endl;
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 //Print info IF COMPLEX BOX
1874 content += "COMPLEXBOX:";
1875 if (_isComplexBox) {
1876 content += "TRUE\n";
1878 content += "COMPLEXBOXNAME:";
1879 content += GetCbName();
1882 content += "PACKAGENAME:";
1883 content += GetCbPackageName();
1886 /* CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
1887 * External inputs are possible for applications and complex boxes
1888 //Print info complex input ports
1889 std::vector<int> inputs = getComplexInputPorts();
1890 int insize = inputs.size();
1891 content += "COMPLEXINPUTS:";
1892 sprintf(buffer, "%d", insize);
1896 for (int i = 0; i < insize; i++) {
1898 GObjectController *cont = _controllers[id];
1899 cont->getModel()->save(content);
1903 //Print info complex output ports
1904 std::vector<int> outputs = getComplexOutputPorts();
1905 int outsize = outputs.size();
1906 content += "COMPLEXOUTPUTS:";
1907 sprintf(buffer, "%d", outsize);
1911 for (int i = 0; i < outsize; i++) {
1912 int id = outputs[i];
1913 GObjectController *cont = _controllers[id];
1914 cont->getModel()->save(content);
1918 content += "FALSE\n";
1921 // CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
1922 // External inputs are possible for applications and complex boxes
1923 std::vector<int> inputs = getComplexInputPorts();
1924 int insize = inputs.size();
1925 content += "COMPLEXINPUTS:";
1926 sprintf(buffer, "%d", insize);
1930 for (int i = 0; i < insize; i++) {
1932 GObjectController *cont = _controllers[id];
1933 cont->getModel()->save(content);
1937 std::vector<int> boxes = getBlackBoxes();
1938 int bsize = boxes.size();
1939 content += "BOXES:";
1940 sprintf(buffer, "%d", bsize);
1944 for (int i = 0; i < bsize; i++) {
1946 // std::cout<<"id "<<id<<std::endl;//CFT
1947 GObjectController *cont = _controllers[id];
1948 // std::cout<<"nombre: "<<cont->getStatusText()<<std::endl;//CFT
1949 // std::cout<<"tipo: "<<cont->getModel()->getBBTKType()<<std::endl;//CFT
1950 // //boxesDiagram[i] = cont->getModel()->getBBTKType();//CFT
1951 // std::cout<<"nname: "<<cont->getModel()->getBBTKName()<<std::endl;//CFT
1952 // std::cout<<"categorie: "<<GetCategory()<<std::endl;//CFT
1953 // std::cout<<"type: "<<cont->getModel()->getGObjectType()<<std::endl;//CFT
1954 cont->getModel()->save(content);
1958 std::vector<int> connections = getConnections();
1959 int csize = connections.size();
1960 content += "CONNECTIONS:";
1961 sprintf(buffer, "%d", csize);
1965 for (int i = 0; i < csize; i++) {
1966 int id = connections[i];
1967 GObjectController *cont = _controllers[id];
1968 cont->getModel()->save(content);
1973 //=========================================================================
1974 void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &line)
1976 getline(inputStream, line,'\n');
1977 int size = line.length();
1980 if ( line[ size-1 ]==13 )
1982 line.erase(size-1,1);
1987 //=========================================================================
1988 void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
1991 std::string version = "<void>";
1992 std::string line = "";
1993 char delims[] = ":";
1994 char *result = NULL;
1995 char poort[POORT_MAX_LINE_SIZE_INTERPRETER];
1997 getCleanLine(inputStream, line);
2000 while (!inputStream.eof()) {
2001 if (line == "" || line[0] == '#') {
2003 getCleanLine(inputStream, line);
2005 if (line == "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file") {
2006 version = line.substr(18, 3);
2008 if (line == "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file") {
2009 version = line.substr(18, 3);
2011 if (line == "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file") {
2012 version = line.substr(18, 3);
2014 if (line == "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file") {
2015 version = line.substr(18, 3);
2017 if (line == "# - BBTKGEditor v 1.4 BBG BlackBox Diagram file") {
2018 version = line.substr(18, 3);
2020 if (line == "# - BBTKGEditor v 1.5 BBG BlackBox Diagram file") {
2021 version = line.substr(18, 3);
2023 } else if (line == "APP_START") {
2033 if ((version != "1.0") && (version != "1.1")) {
2034 getCleanLine(inputStream, line);//CATEGORY:<category of the box>
2035 char categoryTmp[30];
2036 strcpy(categoryTmp, line.c_str());
2037 result = strtok(categoryTmp, delims);
2038 result = strtok(NULL, delims);
2039 SetCategory(result);
2041 getCleanLine(inputStream, line);//DESCRIPTION:<description of the box>
2042 char descriptionTmp[1024];
2043 strcpy(descriptionTmp, line.c_str());
2044 result = strtok(descriptionTmp, delims);
2045 result = strtok(NULL, delims);
2046 SetDescription(result);
2048 getCleanLine(inputStream, line);//AUTHOR:<author>
2049 char authorTmp[255];
2050 strcpy(authorTmp, line.c_str());
2051 result = strtok(authorTmp, delims);
2052 result = strtok(NULL, delims);
2057 getCleanLine(inputStream, line);//COMPLEX_BOX:TRUE|FALSE
2058 char complexTmp[30];
2059 strcpy(complexTmp, line.c_str());
2060 result = strtok(complexTmp, delims);
2061 result = strtok(NULL, delims);
2062 std::string isComplexBox(result);
2064 if (isComplexBox == "TRUE")
2066 _isComplexBox = true;
2068 if ((version != "1.0") && (version != "1.1"))
2070 getCleanLine(inputStream, line);//COMPLEXNAME:<name of the complex box>
2071 char complexboxnameTmp[255];
2072 strcpy(complexboxnameTmp, line.c_str());
2073 result = strtok(complexboxnameTmp, delims);
2074 result = strtok(NULL, delims);
2077 getCleanLine(inputStream, line);//PACKAGENAME:<name of the package of the box>
2078 char packagenameTmp[255];
2079 strcpy(packagenameTmp, line.c_str());
2080 result = strtok(packagenameTmp, delims);
2081 result = strtok(NULL, delims);
2082 SetCbPackageName(result);
2083 } // if version !1.0 !1.1
2087 //-----------------------
2088 //- COMPLEX INPUT PORTS
2089 //-----------------------
2090 getCleanLine(inputStream, line);//COMPLEXINPUTS:num
2092 strcpy(inputs, line.c_str());
2093 result = strtok(inputs, delims);
2094 result = strtok(NULL, delims);
2097 std::istringstream inps(result);
2100 for (int i = 0; i < numInputs; i++)
2103 getCleanLine(inputStream, line);//COMPLEX_PORT
2104 getCleanLine(inputStream, line);//name
2105 std::string inputPortName(line);
2108 getCleanLine(inputStream, line);//xInic:yInic:zInic
2110 strcpy(coord, line.c_str());
2111 result = strtok(coord, delims);//xInic
2112 std::string xInic(result);
2113 result = strtok(NULL, delims);//yInic
2114 std::string yInic(result);
2115 result = strtok(NULL, delims);//zInic
2116 std::string zInic(result);
2118 double xIn, yIn, zIn;
2119 std::istringstream xSt(xInic);
2121 std::istringstream ySt(yInic);
2123 std::istringstream zSt(zInic);
2128 if (zIn==900) zIn=GPOSITION_Z;
2129 } // if version <=1.2
2131 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2133 configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
2135 } // for input complex box
2136 } // if version < 1.4
2140 //-----------------------
2141 //- COMPLEX OUTPUT PORTS
2142 //-----------------------
2144 getCleanLine(inputStream, line);//COMPLEXOUTPUTS:num
2146 strcpy(outputs, line.c_str());
2147 result = strtok(outputs, delims);
2148 result = strtok(NULL, delims);
2151 std::istringstream outps(result);
2152 outps >> numOutputs;
2154 for (int i = 0; i < numOutputs; i++)
2157 getCleanLine(inputStream, line);//COMPLEX_PORT
2158 getCleanLine(inputStream, line);//name
2159 std::string outputPortName(line);
2162 getCleanLine(inputStream, line);//xInic:yInic:zInic
2164 strcpy(coord, line.c_str());
2165 result = strtok(coord, delims);//xInic
2166 std::string xInic(result);
2167 result = strtok(NULL, delims);//yInic
2168 std::string yInic(result);
2169 result = strtok(NULL, delims);//zInic
2170 std::string zInic(result);
2172 double xIn, yIn, zIn;
2173 std::istringstream xSt(xInic);
2175 std::istringstream ySt(yInic);
2177 std::istringstream zSt(zInic);
2182 if (zIn==900) zIn=GPOSITION_Z;
2191 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2193 configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn);
2195 } // for output complex box
2196 } // if isComplexBox
2199 // RaC2012 2nd Hackfest
2200 if(version >= "1.4")
2202 //-----------------------
2203 //- EXTERNAL INPUT PORTS
2204 //-----------------------
2205 getCleanLine(inputStream, line);//COMPLEXINPUTS:num
2207 strcpy(inputs, line.c_str());
2208 result = strtok(inputs, delims);
2209 result = strtok(NULL, delims);
2212 std::istringstream inps(result);
2215 for (int i = 0; i < numInputs; i++)
2217 getCleanLine(inputStream, line);//COMPLEX_PORT
2218 getCleanLine(inputStream, line);//name
2219 std::string inputPortName(line);
2220 getCleanLine(inputStream, line);//xInic:yInic:zInic
2222 strcpy(coord, line.c_str());
2223 result = strtok(coord, delims);//xInic
2224 std::string xInic(result);
2225 result = strtok(NULL, delims);//yInic
2226 std::string yInic(result);
2227 result = strtok(NULL, delims);//zInic
2228 std::string zInic(result);
2229 double xIn, yIn, zIn;
2230 std::istringstream xSt(xInic);
2232 std::istringstream ySt(yInic);
2234 std::istringstream zSt(zInic);
2238 if (zIn==900) zIn=GPOSITION_Z;
2246 getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
2247 configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
2248 } // for external input
2249 } // if(version >= "1.4")
2252 getCleanLine(inputStream, line);//BOXES:num
2254 strcpy(boxes, line.c_str());
2255 result = strtok(boxes, delims);
2256 result = strtok(NULL, delims);
2259 std::istringstream is(result);
2262 for (int i = 0; i < numBoxes; i++)
2265 getCleanLine(inputStream, line);//BOX
2266 getCleanLine(inputStream, line);//package:type:name
2268 strcpy(box, line.c_str());
2269 result = strtok(box, delims);//package
2270 std::string package(result);
2271 result = strtok(NULL, delims);//type
2272 std::string type(result);
2273 result = strtok(NULL, delims);//name
2274 std::string name(result);
2277 getCleanLine(inputStream, line);//ISEXEC:TRUE|FALSE
2279 strcpy(exec, line.c_str());
2280 result = strtok(exec, delims);//ISEXEC
2281 result = strtok(NULL, delims);//TRUE|FALSE
2282 std::string isExec(result);
2285 getCleanLine(inputStream, line);//xInic:yInic:zInic
2287 strcpy(coord, line.c_str());
2288 result = strtok(coord, delims);//xInic
2289 std::string xInic(result);
2290 result = strtok(NULL, delims);//yInic
2291 std::string yInic(result);
2292 result = strtok(NULL, delims);//zInic
2293 std::string zInic(result);
2294 double xIn, yIn, zIn;
2295 std::istringstream xSt(xInic);
2297 std::istringstream ySt(yInic);
2299 std::istringstream zSt(zInic);
2304 if (zIn==900) zIn=GPOSITION_Z;
2313 getCleanLine(inputStream, line);//xEnd:yEnd:zEnd
2314 strcpy(coord, line.c_str());
2315 result = strtok(coord, delims);//xEnd
2316 std::string xEnd(result);
2317 result = strtok(NULL, delims);//yEnd
2318 std::string yEnd(result);
2319 result = strtok(NULL, delims);//zEnd
2320 std::string zEnd(result);
2322 double xEn, yEn, zEn;
2323 std::istringstream xEt(xEnd);
2325 std::istringstream yEt(yEnd);
2327 std::istringstream zEt(zEnd);
2332 if (zEn==900) zEn=GPOSITION_Z;
2335 yEn = yIn-BOX_HEIGHT;
2337 bool boxExecutable = false;
2338 if (isExec == "TRUE")
2340 boxExecutable = true;
2343 int idBox = createGBlackBox(xIn, yIn, package, type);
2344 configGBlackBox(idBox, xIn, yIn, zIn, name, boxExecutable, xEn, yEn, zEn);
2346 GObjectController *cont = _controllers[idBox];
2347 GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel();
2350 getCleanLine(inputStream, line);//PORT o FIN_BOX
2351 std::string port = line.substr(0, 4);
2352 while (port == "PORT")
2354 getCleanLine(inputStream, line);//name:value
2355 if (line.length()>=POORT_MAX_LINE_SIZE_INTERPRETER-1)
2357 line=line.substr(0, POORT_MAX_LINE_SIZE_INTERPRETER-1);
2360 strcpy(poort, line.c_str());
2361 result = strtok(poort, delims);//name
2362 std::string name(result);
2364 //EED 16 oct 2012 Adding at the end character " if necesary in the value definition
2365 result = strtok(NULL, delims);//value
2366 if (( result[0]=='"' ) && ( result[ strlen(result)-1 ]!='"' ) )
2368 std::string tmpString=" ";
2369 tmpString[0]=34; // character "
2370 strcat(result,tmpString.c_str());
2372 std::string value(result);
2373 bbmod->setValueToInput(name, value);
2374 getCleanLine(inputStream, line);//PORT o FIN_BOX
2375 port = line.substr(0, 4);
2378 //EED bbmod->notifyObservers(_idManager);
2383 getCleanLine(inputStream, line);//CONNECTIONS:num
2385 strcpy(conns, line.c_str());
2386 result = strtok(conns, delims);
2387 result = strtok(NULL, delims);
2389 std::istringstream isCons(result);
2393 for (int i = 0; i < numConns; i++)
2396 getCleanLine(inputStream, line);//CONNECTION
2397 getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName
2399 strcpy(connec, line.c_str());
2400 result = strtok(connec, delims);
2401 std::string nameStartBox(result);
2402 result = strtok(NULL, delims);
2403 std::string nameStartPort(result);
2404 result = strtok(NULL, delims);
2405 std::string nameEndBox(result);
2406 result = strtok(NULL, delims);
2407 std::string nameEndPort(result);
2408 int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort);
2409 if (version != "1.0") {
2410 //Readding control points of the manualContour
2411 GConnectorController *tempp = (GConnectorController*) _controllers[idCon];
2412 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2413 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2414 getCleanLine(inputStream, line); //NumberOfControlPoints:##
2415 strcpy(conns, line.c_str());
2416 result = strtok(conns, delims);
2417 result = strtok(NULL, delims);
2418 int numberOfControlPoints;
2419 std::istringstream isCons(result);
2420 isCons >> numberOfControlPoints;
2421 for (int ii = 0; ii < numberOfControlPoints; ii++) {
2422 getCleanLine(inputStream, line); //XX:YY:ZZ
2424 strcpy(connec, line.c_str());
2426 result = strtok(connec, delims);
2427 std::istringstream isPointX(result);
2429 result = strtok(NULL, delims);
2430 std::istringstream isPointY(result);
2432 result = strtok(NULL, delims);
2433 std::istringstream isPointZ(result);
2437 if (pz==900) pz=GPOSITION_Z;
2445 conMod->getManualContourModel()->InsertPoint_id(ii + 1, px, py, pz);
2446 conView->getManualContourView()->AddPoint();
2448 }// if version !=1.0
2452 //=========================================================================
2455 //=========================================================================
2456 void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput,
2457 std::string portName, double xIn, double yIn, double zIn)
2460 if (inputoutput == true) {
2461 idPort = createGComplexBoxInputPort(portName);
2463 idPort = createGComplexBoxOutputPort(portName);
2465 GObjectController *cont = _controllers[idPort];
2466 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2467 cbmod->setInicPoint(xIn, yIn, zIn);
2468 cbmod->notifyObservers(_idManager);
2470 //=========================================================================
2473 //=========================================================================
2474 GBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
2479 GBoxModel *boxModel = NULL;
2480 std::vector<int> lstB = getBlackBoxes();
2481 for (j = 0; j < (int) lstB.size(); j++) {
2483 bMod = (GBoxModel*) _controllers[idB]->getModel();
2484 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2492 if (boxModel == NULL) {
2493 std::vector<int> lstInputs = getComplexInputPorts();
2494 for (j = 0; j < (int) lstInputs.size(); j++) {
2496 bMod = (GBoxModel*) _controllers[idB]->getModel();
2497 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2505 std::vector<int> lstOutputs = getComplexOutputPorts();
2506 for (j = 0; j < (int) lstOutputs.size(); j++) {
2507 int idB = lstOutputs[j];
2508 bMod = (GBoxModel*) _controllers[idB]->getModel();
2509 if (_controllers[idB]->getModel()->getBBTKName() == boxname)
2521 //=========================================================================
2524 int wxVtkSceneManager::configGConnetion(std::string nameStartBox,
2525 std::string nameStartPort, std::string nameEndBox,
2526 std::string nameEndPort) {
2528 GBoxModel *boxModel;
2529 GPortModel *startP = NULL;
2530 GPortModel *endP = NULL;
2532 boxModel = findGBox(nameStartBox);
2533 if(boxModel == NULL)
2535 printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str());
2537 if (boxModel != NULL) {
2538 startP = boxModel->getOutputPort(nameStartPort);
2540 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() );
2544 boxModel = findGBox(nameEndBox);
2545 if(boxModel == NULL)
2547 printf("RaC: ERROR in wxVtkSceneManager::configGConnetion A box to connect start port %s is null. Box name is probably wrong.\n", nameStartPort.c_str());
2549 if (boxModel != NULL) {
2550 endP = boxModel->getInputPort(nameEndPort);
2552 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());
2557 int idCon = createGConnector(startP);
2559 _worldState = NOTHING_HAPPENS;
2560 GConnectorController *tempp = (GConnectorController*) _controllers[idCon];
2562 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2563 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2564 tempp->endContourCreation();
2565 conMod->setEndPort(endP);
2566 conView->updateStartEndPoints();
2570 //=========================================================================
2572 bool wxVtkSceneManager::boxExist(std::string boxname) {
2574 std::map<int, GObjectController*>::iterator it;
2575 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2576 GObjectController *cont = it->second;
2577 if (cont->getModel()->getBBTKName() == boxname) {
2584 //=========================================================================
2586 std::vector<int> wxVtkSceneManager::getBlackBoxes() {
2587 std::vector<int> vect;
2588 std::map<int, GObjectController*>::iterator it;
2589 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2590 GObjectController *cont = it->second;
2591 if (cont->getGObjectType() == GBLACKBOX) {
2592 vect.push_back(cont->getId());
2598 //=========================================================================
2600 std::vector<int> wxVtkSceneManager::getComplexInputPorts() {
2601 std::vector<int> vect;
2602 std::map<int, GObjectController*>::iterator it;
2603 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2604 GObjectController *cont = it->second;
2605 if (cont->getGObjectType() == GCOMPLEXINPUTPORT) {
2606 vect.push_back(cont->getId());
2612 //=========================================================================
2614 std::vector<int> wxVtkSceneManager::getComplexOutputPorts() {
2615 std::vector<int> vect;
2616 std::map<int, GObjectController*>::iterator it;
2617 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2618 GObjectController *cont = it->second;
2619 if (cont->getGObjectType() == GCOMPLEXOUTPUTPORT) {
2620 vect.push_back(cont->getId());
2626 //=========================================================================
2628 std::vector<int> wxVtkSceneManager::getConnections() {
2629 std::vector<int> vect;
2630 std::map<int, GObjectController*>::iterator it;
2631 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2632 GObjectController *cont = it->second;
2633 if (cont->getGObjectType() == GCONNECTOR) {
2634 vect.push_back(cont->getId());
2640 //=========================================================================
2642 bool wxVtkSceneManager::isComplexBox() {
2643 return _isComplexBox;
2646 //=========================================================================
2648 void wxVtkSceneManager::setComplexBox(bool val) {
2649 _isComplexBox = val;
2652 //=========================================================================
2654 int wxVtkSceneManager::addObjectController(GObjectController* objController) {
2655 //Register the controller of the new object
2656 registerController((InteractorStyleMaracas*) objController);
2657 //Add the object to the objects list
2658 int newId = _contLastId;//_controllers.size();
2659 objController->setId(newId);
2660 _controllers[newId] = objController;
2661 //std::cout << "DFCH: int wxVtkSceneManager::addObjectController(GObjectController* objController) ---- _contLastId = " << _contLastId << std::endl;
2666 //=========================================================================
2668 void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objectsMap)
2670 std::map<int, int> oldIdNewIdBoxes;
2671 std::vector<int> connections;
2672 std::vector<int> newBoxesID;
2673 std::map<int, GObjectController*>::iterator it;
2674 for (it = objectsMap.begin(); it != objectsMap.end(); ++it)
2676 GObjectController *cont = it->second;
2677 int type = cont->getGObjectType();
2678 if (type == GBLACKBOX)
2681 double xInic, yInic, zInic;
2682 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
2683 copyBox->getInicPoint(xInic, yInic, zInic);
2684 int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), copyBox->getBBTKType());
2686 int idcB = copyBox->getObjectId();
2687 oldIdNewIdBoxes[idcB] = idBox;
2688 cont = _controllers[idBox];
2689 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
2690 newbox->setInicPoint(xInic, yInic, zInic);
2691 int num = newbox->getNumInputPorts();
2692 for (int j = 0; j < num; j++)
2694 newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
2698 // newbox->move(xInic + 20, yInic + 20, zInic);
2699 newbox->move(xInic + 14, yInic + 6, zInic);
2701 newbox->notifyObservers(_idManager);
2702 newBoxesID.push_back(newbox->getObjectId());
2704 } else if (type == GCONNECTOR) {
2705 int idCon = cont->getId();
2706 connections.push_back(idCon);
2711 for (int i = 0; i < (int) connections.size(); i++)
2713 int objId = connections[i];
2714 GObjectController *cont = objectsMap[objId];
2715 GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
2717 GPortModel* startPort = connectModel->getStartPort();
2718 int startPortIndex = startPort->getPosInBox();
2719 GPortModel* endPort = connectModel->getEndPort();
2720 int endPortIndex = endPort->getPosInBox();
2722 GBlackBoxModel* startPortParentBox =
2723 (GBlackBoxModel*) startPort->getParentBox();
2724 GBlackBoxModel* endPortParentBox =
2725 (GBlackBoxModel*) endPort->getParentBox();
2727 int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
2728 int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
2730 GBlackBoxModel* newStartBox =
2731 (GBlackBoxModel*) _controllers[idNewStartBox]->getModel();
2732 GBlackBoxModel* newEndBox =
2733 (GBlackBoxModel*) _controllers[idNewEndBox]->getModel();
2735 GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
2736 GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
2738 // Creates connection
2739 int idCon = createGConnector(newStartPort);
2740 GConnectorController *tempp =
2741 (GConnectorController*) _controllers[idCon];
2742 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2743 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2744 tempp->endContourCreation();
2745 conMod->setEndPort(newEndPort);
2746 conView->updateStartEndPoints();
2749 /// the new selected boxes are the duplicate ones
2751 UnSelectBlackBoxes();
2752 for (int i = 0; i < newBoxesID.size(); i++)
2754 _selectedObjects.push_back(newBoxesID.at(i));
2757 for (int i = 0; i < (int) _selectedObjects.size(); i++)
2759 int id = _selectedObjects[i];
2760 GObjectController* cont = _controllers[id];
2761 cont->getView()->setState(SELECTED);
2762 cont->getModel()->notifyObservers(_idManager);
2767 //=========================================================================
2769 int wxVtkSceneManager::getNumSelectedObjects() {
2770 return _selectedObjects.size();
2773 //=========================================================================
2775 std::map<int, GObjectController*> wxVtkSceneManager::getSelectedObjects() {
2776 std::map<int, GObjectController*> mapSelected;
2778 std::map<int, GObjectController*>::iterator it;
2779 for (it = _controllers.begin(); it != _controllers.end(); ++it) {
2780 GObjectController *cont = it->second;
2781 if (cont->getGObjectType() == GBLACKBOX && cont->getView()->getState()
2783 mapSelected[cont->getId()] = cont;
2787 std::map<int, GObjectController*>::iterator it2;
2788 for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) {
2789 GObjectController *cont = it2->second;
2790 if (cont->getGObjectType() == GCONNECTOR) {
2791 GConnectorModel* cmod = (GConnectorModel*) cont->getModel();
2792 GBoxModel* endPortParentBox = cmod->getEndPort()->getParentBox();
2793 GBoxModel* startPortParentBox =
2794 cmod->getStartPort()->getParentBox();
2796 std::map<int, GObjectController*>::iterator iterOBJ1 =
2797 mapSelected.find(startPortParentBox->getObjectId());
2798 std::map<int, GObjectController*>::iterator iterOBJ2 =
2799 mapSelected.find(endPortParentBox->getObjectId());
2801 if (iterOBJ1 != mapSelected.end() && iterOBJ2 != mapSelected.end()) {
2802 int ID = cont->getId();
2803 mapSelected[ID] = cont;
2810 //=========================================================================
2812 void wxVtkSceneManager::addObjects(std::map<int, GObjectController*> objectsMap) {
2814 std::map<int, int> oldIdNewIdBoxes;
2815 std::vector<int> connections;
2817 std::map<int, GObjectController*>::iterator it;
2818 for (it = objectsMap.begin(); it != objectsMap.end(); ++it) {
2819 GObjectController *cont = it->second;
2820 int type = cont->getGObjectType();
2822 if (type == GBLACKBOX) {
2824 double xInic, yInic, zInic;
2825 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
2826 copyBox->getInicPoint(xInic, yInic, zInic);
2827 int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(),copyBox->getBBTKType());
2829 int idcB = copyBox->getObjectId();
2830 oldIdNewIdBoxes[idcB] = idBox;
2831 cont = _controllers[idBox];
2832 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
2833 newbox->setInicPoint(xInic, yInic, zInic);
2834 int num = newbox->getNumInputPorts();
2835 for (int j = 0; j < num; j++)
2837 newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
2839 newbox->notifyObservers(_idManager);
2840 } else if (type == GCONNECTOR) {
2841 int idCon = cont->getId();
2842 connections.push_back(idCon);
2847 for (int i = 0; i < (int) connections.size(); i++) {
2848 int objId = connections[i];
2849 GObjectController *cont = objectsMap[objId];
2850 GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
2852 GPortModel* startPort = connectModel->getStartPort();
2853 int startPortIndex = startPort->getPosInBox();
2854 GPortModel* endPort = connectModel->getEndPort();
2855 int endPortIndex = endPort->getPosInBox();
2857 GBlackBoxModel* startPortParentBox =
2858 (GBlackBoxModel*) startPort->getParentBox();
2859 GBlackBoxModel* endPortParentBox =
2860 (GBlackBoxModel*) endPort->getParentBox();
2862 int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()];
2863 int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()];
2865 GBlackBoxModel* newStartBox =
2866 (GBlackBoxModel*) _controllers[idNewStartBox]->getModel();
2867 GBlackBoxModel* newEndBox =
2868 (GBlackBoxModel*) _controllers[idNewEndBox]->getModel();
2870 GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex);
2871 GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex);
2873 // Creates connection
2874 int idCon = createGConnector(newStartPort);
2875 GConnectorController *tempp =
2876 (GConnectorController*) _controllers[idCon];
2877 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2878 vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView();
2879 tempp->endContourCreation();
2880 conMod->setEndPort(newEndPort);
2881 conView->updateStartEndPoints();
2884 std::map<int, int>::iterator itIds;
2885 for (itIds = oldIdNewIdBoxes.begin(); itIds != oldIdNewIdBoxes.end(); ++itIds) {
2886 int idOld = itIds->first;
2887 int idNew = itIds->second;
2889 GBlackBoxModel* oldBox =
2890 (GBlackBoxModel*) objectsMap[idOld]->getModel();
2891 GBlackBoxModel* newBox =
2892 (GBlackBoxModel*) _controllers[idNew]->getModel();
2894 std::vector<int> oldInputConnections = oldBox->getConnectedInputs();
2895 std::vector<int> oldOutputConnections = oldBox->getConnectedOutputs();
2896 std::vector<int> newInputConnections = newBox->getConnectedInputs();
2897 std::vector<int> newOutputConnections = newBox->getConnectedOutputs();
2899 for (int k = 0; k < (int) oldInputConnections.size(); k++) {
2901 //EED int toCreate=-1;
2902 for (int l = 0; l < (int) newInputConnections.size() && !exist; l++) {
2903 if (oldInputConnections[k] == newInputConnections[l]) {
2908 if (exist == false) {
2909 //Create complex input
2910 int posInBox = oldInputConnections[k];
2911 GPortModel* inputPort = oldBox->getInputPort(posInBox);
2912 std::string inputPortName = inputPort->getBBTKName();
2913 int idInputPort = createGComplexBoxInputPort(inputPortName);
2914 GObjectController *cont = _controllers[idInputPort];
2915 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2916 double xIn, yIn, zIn;
2917 inputPort->getInicPoint(xIn, yIn, zIn);
2919 cbmod->setInicPoint(xIn, yIn, zIn);
2920 cbmod->notifyObservers(_idManager);
2922 GPortModel* inputPortEnd = newBox->getInputPort(posInBox);
2924 // Creates connection
2925 int idCon = createGConnector(cbmod->getOutputPort(0));
2926 GConnectorController *tempp =
2927 (GConnectorController*) _controllers[idCon];
2928 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2929 vtkGConnectorView *conView =
2930 (vtkGConnectorView*) tempp->getView();
2931 tempp->endContourCreation();
2932 conMod->setEndPort(inputPortEnd);
2933 conView->updateStartEndPoints();
2939 for (int k = 0; k < (int) oldOutputConnections.size(); k++) {
2941 //EED int toCreate=-1;
2942 for (int l = 0; l < (int) newOutputConnections.size() && !exist; l++) {
2943 if (oldOutputConnections[k] == newOutputConnections[l]) {
2948 if (exist == false) {
2949 //Create complex output
2950 int posInBox = oldOutputConnections[k];
2951 GPortModel* outputPort = oldBox->getOutputPort(posInBox);
2952 std::string outputPortName = outputPort->getBBTKName();
2953 int idOutputPort = createGComplexBoxOutputPort(outputPortName);
2954 GObjectController *cont = _controllers[idOutputPort];
2955 GBoxModel *cbmod = (GBoxModel*) cont->getModel();
2956 double xIn, yIn, zIn;
2957 outputPort->getInicPoint(xIn, yIn, zIn);
2959 cbmod->setInicPoint(xIn, yIn, zIn);
2960 cbmod->notifyObservers(_idManager);
2962 GPortModel* outputPortEnd = newBox->getOutputPort(posInBox);
2964 // Creates connection
2965 int idCon = createGConnector(outputPortEnd);
2966 GConnectorController *tempp =
2967 (GConnectorController*) _controllers[idCon];
2968 GConnectorModel *conMod = (GConnectorModel*) tempp->getModel();
2969 vtkGConnectorView *conView =
2970 (vtkGConnectorView*) tempp->getView();
2971 tempp->endContourCreation();
2972 conMod->setEndPort(cbmod->getInputPort(0));
2973 conView->updateStartEndPoints();
2983 //=========================================================================
2984 void wxVtkSceneManager::SetCbName(std::string cbName) {
2986 if (_cbName == "") {
2987 _cbName = "<complex box name>";
2991 //=========================================================================
2992 std::string wxVtkSceneManager::GetCbName() {
2996 //=========================================================================
2997 void wxVtkSceneManager::SetCbPackageName(std::string packagename) {
2998 _cbPackageName = packagename;
2999 if (_cbPackageName == "") {
3000 _cbPackageName = "<package name of the complex box>";
3004 //=========================================================================
3005 std::string wxVtkSceneManager::GetCbPackageName() {
3006 return _cbPackageName;
3009 //=========================================================================
3010 void wxVtkSceneManager::SetAuthor(std::string author) {
3012 if (_Author == "") {
3013 _Author = "<author of the box>";
3017 //=========================================================================
3018 std::string wxVtkSceneManager::GetAuthor() {
3022 //=========================================================================
3023 void wxVtkSceneManager::SetCategory(std::string category) {
3024 _Category = category;
3025 if (_Category == "") {
3026 _Category = "<category of the box>";
3030 //=========================================================================
3031 std::string wxVtkSceneManager::GetCategory() {
3035 //=========================================================================
3036 void wxVtkSceneManager::SetDescription(std::string description) {
3037 _Description = description;
3038 if (_Description == "") {
3039 _Description = "<description of the box>";
3043 //=========================================================================
3044 std::string wxVtkSceneManager::GetDescription() {
3045 return _Description;
3048 //=========================================================================
3050 void wxVtkSceneManager::SetMessageKind(std::string kind) {
3051 _MessageKind = kind;
3055 //=========================================================================
3057 std::string wxVtkSceneManager::GetMessageKind(){
3058 return _MessageKind;
3061 //=========================================================================
3063 void wxVtkSceneManager::SetMessageLevel(std::string Level){
3064 _MessageLevel = Level;
3067 //=========================================================================
3069 std::string wxVtkSceneManager::GetMessageLevel(){
3070 return _MessageLevel;
3073 //=========================================================================
3075 std::vector< std::string> wxVtkSceneManager::GetExternalInputsNames()
3078 std::vector< std::string> extInputs;
3079 std::map<int, GObjectController*>::iterator it;
3080 for (it = _controllers.begin(); it != _controllers.end(); ++it)
3082 GObjectController *cont = it->second;
3083 if (cont->getGObjectType() == GCOMPLEXINPUTPORT)
3085 extInputs.push_back(cont->getModel()->getBBTKName());
3091 //=========================================================================
3092 void wxVtkSceneManager::printAll(int com , int sta )
3094 int tmpState = sta ;
3095 if ( tmpState == NOTHING_HAPPENS ) {
3096 std::cout << "CONTROLER STATE---->NOTHING_HAPPENS\n" ;
3098 if ( tmpState == HIGHLIGHTED ) {
3099 std::cout << "CONTROLER STATE---->HIGHLIGHTED\n" ;
3101 if ( tmpState == POSSIBLE_CONNECTION ) {
3102 std::cout << "CONTROLER STATE---->POSSIBLE_CONNECTION\n" ;
3104 if ( tmpState == SELECTED_POSSIBLE_CONNECTION ) {
3105 std::cout << "CONTROLER STATE---->SELECTED_POSSIBLE_CONNECTION\n" ;
3107 if ( tmpState == CLICKED ) {
3108 std::cout << "CONTROLER STATE---->CLICKED\n" ;
3110 if ( tmpState == DRAG ) {
3111 std::cout << "CONTROLER STATE---->DRAG\n" ;
3113 if ( tmpState == SELECTED ) {
3114 std::cout << "CONTROLER STATE---->SELECTED\n" ;
3116 if ( tmpState == CREATING_CONTOUR ) {
3117 std::cout << "CONTROLER STATE---->CREATING_CONTOUR\n" ;
3123 if ( command == INIT_CREATION_CONTOUR ) {
3124 std::cout << "COMMAND ----> INIT_CREATION_CONTOUR \n" ;
3126 if ( command == FIN_CREATION_CONTOUR ) {
3127 std::cout << "COMMAND ----> FIN_CREATION_CONTOUR \n" ;
3129 if ( command == ADD_TO_SELECTED ) {
3130 std::cout << "COMMAND ----> ADD_TO_SELECTED \n" ;
3132 if ( command == DRAG_OBJECTS ) {
3133 std::cout << "COMMAND ----> DRAG_OBJECTS \n" ;
3135 if ( command == EDIT_BLACKBOX ) {
3136 std::cout << "COMMAND ----> EDIT_BLACKBOX \n" ;
3138 if ( command == REMOVE_FROM_SELECTED ) {
3139 std::cout << "COMMAND ----> REMOVE_FROM_SELECTED \n" ;
3144 //=========================================================================
3146 void wxVtkSceneManager::SelectBoxWithPossibleName( std::string possibleName )
3148 UnSelectBlackBoxes();
3149 std::map<int, GObjectController*>::iterator it;
3150 GObjectController *desc;
3154 std::string possibleNameAA = possibleName;
3155 std::string boxNameBB;
3157 size = possibleNameAA.length();
3158 for (i=0;i<size;i++)
3160 if ((possibleNameAA[i]>='A')&&(possibleNameAA[i]<='Z')) { possibleNameAA[i]=possibleNameAA[i]+32; }
3162 for (it = _controllers.begin(); it != _controllers.end(); ++it)
3165 type = desc->getGObjectType();
3166 if ( type==GBLACKBOX)
3168 boxNameBB = desc->getModel()->getBBTKType() +":"+ desc->getModel()->getBBTKName();
3169 size=boxNameBB.length();
3170 for (i=0;i<size;i++)
3172 if ((boxNameBB[i]>='A')&&(boxNameBB[i]<='Z')) { boxNameBB[i]=boxNameBB[i]+32; }
3175 pos=boxNameBB.find( possibleNameAA );
3178 desc->getView()->setState(SELECTED);
3179 id = desc->getModel()->getObjectId();
3180 desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
3187 } // EO namespace bbtk