2016-06-27 21:01:17 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2016 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-06-27 21:01:17 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-06-27 21:01:17 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-06-27 21:01:17 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicSnapshotViewToClipboardFeature.h"
|
2017-11-29 11:45:01 +01:00
|
|
|
#include "RicGridStatisticsDialog.h"
|
2016-06-27 21:01:17 +02:00
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
#include "RiaGuiApplication.h"
|
2017-04-06 10:38:20 +02:00
|
|
|
#include "RiaLogging.h"
|
2016-06-27 21:01:17 +02:00
|
|
|
|
2017-02-14 15:03:54 +01:00
|
|
|
#include "RimMainPlotCollection.h"
|
2016-10-27 08:09:49 +02:00
|
|
|
#include "RimProject.h"
|
2016-06-27 21:01:17 +02:00
|
|
|
#include "RimViewWindow.h"
|
2018-04-27 06:28:08 +02:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2016-10-27 11:03:13 +02:00
|
|
|
|
|
|
|
|
#include "cafUtils.h"
|
2016-06-27 21:01:17 +02:00
|
|
|
|
|
|
|
|
#include <QAction>
|
2016-06-28 11:38:11 +02:00
|
|
|
#include <QClipboard>
|
2016-10-27 08:09:49 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QFileInfo>
|
2016-06-28 11:38:11 +02:00
|
|
|
#include <QMdiSubWindow>
|
2016-06-27 21:01:17 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicSnapshotViewToClipboardFeature, "RicSnapshotViewToClipboardFeature" );
|
2016-06-27 21:01:17 +02:00
|
|
|
|
2017-11-29 11:45:01 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 11:45:01 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicSnapshotViewToClipboardFeature::copyToClipboard( const QImage& image )
|
2017-11-29 11:45:01 +01:00
|
|
|
{
|
|
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( clipboard )
|
2017-11-29 11:45:01 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
clipboard->setImage( image );
|
2017-11-29 11:45:01 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 11:45:01 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QIcon RicSnapshotViewToClipboardFeature::icon()
|
|
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
return QIcon( ":/SnapShot.png" );
|
2017-11-29 11:45:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-11-29 11:45:01 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RicSnapshotViewToClipboardFeature::text()
|
|
|
|
|
{
|
|
|
|
|
return "Snapshot To Clipboard";
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 21:01:17 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-06-27 21:01:17 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicSnapshotViewToClipboardFeature::isCommandEnabled()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-06-27 21:01:17 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicSnapshotViewToClipboardFeature::onActionTriggered( bool isChecked )
|
2016-06-27 21:01:17 +02:00
|
|
|
{
|
2017-04-20 10:38:58 +02:00
|
|
|
this->disableModelChangeContribution();
|
|
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
RimViewWindow* viewWindow = RiaGuiApplication::activeViewWindow();
|
2016-06-27 21:01:17 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( viewWindow )
|
2016-06-27 21:01:17 +02:00
|
|
|
{
|
|
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( clipboard )
|
2016-06-27 21:01:17 +02:00
|
|
|
{
|
|
|
|
|
QImage image = viewWindow->snapshotWindowContent();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !image.isNull() )
|
2016-06-27 21:01:17 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
clipboard->setImage( image );
|
2016-06-27 21:01:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-06-27 21:01:17 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicSnapshotViewToClipboardFeature::setupActionLook( QAction* actionToSetup )
|
2016-06-27 21:01:17 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( text() );
|
|
|
|
|
actionToSetup->setIcon( icon() );
|
2016-06-27 21:01:17 +02:00
|
|
|
}
|