mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-11 07:56:08 -06:00
#4796 Summary Plot Template : Add context menu of summary cases
This commit is contained in:
parent
18e6bec1bf
commit
64e617562d
@ -312,6 +312,9 @@ RiaPreferences::RiaPreferences( void )
|
||||
"",
|
||||
"" );
|
||||
m_searchPlotTemplateFoldersRecursively.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_defaultPlotTemplate, "defaultPlotTemplate", "Default Plot Template", "", "", "" );
|
||||
// m_plotTemplateFolders.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -331,22 +334,32 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
{
|
||||
m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute );
|
||||
|
||||
if ( field == &scriptDirectories || field == &m_plotTemplateFolders )
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->m_selectDirectory = true;
|
||||
myAttr->m_appendUiSelectedFolderToText = true;
|
||||
if ( field == &scriptDirectories || field == &m_plotTemplateFolders )
|
||||
{
|
||||
myAttr->m_selectDirectory = true;
|
||||
myAttr->m_appendUiSelectedFolderToText = true;
|
||||
}
|
||||
else if ( field == &m_defaultPlotTemplate )
|
||||
{
|
||||
auto folders = plotTemplateFolders();
|
||||
if ( !folders.empty() )
|
||||
{
|
||||
myAttr->m_defaultPath = folders.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
|
||||
field == &loadAndShowSoil || field == &useShaders || field == &showHud ||
|
||||
field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText ||
|
||||
field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile ||
|
||||
field == &showLasCurveWithoutTvdWarning || field == &holoLensDisableCertificateVerification ||
|
||||
field == &m_showProjectChangedDialog || field == &m_searchPlotTemplateFoldersRecursively ||
|
||||
field == &showLegendBackground )
|
||||
|
||||
if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
|
||||
field == &loadAndShowSoil || field == &useShaders || field == &showHud || field == &m_appendClassNameToUiText ||
|
||||
field == &m_appendFieldKeywordToToolTipText || field == &m_showTestToolbar ||
|
||||
field == &m_includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning ||
|
||||
field == &holoLensDisableCertificateVerification || field == &m_showProjectChangedDialog ||
|
||||
field == &m_searchPlotTemplateFoldersRecursively || field == &showLegendBackground )
|
||||
{
|
||||
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
@ -438,6 +451,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Plot Templates" );
|
||||
group->add( &m_plotTemplateFolders );
|
||||
group->add( &m_searchPlotTemplateFoldersRecursively );
|
||||
group->add( &m_defaultPlotTemplate );
|
||||
}
|
||||
else if ( uiConfigName == RiaPreferences::tabNameScripting() )
|
||||
{
|
||||
@ -732,6 +746,14 @@ void RiaPreferences::appendPlotTemplateFolders( const QString& folder )
|
||||
m_plotTemplateFolders = folders;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaPreferences::defaultPlotTemplateAbsolutePath() const
|
||||
{
|
||||
return m_defaultPlotTemplate().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
bool searchPlotTemplateFoldersRecursively() const;
|
||||
QStringList plotTemplateFolders() const;
|
||||
void appendPlotTemplateFolders( const QString& folder );
|
||||
QString defaultPlotTemplateAbsolutePath() const;
|
||||
|
||||
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
||||
|
||||
@ -167,8 +168,9 @@ private:
|
||||
caf::PdmField<QString> m_dateFormat;
|
||||
caf::PdmField<QString> m_timeFormat;
|
||||
|
||||
caf::PdmField<QString> m_plotTemplateFolders;
|
||||
caf::PdmField<bool> m_searchPlotTemplateFoldersRecursively;
|
||||
caf::PdmField<QString> m_plotTemplateFolders;
|
||||
caf::PdmField<bool> m_searchPlotTemplateFoldersRecursively;
|
||||
caf::PdmField<caf::FilePath> m_defaultPlotTemplate;
|
||||
|
||||
QStringList m_tabNames;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotTemplateTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadPlotTemplatesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateByShortcutFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -15,6 +16,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotTemplateTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicReloadPlotTemplatesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateByShortcutFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,74 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicCreatePlotFromTemplateByShortcutFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RicSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateByShortcutFeature, "RicCreatePlotFromTemplateByShortcutFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedSummaryCases().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
QString fileName = RiaApplication::instance()->preferences()->defaultPlotTemplateAbsolutePath();
|
||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Plot from Template" );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
||||
|
||||
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
|
||||
actionToSetup->setShortcut( keySeq );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicCreatePlotFromTemplateByShortcutFeature::selectedSummaryCases() const
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCreatePlotFromTemplateByShortcutFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
};
|
@ -86,6 +86,12 @@ bool RiuTreeViewEventFilter::eventFilter( QObject* obj, QEvent* event )
|
||||
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut(
|
||||
QKeySequence::Delete );
|
||||
}
|
||||
else
|
||||
{
|
||||
QKeySequence keySeq( keyEvent->modifiers() + keyEvent->key() );
|
||||
|
||||
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut( keySeq );
|
||||
}
|
||||
|
||||
for ( caf::CmdFeature* feature : matches )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user