All Classes Functions
DirectAscentPage.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 // DirectAscentPage.h - data input and output for and from direct ascent algorithm
17 // Authors - Szymon "Enjo" Ender
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 #pragma once
43 
44 #include "../globals.h"
45 #include "../MFDPage.h"
46 #include "../Types.hpp"
47 #include "../localisation.h"
48 #include "../../lib/Visual/Canvas.hpp"
49 #include "../../lib/PID/PID.hpp"
50 #include "../Pens.h"
51 #include "Systems/RectangleMy.hpp"
52 #include "DirectAscent.h"
53 #include "DirectAscentResults.hpp"
54 #include <vector>
55 #include <string>
56 #include <sstream>
57 
58 
59 class MFDDataLaunchMFD;
60 
61 class DirectAscentPage : public MFDPage, public DirectAscent, public Canvas
62 {
63 
64 public:
65  DirectAscentPage(DWORD w, DWORD h, VESSEL *v);
66  virtual ~DirectAscentPage();
67  #ifdef ORB2006
68  void
69  #else
70  bool
71  #endif
72  Update ( MyDC hDC );
73  bool Reset();
74 
75  void ScheduleForCalculation();
76  void SetTargetString(char * cTgt);
77  void InnerLoop();
78  void SetMFDData( MFDDataLaunchMFD * data );
79 
80  // Canvas
81  Point GetWindowSize() const;
82  RectangleMy GetDataSize() const;
83  RectangleMy GetDataToDisplaySize() const;
84 
85 protected:
86  // Direct ascent
87  bool InitInternalVars();
88  double GetShipsInitialAcceleration();
89 
90  // Canvas
91  void RefreshClient();
92  void ScaleData();
93 
94 
95 private:
96 
97  void Center( bool reset );
98  void Zoom();
99  void UpdateZoom(double diffT);
100 
101  void SetLineStyle(MyDC hDC, Pens::LineStyle lineStyle );
102  void DrawInnerLoop(MyDC hDC);
103  void DrawError(MyDC hDC);
104  void PrintWords(MyDC hDC);
105  void DrawTrajectory(MyDC hDC, const std::vector <Point> & trajectory, Pens::LineStyle lineStyle, double diffFromRotation = 0);
106 
107  Pens pens;
108 
109  void InitWords();
110 
111  DirectAscentResults CalculateDirectAscent();
112 
113  void ScalePath();
114  void ScaleGC( bool bSatOnly = true);
115  void InitOutputVars();
116  double CalcAngSatEqu( VESSEL * target );
117 
118  double GetDiffTime();
119 
120  double m_zoomTarget;
121  Point m_refSystemTarget;
122  std::string sTgt;
123 
124  bool m_bScheduledForCalculation;
125 
126  std::vector <Point> vs;
127  std::vector <Point> vsRec;
128  std::vector <Point> vGCsatScaled; // sat's path (great circle)
129  std::vector <Point> vGCshScaled; // ship's path (great circle)
130  std::vector <Point> vGCshStartScaled; // ship's starting path (great circle)
131 
132  bool alreadyMoved;
133  double needed_east_v_at_this_alt;
134  MFDDataLaunchMFD * m_data;
135  double diffXFromRotation;
136  PID m_pidZoom, m_pidCoordSystem;
137 
138  std::vector<std::string> vs_output_da, vs_vars_da;
139 };