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()
|
RimPolygon::RimPolygon()
|
||||||
: objectChanged( this )
|
: objectChanged( this )
|
||||||
|
, coordinatesChanged( this )
|
||||||
{
|
{
|
||||||
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
|
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
|
||||||
|
|
||||||
@ -83,8 +84,14 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
||||||
{
|
{
|
||||||
|
menuBuilder << "RicDuplicatePolygonFeature";
|
||||||
menuBuilder << "RicNewPolygonIntersectionFeature";
|
menuBuilder << "RicNewPolygonIntersectionFeature";
|
||||||
menuBuilder << "RicNewPolygonFilterFeature";
|
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 )
|
void RimPolygon::setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points )
|
||||||
{
|
{
|
||||||
m_pointsInDomainCoords = points;
|
m_pointsInDomainCoords = points;
|
||||||
|
|
||||||
objectChanged.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -187,13 +192,14 @@ void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons
|
|||||||
{
|
{
|
||||||
if ( changedField == &m_pointsInDomainCoords )
|
if ( changedField == &m_pointsInDomainCoords )
|
||||||
{
|
{
|
||||||
|
coordinatesChanged.send();
|
||||||
objectChanged.send();
|
objectChanged.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( changedField == &m_editPolygonButton )
|
if ( changedField == &m_editPolygonButton )
|
||||||
{
|
{
|
||||||
auto activeView = RiaApplication::instance()->activeReservoirView();
|
auto activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
RimPolygonTools::selectAndActivatePolygonInView( this, activeView );
|
RimPolygonTools::activate3dEditOfPolygonInView( this, activeView );
|
||||||
|
|
||||||
m_editPolygonButton = false;
|
m_editPolygonButton = false;
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
caf::Signal<> objectChanged;
|
caf::Signal<> objectChanged;
|
||||||
|
caf::Signal<> coordinatesChanged;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RimPolygon();
|
RimPolygon();
|
||||||
|
@ -52,10 +52,20 @@ void RimPolygonCollection::loadData()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
|
RimPolygon* RimPolygonCollection::createUserDefinedPolygon()
|
||||||
{
|
{
|
||||||
auto newPolygon = new RimPolygon();
|
auto newPolygon = new RimPolygon();
|
||||||
newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) );
|
newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) );
|
||||||
|
|
||||||
|
return newPolygon;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
|
||||||
|
{
|
||||||
|
auto newPolygon = createUserDefinedPolygon();
|
||||||
addUserDefinedPolygon( newPolygon );
|
addUserDefinedPolygon( newPolygon );
|
||||||
|
|
||||||
return newPolygon;
|
return newPolygon;
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
RimPolygonCollection();
|
RimPolygonCollection();
|
||||||
|
|
||||||
void loadData();
|
void loadData();
|
||||||
|
RimPolygon* createUserDefinedPolygon();
|
||||||
RimPolygon* appendUserDefinedPolygon();
|
RimPolygon* appendUserDefinedPolygon();
|
||||||
void addUserDefinedPolygon( RimPolygon* polygon );
|
void addUserDefinedPolygon( RimPolygon* polygon );
|
||||||
void deleteUserDefinedPolygons();
|
void deleteUserDefinedPolygons();
|
||||||
|
@ -90,18 +90,10 @@ RimPolygon* RimPolygonInView::polygon() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimPolygonInView::setPolygon( RimPolygon* polygon )
|
void RimPolygonInView::setPolygon( RimPolygon* polygon )
|
||||||
{
|
{
|
||||||
if ( m_polygon )
|
|
||||||
{
|
|
||||||
m_polygon->objectChanged.disconnect( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( polygon )
|
|
||||||
{
|
|
||||||
polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_polygon = polygon;
|
m_polygon = polygon;
|
||||||
|
|
||||||
|
connectSignals();
|
||||||
|
|
||||||
updateTargetsFromPolygon();
|
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();
|
updateVisualization();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimPolygonInView::onCoordinatesChanged( const caf::SignalEmitter* emitter )
|
||||||
|
{
|
||||||
|
updateTargetsFromPolygon();
|
||||||
|
|
||||||
|
updateConnectedEditors();
|
||||||
|
updateVisualization();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimPolygonInView::initAfterRead()
|
void RimPolygonInView::initAfterRead()
|
||||||
{
|
{
|
||||||
if ( m_polygon )
|
connectSignals();
|
||||||
{
|
|
||||||
m_polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -51,6 +51,7 @@ public:
|
|||||||
|
|
||||||
RimPolygon* polygon() const;
|
RimPolygon* polygon() const;
|
||||||
void setPolygon( RimPolygon* polygon );
|
void setPolygon( RimPolygon* polygon );
|
||||||
|
void updateTargetsFromPolygon();
|
||||||
|
|
||||||
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
|
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
|
||||||
void enablePicking( bool enable );
|
void enablePicking( bool enable );
|
||||||
@ -80,13 +81,14 @@ protected:
|
|||||||
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
|
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
|
||||||
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
||||||
void onObjectChanged( const caf::SignalEmitter* emitter );
|
void onObjectChanged( const caf::SignalEmitter* emitter );
|
||||||
|
void onCoordinatesChanged( const caf::SignalEmitter* emitter );
|
||||||
void initAfterRead() override;
|
void initAfterRead() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateNameField();
|
void updateNameField();
|
||||||
|
|
||||||
void updatePolygonFromTargets();
|
void updatePolygonFromTargets();
|
||||||
void updateTargetsFromPolygon();
|
void connectSignals();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmPtrField<RimPolygon*> m_polygon;
|
caf::PdmPtrField<RimPolygon*> m_polygon;
|
||||||
|
@ -223,6 +223,7 @@ void RimPolygonInViewCollection::syncPolygonsWithView()
|
|||||||
{
|
{
|
||||||
newPolygonsInView.push_back( *it );
|
newPolygonsInView.push_back( *it );
|
||||||
existingPolygonsInView.erase( it );
|
existingPolygonsInView.erase( it );
|
||||||
|
( *it )->updateTargetsFromPolygon();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user