Rename ApplicationCode to ApplicationLibCode

This commit is contained in:
Gaute Lindkvist
2021-01-06 14:55:29 +01:00
parent 751df1a421
commit 81699db187
3242 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotFeatureImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeatureUi.h
${CMAKE_CURRENT_LIST_DIR}/RicViewZoomAllFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveSwitchAxisFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewGridTimeHistoryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSelectSummaryPlotUI.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteTimeHistoryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCrossPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorUi.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorWidgetCreator.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorDialog.h
${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorWidgetCreator.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorUi.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewEnsembleCurveFilterFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewDerivedEnsembleFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicActivateCurveFilterInToolbarFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewDerivedSummaryFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotFeatureImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicViewZoomAllFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveSwitchAxisFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewGridTimeHistoryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSelectSummaryPlotUI.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteTimeHistoryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorWidgetCreator.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorWidgetCreator.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewEnsembleCurveFilterFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewDerivedEnsembleFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicActivateCurveFilterInToolbarFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewDerivedSummaryFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND COMMAND_CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
list(APPEND COMMAND_QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorWidgetCreator.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorDialog.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorWidgetCreator.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h
)
source_group( "CommandFeature\\SummaryPlot" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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 "RicActivateCurveFilterInToolbarFeature.h"
#include "RiaGuiApplication.h"
#include "RiuPlotMainWindow.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicActivateCurveFilterInToolbarFeature, "RicActivateCurveFilterInToolbarFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicActivateCurveFilterInToolbarFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicActivateCurveFilterInToolbarFeature::onActionTriggered( bool isChecked )
{
if ( RiaGuiApplication::isRunning() )
{
auto plotWindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( plotWindow )
{
plotWindow->setFocusToLineEditInSummaryToolBar();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicActivateCurveFilterInToolbarFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Activate Summary Curve Filter Editor" );
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+F" ) ) );
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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 RicActivateCurveFilterInToolbarFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,183 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicAsciiExportSummaryPlotFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RicResampleDialog.h"
#include "RimSummaryPlot.h"
#include "RiuFileDialogTools.h"
#include "RiuMainWindow.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafProgressInfo.h"
#include "cafSelectionManager.h"
#include "cafUtils.h"
#include "cvfAssert.h"
#include <QAction>
#include <QDebug>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT( RicAsciiExportSummaryPlotFeature, "RicAsciiExportSummaryPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAsciiExportSummaryPlotFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAsciiExportSummaryPlotFeature::onActionTriggered( bool isChecked )
{
this->disableModelChangeContribution();
std::vector<RimSummaryPlot*> selectedSummaryPlots;
caf::SelectionManager::instance()->objectsByType( &selectedSummaryPlots );
QString defaultDir = defaultExportDir();
RiaPreferences* prefs = RiaApplication::instance()->preferences();
// Ask user about resampling
auto result = RicResampleDialog::openDialog();
if ( !result.ok ) return;
if ( selectedSummaryPlots.size() == 1 )
{
RimSummaryPlot* summaryPlot = selectedSummaryPlots.at( 0 );
QString fileName = getFileNameFromUserDialog( summaryPlot->description(), defaultDir );
if ( fileName.isEmpty() ) return;
caf::ProgressInfo pi( selectedSummaryPlots.size(), QString( "Exporting plot data to ASCII" ) );
size_t progress = 0;
RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( fileName,
summaryPlot,
result.period,
prefs->showSummaryTimeAsLongString() );
progress++;
pi.setProgress( progress );
}
else if ( selectedSummaryPlots.size() > 1 )
{
std::vector<QString> fileNames;
for ( RimSummaryPlot* summaryPlot : selectedSummaryPlots )
{
QString fileName = caf::Utils::makeValidFileBasename( summaryPlot->description() ) + ".ascii";
fileNames.push_back( fileName );
}
QString saveDir;
bool writeFiles = caf::Utils::getSaveDirectoryAndCheckOverwriteFiles( defaultDir, fileNames, &saveDir );
if ( !writeFiles ) return;
caf::ProgressInfo pi( selectedSummaryPlots.size(), QString( "Exporting plot data to ASCII" ) );
size_t progress = 0;
RiaLogging::info( QString( "Writing to directory %1" ).arg( saveDir ) );
for ( RimSummaryPlot* summaryPlot : selectedSummaryPlots )
{
QString fileName = saveDir + "/" + caf::Utils::makeValidFileBasename( summaryPlot->description() ) + ".ascii";
RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( fileName,
summaryPlot,
result.period,
prefs->showSummaryTimeAsLongString() );
progress++;
pi.setProgress( progress );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAsciiExportSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Export Plot Data to Text File" );
actionToSetup->setIcon( QIcon( ":/Save.svg" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicAsciiExportSummaryPlotFeature::defaultExportDir()
{
return RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "PLOT_ASCIIEXPORT_DIR" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicAsciiExportSummaryPlotFeature::getFileNameFromUserDialog( const QString& fileNameCandidate,
const QString& defaultDir )
{
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename( fileNameCandidate ) + ".ascii";
QString fileName = RiuFileDialogTools::getSaveFileName( nullptr,
"Select File for Summary Plot Export",
defaultFileName,
"Text File(*.ascii);;All files(*.*)" );
return fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAsciiExportSummaryPlotFeature::exportTextToFile( const QString& fileName, const QString& text )
{
QFile file( fileName );
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
return false;
}
RiaLogging::info( QString( "Writing values for summary plot(s) to file: %1" ).arg( fileName ) );
QTextStream out( &file );
out << text;
RiaLogging::info( QString( "Competed writing values for summary plot(s) to file %1" ).arg( fileName ) );
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( const QString& fileName,
const RimSummaryPlot* summaryPlot,
RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
bool showTimeAsLongString )
{
QString text = summaryPlot->description();
text.append( summaryPlot->asciiDataForSummaryPlotExport( resamplingPeriod, showTimeAsLongString ) );
text.append( "\n\n" );
return exportTextToFile( fileName, text );
}

View File

@@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RiaQDateTimeTools.h"
#include "cafCmdFeature.h"
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicAsciiExportSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static QString defaultExportDir();
static QString getFileNameFromUserDialog( const QString& fileNameCandidate, const QString& defaultDir );
static bool exportTextToFile( const QString& fileName, const QString& text );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static bool exportAsciiForSummaryPlot( const QString& fileName,
const RimSummaryPlot* selectedSummaryPlots,
RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
bool showTimeAsLongString );
};

View File

@@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 "RicClearSourceSteppingEnsembleCurveSetFeature.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicClearSourceSteppingEnsembleCurveSetFeature, "RicClearSourceSteppingEnsembleCurveSetFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicClearSourceSteppingEnsembleCurveSetFeature::isCommandEnabled()
{
std::vector<caf::PdmObject*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
if ( objects.size() == 1 )
{
auto c = objects[0];
RimSummaryPlot* summaryPlot = nullptr;
c->firstAncestorOrThisOfTypeAsserted( summaryPlot );
if ( summaryPlot )
{
if ( summaryPlot->ensembleCurveSetCollection()->curveSetForSourceStepping() ||
summaryPlot->summaryCurveCollection()->curveForSourceStepping() )
{
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicClearSourceSteppingEnsembleCurveSetFeature::onActionTriggered( bool isChecked )
{
std::vector<caf::PdmObject*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
if ( objects.size() == 1 )
{
auto c = objects[0];
RimSummaryPlot* summaryPlot = nullptr;
c->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
clearAllSourceSteppingInSummaryPlot( summaryPlot );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicClearSourceSteppingEnsembleCurveSetFeature::clearAllSourceSteppingInSummaryPlot( const RimSummaryPlot* summaryPlot )
{
RimEnsembleCurveSet* previousCurveSet = summaryPlot->ensembleCurveSetCollection()->curveSetForSourceStepping();
summaryPlot->ensembleCurveSetCollection()->setCurveSetForSourceStepping( nullptr );
RimSummaryCurve* previousCurve = summaryPlot->summaryCurveCollection()->curveForSourceStepping();
summaryPlot->summaryCurveCollection()->setCurveForSourceStepping( nullptr );
if ( previousCurveSet )
{
previousCurveSet->updateConnectedEditors();
}
if ( previousCurve )
{
previousCurve->updateConnectedEditors();
}
RiuPlotMainWindowTools::refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicClearSourceSteppingEnsembleCurveSetFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Clear Source Stepping Curve Set" );
actionToSetup->setIcon( QIcon( ":/StepUpDown16x16.png" ) );
}

View File

@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicClearSourceSteppingEnsembleCurveSetFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void clearAllSourceSteppingInSummaryPlot( const RimSummaryPlot* summaryPlot );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 "RicClearSourceSteppingSummaryCurveFeature.h"
#include "RicClearSourceSteppingEnsembleCurveSetFeature.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include "RimEnsembleCurveSetCollection.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicClearSourceSteppingSummaryCurveFeature, "RicClearSourceSteppingSummaryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicClearSourceSteppingSummaryCurveFeature::isCommandEnabled()
{
std::vector<caf::PdmObject*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
if ( objects.size() == 1 )
{
auto c = objects[0];
RimSummaryPlot* summaryPlot = nullptr;
c->firstAncestorOrThisOfTypeAsserted( summaryPlot );
if ( summaryPlot )
{
if ( summaryPlot->ensembleCurveSetCollection()->curveSetForSourceStepping() ||
summaryPlot->summaryCurveCollection()->curveForSourceStepping() )
{
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicClearSourceSteppingSummaryCurveFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryCurve*> summaryCurves;
caf::SelectionManager::instance()->objectsByType( &summaryCurves );
if ( summaryCurves.size() == 1 )
{
auto c = summaryCurves[0];
RimSummaryPlot* summaryPlot = nullptr;
c->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
RicClearSourceSteppingEnsembleCurveSetFeature::clearAllSourceSteppingInSummaryPlot( summaryPlot );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicClearSourceSteppingSummaryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Clear Source Stepping Curve" );
actionToSetup->setIcon( QIcon( ":/StepUpDown16x16.png" ) );
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 RicClearSourceSteppingSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCrossPlotCurveFeature.h"
#include "RicPasteSummaryCurveFeature.h"
#include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "RimSummaryCurve.h"
#include "RiuPlotMainWindow.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDuplicateSummaryCrossPlotCurveFeature, "RicDuplicateSummaryCrossPlotCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryCrossPlotCurveFeature::isCommandEnabled()
{
RimSummaryCrossPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCrossPlot*>();
return ( selectedPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCrossPlotCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Duplicate Summary Cross Plot Curve" );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
}

View File

@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCurveFeature.h"
#include "cafCmdFeature.h"
#include <vector>
class RimSummaryCrossPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryCrossPlotCurveFeature : public RicDuplicateSummaryCurveFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCrossPlotFeature.h"
#include "RiaSummaryTools.h"
#include "RicPasteSummaryCrossPlotFeature.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDuplicateSummaryCrossPlotFeature, "RicDuplicateSummaryCrossPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryCrossPlotFeature::isCommandEnabled()
{
RimSummaryCrossPlotCollection* sumPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlotColl = RiaSummaryTools::parentCrossPlotCollection( selObj );
}
if ( sumPlotColl ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCrossPlotFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryCrossPlot*> selectedObjects = caf::selectedObjectsByType<RimSummaryCrossPlot*>();
if ( selectedObjects.size() == 1 )
{
RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection( selectedObjects[0] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCrossPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Duplicate Summary Cross Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
}

View 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 RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCurveFeature.h"
#include "RiaSummaryTools.h"
#include "RicPasteSummaryCurveFeature.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDuplicateSummaryCurveFeature, "RicDuplicateSummaryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryCurveFeature::isCommandEnabled()
{
RimSummaryPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot*>();
return ( selectedPlot && !RiaSummaryTools::isSummaryCrossPlot( selectedPlot ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCurveFeature::onActionTriggered( bool isChecked )
{
RimSummaryCurve* curve = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCurve*>();
if ( curve )
{
RimSummaryCurve* newCurve = RicPasteSummaryCurveFeature::copyCurveAndAddToPlot( curve );
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem( newCurve );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Duplicate Summary Curve" );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
}

View 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"
#include <vector>
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryPlotFeature.h"
#include "RiaSummaryTools.h"
#include "RicPasteSummaryPlotFeature.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDuplicateSummaryPlotFeature, "RicDuplicateSummaryPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryPlotFeature::isCommandEnabled()
{
RimSummaryPlotCollection* sumPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection( selObj );
}
if ( sumPlotColl ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryPlotFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryPlot*> selectedObjects = caf::selectedObjectsByType<RimSummaryPlot*>();
if ( selectedObjects.size() == 1 )
{
RicPasteSummaryPlotFeature::copyPlotAndAddToCollection( selectedObjects[0] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Duplicate Summary Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
}

View 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 RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEditSummaryCrossPlotFeature.h"
#include "RiaPreferences.h"
#include "RicSummaryPlotEditorDialog.h"
#include "RicSummaryPlotEditorUi.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "RimSummaryPlot.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicEditSummaryCrossPlotFeature, "RicEditSummaryCrossPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicEditSummaryCrossPlotFeature::RicEditSummaryCrossPlotFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryCrossPlotFeature::closeDialogAndResetTargetPlot()
{
auto dialog = RicEditSummaryCrossPlotFeature::curveCreatorDialog();
if ( dialog && dialog->isVisible() )
{
dialog->hide();
}
dialog->updateFromSummaryPlot( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorDialog* RicEditSummaryCrossPlotFeature::curveCreatorDialog()
{
static RicSummaryPlotEditorDialog* singletonDialog = new RicSummaryPlotEditorDialog( nullptr );
return singletonDialog;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEditSummaryCrossPlotFeature::isCommandEnabled()
{
if ( selectedSummaryPlot() ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryCrossPlotFeature::onActionTriggered( bool isChecked )
{
auto dialog = RicEditSummaryCrossPlotFeature::curveCreatorDialog();
if ( !dialog->isVisible() )
{
dialog->show();
}
else
{
dialog->raise();
}
// Set target plot
if ( selectedSummaryPlot() )
{
// dialog->updateFromSummaryPlot(selectedSummaryPlot());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryCrossPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Edit Summary Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicEditSummaryCrossPlotFeature::selectedSummaryPlot() const
{
RimSummaryPlot* sumPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( sumPlot );
}
return sumPlot;
}

View File

@@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSummaryPlot;
class RicSummaryPlotEditorDialog;
//==================================================================================================
///
//==================================================================================================
class RicEditSummaryCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
RicEditSummaryCrossPlotFeature();
public:
void closeDialogAndResetTargetPlot();
static RicSummaryPlotEditorDialog* curveCreatorDialog();
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimSummaryPlot* selectedSummaryPlot() const;
};

View File

@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicEditSummaryCurveCalculationFeature.h"
#include "RicShowSummaryCurveCalculatorFeature.h"
#include "RicSummaryCurveCalculatorDialog.h"
#include "RicSummaryCurveCalculatorUi.h"
#include "RifEclipseSummaryAddress.h"
#include "RimProject.h"
#include "RimSummaryCalculation.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicEditSummaryCurveCalculationFeature, "RicEditSummaryCurveCalculationFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEditSummaryCurveCalculationFeature::isCommandEnabled()
{
std::vector<RimSummaryCurve*> selectedCurves = caf::selectedObjectsByType<RimSummaryCurve*>();
return selectedCurves.size() == 1 &&
selectedCurves.front()->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryCurveCalculationFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryCurve*> selectedCurves = caf::selectedObjectsByType<RimSummaryCurve*>();
RimSummaryCalculation* calculation = nullptr;
if ( selectedCurves.size() > 0 )
{
RifEclipseSummaryAddress selectedAddress = selectedCurves.front()->summaryAddressY();
RimProject* proj = RimProject::current();
RimSummaryCalculationCollection* calculationColl = proj->calculationCollection();
if ( calculationColl )
{
calculation = calculationColl->findCalculationById( selectedAddress.id() );
}
}
RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog();
dialog->setCalculationAndUpdateUi( calculation );
dialog->show();
dialog->raise();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryCurveCalculationFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Edit Curve Calculation" );
actionToSetup->setIcon( QIcon( ":/Calculator.svg" ) );
}

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RimSummaryPlot;
class RimSummaryPlotCollection;
class RimSummaryCase;
//==================================================================================================
///
//==================================================================================================
class RicEditSummaryCurveCalculationFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,141 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEditSummaryPlotFeature.h"
#include "RiaPreferences.h"
#include "RiaSummaryTools.h"
#include "RicSummaryPlotEditorDialog.h"
#include "RicSummaryPlotEditorUi.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindow.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
#include <memory>
CAF_CMD_SOURCE_INIT( RicEditSummaryPlotFeature, "RicEditSummaryPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicEditSummaryPlotFeature::RicEditSummaryPlotFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryPlotFeature::closeDialogAndResetTargetPlot()
{
auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog();
if ( dialog && dialog->isVisible() )
{
dialog->hide();
}
dialog->updateFromSummaryPlot( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorDialog* RicEditSummaryPlotFeature::curveCreatorDialog()
{
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( mainPlotWindow )
{
return mainPlotWindow->summaryCurveCreatorDialog();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryPlotFeature::editSummaryPlot( RimSummaryPlot* plot )
{
auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog();
if ( !dialog->isVisible() )
{
dialog->show();
}
else
{
dialog->raise();
}
if ( plot )
{
dialog->updateFromSummaryPlot( plot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEditSummaryPlotFeature::isCommandEnabled()
{
if ( selectedSummaryPlot() ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryPlotFeature::onActionTriggered( bool isChecked )
{
editSummaryPlot( selectedSummaryPlot() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Edit Summary Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicEditSummaryPlotFeature::selectedSummaryPlot()
{
RimSummaryPlot* sumPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
}
return sumPlot;
}

View File

@@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSummaryPlot;
class RicSummaryPlotEditorDialog;
//==================================================================================================
///
//==================================================================================================
class RicEditSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
RicEditSummaryPlotFeature();
public:
void closeDialogAndResetTargetPlot();
static RicSummaryPlotEditorDialog* curveCreatorDialog();
static void editSummaryPlot( RimSummaryPlot* plot );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static RimSummaryPlot* selectedSummaryPlot();
};

View File

@@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewDerivedEnsembleFeature.h"
#include "RimDerivedEnsembleCaseCollection.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
#include <QMessageBox>
#include <memory>
CAF_CMD_SOURCE_INIT( RicNewDerivedEnsembleFeature, "RicNewDerivedEnsembleFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDerivedEnsembleFeature::showWarningDialog()
{
QMessageBox::warning( nullptr, "Ensemble Matching", "None of the cases in the ensembles match" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewDerivedEnsembleFeature::showWarningDialogWithQuestion()
{
QMessageBox msgBox;
msgBox.setIcon( QMessageBox::Question );
msgBox.setWindowTitle( "Ensemble Matching" );
msgBox.setText( "None of the cases in the ensembles match" );
msgBox.setInformativeText( "Do you want to keep the delta ensemble?" );
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
int ret = msgBox.exec();
return ret == QMessageBox::Yes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewDerivedEnsembleFeature::isCommandEnabled()
{
std::vector<RimSummaryCaseMainCollection*> mainColls =
caf::selectedObjectsByTypeStrict<RimSummaryCaseMainCollection*>();
std::vector<RimSummaryCaseCollection*> ensembles = caf::selectedObjectsByTypeStrict<RimSummaryCaseCollection*>();
return mainColls.size() == 1 || ensembles.size() == 1 || ensembles.size() == 2;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDerivedEnsembleFeature::onActionTriggered( bool isChecked )
{
if ( isCommandEnabled() )
{
auto project = RimProject::current();
auto mainColl = project->firstSummaryCaseMainCollection();
auto newColl = mainColl->addCaseCollection( {}, "", true, []() { return new RimDerivedEnsembleCaseCollection(); } );
auto newEnsemble = dynamic_cast<RimDerivedEnsembleCaseCollection*>( newColl );
{
std::vector<RimSummaryCaseCollection*> ensembles = caf::selectedObjectsByType<RimSummaryCaseCollection*>();
if ( ensembles.size() >= 1 ) newEnsemble->setEnsemble1( ensembles[0] );
if ( ensembles.size() == 2 )
{
newEnsemble->setEnsemble2( ensembles[1] );
newEnsemble->createDerivedEnsembleCases();
if ( newEnsemble->allSummaryCases().empty() )
{
if ( !showWarningDialogWithQuestion() )
{
mainColl->removeCaseCollection( newEnsemble );
}
}
}
}
mainColl->updateConnectedEditors();
RiuPlotMainWindowTools::selectAsCurrentItem( newEnsemble );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDerivedEnsembleFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Delta Ensemble" );
actionToSetup->setIcon( QIcon( ":/SummaryEnsemble.svg" ) );
}

View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicNewDerivedEnsembleFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void showWarningDialog();
static bool showWarningDialogWithQuestion();
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 "RicNewDerivedSummaryFeature.h"
#include "RimDerivedSummaryCase.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewDerivedSummaryFeature, "RicNewDerivedSummaryFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewDerivedSummaryFeature::isCommandEnabled()
{
if ( mainCollection() ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDerivedSummaryFeature::onActionTriggered( bool isChecked )
{
auto mainColl = mainCollection();
if ( mainColl )
{
auto derivedCase = new RimDerivedSummaryCase;
auto selectedCases = twoSelectedSummaryCases();
if ( selectedCases.empty() )
{
auto allCases = mainColl->allSummaryCases();
if ( allCases.size() > 0 )
{
selectedCases.push_back( allCases[0] );
}
if ( allCases.size() > 1 )
{
selectedCases.push_back( allCases[1] );
}
}
if ( !selectedCases.empty() )
{
RimSummaryCase* sumCase1 = selectedCases[0];
RimSummaryCase* sumCase2 = nullptr;
if ( selectedCases.size() > 1 )
{
sumCase2 = selectedCases[1];
}
derivedCase->setSummaryCases( sumCase1, sumCase2 );
derivedCase->createSummaryReaderInterface();
}
mainColl->addCase( derivedCase );
derivedCase->updateDisplayNameFromCases();
mainColl->updateConnectedEditors();
RiuPlotMainWindowTools::selectAsCurrentItem( derivedCase );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDerivedSummaryFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Delta Summary Case" );
actionToSetup->setIcon( QIcon( ":/SummaryCase.svg" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCaseMainCollection* RicNewDerivedSummaryFeature::mainCollection()
{
std::vector<RimSummaryCaseMainCollection*> mainColls =
caf::selectedObjectsByTypeStrict<RimSummaryCaseMainCollection*>();
if ( mainColls.size() == 1 ) return mainColls.front();
auto sumCases = twoSelectedSummaryCases();
if ( !sumCases.empty() )
{
RimSummaryCaseMainCollection* mainColl = nullptr;
sumCases.front()->firstAncestorOfType( mainColl );
return mainColl;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCase*> RicNewDerivedSummaryFeature::twoSelectedSummaryCases()
{
auto sumCases = caf::selectedObjectsByTypeStrict<RimSummaryCase*>();
if ( sumCases.size() == 2 ) return sumCases;
return {};
}

View File

@@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 RimSummaryCase;
class RimSummaryCaseMainCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewDerivedSummaryFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static RimSummaryCaseMainCollection* mainCollection();
static std::vector<RimSummaryCase*> twoSelectedSummaryCases();
};

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewEnsembleCurveFilterFeature.h"
#include "RimEnsembleCurveFilter.h"
#include "RimEnsembleCurveFilterCollection.h"
#include "RimEnsembleCurveSet.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewEnsembleCurveFilterFeature, "RicNewEnsembleCurveFilterFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewEnsembleCurveFilterFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEnsembleCurveFilterFeature::onActionTriggered( bool isChecked )
{
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !selObj ) return;
RimEnsembleCurveFilterCollection* filterCollection = nullptr;
{
std::vector<RimEnsembleCurveFilterCollection*> filterColls;
selObj->descendantsIncludingThisOfType( filterColls );
if ( filterColls.size() == 1 )
{
filterCollection = filterColls.front();
}
}
if ( filterCollection )
{
RimEnsembleCurveFilter* newFilter = filterCollection->addFilter();
if ( !filterCollection->filters().empty() )
{
auto existingFilter = filterCollection->filters().front();
newFilter->setSummaryAddresses( existingFilter->summaryAddresses() );
}
else
{
std::vector<RifEclipseSummaryAddress> addresses;
addresses.push_back( newFilter->parentCurveSet()->summaryAddress() );
newFilter->setSummaryAddresses( addresses );
}
newFilter->loadDataAndUpdate();
filterCollection->updateConnectedEditors();
selObj->updateConnectedEditors();
RiuPlotMainWindowTools::selectAsCurrentItem( newFilter );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEnsembleCurveFilterFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Ensemble Curve Filter" );
actionToSetup->setIcon( QIcon( ":/Filter.svg" ) );
}

View 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 RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicNewEnsembleCurveFilterFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,266 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicNewGridTimeHistoryCurveFeature.h"
#include "RiaGuiApplication.h"
#include "RiaSummaryTools.h"
#include "RigFemResultAddress.h"
#include "RicNewSummaryCurveFeature.h"
#include "RicSelectSummaryPlotUI.h"
#include "RicWellLogTools.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "Riu3dSelectionManager.h"
#include "RiuPlotMainWindowTools.h"
#include "cafPdmReferenceHelper.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cvfAssert.h"
#include "cvfColor3.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewGridTimeHistoryCurveFeature, "RicNewGridTimeHistoryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem( const RiuSelectionItem* selectionItem,
RimSummaryPlot* plot )
{
CVF_ASSERT( selectionItem );
CVF_ASSERT( plot );
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
newCurve->setFromSelectionItem( selectionItem );
newCurve->setLineThickness( 2 );
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plot->curveCount() );
newCurve->setColor( curveColor );
plot->addGridTimeHistoryCurve( newCurve );
newCurve->loadDataAndUpdate( true );
plot->updateConnectedEditors();
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem( newCurve );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot()
{
RiaGuiApplication* app = RiaGuiApplication::instance();
const QString lastUsedSummaryPlotKey( "lastUsedSummaryPlotKey" );
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
RimSummaryPlot* defaultSelectedPlot = nullptr;
{
QString lastUsedPlotRef = app->cacheDataObject( lastUsedSummaryPlotKey ).toString();
RimSummaryPlot* lastUsedPlot = dynamic_cast<RimSummaryPlot*>(
caf::PdmReferenceHelper::objectFromReference( app->project(), lastUsedPlotRef ) );
if ( lastUsedPlot )
{
defaultSelectedPlot = lastUsedPlot;
}
if ( !defaultSelectedPlot )
{
defaultSelectedPlot = dynamic_cast<RimSummaryPlot*>( app->activePlotWindow() );
}
if ( !defaultSelectedPlot && !summaryPlotColl->plots().empty() )
{
defaultSelectedPlot = summaryPlotColl->plots().front();
}
}
RicSelectSummaryPlotUI featureUi;
if ( defaultSelectedPlot )
{
featureUi.setDefaultSummaryPlot( defaultSelectedPlot );
}
QString newPlotName = RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName();
featureUi.setSuggestedPlotName( newPlotName );
caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &featureUi, "Select Destination Plot", "" );
propertyDialog.resize( QSize( 400, 200 ) );
if ( propertyDialog.exec() != QDialog::Accepted ) return nullptr;
RimSummaryPlot* summaryPlot = nullptr;
if ( featureUi.isCreateNewPlotChecked() )
{
RimSummaryPlot* plot = summaryPlotColl->createNamedSummaryPlot( featureUi.newPlotName() );
summaryPlotColl->updateConnectedEditors();
plot->loadDataAndUpdate();
summaryPlot = plot;
}
else
{
summaryPlot = featureUi.selectedSummaryPlot();
}
QString refFromProjectToView = caf::PdmReferenceHelper::referenceFromRootToObject( app->project(), summaryPlot );
app->setCacheDataObject( lastUsedSummaryPlotKey, refFromProjectToView );
return summaryPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName()
{
QString resultName;
{
Rim3dView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( activeView );
if ( eclView )
{
RimEclipseResultDefinition* resDef = eclView->cellResult();
resultName = resDef->resultVariableUiShortName();
}
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>( activeView );
if ( geoView )
{
// NOTE: See also RimGeoMechProertyFilter for generation of result name
RimGeoMechResultDefinition* resultDefinition = geoView->cellResultResultDefinition();
RigFemResultAddress resultAddress = resultDefinition->resultAddress();
if ( resultAddress.resultPosType == RIG_FORMATION_NAMES )
{
resultName = resultDefinition->resultFieldName();
}
else
{
QString posName;
switch ( resultAddress.resultPosType )
{
case RIG_NODAL:
posName = "N";
break;
case RIG_ELEMENT_NODAL:
posName = "EN";
break;
case RIG_INTEGRATION_POINT:
posName = "IP";
break;
case RIG_ELEMENT:
posName = "E";
break;
}
QString fieldUiName = resultDefinition->resultFieldUiName();
QString compoUiName = resultDefinition->resultComponentUiName();
resultName = posName + ", " + fieldUiName + ", " + compoUiName;
}
}
}
QString plotName = "New Plot Name";
if ( !resultName.isEmpty() )
{
plotName = QString( "Cell Result - %1" ).arg( resultName );
}
return plotName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewGridTimeHistoryCurveFeature::isCommandEnabled()
{
if ( RicWellLogTools::isWellPathOrSimWellSelectedInView() ) return false;
std::vector<RiuSelectionItem*> items;
Riu3dSelectionManager::instance()->selectedItems( items );
if ( items.size() > 0 )
{
const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>( items[0] );
if ( eclSelectionItem && eclSelectionItem->m_resultDefinition )
{
if ( eclSelectionItem->m_resultDefinition->isFlowDiagOrInjectionFlooding() &&
eclSelectionItem->m_resultDefinition->resultVariable() != RIG_NUM_FLOODED_PV )
{
return false;
}
}
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewGridTimeHistoryCurveFeature::onActionTriggered( bool isChecked )
{
RimSummaryPlot* summaryPlot = RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot();
if ( !summaryPlot ) return;
std::vector<RiuSelectionItem*> items;
Riu3dSelectionManager::instance()->selectedItems( items );
CVF_ASSERT( items.size() > 0 );
for ( auto item : items )
{
RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem( item, summaryPlot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewGridTimeHistoryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Plot Time History for Selected Cells" );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
}

View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RiuSelectionItem;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicNewGridTimeHistoryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static void createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot );
static RimSummaryPlot* userSelectedSummaryPlot();
static QString suggestedNewPlotName();
};

View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicNewSummaryCrossPlotCurveFeature.h"
#include "RiaGuiApplication.h"
#include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewSummaryCrossPlotCurveFeature, "RicNewSummaryCrossPlotCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryCrossPlotCurveFeature::isCommandEnabled()
{
return ( selectedCrossPlot() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCrossPlotCurveFeature::onActionTriggered( bool isChecked )
{
RimProject* project = RimProject::current();
RimSummaryCrossPlot* plot = selectedCrossPlot();
if ( plot )
{
RimSummaryCurve* newCurve = new RimSummaryCurve();
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plot->curveCount() );
newCurve->setColor( curveColor );
plot->addCurveAndUpdate( newCurve );
RimSummaryCase* defaultCase = nullptr;
if ( project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0 )
{
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase( 0 );
newCurve->setSummaryCaseY( defaultCase );
newCurve->loadDataAndUpdate( true );
}
plot->updateConnectedEditors();
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem( newCurve );
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateSummaryPlotToolBar();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCrossPlotCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Summary Cross Plot Curve" );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCrossPlot* RicNewSummaryCrossPlotCurveFeature::selectedCrossPlot() const
{
RimSummaryCrossPlot* crossPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
crossPlot = RiaSummaryTools::parentCrossPlot( selObj );
}
return crossPlot;
}

View File

@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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"
#include <vector>
class RimSummaryCrossPlot;
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryCrossPlotCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimSummaryCrossPlot* selectedCrossPlot() const;
};

View File

@@ -0,0 +1,105 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewSummaryCrossPlotFeature.h"
#include "RiaPreferences.h"
#include "RiaSummaryTools.h"
#include "RicEditSummaryPlotFeature.h"
#include "RicSummaryPlotEditorDialog.h"
#include "RicSummaryPlotEditorUi.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCrossPlotCollection.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewSummaryCrossPlotFeature, "RicNewSummaryCrossPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryCrossPlotFeature::isCommandEnabled()
{
RimSummaryCrossPlotCollection* sumPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlotColl = RiaSummaryTools::parentCrossPlotCollection( selObj );
}
if ( sumPlotColl ) return true;
// Multiple case selections
std::vector<caf::PdmUiItem*> selectedItems = caf::selectedObjectsByTypeStrict<caf::PdmUiItem*>();
for ( auto item : selectedItems )
{
RimSummaryCase* sumCase = dynamic_cast<RimSummaryCase*>( item );
RimSummaryCaseCollection* sumGroup = dynamic_cast<RimSummaryCaseCollection*>( item );
if ( sumGroup && sumGroup->isEnsemble() ) sumGroup = nullptr;
if ( !sumCase && !sumGroup ) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCrossPlotFeature::onActionTriggered( bool isChecked )
{
RimProject* project = RimProject::current();
CVF_ASSERT( project );
RimSummaryCrossPlotCollection* summaryCrossPlotColl = project->mainPlotCollection()->summaryCrossPlotCollection();
RimSummaryPlot* summaryPlot = summaryCrossPlotColl->createSummaryPlot();
summaryCrossPlotColl->addPlot( summaryPlot );
if ( summaryPlot )
{
summaryCrossPlotColl->updateConnectedEditors();
summaryPlot->loadDataAndUpdate();
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem( summaryPlot );
RiuPlotMainWindowTools::setExpanded( summaryPlot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCrossPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Summary Cross Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
}

View 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 RimSummaryCrossPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewSummaryCurveFeature.h"
#include "RiaColorTables.h"
#include "RiaGuiApplication.h"
#include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "RicSummaryPlotFeatureImpl.h"
#include "RiuPlotMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryCurveFeature::isCommandEnabled()
{
return ( selectedSummaryPlot() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::onActionTriggered( bool isChecked )
{
RiaGuiApplication* app = RiaGuiApplication::instance();
RimProject* project = app->project();
CVF_ASSERT( project );
RimSummaryPlot* plot = selectedSummaryPlot();
if ( plot )
{
RimSummaryCase* defaultCase = nullptr;
if ( !plot->summaryCurves().empty() )
{
defaultCase = plot->summaryCurves().back()->summaryCaseY();
}
else if ( project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0 )
{
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase( 0 );
}
if ( !defaultCase )
{
std::vector<RimSummaryCase*> allSummaryCases =
project->activeOilField()->summaryCaseMainCollection()->allSummaryCases();
if ( !allSummaryCases.empty() )
{
defaultCase = allSummaryCases.front();
}
}
RimSummaryCurve* newCurve = new RimSummaryCurve();
// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
cvf::Color3f curveColor =
RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( plot->singleColorCurveCount() );
newCurve->setColor( curveColor );
plot->addCurveNoUpdate( newCurve );
newCurve->setSummaryCaseY( defaultCase );
plot->loadDataAndUpdate();
plot->updateConnectedEditors();
app->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem( newCurve );
RiuPlotMainWindow* mainPlotWindow = app->mainPlotWindow();
mainPlotWindow->updateSummaryPlotToolBar();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Summary Curve" );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const
{
RimSummaryPlot* sumPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
}
return sumPlot;
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include <vector>
class RimSummaryPlot;
class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryPlotCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimSummaryPlot* selectedSummaryPlot() const;
};

View File

@@ -0,0 +1,202 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewSummaryEnsembleCurveSetFeature.h"
#include "RiaColorTables.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RiaSummaryTools.h"
#include "RimEnsembleCurveFilterCollection.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimEnsembleCurveSetColorManager.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewSummaryEnsembleCurveSetFeature, "RicNewSummaryEnsembleCurveSetFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEnsembleCurveSet*>
RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble )
{
CVF_ASSERT( plot && ensemble );
RimProject* project = RimProject::current();
CVF_ASSERT( project );
QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter;
QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts );
std::set<RifEclipseSummaryAddress> addrs = ensemble->ensembleSummaryAddresses();
std::vector<RimEnsembleCurveSet*> curveSets;
for ( const auto& addr : addrs )
{
for ( auto filter : curveFilters )
{
if ( addr.isUiTextMatchingFilterText( filter ) )
{
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
// Use same counting as RicNewSummaryCurveFeature::onActionTriggered
auto colorIndex = plot->singleColorCurveCount();
curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) );
curveSet->legendConfig()->setColorLegend( RimRegularLegendConfig::mapToColorLegend(
RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast<int>( colorIndex ) ) ) );
curveSet->setSummaryCaseCollection( ensemble );
curveSet->setSummaryAddress( addr );
curveSet->filterCollection()->addFilter();
plot->ensembleCurveSetCollection()->addCurveSet( curveSet );
curveSets.push_back( curveSet );
}
}
}
return curveSets;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot*
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( std::vector<RimSummaryCaseCollection*> ensembles )
{
RiaGuiApplication* app = RiaGuiApplication::instance();
RimProject* proj = app->project();
if ( RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() ) return nullptr;
RimSummaryPlotCollection* summaryPlotCollection = proj->mainPlotCollection->summaryPlotCollection();
RimSummaryPlot* plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
RimEnsembleCurveSet* firstCurveSetCreated = nullptr;
for ( RimSummaryCaseCollection* ensemble : ensembles )
{
std::vector<RimEnsembleCurveSet*> curveSets =
RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble );
if ( !firstCurveSetCreated && !curveSets.empty() ) firstCurveSetCreated = curveSets.front();
}
plot->loadDataAndUpdate();
summaryPlotCollection->updateConnectedEditors();
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
if ( mainPlotWindow )
{
mainPlotWindow->selectAsCurrentItem( firstCurveSetCreated );
mainPlotWindow->updateSummaryPlotToolBar();
}
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryEnsembleCurveSetFeature::isCommandEnabled()
{
bool summaryPlotSelected = selectedSummaryPlot();
if ( summaryPlotSelected )
{
RimProject* project = RimProject::current();
CVF_ASSERT( project );
if ( !project->summaryGroups().empty() )
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered( bool isChecked )
{
RimProject* project = RimProject::current();
CVF_ASSERT( project );
RimSummaryPlot* plot = selectedSummaryPlot();
if ( plot )
{
CVF_ASSERT( !project->summaryGroups().empty() );
auto ensemble = project->summaryGroups().back();
RimEnsembleCurveSet* firstCurveSet = nullptr;
if ( !RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() )
{
auto curveSets = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble );
if ( !curveSets.empty() ) firstCurveSet = curveSets.front();
}
plot->loadDataAndUpdate();
plot->updateConnectedEditors();
RiaGuiApplication* app = RiaGuiApplication::instance();
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
if ( mainPlotWindow && firstCurveSet )
{
mainPlotWindow->selectAsCurrentItem( firstCurveSet );
mainPlotWindow->updateSummaryPlotToolBar();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryEnsembleCurveSetFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Ensemble Curve Set" );
actionToSetup->setIcon( QIcon( ":/EnsembleCurveSet16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::selectedSummaryPlot() const
{
RimSummaryPlot* sumPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
}
return sumPlot;
}

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include <vector>
class RimSummaryPlot;
class RimEnsembleCurveSet;
class RimSummaryCaseCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryEnsembleCurveSetFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimSummaryPlot* createPlotForCurveSetsAndUpdate( std::vector<RimSummaryCaseCollection*> ensembles );
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<RimEnsembleCurveSet*> addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble );
private:
RimSummaryPlot* selectedSummaryPlot() const;
};

View File

@@ -0,0 +1,300 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewSummaryPlotFeature.h"
#include "RiaPreferences.h"
#include "RiaSummaryTools.h"
#include "RicEditSummaryPlotFeature.h"
#include "RicNewSummaryEnsembleCurveSetFeature.h"
#include "RicSummaryPlotEditorDialog.h"
#include "RicSummaryPlotEditorUi.h"
#include "RicSummaryPlotFeatureImpl.h"
#include "RimCustomObjectiveFunctionCollection.h"
#include "RimEnsembleCurveFilter.h"
#include "RimEnsembleCurveFilterCollection.h"
#include "RimProject.h"
#include "RimRegularLegendConfig.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryPlotFeature::isCommandEnabled()
{
RimSummaryPlotCollection* sumPlotColl = nullptr;
RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection( selObj );
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
}
auto ensembleFilter = dynamic_cast<RimEnsembleCurveFilter*>( selObj );
auto ensembleFilterColl = dynamic_cast<RimEnsembleCurveFilterCollection*>( selObj );
auto legendConfig = dynamic_cast<RimRegularLegendConfig*>( selObj );
if ( ensembleFilter || ensembleFilterColl || legendConfig || customObjFuncCollection ) return false;
if ( sumPlotColl ) return true;
// Multiple case selections
std::vector<caf::PdmUiItem*> selectedItems = caf::selectedObjectsByTypeStrict<caf::PdmUiItem*>();
for ( auto item : selectedItems )
{
if ( !dynamic_cast<RimSummaryCase*>( item ) && !dynamic_cast<RimSummaryCaseCollection*>( item ) ) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryPlotFeature::onActionTriggered( bool isChecked )
{
RimProject* project = RimProject::current();
CVF_ASSERT( project );
std::vector<RimSummaryCase*> selectedCases = caf::selectedObjectsByType<RimSummaryCase*>();
std::vector<RimSummaryCaseCollection*> selectedGroups = caf::selectedObjectsByType<RimSummaryCaseCollection*>();
std::vector<caf::PdmObject*> sourcesToSelect( selectedCases.begin(), selectedCases.end() );
if ( sourcesToSelect.empty() && selectedGroups.empty() )
{
const auto allSingleCases = project->firstSummaryCaseMainCollection()->topLevelSummaryCases();
const auto allGroups = project->summaryGroups();
std::vector<RimSummaryCaseCollection*> allEnsembles;
for ( const auto group : allGroups )
if ( group->isEnsemble() ) allEnsembles.push_back( group );
if ( !allSingleCases.empty() )
{
sourcesToSelect.push_back( allSingleCases.front() );
}
else if ( !allEnsembles.empty() )
{
sourcesToSelect.push_back( allEnsembles.front() );
}
}
// Append grouped cases
for ( auto group : selectedGroups )
{
if ( group->isEnsemble() )
{
sourcesToSelect.push_back( group );
}
else
{
auto groupCases = group->allSummaryCases();
sourcesToSelect.insert( sourcesToSelect.end(), groupCases.begin(), groupCases.end() );
}
}
auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog();
if ( !dialog->isVisible() )
{
dialog->show();
}
else
{
dialog->raise();
}
dialog->updateFromDefaultCases( sourcesToSelect );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Open Summary Plot Editor" );
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
}
//==================================================================================================
///
//==================================================================================================
#include "RicNewSummaryCurveFeature.h"
#include "RicSummaryPlotFeatureImpl.h"
#include "RimMainPlotCollection.h"
#include "RiuPlotMainWindowTools.h"
CAF_CMD_SOURCE_INIT( RicNewDefaultSummaryPlotFeature, "RicNewDefaultSummaryPlotFeature" );
void extractPlotObjectsFromSelection( std::vector<RimSummaryCase*>* selectedIndividualSummaryCases,
std::vector<RimSummaryCaseCollection*>* selectedEnsembles )
{
CAF_ASSERT( selectedIndividualSummaryCases && selectedEnsembles );
// First try selected ensembles
caf::SelectionManager::instance()->objectsByTypeStrict( selectedEnsembles );
if ( !selectedEnsembles->empty() )
{
return;
}
// Second try selected summary cases
caf::SelectionManager::instance()->objectsByTypeStrict( selectedIndividualSummaryCases );
if ( !selectedIndividualSummaryCases->empty() )
{
return;
}
RimSummaryPlotCollection* sumPlotColl =
caf::SelectionManager::instance()->selectedItemAncestorOfType<RimSummaryPlotCollection>();
if ( sumPlotColl )
{
RimSummaryCase* firstIndividualSummaryCase = nullptr;
RimSummaryCaseCollection* firstEnsemble = nullptr;
auto sumCaseVector = RimProject::current()->allSummaryCases();
for ( RimSummaryCase* summaryCase : sumCaseVector )
{
RimSummaryCaseCollection* parentEnsemble = nullptr;
summaryCase->firstAncestorOrThisOfType( parentEnsemble );
if ( !parentEnsemble && !firstIndividualSummaryCase )
{
firstIndividualSummaryCase = summaryCase;
break;
}
else if ( parentEnsemble && !firstEnsemble )
{
firstEnsemble = parentEnsemble;
}
}
if ( firstIndividualSummaryCase )
{
selectedIndividualSummaryCases->push_back( firstIndividualSummaryCase );
}
else if ( firstEnsemble )
{
selectedEnsembles->push_back( firstEnsemble );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicNewDefaultSummaryPlotFeature::createFromSummaryCases( RimSummaryPlotCollection* plotCollection,
const std::vector<RimSummaryCase*>& summaryCases )
{
RimSummaryPlot* newPlot = plotCollection->createSummaryPlotWithAutoTitle();
for ( RimSummaryCase* sumCase : summaryCases )
{
RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( newPlot, sumCase );
}
newPlot->applyDefaultCurveAppearances();
newPlot->loadDataAndUpdate();
plotCollection->updateConnectedEditors();
RiuPlotMainWindowTools::setExpanded( newPlot );
RiuPlotMainWindowTools::selectAsCurrentItem( newPlot );
return newPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewDefaultSummaryPlotFeature::isCommandEnabled()
{
std::vector<RimSummaryCase*> selectedIndividualSummaryCases;
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles );
RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr;
RimEnsembleCurveFilter* curveFilter = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
selObj->firstAncestorOrThisOfType( curveFilter );
}
if ( customObjFuncCollection || curveFilter ) return false;
return !( selectedIndividualSummaryCases.empty() && selectedEnsembles.empty() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDefaultSummaryPlotFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryCase*> selectedIndividualSummaryCases;
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles );
if ( !selectedIndividualSummaryCases.empty() )
{
RimSummaryPlotCollection* sumPlotColl = RimProject::current()->mainPlotCollection()->summaryPlotCollection();
createFromSummaryCases( sumPlotColl, selectedIndividualSummaryCases );
}
else
{
CAF_ASSERT( !selectedEnsembles.empty() );
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( selectedEnsembles );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDefaultSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
std::vector<RimSummaryCase*> selectedIndividualSummaryCases;
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles );
if ( !selectedIndividualSummaryCases.empty() )
{
actionToSetup->setText( "New Summary Plot" );
}
else
{
actionToSetup->setText( "New Ensemble Summary Plot" );
}
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
}

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicfCommandObject.h"
#include "cafCmdFeature.h"
class RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryCaseCollection;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
//==================================================================================================
///
//==================================================================================================
class RicNewDefaultSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimSummaryPlot* createFromSummaryCases( RimSummaryPlotCollection* plotCollection,
const std::vector<RimSummaryCase*>& summaryCases );
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicPasteAsciiDataCurveFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
#include "RimAsciiDataCurve.h"
#include "RimSummaryPlot.h"
CAF_CMD_SOURCE_INIT( RicPasteAsciiDataCurveFeature, "RicPasteAsciiDataCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteAsciiDataCurveFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject )
{
return false;
}
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlot );
if ( !summaryPlot )
{
return false;
}
return RicPasteAsciiDataCurveFeature::asciiDataCurves().size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataCurveFeature::onActionTriggered( bool isChecked )
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
CVF_ASSERT( destinationObject );
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlot );
if ( !summaryPlot )
{
return;
}
std::vector<caf::PdmPointer<RimAsciiDataCurve>> sourceObjects = RicPasteAsciiDataCurveFeature::asciiDataCurves();
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
RimAsciiDataCurve* newObject = dynamic_cast<RimAsciiDataCurve*>(
sourceObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( newObject );
summaryPlot->addAsciiDataCruve( newObject );
// Resolve references after object has been inserted into the project data model
newObject->resolveReferencesRecursively();
// If source curve is part of a curve filter, resolve of references to the summary case does not
// work when pasting the new curve into a plot. Must set summary case manually.
// newObject->setSummaryCase(sourceObjects[i]->summaryCase());
newObject->initAfterReadRecursively();
newObject->loadDataAndUpdate( true );
newObject->updateConnectedEditors();
summaryPlot->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste ASCII Data Curve" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimAsciiDataCurve>> RicPasteAsciiDataCurveFeature::asciiDataCurves()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimAsciiDataCurve>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}

View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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"
#include "cafPdmPointer.h"
#include <vector>
class RimAsciiDataCurve;
//==================================================================================================
///
//==================================================================================================
class RicPasteAsciiDataCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<caf::PdmPointer<RimAsciiDataCurve>> asciiDataCurves();
};

View File

@@ -0,0 +1,263 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicPasteAsciiDataToSummaryPlotFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RicNewSummaryPlotFeature.h"
#include "RicPasteAsciiDataToSummaryPlotFeatureUi.h"
#include "RiaLogging.h"
#include "RimAsciiDataCurve.h"
#include "RimSummaryCurveAppearanceCalculator.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafPdmSettings.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "cvfColor3.h"
#include <QAction>
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
CAF_CMD_SOURCE_INIT( RicPasteAsciiDataToSummaryPlotFeature, "RicPasteAsciiDataToSummaryPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteAsciiDataToSummaryPlotFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return false;
RimSummaryPlotCollection* summaryPlotCollection = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlotCollection );
if ( !summaryPlotCollection )
{
return false;
}
return hasPastedText();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered( bool isChecked )
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlot );
QString text = getPastedData();
RicPasteAsciiDataToSummaryPlotFeatureUi pasteOptions;
caf::PdmSettings::readFieldsFromApplicationStore( &pasteOptions );
if ( !summaryPlot ) pasteOptions.createNewPlot();
pasteOptions.setUiModePasteText( text );
caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &pasteOptions, "Set Paste Options", "" );
if ( propertyDialog.exec() != QDialog::Accepted ) return;
std::vector<RimAsciiDataCurve*> curves = parseCurves( text, pasteOptions );
if ( curves.size() > 0 )
{
if ( !summaryPlot )
{
RimSummaryPlotCollection* summaryPlotCollection = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlotCollection );
if ( !summaryPlotCollection )
{
return;
}
summaryPlot = createSummaryPlotAndAddToPlotCollection( summaryPlotCollection );
summaryPlotCollection->updateConnectedEditors();
}
caf::PdmSettings::writeFieldsToApplicationStore( &pasteOptions );
for ( RimAsciiDataCurve* curve : curves )
{
summaryPlot->addAsciiDataCruve( curve );
}
summaryPlot->updateConnectedEditors();
summaryPlot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Excel Data to Summary Plot" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicPasteAsciiDataToSummaryPlotFeature::getPastedData()
{
if ( hasPastedText() )
{
QClipboard* clipboard = QApplication::clipboard();
return clipboard->text();
}
return QString();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteAsciiDataToSummaryPlotFeature::hasPastedText()
{
QClipboard* clipboard = QApplication::clipboard();
const QMimeData* mimeData = clipboard->mimeData();
if ( mimeData->hasText() && mimeData->text().size() > 12 )
{
QString text = mimeData->text();
if ( text.size() > 12 ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimAsciiDataCurve*>
RicPasteAsciiDataToSummaryPlotFeature::parseCurves( QString& data,
const RicPasteAsciiDataToSummaryPlotFeatureUi& settings )
{
std::vector<RimAsciiDataCurve*> curves;
const AsciiDataParseOptions& parseOptions = settings.parseOptions();
RifCsvUserDataPastedTextParser parser = RifCsvUserDataPastedTextParser( data );
if ( !parser.parse( parseOptions ) )
{
return curves;
}
if ( parser.tableData().columnInfos().empty() || !parser.dateTimeColumn() )
{
return curves;
}
std::map<CurveType, std::vector<RimAsciiDataCurve*>> curveToTypeMap;
QString curvePrefix = parseOptions.curvePrefix;
for ( size_t i = 0; i < parser.tableData().columnInfos().size(); i++ )
{
const Column* col = parser.columnInfo( i );
if ( col->dataType != Column::NUMERIC ) continue;
RimAsciiDataCurve* curve = new RimAsciiDataCurve();
curve->setTimeSteps( parser.dateTimeColumn()->qDateTimeValues() );
curve->setValues( parser.columnInfo( i )->values );
if ( curvePrefix.isEmpty() )
{
curve->setTitle( QString::fromStdString( col->columnName() ) );
}
else
{
curve->setTitle( QString( "%1: %2" ).arg( curvePrefix ).arg( QString::fromStdString( col->columnName() ) ) );
}
// Appearance
curve->setSymbol( parseOptions.curveSymbol );
curve->setLineStyle( parseOptions.curveLineStyle );
curve->setSymbolSkipDistance( parseOptions.curveSymbolSkipDistance );
curveToTypeMap[guessCurveType( QString::fromStdString( col->columnName() ) )].push_back( curve );
curves.push_back( curve );
}
for ( auto& it : curveToTypeMap )
{
for ( int i = 0; i < static_cast<int>( it.second.size() ); ++i )
{
cvf::Color3f color;
switch ( it.first )
{
case CURVE_GAS:
color = RimSummaryCurveAppearanceCalculator::cycledGreenColor( i );
break;
case CURVE_OIL:
color = RimSummaryCurveAppearanceCalculator::cycledRedColor( i );
break;
case CURVE_WAT:
color = RimSummaryCurveAppearanceCalculator::cycledBlueColor( i );
break;
default:
color = RimSummaryCurveAppearanceCalculator::cycledNoneRGBBrColor( i );
break;
}
it.second[i]->setColor( color );
}
}
return curves;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPasteAsciiDataToSummaryPlotFeature::CurveType
RicPasteAsciiDataToSummaryPlotFeature::guessCurveType( const QString& curveName )
{
if ( curveName.contains( "SW" ) || curveName.contains( "water", Qt::CaseInsensitive ) )
{
return CURVE_WAT;
}
else if ( curveName.contains( "oil", Qt::CaseInsensitive ) )
{
return CURVE_OIL;
}
else if ( curveName.contains( "gas", Qt::CaseInsensitive ) )
{
return CURVE_GAS;
}
return CURVE_UNKNOWN;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot*
RicPasteAsciiDataToSummaryPlotFeature::createSummaryPlotAndAddToPlotCollection( RimSummaryPlotCollection* plotCollection )
{
QString name = QString( "Summary Plot %1" ).arg( plotCollection->plots().size() + 1 );
return plotCollection->createNamedSummaryPlot( name );
}

View File

@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryCurve;
class RimAsciiDataCurve;
class RicPasteAsciiDataToSummaryPlotFeatureUi;
class RimSummaryPlotCollection;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicPasteAsciiDataToSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
enum CurveType
{
CURVE_GAS,
CURVE_OIL,
CURVE_WAT,
CURVE_UNKNOWN,
};
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static QString getPastedData();
static bool hasPastedText();
static std::vector<RimAsciiDataCurve*> parseCurves( QString& data,
const RicPasteAsciiDataToSummaryPlotFeatureUi& settings );
static CurveType guessCurveType( const QString& curveName );
static RimSummaryPlot* createSummaryPlotAndAddToPlotCollection( RimSummaryPlotCollection* plotCollection );
};

View File

@@ -0,0 +1,558 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicPasteAsciiDataToSummaryPlotFeatureUi.h"
#include "RifCsvUserDataParser.h"
#include "cafPdmUiItem.h"
#include "cafPdmUiTextEditor.h"
namespace caf
{
template <>
void RicPasteAsciiDataToSummaryPlotFeatureUi::DecimalSeparatorEnum::setUp()
{
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT, "DOT", "Dot (.)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_COMMA, "COMMA", "Comma (,)" );
setDefault( RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT );
}
template <>
void RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormatEnum::setUp()
{
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DOT_SEPARATED,
"dd.MM.yyyy",
"Day.Month.Year (dd.MM.yyyy)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DASH_SEPARATED,
"dd-MM-yyyy",
"Day-Month-Year (dd-MM-yyyy)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_SLASH_SEPARATED,
"dd/MM/yyyy",
"Day/Month/Year (dd/MM/yyyy)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_YYYYMMDD_DOT_SEPARATED,
"yyyy.MM.dd",
"Year.Month.Day (yyyy.MM.dd)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_YYYYMMDD_DASH_SEPARATED,
"yyyy-MM-dd",
"Year-Month-Day (yyyy-MM-dd)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_YYYYMMDD_SLASH_SEPARATED,
"yyyy/MM/dd",
"Year/Month/Day (yyyy/MM/dd)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_MMDDYYYY_SLASH_SEPARATED,
"MM/dd/yyyy",
"Month/Day/Year (MM/dd/yyyy)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_MMDDYY_SLASH_SEPARATED, "MM/dd/yy", "Month/Day/Year (MM/dd/yy)" );
setDefault( RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DOT_SEPARATED );
}
template <>
void RicPasteAsciiDataToSummaryPlotFeatureUi::TimeFormatEnum::setUp()
{
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_NONE, "", "None" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMM, "hh:mm", "Hour:Minute (hh:mm)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMMSS, "hh:mm:ss", "Hour:Minute:Second (hh:mm:ss)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMMSSZZZ,
"hh:mm:ss.zzz",
"Hour:Minute:Second.Millisecond (hh:mm:ss.zzz)" );
setDefault( RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_NONE );
}
template <>
void RicPasteAsciiDataToSummaryPlotFeatureUi::CellSeparatorEnum::setUp()
{
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB, "TAB", "Tab" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_COMMA, "COMMA", "Comma: (,)" );
addItem( RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_SEMICOLON, "SEMICOLON", "Semicolon (;)" );
setDefault( RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RicPasteAsciiDataToSummaryPlotFeatureUi, "RicPasteAsciiDataToSummaryPlotFeatureUi" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString DATETIME_FORMAT_TOOLTIP = R"(
<table>
<style>td {white-space:nowrap;}</style>
<tr> <th>Expression</th> <th>Description</th> </tr>
<tr> <td>d</td> <td>the day as number without a leading zero (1 to 31)</td> </tr>
<tr> <td>dd</td> <td>the day as number with a leading zero (01 to 31)</td> </tr>
<tr> <td>ddd</td> <td>the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName().</td> </tr>
<tr> <td>dddd</td> <td>the long localized day name (e.g. 'Monday' to 'Sunday'). Uses QDate::longDayName().</td> </tr>
<tr> <td>M</td> <td>the month as number without a leading zero (1-12)</td> </tr>
<tr> <td>MM</td> <td>the month as number with a leading zero (01-12)</td> </tr>
<tr> <td>MMM</td> <td>the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName().</td> </tr>
<tr> <td>MMMM</td> <td>the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName().</td> </tr>
<tr> <td>yy</td> <td>the year as two digit number (00-99)</td> </tr>
<tr> <td>yyyy</td> <td>the year as four digit number</td> </tr>
<tr> <td>h</td> <td>the hour without a leading zero(0 to 23 or 1 to 12 if AM / PM display)</td> </tr>
<tr> <td>hh</td> <td>the hour with a leading zero(00 to 23 or 01 to 12 if AM / PM display)</td> </tr>
<tr> <td>H</td> <td>the hour without a leading zero(0 to 23, even with AM / PM display)</td> </tr>
<tr> <td>HH</td> <td>the hour with a leading zero(00 to 23, even with AM / PM display)</td> </tr>
<tr> <td>m</td> <td>the minute without a leading zero(0 to 59)</td> </tr>
<tr> <td>mm</td> <td>the minute with a leading zero(00 to 59)</td> </tr>
<tr> <td>s</td> <td>the second without a leading zero(0 to 59)</td> </tr>
<tr> <td>ss</td> <td>the second with a leading zero(00 to 59)</td> </tr>
<tr> <td>z</td> <td>the milliseconds without leading zeroes(0 to 999)</td> </tr>
<tr> <td>zzz</td> <td>the milliseconds with leading zeroes(000 to 999)</td> </tr>
<tr> <td>AP or A</td> <td>interpret as an AM / PM time.AP must be either "AM" or "PM".</td> </tr>
<tr> <td>ap or a</td> <td>Interpret as an AM / PM time.ap must be either "am" or "pm".</td> </tr>
</table>
<hr>
Example: 'yyyy.MM.dd hh:mm:ss'
)";
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
#define PREVIEW_TEXT_LINE_COUNT 30
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPasteAsciiDataToSummaryPlotFeatureUi::CellSeparator mapCellSeparator( const QString& sep )
{
if ( sep == "\t" ) return RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB;
if ( sep == ";" ) return RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_SEMICOLON;
if ( sep == "," ) return RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_COMMA;
return RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString mapCellSeparator( RicPasteAsciiDataToSummaryPlotFeatureUi::CellSeparator cellSep )
{
switch ( cellSep )
{
case RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_COMMA:
return ",";
case RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_SEMICOLON:
return ";";
case RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB:
return "\t";
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPasteAsciiDataToSummaryPlotFeatureUi::DecimalSeparator mapDecimalSeparator( const QString& sep )
{
if ( sep == "." ) return RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT;
if ( sep == "," ) return RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_COMMA;
return RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPasteAsciiDataToSummaryPlotFeatureUi::RicPasteAsciiDataToSummaryPlotFeatureUi()
: m_createNewPlot( false )
{
CAF_PDM_InitObject( "RicPasteAsciiDataToSummaryPlotFeatureUi", "", "", "" );
CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString(), "Plot Title", "", "", "" );
CAF_PDM_InitField( &m_curvePrefix, "CurvePrefix", QString(), "Curve Prefix", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_decimalSeparator, "DecimalSeparator", "Decimal Separator", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_dateFormat, "DateFormat", "Date Format", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_timeFormat, "TimeFormat", "Time Format", "", "", "" );
CAF_PDM_InitField( &m_useCustomDateFormat, "UseCustomDateFormat", false, "Use Custom Date Time Format", "", "", "" );
CAF_PDM_InitField( &m_customDateTimeFormat,
"CustomDateTimeFormat",
QString(),
"Custom Date Time Format",
"",
DATETIME_FORMAT_TOOLTIP,
"" );
CAF_PDM_InitField( &m_curveLineStyle,
"LineStyle",
caf::AppEnum<RiuQwtPlotCurveDefines::LineStyleEnum>(
RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ),
"Line Style",
"",
"",
"" );
CAF_PDM_InitField( &m_curveSymbol,
"Symbol",
caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>( RiuQwtSymbol::SYMBOL_ELLIPSE ),
"Symbol",
"",
"",
"" );
CAF_PDM_InitField( &m_curveSymbolSkipDistance, "SymbolSkipDinstance", 0.0f, "Symbol Skip Distance", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_cellSeparator, "CellSeparator", "Cell Separator", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_timeSeriesColumnName, "TimeColumnName", "Selected Time Column", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_previewText, "PreviewText", "Preview Text", "", "", "" );
m_previewText.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );
m_previewText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_previewText.uiCapability()->setUiReadOnly( true );
m_uiMode = UI_MODE_NONE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::setUiModeImport( const QString& fileName )
{
m_parser = std::unique_ptr<RifCsvUserDataParser>( new RifCsvUserDataFileParser( fileName ) );
if ( m_parser->determineCsvLayout() != RifCsvUserDataParser::LineBased )
{
m_uiMode = UI_MODE_IMPORT;
initialize( m_parser.get() );
}
else
{
m_uiMode = UI_MODE_SILENT;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::setUiModePasteText( const QString& text )
{
m_uiMode = UI_MODE_PASTE;
m_parser = std::unique_ptr<RifCsvUserDataParser>( new RifCsvUserDataPastedTextParser( text ) );
initialize( m_parser.get() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPasteAsciiDataToSummaryPlotFeatureUi::UiMode RicPasteAsciiDataToSummaryPlotFeatureUi::uiModeImport() const
{
return m_uiMode;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const AsciiDataParseOptions RicPasteAsciiDataToSummaryPlotFeatureUi::parseOptions() const
{
AsciiDataParseOptions parseOptions;
parseOptions.assumeNumericDataColumns = true;
parseOptions.plotTitle = m_plotTitle();
parseOptions.curvePrefix = m_curvePrefix();
{
switch ( m_decimalSeparator() )
{
case DECIMAL_COMMA:
parseOptions.decimalSeparator = ",";
parseOptions.locale = RifCsvUserDataParser::localeFromDecimalSeparator( "," );
break;
case DECIMAL_DOT:
default:
parseOptions.decimalSeparator = ".";
parseOptions.locale = RifCsvUserDataParser::localeFromDecimalSeparator( "." );
break;
}
}
{
if ( m_useCustomDateFormat() )
{
parseOptions.useCustomDateTimeFormat = true;
parseOptions.dateFormat = "";
parseOptions.timeFormat = "";
parseOptions.dateTimeFormat = m_customDateTimeFormat();
}
else
{
parseOptions.useCustomDateTimeFormat = false;
parseOptions.dateFormat = m_dateFormat().text();
parseOptions.timeFormat = m_timeFormat().text();
parseOptions.dateTimeFormat = parseOptions.dateFormat +
( m_timeFormat() != TimeFormat::TIME_NONE ? " " + parseOptions.timeFormat : "" );
}
if ( m_timeFormat() == TimeFormat::TIME_NONE )
{
parseOptions.fallbackDateTimeFormat =
parseOptions.dateFormat + " " + RicPasteAsciiDataToSummaryPlotFeatureUi::TimeFormatEnum::text( TIME_HHMM );
}
}
parseOptions.timeSeriesColumnName = m_timeSeriesColumnName();
parseOptions.cellSeparator = mapCellSeparator( m_cellSeparator() );
parseOptions.curveLineStyle = m_curveLineStyle();
parseOptions.curveSymbol = m_curveSymbol();
parseOptions.curveSymbolSkipDistance = m_curveSymbolSkipDistance();
return parseOptions;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::createNewPlot()
{
m_createNewPlot = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat
RicPasteAsciiDataToSummaryPlotFeatureUi::dateFormatFromString( const QString& dateString )
{
std::vector<int> values;
{
QStringList split = dateString.split( ".", QString::SkipEmptyParts );
if ( split.size() == 3 )
{
values.push_back( split.at( 0 ).toInt() );
values.push_back( split.at( 1 ).toInt() );
values.push_back( split.at( 2 ).toInt() );
if ( values[0] > 31 ) return DATE_YYYYMMDD_DOT_SEPARATED;
if ( values[2] > 31 ) return DATE_DDMMYYYY_DOT_SEPARATED;
}
}
{
QStringList split = dateString.split( "-", QString::SkipEmptyParts );
if ( split.size() == 3 )
{
values.push_back( split.at( 0 ).toInt() );
values.push_back( split.at( 1 ).toInt() );
values.push_back( split.at( 2 ).toInt() );
if ( values[0] > 31 ) return DATE_YYYYMMDD_DASH_SEPARATED;
if ( values[2] > 31 ) return DATE_DDMMYYYY_DASH_SEPARATED;
}
}
{
QStringList split = dateString.split( "/", QString::SkipEmptyParts );
if ( split.size() == 3 )
{
values.push_back( split.at( 0 ).toInt() );
values.push_back( split.at( 1 ).toInt() );
values.push_back( split.at( 2 ).toInt() );
if ( split.at( 0 ).size() == 2 && split.at( 1 ).size() == 2 && split.at( 2 ).size() == 2 )
return DATE_MMDDYY_SLASH_SEPARATED;
if ( values[0] > 31 )
{
return DATE_YYYYMMDD_SLASH_SEPARATED;
}
else if ( values[2] > 31 )
{
if ( values[0] > 12 )
{
return DATE_DDMMYYYY_SLASH_SEPARATED;
}
if ( values[1] > 12 )
{
return DATE_MMDDYYYY_SLASH_SEPARATED;
}
return DATE_DDMMYYYY_SLASH_SEPARATED;
}
}
}
return DATE_DDMMYYYY_DOT_SEPARATED;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
CVF_ASSERT( m_uiMode != UI_MODE_NONE );
if ( m_uiMode == UI_MODE_PASTE )
{
caf::PdmUiGroup* namingGroup = uiOrdering.addNewGroup( "Naming" );
if ( m_createNewPlot )
{
namingGroup->add( &m_plotTitle );
}
namingGroup->add( &m_curvePrefix );
}
{
caf::PdmUiGroup* formatGroup = uiOrdering.addNewGroup( "Format" );
formatGroup->add( &m_cellSeparator );
formatGroup->add( &m_decimalSeparator );
}
{
caf::PdmUiGroup* dateGroup = uiOrdering.addNewGroup( "Time column" );
dateGroup->add( &m_timeSeriesColumnName );
dateGroup->add( &m_useCustomDateFormat );
if ( m_useCustomDateFormat() )
{
dateGroup->add( &m_customDateTimeFormat );
}
else
{
dateGroup->add( &m_dateFormat );
dateGroup->add( &m_timeFormat );
}
}
if ( m_uiMode == UI_MODE_PASTE )
{
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
appearanceGroup->add( &m_curveLineStyle );
appearanceGroup->add( &m_curveSymbol );
appearanceGroup->add( &m_curveSymbolSkipDistance );
}
{
caf::PdmUiGroup* previewGroup = uiOrdering.addNewGroup(
QString( "Preview - First %1 lines, Pretty Print" ).arg( QString::number( PREVIEW_TEXT_LINE_COUNT ) ) );
previewGroup->add( &m_previewText );
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RicPasteAsciiDataToSummaryPlotFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
CVF_ASSERT( m_uiMode != UI_MODE_NONE );
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_timeSeriesColumnName )
{
const std::vector<Column>& columnInfoList = m_parser->tableData().columnInfos();
for ( const Column& columnInfo : columnInfoList )
{
QString columnName = QString::fromStdString( columnInfo.columnName() );
options.push_back( caf::PdmOptionItemInfo( columnName, columnName ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_previewText )
{
caf::PdmUiTextEditorAttribute* attrib = dynamic_cast<caf::PdmUiTextEditorAttribute*>( attribute );
if ( attrib )
{
attrib->wrapMode = caf::PdmUiTextEditorAttribute::NoWrap;
QFont font( "Monospace", 7 );
attrib->font = font;
attrib->textMode = caf::PdmUiTextEditorAttribute::HTML;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_cellSeparator || changedField == &m_timeSeriesColumnName )
{
updatePreviewTextAndDateFormat();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::initialize( RifCsvUserDataParser* parser )
{
CVF_ASSERT( parser );
QString cellSep = parser->tryDetermineCellSeparator();
if ( !cellSep.isEmpty() )
{
m_cellSeparator = mapCellSeparator( cellSep );
QString decimalSep = parser->tryDetermineDecimalSeparator( cellSep );
if ( !decimalSep.isEmpty() )
{
m_decimalSeparator = mapDecimalSeparator( decimalSep );
}
}
parser->parseColumnInfo( parseOptions() );
if ( parser->tableData().columnInfos().size() > 0 )
{
m_timeSeriesColumnName = QString::fromStdString( parser->tableData().columnInfos()[0].columnName() );
}
updatePreviewTextAndDateFormat();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteAsciiDataToSummaryPlotFeatureUi::updatePreviewTextAndDateFormat()
{
m_previewText = m_parser->previewText( PREVIEW_TEXT_LINE_COUNT, parseOptions() );
QStringList timeStrings = m_parser->timeColumnPreviewData( PREVIEW_TEXT_LINE_COUNT, parseOptions() );
DateFormat df = DATE_DDMMYYYY_DOT_SEPARATED;
for ( auto& s : timeStrings )
{
df = dateFormatFromString( s );
}
m_dateFormat = df;
}

View File

@@ -0,0 +1,170 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RimPlotCurve.h"
#include "RifCsvUserDataParser.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QLocale>
#include <QString>
#include <memory>
//==================================================================================================
///
//==================================================================================================
class AsciiDataParseOptions
{
public:
AsciiDataParseOptions()
: useCustomDateTimeFormat( false )
, assumeNumericDataColumns( false )
, curveSymbolSkipDistance( 0.0f )
{
}
QString plotTitle;
QString curvePrefix;
QString decimalSeparator;
QLocale locale;
bool useCustomDateTimeFormat;
QString dateFormat;
QString timeFormat;
QString fallbackDateTimeFormat;
QString dateTimeFormat;
QString cellSeparator;
QString timeSeriesColumnName;
bool assumeNumericDataColumns;
RiuQwtPlotCurveDefines::LineStyleEnum curveLineStyle;
RiuQwtSymbol::PointSymbolEnum curveSymbol;
float curveSymbolSkipDistance;
};
//==================================================================================================
///
//==================================================================================================
class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum UiMode
{
UI_MODE_NONE,
UI_MODE_IMPORT,
UI_MODE_PASTE,
UI_MODE_SILENT
};
enum DecimalSeparator
{
DECIMAL_COMMA,
DECIMAL_DOT,
};
typedef caf::AppEnum<DecimalSeparator> DecimalSeparatorEnum;
enum DateFormat
{
DATE_DDMMYYYY_DOT_SEPARATED,
DATE_DDMMYYYY_DASH_SEPARATED,
DATE_DDMMYYYY_SLASH_SEPARATED,
DATE_YYYYMMDD_DOT_SEPARATED,
DATE_YYYYMMDD_DASH_SEPARATED,
DATE_YYYYMMDD_SLASH_SEPARATED,
DATE_MMDDYYYY_SLASH_SEPARATED,
DATE_MMDDYY_SLASH_SEPARATED
};
typedef caf::AppEnum<DateFormat> DateFormatEnum;
enum TimeFormat
{
TIME_NONE,
TIME_HHMM,
TIME_HHMMSS,
TIME_HHMMSSZZZ,
};
typedef caf::AppEnum<TimeFormat> TimeFormatEnum;
enum CellSeparator
{
CELL_COMMA,
CELL_TAB,
CELL_SEMICOLON
};
typedef caf::AppEnum<CellSeparator> CellSeparatorEnum;
public:
RicPasteAsciiDataToSummaryPlotFeatureUi();
void setUiModeImport( const QString& fileName );
void setUiModePasteText( const QString& text );
UiMode uiModeImport() const;
const AsciiDataParseOptions parseOptions() const;
void createNewPlot();
static DateFormat dateFormatFromString( const QString& dateString );
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
void initialize( RifCsvUserDataParser* parser );
void updatePreviewTextAndDateFormat();
private:
UiMode m_uiMode;
caf::PdmField<QString> m_plotTitle;
caf::PdmField<QString> m_curvePrefix;
caf::PdmField<DecimalSeparatorEnum> m_decimalSeparator;
caf::PdmField<DateFormatEnum> m_dateFormat;
caf::PdmField<TimeFormatEnum> m_timeFormat;
caf::PdmField<bool> m_useCustomDateFormat;
caf::PdmField<QString> m_customDateTimeFormat;
caf::PdmField<CellSeparatorEnum> m_cellSeparator;
caf::PdmField<QString> m_timeSeriesColumnName;
caf::PdmField<caf::AppEnum<RiuQwtPlotCurveDefines::LineStyleEnum>> m_curveLineStyle;
caf::PdmField<caf::AppEnum<RiuQwtSymbol::PointSymbolEnum>> m_curveSymbol;
caf::PdmField<float> m_curveSymbolSkipDistance;
bool m_createNewPlot;
caf::PdmField<QString> m_previewText;
std::unique_ptr<RifCsvUserDataParser> m_parser;
};

View File

@@ -0,0 +1,142 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteEnsembleCurveSetFeature.h"
#include "RiaSummaryTools.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimSummaryPlot.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteEnsembleCurveSetFeature, "RicPasteEnsembleCurveSetFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleCurveSet*
RicPasteEnsembleCurveSetFeature::copyCurveSetAndAddToCollection( RimEnsembleCurveSetCollection* curveSetCollection,
const RimEnsembleCurveSet* sourceCurveSet )
{
CVF_ASSERT( curveSetCollection );
RimEnsembleCurveSet* newCurveSet = dynamic_cast<RimEnsembleCurveSet*>(
sourceCurveSet->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( newCurveSet );
curveSetCollection->addCurveSet( newCurveSet );
// Resolve references after object has been inserted into the project data model
newCurveSet->resolveReferencesRecursively();
newCurveSet->initAfterReadRecursively();
newCurveSet->loadDataAndUpdate( false );
newCurveSet->updateConnectedEditors();
return newCurveSet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteEnsembleCurveSetFeature::isCommandEnabled()
{
caf::PdmObject* destinationObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return false;
RimSummaryPlot* plot = nullptr;
RimEnsembleCurveSetCollection* coll = nullptr;
destinationObject->firstAncestorOrThisOfType( plot );
destinationObject->firstAncestorOrThisOfType( coll );
if ( !coll && !plot )
{
return false;
}
if ( ensembleCurveSetsOnClipboard().empty() )
{
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEnsembleCurveSetFeature::onActionTriggered( bool isChecked )
{
std::vector<caf::PdmPointer<RimEnsembleCurveSet>> sourceObjects =
RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard();
if ( sourceObjects.empty() ) return;
RimSummaryPlot* plot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot*>();
RimEnsembleCurveSetCollection* coll = caf::firstAncestorOfTypeFromSelectedObject<RimEnsembleCurveSetCollection*>();
if ( !coll && plot )
{
coll = plot->ensembleCurveSetCollection();
}
if ( !coll ) return;
for ( const auto& sourceObject : sourceObjects )
{
copyCurveSetAndAddToCollection( coll, sourceObject );
}
if ( plot )
{
plot->updateAll();
}
coll->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEnsembleCurveSetFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Ensemble Curve Set" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimEnsembleCurveSet>> RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimEnsembleCurveSet>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "cafPdmPointer.h"
#include <vector>
class RimEnsembleCurveSet;
class RimEnsembleCurveSetCollection;
//==================================================================================================
///
//==================================================================================================
class RicPasteEnsembleCurveSetFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
static RimEnsembleCurveSet* copyCurveSetAndAddToCollection( RimEnsembleCurveSetCollection* coll,
const RimEnsembleCurveSet* sourceCurveSet );
static std::vector<caf::PdmPointer<RimEnsembleCurveSet>> ensembleCurveSetsOnClipboard();
};

View File

@@ -0,0 +1,166 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicPasteSummaryCaseFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryPlot.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteSummaryCaseFeature, "RicPasteSummaryCaseFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCaseFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return false;
RimSummaryCaseCollection* summaryCaseCollection = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryCaseCollection );
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryCaseMainCollection );
if ( !( summaryCaseCollection || summaryCaseMainCollection ) )
{
return false;
}
std::vector<caf::PdmPointer<RimSummaryCase>> summaryCases = RicPasteSummaryCaseFeature::summaryCases();
if ( summaryCases.size() == 0 )
{
return false;
}
for ( RimSummaryCase* summaryCase : summaryCases )
{
if ( summaryCase->isObservedData() )
{
return false;
}
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCaseFeature::onActionTriggered( bool isChecked )
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return;
std::vector<caf::PdmPointer<RimSummaryCase>> sourceObjects = RicPasteSummaryCaseFeature::summaryCases();
RimSummaryCaseCollection* summaryCaseCollection = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryCaseCollection );
if ( summaryCaseCollection )
{
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
RicPasteSummaryCaseFeature::removeFromSourceCollection( sourceObjects[i] );
summaryCaseCollection->addCase( sourceObjects[i] );
}
summaryCaseCollection->updateConnectedEditors();
RicPasteFeatureImpl::clearClipboard();
return;
}
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryCaseMainCollection );
if ( summaryCaseMainCollection )
{
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
RicPasteSummaryCaseFeature::removeFromSourceCollection( sourceObjects[i] );
summaryCaseMainCollection->addCase( sourceObjects[i] );
}
RicPasteFeatureImpl::clearClipboard();
summaryCaseMainCollection->updateAllRequiredEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCaseFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Summary Case" );
actionToSetup->setIcon( QIcon( ":/clipboard.png" ) );
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Paste );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimSummaryCase>> RicPasteSummaryCaseFeature::summaryCases()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimSummaryCase>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCaseFeature::removeFromSourceCollection( RimSummaryCase* summaryCase )
{
RimSummaryCaseCollection* sourceSummaryCaseCollection = nullptr;
summaryCase->firstAncestorOrThisOfType( sourceSummaryCaseCollection );
if ( sourceSummaryCaseCollection )
{
sourceSummaryCaseCollection->removeCase( summaryCase );
sourceSummaryCaseCollection->updateConnectedEditors();
return;
}
RimSummaryCaseMainCollection* sourceSummaryCaseMainCollection = nullptr;
summaryCase->firstAncestorOrThisOfType( sourceSummaryCaseMainCollection );
if ( sourceSummaryCaseMainCollection )
{
sourceSummaryCaseMainCollection->removeCase( summaryCase );
sourceSummaryCaseMainCollection->updateConnectedEditors();
}
}

View File

@@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryCase;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryCaseFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* action ) override;
static std::vector<caf::PdmPointer<RimSummaryCase>> summaryCases();
static void removeFromSourceCollection( RimSummaryCase* summaryCase );
};

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCrossPlotCurveFeature.h"
#include "RiaSummaryTools.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveFilter.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteSummaryCrossPlotCurveFeature, "RicPasteSummaryCrossPlotCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCrossPlotCurveFeature::isCommandEnabled()
{
caf::PdmObject* destinationObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !RiaSummaryTools::parentCrossPlot( destinationObject ) )
{
return false;
}
if ( summaryCurvesOnClipboard().size() == 0 )
{
return false;
}
for ( caf::PdmPointer<RimSummaryCurve> curve : summaryCurvesOnClipboard() )
{
// Check that owner plot is correct type
RimSummaryCrossPlot* ownerPlot = nullptr;
curve->firstAncestorOrThisOfType( ownerPlot );
if ( !ownerPlot ) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
// void RicPasteSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked)
//{
// std::vector<caf::PdmPointer<RimSummaryCurve> > sourceObjects = RicPasteSummaryCurveFeature::summaryCurves();
//
// for (size_t i = 0; i < sourceObjects.size(); i++)
// {
// copyCurveAndAddToPlot(sourceObjects[i]);
// }
//}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Summary Cross Plot Curve" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}

View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCurveFeature.h"
#include "cafCmdFeature.h"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryCurve;
class RimSummaryCurveFilter;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryCrossPlotCurveFeature : public RicPasteSummaryCurveFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
// virtual void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCrossPlotFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteSummaryCrossPlotFeature, "RicPasteSummaryCrossPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection( RimSummaryCrossPlot* sourcePlot )
{
RimSummaryCrossPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCrossPlotCollection*>();
if ( plotColl )
{
RimSummaryCrossPlot* newSummaryPlot = dynamic_cast<RimSummaryCrossPlot*>(
sourcePlot->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( newSummaryPlot );
plotColl->addPlot( newSummaryPlot );
// Resolve references after object has been inserted into the data model
newSummaryPlot->resolveReferencesRecursively();
newSummaryPlot->initAfterReadRecursively();
QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description();
newSummaryPlot->setDescription( nameOfCopy );
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCrossPlotFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return false;
RimSummaryCrossPlotCollection* plotColl = nullptr;
destinationObject->firstAncestorOrThisOfType( plotColl );
if ( !plotColl )
{
return false;
}
return RicPasteSummaryCrossPlotFeature::summaryPlots().size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotFeature::onActionTriggered( bool isChecked )
{
std::vector<caf::PdmPointer<RimSummaryCrossPlot>> sourceObjects = RicPasteSummaryCrossPlotFeature::summaryPlots();
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
copyPlotAndAddToCollection( sourceObjects[i] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Summary Cross Plot" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimSummaryCrossPlot>> RicPasteSummaryCrossPlotFeature::summaryPlots()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimSummaryCrossPlot>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryCrossPlot;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void copyPlotAndAddToCollection( RimSummaryCrossPlot* sourcePlot );
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<caf::PdmPointer<RimSummaryCrossPlot>> summaryPlots();
};

View File

@@ -0,0 +1,136 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCurveFeature.h"
#include "RiaSummaryTools.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteSummaryCurveFeature, "RicPasteSummaryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot( RimSummaryCurve* sourceCurve )
{
RimSummaryPlot* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot*>();
RimSummaryCurve* newCurve = dynamic_cast<RimSummaryCurve*>(
sourceCurve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( newCurve );
summaryPlot->addCurveAndUpdate( newCurve );
// Resolve references after object has been inserted into the project data model
newCurve->resolveReferencesRecursively();
// If source curve is part of a curve filter, resolve of references to the summary case does not
// work when pasting the new curve into a plot. Must set summary case manually.
newCurve->setSummaryCaseY( sourceCurve->summaryCaseY() );
newCurve->initAfterReadRecursively();
newCurve->loadDataAndUpdate( true );
newCurve->updateConnectedEditors();
summaryPlot->updateConnectedEditors();
return newCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCurveFeature::isCommandEnabled()
{
caf::PdmObject* destinationObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return false;
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlot );
if ( !RiaSummaryTools::parentSummaryPlot( destinationObject ) )
{
return false;
}
if ( summaryCurvesOnClipboard().size() == 0 )
{
return false;
}
for ( caf::PdmPointer<RimSummaryCurve> curve : summaryCurvesOnClipboard() )
{
// Check that owner plot is correct type
RimSummaryPlot* ownerPlot = RiaSummaryTools::parentSummaryPlot( curve );
if ( !ownerPlot ) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCurveFeature::onActionTriggered( bool isChecked )
{
std::vector<caf::PdmPointer<RimSummaryCurve>> sourceObjects = RicPasteSummaryCurveFeature::summaryCurvesOnClipboard();
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
copyCurveAndAddToPlot( sourceObjects[i] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Summary Curve" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimSummaryCurve>> RicPasteSummaryCurveFeature::summaryCurvesOnClipboard()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimSummaryCurve>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryCurve;
class RimSummaryCurveFilter;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimSummaryCurve* copyCurveAndAddToPlot( RimSummaryCurve* sourceCurve );
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
static std::vector<caf::PdmPointer<RimSummaryCurve>> summaryCurvesOnClipboard();
};

View File

@@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryPlotFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteSummaryPlotFeature, "RicPasteSummaryPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryPlotFeature::copyPlotAndAddToCollection( RimSummaryPlot* sourcePlot )
{
RimSummaryPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlotCollection*>();
if ( plotColl )
{
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>(
sourcePlot->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( newSummaryPlot );
plotColl->addPlot( newSummaryPlot );
// Resolve references after object has been inserted into the data model
newSummaryPlot->resolveReferencesRecursively();
newSummaryPlot->initAfterReadRecursively();
QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description();
newSummaryPlot->setDescription( nameOfCopy );
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryPlotFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject ) return false;
RimSummaryPlotCollection* plotColl = nullptr;
destinationObject->firstAncestorOrThisOfType( plotColl );
if ( !plotColl )
{
return false;
}
return RicPasteSummaryPlotFeature::summaryPlots().size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryPlotFeature::onActionTriggered( bool isChecked )
{
std::vector<caf::PdmPointer<RimSummaryPlot>> sourceObjects = RicPasteSummaryPlotFeature::summaryPlots();
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
copyPlotAndAddToCollection( sourceObjects[i] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Summary Plot" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimSummaryPlot>> RicPasteSummaryPlotFeature::summaryPlots()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimSummaryPlot>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void copyPlotAndAddToCollection( RimSummaryPlot* sourcePlot );
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<caf::PdmPointer<RimSummaryPlot>> summaryPlots();
};

View File

@@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteTimeHistoryCurveFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimSummaryPlot.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicPasteTimeHistoryCurveFeature, "RicPasteTimeHistoryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteTimeHistoryCurveFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
if ( !destinationObject )
{
return false;
}
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlot );
if ( !summaryPlot )
{
return false;
}
return RicPasteTimeHistoryCurveFeature::timeHistoryCurves().size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteTimeHistoryCurveFeature::onActionTriggered( bool isChecked )
{
caf::PdmObjectHandle* destinationObject =
dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
CVF_ASSERT( destinationObject );
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType( summaryPlot );
if ( !summaryPlot )
{
return;
}
std::vector<caf::PdmPointer<RimGridTimeHistoryCurve>> sourceObjects =
RicPasteTimeHistoryCurveFeature::timeHistoryCurves();
for ( size_t i = 0; i < sourceObjects.size(); i++ )
{
RimGridTimeHistoryCurve* newObject = dynamic_cast<RimGridTimeHistoryCurve*>(
sourceObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( newObject );
summaryPlot->addGridTimeHistoryCurve( newObject );
// Resolve references after object has been inserted into the project data model
newObject->resolveReferencesRecursively();
// If source curve is part of a curve filter, resolve of references to the summary case does not
// work when pasting the new curve into a plot. Must set summary case manually.
// newObject->setSummaryCase(sourceObjects[i]->summaryCase());
newObject->initAfterReadRecursively();
newObject->loadDataAndUpdate( true );
newObject->updateConnectedEditors();
summaryPlot->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteTimeHistoryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Time History Curve" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimGridTimeHistoryCurve>> RicPasteTimeHistoryCurveFeature::timeHistoryCurves()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimGridTimeHistoryCurve>> typedObjects;
objectGroup.objectsByType( &typedObjects );
return typedObjects;
}

View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "cafPdmPointer.h"
#include <vector>
class RimGridTimeHistoryCurve;
//==================================================================================================
///
//==================================================================================================
class RicPasteTimeHistoryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<caf::PdmPointer<RimGridTimeHistoryCurve>> timeHistoryCurves();
};

View File

@@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicSelectSummaryPlotUI.h"
#include "RiaSummaryTools.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
CAF_PDM_SOURCE_INIT( RicSelectSummaryPlotUI, "RicSelectSummaryPlotUI" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSelectSummaryPlotUI::RicSelectSummaryPlotUI()
{
CAF_PDM_InitObject( "RicSelectSummaryPlotUI", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_selectedSummaryPlot, "SelectedSummaryPlot", "Select Plot", "", "", "" );
CAF_PDM_InitField( &m_createNewPlot, "CreateNewPlot", false, "Create New Plot", "", "", "" );
CAF_PDM_InitField( &m_newSummaryPlotName, "NewViewName", QString( "Cell Results" ), "New Plot Name", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSelectSummaryPlotUI::setDefaultSummaryPlot( RimSummaryPlot* summaryPlot )
{
m_selectedSummaryPlot = summaryPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSelectSummaryPlotUI::setSuggestedPlotName( const QString& name )
{
m_newSummaryPlotName = name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicSelectSummaryPlotUI::selectedSummaryPlot() const
{
return m_selectedSummaryPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSelectSummaryPlotUI::isCreateNewPlotChecked() const
{
return m_createNewPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSelectSummaryPlotUI::newPlotName() const
{
return m_newSummaryPlotName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RicSelectSummaryPlotUI::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_selectedSummaryPlot )
{
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
summaryPlotColl->summaryPlotItemInfos( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSelectSummaryPlotUI::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( RiaSummaryTools::summaryPlotCollection()->plots().empty() )
{
m_createNewPlot = true;
}
if ( m_createNewPlot )
{
m_newSummaryPlotName.uiCapability()->setUiReadOnly( false );
m_selectedSummaryPlot.uiCapability()->setUiReadOnly( true );
}
else
{
m_newSummaryPlotName.uiCapability()->setUiReadOnly( true );
m_selectedSummaryPlot.uiCapability()->setUiReadOnly( false );
}
}

View File

@@ -0,0 +1,55 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
class RimSummaryPlot;
class RimSummaryPlotCollection;
//==================================================================================================
///
//==================================================================================================
class RicSelectSummaryPlotUI : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicSelectSummaryPlotUI();
void setDefaultSummaryPlot( RimSummaryPlot* summaryPlot );
void setSuggestedPlotName( const QString& name );
RimSummaryPlot* selectedSummaryPlot() const;
bool isCreateNewPlotChecked() const;
QString newPlotName() const;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private:
caf::PdmPtrField<RimSummaryPlot*> m_selectedSummaryPlot;
caf::PdmField<bool> m_createNewPlot;
caf::PdmField<QString> m_newSummaryPlotName;
};

View File

@@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 "RicSetSourceSteppingEnsembleCurveSetFeature.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include "RicClearSourceSteppingEnsembleCurveSetFeature.h"
#include "RimSummaryPlot.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicSetSourceSteppingEnsembleCurveSetFeature, "RicSetSourceSteppingEnsembleCurveSetFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSetSourceSteppingEnsembleCurveSetFeature::isCommandEnabled()
{
std::vector<RimEnsembleCurveSet*> ensembleCurveSets;
caf::SelectionManager::instance()->objectsByType( &ensembleCurveSets );
if ( ensembleCurveSets.size() == 1 )
{
auto c = ensembleCurveSets[0];
RimEnsembleCurveSetCollection* coll = nullptr;
c->firstAncestorOrThisOfType( coll );
if ( coll )
{
if ( coll->curveSetForSourceStepping() != c )
{
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSetSourceSteppingEnsembleCurveSetFeature::onActionTriggered( bool isChecked )
{
std::vector<RimEnsembleCurveSet*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
if ( objects.size() == 1 )
{
auto c = objects[0];
RimSummaryPlot* summaryPlot = nullptr;
c->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
RicClearSourceSteppingEnsembleCurveSetFeature::clearAllSourceSteppingInSummaryPlot( summaryPlot );
}
RimEnsembleCurveSetCollection* coll = nullptr;
c->firstAncestorOrThisOfType( coll );
if ( coll )
{
coll->setCurveSetForSourceStepping( c );
c->updateConnectedEditors();
RiuPlotMainWindowTools::refreshToolbars();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSetSourceSteppingEnsembleCurveSetFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Set as Source Stepping Curve Set" );
actionToSetup->setIcon( QIcon( ":/StepUpDown16x16.png" ) );
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 RicSetSourceSteppingEnsembleCurveSetFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 "RicSetSourceSteppingSummaryCurveFeature.h"
#include "RicClearSourceSteppingEnsembleCurveSetFeature.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicSetSourceSteppingSummaryCurveFeature, "RicSetSourceSteppingSummaryCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSetSourceSteppingSummaryCurveFeature::isCommandEnabled()
{
std::vector<RimSummaryCurve*> summaryCurves;
caf::SelectionManager::instance()->objectsByType( &summaryCurves );
if ( summaryCurves.size() == 1 )
{
auto c = summaryCurves[0];
RimSummaryCurveCollection* coll = nullptr;
c->firstAncestorOrThisOfTypeAsserted( coll );
if ( coll )
{
if ( coll->curveForSourceStepping() != c )
{
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSetSourceSteppingSummaryCurveFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryCurve*> summaryCurves;
caf::SelectionManager::instance()->objectsByType( &summaryCurves );
if ( summaryCurves.size() == 1 )
{
auto c = summaryCurves[0];
RimSummaryPlot* summaryPlot = nullptr;
c->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
RicClearSourceSteppingEnsembleCurveSetFeature::clearAllSourceSteppingInSummaryPlot( summaryPlot );
}
RimSummaryCurveCollection* coll = nullptr;
c->firstAncestorOrThisOfTypeAsserted( coll );
if ( coll )
{
coll->setCurveForSourceStepping( c );
c->updateConnectedEditors();
RiuPlotMainWindowTools::refreshToolbars();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSetSourceSteppingSummaryCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Set as Source Stepping Curve" );
actionToSetup->setIcon( QIcon( ":/StepUpDown16x16.png" ) );
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 RicSetSourceSteppingSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicShowSummaryCurveCalculatorFeature.h"
#include "RicSummaryCurveCalculatorDialog.h"
#include "RiaGuiApplication.h"
#include "RimProject.h"
#include "RimSummaryCalculationCollection.h"
#include "RiuPlotMainWindow.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicShowSummaryCurveCalculatorFeature, "RicShowSummaryCurveCalculatorFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorDialog* RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog()
{
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( mainPlotWindow )
{
return mainPlotWindow->summaryCurveCalculatorDialog();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog()
{
auto dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog();
dialog->hide();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled()
{
RimProject* proj = RimProject::current();
if ( !proj ) return false;
const auto& allSumCases = proj->allSummaryCases();
return !allSumCases.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowSummaryCurveCalculatorFeature::onActionTriggered( bool isChecked )
{
RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog();
RimProject* proj = RimProject::current();
RimSummaryCalculationCollection* calcColl = proj->calculationCollection();
if ( calcColl->calculations().size() == 0 )
{
calcColl->addCalculation();
}
dialog->setCalculationAndUpdateUi( calcColl->calculations()[0] );
dialog->show();
dialog->raise();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowSummaryCurveCalculatorFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Curve Calculator" );
actionToSetup->setIcon( QIcon( ":/Calculator.svg" ) );
}

View File

@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RicSummaryCurveCalculatorDialog;
//==================================================================================================
///
//==================================================================================================
class RicShowSummaryCurveCalculatorFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RicSummaryCurveCalculatorDialog* curveCalculatorDialog();
static void hideCurveCalculatorDialog();
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,147 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicSummaryCurveCalculatorDialog.h"
#include "RicSummaryCurveCalculatorUi.h"
#include "RicSummaryCurveCalculatorWidgetCreator.h"
#include "RimSummaryCalculation.h"
#include "RimSummaryCalculationCollection.h"
#include "RiuTools.h"
#include <QDialogButtonBox>
#include <QMessageBox>
#include <QVBoxLayout>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorDialog::RicSummaryCurveCalculatorDialog( QWidget* parent )
: QDialog( parent, RiuTools::defaultDialogFlags() )
{
setWindowTitle( "Summary Curve Calculator" );
resize( 1200, 800 );
setUp();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorDialog::~RicSummaryCurveCalculatorDialog()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorDialog::setCalculationAndUpdateUi( RimSummaryCalculation* calculation )
{
m_summaryCalcEditor->calculator()->setCurrentCalculation( calculation );
m_summaryCalcEditor->updateUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorDialog::slotTryCloseDialog()
{
RimSummaryCalculationCollection* calculationCollection = RicSummaryCurveCalculatorUi::calculationCollection();
if ( dirtyCount() > 0 )
{
QMessageBox msgBox( this );
msgBox.setIcon( QMessageBox::Question );
QString questionText = QString( "Detected calculation expression text modifications." );
msgBox.setText( questionText );
msgBox.setInformativeText( "Do you want to trigger calculation?" );
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
int ret = msgBox.exec();
if ( ret == QMessageBox::No )
{
reject();
}
else if ( ret == QMessageBox::Yes )
{
for ( auto c : calculationCollection->calculations() )
{
if ( c->isDirty() )
{
c->calculate();
c->updateDependentCurvesAndPlots();
}
}
if ( dirtyCount() > 0 )
{
return;
}
}
else
{
return;
}
}
accept();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorDialog::setUp()
{
QVBoxLayout* mainLayout = new QVBoxLayout( this );
mainLayout->setContentsMargins( 0, 0, 0, 0 );
m_summaryCalcEditor =
std::unique_ptr<RicSummaryCurveCalculatorWidgetCreator>( new RicSummaryCurveCalculatorWidgetCreator() );
mainLayout->addWidget( m_summaryCalcEditor->getOrCreateWidget( this ) );
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( slotTryCloseDialog() ) );
mainLayout->addWidget( buttonBox );
m_summaryCalcEditor->updateUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RicSummaryCurveCalculatorDialog::dirtyCount() const
{
size_t count = 0;
RimSummaryCalculationCollection* calculationCollection = RicSummaryCurveCalculatorUi::calculationCollection();
for ( auto c : calculationCollection->calculations() )
{
if ( c->isDirty() )
{
count++;
}
}
return count;
}

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 <QDialog>
#include <memory>
class RicSummaryCurveCalculatorWidgetCreator;
class RimSummaryCalculation;
//==================================================================================================
///
///
//==================================================================================================
class RicSummaryCurveCalculatorDialog : public QDialog
{
Q_OBJECT
public:
RicSummaryCurveCalculatorDialog( QWidget* parent );
~RicSummaryCurveCalculatorDialog() override;
void setCalculationAndUpdateUi( RimSummaryCalculation* calculation );
private slots:
void slotTryCloseDialog();
private:
void setUp();
size_t dirtyCount() const;
private:
std::unique_ptr<RicSummaryCurveCalculatorWidgetCreator> m_summaryCalcEditor;
};

View File

@@ -0,0 +1,298 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicSummaryCurveCalculatorUi.h"
#include "RiaSummaryTools.h"
#include "RimProject.h"
#include "RimSummaryCalculation.h"
#include "RimSummaryCalculationCollection.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiObjectEditorHandle.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT( RicSummaryCurveCalculatorUi, "RicSummaryCurveCalculator" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorUi::RicSummaryCurveCalculatorUi()
{
CAF_PDM_InitObject( "RicSummaryCurveCalculator", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_currentCalculation, "CurrentCalculation", "", "", "", "" );
m_currentCalculation.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
// m_currentCalculation.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
m_currentCalculation.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_newCalculation, "NewCalculation", "New Calculation", "", "", "" );
RicSummaryCurveCalculatorUi::assignPushButtonEditor( &m_newCalculation );
CAF_PDM_InitFieldNoDefault( &m_deleteCalculation, "DeleteCalculation", "Delete Calculation", "", "", "" );
RicSummaryCurveCalculatorUi::assignPushButtonEditor( &m_deleteCalculation );
m_calcContextMenuMgr = std::unique_ptr<RiuCalculationsContextMenuManager>( new RiuCalculationsContextMenuManager() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryCurveCalculatorUi::calculatedSummariesGroupName()
{
return "CalculatedSummariesGroupName";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryCurveCalculatorUi::calulationGroupName()
{
return "CalulationGroupName";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCalculation* RicSummaryCurveCalculatorUi::currentCalculation() const
{
return m_currentCalculation();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::setCurrentCalculation( RimSummaryCalculation* calculation )
{
m_currentCalculation = calculation;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryCurveCalculatorUi::parseExpression() const
{
if ( m_currentCalculation() )
{
QString previousCurveName = m_currentCalculation->description();
if ( !m_currentCalculation()->parseExpression() )
{
return false;
}
QString currentCurveName = m_currentCalculation->description();
if ( previousCurveName != currentCurveName )
{
RiaSummaryTools::notifyCalculatedCurveNameHasChanged( m_currentCalculation()->id(), currentCurveName );
}
m_currentCalculation()->updateDependentCurvesAndPlots();
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_newCalculation )
{
m_newCalculation = false;
m_currentCalculation = calculationCollection()->addCalculation();
this->updateConnectedEditors();
}
else if ( changedField == &m_deleteCalculation )
{
m_deleteCalculation = false;
if ( m_currentCalculation() )
{
calculationCollection()->deleteCalculation( m_currentCalculation() );
m_currentCalculation = nullptr;
this->updateConnectedEditors();
caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( !m_currentCalculation() )
{
if ( calculationCollection()->calculations().size() > 0 )
{
m_currentCalculation = calculationCollection()->calculations()[0];
}
}
{
caf::PdmUiGroup* group =
uiOrdering.addNewGroupWithKeyword( "Calculated Summaries",
RicSummaryCurveCalculatorUi::calculatedSummariesGroupName() );
group->add( &m_currentCalculation );
group->add( &m_newCalculation );
group->add( &m_deleteCalculation );
}
{
caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword( "Calculation Settings",
RicSummaryCurveCalculatorUi::calulationGroupName() );
if ( m_currentCalculation() )
{
m_currentCalculation->uiOrdering( uiConfigName, *group );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RicSummaryCurveCalculatorUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_currentCalculation )
{
for ( auto c : calculationCollection()->calculations() )
{
options.push_back( caf::PdmOptionItemInfo( c->description(), c ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCalculationCollection* RicSummaryCurveCalculatorUi::calculationCollection()
{
RimProject* proj = RimProject::current();
if ( proj )
{
return proj->calculationCollection();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::assignPushButtonEditor( caf::PdmFieldHandle* fieldHandle )
{
CVF_ASSERT( fieldHandle );
CVF_ASSERT( fieldHandle->uiCapability() );
fieldHandle->uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
fieldHandle->uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::assignPushButtonEditorText( caf::PdmUiEditorAttribute* attribute, const QString& text )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_buttonText = text;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryCurveCalculatorUi::calculate() const
{
if ( m_currentCalculation() )
{
QString previousCurveName = m_currentCalculation->description();
if ( !m_currentCalculation()->parseExpression() )
{
return false;
}
QString currentCurveName = m_currentCalculation->description();
if ( previousCurveName != currentCurveName )
{
RiaSummaryTools::notifyCalculatedCurveNameHasChanged( m_currentCalculation()->id(), currentCurveName );
}
if ( !m_currentCalculation()->calculate() )
{
return false;
}
m_currentCalculation()->updateDependentCurvesAndPlots();
caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors();
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( &m_newCalculation == field )
{
RicSummaryCurveCalculatorUi::assignPushButtonEditorText( attribute, "New Calculation" );
}
else if ( &m_deleteCalculation == field )
{
RicSummaryCurveCalculatorUi::assignPushButtonEditorText( attribute, "Delete Calculation" );
}
}
//--------------------------------------------------------------------------------------------------
/// f
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorUi::onEditorWidgetsCreated()
{
if ( m_currentCalculation() != nullptr )
{
m_currentCalculation->attachToWidget();
}
for ( const auto& e : m_currentCalculation.uiCapability()->connectedEditors() )
{
caf::PdmUiListEditor* listEditor = dynamic_cast<caf::PdmUiListEditor*>( e );
if ( !listEditor ) continue;
QWidget* widget = listEditor->editorWidget();
if ( !widget ) continue;
m_calcContextMenuMgr->attachWidget( widget, this );
}
}

View File

@@ -0,0 +1,73 @@
//////////////////////////// /////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RiuCalculationsContextMenuManager.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <memory>
class RimSummaryCalculationCollection;
class RimSummaryCalculation;
//==================================================================================================
///
//==================================================================================================
class RicSummaryCurveCalculatorUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicSummaryCurveCalculatorUi();
static QString calculatedSummariesGroupName();
static QString calulationGroupName();
RimSummaryCalculation* currentCalculation() const;
void setCurrentCalculation( RimSummaryCalculation* calculation );
bool parseExpression() const;
bool calculate() const;
static RimSummaryCalculationCollection* calculationCollection();
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void onEditorWidgetsCreated() override;
private:
// TODO : Move to a common caf helper class
static void assignPushButtonEditor( caf::PdmFieldHandle* fieldHandle );
static void assignPushButtonEditorText( caf::PdmUiEditorAttribute* attribute, const QString& text );
private:
caf::PdmPtrField<RimSummaryCalculation*> m_currentCalculation;
caf::PdmField<bool> m_newCalculation;
caf::PdmField<bool> m_deleteCalculation;
std::unique_ptr<RiuCalculationsContextMenuManager> m_calcContextMenuMgr;
};

View File

@@ -0,0 +1,220 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicSummaryCurveCalculatorWidgetCreator.h"
#include "RicSummaryCurveCalculatorUi.h"
#include "RimSummaryCalculation.h"
#include "cafPdmUiTableView.h"
#include "QMinimizePanel.h"
#include <QBoxLayout>
#include <QHeaderView>
#include <QPushButton>
#include <QSplitter>
#include <QTableView>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorWidgetCreator::RicSummaryCurveCalculatorWidgetCreator()
: m_pdmTableView( nullptr )
{
m_calculator = std::unique_ptr<RicSummaryCurveCalculatorUi>( new RicSummaryCurveCalculatorUi );
this->setPdmObject( m_calculator.get() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorWidgetCreator::~RicSummaryCurveCalculatorWidgetCreator()
{
if ( m_pdmTableView )
{
m_pdmTableView->setChildArrayField( nullptr );
delete m_pdmTableView;
m_pdmTableView = nullptr;
}
this->setPdmObject( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorWidgetCreator::recursivelyConfigureAndUpdateTopLevelUiOrdering(
const caf::PdmUiOrdering& topLevelUiOrdering,
const QString& uiConfigName )
{
if ( !m_firstRowLeftLayout || !m_firstRowRightLayout ) return;
const std::vector<caf::PdmUiItem*>& topLevelUiItems = topLevelUiOrdering.uiItems();
int layoutItemIndex = 0;
for ( size_t i = 0; i < topLevelUiItems.size(); ++i )
{
if ( topLevelUiItems[i]->isUiHidden( uiConfigName ) ) continue;
if ( topLevelUiItems[i]->isUiGroup() )
{
caf::PdmUiGroup* group = static_cast<caf::PdmUiGroup*>( topLevelUiItems[i] );
auto groupBox = updateGroupBoxWithContent( group, uiConfigName );
if ( group->keyword() == RicSummaryCurveCalculatorUi::calculatedSummariesGroupName() )
{
m_firstRowLeftLayout->addWidget( groupBox );
}
else if ( group->keyword() == RicSummaryCurveCalculatorUi::calulationGroupName() )
{
m_firstRowRightLayout->insertWidget( layoutItemIndex++, groupBox );
}
}
}
if ( m_firstRowRightLayout->itemAt( layoutItemIndex ) != m_parseButtonLayout )
{
m_firstRowRightLayout->insertLayout( layoutItemIndex, m_parseButtonLayout );
}
layoutItemIndex++;
if ( m_calculator->currentCalculation() )
{
m_pdmTableView->setChildArrayField( m_calculator->currentCalculation()->variables() );
}
else
m_pdmTableView->setChildArrayField( nullptr );
m_firstRowRightLayout->insertWidget( layoutItemIndex++, m_pdmTableView );
if ( m_firstRowRightLayout->itemAt( layoutItemIndex ) != m_calculateButtonLayout )
{
m_firstRowRightLayout->insertLayout( layoutItemIndex, m_calculateButtonLayout );
}
layoutItemIndex++;
m_pdmTableView->tableView()->resizeColumnsToContents();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RicSummaryCurveCalculatorWidgetCreator::createWidget( QWidget* parent )
{
m_pdmTableView = new caf::PdmUiTableView( parent );
m_pdmTableView->tableView()->setSelectionMode( QAbstractItemView::ExtendedSelection );
m_pdmTableView->enableHeaderText( false );
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
verticalHeader->setSectionResizeMode( QHeaderView::Interactive );
m_pdmTableView->tableView()->resizeColumnsToContents();
QWidget* widget = new QWidget( parent );
QVBoxLayout* mainLayout = new QVBoxLayout();
mainLayout->setContentsMargins( 5, 5, 5, 5 );
widget->setLayout( mainLayout );
QFrame* firstRowFrame = new QFrame( widget );
QHBoxLayout* firstRowLayout = new QHBoxLayout;
firstRowLayout->setContentsMargins( 0, 0, 0, 0 );
firstRowFrame->setLayout( firstRowLayout );
QFrame* firstRowLeftFrame = new QFrame( widget );
m_firstRowLeftLayout = new QHBoxLayout;
m_firstRowLeftLayout->setContentsMargins( 0, 0, 0, 0 );
firstRowLeftFrame->setLayout( m_firstRowLeftLayout );
QFrame* firstRowRightFrame = new QFrame( widget );
m_firstRowRightLayout = new QVBoxLayout;
m_firstRowRightLayout->setContentsMargins( 0, 0, 0, 0 );
firstRowRightFrame->setLayout( m_firstRowRightLayout );
QSplitter* rowSplitter = new QSplitter( Qt::Horizontal );
rowSplitter->setContentsMargins( 0, 0, 0, 0 );
rowSplitter->setHandleWidth( 6 );
rowSplitter->setStyleSheet( "QSplitter::handle { image: url(:/SplitterV.png); }" );
rowSplitter->insertWidget( 0, firstRowLeftFrame );
rowSplitter->insertWidget( 1, firstRowRightFrame );
rowSplitter->setSizes( QList<int>() << 1 << 1 );
firstRowLayout->addWidget( rowSplitter );
mainLayout->addWidget( rowSplitter );
{
QPushButton* pushButton = new QPushButton( "Parse Expression" );
connect( pushButton, SIGNAL( clicked() ), this, SLOT( slotParseExpression() ) );
m_parseButtonLayout = new QHBoxLayout;
m_parseButtonLayout->addStretch( 10 );
m_parseButtonLayout->addWidget( pushButton );
}
{
QPushButton* pushButton = new QPushButton( "Calculate" );
connect( pushButton, SIGNAL( clicked() ), this, SLOT( slotCalculate() ) );
m_calculateButtonLayout = new QHBoxLayout;
m_calculateButtonLayout->addStretch( 10 );
m_calculateButtonLayout->addWidget( pushButton );
}
return widget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMinimizePanel* RicSummaryCurveCalculatorWidgetCreator::updateGroupBoxWithContent( caf::PdmUiGroup* group,
const QString& uiConfigName )
{
QMinimizePanel* groupBox = findOrCreateGroupBox( this->widget(), group, uiConfigName );
recursivelyConfigureAndUpdateUiOrderingInGridLayout( *group, groupBox->contentFrame(), uiConfigName );
return groupBox;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorUi* RicSummaryCurveCalculatorWidgetCreator::calculator() const
{
return m_calculator.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorWidgetCreator::slotCalculate()
{
m_calculator->calculate();
m_calculator->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCalculatorWidgetCreator::slotParseExpression()
{
m_calculator->parseExpression();
m_calculator->updateConnectedEditors();
}

View File

@@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "cafPdmUiFormLayoutObjectEditor.h"
#include <memory>
#include <vector>
class RicSummaryCurveCalculatorUi;
class QMinimizePanel;
class QString;
class QVBoxLayout;
class QHBoxLayout;
class QPushButton;
namespace caf
{
class PdmUiItem;
class PdmUiTableView;
} // namespace caf
//==================================================================================================
///
///
//==================================================================================================
class RicSummaryCurveCalculatorWidgetCreator : public caf::PdmUiFormLayoutObjectEditor
{
Q_OBJECT
public:
RicSummaryCurveCalculatorWidgetCreator();
~RicSummaryCurveCalculatorWidgetCreator() override;
RicSummaryCurveCalculatorUi* calculator() const;
private:
void recursivelyConfigureAndUpdateTopLevelUiOrdering( const caf::PdmUiOrdering& topLevelUiItems,
const QString& uiConfigName ) override;
QWidget* createWidget( QWidget* parent ) override;
QMinimizePanel* updateGroupBoxWithContent( caf::PdmUiGroup* group, const QString& uiConfigName );
private slots:
void slotCalculate();
void slotParseExpression();
private:
QPointer<QHBoxLayout> m_firstRowLeftLayout;
QPointer<QVBoxLayout> m_firstRowRightLayout;
QPointer<QHBoxLayout> m_parseButtonLayout;
QPointer<QHBoxLayout> m_calculateButtonLayout;
caf::PdmUiTableView* m_pdmTableView;
std::unique_ptr<RicSummaryCurveCalculatorUi> m_calculator;
};

View File

@@ -0,0 +1,144 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicSummaryCurveSwitchAxisFeature.h"
#include "RimAsciiDataCurve.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicSummaryCurveSwitchAxisFeature, "RicSummaryCurveSwitchAxisFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryCurveSwitchAxisFeature::isCommandEnabled()
{
std::vector<RimSummaryCurve*> summaryCurves;
std::vector<RimAsciiDataCurve*> asciiDataCurves;
std::vector<RimGridTimeHistoryCurve*> gridTimeHistoryCurves;
RicSummaryCurveSwitchAxisFeature::extractSelectedCurves( &summaryCurves, &asciiDataCurves, &gridTimeHistoryCurves );
return summaryCurves.size() || asciiDataCurves.size() || gridTimeHistoryCurves.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveSwitchAxisFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryCurve*> summaryCurves;
std::vector<RimAsciiDataCurve*> asciiDataCurves;
std::vector<RimGridTimeHistoryCurve*> gridTimeHistoryCurves;
RicSummaryCurveSwitchAxisFeature::extractSelectedCurves( &summaryCurves, &asciiDataCurves, &gridTimeHistoryCurves );
for ( RimSummaryCurve* summaryCurve : summaryCurves )
{
RiaDefines::PlotAxis plotAxis = summaryCurve->axisY();
if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
summaryCurve->setLeftOrRightAxisY( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
}
else
{
summaryCurve->setLeftOrRightAxisY( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
summaryCurve->updateQwtPlotAxis();
summaryCurve->updateConnectedEditors();
RimSummaryPlot* plot = nullptr;
summaryCurve->firstAncestorOrThisOfType( plot );
if ( plot ) plot->updateAxes();
}
for ( RimAsciiDataCurve* asciiCurve : asciiDataCurves )
{
RiaDefines::PlotAxis plotAxis = asciiCurve->yAxis();
if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
asciiCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
}
else
{
asciiCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
asciiCurve->updateQwtPlotAxis();
asciiCurve->updateConnectedEditors();
RimSummaryPlot* plot = nullptr;
asciiCurve->firstAncestorOrThisOfType( plot );
if ( plot ) plot->updateAxes();
}
for ( RimGridTimeHistoryCurve* timeHistoryCurve : gridTimeHistoryCurves )
{
RiaDefines::PlotAxis plotAxis = timeHistoryCurve->yAxis();
if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT )
{
timeHistoryCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
}
else
{
timeHistoryCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
}
timeHistoryCurve->updateConnectedEditors();
RimSummaryPlot* plot = nullptr;
timeHistoryCurve->firstAncestorOrThisOfType( plot );
if ( plot ) plot->updateAxes();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveSwitchAxisFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Switch Plot Axis" );
}
//--------------------------------------------------------------------------------------------------
/// Solo curves means selected curves that does not have a selected curve filter as parent
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveSwitchAxisFeature::extractSelectedCurves( std::vector<RimSummaryCurve*>* summaryCurves,
std::vector<RimAsciiDataCurve*>* asciiDataCurves,
std::vector<RimGridTimeHistoryCurve*>* gridTimeHistoryCurves )
{
summaryCurves->clear();
asciiDataCurves->clear();
gridTimeHistoryCurves->clear();
*summaryCurves = caf::selectedObjectsByType<RimSummaryCurve*>();
*asciiDataCurves = caf::selectedObjectsByType<RimAsciiDataCurve*>();
*gridTimeHistoryCurves = caf::selectedObjectsByType<RimGridTimeHistoryCurve*>();
}

View File

@@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include <set>
class RimAsciiDataCurve;
class RimSummaryCurve;
class RimSummaryCurveFilter;
class RimGridTimeHistoryCurve;
//==================================================================================================
///
//==================================================================================================
class RicSummaryCurveSwitchAxisFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static void extractSelectedCurves( std::vector<RimSummaryCurve*>* summaryCurves,
std::vector<RimAsciiDataCurve*>* asciiDataCurves,
std::vector<RimGridTimeHistoryCurve*>* gridTimeHistoryCurves );
};

View File

@@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicSummaryPlotEditorDialog.h"
#include "RiaGuiApplication.h"
#include "RicSummaryPlotEditorUi.h"
#include "RicSummaryPlotEditorWidgetCreator.h"
#include "RifReaderEclipseSummary.h"
#include "RiuPlotMainWindow.h"
#include "RiuTools.h"
#include <QVBoxLayout>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorDialog::RicSummaryPlotEditorDialog( QWidget* parent )
: QDialog( parent, RiuTools::defaultDialogFlags() )
{
m_curveCreatorSplitterUi = new RicSummaryPlotEditorWidgetCreator( this );
QWidget* propertyWidget = m_curveCreatorSplitterUi->getOrCreateWidget( this );
QVBoxLayout* dummy = new QVBoxLayout( this );
dummy->setContentsMargins( 0, 0, 0, 0 );
dummy->addWidget( propertyWidget );
setWindowTitle( "Plot Editor" );
resize( 1200, 800 );
connect( m_curveCreatorSplitterUi, SIGNAL( signalCloseButtonPressed() ), this, SLOT( accept() ) );
connect( this, SIGNAL( finished( int ) ), this, SLOT( slotDialogFinished() ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorDialog::~RicSummaryPlotEditorDialog()
{
m_curveCreatorSplitterUi->setPdmObject( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorDialog::updateFromSummaryPlot( RimSummaryPlot* summaryPlot )
{
m_curveCreatorSplitterUi->updateFromSummaryPlot( summaryPlot );
m_curveCreatorSplitterUi->updateUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorDialog::updateFromDefaultCases( const std::vector<caf::PdmObject*> defaultSources )
{
m_curveCreatorSplitterUi->updateFromDefaultSources( defaultSources );
m_curveCreatorSplitterUi->updateUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorDialog::slotDialogFinished()
{
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( plotwindow )
{
plotwindow->cleanUpTemporaryWidgets();
}
}

View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 <QDialog>
namespace caf
{
class PdmObject;
};
class RicSummaryPlotEditorWidgetCreator;
class RimSummaryPlot;
class RimSummaryCase;
//==================================================================================================
///
///
//==================================================================================================
class RicSummaryPlotEditorDialog : public QDialog
{
Q_OBJECT
public:
RicSummaryPlotEditorDialog( QWidget* parent );
~RicSummaryPlotEditorDialog() override;
void updateFromSummaryPlot( RimSummaryPlot* summaryPlot );
void updateFromDefaultCases( const std::vector<caf::PdmObject*> defaultSources );
private slots:
void slotDialogFinished();
private:
RicSummaryPlotEditorWidgetCreator* m_curveCreatorSplitterUi;
};

View File

@@ -0,0 +1,996 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicSummaryPlotEditorUi.h"
#include "RiaColorTables.h"
#include "RiaCurveSetDefinition.h"
#include "RiaGuiApplication.h"
#include "RiaSummaryCurveDefinition.h"
#include "RicSelectSummaryPlotUI.h"
#include "RiuSummaryCurveDefinitionKeywords.h"
#include "RifReaderEclipseSummary.h"
#include "RimDerivedEnsembleCaseCollection.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimEnsembleCurveSetColorManager.h"
#include "RimMainPlotCollection.h"
#include "RimObservedDataCollection.h"
#include "RimObservedSummaryData.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveAutoName.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuSummaryVectorSelectionUi.h"
#include "RiuTools.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include <QInputDialog>
#include <QMessageBox>
#include <algorithm>
#include <sstream>
CAF_PDM_SOURCE_INIT( RicSummaryPlotEditorUi, "RicSummaryCurveCreator" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const size_t ENSEMBLE_CURVE_COUNT_THRESHOLD = 600;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString RicSummaryPlotEditorUi::CONFIGURATION_NAME = "CurveCreatorCfg";
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
int ensembleCurveCount( const std::set<RiaSummaryCurveDefinition>& allCurveDefs );
template <typename T>
std::vector<T> toVector( const std::set<T>& set );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorUi::RicSummaryPlotEditorUi()
{
CAF_PDM_InitFieldNoDefault( &m_targetPlot, "TargetPlot", "Target Plot", "", "", "" );
CAF_PDM_InitField( &m_useAutoAppearanceAssignment, "UseAutoAppearanceAssignment", true, "Auto", "", "", "" );
CAF_PDM_InitField( &m_appearanceApplyButton, "AppearanceApplyButton", false, "", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_caseAppearanceType, "CaseAppearanceType", "Case", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_variableAppearanceType, "VariableAppearanceType", "Vector", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellAppearanceType, "WellAppearanceType", "Well", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_groupAppearanceType, "GroupAppearanceType", "Group", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region", "", "", "" );
m_previewPlot.reset( new RimSummaryPlot() );
CAF_PDM_InitFieldNoDefault( &m_useAutoPlotTitleProxy, "UseAutoPlotTitle", "Auto Plot Title", "", "", "" );
m_useAutoPlotTitleProxy.registerGetMethod( this, &RicSummaryPlotEditorUi::proxyPlotAutoTitle );
m_useAutoPlotTitleProxy.registerSetMethod( this, &RicSummaryPlotEditorUi::proxyEnablePlotAutoTitle );
CAF_PDM_InitFieldNoDefault( &m_applyButtonField, "ApplySelection", "", "", "", "" );
m_applyButtonField = false;
m_applyButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_applyButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_closeButtonField, "Close", "", "", "", "" );
m_closeButtonField = false;
m_closeButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_closeButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_okButtonField, "OK", "", "", "", "" );
m_okButtonField = false;
m_okButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_okButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_appearanceApplyButton = false;
m_appearanceApplyButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_appearanceApplyButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LEFT );
CAF_PDM_InitFieldNoDefault( &m_curveNameConfig, "SummaryCurveNameConfig", "SummaryCurveNameConfig", "", "", "" );
m_curveNameConfig = new RimSummaryCurveAutoName();
m_curveNameConfig.uiCapability()->setUiHidden( true );
m_curveNameConfig.uiCapability()->setUiTreeChildrenHidden( true );
m_summaryCurveSelectionEditor.reset( new RiuSummaryVectorSelectionWidgetCreator() );
m_summaryCurveSelectionEditor->summaryAddressSelection()->setFieldChangedHandler(
[this]() { this->selectionEditorFieldChanged(); } );
m_summaryCurveSelectionEditor->summaryAddressSelection()->setMultiSelectionMode( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorUi::~RicSummaryPlotEditorUi()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicSummaryPlotEditorUi::previewPlot() const
{
return m_previewPlot.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::updateFromSummaryPlot( RimSummaryPlot* targetPlot,
const std::vector<SummarySource*>& defaultSources )
{
if ( targetPlot == nullptr || m_targetPlot != targetPlot )
{
resetAllFields();
}
m_targetPlot = targetPlot;
m_useAutoAppearanceAssignment = true;
if ( m_targetPlot )
{
populateCurveCreator( *m_targetPlot );
syncPreviewCurvesFromUiSelection();
setInitialCurveVisibility( targetPlot );
m_previewPlot->loadDataAndUpdate();
}
else
{
setDefaultCurveSelection( defaultSources );
m_previewPlot->enableAutoPlotTitle( true );
syncPreviewCurvesFromUiSelection();
}
caf::PdmUiItem::updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RicSummaryPlotEditorUi::addressSelectionWidget( QWidget* parent )
{
return m_summaryCurveSelectionEditor->getOrCreateWidget( parent );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryPlotEditorUi::isCloseButtonPressed() const
{
return m_closeButtonField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::clearCloseButton()
{
m_closeButtonField = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_applyButtonField || changedField == &m_okButtonField )
{
if ( m_targetPlot == nullptr )
{
createNewPlot();
}
updateTargetPlot();
if ( changedField == &m_okButtonField )
{
m_closeButtonField = true;
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem( m_targetPlot );
RiuPlotMainWindowTools::setExpanded( m_targetPlot );
}
m_applyButtonField = false;
m_okButtonField = false;
caf::PdmField<bool>* field =
dynamic_cast<caf::PdmField<bool>*>( m_targetPlot->uiCapability()->objectToggleField() );
field->setValueWithFieldChanged( true );
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateSummaryPlotToolBar();
}
else if ( changedField == &m_useAutoAppearanceAssignment && m_useAutoAppearanceAssignment )
{
updateAppearanceEditor();
}
else if ( changedField == &m_appearanceApplyButton )
{
applyAppearanceToAllPreviewCurves();
m_previewPlot->loadDataAndUpdate();
m_appearanceApplyButton = false;
}
else if ( changedField == &m_useAutoPlotTitleProxy )
{
m_previewPlot->updatePlotTitle();
m_previewPlot->summaryCurveCollection()->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RicSummaryPlotEditorUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_targetPlot )
{
RimProject* proj = RimProject::current();
RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection();
// Create New Plot item
QString displayName = "( New Plot )";
options.push_back( caf::PdmOptionItemInfo( displayName, nullptr ) );
if ( summaryPlotColl )
{
summaryPlotColl->summaryPlotItemInfos( &options );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
// Appearance settings
caf::PdmUiGroup* appearanceGroup =
uiOrdering.addNewGroupWithKeyword( "Curve Appearance Assignment", RiuSummaryCurveDefinitionKeywords::appearance() );
caf::PdmUiGroup* appearanceSubGroup = appearanceGroup->addNewGroup( "Appearance Type Assignment" );
appearanceSubGroup->setCollapsedByDefault( true );
appearanceSubGroup->add( &m_useAutoAppearanceAssignment );
appearanceSubGroup->add( &m_caseAppearanceType );
appearanceSubGroup->add( &m_variableAppearanceType );
appearanceSubGroup->add( &m_wellAppearanceType );
appearanceSubGroup->add( &m_groupAppearanceType );
appearanceSubGroup->add( &m_regionAppearanceType );
appearanceGroup->add( &m_appearanceApplyButton );
// Appearance option sensitivity
{
m_caseAppearanceType.uiCapability()->setUiReadOnly( m_useAutoAppearanceAssignment );
m_variableAppearanceType.uiCapability()->setUiReadOnly( m_useAutoAppearanceAssignment );
m_wellAppearanceType.uiCapability()->setUiReadOnly( m_useAutoAppearanceAssignment );
m_groupAppearanceType.uiCapability()->setUiReadOnly( m_useAutoAppearanceAssignment );
m_regionAppearanceType.uiCapability()->setUiReadOnly( m_useAutoAppearanceAssignment );
}
// Name config
caf::PdmUiGroup* autoNameGroup = uiOrdering.addNewGroupWithKeyword( "Plot and Curve Name Configuration",
RiuSummaryCurveDefinitionKeywords::nameConfig() );
autoNameGroup->setCollapsedByDefault( true );
autoNameGroup->add( &m_useAutoPlotTitleProxy );
m_curveNameConfig->uiOrdering( uiConfigName, *autoNameGroup );
// Fields to be displayed directly in UI
uiOrdering.add( &m_targetPlot );
uiOrdering.add( &m_okButtonField );
uiOrdering.add( &m_applyButtonField );
uiOrdering.add( &m_closeButtonField );
uiOrdering.skipRemainingFields( true );
syncPreviewCurvesFromUiSelection();
m_summaryCurveSelectionEditor->updateUi( uiConfigName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::syncPreviewCurvesFromUiSelection()
{
std::vector<RiaSummaryCurveDefinition> allCurveDefinitionsVector =
m_summaryCurveSelectionEditor->summaryAddressSelection()->allCurveDefinitionsFromSelection();
std::set<RiaSummaryCurveDefinition> allCurveDefinitions =
std::set<RiaSummaryCurveDefinition>( allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end() );
std::vector<RimSummaryCurve*> currentCurvesInPreviewPlot = m_previewPlot->summaryAndEnsembleCurves();
{
std::set<RiaSummaryCurveDefinition> currentCurveDefs;
std::set<RiaSummaryCurveDefinition> newCurveDefs;
std::set<RimSummaryCurve*> curvesToDelete;
for ( const auto& curve : currentCurvesInPreviewPlot )
{
currentCurveDefs.insert( curve->curveDefinitionY() );
}
{
// Determine which curves to delete from plot
std::set<RiaSummaryCurveDefinition> deleteCurveDefs;
std::set_difference( currentCurveDefs.begin(),
currentCurveDefs.end(),
allCurveDefinitions.begin(),
allCurveDefinitions.end(),
std::inserter( deleteCurveDefs, deleteCurveDefs.end() ) );
for ( const auto& curve : currentCurvesInPreviewPlot )
{
RiaSummaryCurveDefinition curveDef = curve->curveDefinitionY();
if ( deleteCurveDefs.count( curveDef ) > 0 ) curvesToDelete.insert( curve );
}
}
{
// Determine which curves are new since last time
std::set_difference( allCurveDefinitions.begin(),
allCurveDefinitions.end(),
currentCurveDefs.begin(),
currentCurveDefs.end(),
std::inserter( newCurveDefs, newCurveDefs.end() ) );
}
// Curve sets to delete
std::set<RimEnsembleCurveSet*> curveSetsToDelete;
{
std::vector<RiaCurveSetDefinition> allCurveSetDefinitionsVector =
m_summaryCurveSelectionEditor->summaryAddressSelection()->allCurveSetDefinitionsFromSelections();
std::set<RiaCurveSetDefinition> allCurveSetDefinitions =
std::set<RiaCurveSetDefinition>( allCurveSetDefinitionsVector.begin(), allCurveSetDefinitionsVector.end() );
std::vector<RimEnsembleCurveSet*> currentCurveSetsInPreviewPlot = m_previewPlot->curveSets();
std::set<RiaCurveSetDefinition> currentCurveSetDefs;
for ( const auto& curveSet : currentCurveSetsInPreviewPlot )
{
RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection();
currentCurveSetDefs.insert( RiaCurveSetDefinition( ensemble, curveSet->summaryAddress() ) );
}
if ( allCurveSetDefinitions.size() < currentCurveSetsInPreviewPlot.size() )
{
// Determine which curves to delete from plot
std::set<RiaCurveSetDefinition> deleteCurveSetDefs;
std::set_difference( currentCurveSetDefs.begin(),
currentCurveSetDefs.end(),
allCurveSetDefinitions.begin(),
allCurveSetDefinitions.end(),
std::inserter( deleteCurveSetDefs, deleteCurveSetDefs.end() ) );
for ( const auto& curveSet : currentCurveSetsInPreviewPlot )
{
RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection();
RiaCurveSetDefinition curveSetDef = RiaCurveSetDefinition( ensemble, curveSet->summaryAddress() );
if ( deleteCurveSetDefs.count( curveSetDef ) > 0 ) curveSetsToDelete.insert( curveSet );
}
}
}
updatePreviewCurvesFromCurveDefinitions( allCurveDefinitions, newCurveDefs, curvesToDelete, curveSetsToDelete );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::updatePreviewCurvesFromCurveDefinitions(
const std::set<RiaSummaryCurveDefinition>& allCurveDefsToDisplay,
const std::set<RiaSummaryCurveDefinition>& curveDefsToAdd,
const std::set<RimSummaryCurve*>& curvesToDelete,
const std::set<RimEnsembleCurveSet*>& curveSetsToDelete )
{
static bool warningDisplayed = false;
std::set<RiaSummaryCurveDefinition> summaryCurveDefsToDisplay;
// Ignore curve sets when assigning colors to singe summary curves
for ( const auto& def : allCurveDefsToDisplay )
{
if ( !def.isEnsembleCurve() ) summaryCurveDefsToDisplay.insert( def );
}
RimSummaryCurveAppearanceCalculator curveLookCalc( summaryCurveDefsToDisplay );
initCurveAppearanceCalculator( curveLookCalc );
// Delete curves
if ( !curveSetsToDelete.empty() )
{
m_previewPlot->ensembleCurveSetCollection()->deleteCurveSets( toVector( curveSetsToDelete ) );
}
if ( !curvesToDelete.empty() )
{
m_previewPlot->deleteCurves( toVector( curvesToDelete ) );
}
size_t ensembleCurveCnt = ensembleCurveCount( allCurveDefsToDisplay );
bool speedCheatsRequired = ensembleCurveCnt > ENSEMBLE_CURVE_COUNT_THRESHOLD;
bool legendsVisible = m_previewPlot->legendsVisible();
// Disable legends when adding curves
if ( speedCheatsRequired ) m_previewPlot->setLegendsVisible( false );
// Add new curves
std::map<RimSummaryCurve*, std::pair<bool, bool>> stashedErrorBarsAndLegendVisibility;
for ( const auto& curveDef : curveDefsToAdd )
{
RimSummaryCase* currentCase = curveDef.summaryCase();
RimSummaryCurve* curve = new RimSummaryCurve();
if ( speedCheatsRequired )
{
stashedErrorBarsAndLegendVisibility[curve] = std::make_pair( curve->errorBarsVisible(), curve->showInLegend() );
curve->setErrorBarsVisible( false );
curve->setShowInLegend( false );
}
curve->setSummaryCaseY( currentCase );
curve->setSummaryAddressYAndApplyInterpolation( curveDef.summaryAddress() );
curve->applyCurveAutoNameSettings( *m_curveNameConfig() );
if ( currentCase->isObservedData() ) curve->setSymbolSkipDistance( 0 );
if ( curveDef.isEnsembleCurve() )
{
// Find curveSet
RimEnsembleCurveSet* curveSet = nullptr;
for ( const auto& cs : m_previewPlot->ensembleCurveSetCollection()->curveSets() )
{
if ( cs->summaryCaseCollection() == curveDef.ensemble() &&
cs->summaryAddress() == curveDef.summaryAddress() )
{
curveSet = cs;
break;
}
}
if ( !curveSet )
{
curveSet = new RimEnsembleCurveSet();
curveSet->disableStatisticCurves();
curveSet->setSummaryCaseCollection( curveDef.ensemble() );
curveSet->setSummaryAddress( curveDef.summaryAddress() );
// Set single curve set color
auto allCurveSets = m_previewPlot->ensembleCurveSetCollection()->curveSets();
size_t colorIndex =
std::count_if( allCurveSets.begin(), allCurveSets.end(), []( RimEnsembleCurveSet* curveSet ) {
return curveSet->colorMode() == RimEnsembleCurveSet::ColorMode::SINGLE_COLOR;
} );
curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) );
// Add curve to plot
m_previewPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
if ( m_previewPlot->ensembleCurveSetCollection()->curveSets().size() > 1 &&
ensembleCurveCnt > ENSEMBLE_CURVE_COUNT_THRESHOLD )
{
// Toggle off new curve set and display warning
curveSet->showCurves( false );
if ( !warningDisplayed )
{
QMessageBox mbox;
mbox.setIcon( QMessageBox::Icon::Warning );
mbox.setInformativeText(
"The new curve set is hidden. Too many visible curve sets may lead to poor performance" );
mbox.exec();
warningDisplayed = true;
}
}
}
curveSet->addCurve( curve );
}
else
{
m_previewPlot->addCurveNoUpdate( curve );
curveLookCalc.setupCurveLook( curve );
}
}
// Enable legends if there is not too many curves
if ( speedCheatsRequired && !warningDisplayed )
{
m_previewPlot->setLegendsVisible( legendsVisible );
for ( const auto& curveAndVisibilityPair : stashedErrorBarsAndLegendVisibility )
{
auto curve = curveAndVisibilityPair.first;
auto errorBarsAndLegendVisibility = curveAndVisibilityPair.second;
curve->setErrorBarsVisible( errorBarsAndLegendVisibility.first );
curve->setShowInLegend( errorBarsAndLegendVisibility.second );
}
}
m_previewPlot->loadDataAndUpdate();
m_previewPlot->zoomAll();
m_previewPlot->updateConnectedEditors();
m_previewPlot->summaryCurveCollection()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( &m_applyButtonField == field )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_buttonText = "Apply";
}
}
else if ( &m_closeButtonField == field )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_buttonText = "Cancel";
}
}
else if ( &m_okButtonField == field )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_buttonText = "OK";
}
}
else if ( &m_appearanceApplyButton == field )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_buttonText = "Apply";
}
}
else if ( &m_targetPlot == field )
{
caf::PdmUiComboBoxEditorAttribute* attrib = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute );
if ( attrib )
{
attrib->adjustWidthToContents = true;
}
}
}
//--------------------------------------------------------------------------------------------------
/// Populate curve creator from the given curve collection
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::populateCurveCreator( const RimSummaryPlot& sourceSummaryPlot )
{
std::vector<RiaSummaryCurveDefinition> curveDefs;
m_previewPlot->deleteAllSummaryCurves();
m_previewPlot->ensembleCurveSetCollection()->deleteAllCurveSets();
for ( const auto& curve : sourceSummaryPlot.summaryCurves() )
{
curveDefs.push_back( curve->curveDefinitionY() );
// Copy curve object to the preview plot
copyCurveAndAddToPlot( curve, m_previewPlot.get(), true );
}
RimEnsembleCurveSetCollection* previewCurveSetColl = m_previewPlot->ensembleCurveSetCollection();
for ( const auto& curveSet : sourceSummaryPlot.ensembleCurveSetCollection()->curveSets() )
{
RimEnsembleCurveSet* newCurveSet = curveSet->clone();
newCurveSet->disableStatisticCurves();
previewCurveSetColl->addCurveSet( newCurveSet );
RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection();
for ( const auto& curve : curveSet->curves() )
{
curveDefs.push_back( curve->curveDefinitionY() );
}
}
m_previewPlot->copyAxisPropertiesFromOther( sourceSummaryPlot );
m_previewPlot->enableAutoPlotTitle( sourceSummaryPlot.autoPlotTitle() );
m_previewPlot->updatePlotTitle();
m_previewPlot->updateAxes();
m_summaryCurveSelectionEditor->summaryAddressSelection()->setSelectedCurveDefinitions( curveDefs );
updateAppearanceEditor();
}
//--------------------------------------------------------------------------------------------------
/// Copy curves from preview plot to target plot
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::updateTargetPlot()
{
if ( !m_targetPlot ) return;
m_targetPlot->deleteAllSummaryCurves();
m_targetPlot->ensembleCurveSetCollection()->deleteAllCurveSets();
// Add edited curves to target plot
for ( const auto& editedCurve : m_previewPlot->summaryCurves() )
{
if ( !editedCurve->isCurveVisible() )
{
continue;
}
copyCurveAndAddToPlot( editedCurve, m_targetPlot );
}
for ( const auto& editedCurveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets() )
{
if ( !editedCurveSet->isCurvesVisible() )
{
continue;
}
RimEnsembleCurveSet* newCurveSet = editedCurveSet->clone();
m_targetPlot->ensembleCurveSetCollection()->addCurveSet( newCurveSet );
for ( const auto& editedCurve : newCurveSet->curves() )
{
copyEnsembleCurveAndAddToCurveSet( editedCurve, editedCurveSet );
}
newCurveSet->setParentQwtPlotNoReplot( m_targetPlot->viewer() );
}
m_targetPlot->enableAutoPlotTitle( m_useAutoPlotTitleProxy() );
m_targetPlot->loadDataAndUpdate();
m_targetPlot->updatePlotTitle();
m_targetPlot->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::copyCurveAndAddToPlot( const RimSummaryCurve* curve, RimSummaryPlot* plot, bool forceVisible )
{
RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(
curve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( curveCopy );
if ( forceVisible )
{
curveCopy->setCurveVisibility( true );
}
plot->addCurveNoUpdate( curveCopy );
// The curve creator is not a descendant of the project, and need to be set manually
curveCopy->setSummaryCaseY( curve->summaryCaseY() );
curveCopy->initAfterReadRecursively();
curveCopy->loadDataAndUpdate( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::copyEnsembleCurveAndAddToCurveSet( const RimSummaryCurve* curve,
RimEnsembleCurveSet* curveSet,
bool forceVisible )
{
RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(
curve->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( curveCopy );
if ( forceVisible )
{
curveCopy->setCurveVisibility( true );
}
curveSet->addCurve( curveCopy );
// The curve creator is not a descendant of the project, and need to be set manually
curveCopy->setSummaryCaseY( curve->summaryCaseY() );
curveCopy->initAfterReadRecursively();
curveCopy->loadDataAndUpdate( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::setDefaultCurveSelection( const std::vector<SummarySource*>& defaultSources )
{
m_summaryCurveSelectionEditor->summaryAddressSelection()->setDefaultSelection( defaultSources );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::resetAllFields()
{
std::vector<RiaSummaryCurveDefinition> curveDefinitions;
m_summaryCurveSelectionEditor->summaryAddressSelection()->setSelectedCurveDefinitions( curveDefinitions );
m_previewPlot->deleteAllSummaryCurves();
m_targetPlot = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::initCurveAppearanceCalculator( RimSummaryCurveAppearanceCalculator& curveAppearanceCalc )
{
if ( !m_useAutoAppearanceAssignment() )
{
curveAppearanceCalc.assignDimensions( m_caseAppearanceType(),
m_variableAppearanceType(),
m_wellAppearanceType(),
m_groupAppearanceType(),
m_regionAppearanceType() );
}
else
{
RimSummaryCurveAppearanceCalculator::CurveAppearanceType caseAppearance;
RimSummaryCurveAppearanceCalculator::CurveAppearanceType variAppearance;
RimSummaryCurveAppearanceCalculator::CurveAppearanceType wellAppearance;
RimSummaryCurveAppearanceCalculator::CurveAppearanceType gropAppearance;
RimSummaryCurveAppearanceCalculator::CurveAppearanceType regiAppearance;
curveAppearanceCalc.getDimensions( &caseAppearance, &variAppearance, &wellAppearance, &gropAppearance, &regiAppearance );
m_caseAppearanceType = caseAppearance;
m_variableAppearanceType = variAppearance;
m_wellAppearanceType = wellAppearance;
m_groupAppearanceType = gropAppearance;
m_regionAppearanceType = regiAppearance;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::applyAppearanceToAllPreviewCurves()
{
std::set<RiaSummaryCurveDefinition> allCurveDefs = m_previewPlot->summaryAndEnsembleCurveDefinitions();
RimSummaryCurveAppearanceCalculator curveLookCalc( allCurveDefs );
initCurveAppearanceCalculator( curveLookCalc );
// Summary curves
for ( auto& curve : m_previewPlot->summaryCurves() )
{
curve->resetAppearance();
curveLookCalc.setupCurveLook( curve );
}
// Ensemble curve sets
int colorIndex = 0;
for ( auto& curveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets() )
{
if ( curveSet->colorMode() != RimEnsembleCurveSet::ColorMode::SINGLE_COLOR ) continue;
curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex++ ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::updateAppearanceEditor()
{
std::set<RiaSummaryCurveDefinition> allCurveDefs = m_previewPlot->summaryAndEnsembleCurveDefinitions();
RimSummaryCurveAppearanceCalculator curveLookCalc( allCurveDefs );
initCurveAppearanceCalculator( curveLookCalc );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::createNewPlot()
{
RimProject* proj = RimProject::current();
RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection();
if ( summaryPlotColl )
{
RimSummaryPlot* newSummaryPlot = nullptr;
if ( m_useAutoPlotTitleProxy() )
{
newSummaryPlot = summaryPlotColl->createSummaryPlotWithAutoTitle();
}
else
{
QString candidatePlotName;
if ( m_previewPlot )
{
candidatePlotName = m_previewPlot->generatedPlotTitleFromAllCurves();
}
{
bool ok = false;
candidatePlotName = QInputDialog::getText( nullptr,
"New Summary Plot Name",
"New Summary Plot Name",
QLineEdit::Normal,
candidatePlotName,
&ok,
RiuTools::defaultDialogFlags() );
if ( !ok )
{
return;
}
newSummaryPlot = summaryPlotColl->createNamedSummaryPlot( candidatePlotName );
}
}
if ( newSummaryPlot )
{
newSummaryPlot->loadDataAndUpdate();
summaryPlotColl->updateConnectedEditors();
m_targetPlot = newSummaryPlot;
updateTargetPlot();
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateSummaryPlotToolBar();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::updateCurveNames()
{
for ( RimSummaryCurve* curve : m_previewPlot->summaryCurves() )
{
curve->applyCurveAutoNameSettings( *m_curveNameConfig() );
curve->updateCurveNameNoLegendUpdate();
}
if ( m_previewPlot && m_previewPlot->viewer() ) m_previewPlot->viewer()->updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryPlotEditorUi::isObservedData( RimSummaryCase* sumCase ) const
{
return dynamic_cast<RimObservedSummaryData*>( sumCase ) != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RicSummaryPlotEditorUi::calculatedSummaryCase()
{
RimSummaryCalculationCollection* calcColl = RimProject::current()->calculationCollection();
return calcColl->calculationSummaryCase();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::selectionEditorFieldChanged()
{
syncPreviewCurvesFromUiSelection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::proxyEnablePlotAutoTitle( const bool& enable )
{
m_previewPlot->enableAutoPlotTitle( enable );
m_previewPlot->setPlotTitleVisible( enable );
m_previewPlot->updateCurveNames();
m_previewPlot->loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryPlotEditorUi::proxyPlotAutoTitle() const
{
return m_previewPlot->autoPlotTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorUi::setInitialCurveVisibility( const RimSummaryPlot* targetPlot )
{
// Set visibility for imported curves which were not checked in source plot
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress>> sourceCurveDefs;
for ( const auto& curve : targetPlot->summaryCurves() )
{
sourceCurveDefs.insert( std::make_pair( curve->summaryCaseY(), curve->summaryAddressY() ) );
}
for ( const auto& curve : m_previewPlot->summaryCurves() )
{
auto curveDef = std::make_pair( curve->summaryCaseY(), curve->summaryAddressY() );
if ( sourceCurveDefs.count( curveDef ) == 0 )
{
curve->setCurveVisibility( false );
}
}
std::set<std::pair<RimSummaryCaseCollection*, RifEclipseSummaryAddress>> sourceCurveSetDefs;
for ( const auto& curveSet : targetPlot->ensembleCurveSetCollection()->curveSets() )
{
sourceCurveSetDefs.insert( std::make_pair( curveSet->summaryCaseCollection(), curveSet->summaryAddress() ) );
}
for ( const auto& curveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets() )
{
auto curveDef = std::make_pair( curveSet->summaryCaseCollection(), curveSet->summaryAddress() );
if ( sourceCurveSetDefs.count( curveDef ) == 0 )
{
curveSet->showCurves( false );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int ensembleCurveCount( const std::set<RiaSummaryCurveDefinition>& allCurveDefs )
{
return std::count_if( allCurveDefs.begin(), allCurveDefs.end(), []( const RiaSummaryCurveDefinition& def ) {
return def.isEnsembleCurve();
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
std::vector<T> toVector( const std::set<T>& set )
{
return std::vector<T>( set.begin(), set.end() );
}

View File

@@ -0,0 +1,136 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifEclipseSummaryAddress.h"
#include "RimSummaryCurveAppearanceCalculator.h"
#include "RiuSummaryVectorSelectionWidgetCreator.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmProxyValueField.h"
#include "cafPdmPtrArrayField.h"
#include "cafPdmPtrField.h"
#include <memory>
#define OBSERVED_DATA_AVALUE_POSTFIX "_OBSDATA"
namespace caf
{
class PdmObject;
};
class RimSummaryCase;
class RimSummaryCurveAutoName;
class RimSummaryPlot;
class RiaSummaryCurveDefinition;
class RimEnsembleCurveSet;
//==================================================================================================
///
///
//==================================================================================================
class RicSummaryPlotEditorUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
static const QString CONFIGURATION_NAME;
private:
typedef caf::AppEnum<RimSummaryCurveAppearanceCalculator::CurveAppearanceType> AppearanceTypeAppEnum;
public:
RicSummaryPlotEditorUi();
~RicSummaryPlotEditorUi() override;
RimSummaryPlot* previewPlot() const;
void updateFromSummaryPlot( RimSummaryPlot* targetPlot,
const std::vector<caf::PdmObject*>& defaultSources = std::vector<caf::PdmObject*>() );
QWidget* addressSelectionWidget( QWidget* parent );
bool isCloseButtonPressed() const;
void clearCloseButton();
void updateCurveNames();
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void syncPreviewCurvesFromUiSelection();
void updatePreviewCurvesFromCurveDefinitions( const std::set<RiaSummaryCurveDefinition>& allCurveDefsToDisplay,
const std::set<RiaSummaryCurveDefinition>& curveDefsToAdd,
const std::set<RimSummaryCurve*>& curvesToDelete,
const std::set<RimEnsembleCurveSet*>& curveSetsToDelete );
void populateCurveCreator( const RimSummaryPlot& sourceSummaryPlot );
void updateTargetPlot();
static void copyCurveAndAddToPlot( const RimSummaryCurve* curve, RimSummaryPlot* plot, bool forceVisible = false );
static void copyEnsembleCurveAndAddToCurveSet( const RimSummaryCurve* curve,
RimEnsembleCurveSet* curveSet,
bool forceVisible = false );
void setDefaultCurveSelection( const std::vector<caf::PdmObject*>& defaultCases );
void resetAllFields();
void initCurveAppearanceCalculator( RimSummaryCurveAppearanceCalculator& curveAppearanceCalc );
void applyAppearanceToAllPreviewCurves();
void updateAppearanceEditor();
void createNewPlot();
bool isObservedData( RimSummaryCase* sumCase ) const;
static RimSummaryCase* calculatedSummaryCase();
void selectionEditorFieldChanged();
void proxyEnablePlotAutoTitle( const bool& enable );
bool proxyPlotAutoTitle() const;
void setInitialCurveVisibility( const RimSummaryPlot* targetPlot );
private:
caf::PdmPtrField<RimSummaryPlot*> m_targetPlot;
std::unique_ptr<RimSummaryPlot> m_previewPlot;
caf::PdmProxyValueField<bool> m_useAutoPlotTitleProxy;
caf::PdmField<bool> m_useAutoAppearanceAssignment;
caf::PdmField<bool> m_appearanceApplyButton;
caf::PdmField<AppearanceTypeAppEnum> m_caseAppearanceType;
caf::PdmField<AppearanceTypeAppEnum> m_variableAppearanceType;
caf::PdmField<AppearanceTypeAppEnum> m_wellAppearanceType;
caf::PdmField<AppearanceTypeAppEnum> m_groupAppearanceType;
caf::PdmField<AppearanceTypeAppEnum> m_regionAppearanceType;
caf::PdmChildField<RimSummaryCurveAutoName*> m_curveNameConfig;
caf::PdmField<bool> m_okButtonField;
caf::PdmField<bool> m_applyButtonField;
caf::PdmField<bool> m_closeButtonField;
std::unique_ptr<RiuSummaryVectorSelectionWidgetCreator> m_summaryCurveSelectionEditor;
};

View File

@@ -0,0 +1,329 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicSummaryPlotEditorWidgetCreator.h"
#include "RicSummaryPlotEditorUi.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuSummaryCurveDefinitionKeywords.h"
#include "RiuSummaryVectorSelectionUi.h"
#include "RiuSummaryVectorSelectionWidgetCreator.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldHandle.h"
#include "cafPdmUiGroup.h"
#include "cafPdmUiTreeView.h"
#include "QMinimizePanel.h"
#include <QBoxLayout>
#include <QFrame>
#include <QSplitter>
#include <QTreeView>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorWidgetCreator::RicSummaryPlotEditorWidgetCreator( QWidget* parent )
{
m_parentWidget = parent;
m_summaryCurveCreator.reset( new RicSummaryPlotEditorUi() );
this->setPdmObject( m_summaryCurveCreator.get() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryPlotEditorWidgetCreator::~RicSummaryPlotEditorWidgetCreator()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorWidgetCreator::updateFromSummaryPlot( RimSummaryPlot* summaryPlot )
{
m_summaryCurveCreator->updateFromSummaryPlot( summaryPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorWidgetCreator::updateFromDefaultSources( const std::vector<caf::PdmObject*> defaultSources )
{
m_summaryCurveCreator->updateFromSummaryPlot( nullptr, defaultSources );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorWidgetCreator::recursivelyConfigureAndUpdateTopLevelUiOrdering( const caf::PdmUiOrdering& topLevelUiOrdering,
const QString& uiConfigName )
{
const std::vector<caf::PdmUiItem*>& topLevelUiItems = topLevelUiOrdering.uiItems();
if ( m_summaryCurveCreator->isCloseButtonPressed() )
{
m_summaryCurveCreator->clearCloseButton();
emit signalCloseButtonPressed();
}
if ( !m_layout ) return;
QWidget* addrWidget = m_summaryCurveCreator->addressSelectionWidget( m_parentWidget );
m_firstRowLayout->addWidget( addrWidget );
caf::PdmUiGroup* appearanceGroup =
findGroupByKeyword( topLevelUiItems, RiuSummaryCurveDefinitionKeywords::appearance(), uiConfigName );
auto appearanceGroupBox = createGroupBoxWithContent( appearanceGroup, uiConfigName );
m_lowerLeftLayout->insertWidget( 0, appearanceGroupBox );
caf::PdmUiGroup* nameConfigGroup =
findGroupByKeyword( topLevelUiItems, RiuSummaryCurveDefinitionKeywords::nameConfig(), uiConfigName );
auto nameConfigGroupBox = createGroupBoxWithContent( nameConfigGroup, uiConfigName );
m_lowerLeftLayout->insertWidget( 1, nameConfigGroupBox );
QMinimizePanel* curveGroup = getOrCreateCurveTreeGroup();
m_lowerLeftLayout->insertWidget( 2, curveGroup, 1 );
m_lowerLeftLayout->addStretch( 0 );
m_lowerRightLayout->insertWidget( 1, getOrCreatePlotWidget() );
// Fields at bottom of dialog
configureAndUpdateFields( 1, m_bottomFieldLayout, topLevelUiItems, uiConfigName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RicSummaryPlotEditorWidgetCreator::createWidget( QWidget* parent )
{
QWidget* widget = new QWidget( parent );
m_layout = new QVBoxLayout();
m_layout->setContentsMargins( 5, 5, 5, 5 );
widget->setLayout( m_layout );
QFrame* firstRowFrame = new QFrame( widget );
m_firstRowLayout = new QHBoxLayout;
m_firstRowLayout->setContentsMargins( 0, 0, 0, 0 );
firstRowFrame->setLayout( m_firstRowLayout );
QFrame* secondRowFrame = new QFrame( widget );
m_secondRowLayout = new QHBoxLayout;
m_secondRowLayout->setContentsMargins( 0, 4, 0, 0 );
secondRowFrame->setLayout( m_secondRowLayout );
m_lowerLeftLayout = new QVBoxLayout;
m_lowerLeftLayout->setContentsMargins( 0, 0, 0, 0 );
m_secondRowLayout->addLayout( m_lowerLeftLayout );
m_lowerRightLayout = new QVBoxLayout;
m_lowerRightLayout->setContentsMargins( 0, 0, 0, 0 );
m_secondRowLayout->addLayout( m_lowerRightLayout );
{
auto label = new QLabel( "Plot Preview" );
label->setAlignment( Qt::AlignCenter );
auto font = label->font();
font.setPixelSize( 20 );
label->setFont( font );
m_lowerRightLayout->insertWidget( 0, label );
}
m_firstColumnSplitter = new QSplitter( Qt::Vertical );
m_firstColumnSplitter->setContentsMargins( 0, 0, 0, 0 );
m_firstColumnSplitter->setHandleWidth( 6 );
m_firstColumnSplitter->setStyleSheet( "QSplitter::handle { image: url(:/SplitterH.png); }" );
m_firstColumnSplitter->insertWidget( 0, firstRowFrame );
m_firstColumnSplitter->insertWidget( 1, secondRowFrame );
const int firstRowPixelHeight = 500;
const int secondRowPixelHeight = 300;
m_firstColumnSplitter->setSizes( QList<int>() << firstRowPixelHeight << secondRowPixelHeight );
m_layout->addWidget( m_firstColumnSplitter );
m_bottomFieldLayout = new QHBoxLayout;
m_bottomFieldLayout->setContentsMargins( 0, 2, 0, 0 );
m_layout->addLayout( m_bottomFieldLayout );
m_bottomFieldLayout->insertStretch( 0, 1 );
return widget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmUiGroup* RicSummaryPlotEditorWidgetCreator::findGroupByKeyword( const std::vector<caf::PdmUiItem*>& topLevelUiItems,
const QString& keyword,
const QString& uiConfigName )
{
for ( auto uiItem : topLevelUiItems )
{
if ( uiItem->isUiHidden( uiConfigName ) ) continue;
if ( uiItem->isUiGroup() )
{
caf::PdmUiGroup* group = static_cast<caf::PdmUiGroup*>( uiItem );
if ( group->keyword() == keyword )
{
return group;
}
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMinimizePanel* RicSummaryPlotEditorWidgetCreator::getOrCreateCurveTreeGroup()
{
if ( !m_curvesPanel )
{
m_curvesPanel = new QMinimizePanel( this->widget() );
m_curvesPanel->setTitle( "Curves" );
QVBoxLayout* curvesLayout = new QVBoxLayout( m_curvesPanel->contentFrame() );
m_curveTreeView = new caf::PdmUiTreeView( m_curvesPanel->contentFrame() );
curvesLayout->setStretchFactor( m_curveTreeView, 1 );
curvesLayout->addWidget( m_curveTreeView );
m_curveTreeView->treeView()->setHeaderHidden( true );
}
if ( m_summaryCurveCreator )
{
RimSummaryPlot* previewPlot = m_summaryCurveCreator->previewPlot();
m_curveTreeView->setPdmItem( previewPlot );
m_curveTreeView->setUiConfigurationName( RicSummaryPlotEditorUi::CONFIGURATION_NAME );
m_curveTreeView->setExpanded( previewPlot->summaryCurveCollection(), true );
m_curveTreeView->setExpanded( previewPlot->ensembleCurveSetCollection(), true );
}
return m_curvesPanel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RicSummaryPlotEditorWidgetCreator::getOrCreatePlotWidget()
{
if ( m_summaryCurveCreator )
{
auto widget = m_summaryCurveCreator->previewPlot()->createPlotWidget( this->widget() );
widget->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
return widget;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotEditorWidgetCreator::configureAndUpdateFields( int widgetStartIndex,
QBoxLayout* layout,
const std::vector<caf::PdmUiItem*>& uiItems,
const QString& uiConfigName )
{
int currentWidgetIndex = widgetStartIndex;
for ( size_t i = 0; i < uiItems.size(); ++i )
{
if ( uiItems[i]->isUiHidden( uiConfigName ) ) continue;
if ( uiItems[i]->isUiGroup() ) continue;
{
caf::PdmUiFieldHandle* field = dynamic_cast<caf::PdmUiFieldHandle*>( uiItems[i] );
caf::PdmUiFieldEditorHandle* fieldEditor = findOrCreateFieldEditor( this->widget(), field, uiConfigName );
if ( fieldEditor )
{
// Place the widget(s) into the correct parent and layout
QWidget* fieldCombinedWidget = fieldEditor->combinedWidget();
if ( fieldCombinedWidget )
{
fieldCombinedWidget->setParent( this->widget() );
layout->insertWidget( currentWidgetIndex++, fieldCombinedWidget );
}
else
{
caf::PdmUiItemInfo::LabelPosType labelPos = field->uiLabelPosition( uiConfigName );
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
if ( labelPos != caf::PdmUiItemInfo::HIDDEN )
{
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
if ( fieldLabelWidget )
{
fieldLabelWidget->setParent( this->widget() );
layout->insertWidget( currentWidgetIndex++, fieldLabelWidget );
fieldLabelWidget->show();
}
}
else
{
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
if ( fieldLabelWidget ) fieldLabelWidget->hide();
}
if ( fieldEditorWidget )
{
fieldEditorWidget->setParent( this->widget() ); // To make sure this widget has the current
// group box as parent.
layout->insertWidget( currentWidgetIndex++, fieldEditorWidget );
}
}
fieldEditor->updateUi( uiConfigName );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMinimizePanel* RicSummaryPlotEditorWidgetCreator::createGroupBoxWithContent( caf::PdmUiGroup* group,
const QString& uiConfigName )
{
QMinimizePanel* groupBox = findOrCreateGroupBox( this->widget(), group, uiConfigName );
recursivelyConfigureAndUpdateUiOrderingInGridLayout( *group, groupBox->contentFrame(), uiConfigName );
return groupBox;
}

View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "cafPdmUiFormLayoutObjectEditor.h"
#include <memory>
#include <vector>
class RimSummaryPlot;
class RimSummaryCase;
class RicSummaryPlotEditorUi;
class QMinimizePanel;
class QSplitter;
class QString;
class QVBoxLayout;
class QHBoxLayout;
class QBoxLayout;
namespace caf
{
class PdmObject;
class PdmUiItem;
class PdmUiTreeView;
} // namespace caf
//==================================================================================================
///
///
//==================================================================================================
class RicSummaryPlotEditorWidgetCreator : public caf::PdmUiFormLayoutObjectEditor
{
Q_OBJECT
public:
RicSummaryPlotEditorWidgetCreator( QWidget* parent );
~RicSummaryPlotEditorWidgetCreator() override;
void updateFromSummaryPlot( RimSummaryPlot* summaryPlot );
void updateFromDefaultSources( const std::vector<caf::PdmObject*> defaultSources );
private:
void recursivelyConfigureAndUpdateTopLevelUiOrdering( const caf::PdmUiOrdering& topLevelUiOrdering,
const QString& uiConfigName ) override;
QWidget* createWidget( QWidget* parent ) override;
QMinimizePanel* getOrCreateCurveTreeGroup();
QWidget* getOrCreatePlotWidget();
static caf::PdmUiGroup* findGroupByKeyword( const std::vector<caf::PdmUiItem*>& topLevelUiItems,
const QString& keyword,
const QString& uiConfigName );
void configureAndUpdateFields( int widgetStartIndex,
QBoxLayout* layout,
const std::vector<caf::PdmUiItem*>& topLevelUiItems,
const QString& uiConfigName );
QMinimizePanel* createGroupBoxWithContent( caf::PdmUiGroup* group, const QString& uiConfigName );
signals:
void signalCloseButtonPressed();
private:
QPointer<QVBoxLayout> m_layout;
QPointer<QSplitter> m_firstColumnSplitter;
QPointer<QMinimizePanel> m_curvesPanel;
QPointer<QHBoxLayout> m_firstRowLayout;
QPointer<QHBoxLayout> m_secondRowLayout;
QPointer<QVBoxLayout> m_lowerLeftLayout;
QPointer<QVBoxLayout> m_lowerRightLayout;
QPointer<QHBoxLayout> m_bottomFieldLayout;
QPointer<caf::PdmUiTreeView> m_curveTreeView;
QWidget* m_parentWidget;
std::unique_ptr<RicSummaryPlotEditorUi> m_summaryCurveCreator;
};

View File

@@ -0,0 +1,918 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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 "RicSummaryPlotFeatureImpl.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaDefines.h"
#include "RiaEclipseFileNameTools.h"
#include "RiaImportEclipseCaseTools.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RicCreateSummaryCaseCollectionFeature.h"
#include "RicImportGeneralDataFeature.h"
#include "RicImportSummaryCasesFeature.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "RifSummaryReaderInterface.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseResultAddress.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseResultCase.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h"
#include <QFileInfo>
#include <QRegularExpression>
#include <QStringList>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicSummaryPlotFeatureImpl::addDefaultCurveToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase )
{
if ( plot && summaryCase && summaryCase->summaryReader() )
{
RifEclipseSummaryAddress defaultAddressToUse;
QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter;
QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts );
if ( curveFilters.size() )
{
const std::set<RifEclipseSummaryAddress>& addrs = summaryCase->summaryReader()->allResultAddresses();
for ( const auto& addr : addrs )
{
const QString& filter = curveFilters[0];
{
if ( addr.isUiTextMatchingFilterText( filter ) )
{
defaultAddressToUse = addr;
}
}
}
}
RimSummaryCurve* newCurve = new RimSummaryCurve();
// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
cvf::Color3f curveColor =
RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( plot->singleColorCurveCount() );
newCurve->setColor( curveColor );
plot->addCurveNoUpdate( newCurve );
if ( summaryCase )
{
newCurve->setSummaryCaseY( summaryCase );
}
newCurve->setSummaryAddressYAndApplyInterpolation( defaultAddressToUse );
return newCurve;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCurve*> RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( RimSummaryPlot* plot,
RimSummaryCase* summaryCase )
{
QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter;
QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts );
return addCurvesFromAddressFiltersToPlot( curveFilters, plot, summaryCase, false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection,
RimSummaryCase* summaryCase )
{
if ( summaryPlotCollection && summaryCase )
{
if ( summaryPlotCollection->plots().empty() )
{
auto objectToSelect = createDefaultSummaryPlot( summaryCase );
if ( objectToSelect )
{
RiuPlotMainWindowTools::setExpanded( objectToSelect );
RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summaryCase )
{
RimSummaryPlotCollection* summaryPlotCollection = RimProject::current()->mainPlotCollection->summaryPlotCollection();
caf::PdmObject* itemToSelect = nullptr;
if ( summaryPlotCollection && summaryCase &&
!RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() )
{
auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
std::vector<RimSummaryCurve*> curves = RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( plot, summaryCase );
plot->applyDefaultCurveAppearances();
plot->loadDataAndUpdate();
summaryPlotCollection->updateConnectedEditors();
if ( curves.size() )
{
itemToSelect = curves[0];
}
else
{
itemToSelect = plot;
}
}
return itemToSelect;
}
RimSummaryCurve* createHistoryCurve( const RifEclipseSummaryAddress& addr, RimSummaryCase* summaryCasesToUse )
{
RifEclipseSummaryAddress historyAddr = addr;
historyAddr.setQuantityName( historyAddr.quantityName() + "H" );
if ( summaryCasesToUse->summaryReader()->allResultAddresses().count( historyAddr ) )
{
RimSummaryCurve* historyCurve = new RimSummaryCurve();
historyCurve->setSummaryCaseY( summaryCasesToUse );
historyCurve->setSummaryAddressYAndApplyInterpolation( historyAddr );
return historyCurve;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigGridCellResultAddress> RigGridCellResultAddress::createGridCellAddressesFromFilter( const QString& text )
{
std::vector<RigGridCellResultAddress> addresses;
QStringList addressParts = text.split( ":" );
if ( addressParts.size() > 1 )
{
QString resultVarName = addressParts[0];
size_t gridIdx = 0;
if ( addressParts.size() > 2 )
{
gridIdx = addressParts[1].toULong();
}
QString ijkText = addressParts.back();
QStringList ijkTextParts = ijkText.split( "," );
if ( ijkTextParts.size() == 3 )
{
bool isOk = true;
bool allOk = true;
size_t i = ijkTextParts[0].toULong( &isOk );
allOk &= isOk;
size_t j = ijkTextParts[1].toULong( &isOk );
allOk &= isOk;
size_t k = ijkTextParts[2].toULong( &isOk );
allOk &= isOk;
if ( allOk )
{
addresses.emplace_back(
RigGridCellResultAddress( gridIdx, i - 1, j - 1, k - 1, RigEclipseResultAddress( resultVarName ) ) );
}
}
}
return addresses;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEclipseCase*> openEclipseCasesForCellPlotting( QStringList gridFileNames )
{
std::vector<RimEclipseCase*> openedCases;
RiaApplication* app = RiaApplication::instance();
RimProject* project = app->project();
RimEclipseCaseCollection* analysisModels = project->activeOilField()->analysisModels();
for ( const QString& fileName : gridFileNames )
{
QFileInfo gridFileInfo( fileName );
if ( !gridFileInfo.exists() ) continue;
QString caseName = gridFileInfo.completeBaseName();
RimEclipseResultCase* rimResultReservoir = new RimEclipseResultCase();
rimResultReservoir->setCaseInfo( caseName, fileName );
analysisModels->cases.push_back( rimResultReservoir );
if ( !rimResultReservoir->openReserviorCase() )
{
analysisModels->removeCaseFromAllGroups( rimResultReservoir );
delete rimResultReservoir;
continue;
}
else
{
openedCases.push_back( rimResultReservoir );
}
}
analysisModels->updateConnectedEditors();
return openedCases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStringList& arguments )
{
// Split arguments in options, vectors and filenames
QStringList options;
QStringList allCurveAddressFilters;
QStringList summaryFileNames;
QStringList gridFileNames;
QString ensembleColoringParameter;
std::set<QString> validOptions = { "-help", "-h", "-nl", "-s", "-n", "-e", "-c", "-cl" };
for ( int optionIdx = 0; optionIdx < arguments.size(); ++optionIdx )
{
if ( arguments[optionIdx].startsWith( "-" ) )
{
if ( arguments[optionIdx] == "-help" )
{
QString text = RicSummaryPlotFeatureImpl::summaryPlotCommandLineHelpText();
RiaApplication::instance()->showFormattedTextInMessageBoxOrConsole( text );
return;
}
if ( validOptions.count( arguments[optionIdx] ) )
{
options.push_back( arguments[optionIdx] );
if ( arguments[optionIdx] == "-c" || arguments[optionIdx] == "-cl" )
{
optionIdx++;
if ( optionIdx < arguments.size() ) ensembleColoringParameter = arguments[optionIdx];
}
}
else
{
RiaLogging::error( "The summaryplot option: \"" + arguments[optionIdx] + "\" is unknown." );
}
}
else
{
RiaEclipseFileNameTools nameTool( arguments[optionIdx] );
QString smSpecFileName = nameTool.findRelatedSummarySpecFile();
QString gridFileName = nameTool.findRelatedGridFile();
if ( smSpecFileName != "" || gridFileName != "" )
{
if ( smSpecFileName != "" ) summaryFileNames.push_back( smSpecFileName );
if ( gridFileName != "" ) gridFileNames.push_back( gridFileName );
}
else
{
allCurveAddressFilters.push_back( arguments[optionIdx] );
}
}
}
summaryFileNames.removeDuplicates();
gridFileNames.removeDuplicates();
if ( allCurveAddressFilters.empty() )
{
RiaLogging::error( "Needs at least one vector to create a plot." );
}
bool hideLegend = options.contains( "-nl" );
bool addHistoryCurves = options.contains( "-h" );
bool isNormalizedY = options.contains( "-n" );
bool isSinglePlot = options.contains( "-s" );
EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE;
{
int e_pos = options.lastIndexOf( "-e" );
int c_pos = options.lastIndexOf( "-c" );
int cl_pos = options.lastIndexOf( "-cl" );
int lastEnsembleOptionPos = -1;
if ( e_pos > lastEnsembleOptionPos )
{
lastEnsembleOptionPos = e_pos;
ensembleColoringStyle = EnsembleColoringType::SINGLE_COLOR;
}
if ( c_pos > lastEnsembleOptionPos )
{
lastEnsembleOptionPos = c_pos;
ensembleColoringStyle = EnsembleColoringType::PARAMETER;
}
if ( cl_pos > lastEnsembleOptionPos )
{
lastEnsembleOptionPos = cl_pos;
ensembleColoringStyle = EnsembleColoringType::LOG_PARAMETER;
}
}
bool isEnsembleMode = ensembleColoringStyle != EnsembleColoringType::NONE;
std::vector<RimSummaryCase*> summaryCasesToUse;
if ( summaryFileNames.size() )
{
RicImportSummaryCasesFeature::createSummaryCasesFromFiles( summaryFileNames, &summaryCasesToUse, isEnsembleMode );
RicImportSummaryCasesFeature::addSummaryCases( summaryCasesToUse );
RiaApplication::instance()->setLastUsedDialogDirectory( RiaDefines::defaultDirectoryLabel(
RiaDefines::ImportFileType::ECLIPSE_SUMMARY_FILE ),
QFileInfo( summaryFileNames[0] ).absolutePath() );
}
if ( summaryCasesToUse.size() )
{
// Sort in summary and grid curve addresses
QStringList gridResultAddressFilters;
QStringList summaryAddressFilters;
RimSummaryPlot* lastPlotCreated = nullptr;
RimSummaryPlotCollection* sumPlotColl = RimProject::current()->mainPlotCollection()->summaryPlotCollection();
splitAddressFiltersInGridAndSummary( summaryCasesToUse[0],
allCurveAddressFilters,
&summaryAddressFilters,
&gridResultAddressFilters );
if ( summaryAddressFilters.size() )
{
RimSummaryCaseCollection* ensemble = nullptr;
if ( isEnsembleMode )
{
ensemble = RicCreateSummaryCaseCollectionFeature::groupSummaryCases( summaryCasesToUse, "Ensemble", true );
}
if ( isSinglePlot )
{
RimSummaryPlot* newPlot = createSummaryPlotFromAddresses( sumPlotColl,
summaryCasesToUse,
ensemble,
summaryAddressFilters,
addHistoryCurves,
ensembleColoringStyle,
ensembleColoringParameter );
lastPlotCreated = newPlot;
newPlot->setLegendsVisible( !hideLegend );
newPlot->setNormalizationEnabled( isNormalizedY );
newPlot->loadDataAndUpdate();
}
else // Multiplot, one for each separate summary address
{
std::vector<RimSummaryPlot*> summaryPlots =
createMultipleSummaryPlotsFromAddresses( sumPlotColl,
summaryCasesToUse,
ensemble,
summaryAddressFilters,
addHistoryCurves,
ensembleColoringStyle,
ensembleColoringParameter );
lastPlotCreated = summaryPlots.back();
for ( auto summaryPlot : summaryPlots )
{
summaryPlot->setLegendsVisible( !hideLegend );
summaryPlot->setNormalizationEnabled( isNormalizedY );
summaryPlot->loadDataAndUpdate();
}
}
}
// Grid Cell Result vectors
if ( gridResultAddressFilters.size() )
{
// Todo: Use identical grid case import if -e -c or -cl
std::vector<RimEclipseCase*> gridCasesToPlotFrom = openEclipseCasesForCellPlotting( gridFileNames );
if ( isSinglePlot )
{
std::vector<RimGridTimeHistoryCurve*> createdCurves;
int curveColorIndex = 0;
for ( const QString& gridAddressFilter : gridResultAddressFilters )
{
std::vector<RigGridCellResultAddress> cellResAddrs =
RigGridCellResultAddress::createGridCellAddressesFromFilter( gridAddressFilter );
for ( RigGridCellResultAddress cellResAddr : cellResAddrs )
{
for ( RimEclipseCase* eclCase : gridCasesToPlotFrom )
{
if ( !( eclCase->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL ) &&
eclCase->eclipseCaseData()
->results( RiaDefines::PorosityModelType::MATRIX_MODEL )
->resultInfo( cellResAddr.eclipseResultAddress ) ) )
{
RiaLogging::warning( "Could not find a restart result property with name: \"" +
cellResAddr.eclipseResultAddress.m_resultName + "\"" );
continue;
}
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
newCurve->setFromEclipseCellAndResult( eclCase,
cellResAddr.gridIndex,
cellResAddr.i,
cellResAddr.j,
cellResAddr.k,
cellResAddr.eclipseResultAddress );
newCurve->setLineThickness( 2 );
cvf::Color3f curveColor =
RicWellLogPlotCurveFeatureImpl::curveColorFromTable( curveColorIndex );
newCurve->setColor( curveColor );
if ( !isEnsembleMode ) ++curveColorIndex;
createdCurves.push_back( newCurve );
}
if ( isEnsembleMode ) ++curveColorIndex;
}
}
if ( createdCurves.size() )
{
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
for ( auto curve : createdCurves )
{
newPlot->addGridTimeHistoryCurve( curve );
}
newPlot->setLegendsVisible( !hideLegend );
newPlot->setNormalizationEnabled( isNormalizedY );
newPlot->loadDataAndUpdate();
lastPlotCreated = newPlot;
}
}
else // Multiplot
{
int curveColorIndex = 0;
for ( const QString& gridAddressFilter : gridResultAddressFilters )
{
std::vector<RigGridCellResultAddress> cellResAddrs =
RigGridCellResultAddress::createGridCellAddressesFromFilter( gridAddressFilter );
for ( RigGridCellResultAddress cellResAddr : cellResAddrs )
{
std::vector<RimGridTimeHistoryCurve*> createdCurves;
for ( RimEclipseCase* eclCase : gridCasesToPlotFrom )
{
if ( !( eclCase->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL ) &&
eclCase->eclipseCaseData()
->results( RiaDefines::PorosityModelType::MATRIX_MODEL )
->resultInfo( cellResAddr.eclipseResultAddress ) ) )
{
RiaLogging::warning( "Could not find a restart result property with name: \"" +
cellResAddr.eclipseResultAddress.m_resultName + "\"" );
continue;
}
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
newCurve->setFromEclipseCellAndResult( eclCase,
cellResAddr.gridIndex,
cellResAddr.i,
cellResAddr.j,
cellResAddr.k,
cellResAddr.eclipseResultAddress );
newCurve->setLineThickness( 2 );
cvf::Color3f curveColor =
RicWellLogPlotCurveFeatureImpl::curveColorFromTable( curveColorIndex );
newCurve->setColor( curveColor );
if ( !isEnsembleMode ) ++curveColorIndex;
createdCurves.push_back( newCurve );
}
if ( isEnsembleMode ) ++curveColorIndex;
if ( createdCurves.size() )
{
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
for ( auto newCurve : createdCurves )
{
newPlot->addGridTimeHistoryCurve( newCurve );
}
newPlot->setLegendsVisible( !hideLegend );
newPlot->setNormalizationEnabled( isNormalizedY );
newPlot->loadDataAndUpdate();
lastPlotCreated = newPlot;
}
}
}
}
}
if ( lastPlotCreated )
{
sumPlotColl->updateConnectedEditors();
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
// Needed to avoid unnecessary activation of sub windows (plots)
// which results in population of property editor, and missing deleteLater because we are outside any event
// loop when switching object. Results in stray widgets.
mpw->setBlockViewSelectionOnSubWindowActivated( true );
RiuPlotMainWindowTools::showPlotMainWindow();
mpw->setBlockViewSelectionOnSubWindowActivated( false );
RiuPlotMainWindowTools::setExpanded( lastPlotCreated );
RiuPlotMainWindowTools::selectAsCurrentItem( lastPlotCreated );
RiuMainWindow::instance()->close();
}
}
else
{
RiaLogging::error( "Needs at least one summary case to create a plot." );
}
}
RimSummaryPlot*
RicSummaryPlotFeatureImpl::createSummaryPlotFromAddresses( RimSummaryPlotCollection* sumPlotColl,
const std::vector<RimSummaryCase*>& summaryCasesToUse,
RimSummaryCaseCollection* ensemble,
QStringList summaryAddressFilters,
bool addHistoryCurves,
EnsembleColoringType ensembleColoringStyle,
QString ensembleColoringParameter )
{
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
if ( ensemble )
{
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases =
applySummaryAddressFiltersToCases( summaryCasesToUse, summaryAddressFilters );
for ( const auto& addr : filteredAdressesFromCases )
{
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
curveSet->setSummaryCaseCollection( ensemble );
curveSet->setSummaryAddress( addr );
if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER ||
ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
{
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM );
curveSet->setEnsembleParameter( ensembleColoringParameter );
if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
{
curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS );
}
}
newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
if ( addHistoryCurves )
{
RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] );
if ( historyCurve ) newPlot->addCurveNoUpdate( historyCurve );
}
}
}
else
{
for ( RimSummaryCase* sumCase : summaryCasesToUse )
{
RicSummaryPlotFeatureImpl::addCurvesFromAddressFiltersToPlot( summaryAddressFilters,
newPlot,
sumCase,
addHistoryCurves );
addHistoryCurves = false;
}
}
newPlot->applyDefaultCurveAppearances();
return newPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryPlot*> RicSummaryPlotFeatureImpl::createMultipleSummaryPlotsFromAddresses(
RimSummaryPlotCollection* sumPlotColl,
const std::vector<RimSummaryCase*>& summaryCasesToUse,
RimSummaryCaseCollection* ensemble,
QStringList summaryAddressFilters,
bool addHistoryCurves,
EnsembleColoringType ensembleColoringStyle /*= EnsembleColoringType::NONE*/,
QString ensembleColoringParameter /*= "" */ )
{
std::vector<RimSummaryPlot*> newSummaryPlots;
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases =
applySummaryAddressFiltersToCases( summaryCasesToUse, summaryAddressFilters );
for ( const auto& addr : filteredAdressesFromCases )
{
std::vector<RimSummaryCurve*> createdCurves;
std::vector<RimEnsembleCurveSet*> createdEnsembleCurveSets;
if ( ensemble )
{
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
curveSet->setSummaryCaseCollection( ensemble );
curveSet->setSummaryAddress( addr );
if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER ||
ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
{
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM );
curveSet->setEnsembleParameter( ensembleColoringParameter );
if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
{
curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS );
}
}
createdEnsembleCurveSets.push_back( curveSet );
}
else
{
for ( RimSummaryCase* sumCase : summaryCasesToUse )
{
const std::set<RifEclipseSummaryAddress>& allAddrsInCase = sumCase->summaryReader()->allResultAddresses();
if ( allAddrsInCase.count( addr ) )
{
RimSummaryCurve* newCurve = new RimSummaryCurve();
newCurve->setSummaryCaseY( sumCase );
newCurve->setSummaryAddressYAndApplyInterpolation( addr );
createdCurves.push_back( newCurve );
}
}
}
if ( addHistoryCurves )
{
RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] );
if ( historyCurve ) createdCurves.push_back( historyCurve );
}
if ( createdCurves.size() || createdEnsembleCurveSets.size() )
{
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
for ( auto curve : createdCurves )
{
newPlot->addCurveNoUpdate( curve );
}
for ( auto curveSet : createdEnsembleCurveSets )
{
newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
}
newPlot->applyDefaultCurveAppearances();
newSummaryPlots.push_back( newPlot );
}
}
return newSummaryPlots;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotFeatureImpl::splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryBaseCases,
const QStringList& allCurveAddressFilters,
QStringList* summaryAddressFilters,
QStringList* gridResultAddressFilters )
{
if ( summaryBaseCases )
{
const std::set<RifEclipseSummaryAddress>& addrs = summaryBaseCases->summaryReader()->allResultAddresses();
std::vector<bool> usedFilters;
std::set<RifEclipseSummaryAddress> setToInsertFilteredAddressesIn;
filteredSummaryAdressesFromCase( allCurveAddressFilters, addrs, &setToInsertFilteredAddressesIn, &usedFilters );
QRegularExpression gridAddressPattern( "^[A-Z]+:[0-9]+,[0-9]+,[0-9]+$" );
for ( int filterIdx = 0; filterIdx < allCurveAddressFilters.size(); ++filterIdx )
{
const QString& address = allCurveAddressFilters[filterIdx];
if ( usedFilters[filterIdx] )
{
summaryAddressFilters->push_back( address );
}
else
{
if ( gridAddressPattern.match( address ).hasMatch() )
{
gridResultAddressFilters->push_back( address );
}
else
{
RiaLogging::warning( "No summary or restart vectors matched \"" + address + "\"" );
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RifEclipseSummaryAddress>
RicSummaryPlotFeatureImpl::applySummaryAddressFiltersToCases( const std::vector<RimSummaryCase*>& summaryCasesToUse,
const QStringList& summaryAddressFilters )
{
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases;
for ( RimSummaryCase* sumCase : summaryCasesToUse )
{
const std::set<RifEclipseSummaryAddress>& addrs = sumCase->summaryReader()->allResultAddresses();
std::vector<bool> usedFilters;
filteredSummaryAdressesFromCase( summaryAddressFilters, addrs, &filteredAdressesFromCases, &usedFilters );
for ( size_t cfIdx = 0; cfIdx < usedFilters.size(); ++cfIdx )
{
if ( !usedFilters[cfIdx] )
{
RiaLogging::warning( "Vector filter \"" + summaryAddressFilters[static_cast<int>( cfIdx )] +
"\" did not match anything in case: \"" + sumCase->nativeCaseName() + "\"" );
}
}
}
return filteredAdressesFromCases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCurve*> RicSummaryPlotFeatureImpl::addCurvesFromAddressFiltersToPlot( const QStringList& curveFilters,
RimSummaryPlot* plot,
RimSummaryCase* summaryCase,
bool addHistoryCurves )
{
std::vector<RimSummaryCurve*> createdCurves;
if ( !plot ) return createdCurves;
if ( !summaryCase || !summaryCase->summaryReader() ) return createdCurves;
std::set<RifEclipseSummaryAddress> curveAddressesToUse;
const std::set<RifEclipseSummaryAddress>& addrs = summaryCase->summaryReader()->allResultAddresses();
std::vector<bool> usedFilters;
filteredSummaryAdressesFromCase( curveFilters, addrs, &curveAddressesToUse, &usedFilters );
for ( size_t cfIdx = 0; cfIdx < usedFilters.size(); ++cfIdx )
{
if ( !usedFilters[cfIdx] )
{
RiaLogging::warning( "Vector filter \"" + curveFilters[static_cast<int>( cfIdx )] +
"\" did not match anything in case: \"" + summaryCase->nativeCaseName() + "\"" );
}
}
if ( addHistoryCurves )
{
std::vector<RifEclipseSummaryAddress> historyAddressesToUse;
for ( RifEclipseSummaryAddress historyAddr : curveAddressesToUse )
{
historyAddr.setQuantityName( historyAddr.quantityName() + "H" );
if ( addrs.count( historyAddr ) )
{
historyAddressesToUse.push_back( historyAddr );
}
}
curveAddressesToUse.insert( historyAddressesToUse.begin(), historyAddressesToUse.end() );
}
for ( const auto& addr : curveAddressesToUse )
{
RimSummaryCurve* newCurve = new RimSummaryCurve();
plot->addCurveNoUpdate( newCurve );
if ( summaryCase )
{
newCurve->setSummaryCaseY( summaryCase );
}
newCurve->setSummaryAddressYAndApplyInterpolation( addr );
createdCurves.push_back( newCurve );
}
return createdCurves;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotFeatureImpl::filteredSummaryAdressesFromCase(
const QStringList& curveFilters,
const std::set<RifEclipseSummaryAddress>& allAddressesInCase,
std::set<RifEclipseSummaryAddress>* setToInsertFilteredAddressesIn,
std::vector<bool>* usedFilters )
{
int curveFilterCount = curveFilters.size();
usedFilters->clear();
usedFilters->resize( curveFilterCount, false );
for ( const auto& addr : allAddressesInCase )
{
for ( int cfIdx = 0; cfIdx < curveFilterCount; ++cfIdx )
{
if ( addr.isUiTextMatchingFilterText( curveFilters[cfIdx] ) )
{
setToInsertFilteredAddressesIn->insert( addr );
( *usedFilters )[cfIdx] = true;
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryPlotFeatureImpl::summaryPlotCommandLineHelpText()
{
// clang-format off
QString txt =
"The --summaryplot option has the following syntax:\n"
"\n"
"[<plotOptions>] <eclipsesummaryvectorfilters> <eclipsedatafiles>\n"
"\n"
"It creates one summary plot for each of the the summary vectors matched by the "
"<eclipsesummaryvectorfilters> using all the <eclipsedatafiles> in each plot.\n"
"The <eclipsesummaryvectorfilters> has the syntax <vectorname>[:<item>[:<subitem>[:i,j,k]]] and can be repeated.\n"
"Wildcards can also be used, eg. \"WOPT:*\" to select the total oil production from all the wells.\n"
"3D Grid properties from restart files can also be requested in the form <propertyname>:i,j,k.\n"
"The <eclipsedatafiles> can be written with or without extension.\n"
"As long as only summary vectors are requested, only the corresponding SMSPEC file will be opened for each case.\n"
"If a grid property is requested, however (eg. SOIL:20,21,1) the corresponding EGRID and restart data will be loaded as well.\n"
"\n"
"The summary plot options are: \n"
" -help\t Show this help text and ignore the rest of the options.\n"
" -h\t Include history vectors. Will be read from the summary file if the vectors exist.\n"
" \t Only history vectors from the first summary case in the project will be included.\n"
" -nl\t Omit legend in plot.\n"
" -s\t Create only one plot including all the defined vectors and cases.\n"
" -n\t Scale all curves into the range 0.0-1.0. Useful when using -s.\n"
" -e\t Import all the cases as an ensemble, and create ensemble curves sets instead of single curves.\n"
" -c <parametername>\t Same as -e, but colors the curves by the ensemble parameter <parametername> . \n"
" -cl <parametername>\t Same as -c, but uses logarithmic legend.\n";
// clang-format on
return txt;
}

View File

@@ -0,0 +1,132 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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 "RifEclipseSummaryAddress.h"
#include <QString>
#include <set>
#include <vector>
namespace caf
{
class PdmObject;
}
class RimSummaryCurve;
class RimSummaryPlot;
class RimSummaryCase;
class RimSummaryCaseCollection;
class RimSummaryPlotCollection;
class QStringList;
class RicSummaryPlotFeatureImpl
{
public:
enum class EnsembleColoringType
{
SINGLE_COLOR,
PARAMETER,
LOG_PARAMETER,
NONE
};
static RimSummaryCurve* addDefaultCurveToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase );
static std::vector<RimSummaryCurve*> addDefaultCurvesToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase );
static void ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase );
static caf::PdmObject* createDefaultSummaryPlot( RimSummaryCase* summaryCase );
static void createSummaryPlotsFromArgumentLine( const QStringList& arguments );
static RimSummaryPlot*
createSummaryPlotFromAddresses( RimSummaryPlotCollection* sumPlotColl,
const std::vector<RimSummaryCase*>& summaryCasesToUse,
RimSummaryCaseCollection* ensemble,
QStringList summaryAddressFilters,
bool addHistoryCurves = false,
EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE,
QString ensembleColoringParameter = "" );
static std::vector<RimSummaryPlot*>
createMultipleSummaryPlotsFromAddresses( RimSummaryPlotCollection* sumPlotColl,
const std::vector<RimSummaryCase*>& summaryCasesToUse,
RimSummaryCaseCollection* ensemble,
QStringList summaryAddressFilters,
bool addHistoryCurves = false,
EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE,
QString ensembleColoringParameter = "" );
static void filteredSummaryAdressesFromCase( const QStringList& curveFilters,
const std::set<RifEclipseSummaryAddress>& allAddressesInCase,
std::set<RifEclipseSummaryAddress>* setToInsertFilteredAddressesIn,
std::vector<bool>* usedFilters );
static QString summaryPlotCommandLineHelpText();
private:
static std::vector<RimSummaryCurve*> addCurvesFromAddressFiltersToPlot( const QStringList& curveFilters,
RimSummaryPlot* plot,
RimSummaryCase* summaryCase,
bool addHistoryCurves );
static std::set<RifEclipseSummaryAddress>
applySummaryAddressFiltersToCases( const std::vector<RimSummaryCase*>& summaryCasesToUse,
const QStringList& summaryAddressFilters );
static void splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryBaseCases,
const QStringList& allCurveAddressFilters,
QStringList* summaryAddressFilters,
QStringList* gridResultAddressFilters );
};
#include "RigEclipseResultAddress.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigGridCellResultAddress
{
public:
RigGridCellResultAddress()
: gridIndex( -1 )
, i( -1 )
, j( -1 )
, k( -1 )
{
}
RigGridCellResultAddress( size_t gridIndex, size_t i, size_t j, size_t k, const RigEclipseResultAddress& eclipseResultAddress )
: gridIndex( gridIndex )
, i( i )
, j( j )
, k( k )
, eclipseResultAddress( eclipseResultAddress )
{
}
static std::vector<RigGridCellResultAddress> createGridCellAddressesFromFilter( const QString& text );
// Using zero based ijk
size_t gridIndex;
size_t i;
size_t j;
size_t k;
RigEclipseResultAddress eclipseResultAddress;
};

View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicViewZoomAllFeature.h"
#include "RiaGuiApplication.h"
#include "Rim3dView.h"
#include "RimViewWindow.h"
#include "RiuInterfaceToViewWindow.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include <QAction>
#include <QMdiSubWindow>
CAF_CMD_SOURCE_INIT( RicViewZoomAllFeature, "RicViewZoomAllFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicViewZoomAllFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicViewZoomAllFeature::onActionTriggered( bool isChecked )
{
this->disableModelChangeContribution();
QWidget* topLevelWidget = RiaGuiApplication::activeWindow();
if ( dynamic_cast<RiuMainWindow*>( topLevelWidget ) )
{
RimViewWindow* viewWindow = RiaGuiApplication::instance()->activeReservoirView();
if ( viewWindow )
{
viewWindow->zoomAll();
}
}
else if ( dynamic_cast<RiuPlotMainWindow*>( topLevelWidget ) )
{
RiuPlotMainWindow* mainPlotWindow = dynamic_cast<RiuPlotMainWindow*>( topLevelWidget );
QList<QMdiSubWindow*> subwindows = mainPlotWindow->subWindowList( QMdiArea::StackingOrder );
if ( !subwindows.empty() )
{
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( subwindows.back()->widget() );
if ( viewWindow )
{
viewWindow->zoomAll();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicViewZoomAllFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Zoom All" );
actionToSetup->setToolTip( "Zoom All (Ctrl+Alt+A)" );
actionToSetup->setIcon( QIcon( ":/ZoomAll.svg" ) );
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+Alt+A" ) ) );
}

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RicViewZoomAllFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};