All Classes Functions
GreatCircle.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 // GreatCircle - Calculates and draws great circles, Map MFD-style
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 #ifndef GREATCIRCLE_H
43 #define GREATCIRCLE_H
44 
45 #include "Visual/Canvas.hpp"
46 #include "Pens.h"
47 
48 namespace EnjoLib
49 {
50 struct Point;
51 }
52 
53 struct BODYPHYS;
54 class MFDDataLaunchMFD;
55 
56 class GreatCircle : public EnjoLib::Canvas
57 {
58  public:
59  GreatCircle();
60  virtual ~GreatCircle();
61 
62  virtual void Update( MyDC hDC, int W, int H, MFDDataLaunchMFD * data );
63  void SwitchTrack();
64  void SwitchUse();
65  virtual void ZoomIn();
66  virtual void ZoomOut();
67  void SignalPlanetChange( const BODYPHYS & bodyPhys );
68  void IncreasePlotPrecision();
69  void DecreasePlotPrecision();
70  void SetPlotPrecision( double step );
71  double GetPlotPrecision() const;
72 
73  bool m_continuous;
74 
75  protected:
76  // Canvas
77  void RefreshClient();
78  void ScaleData();
79  bool IsSymmetricAround00() const;
80  EnjoLib::Point GetWindowSize() const;
81  EnjoLib::RectangleMy GetDataSize() const;
82  EnjoLib::RectangleMy GetDataToDisplaySize() const;
83  double GetMinAllowedZoom( double proposedZoom ) const;
84  virtual void AutoZoomVirtual();
85 
86  const double m_zoomMultipler;
87  bool m_track;
88 
89 
90  private:
91  void DrawCrosses(MyDC hDC, const EnjoLib::Point & pos, Pens::LineStyle lineStyle );
92  void DrawCross(MyDC hDC, const EnjoLib::Point & pos );
93  void DrawPoint(MyDC hDC, const EnjoLib::Point & pos );
94  void DrawLine(MyDC hDC, const EnjoLib::Point & pos1, const EnjoLib::Point & pos2 );
95  void DrawVessel( MyDC hDC, const VESSEL * v, Pens::LineStyle lineStyle );
96  void DrawTrajectory(MyDC hDC, const std::vector <EnjoLib::Point> & trajectory, Pens::LineStyle lineStyle );
97 
98  Pens m_pens;
99  double m_bodyRad;
100  static double m_plotStep;
101  static double m_plotStepMin, m_plotStepMax;
102 
103 
104  bool m_use;
105  int m_W, m_H;
106 };
107 
108 #endif // GREATCIRCLE_H