diff --git a/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.cpp b/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.cpp index a22eff4bbfed72e478b829708c884d99d4527316..36204cf8a2871e51fceae6f33c8ce55ba8801eb2 100644 --- a/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.cpp +++ b/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.cpp @@ -76,6 +76,63 @@ QString ColorMapPlot::getStatusString() return result; } +void ColorMapPlot::drawLinesOverTheMap() +{ + if(!m_customPlot->graph(0)->visible() || !m_customPlot->graph(1)->visible()) + { + return; + } + + QCPColorMapData *data = m_colorMap->data(); + Q_ASSERT(data); + + //draw line over plot + QCPRange keyRange = data->keyRange(); + QCPRange valueRange = data->valueRange(); + + int keySize = data->keySize(); + int valueSize = data->valueSize(); + + double fraction = (keyRange.upper-keyRange.lower)/keySize; + + QVector<double> x1(keySize+1), y1(valueSize+1); + for(int i=0;i<x1.size();i++) + { + x1[i] = keyRange.lower + (i*fraction); + y1[i] = m_posData.m_yPos; + + //qDebug() << "Line draw1: X:" << x1[i] << " Y:" << y1[i]; + } + m_customPlot->graph(0)->setData(x1, y1); + + //draw vertical line + + fraction = (valueRange.upper-valueRange.lower)/valueSize; + + QVector<double> x2(valueSize+1), y2(keySize+1); + for(int i=0;i<x2.size();i++) + { + x2[i] = m_posData.m_xPos; + y2[i] = valueRange.lower+(i*fraction); + + //qDebug() << "Line draw2: X:" << x2[i] << " Y:" << y2[i]; + } + m_customPlot->graph(1)->setData(x2, y2); + + //replot the graph + m_customPlot->replot(); +} + +void ColorMapPlot::showLinesOverTheMap(bool isVisible) +{ + if(m_customPlot->graph(0) && m_customPlot->graph(1)) + { + m_customPlot->graph(0)->setVisible(isVisible); + m_customPlot->graph(1)->setVisible(isVisible); + m_customPlot->replot(); + } +} + void ColorMapPlot::setLogz(bool logz, bool isReplot) { if(logz) { @@ -212,6 +269,8 @@ void ColorMapPlot::onPropertyChanged(const QString &property_name) m_colorMap->setDataRange(range); m_customPlot->replot(); } + } else if(property_name == NIntensityDataItem::P_PROJECTIONS_FLAG) { + showLinesOverTheMap(m_item->getRegisteredProperty(NIntensityDataItem::P_PROJECTIONS_FLAG).toBool()); } } @@ -264,6 +323,16 @@ void ColorMapPlot::initColorMap() m_gradient_map[Constants::GRADIENT_JET] = QCPColorGradient::gpJet; m_gradient_map[Constants::GRADIENT_HUES] = QCPColorGradient::gpHues; + + QPen pen; + pen.setWidth(1); + pen.setStyle(Qt::SolidLine); + pen.setColor(QColor(255, 255, 255, 130)); + m_customPlot->addGraph(); + m_customPlot->graph(0)->setPen(pen); + m_customPlot->addGraph(); + m_customPlot->graph(1)->setPen(pen); + connect(m_colorMap, SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(onDataRangeChanged(QCPRange))); connect(m_customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(onXaxisRangeChanged(QCPRange))); connect(m_customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(onYaxisRangeChanged(QCPRange))); diff --git a/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.h b/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.h index 12362dbd0486a87f30d9108c79e397400c16efeb..7bd1ddaeb9831a89eed7565ed32648b51fa421d6 100644 --- a/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.h +++ b/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.h @@ -40,6 +40,10 @@ public: QString getStatusString(); + void drawLinesOverTheMap(); + + void showLinesOverTheMap(bool isVisible); + signals: void validMousMove(); diff --git a/GUI/coregui/Views/Components/OutputDataWidgets/IntensityDataPlotWidget.cpp b/GUI/coregui/Views/Components/OutputDataWidgets/IntensityDataPlotWidget.cpp index 06cb9a3e2106456bd8c13c741a1d5283a144ea18..dcb365973d351b1e935963e52e56af203d964640 100644 --- a/GUI/coregui/Views/Components/OutputDataWidgets/IntensityDataPlotWidget.cpp +++ b/GUI/coregui/Views/Components/OutputDataWidgets/IntensityDataPlotWidget.cpp @@ -129,17 +129,22 @@ void IntensityDataPlotWidget::onMouseMove() qDebug() << "IntensityDataPlotWidget::onMouseMove(QMouseEvent *event)"; m_statusLabel->setText(m_centralPlot->getStatusString()); - if(isBottomAreaVisible()) { + bool bottom_is_visible = isBottomAreaVisible(); + if(bottom_is_visible) { QVector<double> x, y; m_centralPlot->getHorizontalSlice(x, y); m_horizontalPlot->plotData(x,y); } - if(isLeftAreaVisible()) { + bool left_is_visible = isLeftAreaVisible(); + if(left_is_visible) { QVector<double> x, y; m_centralPlot->getVerticalSlice(x, y); m_verticalPlot->plotData(x,y); } + + if(bottom_is_visible || left_is_visible) + m_centralPlot->drawLinesOverTheMap(); } void IntensityDataPlotWidget::onPropertyChanged(const QString &property_name)