Patch from Martin Dressler:
This patch moves built-in Class (for now only mag-ribbon) into special directory as you have written it in TODO: in comments of this class in panel_io.cxx. IMHO it is good idea. I want to play with built-in classes and OpenGC and this will be useful.
This commit is contained in:
parent
6e5d22789b
commit
396674ce2e
8 changed files with 136 additions and 64 deletions
|
@ -10,10 +10,13 @@ libCockpit_a_SOURCES = \
|
|||
panel.cxx panel.hxx \
|
||||
panel_io.cxx panel_io.hxx \
|
||||
radiostack.cxx radiostack.hxx \
|
||||
steam.cxx steam.hxx
|
||||
steam.cxx steam.hxx \
|
||||
libBuilt_in.a
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
endif
|
||||
|
||||
SUBDIRS = built_in
|
||||
|
|
3
src/Cockpit/built_in/.cvsignore
Normal file
3
src/Cockpit/built_in/.cvsignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
71
src/Cockpit/built_in/FGMagRibbon.cxx
Normal file
71
src/Cockpit/built_in/FGMagRibbon.cxx
Normal file
|
@ -0,0 +1,71 @@
|
|||
// FGMagRibbon.cxx - Built-in layer for the magnetic compass ribbon layer.
|
||||
//
|
||||
// Written by David Megginson, started January 2000.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#include "FGMagRibbon.hxx"
|
||||
#include "../steam.hxx"
|
||||
|
||||
|
||||
FGMagRibbon::FGMagRibbon (int w, int h)
|
||||
: FGTexturedLayer(w, h)
|
||||
{
|
||||
FGCroppedTexture texture("Aircraft/Instruments/Textures/compass-ribbon.rgb");
|
||||
setTexture(texture);
|
||||
}
|
||||
|
||||
void
|
||||
FGMagRibbon::draw ()
|
||||
{
|
||||
double heading = FGSteam::get_MH_deg();
|
||||
double xoffset, yoffset;
|
||||
|
||||
while (heading >= 360.0) {
|
||||
heading -= 360.0;
|
||||
}
|
||||
while (heading < 0.0) {
|
||||
heading += 360.0;
|
||||
}
|
||||
|
||||
if (heading >= 60.0 && heading <= 180.0) {
|
||||
xoffset = heading / 240.0;
|
||||
yoffset = 0.75;
|
||||
} else if (heading >= 150.0 && heading <= 270.0) {
|
||||
xoffset = (heading - 90.0) / 240.0;
|
||||
yoffset = 0.50;
|
||||
} else if (heading >= 240.0 && heading <= 360.0) {
|
||||
xoffset = (heading - 180.0) / 240.0;
|
||||
yoffset = 0.25;
|
||||
} else {
|
||||
if (heading < 270.0)
|
||||
heading += 360.0;
|
||||
xoffset = (heading - 270.0) / 240.0;
|
||||
yoffset = 0.0;
|
||||
}
|
||||
|
||||
xoffset = 1.0 - xoffset;
|
||||
// Adjust to put the number in the centre
|
||||
xoffset -= 0.25;
|
||||
|
||||
FGCroppedTexture &t = getTexture();
|
||||
t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
|
||||
FGTexturedLayer::draw();
|
||||
}
|
||||
|
||||
// end of FGMagRibbon.cxx
|
41
src/Cockpit/built_in/FGMagRibbon.hxx
Normal file
41
src/Cockpit/built_in/FGMagRibbon.hxx
Normal file
|
@ -0,0 +1,41 @@
|
|||
// FGMagRibbon.hxx - Built-in layer for the magnetic compass ribbon layer.
|
||||
//
|
||||
// Written by David Megginson, started January 2000.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#ifndef __FG_MAG_RIBBON_HXX
|
||||
#define __FG_MAG_RIBBON_HXX
|
||||
|
||||
#include "../panel.hxx"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Built-in layer for the magnetic compass ribbon layer.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FGMagRibbon : public FGTexturedLayer
|
||||
{
|
||||
public:
|
||||
FGMagRibbon (int w, int h);
|
||||
virtual ~FGMagRibbon () {}
|
||||
|
||||
virtual void draw ();
|
||||
};
|
||||
|
||||
#endif // __FG_MAG_RIBBON_HXX
|
||||
|
||||
// end of FGMagRibbon.hxx
|
11
src/Cockpit/built_in/Makefile.am
Normal file
11
src/Cockpit/built_in/Makefile.am
Normal file
|
@ -0,0 +1,11 @@
|
|||
noinst_LIBRARIES = libBuilt_in.a
|
||||
|
||||
libBuilt_in_a_SOURCES = \
|
||||
FGMagRibbon.cxx FGMagRibbon.hxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
endif
|
||||
|
2
src/Cockpit/built_in/README
Normal file
2
src/Cockpit/built_in/README
Normal file
|
@ -0,0 +1,2 @@
|
|||
This is special directory for built-in
|
||||
layers of various sorts.
|
|
@ -48,6 +48,9 @@
|
|||
#include "steam.hxx"
|
||||
#include "panel_io.hxx"
|
||||
|
||||
//built-in layers
|
||||
#include "built_in/FGMagRibbon.hxx"
|
||||
|
||||
#if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(istream);
|
||||
SG_USING_STD(ifstream);
|
||||
|
@ -55,69 +58,6 @@ SG_USING_STD(ifstream);
|
|||
SG_USING_STD(string);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Built-in layer for the magnetic compass ribbon layer.
|
||||
//
|
||||
// TODO: move this out into a special directory for built-in
|
||||
// layers of various sorts.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FGMagRibbon : public FGTexturedLayer
|
||||
{
|
||||
public:
|
||||
FGMagRibbon (int w, int h);
|
||||
virtual ~FGMagRibbon () {}
|
||||
|
||||
virtual void draw ();
|
||||
};
|
||||
|
||||
FGMagRibbon::FGMagRibbon (int w, int h)
|
||||
: FGTexturedLayer(w, h)
|
||||
{
|
||||
FGCroppedTexture texture("Aircraft/Instruments/Textures/compass-ribbon.rgb");
|
||||
setTexture(texture);
|
||||
}
|
||||
|
||||
void
|
||||
FGMagRibbon::draw ()
|
||||
{
|
||||
double heading = FGSteam::get_MH_deg();
|
||||
double xoffset, yoffset;
|
||||
|
||||
while (heading >= 360.0) {
|
||||
heading -= 360.0;
|
||||
}
|
||||
while (heading < 0.0) {
|
||||
heading += 360.0;
|
||||
}
|
||||
|
||||
if (heading >= 60.0 && heading <= 180.0) {
|
||||
xoffset = heading / 240.0;
|
||||
yoffset = 0.75;
|
||||
} else if (heading >= 150.0 && heading <= 270.0) {
|
||||
xoffset = (heading - 90.0) / 240.0;
|
||||
yoffset = 0.50;
|
||||
} else if (heading >= 240.0 && heading <= 360.0) {
|
||||
xoffset = (heading - 180.0) / 240.0;
|
||||
yoffset = 0.25;
|
||||
} else {
|
||||
if (heading < 270.0)
|
||||
heading += 360.0;
|
||||
xoffset = (heading - 270.0) / 240.0;
|
||||
yoffset = 0.0;
|
||||
}
|
||||
|
||||
xoffset = 1.0 - xoffset;
|
||||
// Adjust to put the number in the centre
|
||||
xoffset -= 0.25;
|
||||
|
||||
FGCroppedTexture &t = getTexture();
|
||||
t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
|
||||
FGTexturedLayer::draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Read and construct a panel.
|
||||
|
|
|
@ -58,6 +58,7 @@ fgfs_LDADD = \
|
|||
$(top_builddir)/src/ATC/libATC.a \
|
||||
$(top_builddir)/src/Autopilot/libAutopilot.a \
|
||||
$(top_builddir)/src/Cockpit/libCockpit.a \
|
||||
$(top_builddir)/src/Cockpit/built_in/libBuilt_in.a \
|
||||
$(top_builddir)/src/Controls/libControls.a \
|
||||
$(top_builddir)/src/FDM/libFlight.a \
|
||||
$(top_builddir)/src/FDM/Balloon/libBalloon.a \
|
||||
|
|
Loading…
Add table
Reference in a new issue