qse  0.5.4
qsegraphcontroller.cpp
Go to the documentation of this file.
1 #include "qsegraphcontroller.h"
2 
3 #include <QListWidget>
4 #include <QTableWidget>
5 #include <QPrinter>
6 #include <QPrintDialog>
7 #include <QMenu>
8 #include <QMap>
9 #include <QThread>
10 
11 #include <qwt_plot.h>
12 #include <qwt_plot_zoomer.h>
13 #include <qwt_plot_panner.h>
14 #include <qwt_plot_magnifier.h>
15 #include <qwt_plot_curve.h>
16 #include <qwt_plot_layout.h>
17 #include <qwt_legend.h>
18 #include <qwt_picker_machine.h>
19 #include <qwt_plot_renderer.h>
20 
21 #include "qsedataset.h"
22 #include "qsedataexport.h"
23 #include "qsedatareference.h"
24 #include "qsegraphscansmodel.h"
25 #include "qsegraphcolumnsmodel.h"
26 
27 #include <stdio.h>
28 
30  : QWidget(parent),
31  m_DataSet(f),
32  m_ScansModel(NULL),
33  m_ScansSelection(NULL),
34  m_ColumnsModel(NULL),
35  m_ColumnsSelection(NULL),
36  m_Zoomer(NULL),
37  m_Zoomer2(NULL),
38  m_Panner(NULL),
39  m_Magnifier(NULL),
40  m_Legend(NULL),
41  m_LegendShown(true),
42  m_ScanPenStep(1),
43  m_ScanSymbolStep(0),
44  m_CurvePenStep(0),
45  m_CurveSymbolStep(1)
46 {
47  m_Pens[0].setColor(Qt::black);
48  m_Pens[1].setColor(Qt::red);
49  m_Pens[2].setColor(Qt::green);
50  m_Pens[3].setColor(Qt::blue);
51  m_Pens[4].setColor(Qt::cyan);
52  m_Pens[5].setColor(Qt::magenta);
53  m_Pens[6].setColor(Qt::darkYellow);
54  m_Pens[7].setColor(Qt::darkRed);
55  m_Pens[8].setColor(Qt::darkGreen);
56  m_Pens[9].setColor(Qt::darkBlue);
57  m_Pens[10].setColor(Qt::darkCyan);
58  m_Pens[11].setColor(Qt::darkMagenta);
59 
60  setupUi(this);
61 
62  m_Graph->setCanvasBackground(QColor(Qt::white));
63 
64  m_Zoomer = new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, m_Graph->canvas());
65  m_Zoomer -> setStateMachine(new QwtPickerDragRectMachine());
66  m_Zoomer2 = new QwtPlotZoomer(QwtPlot::xTop, QwtPlot::yRight, m_Graph->canvas());
67  m_Zoomer2 -> setStateMachine(new QwtPickerDragRectMachine());
68 
69  m_Magnifier = new QwtPlotMagnifier(m_Graph->canvas());
70  m_Magnifier -> setMouseFactor(1.0);
71 
72  enableAxes(true, false);
73 
74  // RightButton: zoom out by 1
75  // Ctrl+RightButton: zoom out to full size
76 
77  m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect2,
78  Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier);
79  m_Zoomer2 -> setMousePattern(QwtEventPattern::MouseSelect2,
80  Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier);
81 
82  m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect3,
83  Qt::LeftButton, Qt::ControlModifier);
84  m_Zoomer2 -> setMousePattern(QwtEventPattern::MouseSelect3,
85  Qt::LeftButton, Qt::ControlModifier);
86 
87  m_Panner = new QwtPlotPanner(m_Graph->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_Graph -> insertLegend(m_Legend, QwtPlot::BottomLegend);
96 
97  connect(m_Legend, SIGNAL(checked(const QVariant&, bool, int)), this, SLOT(legendChecked(const QVariant&, bool, int)));
98 
99  m_Graph -> canvas() -> setContextMenuPolicy(Qt::CustomContextMenu);
100  connect(m_Graph -> canvas(), SIGNAL(customContextMenuRequested(const QPoint &)),
101  this, SLOT(graphContextMenu(const QPoint&)));
102 
103  m_ScansView -> setContextMenuPolicy(Qt::CustomContextMenu);
104  connect(m_ScansView, SIGNAL(customContextMenuRequested(const QPoint &)),
105  this, SLOT(scansListContextMenu(const QPoint &)));
106 
107  m_ColumnsView -> setContextMenuPolicy(Qt::CustomContextMenu);
108  connect(m_ColumnsView, SIGNAL(customContextMenuRequested(const QPoint &)),
109  this, SLOT(columnsTableContextMenu(const QPoint &)));
110 
111  m_ScansModel = new QseGraphScansModel(m_DataSet, m_ScansView, this);
112  m_ColumnsModel = new QseGraphColumnsModel(this, m_ColumnsView, this);
113 
114  m_ScansView -> setModel(m_ScansModel);
115  m_ColumnsView -> setModel(m_ColumnsModel);
116 
117  m_ScansSelection = m_ScansView->selectionModel();
118  m_ColumnsSelection = m_ColumnsView->selectionModel();
119 
120  connect(m_DataSet, SIGNAL(dataCleared()), this, SLOT(dataCleared()));
121  connect(m_DataSet, SIGNAL(dataChanged()), this, SLOT(dataChanged()));
122  connect(m_DataSet, SIGNAL(operationCompleted()), this, SLOT(operationCompleted()));
123 // connect(m_DataSet, SIGNAL(scanAdded(int)), this, SLOT(scanAdded(int)));
124 
125  connect(m_ColumnsView, SIGNAL(clicked(const QModelIndex&)),
126  this, SLOT(columnsCellClicked(const QModelIndex&)));
127 
128  connect(m_ScansSelection,
129  SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
130  this,
131  SLOT(scansSelectionChanged(const QItemSelection&, const QItemSelection&)));
132 
133  connect(m_PrintButton, SIGNAL(clicked()), this, SLOT(printGraph()));
134  connect(m_ZoomAllButton, SIGNAL(clicked()), this, SLOT(zoomGraphAll()));
135  connect(m_ZoomInButton, SIGNAL(clicked()), this, SLOT(zoomGraphIn()));
136  connect(m_ZoomOutButton, SIGNAL(clicked()), this, SLOT(zoomGraphOut()));
137  connect(m_ExportButton, SIGNAL(clicked()), this, SLOT(saveSelectedScans()));
138 
139  m_ScansView->resizeColumnsToContents();
140  m_ScansView->resizeRowsToContents();
141 
142  m_ColumnsView->resizeColumnsToContents();
143  m_ColumnsView->resizeRowsToContents();
144 }
145 
147 {
148 }
149 
151 {
152  return m_DataSet;
153 }
154 
156 {
157  return m_SelectedScanColumns.count();
158 }
159 
161 {
162  return m_SelectedScanColumns[i];
163 }
164 
165 void QseGraphController::setTitle(const QString &title)
166 {
167  m_Graph -> setTitle(title);
168 }
169 
171 {
172  m_Actions.append(action);
173 }
174 
176 {
177 }
178 
180 {
181 // printf("QseGraphController::operationCompleted\n");
182 
183 // m_ScansView->resizeRowsToContents();
184 // m_ScansView->resizeColumnsToContents();
185 
186  updateGraph();
187 }
188 
190 {
191  m_SelectedScanColumns.clear();
193 
194  m_ColumnsModel -> columnsChanged();
195 }
196 
198 {
199 }
200 
202 {
203  return m_ScansSelection -> isRowSelected(i, QModelIndex());
204 }
205 
207 {
208  QString colname = selectedColumn(i);
209 
210  return m_PlotXColumns.contains(colname);
211 }
212 
214 {
215  QString colname = selectedColumn(i);
216 
217  return m_PlotYColumns.contains(colname);
218 }
219 
221 {
222  QString colname = selectedColumn(i);
223 
224  return m_PlotY2Columns.contains(colname);
225 }
226 
228 {
229  QString colname = selectedColumn(i);
230 
231  return m_PlotNormColumns.contains(colname);
232 }
233 
235 (const QItemSelection & selected, const QItemSelection & deselected)
236 {
237 // printf("QseGraphController::scansSelectionChanged()\n");
238 
239  m_SelectedScanColumns.clear();
240  m_SelectedScanColumnCounts.clear();
241 
242  int n = scanCount();
243 
244  for (int i = 0; i<n; i++) {
245  if (scanSelected(i)) {
246  QseScan* s = m_DataSet -> scan(i);
247 
248  if (s) {
249  int nc = s->columnCount();
250 
251  for (int i=0; i<nc; i++) {
252  QseColumn* col = s->column(i);
253  if (col) {
254  QString colname = col->name();
255  if (!m_SelectedScanColumnCounts.contains(colname)) {
256  m_SelectedScanColumns.append(colname);
257  }
258  m_SelectedScanColumnCounts[colname] += 1;
259  }
260  }
261  }
262  }
263  }
264 
265  m_ColumnsModel -> columnsChanged();
266 // m_ColumnsView->resizeRowsToContents();
267 // m_ColumnsView->resizeColumnsToContents();
268 
269  updateGraph();
270 }
271 
273 (int n, QSet<QString>& set)
274 {
275  QString colname = selectedColumn(n);
276 
277  if (set.contains(colname)) {
278  set.remove(colname);
279  } else {
280  set.insert(colname);
281  }
282 }
283 
285 (const QItemSelection & selected, const QItemSelection & deselected)
286 {
287 // printf("QseGraphController::columnsSelectionChanged()\n");
288 
289  QItemSelectionRange r;
290 
291  foreach(r, selected) {
292  int tp=r.top(), bt=r.bottom();
293  int lf=r.left(), rt=r.right();
294  for (int i=tp; i<=bt; i++) {
295  for (int j=lf; j<=rt; j++) {
296  printf("QseGraphController::columnsSelectionChanged::selected(%d,%d)\n",i,j);
297 // switch(j) {
298 // case 1:
299 // m_PlotXColumns.clear();
300 // toggleGraphSelection(i, m_PlotXColumns);
301 // break;
302 // case 2:
303 // toggleGraphSelection(i, m_PlotYColumns);
304 // break;
305 // case 3:
306 // toggleGraphSelection(i, m_PlotY2Columns);
307 // break;
308 // case 4:
309 // toggleGraphSelection(i, m_PlotNormColumns);
310 // break;
311 // }
312  }
313  }
314 
315  m_ColumnsModel -> emitDataChanged(r.topLeft(), r.bottomRight());
316  }
317 
318  foreach(r, deselected) {
319  int tp=r.top(), bt=r.bottom();
320  int lf=r.left(), rt=r.right();
321  for (int i=tp; i<=bt; i++) {
322  for (int j=lf; j<=rt; j++) {
323  printf("QseGraphController::columnsSelectionChanged::deselected(%d,%d)\n",i,j);
324  }
325  }
326 
327  m_ColumnsModel -> emitDataChanged(r.topLeft(), r.bottomRight());
328  }
329 // m_ColumnsModel -> columnsChanged();
330 
331  updateGraph();
332 }
333 
334 void QseGraphController::columnsCellClicked(const QModelIndex& index)
335 {
336 // printf("QseGraphController::columnsCellClicked(%d,%d)\n", index.column(), index.row());
337 
338  int i = index.row(), j = index.column();
339 
340  switch (j) {
341  case 1:
342  m_PlotXColumns.clear();
344  m_ColumnsModel -> emitDataChanged(m_ColumnsModel->index(0,1),
345  m_ColumnsModel->index(m_ColumnsModel->rowCount(),1));
346  break;
347  case 2:
349  break;
350  case 3:
352  break;
353  case 4:
355  break;
356  }
357 
358  m_ColumnsModel -> emitDataChanged(index, index);
359 
360  updateGraph();
361 }
362 
364 {
365 // printf("QseGraphController::updateGraph()\n");
366 
367  m_Graph -> detachItems(QwtPlotItem::Rtti_PlotCurve);
368  m_Graph -> detachItems(QwtPlotItem::Rtti_PlotMarker);
369 
370  int s;
371  int nscans = 0;
372  int nscanstotal = m_DataSet -> scanCount();
373 
374  for (s=0; s<nscanstotal; s++) {
375  if (scanSelected(s)) {
376  nscans++;
377  }
378  }
379 
380  int pnnum = 0;
381  int smnum = -1;
382 
383  int ncurves = 0;
384  int npscans = 0;
385  int ncrvscn = 0;
386 
387  QSet<QString> xnames, ynames, y2names;
388 
389  if (nscans > 1) {
390  m_Graph -> setTitle(QString("%1 Scans").arg(nscans));
391  }
392 
393  int hasy1 = false;
394  int hasy2 = false;
395 
396  for (s=0; s<nscanstotal; s++) {
397  if (scanSelected(s)) {
398 // printf("Scan %d\n", s);
399 
400  ncrvscn = 0;
401 
402  if (m_ScanPenStep) {
403  pnnum = (pnnum + m_ScanPenStep + NPENS) % NPENS;
404  } else {
405  pnnum = 0;
406  }
407 
408  if (m_ScanSymbolStep) {
409  smnum = (smnum + m_ScanSymbolStep + NSYMBOLS) % NSYMBOLS;
410  } else {
411  smnum = 0;
412  }
413 
414  QseScan *scan = m_DataSet -> scan(s);
415 
416  if (scan) {
417  if (nscans == 1) {
418  m_Graph->setTitle(scan->scanCommand());
419  }
420  int nc = scan->columnCount();
421  QseColumn *xc = NULL;
422  int nxc = -1;
423 
424  for (int c = 0; c<nc; c++) {
425  QseColumn *col = scan->column(c);
426  if (col) {
427  QString colname = col->name();
428 
429  if (m_PlotXColumns.contains(colname)) {
430  xc = col;
431  nxc = c;
432  break;
433  }
434  }
435  }
436 
437  if (nc && (xc == NULL)) {
438  xc = scan->column(0);
439  nxc = 0;
440  }
441 
442  if (xc) {
443  // int nr = xc->rowCount();
444  int nnc = 0;
445 
446  for (int c = 0; c<nc; c++) {
447  QseColumn *yc = scan->column(c);
448  if (yc) {
449  QString colname = yc->name();
450 
451  if (m_PlotYColumns.contains(colname)) {
452  QString name;
453  nnc += 1;
454  ncurves += 1;
455 
456  if (nnc == 1) {
457  xnames.insert(xc->name());
458  }
459  ynames.insert(colname);
460 
461  if (ncurves <= MAX_CURVES) {
462  if (ncrvscn == 0) {
463  npscans += 1;
464  }
465  ncrvscn += 1;
466 
467  if (nscans == 1) {
468  name = colname;
469  } else {
470  name = QString("S%1:%2").arg(scan->scanNumber()).arg(colname);
471  }
472 
473  QwtPlotCurve *pc = new QwtPlotCurve(name);
474  // pc->setData(xc->data(), yc->data(), nr);
475  pc->setData(new QseDataReference(m_DataSet, s, nxc, c));
476  pc->setPen(m_Pens[pnnum]);
477  QwtSymbol *ps = newSymbol(smnum);
478  ps->setPen(m_Pens[pnnum]);
479  ps->setBrush(QBrush(m_Pens[pnnum].color()));
480  pc->setSymbol(ps);
481  pnnum = (pnnum + m_CurvePenStep + NPENS) % NPENS;
482  smnum = (smnum + m_CurveSymbolStep + NSYMBOLS) % NSYMBOLS;
483  pc->setItemAttribute(QwtPlotItem::Legend, m_LegendShown);
484  pc->attach(m_Graph);
485  hasy1 = true;
486  }
487  }
488  }
489  }
490 
491  for (int c = 0; c<nc; c++) {
492  QseColumn *yc = scan->column(c);
493  if (yc) {
494  QString colname = yc->name();
495 
496  if (m_PlotY2Columns.contains(colname)) {
497  QString name;
498  nnc += 1;
499  ncurves += 1;
500 
501  if (nnc == 1) {
502  xnames.insert(xc->name());
503  }
504  y2names.insert(colname);
505 
506  if (ncurves <= MAX_CURVES) {
507  if (ncrvscn == 0) {
508  npscans += 1;
509  }
510  ncrvscn += 1;
511 
512  if (nscans == 1) {
513  name = colname;
514  } else {
515  name = QString("S%1:%2").arg(scan->scanNumber()).arg(colname);
516  }
517 
518  QwtPlotCurve *pc = new QwtPlotCurve(name);
519  // pc->setData(xc->data(), yc->data(), nr);
520  pc->setData(new QseDataReference(m_DataSet, s, nxc, c));
521  pc->setYAxis(QwtPlot::yRight);
522  pc->setPen(m_Pens[pnnum]);
523  QwtSymbol *ps = newSymbol(smnum);
524  ps->setPen(m_Pens[pnnum]);
525  ps->setBrush(QBrush(m_Pens[pnnum].color()));
526  pc->setSymbol(ps);
527  pnnum = (pnnum + m_CurvePenStep + NPENS) % NPENS;
528  smnum = (smnum + m_CurveSymbolStep + NSYMBOLS) % NSYMBOLS;
529  pc->setItemAttribute(QwtPlotItem::Legend, m_LegendShown);
530  pc->attach(m_Graph);
531  hasy2 = true;
532  }
533  }
534  }
535  }
536  }
537  }
538  }
539  }
540 
541  if (ncurves > MAX_CURVES) {
542  m_Graph -> setTitle(QString("%1 of %2 curves from %3 scans").
543  arg(MAX_CURVES).arg(ncurves).arg(npscans));
544  } else if (npscans > 1) {
545  m_Graph -> setTitle(QString("%1 curves from %2 scans").arg(ncurves).arg(npscans));
546  }
547 
548  setAxisTitle(QwtPlot::xBottom, xnames);
549  setAxisTitle(QwtPlot::yLeft, ynames);
550  setAxisTitle(QwtPlot::yRight, y2names);
551 
552  enableAxes(hasy1, hasy2);
553 
554  m_Graph -> replot();
555 
556  if (m_Zoomer -> zoomRectIndex() == 0) {
557  m_Zoomer -> setZoomBase();
558  }
559 
560  if (m_Zoomer2 -> zoomRectIndex() == 0) {
561  m_Zoomer2 -> setZoomBase();
562  }
563 
564 // printf("finished\n");
565 }
566 
567 void QseGraphController::setAxisTitle(int axisId, const QSet<QString>& names)
568 {
569  QString title, name;
570  int n = names.count();
571  int nt;
572 
573  if (n == 0) {
574  m_Graph -> setAxisTitle(axisId, "");
575  } else {
576  if (n > 4) {
577  nt = 4;
578  } else {
579  nt = n;
580  }
581 
582  QSet<QString>::const_iterator it = names.constBegin();
583  title = *it;
584 
585  for (int i = 1; i<nt; i++) {
586  it++;
587  title += ", " + *it;
588  }
589 
590  if (n > nt) {
591  title += "...";
592  }
593 
594  m_Graph -> setAxisTitle(axisId, title);
595  }
596 }
597 
598 void QseGraphController::enableAxes(bool y1, bool y2)
599 {
600  m_Graph -> enableAxis(QwtPlot::yLeft, y1 | !y2);
601  m_Graph -> enableAxis(QwtPlot::yRight, y2);
602 
603  if (y1 | !y2) {
604  m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOn);
605  m_Zoomer -> setRubberBand(QwtPicker::RectRubberBand);
606  m_Zoomer2 -> setTrackerMode(QwtPicker::AlwaysOff);
607  m_Zoomer2 -> setRubberBand(QwtPicker::NoRubberBand);
608  } else {
609  m_Zoomer2 -> setTrackerMode(QwtPicker::AlwaysOn);
610  m_Zoomer2 -> setRubberBand(QwtPicker::RectRubberBand);
611  m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOff);
612  m_Zoomer -> setRubberBand(QwtPicker::NoRubberBand);
613  }
614 }
615 
617 {
618  m_Graph -> setAxisAutoScale(QwtPlot::xBottom);
619  m_Graph -> setAxisAutoScale(QwtPlot::yLeft);
620  m_Graph -> setAxisAutoScale(QwtPlot::yRight);
621  m_Graph -> replot();
622 
623  m_Zoomer -> setZoomBase();
624  m_Zoomer2 -> setZoomBase();
625 }
626 
628 {
629  m_LegendShown = true;
630 
631  QwtPlotItem *item;
632  const QwtPlotItemList &items = m_Graph->itemList();
633 
634  foreach (item, items) {
635  item->setItemAttribute(QwtPlotItem::Legend, true);
636  }
637 
638  m_Graph -> updateLayout();
639 }
640 
642 {
643  m_LegendShown = false;
644 
645  QwtPlotItem *item;
646  const QwtPlotItemList &items = m_Graph->itemList();
647 
648  foreach (item, items) {
649  item->setItemAttribute(QwtPlotItem::Legend, false);
650  }
651 
652  m_Graph -> updateLayout();
653 }
654 
656 {
657  QPrinter printer (QPrinter::HighResolution);
658 
659  printer.setCreator("Spec EXAFS Processor");
660  // printer.setOrientation(QPrinter::Landscape);
661 
662  QPrintDialog dialog(&printer);
663 
664  if (dialog.exec()) {
665  QwtPlotRenderer filter;
666 
667 // if ( printer.colorMode() == QPrinter::GrayScale ) {
668 // filter.setOptions(QwtPlotPrintFilter::PrintAll & ~QwtPlotPrintFilter::PrintCanvasBackground);
669 // }
670 
671  filter.renderTo(m_Graph, printer);
672  }
673 }
674 
675 void QseGraphController::legendChecked(const QVariant &v, bool checked, int n)
676 {
677 // printf("QseGraphController::legendChecked(%s,%d,%d)\n", qPrintable(v.toString()), checked, n);
678 
679  QwtPlotItem *item = m_Graph->infoToItem(v);
680 
681  if (item) {
682  QwtPlotCurve *pc = dynamic_cast<QwtPlotCurve*>(item);
683 
684  if (pc) {
685  QPen p = pc->pen();
686  if (checked) {
687  p.setWidth(3);
688  } else {
689  p.setWidth(0);
690  }
691 
692  if (m_Graph) {
693  pc->setPen(p);
694  m_Graph->replot();
695  }
696  }
697  }
698 }
699 
701 {
702  QMenu menu(NULL, NULL);
703 
704  QAction* selectCells = menu.addAction(QString("Select..."));
705  QAction* deselectCells = menu.addAction(QString("Deselect..."));
706 
707  menu.setMouseTracking(true);
708 
709  QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), selectCells);
710 
711 }
712 
714 {
715  QMenu menu(NULL, NULL);
716 
717  QAction* selectCells = menu.addAction(QString("Select..."));
718  QAction* deselectCells = menu.addAction(QString("Deselect..."));
719 
720  menu.setMouseTracking(true);
721 
722  QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), selectCells);
723 }
724 
726 {
727  QMenu menu(NULL, NULL);
728  QAction *action;
729 
730  foreach (action, m_Actions) {
731  menu.addAction(action);
732  }
733 
734  QAction* autoscaleItem = menu.addAction(QString("Autoscale Graph"));
735  QAction* printItem = menu.addAction(QString("Print Graph..."));
736 
737  QAction* showLegendItem = NULL;
738  QAction* hideLegendItem = NULL;
739 
740  if (m_LegendShown) {
741  hideLegendItem = menu.addAction(QString("Hide Legend"));
742  } else {
743  showLegendItem = menu.addAction(QString("Display Legend"));
744  }
745 
746  QAction* saveItem = NULL;
747  QAction* removeItem = NULL;
748 
749  if (m_ScansView) {
750  saveItem = menu.addAction(QString("Save selected scans"));
751  removeItem = menu.addAction(QString("Remove selected scans"));
752  }
753 
754  menu.setMouseTracking(true);
755 
756  QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), saveItem);
757 
758  if (id == autoscaleItem) {
759  setAutoScale();
760  } else if (id == printItem) {
761  printGraph();
762  } else if (id == showLegendItem) {
763  showLegend();
764  } else if (id == hideLegendItem) {
765  hideLegend();
766  } else if (m_ScansView && (id == saveItem)) {
768  } else if (m_ScansView && (id == removeItem)) {
770  }
771 }
772 
774 {
775  return m_DataSet -> scanCount();
776 }
777 
779 {
780  QList<int> res;
781  int nscans = scanCount();
782 
783  for (int i=0; i<nscans; i++) {
784  if (scanSelected(i)) {
785  res.append(i);
786  }
787  }
788 
789  return res;
790 }
791 
793 {
794  QseDataExport::exportSelectedData(QString("export/%1").arg(m_DataSet->objectName()), m_DataSet, selectedScans());
795 }
796 
798 {
799 }
800 
802 {
803  setAutoScale();
804 }
805 
807 {
808  m_Zoomer -> zoom(-1);
809  m_Zoomer2 -> zoom(-1);
810 }
811 
813 {
814  m_Zoomer -> zoom(1);
815  m_Zoomer2 -> zoom(1);
816 }
817 
819 {
820 // printf("QseGraphController::newSymbol(%d)\n", n);
821 
822  QwtSymbol *res = NULL;
823 
824  switch (n) {
825  default:
826  case 0:
827  res = new QwtSymbol(QwtSymbol::Ellipse, QBrush(), m_Pens[0], QSize(3,3));
828  break;
829 
830  case 1:
831  res = new QwtSymbol(QwtSymbol::Ellipse, QBrush(), m_Pens[1], QSize(5,5));
832  break;
833 
834  case 2:
835  res = new QwtSymbol(QwtSymbol::Rect, QBrush(), m_Pens[2], QSize(5,5));
836  break;
837 
838  case 3:
839  res = new QwtSymbol(QwtSymbol::Diamond, QBrush(), m_Pens[3], QSize(5,5));
840  break;
841 
842  case 4:
843  res = new QwtSymbol(QwtSymbol::Triangle, QBrush(), m_Pens[4], QSize(5,5));
844  break;
845 
846  case 5:
847  res = new QwtSymbol(QwtSymbol::DTriangle, QBrush(), m_Pens[5], QSize(5,5));
848  break;
849 
850  case 6:
851  res = new QwtSymbol(QwtSymbol::UTriangle, QBrush(), m_Pens[6], QSize(5,5));
852  break;
853 
854  case 7:
855  res = new QwtSymbol(QwtSymbol::LTriangle, QBrush(), m_Pens[7], QSize(5,5));
856  break;
857 
858  case 8:
859  res = new QwtSymbol(QwtSymbol::RTriangle, QBrush(), m_Pens[8], QSize(5,5));
860  break;
861 
862  case 9:
863  res = new QwtSymbol(QwtSymbol::Cross, QBrush(), m_Pens[9], QSize(5,5));
864  break;
865 
866  case 10:
867  res = new QwtSymbol(QwtSymbol::XCross, QBrush(), m_Pens[10], QSize(5,5));
868  break;
869 
870  case 11:
871  res = new QwtSymbol(QwtSymbol::Star1, QBrush(), m_Pens[11], QSize(5,5));
872  break;
873  }
874 
875  return res;
876 }
static const int NPENS
QString selectedColumn(int i) const
QSet< QString > m_PlotYColumns
QwtSymbol * newSymbol(int n)
QHash< QString, int > m_SelectedScanColumnCounts
void setAxisTitle(int axisId, const QSet< QString > &names)
void scansSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
bool selectedPlotY(int i) const
QseGraphController(QseDataSet *ds, QWidget *parent=0)
QItemSelectionModel * m_ColumnsSelection
void toggleGraphSelection(int n, QSet< QString > &set)
QwtPlotPanner * m_Panner
bool selectedPlotX(int i) const
int scanNumber() const
Definition: qsescan.cpp:353
QseGraphScansModel * m_ScansModel
static const int MAX_CURVES
void graphContextMenu(const QPoint &pos)
QSet< QString > m_PlotXColumns
int columnCount() const
Definition: qsescan.cpp:45
QString scanCommand() const
Definition: qsescan.cpp:226
QList< int > selectedScans()
void columnsSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
static void exportSelectedData(const QString &id, QseDataSet *data, QList< int > selections)
void enableAxes(bool y1, bool y2)
QwtPlotZoomer * m_Zoomer2
void columnsCellClicked(const QModelIndex &index)
static const int NSYMBOLS
QList< QString > m_SelectedScanColumns
QList< QAction * > m_Actions
QString name() const
Definition: qsecolumn.cpp:26
int rowCount(const QModelIndex &parent=QModelIndex()) const
void setTitle(const QString &title)
void addContextMenuAction(QAction *action)
void scansListContextMenu(const QPoint &pos)
QseColumn * column(int n) const
Definition: qsescan.cpp:104
void columnsTableContextMenu(const QPoint &pos)
QwtPlotMagnifier * m_Magnifier
QSet< QString > m_PlotNormColumns
void legendChecked(const QVariant &v, bool checked, int n)
QseGraphColumnsModel * m_ColumnsModel
QSet< QString > m_PlotY2Columns
int selectedColumnCount() const
bool selectedPlotY2(int i) const
bool selectedPlotNorm(int i) const
QItemSelectionModel * m_ScansSelection
QseDataSet * dataSet() const
QwtPlotZoomer * m_Zoomer