qse  0.5.4
Public Slots | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
QseGraphController Class Reference

#include <qsegraphcontroller.h>

Inheritance diagram for QseGraphController:
Inheritance graph

Public Slots

void printGraph ()
 
void setAutoScale ()
 
void showLegend ()
 
void hideLegend ()
 
void legendChecked (const QVariant &v, bool checked, int n)
 
void addContextMenuAction (QAction *action)
 
void setTitle (const QString &title)
 
void columnsCellClicked (const QModelIndex &index)
 
void saveSelectedScans ()
 
void removeSelectedScans ()
 
void zoomGraphIn ()
 
void zoomGraphOut ()
 
void zoomGraphAll ()
 

Public Member Functions

 QseGraphController (QseDataSet *ds, QWidget *parent=0)
 
 ~QseGraphController ()
 
QseDataSetdataSet () const
 
int selectedColumnCount () const
 
QString selectedColumn (int i) const
 
QList< int > selectedScans ()
 
int scanCount ()
 
bool selectedPlotX (int i) const
 
bool selectedPlotY (int i) const
 
bool selectedPlotY2 (int i) const
 
bool selectedPlotNorm (int i) const
 

Private Slots

void dataCleared ()
 
void dataChanged ()
 
void operationCompleted ()
 
void scanAdded (int s)
 
void scansSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 
void columnsSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 
void updateGraph ()
 
void scansListContextMenu (const QPoint &pos)
 
void columnsTableContextMenu (const QPoint &pos)
 
void graphContextMenu (const QPoint &pos)
 

Private Member Functions

bool scanSelected (int i)
 
void toggleGraphSelection (int n, QSet< QString > &set)
 
void enableAxes (bool y1, bool y2)
 
void setAxisTitle (int axisId, const QSet< QString > &names)
 
QwtSymbol * newSymbol (int n)
 

Private Attributes

QPen m_Pens [NPENS]
 
QList< QString > m_SelectedScanColumns
 
QHash< QString, int > m_SelectedScanColumnCounts
 
QSet< QString > m_PlotXColumns
 
QSet< QString > m_PlotYColumns
 
QSet< QString > m_PlotY2Columns
 
QSet< QString > m_PlotNormColumns
 
QseDataSetm_DataSet
 
QseGraphScansModelm_ScansModel
 
QItemSelectionModel * m_ScansSelection
 
QseGraphColumnsModelm_ColumnsModel
 
QItemSelectionModel * m_ColumnsSelection
 
QwtPlotZoomer * m_Zoomer
 
QwtPlotZoomer * m_Zoomer2
 
QwtPlotPanner * m_Panner
 
QwtPlotMagnifier * m_Magnifier
 
QwtLegend * m_Legend
 
bool m_LegendShown
 
QList< QAction * > m_Actions
 
int m_ScanPenStep
 
int m_ScanSymbolStep
 
int m_CurvePenStep
 
int m_CurveSymbolStep
 

Static Private Attributes

static const int MAX_CURVES = 500
 
static const int NPENS = 12
 
static const int NSYMBOLS = 12
 

Detailed Description

Definition at line 29 of file qsegraphcontroller.h.

Constructor & Destructor Documentation

QseGraphController::QseGraphController ( QseDataSet ds,
QWidget *  parent = 0 
)

Definition at line 29 of file qsegraphcontroller.cpp.

References columnsCellClicked(), columnsTableContextMenu(), dataChanged(), dataCleared(), enableAxes(), graphContextMenu(), legendChecked(), m_ColumnsModel, m_ColumnsSelection, m_DataSet, m_Legend, m_Magnifier, m_Panner, m_Pens, m_ScansModel, m_ScansSelection, m_Zoomer, m_Zoomer2, operationCompleted(), printGraph(), saveSelectedScans(), scansListContextMenu(), scansSelectionChanged(), zoomGraphAll(), zoomGraphIn(), and zoomGraphOut().

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),
44  m_CurvePenStep(0),
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 }
void scansSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
QItemSelectionModel * m_ColumnsSelection
QwtPlotPanner * m_Panner
QseGraphScansModel * m_ScansModel
void graphContextMenu(const QPoint &pos)
void enableAxes(bool y1, bool y2)
QwtPlotZoomer * m_Zoomer2
void columnsCellClicked(const QModelIndex &index)
void scansListContextMenu(const QPoint &pos)
void columnsTableContextMenu(const QPoint &pos)
QwtPlotMagnifier * m_Magnifier
void legendChecked(const QVariant &v, bool checked, int n)
QseGraphColumnsModel * m_ColumnsModel
QItemSelectionModel * m_ScansSelection
QwtPlotZoomer * m_Zoomer
QseGraphController::~QseGraphController ( )

