Add polygon classes

This commit is contained in:
Magne Sjaastad 2024-02-12 10:19:52 +01:00
parent 573a8f78cf
commit 5fdf30d124
40 changed files with 1816 additions and 37 deletions

View File

@ -40,6 +40,8 @@
#include "RicfCommandObject.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
#include "Polygons/RimPolygonCollection.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
@ -544,6 +546,8 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
{
seismicData->ensureFileReaderIsInitialized();
}
oilField->polygonCollection()->loadData();
}
{

View File

@ -243,8 +243,17 @@ enum class View3dContent
ALL = 0b00011111
};
enum class ItemIn3dView
{
NONE = 0b00000000,
SURFACE = 0b00000001,
POLYGON = 0b00000010,
ALL = 0b00000011
};
}; // namespace RiaDefines
// Activate bit mask operators at global scope
ENABLE_BITMASK_OPERATORS( RiaDefines::MultiPlotPageUpdateType )
ENABLE_BITMASK_OPERATORS( RiaDefines::View3dContent )
ENABLE_BITMASK_OPERATORS( RiaDefines::ItemIn3dView )

View File

@ -123,6 +123,7 @@ list(
ProjectDataModel/Intersections/CMakeLists_files.cmake
ProjectDataModel/CellFilters/CMakeLists_files.cmake
ProjectDataModel/ProcessControl/CMakeLists_files.cmake
ProjectDataModel/Polygons/CMakeLists_files.cmake
ProjectDataModel/WellLog/CMakeLists_files.cmake
ProjectDataModel/WellMeasurement/CMakeLists_files.cmake
ProjectDataModel/WellPath/CMakeLists_files.cmake

View File

@ -41,6 +41,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES
PlotTemplateCommands/CMakeLists_files.cmake
FractureCommands/CMakeLists_files.cmake
PlotBuilderCommands/CMakeLists_files.cmake
PolygonCommands/CMakeLists_files.cmake
)
# Include source file lists from *.cmake files

View File

@ -0,0 +1,19 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
source_group(
"CommandFeature\\Polygons"
FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake
)

View File

@ -0,0 +1,54 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewPolygonFeature.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonFeature, "RicNewPolygonFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFeature::onActionTriggered( bool isChecked )
{
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto newPolygon = polygonCollection->appendUserDefinedPolygon();
polygonCollection->uiCapability()->updateAllRequiredEditors();
RiuPlotMainWindowTools::setExpanded( newPolygon );
RiuPlotMainWindowTools::selectAsCurrentItem( newPolygon );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Polygon" );
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicNewPolygonFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022 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 "RicNewPolygonFileFeature.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonFile.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonFileFeature, "RicNewPolygonFileFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFileFeature::onActionTriggered( bool isChecked )
{
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto newPolygonFile = new RimPolygonFile();
newPolygonFile->setName( "File Polygon " + QString::number( polygonCollection->polygonFiles().size() + 1 ) );
polygonCollection->addPolygonFile( newPolygonFile );
polygonCollection->uiCapability()->updateAllRequiredEditors();
RiuPlotMainWindowTools::setExpanded( newPolygonFile );
RiuPlotMainWindowTools::selectAsCurrentItem( newPolygonFile );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFileFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New File Polygon" );
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicNewPolygonFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -31,6 +31,7 @@
#include "RigFormationNames.h"
#include "RigGeoMechCaseData.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseResultDefinition.h"
@ -153,7 +154,7 @@ void RimGeoMechView::onLoadDataAndUpdate()
onUpdateScaleTransform();
updateSurfacesInViewTreeItems();
updateViewTreeItems( RiaDefines::ItemIn3dView::ALL );
if ( m_geomechCase )
{
@ -319,6 +320,12 @@ void RimGeoMechView::onCreateDisplayModel()
m_seismicSectionCollection->appendPartsToModel( this, m_seismicVizModel.p(), transform.p(), femBBox );
nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() );
// Polygons
m_polygonVizModel->removeAllParts();
m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), femBBox );
nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() );
// Surfaces
m_surfaceVizModel->removeAllParts();
@ -1043,6 +1050,8 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() );
if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() );
uiTreeOrdering.add( m_polygonCollection );
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@ -0,0 +1,27 @@
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
)
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
)
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,115 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonAppearance.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_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::setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points )
{
m_pointsInDomainCoords = points;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimPolygon::pointsInDomainCoords() const
{
return m_pointsInDomainCoords();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygon::isClosed() const
{
return m_appearance->isClosed();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( nameField() );
uiOrdering.add( &m_isReadOnly );
auto groupPoints = uiOrdering.addNewGroup( "Points" );
groupPoints->setCollapsedByDefault();
groupPoints->add( &m_pointsInDomainCoords );
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();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
objectChanged.send();
}

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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimNamedObject.h"
#include "RimPolylinesDataInterface.h"
#include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cvfVector3.h"
class RimPolygonAppearance;
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;
bool isClosed() const;
cvf::ref<RigPolyLinesData> polyLinesData() const 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;
private:
caf::PdmField<bool> m_isReadOnly;
caf::PdmField<std::vector<cvf::Vec3d>> m_pointsInDomainCoords;
caf::PdmChildField<RimPolygonAppearance*> m_appearance;
};

View File

@ -0,0 +1,205 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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", false, "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 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 );
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,205 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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,362 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolylineTarget.h"
#include "RimTools.h"
#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h"
#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h"
#include "RiuGuiTheme.h"
#include "RivPolylinePartMgr.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafDisplayCoordTransform.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableViewEditor.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::configureEditorForField( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
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
{
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();
if ( m_polygon() ) uiOrdering.add( m_polygon );
uiOrdering.add( &m_enablePicking );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_enablePicking )
{
updateConnectedEditors();
}
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;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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_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 )
{
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,94 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 );
// RimPolylinesDataInterface
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;
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;
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;
private:
void updateNameField();
void updatePolygonFromTargets();
void updateTargetsFromPolygon();
private:
caf::PdmPtrField<RimPolygon*> m_polygon;
caf::PdmField<bool> m_enablePicking;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
};

