qmca  0.0.20
Public Slots | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MCAController Class Reference

#include <mcacontroller.h>

Inheritance diagram for MCAController:
Inheritance graph

Public Slots

void printGraph ()
 
void wantToQuit ()
 
void zoomIn ()
 
void zoomOut ()
 
void autoscaleGraph ()
 
void saveData ()
 
void saveEnergyWindows ()
 
void loadEnergyWindows ()
 
void save_a ()
 
void save_b ()
 
void save_c ()
 
void clear_a ()
 
void clear_b ()
 
void clear_c ()
 

Public Member Functions

 MCAController (MCAMainWindow *w, QObject *parent=0)
 
 ~MCAController ()
 
void addArgument (QString arg)
 
void replot ()
 
QwtPlot * graph ()
 

Private Types

enum  Adding {
  NONE, MCA, AMP, ADC,
  TCA, HVPS, BM12
}
 

Private Member Functions

void save_curves (QList< QwtPlotCurve * > &crvs, QString suffix, Qt::PenStyle style)
 
void clear_curves (QList< QwtPlotCurve * > &crvs)
 

Private Attributes

MCAMainWindowm_MainWindow
 
QMCAControlPanelm_MainControlPanel
 
QList< QwtPlotCurve * > m_MCACurves
 
QList< QwtPlotCurve * > m_MCACurvesA
 
QList< QwtPlotCurve * > m_MCACurvesB
 
QList< QwtPlotCurve * > m_MCACurvesC
 
QwtPlot * m_Plot
 
QwtPlotZoomer * m_Zoomer
 
QwtPlotPanner * m_Panner
 
QwtLegend * m_Legend
 
QwtPlotGrid * m_Grid
 
Adding m_Adding
 
MCAControlPanelm_MCAControlPanel
 
AmplifierControlPanelm_AmplifierControlPanel
 
A2DConverterControlPanelm_A2DConverterControlPanel
 
PulseAnalyserControlPanelm_PulseAnalyserControlPanel
 
PowerSupplyControlPanelm_PowerSupplyControlPanel
 
BM12ControlPanelm_BM12ControlPanel
 
QTimer * m_Timer
 

Detailed Description

Definition at line 32 of file mcacontroller.h.

Member Enumeration Documentation

enum MCAController::Adding
private
Enumerator
NONE 
MCA 
AMP 
ADC 
TCA 
HVPS 
BM12 

Definition at line 68 of file mcacontroller.h.

Constructor & Destructor Documentation

MCAController::MCAController ( MCAMainWindow w,
QObject *  parent = 0 
)

Definition at line 39 of file mcacontroller.cpp.

References autoscaleGraph(), loadEnergyWindows(), m_Legend, m_MainWindow, m_Panner, m_Pens, m_Plot, m_Zoomer, NPENS, printGraph(), saveData(), saveEnergyWindows(), wantToQuit(), zoomIn(), and zoomOut().

