mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06: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,6 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
|
||||
<defs>
|
||||
<style>.canvas{fill: none; opacity: 0;}.light-blue{fill: #005dba; opacity: 1;}.light-defaultgrey{fill: #212121; opacity: 1;}</style>
|
||||
<style>.canvas{fill: none; opacity: 0;}.light-blue{fill: #005dba; opacity: 1;}.light-defaultgrey{fill: rgb(128, 128, 128); opacity: 1;}</style>
|
||||
</defs>
|
||||
<title>IconLightSelect</title>
|
||||
<g id="canvas" class="canvas">
|
||||
|
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 885 B |
@@ -3,7 +3,7 @@
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
fill="currentColor"
|
||||
fill="rgb(128, 128, 128)"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="pinned-remove.svg"
|
||||
@@ -73,19 +73,19 @@
|
||||
d="M4 2h7v.278c0 .406-.086.778-.258 1.117-.172.339-.42.63-.742.875v2.86c.307.145.583.328.828.546.245.219.456.464.633.735.177.27.31.565.398.882.089.318.136.646.141.985v.5H8V14l-.5 1-.5-1v-3.222H3v-.5c0-.339.047-.664.14-.977.094-.312.227-.607.4-.883A3.404 3.404 0 0 1 5 7.13V4.27a2.561 2.561 0 0 1-.734-.875A2.505 2.505 0 0 1 4 2.278V2zm1.086.778c.042.125.094.232.156.32a1.494 1.494 0 0 0 .461.43L6 3.715v4.102l-.336.117c-.411.146-.76.383-1.047.711C4.331 8.973 4.09 9.573 4 10h7c-.088-.427-.33-1.027-.617-1.355a2.456 2.456 0 0 0-1.047-.71L9 7.816V3.715l.297-.18c.094-.057.177-.122.25-.195a2.28 2.28 0 0 0 .21-.242.968.968 0 0 0 .157-.32H5.086z"
|
||||
id="path1" />
|
||||
<path
|
||||
style="fill:#effafc;fill-opacity:1;stroke:url(#linearGradient2);stroke-width:3.368;stroke-dasharray:none"
|
||||
style="fill:rgb(128, 128, 128);fill-opacity:1;stroke:url(#linearGradient2);stroke-width:3.368;stroke-dasharray:none"
|
||||
d="M 1.8566228,1.6050444 14.828324,13.503263"
|
||||
id="path2" />
|
||||
<path
|
||||
style="fill:url(#linearGradient3);fill-opacity:1;stroke-width:1.8;stroke-dasharray:none"
|
||||
style="fill:rgb(128, 128, 128);fill-opacity:1;stroke-width:1.8;stroke-dasharray:none"
|
||||
d="M 2.9064985,2.1250343 11.763093,11.406636"
|
||||
id="path3" />
|
||||
<path
|
||||
style="fill:#fbf0fb;fill-opacity:1;stroke-width:1.8;stroke-dasharray:none"
|
||||
style="fill:rgb(128, 128, 128);fill-opacity:1;stroke-width:1.8;stroke-dasharray:none"
|
||||
d="M 0.67178503,4.1266795 2.9476282,7.2525363"
|
||||
id="path4" />
|
||||
<path
|
||||
style="fill:#fbf0fb;fill-opacity:1;stroke:#000000;stroke-width:0.926755;stroke-dasharray:none;stroke-opacity:1"
|
||||
style="fill:rgb(128, 128, 128);fill-opacity:1;stroke:#000000;stroke-width:0.926755;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 2.5651472,1.7153576 13.371336,12.802924"
|
||||
id="path5" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
@@ -345,6 +345,16 @@ QMenu::item:selected {
|
||||
color: $textColor;
|
||||
}
|
||||
|
||||
QMenu::icon:checked {
|
||||
background-color: $primaryColor;
|
||||
border: 1px inset $backgroundColor1;
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
bottom: 1px;
|
||||
left: 1px;
|
||||
}
|
||||
|
||||
QLineEdit,
|
||||
QComboBox,
|
||||
QSpinBox,
|
||||
|
@@ -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