]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
Bug #1365,
[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         }
52
53         //=========================================================================
54         wxTabPanelsManager::~wxTabPanelsManager()
55         {
56         }
57
58         //=========================================================================
59         void wxTabPanelsManager::addNewTab(wxString tabName)
60         {
61 printf("EED wxTabPanelsManager::addNewTab 0\n");
62
63                 _lastId++;
64                 wxGEditorTabPanel *newPanel         = new wxGEditorTabPanel(_notebook,_lastId);
65                 newPanel->setPanelsManager(this);
66                 _panels[_lastId]                    = newPanel;
67                 _actual                             = newPanel;
68                 _notebook->AddPage(newPanel, tabName  ,true);
69 printf("EED wxTabPanelsManager::addNewTab 1\n");
70         }
71
72         //=========================================================================
73         wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
74         {
75                 return _notebook;
76         }
77
78         //=========================================================================
79         wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
80         {
81                 return _actual;
82         }
83
84         //=========================================================================
85
86         void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
87         {
88                 _parent->displayBlackBoxInfo(packageName,boxName);
89         }
90
91         //=========================================================================
92
93         void wxTabPanelsManager::updateStatusBar(std::string textStatus)
94         {
95                 _parent->updateStatusBar(textStatus);
96         }
97
98         //=========================================================================
99
100         std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
101         {
102                 return _actual->getDiagramBBS(wln);
103         }
104
105         //=========================================================================
106
107         std::string wxTabPanelsManager::getActualComplexBoxBBS()
108         {
109                 return _actual->saveComplexBoxBBS();
110         }
111
112         //=========================================================================
113
114         void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
115         {
116                 _parent->editBlackBox(bbmodel);
117         }
118
119         //=========================================================================
120
121         void wxTabPanelsManager::deleteAllBoxesActualDiagram()
122         {
123                 _actual->deleteAllBoxes();
124         }
125
126         //=========================================================================
127
128         void wxTabPanelsManager::centerViewActualDiagram()
129         {
130                 _actual->centerView();
131         }
132
133         //=========================================================================
134
135         void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
136         {
137                 _actual->saveDiagram(content, path);
138         }
139
140         //=========================================================================
141
142         void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
143         {
144                 _actual->loadDiagram(inputStream, path);
145         }
146         //=========================================================================
147         void wxTabPanelsManager::saveTempActualDiagram() //FCY
148         {
149                 _actual->saveTempDiagram();
150         }
151         //=========================================================================
152         void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
153         {
154                  _actual->loadTempDiagram(un);
155         }
156
157         //=========================================================================
158         unsigned short wxTabPanelsManager::getUndoState() //FCY
159         {
160                  return _actual->getUndoState();
161         }
162                 //=========================================================================
163         unsigned short wxTabPanelsManager::getRedoState() //FCY
164         {
165                  return _actual->getRedoState();
166         }
167         //=========================================================================
168
169         bool wxTabPanelsManager::isActualDiagramComplexBox()
170         {
171                 return _actual->isComplexBox();
172         }
173
174         //=========================================================================
175
176         void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
177         {
178                 _actual->setComplexBox(val);
179         }
180
181         //=========================================================================
182
183         void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
184         {
185                 _actual->addComplexInputPort(portName);
186         }
187
188         //=========================================================================
189
190         void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
191         {
192                 _actual->addComplexOutputPort(portName);
193         }
194
195         //=========================================================================
196
197         void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
198         {
199                 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
200                 addNewTab();
201                 setActualDiagramComplexBox(true);
202                 _actual->addObjects(mapSelected);
203                 _parent->refreshGUIControls();
204         }
205
206         //=========================================================================
207
208         int wxTabPanelsManager::getNumActualSelectedObjects()
209         {
210                 return _actual->getNumSelectedObjects();
211         }
212
213         //=========================================================================
214
215         void wxTabPanelsManager::VerifyLastTabPanel()
216         {
217 printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPageCount() );
218             if (this->_notebook->GetPageCount()==0)
219             {
220                 this->_actual=NULL;
221             }
222         }
223
224         //=========================================================================
225
226         void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
227         {
228                 int index                   = event.GetSelection();
229                 wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
230                 int id                      = tab->getPanelId();
231                 _actual                     = _panels[id];
232                 _parent->refreshGUIControls();
233
234         }
235
236         //=========================================================================
237     std::string wxTabPanelsManager::GetCbName()
238         {
239             return _actual->GetCbName();
240         }
241         
242         //=========================================================================
243         void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
244         {
245             int id          = _notebook->GetSelection();
246             _notebook->SetPageText( id , tabpanelname );
247         }
248
249         std::string wxTabPanelsManager::GetNameTabPanel() 
250         {
251                  int id = _notebook->GetSelection();
252                 return crea::wx2std(_notebook->GetPageText(id));
253         }
254
255         //=========================================================================
256         //DFCH
257         std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
258         {
259                 int id          = _notebook->GetSelection();
260                 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
261                 return( auxPanel->GetFullPath( ) );
262             //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
263         }
264
265
266         //=========================================================================
267     std::string wxTabPanelsManager::GetCbPackageName()
268         {
269             return _actual->GetCbPackageName();
270         }
271
272         //=========================================================================
273     std::string wxTabPanelsManager::GetAuthor()
274         {
275             return _actual->GetAuthor();
276         }
277
278         //=========================================================================
279     std::string wxTabPanelsManager::GetDescription()
280         {
281             return _actual->GetDescription();
282         }
283
284         //=========================================================================
285     std::string wxTabPanelsManager::GetCategory()
286         {
287             return _actual->GetCategory();
288         }
289
290         //=========================================================================
291     void wxTabPanelsManager::SetCbName(std::string cbName)
292     {
293         _actual->SetCbName( cbName );
294     }
295
296         //=========================================================================
297     void wxTabPanelsManager::SetCbPackageName(std::string packagename)
298     {
299         _actual->SetCbPackageName( packagename );
300     }
301
302
303         //=========================================================================
304     void wxTabPanelsManager::SetAuthor(std::string author)
305     {
306         _actual->SetAuthor( author );
307     }
308
309
310         //=========================================================================
311     void wxTabPanelsManager::SetCategory(std::string category)
312     {
313         _actual->SetCategory( category );
314     }
315
316
317         //=========================================================================
318     void wxTabPanelsManager::SetDescription(std::string description)
319     {
320         _actual->SetDescription( description );
321     }
322
323
324
325
326
327
328
329
330
331
332 }  // EO namespace bbtk
333
334 // EOF
335