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()\n" , this );
66 //ED02JUIN2010 _sceneManager->disconnectDrop();
68 _panelsManager->VerifyLastTabPanel();
75 //=========================================================================
76 void wxGEditorTabPanel::initWxVtkCanvas()
78 printf("EED wxGEditorTabPanel::initWxVtkCanvas 0\n");
79 wxVtk3DBaseView *baseview = new wxVtk3DBaseView(this);
80 baseview->Configure();
81 _sceneManager=new wxVtkSceneManager(this,baseview,_id);
85 printf("RaC-EED 21-06-2010 wxGEditorTabPanel::initWxVtkCanvas Remove the panelAUIMgr, and change to a normal sizer inside the wxGEditorTabPanel\n");
86 _panelAUIMgr->AddPane((wxWindow*)baseview->GetWxVTKRenderWindowInteractor(),wxAuiPaneInfo().Fixed().CenterPane());
88 _panelAUIMgr->Update();
89 printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n");
92 //=========================================================================
94 bool wxGEditorTabPanel::OnDropText(wxCoord x, wxCoord y, const wxString& data)
96 std::string packageName="";
97 std::string boxType="";
99 wxString foo( (data) );
101 strcpy( str, (const char*)foo.mb_str(wxConvUTF8) );
105 result = strtok( str, delims );
106 packageName += result;
108 result = strtok( NULL, delims );
111 _sceneManager->createGBlackBox(x,y,packageName, boxType);
116 //=========================================================================
118 void wxGEditorTabPanel::setPanelsManager(wxTabPanelsManager* panelsManager)
120 _panelsManager = panelsManager;
123 //=========================================================================
125 void wxGEditorTabPanel::displayBlackBoxInfo(std::string packageName, std::string boxName)
127 _panelsManager->displayBlackBoxInfo(packageName,boxName);
130 //=========================================================================
132 void wxGEditorTabPanel::updateStatusBar(std::string textStatus)
134 _panelsManager->updateStatusBar(textStatus);
137 //=========================================================================
139 std::string wxGEditorTabPanel::getDiagramBBS(bool wln)
141 return _sceneManager->getDiagramBBS(wln);
144 //=========================================================================
146 std::string wxGEditorTabPanel::saveComplexBoxBBS()
148 return _sceneManager->saveComplexBoxBBS();
151 //=========================================================================
153 void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel)
155 _panelsManager->editBlackBox(bbmodel);
158 //=========================================================================
160 void wxGEditorTabPanel::deleteAllBoxes()
162 _sceneManager->deleteAllBoxes();
165 //=========================================================================
167 void wxGEditorTabPanel::centerView()
171 _sceneManager->centerView();
175 //=========================================================================
177 void wxGEditorTabPanel::saveDiagram(std::string &content, const std::string &path) //DFCH
179 this->SetFullPath(path);
180 _sceneManager->saveDiagram(content);
183 //=========================================================================
185 void wxGEditorTabPanel::saveTempDiagram() //FCY
187 std::string content = "";
188 // writing file header
189 content += "# ----------------------------------\n";
190 content += "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file\n";
194 content += "# ----------------------------------\n";
196 content += "APP_START\n";
197 _sceneManager->saveDiagram(content);
198 content += "APP_END\n"; //put here to avoid mistakes
199 if(_actualdo == states.end() ) // same size, write to the end
201 states.push_back (content);
205 std::vector<std::string>::iterator it = _actualdo+1;
206 states.erase(it, states.end());
207 states.push_back(content);
209 _actualdo = states.end();
213 //=========================================================================
215 void wxGEditorTabPanel::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
217 this->SetFullPath(path);
219 ss << inputStream.rdbuf() ;
220 _sceneManager->loadDiagram(ss);
223 //=========================================================================
224 unsigned short wxGEditorTabPanel::getUndoState()
228 if(_actualdo == states.begin() )
235 unsigned short wxGEditorTabPanel::getRedoState()
239 if(_actualdo == --states.end() || states.size() == 1)
246 //=========================================================================
247 void wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY
249 unsigned short res = 1;
251 std::stringstream ss;
254 if(_actualdo == states.end() ) // same size, write to the end
258 if(_actualdo != states.begin() )
260 ss << *(--_actualdo);
271 if(_actualdo != states.end())
280 _sceneManager->loadDiagram(ss);
284 //=========================================================================
286 int wxGEditorTabPanel::getPanelId()
291 //=========================================================================
293 bool wxGEditorTabPanel::isComplexBox()
295 return _sceneManager->isComplexBox();
298 //=========================================================================
300 void wxGEditorTabPanel::setComplexBox(bool val)
302 _sceneManager->setComplexBox(val);
305 //=========================================================================
307 void wxGEditorTabPanel::addComplexInputPort(std::string portName)
309 _sceneManager->createGComplexBoxInputPort(portName);
312 //=========================================================================
314 void wxGEditorTabPanel::addComplexOutputPort(std::string portName)
316 _sceneManager->createGComplexBoxOutputPort(portName);
319 //=========================================================================
321 std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
323 return _sceneManager->getSelectedObjects();
326 //=========================================================================
328 void wxGEditorTabPanel::addObjects(std::map<int,GObjectController*> objectsMap)
330 _sceneManager->addObjects(objectsMap);
333 //=========================================================================
335 int wxGEditorTabPanel::getNumSelectedObjects()
337 return _sceneManager->getNumSelectedObjects();
340 //=========================================================================
343 wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
345 return _sceneManager;
348 //=========================================================================
349 std::string wxGEditorTabPanel::GetCbName()
351 return _sceneManager->GetCbName();
355 //=========================================================================
356 std::string wxGEditorTabPanel::GetCbPackageName()
358 return _sceneManager->GetCbPackageName();
361 //=========================================================================
362 std::string wxGEditorTabPanel::GetAuthor()
364 return _sceneManager->GetAuthor();
367 //=========================================================================
368 std::string wxGEditorTabPanel::GetDescription()
370 return _sceneManager->GetDescription();
373 //=========================================================================
374 std::string wxGEditorTabPanel::GetCategory()
376 return _sceneManager->GetCategory();
379 //=========================================================================
380 void wxGEditorTabPanel::SetCbName(std::string cbName)
382 _sceneManager->SetCbName( cbName );
385 //=========================================================================
386 void wxGEditorTabPanel::SetCbPackageName(std::string packagename)
388 _sceneManager->SetCbPackageName( packagename );
392 //=========================================================================
393 void wxGEditorTabPanel::SetAuthor(std::string author)
395 _sceneManager->SetAuthor( author );
399 //=========================================================================
400 void wxGEditorTabPanel::SetCategory(std::string category)
402 _sceneManager->SetCategory( category );
406 //=========================================================================
407 void wxGEditorTabPanel::SetDescription(std::string description)
409 _sceneManager->SetDescription( description );
411 //=========================================================================
413 void wxGEditorTabPanel::SetFullPath( const std::string& fullpath )
415 this->_fullPath = fullpath;
417 //=========================================================================
419 void wxGEditorTabPanel::SetFileName( const std::string& filename )
421 this->_fileName = filename;
423 //=========================================================================
425 std::string wxGEditorTabPanel::GetFullPath( )
427 return( this->_fullPath );
429 //=========================================================================
431 std::string wxGEditorTabPanel::GetFileName( )
433 return( this->_fileName );
439 } // EO namespace bbtk