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 "chcanv.h"
36
37WX_DECLARE_OBJARRAY(wxRect, RectArray);
38
39enum { PIANO_MODE_COMPOSITE = 0, PIANO_MODE_LEGACY };
40
41//----------------------------------------------------------------------------
42// PianoKeyElement
43//----------------------------------------------------------------------------
45public:
46 PianoKeyElement() {};
49
50 int chart_scale;
51 ChartTypeEnum chart_type;
52 ChartFamilyEnum chart_family;
53 std::vector<int> dbindex_list;
54};
55
56//----------------------------------------------------------------------------
57// Piano
58//----------------------------------------------------------------------------
59class Piano : public wxEvtHandler {
60public:
61 Piano(ChartCanvas *parent);
62 ~Piano();
63
64 void Paint(int y, wxDC &dc, wxDC *shapeDC = NULL);
65 void Paint(int y, ocpnDC &dc, wxDC *shapeDC = NULL);
66 void DrawGL(int y);
67 void FormatKeys(void);
68 bool MouseEvent(wxMouseEvent &event);
69 void SetColorScheme(ColorScheme cs);
70 void SetKeyArray(std::vector<int> &center_array,
71 std::vector<int> &full_array);
72 void SetActiveKey(int iactive) { m_iactive = iactive; }
73 void SetActiveKeyArray(std::vector<int> array);
74 void SetNoshowIndexArray(std::vector<int> array);
75 void AddNoshowIndexArray(std::vector<int> array);
76 void SetEclipsedIndexArray(std::vector<int> array);
77 void SetSkewIndexArray(std::vector<int> array);
78 void SetTmercIndexArray(std::vector<int> array);
79 void SetPolyIndexArray(std::vector<int> array);
80 int GetPianoMode() { return m_piano_mode; }
81
82 std::vector<int> GetActiveKeyArray() { return m_active_index_array; }
83
84 void SetVizIcon(wxBitmap *picon_bmp) {
85 if (m_pVizIconBmp) delete m_pVizIconBmp;
86 m_pVizIconBmp = picon_bmp;
87 }
88 void SetInVizIcon(wxBitmap *picon_bmp) {
89 if (m_pInVizIconBmp) delete m_pInVizIconBmp;
90 m_pInVizIconBmp = picon_bmp;
91 }
92 void SetSkewIcon(wxBitmap *picon_bmp) {
93 if (m_pSkewIconBmp) delete m_pSkewIconBmp;
94 m_pSkewIconBmp = picon_bmp;
95 }
96 void SetTMercIcon(wxBitmap *picon_bmp) {
97 if (m_pTmercIconBmp) delete m_pTmercIconBmp;
98 m_pTmercIconBmp = picon_bmp;
99 }
100 void SetPolyIcon(wxBitmap *picon_bmp) {
101 if (m_pPolyIconBmp) delete m_pPolyIconBmp;
102 m_pPolyIconBmp = picon_bmp;
103 }
104 void ShowBusy(bool busy);
105 void onTimerEvent(wxTimerEvent &event);
106
107 wxPoint GetKeyOrigin(int key_index);
108 void ResetRollover(void);
109 void SetRoundedRectangles(bool val) {
110 m_brounded = val;
111 m_hash.Clear();
112 }
113
114 int GetHeight();
115 int GetWidth();
116
117 wxString &GenerateAndStoreNewHash();
118 wxString &GetStoredHash();
119
120 int GetnKeys() { return m_nRegions; }
121
122private:
123 void SetPianoMode(int new_mode) { m_piano_mode = new_mode; }
124
125 void DrawGLSL(int y);
126 void BuildGLTexture();
127 bool InArray(std::vector<int> &array, int key);
128 bool IsAnyActiveChartInPianoKeyElement(PianoKeyElement &pke);
129 bool IsAllEclipsedChartInPianoKeyElement(PianoKeyElement &pke);
130
131 wxString GetStateHash();
132 wxString m_hash;
133
134 ChartCanvas *m_parentCanvas;
135 int m_piano_mode;
136
137 std::vector<PianoKeyElement> m_composite_array;
138
139 int m_nRegions;
140 int m_index_last;
141 int m_hover_icon_last;
142 int m_hover_last;
143 bool m_gotPianoDown;
144
145 wxBrush m_backBrush;
146 wxBrush m_srBrush, m_rBrush;
147 wxBrush m_svBrush, m_vBrush;
148 wxBrush m_unavailableBrush;
149 wxBrush m_utileBrush, m_tileBrush;
150
151 wxBrush m_cBrush;
152 wxBrush m_scBrush;
153
154 std::vector<int> m_key_array;
155 std::vector<int> m_noshow_index_array;
156 std::vector<int> m_active_index_array;
157 std::vector<int> m_eclipsed_index_array;
158 std::vector<int> m_skew_index_array;
159 std::vector<int> m_tmerc_index_array;
160 std::vector<int> m_poly_index_array;
161 bool m_bBusy;
162 wxTimer m_eventTimer;
163 int m_click_sel_index;
164 int m_action;
165
166 std::vector<wxRect> KeyRect;
167
168 wxBitmap *m_pVizIconBmp;
169 wxBitmap *m_pInVizIconBmp;
170 wxBitmap *m_pTmercIconBmp;
171 wxBitmap *m_pSkewIconBmp;
172 wxBitmap *m_pPolyIconBmp;
173
174 int m_iactive;
175 bool m_brounded;
176 bool m_bleaving;
177
178 unsigned int m_tex, m_texw, m_texh, m_tex_piano_height;
179 int m_ref, m_pad, m_radius, m_texPitch;
180
181 int m_width;
182 int m_width_avail;
183
184 DECLARE_EVENT_TABLE()
185};
186
187//----------------------------------------------------------------------------
188// ChartBarWin
189//----------------------------------------------------------------------------
190class ChartBarWin : public wxDialog {
191public:
192 ChartBarWin(wxWindow *win);
193 ~ChartBarWin();
194 void OnSize(wxSizeEvent &event);
195 void OnPaint(wxPaintEvent &event);
196 void MouseEvent(wxMouseEvent &event);
197 int GetFontHeight();
198 void RePosition();
199 void ReSize();
200
201 DECLARE_EVENT_TABLE()
202};
203
204#endif
Generic Chart canvas base.
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:157
Definition piano.h:59
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:60