40  : QObject(parent),
41  m_MainWindow(w),
42  m_MainControlPanel(m_MainWindow->mainControlPanel),
43  m_Plot(m_MainWindow->qwtPlot),
44  m_Zoomer(NULL),
45  m_Panner(NULL),
46  m_Legend(NULL),
47  m_Grid(NULL),
48  m_Adding(NONE),
49  m_MCAControlPanel(NULL),// m_MainWindow->mcaPanel),
50  m_AmplifierControlPanel(NULL), // m_MainWindow->ampPanel),
51  m_A2DConverterControlPanel(NULL), // m_MainWindow->a2dPanel),
52  m_PulseAnalyserControlPanel(NULL), // m_MainWindow->tcaPanel),
53  m_PowerSupplyControlPanel(NULL), // m_MainWindow->hvpsPanel)
54  m_BM12ControlPanel(NULL),
55  m_Timer(NULL)
56 {
57  m_Pens[0].setColor(Qt::black);
58  m_Pens[1].setColor(Qt::red);
59  m_Pens[2].setColor(Qt::green);
60  m_Pens[3].setColor(Qt::blue);
61  m_Pens[4].setColor(Qt::cyan);
62  m_Pens[5].setColor(Qt::magenta);
63  m_Pens[6].setColor(Qt::darkYellow);
64  m_Pens[7].setColor(Qt::darkRed);
65  m_Pens[8].setColor(Qt::darkGreen);
66  m_Pens[9].setColor(Qt::darkBlue);
67  m_Pens[10].setColor(Qt::darkCyan);
68  m_Pens[11].setColor(Qt::darkMagenta);
69 
70  for (int i = 0; i<NPENS; i++) {
71  m_Pens[i].setWidthF(0.75);
72  }
73 
74  m_Plot->setCanvasBackground(QColor(255,255,250,255));
75 
76  m_Zoomer = new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, m_Plot->canvas());
77  m_Zoomer -> setStateMachine(new QwtPickerDragRectMachine());
78  m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOn);
79  m_Zoomer -> setRubberBand(QwtPicker::RectRubberBand);
80  m_Zoomer -> setRubberBandPen(m_Pens[2]);
81 
82  m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect2,
83  Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier);
84  m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect3,
85  Qt::LeftButton, Qt::ControlModifier);
86 
87  m_Panner = new QwtPlotPanner(m_Plot->canvas());
88  m_Panner -> setMouseButton(Qt::MidButton);
89  m_Panner -> setEnabled(true);
90 
91  m_Legend = new QwtLegend();
92  m_Legend -> setFrameStyle(QFrame::Box|QFrame::Sunken);
93  m_Legend -> setDefaultItemMode(QwtLegendData::Checkable);
94 
95  m_Plot -> insertLegend(m_Legend, QwtPlot::BottomLegend);
96 
97 // m_Grid = new QwtPlotGrid();
98 // m_Grid -> setPen(QPen(QColor(220,220,220,255),0,Qt::DotLine));
99 // m_Grid -> attach(m_Plot);
100 
101  connect(m_MainWindow->actionPrintGraph, SIGNAL(triggered()), this, SLOT(printGraph()));
102  connect(m_MainWindow->actionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
103  connect(m_MainWindow->actionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));
104  connect(m_MainWindow->actionAutoscaleGraph, SIGNAL(triggered()), this, SLOT(autoscaleGraph()));
105  connect(m_MainWindow->actionSaveData, SIGNAL(triggered()), this, SLOT(saveData()));
106  connect(m_MainWindow->actionSaveEnergyWindows, SIGNAL(triggered()), this, SLOT(saveEnergyWindows()));
107  connect(m_MainWindow->actionLoadEnergyWindows, SIGNAL(triggered()), this, SLOT(loadEnergyWindows()));
108  connect(m_MainWindow->actionExit, SIGNAL(triggered()), this, SLOT(wantToQuit()));
109 }
QwtPlotPanner * m_Panner
Definition: mcacontroller.h:80
QwtPlotZoomer * m_Zoomer
Definition: mcacontroller.h:79
static const int NPENS
PulseAnalyserControlPanel * m_PulseAnalyserControlPanel
Definition: mcacontroller.h:87
static QPen m_Pens[NPENS]
MCAControlPanel * m_MCAControlPanel
Definition: mcacontroller.h:84
PowerSupplyControlPanel * m_PowerSupplyControlPanel
Definition: mcacontroller.h:88
void loadEnergyWindows()
AmplifierControlPanel * m_AmplifierControlPanel
Definition: mcacontroller.h:85
A2DConverterControlPanel * m_A2DConverterControlPanel
Definition: mcacontroller.h:86
BM12ControlPanel * m_BM12ControlPanel
Definition: mcacontroller.h:89
void saveEnergyWindows()
QMCAControlPanel * m_MainControlPanel
Definition: mcacontroller.h:73
QwtPlot * m_Plot
Definition: mcacontroller.h:78
MCAMainWindow * m_MainWindow
Definition: mcacontroller.h:72
QwtLegend * m_Legend
Definition: mcacontroller.h:81
QTimer * m_Timer
Definition: mcacontroller.h:90
QwtPlotGrid * m_Grid
Definition: mcacontroller.h:82
MCAController::~MCAController ( )

Definition at line 111 of file mcacontroller.cpp.

