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