2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxBlackBox.cxx,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.45 $
34 =========================================================================*/
45 #include "bbtkWtBlackBox.h"
46 #include "bbtkBlackBoxOutputConnector.h"
49 //#include "bbtkWxContainerBlackBox.h"
50 //#include <wx/dialog.h>
52 //#include "bbtkData.h"
53 //#include "bbtkFactory.h"
55 static std::string jScriptLine;
59 //=========================================================================
61 //=========================================================================
63 // For the very first contruction of the application
66 Wt::WContainerWidget *parent;
67 WtBlackBox::Pointer b;
71 static wtData myWtData;
73 //=========================================================================
75 //=========================================================================
76 //Contains all the JS statements needed for the bbwt.
78 //=========================================================================
80 //=========================================================================
81 // Application WT deployed
82 //==================================================================
86 class WtWFrame : public Wt::WApplication
90 const Wt::WEnvironment& env
96 WtBlackBox::WeakPointer mBox;
103 const Wt::WEnvironment& env
106 Wt::WApplication(env)
108 //std::cout<<"Adding JavaScript -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
109 this->require("js/xtk.js");
110 //this->require("js/demo/demo2.js");
111 //this->useStyleSheet("css/demo.css");
116 std::cout<<" SIN PADRE "<<std::endl;
117 if(myWtData.parent == 0){std::cout<<" PARENT 0 "<<std::endl;}
118 if(myWtData.parent == NULL){std::cout<<" PARENT NULL "<<std::endl;}
119 myWtData.parent = new Wt::WContainerWidget();
120 std::cout<<"Parent created -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
123 Wt::WContainerWidget *myCont = new Wt::WContainerWidget(myWtData.parent);
124 myCont->setMinimumSize(800,500);
125 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................50%"<<std::endl;
126 myWtData.b->bbUserCreateWidget(myCont);
127 root()->addWidget(myWtData.parent);
128 //bbmWindow = myCont;
129 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................80%"<<std::endl;
130 this->doJavaScript(jScriptLine);
134 //==================================================================
135 //==================================================================
136 WtWFrame::~WtWFrame()
139 bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
140 <<"] $$$$$$$$$$$$$$$$$$$ ~W()"
143 bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
144 bbtkDebugMessage("widget",9,"WtWFrame::~WtWFrame()"<<std::endl);
145 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
146 WWt::DecNbWindowsAlive();
152 Wt::WApplication *createApplication(const Wt::WEnvironment& env)
154 return new WtWFrame(env);
158 //=========================================================================
159 // WxDialogWxBlackBox::Pointer box
160 //=========================================================================
162 //==================================================================
163 // Dialog window which is modal
164 /* class BBTK_EXPORT WxDialog : public wxDialog
167 WxDialog(WxBlackBox::Pointer box,
171 ~WxDialog();Wt::GetTopWindow()
172 void OnCloseWindow(wxCloseEvent& event);
175 WxBlackBox::WeakPointer mBox;
176 DECLARE_EVENT_TABLE();
180 BEGIN_EVENT_TABLE(WxDialog, wxDialog)
181 EVT_CLOSE(WxDialog::OnCloseWindow)
183 //=========================================================================
185 //=========================================================================
186 WxDialog::WxDialog(WxBlackBox::Pointer b,
205 bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
206 <<std::endl);WxBlackBox::Pointer box
207 Wx::IncNbWindowsAlive();
208 b->bbSetWindow(this);
209 // Insert the widget into the window
210 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
211 b->bbUserCreateWidget(this);
212 wxWindow* widget = b->bbGetOutputWidget();
213 sizer->Add( widget, 1, wxALL|wxGROW, 2);
217 //==================================================================
218 //==================================================================
219 WxDialog::~WxDialog()
221 bbtkDebugMessage("widget",9,"WxDialog::~WxDialog()"<<std::endl);
222 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
223 // if (mBox.lock()) mBox.lock()->bbSetWindow(0);
224 // Wx::DecNbWindowsAlive();
226 //==================================================================
227 //==================================================================
228 void WxDialog::OnCloseWindow(wxCloseEvent& event)
230 bbtkDebugMessage("widget",9,"WxDialog::OnCloseWindow()"<<wxGUIEditorGraphicBBS:std::endl);
231 if (mBox.lock()) mBox.lock()->bbSetWindow(0); http://doodle.com/qx65tfxismf7d6ku5vxykghs/admin#table
232 Wx::DecNbWindowsAlive();
235 //==================================================================
238 //=========================================================================
240 //=========================================================================
242 //=========================================================================
243 //=========================================================================
244 //=========================================================================
245 //=========================================================================
246 BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
248 //=========================================================================
249 //=========================================================================
250 void WtBlackBox::bbUserSetDefaultValues()
252 bbtkBlackBoxDebugMessage("widget",5,"WtBlackBox::bbUserSetDefaultValues()"<<std::endl);
255 //=========================================================================
257 //=========================================================================
258 void WtBlackBox::bbUserInitializeProcessing()
262 //================================================================http://intranet-if.insa-lyon.fr/temps/5IF39.html==
264 //=========================================================================
265 void WtBlackBox::bbUserFinalizeProcessing()
267 bbtkBlackBoxDebugMessage("widget",5,"==> WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
269 bbtkBlackBoxDebugMessage("widget",5,"<== WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
271 //==================================================================
273 //==================================================================
274 /// Callback for creating a Dialog window (modal)
275 void WtBlackBox::bbCreateDialogWindow()
277 bbtkBlackBoxDebugMessage("widget",3,
278 "==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
282 //=========================================================================
284 //==================================================================
286 //==================================================================
287 /// Callback for creating a Frame window
288 void WtBlackBox::bbCreateFrameWindow()
291 bbtkBlackBoxDebugMessage("widget",3,
292 "==> WtBlackBox::bbCreateFrameWindow() - parent = "
293 <<WWt::GetTopWindow()
296 //Setting necessary data for Wt server deployment
297 myWtData.parent = WWt::GetTopWindow();
298 myWtData.b = GetThisPointer<WtBlackBox>();
299 myWtData.title = std2wt( bbGetInputWinTitle()
300 + " - bbtk (c) CREATIS");
302 std::cout<<"Creating Container WT -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
303 char *argv[7] = {"./WtTest","--docroot","/home/gonzalez/Documents/pruebaResources","--http-address","0.0.0.0","--http-port","8080"};
305 /* if(Wt::WServer::instance()->isRunning())
307 std::cout<<"Checking the existence of a Server deployed -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
308 Wt::WServer::instance()->stop();
311 std::cout<<"Deploying Server -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
312 Wt::WRun(argc,argv,&createApplication);
315 //==================================================================
317 //==================================================================
318 void WtBlackBox::bbSetWindow(Wt::WContainerWidget* w)
320 bbtkBlackBoxDebugMessage("widget",9,"==> WtBlackBox::bbSetWindow("<<w<<")"<<std::endl);
321 if ((bbmWindow != 0)&&(w!=0))
323 std::cout << "ERRRRRRRROOOOR"<<std::endl;
330 //==================================================================
332 //==================================================================
333 void WtBlackBox::bbShowWindow()
335 if ((bbmWindow) && (!bbIsShown()))
337 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
339 if (bbGetInputWinDialog())
341 // ((WxDialog*)bbmWindow)->ShowModal();
345 // There is not such a thing like show becouse it is a webapp
346 // bbGetWindow()->Show();
347 // WWt::CreateWtAppIfNeeded();
352 //==================================================================
354 //==================================================================
355 void WtBlackBox::bbDestroyWindow()
357 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
358 if (bbGetWindow()!=NULL)
360 // wxWindow* w = bbGetWindow();
362 // WE SHOULD DESTROY THE WINDOW WITH THE Close METHOD
366 delete bbGetWindow();
369 bbtkBlackBoxDebugMessage("widget",3,"<== WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
372 //==================================================================