112 {
113 }

Member Function Documentation

void MCAController::addArgument ( QString  arg)

Definition at line 115 of file mcacontroller.cpp.

References ADC, AMP, AmplifierControlPanel::append(), A2DConverterControlPanel::append(), PulseAnalyserControlPanel::append(), MCAControlPanel::append(), BM12, HVPS, m_A2DConverterControlPanel, m_Adding, m_AmplifierControlPanel, m_BM12ControlPanel, m_MainControlPanel, m_MCAControlPanel, m_MCACurves, m_Pens, m_Plot, m_PowerSupplyControlPanel, m_PulseAnalyserControlPanel, MCA, NPENS, and TCA.

116 {
117  if (arg == "-mca") {
118  m_Adding = MCA;
119  } else if (arg == "-amp") {
120  m_Adding = AMP;
121  } else if (arg == "-adc") {
122  m_Adding = ADC;
123  } else if (arg == "-tca") {
124  m_Adding = TCA;
125  } else if (arg == "-hvps") {
126  m_Adding = HVPS;
127  } else if (arg == "-bm12") {
128  m_Adding = BM12;
129 
130  if (m_BM12ControlPanel == NULL) {
131  m_BM12ControlPanel = m_MainControlPanel -> newBM12ControlPanel(this);
132  }
133  } else if (m_Adding == MCA) {
134  EpicsMCA *newMCA = new EpicsMCA(arg);
135 
136  if (m_MCAControlPanel == NULL) {
137  m_MCAControlPanel = m_MainControlPanel -> newMCAControlPanel(this);
138  }
139 
140  m_MCAControlPanel->append(newMCA);
141 
142  MCAPlotCurve *pc = new MCAPlotCurve(NULL, arg, this, m_Plot, newMCA);
143  pc->setPen(m_Pens[m_MCACurves.size()%NPENS]);
144 
145  m_MCACurves.append(pc);
146 
147  pc->attach(m_Plot);
148  } else if (m_Adding == AMP) {
149  EpicsAmplifier *newAmp = new EpicsAmplifier(arg);
150 
151  if (m_AmplifierControlPanel == NULL) {
152  m_AmplifierControlPanel = m_MainControlPanel -> newAmplifierControlPanel(this);
153  }
154 
156  } else if (m_Adding == ADC) {
157  EpicsA2DConverter *newADC = new EpicsA2DConverter(arg);
158 
159  if (m_A2DConverterControlPanel == NULL) {
160  m_A2DConverterControlPanel = m_MainControlPanel -> newA2DConverterControlPanel(this);
161  }
162 
164  } else if (m_Adding == TCA) {
165  EpicsPulseAnalyser *newTCA = new EpicsPulseAnalyser(arg);
166 
167  if (m_PulseAnalyserControlPanel == NULL) {
168  m_PulseAnalyserControlPanel = m_MainControlPanel -> newPulseAnalyserControlPanel(this);
169  }
170 
172  } else if (m_Adding == HVPS) {
173  EpicsPowerSupply *newHVPS = new EpicsPowerSupply(arg);
174 
175  if (m_PowerSupplyControlPanel == NULL) {
176  m_PowerSupplyControlPanel = m_MainControlPanel -> newPowerSupplyControlPanel(this);
177  }
178 
179  m_PowerSupplyControlPanel -> append(newHVPS);
180  }
181 }
static const int NPENS
PulseAnalyserControlPanel * m_PulseAnalyserControlPanel
Definition: mcacontroller.h:87
static QPen m_Pens[NPENS]
MCAControlPanel * m_MCAControlPanel
Definition: mcacontroller.h:84
PowerSupplyControlPanel * m_PowerSupplyControlPanel
Definition: mcacontroller.h:88
AmplifierControlPanel * m_AmplifierControlPanel
Definition: mcacontroller.h:85
A2DConverterControlPanel * m_A2DConverterControlPanel
Definition: mcacontroller.h:86
QList< QwtPlotCurve * > m_MCACurves
Definition: mcacontroller.h:74
void append(EpicsAmplifier *amp)
BM12ControlPanel * m_BM12ControlPanel
Definition: mcacontroller.h:89
QMCAControlPanel * m_MainControlPanel
Definition: mcacontroller.h:73
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void append(EpicsPulseAnalyser *conv)
void append(EpicsA2DConverter *conv)
void append(EpicsMCA *mca)
void MCAController::autoscaleGraph ( )
slot

