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