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