Definition at line 245 of file mcacontroller.cpp.

References m_Plot, m_Zoomer, and replot().

Referenced by MCAController().

246 {
247  m_Plot -> setAxisAutoScale(QwtPlot::xBottom);
248  m_Plot -> setAxisAutoScale(QwtPlot::yLeft);
249 
250  m_Plot -> replot();
251 
252  m_Zoomer -> setZoomBase();
253 }
QwtPlotZoomer * m_Zoomer
Definition: mcacontroller.h:79
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void MCAController::clear_a ( )
slot

Definition at line 297 of file mcacontroller.cpp.

References clear_curves(), and m_MCACurvesA.

298 {
299 // printf("MCAController::clear_a()\n");
300 
302 }
void clear_curves(QList< QwtPlotCurve * > &crvs)
QList< QwtPlotCurve * > m_MCACurvesA
Definition: mcacontroller.h:75
void MCAController::clear_b ( )
slot

Definition at line 304 of file mcacontroller.cpp.

References clear_curves(), and m_MCACurvesB.

305 {
306 // printf("MCAController::clear_b()\n");
307 
309 }
void clear_curves(QList< QwtPlotCurve * > &crvs)
QList< QwtPlotCurve * > m_MCACurvesB
Definition: mcacontroller.h:76
void MCAController::clear_c ( )
slot

Definition at line 311 of file mcacontroller.cpp.

References clear_curves(), and m_MCACurvesC.

312 {
313 // printf("MCAController::clear_c()\n");
314 
316 }
void clear_curves(QList< QwtPlotCurve * > &crvs)
QList< QwtPlotCurve * > m_MCACurvesC
Definition: mcacontroller.h:77
void MCAController::clear_curves ( QList< QwtPlotCurve * > &  crvs)
private

Definition at line 356 of file mcacontroller.cpp.

Referenced by clear_a(), clear_b(), and clear_c().

357 {
358  QwtPlotCurve *pc;
359 
360  foreach(pc, crvs) {
361 // printf("Detach %s\n", qPrintable(pc->title().text()));
362 
363  pc -> detach();
364  delete pc;
365  }
366 
367  crvs.clear();
368 }
QwtPlot * MCAController::graph ( )

Definition at line 192 of file mcacontroller.cpp.

References m_Plot.

Referenced by QMCAControlPanel::newBM12ControlPanel().

193 {
194  return m_Plot;
195 }
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void MCAController::loadEnergyWindows ( )
slot

Definition at line 269 of file mcacontroller.cpp.

References m_BM12ControlPanel.

Referenced by MCAController().

270 {
271  if (m_BM12ControlPanel) {
273  }
274 }
void loadEnergyWindows()
BM12ControlPanel * m_BM12ControlPanel
Definition: mcacontroller.h:89
void MCAController::printGraph ( )
slot

Definition at line 197 of file mcacontroller.cpp.

References m_Plot.

Referenced by MCAController().

198 {
199  QPrinter printer(QPrinter::HighResolution);
200 
201  printer.setCreator("qmca");
202  printer.setOrientation(QPrinter::Landscape);
203 
204  QPrintDialog dialog(&printer);
205 
206  if (dialog.exec()) {
207  QwtPlotRenderer filter;
208 
209 // if ( printer.colorMode() == QPrinter::GrayScale ) {
210 // filter.setOptions(QwtPlotPrintFilter::PrintAll &
211 // ~QwtPlotPrintFilter::PrintBackground);
212 // }
213 
214  QRect geo = m_Plot -> geometry();
215  QPainter p(&printer);
216 
217 // m_Plot -> print(&p, geo, filter);
218  filter.renderTo(m_Plot, printer);
219  }
220 }
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void MCAController::replot ( )

Definition at line 183 of file mcacontroller.cpp.

