]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/panel.cxx
Some changes contributed by David Megginson to allow for more interesting
[flightgear.git] / src / Cockpit / panel.cxx
1 //  panel.cxx - default, 2D single-engine prop instrument panel
2 //
3 //  Written by David Megginson, started January 2000.
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License as
7 //  published by the Free Software Foundation; either version 2 of the
8 //  License, or (at your option) any later version.
9 // 
10 //  This program is distributed in the hope that it will be useful, but
11 //  WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 //  General Public License for more details.
14 // 
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //
19 //  $Id$
20
21 #ifdef HAVE_CONFIG_H
22 #  include <config.h>
23 #endif
24
25 #ifdef HAVE_WINDOWS_H          
26 #  include <windows.h>
27 #endif
28
29 #include <string.h>
30
31 #include <plib/ssg.h>
32 #include <plib/fnt.h>
33
34 #include <simgear/debug/logstream.hxx>
35 #include <simgear/misc/fgpath.hxx>
36 #include <Main/options.hxx>
37 #include <Main/views.hxx>
38 #include <Objects/texload.h>
39
40 #include "hud.hxx"
41 #include "panel.hxx"
42
43
44 bool
45 fgPanelVisible ()
46 {
47   return ((current_options.get_panel_status()) &&
48           (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_PILOT) &&
49           (current_view.get_view_offset() == 0.0));
50 }
51
52
53 \f
54 ////////////////////////////////////////////////////////////////////////
55 // Implementation of FGTextureManager.
56 ////////////////////////////////////////////////////////////////////////
57
58 map<string,ssgTexture *> FGTextureManager::_textureMap;
59
60 ssgTexture *
61 FGTextureManager::createTexture (const string &relativePath)
62 {
63   ssgTexture * texture = _textureMap[relativePath];
64   if (texture == 0) {
65     cerr << "Texture " << relativePath << " does not yet exist" << endl;
66     FGPath tpath(current_options.get_fg_root());
67     tpath.append(relativePath);
68     texture = new ssgTexture((char *)tpath.c_str(), false, false);
69     _textureMap[relativePath] = texture;
70     if (_textureMap[relativePath] == 0) 
71       cerr << "Texture *still* doesn't exist" << endl;
72     cerr << "Created texture " << relativePath
73          << " handle=" << texture->getHandle() << endl;
74   }
75
76   return texture;
77 }
78
79
80
81 \f
82 ////////////////////////////////////////////////////////////////////////
83 // Implementation of FGCropped Texture.
84 ////////////////////////////////////////////////////////////////////////
85
86
87 FGCroppedTexture::FGCroppedTexture ()
88   : _path(""), _texture(0),
89     _minX(0.0), _minY(0.0), _maxX(1.0), _maxY(1.0)
90 {
91 }
92
93
94 FGCroppedTexture::FGCroppedTexture (const string &path,
95                                     float minX, float minY,
96                                     float maxX, float maxY)
97   : _path(path), _texture(0),
98     _minX(minX), _minY(minY), _maxX(maxX), _maxY(maxY)
99 {
100 }
101
102
103 FGCroppedTexture::~FGCroppedTexture ()
104 {
105 }
106
107
108 ssgTexture *
109 FGCroppedTexture::getTexture ()
110 {
111   if (_texture == 0) {
112     _texture = FGTextureManager::createTexture(_path);
113   }
114   return _texture;
115 }
116
117
118 \f
119 ////////////////////////////////////////////////////////////////////////
120 // Implementation of FGPanel.
121 ////////////////////////////////////////////////////////////////////////
122
123 FGPanel * current_panel = NULL;
124 static fntRenderer text_renderer;
125
126
127 /**
128  * Constructor.
129  */
130 FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
131   : _mouseDown(false),
132     _mouseInstrument(0),
133     _winx(window_x), _winy(window_y), _winw(window_w), _winh(window_h),
134     _width(_winw), _height(int(_winh * 0.5768 + 1)),
135     _x_offset(0), _y_offset(0), _view_height(int(_winh * 0.4232))
136 {
137   setVisibility(fgPanelVisible());
138 }
139
140
141 /**
142  * Destructor.
143  */
144 FGPanel::~FGPanel ()
145 {
146   for (instrument_list_type::iterator it = _instruments.begin();
147        it != _instruments.end();
148        it++) {
149     delete *it;
150     *it = 0;
151   }
152 }
153
154
155 /**
156  * Add an instrument to the panel.
157  */
158 void
159 FGPanel::addInstrument (FGPanelInstrument * instrument)
160 {
161   _instruments.push_back(instrument);
162 }
163
164
165 /**
166  * Update the panel.
167  */
168 void
169 FGPanel::update () const
170 {
171                                 // Do nothing if the panel isn't visible.
172   if (!fgPanelVisible())
173     return;
174
175                                 // If the mouse is down, do something
176   if (_mouseDown) {
177     _mouseDelay--;
178     if (_mouseDelay < 0) {
179       _mouseInstrument->doMouseAction(_mouseButton, _mouseX, _mouseY);
180       _mouseDelay = 2;
181     }
182   }
183
184                                 // Now, draw the panel
185   glMatrixMode(GL_PROJECTION);
186   glPushMatrix();
187   glLoadIdentity();
188   gluOrtho2D(_winx, _winx + _winw, _winy, _winy + _winh);
189
190   glMatrixMode(GL_MODELVIEW);
191   glPushMatrix();
192   glLoadIdentity();
193
194   glTranslated(_x_offset, _y_offset, 0);
195
196                                 // Draw the background
197   glEnable(GL_TEXTURE_2D);
198   glDisable(GL_LIGHTING);
199   glEnable(GL_BLEND);
200   glEnable(GL_ALPHA_TEST);
201   glEnable(GL_COLOR_MATERIAL);
202   // glColor4f(1.0, 1.0, 1.0, 1.0);
203   if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
204       glColor4fv( cur_light_params.scene_diffuse );
205   } else {
206       glColor4f(0.7, 0.2, 0.2, 1.0);
207   }
208   glBindTexture(GL_TEXTURE_2D, _bg->getHandle());
209   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
210   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
211   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
212   glBegin(GL_POLYGON);
213   glTexCoord2f(0.0, 0.0); glVertex3f(_winx, _winy, 0);
214   glTexCoord2f(1.0, 0.0); glVertex3f(_winx + _width, _winy, 0);
215   glTexCoord2f(1.0, 1.0); glVertex3f(_winx + _width, _winy + _height, 0);
216   glTexCoord2f(0.0, 1.0); glVertex3f(_winx, _winy + _height, 0);
217   glEnd();
218
219                                 // Draw the instruments.
220   instrument_list_type::const_iterator current = _instruments.begin();
221   instrument_list_type::const_iterator end = _instruments.end();
222
223   for ( ; current != end; current++) {
224     FGPanelInstrument * instr = *current;
225     glLoadIdentity();
226     glTranslated(_x_offset, _y_offset, 0);
227     glTranslated(instr->getXPos(), instr->getYPos(), 0);
228     instr->draw();
229   }
230
231   glMatrixMode(GL_PROJECTION);
232   glPopMatrix();
233   glMatrixMode(GL_MODELVIEW);
234   glPopMatrix();
235   ssgForceBasicState();
236   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
237 }
238
239
240 /**
241  * Set the panel's visibility.
242  */
243 void
244 FGPanel::setVisibility (bool visibility)
245 {
246   _visibility = visibility;
247 }
248
249
250 /**
251  * Return true if the panel is visible.
252  */
253 bool
254 FGPanel::getVisibility () const
255 {
256   return _visibility;
257 }
258
259
260 /**
261  * Set the panel's background texture.
262  */
263 void
264 FGPanel::setBackground (ssgTexture * texture)
265 {
266   _bg = texture;
267 }
268
269
270 /**
271  * Set the panel's x-offset.
272  */
273 void
274 FGPanel::setXOffset (int offset)
275 {
276   if (offset <= 0 && offset >= -_width + _winw)
277     _x_offset = offset;
278 }
279
280
281 /**
282  * Set the panel's y-offset.
283  */
284 void
285 FGPanel::setYOffset (int offset)
286 {
287   if (offset <= 0 && offset >= -_height)
288     _y_offset = offset;
289 }
290
291
292 /**
293  * Perform a mouse action.
294  */
295 bool
296 FGPanel::doMouseAction (int button, int updown, int x, int y)
297 {
298
299                                 // Note a released button and return
300   // cerr << "Doing mouse action\n";
301   if (updown == 1) {
302     _mouseDown = false;
303     _mouseInstrument = 0;
304     return true;
305   }
306
307                                 // Scale for the real window size.
308   x = int(((float)x / current_view.get_winWidth()) * _winw);
309   y = int(_winh - (((float)y / current_view.get_winHeight()) * _winh));
310
311                                 // Adjust for offsets.
312   x -= _x_offset;
313   y -= _y_offset;
314
315                                 // Search for a matching instrument.
316   for (int i = 0; i < (int)_instruments.size(); i++) {
317     FGPanelInstrument *inst = _instruments[i];
318     int ix = inst->getXPos();
319     int iy = inst->getYPos();
320     int iw = inst->getWidth() / 2;
321     int ih = inst->getHeight() / 2;
322     if (x >= ix - iw && x < ix + iw && y >= iy - ih && y < iy + ih) {
323       _mouseDown = true;
324       _mouseDelay = 20;
325       _mouseInstrument = inst;
326       _mouseButton = button;
327       _mouseX = x - ix;
328       _mouseY = y - iy;
329                                 // Always do the action once.
330       _mouseInstrument->doMouseAction(_mouseButton, _mouseX, _mouseY);
331       return true;
332     }
333   }
334   return false;
335 }
336
337
338 \f
339 ////////////////////////////////////////////////////////////////////////.
340 // Implementation of FGPanelAction.
341 ////////////////////////////////////////////////////////////////////////
342
343 FGPanelAction::FGPanelAction ()
344 {
345 }
346
347 FGPanelAction::FGPanelAction (int button, int x, int y, int w, int h)
348   : _button(button), _x(x), _y(y), _w(w), _h(h)
349 {
350 }
351
352 FGPanelAction::~FGPanelAction ()
353 {
354 }
355
356
357 \f
358 ////////////////////////////////////////////////////////////////////////
359 // Implementation of FGAdjustAction.
360 ////////////////////////////////////////////////////////////////////////
361
362 FGAdjustAction::FGAdjustAction (int button, int x, int y, int w, int h,
363                                 SGValue * value, float increment, 
364                                 float min, float max, bool wrap)
365   : FGPanelAction(button, x, y, w, h),
366     _value(value), _increment(increment), _min(min), _max(max), _wrap(wrap)
367 {
368 }
369
370 FGAdjustAction::~FGAdjustAction ()
371 {
372 }
373
374 void
375 FGAdjustAction::doAction ()
376 {
377   float val = _value->getFloatValue();
378   val += _increment;
379   if (val < _min) {
380     val = (_wrap ? _max : _min);
381   } else if (val > _max) {
382     val = (_wrap ? _min : _max);
383   }
384   _value->setDoubleValue(val);
385 }
386
387
388 \f
389 ////////////////////////////////////////////////////////////////////////
390 // Implementation of FGSwapAction.
391 ////////////////////////////////////////////////////////////////////////
392
393 FGSwapAction::FGSwapAction (int button, int x, int y, int w, int h,
394                             SGValue * value1, SGValue * value2)
395   : FGPanelAction(button, x, y, w, h), _value1(value1), _value2(value2)
396 {
397 }
398
399 FGSwapAction::~FGSwapAction ()
400 {
401 }
402
403 void
404 FGSwapAction::doAction ()
405 {
406   float val = _value1->getFloatValue();
407   _value1->setDoubleValue(_value2->getFloatValue());
408   _value2->setDoubleValue(val);
409 }
410
411
412 \f
413 ////////////////////////////////////////////////////////////////////////
414 // Implementation of FGToggleAction.
415 ////////////////////////////////////////////////////////////////////////
416
417 FGToggleAction::FGToggleAction (int button, int x, int y, int w, int h,
418                                 SGValue * value)
419   : FGPanelAction(button, x, y, w, h), _value(value)
420 {
421 }
422
423 FGToggleAction::~FGToggleAction ()
424 {
425 }
426
427 void
428 FGToggleAction::doAction ()
429 {
430   _value->setBoolValue(!(_value->getBoolValue()));
431 }
432
433
434 \f
435 ////////////////////////////////////////////////////////////////////////
436 // Implementation of FGPanelTransformation.
437 ////////////////////////////////////////////////////////////////////////
438
439 FGPanelTransformation::FGPanelTransformation ()
440 {
441 }
442
443 FGPanelTransformation::~FGPanelTransformation ()
444 {
445 }
446
447
448 \f
449 ////////////////////////////////////////////////////////////////////////
450 // Implementation of FGPanelInstrument.
451 ////////////////////////////////////////////////////////////////////////
452
453
454 FGPanelInstrument::FGPanelInstrument ()
455 {
456   setPosition(0, 0);
457   setSize(0, 0);
458 }
459
460 FGPanelInstrument::FGPanelInstrument (int x, int y, int w, int h)
461 {
462   setPosition(x, y);
463   setSize(w, h);
464 }
465
466 FGPanelInstrument::~FGPanelInstrument ()
467 {
468   for (action_list_type::iterator it = _actions.begin();
469        it != _actions.end();
470        it++) {
471     delete *it;
472     *it = 0;
473   }
474 }
475
476 void
477 FGPanelInstrument::setPosition (int x, int y)
478 {
479   _x = x;
480   _y = y;
481 }
482
483 void
484 FGPanelInstrument::setSize (int w, int h)
485 {
486   _w = w;
487   _h = h;
488 }
489
490 int
491 FGPanelInstrument::getXPos () const
492 {
493   return _x;
494 }
495
496 int
497 FGPanelInstrument::getYPos () const
498 {
499   return _y;
500 }
501
502 int
503 FGPanelInstrument::getWidth () const
504 {
505   return _w;
506 }
507
508 int
509 FGPanelInstrument::getHeight () const
510 {
511   return _h;
512 }
513
514 void
515 FGPanelInstrument::addAction (FGPanelAction * action)
516 {
517   _actions.push_back(action);
518 }
519
520                                 // Coordinates relative to centre.
521 bool
522 FGPanelInstrument::doMouseAction (int button, int x, int y)
523 {
524   action_list_type::iterator it = _actions.begin();
525   action_list_type::iterator last = _actions.end();
526   for ( ; it != last; it++) {
527     if ((*it)->inArea(button, x, y)) {
528       (*it)->doAction();
529       return true;
530     }
531   }
532   return false;
533 }
534
535
536 \f
537 ////////////////////////////////////////////////////////////////////////
538 // Implementation of FGLayeredInstrument.
539 ////////////////////////////////////////////////////////////////////////
540
541 FGLayeredInstrument::FGLayeredInstrument (int x, int y, int w, int h)
542   : FGPanelInstrument(x, y, w, h)
543 {
544 }
545
546 FGLayeredInstrument::~FGLayeredInstrument ()
547 {
548   for (layer_list::iterator it = _layers.begin(); it != _layers.end(); it++) {
549     delete *it;
550     *it = 0;
551   }
552 }
553
554 void
555 FGLayeredInstrument::draw ()
556 {
557   for (int i = 0; i < (int)_layers.size(); i++) {
558     glPushMatrix();
559     glTranslatef(0.0, 0.0, (i / 100.0) + 0.1);
560     _layers[i]->draw();
561     glPopMatrix();
562   }
563 }
564
565 int
566 FGLayeredInstrument::addLayer (FGInstrumentLayer *layer)
567 {
568   int n = _layers.size();
569   if (layer->getWidth() == -1) {
570     layer->setWidth(getWidth());
571   }
572   if (layer->getHeight() == -1) {
573     layer->setHeight(getHeight());
574   }
575   _layers.push_back(layer);
576   return n;
577 }
578
579 int
580 FGLayeredInstrument::addLayer (FGCroppedTexture &texture,
581                                int w, int h)
582 {
583   return addLayer(new FGTexturedLayer(texture, w, h));
584 }
585
586 void
587 FGLayeredInstrument::addTransformation (FGPanelTransformation * transformation)
588 {
589   int layer = _layers.size() - 1;
590   _layers[layer]->addTransformation(transformation);
591 }
592
593
594 \f
595 ////////////////////////////////////////////////////////////////////////
596 // Implementation of FGInstrumentLayer.
597 ////////////////////////////////////////////////////////////////////////
598
599 FGInstrumentLayer::FGInstrumentLayer (int w, int h)
600   : _w(w),
601     _h(h)
602 {
603 }
604
605 FGInstrumentLayer::~FGInstrumentLayer ()
606 {
607   for (transformation_list::iterator it = _transformations.begin();
608        it != _transformations.end();
609        it++) {
610     delete *it;
611     *it = 0;
612   }
613 }
614
615 void
616 FGInstrumentLayer::transform () const
617 {
618   transformation_list::const_iterator it = _transformations.begin();
619   transformation_list::const_iterator last = _transformations.end();
620   while (it != last) {
621     FGPanelTransformation *t = *it;
622     float val = (t->value == 0 ? 0.0 : t->value->getFloatValue());
623     if (val < t->min) {
624       val = t->min;
625     } else if (val > t->max) {
626       val = t->max;
627     }
628     val = val * t->factor + t->offset;
629
630     switch (t->type) {
631     case FGPanelTransformation::XSHIFT:
632       glTranslatef(val, 0.0, 0.0);
633       break;
634     case FGPanelTransformation::YSHIFT:
635       glTranslatef(0.0, val, 0.0);
636       break;
637     case FGPanelTransformation::ROTATION:
638       glRotatef(-val, 0.0, 0.0, 1.0);
639       break;
640     }
641     it++;
642   }
643 }
644
645 void
646 FGInstrumentLayer::addTransformation (FGPanelTransformation * transformation)
647 {
648   _transformations.push_back(transformation);
649 }
650
651
652 \f
653 ////////////////////////////////////////////////////////////////////////
654 // Implementation of FGTexturedLayer.
655 ////////////////////////////////////////////////////////////////////////
656
657
658 FGTexturedLayer::FGTexturedLayer (const FGCroppedTexture &texture, int w, int h)
659   : FGInstrumentLayer(w, h)
660 {
661   setTexture(texture);
662 }
663
664
665 FGTexturedLayer::~FGTexturedLayer ()
666 {
667 }
668
669
670 void
671 FGTexturedLayer::draw ()
672 {
673   int w2 = _w / 2;
674   int h2 = _h / 2;
675
676   transform();
677   glBindTexture(GL_TEXTURE_2D, _texture.getTexture()->getHandle());
678   glBegin(GL_POLYGON);
679
680                                 // From Curt: turn on the panel
681                                 // lights after sundown.
682   if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
683       glColor4fv( cur_light_params.scene_diffuse );
684   } else {
685       glColor4f(0.7, 0.2, 0.2, 1.0);
686   }
687
688
689   glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2);
690   glTexCoord2f(_texture.getMaxX(), _texture.getMinY()); glVertex2f(w2, -h2);
691   glTexCoord2f(_texture.getMaxX(), _texture.getMaxY()); glVertex2f(w2, h2);
692   glTexCoord2f(_texture.getMinX(), _texture.getMaxY()); glVertex2f(-w2, h2);
693   glEnd();
694 }
695
696
697 \f
698 ////////////////////////////////////////////////////////////////////////
699 // Implementation of FGTextLayer.
700 ////////////////////////////////////////////////////////////////////////
701
702 FGTextLayer::FGTextLayer (int w, int h)
703   : FGInstrumentLayer(w, h), _pointSize(14.0)
704 {
705   _then.stamp();
706   _color[0] = _color[1] = _color[2] = 0.0;
707   _color[3] = 1.0;
708 }
709
710 FGTextLayer::~FGTextLayer ()
711 {
712   chunk_list::iterator it = _chunks.begin();
713   chunk_list::iterator last = _chunks.end();
714   for ( ; it != last; it++) {
715     delete *it;
716   }
717 }
718
719 void
720 FGTextLayer::draw ()
721 {
722   glPushMatrix();
723   glColor4fv(_color);
724   transform();
725   text_renderer.setFont(guiFntHandle);
726   text_renderer.setPointSize(_pointSize);
727   text_renderer.begin();
728   text_renderer.start3f(0, 0, 0);
729
730   _now.stamp();
731   if (_now - _then > 100000) {
732     recalc_value();
733     _then = _now;
734   }
735   text_renderer.puts((char *)(_value.c_str()));
736
737   text_renderer.end();
738   glColor4f(1.0, 1.0, 1.0, 1.0);        // FIXME
739   glPopMatrix();
740 }
741
742 void
743 FGTextLayer::addChunk (FGTextLayer::Chunk * chunk)
744 {
745   _chunks.push_back(chunk);
746 }
747
748 void
749 FGTextLayer::setColor (float r, float g, float b)
750 {
751   _color[0] = r;
752   _color[1] = g;
753   _color[2] = b;
754   _color[3] = 1.0;
755 }
756
757 void
758 FGTextLayer::setPointSize (float size)
759 {
760   _pointSize = size;
761 }
762
763 void
764 FGTextLayer::setFont(fntFont * font)
765 {
766   text_renderer.setFont(font);
767 }
768
769
770 void
771 FGTextLayer::recalc_value () const
772 {
773   _value = "";
774   chunk_list::const_iterator it = _chunks.begin();
775   chunk_list::const_iterator last = _chunks.end();
776   for ( ; it != last; it++) {
777     _value += (*it)->getValue();
778   }
779 }
780
781
782 \f
783 ////////////////////////////////////////////////////////////////////////
784 // Implementation of FGTextLayer::Chunk.
785 ////////////////////////////////////////////////////////////////////////
786
787 FGTextLayer::Chunk::Chunk (const string &text, const string &fmt)
788   : _type(FGTextLayer::TEXT), _fmt(fmt)
789 {
790   _text = text;
791   if (_fmt == "") 
792     _fmt = "%s";
793 }
794
795 FGTextLayer::Chunk::Chunk (ChunkType type, const SGValue * value,
796                            const string &fmt, float mult)
797   : _type(type), _fmt(fmt), _mult(mult)
798 {
799   if (_fmt == "") {
800     if (type == TEXT_VALUE)
801       _fmt = "%s";
802     else
803       _fmt = "%.2f";
804   }
805   _value = value;
806 }
807
808 const char *
809 FGTextLayer::Chunk::getValue () const
810 {
811   switch (_type) {
812   case TEXT:
813     sprintf(_buf, _fmt.c_str(), _text.c_str());
814     return _buf;
815   case TEXT_VALUE:
816     sprintf(_buf, _fmt.c_str(), _value->getStringValue().c_str());
817     break;
818   case DOUBLE_VALUE:
819     sprintf(_buf, _fmt.c_str(), _value->getFloatValue() * _mult);
820     break;
821   }
822   return _buf;
823 }
824
825
826 \f
827 ////////////////////////////////////////////////////////////////////////
828 // Implementation of FGSwitchLayer.
829 ////////////////////////////////////////////////////////////////////////
830
831 FGSwitchLayer::FGSwitchLayer (int w, int h, const SGValue * value,
832                               FGInstrumentLayer * layer1,
833                               FGInstrumentLayer * layer2)
834   : FGInstrumentLayer(w, h), _value(value), _layer1(layer1), _layer2(layer2)
835 {
836 }
837
838 FGSwitchLayer::~FGSwitchLayer ()
839 {
840   delete _layer1;
841   delete _layer2;
842 }
843
844 void
845 FGSwitchLayer::draw ()
846 {
847   transform();
848   if (_value->getBoolValue()) {
849     _layer1->draw();
850   } else {
851     _layer2->draw();
852   }
853 }
854
855 \f
856 // end of panel.cxx