mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#279 Use frame buffer objects for snapshots when available, otherwise use grabFrameBuffer()
This commit is contained in:
@@ -108,6 +108,8 @@
|
||||
#ifdef WIN32
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuWellLogPlot.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -1392,6 +1394,43 @@ RiuMainPlotWindow* RiaApplication::mainPlotWindow()
|
||||
return m_mainPlotWindow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewWindow* RiaApplication::activeViewWindow()
|
||||
{
|
||||
RimViewWindow* viewWindow = NULL;
|
||||
|
||||
QWidget* topLevelWidget = RiaApplication::activeWindow();
|
||||
|
||||
if (dynamic_cast<RiuMainWindow*>(topLevelWidget))
|
||||
{
|
||||
viewWindow = RiaApplication::instance()->activeReservoirView();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
viewWindow = summaryQwtPlot->ownerPlotDefinition();
|
||||
}
|
||||
|
||||
RiuWellLogPlot* wellLogPlot = dynamic_cast<RiuWellLogPlot*>(subwindows.back()->widget());
|
||||
if (wellLogPlot)
|
||||
{
|
||||
viewWindow = wellLogPlot->ownerPlotDefinition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return viewWindow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1777,9 +1816,9 @@ void RiaApplication::saveSnapshotAs(const QString& fileName)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::copySnapshotToClipboard()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
QImage image = grabFrameBufferImage();
|
||||
if (!image.isNull())
|
||||
{
|
||||
@@ -2160,21 +2199,26 @@ cvf::Font* RiaApplication::customFont()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RiaApplication::grabFrameBufferImage()
|
||||
{
|
||||
// TODO: Create a general solution that also works with well log plots and summary plots
|
||||
// For now, only reservoir views are supported by this solution
|
||||
/*
|
||||
RimViewWindow* viewWindow = RiaApplication::activeViewWindow();
|
||||
if (viewWindow)
|
||||
{
|
||||
return viewWindow->snapshotWindowContent();
|
||||
}
|
||||
|
||||
return QImage();
|
||||
*/
|
||||
|
||||
QImage image;
|
||||
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
||||
{
|
||||
m_activeReservoirView->viewer()->repaint();
|
||||
|
||||
GLint currentReadBuffer;
|
||||
glGetIntegerv(GL_READ_BUFFER, ¤tReadBuffer);
|
||||
|
||||
glReadBuffer(GL_FRONT);
|
||||
image = m_activeReservoirView->viewer()->grabFrameBuffer();
|
||||
|
||||
glReadBuffer(currentReadBuffer);
|
||||
return m_activeReservoirView->snapshotWindowContent();
|
||||
}
|
||||
|
||||
return image;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -48,6 +48,7 @@ class RimEclipseView;
|
||||
class RimProject;
|
||||
class RimSummaryPlot;
|
||||
class RimView;
|
||||
class RimViewWindow;
|
||||
class RimWellLogPlot;
|
||||
|
||||
class RiuMainPlotWindow;
|
||||
@@ -178,6 +179,8 @@ public:
|
||||
RiuMainPlotWindow* getOrCreateAndShowMainPlotWindow();
|
||||
RiuMainPlotWindow* mainPlotWindow();
|
||||
|
||||
static RimViewWindow* activeViewWindow();
|
||||
|
||||
private:
|
||||
enum ProjectLoadAction
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user