mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added CopyViewToClipboard feature
This commit is contained in:
parent
2e0553d99c
commit
0680e830b4
@ -47,6 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
|
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.h
|
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
|
||||||
|
|
||||||
# General delete of any object in a child array field
|
# General delete of any object in a child array field
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
|
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
|
||||||
@ -96,6 +97,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
|
||||||
|
|
||||||
|
|
||||||
# General delete of any object in a child array field
|
# General delete of any object in a child array field
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicSnapshotViewToClipboardFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "RimView.h"
|
||||||
|
#include "RimViewWindow.h"
|
||||||
|
#include "RimWellLogPlot.h"
|
||||||
|
|
||||||
|
#include "RiuMainPlotWindow.h"
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicSnapshotViewToClipboardFeature, "RicSnapshotViewToClipboardFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicSnapshotViewToClipboardFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSnapshotViewToClipboardFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimViewWindow* viewWindow = NULL;
|
||||||
|
|
||||||
|
QWidget* topLevelWidget = RiaApplication::activeWindow();
|
||||||
|
|
||||||
|
if (dynamic_cast<RiuMainWindow*>(topLevelWidget))
|
||||||
|
{
|
||||||
|
viewWindow = RiaApplication::instance()->activeReservoirView();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dynamic_cast<RiuMainPlotWindow*>(topLevelWidget))
|
||||||
|
{
|
||||||
|
viewWindow = RiaApplication::instance()->activeWellLogPlot();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewWindow)
|
||||||
|
{
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
if (clipboard)
|
||||||
|
{
|
||||||
|
QImage image = viewWindow->snapshotWindowContent();
|
||||||
|
if (!image.isNull())
|
||||||
|
{
|
||||||
|
clipboard->setImage(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSnapshotViewToClipboardFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Close");
|
||||||
|
}
|
||||||
|
|
39
ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.h
Normal file
39
ApplicationCode/Commands/RicSnapshotViewToClipboardFeature.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 RicSnapshotViewToClipboardFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook( QAction* actionToSetup );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
|||||||
#include "cvfColor3.h"
|
#include "cvfColor3.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include "qwt_plot_renderer.h"
|
||||||
|
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimSummaryPlot, "SummaryPlot");
|
CAF_PDM_SOURCE_INIT(RimSummaryPlot, "SummaryPlot");
|
||||||
@ -197,6 +198,29 @@ void RimSummaryPlot::setupBeforeSave()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QImage RimSummaryPlot::snapshotWindowContent()
|
||||||
|
{
|
||||||
|
QImage image;
|
||||||
|
|
||||||
|
if (m_qwtPlot)
|
||||||
|
{
|
||||||
|
image = QImage(m_qwtPlot->size(), QImage::Format_ARGB32);
|
||||||
|
image.fill(QColor(Qt::white).rgb());
|
||||||
|
|
||||||
|
QPainter painter(&image);
|
||||||
|
QRectF rect(0, 0, m_qwtPlot->size().width(), m_qwtPlot->size().height());
|
||||||
|
|
||||||
|
QwtPlotRenderer plotRenderer;
|
||||||
|
plotRenderer.render(m_qwtPlot, &painter, rect);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
void loadDataAndUpdate();
|
void loadDataAndUpdate();
|
||||||
void handleViewerDeletion();
|
void handleViewerDeletion();
|
||||||
void updateYAxisUnit();
|
void updateYAxisUnit();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overridden PDM methods
|
// Overridden PDM methods
|
||||||
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
|
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
|
||||||
@ -61,6 +62,8 @@ protected:
|
|||||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||||
virtual void setupBeforeSave() override;
|
virtual void setupBeforeSave() override;
|
||||||
|
|
||||||
|
virtual QImage snapshotWindowContent() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateViewerWidget();
|
void updateViewerWidget();
|
||||||
void detachAllCurves();
|
void detachAllCurves();
|
||||||
|
@ -242,6 +242,28 @@ void RimView::updateViewerWidget()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QImage RimView::snapshotWindowContent()
|
||||||
|
{
|
||||||
|
QImage image;
|
||||||
|
if (m_viewer)
|
||||||
|
{
|
||||||
|
m_viewer->repaint();
|
||||||
|
|
||||||
|
GLint currentReadBuffer;
|
||||||
|
glGetIntegerv(GL_READ_BUFFER, ¤tReadBuffer);
|
||||||
|
|
||||||
|
glReadBuffer(GL_FRONT);
|
||||||
|
image = m_viewer->grabFrameBuffer();
|
||||||
|
|
||||||
|
glReadBuffer(currentReadBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -192,6 +192,9 @@ protected:
|
|||||||
virtual void resetLegendsInViewer() = 0;
|
virtual void resetLegendsInViewer() = 0;
|
||||||
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility) = 0;
|
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility) = 0;
|
||||||
|
|
||||||
|
virtual QImage snapshotWindowContent() override;
|
||||||
|
|
||||||
|
|
||||||
QPointer<RiuViewer> m_viewer;
|
QPointer<RiuViewer> m_viewer;
|
||||||
|
|
||||||
caf::PdmField<int> m_currentTimeStep;
|
caf::PdmField<int> m_currentTimeStep;
|
||||||
|
@ -44,12 +44,13 @@ public:
|
|||||||
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry);
|
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry);
|
||||||
RimMdiWindowGeometry mdiWindowGeometry();
|
RimMdiWindowGeometry mdiWindowGeometry();
|
||||||
|
|
||||||
|
virtual QImage snapshotWindowContent() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setViewWidget(QWidget* viewWidget);
|
void setViewWidget(QWidget* viewWidget);
|
||||||
|
|
||||||
// Possible abilities of this class
|
// Possible abilities of this class
|
||||||
|
|
||||||
//virtual QImage snapshotWindowContent() = 0;
|
|
||||||
//caf::PdmField<QString> name;
|
//caf::PdmField<QString> name;
|
||||||
//caf::PdmField<bool> showWindow;
|
//caf::PdmField<bool> showWindow;
|
||||||
|
|
||||||
|
@ -181,6 +181,22 @@ caf::PdmFieldHandle* RimWellLogPlot::objectToggleField()
|
|||||||
return &m_showWindow;
|
return &m_showWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QImage RimWellLogPlot::snapshotWindowContent()
|
||||||
|
{
|
||||||
|
QImage image;
|
||||||
|
|
||||||
|
if (m_viewer)
|
||||||
|
{
|
||||||
|
QPixmap pix = QPixmap::grabWidget(m_viewer);
|
||||||
|
image = pix.toImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -93,6 +93,9 @@ protected:
|
|||||||
virtual caf::PdmFieldHandle* objectToggleField();
|
virtual caf::PdmFieldHandle* objectToggleField();
|
||||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||||
|
|
||||||
|
virtual QImage snapshotWindowContent() override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateViewerWidget();
|
void updateViewerWidget();
|
||||||
void updateViewerWidgetWindowTitle();
|
void updateViewerWidgetWindowTitle();
|
||||||
|
@ -160,6 +160,9 @@ void RiuMainPlotWindow::createMenus()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMainPlotWindow::createToolBars()
|
void RiuMainPlotWindow::createToolBars()
|
||||||
{
|
{
|
||||||
|
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
|
||||||
|
CVF_ASSERT(cmdFeatureMgr);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Snapshots
|
// Snapshots
|
||||||
QToolBar* toolbar = addToolBar(tr("View Snapshots"));
|
QToolBar* toolbar = addToolBar(tr("View Snapshots"));
|
||||||
@ -167,10 +170,10 @@ void RiuMainPlotWindow::createToolBars()
|
|||||||
toolbar->addAction(m_snapshotToClipboard);
|
toolbar->addAction(m_snapshotToClipboard);
|
||||||
toolbar->addAction(m_snapshotToFile);
|
toolbar->addAction(m_snapshotToFile);
|
||||||
toolbar->addAction(m_snapshotAllViewsToFile);
|
toolbar->addAction(m_snapshotAllViewsToFile);
|
||||||
|
|
||||||
|
toolbar->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
|
||||||
}
|
}
|
||||||
|
|
||||||
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
|
|
||||||
CVF_ASSERT(cmdFeatureMgr);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QToolBar* toolbar = addToolBar(tr("Window Management"));
|
QToolBar* toolbar = addToolBar(tr("Window Management"));
|
||||||
|
Loading…
Reference in New Issue
Block a user