All Classes Functions
LaunchMFD.h
1 // ==============================================================
2 // ORBITER MODULE: LaunchMFD
3 // Part of the ORBITER SDK
4 //
5 // Copyright (C) 2004 rjcroy - robust time based pitch autopilot (borrowed code)
6 // Copyright (C) 2004 Dave "Daver" Rowbotham - conversion of rjcroy's autopolot to C++ (borrowed code)
7 // Copyright (C) 2004 Erik H. "Sputnik" Anderson - conversion of the autopilot to energy based (borrowed code)
8 // Copyright (C) 2007 "Vanguard" - dressing up azimuth calcualtions into an MFD (author)
9 // Copyright (C) 2007 Pawel "She'da'Lier" Stiasny - yaw error visual representation (contributor)
10 // Copyright (C) 2008 Mohd "Computerex" Ali - borrowed his code (multiple vessels support) (borrowed code)
11 // Copyright (C) 2008 Chris "Kwan" Jeppesen - borrowed his code (peg guidance) (borrowed code)
12 // Copyright (C) 2008 Steve "agentgonzo" Arch - peg integration, offplane correction, compass, hud display (co-developer)
13 // Copyright (C) 2007-2012 Szymon "Enjo" Ender - everything else ;> (author and maintainer)
14 // All rights reserved
15 //
16 // LaunchMFD.h - Main MFD class
17 // Authors - "Vanguard", Szymon "Enjo" Ender, Steve "agentgonzo" Arch
18 //
19 // This module calculates the appropriate launch azimuth given
20 // desired orbital inclination and desired orbit altitude. This
21 // MFD takes the planets rotation into account, which provides a
22 // much more accurate azimuth. The calculations are performed
23 // 'on the fly' (technically and methaphorically), meaning that
24 // you get info about necessary course corrections.
25 //
26 // This file is part of LaunchMFD.
27 //
28 // LaunchMFD is free software: you can redistribute it and/or modify
29 // it under the terms of the GNU General Public License as published by
30 // the Free Software Foundation, either version 3 of the License, or
31 // (at your option) any later version.
32 //
33 // LaunchMFD is distributed in the hope that it will be useful,
34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 // GNU General Public License for more details.
37 //
38 // You should have received a copy of the GNU General Public License
39 // along with LaunchMFD. If not, see <http://www.gnu.org/licenses/>.
40 // ==============================================================
41 
42 
43 #ifndef __LAUNCHMFD_H
44 #define __LAUNCHMFD_H
45 
46 #include <orbitersdk.h>
47 
48 #include "LaunchCompass.h"
49 #include "DirectAscentPage.hpp"
50 #include "globals.h"
51 #include "Pens.h"
52 #include "MFDHUDDrawer/IMFDDrawsHUD.hpp"
53 
54 #include <vector>
55 #include <string>
56 #include <sstream>
57 
58 class MFDDataLaunchMFD;
60 class PluginLaunchMFD;
61 
62 namespace EnjoLib
63 {
64  namespace MFDGoodies
65  {
66  class Sound;
67  }
68 }
69 
71 
77 class LaunchMFD: public MY_MFD, public EnjoLib::MFDGoodies::IMFDDrawsHUD
78 {
79 public:
81 
88  LaunchMFD (DWORD w, DWORD h, VESSEL * vessel, PluginLaunchMFD * plugin );
89 
91  ~LaunchMFD ();
92  char *ButtonLabel (int bt);
93  int ButtonMenu (const MFDBUTTONMENU **menu) const;
94 
95  MFD_RETURN_TYPE Update ( MyDC myDC );
96 
97  bool ConsumeKeyBuffered(DWORD key);
98  bool ConsumeKeyImmediate(char * kstate );
99  bool ConsumeButton (int bt, int event);
100 
101 
103 
105  EnjoLib::MFDGoodies::Sound & GetSound();
106 
108 
111  const MFDDataLaunchMFD * GetData() const;
112 
113  void WriteStatus (FILEHANDLE scn) const;
114  void ReadStatus (FILEHANDLE scn);
115 
116  bool ShouldDrawHUD() const;
117  void DrawHUD(int mode, const HUDPAINTSPEC *hps, MyDC hDC);
118  static int MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam);
119 
120  void SwitchButtonsPage();
121  void SwitchMode();
122  void SwitchAutopilot();
123  void SwitchPitchGuidance();
124  void SwitchOffplaneCorrection();
125  void SwitchAzimuth();
126  void SwitchGreatCircleUse();
127  void SwitchGreatCircleTrack();
128  void SwitchGreatCircleLines();
129  void SwitchHUD();
130  void SwitchSound();
131  void GreatCircleZoomIn();
132  void GreatCircleZoomOut();
133  void GreatCircleIncreasePlotPrecision();
134  void GreatCircleDecreasePlotPrecision();
135  void IncreaseInclination();
136  void DecreaseInclination();
137  void IncreaseInclinationFactor();
138  void DecreaseInclinationFactor();
139  void DefaultAction();
140  void OpenDialogTarget();
141  void OpenDialogAltitude();
142  void OpenDialogPIDXY();
143  void OpenDialogPIDBank();
144  void DoNothing();
145 
146 protected:
147 
148 private:
149 
150  void SetError();
151  void CheckErrorExcess();
152  void ReactOnShipStatus();
153 
154 
155  void DrawErrorAndMarks(MyDC hDC, const int status);
156  void PrintResults(MyDC hDC);
157  void PrintTargetParamsForAzimuthMode(MyDC hDC);
158  void ReactOnReachingOrbit(MyDC hDC);
159 
160 
161  double az, az_desc, error, heading, pitchError;
162 
163  LaunchCompass compass;
164  DirectAscentPage daAtmo;
165 
167 
168  MFDDataLaunchMFD * m_data;
169 
171 
172  EnjoLib::MFDGoodies::Sound & m_sound;
173  const MFDButtonPageLaunchMFD & m_buttonPages;
174  bool m_beep;
175  const static double MAX_ERROR;
176 
177  Pens m_pens;
178 };
179 
180 #endif // !__LAUNCHMFD_H