#include <qsegraphcontroller.h>


Public Slots | |
| void | columnsSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected) |
| void | printGraph () |
| void | setAutoScale () |
| void | showLegend () |
| void | hideLegend () |
| void | legendChecked (QwtPlotItem *pi, bool checked) |
| void | addContextMenuAction (QAction *action) |
| void | setTitle (const QString &title) |
| void | columnsCellClicked (const QModelIndex &index) |
| void | columnsCellPressed (const QModelIndex &index) |
| void | columnsCellEntered (const QModelIndex &index) |
| void | saveSelectedScans () |
| void | removeSelectedScans () |
Public Member Functions | |
| QseGraphController (QseDataSet *ds, QWidget *parent=0) | |
| ~QseGraphController () | |
| QseDataSet * | dataSet () const |
| int | selectedColumnCount () const |
| QString | selectedColumn (int i) const |
| 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 | loadCompleted () |
| void | scansSelectionChanged (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 | |
| void | selectScan (int i) |
| void | toggleGraphSelection (int n, QSet< QString > &set) |
| void | enableAxes (bool y1, bool y2) |
| void | setAxisTitle (int axisId, const QSet< QString > &names) |
Private Attributes | |
| QPen | m_Pens [NPENS] |
| QwtSymbol | m_Symbols [NSYMBOLS] |
| QList< int > | m_SelectedScans |
| 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 |
| QseDataSet * | m_DataSet |
| QseGraphScansModel * | m_ScansModel |
| QItemSelectionModel * | m_ScansSelection |
| QseGraphColumnsModel * | m_ColumnsModel |
| QItemSelectionModel * | m_ColumnsSelection |
| QwtPlotZoomer * | m_Zoomer |
| QwtPlotZoomer * | m_Zoomer2 |
| QwtPlotPanner * | m_Panner |
| QwtLegend * | m_Legend |
| bool | m_LegendShown |
| QList< QAction * > | m_Actions |
Static Private Attributes | |
| static const int | MAX_CURVES = 500 |
| static const int | NPENS = 12 |
| static const int | NSYMBOLS = 12 |
Definition at line 26 of file qsegraphcontroller.h.
| QseGraphController::QseGraphController | ( | QseDataSet * | ds, | |
| QWidget * | parent = 0 | |||
| ) |
Definition at line 28 of file qsegraphcontroller.cpp.
References columnsCellClicked(), columnsTableContextMenu(), dataChanged(), dataCleared(), enableAxes(), graphContextMenu(), legendChecked(), loadCompleted(), m_ColumnsModel, m_ColumnsSelection, m_DataSet, m_Legend, m_Panner, m_Pens, m_ScansModel, m_ScansSelection, m_Symbols, m_Zoomer, m_Zoomer2, scansListContextMenu(), and scansSelectionChanged().
00029 : QWidget(parent), 00030 m_DataSet(f), 00031 m_ScansModel(NULL), 00032 m_ScansSelection(NULL), 00033 m_ColumnsModel(NULL), 00034 m_ColumnsSelection(NULL), 00035 m_Zoomer(NULL), 00036 m_Zoomer2(NULL), 00037 m_Panner(NULL), 00038 m_Legend(NULL), 00039 m_LegendShown(true) 00040 { 00041 m_Pens[0].setColor(Qt::black); 00042 m_Pens[1].setColor(Qt::red); 00043 m_Pens[2].setColor(Qt::green); 00044 m_Pens[3].setColor(Qt::blue); 00045 m_Pens[4].setColor(Qt::cyan); 00046 m_Pens[5].setColor(Qt::magenta); 00047 m_Pens[6].setColor(Qt::darkYellow); 00048 m_Pens[7].setColor(Qt::darkRed); 00049 m_Pens[8].setColor(Qt::darkGreen); 00050 m_Pens[9].setColor(Qt::darkBlue); 00051 m_Pens[10].setColor(Qt::darkCyan); 00052 m_Pens[11].setColor(Qt::darkMagenta); 00053 00054 m_Symbols[0] = QwtSymbol(QwtSymbol::NoSymbol, QBrush(), m_Pens[0], QSize(5,5)); 00055 m_Symbols[1] = QwtSymbol(QwtSymbol::Ellipse, QBrush(), m_Pens[1], QSize(5,5)); 00056 m_Symbols[2] = QwtSymbol(QwtSymbol::Rect, QBrush(), m_Pens[2], QSize(5,5)); 00057 m_Symbols[3] = QwtSymbol(QwtSymbol::Diamond, QBrush(), m_Pens[3], QSize(5,5)); 00058 m_Symbols[4] = QwtSymbol(QwtSymbol::Triangle, QBrush(), m_Pens[4], QSize(5,5)); 00059 m_Symbols[5] = QwtSymbol(QwtSymbol::DTriangle, QBrush(), m_Pens[5], QSize(5,5)); 00060 m_Symbols[6] = QwtSymbol(QwtSymbol::UTriangle, QBrush(), m_Pens[6], QSize(5,5)); 00061 m_Symbols[7] = QwtSymbol(QwtSymbol::LTriangle, QBrush(), m_Pens[7], QSize(5,5)); 00062 m_Symbols[8] = QwtSymbol(QwtSymbol::RTriangle, QBrush(), m_Pens[8], QSize(5,5)); 00063 m_Symbols[9] = QwtSymbol(QwtSymbol::Cross, QBrush(), m_Pens[9], QSize(5,5)); 00064 m_Symbols[10] = QwtSymbol(QwtSymbol::XCross, QBrush(), m_Pens[10], QSize(5,5)); 00065 m_Symbols[11] = QwtSymbol(QwtSymbol::Star1, QBrush(), m_Pens[11], QSize(5,5)); 00066 00067 setupUi(this); 00068 00069 m_Graph->setCanvasBackground(QColor(Qt::white)); 00070 00071 m_Zoomer = new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, m_Graph->canvas()); 00072 m_Zoomer -> setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner); 00073 00074 m_Zoomer2 = new QwtPlotZoomer(QwtPlot::xTop, QwtPlot::yRight, m_Graph->canvas()); 00075 m_Zoomer2 -> setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner); 00076 00077 enableAxes(true, false); 00078 00079 // RightButton: zoom out by 1 00080 // Ctrl+RightButton: zoom out to full size 00081 00082 #if QT_VERSION < 0x040000 00083 00084 m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect2, 00085 Qt::LeftButton, Qt::ControlButton | Qt::ShiftButton); 00086 m_Zoomer2 -> setMousePattern(QwtEventPattern::MouseSelect2, 00087 Qt::LeftButton, Qt::ControlButton | Qt::ShiftButton); 00088 #else 00089 00090 m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect2, 00091 Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier); 00092 m_Zoomer2 -> setMousePattern(QwtEventPattern::MouseSelect2, 00093 Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier); 00094 #endif 00095 00096 m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect3, 00097 Qt::LeftButton, Qt::ControlModifier); 00098 m_Zoomer2 -> setMousePattern(QwtEventPattern::MouseSelect3, 00099 Qt::LeftButton, Qt::ControlModifier); 00100 00101 m_Panner = new QwtPlotPanner(m_Graph->canvas()); 00102 m_Panner -> setMouseButton(Qt::MidButton); 00103 m_Panner -> setEnabled(true); 00104 00105 m_Legend = new QwtLegend; 00106 m_Legend -> setFrameStyle(QFrame::Box|QFrame::Sunken); 00107 m_Legend -> setItemMode(QwtLegend::CheckableItem); 00108 00109 m_Graph -> insertLegend(m_Legend, QwtPlot::BottomLegend); 00110 00111 connect(m_Graph, SIGNAL(legendChecked(QwtPlotItem*,bool)), 00112 this, SLOT(legendChecked(QwtPlotItem*,bool))); 00113 00114 m_Graph -> canvas() -> setContextMenuPolicy(Qt::CustomContextMenu); 00115 connect(m_Graph -> canvas(), SIGNAL(customContextMenuRequested(const QPoint &)), 00116 this, SLOT(graphContextMenu(const QPoint&))); 00117 00118 connect(m_DataSet, SIGNAL(dataCleared()), this, SLOT(dataCleared())); 00119 connect(m_DataSet, SIGNAL(dataChanged()), this, SLOT(dataChanged())); 00120 00121 m_ScansView -> setContextMenuPolicy(Qt::CustomContextMenu); 00122 connect(m_ScansView, SIGNAL(customContextMenuRequested(const QPoint &)), 00123 this, SLOT(scansListContextMenu(const QPoint &))); 00124 00125 m_ColumnsView -> setContextMenuPolicy(Qt::CustomContextMenu); 00126 connect(m_ColumnsView, SIGNAL(customContextMenuRequested(const QPoint &)), 00127 this, SLOT(columnsTableContextMenu(const QPoint &))); 00128 00129 m_ScansModel = new QseGraphScansModel(m_DataSet, this); 00130 m_ColumnsModel = new QseGraphColumnsModel(this, this); 00131 00132 m_ScansView -> setModel(m_ScansModel); 00133 m_ColumnsView -> setModel(m_ColumnsModel); 00134 00135 m_ScansSelection = m_ScansView->selectionModel(); 00136 m_ColumnsSelection = m_ColumnsView->selectionModel(); 00137 00138 m_ColumnsView -> setItemDelegate(new QseGraphColumnsDelegate(this)); 00139 00140 connect(m_DataSet, SIGNAL(loadCompleted()), 00141 this, SLOT(loadCompleted())); 00142 00143 connect(m_ColumnsView, SIGNAL(clicked(const QModelIndex&)), 00144 this, SLOT(columnsCellClicked(const QModelIndex&))); 00145 00146 // connect(m_ColumnsView, SIGNAL(pressed(const QModelIndex&)), 00147 // this, SLOT(columnsCellPressed(const QModelIndex&))); 00148 00149 // connect(m_ColumnsView, SIGNAL(entered(const QModelIndex&)), 00150 // this, SLOT(columnsCellEntered(const QModelIndex&))); 00151 00152 connect(m_ScansSelection, 00153 SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), 00154 this, 00155 SLOT(scansSelectionChanged(const QItemSelection&, const QItemSelection&))); 00156 00157 // connect(m_ColumnsSelection, 00158 // SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), 00159 // this, 00160 // SLOT(columnsSelectionChanged(const QItemSelection&, const QItemSelection&))); 00161 }

