#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; std::vector<RimSummaryPlot*> selectedSummaryPlots;
caf::SelectionManager::instance()->objectsByType(&selectedSummaryPlots); caf::SelectionManager::instance()->objectsByType(&selectedSummaryPlots);
if (selectedSummaryPlots.size() > 0) return true;
std::vector<RimWellLogPlot*> wellLogPlots; std::vector<RimWellLogPlot*> wellLogPlots;
caf::SelectionManager::instance()->objectsByType(&wellLogPlots); caf::SelectionManager::instance()->objectsByType(&wellLogPlots);
if (wellLogPlots.size() > 0) return true;
if (selectedSummaryPlots.size() > 0 || wellLogPlots.size() > 0)
{
return true;
}
return false; return false;
} }

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -19,20 +19,25 @@
#include "RiuWellLogPlot.h" #include "RiuWellLogPlot.h"
#include "RimContextCommandBuilder.h"
#include "RimWellLogPlot.h" #include "RimWellLogPlot.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
#include "RiuWellLogTrack.h" #include "RiuWellLogTrack.h"
#include "qwt_legend.h" #include "cafSelectionManager.h"
#include "cvfAssert.h" #include "cvfAssert.h"
#include "qwt_legend.h"
#include <QFocusEvent> #include <QFocusEvent>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QMdiSubWindow> #include <QMdiSubWindow>
#include <QScrollBar> #include <QScrollBar>
#include <QTimer> #include <QTimer>
#include <QMenu>
#include <math.h> #include <math.h>
@ -203,6 +208,27 @@ QSize RiuWellLogPlot::sizeHint() const
return QSize(1,1); 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 showEvent(QShowEvent *);
virtual void changeEvent(QEvent *); virtual void changeEvent(QEvent *);
virtual QSize sizeHint() const override; virtual QSize sizeHint() const override;
virtual void contextMenuEvent(QContextMenuEvent *) override;
private: private:
void updateScrollBar(double minDepth, double maxDepth); void updateScrollBar(double minDepth, double maxDepth);