mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use signal to notify listeners when coordinates of a polygon changes
This commit is contained in:
parent
5d640b91d2
commit
5217ab5c8b
@ -41,6 +41,7 @@ CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolygon::RimPolygon()
|
||||
: objectChanged( this )
|
||||
, coordinatesChanged( this )
|
||||
{
|
||||
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
|
||||
|
||||
@ -83,8 +84,14 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
||||
{
|
||||
menuBuilder << "RicDuplicatePolygonFeature";
|
||||
menuBuilder << "RicNewPolygonIntersectionFeature";
|
||||
menuBuilder << "RicNewPolygonFilterFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicExportPolygonCsvFeature";
|
||||
menuBuilder << "RicExportPolygonPolFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicSimplifyPolygonFeature";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -93,8 +100,6 @@ void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) cons
|
||||
void RimPolygon::setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points )
|
||||
{
|
||||
m_pointsInDomainCoords = points;
|
||||
|
||||
objectChanged.send();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -187,13 +192,14 @@ void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons
|
||||
{
|
||||
if ( changedField == &m_pointsInDomainCoords )
|
||||
{
|
||||
coordinatesChanged.send();
|
||||
objectChanged.send();
|
||||
}
|
||||
|
||||
if ( changedField == &m_editPolygonButton )
|
||||
{
|
||||
auto activeView = RiaApplication::instance()->activeReservoirView();
|
||||
RimPolygonTools::selectAndActivatePolygonInView( this, activeView );
|
||||
RimPolygonTools::activate3dEditOfPolygonInView( this, activeView );
|
||||
|
||||
m_editPolygonButton = false;
|
||||
|
||||
|
@ -40,6 +40,7 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface
|
||||
|
||||
public:
|
||||
caf::Signal<> objectChanged;
|
||||
caf::Signal<> coordinatesChanged;
|
||||
|
||||
public:
|
||||
RimPolygon();
|
||||
|
@ -52,10 +52,20 @@ void RimPolygonCollection::loadData()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
|
||||
RimPolygon* RimPolygonCollection::createUserDefinedPolygon()
|
||||
{
|
||||
auto newPolygon = new RimPolygon();
|
||||
newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) );
|
||||
|
||||
return newPolygon;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
|
||||
{
|
||||
auto newPolygon = createUserDefinedPolygon();
|
||||
addUserDefinedPolygon( newPolygon );
|
||||
|
||||
return newPolygon;
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
RimPolygonCollection();
|
||||
|
||||
void loadData();
|
||||
RimPolygon* createUserDefinedPolygon();
|
||||
RimPolygon* appendUserDefinedPolygon();
|
||||
void addUserDefinedPolygon( RimPolygon* polygon );
|
||||
void deleteUserDefinedPolygons();
|
||||
|
@ -90,18 +90,10 @@ RimPolygon* RimPolygonInView::polygon() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolygonInView::setPolygon( RimPolygon* polygon )
|
||||
{
|
||||
if ( m_polygon )
|
||||
{
|
||||
m_polygon->objectChanged.disconnect( this );
|
||||
}
|
||||
|
||||
if ( polygon )
|
||||
{
|
||||
polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged );
|
||||
}
|
||||
|
||||
m_polygon = polygon;
|
||||
|
||||
connectSignals();
|
||||
|
||||
updateTargetsFromPolygon();
|
||||
}
|
||||
|
||||
@ -244,6 +236,18 @@ void RimPolygonInView::updatePolygonFromTargets()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolygonInView::connectSignals()
|
||||
{
|
||||
if ( m_polygon )
|
||||
{
|
||||
m_polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged );
|
||||
m_polygon->coordinatesChanged.connect( this, &RimPolygonInView::onCoordinatesChanged );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -381,15 +385,23 @@ void RimPolygonInView::onObjectChanged( const caf::SignalEmitter* emitter )
|
||||
updateVisualization();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolygonInView::onCoordinatesChanged( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
updateTargetsFromPolygon();
|
||||
|
||||
updateConnectedEditors();
|
||||
updateVisualization();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolygonInView::initAfterRead()
|
||||
{
|
||||
if ( m_polygon )
|
||||
{
|
||||
m_polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged );
|
||||
}
|
||||
connectSignals();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
|
||||
RimPolygon* polygon() const;
|
||||
void setPolygon( RimPolygon* polygon );
|
||||
void updateTargetsFromPolygon();
|
||||
|
||||
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
|
||||
void enablePicking( bool enable );
|
||||
@ -80,13 +81,14 @@ protected:
|
||||
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
|
||||
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
||||
void onObjectChanged( const caf::SignalEmitter* emitter );
|
||||
void onCoordinatesChanged( const caf::SignalEmitter* emitter );
|
||||
void initAfterRead() override;
|
||||
|
||||
private:
|
||||
void updateNameField();
|
||||
|
||||
void updatePolygonFromTargets();
|
||||
void updateTargetsFromPolygon();
|
||||
void connectSignals();
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimPolygon*> m_polygon;
|
||||
|
@ -223,6 +223,7 @@ void RimPolygonInViewCollection::syncPolygonsWithView()
|
||||
{
|
||||
newPolygonsInView.push_back( *it );
|
||||
existingPolygonsInView.erase( it );
|
||||
( *it )->updateTargetsFromPolygon();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user