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);
155 //=========================================================================
156 void wxTabPanelsManager::saveTempandUpdate() //FCY
158 _parent->SaveTempActualDiagram();
160 //=========================================================================
161 void wxTabPanelsManager::saveTempActualDiagram() //FCY
163 _actual->saveTempDiagram();
165 //=========================================================================
166 void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
168 _actual->loadTempDiagram(un);
171 //=========================================================================
172 unsigned short wxTabPanelsManager::getUndoState() //FCY
174 return _actual->getUndoState();
176 //=========================================================================
177 unsigned short wxTabPanelsManager::getRedoState() //FCY
179 return _actual->getRedoState();
181 //=========================================================================
183 bool wxTabPanelsManager::isActualDiagramComplexBox()
185 return _actual->isComplexBox();
188 //=========================================================================
190 void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
192 _actual->setComplexBox(val);
195 //=========================================================================
197 void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
199 _actual->addComplexInputPort(portName);
202 //=========================================================================
204 void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
206 _actual->addComplexOutputPort(portName);
209 //=========================================================================
211 void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
213 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
215 setActualDiagramComplexBox(true);
216 _actual->addObjects(mapSelected);
217 _parent->refreshGUIControls();
220 //=========================================================================
222 int wxTabPanelsManager::getNumActualSelectedObjects()
224 return _actual->getNumSelectedObjects();
227 //=========================================================================
229 void wxTabPanelsManager::VerifyLastTabPanel()
231 printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPageCount() );
232 if (this->_notebook->GetPageCount()==0)
238 //=========================================================================
240 void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
242 int index = event.GetSelection();
243 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
244 int id = tab->getPanelId();
245 _actual = _panels[id];
246 _parent->refreshGUIControls();
250 //=========================================================================
252 void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
255 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
256 int index = event.GetSelection();
260 wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index);
261 int id = tab->getPanelId();
262 tab->deleteAllBoxes();
265 _notebook->RemovePage(index);
267 std::cout<<"RaC wxTabPanelsManager::OnTabClose IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
268 //////////////////////////////
269 // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
270 // Only the objects are deleted and the tab is hidden
271 // Execution problems when a tab is deleted using delete or DeletePage
274 map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
275 _actual=(*it).second;
277 std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
281 //=========================================================================
282 std::string wxTabPanelsManager::GetCbName()
284 return _actual->GetCbName();
287 //=========================================================================
288 void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
290 int id = _notebook->GetSelection();
291 _notebook->SetPageText( id , tabpanelname );
294 std::string wxTabPanelsManager::GetNameTabPanel()
296 int id = _notebook->GetSelection();
297 return crea::wx2std(_notebook->GetPageText(id));
300 //=========================================================================
302 std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
304 int id = _notebook->GetSelection();
305 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
306 return( auxPanel->GetFullPath( ) );
307 //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
311 //=========================================================================
312 std::string wxTabPanelsManager::GetCbPackageName()
314 return _actual->GetCbPackageName();
317 //=========================================================================
318 std::string wxTabPanelsManager::GetAuthor()
320 return _actual->GetAuthor();
323 //=========================================================================
324 std::string wxTabPanelsManager::GetDescription()
326 return _actual->GetDescription();
329 //=========================================================================
330 std::string wxTabPanelsManager::GetCategory()
332 return _actual->GetCategory();
335 //=========================================================================
336 void wxTabPanelsManager::SetCbName(std::string cbName)
338 _actual->SetCbName( cbName );
341 //=========================================================================
342 void wxTabPanelsManager::SetCbPackageName(std::string packagename)
344 _actual->SetCbPackageName( packagename );
348 //=========================================================================
349 void wxTabPanelsManager::SetAuthor(std::string author)
351 _actual->SetAuthor( author );
355 //=========================================================================
356 void wxTabPanelsManager::SetCategory(std::string category)
358 _actual->SetCategory( category );
362 //=========================================================================
363 void wxTabPanelsManager::SetDescription(std::string description)
365 _actual->SetDescription( description );
377 } // EO namespace bbtk