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::wxTabPanelsManager .
37 #include "wxTabPanelsManager.h"
43 //=========================================================================
44 wxTabPanelsManager::wxTabPanelsManager(wxGUIEditorGraphicBBS *parent)
48 _notebook = _parent->getAuiNotebook();
50 _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabChanged),0,this);
51 _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabClose),0,this);
55 //=========================================================================
56 wxTabPanelsManager::~wxTabPanelsManager()
60 //=========================================================================
61 void wxTabPanelsManager::addNewTab(wxString tabName)
65 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel(_notebook,_lastId);
66 newPanel->setPanelsManager(this);
67 _panels[_lastId] = newPanel;
70 _notebook->AddPage(newPanel, tabName ,true);
77 //=========================================================================
78 wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
83 //=========================================================================
84 wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
89 //=========================================================================
91 void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
93 _parent->displayBlackBoxInfo(packageName,boxName);
96 //=========================================================================
98 void wxTabPanelsManager::updateStatusBar(std::string textStatus)
100 _parent->updateStatusBar(textStatus);
103 //=========================================================================
105 std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
107 return _actual->getDiagramBBS(wln);
110 //=========================================================================
112 std::string wxTabPanelsManager::getActualComplexBoxBBS()
114 return _actual->saveComplexBoxBBS();
117 //=========================================================================
119 void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
121 _parent->editBlackBox(bbmodel);
124 //=========================================================================
126 void wxTabPanelsManager::deleteAllBoxesActualDiagram()
128 _actual->deleteAllBoxes();
131 //=========================================================================
133 void wxTabPanelsManager::centerViewActualDiagram()
135 _actual->centerView();
138 //=========================================================================
140 void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
142 _actual->saveDiagram(content, path);
145 //=========================================================================
147 void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
149 _actual->loadDiagram(inputStream, path);
152 //=========================================================================
153 void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY
155 _parent->SaveTempActualDiagram(action);
157 //=========================================================================
158 void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY
160 _actual->saveTempDiagram(action);
162 //=========================================================================
163 void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
165 _actual->loadTempDiagram(un);
168 //=========================================================================
169 unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY
171 return _actual->getUndoState(stun);
173 //=========================================================================
174 unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY
176 return _actual->getRedoState(stre);
178 //=========================================================================
180 bool wxTabPanelsManager::isActualDiagramComplexBox()
182 return _actual->isComplexBox();
185 //=========================================================================
187 void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
189 _actual->setComplexBox(val);
192 //=========================================================================
194 void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
196 _actual->addComplexInputPort(portName);
199 //=========================================================================
201 void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
203 _actual->addComplexOutputPort(portName);
206 //=========================================================================
208 void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
210 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
212 setActualDiagramComplexBox(true);
213 _actual->addObjects(mapSelected);
214 _parent->refreshGUIControls();
217 //=========================================================================
219 int wxTabPanelsManager::getNumActualSelectedObjects()
221 return _actual->getNumSelectedObjects();
224 //=========================================================================
226 void wxTabPanelsManager::VerifyLastTabPanel()
228 printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() );
229 if (this->_notebook->GetPageCount()==0)
235 //=========================================================================
237 void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
239 int index = event.GetSelection();
240 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
241 int id = tab->getPanelId();
242 _actual = _panels[id];
243 _parent->refreshGUIControls();
247 //=========================================================================
249 void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
252 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
253 int index = event.GetSelection();
257 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
258 int id = tab->getPanelId();
259 tab->deleteAllBoxes();
262 _notebook->RemovePage(index);
264 std::cout<<"RaC wxTabPanelsManager::OnTabClose IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
265 //////////////////////////////
266 // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
267 // Only the objects are deleted and the tab is hidden
268 // Execution problems when a tab is deleted using delete or DeletePage
271 map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
272 _actual=(*it).second;
274 std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
278 //=========================================================================
279 std::string wxTabPanelsManager::GetCbName()
281 return _actual->GetCbName();
284 //=========================================================================
285 void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
287 int id = _notebook->GetSelection();
288 _notebook->SetPageText( id , tabpanelname );
291 std::string wxTabPanelsManager::GetNameTabPanel()
293 int id = _notebook->GetSelection();
294 return crea::wx2std(_notebook->GetPageText(id));
297 //=========================================================================
299 std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
301 int id = _notebook->GetSelection();
302 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
303 return( auxPanel->GetFullPath( ) );
304 //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
308 //=========================================================================
309 std::string wxTabPanelsManager::GetCbPackageName()
311 return _actual->GetCbPackageName();
314 //=========================================================================
315 std::string wxTabPanelsManager::GetAuthor()
317 return _actual->GetAuthor();
320 //=========================================================================
321 std::string wxTabPanelsManager::GetDescription()
323 return _actual->GetDescription();
326 //=========================================================================
327 std::string wxTabPanelsManager::GetCategory()
329 return _actual->GetCategory();
332 //=========================================================================
333 void wxTabPanelsManager::SetCbName(std::string cbName)
335 _actual->SetCbName( cbName );
338 //=========================================================================
339 void wxTabPanelsManager::SetCbPackageName(std::string packagename)
341 _actual->SetCbPackageName( packagename );
345 //=========================================================================
346 void wxTabPanelsManager::SetAuthor(std::string author)
348 _actual->SetAuthor( author );
352 //=========================================================================
353 void wxTabPanelsManager::SetCategory(std::string category)
355 _actual->SetCategory( category );
359 //=========================================================================
360 void wxTabPanelsManager::SetDescription(std::string description)
362 _actual->SetDescription( description );
374 } // EO namespace bbtk