2017-09-08 07:49:41 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-09-21 03:47:55 -05:00
|
|
|
#include "RicEditSummaryPlotFeature.h"
|
2017-09-13 06:55:28 -05:00
|
|
|
|
2017-09-08 07:49:41 -05:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaPreferences.h"
|
2017-09-13 06:55:28 -05:00
|
|
|
|
2017-09-08 07:49:41 -05:00
|
|
|
#include "RicSummaryCurveCreator.h"
|
2017-09-15 03:48:38 -05:00
|
|
|
#include "RicSummaryCurveCreatorDialog.h"
|
2017-09-13 06:55:28 -05:00
|
|
|
|
2017-09-08 07:49:41 -05:00
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
2017-09-15 06:37:52 -05:00
|
|
|
#include "cafSelectionManager.h"
|
2017-09-21 02:49:49 -05:00
|
|
|
#include "RicSummaryCurveCreatorFactoryImpl.h"
|
2017-09-08 07:49:41 -05:00
|
|
|
|
|
|
|
|
2017-09-21 03:47:55 -05:00
|
|
|
CAF_CMD_SOURCE_INIT(RicEditSummaryPlotFeature, "RicEditSummaryPlotFeature");
|
2017-09-08 07:49:41 -05:00
|
|
|
|
2017-09-21 02:49:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-21 03:47:55 -05:00
|
|
|
RicEditSummaryPlotFeature::RicEditSummaryPlotFeature()
|
2017-09-21 02:49:49 -05:00
|
|
|
{
|
|
|
|
m_curveCreatorFactory = RicSummaryCurveCreatorFactoryImpl::instance();
|
|
|
|
}
|
|
|
|
|
2017-09-18 00:46:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-21 03:47:55 -05:00
|
|
|
void RicEditSummaryPlotFeature::closeDialogAndResetTargetPlot()
|
2017-09-18 00:46:29 -05:00
|
|
|
{
|
2017-09-21 02:49:49 -05:00
|
|
|
auto dialog = m_curveCreatorFactory->dialog();
|
|
|
|
auto curveCreator = m_curveCreatorFactory->curveCreator();
|
|
|
|
|
|
|
|
if (dialog && dialog->isVisible())
|
2017-09-18 00:46:29 -05:00
|
|
|
{
|
2017-09-21 02:49:49 -05:00
|
|
|
dialog->hide();
|
2017-09-18 00:46:29 -05:00
|
|
|
}
|
|
|
|
|
2017-09-21 02:49:49 -05:00
|
|
|
if (curveCreator)
|
2017-09-18 00:46:29 -05:00
|
|
|
{
|
2017-09-21 02:49:49 -05:00
|
|
|
curveCreator->updateFromSummaryPlot(nullptr);
|
2017-09-18 00:46:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-08 07:49:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-21 03:47:55 -05:00
|
|
|
bool RicEditSummaryPlotFeature::isCommandEnabled()
|
2017-09-08 07:49:41 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-21 03:47:55 -05:00
|
|
|
void RicEditSummaryPlotFeature::onActionTriggered(bool isChecked)
|
2017-09-08 07:49:41 -05:00
|
|
|
{
|
|
|
|
RimProject* project = RiaApplication::instance()->project();
|
|
|
|
CVF_ASSERT(project);
|
|
|
|
|
2017-09-21 02:49:49 -05:00
|
|
|
auto dialog = m_curveCreatorFactory->dialog();
|
|
|
|
auto curveCreator = m_curveCreatorFactory->curveCreator();
|
2017-09-13 06:55:28 -05:00
|
|
|
|
2017-09-21 02:49:49 -05:00
|
|
|
if (!dialog->isVisible())
|
2017-09-21 08:48:00 -05:00
|
|
|
{
|
2017-09-21 02:49:49 -05:00
|
|
|
dialog->show();
|
2017-09-21 08:48:00 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialog->raise();
|
|
|
|
}
|
2017-09-15 06:37:52 -05:00
|
|
|
|
|
|
|
// Set target plot
|
|
|
|
std::vector<RimSummaryPlot*> plots;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&plots);
|
|
|
|
if (plots.size() == 1)
|
|
|
|
{
|
2017-09-21 02:49:49 -05:00
|
|
|
curveCreator->updateFromSummaryPlot(plots.front());
|
2017-09-15 06:37:52 -05:00
|
|
|
}
|
2017-09-08 07:49:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-21 03:47:55 -05:00
|
|
|
void RicEditSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
|
2017-09-08 07:49:41 -05:00
|
|
|
{
|
2017-09-21 03:47:55 -05:00
|
|
|
actionToSetup->setText("Edit Summary Plot");
|
|
|
|
actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png"));
|
2017-09-08 07:49:41 -05:00
|
|
|
}
|