forked from cculianu/SpikeGL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileViewerWindow.h
More file actions
213 lines (181 loc) · 7.02 KB
/
FileViewerWindow.h
File metadata and controls
213 lines (181 loc) · 7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
* FileViewerWindow.h
* SpikeGL
*
* Created by calin on 10/26/10.
* Copyright 2010 Calin Culianu <calin.culianu@gmail.com>. All rights reserved.
*
*/
#ifndef FileViewerWindow_H
#define FileViewerWindow_H
#include <QMainWindow>
#include "DataFile.h"
#include "VecWrapBuffer.h"
#include <QPair>
#include "ChanMap.h"
#include <QBitArray>
class GLGraph;
class QScrollArea;
class QSpinBox;
class QDoubleSpinBox;
class QSlider;
class QLabel;
class QToolBar;
class QPushButton;
class QTimer;
class QMenu;
class QAction;
class ExportDialogController;
struct ExportParams;
class QFrame;
class QCheckBox;
class HPFilter;
class QEvent;
class TaggableLabel;
class QComboBox;
class Ui_FVW_Readme;
/// The class that handles the window you get when opening files.
class FileViewerWindow : public QMainWindow
{
Q_OBJECT
public:
FileViewerWindow();
~FileViewerWindow();
/// Call this method to associate a file with this class and open it and view it.
/// Ok to call it multiple times to open new files using same window.
bool viewFile(const QString & fileName, QString *errMsg_out = 0);
/// Returns the filename with path of the .bin file that is opened by this instance, or null QString if nothing is open
QString file() const { if (dataFile.isOpen()) return dataFile.fileName(); return QString::null; }
/// Offer the user opportunity to abort a close operation, otherwise closes the window
bool queryCloseOK();
protected:
void resizeEvent(QResizeEvent *);
void showEvent(QShowEvent *);
bool eventFilter(QObject *obj, QEvent *event);
private slots:
void setFilePos(int pos); // TODO/FIXME/XXX: this should take a 64-bit parameter but we need to connect to Qt gui stuff that is 32 bit
void setFilePosSecs(double);
void setXScaleSecs(double);
void setYScale(double);
void setNDivs(int);
void colorSchemeMenuSlot();
void setAuxGain(double);
void mouseOverGraph(double,double);
void mouseOverGraphInWindowCoords(int,int);
void clickedGraphInWindowCoords(int,int);
void toggleMaximize(); // maximize/minimize
void showAllGraphs();
void hideUnhideGraphSlot();
void hideCloseTimeout();
void viewModeMenuSlot();
void resizeIt();
void updateData();
void mouseClickSlot(double,double);
void mouseReleaseSlot(double,double);
void exportSlot();
void selectGraph(int graphNum); ///< pass in a graph id (which is relative to current page)
void hpfChk(bool);
void dcfChk(bool);
void hpfLblClk();
void dcfLblClk();
void applyAllSlot();
void fileOpenMenuSlot();
void fileOptionsMenuSlot();
void clickedCloseLbl(GLGraph *g);
void sortGraphsByIntan();
void sortGraphsByElectrode();
void graphsPerPageChanged(int);
void repaginate();
void pageChanged(int);
void updateSelection(); ///< calls updateSelection(true)
void readmeDlgDone();
private:
void loadSettings();
void saveSettings();
void layoutGraphs();
double timeFromPos(qint64 p) const;
qint64 posFromTime(double) const;
void configureMiscControls(bool blockSignals = false);
qint64 nScansPerGraph() const;
QPair<double, double> yVoltsAfterGain(int whichGraph) const;
void applyColorScheme(GLGraph *);
void hideGraph(int n); ///< pass in a graph id (which is relative to current page)
void showGraph(int n); ///< pass in a graph id (which is relative to current page)
void mouseOverGraphInWindowCoords(GLGraph *, int,int);
void setFilePos64(qint64 pos, bool noupdate = false);
void printStatusMessage();
void doExport(const ExportParams &);
int graphsPerPage() const { return n_graphs_pg; }
int currentGraphsPage() const { return curr_graph_page; }
int g2i(int g) const { int ix = currentGraphsPage()*graphsPerPage() + g; if (ix >= 0 && ix < graphSorting.size()) return graphSorting[ix]; return -1; }
int i2g(int i) const { if (i >= 0 && i < revGraphSorting.size()) return revGraphSorting[i] - currentGraphsPage()*graphsPerPage(); return -1; }
void redoGraphs(); ///< used when graphs per page changes and also as a setup function when opening a new file. deletes all old graph data and reestablishes graph data structures
void updateSelection(bool do_opengl_update);
QString generateGraphNameString(unsigned graphNum, bool verbose = true) const;
enum ViewMode { Tiled = 0, Stacked, StackedLarge, StackedHuge, N_ViewMode } viewMode;
static const QString viewModeNames[];
enum ColorScheme { Ice = 0, Fire, Green, BlackWhite, Classic, N_ColorScheme, DefaultScheme = Ice } colorScheme;
static const QString colorSchemeNames[];
DataFile dataFile;
QScrollArea *scrollArea; ///< the central widget
QWidget *graphParent;
struct GraphParams {
double yZoom, gain;
bool filter300Hz, dcFilter;
QString objname;
GraphParams() : yZoom(1.0), gain(1.0), filter300Hz(false), dcFilter(true) {}
};
/*-- Below are: INDEXED by numChans! */
QVector<QAction *> graphHideUnhideActions; ///< indexed by numChans!
QBitArray hiddenGraphs; ///< indexed by numChans!
QVector<GraphParams> graphParams; ///< per-graph params
QVector<int> graphSorting, revGraphSorting; ///< used for sort by electrode id/sort by intan feature to sort the graphs.
/*-- Below two are: INDEXED BY graphsPerPage(), not numChans.. graphs on screen are a subset of all channels as of June 2016 */
QVector<GLGraph *> graphs; ///< indexed by graphsPerPage()
QVector<QFrame *> graphFrames; ///< indexed by graphsPerPage()
QVector<Vec2fWrapBuffer> graphBufs; ///< indexed by graphsPerPage()!
// BELOW TWO MEMBERS ARE BY GRAPH ID, NOT CHANNEL INDEX!
int maximizedGraph; ///< if non-negative, we are maximized on a particular graph
int selectedGraph;
QVector<QVector<Vec2f> > scratchVecs;
QSpinBox *posScansSB, *graphPgSz;
QDoubleSpinBox *posSecsSB;
QSlider *posSlider;
QLabel *totScansLbl;
QLabel *totSecsLbl;
QToolBar *toolBar;
QDoubleSpinBox *xScaleSB, *yScaleSB, *auxGainSB;
QLabel *xDivLbl, *yDivLbl;
QSpinBox *nDivsSB;
TaggableLabel *closeLbl;
QLabel *graphNameLbl;
QCheckBox *highPassChk, *dcfilterChk;
bool electrodeSort;
QMenu *channelsMenu;
QAction *colorSchemeActions[N_ColorScheme];
QAction *viewModeActions[N_ViewMode];
QAction *sortByElectrode, *sortByIntan;
QTimer *hideCloseTimer;
bool didLayout;
// misc graph zoom/view/etc settings
double nSecsZoom, defaultYZoom, defaultGain;
unsigned nDivs;
qint64 pos, ///< in scan counts
pscale; ///< scaling factor for the QSlider since it uses 32-bit values and file pos can theoretically be 64-bit
qint64 selectionBegin, selectionEnd; ///< selection position (in scans) and number of scans. if begin is negative, no selection
qint64 saved_selectionBegin, saved_selectionEnd;
ChanMap chanMap;
double mouseOverT, mouseOverV;
int mouseOverGNum;
bool mouseButtonIsDown, dontKillSelection;
QAction *exportAction, *exportSelectionAction, *maxunmaxAction;
ExportDialogController *exportCtl;
HPFilter *hpfilter;
double arrowKeyFactor, pgKeyFactor;
QComboBox *pageCB;
QLabel *maximizedLbl, *pgLbl, *allChannelsHiddenLbl;
int n_graphs_pg, curr_graph_page;
bool showReadme;
QDialog *readmeDlg; Ui_FVW_Readme *readme;
};
#endif