mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-13 08:52:14 -05:00
Improve Quick Access
* Add css to checked menu items * Improve icons * Use group name for field if found * Add quick access fields for IJK Filter * Add tree selection for selection of multiple fields
This commit is contained in:
1 parent
67e6df28b5
commit
94d6f81b0f
9 files changed
+243
-11
No files matched your search
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "QuickAccess/RimFieldQuickAccessInterface.h"
|
||||
#include "QuickAccess/RimFieldReference.h"
|
||||
#include "QuickAccess/RimFieldSelection.h"
|
||||
#include "QuickAccess/RimQuickAccessCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
@@ -51,15 +52,26 @@ void RicAddFieldToQuickAccessFeature::onActionTriggered( bool isChecked )
|
||||
auto firstObject = objects.front();
|
||||
if ( !firstObject ) return;
|
||||
|
||||
RimFieldReference fieldRef;
|
||||
fieldRef.setObject( firstObject );
|
||||
RimFieldSelection fieldSelection;
|
||||
fieldSelection.setObject( firstObject );
|
||||
fieldSelection.selectAllFields();
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(), &fieldRef, "Select Field for Quick Access", "" );
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(), &fieldSelection, "Select Field for Quick Access", "" );
|
||||
propertyDialog.setWindowIcon( QIcon( ":/pin.svg" ) );
|
||||
propertyDialog.resize( QSize( 400, 500 ) );
|
||||
|
||||
if ( propertyDialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
RimQuickAccessCollection::instance()->addQuickAccessField( fieldRef );
|
||||
auto selectedFields = fieldSelection.fields();
|
||||
for ( auto field : selectedFields )
|
||||
{
|
||||
RimFieldReference fieldRef;
|
||||
fieldRef.setObject( firstObject );
|
||||
fieldRef.setField( field );
|
||||
|
||||
RimQuickAccessCollection::instance()->addQuickAccessField( fieldRef );
|
||||
}
|
||||
|
||||
RimQuickAccessCollection::instance()->updateAllRequiredEditors();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,17 @@ std::map<QString, std::vector<caf::PdmFieldHandle*>> RimCellRangeFilter::quickAc
|
||||
if ( cellCountJ == 1 ) fields[""].push_back( &startIndexJ );
|
||||
if ( cellCountK == 1 ) fields[""].push_back( &startIndexK );
|
||||
|
||||
if ( fields.empty() )
|
||||
{
|
||||
QString groupName = "IJK Filter";
|
||||
fields[groupName].push_back( &startIndexI );
|
||||
fields[groupName].push_back( &cellCountI );
|
||||
fields[groupName].push_back( &startIndexJ );
|
||||
fields[groupName].push_back( &cellCountJ );
|
||||
fields[groupName].push_back( &startIndexK );
|
||||
fields[groupName].push_back( &cellCountK );
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldQuickAccessGroup.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldQuickAccessInterface.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldReference.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldSelection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimQuickAccessCollection.h
|
||||
)
|
||||
|
||||
@@ -10,6 +11,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldQuickAccess.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldQuickAccessGroup.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldReference.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFieldSelection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimQuickAccessCollection.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024- 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 "RimFieldSelection.h"
|
||||
|
||||
#include "RimFieldQuickAccessInterface.h"
|
||||
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimFieldSelection, "RimFieldSelection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFieldSelection::RimFieldSelection()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault( &m_objectName, "ObjectName", "Object" );
|
||||
m_objectName.registerGetMethod( this, &RimFieldSelection::objectName );
|
||||
m_objectName.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_keywords, "Keywords", "Field Keywords" );
|
||||
m_keywords.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
||||
m_keywords.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFieldSelection::setObject( caf::PdmObject* object )
|
||||
{
|
||||
m_object = object;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFieldSelection::selectAllFields()
|
||||
{
|
||||
if ( auto quickInterface = dynamic_cast<RimFieldQuickAccessInterface*>( m_object.p() ) )
|
||||
{
|
||||
std::vector<QString> keywords;
|
||||
for ( const auto& [groupName, fields] : quickInterface->quickAccessFields() )
|
||||
{
|
||||
for ( auto field : fields )
|
||||
{
|
||||
keywords.push_back( field->keyword() );
|
||||
}
|
||||
}
|
||||
|
||||
m_keywords = keywords;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmFieldHandle*> RimFieldSelection::fields() const
|
||||
{
|
||||
std::vector<caf::PdmFieldHandle*> fieldSelection;
|
||||
if ( auto quickInterface = dynamic_cast<RimFieldQuickAccessInterface*>( m_object.p() ) )
|
||||
{
|
||||
for ( const auto& [groupName, fields] : quickInterface->quickAccessFields() )
|
||||
{
|
||||
for ( auto field : fields )
|
||||
{
|
||||
const auto& keyword = field->keyword();
|
||||
if ( m_keywords().empty() || std::find( m_keywords().begin(), m_keywords().end(), keyword ) != m_keywords().end() )
|
||||
{
|
||||
fieldSelection.push_back( field );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fieldSelection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFieldSelection::objectName() const
|
||||
{
|
||||
if ( m_object )
|
||||
{
|
||||
return m_object->uiName();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimFieldSelection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_keywords )
|
||||
{
|
||||
if ( auto quickInterface = dynamic_cast<RimFieldQuickAccessInterface*>( m_object.p() ) )
|
||||
{
|
||||
for ( const auto& [groupName, fields] : quickInterface->quickAccessFields() )
|
||||
{
|
||||
for ( auto field : fields )
|
||||
{
|
||||
QString displayText = field->keyword();
|
||||
if ( field->uiCapability() )
|
||||
{
|
||||
displayText = field->uiCapability()->uiName();
|
||||
}
|
||||
options.push_back( { displayText, field->keyword() } );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024- 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
|
||||
class RimFieldSelection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimFieldSelection();
|
||||
|
||||
void setObject( caf::PdmObject* object );
|
||||
void selectAllFields();
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields() const;
|
||||
|
||||
private:
|
||||
QString objectName() const;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<std::vector<QString>> m_keywords;
|
||||
caf::PdmProxyValueField<QString> m_objectName;
|
||||
|
||||
caf::PdmPointer<caf::PdmObject> m_object;
|
||||
};
|
||||
@@ -99,7 +99,23 @@ void RimQuickAccessCollection::addQuickAccessField( const RimFieldReference& fie
|
||||
auto field = fieldReference.field();
|
||||
if ( object && field )
|
||||
{
|
||||
if ( auto group = findOrCreateGroup( object, "" ) )
|
||||
QString groupNameForField;
|
||||
|
||||
if ( auto quickInterface = dynamic_cast<RimFieldQuickAccessInterface*>( object ) )
|
||||
{
|
||||
for ( const auto& [qaGroupName, qaFields] : quickInterface->quickAccessFields() )
|
||||
{
|
||||
for ( const auto qaField : qaFields )
|
||||
{
|
||||
if ( qaField == field )
|
||||
{
|
||||
groupNameForField = qaGroupName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( auto group = findOrCreateGroup( object, groupNameForField ) )
|
||||
{
|
||||
group->addField( field );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user