]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/panel.cxx
Moved winWidth and winHeight out of FGViewer since these are set on a
[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/globals.hxx>
37 #include <Objects/texload.h>
38
39 #include "hud.hxx"
40 #include "panel.hxx"
41
42
43 bool
44 fgPanelVisible ()
45 {
46   return ((globals->get_options()->get_panel_status()) &&
47           (globals->get_options()->get_view_mode() == FGOptions::FG_VIEW_PILOT) &&
48           (globals->get_current_view()->get_view_offset() == 0.0));
49 }
50
51
52 \f
53 ////////////////////////////////////////////////////////////////////////
54 // Implementation of FGTextureManager.
55 ////////////////////////////////////////////////////////////////////////
56
57 map<string,ssgTexture *> FGTextureManager::_textureMap;
58
59 ssgTexture *
60 FGTextureManager::createTexture (const string &relativePath)
61 {
62   ssgTexture * texture = _textureMap[relativePath];
63   if (texture == 0) {
64     cerr << "Texture " << relativePath << " does not yet exist" << endl;
65     FGPath tpath(globals->get_options()->get_fg_root());
66     tpath.append(relativePath);
67     texture = new ssgTexture((char *)tpath.c_str(), false, false);
68     _textureMap[relativePath] = texture;
69     if (_textureMap[relativePath] == 0) 
70       cerr << "Texture *still* doesn't exist" << endl;
71     cerr << "Created texture " << relativePath
72          << " handle=" << texture->getHandle() << endl;
73   }
74
75   return texture;
76 }
77
78
79
80 \f
81 ////////////////////////////////////////////////////////////////////////
82 // Implementation of FGCropped Texture.
83 ////////////////////////////////////////////////////////////////////////
84
85
86 FGCroppedTexture::FGCroppedTexture ()
87   : _path(""), _texture(0),
88     _minX(0.0), _minY(0.0), _maxX(1.0), _maxY(1.0)
89 {
90 }
91
92
93 FGCroppedTexture::FGCroppedTexture (const string &path,
94                                     float minX, float minY,
95                                     float maxX, float maxY)
96   : _path(path), _texture(0),
97     _minX(minX), _minY(minY), _maxX(maxX), _maxY(maxY)
98 {
99 }
100
101
102 FGCroppedTexture::~FGCroppedTexture ()
103 {
104 }
105
106
107 ssgTexture *
108 FGCroppedTexture::getTexture ()
109 {
110   if (_texture == 0) {
111     _texture = FGTextureManager::createTexture(_path);
112   }
113   return _texture;
114 }
115
116
117 \f
118 ////////////////////////////////////////////////////////////////////////
119 // Implementation of FGPanel.
120 ////////////////////////////////////////////////////////////////////////
121
122 FGPanel * current_panel = NULL;
123 static fntRenderer text_renderer;
124
125
126 /**
127  * Constructor.
128  */
129 FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
130   : _mouseDown(false),
131     _mouseInstrument(0),
132     _winx(window_x), _winy(window_y), _winw(window_w), _winh(window_h),
133     _width(_winw), _height(int(_winh * 0.5768 + 1)),
134     _x_offset(0), _y_offset(0), _view_height(int(_winh * 0.4232))
135 {
136   setVisibility(fgPanelVisible());
137 }
138
139
140 /**
141  * Destructor.
142  */
143 FGPanel::~FGPanel ()
144 {
145   for (instrument_list_type::iterator it = _instruments.begin();
146        it != _instruments.end();
147        it++) {
148     delete *it;
149     *it = 0;
150   }
151 }
152
153
154 /**
155  * Add an instrument to the panel.
156  */
157 void
158 FGPanel::addInstrument (FGPanelInstrument * instrument)
159 {
160   _instruments.push_back(instrument);
161 }
162
163
164 /**
165  * Update the panel.
166  */
167 void
168 FGPanel::update () const
169 {
170                                 // Do nothing if the panel isn't visible.
171   if (!fgPanelVisible())
172     return;
173
174                                 // If the mouse is down, do something
175   if (_mouseDown) {
176     _mouseDelay--;
177     if (_mouseDelay < 0) {
178       _mouseInstrument->doMouseAction(_mouseButton, _mouseX, _mouseY);
179       _mouseDelay = 2;
180     }
181   }
182
183                                 // Now, draw the panel
184   glMatrixMode(GL_PROJECTION);
185   glPushMatrix();
186   glLoadIdentity();
187   gluOrtho2D(_winx, _winx + _winw, _winy, _winy + _winh);
188
189   glMatrixMode(GL_MODELVIEW);
190   glPushMatrix();
191   glLoadIdentity();
192
193   glTranslated(_x_offset, _y_offset, 0);
194
195                                 // Draw the background
196   glEnable(GL_TEXTURE_2D);
197   glDisable(GL_LIGHTING);
198   glEnable(GL_BLEND);
199   glEnable(GL_ALPHA_TEST);
200   glEnable(GL_COLOR_MATERIAL);
201   // glColor4f(1.0, 1.0, 1.0, 1.0);
202   if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
203       glColor4fv( cur_light_params.scene_diffuse );
204   } else {
205       glColor4f(0.7, 0.2, 0.2, 1.0);
206   }
207   glBindTexture(GL_TEXTURE_2D, _bg->getHandle());
208   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
209   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
210   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
211   glBegin(GL_POLYGON);
212   glTexCoord2f(0.0, 0.0); glVertex3f(_winx, _winy, 0);
213   glTexCoord2f(1.0, 0.0); glVertex3f(_winx + _width, _winy, 0);
214   glTexCoord2f(1.0, 1.0); glVertex3f(_winx + _width, _winy + _height, 0);
215   glTexCoord2f(0.0, 1.0); glVertex3f(_winx, _winy + _height, 0);
216   glEnd();
217
218                                 // Draw the instruments.
219   instrument_list_type::const_iterator current = _instruments.begin();
220   instrument_list_type::const_iterator end = _instruments.end();
221
222   for ( ; current != end; current++) {
223     FGPanelInstrument * instr = *current;
224     glLoadIdentity();
225     glTranslated(_x_offset, _y_offset, 0);
226     glTranslated(instr->getXPos(), instr->getYPos(), 0);
227     instr->draw();
228   }
229
230   glMatrixMode(GL_PROJECTION);
231   glPopMatrix();
232   glMatrixMode(GL_MODELVIEW);
233   glPopMatrix();
234   ssgForceBasicState();
235   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
236 }
237
238
239 /**
240  * Set the panel's visibility.
241  */
242 void
243 FGPanel::setVisibility (bool visibility)
244 {
245   _visibility = visibility;
246 }
247
248
249 /**
250  * Return true if the panel is visible.
251  */
252 bool
253 FGPanel::getVisibility () const
254 {
255   return _visibility;
256 }
257
258
259 /**
260  * Set the panel's background texture.
261  */
262 void
263 FGPanel::setBackground (ssgTexture * texture)
264 {
265   _bg = texture;
266 }
267
268
269 /**
270  * Set the panel's x-offset.
271  */
272 void
273 FGPanel::setXOffset (int offset)
274 {
275   if (offset <= 0 && offset >= -_width + _winw)
276     _x_offset = offset;
277 }
278
279
280 /**
281  * Set the panel's y-offset.
282  */
283 void
284 FGPanel::setYOffset (int offset)
285 {
286   if (offset <= 0 && offset >= -_height)
287     _y_offset = offset;
288 }
289
290
291 /**
292  * Perform a mouse action.
293  */
294 bool
295 FGPanel::doMouseAction (int button, int updown, int x, int y)
296 {
297
298                                 // Note a released button and return
299   // cerr << "Doing mouse action\n";
300   if (updown == 1) {
301     _mouseDown = false;
302     _mouseInstrument = 0;
303     return true;
304   }
305
306                                 // Scale for the real window size.
307   x = int(((float)x / globals->get_options()->get_xsize()) * _winw);
308   y = int(_winh - (((float)y / globals->get_options()->get_ysize())
309                    * _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