#4687 Summary Template : Add UI to select template

#4705 Summary Template : Add icon and use from features and dialogs
This commit is contained in:
Magne Sjaastad
2019-09-12 08:43:09 +02:00
parent d045c0aade
commit 7fc0a47443
11 changed files with 256 additions and 57 deletions

View File

@@ -2,11 +2,13 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -16,12 +16,15 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicCreatePlotFromSelectionFeature.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaSummaryTools.h"
#include "RicCreatePlotFromSelectionFeature.h"
#include "RicSelectPlotTemplateUi.h"
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
@@ -30,7 +33,10 @@
#include "RimSummaryPlotCollection.h"
#include "RimWellPath.h"
#include "RiuPlotMainWindow.h"
#include "cafPdmObject.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
@@ -60,76 +66,92 @@ bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
{
{
auto sumCases = selectedSummaryCases();
if ( sumCases.size() == 2 )
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
RicSelectPlotTemplateUi ui;
caf::PdmUiPropertyViewDialog propertyDialog( plotwindow,
&ui,
"Select Case to create Pressure Saturation plots",
"" );
if ( propertyDialog.exec() != QDialog::Accepted ) return;
if ( ui.selectedPlotTemplates().empty() ) return;
QString fileName = ui.selectedPlotTemplates().front()->absoluteFilePath();
{
QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt";
RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName );
if ( newSummaryPlot )
auto sumCases = selectedSummaryCases();
if ( sumCases.size() == 2 )
{
RimSummaryPlotCollection* plotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
// QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt";
plotColl->summaryPlots.push_back( 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 );
auto summaryCurves = newSummaryPlot->summaryCurves();
if ( summaryCurves.size() == sumCases.size() )
RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName );
if ( newSummaryPlot )
{
for ( size_t i = 0; i < summaryCurves.size(); i++ )
RimSummaryPlotCollection* plotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
plotColl->summaryPlots.push_back( 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 );
auto summaryCurves = newSummaryPlot->summaryCurves();
if ( summaryCurves.size() == sumCases.size() )
{
auto sumCase = sumCases[i];
summaryCurves[i]->setSummaryCaseY( sumCase );
for ( size_t i = 0; i < summaryCurves.size(); i++ )
{
auto sumCase = sumCases[i];
summaryCurves[i]->setSummaryCaseY( sumCase );
}
}
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
}
}
{
auto wellPaths = selectedWellPaths();
if ( wellPaths.size() == 2 )
{
QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt";
RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName );
if ( newSummaryPlot )
auto wellPaths = selectedWellPaths();
if ( wellPaths.size() == 2 )
{
RimSummaryPlotCollection* plotColl = RiaSummaryTools::summaryPlotCollection();
plotColl->summaryPlots.push_back( 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 );
auto summaryCurves = newSummaryPlot->summaryCurves();
if ( summaryCurves.size() == wellPaths.size() )
// QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt";
RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName );
if ( newSummaryPlot )
{
for ( size_t i = 0; i < summaryCurves.size(); i++ )
RimSummaryPlotCollection* plotColl = RiaSummaryTools::summaryPlotCollection();
plotColl->summaryPlots.push_back( 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 );
auto summaryCurves = newSummaryPlot->summaryCurves();
if ( summaryCurves.size() == wellPaths.size() )
{
auto wellPath = wellPaths[i];
for ( size_t i = 0; i < summaryCurves.size(); i++ )
{
auto wellPath = wellPaths[i];
summaryCurves[i]->summaryAddressY().setWellName( wellPath->name().toStdString() );
summaryCurves[i]->summaryAddressY().setWellName( wellPath->name().toStdString() );
}
}
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
}
}
@@ -141,7 +163,7 @@ void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
void RicCreatePlotFromSelectionFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create Plot from Template" );
// actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -21,6 +21,7 @@
#include "cafCmdFeature.h"
class RimSummaryCase;
class RimSummaryPlot;
class RimWellPath;
//==================================================================================================

View File

@@ -93,7 +93,7 @@ void RicSavePlotTemplateFeature::onActionTriggered( bool isChecked )
void RicSavePlotTemplateFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Save As Plot Template" );
// actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicSelectPlotTemplateUi.h"
#include "RiaApplication.h"
#include "RiaSummaryTools.h"
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT( RicSelectPlotTemplateUi, "RicSelectPlotTemplateUi" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSelectPlotTemplateUi::RicSelectPlotTemplateUi()
{
CAF_PDM_InitObject( "RicSelectPlotTemplateUi", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_selectedPlotTemplates, "SelectedPlotTemplates", "Plot Templates", "", "", "" );
m_selectedPlotTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
m_selectedPlotTemplates.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPlotTemplateFileItem*> RicSelectPlotTemplateUi::selectedPlotTemplates()
{
std::vector<RimPlotTemplateFileItem*> objs;
for ( const auto& a : m_selectedPlotTemplates() )
{
objs.push_back( a );
}
return objs;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RicSelectPlotTemplateUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_selectedPlotTemplates )
{
auto plotTemplateRoot = RiaApplication::instance()->project()->rootPlotTemlateItem();
RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplates( options, plotTemplateRoot );
}
return options;
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmPtrArrayField.h"
class RimPlotTemplateFileItem;
class RimPlotTemplateFolderItem;
//==================================================================================================
///
//==================================================================================================
class RicSelectPlotTemplateUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicSelectPlotTemplateUi();
std::vector<RimPlotTemplateFileItem*> selectedPlotTemplates();
private:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private:
caf::PdmPtrArrayField<RimPlotTemplateFileItem*> m_selectedPlotTemplates;
};

View File

@@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT( RimPlotTemplateFileItem, "PlotTemplateFileItem" );
//--------------------------------------------------------------------------------------------------
RimPlotTemplateFileItem::RimPlotTemplateFileItem()
{
CAF_PDM_InitObject( "PlotTemplateFileItem", ":/OctaveScriptFile16x16.png", "Calc Script", "" );
CAF_PDM_InitObject( "PlotTemplateFileItem", ":/SummaryTemplate16x16.png", "Plot Template", "" );
CAF_PDM_InitField( &m_absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "" );
m_absoluteFileName.uiCapability()->setUiReadOnly( true );

View File

@@ -74,6 +74,15 @@ std::vector<RimPlotTemplateFolderItem*> RimPlotTemplateFolderItem::subFolders()
return m_subFolders.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplates( QList<caf::PdmOptionItemInfo>& options,
RimPlotTemplateFolderItem* templateFolderItem )
{
appendOptionItemsForPlotTemplatesRecursively( options, templateFolderItem, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -176,6 +185,37 @@ void RimPlotTemplateFolderItem::defineEditorAttribute( const caf::PdmFieldHandle
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplatesRecursively(
QList<caf::PdmOptionItemInfo>& options, RimPlotTemplateFolderItem* templateFolderItem, int menuLevel )
{
{
auto subFolders = templateFolderItem->subFolders();
for ( auto sub : subFolders )
{
caf::PdmOptionItemInfo optionInfo = caf::PdmOptionItemInfo::createHeader( sub->uiName(), true );
optionInfo.setLevel( menuLevel );
options.push_back( optionInfo );
appendOptionItemsForPlotTemplatesRecursively( options, sub, menuLevel + 1 );
}
}
caf::QIconProvider templateIcon( ":/SummaryTemplate16x16.png" );
auto files = templateFolderItem->fileNames();
for ( auto file : files )
{
caf::PdmOptionItemInfo optionInfo( file->uiName(), file, false, templateIcon );
optionInfo.setLevel( menuLevel );
options.push_back( optionInfo );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -46,6 +46,9 @@ public:
std::vector<RimPlotTemplateFileItem*> fileNames() const;
std::vector<RimPlotTemplateFolderItem*> subFolders() const;
static void appendOptionItemsForPlotTemplates( QList<caf::PdmOptionItemInfo>& options,
RimPlotTemplateFolderItem* templateFolderItem );
private:
void searchForFileAndFolderNames();
void setFolderPath( const QString& path );
@@ -60,6 +63,10 @@ private:
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
static void appendOptionItemsForPlotTemplatesRecursively( QList<caf::PdmOptionItemInfo>& options,
RimPlotTemplateFolderItem* templateFolderItem,
int menuLevel );
private:
caf::PdmField<caf::FilePath> m_folderName;
caf::PdmChildArrayField<RimPlotTemplateFileItem*> m_fileNames;

View File

@@ -157,6 +157,7 @@
<file>Ruler24x24.png</file>
<file>RulerPoly24x24.png</file>
<file>Swap.png</file>
<file>SummaryTemplate16x16.png</file>
</qresource>
<qresource prefix="/Shader/">
<file>fs_CellFace.glsl</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B