ODIN
odinplot.h
1 /***************************************************************************
2  odinplot.h - description
3  -------------------
4  begin : Mon Jul 26 2004
5  copyright : (C) 2000-2021 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef OdinPlot_H
19 #define OdinPlot_H
20 
21 #include <qwidget.h>
22 
23 #include <odinpara/ldrtypes.h>
24 #include <odinpara/ldrnumbers.h>
25 
26 #include <odinqt/plot.h>
27 #include <odinqt/ldrwidget.h>
28 
29 #include <odinseq/seqplot.h>
30 
31 #include "odinplot_vtk.h"
32 
33 
34 #define MIN_HEIGHT_PER_CHAN 120
35 #define MIN_WIDTH_PER_CHAN 1000
36 
37 #define CLOSEST_CURVE_MAX 30
38 #define PLOT_SYMBOLS_MAX_RANGE 10
39 #define MAX_HIGHRES_INTERVAL 1000.0
40 #define MAX_MARKER_INTERVAL 400.0
41 #define MAX_START_RANGE 10000
42 
43 #define MAGN_PLOT_PAGE_DURATION 20.0
44 
45 
46 class RangeWidget; // forward declaration
47 
49 
50 class PlotView : public QWidget, public SeqSimFeedbackAbstract {
51 
52  Q_OBJECT
53 
54  public:
55  PlotView(const char* method, const STD_string& nucleus, GuiMainWindow* parent);
56 
57  ~PlotView();
58 
59  const SeqTimecourseData* get_timecourses();
60  const SeqTimecourseData* get_kspace_trajs();
61 
62  bool simulate(const STD_string& fidfile, const STD_string& samplefile, ProgressMeter* progmeter);
63 
64 
65 
66  public slots:
67 
68  void replot();
69 
70  void mouseMovedInPlot0(const QMouseEvent& e) {mouseMovedInPlot(0,e);}
71  void mouseMovedInPlot1(const QMouseEvent& e) {mouseMovedInPlot(1,e);}
72  void mouseMovedInPlot2(const QMouseEvent& e) {mouseMovedInPlot(2,e);}
73  void mouseMovedInPlot3(const QMouseEvent& e) {mouseMovedInPlot(3,e);}
74  void mouseMovedInPlot4(const QMouseEvent& e) {mouseMovedInPlot(4,e);}
75  void mouseMovedInPlot5(const QMouseEvent& e) {mouseMovedInPlot(5,e);}
76  void mouseMovedInPlot6(const QMouseEvent& e) {mouseMovedInPlot(6,e);}
77  void mouseMovedInPlot7(const QMouseEvent& e) {mouseMovedInPlot(7,e);}
78  void mouseMovedInPlot8(const QMouseEvent& e) {mouseMovedInPlot(8,e);}
79 
80  void mousePressedInPlot0(const QMouseEvent& e) {mousePressedInPlot(0,e);}
81  void mousePressedInPlot1(const QMouseEvent& e) {mousePressedInPlot(1,e);}
82  void mousePressedInPlot2(const QMouseEvent& e) {mousePressedInPlot(2,e);}
83  void mousePressedInPlot3(const QMouseEvent& e) {mousePressedInPlot(3,e);}
84  void mousePressedInPlot4(const QMouseEvent& e) {mousePressedInPlot(4,e);}
85  void mousePressedInPlot5(const QMouseEvent& e) {mousePressedInPlot(5,e);}
86  void mousePressedInPlot6(const QMouseEvent& e) {mousePressedInPlot(6,e);}
87  void mousePressedInPlot7(const QMouseEvent& e) {mousePressedInPlot(7,e);}
88  void mousePressedInPlot8(const QMouseEvent& e) {mousePressedInPlot(8,e);}
89 
90  void mouseReleasedInPlot0(const QMouseEvent& e) {mouseReleasedInPlot(0,e);}
91  void mouseReleasedInPlot1(const QMouseEvent& e) {mouseReleasedInPlot(1,e);}
92  void mouseReleasedInPlot2(const QMouseEvent& e) {mouseReleasedInPlot(2,e);}
93  void mouseReleasedInPlot3(const QMouseEvent& e) {mouseReleasedInPlot(3,e);}
94  void mouseReleasedInPlot4(const QMouseEvent& e) {mouseReleasedInPlot(4,e);}
95  void mouseReleasedInPlot5(const QMouseEvent& e) {mouseReleasedInPlot(5,e);}
96  void mouseReleasedInPlot6(const QMouseEvent& e) {mouseReleasedInPlot(6,e);}
97  void mouseReleasedInPlot7(const QMouseEvent& e) {mouseReleasedInPlot(7,e);}
98  void mouseReleasedInPlot8(const QMouseEvent& e) {mouseReleasedInPlot(8,e);}
99 
100  void autoscalePlot0() {autoscale_y(0);}
101  void autoscalePlot1() {autoscale_y(1);}
102  void autoscalePlot2() {autoscale_y(2);}
103  void autoscalePlot3() {autoscale_y(3);}
104  void autoscalePlot4() {autoscale_y(4);}
105  void autoscalePlot5() {autoscale_y(5);}
106  void autoscalePlot6() {autoscale_y(6);}
107  void autoscalePlot7() {autoscale_y(7);}
108  void autoscalePlot8() {autoscale_y(8);}
109 
110  void rescalePlot0(double val) {rescale_y(0,val);}
111  void rescalePlot1(double val) {rescale_y(1,val);}
112  void rescalePlot2(double val) {rescale_y(2,val);}
113  void rescalePlot3(double val) {rescale_y(3,val);}
114  void rescalePlot4(double val) {rescale_y(4,val);}
115  void rescalePlot5(double val) {rescale_y(5,val);}
116  void rescalePlot6(double val) {rescale_y(6,val);}
117  void rescalePlot7(double val) {rescale_y(7,val);}
118  void rescalePlot8(double val) {rescale_y(8,val);}
119 
120 
121  void update_x_axes();
122 
123  void autoscale_x();
124 
125  void hide_and_show();
126 
127  void set_rect_zoom_tool() {set_zoom_tool(rect);}
128  void set_hort_zoom_tool() {set_zoom_tool(horizontal);}
129  void set_vert_zoom_tool() {set_zoom_tool(vertical);}
130 
131 
132  void change_toolbar();
133 
134  void plot_all();
135 
136  void osci();
137 
138  void print();
139 
140  void save();
141 
142 
143  void close();
144 
145  void changeMode(int newmode);
146 
147  void settingsChanged();
148 
149  void save_closest_curve_data();
150  void save_current_channel_data();
151 
152  signals:
153  void setMessage(const char* text);
154 
155  void closeMe();
156 
157  private:
158  friend class PlotWindow;
159 
160 
161  double get_x(int iplot, int x_pixel);
162  double get_y(int iplot, int y_pixel);
163 
164 
165  void mouseMovedInPlot (int iplot, const QMouseEvent& e);
166  void mousePressedInPlot (int iplot, const QMouseEvent& e);
167  void mouseReleasedInPlot(int iplot, const QMouseEvent& e);
168 
169  void set_range_and_update_x_axes(double min, double max, bool discard_scrollbar=false);
170 
171  void autoscale_all_y();
172  void autoscale_y(int iplot);
173  void rescale_y(int iplot, double val);
174 
175 
176  void get_plot_label(int iplot, STD_string& label, STD_string& unit) const;
177  void set_plot_labels(bool extra_space=false);
178 
179  void set_curve_pens(bool thick_lines=false);
180 
181  void create_baseline();
182 
183  void add_plotcurve(const Curve4Qwt& curve);
184  void create_plotcurves();
185 
186  void add_marker(const Marker4Qwt& marker);
187  void add_tc_marker(const TimecourseMarker4Qwt& marker);
188  void create_markers();
189 
190  void create_plotcurves_and_markers();
191 
192 
193  bool create_timecourses(timecourseMode type);
194 
195  void create_timecourse_markers();
196 
197  void plot_timecourses(timecourseMode type);
198 
199 
200 
201  SeqPlotDataAbstract* plotdata;
202 
203  double totaldur;
204  STD_string nuc;
205 
206  int plot_pressed,x_pressed,y_pressed;
207 
208  static int lastplot_old;
209 
210  double baseline_x[2];
211  double baseline_y[2];
212  long curveid_baseline[numof_plotchan];
213 
214 
215  int closest;
216  int lastplot_closest;
217  int lastcurve_closest;
218 
219  int iplot_cache;
220 
221 
222  GuiToolBar* chan_toolbar;
223  GuiToolBar* zoom_toolbar;
224  GuiToolBar* settings_toolbar;
225 
226  GuiComboBox* plotmode;
227  timecourseMode oldmode;
228 
229 
230  GuiGridLayout* grid;
231  GuiPlot* plotter[numof_plotchan];
232  GuiWheel* wheel[numof_plotchan];
233  GuiToolButton* plotflag[numof_plotchan];
234 // GuiButton* autoscalebutton[numof_plotchan];
235 
236  GuiToolButton* oscibutton;
237  GuiToolButton* printbutton;
238  GuiToolButton* savebutton;
239  GuiToolButton* closebutton;
240 
241  RangeWidget* x_range;
242  GuiPrinter* printer;
243 
244  GuiToolButton* plotAxes;
245  GuiToolButton* plotMarkers;
246  GuiToolButton* plotGrid;
247 
248 
249  enum zoomMode {rect=0, horizontal, vertical, numof_zoomModes};
250 
251  void set_zoom_tool(zoomMode mode);
252 
253  GuiToolButton* zoomflag[numof_zoomModes];
254 
255  long markid_vertzoom;
256  long markid_hortzoom;
257 
258 
259  STD_map<long,Curve4Qwt> curves_map[numof_plotchan];
260 
261  long timecourse_curve_id[numof_tcmodes][numof_plotchan];
262 
263 
264  // Stuff for osci
265  LDRenum TriggerType;
266  LDRdouble TriggerWidth;
267  LDRdouble RefreshRate;
268 
269 
270  VtkMagnPlotter* active_magplot;
271  long markid_magplot;
272  int ipage;
273  void plot_vector(double timepoint, float M[3], float* dM); // implementing virtual function of SeqSimFeedbackAbstract
274 
275 };
276 
278 
279 class PlotWindow : public QObject, public GuiMainWindow {
280  Q_OBJECT
281 
282  public:
283  PlotWindow(const char* method, const STD_string& nucleus, QWidget *parent);
284  ~PlotWindow();
285 
286  const SeqTimecourseData* get_timecourses() {return view->get_timecourses();}
287  const SeqTimecourseData* get_kspace_trajs() {return view->get_kspace_trajs();}
288 
289  bool simulate(const STD_string& fidfile, const STD_string& samplefile, ProgressMeter* progmeter) {return view->simulate(fidfile,samplefile,progmeter);}
290 
291  public slots:
292  void statusBarMessage(const char* text);
293  void close();
294 
295  private:
296  PlotView* view;
297 };
298 
299 
300 #endif
Definition: plot.h:51
Definition: plot.h:150