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 wxGUIEditorGraphicBBS* wxTabPanelsManager::GetParentGUIEditorGraphicBBS() const
91 //=========================================================================
92 void wxTabPanelsManager::addNewTab(wxString tabName)
96 //EED 13/10/2012 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel( _notebook,_lastId );
97 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel( _notebook,_lastId, _parent->GetBBTKFactory() );
99 newPanel->setPanelsManager(this);
100 _panels[_lastId] = newPanel;
102 _notebook->AddPage(newPanel, tabName ,true);
109 //=========================================================================
110 wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
115 //=========================================================================
116 wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
121 //=========================================================================
123 void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
125 _parent->displayBlackBoxInfo(packageName,boxName);
128 //=========================================================================
130 void wxTabPanelsManager::updateStatusBar(std::string textStatus)
132 _parent->updateStatusBar(textStatus);
135 //=========================================================================
137 std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
139 return _actual->getDiagramBBS(wln);
142 //=========================================================================
144 std::string wxTabPanelsManager::getActualComplexBoxBBS()
146 return _actual->saveComplexBoxBBS();
149 //=========================================================================
151 void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
153 _parent->editBlackBox(bbmodel);
156 //=========================================================================
158 void wxTabPanelsManager::deleteAllBoxesActualDiagram()
160 _actual->deleteAllBoxes();
163 //=========================================================================
165 void wxTabPanelsManager::centerViewActualDiagram()
167 _actual->centerView();
170 //=========================================================================
172 void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
174 _actual->saveDiagram(content, path);
177 //=========================================================================
179 void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
181 _actual->loadDiagram(inputStream, path);
184 //=========================================================================
185 void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY
187 _parent->SaveTempActualDiagram(action);
189 //=========================================================================
190 void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY
192 _actual->saveTempDiagram(action);
194 //=========================================================================
195 void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
197 _actual->loadTempDiagram(un);
200 //=========================================================================
201 unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY
203 return _actual->getUndoState(stun);
205 //=========================================================================
206 unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY
208 return _actual->getRedoState(stre);
210 //=========================================================================
212 bool wxTabPanelsManager::isActualDiagramComplexBox()
214 return _actual->isComplexBox();
217 //=========================================================================
219 void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
221 _actual->setComplexBox(val);
224 //=========================================================================
226 void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
228 _actual->addComplexInputPort(portName);
231 //=========================================================================
233 void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
235 _actual->addComplexOutputPort(portName);
238 //=========================================================================
240 void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
242 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
244 setActualDiagramComplexBox(true);
245 _actual->addObjects(mapSelected);
246 _parent->refreshGUIControls();
249 //=========================================================================
251 int wxTabPanelsManager::getNumActualSelectedObjects()
253 return _actual->getNumSelectedObjects();
256 //=========================================================================
258 void wxTabPanelsManager::VerifyLastTabPanel()
260 if (this->_notebook->GetPageCount()==0)
266 //=========================================================================
268 void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
270 int index = event.GetSelection();
271 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
272 int id = tab->getPanelId();
273 _actual = _panels[id];
274 _parent->refreshGUIControls();
278 //=========================================================================
280 void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
283 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
284 int index = event.GetSelection();
288 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
289 int id = tab->getPanelId();
290 tab->deleteAllBoxes();
293 _notebook->RemovePage(index);
295 std::cout<<"RaC wxTabPanelsManager::OnTabClose IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
296 //////////////////////////////
297 // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
298 // Only the objects are deleted and the tab is hidden
299 // Execution problems when a tab is deleted using delete or DeletePage
302 map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
303 _actual=(*it).second;
305 std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
309 //=========================================================================
310 std::string wxTabPanelsManager::GetCbName()
312 return _actual->GetCbName();
315 //=========================================================================
316 void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
318 int id = _notebook->GetSelection();
319 _notebook->SetPageText( id , tabpanelname );
322 std::string wxTabPanelsManager::GetNameTabPanel()
324 int id = _notebook->GetSelection();
325 return crea::wx2std(_notebook->GetPageText(id));
328 //=========================================================================
330 std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
332 int id = _notebook->GetSelection();
333 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
334 return( auxPanel->GetFullPath( ) );
335 //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
338 //=========================================================================
340 int wxTabPanelsManager::FindTab(std::string filename)
342 std::map<int, wxGEditorTabPanel*>::iterator it;
343 for (it = _panels.begin(); it != _panels.end(); ++it)
345 wxGEditorTabPanel *obj = it->second;
347 if(obj->GetFullPath()==filename)
353 //=========================================================================
354 std::string wxTabPanelsManager::GetCbPackageName()
356 return _actual->GetCbPackageName();
359 //=========================================================================
360 std::string wxTabPanelsManager::GetAuthor()
362 return _actual->GetAuthor();
365 //=========================================================================
366 std::string wxTabPanelsManager::GetDescription()
368 return _actual->GetDescription();
371 //=========================================================================
372 std::string wxTabPanelsManager::GetCategory()
374 return _actual->GetCategory();
377 //=========================================================================
378 std::string wxTabPanelsManager::GetMessageKind()
380 return _actual->GetMessageKind();
383 //=========================================================================
384 std::string wxTabPanelsManager::GetMessageLevel()
386 return _actual->GetMessageLevel();
389 //=========================================================================
390 void wxTabPanelsManager::SetCbName(std::string cbName)
392 _actual->SetCbName( cbName );
395 //=========================================================================
396 void wxTabPanelsManager::SetCbPackageName(std::string packagename)
398 _actual->SetCbPackageName( packagename );
402 //=========================================================================
403 void wxTabPanelsManager::SetAuthor(std::string author)
405 _actual->SetAuthor( author );
409 //=========================================================================
410 void wxTabPanelsManager::SetCategory(std::string category)
412 _actual->SetCategory( category );
415 //=========================================================================
416 void wxTabPanelsManager::SetDescription(std::string description)
418 _actual->SetDescription( description );
422 //=========================================================================
423 void wxTabPanelsManager::SetMessageKind(std::string kind){
424 _actual->SetMessageKind(kind);
428 //=========================================================================
429 void wxTabPanelsManager::SetMessageLevel(std::string level){
430 _actual->SetMessageLevel(level);
433 //=========================================================================
434 bool wxTabPanelsManager::TryToOpenScriptApplication(std::string packageName ,std::string boxType)
436 return _parent->TryToOpenScriptApplication( packageName, boxType );
439 //=========================================================================
441 void wxTabPanelsManager::SelectBoxWithPossibleName(std::string nameFilter )
443 _actual->SelectBoxWithPossibleName( nameFilter );
446 } // EO namespace bbtk