cWidget::BarGauge Class Reference

Processes and renders a bar gauge. More...

#include <cGauges.h>

Inheritance diagram for cWidget::BarGauge:

Inheritance graph
[legend]
Collaboration diagram for cWidget::BarGauge:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~BarGauge ()
void Render ()
 Do- nothing destructor.
virtual bool Process (tXmlParser::node cur)
 Passes on to all Process() functions of the base classes and calls Base::DisplayError() on failure.

Protected Member Functions

virtual void RenderGraph (float min, float max, float val, float factor, tValue::Base const &val_s)
 Renders the Background, bar and current value (if enabled).
virtual void RenderMinMax (tValue::Base const &min_s, tValue::Base const &max_s)
 Renders the minimum and maximum values (if enabled).
virtual void RenderCaption (void)
 Renders the caption (if enabled).


Detailed Description

Processes and renders a bar gauge.

Definition at line 43 of file cGauges.h.


Constructor & Destructor Documentation

virtual cWidget::BarGauge::~BarGauge (  )  [inline, virtual]

Definition at line 45 of file cGauges.h.

00045 { }; 


Member Function Documentation

void cWidget::BarGauge::Render (  )  [virtual]

Do- nothing destructor.

Renders the gauge

Implements cWidget::Base.

Definition at line 85 of file cGauges.cpp.

References vValue::Expr::Core::Base::GetFloat(), vValue::Type::Set::GetMax(), vValue::Type::Set::GetMin(), vValue::Type::Set::GetVal(), cWidget::WithSingleData::m_data, cWidget::WithReverse::m_reverse, max(), RenderCaption(), RenderGraph(), and RenderMinMax().

00085                       {
00086     glDisable(GL_TEXTURE_2D);
00087     //sr_ResetRenderState(0); //needs this because rFont has bugs i presume.. Ie I have problems as soon as rTextFirld is used
00088     // z-man: actually, it is needed because per-frame-tasks get called without rendering context, so it has to be set.
00089 
00090     const tValue::Base &val_s = m_data.GetVal();
00091     const tValue::Base &min_s = m_data.GetMin();
00092     const tValue::Base &max_s = m_data.GetMax();
00093 
00094     float min = min_s.GetFloat();
00095     float max = max_s.GetFloat();
00096     float val = val_s.GetFloat();
00097 
00098     if (val > max) val = max;
00099     if (val < min) val = min;
00100     if (min >= max) return;
00101 
00102     RenderGraph(min, max, val,m_reverse?-1.:1., val_s);
00103 
00104     RenderMinMax(min_s, max_s);
00105     RenderCaption();
00106 
00107     //if (!sr_glOut)
00108     //    return;
00109 
00110     //glColor3f(1,1,1);
00111 }

Here is the call graph for this function:

bool cWidget::BarGauge::Process ( tXmlParser::node  cur  )  [virtual]

Passes on to all Process() functions of the base classes and calls Base::DisplayError() on failure.

Reimplemented from cWidget::WithCoordinates.

Definition at line 37 of file cGauges.cpp.

References cWidget::Base::DisplayError(), cWidget::WithReverse::Process(), cWidget::WithShowSettings::Process(), cWidget::WithCaption::Process(), cWidget::WithCoordinates::Process(), cWidget::WithLineColor::Process(), cWidget::WithForeground::Process(), cWidget::WithBackground::Process(), cWidget::WithSingleData::Process(), and cWidget::WithAngles::Process().

00037                                          {
00038     if (
00039         WithAngles      ::Process(cur) ||
00040         WithSingleData  ::Process(cur) ||
00041         WithBackground  ::Process(cur) ||
00042         WithForeground  ::Process(cur) ||
00043         WithLineColor   ::Process(cur) ||
00044         WithCoordinates ::Process(cur) ||
00045         WithCaption     ::Process(cur) ||
00046         WithShowSettings::Process(cur) ||
00047         WithReverse     ::Process(cur))
00048         return true;
00049     else {
00050         DisplayError(cur);
00051         return false;
00052     }
00053 }

Here is the call graph for this function:

void cWidget::BarGauge::RenderGraph ( float  min,
float  max,
float  val,
float  factor,
tValue::Base const &  val_s 
) [protected, virtual]

Renders the Background, bar and current value (if enabled).

Reimplemented in cWidget::VerticalBarGauge, and cWidget::NeedleGauge.

Definition at line 113 of file cGauges.cpp.