Definition at line 146 of file qsegraphcontroller.cpp.

147 {
148 }

Member Function Documentation

void QseGraphController::addContextMenuAction ( QAction *  action)
slot

Definition at line 170 of file qsegraphcontroller.cpp.

References m_Actions.

171 {
172  m_Actions.append(action);
173 }
QList< QAction * > m_Actions
void QseGraphController::columnsCellClicked ( const QModelIndex &  index)
slot

Definition at line 334 of file qsegraphcontroller.cpp.

References m_ColumnsModel, m_PlotNormColumns, m_PlotXColumns, m_PlotY2Columns, m_PlotYColumns, QseGraphColumnsModel::rowCount(), toggleGraphSelection(), and updateGraph().

Referenced by QseGraphController().

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 }
QSet< QString > m_PlotYColumns
void toggleGraphSelection(int n, QSet< QString > &set)
QSet< QString > m_PlotXColumns
int rowCount(const QModelIndex &parent=QModelIndex()) const
QSet< QString > m_PlotNormColumns
QseGraphColumnsModel * m_ColumnsModel
QSet< QString > m_PlotY2Columns
void QseGraphController::columnsSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
privateslot

Definition at line 285 of file qsegraphcontroller.cpp.

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 }
QseGraphColumnsModel * m_ColumnsModel
void QseGraphController::columnsTableContextMenu ( const QPoint &  pos)
privateslot

Definition at line 700 of file qsegraphcontroller.cpp.

Referenced by QseGraphController().

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 }
void QseGraphController::dataChanged ( )
privateslot

Definition at line 197 of file qsegraphcontroller.cpp.

Referenced by QseGraphController().

198 {
199 }
void QseGraphController::dataCleared ( )
privateslot

Definition at line 189 of file qsegraphcontroller.cpp.

References m_ColumnsModel, m_SelectedScanColumnCounts, and m_SelectedScanColumns.

Referenced by QseGraphController().

190 {
191  m_SelectedScanColumns.clear();
193 
194  m_ColumnsModel -> columnsChanged();
195 }
QHash< QString, int > m_SelectedScanColumnCounts
QList< QString > m_SelectedScanColumns
QseGraphColumnsModel * m_ColumnsModel
QseDataSet * QseGraphController::dataSet ( ) const

Definition at line 150 of file qsegraphcontroller.cpp.

References m_DataSet.

151 {
152  return m_DataSet;
153 }
void QseGraphController::enableAxes ( bool  y1,
bool  y2 
)
private

Definition at line 598 of file qsegraphcontroller.cpp.

References m_Zoomer, and m_Zoomer2.

Referenced by QseGraphController(), and updateGraph().

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 }
QwtPlotZoomer * m_Zoomer2
QwtPlotZoomer * m_Zoomer
void QseGraphController::graphContextMenu ( const QPoint &  pos)
privateslot

Definition at line 725 of file qsegraphcontroller.cpp.

References hideLegend(), m_Actions, m_LegendShown, printGraph(), removeSelectedScans(), saveSelectedScans(), setAutoScale(), and showLegend().

Referenced by QseGraphController().

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 }
QList< QAction * > m_Actions
void QseGraphController::hideLegend ( )
slot

Definition at line 641 of file qsegraphcontroller.cpp.

References m_LegendShown.

Referenced by graphContextMenu().

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 }
void QseGraphController::legendChecked ( const QVariant &  v,
bool  checked,
int  n 
)
slot

Definition at line 675 of file qsegraphcontroller.cpp.

Referenced by QseGraphController().

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 }
QwtSymbol * QseGraphController::newSymbol ( int  n)
private

Definition at line 818 of file qsegraphcontroller.cpp.

References m_Pens.

Referenced by updateGraph().

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 }
void QseGraphController::operationCompleted ( )
privateslot

Definition at line 179 of file qsegraphcontroller.cpp.

References updateGraph().

Referenced by QseGraphController().

180 {
181 // printf("QseGraphController::operationCompleted\n");
182 
183 // m_ScansView->resizeRowsToContents();
184 // m_ScansView->resizeColumnsToContents();
185 
186  updateGraph();
187 }
void QseGraphController::printGraph ( )
slot

