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::wxTabPanelsManager .
62 #include "wxTabPanelsManager.h"
68 //=========================================================================
69 wxTabPanelsManager::wxTabPanelsManager(wxGUIEditorGraphicBBS *parent)
73 _notebook = _parent->getAuiNotebook();
75 _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabChanged),0,this);
76 _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabClose),0,this);
80 //=========================================================================
81 wxTabPanelsManager::~wxTabPanelsManager()
85 //=========================================================================
86 void wxTabPanelsManager::addNewTab(wxString tabName)
90 //EED 13/10/2012 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel( _notebook,_lastId );
91 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel( _notebook,_lastId, _parent->GetBBTKFactory() );
93 newPanel->setPanelsManager(this);
94 _panels[_lastId] = newPanel;
96 _notebook->AddPage(newPanel, tabName ,true);
103 //=========================================================================
104 wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
109 //=========================================================================
110 wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
115 //=========================================================================
117 void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
119 _parent->displayBlackBoxInfo(packageName,boxName);
122 //=========================================================================
124 void wxTabPanelsManager::updateStatusBar(std::string textStatus)
126 _parent->updateStatusBar(textStatus);
129 //=========================================================================
131 std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
133 return _actual->getDiagramBBS(wln);
136 //=========================================================================
138 std::string wxTabPanelsManager::getActualComplexBoxBBS()
140 return _actual->saveComplexBoxBBS();
143 //=========================================================================
145 void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
147 _parent->editBlackBox(bbmodel);
150 //=========================================================================
152 void wxTabPanelsManager::deleteAllBoxesActualDiagram()
154 _actual->deleteAllBoxes();
157 //=========================================================================
159 void wxTabPanelsManager::centerViewActualDiagram()
161 _actual->centerView();
164 //=========================================================================
166 void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
168 _actual->saveDiagram(content, path);
171 //=========================================================================
173 void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
175 _actual->loadDiagram(inputStream, path);
178 //=========================================================================
179 void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY
181 _parent->SaveTempActualDiagram(action);
183 //=========================================================================
184 void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY
186 _actual->saveTempDiagram(action);
188 //=========================================================================
189 void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
191 _actual->loadTempDiagram(un);
194 //=========================================================================
195 unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY
197 return _actual->getUndoState(stun);
199 //=========================================================================
200 unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY
202 return _actual->getRedoState(stre);
204 //=========================================================================
206 bool wxTabPanelsManager::isActualDiagramComplexBox()
208 return _actual->isComplexBox();
211 //=========================================================================
213 void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
215 _actual->setComplexBox(val);
218 //=========================================================================
220 void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
222 _actual->addComplexInputPort(portName);
225 //=========================================================================
227 void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
229 _actual->addComplexOutputPort(portName);
232 //=========================================================================
234 void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
236 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
238 setActualDiagramComplexBox(true);
239 _actual->addObjects(mapSelected);
240 _parent->refreshGUIControls();
243 //=========================================================================
245 int wxTabPanelsManager::getNumActualSelectedObjects()
247 return _actual->getNumSelectedObjects();
250 //=========================================================================
252 void wxTabPanelsManager::VerifyLastTabPanel()
254 printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() );
255 if (this->_notebook->GetPageCount()==0)
261 //=========================================================================
263 void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
265 int index = event.GetSelection();
266 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
267 int id = tab->getPanelId();
268 _actual = _panels[id];
269 _parent->refreshGUIControls();
273 //=========================================================================
275 void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
278 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
279 int index = event.GetSelection();
283 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
284 int id = tab->getPanelId();
285 tab->deleteAllBoxes();
288 _notebook->RemovePage(index);
290 std::cout<<"RaC wxTabPanelsManager::OnTabClose IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
291 //////////////////////////////
292 // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
293 // Only the objects are deleted and the tab is hidden
294 // Execution problems when a tab is deleted using delete or DeletePage
297 map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
298 _actual=(*it).second;
300 std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
304 //=========================================================================
305 std::string wxTabPanelsManager::GetCbName()
307 return _actual->GetCbName();
310 //=========================================================================
311 void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
313 int id = _notebook->GetSelection();
314 _notebook->SetPageText( id , tabpanelname );
317 std::string wxTabPanelsManager::GetNameTabPanel()
319 int id = _notebook->GetSelection();
320 return crea::wx2std(_notebook->GetPageText(id));
323 //=========================================================================
325 std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
327 int id = _notebook->GetSelection();
328 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
329 return( auxPanel->GetFullPath( ) );
330 //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
333 //=========================================================================
335 int wxTabPanelsManager::FindTab(std::string filename)
337 std::map<int, wxGEditorTabPanel*>::iterator it;
338 for (it = _panels.begin(); it != _panels.end(); ++it)
340 wxGEditorTabPanel *obj = it->second;
342 if(obj->GetFullPath()==filename)
348 //=========================================================================
349 std::string wxTabPanelsManager::GetCbPackageName()
351 return _actual->GetCbPackageName();
354 //=========================================================================
355 std::string wxTabPanelsManager::GetAuthor()
357 return _actual->GetAuthor();
360 //=========================================================================
361 std::string wxTabPanelsManager::GetDescription()
363 return _actual->GetDescription();
366 //=========================================================================
367 std::string wxTabPanelsManager::GetCategory()
369 return _actual->GetCategory();
372 //=========================================================================
373 void wxTabPanelsManager::SetCbName(std::string cbName)
375 _actual->SetCbName( cbName );
378 //=========================================================================
379 void wxTabPanelsManager::SetCbPackageName(std::string packagename)
381 _actual->SetCbPackageName( packagename );
385 //=========================================================================
386 void wxTabPanelsManager::SetAuthor(std::string author)
388 _actual->SetAuthor( author );
392 //=========================================================================
393 void wxTabPanelsManager::SetCategory(std::string category)
395 _actual->SetCategory( category );
398 //=========================================================================
399 void wxTabPanelsManager::SetDescription(std::string description)
401 _actual->SetDescription( description );
404 //=========================================================================
405 bool wxTabPanelsManager::TryToOpenScriptApplication(std::string packageName ,std::string boxType)
407 return _parent->TryToOpenScriptApplication( packageName, boxType );
410 } // EO namespace bbtk