diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 6bbf648e20..06f36abbb2 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -9,13 +9,14 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h +${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp - +${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp new file mode 100644 index 0000000000..33952169e2 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicViewZoomAllFeature.h" + +#include "RiaApplication.h" + +#include "RimSummaryPlot.h" +#include "RimView.h" +#include "RimViewWindow.h" +#include "RimWellLogPlot.h" + +#include "RiuMainPlotWindow.h" +#include "RiuMainWindow.h" +#include "RiuSummaryQwtPlot.h" +#include "RiuWellLogPlot.h" + +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicViewZoomAllFeature, "RicViewZoomAllFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicViewZoomAllFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicViewZoomAllFeature::onActionTriggered(bool isChecked) +{ + QWidget* topLevelWidget = RiaApplication::activeWindow(); + + if (dynamic_cast(topLevelWidget)) + { + RimViewWindow* viewWindow = RiaApplication::instance()->activeReservoirView(); + viewWindow->zoomAll(); + } + else if (dynamic_cast(topLevelWidget)) + { + RiuMainPlotWindow* mainPlotWindow = dynamic_cast(topLevelWidget); + QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); + if (subwindows.size() > 0) + { + RiuSummaryQwtPlot* summaryQwtPlot = dynamic_cast(subwindows.back()->widget()); + if (summaryQwtPlot) + { + RimViewWindow* viewWindow = summaryQwtPlot->ownerPlotDefinition(); + + viewWindow->zoomAll(); + summaryQwtPlot->replot(); + } + + RiuWellLogPlot* wellLogPlot = dynamic_cast(subwindows.back()->widget()); + if (wellLogPlot) + { + RimViewWindow* viewWindow = wellLogPlot->ownerPlotDefinition(); + viewWindow->zoomAll(); + wellLogPlot->update(); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicViewZoomAllFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Zoom All"); + actionToSetup->setIcon(QIcon(":/ZoomAll16x16.png")); +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h new file mode 100644 index 0000000000..c7a4a1a85e --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + + +//================================================================================================== +/// +//================================================================================================== +class RicViewZoomAllFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index f62c7d18b2..1edf8785c1 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -272,6 +272,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() { commandIds << "RicNewSummaryCurveFeature"; commandIds << "RicNewSummaryCurveFilterFeature"; + commandIds << "RicViewZoomAllFeature"; commandIds << "RicDeleteItemFeature"; } diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp index 9a9f736dd3..fb06a9353d 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp @@ -320,8 +320,10 @@ QString RimSummaryCurve::createCurveAutoName() //-------------------------------------------------------------------------------------------------- void RimSummaryCurve::zoomAllParentPlot() { - // Todo + RimSummaryPlot* plot = nullptr; + firstAnchestorOrThisOfType(plot); + plot->zoomAll(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp index 0601ce5fb2..4a46a5d465 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp @@ -139,6 +139,17 @@ QWidget* RimSummaryPlot::viewer() return m_qwtPlot; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::zoomAll() +{ + if (m_qwtPlot) + { + m_qwtPlot->zoomAll(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/RimSummaryPlot.h index 54e9f6b7b4..7d48eb972b 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlot.h @@ -57,6 +57,9 @@ public: QWidget* viewer(); + + virtual void zoomAll() override; + protected: // Overridden PDM methods virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; } diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp index 13f85fd90b..9191294677 100644 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ b/ApplicationCode/ProjectDataModel/RimView.cpp @@ -906,3 +906,14 @@ void RimView::selectOverlayInfoConfig() RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::zoomAll() +{ + if (m_viewer) + { + m_viewer->zoomAll(); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/RimView.h index 269952166e..a0369b5024 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/RimView.h @@ -152,6 +152,9 @@ public: void selectOverlayInfoConfig(); + + virtual void zoomAll() override; + public: virtual void loadDataAndUpdate() = 0; virtual RimCase* ownerCase() = 0; diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.h b/ApplicationCode/ProjectDataModel/RimViewWindow.h index b21c12870f..ffca3d84c4 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.h @@ -44,7 +44,8 @@ public: void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry); RimMdiWindowGeometry mdiWindowGeometry(); - virtual QImage snapshotWindowContent() = 0; + virtual QImage snapshotWindowContent() = 0; + virtual void zoomAll() = 0; protected: void setViewWidget(QWidget* viewWidget); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 5dbd2d5479..56e5e116f5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -370,6 +370,17 @@ bool RimWellLogPlot::hasAvailableDepthRange() const return m_minAvailableDepth < HUGE_VAL && m_maxAvailableDepth > -HUGE_VAL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlot::zoomAll() +{ + m_isAutoScaleDepthEnabled = true; + m_isAutoScaleDepthEnabled.uiCapability()->updateConnectedEditors(); + + updateDepthZoom(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index c1b6c09298..88100283a7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -48,6 +48,7 @@ public: TRUE_VERTICAL_DEPTH }; + public: RimWellLogPlot(); virtual ~RimWellLogPlot(); @@ -84,6 +85,8 @@ public: void availableDepthRange(double* minimumDepth, double* maximumDepth) const; bool hasAvailableDepthRange() const; + virtual void zoomAll() override; + protected: // Overridden PDM methods diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 92262a8b02..2f4bacdd31 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -178,6 +178,12 @@ void RiuMainPlotWindow::createToolBars() toolbar->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature")); } + { + // Snapshots + QToolBar* toolbar = addToolBar(tr("View")); + toolbar->setObjectName(toolbar->windowTitle()); + toolbar->addAction(cmdFeatureMgr->action("RicViewZoomAllFeature")); + } { QToolBar* toolbar = addToolBar(tr("Window Management")); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 3b6b74e7d0..35537539e9 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -29,6 +29,8 @@ #include "qwt_plot_curve.h" #include "qwt_plot_grid.h" #include "qwt_plot_layout.h" +#include "qwt_plot_panner.h" +#include "qwt_plot_zoomer.h" #include "qwt_scale_engine.h" #include @@ -48,6 +50,17 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* pa m_grid->attach(this); setDefaults(); + + // LeftButton for the zooming + zoomer = new QwtPlotZoomer(canvas()); + zoomer->setRubberBandPen(QColor(Qt::black)); + zoomer->setTrackerMode(QwtPicker::AlwaysOff); + zoomer->setTrackerPen(QColor(Qt::black)); + zoomer->initMousePattern(1); + + // MidButton for the panning + QwtPlotPanner* panner = new QwtPlotPanner(canvas()); + panner->setMouseButton(Qt::MidButton); } //-------------------------------------------------------------------------------------------------- @@ -82,6 +95,17 @@ void RiuSummaryQwtPlot::setYAxisTitle(const QString& title) setAxisTitle(QwtPlot::yLeft, axisTitleY); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::zoomAll() +{ + setAxisAutoScale(yLeft, true); + setAxisAutoScale(xBottom, true); + + zoomer->setZoomBase(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 0cc57fc16e..24d9357143 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -21,8 +21,11 @@ #include "qwt_plot.h" #include "cafPdmPointer.h" +#include + class QwtPlotCurve; -class QwtPlotGrid; +class QwtPlotGrid; +class QwtPlotZoomer; class RimSummaryPlot; @@ -39,6 +42,7 @@ public: RimSummaryPlot* ownerPlotDefinition(); void setYAxisTitle(const QString& title); + void zoomAll(); protected: virtual bool eventFilter(QObject* watched, QEvent* event); @@ -50,6 +54,7 @@ private: private: QwtPlotGrid* m_grid; caf::PdmPointer m_plotDefinition; + QPointer zoomer; };