Merge remote-tracking branch 'origin/dev' into grid-geometry-extraction

This commit is contained in:
Jørgen Herje
2024-02-27 12:48:43 +01:00
186 changed files with 3704 additions and 1204 deletions

View File

@@ -29,9 +29,7 @@ CAF_PDM_SOURCE_INIT( RimPolylineTarget, "PolylineTarget" );
///
//--------------------------------------------------------------------------------------------------
RimPolylineTarget::RimPolylineTarget()
: m_isFullUpdateEnabled( true )
{
CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "" );
CAF_PDM_InitFieldNoDefault( &m_targetPointXyd, "TargetPointXyd", "Point" );
}
@@ -42,14 +40,6 @@ RimPolylineTarget::~RimPolylineTarget()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolylineTarget::isEnabled() const
{
return m_isEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -84,14 +74,6 @@ caf::PdmUiFieldHandle* RimPolylineTarget::targetPointUiCapability()
return m_targetPointXyd.uiCapability();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylineTarget::enableFullUpdate( bool enable )
{
m_isFullUpdateEnabled = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -38,14 +38,11 @@ public:
RimPolylineTarget();
~RimPolylineTarget() override;
bool isEnabled() const;
void setAsPointTargetXYD( const cvf::Vec3d& point );
void setAsPointXYZ( const cvf::Vec3d& point );
cvf::Vec3d targetPointXYZ() const;
caf::PdmUiFieldHandle* targetPointUiCapability();
void enableFullUpdate( bool enable );
void triggerVisualizationUpdate() const;
@@ -54,7 +51,5 @@ private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
bool m_isFullUpdateEnabled;
caf::PdmField<bool> m_isEnabled;
caf::PdmField<cvf::Vec3d> m_targetPointXyd;
};

View File

@@ -158,7 +158,7 @@ bool RimPolylinesFromFileAnnotation::isEmpty()
{
if ( m_polyLinesData.isNull() ) return true;
for ( const std::vector<cvf::Vec3d>& line : m_polyLinesData->polyLines() )
for ( const std::vector<cvf::Vec3d>& line : m_polyLinesData->rawPolyLines() )
{
if ( !line.empty() ) return false;
}

View File

@@ -44,8 +44,7 @@ RimReachCircleAnnotation::RimReachCircleAnnotation()
CAF_PDM_InitField( &m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point" );
m_centerPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_centerPointPickEnabled, "AnchorPointPick", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_centerPointPickEnabled );
m_centerPointPickEnabled.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_centerPointPickEnabled );
CAF_PDM_InitField( &m_radius, "Radius", 100.0, "Radius" );
CAF_PDM_InitField( &m_name, "Name", QString( "Circle Annotation" ), "Name" );

View File

@@ -51,14 +51,12 @@ RimTextAnnotation::RimTextAnnotation()
CAF_PDM_InitField( &m_anchorPointXyd, "AnchorPointXyd", Vec3d::ZERO, "Anchor Point" );
m_anchorPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_anchorPointPickEnabledButtonField, "AnchorPointPick", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_anchorPointPickEnabledButtonField );
m_anchorPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_anchorPointPickEnabledButtonField );
CAF_PDM_InitField( &m_labelPointXyd, "LabelPointXyd", Vec3d::ZERO, "Label Point" );
m_labelPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_labelPointPickEnabledButtonField, "LabelPointPick", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_labelPointPickEnabledButtonField );
m_labelPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_labelPointPickEnabledButtonField );
CAF_PDM_InitField( &m_text, "Text", QString( "(New text)" ), "Text" );
m_text.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );

View File

@@ -49,7 +49,7 @@ RimUserDefinedPolylinesAnnotation::RimUserDefinedPolylinesAnnotation()
CAF_PDM_InitField( &m_name, "Name", QString( "User Defined Polyline" ), "Name" );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
@@ -152,31 +152,6 @@ void RimUserDefinedPolylinesAnnotation::deleteTarget( RimPolylineTarget* targetT
delete targetToDelete;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<RimPolylineTarget*, RimPolylineTarget*>
RimUserDefinedPolylinesAnnotation::findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore )
{
RimPolylineTarget* before = nullptr;
RimPolylineTarget* after = nullptr;
bool foundTarget = false;
for ( const auto& wt : m_targets )
{
if ( wt == targetToInsertBefore )
{
foundTarget = true;
}
if ( wt->isEnabled() && !after && foundTarget ) after = wt;
if ( wt->isEnabled() && !foundTarget ) before = wt;
}
return { before, after };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -60,8 +60,6 @@ public:
void appendTarget( const cvf::Vec3d& defaultPos = cvf::Vec3d::ZERO );
std::pair<RimPolylineTarget*, RimPolylineTarget*> findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore );
void enablePicking( bool enable );
protected:

View File

@@ -267,6 +267,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEmCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp
)
if(RESINSIGHT_USE_QT_CHARTS)

View File

@@ -145,6 +145,12 @@ void RimCellFilterCollection::fieldChangedByUi( const caf::PdmFieldHandle* chang
uiCapability()->updateConnectedEditors();
onFilterUpdated( nullptr );
for ( const auto& filter : m_cellFilters )
{
// Update the filters to make sure the 3D polygon targets are removed if the filter collection is disabled
filter->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
@@ -255,12 +261,22 @@ bool RimCellFilterCollection::hasActiveIncludeRangeFilters() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase )
RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon )
{
RimPolygonFilter* pFilter = new RimPolygonFilter();
pFilter->setCase( srcCase );
pFilter->setPolygon( polygon );
addFilter( pFilter );
pFilter->enablePicking( true );
pFilter->configurePolygonEditor();
if ( polygon )
{
pFilter->enableFilter( true );
}
else
{
pFilter->enablePicking( true );
}
onFilterUpdated( pFilter );
return pFilter;
}
@@ -485,3 +501,23 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimCellFilterCollection::enabledCellFilterPolygons() const
{
std::vector<RimPolygonInView*> polyInView;
for ( const auto& filter : m_cellFilters )
{
if ( !filter->isActive() ) continue;
if ( auto polygonFilter = dynamic_cast<RimPolygonFilter*>( filter.p() ) )
{
polyInView.push_back( polygonFilter->polygonInView() );
}
}
return polyInView;
}

View File

@@ -32,6 +32,8 @@ class RimPolygonFilter;
class RimUserDefinedFilter;
class RimUserDefinedIndexFilter;
class RimCase;
class RimPolygonInView;
class RimPolygon;
namespace cvf
{
@@ -52,7 +54,7 @@ public:
caf::Signal<> filtersChanged;
RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase );
RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon );
RimCellRangeFilter* addNewCellRangeFilter( RimCase* srcCase, int gridIndex, int sliceDirection = -1, int defaultSlice = -1 );
RimCellIndexFilter* addNewCellIndexFilter( RimCase* srcCase );
RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase );
@@ -69,7 +71,8 @@ public:
void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const;
void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const;
std::vector<RimCellFilter*> filters() const;
std::vector<RimPolygonInView*> enabledCellFilterPolygons() const;
std::vector<RimCellFilter*> filters() const;
bool hasActiveFilters() const;
bool hasActiveIncludeIndexFilters() const;

View File

