Add pin icon and rename to Pin Field to Quick Access

This commit is contained in:
Magne Sjaastad 2024-10-10 11:40:39 +02:00
parent c56cd59080
commit 5ced7e1d2f
10 changed files with 143 additions and 27 deletions

View File

@ -290,6 +290,7 @@
<file>cloud-and-server.svg</file>
<file>Cloud.svg</file>
<file>CloudBlobs.svg</file>
<file>pin.svg</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="none">
<path stroke="#535358" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M28 11.333L20.667 4l-6.076 6.38a2 2 0 01-1.448.62H9.414c-.89 0-1.337 1.077-.707 1.707l10.586 10.586c.63.63 1.707.184 1.707-.707v-3.729a2 2 0 01.62-1.448L28 11.333zM14 18l-8 8"/>
</svg>

After

Width:  |  Height:  |  Size: 497 B

View File

@ -18,15 +18,12 @@
#include "RicAddFieldToQuickAccessFeature.h"
/*
#include "RiaApplication.h"
#include "RimFieldReference.h"
#include "RimPinnedFieldCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimGridView.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "RiuViewer.h"
#include "RiuViewerCommands.h"
*/
#include "Riu3DMainWindowTools.h"
#include <QAction>
@ -41,6 +38,20 @@ void RicAddFieldToQuickAccessFeature::onActionTriggered( bool isChecked )
if ( objects.empty() ) return;
auto firstObject = objects.front();
RimFieldReference fieldRef;
fieldRef.setObject( firstObject );
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(), &fieldRef, "Select Field", "" );
if ( propertyDialog.exec() == QDialog::Accepted )
{
auto field = fieldRef.field();
if ( field )
{
RimPinnedFieldCollection::instance()->addField( field );
RimPinnedFieldCollection::instance()->updateAllRequiredEditors();
}
}
}
//--------------------------------------------------------------------------------------------------
@ -48,6 +59,6 @@ void RicAddFieldToQuickAccessFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicAddFieldToQuickAccessFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Add Field To Quick Access" );
// actionToSetup->setIcon( QIcon( ":/SummaryEnsemble.svg" ) );
actionToSetup->setText( "Pin Field To Quick Access" );
actionToSetup->setIcon( QIcon( ":/pin.svg" ) );
}

View File

@ -1125,6 +1125,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicPasteAsciiDataCurveFeature";
menuBuilder << "RicPasteSummaryCaseFeature";
menuBuilder.addSeparator();
menuBuilder << "RicAddFieldToQuickAccessFeature";
menuBuilder.addSeparator();
menuBuilder << "RicCopyReferencesToClipboardFeature";
menuBuilder << "RicLinkViewFeature";

View File

