-
Notifications
You must be signed in to change notification settings - Fork 0
/
TwoThetaWindow.h
225 lines (187 loc) · 5.44 KB
/
TwoThetaWindow.h
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
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
* TwoThetaWindow.h
* GandolfiViewer
*
* Created by Joe Petrus on 08/02/10.
*
*/
#ifndef TwoThetaWindow_H
#define TwoThetaWindow_H
/* QT Related headers */
#include <QMainWindow>
#include <QLabel>
#include <QMenu>
#include <QPrinter>
#include <QMouseEvent>
#include <QPen>
#include <QFileDialog>
#include <QDir>
#include <QInputDialog>
#include <QStatusBar>
#include <QToolBar>
#include <QToolButton>
#include <QStyle>
#include <QComboBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QDockWidget>
#include <QDateTime>
#include <QPainter>
#include <QPrintDialog>
#include <QDesktopServices>
#include <QUrl>
#include "ui_MacroDialog.h"
/* QWT Related headers */
#ifdef __APPLE__
#include "/usr/local/qwt-5.2.2/include/qwt.h"
#include "/usr/local/qwt-5.2.2/include/qwt_plot.h"
#include "/usr/local/qwt-5.2.2/include/qwt_plot_zoomer.h"
#include "/usr/local/qwt-5.2.2/include/qwt_plot_picker.h"
#include "/usr/local/qwt-5.2.2/include/qwt_painter.h"
#include "/usr/local/qwt-5.2.2/include/qwt_plot_canvas.h"
#include "/usr/local/qwt-5.2.2/include/qwt_plot_marker.h"
#include "/usr/local/qwt-5.2.2/include/qwt_plot_curve.h"
#include "/usr/local/qwt-5.2.2/include/qwt_scale_widget.h"
#include "/usr/local/qwt-5.2.2/include/qwt_legend.h"
#include "/usr/local/qwt-5.2.2/include/qwt_scale_draw.h"
#include "/usr/local/qwt-5.2.2/include/qwt_math.h"
#include "/usr/local/qwt-5.2.2/include/qwt_symbol.h"
#else
#include "c:\qwt-5.2.0/include/qwt.h"
#include "c:\qwt-5.2.0/include/qwt_plot.h"
#include "c:\qwt-5.2.0/include/qwt_plot_zoomer.h"
#include "c:\qwt-5.2.0/include/qwt_plot_picker.h"
#include "c:\qwt-5.2.0/include/qwt_painter.h"
#include "c:\qwt-5.2.0/include/qwt_plot_canvas.h"
#include "c:\qwt-5.2.0/include/qwt_plot_marker.h"
#include "c:\qwt-5.2.0/include/qwt_plot_curve.h"
#include "c:\qwt-5.2.0/include/qwt_scale_widget.h"
#include "c:\qwt-5.2.0/include/qwt_legend.h"
#include "c:\qwt-5.2.0/include/qwt_scale_draw.h"
#include "c:\qwt-5.2.0/include/qwt_math.h"
#include "c:\qwt-5.2.0/include/qwt_symbol.h"
#endif
#include <cmath>
#include <iostream>
#include <fstream>
#include <ctime>
#include "AppConfig.h"
#include "TwoThetaPlot.h"
#include "ui_MineralSearchDialog.h"
using namespace std;
QT_BEGIN_NAMESPACE
class QAction;
class QLabel;
class QMenu;
class QScrollArea;
class QScrollBar;
class QwtPlot;
class XYPlot;
class TwoThetaPlot;
QT_END_NAMESPACE
/* Weighted Average Cu and Co wavelengths */
#define CuLambda 1.5418e-10
#define CoLambda 1.7902e-10
struct Mineral
{
QString name;
QList<QString> elements;
QString formula;
QVarLengthArray<double> lines;
QVarLengthArray<double> intensities;
int nLines;
};
class QToolMacro : public QToolButton
{
Q_OBJECT
public:
QToolMacro(QWidget *parent) : QToolButton(parent) { rightDown = false; }
void mouseReleaseEvent(QMouseEvent *e)
{
rightDown = false;
QToolButton::mouseReleaseEvent(e);
}
void mousePressEvent(QMouseEvent *e) {
if (e->button() == Qt::RightButton )
rightDown = true;
else
rightDown = false;
QToolButton::mousePressEvent(e);
QToolButton::click();
}
bool isRightClick() { return rightDown; }
private:
bool rightDown;
};
class TwoThetaWindow : public QMainWindow
{
Q_OBJECT
public:
TwoThetaWindow(QWidget *parent, AppConfig &_appConfig);
void setXYData(double *xd, double *yd, int s, int sx = 0, int ex = 180);
void setYMinData(double *yd) { twoThetaXYPlot->setYMinData(yd); }
void setYMaxData(double *yd) { twoThetaXYPlot->setYMaxData(yd); }
void setSuggestedName(QString s) { suggestedName = s.split(".").at(0); }
void doScale(double s);
void doOffset(double o);
void sharpness();
void findPrimarySpacings();
void contextMenuEvent(QContextMenuEvent *event);
void createToolbar();
void initializeDB();
QList<QString> getElementsFromString(QString s);
void keyPressEvent(QKeyEvent *);
public slots:
void saveUDF();
void saveCSV();
void reset();
// void finishedSlot(QNetworkReply* reply);
void searchClicked();
void openWebMineral();
void showMineralLines(QListWidgetItem *);
void showMineralLines(int);
void addMacro();
private slots:
void selected(const QwtDoublePoint &pos);
void enableZoomMode(bool z);
void toggleMinMax(bool b);
void toggleBGS(bool b);
void intOffset(bool prompt = true, double offset = 0.0);
void intScale(bool prompt = true, double scale = 1.0);
void truncate(bool prompt = true, double start = 0.0, double stop = 180.0);
void doMacro(QAction *);
void deleteMacro();
void printData();
private:
AppConfig *appConfig;
QWidget *searchDialog;
QDialog *macroDialog;
QDockWidget *dockWidget;
Ui::MineralSearchDialog UiD;
TwoThetaPlot *twoThetaXYPlot;
QwtPlotZoomer *zoomer;
QwtPlotPicker *picker;
//QComboBox *cbxSource;
QToolBar *toolbar;
QStatusBar *sb;
QPrinter printer;
QMap<QString, Mineral> mindb;
QVarLengthArray<QwtPlotMarker *> minMarkers;
QwtSymbol minSymbol;
QString currentMineral;
QVarLengthArray<QString> mineralUrls;
int activeD;
QVarLengthArray<QToolMacro *> macroButtonArray;
// QToolMacro *btnMacro1;
// QToolMacro *btnMacro2;
// QToolMacro *btnMacro3;
QString suggestedName;
Ui::MacroDialog UiMacro;
double start2Theta;
double end2Theta;
};
inline bool operator<(const Mineral &m1, const Mineral &m2)
{
return m1.name < m2.name;
}
#endif