#792 Added Window zoom and Zoom All

This commit is contained in:
Magne Sjaastad 2016-07-05 10:47:03 +02:00
parent 2715310782
commit b8615f0ebc
15 changed files with 215 additions and 4 deletions

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QAction>
#include <QClipboard>
#include <QMdiSubWindow>
CAF_CMD_SOURCE_INIT(RicViewZoomAllFeature, "RicViewZoomAllFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicViewZoomAllFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicViewZoomAllFeature::onActionTriggered(bool isChecked)
{
QWidget* topLevelWidget = RiaApplication::activeWindow();
if (dynamic_cast<RiuMainWindow*>(topLevelWidget))
{
RimViewWindow* viewWindow = RiaApplication::instance()->activeReservoirView();
viewWindow->zoomAll();
}
else if (dynamic_cast<RiuMainPlotWindow*>(topLevelWidget))
{
RiuMainPlotWindow* mainPlotWindow = dynamic_cast<RiuMainPlotWindow*>(topLevelWidget);
QList<QMdiSubWindow*> subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder);
if (subwindows.size() > 0)
{
RiuSummaryQwtPlot* summaryQwtPlot = dynamic_cast<RiuSummaryQwtPlot*>(subwindows.back()->widget());
if (summaryQwtPlot)
{
RimViewWindow* viewWindow = summaryQwtPlot->ownerPlotDefinition();
viewWindow->zoomAll();
summaryQwtPlot->replot();
}
RiuWellLogPlot* wellLogPlot = dynamic_cast<RiuWellLogPlot*>(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"));
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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);
};

View File

@ -272,6 +272,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
{
commandIds << "RicNewSummaryCurveFeature";
commandIds << "RicNewSummaryCurveFilterFeature";
commandIds << "RicViewZoomAllFeature";
commandIds << "RicDeleteItemFeature";
}

View File

@ -320,8 +320,10 @@ QString RimSummaryCurve::createCurveAutoName()
//--------------------------------------------------------------------------------------------------
void RimSummaryCurve::zoomAllParentPlot()
{
// Todo
RimSummaryPlot* plot = nullptr;
firstAnchestorOrThisOfType(plot);
plot->zoomAll();
}
//--------------------------------------------------------------------------------------------------

View File

@ -139,6 +139,17 @@ QWidget* RimSummaryPlot::viewer()
return m_qwtPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::zoomAll()
{
if (m_qwtPlot)
{
m_qwtPlot->zoomAll();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -57,6 +57,9 @@ public:
QWidget* viewer();
virtual void zoomAll() override;
protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }

View File

@ -906,3 +906,14 @@ void RimView::selectOverlayInfoConfig()
RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::zoomAll()
{
if (m_viewer)
{
m_viewer->zoomAll();
}
}

View File

@ -152,6 +152,9 @@ public:
void selectOverlayInfoConfig();
virtual void zoomAll() override;
public:
virtual void loadDataAndUpdate() = 0;
virtual RimCase* ownerCase() = 0;

View File

@ -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);

View File

@ -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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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

View File

@ -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"));

View File

@ -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 <QEvent>
@ -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);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -21,8 +21,11 @@
#include "qwt_plot.h"
#include "cafPdmPointer.h"
#include <QPointer>
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<RimSummaryPlot> m_plotDefinition;
QPointer<QwtPlotZoomer> zoomer;
};