| QseGraphController::~QseGraphController | ( | ) |
| void QseGraphController::columnsSelectionChanged | ( | const QItemSelection & | selected, | |
| const QItemSelection & | deselected | |||
| ) | [slot] |
Definition at line 314 of file qsegraphcontroller.cpp.
References m_ColumnsModel, and updateGraph().
00315 { 00316 printf("QseGraphController::columnsSelectionChanged\n"); 00317 00318 QItemSelectionRange r; 00319 00320 foreach(r, selected) { 00321 int tp=r.top(), bt=r.bottom(); 00322 int lf=r.left(), rt=r.right(); 00323 for (int i=tp; i<=bt; i++) { 00324 for (int j=lf; j<=rt; j++) { 00325 printf("QseGraphController::columnsSelectionChanged::selected(%d,%d)\n",i,j); 00326 // switch(j) { 00327 // case 1: 00328 // m_PlotXColumns.clear(); 00329 // toggleGraphSelection(i, m_PlotXColumns); 00330 // break; 00331 // case 2: 00332 // toggleGraphSelection(i, m_PlotYColumns); 00333 // break; 00334 // case 3: 00335 // toggleGraphSelection(i, m_PlotY2Columns); 00336 // break; 00337 // case 4: 00338 // toggleGraphSelection(i, m_PlotNormColumns); 00339 // break; 00340 // } 00341 } 00342 } 00343 00344 m_ColumnsModel -> emitDataChanged(r.topLeft(), r.bottomRight()); 00345 } 00346 00347 foreach(r, deselected) { 00348 int tp=r.top(), bt=r.bottom(); 00349 int lf=r.left(), rt=r.right(); 00350 for (int i=tp; i<=bt; i++) { 00351 for (int j=lf; j<=rt; j++) { 00352 printf("QseGraphController::columnsSelectionChanged::deselected(%d,%d)\n",i,j); 00353 } 00354 } 00355 00356 m_ColumnsModel -> emitDataChanged(r.topLeft(), r.bottomRight()); 00357 } 00358 // m_ColumnsModel -> columnsChanged(); 00359 00360 updateGraph(); 00361 }
| void QseGraphController::printGraph | ( | ) | [slot] |
Definition at line 670 of file qsegraphcontroller.cpp.
Referenced by graphContextMenu().
00671 { 00672 QPrinter printer; 00673 00674 printer.setCreator("Spec EXAFS Processor"); 00675 // printer.setOrientation(QPrinter::Landscape); 00676 00677 QPrintDialog dialog(&printer); 00678 00679 if (dialog.exec()) { 00680 QwtPlotPrintFilter filter; 00681 00682 if ( printer.colorMode() == QPrinter::GrayScale ) { 00683 filter.setOptions(QwtPlotPrintFilter::PrintAll & ~QwtPlotPrintFilter::PrintCanvasBackground); 00684 } 00685 00686 m_Graph -> print(printer, filter); 00687 } 00688 }
| void QseGraphController::setAutoScale | ( | ) | [slot] |
Definition at line 631 of file qsegraphcontroller.cpp.
References m_Zoomer, and m_Zoomer2.
Referenced by graphContextMenu().
00632 { 00633 m_Graph -> setAxisAutoScale(QwtPlot::xBottom); 00634 m_Graph -> setAxisAutoScale(QwtPlot::yLeft); 00635 m_Graph -> setAxisAutoScale(QwtPlot::yRight); 00636 m_Graph -> replot(); 00637 00638 m_Zoomer -> setZoomBase(); 00639 m_Zoomer2 -> setZoomBase(); 00640 }
| void QseGraphController::showLegend | ( | ) | [slot] |
Definition at line 642 of file qsegraphcontroller.cpp.
References m_LegendShown.
Referenced by graphContextMenu().
00643 { 00644 m_LegendShown = true; 00645 00646 QwtPlotItem *item; 00647 const QwtPlotItemList &items = m_Graph->itemList(); 00648 00649 foreach (item, items) { 00650 item->setItemAttribute(QwtPlotItem::Legend, true); 00651 } 00652 00653 m_Graph -> updateLayout(); 00654 }
| void QseGraphController::hideLegend | ( | ) | [slot] |
Definition at line 656 of file qsegraphcontroller.cpp.
References m_LegendShown.
Referenced by graphContextMenu().
00657 { 00658 m_LegendShown = false; 00659 00660 QwtPlotItem *item; 00661 const QwtPlotItemList &items = m_Graph->itemList(); 00662 00663 foreach (item, items) { 00664 item->setItemAttribute(QwtPlotItem::Legend, false); 00665 } 00666 00667 m_Graph -> updateLayout(); 00668 }
| void QseGraphController::legendChecked | ( | QwtPlotItem * | pi, | |
| bool | checked | |||
| ) | [slot] |
Definition at line 690 of file qsegraphcontroller.cpp.
Referenced by QseGraphController().
00691 { 00692 if (it) { 00693 QwtPlotCurve *pc = dynamic_cast<QwtPlotCurve*>(it); 00694 00695 if (pc) { 00696 QPen p = pc->pen(); 00697 if (checked) { 00698 p.setWidth(3); 00699 } else { 00700 p.setWidth(0); 00701 } 00702 00703 if (m_Graph) { 00704 pc->setPen(p); 00705 m_Graph->replot(); 00706 } 00707 } 00708 } 00709 }
| void QseGraphController::addContextMenuAction | ( | QAction * | action | ) | [slot] |
Definition at line 187 of file qsegraphcontroller.cpp.
References m_Actions.
00188 { 00189 m_Actions.append(action); 00190 }
| void QseGraphController::setTitle | ( | const QString & | title | ) | [slot] |
Definition at line 182 of file qsegraphcontroller.cpp.
Referenced by updateGraph().
00183 { 00184 m_Graph -> setTitle(title); 00185 }
| void QseGraphController::columnsCellClicked | ( | const QModelIndex & | index | ) | [slot] |
Definition at line 363 of file qsegraphcontroller.cpp.
References m_ColumnsModel, m_PlotNormColumns, m_PlotXColumns, m_PlotY2Columns, m_PlotYColumns, QseGraphColumnsModel::rowCount(), toggleGraphSelection(), and updateGraph().
Referenced by QseGraphController().
00364 { 00365 // printf("QseGraphController::columnsCellClicked(%d,%d)\n", index.column(), index.row()); 00366 00367 int i = index.row(), j = index.column(); 00368 00369 switch (j) { 00370 case 1: 00371 m_PlotXColumns.clear(); 00372 toggleGraphSelection(i, m_PlotXColumns); 00373 m_ColumnsModel -> emitDataChanged(m_ColumnsModel->index(0,1), 00374 m_ColumnsModel->index(m_ColumnsModel->rowCount(),1)); 00375 break; 00376 case 2: 00377 toggleGraphSelection(i, m_PlotYColumns); 00378 break; 00379 case 3: 00380 toggleGraphSelection(i, m_PlotY2Columns); 00381 break; 00382 case 4: 00383 toggleGraphSelection(i, m_PlotNormColumns); 00384 break; 00385 } 00386 00387 m_ColumnsModel -> emitDataChanged(index, index); 00388 00389 updateGraph(); 00390 }
| void QseGraphController::columnsCellPressed | ( | const QModelIndex & | index | ) | [slot] |
Definition at line 392 of file qsegraphcontroller.cpp.
00393 { 00394 printf("QseGraphController::columnsCellPressed(%d,%d)\n", index.column(), index.row()); 00395 }
| void QseGraphController::columnsCellEntered | ( | const QModelIndex & | index | ) | [slot] |
Definition at line 397 of file qsegraphcontroller.cpp.
00398 { 00399 printf("QseGraphController::columnsCellEntered(%d,%d)\n", index.column(), index.row()); 00400 }
| QseDataSet * QseGraphController::dataSet | ( | ) | const |
Definition at line 167 of file qsegraphcontroller.cpp.
References m_DataSet.
00168 { 00169 return m_DataSet; 00170 }
| int QseGraphController::selectedColumnCount | ( | ) | const |
Definition at line 172 of file qsegraphcontroller.cpp.
References m_SelectedScanColumns.
Referenced by QseGraphColumnsModel::rowCount().
00173 { 00174 return m_SelectedScanColumns.count(); 00175 }
| QString QseGraphController::selectedColumn | ( | int | i | ) | const |
Definition at line 177 of file qsegraphcontroller.cpp.
References m_SelectedScanColumns.
Referenced by QseGraphColumnsModel::data(), selectedPlotNorm(), selectedPlotX(), selectedPlotY(), selectedPlotY2(), and toggleGraphSelection().
00178 { 00179 return m_SelectedScanColumns[i]; 00180 }
| bool QseGraphController::selectedPlotX | ( | int | i | ) | const |
Definition at line 248 of file qsegraphcontroller.cpp.
References m_PlotXColumns, and selectedColumn().
Referenced by QseGraphColumnsModel::data().
00249 { 00250 QString colname = selectedColumn(i); 00251 00252 return m_PlotXColumns.contains(colname); 00253 }

| bool QseGraphController::selectedPlotY | ( | int | i | ) | const |
Definition at line 255 of file qsegraphcontroller.cpp.
References m_PlotYColumns, and selectedColumn().
Referenced by QseGraphColumnsModel::data().
00256 { 00257 QString colname = selectedColumn(i); 00258 00259 return m_PlotYColumns.contains(colname); 00260 }

| bool QseGraphController::selectedPlotY2 | ( | int | i | ) | const |
Definition at line 262 of file qsegraphcontroller.cpp.
References m_PlotY2Columns, and selectedColumn().
Referenced by QseGraphColumnsModel::data().
00263 { 00264 QString colname = selectedColumn(i); 00265 00266 return m_PlotY2Columns.contains(colname); 00267 }

| bool QseGraphController::selectedPlotNorm | ( | int | i | ) | const |
Definition at line 269 of file qsegraphcontroller.cpp.
References m_PlotNormColumns, and selectedColumn().
Referenced by QseGraphColumnsModel::data().
00270 { 00271 QString colname = selectedColumn(i); 00272 00273 return m_PlotNormColumns.contains(colname); 00274 }

| void QseGraphController::dataCleared | ( | ) | [private, slot] |
Definition at line 198 of file qsegraphcontroller.cpp.
References m_ColumnsModel, m_SelectedScanColumnCounts, m_SelectedScanColumns, and m_SelectedScans.
Referenced by QseGraphController().
00199 { 00200 printf("QseGraphController::dataCleared\n"); 00201 00202 m_SelectedScans.clear(); 00203 m_SelectedScanColumns.clear(); 00204 m_SelectedScanColumnCounts.clear(); 00205 00206 m_ColumnsModel -> columnsChanged(); 00207 // m_ScansView->clear(); 00208 }
| void QseGraphController::dataChanged | ( | ) | [private, slot] |
Definition at line 210 of file qsegraphcontroller.cpp.
Referenced by QseGraphController().
00211 { 00212 // printf("QseGraphController::dataChanged\n"); 00213 00214 // int nscans = m_DataSet -> scanCount(); 00215 // int nlines = m_ScansView -> count(); 00216 00217 // if (nscans > nlines) { 00218 // for (int i = nlines; i<nscans; i++) { 00219 // m_ScansView->addItem(m_DataSet->scan(i)->name()); 00220 // } 00221 // } else if (nscans < nlines) { 00222 // printf("QseGraphController::dataChanged removed scans:%d lines%d\n", nscans, nlines); 00223 // } 00224 }
| void QseGraphController::loadCompleted | ( | ) | [private, slot] |
Definition at line 192 of file qsegraphcontroller.cpp.
Referenced by QseGraphController().
00193 { 00194 m_ScansView->resizeRowsToContents(); 00195 m_ScansView->resizeColumnsToContents(); 00196 }
| void QseGraphController::scansSelectionChanged | ( | const QItemSelection & | selected, | |
| const QItemSelection & | deselected | |||
| ) | [private, slot] |
Definition at line 277 of file qsegraphcontroller.cpp.
References m_ColumnsModel, m_ScansSelection, m_SelectedScanColumnCounts, m_SelectedScanColumns, m_SelectedScans, selectScan(), and updateGraph().
Referenced by QseGraphController().
00278 { 00279 const QItemSelection s = m_ScansSelection -> selection(); 00280 QItemSelectionRange r; 00281 00282 m_SelectedScans.clear(); 00283 m_SelectedScanColumns.clear(); 00284 m_SelectedScanColumnCounts.clear(); 00285 00286 foreach(r, s) { 00287 int t=r.top(), b=r.bottom(); 00288 00289 for (int i=t; i<=b; i++) { 00290 selectScan(i); 00291 } 00292 } 00293 00294 m_ColumnsModel -> columnsChanged(); 00295 m_ColumnsView->resizeRowsToContents(); 00296 m_ColumnsView->resizeColumnsToContents(); 00297 00298 updateGraph(); 00299 }
| void QseGraphController::updateGraph | ( | ) | [private, slot] |
Definition at line 402 of file qsegraphcontroller.cpp.
References QseScan::column(), QseScan::columnCount(), enableAxes(), m_DataSet, m_LegendShown, m_Pens, m_PlotXColumns, m_PlotY2Columns, m_PlotYColumns, m_SelectedScans, m_Symbols, m_Zoomer, m_Zoomer2, MAX_CURVES, QseColumn::name(), NPENS, NSYMBOLS, QseScan::scanCommand(), QseScan::scanNumber(), setAxisTitle(), and setTitle().
Referenced by columnsCellClicked(), columnsSelectionChanged(), and scansSelectionChanged().
00403 { 00404 // printf("QseGraphController::updateGraph()\n"); 00405 00406 m_Graph -> clear(); 00407 00408 int s; 00409 int nscans = m_SelectedScans.count(); 00410 00411 int pnnum = 0; 00412 int smnum = -1; 00413 00414 int ncurves = 0; 00415 int npscans = 0; 00416 int ncrvscn = 0; 00417 00418 QSet<QString> xnames, ynames, y2names; 00419 00420 if (nscans > 1) { 00421 m_Graph -> setTitle(QString("%1 Scans").arg(nscans)); 00422 } 00423 00424 int hasy1 = false; 00425 int hasy2 = false; 00426 00427 foreach(s, m_SelectedScans) { 00428 // printf("Scan %d\n", s); 00429 00430 ncrvscn = 0; 00431 pnnum = 0; 00432 smnum = (smnum + 1) % NSYMBOLS; 00433 00434 QseScan *scan = m_DataSet -> scan(s); 00435 00436 if (scan) { 00437 if (nscans == 1) { 00438 m_Graph->setTitle(scan->scanCommand()); 00439 } 00440 int nc = scan->columnCount(); 00441 QseColumn *xc = NULL; 00442 int nxc = -1; 00443 00444 for (int c = 0; c<nc; c++) { 00445 QseColumn *col = scan->column(c); 00446 if (col) { 00447 QString colname = col->name(); 00448 00449 if (m_PlotXColumns.contains(colname)) { 00450 xc = col; 00451 nxc = c; 00452 break; 00453 } 00454 } 00455 } 00456 00457 if (nc && (xc == NULL)) { 00458 xc = scan->column(0); 00459 nxc = 0; 00460 } 00461 00462 if (xc) { 00463 // int nr = xc->rowCount(); 00464 int nnc = 0; 00465 00466 for (int c = 0; c<nc; c++) { 00467 QseColumn *yc = scan->column(c); 00468 if (yc) { 00469 QString colname = yc->name(); 00470 00471 if (m_PlotYColumns.contains(colname)) { 00472 QString name; 00473 nnc += 1; 00474 ncurves += 1; 00475 00476 if (nnc == 1) { 00477 xnames.insert(xc->name()); 00478 } 00479 ynames.insert(colname); 00480 00481 if (ncurves <= MAX_CURVES) { 00482 if (ncrvscn == 0) { 00483 npscans += 1; 00484 } 00485 ncrvscn += 1; 00486 00487 if (nscans == 1) { 00488 name = colname; 00489 } else { 00490 name = QString("S%1:%2").arg(scan->scanNumber()).arg(colname); 00491 } 00492 00493 QwtPlotCurve *pc = new QwtPlotCurve(name); 00494 // pc->setData(xc->data(), yc->data(), nr); 00495 pc->setData(QseDataReference(m_DataSet, s, nxc, c)); 00496 pc->setPen(m_Pens[pnnum]); 00497 QwtSymbol ps = m_Symbols[smnum]; 00498 ps.setPen(m_Pens[pnnum]); 00499 ps.setBrush(QBrush(m_Pens[pnnum].color())); 00500 pc->setSymbol(ps); 00501 pnnum = (pnnum + 1) % NPENS; 00502 pc->setItemAttribute(QwtPlotItem::Legend, m_LegendShown); 00503 pc->attach(m_Graph); 00504 hasy1 = true; 00505 } 00506 } 00507 } 00508 } 00509 00510 for (int c = 0; c<nc; c++) { 00511 QseColumn *yc = scan->column(c); 00512 if (yc) { 00513 QString colname = yc->name(); 00514 00515 if (m_PlotY2Columns.contains(colname)) { 00516 QString name; 00517 nnc += 1; 00518 ncurves += 1; 00519 00520 if (nnc == 1) { 00521 xnames.insert(xc->name()); 00522 } 00523 y2names.insert(colname); 00524 00525 if (ncurves <= MAX_CURVES) { 00526 if (ncrvscn == 0) { 00527 npscans += 1; 00528 } 00529 ncrvscn += 1; 00530 00531 if (nscans == 1) { 00532 name = colname; 00533 } else { 00534 name = QString("S%1:%2").arg(scan->scanNumber()).arg(colname); 00535 } 00536 00537 QwtPlotCurve *pc = new QwtPlotCurve(name); 00538 // pc->setData(xc->data(), yc->data(), nr); 00539 pc->setData(QseDataReference(m_DataSet, s, nxc, c)); 00540 pc->setYAxis(QwtPlot::yRight); 00541 pc->setPen(m_Pens[pnnum]); 00542 QwtSymbol ps = m_Symbols[smnum]; 00543 ps.setPen(m_Pens[pnnum]); 00544 ps.setBrush(QBrush(m_Pens[pnnum].color())); 00545 pc->setSymbol(ps); 00546 pnnum = (pnnum + 1) % NPENS; 00547 pc->setItemAttribute(QwtPlotItem::Legend, m_LegendShown); 00548 pc->attach(m_Graph); 00549 hasy2 = true; 00550 } 00551 } 00552 } 00553 } 00554 } 00555 } 00556 } 00557 00558 if (ncurves > MAX_CURVES) { 00559 m_Graph -> setTitle(QString("%1 of %2 curves from %3 scans"). 00560 arg(MAX_CURVES).arg(ncurves).arg(npscans)); 00561 } else if (npscans > 1) { 00562 m_Graph -> setTitle(QString("%1 curves from %2 scans").arg(ncurves).arg(npscans)); 00563 } 00564 00565 setAxisTitle(QwtPlot::xBottom, xnames); 00566 setAxisTitle(QwtPlot::yLeft, ynames); 00567 setAxisTitle(QwtPlot::yRight, y2names); 00568 00569 enableAxes(hasy1, hasy2); 00570 00571 m_Graph -> replot(); 00572 00573 if (m_Zoomer -> zoomRectIndex() == 0) { 00574 m_Zoomer -> setZoomBase(); 00575 } 00576 00577 if (m_Zoomer2 -> zoomRectIndex() == 0) { 00578 m_Zoomer2 -> setZoomBase(); 00579 } 00580 }
| void QseGraphController::scansListContextMenu | ( | const QPoint & | pos | ) | [private, slot] |
Definition at line 724 of file qsegraphcontroller.cpp.
Referenced by QseGraphController().
00725 { 00726 QMenu menu(NULL, NULL); 00727 00728 QAction* selectCells = menu.addAction(QString("Select...")); 00729 QAction* deselectCells = menu.addAction(QString("Deselect...")); 00730 00731 menu.setMouseTracking(TRUE); 00732 00733 QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), selectCells); 00734 }
| void QseGraphController::columnsTableContextMenu | ( | const QPoint & | pos | ) | [private, slot] |
Definition at line 711 of file qsegraphcontroller.cpp.
Referenced by QseGraphController().
00712 { 00713 QMenu menu(NULL, NULL); 00714 00715 QAction* selectCells = menu.addAction(QString("Select...")); 00716 QAction* deselectCells = menu.addAction(QString("Deselect...")); 00717 00718 menu.setMouseTracking(TRUE); 00719 00720 QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), selectCells); 00721 00722 }
| void QseGraphController::graphContextMenu | ( | const QPoint & | pos | ) | [private, slot] |
Definition at line 736 of file qsegraphcontroller.cpp.
References hideLegend(), m_Actions, m_LegendShown, printGraph(), removeSelectedScans(), saveSelectedScans(), setAutoScale(), and showLegend().
Referenced by QseGraphController().
00737 { 00738 QMenu menu(NULL, NULL); 00739 QAction *action; 00740 00741 foreach (action, m_Actions) { 00742 menu.addAction(action); 00743 } 00744 00745 QAction* autoscaleItem = menu.addAction(QString("Autoscale Graph")); 00746 QAction* printItem = menu.addAction(QString("Print Graph...")); 00747 00748 QAction* showLegendItem = NULL; 00749 QAction* hideLegendItem = NULL; 00750 00751 if (m_LegendShown) { 00752 hideLegendItem = menu.addAction(QString("Hide Legend")); 00753 } else { 00754 showLegendItem = menu.addAction(QString("Display Legend")); 00755 } 00756 00757 QAction* saveItem = NULL; 00758 QAction* removeItem = NULL; 00759 00760 if (m_ScansView) { 00761 saveItem = menu.addAction(QString("Save selected scans")); 00762 removeItem = menu.addAction(QString("Remove selected scans")); 00763 } 00764 00765 menu.setMouseTracking(TRUE); 00766 00767 QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), saveItem); 00768 00769 if (id == autoscaleItem) { 00770 setAutoScale(); 00771 } else if (id == printItem) { 00772 printGraph(); 00773 } else if (id == showLegendItem) { 00774 showLegend(); 00775 } else if (id == hideLegendItem) { 00776 hideLegend(); 00777 } else if (m_ScansView && (id == saveItem)) { 00778 saveSelectedScans(); 00779 } else if (m_ScansView && (id == removeItem)) { 00780 removeSelectedScans(); 00781 } 00782 }
| void QseGraphController::saveSelectedScans | ( | ) | [slot] |
Definition at line 784 of file qsegraphcontroller.cpp.
References QseDataExport::exportSelectedData(), m_DataSet, and m_SelectedScans.
Referenced by graphContextMenu().
00785 { 00786 QseDataExport::exportSelectedData("export/data", m_DataSet, m_SelectedScans); 00787 }
| void QseGraphController::removeSelectedScans | ( | ) | [slot] |
| void QseGraphController::selectScan | ( | int | i | ) | [private] |
Definition at line 226 of file qsegraphcontroller.cpp.
References QseScan::column(), QseScan::columnCount(), m_DataSet, m_SelectedScanColumnCounts, m_SelectedScanColumns, m_SelectedScans, and QseColumn::name().
Referenced by scansSelectionChanged().
00227 { 00228 m_SelectedScans.append(i); 00229 00230 QseScan* s = m_DataSet -> scan(i); 00231 00232 if (s) { 00233 int nc = s->columnCount(); 00234 00235 for (int i=0; i<nc; i++) { 00236 QseColumn* col = s->column(i); 00237 if (col) { 00238 QString colname = col->name(); 00239 if (!m_SelectedScanColumnCounts.contains(colname)) { 00240 m_SelectedScanColumns.append(colname); 00241 } 00242 m_SelectedScanColumnCounts[colname] += 1; 00243 } 00244 } 00245 } 00246 }

| void QseGraphController::toggleGraphSelection | ( | int | n, | |
| QSet< QString > & | set | |||
| ) | [private] |
Definition at line 302 of file qsegraphcontroller.cpp.
References selectedColumn().
Referenced by columnsCellClicked().
00303 { 00304 QString colname = selectedColumn(n); 00305 00306 if (set.contains(colname)) { 00307 set.remove(colname); 00308 } else { 00309 set.insert(colname); 00310 } 00311 }

| void QseGraphController::enableAxes | ( | bool | y1, | |
| bool | y2 | |||
| ) | [private] |
Definition at line 613 of file qsegraphcontroller.cpp.
References m_Zoomer, and m_Zoomer2.
Referenced by QseGraphController(), and updateGraph().
00614 { 00615 m_Graph -> enableAxis(QwtPlot::yLeft, y1 | !y2); 00616 m_Graph -> enableAxis(QwtPlot::yRight, y2); 00617 00618 if (y1 | !y2) { 00619 m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOn); 00620 m_Zoomer -> setRubberBand(QwtPicker::RectRubberBand); 00621 m_Zoomer2 -> setTrackerMode(QwtPicker::AlwaysOff); 00622 m_Zoomer2 -> setRubberBand(QwtPicker::NoRubberBand); 00623 } else { 00624 m_Zoomer2 -> setTrackerMode(QwtPicker::AlwaysOn); 00625 m_Zoomer2 -> setRubberBand(QwtPicker::RectRubberBand); 00626 m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOff); 00627 m_Zoomer -> setRubberBand(Qwt