Skip to content

Commit

Permalink
Prepare for polygon edit
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 19, 2024
1 parent 356e69c commit bf4bd42
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 3 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
updateNameField();

uiOrdering.add( &m_handleScalingFactor );

if ( m_polygon() ) uiOrdering.add( m_polygon );
uiOrdering.add( m_polygon );
uiOrdering.add( &m_enablePicking );

uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
uiOrdering.skipRemainingFields();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ void RimPolygonInViewCollection::appendPartsToModel( cvf::ModelBasicList*
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimPolygonInViewCollection::polygonsInView() const
{
return m_polygons.childrenByType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cafPdmObject.h"

class RimPolygonInView;
class RimPolygon;

namespace cvf
{
Expand Down Expand Up @@ -49,6 +50,8 @@ class RimPolygonInViewCollection : public caf::PdmObject

void appendPartsToModel( cvf::ModelBasicList* model, caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );

std::vector<RimPolygonInView*> polygonsInView() const;

private:
caf::PdmChildArrayField<RimPolygonInView*> m_polygons;
};
46 changes: 46 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RimPolygonTools.h"

#include "RimGridView.h"
#include "RimPolygonInView.h"
#include "RimPolygonInViewCollection.h"

#include "Riu3DMainWindowTools.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonTools::selectPolygonInView( 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 )
{
Riu3DMainWindowTools::selectAsCurrentItem( polygonInView );

return;
}
}
}
}
32 changes: 32 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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;

namespace caf
{
class PdmObject;
}

class RimPolygonTools
{
public:
static void selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
};

0 comments on commit bf4bd42

Please sign in to comment.