]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
some memory leaks
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxGEditorTabPanel.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::wxGEditorTabPanel .
34 */
35
36
37 #include "wxGEditorTabPanel.h"
38 #include "creaWx.h"
39
40 namespace bbtk
41 {
42
43         //=========================================================================
44         wxGEditorTabPanel::wxGEditorTabPanel()
45         {
46                 printf ("EED %p wxGEditorTabPanel 1 ()\n" , this );
47         }
48
49         //=========================================================================
50         wxGEditorTabPanel::wxGEditorTabPanel(wxWindow *parent,int id):wxPanel(parent),wxTextDropTarget()
51         {
52 printf("EED wxGEditorTabPanel::wxGEditorTabPanel 0\n");
53                 printf ("EED %p wxGEditorTabPanel 2 ()\n" , this );
54                 _id=id;
55                 _panelAUIMgr = new wxAuiManager(this);
56                 _sceneManager = NULL;
57                 initWxVtkCanvas();
58 printf("EED wxGEditorTabPanel::wxGEditorTabPanel 1\n");
59         }
60
61         //=========================================================================
62         wxGEditorTabPanel::~wxGEditorTabPanel()
63         {
64 printf ("EED %p ~wxGEditorTabPanel()\n" , this );
65 //ED02JUIN2010          _sceneManager->disconnectDrop();
66
67         _panelsManager->VerifyLastTabPanel();
68                 //FCY memory leaks
69                 delete _panelAUIMgr;
70                 delete _sceneManager;
71
72         }
73
74         //=========================================================================
75         void wxGEditorTabPanel::initWxVtkCanvas()
76         {
77 printf("EED wxGEditorTabPanel::initWxVtkCanvas 0\n");
78                 wxVtk3DBaseView *baseview = new wxVtk3DBaseView(this);
79                 baseview->Configure();
80                 _sceneManager=new wxVtkSceneManager(this,baseview,_id);
81
82
83 //EED02JUIN2010
84                 printf("RaC-EED 21-06-2010 wxGEditorTabPanel::initWxVtkCanvas Remove the panelAUIMgr, and change to a normal sizer inside the wxGEditorTabPanel\n");
85                 _panelAUIMgr->AddPane((wxWindow*)baseview->GetWxVTKRenderWindowInteractor(),wxAuiPaneInfo().Fixed().CenterPane());
86
87                 _panelAUIMgr->Update();
88 printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n");
89         }
90
91         //=========================================================================
92
93         bool wxGEditorTabPanel::OnDropText(wxCoord x, wxCoord y, const wxString& data)
94         {
95                 std::string packageName="";
96                 std::string boxType="";
97
98                 wxString foo( (data) );
99                 char str[150];
100                 strcpy( str, (const char*)foo.mb_str(wxConvUTF8) );
101
102                 char delims[] = ":";
103                  char *result = NULL;
104                  result = strtok( str, delims );
105                  packageName += result;
106
107                  result = strtok( NULL, delims );
108                  boxType += result;
109
110                 _sceneManager->createGBlackBox(x,y,packageName, boxType);
111
112           return true;
113         }
114
115         //=========================================================================
116
117         void wxGEditorTabPanel::setPanelsManager(wxTabPanelsManager* panelsManager)
118         {
119                 _panelsManager = panelsManager;
120         }
121
122         //=========================================================================
123
124         void wxGEditorTabPanel::displayBlackBoxInfo(std::string packageName, std::string boxName)
125         {
126                 _panelsManager->displayBlackBoxInfo(packageName,boxName);
127         }
128
129         //=========================================================================
130
131         void wxGEditorTabPanel::updateStatusBar(std::string textStatus)
132         {
133                 _panelsManager->updateStatusBar(textStatus);
134         }
135
136         //=========================================================================
137
138         std::string wxGEditorTabPanel::getDiagramBBS(bool wln)
139         {
140                 return _sceneManager->getDiagramBBS(wln);
141         }
142
143         //=========================================================================
144
145         std::string wxGEditorTabPanel::saveComplexBoxBBS()
146         {
147                 return _sceneManager->saveComplexBoxBBS();
148         }
149
150         //=========================================================================
151
152         void wxGEditorTabPanel::editBlackBox(GBlackBoxModel *bbmodel)
153         {
154                 _panelsManager->editBlackBox(bbmodel);
155         }
156
157         //=========================================================================
158
159         void wxGEditorTabPanel::deleteAllBoxes()
160         {
161                 _sceneManager->deleteAllBoxes();
162         }
163
164         //=========================================================================
165
166         void wxGEditorTabPanel::centerView()
167         {
168                 if(_sceneManager)
169                 {
170                         _sceneManager->centerView();
171                 }
172         }
173
174         //=========================================================================
175
176         void wxGEditorTabPanel::saveDiagram(std::string &content)
177         {
178                 _sceneManager->saveDiagram(content);
179         }
180
181         //=========================================================================
182
183         void wxGEditorTabPanel::loadDiagram(ifstream &inputStream)
184         {
185                 _sceneManager->loadDiagram(inputStream);
186         }
187
188         //=========================================================================
189
190         int wxGEditorTabPanel::getPanelId()
191         {
192                 return _id;
193         }
194
195         //=========================================================================
196
197         bool wxGEditorTabPanel::isComplexBox()
198         {
199                 return _sceneManager->isComplexBox();
200         }
201
202         //=========================================================================
203
204         void wxGEditorTabPanel::setComplexBox(bool val)
205         {
206                 _sceneManager->setComplexBox(val);
207         }
208
209         //=========================================================================
210
211         void wxGEditorTabPanel::addComplexInputPort(std::string portName)
212         {
213                 _sceneManager->createGComplexBoxInputPort(portName);
214         }
215
216         //=========================================================================
217
218         void wxGEditorTabPanel::addComplexOutputPort(std::string portName)
219         {
220                 _sceneManager->createGComplexBoxOutputPort(portName);
221         }
222
223         //=========================================================================
224
225         std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
226         {
227                 return _sceneManager->getSelectedObjects();
228         }
229
230         //=========================================================================
231
232         void wxGEditorTabPanel::addObjects(std::map<int,GObjectController*> objectsMap)
233         {
234                 _sceneManager->addObjects(objectsMap);
235         }
236
237         //=========================================================================
238
239         int wxGEditorTabPanel::getNumSelectedObjects()
240         {
241                 return _sceneManager->getNumSelectedObjects();
242         }
243
244         //=========================================================================
245
246
247         wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
248         {
249                 return _sceneManager;
250         }
251
252         //=========================================================================
253     std::string wxGEditorTabPanel::GetCbName()
254         {
255             return _sceneManager->GetCbName();
256         }
257
258
259         //=========================================================================
260     std::string wxGEditorTabPanel::GetCbPackageName()
261         {
262             return _sceneManager->GetCbPackageName();
263         }
264
265         //=========================================================================
266     std::string wxGEditorTabPanel::GetAuthor()
267         {
268             return _sceneManager->GetAuthor();
269         }
270
271         //=========================================================================
272     std::string wxGEditorTabPanel::GetDescription()
273         {
274             return _sceneManager->GetDescription();
275         }
276
277         //=========================================================================
278     std::string wxGEditorTabPanel::GetCategory()
279         {
280             return _sceneManager->GetCategory();
281         }
282
283         //=========================================================================
284     void wxGEditorTabPanel::SetCbName(std::string cbName)
285     {
286         _sceneManager->SetCbName( cbName );
287     }
288
289         //=========================================================================
290     void wxGEditorTabPanel::SetCbPackageName(std::string packagename)
291     {
292         _sceneManager->SetCbPackageName( packagename );
293     }
294
295
296         //=========================================================================
297     void wxGEditorTabPanel::SetAuthor(std::string author)
298     {
299         _sceneManager->SetAuthor( author );
300     }
301
302
303         //=========================================================================
304     void wxGEditorTabPanel::SetCategory(std::string category)
305     {
306         _sceneManager->SetCategory( category );
307     }
308
309
310         //=========================================================================
311     void wxGEditorTabPanel::SetDescription(std::string description)
312     {
313         _sceneManager->SetDescription( description );
314     }
315
316
317
318
319
320
321
322
323 }  // EO namespace bbtk
324
325 // EOF