Open Ephys GUI
 All Classes Functions Variables Pages
ControlPanel.h
1 /*
2  ------------------------------------------------------------------
3 
4  This file is part of the Open Ephys GUI
5  Copyright (C) 2012 Open Ephys
6 
7  ------------------------------------------------------------------
8 
9  This program is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef __CONTROLPANEL_H_AD81E528__
25 #define __CONTROLPANEL_H_AD81E528__
26 
27 #include "../../JuceLibraryCode/JuceHeader.h"
28 #include "../Audio/AudioComponent.h"
29 #include "../Processors/Editors/AudioEditor.h"
30 #include "../Processors/ProcessorGraph.h"
31 #include "../Processors/RecordNode.h"
32 #include "CustomLookAndFeel.h"
33 #include "../AccessClass.h"
34 #include "../Processors/Editors/GenericEditor.h" // for UtilityButton
35 
36 #include "../OpenGL.h"
37 
38 /**
39 
40  Displays information and provides buttons to control acquistion and recording.
41 
42  The ControlPanel is located along the top of the application window.
43 
44  @see UIComponent
45 
46 */
47 
48 
49 class PlayButton : public DrawableButton
50 {
51  public:
52  PlayButton();
53  ~PlayButton();
54 };
55 
56 class RecordButton : public DrawableButton
57 {
58  public:
59  RecordButton();
60  ~RecordButton();
61 };
62 
63 class CPUMeter : public Label
64 {
65  public:
66  CPUMeter();
67  ~CPUMeter();
68 
69  void updateCPU(float usage);
70 
71  void paint (Graphics& g);
72 
73  private:
74 
75  Font font;
76 
77  float cpu;
78  float lastCpu;
79 
80 };
81 
82 class DiskSpaceMeter : public Component
83 {
84 public:
86  ~DiskSpaceMeter();
87 
88  void updateDiskSpace(float percent);
89 
90  void paint (Graphics& g);
91 
92 private:
93 
94  Font font;
95 
96  float diskFree;
97  ProcessorGraph* graph;
98 
99 };
100 
101 class Clock : public OpenGLComponent
102 {
103  public:
104  Clock();
105  ~Clock();
106 
107  void newOpenGLContextCreated();
108  void renderOpenGL();
109 
110  void start();
111  void stop();
112 
113  void startRecording();
114  void stopRecording();
115 
116  void resetRecordTime();
117 
118  private:
119 
120  void drawTime();
121 
122  int64 lastTime;
123 
124  int64 totalTime;
125  int64 totalRecordTime;
126 
127  bool isRunning;
128  bool isRecording;
129 
130  FTPixmapFont* font;
131 };
132 
133 class ControlPanelButton : public OpenGLComponent
134 {
135 public:
138 
139  bool isOpen() {return open;}
140  void toggleState();
141 
142  void newOpenGLContextCreated();
143  void renderOpenGL();
144 
145  void drawButton();
146 
147  void mouseDown(const MouseEvent& e);
148 
149 private:
150 
151  ControlPanel* cp;
152 
153  bool open;
154 
155 };
156 
157 class UtilityButton;
158 
159 class ControlPanel : public Component,
160  public Button::Listener,
161  public ActionListener,
162  public Timer,
163  public AccessClass
164 
165 {
166 public:
168  ~ControlPanel();
169 
170  void disableCallbacks();
171 
172  AccessClass* getAudioEditor() {return (AccessClass*) audioEditor;}
173 
174  void openState(bool);
175 
176  void toggleState();
177 
178  bool isOpen() {return open;}
179 
180 private:
181  PlayButton* playButton;
182  RecordButton* recordButton;
183  Clock* masterClock;
184  CPUMeter* cpuMeter;
185  DiskSpaceMeter* diskMeter;
186  AudioComponent* audio;
187  ProcessorGraph* graph;
188  AudioEditor* audioEditor;
189  FilenameComponent* filenameComponent;
190  UtilityButton* newDirectoryButton;
191 
192  ControlPanelButton* cpb;
193 
194  void paint(Graphics& g);
195 
196  void resized();
197  void buttonClicked(Button* button);
198 
199  void actionListenerCallback(const String& msg);
200 
201  void updateChildComponents();
202 
203  void timerCallback();
204 
205  bool keyPressed(const KeyPress &key);
206 
207  Font font;
208 
209  bool open;
210 
211  Path p1, p2;
212 
213  void createPaths();
214 
215 };
216 
217 
218 #endif // __CONTROLPANEL_H_AD81E528__