Prototype use of uiOrdering

This commit is contained in:
Magne Sjaastad 2024-10-15 15:52:43 +02:00
parent a93ecb3940
commit 90611208c9
6 changed files with 103 additions and 20 deletions

View File

@ -26,11 +26,13 @@
#include "RimEclipsePropertyFilterCollection.h" #include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseResultDefinition.h" #include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimPinnedFieldCollection.h"
#include "RimViewController.h" #include "RimViewController.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "Riu3DMainWindowTools.h"
#include "cvfAssert.h" #include "cvfAssert.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -64,6 +66,8 @@ void RicEclipsePropertyFilterFeatureImpl::addPropertyFilter( RimEclipsePropertyF
propertyFilterCollection->propertyFiltersField().push_back( propertyFilter ); propertyFilterCollection->propertyFiltersField().push_back( propertyFilter );
setDefaults( propertyFilter ); setDefaults( propertyFilter );
RimPinnedFieldCollection::instance()->addQuickAccessFields( propertyFilter );
propertyFilterCollection->reservoirView()->scheduleGeometryRegen( PROPERTY_FILTERED ); propertyFilterCollection->reservoirView()->scheduleGeometryRegen( PROPERTY_FILTERED );
propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw();
@ -82,6 +86,8 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter( RimEclipseProper
propertyFilterCollection->propertyFiltersField().insertAt( static_cast<int>( index ), propertyFilter ); propertyFilterCollection->propertyFiltersField().insertAt( static_cast<int>( index ), propertyFilter );
setDefaults( propertyFilter ); setDefaults( propertyFilter );
RimPinnedFieldCollection::instance()->addQuickAccessFields( propertyFilter );
propertyFilterCollection->reservoirView()->scheduleGeometryRegen( PROPERTY_FILTERED ); propertyFilterCollection->reservoirView()->scheduleGeometryRegen( PROPERTY_FILTERED );
propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw();

View File

@ -247,6 +247,41 @@ void RimEclipsePropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmU
updateRangeLabel(); updateRangeLabel();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmFieldHandle*> RimEclipsePropertyFilter::quickAccessFields()
{
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::quickAccessUiOrdering( caf::PdmUiOrdering& uiOrdering )
{
auto name = "Property Filter : " + m_resultDefinition->resultVariableUiName();
int index = 1;
auto candidate = name;
while ( uiOrdering.findGroup( candidate ) != nullptr )
{
candidate = name + " (" + QString::number( index++ ) + ")";
}
auto group = uiOrdering.addNewGroup( candidate );
group->add( &m_lowerBound );
group->add( &m_upperBound );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilter::hasUiOrdering() const
{
return true;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@
#pragma once #pragma once
#include "RimFieldQuickAccessInterface.h"
#include "RimPropertyFilter.h" #include "RimPropertyFilter.h"
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
@ -31,7 +32,7 @@ class RimEclipseResultDefinition;
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimEclipsePropertyFilter : public RimPropertyFilter class RimEclipsePropertyFilter : public RimPropertyFilter, public RimFieldQuickAccessInterface
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@ -56,6 +57,10 @@ public:
void updateUiFieldsFromActiveResult(); void updateUiFieldsFromActiveResult();
std::vector<caf::PdmFieldHandle*> quickAccessFields() override;
void quickAccessUiOrdering( caf::PdmUiOrdering& uiOrdering ) override;
bool hasUiOrdering() const override;
private: private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;

View File

@ -18,8 +18,18 @@
#pragma once #pragma once
#include <vector>
namespace caf
{
class PdmFieldHandle;
class PdmUiOrdering;
}; // namespace caf
class RimFieldQuickAccessInterface class RimFieldQuickAccessInterface
{ {
public: public:
virtual std::vector<caf::PdmFieldHandle*> quickAccessFields() = 0; virtual std::vector<caf::PdmFieldHandle*> quickAccessFields() = 0;
virtual void quickAccessUiOrdering( caf::PdmUiOrdering& uiOrdering ){};
virtual bool hasUiOrdering() const { return false; };
}; };

View File

@ -36,7 +36,9 @@ RimPinnedFieldCollection::RimPinnedFieldCollection()
{ {
CAF_PDM_InitObject( "Field Reference Collection" ); CAF_PDM_InitObject( "Field Reference Collection" );
CAF_PDM_InitFieldNoDefault( &m_fieldReferences, "Objects", "Objects" ); CAF_PDM_InitFieldNoDefault( &m_fieldReferences, "FieldReferences", "Field References" );
CAF_PDM_InitFieldNoDefault( &m_objectReferences, "ObjectReferences", "Objects With UiOrdering" );
m_objectReferences.uiCapability()->setUiHidden( true );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -56,13 +58,12 @@ RimPinnedFieldCollection* RimPinnedFieldCollection::instance()
void RimPinnedFieldCollection::addQuickAccessFieldsRecursively( caf::PdmObjectHandle* object ) void RimPinnedFieldCollection::addQuickAccessFieldsRecursively( caf::PdmObjectHandle* object )
{ {
if ( object == nullptr ) return; if ( object == nullptr ) return;
addQuickAccessFields( object );
for ( auto field : object->fields() ) for ( auto field : object->fields() )
{ {
if ( !field ) continue; if ( !field ) continue;
addQuickAccessFields( object );
for ( auto childObject : field->children() ) for ( auto childObject : field->children() )
{ {
addQuickAccessFieldsRecursively( childObject ); addQuickAccessFieldsRecursively( childObject );
@ -84,6 +85,11 @@ void RimPinnedFieldCollection::addQuickAccessFields( caf::PdmObjectHandle* objec
{ {
addField( field ); addField( field );
} }
if ( quickInterface->hasUiOrdering() )
{
m_objectReferences.push_back( object );
}
} }
} }
@ -134,6 +140,7 @@ void RimPinnedFieldCollection::defineUiOrdering( QString uiConfigName, caf::PdmU
if ( !activeView ) return; if ( !activeView ) return;
deleteMarkedObjects(); deleteMarkedObjects();
m_objectReferences.removeChild( nullptr );
std::vector<RimFieldQuickAccess*> fieldsForView; std::vector<RimFieldQuickAccess*> fieldsForView;
@ -156,24 +163,42 @@ void RimPinnedFieldCollection::defineUiOrdering( QString uiConfigName, caf::PdmU
} }
} }
if ( fieldsForView.empty() ) return; if ( !fieldsForView.empty() )
QString groupName;
auto uiCapability = activeView->uiCapability();
if ( uiCapability->userDescriptionField() && uiCapability->userDescriptionField()->uiCapability() )
{ {
groupName = uiCapability->userDescriptionField()->uiCapability()->uiValue().toString(); QString groupName;
} auto uiCapability = activeView->uiCapability();
else if ( uiCapability->userDescriptionField() && uiCapability->userDescriptionField()->uiCapability() )
{ {
groupName = "Group "; groupName = uiCapability->userDescriptionField()->uiCapability()->uiValue().toString();
} }
else
{
groupName = "Group ";
}
auto group = uiOrdering.addNewGroup( groupName ); auto group = uiOrdering.addNewGroup( groupName );
for ( auto fieldRef : fieldsForView ) for ( auto fieldRef : fieldsForView )
{ {
fieldRef->uiOrdering( uiConfigName, *group ); fieldRef->uiOrdering( uiConfigName, *group );
}
auto objects = m_objectReferences.ptrReferencedObjectsByType();
for ( auto obj : objects )
{
if ( !obj ) continue;
auto view = obj->firstAncestorOrThisOfType<RimGridView>();
if ( view != activeView ) continue;
if ( auto qaInterface = dynamic_cast<RimFieldQuickAccessInterface*>( obj ) )
{
if ( qaInterface->hasUiOrdering() )
{
qaInterface->quickAccessUiOrdering( *group );
}
}
}
} }
} }

View File

@ -21,6 +21,7 @@
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cafPdmPtrArrayField.h"
class RimFieldQuickAccess; class RimFieldQuickAccess;
@ -50,6 +51,7 @@ private:
private: private:
caf::PdmChildArrayField<RimFieldQuickAccess*> m_fieldReferences; caf::PdmChildArrayField<RimFieldQuickAccess*> m_fieldReferences;
caf::PdmPtrArrayField<caf::PdmObjectHandle*> m_objectReferences;
std::set<RimFieldQuickAccess*> m_toBeDeleted; std::set<RimFieldQuickAccess*> m_toBeDeleted;
}; };