8 #include <qwt_legend.h>
9 #include <qwt_plot_grid.h>
10 #include <qwt_plot_spectrogram.h>
11 #include <qwt_symbol.h>
12 #include <qwt_scale_engine.h>
21 #include "CubePlotCurveConfigureDialog.h"
25 #include "MainWindow.h"
27 #include "PlotWindowBestFitDialog.h"
33 #include "TableMainWindow.h"
64 setObjectName(
"Plot Window: " + title);
71 IString msg =
"PlotWindow cannot be instantiated with a NULL parent";
75 installEventFilter(
this);
79 setWindowTitle(title);
83 connect(QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
87 connect(
this, SIGNAL(requestFillTable()),
88 this, SLOT(
fillTable()), Qt::QueuedConnection);
100 plot()->setAxisTitle(QwtPlot::xBottom, unitLabels[xAxisUnits]);
101 plot()->setAxisTitle(QwtPlot::yLeft, unitLabels[yAxisUnits]);
109 setWindowFlags(Qt::Tool);
111 setWindowFlags(Qt::Dialog);
117 PlotWindow::~PlotWindow() {
134 m_plot->installEventFilter(
this);
135 m_plot->setAxisMaxMinor(QwtPlot::yLeft, 5);
136 m_plot->setAxisMaxMajor(QwtPlot::xBottom, 30);
137 m_plot->setAxisMaxMinor(QwtPlot::xBottom, 5);
138 m_plot->setAxisLabelRotation(QwtPlot::xBottom, 45);
139 m_plot->setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignRight);
142 QwtLegend *legend =
new QwtLegend();
143 legend->setItemMode(QwtLegend::ClickableItem);
144 legend->setWhatsThis(
"Right Click on a legend item to display the context "
146 m_plot->insertLegend(legend, QwtPlot::RightLegend, 1.0);
147 legend->installEventFilter(
this);
152 m_grid->setMajPen(QPen(Qt::white, 1, Qt::DotLine));
153 m_grid->setMinPen(QPen(Qt::gray, 1, Qt::DotLine));
155 m_grid->setVisible(
false);
159 m_zoomer->setRubberBandPen(QPen(Qt::lightGray));
160 m_zoomer->setTrackerPen(QPen(Qt::lightGray));
195 m_plot->setAxisTitle(axisId, title);
228 return m_plot->title().text();
276 m_plot->setCanvasBackground(c);
304 return m_plot->canvasBackground().color();
317 const QwtPlotItemList &plotItems =
m_plot->itemList();
319 for (
int itemIndex = 0; itemIndex < plotItems.size(); itemIndex++) {
322 if (item->rtti() == QwtPlotItem::Rtti_PlotCurve) {
325 if (curve && curve->
color().alpha() != 0)
326 foundCurves.append(curve);
343 const QwtPlotItemList &plotItems =
m_plot->itemList();
345 for (
int itemIndex = 0; itemIndex < plotItems.size(); itemIndex++) {
348 if (item->rtti() == QwtPlotItem::Rtti_PlotCurve) {
352 foundCurves.append(curve);
370 const QwtPlotItemList &plotItems =
m_plot->itemList();
372 for (
int itemIndex = 0; itemIndex < plotItems.size(); itemIndex++) {
375 if (item->rtti() == QwtPlotItem::Rtti_PlotSpectrogram) {
376 QwtPlotSpectrogram *spectrogram =
377 dynamic_cast<QwtPlotSpectrogram *
>(item);
380 foundSpectrograms.append(spectrogram);
384 return foundSpectrograms;
398 const QwtPlotItemList &plotItems =
m_plot->itemList();
400 for (
int itemIndex = 0; itemIndex < plotItems.size(); itemIndex++) {
403 if (item->rtti() == QwtPlotItem::Rtti_PlotSpectrogram) {
404 const QwtPlotSpectrogram *spectrogram =
405 dynamic_cast<const QwtPlotSpectrogram *
>(item);
408 foundSpectrograms.append(spectrogram);
412 return foundSpectrograms;
424 QMessageBox::warning(NULL,
"Failed to add plot curve",
425 "Can not add plot curves with x/y units that do not match the plot's "
429 QString curveTitle = pc->title().text();
431 bool titleAccepted =
false;
432 int titleTryCount = 0;
433 while (!titleAccepted) {
434 if (titleTryCount > 0) {
435 curveTitle = pc->title().text() +
" (" +
436 QString::number(titleTryCount + 1) +
")";
440 titleAccepted =
true;
442 const QwtPlotItemList &plotItems =
m_plot->itemList();
444 for (
int itemIndex = 0; itemIndex < plotItems.size(); itemIndex ++) {
447 if (item->title().text() == curveTitle)
448 titleAccepted =
false;
452 pc->setTitle(curveTitle);
459 connect(pc, SIGNAL(needsRepaint()),
461 connect(pc, SIGNAL(destroyed(
QObject *)),
494 if (curves.size() < 1) {
499 configDialog->exec();
523 const QwtPlotItemList &plotItems =
m_plot->itemList();
525 for (
int itemIndex = plotItems.size()- 1; itemIndex >= 0; itemIndex --) {
528 if (item->rtti() == QwtPlotItem::Rtti_PlotCurve ||
529 item->rtti() == QwtPlotItem::Rtti_PlotHistogram) {
543 if (
m_zoomer->trackerMode() == QwtPicker::ActiveOnly) {
544 m_zoomer->setTrackerMode(QwtPicker::AlwaysOn);
547 m_zoomer->setTrackerMode(QwtPicker::ActiveOnly);
558 static QPrinter *printer = NULL;
559 if (printer == NULL) printer =
new QPrinter;
560 printer->setPageSize(QPrinter::Letter);
561 printer->setColorMode(QPrinter::Color);
563 QPrintDialog printDialog(printer, (
QWidget *)parent());
565 if (printDialog.exec() == QDialog::Accepted) {
567 pixmap = QPixmap::grabWidget(
m_plot);
568 QImage img = pixmap.toImage();
570 QPainter painter(printer);
571 QRect rect = painter.viewport();
572 QSize size = img.size();
573 size.scale(rect.size(), Qt::KeepAspectRatio);
574 painter.setViewport(rect.x(), rect.y(),
575 size.width(), size.height());
576 painter.setWindow(img.rect());
577 painter.drawImage(0, 0, img);
590 QFileDialog::getSaveFileName((
QWidget *)parent(),
591 "Choose output file",
593 QString(
"Images (*.png *.jpg *.tif)"));
594 if (output.isEmpty())
return;
596 if (!output.isEmpty()) {
597 if (!output.endsWith(
".png") && !output.endsWith(
".jpg") && !output.endsWith(
".tif")) {
598 output = output +
".png";
602 QString format = QFileInfo(output).suffix();
603 pixmap = QPixmap::grabWidget(
m_plot);
605 std::string formatString = format.toStdString();
606 if (!pixmap.save(output, formatString.c_str())) {
607 QMessageBox::information((
QWidget *)parent(),
"Error",
"Unable to save " + output);
618 QPen *pen =
new QPen(Qt::white);
620 if (
m_plot->canvasBackground() == Qt::white) {
621 m_plot->setCanvasBackground(Qt::black);
622 m_grid->setMajPen(QPen(Qt::white, 1, Qt::DotLine));
625 m_plot->setCanvasBackground(Qt::white);
626 pen->setColor(Qt::black);
627 m_grid->setMajPen(QPen(Qt::black, 1, Qt::DotLine));
647 m_plot->setAxisAutoScale(QwtPlot::xBottom);
652 m_plot->setAxisScale(QwtPlot::xBottom, calculatedXRange.first,
653 calculatedXRange.second);
657 m_plot->setAxisAutoScale(QwtPlot::yLeft);
662 m_plot->setAxisScale(QwtPlot::yLeft, calculatedYRange.first,
663 calculatedYRange.second);
678 m_plot->setAxisScaleEngine(QwtPlot::xBottom,
new QwtLog10ScaleEngine);
681 m_plot->setAxisScaleEngine(QwtPlot::xBottom,
new QwtLinearScaleEngine);
685 m_plot->setAxisScaleEngine(QwtPlot::yLeft,
new QwtLog10ScaleEngine);
688 m_plot->setAxisScaleEngine(QwtPlot::yLeft,
new QwtLinearScaleEngine);
700 m_plot->setAxisScale(QwtPlot::xBottom, xMin, xMax);
708 m_plot->setAxisScale(QwtPlot::yLeft, yMin, yMax);
723 dialog->setWindowTitle(
"Set Display Range");
725 QGridLayout *dialogLayout =
new QGridLayout;
729 QLabel *autoLabel =
new QLabel(
"Auto-Scale: ");
730 dialogLayout->addWidget(autoLabel, row, 0);
739 QLabel *xLabel =
new QLabel(
"<h3>X-Axis</h3>");
740 dialogLayout->addWidget(xLabel, row, 0, 1, 2);
743 QLabel *xMinLabel =
new QLabel(
"Minimum: ");
744 dialogLayout->addWidget(xMinLabel, row, 0);
746 double xMin =
plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
747 m_xMinEdit =
new QLineEdit(QString::number(xMin));
751 QLabel *xMaxLabel =
new QLabel(
"Maximum: ");
752 dialogLayout->addWidget(xMaxLabel, row, 0);
754 double xMax =
plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound();
755 m_xMaxEdit =
new QLineEdit(QString::number(xMax));
759 QLabel *xLogLabel =
new QLabel(
"Logarithmic Scale");
760 dialogLayout->addWidget(xLogLabel, row, 0);
764 m_plot->axisScaleEngine(QwtPlot::xBottom)->transformation()->type() ==
765 QwtScaleTransformation::Log10);
769 QLabel *yLabel =
new QLabel(
"<h3>Y-Axis</h3>");
770 dialogLayout->addWidget(yLabel, row, 0, 1, 2);
773 QLabel *yMinLabel =
new QLabel(
"Minimum: ");
774 dialogLayout->addWidget(yMinLabel, row, 0);
776 double yMin =
plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
777 m_yMinEdit =
new QLineEdit(QString::number(yMin));
781 QLabel *yMaxLabel =
new QLabel(
"Maximum: ");
782 dialogLayout->addWidget(yMaxLabel, row, 0);
784 double yMax =
plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound();
785 m_yMaxEdit =
new QLineEdit(QString::number(yMax));
789 QLabel *yLogLabel =
new QLabel(
"Logarithmic Scale");
790 dialogLayout->addWidget(yLogLabel, row, 0);
794 m_plot->axisScaleEngine(QwtPlot::yLeft)->transformation()->type() ==
795 QwtScaleTransformation::Log10);
799 QHBoxLayout *buttonsLayout =
new QHBoxLayout;
800 buttonsLayout->addStretch();
802 QPushButton *okButton =
new QPushButton(
"&Ok");
803 okButton->setIcon(QIcon::fromTheme(
"dialog-ok"));
804 connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
805 connect(dialog, SIGNAL(accepted()),
this, SLOT(
setUserValues()));
806 okButton->setShortcut(Qt::Key_Enter);
807 buttonsLayout->addWidget(okButton);
809 QPushButton *cancelButton =
new QPushButton(
"&Cancel");
810 cancelButton->setIcon(QIcon::fromTheme(
"dialog-cancel"));
811 connect(cancelButton, SIGNAL(clicked()), dialog, SLOT(reject()));
812 buttonsLayout->addWidget(cancelButton);
815 buttonsWrapper->setLayout(buttonsLayout);
816 dialogLayout->addWidget(buttonsWrapper, row, 0, 1, 2);
821 dialog->setLayout(dialogLayout);
832 dialog->setWindowTitle(
"Name Plot Labels");
834 QGridLayout *dialogLayout =
new QGridLayout;
837 QLabel *plotLabel =
new QLabel(
"Plot Title: ");
838 dialogLayout->addWidget(plotLabel, row, 0);
844 QLabel *xAxisLabel =
new QLabel(
"X-Axis Label: ");
845 dialogLayout->addWidget(xAxisLabel, row, 0);
851 QLabel *yAxisLabel =
new QLabel(
"Y-Axis Label: ");
852 dialogLayout->addWidget(yAxisLabel, row, 0);
858 QHBoxLayout *buttonsLayout =
new QHBoxLayout;
859 buttonsLayout->addStretch();
861 QPushButton *okButton =
new QPushButton(
"&Ok");
862 okButton->setIcon(QIcon::fromTheme(
"dialog-ok"));
863 connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
864 connect(dialog, SIGNAL(accepted()),
this, SLOT(
setLabels()));
865 okButton->setShortcut(Qt::Key_Enter);
866 buttonsLayout->addWidget(okButton);
868 QPushButton *cancelButton =
new QPushButton(
"&Cancel");
869 cancelButton->setIcon(QIcon::fromTheme(
"dialog-cancel"));
870 connect(cancelButton, SIGNAL(clicked()), dialog, SLOT(reject()));
871 buttonsLayout->addWidget(cancelButton);
874 buttonsWrapper->setLayout(buttonsLayout);
875 dialogLayout->addWidget(buttonsWrapper, row, 0, 1, 2);
878 dialog->setLayout(dialogLayout);
902 if (
m_grid->isVisible()) {
918 method = &QwtPlotItem::hide;
924 method = &QwtPlotItem::show;
929 for (
int i = 0; i <
m_plot->itemList().size(); i ++) {
931 if (plotItem->rtti() == QwtPlotItem::Rtti_PlotMarker)
932 (plotItem->*method)();
946 method = &QwtPlotItem::hide;
950 QPixmap(
FileName(
"$base/icons/plot_showCurves.png").expanded()));
954 method = &QwtPlotItem::show;
958 QPixmap(
FileName(
"$base/icons/plot_hideCurves.png").expanded()));
961 for (
int i = 0; i <
m_plot->itemList().size(); i ++) {
963 if (plotItem->rtti() == QwtPlotItem::Rtti_PlotCurve)
964 (plotItem->*method)();
977 d->setWindowTitle(
"Basic Help");
979 QLabel *zoomLabel =
new QLabel(
"<U>Zoom Options:</U>");
981 QLabel(
" <b>Left click</b> on the mouse, drag, and release to select an area to zoom in on");
982 QLabel *zoomOut =
new
983 QLabel(
" <b>Middle click</b> on the mouse to zoom out one level");
984 QLabel *zoomReset =
new
985 QLabel(
" <b>Right click</b> on the mouse and select <I>Reset Scale</I> to clear the zoom and return to the original plot");
987 QLabel *curveConfigLabel =
new QLabel(
"<br><U>Curve Configuration:</U>");
988 QLabel *configDirections =
new
989 QLabel(
" <b>To configure the curve properties</b> Right click on the legend and select <I>Configure</I> from <br> the menu"
990 " or click on the configure icon in the tool bar.");
991 QLabel *config =
new QLabel();
992 config->setPixmap(QPixmap(
FileName(
"$base/icons/plot_configure.png").expanded()));
994 QLabel *tableLabel =
new QLabel(
"<br><U>Table Options:</U>");
995 QLabel *tableDirections =
new
996 QLabel(
" <b>To view the table</b> Click on the File menu and select <I>Show Table</I> or click on the table icon in the <br> tool bar.");
997 QLabel *table =
new QLabel();
998 table->setPixmap(QPixmap(
FileName(
"$base/icons/plot_table.png").expanded()));
1000 QVBoxLayout *layout =
new QVBoxLayout();
1001 layout->addWidget(zoomLabel);
1002 layout->addWidget(zoomIn);
1003 layout->addWidget(zoomOut);
1004 layout->addWidget(zoomReset);
1005 layout->addWidget(curveConfigLabel);
1006 layout->addWidget(config);
1007 layout->addWidget(configDirections);
1008 layout->addWidget(tableLabel);
1009 layout->addWidget(table);
1010 layout->addWidget(tableDirections);
1012 d->setLayout(layout);
1028 QMenu *fileMenu =
new QMenu(
"&File");
1029 QMenu *editMenu =
new QMenu(
"&Edit");
1030 QMenu *optionsMenu =
new QMenu(
"&Options");
1035 save->setText(
"&Save Plot As");
1036 save->setIcon(QIcon::fromTheme(
"document-save-as"));
1038 "<b>Function:</b> Save the plot as a png, jpg, or tif file.";
1039 save->setWhatsThis(text);
1040 connect(save, SIGNAL(activated()),
this, SLOT(
savePlot()));
1041 fileMenu->addAction(save);
1042 actions.push_back(save);
1047 prt->setText(
"&Print Plot");
1048 prt->setIcon(QIcon::fromTheme(
"document-print"));
1050 "<b>Function:</b> Sends the plot image to the printer";
1051 prt->setWhatsThis(text);
1052 connect(prt, SIGNAL(activated()),
this, SLOT(
printPlot()));
1053 fileMenu->addAction(prt);
1054 actions.push_back(prt);
1059 table->setText(
"Show Table");
1061 QPixmap(
FileName(
"$base/icons/plot_table.png").expanded()));
1063 "<b>Function:</b> Activates the table which displays the data of the "
1065 table->setWhatsThis(text);
1066 connect(table, SIGNAL(activated()),
this, SLOT(
showTable()));
1067 fileMenu->addAction(table);
1068 actions.push_back(table);
1071 QAction *close =
new QAction(QIcon::fromTheme(
"document-close"),
"&Close",
1073 connect(close, SIGNAL(activated()),
this, SLOT(close()));
1074 fileMenu->addAction(close);
1078 track->setText(
"Show Mouse &Tracking");
1080 QPixmap(
FileName(
"$base/icons/goto.png").expanded()));
1081 track->setCheckable(
true);
1083 "<b>Function:</b> Displays the x,y coordinates as the cursor moves "
1084 "around on the plot.";
1085 track->setWhatsThis(text);
1086 connect(track, SIGNAL(activated()),
this, SLOT(
trackerEnabled()));
1087 optionsMenu->addAction(track);
1091 BackgroundSwitchMenuOption) {
1093 backgrdSwitch->setText(
"White/Black &Background");
1094 backgrdSwitch->setIcon(
1095 QPixmap(
FileName(
"$base/icons/plot_switchBackgrd.png").expanded()));
1097 "<b>Function:</b> Switch the background color between black and "
1099 backgrdSwitch->setWhatsThis(text);
1100 connect(backgrdSwitch, SIGNAL(activated()),
1102 optionsMenu->addAction(backgrdSwitch);
1103 actions.push_back(backgrdSwitch);
1110 QPixmap(
FileName(
"$base/icons/plot_grid.png").expanded()));
1112 "<b>Function:</b> Display grid lines on the plot.";
1121 changeLabels->setText(
"Rename Plot &Labels");
1122 changeLabels->setIcon(
1123 QPixmap(
FileName(
"$base/icons/plot_renameLabels.png").expanded()));
1125 "<b>Function:</b> Edit the plot title, x and y axis labels.";
1126 changeLabels->setWhatsThis(text);
1127 connect(changeLabels, SIGNAL(activated()),
1129 optionsMenu->addAction(changeLabels);
1130 actions.push_back(changeLabels);
1134 SetDisplayRangeMenuOption) {
1136 changeScale->setText(
"Set &Display Range");
1137 changeScale->setIcon(
1138 QPixmap(
FileName(
"$base/icons/plot_setScale.png").expanded()));
1140 "<b>Function:</b> Adjust the scale for the x and y axis on the "
1142 changeScale->setWhatsThis(text);
1143 connect(changeScale, SIGNAL(activated()),
this, SLOT(
setDefaultRange()));
1144 optionsMenu->addAction(changeScale);
1145 actions.push_back(changeScale);
1149 ShowHideCurvesMenuOption) {
1153 QPixmap(
FileName(
"$base/icons/plot_showCurves.png").expanded()));
1155 "<b>Function:</b> Displays or hides all the curves currently "
1156 "displayed on the plot.";
1165 ShowHideMarkersMenuOption) {
1169 QPixmap(
FileName(
"$base/icons/plot_markers.png").expanded()));
1170 QString text =
"<b>Function:</b> Displays or hides a symbol for each "
1171 "data point plotted on a plot.";
1181 resetScaleButton->setText(
"Reset Scale");
1182 resetScaleButton->setIcon(
1183 QPixmap(
FileName(
"$base/icons/plot_resetscale.png").expanded()));
1185 "<b>Function:</b> Reset the plot's scale.";
1186 resetScaleButton->setWhatsThis(text);
1187 connect(resetScaleButton, SIGNAL(activated()),
this, SLOT(
resetScale()));
1188 actions.push_back(resetScaleButton);
1193 clear->setText(
"Clear Plot");
1195 QPixmap(
FileName(
"$base/icons/plot_clear.png").expanded()));
1197 "<b>Function:</b> Removes all the curves from the plot.";
1198 clear->setWhatsThis(text);
1199 connect(clear, SIGNAL(activated()),
this, SLOT(
clearPlot()));
1200 actions.push_back(clear);
1205 lineFit->setText(
"Create Best Fit Line");
1207 QPixmap(
FileName(
"$base/icons/linefit.png").expanded()));
1208 QString text =
"<b>Function:</b> Calculates a best fit line from an "
1210 lineFit->setWhatsThis(text);
1212 optionsMenu->addAction(lineFit);
1213 actions.push_back(lineFit);
1218 configurePlot->setText(
"Configure Plot");
1219 configurePlot->setIcon(
1220 QPixmap(
FileName(
"$base/icons/plot_configure.png").expanded() ) );
1221 QString text =
"<b>Function:</b> Change the name, color, style, and vertex symbol of the "
1223 configurePlot->setWhatsThis(text);
1224 connect( configurePlot, SIGNAL( activated() ),
1226 optionsMenu->addAction(configurePlot);
1227 actions.push_back(configurePlot);
1234 m_pasteAct->setShortcut(Qt::CTRL | Qt::Key_V);
1245 menu.push_back(fileMenu);
1246 menu.push_back(editMenu);
1248 if (optionsMenu->actions().size()) {
1249 menu.push_back(optionsMenu);
1280 bool userCanAdd =
false;
1283 curve->hasFormat(
"application/isis3-plot-curve")) {
1286 curve->data(
"application/isis3-plot-curve"));
1288 userCanAdd =
canAdd(testCurve);
1335 m_toolBar->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea | Qt::TopToolBarArea);
1336 addToolBar(Qt::TopToolBarArea,
m_toolBar);
1345 for (
int i = 0; i < menu.size(); i++) {
1349 for (
int i = 0; i < actions.size(); i++) {
1373 if (!m_scheduledFillTable) {
1374 m_scheduledFillTable =
true;
1375 emit requestFillTable();
1385 m_scheduledFillTable =
false;
1394 m_plot->axisTitle(QwtPlot::xBottom).text(),
1395 m_plot->axisTitle(QwtPlot::xBottom).text());
1400 curve->title().text(),
1401 curve->title().text());
1418 QProgressDialog progress(tr(
"Re-calculating Table"), tr(
""), 0, 1000,
this);
1419 double percentPerCurve = 0.5 * 1.0 / curves.count();
1421 for (
int curveIndex = 0; curveIndex < curves.count(); curveIndex++) {
1422 progress.setValue(qRound(curveIndex * percentPerCurve * 1000.0));
1426 double percentPerDataIndex = (1.0 / curve->data()->size()) * percentPerCurve;
1430 for (
int dataIndex = (
int)curve->data()->size() - 1;
1433 double xValue = curve->data()->sample(dataIndex).x();
1434 QString xValueString =
toString(xValue);
1436 int inverseDataIndex = (curve->data()->size() - 1) - dataIndex;
1438 qRound( ((curveIndex * percentPerCurve) +
1439 (inverseDataIndex * percentPerDataIndex)) * 1000.0));
1445 qBinaryFind(xAxisPoints.begin(), xAxisPoints.end(), xValueString);
1447 if (foundPos == xAxisPoints.end()) {
1448 bool inserted =
false;
1450 for (
int searchIndex = 0;
1451 searchIndex < xAxisPoints.size() && !inserted;
1453 if (xAxisPoints[searchIndex] > xValueString) {
1455 xAxisPoints.insert(searchIndex, xValueString);
1460 xAxisPoints.append(xValueString);
1465 qSort(xAxisPoints.begin(), xAxisPoints.end(), &numericStringLessThan);
1471 for (
int i = 0; i < curves.count(); i++) {
1472 lastSuccessfulSamples.append(-1);
1478 progress.setValue(500 + qRound(row * progressPerRow * 1000.0));
1480 QString xValueString = xAxisPoints[row];
1481 double xValue =
toDouble(xValueString);
1483 QTableWidgetItem *xAxisItem =
new QTableWidgetItem(xValueString);
1495 bool tooFar =
false;
1497 for (
int dataIndex = lastSuccessfulSamples[col - 1] + 1;
1498 dataIndex < (int)curve->data()->size() && y ==
Null && !tooFar;
1501 if (
toString(curve->data()->sample(dataIndex).x()) == xValueString) {
1503 if (dataIndex > 0 &&
1504 curve->data()->sample(dataIndex - 1).x() < curve->data()->sample(dataIndex).x()) {
1505 lastSuccessfulSamples[col - 1] = dataIndex;
1507 y = curve->data()->sample(dataIndex).y();
1510 else if (dataIndex > 0 &&
1511 curve->data()->sample(dataIndex - 1).x() < curve->data()->sample(dataIndex).x() &&
1512 curve->data()->sample(dataIndex).x() > xValue) {
1517 QTableWidgetItem *item = NULL;
1520 item =
new QTableWidgetItem(QString(
"N/A"));
1522 item =
new QTableWidgetItem(
toString(y));
1564 bool blockWidgetFromEvent =
false;
1566 switch (e->type()) {
1567 case QEvent::MouseButtonPress:
1569 childAt(((QMouseEvent *)e)->pos()) !=
plot()->canvas()) {
1571 blockWidgetFromEvent =
true;
1579 bool stopHandlingEvent =
false;
1580 if (!blockWidgetFromEvent && o ==
this) {
1581 stopHandlingEvent = MainWindow::eventFilter(o, e);
1583 if (e->type() == QEvent::Close && !stopHandlingEvent) {
1588 return stopHandlingEvent || blockWidgetFromEvent;
1602 if (qobject_cast<QWidget *>(
object) &&
1603 event->button() == Qt::RightButton &&
1607 QAction *pasteAct =
new QAction(QIcon::fromTheme(
"edit-paste"),
"Paste",
1609 contextMenu.addAction(pasteAct);
1611 QAction *chosenAct = contextMenu.exec(
1612 qobject_cast<QWidget *>(
object)->mapToGlobal(event->pos()));
1614 if (chosenAct == pasteAct) {
1672 QClipboard *globalClipboard = QApplication::clipboard();
1673 const QMimeData *globalData = globalClipboard->mimeData();
1675 if (globalData->hasFormat(
"application/isis3-plot-curve")) {
1677 globalData->data(
"application/isis3-plot-curve"));
1698 bool foundDataValue =
false;
1702 for (
int dataIndex = 0; dataIndex < (int)curve->dataSize(); dataIndex++) {
1703 if (axisId == QwtPlot::xBottom) {
1704 if (!foundDataValue) {
1705 rangeMinMax.first = curve->sample(dataIndex).x();
1706 rangeMinMax.second = curve->sample(dataIndex).x();
1707 foundDataValue =
true;
1710 rangeMinMax.first = qMin(rangeMinMax.first, curve->sample(dataIndex).x());
1711 rangeMinMax.second = qMax(rangeMinMax.second, curve->sample(dataIndex).x());
1714 else if (axisId == QwtPlot::yLeft) {
1715 if (!foundDataValue) {
1716 rangeMinMax.first = curve->sample(dataIndex).y();
1717 rangeMinMax.second = curve->sample(dataIndex).y();
1718 foundDataValue =
true;
1721 rangeMinMax.first = qMin(rangeMinMax.first, curve->sample(dataIndex).y());
1722 rangeMinMax.second = qMax(rangeMinMax.second, curve->sample(dataIndex).y());
1728 if (!foundDataValue) {
1729 rangeMinMax.first = 1;
1730 rangeMinMax.second = 10;
1732 else if(rangeMinMax.first == rangeMinMax.second) {
1733 rangeMinMax.first -= 0.5;
1734 rangeMinMax.second += 0.5;
1741 bool PlotWindow::numericStringLessThan(QString left, QString right) {
1742 bool result =
false;
1747 catch (IException &) {
1762 curve->
paint(vp, painter);
1797 QWidget *source =
event->source();
1799 if (source !=
m_plot->legend()->contentsWidget() &&
1801 event->acceptProposedAction();
1819 event->mimeData()->hasFormat(
"application/isis3-plot-curve")) {
1820 Qt::DropActions possibleActions =
event->possibleActions();
1821 Qt::DropAction actionToTake =
event->proposedAction();
1824 boldFont.setBold(
true);
1825 QMenu dropActionsMenu;
1828 if (possibleActions.testFlag(Qt::CopyAction)) {
1829 dropActionsMenu.addAction(copyAct);
1831 if (actionToTake == Qt::CopyAction)
1832 copyAct->setFont(boldFont);
1836 if (possibleActions.testFlag(Qt::MoveAction)) {
1837 dropActionsMenu.addAction(moveAct);
1839 if (actionToTake == Qt::MoveAction)
1840 moveAct->setFont(boldFont);
1843 if (dropActionsMenu.actions().size() > 1) {
1844 dropActionsMenu.addSeparator();
1847 dropActionsMenu.addAction(cancelAct);
1849 QAction *chosenAct = dropActionsMenu.exec(mapToGlobal(event->pos()));
1851 if (chosenAct == copyAct) {
1852 actionToTake = Qt::CopyAction;
1854 else if (chosenAct == moveAct) {
1855 actionToTake = Qt::MoveAction;
1858 actionToTake = Qt::IgnoreAction;
1862 if (actionToTake != Qt::IgnoreAction) {
1864 event->mimeData()->data(
"application/isis3-plot-curve"));
1869 event->setDropAction(actionToTake);