References rGradient::BeginDraw(), BeginLines(), DisplayText(), rGradient::DrawPoint(), rGradient::DrawRect(), vValue::Expr::Core::Base::GetString(), cWidget::WithBackground::m_background, cWidget::WithForeground::m_foreground, cWidget::WithLineColor::m_line_color, cWidget::WithCoordinates::m_position, cWidget::WithShowSettings::m_showvalue, cWidget::WithCoordinates::m_size, RenderEnd(), rGradient::SetGradientEdges(), rGradient::SetValue(), sr_fontCockpit, tCoord::x, x, and tCoord::y.

Referenced by Render().

00113                                                                                                  {
00114     float x= factor * ((val-min)/(max-min)*2. - 1.);
00115     float y= (x+1.)/2.;
00116 
00117     const tCoord edge1(tCoord(m_position.x-m_size.x, m_position.y));
00118     const tCoord edge2(tCoord(m_position.x+m_size.x, m_position.y+m_size.y));
00119 
00120     rGradient &left = (factor < .0) ? m_background : m_foreground;
00121     rGradient &right = (factor < .0) ? m_foreground : m_background;
00122 
00123     left.SetGradientEdges(edge1, edge2);
00124     right.SetGradientEdges(edge1, edge2);
00125     m_line_color.SetGradientEdges(edge1, edge2);
00126 
00127     left.SetValue(y);
00128     right.SetValue(y);
00129     m_line_color.SetValue(y);
00130 
00131     right.DrawRect(
00132         tCoord(m_size.x*x+m_position.x, m_position.y),
00133         tCoord(m_size.x+m_position.x, m_position.y+m_size.y));
00134 
00135     left.DrawRect(
00136         tCoord(m_size.x*x+m_position.x, m_position.y),
00137         tCoord(m_position.x-m_size.x, m_position.y+m_size.y));
00138 
00139     m_line_color.BeginDraw();
00140     BeginLines();
00141     m_line_color.DrawPoint(tCoord(m_size.x*x+m_position.x,m_position.y));
00142     m_line_color.DrawPoint(tCoord(m_size.x*x+m_position.x,m_size.y+m_position.y));
00143     RenderEnd();
00144 
00145     //Value
00146     if(m_showvalue)
00147         DisplayText( m_position.x, m_position.y+.20*m_size.x, .24*m_size.x, (val_s.GetString()).c_str(), sr_fontCockpit);
00148 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cWidget::BarGauge::RenderMinMax ( tValue::Base const &  min_s,
tValue::Base const &  max_s 
) [protected, virtual]

Renders the minimum and maximum values (if enabled).

Definition at line 55 of file cGauges.cpp.

References DisplayText(), cWidget::WithCoordinates::m_position, cWidget::WithReverse::m_reverse, cWidget::WithShowSettings::m_showmax, cWidget::WithShowSettings::m_showmin, cWidget::WithCoordinates::m_size, sr_fontCockpit, tCoord::x, and tCoord::y.

Referenced by Render().

00055                                                                             {
00056     //Max and min
00057     if((m_showmin && !m_reverse) || (m_showmax && m_reverse))
00058         DisplayText(
00059             m_position.x-m_size.x, m_position.y-.15*m_size.x,
00060             .24*m_size.x,
00061             ((m_reverse?max_s:min_s).GetString()).c_str(), sr_fontCockpit);
00062     if((m_showmax && !m_reverse) || (m_showmin && m_reverse))
00063         DisplayText( m_position.x+m_size.x, m_position.y-.15*m_size.x,
00064                      .24*m_size.x,
00065                      ((m_reverse?min_s:max_s).GetString()).c_str(), sr_fontCockpit);
00066 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cWidget::BarGauge::RenderCaption ( void   )  [protected, virtual]

Renders the caption (if enabled).

Reimplemented in cWidget::VerticalBarGauge.

Definition at line 68 of file cGauges.cpp.

References DisplayText(), cWidget::WithCaption::m_caption, cWidget::WithCaption::m_captionloc, cWidget::WithCoordinates::m_position, cWidget::WithCoordinates::m_size, cWidget::WithCaption::off, sr_fontCockpit, cWidget::WithCaption::top, tCoord::x, and tCoord::y.

Referenced by Render().

00068                                  {
00069     if ( m_captionloc != off ) {
00070         const float y=(m_captionloc==top ? m_position.y+m_size.y+.2*m_size.x : m_position.y-.15*m_size.x);
00071         DisplayText(m_position.x,y,.24*m_size.x,m_caption.c_str(),sr_fontCockpit);
00072     }
00073 }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:03:40 2008 for Armagetron Advanced by  doxygen 1.5.4