References m_Plot, and m_Zoomer.

Referenced by MCAPlotCurve::arrayValueChanged(), autoscaleGraph(), zoomIn(), and zoomOut().

184 {
185  m_Plot->replot();
186 
187  if (m_Zoomer -> zoomRectIndex() == 0) {
188  m_Zoomer -> setZoomBase();
189  }
190 }
QwtPlotZoomer * m_Zoomer
Definition: mcacontroller.h:79
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void MCAController::save_a ( )
slot

Definition at line 276 of file mcacontroller.cpp.

References m_MCACurvesA, and save_curves().

277 {
278 // printf("MCAController::save_a()\n");
279 
280  save_curves(m_MCACurvesA, ".A", Qt::DashLine);
281 }
QList< QwtPlotCurve * > m_MCACurvesA
Definition: mcacontroller.h:75
void save_curves(QList< QwtPlotCurve * > &crvs, QString suffix, Qt::PenStyle style)
void MCAController::save_b ( )
slot

Definition at line 283 of file mcacontroller.cpp.

References m_MCACurvesB, and save_curves().

284 {
285 // printf("MCAController::save_b()\n");
286 
287  save_curves(m_MCACurvesB, ".B", Qt::DotLine);
288 }
QList< QwtPlotCurve * > m_MCACurvesB
Definition: mcacontroller.h:76
void save_curves(QList< QwtPlotCurve * > &crvs, QString suffix, Qt::PenStyle style)
void MCAController::save_c ( )
slot

Definition at line 290 of file mcacontroller.cpp.

References m_MCACurvesC, and save_curves().

291 {
292 // printf("MCAController::save_c()\n");
293 
294  save_curves(m_MCACurvesC, ".C", Qt::DashDotLine);
295 }
QList< QwtPlotCurve * > m_MCACurvesC
Definition: mcacontroller.h:77
void save_curves(QList< QwtPlotCurve * > &crvs, QString suffix, Qt::PenStyle style)
void MCAController::save_curves ( QList< QwtPlotCurve * > &  crvs,
QString  suffix,
Qt::PenStyle  style 
)
private

Definition at line 318 of file mcacontroller.cpp.

References m_MCACurves, and m_Plot.

Referenced by save_a(), save_b(), and save_c().

319 {
320  QwtPlotCurve *pc;
321 
322  foreach(pc, crvs) {
323 // printf("Detach %s\n", qPrintable(pc->title().text()));
324 
325  pc -> detach();
326  delete pc;
327  }
328 
329  crvs.clear();
330 
331  foreach(pc, m_MCACurves) {
332  QwtPlotCurve *pc1 = new QwtPlotCurve(pc->title().text()+suffix);
333  QwtSeriesData<QPointF> *data = pc->data();
334 
335  QVector<double> x(data->size()), y(data->size());
336 
337  for (int i=0; i<data->size(); i++) {
338  x[i] = data->sample(i).x();
339  y[i] = data->sample(i).y();
340  }
341 
342  QPen pen = pc->pen();
343 
344  pen.setStyle(style);
345 
346 // printf("pen style %d\n", (int) pen.style());
347 
348  pc1 -> setSamples(x,y);
349  pc1 -> setPen(pen);
350  pc1 -> attach(m_Plot);
351 
352  crvs.append(pc1);
353  }
354 }
QList< QwtPlotCurve * > m_MCACurves
Definition: mcacontroller.h:74
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void MCAController::saveData ( )
slot

Definition at line 255 of file mcacontroller.cpp.

References m_BM12ControlPanel.

Referenced by MCAController().

256 {
257  if (m_BM12ControlPanel) {
259  }
260 }
BM12ControlPanel * m_BM12ControlPanel
Definition: mcacontroller.h:89
void MCAController::saveEnergyWindows ( )
slot

Definition at line 262 of file mcacontroller.cpp.

References m_BM12ControlPanel.

Referenced by MCAController().

263 {
264  if (m_BM12ControlPanel) {
266  }
267 }
BM12ControlPanel * m_BM12ControlPanel
Definition: mcacontroller.h:89
void saveEnergyWindows()
void MCAController::wantToQuit ( )
slot

