From d6c49641eae69061eb05f10f59d77d9a9ce4529e Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Tue, 10 Feb 2015 18:29:37 +0100
Subject: [PATCH] Linex over the color map to show projections are restored.

---
 .../OutputDataWidgets/ColorMapPlot.cpp        | 69 +++++++++++++++++++
 .../OutputDataWidgets/ColorMapPlot.h          |  4 ++
 .../IntensityDataPlotWidget.cpp               |  9 ++-
 3 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.cpp b/GUI/coregui/Views/Components/OutputDataWidgets/ColorMapPlot.cpp
index a22eff4bbfe..36204cf8a28 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 12362dbd048..7bd1ddaeb98 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 06cb9a3e210..dcb365973d3 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)
-- 
GitLab