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