]> Creatis software - creaWT.git/blob - wt/bbtk_wt_PKG/src/bbwtAddMesh.cxx
bugs wt xtk
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtAddMesh.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 "bbwtAddMesh.h"
5 #include "bbwtPackage.h"
6
7 #include<Wt/WApplication>
8
9
10 namespace bbwt
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,AddMesh)
14 BBTK_BLACK_BOX_IMPLEMENTATION(AddMesh,bbtk::AtomicBlackBox);
15 //===== 
16 // 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)
17 //===== 
18 void AddMesh::Process()
19 {
20
21 // THE MAIN PROCESSING METHOD BODY
22 //   Here we simply set the input 'In' value to the output 'Out'
23 //   And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 //    void bbSet{Input|Output}NAME(const TYPE&)
26 //    const TYPE& bbGet{Input|Output}NAME() const 
27 //    Where :
28 //    * NAME is the name of the input/output
29 //      (the one provided in the attribute 'name' of the tag 'input')
30 //    * TYPE is the C++ type of the input/output
31 //      (the one provided in the attribute 'type' of the tag 'input')
32
33
34      printf("EED =====================================================AddMesh::Process() mesh %s\n", bbGetInputMesh().c_str() );
35
36
37
38
39      Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetInputViewerWt();
40      char strPointer[15];
41      sprintf(strPointer,"%p",this);
42      std::string mMesh = w->jsRef() + ".mMesh"+strPointer;
43      std::string mCont = w->jsRef() + ".mCont"+strPointer;
44      std::string mRenderer = w->jsRef() + ".mRenderer";
45
46      printf("EED =====================================================AddMesh::Process() mMesh %s\n", mMesh.c_str() );
47
48
49       std::string jsCom = "\
50       try\
51       {\
52                         " + mCont+" = true;\
53       "+mMesh+".file = '"+bbGetInputMesh()+"';\
54       "+mMesh+".modified(true);\
55       "+mRenderer+".render();\
56       }\
57       catch(err)\
58       {\
59         var mMesh = new X.mesh();\
60                           " + mMesh+" = mMesh;\
61                           mMesh.file = '"+bbGetInputMesh()+"';\
62                           mMesh.color = [1,0.8,0];\
63                           mMesh.opacity=1;\
64                           " + mCont+" = false;\
65                           "+mRenderer+".onShowtime = function()\
66                           {\
67                             if(!" + mCont +")\
68                             {\
69                             }\
70                           };\
71                               " + mRenderer+".add( " + mMesh+");\
72                               " + mRenderer+".render();\
73                               " + mMesh+".transform.flipX();\
74                               " + mMesh+".transform.flipY();\
75                               " + mMesh+".transform.translateY(-10);\
76                               " + mRenderer+".render();\
77         }";
78
79           std::cout<<"DEBUG ADD OBJECT ----  "<<jsCom<<std::endl;
80   // w->doJavaScript(jsCom);
81      Wt::WApplication::instance()->doJavaScript(jsCom);
82
83
84
85
86
87
88 /*
89
90       std::string jsCom = "\
91       try\
92       {\
93                         " + mCont+" = true;\
94       "+mMesh+".file = '"+bbGetInputMesh()+"';\
95       "+mMesh+".modified(true);\
96       "+w->jsRef()+".mRenderer.render();\
97       }\
98       catch(err)\
99       {\
100         var mMesh = new X.mesh();\
101                           " + mMesh+" = mMesh;\
102                           mMesh.file = '"+bbGetInputMesh()+"';\
103                           mMesh.color = [1,0.8,0];\
104                           mMesh.opacity=1;\
105                           " + mCont+" = false;\
106                           "+w->jsRef() +".mRenderer.onShowtime = function()\
107                           {\
108                             if(!" + mCont +")\
109                             {\
110                             }\
111                           };\
112                               " + mMesh+".transform.flipX();\
113                               " + mMesh+".transform.flipY();\
114                               " + mMesh+".transform.translateY(-10);\
115                           " + w->jsRef() +".mRenderer.add( " + mMesh+");\
116                               " + mMesh+".transform.flipX();\
117                               " + mMesh+".transform.flipY();\
118                               " + mMesh+".transform.translateY(-10);\
119                               " + mMesh+".visible = true;\
120       "+mMesh+".modified(true);\
121                           " + w->jsRef() + ".mRenderer.render();\
122         }";
123
124           std::cout<<"DEBUG ADD OBJECT ----  "<<jsCom<<std::endl;
125   // w->doJavaScript(jsCom);
126      Wt::WApplication::instance()->doJavaScript(jsCom);
127
128
129 */
130
131
132
133
134
135 /*
136       std::string jsCom = "\
137       try\
138       {\
139                         " + mCont+" = true;\
140       "+mMesh+".file = '"+bbGetInputMesh()+"';\
141       "+mMesh+".modified(true);\
142       "+w->jsRef()+".mRenderer.render();\
143       }\
144       catch(err)\
145       {\
146         var mMesh = new X.mesh();\
147                           mMesh.file = '"+bbGetInputMesh()+"';\
148                           mMesh.color = [1,0.8,0];\
149                           mMesh.opacity=1;\
150                           " + mMesh+" = mMesh;\
151                           " + mCont+" = false;\
152                           "+w->jsRef() +".mRenderer.onShowtime = function()\
153                           {\
154                             if(!" + mCont +")\
155                             {\
156                               " + mMesh+".transform.flipX();\
157                               " + mMesh+".transform.flipY();\
158                               " + mMesh+".transform.translateY(-10);\
159                               " + mMesh+".visible = true;\
160                             }\
161                           };\
162                           " + w->jsRef() +".mRenderer.add( " + mMesh+");\
163                           " + w->jsRef() + ".mRenderer.render();\
164         }";
165
166           std::cout<<"DEBUG ADD OBJECT ----  "<<jsCom<<std::endl;
167   // w->doJavaScript(jsCom);
168      Wt::WApplication::instance()->doJavaScript(jsCom);
169 */
170
171   
172
173 /*
174
175      Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetInputViewerWt();
176                                                 std::string jsCom = "\
177       try{\
178                         " + w->jsRef() + ".cont = true;\
179       " + w->jsRef() + ".mMesh.file = '"+bbGetInputMesh()+"';\
180       "+w->jsRef() +".mRenderer.add( " + w->jsRef() + ".mMesh);\
181       "+w->jsRef()+".mRenderer.render();\
182       }\
183       catch(err)\
184       {\
185         var mMesh = new X.mesh();\
186                           mMesh.file = '"+bbGetInputMesh()+"';\
187                           mMesh.color = [1,0.8,0];\
188                           mMesh.opacity=1;\
189                           " + w->jsRef() + ".mMesh = mMesh;\
190                           " + w->jsRef() + ".cont = false;\
191                           "+w->jsRef() +".mRenderer.onShowtime = function() {\
192                           if(!" + w->jsRef() + ".cont)\
193                           {\
194                           " + w->jsRef() + ".mMesh.transform.flipX();\
195                           " + w->jsRef() + ".mMesh.transform.flipY();\
196                           " + w->jsRef() + ".mMesh.transform.translateY(-10);\
197                           " + w->jsRef() + ".mMesh.visible = true;\
198                           }\
199                           };\
200                           " + w->jsRef() + ".mMesh.modified(true);\
201                           " + w->jsRef() + ".mRenderer.render();\
202                           }";
203
204           std::cout<<"DEBUG ADD OBJECT ----  "<<jsCom<<std::endl;
205   // w->doJavaScript(jsCom);
206      Wt::WApplication::instance()->doJavaScript(jsCom);
207
208 */
209
210
211
212
213 }
214 //===== 
215 // 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)
216 //===== 
217 void AddMesh::bbUserSetDefaultValues()
218 {
219
220 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
221 //    Here we initialize the input 'In' to 0
222    bbSetInputMesh("<void>");
223    bbSetInputViewerWt(NULL);
224   
225 }
226 //===== 
227 // 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)
228 //===== 
229 void AddMesh::bbUserInitializeProcessing()
230 {
231
232 //  THE INITIALIZATION METHOD BODY :
233 //    Here does nothing 
234 //    but this is where you should allocate the internal/output pointers 
235 //    if any 
236
237   
238 }
239 //===== 
240 // 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)
241 //===== 
242 void AddMesh::bbUserFinalizeProcessing()
243 {
244
245 //  THE FINALIZATION METHOD BODY :
246 //    Here does nothing 
247 //    but this is where you should desallocate the internal/output pointers 
248 //    if any
249   
250 }
251 }
252 // EO namespace bbwt
253
254