]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
Save Mechanism working // Diego CACERES DFCH
[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         //=========================================================================
148
149         bool wxTabPanelsManager::isActualDiagramComplexBox()
150         {
151                 return _actual->isComplexBox();
152         }
153
154         //=========================================================================
155
156         void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
157         {
158                 _actual->setComplexBox(val);
159         }
160
161         //=========================================================================
162
163         void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
164         {
165                 _actual->addComplexInputPort(portName);
166         }
167
168         //=========================================================================
169
170         void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
171         {
172                 _actual->addComplexOutputPort(portName);
173         }
174
175         //=========================================================================
176
177         void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
178         {
179                 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
180                 addNewTab();
181                 setActualDiagramComplexBox(true);
182                 _actual->addObjects(mapSelected);
183                 _parent->refreshGUIControls();
184         }
185
186         //=========================================================================
187
188         int wxTabPanelsManager::getNumActualSelectedObjects()
189         {
190                 return _actual->getNumSelectedObjects();
191         }
192
193         //=========================================================================
194
195         void wxTabPanelsManager::VerifyLastTabPanel()
196         {
197 printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPageCount() );
198             if (this->_notebook->GetPageCount()==0)
199             {
200                 this->_actual=NULL;
201             }
202         }
203
204         //=========================================================================
205
206         void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
207         {
208                 int index                   = event.GetSelection();
209                 wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
210                 int id                      = tab->getPanelId();
211                 _actual                     = _panels[id];
212                 _parent->refreshGUIControls();
213         }
214
215         //=========================================================================
216     std::string wxTabPanelsManager::GetCbName()
217         {
218             return _actual->GetCbName();
219         }
220         
221         //=========================================================================
222         void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
223         {
224             int id          = _notebook->GetSelection();
225             _notebook->SetPageText( id , tabpanelname );
226         }
227
228         //=========================================================================
229         //DFCH
230         std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
231         {
232                 int id          = _notebook->GetSelection();
233                 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
234                 return( auxPanel->GetFullPath( ) );
235             //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
236         }
237
238
239         //=========================================================================
240     std::string wxTabPanelsManager::GetCbPackageName()
241         {
242             return _actual->GetCbPackageName();
243         }
244
245         //=========================================================================
246     std::string wxTabPanelsManager::GetAuthor()
247         {
248             return _actual->GetAuthor();
249         }
250
251         //=========================================================================
252     std::string wxTabPanelsManager::GetDescription()
253         {
254             return _actual->GetDescription();
255         }
256
257         //=========================================================================
258     std::string wxTabPanelsManager::GetCategory()
259         {
260             return _actual->GetCategory();
261         }
262
263         //=========================================================================
264     void wxTabPanelsManager::SetCbName(std::string cbName)
265     {
266         _actual->SetCbName( cbName );
267     }
268
269         //=========================================================================
270     void wxTabPanelsManager::SetCbPackageName(std::string packagename)
271     {
272         _actual->SetCbPackageName( packagename );
273     }
274
275
276         //=========================================================================
277     void wxTabPanelsManager::SetAuthor(std::string author)
278     {
279         _actual->SetAuthor( author );
280     }
281
282
283         //=========================================================================
284     void wxTabPanelsManager::SetCategory(std::string category)
285     {
286         _actual->SetCategory( category );
287     }
288
289
290         //=========================================================================
291     void wxTabPanelsManager::SetDescription(std::string description)
292     {
293         _actual->SetDescription( description );
294     }
295
296
297
298
299
300
301
302
303
304
305 }  // EO namespace bbtk
306
307 // EOF
308