Definition at line 655 of file qsegraphcontroller.cpp.

Referenced by graphContextMenu(), and QseGraphController().

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 }
void QseGraphController::removeSelectedScans ( )
slot

Definition at line 797 of file qsegraphcontroller.cpp.

Referenced by graphContextMenu().

798 {
799 }
void QseGraphController::saveSelectedScans ( )
slot

Definition at line 792 of file qsegraphcontroller.cpp.

References QseDataExport::exportSelectedData(), m_DataSet, and selectedScans().

Referenced by graphContextMenu(), and QseGraphController().

793 {
794  QseDataExport::exportSelectedData(QString("export/%1").arg(m_DataSet->objectName()), m_DataSet, selectedScans());
795 }
QList< int > selectedScans()
static void exportSelectedData(const QString &id, QseDataSet *data, QList< int > selections)
void QseGraphController::scanAdded ( int  s)
privateslot

Definition at line 175 of file qsegraphcontroller.cpp.

176 {
177 }
int QseGraphController::scanCount ( )

Definition at line 773 of file qsegraphcontroller.cpp.

References m_DataSet.

Referenced by selectedScans(), and updateGraph().

774 {
775  return m_DataSet -> scanCount();
776 }
bool QseGraphController::scanSelected ( int  i)
private

Definition at line 201 of file qsegraphcontroller.cpp.

References m_ScansSelection.

Referenced by selectedScans(), and updateGraph().

202 {
203  return m_ScansSelection -> isRowSelected(i, QModelIndex());
204 }
QItemSelectionModel * m_ScansSelection
void QseGraphController::scansListContextMenu ( const QPoint &  pos)
privateslot

Definition at line 713 of file qsegraphcontroller.cpp.

Referenced by QseGraphController().

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 }
void QseGraphController::scansSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
privateslot

Definition at line 235 of file qsegraphcontroller.cpp.

References QseScan::column(), QseScan::columnCount(), and QseColumn::name().

Referenced by QseGraphController().

236 {
237 // printf("QseGraphController::scansSelectionChanged()\n");
238 
239  m_SelectedScanColumns.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 }
QHash< QString, int > m_SelectedScanColumnCounts
int columnCount() const
Definition: qsescan.cpp:45
QList< QString > m_SelectedScanColumns
QString name() const
Definition: qsecolumn.cpp:26
QseColumn * column(int n) const
Definition: qsescan.cpp:104
QseGraphColumnsModel * m_ColumnsModel
QString QseGraphController::selectedColumn ( int  i) const

Definition at line 160 of file qsegraphcontroller.cpp.

References m_SelectedScanColumns.

Referenced by QseGraphColumnsModel::data(), selectedPlotNorm(), selectedPlotX(), selectedPlotY(), and selectedPlotY2().

161 {
162  return m_SelectedScanColumns[i];
163 }
QList< QString > m_SelectedScanColumns
int QseGraphController::selectedColumnCount ( ) const

Definition at line 155 of file qsegraphcontroller.cpp.

References m_SelectedScanColumns.

Referenced by QseGraphColumnsModel::rowCount().

156 {
157  return m_SelectedScanColumns.count();
158 }
QList< QString > m_SelectedScanColumns
bool QseGraphController::selectedPlotNorm ( int  i) const

Definition at line 227 of file qsegraphcontroller.cpp.

References m_PlotNormColumns, and selectedColumn().

228 {
229  QString colname = selectedColumn(i);
230 
231  return m_PlotNormColumns.contains(colname);
232 }
QString selectedColumn(int i) const
QSet< QString > m_PlotNormColumns
bool QseGraphController::selectedPlotX ( int  i) const

Definition at line 206 of file qsegraphcontroller.cpp.

References m_PlotXColumns, and selectedColumn().

Referenced by QseGraphColumnsModel::data().

207 {
208  QString colname = selectedColumn(i);
209 
210  return m_PlotXColumns.contains(colname);
211 }
QString selectedColumn(int i) const
QSet< QString > m_PlotXColumns
bool QseGraphController::selectedPlotY ( int  i) const

Definition at line 213 of file qsegraphcontroller.cpp.

References m_PlotYColumns, and selectedColumn().

Referenced by QseGraphColumnsModel::data().

214 {
215  QString colname = selectedColumn(i);
216 
217  return m_PlotYColumns.contains(colname);
218 }
QString selectedColumn(int i) const
QSet< QString > m_PlotYColumns
bool QseGraphController::selectedPlotY2 ( int  i) const