@ -31,6 +31,20 @@ RimFieldReference::RimFieldReference()
CAF_PDM_InitFieldNoDefault( &m_fieldName, "FieldName", "FieldName" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFieldReference::setObject( caf::PdmObject* object )
{
m_object = object;
std::vector<QString> fieldNames = RimFieldReference::fieldNames( object );
if ( !fieldNames.empty() )
{
m_fieldName = fieldNames[0];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -38,10 +52,29 @@ void RimFieldReference::setField( caf::PdmFieldHandle* field )
{
if ( !field ) return;
auto ownerObject = field->ownerObject();
auto ownerObject = dynamic_cast<caf::PdmObject*>( field->ownerObject() );
if ( !ownerObject ) return;
setField( field->ownerObject(), field->keyword() );
setField( ownerObject, field->keyword() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RimFieldReference::fieldNames( caf::PdmObject* object )
{
std::vector<QString> names;
if ( object )
{
auto allFields = object->fields();
for ( auto field : allFields )
{
names.push_back( field->keyword() );
}
}
return names;
}
//--------------------------------------------------------------------------------------------------
@ -49,12 +82,44 @@ void RimFieldReference::setField( caf::PdmFieldHandle* field )
//--------------------------------------------------------------------------------------------------
void RimFieldReference::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( field() )
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimFieldReference::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_fieldName )
{
uiOrdering.add( field() );
auto fieldNames = RimFieldReference::fieldNames( m_object );
for ( const auto& name : fieldNames )
{
options.push_back( caf::PdmOptionItemInfo( name, name ) );
}
}
else if ( fieldNeedingOptions == &m_object )
{
if ( m_objectsForSelection.empty() )
{
if ( m_object )
{
QString text = m_object()->uiName();
options.push_back( caf::PdmOptionItemInfo( text, m_object ) );
}
}
else
{
for ( auto obj : m_objectsForSelection )
{
QString text = obj->uiName();
options.push_back( caf::PdmOptionItemInfo( text, obj ) );
}
}
}
uiOrdering.skipRemainingFields();
return options;
}
//--------------------------------------------------------------------------------------------------
@ -70,7 +135,7 @@ caf::PdmFieldHandle* RimFieldReference::field() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimFieldReference::object() const
caf::PdmObject* RimFieldReference::object() const
{
return m_object;
}
@ -78,7 +143,15 @@ caf::PdmObjectHandle* RimFieldReference::object() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFieldReference::setField( caf::PdmObjectHandle* object, const QString& fieldName )
void RimFieldReference::setObjectsForSelection( const std::vector<caf::PdmObject*>& objectsForSelection )
{
m_objectsForSelection = objectsForSelection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFieldReference::setField( caf::PdmObject* object, const QString& fieldName )
{
m_object = object;
m_fieldName = fieldName;

View File

@ -37,17 +37,25 @@ class RimFieldReference : public caf::PdmObject
public:
RimFieldReference();
void setObject( caf::PdmObject* object );
void setField( caf::PdmFieldHandle* field );
caf::PdmFieldHandle* field() const;
caf::PdmObjectHandle* object() const;
caf::PdmObject* object() const;
void setObjectsForSelection( const std::vector<caf::PdmObject*>& objectsForSelection );
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void setField( caf::PdmObjectHandle* object, const QString& fieldName );
void setField( caf::PdmObject* object, const QString& fieldName );
static std::vector<QString> fieldNames( caf::PdmObject* object );
private:
caf::PdmPtrField<caf::PdmObjectHandle*> m_object;
caf::PdmField<QString> m_fieldName;
caf::PdmPtrField<caf::PdmObject*> m_object;
caf::PdmField<QString> m_fieldName;
std::vector<caf::PdmObject*> m_objectsForSelection;
};

View File

@ -131,11 +131,7 @@ void RimPinnedFieldCollection::defineUiOrdering( QString uiConfigName, caf::PdmU
for ( auto fieldRef : fieldRefs )
{
group->add( fieldRef->field() );
}
if ( !fieldRefs.empty() )
{
group->add( fieldRefs.front()->selectObjectButton(), { .newRow = false } );
group->add( fieldRef->selectObjectButton(), { .newRow = false } );
}
}
}

View File

@ -139,6 +139,14 @@ QString RiuDockWidgetTools::mainWindowUndoStackName()
return "dockUndoStack_mainWindow";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuDockWidgetTools::mainWindowQuickAccessName()
{
return "dockQuickAccess_mainWindow";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -147,6 +155,14 @@ QString RiuDockWidgetTools::plotMainWindowPlotManagerName()
return "dockSummaryPlotManager";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuDockWidgetTools::plotWindowQuickAccessName()
{
return "dockQuickAccess_plotWindow";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -383,6 +399,8 @@ QIcon RiuDockWidgetTools::dockIcon( const QString dockWidgetName )
return QIcon( ":/graph.svg" );
else if ( dockWidgetName == plotMainWindowCloudTreeName() )
return QIcon( ":/Cloud.svg" );
else if ( dockWidgetName == plotWindowQuickAccessName() || dockWidgetName == mainWindowQuickAccessName() )
return QIcon( ":/pin.svg" );
return QIcon( ":/view.svg" );
}

View File

@ -58,6 +58,7 @@ public:
static QString mainWindowMessagesName();
static QString mainWindowMohrsCirclePlotName();
static QString mainWindowUndoStackName();
static QString mainWindowQuickAccessName();
static QString mainWindowProjectTreeName();
static QString mainWindowDataSourceTreeName();
@ -74,6 +75,7 @@ public:
static QString plotMainWindowMessagesName();
static QString plotMainWindowUndoStackName();
static QString plotMainWindowPlotManagerName();
static QString plotWindowQuickAccessName();
static QString dockState3DEclipseName();
static QString dockState3DGeoMechName();

View File

@ -822,7 +822,8 @@ void RiuMainWindow::createDockPanels()
}
{
auto dockWidget = RiuDockWidgetTools::createDockWidget( "Quick Access", "Quick Access", dockManager() );
auto dockWidget =
RiuDockWidgetTools::createDockWidget( "Quick Access", RiuDockWidgetTools::mainWindowQuickAccessName(), dockManager() );
m_pinnedFieldView = new caf::PdmUiPropertyView( dockWidget );
dockWidget->setWidget( m_pinnedFieldView );