]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
cd591b16d36a18a543dc1a82928c583aa0ebd911
[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, const std::string &path) //DFCH
177         {
178                 this->SetFullPath(path);
179                 _sceneManager->saveDiagram(content);
180         }
181
182         //=========================================================================
183
184         void wxGEditorTabPanel::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
185         {
186                 this->SetFullPath(path);
187                 _sceneManager->loadDiagram(inputStream);
188         }
189
190         //=========================================================================
191
192         int wxGEditorTabPanel::getPanelId()
193         {
194                 return _id;
195         }
196
197         //=========================================================================
198
199         bool wxGEditorTabPanel::isComplexBox()
200         {
201                 return _sceneManager->isComplexBox();
202         }
203
204         //=========================================================================
205
206         void wxGEditorTabPanel::setComplexBox(bool val)
207         {
208                 _sceneManager->setComplexBox(val);
209         }
210
211         //=========================================================================
212
213         void wxGEditorTabPanel::addComplexInputPort(std::string portName)
214         {
215                 _sceneManager->createGComplexBoxInputPort(portName);
216         }
217
218         //=========================================================================
219
220         void wxGEditorTabPanel::addComplexOutputPort(std::string portName)
221         {
222                 _sceneManager->createGComplexBoxOutputPort(portName);
223         }
224
225         //=========================================================================
226
227         std::map<int,GObjectController*> wxGEditorTabPanel::getSelectedObjects()
228         {
229                 return _sceneManager->getSelectedObjects();
230         }
231
232         //=========================================================================
233
234         void wxGEditorTabPanel::addObjects(std::map<int,GObjectController*> objectsMap)
235         {
236                 _sceneManager->addObjects(objectsMap);
237         }
238
239         //=========================================================================
240
241         int wxGEditorTabPanel::getNumSelectedObjects()
242         {
243                 return _sceneManager->getNumSelectedObjects();
244         }
245
246         //=========================================================================
247
248
249         wxVtkSceneManager* wxGEditorTabPanel::getSceneManager()
250         {
251                 return _sceneManager;
252         }
253
254         //=========================================================================
255     std::string wxGEditorTabPanel::GetCbName()
256         {
257             return _sceneManager->GetCbName();
258         }
259
260
261         //=========================================================================
262     std::string wxGEditorTabPanel::GetCbPackageName()
263         {
264             return _sceneManager->GetCbPackageName();
265         }
266
267         //=========================================================================
268     std::string wxGEditorTabPanel::GetAuthor()
269         {
270             return _sceneManager->GetAuthor();
271         }
272
273         //=========================================================================
274     std::string wxGEditorTabPanel::GetDescription()
275         {
276             return _sceneManager->GetDescription();
277         }
278
279         //=========================================================================
280     std::string wxGEditorTabPanel::GetCategory()
281         {
282             return _sceneManager->GetCategory();
283         }
284
285         //=========================================================================
286     void wxGEditorTabPanel::SetCbName(std::string cbName)
287     {
288         _sceneManager->SetCbName( cbName );
289     }
290
291         //=========================================================================
292     void wxGEditorTabPanel::SetCbPackageName(std::string packagename)
293     {
294         _sceneManager->SetCbPackageName( packagename );
295     }
296
297
298         //=========================================================================
299     void wxGEditorTabPanel::SetAuthor(std::string author)
300     {
301         _sceneManager->SetAuthor( author );
302     }
303
304
305         //=========================================================================
306     void wxGEditorTabPanel::SetCategory(std::string category)
307     {
308         _sceneManager->SetCategory( category );
309     }
310
311
312         //=========================================================================
313     void wxGEditorTabPanel::SetDescription(std::string description)
314     {
315         _sceneManager->SetDescription( description );
316     }
317     //=========================================================================
318         //DFCH
319         void wxGEditorTabPanel::SetFullPath( const std::string& fullpath )
320         {
321                 this->_fullPath = fullpath;
322         }
323         //=========================================================================
324         //DFCH
325         void wxGEditorTabPanel::SetFileName( const std::string& filename )
326         {
327                 this->_fileName = filename;
328         }
329         //=========================================================================
330         //DFCH
331         std::string wxGEditorTabPanel::GetFullPath( )
332         {
333                 return( this->_fullPath );
334         }
335         //=========================================================================
336         //DFCH
337     std::string wxGEditorTabPanel::GetFileName( )
338     {
339                 return( this->_fileName );
340         }
341
342
343
344
345 }  // EO namespace bbtk
346
347 // EOF