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)
63 printf("EED wxTabPanelsManager::addNewTab 0\n");
66 wxGEditorTabPanel *newPanel = new wxGEditorTabPanel(_notebook,_lastId);
67 newPanel->setPanelsManager(this);
68 _panels[_lastId] = newPanel;
71 _notebook->AddPage(newPanel, tabName ,true);
73 printf("EED wxTabPanelsManager::addNewTab 1\n");
80 //=========================================================================
81 wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
86 //=========================================================================
87 wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
92 //=========================================================================
94 void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
96 _parent->displayBlackBoxInfo(packageName,boxName);
99 //=========================================================================
101 void wxTabPanelsManager::updateStatusBar(std::string textStatus)
103 _parent->updateStatusBar(textStatus);
106 //=========================================================================
108 std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
110 return _actual->getDiagramBBS(wln);
113 //=========================================================================
115 std::string wxTabPanelsManager::getActualComplexBoxBBS()
117 return _actual->saveComplexBoxBBS();
120 //=========================================================================
122 void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
124 _parent->editBlackBox(bbmodel);
127 //=========================================================================
129 void wxTabPanelsManager::deleteAllBoxesActualDiagram()
131 _actual->deleteAllBoxes();
134 //=========================================================================
136 void wxTabPanelsManager::centerViewActualDiagram()
138 _actual->centerView();
141 //=========================================================================
143 void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
145 _actual->saveDiagram(content, path);
148 //=========================================================================
150 void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
152 _actual->loadDiagram(inputStream, path);
154 //=========================================================================
155 void wxTabPanelsManager::saveTempActualDiagram() //FCY
157 _actual->saveTempDiagram();
159 //=========================================================================
160 void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
162 _actual->loadTempDiagram(un);
165 //=========================================================================
166 unsigned short wxTabPanelsManager::getUndoState() //FCY
168 return _actual->getUndoState();
170 //=========================================================================
171 unsigned short wxTabPanelsManager::getRedoState() //FCY
173 return _actual->getRedoState();
175 //=========================================================================
177 bool wxTabPanelsManager::isActualDiagramComplexBox()
179 return _actual->isComplexBox();
182 //=========================================================================
184 void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
186 _actual->setComplexBox(val);
189 //=========================================================================
191 void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
193 _actual->addComplexInputPort(portName);
196 //=========================================================================
198 void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
200 _actual->addComplexOutputPort(portName);
203 //=========================================================================
205 void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
207 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
209 setActualDiagramComplexBox(true);
210 _actual->addObjects(mapSelected);
211 _parent->refreshGUIControls();
214 //=========================================================================
216 int wxTabPanelsManager::getNumActualSelectedObjects()
218 return _actual->getNumSelectedObjects();
221 //=========================================================================
223 void wxTabPanelsManager::VerifyLastTabPanel()
225 printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() );
226 if (this->_notebook->GetPageCount()==0)
232 //=========================================================================
234 void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
236 int index = event.GetSelection();
237 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
238 int id = tab->getPanelId();
239 _actual = _panels[id];
240 _parent->refreshGUIControls();
244 //=========================================================================
246 void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
249 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
250 int index = event.GetSelection();
254 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
255 int id = tab->getPanelId();
256 tab->deleteAllBoxes();
259 _notebook->RemovePage(index);
261 std::cout<<"RaC wxTabPanelsManager::OnTabClose IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
262 //////////////////////////////
263 // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
264 // Only the objects are deleted and the tab is hidden
265 // Execution problems when a tab is deleted using delete or DeletePage
268 map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
269 _actual=(*it).second;
271 std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
275 //=========================================================================
276 std::string wxTabPanelsManager::GetCbName()
278 return _actual->GetCbName();
281 //=========================================================================
282 void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
284 int id = _notebook->GetSelection();
285 _notebook->SetPageText( id , tabpanelname );
288 std::string wxTabPanelsManager::GetNameTabPanel()
290 int id = _notebook->GetSelection();
291 return crea::wx2std(_notebook->GetPageText(id));
294 //=========================================================================
296 std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
298 int id = _notebook->GetSelection();
299 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
300 return( auxPanel->GetFullPath( ) );
301 //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
305 //=========================================================================
306 std::string wxTabPanelsManager::GetCbPackageName()
308 return _actual->GetCbPackageName();
311 //=========================================================================
312 std::string wxTabPanelsManager::GetAuthor()
314 return _actual->GetAuthor();
317 //=========================================================================
318 std::string wxTabPanelsManager::GetDescription()
320 return _actual->GetDescription();
323 //=========================================================================
324 std::string wxTabPanelsManager::GetCategory()
326 return _actual->GetCategory();
329 //=========================================================================
330 void wxTabPanelsManager::SetCbName(std::string cbName)
332 _actual->SetCbName( cbName );
335 //=========================================================================
336 void wxTabPanelsManager::SetCbPackageName(std::string packagename)
338 _actual->SetCbPackageName( packagename );
342 //=========================================================================
343 void wxTabPanelsManager::SetAuthor(std::string author)
345 _actual->SetAuthor( author );
349 //=========================================================================
350 void wxTabPanelsManager::SetCategory(std::string category)
352 _actual->SetCategory( category );
356 //=========================================================================
357 void wxTabPanelsManager::SetDescription(std::string description)
359 _actual->SetDescription( description );
371 } // EO namespace bbtk