]> git.mxchange.org Git - flightgear.git/blob - Cockpit/hud_scal.cxx
C++ ifying ...
[flightgear.git] / Cockpit / hud_scal.cxx
1 #ifdef HAVE_CONFIG_H
2 #  include <config.h>
3 #endif
4
5 #ifdef HAVE_WINDOWS_H
6 #  include <windows.h>
7 #endif
8 #include <stdlib.h>
9 #include <string.h>
10 #include <Aircraft/aircraft.hxx>
11 #include <Debug/fg_debug.h>
12 #include <Include/fg_constants.h>
13 #include <Math/fg_random.h>
14 #include <Math/mat3.h>
15 #include <Math/polar3d.hxx>
16 #include <Scenery/scenery.hxx>
17 #include <Time/fg_timer.hxx>
18
19
20 #include "hud.hxx"
21 //============== Top of instr_scale class memeber definitions ===============
22 //
23 // Notes:
24 // 1. instr_scales divide the specified location into half and then
25 //    the half opposite the read direction in half again. A bar is
26 //    then drawn along the second divider. Scale ticks are drawn
27 //    between the middle and quarter section lines (minor division
28 //    markers) or just over the middle line.
29 //
30 // 2.  This class was not intended to be instanciated. See moving_scale
31 //     and guage_instr classes.
32 //============================================================================
33 instr_scale ::
34 instr_scale ( int       x,
35               int       y,
36               UINT      width,
37               UINT      height,
38               DBLFNPTR  load_fn,
39               UINT      options,
40               double    show_range,
41               double    maxValue,
42               double    minValue,
43               double    disp_scale,
44               UINT      major_divs,
45               UINT      minor_divs,
46               UINT      rollover,
47               int       dp_showing,
48               bool      working ) :
49                 instr_item( x, y, width, height,
50                             load_fn, disp_scale, options, working),
51                 range_shown  ( show_range ),
52                 Maximum_value( maxValue   ),
53                 Minimum_value( minValue   ),
54                 Maj_div      ( major_divs ),
55                 Min_div      ( minor_divs ),
56                 Modulo       ( rollover   ),
57                 signif_digits( dp_showing )
58 {
59 int temp;
60
61   scale_factor   = (double)get_span() / range_shown;
62   if( show_range < 0 ) {
63     range_shown = -range_shown;
64     }
65   temp = (Maximum_value - Minimum_value) / 100;
66   if( range_shown < temp ) {
67     range_shown = temp;
68     }
69 }
70
71 instr_scale ::
72   instr_scale( const instr_scale & image ) :
73             instr_item( (const instr_item &) image),
74             range_shown  ( image.range_shown   ),
75             Maximum_value( image.Maximum_value ),
76             Minimum_value( image.Minimum_value ),
77             scale_factor ( image.scale_factor  ),
78             Maj_div      ( image.Maj_div       ),
79             Min_div      ( image.Min_div       ),
80             Modulo       ( image.Modulo        ),
81             signif_digits( image.signif_digits )
82 {
83 }
84
85 instr_scale & instr_scale :: operator = (const instr_scale & rhs )
86 {
87   if( !(this == &rhs)) {
88     instr_item::operator = (rhs);
89     range_shown   = rhs.range_shown;
90     scale_factor  = rhs.scale_factor;
91     Maximum_value = rhs.Maximum_value;
92     Minimum_value = rhs.Minimum_value;
93     Maj_div       = rhs.Maj_div;
94     Min_div       = rhs.Min_div;
95     Modulo        = rhs.Modulo;
96     signif_digits = rhs.signif_digits;
97     }
98   return *this;
99 }
100
101 instr_scale :: ~ instr_scale () {}
102