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