libeblearngui
|
00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Pierre Sermanet * 00003 * pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef ELB_ARCH_GUI_HPP_ 00034 #define ELB_ARCH_GUI_HPP_ 00035 00036 #include <ostream> 00037 #include <typeinfo> 00038 00039 #include "ebl_layers_gui.h" 00040 #include "ebl_basic_gui.h" 00041 00042 using namespace std; 00043 00044 namespace ebl { 00045 00047 // module_1_1_gui 00048 00049 #define DISPLAY_1_1(name1, name2, Tin, Tout) \ 00050 template<typename T, class Tstate> \ 00051 void module_1_1_gui::name1(module_1_1<T,Tstate> &m, Tin &in, Tout &out, \ 00052 uint h0, uint w0, double zoom, T vmin, T vmax, \ 00053 bool show_out, int wid, const char *wname) { \ 00054 name2(m, in, out, h0, w0, zoom, vmin, vmax, show_out, wid, wname); \ 00055 } 00056 00057 #define DISPLAY2_1_1(name1, name2, op, T, Tin, Tout) \ 00058 template<typename T, class Tstate> \ 00059 void module_1_1_gui::name2 \ 00060 (module_1_1<T,Tstate> &m, Tin &in_, Tout &out_, uint &h0, uint &w0, \ 00061 double zoom, T vmin, T vmax, bool show_out, int wid, const char *wname) { \ 00062 display_wid_fprop = (wid >= 0) ? wid : \ 00063 new_window((wname ? wname : "module_1_1 display")); \ 00064 select_window(display_wid_fprop); \ 00065 gui << white_on_transparent() << gui_only(); \ 00066 set_font_size(8); \ 00067 mstate<Tstate> in, out; \ 00068 in.push_back_new(in_); \ 00069 out.push_back_new(out_); \ 00070 \ 00071 if (dynamic_cast< layers<T,Tstate>* >(&m)) { \ 00072 /* layers */ \ 00073 layers_gui::name1(*this, dynamic_cast< layers<T,Tstate>& >(m), \ 00074 in, out, h0, w0, zoom, vmin, vmax, show_out); \ 00075 } else if (dynamic_cast< ms_module<T,Tstate>* >(&m)) { \ 00076 /* ms_module */ \ 00077 ms_module_gui::name1(*this, dynamic_cast< ms_module<T,Tstate>& >(m), \ 00078 in, out, h0, w0, zoom, vmin, vmax, show_out); \ 00079 } else { \ 00080 if (cnt >= 0) { \ 00081 unsigned int h = h0, w = w0; \ 00082 for (uint i = 0; i < in.size(); ++i) { \ 00083 w = w0; \ 00084 Tstate &ini = in[i]; \ 00085 /* display text */ \ 00086 gui << gui_only() << at(h, w) << m.name() << " in[" <<i<<"]:" << ini.T \ 00087 << at(h + 10, w) << "min:" << idx_min(ini.T) \ 00088 << at(h + 20, w) << "max:" << idx_max(ini.T); \ 00089 w += 150; \ 00090 /* display inputs */ \ 00091 idx_bloop1(inp, ini.T, T) { \ 00092 if (w - w0 < MAXWIDTH) { \ 00093 draw_matrix(inp, h, w, zoom, zoom, vmin, vmax); \ 00094 w += (uint) (inp.dim(1) * zoom + 1); \ 00095 } \ 00096 } \ 00097 h += std::max((uint) 30, (uint) (ini.T.dim(1) * zoom + 1)); \ 00098 } \ 00099 h += 2; \ 00100 /* display internal buffers */ \ 00101 if (dynamic_cast< convolution_module<T,Tstate>* >(&m)) { \ 00102 /* convolution_module */ \ 00103 convolution_module_gui:: \ 00104 name1(dynamic_cast< convolution_module<T,Tstate>& >(m), \ 00105 h, w0, zoom, vmin, vmax, show_out); \ 00106 } \ 00107 /* run it */ \ 00108 ((module_1_1<T,Tstate>&)m).op(in_, out_); \ 00109 for (uint i = 0; i < out.size(); ++i) { \ 00110 w = w0; \ 00111 Tstate &outi = out[i]; \ 00112 /* display text */ \ 00113 gui << gui_only() <<at(h, w)<<m.name()<<" out["<<i<<"]:" << outi.T \ 00114 << at(h + 10, w) << "min:" << idx_min(outi.T) \ 00115 << at(h + 20, w) << "max:" << idx_max(outi.T); \ 00116 w += 150; \ 00117 /* display outputs */ \ 00118 idx_bloop1(outp, outi.T, T) { \ 00119 if (w - w0 < MAXWIDTH) { \ 00120 draw_matrix(outp, h, w, zoom, zoom, vmin, vmax); \ 00121 w += (uint) (outp.dim(1) * zoom + 1); \ 00122 } \ 00123 } \ 00124 h += std::max((uint) 30, (uint) (outi.T.dim(1) * zoom + 1)); \ 00125 } \ 00126 h0 = h + 5; \ 00127 } else ((module_1_1<T,Tstate>&)m).op(in_, out_); \ 00128 cnt++; \ 00129 }} 00130 /* else { \ 00131 cerr << "Warning: unknown display function for module_1_1 object"; \ 00132 cerr << " (" << typeid(m).name() << ")." << endl; \ 00133 } \ 00134 }*/ 00135 00136 // } else if (dynamic_cast< full_layer<T,Tstate>* >(&m)) { 00137 // /* full_layer */ 00138 // full_layer_gui::name1(dynamic_cast< full_layer<T,Tstate>& >(m), in, 00139 // out, h0, w0, zoom, vmin, vmax,show_out); 00140 // } else if (dynamic_cast< convolution_layer<T,Tstate>* >(&m)) { 00141 // /* convolution_layer */ 00142 // convolution_layer_gui:: 00143 // name1(dynamic_cast< convolution_layer<T,Tstate>& >(m), 00144 // in, out, h0, w0, zoom, vmin, vmax, show_out); 00145 // } else if (dynamic_cast< convabsnorm_layer<T,Tstate>* >(&m)) { 00146 // /* convabsnorm_layer */ 00147 // convabsnorm_layer_gui:: 00148 // name1(dynamic_cast< convabsnorm_layer<T,Tstate>& >(m), 00149 // in, out, h0, w0, zoom, vmin, vmax, show_out); 00150 // } else if (dynamic_cast< subsampling_layer<T,Tstate>* >(&m)) { 00151 // /* subsampling_layer */ 00152 // subsampling_layer_gui:: 00153 // name1(dynamic_cast< subsampling_layer<T,Tstate>& >(m), 00154 // in, out, h0, w0, zoom, vmin, vmax, show_out); 00155 // } else if (dynamic_cast< subsampling_module_replicable<T,Tstate>* >(&m)) { 00156 // subsampling_module_gui:: 00157 // name1(dynamic_cast< subsampling_module<T,Tstate>& >(m), 00158 // in, out, h0, w0, zoom, vmin, vmax, show_out); 00159 00160 // in: Tstate out: Tstate 00161 DISPLAY_1_1(display_fprop, display_fprop2, Tstate, Tstate) 00162 DISPLAY_1_1(display_bprop, display_bprop2, Tstate, Tstate) 00163 DISPLAY_1_1(display_bbprop, display_bbprop2, Tstate, Tstate) 00164 DISPLAY2_1_1(display_fprop, display_fprop2, fprop, x, Tstate, Tstate) 00165 DISPLAY2_1_1(display_bprop, display_bprop2, bprop, dx, Tstate, Tstate) 00166 DISPLAY2_1_1(display_bbprop, display_bbprop2, bbprop, ddx, Tstate, Tstate) 00167 // in: Tstate out: mstate<Tstate> 00168 DISPLAY_1_1(display_fprop, display_fprop2, Tstate, mstate<Tstate>) 00169 DISPLAY_1_1(display_bprop, display_bprop2, Tstate, mstate<Tstate>) 00170 DISPLAY_1_1(display_bbprop, display_bbprop2, Tstate, mstate<Tstate>) 00171 DISPLAY2_1_1(display_fprop, display_fprop2, fprop, x, Tstate, mstate<Tstate>) 00172 DISPLAY2_1_1(display_bprop, display_bprop2, bprop, dx, Tstate, mstate<Tstate>) 00173 DISPLAY2_1_1(display_bbprop, display_bbprop2,bbprop,ddx,Tstate,mstate<Tstate>) 00174 // in: mstate<Tstate> out: Tstate 00175 DISPLAY_1_1(display_fprop, display_fprop2, mstate<Tstate>, Tstate) 00176 DISPLAY_1_1(display_bprop, display_bprop2, mstate<Tstate>, Tstate) 00177 DISPLAY_1_1(display_bbprop, display_bbprop2, mstate<Tstate>, Tstate) 00178 DISPLAY2_1_1(display_fprop, display_fprop2, fprop, x, mstate<Tstate>, Tstate) 00179 DISPLAY2_1_1(display_bprop, display_bprop2, bprop, dx, mstate<Tstate>, Tstate) 00180 DISPLAY2_1_1(display_bbprop, display_bbprop2,bbprop,ddx,mstate<Tstate>,Tstate) 00181 // in: Tstate out: mstate<Tstate> 00182 DISPLAY_1_1(display_fprop, display_fprop2, mstate<Tstate>, mstate<Tstate>) 00183 DISPLAY_1_1(display_bprop, display_bprop2, mstate<Tstate>, mstate<Tstate>) 00184 DISPLAY_1_1(display_bbprop, display_bbprop2, mstate<Tstate>, mstate<Tstate>) 00185 DISPLAY2_1_1(display_fprop, display_fprop2, fprop, x, mstate<Tstate>, 00186 mstate<Tstate>) 00187 DISPLAY2_1_1(display_bprop, display_bprop2, bprop, dx, mstate<Tstate>, 00188 mstate<Tstate>) 00189 DISPLAY2_1_1(display_bbprop, display_bbprop2, bbprop, ddx, mstate<Tstate>, 00190 mstate<Tstate>) 00191 00192 template<typename T, class Tstate> 00193 void module_1_1_gui:: 00194 display_internals(module_1_1<T,Tstate> &m, unsigned int &h0, unsigned int &w0, 00195 double zoom, T vmin, T vmax, int wid, 00196 const char *wname, uint maxwidth) { 00197 display_wid_fprop = (wid >= 0) ? wid : 00198 (display_wid_fprop >= 0) ? display_wid_fprop : 00199 new_window((wname ? wname : "module_1_1 display")); 00200 select_window(display_wid_fprop); 00201 00202 gui << black_on_white(255, 0) << gui_only(); 00203 unsigned int h = h0, w = w0; 00204 /* display internals */ 00205 for (uint i = 0; i < m.internals.size(); ++i) { 00206 idx<T> internal = m.internals[i]; 00207 string s; 00208 if (i < m.internals_str.size()) 00209 s = m.internals_str[i]; 00210 // expect 3d internal 00211 if (internal.order() != 3) 00212 eblerror("only 3d buffers currently supported, found " << internal); 00213 // show internal's text 00214 gui << gui_only() << at(h, w) << m.name() << " " << s << " " << internal 00215 << at(h + 15, w) << "min:" << idx_min(internal) 00216 << at(h + 30, w) << "max:" << idx_max(internal); 00217 w += TEXT_MARGIN; 00218 // show each slice of internal 00219 idx_bloop1(in, internal, T) { 00220 if (w - w0 >= maxwidth) { 00221 h += (uint) (in.dim(0) * zoom + 1); 00222 w = w0 + TEXT_MARGIN; 00223 } 00224 if (h < MAXHEIGHT) { 00225 draw_matrix(in, h, w, zoom, zoom, vmin, vmax); 00226 w += (uint) (in.dim(1) * zoom + 1); 00227 } 00228 } 00229 w = w0; 00230 h += (uint) (internal.dim(1) * zoom + 1); 00231 } 00232 if (!m.internals.empty()) 00233 h0 = std::max(h0 + TEXT_MIN_HEIGHT, h + MODULES_HSPACE); 00234 } 00235 00237 // module_2_1_gui 00238 00239 #define DISPLAY_2_1(name1) \ 00240 template<typename T, class Tstate, class Tin2, class Tout> \ 00241 void module_2_1_gui::name1(module_2_1<T,Tstate,Tstate,Tout> &m, \ 00242 Tstate &in1, Tin2 &in2, Tout &out, \ 00243 unsigned int &h0, unsigned int &w0, \ 00244 double zoom, T vmin, T vmax, \ 00245 bool show_out, int wid, \ 00246 const char *wname) { \ 00247 display_wid_fprop = (wid >= 0) ? wid : \ 00248 new_window((wname ? wname : "module_2_1 display")); \ 00249 select_window(display_wid_fprop); \ 00250 /* disable_window_updates();*/ \ 00251 gui << black_on_white(255, 0) << gui_only(); \ 00252 \ 00253 if (dynamic_cast< trainable_module<T,T,T,Tstate,Tstate,Tout>* >(&m)) { \ 00254 /* trainable_module */ \ 00255 trainable_module_gui:: \ 00256 name1(*this, \ 00257 dynamic_cast<trainable_module<T,T,T,Tstate,Tstate,Tout>& >(m), \ 00258 in1, in2, out, h0, w0, zoom, vmin, vmax, show_out, wid); \ 00259 } else { \ 00260 cerr << "Warning: unknown display function for module_2_1 object"; \ 00261 cerr << "(" << typeid(m).name() << ")." << endl; \ 00262 } \ 00263 /* enable_window_updates();*/ \ 00264 } 00265 00266 DISPLAY_2_1(display_fprop) 00267 DISPLAY_2_1(display_bprop) 00268 DISPLAY_2_1(display_bbprop) 00269 00271 // trainable_module_gui 00272 00273 #define DISPLAY_TRAINABLE(name1, name2) \ 00274 template<typename T, class Tin1, class Tin2, class Ten,typename \ 00275 Tds1,typename Tds2> \ 00276 void trainable_module_gui:: \ 00277 name1(trainable_module<T,Tds1,Tds2,Tin1,Tin1,Ten> &dse, \ 00278 Tin1 &i1, Tin2 &i2, Ten &energy, uint &h0, uint &w0, \ 00279 double zoom, T vmin, T vmax, bool show_out, int wid, \ 00280 const char *wname) { \ 00281 module_1_1_gui m; \ 00282 m.name2(dse.mod1, i1, dse.out1, h0, w0, zoom, vmin, vmax, \ 00283 show_out, wid, wname); \ 00284 /* TODO add energy, answer display */ \ 00285 } 00286 00287 DISPLAY_TRAINABLE(display_fprop, display_fprop2) 00288 DISPLAY_TRAINABLE(display_bprop, display_bprop2) 00289 DISPLAY_TRAINABLE(display_bbprop, display_bbprop2) 00290 00292 // layers_gui 00293 00294 #define DISPLAY_LAYERS_SS(name1, name2, T) \ 00295 template <typename T, class Tstate> \ 00296 void layers_gui::name1(module_1_1_gui &g, layers<T,Tstate> &ln, \ 00297 Tstate &in, Tstate &out, uint &h0, uint &w0, \ 00298 double zoom, T vmin, T vmax, bool show_out) { \ 00299 ln.msin[0] = in; \ 00300 ln.msout[0] = out; \ 00301 name1(g, ln, ln.msin, ln.msout, h0, w0, zoom, vmin, vmax, show_out); \ 00302 out = ln.msout[0]; \ 00303 } 00304 00305 #define DISPLAY_LAYERS_MS(name1, name2, T) \ 00306 template <typename T, class Tstate> \ 00307 void layers_gui::name1(module_1_1_gui &g, layers<T,Tstate> &ln, \ 00308 mstate<Tstate> &in, Tstate &out, uint &h0, uint &w0, \ 00309 double zoom, T vmin, T vmax, bool show_out) { \ 00310 ln.msout[0] = out; \ 00311 name1(g, ln, in, ln.msout, h0, w0, zoom, vmin, vmax, show_out); \ 00312 out = ln.msout[0]; \ 00313 } 00314 00315 #define DISPLAY_LAYERS_SM(name1, name2, T) \ 00316 template <typename T, class Tstate> \ 00317 void layers_gui::name1(module_1_1_gui &g, layers<T,Tstate> &ln, \ 00318 Tstate &in, mstate<Tstate> &out, uint &h0, uint &w0, \ 00319 double zoom, T vmin, T vmax, bool show_out) { \ 00320 ln.msin[0] = in; \ 00321 name1(g, ln, ln.msin, ln.out, h0, w0, zoom, vmin, vmax, show_out); \ 00322 } 00323 00324 #define DISPLAY_LAYERS(name1, name2, T) \ 00325 template <typename T, class Tstate> \ 00326 void layers_gui::name1(module_1_1_gui &g, layers<T,Tstate> &ln, \ 00327 mstate<Tstate> &in, mstate<Tstate> &out, \ 00328 uint &h0, uint &w0, double zoom, T vmin, T vmax, \ 00329 bool show_out) { \ 00330 EDEBUG("displaying layers " << ln.name() << " with inputs " << in); \ 00331 if (ln.modules.empty()) return ; \ 00332 /* initialize buffers */ \ 00333 ln.hi = ∈ \ 00334 ln.ho = &out; \ 00335 /* loop over modules */ \ 00336 for (uint i = 0; i < ln.modules.size(); i++) { \ 00337 /* if last module, output into out */ \ 00338 if (i == ln.modules.size() - 1) ln.ho = &out; \ 00339 else { /* not last module, use hidden buffers */ \ 00340 ln.ho = (mstate<Tstate>*) ln.hiddens[i]; \ 00341 /* allocate hidden buffer if necessary */ \ 00342 if (ln.ho == NULL) { \ 00343 ln.hiddens[i] = new mstate<Tstate>(*ln.hi); \ 00344 ln.ho = (mstate<Tstate>*) ln.hiddens[i]; \ 00345 } \ 00346 } \ 00347 /* run module */ \ 00348 /* TODO: this display on 1st buf, display all */ \ 00349 module_1_1<T,Tstate> *mod = ln.modules[i]; \ 00350 EDEBUG("ln.hi: " << *ln.hi << " ln.ho: " << *ln.ho); \ 00351 if (mod->mstate_input() == mod->mstate_output()) { /* s-s or ms-ms */ \ 00352 g.name2(*mod, *ln.hi, *ln.ho, h0, w0, zoom, vmin, \ 00353 vmax, false, g.display_wid_fprop); \ 00354 } else { /* s-ms or ms-s */ \ 00355 if (mod->mstate_output()) { /* s-ms */ \ 00356 g.name2(*mod, (*ln.hi)[0], *ln.ho, \ 00357 h0, w0, zoom, vmin, vmax, false, g.display_wid_fprop); \ 00358 } else {/* ms-s */ \ 00359 g.name2(*mod, *ln.hi, (*ln.ho)[0], \ 00360 h0, w0, zoom, vmin, vmax, false, g.display_wid_fprop); \ 00361 } \ 00362 } \ 00363 ln.hi = ln.ho; \ 00364 } \ 00365 if (show_out) { \ 00366 EDEBUG("displaying outputs " << out); \ 00367 unsigned int h = h0, w = w0, zoomf = 1; \ 00368 for (uint i = 0; i < out.size(); ++i) { \ 00369 Tstate &o = out[i]; \ 00370 /* display outputs text */ \ 00371 gui << gui_only() << at(h, w) << "out[" << i << "]:" << o.x; \ 00372 w += 150; \ 00373 /* display outputs */ \ 00374 idx_bloop1(m, o.T, T) { \ 00375 draw_matrix(m, h, w, zoom * zoomf, zoom * zoomf, vmin, vmax); \ 00376 w += (uint) (m.dim(1) * zoom * zoomf + 1); \ 00377 } \ 00378 h0 += (uint) (m.dim(0) * zoom * zoomf + 1); \ 00379 } \ 00380 } \ 00381 /* remember number of input/outputs */ \ 00382 ln.ninputs = in.size(); \ 00383 ln.noutputs = out.size(); \ 00384 } 00385 00386 // in: Tstate out: Tstate 00387 DISPLAY_LAYERS_SS(display_fprop, display_fprop2, x) 00388 DISPLAY_LAYERS_SS(display_bprop, display_bprop2, dx) 00389 DISPLAY_LAYERS_SS(display_bbprop, display_bbprop2, ddx) 00390 // in: mstate<Tstate> out: Tstate 00391 DISPLAY_LAYERS_MS(display_fprop, display_fprop2, x) 00392 DISPLAY_LAYERS_MS(display_bprop, display_bprop2, dx) 00393 DISPLAY_LAYERS_MS(display_bbprop, display_bbprop2, ddx) 00394 // in: Tstate out: mstate<Tstate> 00395 DISPLAY_LAYERS_SM(display_fprop, display_fprop2, x) 00396 DISPLAY_LAYERS_SM(display_bprop, display_bprop2, dx) 00397 DISPLAY_LAYERS_SM(display_bbprop, display_bbprop2, ddx) 00398 // in: mstate<Tstate> out: mstate<Tstate> 00399 DISPLAY_LAYERS(display_fprop, display_fprop2, x) 00400 DISPLAY_LAYERS(display_bprop, display_bprop2, dx) 00401 DISPLAY_LAYERS(display_bbprop, display_bbprop2, ddx) 00402 00404 00405 template<typename T, class Tstate> 00406 void layers_gui::display_internals(layers<T,Tstate> &ln, 00407 unsigned int &h0, 00408 unsigned int &w0, double zoom, T vmin, 00409 T vmax, uint maxwidth) { 00410 if (ln.modules.empty()) 00411 return ; 00412 /* loop over modules */ 00413 for(uint i = 0; i < ln.modules.size(); i++) { 00414 /* display module's internals */ 00415 m11g.display_internals(*ln.modules[i], h0, w0, zoom, vmin, vmax, 00416 -1, NULL, maxwidth); 00417 // recursively display layers 00418 if (dynamic_cast<layers<T,Tstate>*>(ln.modules[i])) { 00419 layers<T,Tstate> &b = (layers<T,Tstate>&) *(ln.modules[i]); 00420 display_internals(b, h0, w0, zoom, vmin, vmax, maxwidth); 00421 } 00422 } 00423 } 00424 00425 template<typename T, class Tstate> 00426 void layers_gui::display_internals(module_1_1<T,Tstate> &m, 00427 unsigned int &h0, 00428 unsigned int &w0, double zoom, T vmin, 00429 T vmax, uint maxwidth) { 00430 if (dynamic_cast< layers<T,Tstate>*>(&m)) 00431 display_internals((layers<T,Tstate>&) m, h0, w0, zoom, vmin, vmax, 00432 maxwidth); 00433 else 00434 eblerror("failed to cast module_1_1 m to layers object for display"); 00435 } 00436 00438 // ms_module_gui 00439 00440 #define DISPLAY_MSMODULE_F(name1, name2, T) \ 00441 template <typename T, class Tstate> \ 00442 void ms_module_gui::name1(module_1_1_gui &g, ms_module<T,Tstate> &ms, \ 00443 mstate<Tstate> &in, mstate<Tstate> &out, \ 00444 uint &h0, uint &w0, double zoom, T vmin, T vmax, \ 00445 bool show_out) { \ 00446 EDEBUG("displaying ms_module " << ms.name() << " with inputs " << in); \ 00447 ms.init_fprop(in, out); \ 00448 /* fprop ins */ \ 00449 for (uint i = 0; i < ms.used_pipes.size(); ++i) { \ 00450 mstate<Tstate> b; \ 00451 EDEBUG("msused " << ms.used_pipes); \ 00452 EDEBUG("msins " << ms.ins); \ 00453 g.name2(*(ms.used_pipes[i]), ms.ins[i], b, h0, w0, zoom, \ 00454 vmin, vmax, false, g.display_wid_fprop); \ 00455 out.push_back_new(b); \ 00456 ms.pipes_noutputs[i] = b.size(); \ 00457 } \ 00458 /* remember number of outputs */ \ 00459 ms.noutputs = out.size(); \ 00460 } 00461 00462 #define DISPLAY_MSMODULE_B(name1, name2, T) \ 00463 template <typename T, class Tstate> \ 00464 void ms_module_gui::name1(module_1_1_gui &g, ms_module<T,Tstate> &ms, \ 00465 mstate<Tstate> &in, mstate<Tstate> &out, \ 00466 uint &h0, uint &w0, double zoom, T vmin, T vmax, \ 00467 bool show_out) { \ 00468 for (uint i = (int) ms.used_pipes.size() - 1; i >= 0; ++i) \ 00469 g.name2(*(ms.used_pipes[i]), ms.ins[i], ms.mbuffers[i], h0, w0, zoom, \ 00470 vmin, vmax, false, g.display_wid_fprop); \ 00471 } 00472 00473 // in: mstate<Tstate> out: mstate<Tstate> 00474 DISPLAY_MSMODULE_F(display_fprop, display_fprop2, x) 00475 DISPLAY_MSMODULE_B(display_bprop, display_bprop2, dx) 00476 DISPLAY_MSMODULE_B(display_bbprop, display_bbprop2, ddx) 00477 00479 // layers2_gui 00480 00481 #define DISPLAY_LAYERS2(name1) \ 00482 template<typename T, class Tstate> \ 00483 void layers_2_gui::name1(module_1_1_gui &g, \ 00484 layers_2<T> &l2, \ 00485 Tstate &in, Tstate &out, \ 00486 unsigned int &h0, unsigned int &w0, \ 00487 double zoom, T vmin, T vmax, \ 00488 bool show_out) { \ 00489 g.name1(l2.layer1, in, l2.hidden, \ 00490 h0, w0, zoom, vmin, vmax, false, g.display_wid_fprop); \ 00491 g.name1(l2.layer2, l2.hidden, out, \ 00492 h0, w0, zoom, vmin, vmax, false, g.display_wid_fprop); \ 00493 } 00494 00495 // DISPLAY_LAYERS2(display_fprop) 00496 // DISPLAY_LAYERS2(display_bprop) 00497 // DISPLAY_LAYERS2(display_bbprop) 00498 00499 } // end namespace ebl 00500 00501 #endif /* ELB_ARCH_GUI_HPP_ */