Definition at line 220 of file qsegraphcontroller.cpp.

References m_PlotY2Columns, and selectedColumn().

Referenced by QseGraphColumnsModel::data().

221 {
222  QString colname = selectedColumn(i);
223 
224  return m_PlotY2Columns.contains(colname);
225 }
QString selectedColumn(int i) const
QSet< QString > m_PlotY2Columns
QList< int > QseGraphController::selectedScans ( )

Definition at line 778 of file qsegraphcontroller.cpp.

References scanCount(), and scanSelected().

Referenced by saveSelectedScans().

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 }
void QseGraphController::setAutoScale ( )
slot

Definition at line 616 of file qsegraphcontroller.cpp.

References m_Zoomer, and m_Zoomer2.

Referenced by graphContextMenu(), and zoomGraphAll().

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 }
QwtPlotZoomer * m_Zoomer2
QwtPlotZoomer * m_Zoomer
void QseGraphController::setAxisTitle ( int  axisId,
const QSet< QString > &  names 
)
private

Definition at line 567 of file qsegraphcontroller.cpp.

Referenced by updateGraph().

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 }
void setAxisTitle(int axisId, const QSet< QString > &names)
void QseGraphController::setTitle ( const QString &  title)
slot

Definition at line 165 of file qsegraphcontroller.cpp.

Referenced by updateGraph().

166 {
167  m_Graph -> setTitle(title);
168 }
void setTitle(const QString &title)
void QseGraphController::showLegend ( )
slot

Definition at line 627 of file qsegraphcontroller.cpp.

References m_LegendShown.

Referenced by graphContextMenu().

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 }
void QseGraphController::toggleGraphSelection ( int  n,
QSet< QString > &  set 
)
private

Definition at line 273 of file qsegraphcontroller.cpp.

Referenced by columnsCellClicked().

274 {
275  QString colname = selectedColumn(n);
276 
277  if (set.contains(colname)) {
278  set.remove(colname);
279  } else {
280  set.insert(colname);
281  }
282 }
QString selectedColumn(int i) const
void QseGraphController::updateGraph ( )
privateslot

Definition at line 363 of file qsegraphcontroller.cpp.

References QseScan::column(), QseScan::columnCount(), enableAxes(), m_CurvePenStep, m_CurveSymbolStep, m_DataSet, m_LegendShown, m_Pens, m_PlotXColumns, m_PlotY2Columns, m_PlotYColumns, m_ScanPenStep, m_ScanSymbolStep, m_Zoomer, m_Zoomer2, MAX_CURVES, QseColumn::name(), newSymbol(), NPENS, NSYMBOLS, QseScan::scanCommand(), scanCount(), QseScan::scanNumber(), scanSelected(), setAxisTitle(), and setTitle().

Referenced by columnsCellClicked(), and operationCompleted().

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 }
static const int NPENS
QSet< QString > m_PlotYColumns
QwtSymbol * newSymbol(int n)
void setAxisTitle(int axisId, const QSet< QString > &names)
int scanNumber() const
Definition: qsescan.cpp:353
static const int MAX_CURVES
QSet< QString > m_PlotXColumns
int columnCount() const
Definition: qsescan.cpp:45
QString scanCommand() const
Definition: qsescan.cpp:226
void enableAxes(bool y1, bool y2)
QwtPlotZoomer * m_Zoomer2
static const int NSYMBOLS
QString name() const
Definition: qsecolumn.cpp:26
void setTitle(const QString &title)
QseColumn * column(int n) const
Definition: qsescan.cpp:104
QSet< QString > m_PlotY2Columns
QwtPlotZoomer * m_Zoomer
void QseGraphController::zoomGraphAll ( )
slot

Definition at line 801 of file qsegraphcontroller.cpp.

References setAutoScale().

Referenced by QseGraphController().

802 {
803  setAutoScale();
804 }
void QseGraphController::zoomGraphIn ( )
slot

Definition at line 812 of file qsegraphcontroller.cpp.

References m_Zoomer, and m_Zoomer2.

Referenced by QseGraphController().

813 {
814  m_Zoomer -> zoom(1);
815  m_Zoomer2 -> zoom(1);
816 }
QwtPlotZoomer * m_Zoomer2
QwtPlotZoomer * m_Zoomer
void QseGraphController::zoomGraphOut ( )
slot

Definition at line 806 of file qsegraphcontroller.cpp.

References m_Zoomer, and m_Zoomer2.

