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