3 # ---------------------------------------------------------------------
5 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
7 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
9 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
11 # This software is governed by the CeCILL-B license under French law and
12 # abiding by the rules of distribution of free software. You can use,
13 # modify and/ or redistribute the software under the terms of the CeCILL-B
14 # license as circulated by CEA, CNRS and INRIA at the following URL
15 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
16 # or in the file LICENSE.txt.
18 # As a counterpart to the access to the source code and rights to copy,
19 # modify and redistribute granted by the license, users are provided only
20 # with a limited warranty and the software's author, the holder of the
21 # economic rights, and the successive licensors have only limited
24 # The fact that you are presently reading this means that you have had
25 # knowledge of the CeCILL-B license and that you accept its terms.
26 # ------------------------------------------------------------------------ */
29 /*=========================================================================
31 Module: $RCSfile: bbtkWxBlackBox.cxx,v $
33 Date: $Date: 2012/11/16 08:49:01 $
34 Version: $Revision: 1.45 $
35 =========================================================================*/
46 #include "bbtkWtBlackBox.h"
47 #include "bbtkBlackBoxOutputConnector.h"
50 //#include "bbtkWxContainerBlackBox.h"
51 //#include <wx/dialog.h>
53 //#include "bbtkData.h"
54 //#include "bbtkFactory.h"
68 std::string jScriptLine;
71 //=========================================================================
73 //=========================================================================
75 // For the very first contruction of the application
76 /* struct wtServerData
86 Wt::WContainerWidget *parent;
87 WtBlackBox::Pointer b;
97 // static bbtk::jScript* js = new bbtk::jScript();
98 static wtData myWtData;
99 // static wtServerData loadedJS;
100 //static std::string* jss;
104 //=========================================================================
106 //=========================================================================
107 //Contains all the JS statements needed for the bbwt.
109 //=========================================================================
111 //=========================================================================
112 // Application WT deployed
113 //==================================================================
115 class WtWFrame : public Wt::WApplication
118 WtWFrame( const Wt::WEnvironment& env );
120 WtBlackBox::WeakPointer mBox;
124 WtWFrame::WtWFrame( const Wt::WEnvironment& env ):Wt::WApplication(env)
126 //std::cout<<"Adding JavaScript -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
127 //this->require("/home/gonzalez/Documents/CREATOOLS/wt_library/wt/bbtk_wt_PKG/src/js/xtk.js");
129 //this->require("http://get.goXTK.com/xtk.js");
130 //this->useStyleSheet("css/demo.css");
132 //this->require("http://get.goXTK.com/xtk.js");
133 this->require( "resourcesXTK/xtk.js" );
135 // this->require("http://get.goXTK.com/xtk_edge.js");
136 // this->require("http://get.goXTK.com/xtk_xdat.gui.js");
137 this->require( "resourcesXTK/xtk_xdat.gui.js" );
139 this->useStyleSheet("resourcesXTK/styleWT.css");
140 // std::cout<<"Cargado------------ "<<loadedJS<<std::endl;
146 std::cout<<" SIN PADRE "<<std::endl;
147 if(myWtData.parent == 0){std::cout<<" PARENT 0 "<<std::endl;}
148 if(myWtData.parent == NULL){std::cout<<" PARENT NULL "<<std::endl;}
149 myWtData.parent = new Wt::WContainerWidget();
150 std::cout<<"Parent created -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
154 //Wt::WContainerWidget *myContainer = new Wt::WContainerWidget( myWtData.parent );
155 Wt::WContainerWidget *myContainer = new Wt::WContainerWidget( );
156 printf("EED (WT) WtWFrame warnning 2019 A parent ?? \n");
158 myContainer->setMinimumSize(800,500);
159 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.......50%"<<std::endl;
160 myWtData.b->bbUserCreateWidget(myContainer);
163 // root()->addWidget(myWtData.parent);
164 printf("EED (WT) WtWFrame warnning 2019 B parent ?? \n");
166 //bbmWindow = myCont;
168 //jss = WtBlackBox::jScript;
169 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx........80%"<<std::endl;
170 std::cout<<"Creando WebWIDGET DELETE ME SCRIPT : ---"<<bbtk::jScript<<"......80%"<<std::endl;
171 //this->doJavaScript(bbtk::jScript);
174 myWtData.pbox->bbwtUpdateInputs();
175 // myWtData.pbox->bbwtProcess();
179 //==================================================================
180 //==================================================================
181 WtWFrame::~WtWFrame()
184 bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
185 <<"] $$$$$$$$$$$$$$$$$$$ ~W()"
188 bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
189 bbtkDebugMessage("widget",9,"WtWFrame::~WtWFrame()"<<std::endl);
190 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
191 WWt::DecNbWindowsAlive();
196 // Wt::WApplication *createApplication(const Wt::WEnvironment& env)
197 std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment& env)
200 printf("EED (WT) createApplication warnning 2019 \n");
202 // return new WtWFrame(env);
203 std::make_unique<WtWFrame>(env);
208 //=========================================================================
209 // WxDialogWxBlackBox::Pointer box
210 //=========================================================================
212 //==================================================================
213 // Dialog window which is modal
214 /* class BBTK_EXPORT WxDialog : public wxDialog
217 WxDialog(WxBlackBox::Pointer box,
221 ~WxDialog();Wt::GetTopWindow()
222 void OnCloseWindow(wxCloseEvent& event);
225 WxBlackBox::WeakPointer mBox;
226 DECLARE_EVENT_TABLE();
230 BEGIN_EVENT_TABLE(WxDialog, wxDialog)
231 EVT_CLOSE(WxDialog::OnCloseWindow)
233 //=========================================================================
235 //=========================================================================
236 WxDialog::WxDialog(WxBlackBox::Pointer b,
255 bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
256 <<std::endl);WxBlackBox::Pointer box
257 Wx::IncNbWindowsAlive();
258 b->bbSetWindow(this);
259 // Insert the widget into the window
260 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
261 b->bbUserCreateWidget(this);
262 wxWindow* widget = b->bbGetOutputWidget();
263 sizer->Add( widget, 1, wxALL|wxGROW, 2);
267 //==================================================================
268 //===========================organise=======================================
269 WxDialog::~WxDialog()
271 bbtkDebugMessage("widget",9,"WxDialog::~WxDialog()"<<std::endl);
272 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
273 // if (mBox.lock()) mBox.lock()->bbSetWindow(0);
274 // Wx::DecNbWindowsAlive();
276 //==================================================================
277 //==================================================================
278 void WxDialog::OnCloseWindow(wxCloseEvent& event)
280 bbtkDebugMessage("widget",9,"WxDialog::OnCloseWindow()"<<wxGUIEditorGraphicBBS:std::endl);
281 if (mBox.lock()) mBox.lock()->bbSetWindow(0); http://doodle.com/qx65tfxismf7d6ku5vxykghs/admin#table
282 Wx::DecNbWindowsAlive();
285 //==================================================================
288 //=========================================================================
290 //=========================================================================
292 //=========================================================================
293 //=========================================================================
294 //=========================================================================
295 //=========================================================================
296 BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
298 //std::string WtBlackBox::wtServerData::docRoot = "/home/gonzalez/Documents/pruebaResources";
299 //std::string WtBlackBox::wtServerData::docRoot = "/usr/local/share/wtResources";
300 //std::string WtBlackBox::wtServerData::port = "8081";
302 std::string WtBlackBox::wtServerData::docRoot = "<void>";
303 std::string WtBlackBox::wtServerData::port = "<void>";
304 std::string WtBlackBox::wtServerData::address = "0.0.0.0";
305 int WtBlackBox::wtServerData::argc = 0;
306 char **WtBlackBox::wtServerData::argv = NULL;
308 //=========================================================================
309 //=========================================================================
310 void WtBlackBox::bbUserSetDefaultValues()
312 bbtkBlackBoxDebugMessage("widget",5,"WtBlackBox::bbUserSetDefaultValues()"<<std::endl);
315 //=========================================================================
317 //=========================================================================
318 void WtBlackBox::bbUserInitializeProcessing()
322 //================================================================http://intranet-if.insa-lyon.fr/temps/5IF39.html==
324 //=========================================================================
325 void WtBlackBox::bbUserFinalizeProcessing()
327 bbtkBlackBoxDebugMessage("widget",5,"==> WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
329 bbtkBlackBoxDebugMessage("widget",5,"<== WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
331 //==================================================================
333 //==================================================================
334 /// Callback for creating a Dialog window (modal)
335 void WtBlackBox::bbCreateDialogWindow()
337 bbtkBlackBoxDebugMessage("widget",3,
338 "==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
342 //=========================================================================
344 //==================================================================
346 //==================================================================
347 /// Callback for creating a Frame window
348 void WtBlackBox::bbCreateFrameWindow()
351 bbtkBlackBoxDebugMessage("widget",3,
352 "==> WtBlackBox::bbCreateFrameWindow() - parent = "
353 <<WWt::GetTopWindow()
356 //Setting necessary data for Wt server deployment
357 myWtData.parent = WWt::GetTopWindow();
358 myWtData.b = GetThisPointer<WtBlackBox>();
359 myWtData.title = std2wt( bbGetInputWinTitle() + " - bbtk (c) CREATIS");
360 myWtData.pbox = this;
362 //char *argv[7] = {"./WtTest","--docroot","/home/gonzalez/Documents/pruebaResources","--http-address","0.0.0.0","--http-port","8080"};
366 char *argv[7] = {"./WtTest"
367 ,"--docroot",(char*)WtBlackBox::wtServerData::docRoot.c_str()
368 ,"--http-address",(char*)WtBlackBox::wtServerData::address.c_str()
369 ,"--http-port",(char*)WtBlackBox::wtServerData::port.c_str()
372 std::cout<<" --- PUERTO :"<<WtBlackBox::wtServerData::port<<std::endl;
376 char *argv[2] = {"./bbiWeb.wt","client"};
381 /* if(Wt::WServer::instance()->isRunning())
383 std::cout<<"Checking the existence of a Server deployed -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
384 Wt::WServer::instance()->stop();
389 std::cout<<"EED WtBlackBox::bbCreateFrameWindow Deploying Server -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
392 // Wt::WRun(argc,argv,&createApplication);
394 Wt::WRun(WtBlackBox::wtServerData::argc,
395 WtBlackBox::wtServerData::argv,
401 //==================================================================
403 //==================================================================
404 void WtBlackBox::bbSetWindow(Wt::WContainerWidget* w)
406 bbtkBlackBoxDebugMessage("widget",9,"==> WtBlackBox::bbSetWindow("<<w<<")"<<std::endl);
407 if ((bbmWindow != 0)&&(w!=0))
409 std::cout << "ERRRRRRRROOOOR"<<std::endl;
416 //==================================================================
418 //==================================================================
419 void WtBlackBox::bbShowWindow()
421 if ((bbmWindow) && (!bbIsShown()))
423 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
425 if (bbGetInputWinDialog())
427 // ((WxDialog*)bbmWindow)->ShowModal();
431 // There is not such a thing like show becouse it is a webapp
432 // bbGetWindow()->Show();
433 // WWt::CreateWtAppIfNeeded();
436 Wt::WRun(WtBlackBox::wtServerData::argc,
437 WtBlackBox::wtServerData::argv,
445 //==================================================================
447 //==================================================================
448 void WtBlackBox::bbDestroyWindow()
450 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
451 if (bbGetWindow()!=NULL)
453 // wxWindow* w = bbGetWindow();
455 // WE SHOULD DESTROY THE WINDOW WITH THE Close METHOD
459 delete bbGetWindow();
462 bbtkBlackBoxDebugMessage("widget",3,"<== WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
467 //==================================================================
468 void WtBlackBox::bbwtUpdateInputs()
470 BlackBox::bbUpdateInputs();
473 //==================================================================
474 void WtBlackBox::bbwtProcess()
476 BlackBox::bbProcess();