@@ -389,7 +389,7 @@ void RimEclipsePropertyFilter::defineObjectEditorAttribute( QString uiConfigName
if ( treeItemAttribute )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/chain.png" );
treeItemAttribute->tags.push_back( std::move( tag ) );

View File

@@ -20,39 +20,29 @@
#include "RigCellGeometryTools.h"
#include "RigEclipseCaseData.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
#include "RigPolyLinesData.h"
#include "RigReservoirGridTools.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimGeoMechCase.h"
#include "RimPolylineTarget.h"
#include "RimTools.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h"
#include "Riu3DMainWindowTools.h"
#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h"
#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h"
#include "RiuViewerCommands.h"
#include "RiaStdStringTools.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include <cafPdmUiDoubleSliderEditor.h>
#include "cvfBoundingBox.h"
#include "cvfStructGrid.h"
#include <QValidator>
#include <limits>
@@ -75,44 +65,24 @@ void caf::AppEnum<RimPolygonFilter::PolygonIncludeType>::setUp()
setDefault( RimPolygonFilter::PolygonIncludeType::CENTER );
}
template <>
void caf::AppEnum<RimPolygonFilter::GeometricalShape>::setUp()
{
addItem( RimPolygonFilter::GeometricalShape::AREA, "AREA", "Area Filter" );
addItem( RimPolygonFilter::GeometricalShape::LINE, "LINE", "Line Filter" );
setDefault( RimPolygonFilter::GeometricalShape::AREA );
}
template <>
void caf::AppEnum<RimPolygonFilter::PolygonDataSource>::setUp()
{
addItem( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER, "DEFINED_IN_FILTER", "Defined in Filter" );
addItem( RimPolygonFilter::PolygonDataSource::GLOBAL_POLYGON, "GLOBAL_POLYGON", "Polygon in Project" );
setDefault( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class ThicknessValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
int val = RiaStdStringTools::toInt( input.toStdString() );
if ( val > 0 && val < 8 )
return State::Acceptable;
else
return State::Invalid;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RadiusValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
double val = RiaStdStringTools::toDouble( input.toStdString() );
if ( val > 0.001 && val <= 2.0 )
return State::Acceptable;
else
return State::Invalid;
}
};
CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" );
//--------------------------------------------------------------------------------------------------
@@ -128,70 +98,44 @@ RimPolygonFilter::RimPolygonFilter()
CAF_PDM_InitFieldNoDefault( &m_polyFilterMode, "PolygonFilterType", "Vertical Filter" );
CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include" );
CAF_PDM_InitFieldNoDefault( &m_polygonDataSource, "PolygonDataSource", "Data Source" );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_geometricalShape, "GeometricalShape", "" );
m_geometricalShape.registerGetMethod( this, &RimPolygonFilter::geometricalShape );
m_geometricalShape.registerSetMethod( this, &RimPolygonFilter::setGeometricalShape );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_targets.uiCapability()->setCustomContextMenuEnabled( true );
CAF_PDM_InitFieldNoDefault( &m_internalPolygon, "InternalPolygon", "Polygon For Filter" );
m_internalPolygon = new RimPolygon;
m_internalPolygon->setName( "Polygon For Filter" );
m_internalPolygon->uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" );
CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" );
CAF_PDM_InitField( &m_closePolygon, "ClosePolygon", true, "Closed Polygon" );
CAF_PDM_InitFieldNoDefault( &m_cellFilterPolygon, "Polygon", "Polygon" );
CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness" );
CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" );
CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::WHITE ), "Line Color" );
CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" );
CAF_PDM_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" );
m_polygonEditor = new RimPolygonInView;
m_polygonEditor->uiCapability()->setUiTreeHidden( true );
m_polygonEditor.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" );
CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" );
CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-20:2", "" );
CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" );
CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" );
CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton );
m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP );
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_OBSOLETE_targets, "Targets", "Targets" );
m_OBSOLETE_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_OBSOLETE_targets.uiCapability()->setUiTreeHidden( true );
m_OBSOLETE_targets.uiCapability()->setUiHidden( true );
m_OBSOLETE_targets.xmlCapability()->setIOWritable( false );
m_propagateToSubGrids = false;
updateIconState();
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFilter::~RimPolygonFilter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateVisualization()
{
updateCells();
filterChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateEditorsAndVisualization()
{
updateConnectedEditors();
updateVisualization();
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
@@ -210,6 +154,18 @@ void RimPolygonFilter::enableKFilter( bool bEnable )
m_enableKFilter = bEnable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::setPolygon( RimPolygon* polygon )
{
if ( polygon )
{
m_polygonDataSource = PolygonDataSource::GLOBAL_POLYGON;
m_cellFilterPolygon = polygon;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -238,32 +194,23 @@ QString RimPolygonFilter::fullName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolylineTarget*> RimPolygonFilter::activeTargets() const
void RimPolygonFilter::initAfterRead()
{
return m_targets.childrenByType();
}
RimCellFilter::initAfterRead();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
{
size_t index = m_targets.indexOf( targetToInsertBefore );
if ( index < m_targets.size() )
m_targets.insert( index, targetToInsert );
else
m_targets.push_back( targetToInsert );
// Move existing polygons to global polygon
if ( !m_OBSOLETE_targets.empty() )
{
std::vector<cvf::Vec3d> points;
for ( const auto& target : m_OBSOLETE_targets )
{
points.push_back( target->targetPointXYZ() );
}
updateCells();
}
m_internalPolygon->setPointsInDomainCoords( points );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete )
{
m_targets.removeChild( targetToDelete );
delete targetToDelete;
configurePolygonEditor();
}
//--------------------------------------------------------------------------------------------------
@@ -271,68 +218,17 @@ void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete )
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_enablePicking )
if ( auto attrib = dynamic_cast<RicPolyline3dEditorAttribute*>( attribute ) )
{
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( pbAttribute )
{
if ( !m_enablePicking )
{
pbAttribute->m_buttonText = "Start Picking Points";
}
else
{
pbAttribute->m_buttonText = "Stop Picking Points";
}
}
attrib->pickEventHandler = m_pickTargetsEventHandler;
attrib->enablePicking = m_polygonEditor->pickingEnabled();
}
else if ( field == &m_targets )
{
auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute );
if ( tvAttribute )
{
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT;
if ( m_enablePicking )
{
tvAttribute->baseColor.setRgb( 255, 220, 255 );
tvAttribute->alwaysEnforceResizePolicy = true;
}
}
}
else if ( field == &m_lineThickness )
if ( field == &m_editPolygonButton )
{
auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( myAttr )
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
myAttr->validator = new ThicknessValidator();
}
}
else if ( field == &m_lineThickness )
{
auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->validator = new RadiusValidator();
}
}
else if ( field == &m_polygonPlaneDepth )
{
auto* attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( attr )
{
if ( m_srcCase )
{
auto bb = m_srcCase->allCellsBoundingBox();
attr->m_minimum = -bb.max().z();
attr->m_maximum = -bb.min().z();
}
else
{
attr->m_minimum = 0;
attr->m_maximum = 10000;
}
attrib->m_buttonText = "Edit";
}
}
}
@@ -340,14 +236,12 @@ void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget )
void RimPolygonFilter::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
caf::CmdFeatureMenuBuilder menuBuilder;
// When interactive edit of polyline coordinates in enabled in RimPolygonInView::m_enablePicking, the editors to RimPolygonFilter must
// be updated to trigger calls to RimPolylinePickerInterface
menuBuilder << "RicDeletePolylineTargetFeature";
menuBuilder << "RicAppendPointsToPolygonFilterFeature";
menuBuilder.appendToMenu( menu );
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -359,34 +253,26 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
auto group = uiOrdering.addNewGroup( "General" );
group->add( &m_filterMode );
group->add( &m_geometricalShape );
group->add( &m_enableFiltering );
group->add( &m_closePolygon );
group->add( &m_polygonDataSource );
if ( !isPolygonDefinedLocally() )
{
group->add( &m_cellFilterPolygon );
group->add( &m_editPolygonButton, { .newRow = false } );
}
auto group1 = uiOrdering.addNewGroup( "Polygon Selection" );
group1->add( &m_polyFilterMode );
if ( m_closePolygon() ) group1->add( &m_polyIncludeType );
group1->add( &m_targets );
group1->add( &m_enablePicking );
bool isPolygonClosed = m_cellFilterPolygon() ? m_cellFilterPolygon->isClosed() : false;
if ( isPolygonClosed )
{
group1->add( &m_polyIncludeType );
}
m_polyIncludeType.uiCapability()->setUiName( "Cells to " + modeString() );
auto group2 = uiOrdering.addNewGroup( "Appearance" );
group2->add( &m_showLines );
group2->add( &m_showSpheres );
if ( m_showLines )
{
group2->add( &m_lineThickness );
group2->add( &m_lineColor );
}
if ( m_showSpheres )
{
group2->add( &m_sphereRadiusFactor );
group2->add( &m_sphereColor );
}
group2->add( &m_lockPolygonToPlane );
if ( m_lockPolygonToPlane ) group2->add( &m_polygonPlaneDepth );
group2->setCollapsedByDefault();
auto group3 = uiOrdering.addNewGroup( "Advanced Filter Settings" );
group3->add( &m_enableKFilter );
group3->add( &m_kFilterStr );
@@ -402,7 +288,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
objField->uiCapability()->setUiReadOnly( readOnlyState );
}
if ( !m_closePolygon() )
if ( !isPolygonClosed )
{
m_polyFilterMode = RimPolygonFilter::PolygonFilterModeType::INDEX_K;
m_polyFilterMode.uiCapability()->setUiReadOnly( true );
@@ -411,6 +297,30 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
m_polyFilterMode.uiCapability()->setUiReadOnly( readOnlyState );
}
if ( isPolygonDefinedLocally() )
{
caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" );
m_polygonEditor()->uiOrderingForLocalPolygon( uiConfigName, *polyDefinitionGroup );
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
appearanceGroup->setCollapsedByDefault();
m_internalPolygon->uiOrderingForLocalPolygon( uiConfigName, *appearanceGroup );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimPolygonFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_cellFilterPolygon )
{
RimTools::polygonOptionItems( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
@@ -418,20 +328,39 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_enablePicking )
if ( changedField == &m_editPolygonButton )
{
updateConnectedEditors();
RimPolygonTools::selectAndActivatePolygonInView( m_cellFilterPolygon(), this );
enableFilter( !m_enablePicking() );
filterChanged.send();
m_editPolygonButton = false;
return;
}
else if ( ( changedField == &m_showLines ) || ( changedField == &m_showSpheres ) || ( changedField == &m_sphereColor ) ||
( changedField == &m_sphereRadiusFactor ) || ( changedField == &m_lineThickness ) || ( changedField == &m_lineColor ) ||
( changedField == &m_lockPolygonToPlane ) || ( changedField == &m_polygonPlaneDepth ) )
if ( changedField == &m_polygonDataSource )
{
filterChanged.send();
if ( !isPolygonDefinedLocally() )
{
if ( m_cellFilterPolygon() == nullptr || m_cellFilterPolygon() == m_internalPolygon )
{
auto polygonCollection = RimTools::polygonCollection();
if ( polygonCollection && !polygonCollection->allPolygons().empty() )
{
m_cellFilterPolygon = polygonCollection->allPolygons().front();
}
}
}
configurePolygonEditor();
updateAllRequiredEditors();
}
else if ( changedField != &m_name )
if ( changedField == &m_cellFilterPolygon )
{
configurePolygonEditor();
updateAllRequiredEditors();
}
if ( changedField != &m_name )
{
updateCells();
filterChanged.send();
@@ -444,26 +373,10 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::enablePicking( bool enable )
{
m_enablePicking = enable;
m_polygonEditor->enablePicking( enable );
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::pickingEnabled() const
{
return m_enablePicking();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const
{
return m_pickTargetsEventHandler.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -583,7 +496,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
const int gIdx = static_cast<int>( grid->gridIndex() );
std::list<size_t> foundCells;
const bool closedPolygon = m_closePolygon();
const bool closedPolygon = isPolygonClosed();
// find all cells in the K layer that matches the polygon
#pragma omp parallel for
@@ -591,8 +504,8 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
{
for ( size_t j = 0; j < grid->cellCountJ(); j++ )
{
size_t cellIdx = grid->cellIndexFromIJK( i, j, K );
RigCell cell = grid->cell( cellIdx );
size_t cellIdx = grid->cellIndexFromIJK( i, j, K );
const RigCell& cell = grid->cell( cellIdx );
// valid cell?
if ( cell.isInvalid() ) continue;
@@ -634,7 +547,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
// get the cell index
size_t newIdx = grid->cellIndexFromIJK( ci, cj, k );
// valid cell?
RigCell cell = grid->cell( newIdx );
const RigCell& cell = grid->cell( newIdx );
if ( cell.isInvalid() ) continue;
m_cells[gIdx].push_back( newIdx );
@@ -652,7 +565,7 @@ void RimPolygonFilter::updateCellsForEclipse( const std::vector<cvf::Vec3d>& poi
if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z )
{
if ( !m_closePolygon() ) return;
if ( !isPolygonClosed() ) return;
for ( size_t gridIndex = 0; gridIndex < data->gridCount(); gridIndex++ )
{
@@ -720,7 +633,7 @@ void RimPolygonFilter::updateCellsDepthGeoMech( const std::vector<cvf::Vec3d>& p
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector<cvf::Vec3d>& points, const RigFemPartGrid* grid, int partId )
{
const bool closedPolygon = m_closePolygon();
const bool closedPolygon = isPolygonClosed();
// we need to find the K layer we hit with the first point
size_t nk;
@@ -839,7 +752,7 @@ void RimPolygonFilter::updateCellsForGeoMech( const std::vector<cvf::Vec3d>& poi
if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z )
{
if ( m_closePolygon() )
if ( isPolygonClosed() )
{
updateCellsDepthGeoMech( points, grid, i );
}
@@ -865,16 +778,17 @@ void RimPolygonFilter::updateCells()
// get polyline as vector
std::vector<cvf::Vec3d> points;
for ( auto& target : m_targets )
if ( m_polygonEditor && m_polygonEditor->polygon() )
{
if ( target->isEnabled() ) points.push_back( target->targetPointXYZ() );
points = m_polygonEditor->polygon()->pointsInDomainCoords();
}
// We need at least three points to make a closed polygon, or just 2 for a polyline
if ( ( !m_closePolygon() && ( points.size() < 2 ) ) || ( m_closePolygon() && ( points.size() < 3 ) ) ) return;
if ( ( !isPolygonClosed() && ( points.size() < 2 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return;
// make sure first and last point is the same (req. by closed polygon methods used later)
if ( m_closePolygon() ) points.push_back( points.front() );
if ( isPolygonClosed() ) points.push_back( points.front() );
RimEclipseCase* eCase = eclipseCase();
RimGeoMechCase* gCase = geoMechCase();
@@ -892,30 +806,119 @@ void RimPolygonFilter::updateCells()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolygonFilter::polyLinesData() const
void RimPolygonFilter::configurePolygonEditor()
{
cvf::ref<RigPolyLinesData> pld = new RigPolyLinesData;
std::vector<cvf::Vec3d> line;
for ( const RimPolylineTarget* target : m_targets )
{
if ( target->isEnabled() ) line.push_back( target->targetPointXYZ() );
}
pld->setPolyLine( line );
RimPolygon* polygon = nullptr;
if ( isPolygonDefinedLocally() )
polygon = m_internalPolygon();
else
polygon = m_cellFilterPolygon();
pld->setLineAppearance( m_lineThickness, m_lineColor, m_closePolygon );
pld->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor );
pld->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth );
m_polygonEditor->setPolygon( polygon );
if ( isActive() )
// Must connect the signals after polygon is assigned to the polygon editor
// When assigning an object to a ptr field, all signals are disconnected
connectObjectSignals( polygon );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInView* RimPolygonFilter::polygonInView() const
{
return m_polygonEditor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
{
m_polygonEditor->insertTarget( targetToInsertBefore, targetToInsert );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete )
{
m_polygonEditor->deleteTarget( targetToDelete );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateEditorsAndVisualization()
{
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateVisualization()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolylineTarget*> RimPolygonFilter::activeTargets() const
{
return m_polygonEditor->activeTargets();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::pickingEnabled() const
{
return m_polygonEditor->pickingEnabled();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const
{
auto filterColl = firstAncestorOfType<RimCellFilterCollection>();
if ( filterColl && !filterColl->isActive() ) return nullptr;
if ( !isActive() ) return nullptr;
return m_pickTargetsEventHandler.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::AppEnum<RimPolygonFilter::GeometricalShape> RimPolygonFilter::geometricalShape() const
{
if ( isPolygonDefinedLocally() )
{
pld->setVisibility( m_showLines, m_showSpheres );
if ( !m_internalPolygon->isClosed() ) return GeometricalShape::LINE;
}
else
{
pld->setVisibility( false, false );
if ( m_cellFilterPolygon && !m_cellFilterPolygon->isClosed() ) return GeometricalShape::LINE;
}
return pld;
return GeometricalShape::AREA;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::setGeometricalShape( const caf::AppEnum<GeometricalShape>& shape )
{
if ( isPolygonDefinedLocally() )
{
m_internalPolygon->setIsClosed( shape == GeometricalShape::AREA );
}
else if ( m_cellFilterPolygon() )
{
m_cellFilterPolygon->setIsClosed( shape == GeometricalShape::AREA );
}
}
//--------------------------------------------------------------------------------------------------
@@ -932,6 +935,53 @@ void RimPolygonFilter::initializeCellList()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::isPolygonClosed() const
{
if ( isPolygonDefinedLocally() ) return m_internalPolygon->isClosed();
if ( m_cellFilterPolygon() ) return m_cellFilterPolygon->isClosed();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::isPolygonDefinedLocally() const
{
return m_polygonDataSource() == PolygonDataSource::DEFINED_IN_FILTER;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::connectObjectSignals( RimPolygon* polygon )
{
if ( m_cellFilterPolygon() )
{
m_cellFilterPolygon()->objectChanged.disconnect( this );
}
if ( polygon )
{
m_cellFilterPolygon = polygon;
polygon->objectChanged.connect( this, &RimPolygonFilter::onObjectChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::onObjectChanged( const caf::SignalEmitter* emitter )
{
updateCells();
filterChanged.send();
updateIconState();
}
//--------------------------------------------------------------------------------------------------
/// Find which K layer we hit, in any of the grids, for any of the selected points
//--------------------------------------------------------------------------------------------------

View File

@@ -21,42 +21,42 @@
#include "RimCellFilter.h"
#include "RimCellFilterIntervalTool.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylinesDataInterface.h"
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmChildField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cafPickEventHandler.h"
#include "cvfColor3.h"
#include <list>
#include <memory>
class RicPolylineTargetsPickEventHandler;
class RimPolygon;
class RimPolylineTarget;
class RimCase;
class RimEclipseCase;
class RimGeoMechCase;
class RigGridBase;
class RigMainGrid;
class RigFemPartGrid;
class RigPolylinesData;
class RimPolygonInView;
class RigEclipseCaseData;
class RicPolylineTargetsPickEventHandler;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface, public RimPolylinesDataInterface
class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface
{
CAF_PDM_HEADER_INIT;
public:
enum class PolygonDataSource
{
DEFINED_IN_FILTER,
GLOBAL_POLYGON
};
enum class GeometricalShape
{
AREA,
LINE
};
enum class PolygonFilterModeType
{
DEPTH_Z,
@@ -71,38 +71,32 @@ public:
};
RimPolygonFilter();
~RimPolygonFilter() override;
void enableFilter( bool bEnable );
void enableKFilter( bool bEnable );
void setPolygon( RimPolygon* polygon );
bool isFilterEnabled() const override;
void updateVisualization() override;
void updateEditorsAndVisualization() override;
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void enablePicking( bool enable );
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override;
void onGridChanged() override;
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void configurePolygonEditor();
RimPolygonInView* polygonInView() const;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void initAfterRead() override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
QString fullName() const override;
private:
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void updateCells();
void updateCellsForEclipse( const std::vector<cvf::Vec3d>& points, RimEclipseCase* eCase );
void updateCellsForGeoMech( const std::vector<cvf::Vec3d>& points, RimGeoMechCase* gCase );
@@ -118,26 +112,45 @@ private:
void initializeCellList();
caf::PdmField<bool> m_enablePicking;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
caf::PdmField<caf::AppEnum<PolygonFilterModeType>> m_polyFilterMode;
caf::PdmField<caf::AppEnum<PolygonIncludeType>> m_polyIncludeType;
caf::PdmField<bool> m_enableFiltering;
caf::PdmField<bool> m_showLines;
caf::PdmField<bool> m_showSpheres;
caf::PdmField<int> m_lineThickness;
caf::PdmField<double> m_sphereRadiusFactor;
caf::PdmField<cvf::Color3f> m_lineColor;
caf::PdmField<cvf::Color3f> m_sphereColor;
caf::PdmField<double> m_polygonPlaneDepth;
caf::PdmField<bool> m_lockPolygonToPlane;
caf::PdmField<bool> m_enableKFilter;
caf::PdmField<QString> m_kFilterStr;
caf::PdmField<bool> m_closePolygon;
bool isPolygonClosed() const;
bool isPolygonDefinedLocally() const;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
void connectObjectSignals( RimPolygon* polygon );
void onObjectChanged( const caf::SignalEmitter* emitter );
// RimPolylinePickerInterface used to forward events to m_polygonEditor
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void updateEditorsAndVisualization() override;
void updateVisualization() override;
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
caf::AppEnum<GeometricalShape> geometricalShape() const;
void setGeometricalShape( const caf::AppEnum<GeometricalShape>& shape );
private:
caf::PdmField<caf::AppEnum<PolygonFilterModeType>> m_polyFilterMode;
caf::PdmField<caf::AppEnum<PolygonIncludeType>> m_polyIncludeType;
caf::PdmField<caf::AppEnum<PolygonDataSource>> m_polygonDataSource;
caf::PdmProxyValueField<caf::AppEnum<GeometricalShape>> m_geometricalShape;
caf::PdmField<bool> m_enableFiltering;
caf::PdmField<bool> m_enableKFilter;
caf::PdmField<QString> m_kFilterStr;
std::vector<std::vector<size_t>> m_cells;
RimCellFilterIntervalTool m_intervalTool;
// Local polygon and polygon editor
caf::PdmPtrField<RimPolygon*> m_cellFilterPolygon;
caf::PdmChildField<RimPolygon*> m_internalPolygon;
caf::PdmChildField<RimPolygonInView*> m_polygonEditor;
caf::PdmField<bool> m_editPolygonButton;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
caf::PdmChildArrayField<RimPolylineTarget*> m_OBSOLETE_targets;
};

View File

@@ -210,9 +210,7 @@ RimFractureTemplate::RimFractureTemplate()
"" );
CAF_PDM_InitField( &m_scaleApplyButton, "ScaleApplyButton", false, "Apply" );
m_scaleApplyButton.xmlCapability()->disableIO();
m_scaleApplyButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_scaleApplyButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_scaleApplyButton );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -66,8 +66,7 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
m_dataSources.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress );
m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonSelectSummaryAddress );
m_pushButtonSelectSummaryAddress = false;
CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" );

View File

@@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimFaultReactivationDataAccessorTemperature.h"
#include "RigFaultReactivationModel.h"
#include "RimFaultReactivationEnums.h"
#include "RiaDefines.h"
@@ -74,10 +75,55 @@ void RimFaultReactivationDataAccessorTemperature::updateResultAccessor()
m_resultAccessor =
RigResultAccessorFactory::createFromResultAddress( m_caseData, 0, RiaDefines::PorosityModelType::MATRIX_MODEL, m_timeStep, resVarAddress );
auto [wellPaths, extractors] =
RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth );
m_wellPaths = wellPaths;
m_extractors = extractors;
if ( m_resultAccessor.notNull() )
{
auto [wellPaths, extractors] =
RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth );
m_wellPaths = wellPaths;
m_extractors = extractors;
m_gradient = computeGradient();
}
}
//--------------------------------------------------------------------------------------------------
/// Find the top encounter with reservoir (of the two well paths), and create gradient from that point
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationDataAccessorTemperature::computeGradient() const
{
double gradient = std::numeric_limits<double>::infinity();
double minDepth = -std::numeric_limits<double>::max();
for ( auto gridPart : m_model->allGridParts() )
{
auto extractor = m_extractors.find( gridPart )->second;
auto wellPath = m_wellPaths.find( gridPart )->second;
auto [values, intersections] =
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath );
int lastOverburdenIndex = RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( values );
if ( lastOverburdenIndex != -1 )
{
double depth = intersections[lastOverburdenIndex].z();
double value = values[lastOverburdenIndex];
if ( !std::isinf( value ) )
{
double currentGradient =
RimFaultReactivationDataAccessorWellLogExtraction::computeGradient( intersections[0].z(),
m_seabedTemperature,
intersections[lastOverburdenIndex].z(),
values[lastOverburdenIndex] );
if ( !std::isinf( value ) && !std::isnan( currentGradient ) && depth > minDepth )
{
gradient = currentGradient;
minDepth = depth;
}
}
}
}
return gradient;
}
//--------------------------------------------------------------------------------------------------
@@ -100,6 +146,13 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::
{
if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() )
{
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
{
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
}
CAF_ASSERT( m_extractors.find( gridPart ) != m_extractors.end() );
auto extractor = m_extractors.find( gridPart )->second;
@@ -110,16 +163,7 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath );
auto [value, pos] =
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, values, position, m_seabedTemperature );
if ( pos.isUndefined() )
{
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
{
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
}
}
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, position, m_seabedTemperature, m_gradient );
return value;
}

View File

@@ -51,13 +51,15 @@ public:
size_t elementIndex = std::numeric_limits<size_t>::max() ) const override;
private:
void updateResultAccessor() override;
void updateResultAccessor() override;
double computeGradient() const;
RimEclipseCase* m_eclipseCase;
RigEclipseCaseData* m_caseData;
const RigMainGrid* m_mainGrid;
double m_seabedTemperature;
double m_seabedDepth;
double m_gradient;
cvf::ref<RigResultAccessor> m_resultAccessor;

View File

@@ -96,23 +96,11 @@ std::pair<double, cvf::Vec3d> RimFaultReactivationDataAccessorWellLogExtraction:
//--------------------------------------------------------------------------------------------------
std::pair<double, cvf::Vec3d>
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( const std::vector<cvf::Vec3d>& intersections,
std::vector<double>& values,
const cvf::Vec3d& position,
double seabedTemperature )
double seabedTemperature,
double gradient )
{
// Fill in missing values
fillInMissingValuesWithTopValue( intersections, values, seabedTemperature );
auto [value, extractionPosition] = findValueAndPosition( intersections, values, position );
double minDistance = computeMinimumDistance( position, intersections );
if ( minDistance < 1.0 )
{
return { value, extractionPosition };
}
else
{
return { value, cvf::Vec3d::UNDEFINED };
}
return { calculateTemperature( seabedTemperature, intersections[0].z(), std::abs( position.z() ), gradient ), position };
}
//--------------------------------------------------------------------------------------------------
@@ -182,16 +170,6 @@ std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findInter
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findOverburdenAndUnderburdenIndex( const std::vector<double>& values )
{
auto findLastOverburdenIndex = []( const std::vector<double>& values )
{
for ( size_t i = 0; i < values.size(); i++ )
{
if ( !std::isinf( values[i] ) ) return static_cast<int>( i );
}
return -1;
};
auto findFirstUnderburdenIndex = []( const std::vector<double>& values )
{
for ( size_t i = values.size() - 1; i > 0; i-- )
@@ -207,6 +185,19 @@ std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findOverb
return { lastOverburdenIndex, firstUnderburdenIndex };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( const std::vector<double>& values )
{
for ( size_t i = 0; i < values.size(); i++ )
{
if ( !std::isinf( values[i] ) ) return static_cast<int>( i );
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -481,3 +472,12 @@ double RimFaultReactivationDataAccessorWellLogExtraction::calculatePorePressure(
{
return RiaEclipseUnitTools::pascalToBar( gradient * 9.81 * depth * 1000.0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( double topValue, double topDepth, double depth, double gradient )
{
double tvdDiff = topDepth - depth;
return tvdDiff * gradient + topValue;
}

View File

@@ -51,9 +51,9 @@ public:
double gradient );
static std::pair<double, cvf::Vec3d> calculateTemperature( const std::vector<cvf::Vec3d>& intersections,
std::vector<double>& values,
const cvf::Vec3d& position,
double seabedTemperature );
double seabedTemperature,
double gradient );
static std::pair<std::map<RimFaultReactivation::GridPart, cvf::ref<RigWellPath>>,
std::map<RimFaultReactivation::GridPart, cvf::ref<RigEclipseWellLogExtractor>>>
createEclipseWellPathExtractors( const RigFaultReactivationModel& model, RigEclipseCaseData& eclipseCaseData, double seabedDepth );
@@ -76,6 +76,10 @@ public:
const cvf::Vec3d& point,
const std::map<RimFaultReactivation::ElementSets, std::vector<unsigned int>>& elementSets );
static int findLastOverburdenIndex( const std::vector<double>& values );
static double computeGradient( double depth1, double value1, double depth2, double value2 );
protected:
static std::pair<int, int> findOverburdenAndUnderburdenIndex( const std::vector<double>& values );
static double computeValueWithGradient( const std::vector<cvf::Vec3d>& intersections,
@@ -89,7 +93,6 @@ protected:
static std::pair<double, cvf::Vec3d>
findValueAndPosition( const std::vector<cvf::Vec3d>& intersections, const std::vector<double>& values, const cvf::Vec3d& position );
static double computeGradient( double depth1, double value1, double depth2, double value2 );
static std::vector<double> extractDepthValues( const std::vector<cvf::Vec3d>& intersections );
static void insertUnderburdenValues( const std::vector<cvf::Vec3d>& intersections,
@@ -103,4 +106,5 @@ protected:
static double computeMinimumDistance( const cvf::Vec3d& position, const std::vector<cvf::Vec3d>& positions );
static double calculatePorePressure( double depth, double gradient );
static double calculateTemperature( double topValue, double topDepth, double depth, double gradient );
};

View File

@@ -99,8 +99,6 @@ RimFaultReactivationModel::RimFaultReactivationModel()
CAF_PDM_InitField( &m_faultZoneCells, "FaultZoneCells", 0, "Fault Zone Width [cells]" );
CAF_PDM_InitField( &m_showModelPlane, "ShowModelPlane", true, "Show 2D Model" );
CAF_PDM_InitField( &m_flipNodeOrderFW, "FlipNodeOrderFW", false, "FW: Flip Node Order" );
CAF_PDM_InitField( &m_flipNodeOrderHW, "FlipNodeOrderHW", false, "HW: Flip Node Order" );
CAF_PDM_InitFieldNoDefault( &m_fault, "Fault", "Fault" );
m_fault.uiCapability()->setUiReadOnly( true );
@@ -344,7 +342,6 @@ void RimFaultReactivationModel::updateVisualization()
m_2Dmodel->setGenerator( generator );
m_2Dmodel->updateGeometry( m_startCellIndex, (cvf::StructGridInterface::FaceType)m_startCellFace() );
m_2Dmodel->postProcessElementSets( eclipseCase() );
m_2Dmodel->flipNodeOrder( m_flipNodeOrderFW, m_flipNodeOrderHW );
view->scheduleCreateDisplayModelAndRedraw();
}
@@ -475,9 +472,6 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm
gridModelGrp->add( &m_modelThickness );
gridModelGrp->add( &m_flipNodeOrderFW );
gridModelGrp->add( &m_flipNodeOrderHW );
auto appModelGrp = modelGrp->addNewGroup( "Appearance" );
appModelGrp->setCollapsedByDefault();
appModelGrp->add( &m_modelPart1Color );
@@ -741,9 +735,9 @@ std::string RimFaultReactivationModel::baseFilePath() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<double, 3> RimFaultReactivationModel::materialParameters( ElementSets elementSet ) const
std::array<double, 4> RimFaultReactivationModel::materialParameters( ElementSets elementSet ) const
{
std::array<double, 3> retVal = { 0.0, 0.0, 0.0 };
std::array<double, 4> retVal = { 0.0, 0.0, 0.0, 0.0 };
static std::map<ElementSets, std::string> groupMap = { { ElementSets::OverBurden, "material_overburden" },
{ ElementSets::Reservoir, "material_reservoir" },
{ ElementSets::IntraReservoir, "material_intrareservoir" },
@@ -759,6 +753,7 @@ std::array<double, 3> RimFaultReactivationModel::materialParameters( ElementSets
retVal[0] = grp->parameterDoubleValue( "youngs_modulus", 0.0 );
retVal[1] = grp->parameterDoubleValue( "poissons_number", 0.0 );
retVal[2] = grp->parameterDoubleValue( "density", 0.0 );
retVal[3] = grp->parameterDoubleValue( "expansion", 0.0 );
break;
}

View File

@@ -107,7 +107,7 @@ public:
std::vector<QDateTime> selectedTimeSteps() const;
std::vector<size_t> selectedTimeStepIndexes() const;
std::array<double, 3> materialParameters( ElementSets elementSet ) const;
std::array<double, 4> materialParameters( ElementSets elementSet ) const;
QStringList commandParameters() const;
@@ -162,8 +162,6 @@ private:
caf::PdmField<cvf::Color3f> m_modelPart2Color;
caf::PdmField<bool> m_showModelPlane;
caf::PdmField<bool> m_flipNodeOrderFW;
caf::PdmField<bool> m_flipNodeOrderHW;
caf::PdmField<double> m_modelExtentFromAnchor;
caf::PdmField<double> m_modelMinZ;

View File

@@ -78,7 +78,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
m_selectedTimeSteps.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_selectedTimeStepsUi, "SelectedTimeStepsUi", "" );
CAF_PDM_InitFieldNoDefault( &m_applyTimeSteps, "ApplyTimeSteps", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeSteps );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeSteps );
CAF_PDM_InitField( &m_maxPvFraction,
"CellPVThreshold",
@@ -97,7 +97,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
CAF_PDM_InitField( &m_tracerFilter, "TracerFilter", QString(), "Tracer Filter" );
CAF_PDM_InitFieldNoDefault( &m_selectedTracerNames, "SelectedTracerNames", " " );
CAF_PDM_InitFieldNoDefault( &m_showRegion, "ShowRegion", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_showRegion );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_showRegion );
CAF_PDM_InitField( &m_minCommunication, "MinCommunication", 0.0, "Min Communication" );
CAF_PDM_InitField( &m_maxTof, "MaxTof", 146000, "Max Time of Flight [days]" );

View File

@@ -116,7 +116,7 @@ RimWellAllocationOverTimePlot::RimWellAllocationOverTimePlot()
CAF_PDM_InitFieldNoDefault( &m_excludeTimeSteps, "ExcludeTimeSteps", "" );
m_excludeTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_applyTimeStepSelections, "ApplyTimeStepSelections", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeStepSelections );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeStepSelections );
CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Plot Type" );
CAF_PDM_InitFieldNoDefault( &m_flowValueType, "FlowValueType", "Value Type" );

View File

@@ -157,7 +157,7 @@ RimWellConnectivityTable::RimWellConnectivityTable()
CAF_PDM_InitFieldNoDefault( &m_excludeTimeSteps, "ExcludeTimeSteps", "" );
m_excludeTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_applyTimeStepSelections, "ApplyTimeStepSelections", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeStepSelections );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeStepSelections );
// Producer/Injector tracer configuration
CAF_PDM_InitFieldNoDefault( &m_selectedProducerTracersUiField, "SelectedProducerTracers", "Producer Tracers" );
@@ -169,7 +169,7 @@ RimWellConnectivityTable::RimWellConnectivityTable()
CAF_PDM_InitField( &m_syncSelectedProducersFromInjectorSelection, "SyncSelectedInjProd", false, "<- Synch Communicators" );
m_syncSelectedProducersFromInjectorSelection.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_applySelectedInectorProducerTracers, "ApplySelectedInectorProducerTracers", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applySelectedInectorProducerTracers );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applySelectedInectorProducerTracers );
// Table settings
CAF_PDM_InitField( &m_showValueLabels, "ShowValueLabels", false, "Show Value Labels" );

View File

@@ -116,13 +116,13 @@ RimGeoMechCase::RimGeoMechCase()
m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_importElementPropertyFileCommand, "importElementPropertyFileCommad", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_importElementPropertyFileCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_importElementPropertyFileCommand );
CAF_PDM_InitField( &m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_closeElementPropertyFileCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_closeElementPropertyFileCommand );
CAF_PDM_InitField( &m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_reloadElementPropertyFileCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_reloadElementPropertyFileCommand );
caf::AppEnum<BiotCoefficientType> defaultBiotCoefficientType = RimGeoMechCase::BiotCoefficientType::BIOT_NONE;
CAF_PDM_InitField( &m_biotCoefficientType, "BiotCoefficientType", defaultBiotCoefficientType, "Biot Coefficient" );

View File

@@ -74,7 +74,7 @@ RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult()
CAF_PDM_InitField( &m_distanceFromFault, "DistanceFromFault", 5.0, "Distance From Fault" );
CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationPlot, "CreateReactivationPlot", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationPlot );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_createFaultReactivationPlot );
CAF_PDM_InitFieldNoDefault( &m_faultNormal, "FaultNormal", "" );
CAF_PDM_InitFieldNoDefault( &m_faultTopPosition, "FaultTopPosition", "" );

View File

@@ -19,6 +19,7 @@
#include "RimGeoMechView.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaRegressionTestRunner.h"
@@ -31,6 +32,7 @@
#include "RigFormationNames.h"
#include "RigGeoMechCaseData.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseResultDefinition.h"
@@ -153,7 +155,7 @@ void RimGeoMechView::onLoadDataAndUpdate()
onUpdateScaleTransform();
updateSurfacesInViewTreeItems();
updateViewTreeItems( RiaDefines::ItemIn3dView::ALL );
if ( m_geomechCase )
{
@@ -319,6 +321,9 @@ void RimGeoMechView::onCreateDisplayModel()
m_seismicSectionCollection->appendPartsToModel( this, m_seismicVizModel.p(), transform.p(), femBBox );
nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() );
// Polygons
appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() );
// Surfaces
m_surfaceVizModel->removeAllParts();
@@ -1043,6 +1048,11 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() );
if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() );
if ( RiaApplication::enableDevelopmentFeatures() )
{
uiTreeOrdering.add( m_polygonInViewCollection );
}
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@@ -91,7 +91,7 @@ RimBoxIntersection::RimBoxIntersection()
CAF_PDM_InitField( &m_depthSliderStepSize, "DepthSliderStepSize", 0.5, "Depth Slider Step Size" );
CAF_PDM_InitFieldNoDefault( &m_show3DManipulator, "show3DManipulator", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_show3DManipulator );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_show3DManipulator );
m_show3DManipulator = false;
setDeletable( true );

View File

@@ -21,23 +21,20 @@
#include "RiaVec3Tools.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigPolyLinesData.h"
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigWellPath.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonTools.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEnsembleSurface.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h"
#include "RimSurface.h"
@@ -48,12 +45,8 @@
#include "RimTools.h"
#include "RimWellPath.h"
#include "RiuViewer.h"
#include "RivExtrudedCurveIntersectionPartMgr.h"
#include "cafCmdFeature.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapabilityCvfVec3d.h"
#include "cafPdmObjectScriptingCapability.h"
@@ -61,12 +54,9 @@
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiSliderEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include "cvfBoundingBox.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
namespace caf
{
@@ -77,6 +67,7 @@ void caf::AppEnum<RimExtrudedCurveIntersection::CrossSectionEnum>::setUp()
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE, "CS_POLYLINE", "Polyline" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE, "CS_AZIMUTHLINE", "Azimuth and Dip" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON, "CS_POLYGON", "Project Polygon" );
setDefault( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE );
}
@@ -186,6 +177,17 @@ void RimExtrudedCurveIntersection::configureForPolyLine()
m_inputPolylineFromViewerEnabled = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::configureForProjectPolyLine( RimPolygon* polygon )
{
m_type = CrossSectionEnum::CS_POLYGON;
m_projectPolygon = polygon;
updateName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -207,6 +209,11 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
CAF_PDM_InitFieldNoDefault( &m_direction, "Direction", "Direction" );
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "Well Path " );
CAF_PDM_InitScriptableFieldNoDefault( &m_simulationWell, "SimulationWell", "Simulation Well" );
CAF_PDM_InitFieldNoDefault( &m_projectPolygon, "ProjectPolygon", "Project Polygon" );
CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton );
CAF_PDM_InitScriptableFieldNoDefault( &m_userPolylineXyz, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" );
CAF_PDM_InitFieldNoDefault( &m_userPolylineXydForUi, "PointsUi", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" );
@@ -233,15 +240,15 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down" );
CAF_PDM_InitFieldNoDefault( &m_inputPolylineFromViewerEnabled, "m_activateUiAppendPointsCommand", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputPolylineFromViewerEnabled );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputPolylineFromViewerEnabled );
m_inputPolylineFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_inputExtrusionPointsFromViewerEnabled, "inputExtrusionPointsFromViewerEnabled", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputExtrusionPointsFromViewerEnabled );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputExtrusionPointsFromViewerEnabled );
m_inputExtrusionPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_inputTwoAzimuthPointsFromViewerEnabled, "inputTwoAzimuthPointsFromViewerEnabled", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputTwoAzimuthPointsFromViewerEnabled );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputTwoAzimuthPointsFromViewerEnabled );
m_inputTwoAzimuthPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_surfaceIntersections, "SurfaceIntersections", "Surface Intersections" );
@@ -439,11 +446,11 @@ void RimExtrudedCurveIntersection::setKFilterOverride( bool collectionOverride,
void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_isActive || changedField == &m_type || changedField == &m_direction || changedField == &m_wellPath ||
changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength ||
changedField == &m_lengthUp || changedField == &m_lengthDown || changedField == &m_showInactiveCells ||
changedField == &m_useSeparateDataSource || changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold ||
changedField == &m_depthLowerThreshold || changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType ||
changedField == &m_enableKFilter || changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride )
changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || changedField == &m_lengthUp ||
changedField == &m_lengthDown || changedField == &m_showInactiveCells || changedField == &m_useSeparateDataSource ||
changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || changedField == &m_depthLowerThreshold ||
changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType || changedField == &m_enableKFilter ||
changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride || changedField == &m_projectPolygon )
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
@@ -453,7 +460,8 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
recomputeSimulationWellBranchData();
}
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex )
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex ||
changedField == &m_projectPolygon || changedField == &m_type )
{
updateName();
}
@@ -511,6 +519,15 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
if ( changedField == &m_editPolygonButton )
{
RimPolygonTools::selectAndActivatePolygonInView( m_projectPolygon(), this );
m_editPolygonButton = false;
return;
}
}
//--------------------------------------------------------------------------------------------------
@@ -540,6 +557,11 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf::
geometryGroup->add( &m_userPolylineXydForUi );
geometryGroup->add( &m_inputPolylineFromViewerEnabled );
}
else if ( type() == CrossSectionEnum::CS_POLYGON )
{
geometryGroup->add( &m_projectPolygon );
geometryGroup->add( &m_editPolygonButton, { .newRow = false } );
}
else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
geometryGroup->add( &m_twoAzimuthPoints );
@@ -668,6 +690,19 @@ QList<caf::PdmOptionItemInfo> RimExtrudedCurveIntersection::calculateValueOption
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
}
else if ( fieldNeedingOptions == &m_projectPolygon )
{
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimTools::polygonOptionItems( &options );
if ( m_projectPolygon() == nullptr )
{
auto polygonCollection = RimTools::polygonCollection();
auto polygons = polygonCollection->allPolygons();
if ( !polygons.empty() ) m_projectPolygon = polygons.front();
}
}
else if ( fieldNeedingOptions == &m_branchIndex )
{
updateSimulationWellCenterline();
@@ -775,8 +810,6 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
{
if ( m_simulationWell() )
{
updateSimulationWellCenterline();
int branchIndexToUse = branchIndex();
if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast<int>( m_simulationWellBranchCenterlines.size() ) )
@@ -794,6 +827,13 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
{
lines.push_back( m_userPolylineXyz );
}
else if ( type() == CrossSectionEnum::CS_POLYGON )
{
if ( m_projectPolygon )
{
lines = m_projectPolygon->polyLinesData()->completePolyLines();
}
}
else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
lines.push_back( m_twoAzimuthPoints );
@@ -863,7 +903,7 @@ std::vector<cvf::Vec3d> RimExtrudedCurveIntersection::polyLinesForExtrusionDirec
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::updateSimulationWellCenterline() const
void RimExtrudedCurveIntersection::updateSimulationWellCenterline()
{
if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
@@ -954,6 +994,10 @@ void RimExtrudedCurveIntersection::updateName()
{
m_name = m_wellPath()->name();
}
else if ( m_type() == CrossSectionEnum::CS_POLYGON && m_projectPolygon() )
{
m_name = m_projectPolygon->name();
}
Rim2dIntersectionView* iView = correspondingIntersectionView();
if ( iView )
@@ -1081,6 +1125,14 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan
{
setBaseColor( m_inputExtrusionPointsFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
}
if ( field == &m_editPolygonButton )
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
attrib->m_buttonText = "Edit";
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -24,9 +24,10 @@
#include "RimIntersectionEnums.h"
#include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmProxyValueField.h"
#include <QString>
#include "cvfVector3.h"
class RimWellPath;
class RivExtrudedCurveIntersectionPartMgr;
@@ -40,6 +41,7 @@ class RimSurfaceCollection;
class RimSurfaceIntersectionCollection;
class RimSurfaceIntersectionCurve;
class RimSurfaceIntersectionBand;
class RimPolygon;
namespace caf
{
@@ -62,7 +64,8 @@ public:
CS_WELL_PATH,
CS_SIMULATION_WELL,
CS_POLYLINE,
CS_AZIMUTHLINE
CS_AZIMUTHLINE,
CS_POLYGON,
};
enum class CrossSectionDirEnum
@@ -102,6 +105,7 @@ public:
void configureForSimulationWell( RimSimWellInView* simWell );
void configureForWellPath( RimWellPath* wellPath );
void configureForPolyLine();
void configureForProjectPolyLine( RimPolygon* polygon );
void configureForAzimuthLine();
std::vector<std::vector<cvf::Vec3d>> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const;
@@ -134,7 +138,7 @@ public:
int branchIndex() const;
void rebuildGeometryAndScheduleCreateDisplayModel();
protected:
private:
caf::PdmFieldHandle* userDescriptionField() final;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
@@ -143,13 +147,12 @@ protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
private:
static void setPushButtonText( bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute );
static void setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute );
RimSimWellInViewCollection* simulationWellCollection() const;
void updateAzimuthLine();
void updateSimulationWellCenterline() const;
void updateSimulationWellCenterline();
void addExtents( std::vector<cvf::Vec3d>& polyLine ) const;
void updateName();
static double azimuthInRadians( cvf::Vec3d vec );
@@ -181,6 +184,9 @@ private:
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimSimWellInView*> m_simulationWell;
caf::PdmPtrField<RimPolygon*> m_projectPolygon;
caf::PdmField<bool> m_editPolygonButton;
caf::PdmField<bool> m_inputPolylineFromViewerEnabled;
caf::PdmField<bool> m_inputExtrusionPointsFromViewerEnabled;
caf::PdmField<bool> m_inputTwoAzimuthPointsFromViewerEnabled;
@@ -202,11 +208,11 @@ private:
cvf::ref<RivExtrudedCurveIntersectionPartMgr> m_crossSectionPartMgr;
mutable std::vector<std::vector<cvf::Vec3d>> m_simulationWellBranchCenterlines;
std::vector<std::vector<cvf::Vec3d>> m_simulationWellBranchCenterlines;
caf::PdmField<bool> m_enableKFilter;
caf::PdmField<QString> m_kFilterText;
caf::PdmField<bool> m_kFilterCollectionOverride;
caf::PdmField<QString> m_kFilterCollectionText;
};
};

View File

@@ -19,7 +19,6 @@
#include "RimIntersection.h"
#include "RigEclipseCaseData.h"
#include "RigFemPartCollection.h"
#include "RigGeoMechCaseData.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"

View File

@@ -18,7 +18,6 @@
#pragma once
#include "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"

View File

@@ -0,0 +1,29 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPolygon.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonFile.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPolygon.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonFile.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
source_group(
"ProjectDataModel\\Polygons"
FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake
)

View File

@@ -0,0 +1,206 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygon.h"
#include "RigPolyLinesData.h"
#include "RiaApplication.h"
#include "Rim3dView.h"
#include "RimPolygonAppearance.h"
#include "RimPolygonTools.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeAttributes.h"
CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon::RimPolygon()
: objectChanged( this )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitField( &m_isReadOnly, "IsReadOnly", false, "Read Only" );
CAF_PDM_InitFieldNoDefault( &m_pointsInDomainCoords, "PointsInDomainCoords", "Points" );
CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton );
CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance" );
m_appearance = new RimPolygonAppearance;
m_appearance.uiCapability()->setUiTreeChildrenHidden( true );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolygon::polyLinesData() const
{
cvf::ref<RigPolyLinesData> pld = new RigPolyLinesData;
pld->setPolyLine( m_pointsInDomainCoords() );
m_appearance->applyAppearanceSettings( pld.p() );
return pld;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
m_appearance->uiOrdering( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicNewPolygonIntersectionFeature";
menuBuilder << "RicNewPolygonFilterFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points )
{
m_pointsInDomainCoords = points;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimPolygon::pointsInDomainCoords() const
{
return m_pointsInDomainCoords();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setIsClosed( bool isClosed )
{
m_appearance->setIsClosed( isClosed );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygon::isClosed() const
{
return m_appearance->isClosed();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setReadOnly( bool isReadOnly )
{
m_isReadOnly = isReadOnly;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygon::isReadOnly() const
{
return m_isReadOnly();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( nameField() );
uiOrdering.add( &m_isReadOnly );
uiOrdering.add( &m_editPolygonButton );
auto groupPoints = uiOrdering.addNewGroup( "Points" );
groupPoints->setCollapsedByDefault();
groupPoints->add( &m_pointsInDomainCoords );
m_pointsInDomainCoords.uiCapability()->setUiReadOnly( m_isReadOnly() );
auto group = uiOrdering.addNewGroup( "Appearance" );
m_appearance->uiOrdering( uiConfigName, *group );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_pointsInDomainCoords )
{
objectChanged.send();
}
if ( changedField == &m_editPolygonButton )
{
auto activeView = RiaApplication::instance()->activeReservoirView();
RimPolygonTools::selectAndActivatePolygonInView( this, activeView );
m_editPolygonButton = false;
return;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_editPolygonButton )
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
attrib->m_buttonText = "Edit in Active View";
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( m_isReadOnly )
{
caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" );
}
}

View File

@@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimNamedObject.h"
#include "RimPolylinesDataInterface.h"
#include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cvfVector3.h"
class RimPolygonAppearance;
namespace caf
{
class CmdFeatureMenuBuilder;
}
class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface
{
CAF_PDM_HEADER_INIT;
public:
caf::Signal<> objectChanged;
public:
RimPolygon();
void setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points );
std::vector<cvf::Vec3d> pointsInDomainCoords() const;
void setIsClosed( bool isClosed );
bool isClosed() const;
void setReadOnly( bool isReadOnly );
bool isReadOnly() const;
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
caf::PdmField<bool> m_isReadOnly;
caf::PdmField<bool> m_editPolygonButton;
caf::PdmField<std::vector<cvf::Vec3d>> m_pointsInDomainCoords;
caf::PdmChildField<RimPolygonAppearance*> m_appearance;
};

View File

@@ -0,0 +1,214 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonAppearance.h"
#include "RimCase.h"
#include "RimProject.h"
#include "RigPolyLinesData.h"
#include "RiaNumericalTools.h"
#include "RiaStdStringTools.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiLineEditor.h"
#include "cvfBoundingBox.h"
CAF_PDM_SOURCE_INIT( RimPolygonAppearance, "RimPolygonAppearance" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class ThicknessValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
int val = RiaStdStringTools::toInt( input.toStdString() );
if ( val > 0 && val < 8 )
return State::Acceptable;
else
return State::Invalid;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RadiusValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
double val = RiaStdStringTools::toDouble( input.toStdString() );
if ( val > 0.001 && val <= 2.0 )
return State::Acceptable;
else
return State::Invalid;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonAppearance::RimPolygonAppearance()
: objectChanged( this )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitField( &m_isClosed, "IsClosed", true, "Closed Polygon" );
CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" );
CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" );
CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness" );
CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" );
CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::WHITE ), "Line Color" );
CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" );
CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" );
CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" );
m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::applyAppearanceSettings( RigPolyLinesData* polyLinesData )
{
polyLinesData->setLineAppearance( m_lineThickness, m_lineColor, m_isClosed );
polyLinesData->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor );
polyLinesData->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth );
polyLinesData->setVisibility( m_showLines, m_showSpheres );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::setIsClosed( bool isClosed )
{
m_isClosed = isClosed;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonAppearance::isClosed() const
{
return m_isClosed();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_showLines );
if ( m_showLines )
{
uiOrdering.add( &m_lineThickness );
uiOrdering.add( &m_lineColor );
}
uiOrdering.add( &m_showSpheres );
if ( m_showSpheres )
{
uiOrdering.add( &m_sphereRadiusFactor );
uiOrdering.add( &m_sphereColor );
}
uiOrdering.add( &m_lockPolygonToPlane );
if ( m_lockPolygonToPlane )
{
uiOrdering.add( &m_polygonPlaneDepth );
}
uiOrdering.add( &m_isClosed );
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_lineThickness )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute ) )
{
myAttr->validator = new ThicknessValidator();
}
}
else if ( field == &m_lineThickness )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute ) )
{
myAttr->validator = new RadiusValidator();
}
}
else if ( field == &m_polygonPlaneDepth )
{
if ( auto attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
auto allCases = RimProject::current()->allGridCases();
if ( allCases.empty() )
{
attr->m_minimum = 0;
attr->m_maximum = 10000.0;
}
else
{
double min = std::numeric_limits<double>::max();
double max = -std::numeric_limits<double>::max();
for ( auto gridCase : allCases )
{
auto bb = gridCase->allCellsBoundingBox();
min = std::min( min, bb.min().z() );
max = std::max( max, bb.max().z() );
}
auto adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( -min, 2 );
auto adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( -max, 2 );
attr->m_minimum = adjustedMax;
attr->m_maximum = adjustedMin;
}
}
}
}

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmFieldCvfColor.h"
#include "cvfVector3.h"
class RigPolyLinesData;
class RimPolygonAppearance : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
caf::Signal<> objectChanged;
void applyAppearanceSettings( RigPolyLinesData* polyLinesData );
void setIsClosed( bool isClosed );
bool isClosed() const;
public:
RimPolygonAppearance();
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
caf::PdmField<bool> m_isClosed;
caf::PdmField<bool> m_showLines;
caf::PdmField<int> m_lineThickness;
caf::PdmField<cvf::Color3f> m_lineColor;
caf::PdmField<bool> m_showSpheres;
caf::PdmField<double> m_sphereRadiusFactor;
caf::PdmField<cvf::Color3f> m_sphereColor;
caf::PdmField<bool> m_lockPolygonToPlane;
caf::PdmField<double> m_polygonPlaneDepth;
};

