Skip to content

Commit

Permalink
Make well targets obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 21, 2024
1 parent 7f80d58 commit e20f91b
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h"

#include "Riu3DMainWindowTools.h"

Expand Down Expand Up @@ -123,6 +124,12 @@ RimPolygonFilter::RimPolygonFilter()
m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );

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();
Expand Down Expand Up @@ -179,6 +186,18 @@ void RimPolygonFilter::initAfterRead()
{
RimCellFilter::initAfterRead();

// 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() );
}

m_internalPolygon->setPointsInDomainCoords( points );
}

configurePolygonEditor();
}

Expand Down Expand Up @@ -297,7 +316,7 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField
{
if ( changedField == &m_editPolygonButton )
{
if ( m_cellFilterPolygon() ) Riu3DMainWindowTools::selectAsCurrentItem( m_cellFilterPolygon() );
RimPolygonTools::selectPolygonInView( m_cellFilterPolygon(), this );

m_editPolygonButton = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
#include "RimPolylinePickerInterface.h"

#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"

class RimPolygon;
class RimPolylineTarget;
class RigGridBase;
class RigFemPartGrid;
class RimPolygonInView;
Expand Down Expand Up @@ -148,4 +150,6 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface
caf::PdmField<bool> m_editPolygonButton;

std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;

caf::PdmChildArrayField<RimPolylineTarget*> m_OBSOLETE_targets;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand Down
64 changes: 64 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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;
}
36 changes: 36 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h
Original file line number Diff line number Diff line change
@@ -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 );
};

0 comments on commit e20f91b

Please sign in to comment.