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 //=========================================================================
120 void wxGEditorTabPanel::setPanelsManager(wxTabPanelsManager* panelsManager)
122 _panelsManager = panelsManager;
125 //=========================================================================
127 void wxGEditorTabPanel::displayBlackBoxInfo(std::string packageName, std::string boxName)
129 _panelsManager->displayBlackBoxInfo(packageName,boxName);
132 //=========================================================================
134 void wxGEditorTabPanel::updateStatusBar(std::string textStatus)
136 _panelsManager->updateStatusBar(textStatus);
139 //=========================================================================
141 std::string wxGEditorTabPanel::getDiagramBBS(bool wln)
143 return _sceneManager->getDiagramBBS(wln);
146 //=========================================================================
148 std::string wxGEditorTabPanel::saveComplexBoxBBS()
150 return _sceneManager->saveComplexBoxBBS();
153 //=========================================================================
155 void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel)
157 _panelsManager->editBlackBox(bbmodel);
160 //=========================================================================
162 void wxGEditorTabPanel::deleteAllBoxes()
164 _sceneManager->deleteAllBoxes();
167 //=========================================================================
169 void wxGEditorTabPanel::centerView()
173 _sceneManager->centerView();
177 //=========================================================================
179 void wxGEditorTabPanel::saveDiagram(std::string &content, const std::string &path) //DFCH
181 this->SetFullPath(path);
182 _sceneManager->saveDiagram(content);
185 //=========================================================================
187 void wxGEditorTabPanel::saveTempDiagram() //FCY
189 std::string content = "";
190 // writing file header
191 content += "# ----------------------------------\n";
192 content += "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file\n";
196 content += "# ----------------------------------\n";
198 content += "APP_START\n";
199 _sceneManager->saveDiagram(content);
200 content += "APP_END\n"; //put here to avoid mistakes
201 if(_actualdo == states.end() ) // same size, write to the end
203 states.push_back (content);
207 std::vector<std::string>::iterator it = _actualdo+1;
208 states.erase(it, states.end());
209 states.push_back(content);
211 _actualdo = states.end();
215 //=========================================================================
217 void wxGEditorTabPanel::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
219 this->SetFullPath(path);
221 ss << inputStream.rdbuf() ;
222 _sceneManager->loadDiagram(ss);
225 //=========================================================================
226 unsigned short wxGEditorTabPanel::getUndoState()
230 if(_actualdo == states.begin() )
237 unsigned short wxGEditorTabPanel::getRedoState()
241 if(_actualdo == --states.end() || states.size() == 1)
248 //=========================================================================
249 void wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY
251 unsigned short res = 1;
253 std::stringstream ss;
256 if(_actualdo == states.end() ) // same size, write to the end
260 if(_actualdo != states.begin() )
262 ss << *(--_actualdo);
273 if(_actualdo != states.end())
282 _sceneManager->loadDiagram(ss);
286 //=========================================================================
288 int wxGEditorTabPanel::getPanelId()
293 //=========================================================================
295 bool wxGEditorTabPanel::isComplexBox()
297 return _sceneManager->isComplexBox();
300 //=========================================================================
302 void wxGEditorTabPanel::setComplexBox(bool val)
304 _sceneManager->setComplexBox(val);
307 //=========================================================================
309 void wxGEditorTabPanel::addComplexInputPort(std::string portName)
311 _sceneManager->createGComplexBoxInputPort(portName);
314 //=========================================================================
316 void wxGEditorTabPanel::addComplexOutputPort(std::string portName)
318 _sceneManager->createGComplexBoxOutputPort(portName);
321 //=========================================================================
323 std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
325 return _sceneManager->getSelectedObjects();
328 //=========================================================================
330 void wxGEditorTabPanel::addObjects(std::map<int,GObjectController*> objectsMap)
332 _sceneManager->addObjects(objectsMap);
335 //=========================================================================
337 int wxGEditorTabPanel::getNumSelectedObjects()
339 return _sceneManager->getNumSelectedObjects();
342 //=========================================================================
345 wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
347 return _sceneManager;
350 //=========================================================================
351 std::string wxGEditorTabPanel::GetCbName()
353 return _sceneManager->GetCbName();
357 //=========================================================================
358 std::string wxGEditorTabPanel::GetCbPackageName()
360 return _sceneManager->GetCbPackageName();
363 //=========================================================================
364 std::string wxGEditorTabPanel::GetAuthor()
366 return _sceneManager->GetAuthor();
369 //=========================================================================
370 std::string wxGEditorTabPanel::GetDescription()
372 return _sceneManager->GetDescription();
375 //=========================================================================
376 std::string wxGEditorTabPanel::GetCategory()
378 return _sceneManager->GetCategory();
381 //=========================================================================
382 void wxGEditorTabPanel::SetCbName(std::string cbName)
384 _sceneManager->SetCbName( cbName );
387 //=========================================================================
388 void wxGEditorTabPanel::SetCbPackageName(std::string packagename)
390 _sceneManager->SetCbPackageName( packagename );
394 //=========================================================================
395 void wxGEditorTabPanel::SetAuthor(std::string author)
397 _sceneManager->SetAuthor( author );
401 //=========================================================================
402 void wxGEditorTabPanel::SetCategory(std::string category)
404 _sceneManager->SetCategory( category );
408 //=========================================================================
409 void wxGEditorTabPanel::SetDescription(std::string description)
411 _sceneManager->SetDescription( description );
413 //=========================================================================
415 void wxGEditorTabPanel::SetFullPath( const std::string& fullpath )
417 this->_fullPath = fullpath;
419 //=========================================================================
421 void wxGEditorTabPanel::SetFileName( const std::string& filename )
423 this->_fileName = filename;
425 //=========================================================================
427 std::string wxGEditorTabPanel::GetFullPath( )
429 return( this->_fullPath );
431 //=========================================================================
433 std::string wxGEditorTabPanel::GetFileName( )
435 return( this->_fileName );
441 } // EO namespace bbtk