#1293 Added "Show Plot Data" to context menu of plots

This commit is contained in:
Magne Sjaastad 2017-03-16 08:23:27 +01:00
parent 19e988925a
commit 141257c83e
6 changed files with 638 additions and 601 deletions

View File

@ -42,14 +42,11 @@ bool RicShowPlotDataFeature::isCommandEnabled()
{
std::vector<RimSummaryPlot*> selectedSummaryPlots;
caf::SelectionManager::instance()->objectsByType(&selectedSummaryPlots);
if (selectedSummaryPlots.size() > 0) return true;
std::vector<RimWellLogPlot*> wellLogPlots;
caf::SelectionManager::instance()->objectsByType(&wellLogPlots);
if (selectedSummaryPlots.size() > 0 || wellLogPlots.size() > 0)
{
return true;
}
if (wellLogPlots.size() > 0) return true;
return false;
}

View File

@ -402,15 +402,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
dynamic_cast<RimSummaryCurveFilter*>(uiItem) )
{
commandIds << "RicSummaryCurveSwitchAxisFeature";
}
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
{
// Do not add twice to make sure the first position in the menu is used for the action
if (!commandIds.contains("RicAsciiExportSummaryPlotFeature"))
{
commandIds << "RicAsciiExportSummaryPlotFeature";
}
commandIds << "RicAsciiExportSummaryPlotFeature";
}
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
{
@ -501,6 +496,13 @@ void RimContextCommandBuilder::appendCommandsToMenu(const QStringList& commandId
QAction* act = commandManager->action(commandIds[i]);
CVF_ASSERT(act);
for (QAction* existingAct : menu->actions())
{
// If action exist, continue to make sure the action is positioned at the first
// location of a command ID
if (existingAct == act) continue;
}
menu->addAction(act);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,90 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "qwt_plot.h"
#include "cafPdmPointer.h"
#include <QPointer>
class QwtPlotCurve;
class QwtPlotGrid;
class QwtPlotZoomer;
class QwtInterval;
class QwtPicker;
class QwtPlotMarker;
class RimSummaryPlot;
//==================================================================================================
//
//
//
//==================================================================================================
class RiuSummaryQwtPlot : public QwtPlot
{
Q_OBJECT;
public:
RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = NULL);
virtual ~RiuSummaryQwtPlot();
RimSummaryPlot* ownerPlotDefinition();
void useDateBasedTimeAxis();
void useTimeBasedTimeAxis();
void currentVisibleWindow(QwtInterval* leftAxis,
QwtInterval* rightAxis,
QwtInterval* timeAxis) const;
void setZoomWindow(const QwtInterval& leftAxis,
const QwtInterval& rightAxis,
const QwtInterval& timeAxis);
protected:
virtual bool eventFilter(QObject* watched, QEvent* event) override;
virtual void leaveEvent(QEvent *) override;
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
private:
friend class RiuQwtPlotPicker;
QPointF closestCurvePoint(const QPoint& pos, QString* valueString, QString* timeString, int* yAxis) const;
void updateClosestCurvePointMarker(const QPointF& pos, int yAxis);
void setDefaults();
void selectClosestCurve(const QPoint& pos);
void showToolTip(const QPoint& pos);
private slots:
void onZoomedSlot( );
void onAxisClicked(int axis, double value);
private:
QwtPlotGrid* m_grid;
QwtPicker* m_plotPicker;
QwtPlotMarker* m_plotMarker;
caf::PdmPointer<RimSummaryPlot> m_plotDefinition;
QPointer<QwtPlotZoomer> m_zoomerLeft;
QPointer<QwtPlotZoomer> m_zoomerRight;
};
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "qwt_plot.h"
#include "cafPdmPointer.h"
#include <QPointer>
class QwtPlotCurve;
class QwtPlotGrid;
class QwtPlotZoomer;
class QwtInterval;
class QwtPicker;
class QwtPlotMarker;
class RimSummaryPlot;
//==================================================================================================
//
//
//
//==================================================================================================
class RiuSummaryQwtPlot : public QwtPlot
{
Q_OBJECT;
public:
RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = NULL);
virtual ~RiuSummaryQwtPlot();
RimSummaryPlot* ownerPlotDefinition();
void useDateBasedTimeAxis();
void useTimeBasedTimeAxis();
void currentVisibleWindow(QwtInterval* leftAxis,
QwtInterval* rightAxis,
QwtInterval* timeAxis) const;
void setZoomWindow(const QwtInterval& leftAxis,
const QwtInterval& rightAxis,
const QwtInterval& timeAxis);
protected:
virtual bool eventFilter(QObject* watched, QEvent* event) override;
virtual void leaveEvent(QEvent *) override;
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
virtual void contextMenuEvent(QContextMenuEvent *) override;
private:
friend class RiuQwtPlotPicker;
QPointF closestCurvePoint(const QPoint& pos, QString* valueString, QString* timeString, int* yAxis) const;
void updateClosestCurvePointMarker(const QPointF& pos, int yAxis);
void setDefaults();
void selectClosestCurve(const QPoint& pos);
void showToolTip(const QPoint& pos);
private slots:
void onZoomedSlot( );
void onAxisClicked(int axis, double value);
private:
QwtPlotGrid* m_grid;
QwtPicker* m_plotPicker;
QwtPlotMarker* m_plotMarker;
caf::PdmPointer<RimSummaryPlot> m_plotDefinition;
QPointer<QwtPlotZoomer> m_zoomerLeft;
QPointer<QwtPlotZoomer> m_zoomerRight;
};

View File

@ -19,20 +19,25 @@
#include "RiuWellLogPlot.h"
#include "RimContextCommandBuilder.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RiuMainWindow.h"
#include "RiuWellLogTrack.h"
#include "qwt_legend.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "qwt_legend.h"
#include <QFocusEvent>
#include <QHBoxLayout>
#include <QMdiSubWindow>
#include <QScrollBar>
#include <QTimer>
#include <QMenu>
#include <math.h>
@ -203,6 +208,27 @@ QSize RiuWellLogPlot::sizeHint() const
return QSize(1,1);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::contextMenuEvent(QContextMenuEvent* event)
{
QMenu menu;
QStringList commandIds;
caf::SelectionManager::instance()->setSelectedItem(ownerPlotDefinition());
commandIds << "RicShowPlotDataFeature";
commandIds << "RicShowContributingWellsFromPlotFeature";
RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
if (menu.actions().size() > 0)
{
menu.exec(event->globalPos());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -62,6 +62,7 @@ protected:
virtual void showEvent(QShowEvent *);
virtual void changeEvent(QEvent *);
virtual QSize sizeHint() const override;
virtual void contextMenuEvent(QContextMenuEvent *) override;
private:
void updateScrollBar(double minDepth, double maxDepth);