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