mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
parent
055c0d4c8c
commit
a3d520e26e
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RicNewPolygonFilter3dviewFeature.h"
|
||||
|
||||
#include "Polygons/RimPolygonInView.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCellFilterCollection.h"
|
||||
|
@ -18,9 +18,12 @@
|
||||
|
||||
#include "RicNewPolygonFilterFeature.h"
|
||||
|
||||
#include "Polygons/RimPolygonInView.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimPolygonFilter.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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
|
||||
|
@ -30,7 +30,6 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h
|
||||
)
|
||||
|
||||
@ -66,7 +65,6 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp
|
||||
)
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RicPointTangentManipulator.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimPolylinePickerInterface.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
@ -96,8 +97,13 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
|
||||
|
||||
const double handleScalingFactor = 0.7;
|
||||
const double handleSize = handleScalingFactor * view->characteristicCellSize();
|
||||
double scalingFactor = 0.7;
|
||||
if ( auto pickerInterface = target->firstAncestorOrThisOfType<RimPolylinePickerInterface>() )
|
||||
{
|
||||
scalingFactor *= pickerInterface->scalingFactorForTarget();
|
||||
}
|
||||
|
||||
const double handleSize = scalingFactor * view->characteristicCellSize();
|
||||
|
||||
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) );
|
||||
m_manipulator->setHandleSize( handleSize );
|
||||
|
@ -1,83 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "RicAppendPointsToPolygonFilterFeature.h"
|
||||
|
||||
#include "RiaTextStringTools.h"
|
||||
|
||||
#include "RimPolygonFilter.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
|
||||
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled() const
|
||||
{
|
||||
auto obj = caf::firstAncestorOfTypeFromSelectedObject<RimPolygonFilter>();
|
||||
return obj != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto polygonFilter = caf::firstAncestorOfTypeFromSelectedObject<RimPolygonFilter>();
|
||||
if ( !polygonFilter ) return;
|
||||
|
||||
QStringList listOfThreeDoubles;
|
||||
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if ( clipboard )
|
||||
{
|
||||
QString content = clipboard->text();
|
||||
listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" );
|
||||
}
|
||||
|
||||
std::vector<cvf::Vec3d> points;
|
||||
caf::PdmValueFieldSpecialization<std::vector<cvf::Vec3d>>::setFromVariant( listOfThreeDoubles, points );
|
||||
|
||||
for ( const auto& p : points )
|
||||
{
|
||||
auto newTarget = new RimPolylineTarget;
|
||||
newTarget->setAsPointTargetXYD( p );
|
||||
polygonFilter->insertTarget( nullptr, newTarget );
|
||||
}
|
||||
|
||||
polygonFilter->updateEditorsAndVisualization();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendPointsToPolygonFilterFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Append Points from Clipboard" );
|
||||
|
||||
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
|
||||
}
|
@ -54,7 +54,6 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.h
|
||||
@ -112,7 +111,6 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.cpp
|
||||
|
@ -1,88 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021 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 "RivCellFilterPartMgr.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimPolygonFilter.h"
|
||||
|
||||
#include "RivPolylinePartMgr.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view )
|
||||
: m_rimView( view )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivCellFilterPartMgr::~RivCellFilterPartMgr()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::BoundingBox& boundingBox )
|
||||
{
|
||||
createCellFilterPartManagers();
|
||||
|
||||
for ( auto& partMgr : m_cellFilterPartMgrs )
|
||||
{
|
||||
partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCellFilterPartMgr::createCellFilterPartManagers()
|
||||
{
|
||||
std::vector<RimCellFilterCollection*> colls = m_rimView->descendantsIncludingThisOfType<RimCellFilterCollection>();
|
||||
|
||||
if ( colls.empty() ) return;
|
||||
auto coll = colls.front();
|
||||
|
||||
clearGeometryCache();
|
||||
|
||||
for ( auto filter : coll->filters() )
|
||||
{
|
||||
RimPolygonFilter* polyFilter = dynamic_cast<RimPolygonFilter*>( filter );
|
||||
if ( polyFilter )
|
||||
{
|
||||
RivPolylinePartMgr* ppm = new RivPolylinePartMgr( m_rimView, polyFilter, coll );
|
||||
m_cellFilterPartMgrs.push_back( ppm );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCellFilterPartMgr::clearGeometryCache()
|
||||
{
|
||||
m_cellFilterPartMgrs.clear();
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021 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 "cafPdmPointer.h"
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfCollection.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class BoundingBox;
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Font;
|
||||
} // namespace cvf
|
||||
namespace caf
|
||||
{
|
||||
class DisplayCoordTransform;
|
||||
}
|
||||
|
||||
class Rim3dView;
|
||||
class RivPolylinePartMgr;
|
||||
|
||||
class RivCellFilterPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivCellFilterPartMgr( Rim3dView* view );
|
||||
~RivCellFilterPartMgr() override;
|
||||
|
||||
void appendGeometryPartsToModel( cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::BoundingBox& boundingBox );
|
||||
|
||||
void clearGeometryCache();
|
||||
|
||||
private:
|
||||
void createCellFilterPartManagers();
|
||||
|
||||
private:
|
||||
caf::PdmPointer<Rim3dView> m_rimView;
|
||||
cvf::Collection<RivPolylinePartMgr> m_cellFilterPartMgrs;
|
||||
};
|
@ -260,6 +260,7 @@ RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase
|
||||
RimPolygonFilter* pFilter = new RimPolygonFilter();
|
||||
pFilter->setCase( srcCase );
|
||||
addFilter( pFilter );
|
||||
pFilter->configurePolygonEditor();
|
||||
pFilter->enablePicking( true );
|
||||
onFilterUpdated( pFilter );
|
||||
return pFilter;
|
||||
@ -485,3 +486,21 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPolygonInView*> RimCellFilterCollection::cellFilterPolygons() const
|
||||
{
|
||||
std::vector<RimPolygonInView*> polyInView;
|
||||
|
||||
for ( const auto& filter : m_cellFilters )
|
||||
{
|
||||
if ( auto polygonFilter = dynamic_cast<RimPolygonFilter*>( filter.p() ) )
|
||||
{
|
||||
polyInView.push_back( polygonFilter->polygonInView() );
|
||||
}
|
||||
}
|
||||
|
||||
return polyInView;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class RimPolygonFilter;
|
||||
class RimUserDefinedFilter;
|
||||
class RimUserDefinedIndexFilter;
|
||||
class RimCase;
|
||||
class RimPolygonInView;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@ -69,7 +70,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*> cellFilterPolygons() const;
|
||||
std::vector<RimCellFilter*> filters() const;
|
||||
|
||||
bool hasActiveFilters() const;
|
||||
bool hasActiveIncludeIndexFilters() const;
|
||||
|
@ -20,39 +20,28 @@
|
||||
|
||||
#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 +64,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 +97,45 @@ 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" );
|
||||
m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -238,32 +182,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 +206,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 +224,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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -357,36 +239,30 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
|
||||
{
|
||||
uiOrdering.add( &m_name );
|
||||
|
||||
auto dataSourceGroup = uiOrdering.addNewGroup( "Polygon Data Source" );
|
||||
dataSourceGroup->add( &m_polygonDataSource );
|
||||
if ( !isPolygonDefinedLocally() )
|
||||
{
|
||||
dataSourceGroup->add( &m_cellFilterPolygon );
|
||||
dataSourceGroup->add( &m_editPolygonButton, { .newRow = false } );
|
||||
}
|
||||
|
||||
auto group = uiOrdering.addNewGroup( "General" );
|
||||
group->add( &m_filterMode );
|
||||
group->add( &m_geometricalShape );
|
||||
group->add( &m_enableFiltering );
|
||||
group->add( &m_closePolygon );
|
||||
|
||||
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 +278,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 +287,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 +318,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::selectPolygonInView( 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 +363,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 +486,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 +494,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 +537,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 +555,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 +623,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 +742,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 +768,17 @@ void RimPolygonFilter::updateCells()
|
||||
|
||||
// get polyline as vector
|
||||
std::vector<cvf::Vec3d> points;
|
||||
for ( auto& target : m_targets )
|
||||
|
||||
for ( auto target : m_polygonEditor->activeTargets() )
|
||||
{
|
||||
points.push_back( target->targetPointXYZ() );
|
||||
}
|
||||
|
||||
// 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 +796,114 @@ 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 )
|
||||
{
|
||||
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
|
||||
{
|
||||
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 +920,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
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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,31 @@ public:
|
||||
};
|
||||
|
||||
RimPolygonFilter();
|
||||
~RimPolygonFilter() override;
|
||||
|
||||
void enableFilter( bool bEnable );
|
||||
void enableKFilter( bool bEnable );
|
||||
|
||||
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 +111,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;
|
||||
};
|
||||
|
@ -322,10 +322,7 @@ void RimGeoMechView::onCreateDisplayModel()
|
||||
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() );
|
||||
appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() );
|
||||
|
||||
// Surfaces
|
||||
|
||||
@ -1053,7 +1050,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
|
||||
if ( RiaApplication::enableDevelopmentFeatures() )
|
||||
{
|
||||
uiTreeOrdering.add( m_polygonCollection );
|
||||
uiTreeOrdering.add( m_polygonInViewCollection );
|
||||
}
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
|
@ -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})
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
|
||||
void applyAppearanceSettings( RigPolyLinesData* polyLinesData );
|
||||
|
||||
void setIsClosed( bool isClosed );
|
||||
bool isClosed() const;
|
||||
|
||||
public:
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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
|
||||
@ -18,17 +18,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
class RimPolygon;
|
||||
class RimPolygonInView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAppendPointsToPolygonFilterFeature : public caf::CmdFeature
|
||||
namespace caf
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() const override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
class RimPolygonTools
|
||||
{
|
||||
public:
|
||||
static void selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
|
||||
|
||||
private:
|
||||
static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
|
||||
};
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -52,7 +52,6 @@ class RiuViewer;
|
||||
class RivAnnotationsPartMgr;
|
||||
class RivMeasurementPartMgr;
|
||||
class RivWellPathsPartMgr;
|
||||
class RivCellFilterPartMgr;
|
||||
class RimViewNameConfig;
|
||||
|
||||
namespace cvf
|
||||
@ -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;
|
||||
|
@ -650,9 +650,7 @@ void RimEclipseView::onCreateDisplayModel()
|
||||
}
|
||||
|
||||
// Polygons
|
||||
m_polygonVizModel->removeAllParts();
|
||||
m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), ownerCase()->allCellsBoundingBox() );
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() );
|
||||
appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() );
|
||||
|
||||
// Well path model
|
||||
m_wellPathPipeVizModel->removeAllParts();
|
||||
@ -1956,7 +1954,7 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
|
||||
if ( RiaApplication::enableDevelopmentFeatures() )
|
||||
{
|
||||
uiTreeOrdering.add( m_polygonCollection );
|
||||
uiTreeOrdering.add( m_polygonInViewCollection );
|
||||
}
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "RimGridView.h"
|
||||
|
||||
#include "Polygons/RimPolygonInViewCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
@ -42,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"
|
||||
@ -97,8 +99,8 @@ 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_polygonInViewCollection, "PolygonInViewCollection", "Polygon Collection Field" );
|
||||
m_polygonInViewCollection = new RimPolygonInViewCollection();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" );
|
||||
m_cellFilterCollection = new RimCellFilterCollection();
|
||||
@ -171,9 +173,9 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolygonInViewCollection* RimGridView::polygonCollection() const
|
||||
RimPolygonInViewCollection* RimGridView::polygonInViewCollection() const
|
||||
{
|
||||
return m_polygonCollection();
|
||||
return m_polygonInViewCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -395,6 +397,36 @@ 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 )
|
||||
{
|
||||
polygonsInView = m_polygonInViewCollection->polygonsInView();
|
||||
}
|
||||
|
||||
if ( cellFilterCollection() )
|
||||
{
|
||||
auto cellFilterPolygonsInView = cellFilterCollection()->cellFilterPolygons();
|
||||
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() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -495,7 +527,7 @@ void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType )
|
||||
|
||||
if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) )
|
||||
{
|
||||
m_polygonCollection->syncPolygonsInView();
|
||||
m_polygonInViewCollection->syncPolygonsInView();
|
||||
}
|
||||
|
||||
updateConnectedEditors();
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const;
|
||||
RimWellMeasurementInViewCollection* measurementCollection() const;
|
||||
RimSeismicSectionCollection* seismicSectionCollection() const;
|
||||
RimPolygonInViewCollection* polygonCollection() const;
|
||||
RimPolygonInViewCollection* polygonInViewCollection() const;
|
||||
|
||||
virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0;
|
||||
|
||||
@ -80,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;
|
||||
@ -107,11 +108,12 @@ protected:
|
||||
caf::PdmChildField<RimCellFilterCollection*> m_cellFilterCollection;
|
||||
caf::PdmChildField<RimCellFilterCollection*> m_overrideCellFilterCollection;
|
||||
caf::PdmChildField<RimSeismicSectionCollection*> m_seismicSectionCollection;
|
||||
caf::PdmChildField<RimPolygonInViewCollection*> m_polygonCollection;
|
||||
caf::PdmChildField<RimPolygonInViewCollection*> m_polygonInViewCollection;
|
||||
|
||||
private:
|
||||
void onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts ) override;
|
||||
|
||||
private:
|
||||
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;
|
||||
bool m_previousGridModeMeshLinesWasFaults;
|
||||
};
|
||||
|
@ -20,6 +20,14 @@
|
||||
|
||||
#include "RimPolylineTarget.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimPolylinePickerInterface::scalingFactorForTarget() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -38,6 +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 );
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user