1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::wxGEditorTabPanel .
37 #include "wxGEditorTabPanel.h"
43 //=========================================================================
44 wxGEditorTabPanel::wxGEditorTabPanel()
46 printf ("EED %p wxGEditorTabPanel 1 ()\n" , this );
49 //=========================================================================
50 wxGEditorTabPanel::wxGEditorTabPanel(wxWindow *parent,int id):wxPanel(parent),wxTextDropTarget()
52 printf("EED wxGEditorTabPanel::wxGEditorTabPanel 0\n");
53 printf ("EED %p wxGEditorTabPanel 2 ()\n" , this );
55 _panelAUIMgr = new wxAuiManager(this);
57 _actualdo = states.begin();
59 printf("EED wxGEditorTabPanel::wxGEditorTabPanel 1\n");
62 //=========================================================================
63 wxGEditorTabPanel::~wxGEditorTabPanel()
65 printf ("EED %p ~wxGEditorTabPanel() START \n" , this );
66 //ED02JUIN2010 _sceneManager->disconnectDrop();
68 _panelsManager->VerifyLastTabPanel();
73 printf ("EED %p ~wxGEditorTabPanel() END\n" , this );
77 //=========================================================================
78 void wxGEditorTabPanel::initWxVtkCanvas()
80 printf("EED wxGEditorTabPanel::initWxVtkCanvas 0\n");
81 wxVtk3DBaseView *baseview = new wxVtk3DBaseView(this);
82 baseview->Configure();
83 _sceneManager=new wxVtkSceneManager(this,baseview,_id);
87 printf("RaC-EED 21-06-2010 wxGEditorTabPanel::initWxVtkCanvas Remove the panelAUIMgr, and change to a normal sizer inside the wxGEditorTabPanel\n");
88 _panelAUIMgr->AddPane((wxWindow*)baseview->GetWxVTKRenderWindowInteractor(),wxAuiPaneInfo().Fixed().CenterPane());
90 _panelAUIMgr->Update();
91 printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n");
94 //=========================================================================
96 bool wxGEditorTabPanel::OnDropText(wxCoord x, wxCoord y, const wxString& data)
98 std::string packageName="";
99 std::string boxType="";
101 wxString foo( (data) );
103 strcpy( str, (const char*)foo.mb_str(wxConvUTF8) );
107 result = strtok( str, delims );
108 packageName += result;
110 result = strtok( NULL, delims );
113 _sceneManager->createGBlackBox(x,y,packageName, boxType);
118 //=========================================================================
119 void wxGEditorTabPanel::saveTempandUpdate()
121 _panelsManager->saveTempandUpdate();
123 //=========================================================================
125 void wxGEditorTabPanel::setPanelsManager(wxTabPanelsManager* panelsManager)
127 _panelsManager = panelsManager;
130 //=========================================================================
132 void wxGEditorTabPanel::displayBlackBoxInfo(std::string packageName, std::string boxName)
134 _panelsManager->displayBlackBoxInfo(packageName,boxName);
137 //=========================================================================
139 void wxGEditorTabPanel::updateStatusBar(std::string textStatus)
141 _panelsManager->updateStatusBar(textStatus);
144 //=========================================================================
146 std::string wxGEditorTabPanel::getDiagramBBS(bool wln)
148 return _sceneManager->getDiagramBBS(wln);
151 //=========================================================================
153 std::string wxGEditorTabPanel::saveComplexBoxBBS()
155 return _sceneManager->saveComplexBoxBBS();
158 //=========================================================================
160 void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel)
162 _panelsManager->editBlackBox(bbmodel);
165 //=========================================================================
167 void wxGEditorTabPanel::deleteAllBoxes()
169 _sceneManager->deleteAllBoxes();
172 //=========================================================================
174 void wxGEditorTabPanel::centerView()
178 _sceneManager->centerView();
182 //=========================================================================
184 void wxGEditorTabPanel::saveDiagram(std::string &content, const std::string &path) //DFCH
186 this->SetFullPath(path);
187 _sceneManager->saveDiagram(content);
190 //=========================================================================
192 void wxGEditorTabPanel::saveTempDiagram() //FCY
194 std::string content = "";
195 // writing file header
196 content += "# ----------------------------------\n";
197 content += "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file\n";
201 content += "# ----------------------------------\n";
203 content += "APP_START\n";
204 _sceneManager->saveDiagram(content);
205 content += "APP_END\n"; //put here to avoid mistakes
206 if(_actualdo == states.end() ) // same size, write to the end
208 states.push_back (content);
212 std::vector<std::string>::iterator it = _actualdo+1;
213 states.erase(it, states.end());
214 states.push_back(content);
216 _actualdo = states.end();
220 //=========================================================================
222 void wxGEditorTabPanel::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
224 this->SetFullPath(path);
226 ss << inputStream.rdbuf() ;
227 _sceneManager->loadDiagram(ss);
230 //=========================================================================
231 unsigned short wxGEditorTabPanel::getUndoState()
235 if(_actualdo == states.begin() )
242 unsigned short wxGEditorTabPanel::getRedoState()
246 if(_actualdo == --states.end() || states.size() == 1)
253 //=========================================================================
254 void wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY
256 unsigned short res = 1;
258 std::stringstream ss;
261 if(_actualdo == states.end() ) // same size, write to the end
265 if(_actualdo != states.begin() )
267 ss << *(--_actualdo);
278 if(_actualdo != states.end())
287 _sceneManager->loadDiagram(ss);
291 //=========================================================================
293 int wxGEditorTabPanel::getPanelId()
298 //=========================================================================
300 bool wxGEditorTabPanel::isComplexBox()
302 return _sceneManager->isComplexBox();
305 //=========================================================================
307 void wxGEditorTabPanel::setComplexBox(bool val)
309 _sceneManager->setComplexBox(val);
312 //=========================================================================
314 void wxGEditorTabPanel::addComplexInputPort(std::string portName)
316 _sceneManager->createGComplexBoxInputPort(portName);
319 //=========================================================================
321 void wxGEditorTabPanel::addComplexOutputPort(std::string portName)
323 _sceneManager->createGComplexBoxOutputPort(portName);
326 //=========================================================================
328 std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
330 return _sceneManager->getSelectedObjects();
333 //=========================================================================
335 void wxGEditorTabPanel::addObjects(std::map<int,GObjectController*> objectsMap)
337 _sceneManager->addObjects(objectsMap);
340 //=========================================================================
342 int wxGEditorTabPanel::getNumSelectedObjects()
344 return _sceneManager->getNumSelectedObjects();
347 //=========================================================================
350 wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
352 return _sceneManager;
355 //=========================================================================
356 std::string wxGEditorTabPanel::GetCbName()
358 return _sceneManager->GetCbName();
362 //=========================================================================
363 std::string wxGEditorTabPanel::GetCbPackageName()
365 return _sceneManager->GetCbPackageName();
368 //=========================================================================
369 std::string wxGEditorTabPanel::GetAuthor()
371 return _sceneManager->GetAuthor();
374 //=========================================================================
375 std::string wxGEditorTabPanel::GetDescription()
377 return _sceneManager->GetDescription();
380 //=========================================================================
381 std::string wxGEditorTabPanel::GetCategory()
383 return _sceneManager->GetCategory();
386 //=========================================================================
387 void wxGEditorTabPanel::SetCbName(std::string cbName)
389 _sceneManager->SetCbName( cbName );
392 //=========================================================================
393 void wxGEditorTabPanel::SetCbPackageName(std::string packagename)
395 _sceneManager->SetCbPackageName( packagename );
399 //=========================================================================
400 void wxGEditorTabPanel::SetAuthor(std::string author)
402 _sceneManager->SetAuthor( author );
406 //=========================================================================
407 void wxGEditorTabPanel::SetCategory(std::string category)
409 _sceneManager->SetCategory( category );
413 //=========================================================================
414 void wxGEditorTabPanel::SetDescription(std::string description)
416 _sceneManager->SetDescription( description );
418 //=========================================================================
420 void wxGEditorTabPanel::SetFullPath( const std::string& fullpath )
422 this->_fullPath = fullpath;
424 //=========================================================================
426 void wxGEditorTabPanel::SetFileName( const std::string& filename )
428 this->_fileName = filename;
430 //=========================================================================
432 std::string wxGEditorTabPanel::GetFullPath( )
434 return( this->_fullPath );
436 //=========================================================================
438 std::string wxGEditorTabPanel::GetFileName( )
440 return( this->_fileName );
446 } // EO namespace bbtk