OpenCPN Partial API docs
Loading...
Searching...
No Matches
piano.h
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Chart Bar Window
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 ***************************************************************************
25 */
26
27#ifndef __statwin_H__
28#define __statwin_H__
29
30//----------------------------------------------------------------------------
31// constants
32//----------------------------------------------------------------------------
33
34#define PIANO_EVENT_TIMER 73566
35#define DEFERRED_KEY_CLICK_DOWN 1
36#define DEFERRED_KEY_CLICK_UP 2
37#define INFOWIN_TIMEOUT 3
38
39// Class declarations
40WX_DECLARE_OBJARRAY(wxRect, RectArray);
41
42class MyFrame;
43class ChartCanvas;
44
45enum { PIANO_MODE_COMPOSITE = 0, PIANO_MODE_LEGACY };
46
47//----------------------------------------------------------------------------
48// PianoKeyElement
49//----------------------------------------------------------------------------
51public:
52 PianoKeyElement() {};
55
56 int chart_scale;
57 ChartTypeEnum chart_type;
58 ChartFamilyEnum chart_family;
59 std::vector<int> dbindex_list;
60};
61
62//----------------------------------------------------------------------------
63// Piano
64//----------------------------------------------------------------------------
65class Piano : public wxEvtHandler {
66public:
67 Piano(ChartCanvas *parent);
68 ~Piano();
69
70 void Paint(int y, wxDC &dc, wxDC *shapeDC = NULL);
71 void Paint(int y, ocpnDC &dc, wxDC *shapeDC = NULL);
72 void DrawGL(int y);
73 void FormatKeys(void);
74 bool MouseEvent(wxMouseEvent &event);
75 void SetColorScheme(ColorScheme cs);
76 void SetKeyArray(std::vector<int> &center_array,
77 std::vector<int> &full_array);
78 void SetActiveKey(int iactive) { m_iactive = iactive; }
79 void SetActiveKeyArray(std::vector<int> array);
80 void SetNoshowIndexArray(std::vector<int> array);
81 void AddNoshowIndexArray(std::vector<int> array);
82 void SetEclipsedIndexArray(std::vector<int> array);
83 void SetSkewIndexArray(std::vector<int> array);
84 void SetTmercIndexArray(std::vector<int> array);
85 void SetPolyIndexArray(std::vector<int> array);
86 int GetPianoMode() { return m_piano_mode; }
87
88 std::vector<int> GetActiveKeyArray() { return m_active_index_array; }
89
90 void SetVizIcon(wxBitmap *picon_bmp) {
91 if (m_pVizIconBmp) delete m_pVizIconBmp;
92 m_pVizIconBmp = picon_bmp;
93 }
94 void SetInVizIcon(wxBitmap *picon_bmp) {
95 if (m_pInVizIconBmp) delete m_pInVizIconBmp;
96 m_pInVizIconBmp = picon_bmp;
97 }
98 void SetSkewIcon(wxBitmap *picon_bmp) {
99 if (m_pSkewIconBmp) delete m_pSkewIconBmp;
100 m_pSkewIconBmp = picon_bmp;
101 }
102 void SetTMercIcon(wxBitmap *picon_bmp) {
103 if (m_pTmercIconBmp) delete m_pTmercIconBmp;
104 m_pTmercIconBmp = picon_bmp;
105 }
106 void SetPolyIcon(wxBitmap *picon_bmp) {
107 if (m_pPolyIconBmp) delete m_pPolyIconBmp;
108 m_pPolyIconBmp = picon_bmp;
109 }
110 void ShowBusy(bool busy);
111 void onTimerEvent(wxTimerEvent &event);
112
113 wxPoint GetKeyOrigin(int key_index);
114 void ResetRollover(void);
115 void SetRoundedRectangles(bool val) {
116 m_brounded = val;
117 m_hash.Clear();
118 }
119
120 int GetHeight();
121 int GetWidth();
122
123 wxString &GenerateAndStoreNewHash();
124 wxString &GetStoredHash();
125
126 int GetnKeys() { return m_nRegions; }
127
128private:
129 void SetPianoMode(int new_mode) { m_piano_mode = new_mode; }
130
131 void DrawGLSL(int y);
132 void BuildGLTexture();
133 bool InArray(std::vector<int> &array, int key);
134 bool IsAnyActiveChartInPianoKeyElement(PianoKeyElement &pke);
135 bool IsAllEclipsedChartInPianoKeyElement(PianoKeyElement &pke);
136
137 wxString GetStateHash();
138 wxString m_hash;
139
140 ChartCanvas *m_parentCanvas;
141 int m_piano_mode;
142
143 std::vector<PianoKeyElement> m_composite_array;
144
145 int m_nRegions;
146 int m_index_last;
147 int m_hover_icon_last;
148 int m_hover_last;
149 bool m_gotPianoDown;
150
151 wxBrush m_backBrush;
152 wxBrush m_srBrush, m_rBrush;
153 wxBrush m_svBrush, m_vBrush;
154 wxBrush m_unavailableBrush;
155 wxBrush m_utileBrush, m_tileBrush;
156
157 wxBrush m_cBrush;
158 wxBrush m_scBrush;
159
160 std::vector<int> m_key_array;
161 std::vector<int> m_noshow_index_array;
162 std::vector<int> m_active_index_array;
163 std::vector<int> m_eclipsed_index_array;
164 std::vector<int> m_skew_index_array;
165 std::vector<int> m_tmerc_index_array;
166 std::vector<int> m_poly_index_array;
167 bool m_bBusy;
168 wxTimer m_eventTimer;
169 int m_click_sel_index;
170 int m_action;
171
172 std::vector<wxRect> KeyRect;
173
174 wxBitmap *m_pVizIconBmp;
175 wxBitmap *m_pInVizIconBmp;
176 wxBitmap *m_pTmercIconBmp;
177 wxBitmap *m_pSkewIconBmp;
178 wxBitmap *m_pPolyIconBmp;
179
180 int m_iactive;
181 bool m_brounded;
182 bool m_bleaving;
183
184 unsigned int m_tex, m_texw, m_texh, m_tex_piano_height;
185 int m_ref, m_pad, m_radius, m_texPitch;
186
187 int m_width;
188 int m_width_avail;
189
190 DECLARE_EVENT_TABLE()
191};
192
193//----------------------------------------------------------------------------
194// ChartBarWin
195//----------------------------------------------------------------------------
196class ChartBarWin : public wxDialog {
197public:
198 ChartBarWin(wxWindow *win);
199 ~ChartBarWin();
200 void OnSize(wxSizeEvent &event);
201 void OnPaint(wxPaintEvent &event);
202 void MouseEvent(wxMouseEvent &event);
203 int GetFontHeight();
204 void RePosition();
205 void ReSize();
206
207 DECLARE_EVENT_TABLE()
208};
209
210#endif
Chart display canvas.
Definition chcanv.h:135
Main application frame.
Definition ocpn_frame.h:136
Definition piano.h:65
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:64