Debian Codegraph @

utils/fgpanel/FGLayeredInstrument.cxx

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2000 David Megginson
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "GL_utils.hxx"
5 #include "FGLayeredInstrument.hxx"
6 #include "FGTexturedLayer.hxx"
7
8 FGLayeredInstrument::FGLayeredInstrument (const int x, const int y, const int w, const int h) :
9 FGPanelInstrument (x, y, w, h) {
10 }
11
12 FGLayeredInstrument::~FGLayeredInstrument () {
13 for (layer_list::iterator it = m_layers.begin();
14 it != m_layers.end();
15 ++it) {
16 delete *it;
17 *it = 0;
18 }
19 }
20
21 void
22 FGLayeredInstrument::draw () {
23 if (test ()) {
24 for (unsigned int i = 0; i < m_layers.size (); ++i) {
25 GL_utils::instance ().glPushMatrix ();
26 m_layers[i]->draw ();
27 GL_utils::instance ().glPopMatrix ();
28 }
29 }
30 }
31
32 int
33 FGLayeredInstrument::addLayer (FGInstrumentLayer * const layer) {
34 const int n (m_layers.size ());
35 if (layer->getWidth () == -1) {
36 layer->setWidth (getWidth ());
37 }
38 if (layer->getHeight () == -1) {
39 layer->setHeight (getHeight ());
40 }
41 m_layers.push_back (layer);
42 return n;
43 }
44
45 int
46 FGLayeredInstrument::addLayer (const FGCroppedTexture_ptr texture, const int w, const int h) {
47 return addLayer (new FGTexturedLayer (texture, w, h));
48 }
49
50 void
51 FGLayeredInstrument::addTransformation (FGPanelTransformation * const transformation) {
52 const int layer (m_layers.size () - 1);
53 m_layers[layer]->addTransformation (transformation);
54 }