]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
Feature #1380
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxTabPanelsManager.cxx
1 /*=========================================================================
2 Program:   bbtk
3 Module:    $RCSfile$
4 Language:  C++
5 Date:      $Date$
6 Version:   $Revision$
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability.
26 *
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 * ------------------------------------------------------------------------ */
30
31 /**
32 *  \file
33 *  \brief Class bbtk::wxTabPanelsManager .
34 */
35
36
37 #include "wxTabPanelsManager.h"
38
39 namespace bbtk
40 {
41
42
43         //=========================================================================
44         wxTabPanelsManager::wxTabPanelsManager(wxGUIEditorGraphicBBS *parent)
45         {
46                 _parent         = parent;
47                 _lastId         = 0;
48                 _notebook       = _parent->getAuiNotebook();
49                 addNewTab();
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);
52
53         }
54
55         //=========================================================================
56         wxTabPanelsManager::~wxTabPanelsManager()
57         {
58         }
59
60         //=========================================================================
61         void wxTabPanelsManager::addNewTab(wxString tabName)
62         {
63 printf("EED wxTabPanelsManager::addNewTab 0\n");
64
65                 _lastId++;
66                 wxGEditorTabPanel *newPanel         = new wxGEditorTabPanel(_notebook,_lastId);
67                 newPanel->setPanelsManager(this);
68                 _panels[_lastId]                    = newPanel;
69                 _actual                             = newPanel;
70
71                 _notebook->AddPage(newPanel, tabName  ,true);
72
73 printf("EED wxTabPanelsManager::addNewTab 1\n");
74         }
75
76
77
78
79
80         //=========================================================================
81         wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
82         {
83                 return _notebook;
84         }
85
86         //=========================================================================
87         wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
88         {
89                 return _actual;
90         }
91
92         //=========================================================================
93
94         void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
95         {
96                 _parent->displayBlackBoxInfo(packageName,boxName);
97         }
98
99         //=========================================================================
100
101         void wxTabPanelsManager::updateStatusBar(std::string textStatus)
102         {
103                 _parent->updateStatusBar(textStatus);
104         }
105
106         //=========================================================================
107
108         std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
109         {
110                 return _actual->getDiagramBBS(wln);
111         }
112
113         //=========================================================================
114
115         std::string wxTabPanelsManager::getActualComplexBoxBBS()
116         {
117                 return _actual->saveComplexBoxBBS();
118         }
119
120         //=========================================================================
121
122         void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
123         {
124                 _parent->editBlackBox(bbmodel);
125         }
126
127         //=========================================================================
128
129         void wxTabPanelsManager::deleteAllBoxesActualDiagram()
130         {
131                 _actual->deleteAllBoxes();
132         }
133
134         //=========================================================================
135
136         void wxTabPanelsManager::centerViewActualDiagram()
137         {
138                 _actual->centerView();
139         }
140
141         //=========================================================================
142
143         void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
144         {
145                 _actual->saveDiagram(content, path);
146         }
147
148         //=========================================================================
149
150         void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
151         {
152                 _actual->loadDiagram(inputStream, path);
153         }
154
155         //=========================================================================
156         void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY
157         {
158                 _parent->SaveTempActualDiagram(action);
159         }
160         //=========================================================================
161         void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY
162         {
163                 _actual->saveTempDiagram(action);
164         }
165         //=========================================================================
166         void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
167         {
168                  _actual->loadTempDiagram(un);
169         }
170
171         //=========================================================================
172         unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY
173         {
174                  return _actual->getUndoState(stun);
175         }
176                 //=========================================================================
177         unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY
178         {
179                  return _actual->getRedoState(stre);
180         }
181         //=========================================================================
182
183         bool wxTabPanelsManager::isActualDiagramComplexBox()
184         {
185                 return _actual->isComplexBox();
186         }
187
188         //=========================================================================
189
190         void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
191         {
192                 _actual->setComplexBox(val);
193         }
194
195         //=========================================================================
196
197         void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
198         {
199                 _actual->addComplexInputPort(portName);
200         }
201
202         //=========================================================================
203
204         void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
205         {
206                 _actual->addComplexOutputPort(portName);
207         }
208
209         //=========================================================================
210
211         void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
212         {
213                 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
214                 addNewTab();
215                 setActualDiagramComplexBox(true);
216                 _actual->addObjects(mapSelected);
217                 _parent->refreshGUIControls();
218         }
219
220         //=========================================================================
221
222         int wxTabPanelsManager::getNumActualSelectedObjects()
223         {
224                 return _actual->getNumSelectedObjects();
225         }
226
227         //=========================================================================
228
229         void wxTabPanelsManager::VerifyLastTabPanel()
230         {
231 printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPageCount() );
232             if (this->_notebook->GetPageCount()==0)
233             {
234                 this->_actual=NULL;
235             }
236         }
237
238         //=========================================================================
239
240         void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
241         {
242                 int index                   = event.GetSelection();
243                 wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
244                 int id                      = tab->getPanelId();
245                 _actual                     = _panels[id];
246                 _parent->refreshGUIControls();
247
248         }
249
250         //=========================================================================
251
252         void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
253         {
254
255                 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
256                 int index = event.GetSelection();
257
258                 if(_panels.size()>0)
259                 {
260                         wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
261                         int id                      = tab->getPanelId();
262                         tab->deleteAllBoxes();
263                         _panels.erase(id);
264
265                         _notebook->RemovePage(index);
266
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
272                         // delete tab;
273
274                         map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
275                         _actual=(*it).second;
276
277                         std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
278                 }
279         }
280
281         //=========================================================================
282     std::string wxTabPanelsManager::GetCbName()
283         {
284             return _actual->GetCbName();
285         }
286         
287         //=========================================================================
288         void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
289         {
290             int id          = _notebook->GetSelection();
291             _notebook->SetPageText( id , tabpanelname );
292         }
293
294         std::string wxTabPanelsManager::GetNameTabPanel() 
295         {
296                  int id = _notebook->GetSelection();
297                 return crea::wx2std(_notebook->GetPageText(id));
298         }
299
300         //=========================================================================
301         //DFCH
302         std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
303         {
304                 int id          = _notebook->GetSelection();
305                 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
306                 return( auxPanel->GetFullPath( ) );
307             //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
308         }
309
310
311         //=========================================================================
312     std::string wxTabPanelsManager::GetCbPackageName()
313         {
314             return _actual->GetCbPackageName();
315         }
316
317         //=========================================================================
318     std::string wxTabPanelsManager::GetAuthor()
319         {
320             return _actual->GetAuthor();
321         }
322
323         //=========================================================================
324     std::string wxTabPanelsManager::GetDescription()
325         {
326             return _actual->GetDescription();
327         }
328
329         //=========================================================================
330     std::string wxTabPanelsManager::GetCategory()
331         {
332             return _actual->GetCategory();
333         }
334
335         //=========================================================================
336     void wxTabPanelsManager::SetCbName(std::string cbName)
337     {
338         _actual->SetCbName( cbName );
339     }
340
341         //=========================================================================
342     void wxTabPanelsManager::SetCbPackageName(std::string packagename)
343     {
344         _actual->SetCbPackageName( packagename );
345     }
346
347
348         //=========================================================================
349     void wxTabPanelsManager::SetAuthor(std::string author)
350     {
351         _actual->SetAuthor( author );
352     }
353
354
355         //=========================================================================
356     void wxTabPanelsManager::SetCategory(std::string category)
357     {
358         _actual->SetCategory( category );
359     }
360
361
362         //=========================================================================
363     void wxTabPanelsManager::SetDescription(std::string description)
364     {
365         _actual->SetDescription( description );
366     }
367
368
369
370
371
372
373
374
375
376
377 }  // EO namespace bbtk
378
379 // EOF
380