Use project polygons from polygon cell filter

* Use RimPolygonInView to edit locally defined polygon
* Add scaling to polygon in view
* Move polygon line visualization to RimGridView
* Rename to polygonInViewCollection
* Show appearance for local polygon
This commit is contained in:
Magne Sjaastad
2024-02-22 15:13:29 +01:00
committed by GitHub
parent 055c0d4c8c
commit a3d520e26e
32 changed files with 582 additions and 645 deletions

View File

@@ -5,6 +5,7 @@ set(SOURCE_GROUP_HEADER_FILES
${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
@@ -14,6 +15,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${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})

View File

@@ -53,6 +53,14 @@ cvf::ref<RigPolyLinesData> RimPolygon::polyLinesData() const
return pld;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
m_appearance->uiOrdering( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -71,6 +79,14 @@ std::vector<cvf::Vec3d> RimPolygon::pointsInDomainCoords() const
return m_pointsInDomainCoords();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setIsClosed( bool isClosed )
{
m_appearance->setIsClosed( isClosed );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -40,10 +40,13 @@ public:
void setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points );
std::vector<cvf::Vec3d> pointsInDomainCoords() const;
void setIsClosed( bool isClosed );
bool isClosed() const;
cvf::ref<RigPolyLinesData> polyLinesData() const 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;

View File

@@ -78,7 +78,7 @@ RimPolygonAppearance::RimPolygonAppearance()
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitField( &m_isClosed, "IsClosed", false, "Closed Polygon" );
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" );
@@ -106,6 +106,15 @@ void RimPolygonAppearance::applyAppearanceSettings( RigPolyLinesData* polyLinesD
polyLinesData->setVisibility( m_showLines, m_showSpheres );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::setIsClosed( bool isClosed )
{
m_isClosed = isClosed;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -34,6 +34,7 @@ public:
void applyAppearanceSettings( RigPolyLinesData* polyLinesData );
void setIsClosed( bool isClosed );
bool isClosed() const;
public:

View File

@@ -58,6 +58,8 @@ RimPolygonInView::RimPolygonInView()
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
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 );
@@ -243,6 +245,8 @@ void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
updateNameField();
uiOrdering.add( &m_handleScalingFactor );
if ( m_polygon() ) uiOrdering.add( m_polygon );
uiOrdering.add( &m_enablePicking );
}
@@ -288,6 +292,24 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_enablePicking );
uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPolygonInView::scalingFactorForTarget() const
{
return m_handleScalingFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -55,7 +55,6 @@ public:
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;
@@ -63,12 +62,15 @@ public:
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;
@@ -87,6 +89,7 @@ private:
caf::PdmPtrField<RimPolygon*> m_polygon;
caf::PdmField<bool> m_enablePicking;
caf::PdmField<double> m_handleScalingFactor;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;

View File

@@ -23,10 +23,6 @@
#include "RimPolygonInView.h"
#include "RimTools.h"
#include "cafDisplayCoordTransform.h"
#include "cvfModelBasicList.h"
CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
//--------------------------------------------------------------------------------------------------
@@ -83,15 +79,7 @@ void RimPolygonInViewCollection::syncPolygonsInView()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::appendPartsToModel( cvf::ModelBasicList* model,
caf::DisplayCoordTransform* scaleTransform,
const cvf::BoundingBox& boundingBox )
std::vector<RimPolygonInView*> RimPolygonInViewCollection::polygonsInView() const
{
for ( auto polygon : m_polygons )
{
if ( polygon && polygon->isChecked() )
{
polygon->appendPartsToModel( model, scaleTransform, boundingBox );
}
}
return m_polygons.childrenByType();
}

View File

@@ -23,17 +23,6 @@
class RimPolygonInView;
namespace cvf
{
class ModelBasicList;
class BoundingBox;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
} // namespace caf
//==================================================================================================
///
///
@@ -47,7 +36,7 @@ public:
void syncPolygonsInView();
void appendPartsToModel( cvf::ModelBasicList* model, caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
std::vector<RimPolygonInView*> polygonsInView() const;
private:
caf::PdmChildArrayField<RimPolygonInView*> m_polygons;

View File

@@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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::selectPolygonInView( 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 ( auto gridView = sourceObject->firstAncestorOfType<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 selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
private:
static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
};