View File

@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygon.h"
#include "RimPolygonCollection.h"
#include "RimPolygonInView.h"
#include "RimTools.h"
#include "cafDisplayCoordTransform.h"
#include "cvfModelBasicList.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;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::appendPartsToModel( cvf::ModelBasicList* model,
caf::DisplayCoordTransform* scaleTransform,
const cvf::BoundingBox& boundingBox )
{
for ( auto polygon : m_polygons )
{
if ( polygon && polygon->isChecked() )
{
polygon->appendPartsToModel( model, scaleTransform, boundingBox );
}
}
}

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimPolygonInView;
namespace cvf
{
class ModelBasicList;
class BoundingBox;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
} // namespace caf
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonInViewCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonInViewCollection();
void syncPolygonsInView();
void appendPartsToModel( cvf::ModelBasicList* model, caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
private:
caf::PdmChildArrayField<RimPolygonInView*> m_polygons;
};

View File

@ -1860,7 +1860,7 @@ void Rim3dView::onUpdateScaleTransform()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateSurfacesInViewTreeItems()
void Rim3dView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType )
{
// default is to do nothing
}

View File

@ -193,7 +193,7 @@ public:
RimViewLinker* assosiatedViewLinker() const override;
RimViewController* viewController() const override;
virtual void updateSurfacesInViewTreeItems();
virtual void updateViewTreeItems( RiaDefines::ItemIn3dView itemType );
RimAnnotationInViewCollection* annotationCollection() const;
void syncronizeLocalAnnotationsFromGlobal();

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 ) )
{

View File

@ -41,6 +41,7 @@
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimAnnotationCollection.h"
@ -647,6 +648,11 @@ void RimEclipseView::onCreateDisplayModel()
nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() );
}
// Polygons
m_polygonVizModel->removeAllParts();
m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), ownerCase()->allCellsBoundingBox() );
nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() );
// Well path model
m_wellPathPipeVizModel->removeAllParts();
@ -1077,7 +1083,7 @@ void RimEclipseView::appendStreamlinesToModel()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::onLoadDataAndUpdate()
{
updateSurfacesInViewTreeItems();
updateViewTreeItems( RiaDefines::ItemIn3dView::ALL );
onUpdateScaleTransform();
@ -1947,6 +1953,8 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() );
if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() );
uiTreeOrdering.add( m_polygonCollection );
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@ -18,6 +18,7 @@
#include "RimGridView.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
@ -96,6 +97,9 @@ RimGridView::RimGridView()
CAF_PDM_InitFieldNoDefault( &m_seismicSectionCollection, "SeismicSectionCollection", "Seismic Collection Field" );
m_seismicSectionCollection = new RimSeismicSectionCollection();
CAF_PDM_InitFieldNoDefault( &m_polygonCollection, "PolygonCollection", "Polygon Collection Field" );
m_polygonCollection = new RimPolygonInViewCollection();
CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" );
m_cellFilterCollection = new RimCellFilterCollection();
@ -104,6 +108,9 @@ RimGridView::RimGridView()
m_intersectionVizModel = new cvf::ModelBasicList;
m_intersectionVizModel->setName( "CrossSectionModel" );
m_polygonVizModel = new cvf::ModelBasicList;
m_polygonVizModel->setName( "PolygonModel" );
}
//--------------------------------------------------------------------------------------------------
@ -161,6 +168,14 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const
return m_seismicSectionCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection* RimGridView::polygonCollection() const
{
return m_polygonCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -455,23 +470,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_polygonCollection->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* polygonCollection() 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();
@ -90,6 +92,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,6 +107,7 @@ protected:
caf::PdmChildField<RimCellFilterCollection*> m_cellFilterCollection;
caf::PdmChildField<RimCellFilterCollection*> m_overrideCellFilterCollection;
caf::PdmChildField<RimSeismicSectionCollection*> m_seismicSectionCollection;
caf::PdmChildField<RimPolygonInViewCollection*> m_polygonCollection;
private:
void onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts ) override;

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

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor ASA
// 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
@ -16,10 +16,10 @@
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimPolylinePickerInterface.h"
#include "RimPolylineTarget.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

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:

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,7 @@ 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 ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() );
}
uiTreeOrdering.add( colorLegendCollection() );

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

@ -22,6 +22,7 @@
#include "RiuSeismicHistogramPanel.h"
#include "Rim3dView.h"
#include "RimPolylineTarget.h"
#include "RimRegularLegendConfig.h"
#include "RimSeismicAlphaMapper.h"
#include "RimSeismicDataInterface.h"

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

@ -302,7 +302,7 @@ void RimSurfaceCollection::updateViews( const std::vector<RimSurface*>& surfsToR
proj->allViews( views );
for ( auto view : views )
{
view->updateSurfacesInViewTreeItems();
view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE );
if ( auto gridView = dynamic_cast<RimGridView*>( view ) )
{
@ -355,7 +355,7 @@ void RimSurfaceCollection::updateViews()
for ( auto view : views )
{
view->updateSurfacesInViewTreeItems();
view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE );
}
for ( auto view : views )