Referenced by QseGraphController().

807 {
808  m_Zoomer -> zoom(-1);
809  m_Zoomer2 -> zoom(-1);
810 }
QwtPlotZoomer * m_Zoomer2
QwtPlotZoomer * m_Zoomer

Member Data Documentation

QList<QAction*> QseGraphController::m_Actions
private

Definition at line 122 of file qsegraphcontroller.h.

Referenced by addContextMenuAction(), and graphContextMenu().

QseGraphColumnsModel* QseGraphController::m_ColumnsModel
private

Definition at line 113 of file qsegraphcontroller.h.

Referenced by columnsCellClicked(), dataCleared(), and QseGraphController().

QItemSelectionModel* QseGraphController::m_ColumnsSelection
private

Definition at line 114 of file qsegraphcontroller.h.

Referenced by QseGraphController().

int QseGraphController::m_CurvePenStep
private

Definition at line 126 of file qsegraphcontroller.h.

Referenced by updateGraph().

int QseGraphController::m_CurveSymbolStep
private

Definition at line 127 of file qsegraphcontroller.h.

Referenced by updateGraph().

QseDataSet* QseGraphController::m_DataSet
private
QwtLegend* QseGraphController::m_Legend
private

Definition at line 120 of file qsegraphcontroller.h.

Referenced by QseGraphController().

bool QseGraphController::m_LegendShown
private

Definition at line 121 of file qsegraphcontroller.h.

Referenced by graphContextMenu(), hideLegend(), showLegend(), and updateGraph().

QwtPlotMagnifier* QseGraphController::m_Magnifier
private

Definition at line 119 of file qsegraphcontroller.h.

Referenced by QseGraphController().

QwtPlotPanner* QseGraphController::m_Panner
private

Definition at line 118 of file qsegraphcontroller.h.

Referenced by QseGraphController().

QPen QseGraphController::m_Pens[NPENS]
private

Definition at line 97 of file qsegraphcontroller.h.

Referenced by newSymbol(), QseGraphController(), and updateGraph().

QSet<QString> QseGraphController::m_PlotNormColumns
private

Definition at line 108 of file qsegraphcontroller.h.

Referenced by columnsCellClicked(), and selectedPlotNorm().

QSet<QString> QseGraphController::m_PlotXColumns
private

Definition at line 105 of file qsegraphcontroller.h.

Referenced by columnsCellClicked(), selectedPlotX(), and updateGraph().

QSet<QString> QseGraphController::m_PlotY2Columns
private

Definition at line 107 of file qsegraphcontroller.h.

Referenced by columnsCellClicked(), selectedPlotY2(), and updateGraph().

QSet<QString> QseGraphController::m_PlotYColumns
private

Definition at line 106 of file qsegraphcontroller.h.

Referenced by columnsCellClicked(), selectedPlotY(), and updateGraph().

int QseGraphController::m_ScanPenStep
private

Definition at line 124 of file qsegraphcontroller.h.

Referenced by updateGraph().

QseGraphScansModel* QseGraphController::m_ScansModel
private

Definition at line 111 of file qsegraphcontroller.h.

Referenced by QseGraphController().

QItemSelectionModel* QseGraphController::m_ScansSelection
private

Definition at line 112 of file qsegraphcontroller.h.

Referenced by QseGraphController(), and scanSelected().

int QseGraphController::m_ScanSymbolStep
private

Definition at line 125 of file qsegraphcontroller.h.

Referenced by updateGraph().

QHash<QString,int> QseGraphController::m_SelectedScanColumnCounts
private

Definition at line 103 of file qsegraphcontroller.h.

Referenced by dataCleared().

QList<QString> QseGraphController::m_SelectedScanColumns
private

Definition at line 102 of file qsegraphcontroller.h.

Referenced by dataCleared(), selectedColumn(), and selectedColumnCount().

QwtPlotZoomer* QseGraphController::m_Zoomer
private
QwtPlotZoomer* QseGraphController::m_Zoomer2
private
const int QseGraphController::MAX_CURVES = 500
staticprivate

Definition at line 94 of file qsegraphcontroller.h.

Referenced by updateGraph().

const int QseGraphController::NPENS = 12
staticprivate

Definition at line 96 of file qsegraphcontroller.h.

Referenced by updateGraph().

const int QseGraphController::NSYMBOLS = 12
staticprivate

Definition at line 99 of file qsegraphcontroller.h.

Referenced by updateGraph().


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