Definition at line 222 of file mcacontroller.cpp.

Referenced by MCAController().

223 {
224  if (QMessageBox::question(NULL, tr("Really Quit?"),
225  tr("Do you really want to exit the application?"),
226  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
227  qApp -> quit();
228  }
229 }
void MCAController::zoomIn ( )
slot

Definition at line 231 of file mcacontroller.cpp.

References m_Plot, m_Zoomer, and replot().

Referenced by MCAController().

232 {
233  m_Zoomer -> zoom(+1);
234 
235  m_Plot -> replot();
236 }
QwtPlotZoomer * m_Zoomer
Definition: mcacontroller.h:79
QwtPlot * m_Plot
Definition: mcacontroller.h:78
void MCAController::zoomOut ( )
slot

Definition at line 238 of file mcacontroller.cpp.

References m_Plot, m_Zoomer, and replot().

Referenced by MCAController().

239 {
240  m_Zoomer -> zoom(-1);
241 
242  m_Plot -> replot();
243 }
QwtPlotZoomer * m_Zoomer
Definition: mcacontroller.h:79
QwtPlot * m_Plot
Definition: mcacontroller.h:78

Member Data Documentation

A2DConverterControlPanel* MCAController::m_A2DConverterControlPanel
private

Definition at line 86 of file mcacontroller.h.

Referenced by addArgument().

Adding MCAController::m_Adding
private

Definition at line 83 of file mcacontroller.h.

Referenced by addArgument().

AmplifierControlPanel* MCAController::m_AmplifierControlPanel
private

Definition at line 85 of file mcacontroller.h.

Referenced by addArgument().

BM12ControlPanel* MCAController::m_BM12ControlPanel
private

Definition at line 89 of file mcacontroller.h.

Referenced by addArgument(), loadEnergyWindows(), saveData(), and saveEnergyWindows().

QwtPlotGrid* MCAController::m_Grid
private

Definition at line 82 of file mcacontroller.h.

QwtLegend* MCAController::m_Legend
private

Definition at line 81 of file mcacontroller.h.

Referenced by MCAController().

QMCAControlPanel* MCAController::m_MainControlPanel
private

Definition at line 73 of file mcacontroller.h.

Referenced by addArgument().

MCAMainWindow* MCAController::m_MainWindow
private

Definition at line 72 of file mcacontroller.h.

Referenced by MCAController().

MCAControlPanel* MCAController::m_MCAControlPanel
private

Definition at line 84 of file mcacontroller.h.

Referenced by addArgument().

QList<QwtPlotCurve*> MCAController::m_MCACurves
private

Definition at line 74 of file mcacontroller.h.

Referenced by addArgument(), and save_curves().

QList<QwtPlotCurve*> MCAController::m_MCACurvesA
private

Definition at line 75 of file mcacontroller.h.

Referenced by clear_a(), and save_a().

QList<QwtPlotCurve*> MCAController::m_MCACurvesB
private

Definition at line 76 of file mcacontroller.h.

Referenced by clear_b(), and save_b().

QList<QwtPlotCurve*> MCAController::m_MCACurvesC
private

Definition at line 77 of file mcacontroller.h.

Referenced by clear_c(), and save_c().

QwtPlotPanner* MCAController::m_Panner
private

Definition at line 80 of file mcacontroller.h.

Referenced by MCAController().

QwtPlot* MCAController::m_Plot
private
PowerSupplyControlPanel* MCAController::m_PowerSupplyControlPanel
private

Definition at line 88 of file mcacontroller.h.

Referenced by addArgument().

PulseAnalyserControlPanel* MCAController::m_PulseAnalyserControlPanel
private

Definition at line 87 of file mcacontroller.h.

Referenced by addArgument().

QTimer* MCAController::m_Timer
private

Definition at line 90 of file mcacontroller.h.

QwtPlotZoomer* MCAController::m_Zoomer
private

Definition at line 79 of file mcacontroller.h.

Referenced by autoscaleGraph(), MCAController(), replot(), zoomIn(), and zoomOut().


The documentation for this class was generated from the following files: