]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
14f85311b1bacc5f87e8e57b0a6c52b23827bb79
[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         void wxTabPanelsManager::saveTempActualDiagram() //FCY
156         {
157                 _actual->saveTempDiagram();
158         }
159         //=========================================================================
160         void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
161         {
162                  _actual->loadTempDiagram(un);
163         }
164
165         //=========================================================================
166         unsigned short wxTabPanelsManager::getUndoState() //FCY
167         {
168                  return _actual->getUndoState();
169         }
170                 //=========================================================================
171         unsigned short wxTabPanelsManager::getRedoState() //FCY
172         {
173                  return _actual->getRedoState();
174         }
175         //=========================================================================
176
177         bool wxTabPanelsManager::isActualDiagramComplexBox()
178         {
179                 return _actual->isComplexBox();
180         }
181
182         //=========================================================================
183
184         void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
185         {
186                 _actual->setComplexBox(val);
187         }
188
189         //=========================================================================
190
191         void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
192         {
193                 _actual->addComplexInputPort(portName);
194         }
195
196         //=========================================================================
197
198         void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
199         {
200                 _actual->addComplexOutputPort(portName);
201         }
202
203         //=========================================================================
204
205         void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
206         {
207                 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
208                 addNewTab();
209                 setActualDiagramComplexBox(true);
210                 _actual->addObjects(mapSelected);
211                 _parent->refreshGUIControls();
212         }
213
214         //=========================================================================
215
216         int wxTabPanelsManager::getNumActualSelectedObjects()
217         {
218                 return _actual->getNumSelectedObjects();
219         }
220
221         //=========================================================================
222
223         void wxTabPanelsManager::VerifyLastTabPanel()
224         {
225 printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPageCount() );
226             if (this->_notebook->GetPageCount()==0)
227             {
228                 this->_actual=NULL;
229             }
230         }
231
232         //=========================================================================
233
234         void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
235         {
236                 int index                   = event.GetSelection();
237                 wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
238                 int id                      = tab->getPanelId();
239                 _actual                     = _panels[id];
240                 _parent->refreshGUIControls();
241
242         }
243
244         //=========================================================================
245
246         void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
247         {
248
249                 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
250                 int index = event.GetSelection();
251
252                 if(_panels.size()>0)
253                 {
254                         wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
255                         int id                      = tab->getPanelId();
256                         tab->deleteAllBoxes();
257                         _panels.erase(id);
258
259                         _notebook->RemovePage(index);
260
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
266                         // delete tab;
267
268                         map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
269                         _actual=(*it).second;
270
271                         std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
272                 }
273         }
274
275         //=========================================================================
276     std::string wxTabPanelsManager::GetCbName()
277         {
278             return _actual->GetCbName();
279         }
280         
281         //=========================================================================
282         void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
283         {
284             int id          = _notebook->GetSelection();
285             _notebook->SetPageText( id , tabpanelname );
286         }
287
288         std::string wxTabPanelsManager::GetNameTabPanel() 
289         {
290                  int id = _notebook->GetSelection();
291                 return crea::wx2std(_notebook->GetPageText(id));
292         }
293
294         //=========================================================================
295         //DFCH
296         std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
297         {
298                 int id          = _notebook->GetSelection();
299                 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
300                 return( auxPanel->GetFullPath( ) );
301             //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
302         }
303
304
305         //=========================================================================
306     std::string wxTabPanelsManager::GetCbPackageName()
307         {
308             return _actual->GetCbPackageName();
309         }
310
311         //=========================================================================
312     std::string wxTabPanelsManager::GetAuthor()
313         {
314             return _actual->GetAuthor();
315         }
316
317         //=========================================================================
318     std::string wxTabPanelsManager::GetDescription()
319         {
320             return _actual->GetDescription();
321         }
322
323         //=========================================================================
324     std::string wxTabPanelsManager::GetCategory()
325         {
326             return _actual->GetCategory();
327         }
328
329         //=========================================================================
330     void wxTabPanelsManager::SetCbName(std::string cbName)
331     {
332         _actual->SetCbName( cbName );
333     }
334
335         //=========================================================================
336     void wxTabPanelsManager::SetCbPackageName(std::string packagename)
337     {
338         _actual->SetCbPackageName( packagename );
339     }
340
341
342         //=========================================================================
343     void wxTabPanelsManager::SetAuthor(std::string author)
344     {
345         _actual->SetAuthor( author );
346     }
347
348
349         //=========================================================================
350     void wxTabPanelsManager::SetCategory(std::string category)
351     {
352         _actual->SetCategory( category );
353     }
354
355
356         //=========================================================================
357     void wxTabPanelsManager::SetDescription(std::string description)
358     {
359         _actual->SetDescription( description );
360     }
361
362
363
364
365
366
367
368
369
370
371 }  // EO namespace bbtk
372
373 // EOF
374