View File

@@ -0,0 +1,206 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonCollection.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonFile.h"
#include "RimProject.h"
CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonCollection::RimPolygonCollection()
{
CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_polygonFiles, "PolygonFiles", "Polygon Files" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::loadData()
{
for ( auto& p : m_polygonFiles() )
{
p->loadData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
{
auto newPolygon = new RimPolygon();
newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) );
addUserDefinedPolygon( newPolygon );
return newPolygon;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::addUserDefinedPolygon( RimPolygon* polygon )
{
m_polygons().push_back( polygon );
connectSignals( polygon );
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::deleteUserDefinedPolygons()
{
m_polygons().deleteChildren();
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::addPolygonFile( RimPolygonFile* polygonFile )
{
m_polygonFiles().push_back( polygonFile );
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygon*> RimPolygonCollection::userDefinedPolygons() const
{
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonFile*> RimPolygonCollection::polygonFiles() const
{
return m_polygonFiles.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygon*> RimPolygonCollection::allPolygons() const
{
std::vector<RimPolygon*> allPolygons;
for ( auto& p : m_polygonFiles() )
{
for ( auto& polygon : p->polygons() )
{
allPolygons.push_back( polygon );
}
}
for ( auto& polygon : m_polygons.childrenByType() )
{
allPolygons.push_back( polygon );
}
return allPolygons;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
{
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::updateViewTreeItems()
{
RimProject* proj = RimProject::current();
// Make sure the tree items are synchronized
std::vector<Rim3dView*> views;
proj->allViews( views );
for ( auto view : views )
{
view->updateViewTreeItems( RiaDefines::ItemIn3dView::POLYGON );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::scheduleRedrawViews()
{
RimProject* proj = RimProject::current();
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::connectSignals( RimPolygon* polygon )
{
if ( polygon )
{
polygon->objectChanged.connect( this, &RimPolygonCollection::onObjectChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onObjectChanged( const caf::SignalEmitter* emitter )
{
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::initAfterRead()
{
for ( auto& p : m_polygons() )
{
connectSignals( p );
}
}

View File

@@ -0,0 +1,65 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
class RimPolygon;
class RimPolygonFile;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonCollection();
void loadData();
RimPolygon* appendUserDefinedPolygon();
void addUserDefinedPolygon( RimPolygon* polygon );
void deleteUserDefinedPolygons();
void addPolygonFile( RimPolygonFile* polygonFile );
std::vector<RimPolygon*> userDefinedPolygons() const;
std::vector<RimPolygonFile*> polygonFiles() const;
std::vector<RimPolygon*> allPolygons() const;
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
private:
void updateViewTreeItems();
void scheduleRedrawViews();
void connectSignals( RimPolygon* polygon );
void onObjectChanged( const caf::SignalEmitter* emitter );
private:
caf::PdmChildArrayField<RimPolygon*> m_polygons;
caf::PdmChildArrayField<RimPolygonFile*> m_polygonFiles;
protected:
void initAfterRead() override;
};

View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonFile.h"
#include "RimPolygon.h"
CAF_PDM_SOURCE_INIT( RimPolygonFile, "RimPolygonFileFile" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFile::RimPolygonFile()
{
CAF_PDM_InitObject( "PolygonFile", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_fileName, "StimPlanFileName", "File Name" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::loadData()
{
loadPolygonsFromFile();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygon*> RimPolygonFile::polygons() const
{
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
loadPolygonsFromFile();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::loadPolygonsFromFile()
{
// m_polygons()->deletePolygons();
auto polygon = new RimPolygon();
polygon->setName( "Polygon 1" );
m_polygons.push_back( polygon );
polygon = new RimPolygon();
polygon->setName( "Polygon 2" );
m_polygons.push_back( polygon );
}

View File

@@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimNamedObject.h"
#include "cafFilePath.h"
#include "cafPdmChildArrayField.h"
class RimPolygon;
class RimPolygonFile : public RimNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonFile();
void loadData();
std::vector<RimPolygon*> polygons() const;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
void loadPolygonsFromFile();
private:
caf::PdmField<caf::FilePath> m_fileName;
caf::PdmChildArrayField<RimPolygon*> m_polygons;
};

View File

@@ -0,0 +1,439 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonInView.h"
#include "RigPolyLinesData.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonInViewCollection.h"
#include "RimPolylineTarget.h"
#include "RimTools.h"
#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h"
#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h"
#include "Riu3DMainWindowTools.h"
#include "RiuGuiTheme.h"
#include "RivPolylinePartMgr.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafDisplayCoordTransform.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeAttributes.h"
#include "cvfModelBasicList.h"
CAF_PDM_SOURCE_INIT( RimPolygonInView, "RimPolygonInView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInView::RimPolygonInView()
: m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygon, "Polygon", "Polygon" );
m_polygon.uiCapability()->setUiReadOnly( true );
nameField()->uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_enablePicking );
CAF_PDM_InitField( &m_selectPolygon, "SelectPolygon", false, "" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_selectPolygon );
CAF_PDM_InitField( &m_handleScalingFactor, "HandleScalingFactor", 1.0, "Handle Scaling Factor" );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_targets.uiCapability()->setCustomContextMenuEnabled( true );
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon* RimPolygonInView::polygon() const
{
return m_polygon();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::setPolygon( RimPolygon* polygon )
{
m_polygon = polygon;
updateTargetsFromPolygon();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::appendPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* scaleTransform,
const cvf::BoundingBox& boundingBox )
{
auto view = firstAncestorOfType<Rim3dView>();
if ( m_polylinePartMgr.isNull() ) m_polylinePartMgr = new RivPolylinePartMgr( view, this, this );
m_polylinePartMgr->appendDynamicGeometryPartsToModel( model, scaleTransform, boundingBox );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::enablePicking( bool enable )
{
m_enablePicking = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
{
size_t index = m_targets.indexOf( targetToInsertBefore );
if ( index < m_targets.size() )
m_targets.insert( index, targetToInsert );
else
m_targets.push_back( targetToInsert );
updatePolygonFromTargets();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::deleteTarget( RimPolylineTarget* targetToDelete )
{
m_targets.removeChild( targetToDelete );
delete targetToDelete;
updatePolygonFromTargets();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateEditorsAndVisualization()
{
updateConnectedEditors();
updateVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateVisualization()
{
auto view = firstAncestorOfType<Rim3dView>();
if ( view )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolylineTarget*> RimPolygonInView::activeTargets() const
{
return m_targets.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonInView::pickingEnabled() const
{
return m_enablePicking();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonInView::pickEventHandler() const
{
auto filterColl = firstAncestorOfType<RimPolygonInViewCollection>();
if ( filterColl && !filterColl->isChecked() ) return nullptr;
if ( !isChecked() ) return nullptr;
if ( m_polygon() && polygon()->isReadOnly() ) return nullptr;
return m_pickTargetsEventHandler.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects )
{
if ( childArray == &m_targets )
{
updatePolygonFromTargets();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolygonInView::polyLinesData() const
{
if ( m_polygon )
{
return m_polygon->polyLinesData();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updatePolygonFromTargets()
{
if ( m_polygon )
{
std::vector<cvf::Vec3d> points;
for ( const RimPolylineTarget* target : m_targets )
{
points.push_back( target->targetPointXYZ() );
}
m_polygon->setPointsInDomainCoords( points );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateTargetsFromPolygon()
{
if ( m_polygon )
{
m_targets.deleteChildren();
for ( const auto& p : m_polygon->pointsInDomainCoords() )
{
auto target = new RimPolylineTarget();
target->setAsPointXYZ( p );
m_targets.push_back( target );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
updateNameField();
bool enableEdit = true;
if ( m_polygon() && m_polygon->isReadOnly() ) enableEdit = false;
uiOrdering.add( m_polygon );
if ( enableEdit )
{
uiOrdering.add( &m_enablePicking );
uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
}
if ( m_polygon() )
{
uiOrdering.add( &m_selectPolygon );
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_enablePicking )
{
updateConnectedEditors();
}
if ( changedField == &m_selectPolygon && m_polygon() )
{
Riu3DMainWindowTools::selectAsCurrentItem( m_polygon() );
}
updateVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimPolygonInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_polygon )
{
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimTools::polygonOptionItems( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( auto attrib = dynamic_cast<RicPolyline3dEditorAttribute*>( attribute ) )
{
attrib->pickEventHandler = m_pickTargetsEventHandler;
attrib->enablePicking = m_enablePicking;
}
if ( m_polygon() && m_polygon->isReadOnly() )
{
caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_enablePicking );
uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPolygonInView::scalingFactorForTarget() const
{
return m_handleScalingFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_enablePicking )
{
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( pbAttribute )
{
if ( !m_enablePicking )
{
pbAttribute->m_buttonText = "Start Picking Points";
}
else
{
pbAttribute->m_buttonText = "Stop Picking Points";
}
}
}
if ( field == &m_selectPolygon )
{
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( pbAttribute )
{
pbAttribute->m_buttonText = "Go to Polygon";
}
}
if ( field == &m_targets )
{
if ( auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute ) )
{
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT;
if ( m_enablePicking )
{
tvAttribute->baseColor = RiuGuiTheme::getColorByVariableName( "externalInputColor" );
}
tvAttribute->alwaysEnforceResizePolicy = true;
tvAttribute->heightHint = 1000;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget )
{
if ( m_polygon() && m_polygon->isReadOnly() ) return;
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicNewPolylineTargetFeature";
menuBuilder << "Separator";
menuBuilder << "RicDeletePolylineTargetFeature";
menuBuilder.appendToMenu( menu );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateNameField()
{
QString name = "Undefined";
if ( m_polygon() )
{
name = m_polygon->name();
}
setName( name );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= "" */ )
{
updateNameField();
}

View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimCheckableNamedObject.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylinesDataInterface.h"
#include "RivPolylinePartMgr.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmPtrField.h"
class RimPolygon;
class RivPolylinePartMgr;
class RicPolylineTargetsPickEventHandler;
class RimPolylineTarget;
namespace cvf
{
class ModelBasicList;
class BoundingBox;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
} // namespace caf
class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesDataInterface, public RimPolylinePickerInterface
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonInView();
RimPolygon* polygon() const;
void setPolygon( RimPolygon* polygon );
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
void enablePicking( bool enable );
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void updateEditorsAndVisualization() override;
void updateVisualization() override;
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
double scalingFactorForTarget() const override;
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
private:
void updateNameField();
void updatePolygonFromTargets();
void updateTargetsFromPolygon();
private:
caf::PdmPtrField<RimPolygon*> m_polygon;
caf::PdmField<bool> m_selectPolygon;
caf::PdmField<bool> m_enablePicking;
caf::PdmField<double> m_handleScalingFactor;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
};

View File

@@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonInViewCollection.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonCollection.h"
#include "RimPolygonInView.h"
#include "RimTools.h"
CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection::RimPolygonInViewCollection()
{
CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::syncPolygonsInView()
{
std::vector<RimPolygonInView*> existingPolygonsInView = m_polygons.childrenByType();
m_polygons.clearWithoutDelete();
auto polygonCollection = RimTools::polygonCollection();
if ( polygonCollection )
{
std::vector<RimPolygonInView*> newPolygonsInView;
for ( auto polygon : polygonCollection->allPolygons() )
{
auto it = std::find_if( existingPolygonsInView.begin(),
existingPolygonsInView.end(),
[polygon]( auto* polygonInView ) { return polygonInView->polygon() == polygon; } );
if ( it != existingPolygonsInView.end() )
{
newPolygonsInView.push_back( *it );
existingPolygonsInView.erase( it );
}
else
{
auto polygonInView = new RimPolygonInView();
polygonInView->setPolygon( polygon );
newPolygonsInView.push_back( polygonInView );
}
}
m_polygons.setValue( newPolygonsInView );
}
for ( auto polyInView : existingPolygonsInView )
{
delete polyInView;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimPolygonInViewCollection::polygonsInView() const
{
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimCheckableObject::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_isChecked )
{
for ( auto poly : polygonsInView() )
{
poly->updateConnectedEditors();
}
if ( auto view = firstAncestorOfType<Rim3dView>() )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimCheckableObject.h"
#include "cafPdmChildArrayField.h"
class RimPolygonInView;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonInViewCollection : public RimCheckableObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonInViewCollection();
void syncPolygonsInView();
std::vector<RimPolygonInView*> polygonsInView() const;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
caf::PdmChildArrayField<RimPolygonInView*> m_polygons;
};

View File

@@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonTools.h"
#include "RimGridView.h"
#include "RimOilField.h"
#include "RimPolygon.h"
#include "RimPolygonCollection.h"
#include "RimPolygonInView.h"
#include "RimPolygonInViewCollection.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonTools::selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
{
auto polygonInView = findPolygonInView( polygon, sourceObject );
if ( polygonInView )
{
polygonInView->enablePicking( true );
Riu3DMainWindowTools::selectAsCurrentItem( polygonInView );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
{
if ( !polygon || !sourceObject )
{
return nullptr;
}
if ( auto gridView = sourceObject->firstAncestorOrThisOfType<RimGridView>() )
{
auto polyCollection = gridView->polygonInViewCollection();
for ( auto polygonInView : polyCollection->polygonsInView() )
{
if ( polygonInView && polygonInView->polygon() == polygon )
{
return polygonInView;
}
}
}
return nullptr;
}

View File

@@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
class RimPolygon;
class RimPolygonInView;
namespace caf
{
class PdmObject;
}
class RimPolygonTools
{
public:
static void selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
private:
static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
};

View File

@@ -51,7 +51,6 @@
#include "RimWellPathCollection.h"
#include "RivAnnotationsPartMgr.h"
#include "RivCellFilterPartMgr.h"
#include "RivMeasurementPartMgr.h"
#include "RivWellPathsPartMgr.h"
@@ -174,7 +173,6 @@ Rim3dView::Rim3dView()
m_wellPathsPartManager = new RivWellPathsPartMgr( this );
m_annotationsPartManager = new RivAnnotationsPartMgr( this );
m_cellfilterPartManager = new RivCellFilterPartMgr( this );
m_measurementPartManager = new RivMeasurementPartMgr( this );
this->setAs3DViewMdiWindow();
@@ -701,14 +699,12 @@ void Rim3dView::updateDisplayModelForCurrentTimeStepAndRedraw()
this->onUpdateDisplayModelForCurrentTimeStep();
appendAnnotationsToModel();
appendMeasurementToModel();
appendCellFiltersToModel();
if ( Rim3dView* depView = prepareComparisonView() )
{
depView->onUpdateDisplayModelForCurrentTimeStep();
depView->appendAnnotationsToModel();
depView->appendMeasurementToModel();
depView->appendCellFiltersToModel();
restoreComparisonView();
}
@@ -1133,19 +1129,6 @@ void Rim3dView::addAnnotationsToModel( cvf::ModelBasicList* annotationsModel )
annotationsModel->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel )
{
if ( !this->ownerCase() ) return;
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
m_cellfilterPartManager->appendGeometryPartsToModel( cellFilterModel, transForm.p(), ownerCase()->allCellsBoundingBox() );
cellFilterModel->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1716,28 +1699,6 @@ void Rim3dView::updateScreenSpaceModel()
nativeOrOverrideViewer()->addStaticModelOnce( m_screenSpaceModel.p(), isUsingOverrideViewer() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::appendCellFiltersToModel()
{
if ( !nativeOrOverrideViewer() ) return;
cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() );
if ( frameScene )
{
cvf::String name = "CellFilters";
this->removeModelByName( frameScene, name );
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
model->setName( name );
addCellFiltersToModel( model.p() );
frameScene->addModel( model.p() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1860,7 +1821,7 @@ void Rim3dView::onUpdateScaleTransform()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateSurfacesInViewTreeItems()
void Rim3dView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType )
{
// default is to do nothing
}

View File

@@ -52,7 +52,6 @@ class RiuViewer;
class RivAnnotationsPartMgr;
class RivMeasurementPartMgr;
class RivWellPathsPartMgr;
class RivCellFilterPartMgr;
class RimViewNameConfig;
namespace cvf
@@ -193,7 +192,7 @@ public:
RimViewLinker* assosiatedViewLinker() const override;
RimViewController* viewController() const override;
virtual void updateSurfacesInViewTreeItems();
virtual void updateViewTreeItems( RiaDefines::ItemIn3dView itemType );
RimAnnotationInViewCollection* annotationCollection() const;
void syncronizeLocalAnnotationsFromGlobal();
@@ -222,7 +221,6 @@ protected:
double characteristicCellSize );
void addAnnotationsToModel( cvf::ModelBasicList* annotationsModel );
void addMeasurementToModel( cvf::ModelBasicList* measureModel );
void addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel );
// Override viewer
@@ -311,7 +309,6 @@ private:
void createHighlightAndGridBoxDisplayModel();
void appendMeasurementToModel();
void appendCellFiltersToModel();
void appendAnnotationsToModel();
void updateScreenSpaceModel();
@@ -349,7 +346,6 @@ private:
// 3D display model data
cvf::ref<RivAnnotationsPartMgr> m_annotationsPartManager;
cvf::ref<RivMeasurementPartMgr> m_measurementPartManager;
cvf::ref<RivCellFilterPartMgr> m_cellfilterPartManager;
// Timer for animations
std::unique_ptr<QTimer> m_animationTimer;

View File

@@ -63,9 +63,7 @@ RimCommandExecuteScript::RimCommandExecuteScript()
CAF_PDM_InitField( &isEnabled, "IsEnabled", true, "Enabled " );
CAF_PDM_InitField( &execute, "Execute", true, "Execute" );
execute.xmlCapability()->disableIO();
execute.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
execute.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &execute );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -23,6 +23,7 @@
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
#include "Polygons/RimPolygonCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "Rim3dWellLogCurveCollection.h"
#include "Rim3dWellLogExtractionCurve.h"
@@ -1138,6 +1139,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicAddGridCalculationFeature";
}
else if ( dynamic_cast<RimPolygonCollection*>( firstUiItem ) )
{
menuBuilder << "RicNewPolygonFeature";
menuBuilder << "RicNewPolygonFileFeature";
}
if ( dynamic_cast<Rim3dView*>( firstUiItem ) )
{
@@ -1151,6 +1157,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
if ( firstUiItem )
{
if ( auto pdmObject = dynamic_cast<caf::PdmUiObjectHandle*>( firstUiItem ) )
{
pdmObject->appendMenuItems( menuBuilder );
}
// Work in progress -- Start
// All commands should be aware of selection of multiple objects
// Based on the selection, the command feature can decide if the command

View File

@@ -52,8 +52,7 @@ RimCustomObjectiveFunctionWeight::RimCustomObjectiveFunctionWeight()
m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton );
m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_objectiveValuesSelectSummaryAddressPushButton );
m_objectiveValuesSelectSummaryAddressPushButton = false;
CAF_PDM_InitField( &m_weightValue, "WeightValue", 1.0, "Weight" );

View File

@@ -99,9 +99,11 @@ RimEclipseCase::RimEclipseCase()
CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis" );
CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis" );
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "CachedFileNamesContainingFaults", "" );
m_filesContainingFaults_OBSOLETE.uiCapability()->setUiHidden( true );
m_filesContainingFaults_OBSOLETE.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults, "CachedFileNamesContainingFaults", "" );
m_filesContainingFaults.uiCapability()->setUiHidden( true );
// Caching of file names causes issues when using the project file as template, do not save to disk
// https://github.com/OPM/ResInsight/issues/7308
m_filesContainingFaults.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" );
m_contourMapCollection = new RimEclipseContourMapViewCollection;
@@ -927,7 +929,7 @@ std::vector<QString> RimEclipseCase::filesContainingFaults() const
{
std::vector<QString> stdPathList;
for ( auto& filePath : m_filesContainingFaults_OBSOLETE() )
for ( auto& filePath : m_filesContainingFaults() )
{
stdPathList.push_back( filePath.path() );
}
@@ -946,7 +948,7 @@ void RimEclipseCase::setFilesContainingFaults( const std::vector<QString>& pathS
filePaths.push_back( pathString );
}
m_filesContainingFaults_OBSOLETE = filePaths;
m_filesContainingFaults = filePaths;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -167,7 +167,5 @@ private:
caf::PdmChildField<RimReservoirCellResultsStorage*> m_matrixModelResults;
caf::PdmChildField<RimReservoirCellResultsStorage*> m_fractureModelResults;
// To be removed as the caching of file names causes issues when using the project file as template
// https://github.com/OPM/ResInsight/issues/7308
caf::PdmField<std::vector<caf::FilePath>> m_filesContainingFaults_OBSOLETE;
caf::PdmField<std::vector<caf::FilePath>> m_filesContainingFaults;
};

View File

@@ -82,7 +82,7 @@ RimEclipseStatisticsCase::RimEclipseStatisticsCase()
CAF_PDM_InitScriptableObject( "Case Group Statistics", ":/Histogram16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_calculateEditCommand, "m_editingAllowed", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_calculateEditCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_calculateEditCommand );
m_calculateEditCommand = false;
CAF_PDM_InitField( &m_selectionSummary, "SelectionSummary", QString( "" ), "Summary of Calculation Setup" );

View File

@@ -20,6 +20,7 @@
#include "RimEclipseView.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaFieldHandleTools.h"
#include "RiaLogging.h"
@@ -41,6 +42,7 @@
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimAnnotationCollection.h"
@@ -671,6 +673,9 @@ void RimEclipseView::onCreateDisplayModel()
nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() );
}
// Polygons
appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() );
// Well path model
m_wellPathPipeVizModel->removeAllParts();
@@ -1101,7 +1106,7 @@ void RimEclipseView::appendStreamlinesToModel()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::onLoadDataAndUpdate()
{
updateSurfacesInViewTreeItems();
updateViewTreeItems( RiaDefines::ItemIn3dView::ALL );
onUpdateScaleTransform();
@@ -1982,6 +1987,11 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() );
if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() );
if ( RiaApplication::enableDevelopmentFeatures() )
{
uiTreeOrdering.add( m_polygonInViewCollection );
}
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@@ -102,8 +102,7 @@ RimGridCalculation::RimGridCalculation()
m_nonVisibleResultAddress = new RimEclipseResultAddress;
CAF_PDM_InitField( &m_editNonVisibleResultAddress, "EditNonVisibleResultAddress", false, "Edit" );
m_editNonVisibleResultAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_editNonVisibleResultAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editNonVisibleResultAddress );
CAF_PDM_InitFieldNoDefault( &m_nonVisibleResultText, "NonVisibleResultText", "" );
m_nonVisibleResultText.registerGetMethod( this, &RimGridCalculation::nonVisibleResultAddressText );

View File

@@ -56,8 +56,7 @@ RimGridCalculationVariable::RimGridCalculationVariable()
CAF_PDM_InitField( &m_timeStep, "TimeStep", allTimeStepsValue(), "Time Step" );
CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "" );
m_button.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_button.xmlCapability()->disableIO();
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_button );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -41,6 +41,9 @@
#include "RimWellMeasurementInViewCollection.h"
#include "RimWellPathCollection.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "RiuMainWindow.h"
@@ -96,6 +99,9 @@ RimGridView::RimGridView()
CAF_PDM_InitFieldNoDefault( &m_seismicSectionCollection, "SeismicSectionCollection", "Seismic Collection Field" );
m_seismicSectionCollection = new RimSeismicSectionCollection();
CAF_PDM_InitFieldNoDefault( &m_polygonInViewCollection, "PolygonInViewCollection", "Polygon Collection Field" );
m_polygonInViewCollection = new RimPolygonInViewCollection();
CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" );
m_cellFilterCollection = new RimCellFilterCollection();
@@ -104,6 +110,9 @@ RimGridView::RimGridView()
m_intersectionVizModel = new cvf::ModelBasicList;
m_intersectionVizModel->setName( "CrossSectionModel" );
m_polygonVizModel = new cvf::ModelBasicList;
m_polygonVizModel->setName( "PolygonModel" );
}
//--------------------------------------------------------------------------------------------------
@@ -161,6 +170,14 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const
return m_seismicSectionCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection* RimGridView::polygonInViewCollection() const
{
return m_polygonInViewCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -380,6 +397,43 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridView::appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox )
{
m_polygonVizModel->removeAllParts();
std::vector<RimPolygonInView*> polygonsInView;
if ( m_polygonInViewCollection && m_polygonInViewCollection->isChecked() )
{
auto candidates = m_polygonInViewCollection->polygonsInView();
for ( auto polygonInView : candidates )
{
if ( polygonInView->isChecked() )
{
polygonsInView.push_back( polygonInView );
}
}
}
if ( cellFilterCollection() && cellFilterCollection()->isActive() )
{
auto cellFilterPolygonsInView = cellFilterCollection()->enabledCellFilterPolygons();
polygonsInView.insert( polygonsInView.end(), cellFilterPolygonsInView.begin(), cellFilterPolygonsInView.end() );
}
for ( RimPolygonInView* polygonInView : polygonsInView )
{
if ( polygonInView )
{
polygonInView->appendPartsToModel( m_polygonVizModel.p(), scaleTransform, boundingBox );
}
}
nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -455,23 +509,32 @@ void RimGridView::updateWellMeasurements()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridView::updateSurfacesInViewTreeItems()
void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType )
{
RimSurfaceCollection* surfColl = RimTools::surfaceCollection();
auto bitmaskEnum = BitmaskEnum( itemType );
if ( surfColl && surfColl->containsSurface() )
if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::SURFACE ) )
{
if ( !m_surfaceCollection() )
RimSurfaceCollection* surfColl = RimTools::surfaceCollection();
if ( surfColl && surfColl->containsSurface() )
{
m_surfaceCollection = new RimSurfaceInViewCollection();
}
if ( !m_surfaceCollection() )
{
m_surfaceCollection = new RimSurfaceInViewCollection();
}
m_surfaceCollection->setSurfaceCollection( surfColl );
m_surfaceCollection->updateFromSurfaceCollection();
m_surfaceCollection->setSurfaceCollection( surfColl );
m_surfaceCollection->updateFromSurfaceCollection();
}
else
{
delete m_surfaceCollection;
}
}
else
if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) )
{
delete m_surfaceCollection;
m_polygonInViewCollection->syncPolygonsInView();
}
updateConnectedEditors();

View File

@@ -32,6 +32,7 @@ class RimCellFilterCollection;
class RimWellMeasurementInViewCollection;
class RimSurfaceInViewCollection;
class RimSeismicSectionCollection;
class RimPolygonInViewCollection;
class RimGridView : public Rim3dView
{
@@ -54,6 +55,7 @@ public:
RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const;
RimWellMeasurementInViewCollection* measurementCollection() const;
RimSeismicSectionCollection* seismicSectionCollection() const;
RimPolygonInViewCollection* polygonInViewCollection() const;
virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0;
@@ -68,7 +70,7 @@ public:
bool isGridVisualizationMode() const override;
void updateWellMeasurements();
void updateSurfacesInViewTreeItems() override;
void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override;
protected:
virtual void updateViewFollowingCellFilterUpdates();
@@ -78,6 +80,7 @@ protected:
RimGridCollection* gridCollection() const;
void clearReservoirCellVisibilities();
void addRequiredUiTreeObjects( caf::PdmUiTreeOrdering& uiTreeOrdering );
void appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void initAfterRead() override;
@@ -90,6 +93,7 @@ protected:
protected:
cvf::ref<cvf::ModelBasicList> m_surfaceVizModel;
cvf::ref<cvf::ModelBasicList> m_intersectionVizModel;
cvf::ref<cvf::ModelBasicList> m_polygonVizModel;
// Fields
caf::PdmChildField<RimIntersectionCollection*> m_intersectionCollection;
@@ -104,10 +108,12 @@ protected:
caf::PdmChildField<RimCellFilterCollection*> m_cellFilterCollection;
caf::PdmChildField<RimCellFilterCollection*> m_overrideCellFilterCollection;
caf::PdmChildField<RimSeismicSectionCollection*> m_seismicSectionCollection;
caf::PdmChildField<RimPolygonInViewCollection*> m_polygonInViewCollection;
private:
void onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts ) override;
private:
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;
bool m_previousGridModeMeshLinesWasFaults;
};

View File

@@ -35,6 +35,8 @@
#include "RimSurfaceCollection.h"
#include "RimWellPathCollection.h"
#include "Polygons/RimPolygonCollection.h"
CAF_PDM_SOURCE_INIT( RimOilField, "ResInsightOilField" );
//--------------------------------------------------------------------------------------------------
///
@@ -55,6 +57,7 @@ RimOilField::RimOilField()
CAF_PDM_InitFieldNoDefault( &annotationCollection, "AnnotationCollection", "Annotations" );
CAF_PDM_InitFieldNoDefault( &ensembleWellLogsCollection, "EnsembleWellLogsCollection", "Ensemble Well Logs" );
CAF_PDM_InitFieldNoDefault( &polygonCollection, "PolygonCollection", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_fractureTemplateCollection_OBSOLETE, "FractureDefinitionCollection", "Defenition of Fractures" );
@@ -80,6 +83,7 @@ RimOilField::RimOilField()
formationNamesCollection = new RimFormationNamesCollection();
annotationCollection = new RimAnnotationCollection();
ensembleWellLogsCollection = new RimEnsembleWellLogsCollection();
polygonCollection = new RimPolygonCollection();
m_fractureTemplateCollection_OBSOLETE = new RimFractureTemplateCollection;
m_fractureTemplateCollection_OBSOLETE.xmlCapability()->setIOWritable( false );

View File

@@ -41,6 +41,7 @@ class RimSeismicDataCollection;
class RimSeismicViewCollection;
class RimSurfaceCollection;
class RimEnsembleWellLogsCollection;
class RimPolygonCollection;
//==================================================================================================
///
@@ -73,6 +74,7 @@ public:
caf::PdmChildField<RimSeismicDataCollection*> seismicDataCollection;
caf::PdmChildField<RimSeismicViewCollection*> seismicViewCollection;
caf::PdmChildField<RimEnsembleWellLogsCollection*> ensembleWellLogsCollection;
caf::PdmChildField<RimPolygonCollection*> polygonCollection;
protected:
void initAfterRead() override;

View File

@@ -731,7 +731,7 @@ void RimPlotAxisProperties::defineObjectEditorAttribute( QString uiConfigName, c
if ( treeItemAttribute )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/chain.png" );
treeItemAttribute->tags.push_back( std::move( tag ) );

View File

@@ -1262,7 +1262,7 @@ void RimPlotCurve::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUi
if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
// Blend with background for a nice look
auto backgroundColor = RiuGuiTheme::getColorByVariableName( "backgroundColor1" );

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolylinePickerInterface.h"
#include "RimPolylineTarget.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPolylinePickerInterface::scalingFactorForTarget() const
{
return 1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<RimPolylineTarget*, RimPolylineTarget*>
RimPolylinePickerInterface::findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore )
{
auto targets = activeTargets();
RimPolylineTarget* before = nullptr;
RimPolylineTarget* after = nullptr;
bool foundTarget = false;
for ( const auto& wt : targets )
{
if ( wt == targetToInsertBefore )
{
foundTarget = true;
}
if ( !after && foundTarget ) after = wt;
if ( !foundTarget ) before = wt;
}
return { before, after };
}

View File

@@ -18,11 +18,16 @@
#pragma once
#include "RimPolylineTarget.h"
#include "cafPickEventHandler.h"
#include <utility>
#include <vector>
namespace caf
{
class PickEventHandler;
}
class RimPolylineTarget;
class RimPolylinePickerInterface
{
public:
@@ -33,4 +38,7 @@ public:
virtual std::vector<RimPolylineTarget*> activeTargets() const = 0;
virtual bool pickingEnabled() const = 0;
virtual caf::PickEventHandler* pickEventHandler() const = 0;
virtual double scalingFactorForTarget() const;
std::pair<RimPolylineTarget*, RimPolylineTarget*> findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore );
};

View File

@@ -33,6 +33,7 @@
#include "RigGridBase.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
#include "Polygons/RimPolygonCollection.h"
#include "RimAdvancedSnapshotExportDefinition.h"
#include "RimAnalysisPlotCollection.h"
#include "RimAnnotationCollection.h"
@@ -1533,6 +1534,11 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() );
if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() );
if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() );
if ( RiaApplication::enableDevelopmentFeatures() )
{
if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() );
}
}
uiTreeOrdering.add( colorLegendCollection() );

View File

@@ -203,8 +203,7 @@ RimRegularLegendConfig::RimRegularLegendConfig()
m_categoryLegend = new caf::CategoryLegend( standardFont, m_categoryMapper.p() );
CAF_PDM_InitField( &m_resetUserDefinedValuesButton, "ResetDefaultValues", false, "Reset Default Values" );
m_resetUserDefinedValuesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_resetUserDefinedValuesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_resetUserDefinedValuesButton );
CAF_PDM_InitField( &m_centerLegendAroundZero, "CenterLegendAroundZero", false, "Center Legend Around Zero" );

View File

@@ -27,26 +27,17 @@
#include "RifSummaryReaderInterface.h"
#include "RimDataSourceSteppingTools.h"
#include "RimObservedDataCollection.h"
#include "RimObservedSummaryData.h"
#include "RimProject.h"
#include "RimSummaryAddress.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCalculationVariable.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlot.h"
#include "RiuExpressionContextMenuManager.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTextEditor.h"
#include "expressionparser/ExpressionParser.h"
@@ -402,35 +393,6 @@ std::optional<std::pair<std::vector<double>, std::vector<time_t>>>
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculation::updateDependentObjects()
{
RimSummaryCalculationCollection* calcColl = firstAncestorOrThisOfTypeAsserted<RimSummaryCalculationCollection>();
calcColl->rebuildCaseMetaData();
// Refresh data sources tree.
// TODO: refresh too much: would be enough to only refresh calculated resutls.
RimSummaryCaseMainCollection* summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection();
auto summaryCases = summaryCaseCollection->allSummaryCases();
for ( RimSummaryCase* summaryCase : summaryCases )
{
summaryCase->createSummaryReaderInterface();
summaryCase->createRftReaderInterface();
summaryCase->refreshMetaData();
}
RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection();
auto observedData = observedDataCollection->allObservedSummaryData();
for ( auto obs : observedData )
{
obs->createSummaryReaderInterface();
obs->createRftReaderInterface();
obs->refreshMetaData();
}
auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections();
for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections )
{
summaryCaseCollection->refreshMetaData();
}
RimSummaryMultiPlotCollection* summaryPlotCollection = RiaSummaryTools::summaryMultiPlotCollection();
for ( auto multiPlot : summaryPlotCollection->multiPlots() )
{
@@ -438,7 +400,7 @@ void RimSummaryCalculation::updateDependentObjects()
{
bool plotContainsCalculatedCurves = false;
for ( RimSummaryCurve* sumCurve : sumPlot->summaryCurves() )
for ( RimSummaryCurve* sumCurve : sumPlot->summaryAndEnsembleCurves() )
{
if ( sumCurve->summaryAddressY().isCalculated() )
{
@@ -461,6 +423,7 @@ void RimSummaryCalculation::updateDependentObjects()
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculation::removeDependentObjects()
{
updateDependentObjects();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -18,7 +18,15 @@
#include "RimSummaryCalculationCollection.h"
#include "RiaSummaryTools.h"
#include "RifSummaryReaderInterface.h"
#include "RimObservedSummaryData.h"
#include "RimSummaryCalculation.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
CAF_PDM_SOURCE_INIT( RimSummaryCalculationCollection, "RimSummaryCalculationCollection" );
//--------------------------------------------------------------------------------------------------
@@ -37,12 +45,53 @@ RimSummaryCalculation* RimSummaryCalculationCollection::createCalculation() cons
return new RimSummaryCalculation;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculationCollection::updateDataDependingOnCalculations()
{
// Refresh data sources tree
// Refresh meta data for all summary cases and rebuild AddressNodes in the summary tree
RimSummaryCaseMainCollection* summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection();
auto summaryCases = summaryCaseCollection->allSummaryCases();
for ( RimSummaryCase* summaryCase : summaryCases )
{
if ( !summaryCase ) continue;
if ( auto reader = summaryCase->summaryReader() )
{
reader->buildMetaData();
summaryCase->onCalculationUpdated();
}
}
RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection();
auto observedData = observedDataCollection->allObservedSummaryData();
for ( auto obs : observedData )
{
if ( !obs ) continue;
if ( auto reader = obs->summaryReader() )
{
reader->buildMetaData();
obs->onCalculationUpdated();
}
}
auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections();
for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections )
{
summaryCaseCollection->onCalculationUpdated();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculationCollection::rebuildCaseMetaData()
{
ensureValidCalculationIds();
updateDataDependingOnCalculations();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -42,5 +42,6 @@ public:
RimSummaryCalculation* createCalculation() const override;
private:
void updateDataDependingOnCalculations();
void initAfterRead() override;
};

View File

@@ -47,8 +47,7 @@ RimSummaryCalculationVariable::RimSummaryCalculationVariable()
CAF_PDM_InitObject( "RimSummaryCalculationVariable", ":/octave.png" );
CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "" );
m_button.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_button.xmlCapability()->disableIO();
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_button );
CAF_PDM_InitFieldNoDefault( &m_case, "SummaryCase", "Summary Case" );
CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address" );

View File

@@ -59,15 +59,15 @@ RimTernaryLegendConfig::RimTernaryLegendConfig()
"" );
CAF_PDM_InitFieldNoDefault( &applyLocalMinMax, "m_applyLocalMinMax", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &applyLocalMinMax );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &applyLocalMinMax );
applyLocalMinMax = false;
CAF_PDM_InitFieldNoDefault( &applyGlobalMinMax, "m_applyGlobalMinMax", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &applyGlobalMinMax );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &applyGlobalMinMax );
applyGlobalMinMax = false;
CAF_PDM_InitFieldNoDefault( &applyFullRangeMinMax, "m_applyFullRangeMinMax", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &applyFullRangeMinMax );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &applyFullRangeMinMax );
applyFullRangeMinMax = false;
CAF_PDM_InitFieldNoDefault( &ternaryRangeSummary, "ternaryRangeSummary", "Range summary" );

View File

@@ -89,7 +89,7 @@ RimTimeStepFilter::RimTimeStepFilter()
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_readOnlyLastFrame );
CAF_PDM_InitFieldNoDefault( &m_applyReloadOfCase, "ApplyReloadOfCase", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyReloadOfCase );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyReloadOfCase );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -25,6 +25,8 @@
#include "RigGeoMechCaseData.h"
#include "RigReservoirGridTools.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "RimCase.h"
#include "RimColorLegend.h"
#include "RimColorLegendCollection.h"
@@ -493,6 +495,20 @@ void RimTools::seismicDataOptionItems( QList<caf::PdmOptionItemInfo>* options, c
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTools::polygonOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
auto project = RimProject::current();
auto coll = project->activeOilField()->polygonCollection();
for ( auto* p : coll->allPolygons() )
{
options->push_back( caf::PdmOptionItemInfo( p->name(), p, false, p->uiIconProvider() ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -546,6 +562,15 @@ RimSurfaceCollection* RimTools::surfaceCollection()
return proj->activeOilField()->surfaceCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonCollection* RimTools::polygonCollection()
{
RimProject* proj = RimProject::current();
return proj->activeOilField()->polygonCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -41,6 +41,7 @@ class RimCase;
class RimWellPath;
class RimSurfaceCollection;
class RimFaultInViewCollection;
class RimPolygonCollection;
//--------------------------------------------------------------------------------------------------
///
@@ -69,6 +70,7 @@ public:
static void colorLegendOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void seismicDataOptionItems( QList<caf::PdmOptionItemInfo>* options, cvf::BoundingBox worldBBox, bool basicDataOnly = false );
static void seismicDataOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void polygonOptionItems( QList<caf::PdmOptionItemInfo>* options );
static void faultOptionItems( QList<caf::PdmOptionItemInfo>* options, RimFaultInViewCollection* coll );
@@ -76,6 +78,7 @@ public:
static RimWellPath* firstWellPath();
static RimSurfaceCollection* surfaceCollection();
static RimPolygonCollection* polygonCollection();
static void timeStepsForCase( RimCase* gridCase, QList<caf::PdmOptionItemInfo>* options );

View File

@@ -53,8 +53,7 @@ RimUserDefinedCalculation::RimUserDefinedCalculation()
m_expression.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_helpButton, "HelpButton", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_helpButton );
m_helpButton.xmlCapability()->disableIO();
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_helpButton );
CAF_PDM_InitFieldNoDefault( &m_helpText,
"Label",

View File

@@ -103,9 +103,11 @@ RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculationCo
//--------------------------------------------------------------------------------------------------
void RimUserDefinedCalculationCollection::deleteCalculation( RimUserDefinedCalculation* calculation )
{
calculation->removeDependentObjects();
m_calculations.removeChild( calculation );
// Call this function after the object is removed from the collection
calculation->removeDependentObjects();
rebuildCaseMetaData();
delete calculation;

View File

@@ -319,7 +319,7 @@ void RimViewWindow::defineObjectEditorAttribute( QString uiConfigName, caf::PdmU
if ( treeItemAttribute && RiaPreferencesSystem::current()->showViewIdInProjectTree() && id() >= 0 )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->text = QString( "%1" ).arg( id() );
cvf::Color3f viewColor = RiaColorTables::contrastCategoryPaletteColors().cycledColor3f( (size_t)id() );
cvf::Color3f viewTextColor = RiaColorTools::contrastColor( viewColor );

View File

@@ -22,6 +22,7 @@
#include "RiuSeismicHistogramPanel.h"
#include "Rim3dView.h"
#include "RimPolylineTarget.h"
#include "RimRegularLegendConfig.h"
#include "RimSeismicAlphaMapper.h"
#include "RimSeismicDataInterface.h"
@@ -84,12 +85,10 @@ RimSeismicSection::RimSeismicSection()
CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "Well Path" );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_enablePicking );
CAF_PDM_InitField( &m_showImage, "ShowImage", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_showImage );
m_showImage.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_showImage );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
@@ -599,7 +598,7 @@ cvf::ref<RigTexturedSection> RimSeismicSection::texturedSection()
for ( int i = 0; i < (int)m_targets.size(); i++ )
{
if ( m_targets[i]->isEnabled() ) points.push_back( m_targets[i]->targetPointXYZ() );
points.push_back( m_targets[i]->targetPointXYZ() );
}
updateTextureSectionFromPoints( points, zmin, zmax );
}

View File

@@ -407,7 +407,7 @@ void RimSeismicView::onUpdateLegends()
//--------------------------------------------------------------------------------------------------
void RimSeismicView::onLoadDataAndUpdate()
{
updateSurfacesInViewTreeItems();
updateViewTreeItems( RiaDefines::ItemIn3dView::ALL );
syncronizeLocalAnnotationsFromGlobal();
onUpdateScaleTransform();
@@ -461,23 +461,28 @@ void RimSeismicView::updateGridBoxData()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSeismicView::updateSurfacesInViewTreeItems()
void RimSeismicView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType )
{
RimSurfaceCollection* surfColl = RimTools::surfaceCollection();
auto bitmaskEnum = BitmaskEnum( itemType );
if ( surfColl && surfColl->containsSurface() )
if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::SURFACE ) )
{
if ( !m_surfaceCollection() )
RimSurfaceCollection* surfColl = RimTools::surfaceCollection();
if ( surfColl && surfColl->containsSurface() )
{
m_surfaceCollection = new RimSurfaceInViewCollection();
}
if ( !m_surfaceCollection() )
{
m_surfaceCollection = new RimSurfaceInViewCollection();
}
m_surfaceCollection->setSurfaceCollection( surfColl );
m_surfaceCollection->updateFromSurfaceCollection();
}
else
{
delete m_surfaceCollection;
m_surfaceCollection->setSurfaceCollection( surfColl );
m_surfaceCollection->updateFromSurfaceCollection();
}
else
{
delete m_surfaceCollection;
}
}
updateConnectedEditors();

View File

@@ -90,7 +90,7 @@ protected:
void setDefaultView() override;
void updateSurfacesInViewTreeItems() override;
void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override;
private:
caf::PdmChildField<RimSurfaceInViewCollection*> m_surfaceCollection;

View File

@@ -87,11 +87,11 @@ void RifCalculatedSummaryCurveReader::buildMetaData()
for ( RimUserDefinedCalculation* calc : m_calculationCollection->calculations() )
{
RimSummaryCalculation* sumCalc = dynamic_cast<RimSummaryCalculation*>( calc );
auto* sumCalc = dynamic_cast<RimSummaryCalculation*>( calc );
CAF_ASSERT( sumCalc );
const auto& allAddresses = sumCalc->allAddressesForSummaryCase( m_summaryCase );
for ( auto calculationAddress : allAddresses )
for ( const auto& calculationAddress : allAddresses )
{
if ( calculationAddress.address().isValid() )
{

View File

@@ -39,7 +39,7 @@ public:
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
void buildMetaData();
void buildMetaData() override;
RiaDefines::EclipseUnitSystem unitSystem() const override;

View File

@@ -67,9 +67,7 @@ RimDerivedEnsembleCaseCollection::RimDerivedEnsembleCaseCollection()
CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator" );
CAF_PDM_InitField( &m_swapEnsemblesButton, "SwapEnsembles", false, "SwapEnsembles" );
m_swapEnsemblesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_swapEnsemblesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
m_swapEnsemblesButton.xmlCapability()->disableIO();
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_swapEnsemblesButton );
CAF_PDM_InitField( &m_caseCount, "CaseCount", QString( "" ), "Matching Cases" );
m_caseCount.uiCapability()->setUiReadOnly( true );

View File

@@ -87,8 +87,7 @@ RimEnsembleCurveFilter::RimEnsembleCurveFilter()
m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton );
m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_objectiveValuesSelectSummaryAddressPushButton );
m_objectiveValuesSelectSummaryAddressPushButton = false;
CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function" );

View File

@@ -47,9 +47,8 @@ RimEnsembleCurveFilterCollection::RimEnsembleCurveFilterCollection()
m_filters.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_newFilterButton, "NewEnsembleFilter", "New Filter" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_newFilterButton );
m_newFilterButton = false;
m_newFilterButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_newFilterButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -139,8 +139,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_yValuesSummaryAddress = new RimSummaryAddress;
CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_yPushButtonSelectSummaryAddress );
m_yPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_yPushButtonSelectSummaryAddress );
m_yPushButtonSelectSummaryAddress = false;
CAF_PDM_InitFieldNoDefault( &m_resampling, "Resampling", "Resampling" );
@@ -191,8 +190,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton );
m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_objectiveValuesSelectSummaryAddressPushButton );
m_objectiveValuesSelectSummaryAddressPushButton = false;
CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunction, "CustomObjectiveFunction", "Objective Function" );
@@ -1064,7 +1062,7 @@ void RimEnsembleCurveSet::defineObjectEditorAttribute( QString uiConfigName, caf
if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->bgColor = RiaColorTools::toQColor( m_colorForRealizations );
tag->fgColor = RiaColorTools::toQColor( m_statistics->color() );
tag->text = "---";

View File

@@ -99,7 +99,7 @@ RimSummaryAddressCollection::~RimSummaryAddressCollection()
//--------------------------------------------------------------------------------------------------
bool RimSummaryAddressCollection::hasDataVector( const QString quantityName ) const
{
for ( auto& address : m_adresses )
for ( const auto& address : m_adresses )
{
if ( address->quantityName() == quantityName ) return true;
}
@@ -346,6 +346,32 @@ void RimSummaryAddressCollection::deleteChildren()
m_subfolders.deleteChildren();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryAddressCollection::deleteCalculatedObjects()
{
std::vector<RimSummaryAddress*> toDelete;
for ( const auto& a : m_adresses )
{
if ( a->address().isCalculated() )
{
toDelete.push_back( a );
}
}
for ( auto a : toDelete )
{
m_adresses.removeChild( a );
delete a;
}
for ( auto& folder : m_subfolders )
{
folder->deleteCalculatedObjects();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -66,6 +66,7 @@ public:
void updateFolderStructure( const std::set<RifEclipseSummaryAddress>& addresses, int caseId, int ensembleId = -1 );
void deleteChildren();
void deleteCalculatedObjects();
bool isEmpty() const;
bool isEnsemble() const;

View File

@@ -64,8 +64,7 @@ RimSummaryAddressSelector::RimSummaryAddressSelector()
m_summaryAddress.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress );
m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonSelectSummaryAddress );
m_pushButtonSelectSummaryAddress = false;
CAF_PDM_InitFieldNoDefault( &m_plotAxisProperties, "PlotAxisProperties", "Axis" );

View File

@@ -400,3 +400,20 @@ void RimSummaryCase::refreshMetaData()
buildChildNodes();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCase::onCalculationUpdated()
{
// Delete all calculated address objects
m_dataVectorFolders->deleteCalculatedObjects();
if ( auto reader = summaryReader() )
{
auto addresses = reader->allResultAddresses();
m_dataVectorFolders->updateFolderStructure( addresses, m_caseId );
}
updateConnectedEditors();
}

View File

@@ -66,6 +66,7 @@ public:
int caseId() const;
void refreshMetaData();
void onCalculationUpdated();
virtual void createSummaryReaderInterface() = 0;
virtual void createRftReaderInterface() {}

View File

@@ -22,30 +22,23 @@
#include "RiaFieldHandleTools.h"
#include "RiaLogging.h"
#include "RiaStatisticsTools.h"
#include "RiaStdStringTools.h"
#include "RiaSummaryAddressAnalyzer.h"
#include "RiaWeightedMeanCalculator.h"
#include "RicfCommandObject.h"
#include "RifReaderRftInterface.h"
#include "RifSummaryReaderInterface.h"
#include "RimAnalysisPlotDataEntry.h"
#include "RimDerivedEnsembleCaseCollection.h"
#include "RimEnsembleCurveSet.h"
#include "RimProject.h"
#include "RimSummaryAddressCollection.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCase.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiTreeOrdering.h"
#include <QDate>
#include <QFileInfo>
#include <algorithm>
#include <cmath>
CAF_PDM_SOURCE_INIT( RimSummaryCaseCollection, "SummaryCaseSubCollection" );
@@ -284,7 +277,7 @@ void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble )
calculateEnsembleParametersIntersectionHash();
}
refreshMetaData();
buildMetaData();
}
}
@@ -1155,13 +1148,24 @@ void RimSummaryCaseCollection::buildChildNodes()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::refreshMetaData()
void RimSummaryCaseCollection::buildMetaData()
{
clearChildNodes();
buildChildNodes();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::onCalculationUpdated()
{
m_dataVectorFolders->deleteCalculatedObjects();
m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId );
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -19,20 +19,17 @@
#pragma once
#include "RiaDefines.h"
#include "RifEclipseSummaryAddress.h"
#include "RigEnsembleParameter.h"
#include "RimObjectiveFunction.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include "cvfObject.h"
#include <QString>
#include <memory>
@@ -103,7 +100,7 @@ public:
RiaDefines::EclipseUnitSystem unitSystem() const;
void refreshMetaData();
void onCalculationUpdated();
void updateReferringCurveSets();
@@ -127,6 +124,7 @@ private:
void onCaseNameChanged( const SignalEmitter* emitter );
void buildMetaData();
void buildChildNodes();
void clearChildNodes();

View File

@@ -79,8 +79,7 @@ RimSummaryCurve::RimSummaryCurve()
CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddress, "SummaryAddress", "Summary Address" );
CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_yPushButtonSelectSummaryAddress );
m_yPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_yPushButtonSelectSummaryAddress );
m_yPushButtonSelectSummaryAddress = false;
m_yValuesSummaryAddress = new RimSummaryAddress;
@@ -105,9 +104,7 @@ RimSummaryCurve::RimSummaryCurve()
CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryAddress, "SummaryAddressX", "Summary Address" );
CAF_PDM_InitFieldNoDefault( &m_xPushButtonSelectSummaryAddress, "SelectAddressX", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_xPushButtonSelectSummaryAddress );
m_xPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_xPushButtonSelectSummaryAddress );
m_xPushButtonSelectSummaryAddress = false;
m_xValuesSummaryAddress = new RimSummaryAddress;

View File

@@ -57,8 +57,7 @@ RimSummaryCurveCollection::RimSummaryCurveCollection()
m_showCurves.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_editPlot, "EditPlot", false, "" );
m_editPlot.xmlCapability()->disableIO();
m_editPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPlot );
CAF_PDM_InitFieldNoDefault( &m_ySourceStepping, "YSourceStepping", "" );
m_ySourceStepping = new RimSummaryPlotSourceStepping;

View File

@@ -114,33 +114,27 @@ RimSummaryMultiPlot::RimSummaryMultiPlot()
CAF_PDM_InitField( &m_autoSubPlotTitle, "AutoSubPlotTitle", true, "Auto Sub Plot Title" );
CAF_PDM_InitField( &m_createPlotDuplicate, "DuplicatePlot", false, "", "", "Duplicate Plot" );
m_createPlotDuplicate.xmlCapability()->disableIO();
m_createPlotDuplicate.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_createPlotDuplicate );
m_createPlotDuplicate.uiCapability()->setUiIconFromResourceString( ":/Copy.svg" );
CAF_PDM_InitField( &m_disableWheelZoom, "DisableWheelZoom", true, "", "", "Disable Mouse Wheel Zooming in Multi Summary Plot" );
m_disableWheelZoom.xmlCapability()->disableIO();
m_disableWheelZoom.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_disableWheelZoom );
m_disableWheelZoom.uiCapability()->setUiIconFromResourceString( ":/DisableZoom.png" );
CAF_PDM_InitField( &m_appendNextPlot, "AppendNextPlot", false, "", "", "Step Next and Add to New Plot" );
m_appendNextPlot.xmlCapability()->disableIO();
m_appendNextPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendNextPlot );
m_appendNextPlot.uiCapability()->setUiIconFromResourceString( ":/AppendNext.png" );
CAF_PDM_InitField( &m_appendPrevPlot, "AppendPrevPlot", false, "", "", "Step Previous and Add to New Plot" );
m_appendPrevPlot.xmlCapability()->disableIO();
m_appendPrevPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendPrevPlot );
m_appendPrevPlot.uiCapability()->setUiIconFromResourceString( ":/AppendPrev.png" );
CAF_PDM_InitField( &m_appendNextCurve, "AppendNextCurve", false, "", "", "Step Next and Add Curve to Plot" );
m_appendNextCurve.xmlCapability()->disableIO();
m_appendNextCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendNextCurve );
m_appendNextCurve.uiCapability()->setUiIconFromResourceString( ":/AppendNextCurve.png" );
CAF_PDM_InitField( &m_appendPrevCurve, "AppendPrevCurve", false, "", "", "Step Previous and Add Curve to Plot" );
m_appendPrevCurve.xmlCapability()->disableIO();
m_appendPrevCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendPrevCurve );
m_appendPrevCurve.uiCapability()->setUiIconFromResourceString( ":/AppendPrevCurve.png" );
CAF_PDM_InitField( &m_linkSubPlotAxes, "LinkSubPlotAxes", false, "Link Y Axes" );
@@ -155,8 +149,7 @@ RimSummaryMultiPlot::RimSummaryMultiPlot()
CAF_PDM_InitFieldNoDefault( &m_axisRangeAggregation, "AxisRangeAggregation", "Y Axis Range" );
CAF_PDM_InitField( &m_hidePlotsWithValuesBelow, "HidePlotsWithValuesBelow", false, "" );
m_hidePlotsWithValuesBelow.xmlCapability()->disableIO();
m_hidePlotsWithValuesBelow.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_hidePlotsWithValuesBelow );
CAF_PDM_InitField( &m_plotFilterYAxisThreshold, "PlotFilterYAxisThreshold", 0.0, "Y-Axis Filter Threshold" );

View File

@@ -93,16 +93,13 @@ RimSummaryPlotManager::RimSummaryPlotManager()
m_includeDiffCurves.uiCapability()->setUiEditorTypeName( caf::PdmUiNativeCheckBoxEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_pushButtonReplace, "PushButtonReplace", "Replace (CTRL + Enter)" );
m_pushButtonReplace.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_pushButtonReplace.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonReplace );
CAF_PDM_InitFieldNoDefault( &m_pushButtonNewPlot, "PushButtonNewPlot", "New (Alt + Enter)" );
m_pushButtonNewPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_pushButtonNewPlot.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonNewPlot );
CAF_PDM_InitFieldNoDefault( &m_pushButtonAppend, "PushButtonAppend", "Append (Shift + Enter)" );
m_pushButtonAppend.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_pushButtonAppend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonAppend );
CAF_PDM_InitFieldNoDefault( &m_labelA, "LabelA", "" );
m_labelA.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );

View File

@@ -204,7 +204,7 @@ void RimSummaryTimeAxisProperties::defineObjectEditorAttribute( QString uiConfig
if ( treeItemAttribute )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/chain.png" );
treeItemAttribute->tags.push_back( std::move( tag ) );

Some files were not shown because too many files have changed in this diff Show More