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 //EED 13/10/2012 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel( _notebook,_lastId );
66 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel( _notebook,_lastId, _parent->GetBBTKFactory() );
68 newPanel->setPanelsManager(this);
69 _panels[_lastId] = newPanel;
71 _notebook->AddPage(newPanel, tabName ,true);
78 //=========================================================================
79 wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
84 //=========================================================================
85 wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
90 //=========================================================================
92 void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
94 _parent->displayBlackBoxInfo(packageName,boxName);
97 //=========================================================================
99 void wxTabPanelsManager::updateStatusBar(std::string textStatus)
101 _parent->updateStatusBar(textStatus);
104 //=========================================================================
106 std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
108 return _actual->getDiagramBBS(wln);
111 //=========================================================================
113 std::string wxTabPanelsManager::getActualComplexBoxBBS()
115 return _actual->saveComplexBoxBBS();
118 //=========================================================================
120 void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
122 _parent->editBlackBox(bbmodel);
125 //=========================================================================
127 void wxTabPanelsManager::deleteAllBoxesActualDiagram()
129 _actual->deleteAllBoxes();
132 //=========================================================================
134 void wxTabPanelsManager::centerViewActualDiagram()
136 _actual->centerView();
139 //=========================================================================
141 void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
143 _actual->saveDiagram(content, path);
146 //=========================================================================
148 void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
150 _actual->loadDiagram(inputStream, path);
153 //=========================================================================
154 void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY
156 _parent->SaveTempActualDiagram(action);
158 //=========================================================================
159 void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY
161 _actual->saveTempDiagram(action);
163 //=========================================================================
164 void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
166 _actual->loadTempDiagram(un);
169 //=========================================================================
170 unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY
172 return _actual->getUndoState(stun);
174 //=========================================================================
175 unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY
177 return _actual->getRedoState(stre);
179 //=========================================================================
181 bool wxTabPanelsManager::isActualDiagramComplexBox()
183 return _actual->isComplexBox();
186 //=========================================================================
188 void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
190 _actual->setComplexBox(val);
193 //=========================================================================
195 void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
197 _actual->addComplexInputPort(portName);
200 //=========================================================================
202 void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
204 _actual->addComplexOutputPort(portName);
207 //=========================================================================
209 void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
211 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
213 setActualDiagramComplexBox(true);
214 _actual->addObjects(mapSelected);
215 _parent->refreshGUIControls();
218 //=========================================================================
220 int wxTabPanelsManager::getNumActualSelectedObjects()
222 return _actual->getNumSelectedObjects();
225 //=========================================================================
227 void wxTabPanelsManager::VerifyLastTabPanel()
229 printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() );
230 if (this->_notebook->GetPageCount()==0)
236 //=========================================================================
238 void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
240 int index = event.GetSelection();
241 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
242 int id = tab->getPanelId();
243 _actual = _panels[id];
244 _parent->refreshGUIControls();
248 //=========================================================================
250 void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
253 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
254 int index = event.GetSelection();
258 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
259 int id = tab->getPanelId();
260 tab->deleteAllBoxes();
263 _notebook->RemovePage(index);
265 std::cout<<"RaC wxTabPanelsManager::OnTabClose IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
266 //////////////////////////////
267 // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
268 // Only the objects are deleted and the tab is hidden
269 // Execution problems when a tab is deleted using delete or DeletePage
272 map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
273 _actual=(*it).second;
275 std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
279 //=========================================================================
280 std::string wxTabPanelsManager::GetCbName()
282 return _actual->GetCbName();
285 //=========================================================================
286 void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
288 int id = _notebook->GetSelection();
289 _notebook->SetPageText( id , tabpanelname );
292 std::string wxTabPanelsManager::GetNameTabPanel()
294 int id = _notebook->GetSelection();
295 return crea::wx2std(_notebook->GetPageText(id));
298 //=========================================================================
300 std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
302 int id = _notebook->GetSelection();
303 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
304 return( auxPanel->GetFullPath( ) );
305 //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
308 //=========================================================================
310 int wxTabPanelsManager::FindTab(std::string filename)
312 std::map<int, wxGEditorTabPanel*>::iterator it;
313 for (it = _panels.begin(); it != _panels.end(); ++it)
315 wxGEditorTabPanel *obj = it->second;
317 if(obj->GetFullPath()==filename)
323 //=========================================================================
324 std::string wxTabPanelsManager::GetCbPackageName()
326 return _actual->GetCbPackageName();
329 //=========================================================================
330 std::string wxTabPanelsManager::GetAuthor()
332 return _actual->GetAuthor();
335 //=========================================================================
336 std::string wxTabPanelsManager::GetDescription()
338 return _actual->GetDescription();
341 //=========================================================================
342 std::string wxTabPanelsManager::GetCategory()
344 return _actual->GetCategory();
347 //=========================================================================
348 void wxTabPanelsManager::SetCbName(std::string cbName)
350 _actual->SetCbName( cbName );
353 //=========================================================================
354 void wxTabPanelsManager::SetCbPackageName(std::string packagename)
356 _actual->SetCbPackageName( packagename );
360 //=========================================================================
361 void wxTabPanelsManager::SetAuthor(std::string author)
363 _actual->SetAuthor( author );
367 //=========================================================================
368 void wxTabPanelsManager::SetCategory(std::string category)
370 _actual->SetCategory( category );
373 //=========================================================================
374 void wxTabPanelsManager::SetDescription(std::string description)
376 _actual->SetDescription( description );
379 //=========================================================================
380 bool wxTabPanelsManager::TryToOpenScriptApplication(std::string packageName ,std::string boxType)
382 _parent->TryToOpenScriptApplication( packageName, boxType );
385 } // EO namespace bbtk