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::wxGEditorTabPanel .
62 #include "wxGEditorTabPanel.h"
68 //=========================================================================
69 wxGEditorTabPanel::wxGEditorTabPanel()
71 printf ("EED %p wxGEditorTabPanel 1 ()\n" , this );
74 //=========================================================================
75 wxGEditorTabPanel::wxGEditorTabPanel(wxWindow *parent,int id, Factory::Pointer bbtkfactory)
76 : wxPanel(parent),wxTextDropTarget()
79 _panelAUIMgr = new wxAuiManager(this);
81 _actualdo = states.begin();
82 _sactualdo = sstates.begin();
83 _bbtkfactory = bbtkfactory;
87 //=========================================================================
88 wxGEditorTabPanel::~wxGEditorTabPanel()
90 //ED02JUIN2010 _sceneManager->disconnectDrop();
92 _panelsManager->VerifyLastTabPanel();
98 //=========================================================================
99 void wxGEditorTabPanel::initWxVtkCanvas()
101 wxVtk3DBaseView *baseview = new wxVtk3DBaseView(this);
102 baseview->Configure();
104 baseview->GetCamera()->SetViewUp (0, 1, 0);
105 baseview->GetCamera()->SetPosition (0, 0, 1);
106 baseview->GetCamera()->SetFocalPoint (0, 0, 0);
108 //EED 15 oct 2012 _sceneManager=new wxVtkSceneManager(this,baseview,_id);
109 _sceneManager=new wxVtkSceneManager(this,baseview,_id, _bbtkfactory);
113 printf("RaC-EED 21-06-2010 wxGEditorTabPanel::initWxVtkCanvas Remove the panelAUIMgr, and change to a normal sizer inside the wxGEditorTabPanel\n");
114 _panelAUIMgr->AddPane((wxWindow*)baseview->GetWxVTKRenderWindowInteractor(),wxAuiPaneInfo().Fixed().CenterPane());
116 _panelAUIMgr->Update();
119 //=========================================================================
121 bool wxGEditorTabPanel::OnDropText(wxCoord x, wxCoord y, const wxString& data)
123 std::string packageName="";
124 std::string boxType="";
126 wxString foo( (data) );
128 strcpy( str, (const char*)foo.mb_str(wxConvUTF8) );
132 result = strtok( str, delims );
133 packageName += result;
135 result = strtok( NULL, delims );
138 if ( _panelsManager->TryToOpenScriptApplication(packageName,boxType) == false )
140 _sceneManager->createGBlackBox(x,y,packageName, boxType);
141 saveTempandUpdate("drop box");
146 //=========================================================================
147 void wxGEditorTabPanel::saveTempandUpdate(const std::string &action)
149 _panelsManager->saveTempandUpdate(action);
151 //=========================================================================
153 void wxGEditorTabPanel::setPanelsManager(wxTabPanelsManager* panelsManager)
155 _panelsManager = panelsManager;
158 //=========================================================================
160 void wxGEditorTabPanel::displayBlackBoxInfo(std::string packageName, std::string boxName)
162 _panelsManager->displayBlackBoxInfo(packageName,boxName);
165 //=========================================================================
167 void wxGEditorTabPanel::updateStatusBar(std::string textStatus)
169 _panelsManager->updateStatusBar(textStatus);
172 //=========================================================================
174 std::string wxGEditorTabPanel::getDiagramBBS(bool wln)
176 return _sceneManager->getDiagramBBS(wln);
179 //=========================================================================
181 std::string wxGEditorTabPanel::saveComplexBoxBBS()
183 return _sceneManager->saveComplexBoxBBS();
186 //=========================================================================
188 void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel)
190 _panelsManager->editBlackBox(bbmodel);
193 //=========================================================================
195 void wxGEditorTabPanel::deleteAllBoxes()
197 _sceneManager->deleteAllBoxes();
200 //=========================================================================
202 void wxGEditorTabPanel::centerView()
206 _sceneManager->centerView();
210 //=========================================================================
212 void wxGEditorTabPanel::saveDiagram(std::string &content, const std::string &path) //DFCH
214 this->SetFullPath(path);
215 _sceneManager->saveDiagram(content);
218 //=========================================================================
220 void wxGEditorTabPanel::saveTempDiagram(const std::string &action) //FCY
222 std::string content = "";
223 // writing file header
224 content += "# ----------------------------------\n";
225 content += "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file\n";
229 content += "# ----------------------------------\n";
231 content += "APP_START\n";
232 _sceneManager->saveDiagram(content);
233 content += "APP_END\n"; //put here to avoid mistakes
234 if(_actualdo == states.end() ) // same size, write to the end
236 states.push_back (content);
237 saveStringAction(action);
241 std::vector<std::string>::iterator it = _actualdo+1;
242 states.erase(it, states.end());
243 states.push_back(content);
245 std::vector<std::string>::iterator sit = _sactualdo+1;
246 sstates.erase(sit, sstates.end());
247 saveStringAction(action);
249 _actualdo = states.end();
250 _sactualdo = sstates.end();
254 //=========================================================================
256 void wxGEditorTabPanel::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
258 this->SetFullPath(path);
260 ss << inputStream.rdbuf() ;
261 _sceneManager->loadDiagram(ss);
264 //=========================================================================
265 unsigned short wxGEditorTabPanel::getUndoState( std::string &stun)
270 if(_actualdo == states.begin() )
278 stun += _sactualdo->substr(0,(--_sactualdo)->find_last_of("."));
285 unsigned short wxGEditorTabPanel::getRedoState( std::string &stre)
290 if(_actualdo == --states.end() || states.size() == 1 || _actualdo == states.end())
295 stre += _sactualdo->substr(0,(++_sactualdo)->find_last_of("."));
302 //=========================================================================
303 void wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY
305 unsigned short res = 1;
307 std::stringstream ss;
310 if(_actualdo == states.end() ) // same size, write to the end
315 if(_actualdo != states.begin() )
317 ss << *(--_actualdo);
330 if(_actualdo != states.end())
339 _sceneManager->loadDiagram(ss);
343 void wxGEditorTabPanel::saveStringAction(const std::string &action)
346 sprintf(temp,".%d", sstates.size());
347 sstates.push_back(action + temp);
350 //=========================================================================
352 int wxGEditorTabPanel::getPanelId()
359 //=========================================================================
361 bool wxGEditorTabPanel::isComplexBox()
363 return _sceneManager->isComplexBox();
366 //=========================================================================
368 void wxGEditorTabPanel::setComplexBox(bool val)
370 _sceneManager->setComplexBox(val);
373 //=========================================================================
375 void wxGEditorTabPanel::addComplexInputPort(std::string portName)
377 _sceneManager->createGComplexBoxInputPort(portName);
380 //=========================================================================
382 void wxGEditorTabPanel::addComplexOutputPort(std::string portName)
384 _sceneManager->createGComplexBoxOutputPort(portName);
387 //=========================================================================
389 std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
391 return _sceneManager->getSelectedObjects();
394 //=========================================================================
396 void wxGEditorTabPanel::addObjects(std::map<int,GObjectController*> objectsMap)
398 _sceneManager->addObjects(objectsMap);
401 //=========================================================================
403 int wxGEditorTabPanel::getNumSelectedObjects()
405 return _sceneManager->getNumSelectedObjects();
408 //=========================================================================
411 wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
413 return _sceneManager;
416 //=========================================================================
417 std::string wxGEditorTabPanel::GetCbName()
419 return _sceneManager->GetCbName();
423 //=========================================================================
424 std::string wxGEditorTabPanel::GetCbPackageName()
426 return _sceneManager->GetCbPackageName();
429 //=========================================================================
430 std::string wxGEditorTabPanel::GetAuthor()
432 return _sceneManager->GetAuthor();
435 //=========================================================================
436 std::string wxGEditorTabPanel::GetDescription()
438 return _sceneManager->GetDescription();
441 //=========================================================================
442 std::string wxGEditorTabPanel::GetCategory()
444 return _sceneManager->GetCategory();
447 //=========================================================================
448 void wxGEditorTabPanel::SetCbName(std::string cbName)
450 _sceneManager->SetCbName( cbName );
453 //=========================================================================
454 void wxGEditorTabPanel::SetCbPackageName(std::string packagename)
456 _sceneManager->SetCbPackageName( packagename );
460 //=========================================================================
461 void wxGEditorTabPanel::SetAuthor(std::string author)
463 _sceneManager->SetAuthor( author );
467 //=========================================================================
468 void wxGEditorTabPanel::SetCategory(std::string category)
470 _sceneManager->SetCategory( category );
474 //=========================================================================
475 void wxGEditorTabPanel::SetDescription(std::string description)
477 _sceneManager->SetDescription( description );
479 //=========================================================================
481 void wxGEditorTabPanel::SetFullPath( const std::string& fullpath )
483 this->_fullPath = fullpath;
485 //=========================================================================
487 void wxGEditorTabPanel::SetFileName( const std::string& filename )
489 this->_fileName = filename;
491 //=========================================================================
493 std::string wxGEditorTabPanel::GetFullPath( )
495 return( this->_fullPath );
497 //=========================================================================
499 std::string wxGEditorTabPanel::GetFileName( )
501 return( this->_fileName );
507 } // EO namespace bbtk