2 Copyright 2006 Johnathan Corgan.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License version 2
6 as published by the Free Software Foundation.
8 This software is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with GNU Radio; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street,
16 Boston, MA 02110-1301, USA.
19 // Application level includes
24 #include <wx/dcclient.h>
27 // System level includes
30 // Event table for TacticalPanel
31 BEGIN_EVENT_TABLE(TacticalPanel, wxPanel)
32 EVT_PAINT(TacticalPanel::OnPaint)
33 EVT_SIZE(TacticalPanel::OnSize)
36 TacticalPanel::TacticalPanel(wxWindow *parent) :
37 wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
39 m_orientation = TrackUp;
40 m_display_doppler = false;
41 m_display_known = false;
42 m_display_estimated = false;
45 m_doppler_bearing = -1.0;
46 m_estimated_bearing = -1.0;
47 m_actual_bearing = -1.0;
49 SetBackgroundColour(*wxBLACK);
52 void TacticalPanel::OnPaint(wxPaintEvent &event)
58 void TacticalPanel::drawPanel(wxDC &dc)
64 dc.SetPen(wxPen(*wxRED, 2, wxSOLID));
65 dc.SetBrush(wxBrush(*wxBLACK, wxTRANSPARENT));
66 dc.DrawCircle(m_center, m_radius);
68 // Calculate end of doppler bearing line
69 // Doppler bearings are relative and must be adjusted for north up display
70 wxPoint doppler_tip = m_center;
71 if (m_doppler_bearing >= 0.0) {
72 brg = m_doppler_bearing;
73 if (m_orientation == NorthUp) {
78 radians = brg*M_PI/180.0;
79 doppler_tip = wxPoint((int)(m_center.x+sin(radians)*m_radius*0.95),
80 (int)(m_height-(m_center.y+cos(radians)*m_radius*0.95)));
83 // Calculate end of actual bearing line
84 // Actual bearings are absolute and must be adjusted for track up display
85 wxPoint actual_tip = m_center;
86 if (m_actual_bearing >= 0.0) {
87 brg = m_actual_bearing;
88 if (m_orientation == TrackUp) {
93 radians = brg*M_PI/180.0;
94 actual_tip = wxPoint((int)(m_center.x+sin(radians)*m_radius*0.95),
95 (int)(m_height-(m_center.y+cos(radians)*m_radius*0.95)));
98 // Calculate end of estimated bearing line
99 // Estimated bearings are absolute and must be adjusted for track up display
100 wxPoint estimated_tip = m_center;
101 if (m_estimated_bearing >= 0.0) {
102 brg = m_estimated_bearing;
103 if (m_orientation == TrackUp) {
108 radians = brg*M_PI/180.0;
109 estimated_tip = wxPoint((int)(m_center.x+sin(radians)*m_radius*0.95),
110 (int)(m_height-(m_center.y+cos(radians)*m_radius*0.95)));
113 if (m_display_known) {
114 dc.SetPen(wxPen(*wxBLUE, 10, wxSOLID));
115 dc.DrawLine(m_center, actual_tip);
118 if (m_display_estimated) {
119 dc.SetPen(wxPen(*wxWHITE, 10, wxSOLID));
120 dc.DrawLine(m_center, estimated_tip);
123 if (m_display_doppler) {
124 dc.SetPen(wxPen(*wxGREEN, 10, wxSOLID));
125 dc.DrawLine(m_center, doppler_tip);
129 void TacticalPanel::OnSize(wxSizeEvent &event)
131 GetClientSize(&m_width, &m_height);
132 m_center = wxPoint(m_width/2, m_height/2);
134 // Circle at 95% of window size
135 if (m_width > m_height)
136 m_radius = m_height/2;
138 m_radius = m_width/2;
139 m_radius = (int)(m_radius*0.95);