Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ProfileDlg.h
1 //
2 // Name: ProfileDlg.h
3 //
4 // Copyright (c) 2004-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef __ProfileDlg_H__
9 #define __ProfileDlg_H__
10 
11 #ifndef WX_PRECOMP
12  #include "wx/wx.h"
13 #endif
14 
15 #include "vtui_UI.h"
16 #include "AutoDialog.h"
17 #include "vtdata/HeightField.h"
18 
20 {
21 public:
22  virtual void Begin() {}
23  virtual float GetElevation(const DPoint2 &p) = 0;
24  virtual float GetCultureHeight(const DPoint2 &p) = 0;
25  virtual bool HasCulture() { return false; }
26 };
27 
28 // WDR: class declarations
29 
30 //----------------------------------------------------------------------------
31 // ProfileDlg
32 //----------------------------------------------------------------------------
33 
35 {
36 public:
37  // constructors and destructors
38  ProfileDlg( wxWindow *parent, wxWindowID id,
39  const wxString& title,
40  const wxPoint& pos = wxDefaultPosition,
41  const wxSize& size = wxDefaultSize,
42  long style = wxDEFAULT_DIALOG_STYLE );
43 
44  // WDR: method declarations for ProfileDlg
45  wxTextCtrl* GetRF() { return (wxTextCtrl*) FindWindow( ID_RF ); }
46  wxChoice* GetCurvature() { return (wxChoice*) FindWindow( ID_CURVATURE ); }
47  wxCheckBox* GetFresnel() { return (wxCheckBox*) FindWindow( ID_FRESNEL ); }
48  wxCheckBox* GetEffective() { return (wxCheckBox*) FindWindow( ID_USE_EFFECTIVE ); }
49  wxTextCtrl* GetHeight2() { return (wxTextCtrl*) FindWindow( ID_HEIGHT2 ); }
50  wxTextCtrl* GetHeight1() { return (wxTextCtrl*) FindWindow( ID_HEIGHT1 ); }
51  wxTextCtrl* GetText() { return (wxTextCtrl*) FindWindow( ID_STATUS_TEXT ); }
52  wxCheckBox* GetLineOfSight() { return (wxCheckBox*) FindWindow( ID_LINE_OF_SIGHT ); }
53  wxCheckBox* GetVisibility() { return (wxCheckBox*) FindWindow( ID_VISIBILITY ); }
54  wxButton* GetShowCulture() { return (wxButton*) FindWindow( ID_SHOW_CULTURE ); }
55 
56  void MakePoint(wxPoint &p, int i, float value);
57  void DrawChart(wxDC& dc);
58  void UpdateMessageText();
59  void UpdateEnabling();
60 
61  void SetProjection(const vtProjection &proj);
62  void SetPath(const DLine2 &path);
63  void SetPoints(const DPoint2 &p1, const DPoint2 &p2);
64  void SetCallback(ProfileCallback *callback);
65 
66  void GetValues();
67  void Analyze();
68  void ComputeLineOfSight();
69  void ComputeVisibility();
70  float ComputeFresnelRadius(float dist, float freq, int zone);
71  void ComputeFirstFresnel();
72  void ComputeGeoidSurface();
73  float ApplyGeoid(float h, int i, char t);
74  void ComputeSignalLoss(float dist, float freq);
75  float TotalHeightAt(int i);
76 
77  void WriteProfileToDXF(const char *filename);
78  void WriteTraceToDXF(const char *filename);
79  void WriteProfileToCSV(const char *filename);
80 
81 private:
82  // WDR: member variable declarations for ProfileDlg
83  ProfileCallback *m_callback;
84  std::vector<float> m_values;
85  std::vector<float> m_values_culture;
86  std::vector<bool> m_visible;
87  vtProjection m_proj;
88  DPoint2 m_p1, m_p2;
89  DLine2 m_path;
90  wxSize m_clientsize;
91  int m_xrange, m_yrange;
92  float m_fMin, m_fMax;
93  float m_fMinDist, m_fMaxDist, m_fTotalDist;
94  float m_fDrawMin, m_fDrawMax, m_fDrawRange;
95  bool m_bHavePoints, m_bHavePath, m_bHaveValues;
96  bool m_bHaveValidData, m_bHaveInvalid;
97  bool m_bMouseOnLine;
98  float m_fMouse, m_fMouseDist;
99  int m_iMin, m_iMax, m_iMouse;
100  wxPoint m_base;
101  bool m_bHaveSlope;
102  float m_fSlope;
103  bool m_bLeftButton;
104  bool m_bValidStart, m_bValidLine;
105  float m_fHeightAtStart, m_fHeightAtEnd;
106  bool m_bIntersectsGround;
107  bool m_bIntersectsCulture;
108  float m_fIntersectHeight;
109  float m_fIntersectDistance;
110  int m_iIntersectIndex;
111 
112  float m_fGeodesicDistance;
113  bool m_bHaveFresnel;
114  bool m_bHaveLOS;
115  bool m_bHaveGeoidSurface;
116  std::vector<float> m_FirstFresnel;
117  std::vector<float> m_LineOfSight;
118  std::vector<float> m_GeoidSurface;
119  std::vector<bool> m_rvisible;
120  float m_fGeoidCurvature;
121  float m_fMouseFresnel;
122  float m_fMouseLOS;
123  std::vector<double> m_fGeoDistAtPoint;
124 
125  // these values are exposed directly in the GUI
126  float m_fHeight1, m_fHeight2;
127  float m_fRadioFrequency;
128  int m_iCurvature; // 0=none, 1=terrain, 2=line of sight
129  bool m_bGetCulture;
130  bool m_bHaveCulture;
131 
132  // these values are retreived as needed from the GUI
133  bool m_bLineOfSight, m_bVisibility;
134  bool m_bUseFresnel, m_bUseEffectiveRadius;
135 
136  DPoint2 m_DrawOrg, m_DrawScale;
137  void MakePoint(FPoint2 &p, int i, float value);
138  void MakePoint(const DPoint2 &p_in, DPoint2 &p_out);
139  void DrawProfileToDXF(FILE *fp);
140  void DrawTraceToDXF(FILE *fp);
141 
142 private:
143  // WDR: handler declarations for ProfileDlg
144  void OnExportCSV( wxCommandEvent &event );
145  void OnExportTrace( wxCommandEvent &event );
146  void OnExportDXF( wxCommandEvent &event );
147  void OnCurvature( wxCommandEvent &event );
148  void OnRF( wxCommandEvent &event );
149  void OnUseEffective( wxCommandEvent &event );
150  void OnFresnel( wxCommandEvent &event );
151  void OnHeight2( wxCommandEvent &event );
152  void OnHeight1( wxCommandEvent &event );
153  void OnLineOfSight( wxCommandEvent &event );
154  void OnShowCulture( wxCommandEvent &event );
155  void OnVisibility( wxCommandEvent &event );
156  void OnPaint(wxPaintEvent &event);
157  void OnDraw(wxDC& dc); // overridden to draw this view
158  void OnSize(wxSizeEvent& event);
159  void OnLeftDown(wxMouseEvent& event);
160  void OnLeftUp(wxMouseEvent& event);
161  void OnMouseMove(wxMouseEvent& event);
162 
163 private:
164  DECLARE_EVENT_TABLE()
165 };
166 
167 #endif // __ProfileDlg_H__
168