]> Creatis software - creaWT.git/blob - wt/bbtk_wt_PKG/src/bbwtshape3D.cxx
2498 BBTK FeatureNewNormal wt-version PackageWt
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtshape3D.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbwtshape3D.h"
5 #include "bbwtPackage.h"
6 #include "bbtkUtilities.h"
7
8 namespace bbwt
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,shape3D)
12 BBTK_BLACK_BOX_IMPLEMENTATION(shape3D,bbtk::WtBlackBox);
13 //===== 
14 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
15 //===== 
16 void shape3D::Process()
17 {
18
19 // THE MAIN PROCESSING METHOD BODY
20 //   Here we simply set the input 'In' value to the output 'Out'
21 //   And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 //    void bbSet{Input|Output}NAME(const TYPE&)
24 //    const TYPE& bbGet{Input|Output}NAME() const 
25 //    Where :
26 //    * NAME is the name of the input/output
27 //      (the one provided in the attribute 'name' of the tag 'input')
28 //    * TYPE is the C++ type of the input/output
29 //      (the one provided in the attribute 'type' of the tag 'input')
30 //   bbSetOutputOut( bbGetInputIn() );
31 //  std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
32         std::cout<<"JFGA shape3D::Process START"<<std::endl;
33         flip = flip *(-1);
34         Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetOutputWidget();
35 /**
36         
37                                                         skull.file = 'http://x.babymri.org/?skull.vtk';
38                                                 r.add(skull);
39                 
40
41         
42                 
43                                                 r.render();
44 */
45 //w->doJavaScript("alert(window.rr.container);");
46 //w->doJavaScript("skull3.file = 'http://x.babymri.org/?skull.vtk';\
47                 window.rr.add(skull3);\
48                 window.rr.render();");
49                         w->doJavaScript(w->jsRef() + ".skull.file = 'http://x.babymri.org/?skull.vtk';\
50                                         " + w->jsRef() + ".r.add("+ w->jsRef()+".skull);                        \
51                                         " + w->jsRef() + ".r.render();");
52
53         if(flip == -1)
54         {
55
56 //                      w->doJavaScript("var skull = new X.mesh(); skull.file= 'http://x.babymri.org/?skull.vtk';window.rr.add(skull);window.rr.render();");
57         }
58         else
59         {
60 //                      w->doJavaScript("var skull2 = new X.mesh();skull2.file= ''http://x.babymri.org/?lefthemisphere.smoothwm'';window.rr.add(skull2);window.rr.render();");
61         }
62 //  w->doJavaScript("r.add(skull);");
63         //w->doJavaScript(";alert('-+++>  '+x+'<>'+y);");
64 //      w->doJavaScript("r.render();");
65                 std::cout<<"JFGA shape3D::Process END"<<std::endl;
66 }
67
68 //===== 
69 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
70 //===== 
71 void shape3D::CreateWidget(Wt::WContainerWidget* parent)
72 {
73
74
75         Wt::WContainerWidget* w = new Wt::WContainerWidget(parent);
76         //Wt::WText* text = new Wt::WText("<div id=\"3d\" style=\"background-color: #000; width: 100%; height: 70%; margin-bottom: 2px;\"></div>",w);
77
78 //      std::string cadena ="var x = 100;\
79         //                              var y = 200;";
80
81
82         /*std::string cadena =   "                                      \
83                                 goog.require('X.renderer3D');           \
84                                 goog.require('X.cube');                 \
85                                 goog.require('X.mesh');                 \
86                                 var run = function() {                  \
87                                         window.r = new X.renderer3D();  \
88                                         r.container = 'r';              \
89                                         r.init();                       \
90                                         window.skull = new X.mesh();    \
91                                 };                                      \
92                                 var bot1 = function(){                  \
93                                         skull.file = 'http://x.babymri.org/?skull.vtk'; \
94                                         r.add(skull);                   \
95                                         r.render();                     \
96                                 };                                      \
97                                 var bot3 = function()                   \
98                                 {                                       \
99                                         skull.file = 'mesh1.vtk';       \
100                                         r.add(skull);                   \
101                                         r.render();                     \
102                                 };                                      \
103                                 var bot2 = function(){                  \
104                                         r.removeAll()                   \                               };"*/
105 /*      
106         std::string cadena =" \
107                         window.r = new X.renderer3D();  \
108                         r.container = '" +text->id()+ "';       \
109                         r.init();       \
110                         window.skull = new X.mesh();    \
111                         window.skull2 = new X.mesh();   \
112                                 ";
113 */
114
115
116 /*
117                 std::string cadena =" \
118                         window.r = new X.renderer3D();  \
119                         r.container = '" +text->id()+ "';       \
120                         r.init();       \
121                         window.skull     = new X.mesh();        \
122                         skull.file='http://x.babymri.org/?skull.vtk';\
123                         r.add(skull);   \
124                         r.render()      \
125                                 ";
126 */
127         std::string cadena =" \
128                         var r = new X.renderer3D();     \
129                         " + w->jsRef() + ".r = r;       \
130                         r.container = '" +w->id()+ "';  \
131                         r.init();       \
132                         var skull = new X.mesh();       \
133                         skull.file = 'http://x.babymri.org/?avf.vtk';\
134                         " + w->jsRef() + ".skull = skull;               \
135                         r.add(skull);   \
136                         r.render();     \
137                         window.rr = r; \
138                         window.skulll = skull; \
139                                 ";
140 //window.rr=r;
141         
142         std::cout<<"SHAPE 3d --- CADENA ----   "<<cadena<<std::endl;
143         std::cout<<"SHAPE 3d --- JSREF ----   "<<w->jsRef()<<std::endl;
144 //      Wt::WWebWidget::jsStringLiteral(cadena);
145         w->doJavaScript(cadena);
146         bbSetOutputWidget( w );
147         //Process();
148         //Wt::WContainerWidget* l = (Wt::WContainerWidget*)bbGetOutputWidget();
149         //w->doJavaScript("x = 13; alert('Ahasora   ' + x + '  <>  ' + y);");
150 }
151 //===== 
152 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
153 //===== 
154 void shape3D::bbUserSetDefaultValues()
155 {
156
157 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
158 //    Here we initialize the input 'In' to 0
159    bbSetInputShape("C");
160    flip = 1;
161   
162 }
163 //===== 
164 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
165 //===== 
166 void shape3D::bbUserInitializeProcessing()
167 {
168
169 //  THE INITIALIZATION METHOD BODY :
170 //    Here does nothing 
171 //    but this is where you should allocate the internal/output pointers 
172 //    if any 
173
174   
175 }
176 //===== 
177 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
178 //===== 
179 void shape3D::bbUserFinalizeProcessing()
180 {
181
182 //  THE FINALIZATION METHOD BODY :
183 //    Here does nothing 
184 //    but this is where you should desallocate the internal/output pointers 
185 //    if any
186   
187 }
188 }
189 // EO namespace bbwt
190
191