SHAPER  9.12.0
SketchSolver_Manager Class Reference

Listens the changes of SketchPlugin features and transforms the Constraint feature into the format understandable by sketch solver. More...

Inheritance diagram for SketchSolver_Manager:
Inheritance graph

Public Member Functions

virtual void processEvent (const std::shared_ptr< Events_Message > &theMessage)
 Implementation of Event Listener method. More...
 
virtual bool groupMessages ()
 The solver needs all the updated objects are transfered in one group, not one by one. More...
 

Static Public Member Functions

static SketchSolver_Managerinstance ()
 Main method to create constraint manager. More...
 

Protected Member Functions

bool updateFeature (const std::shared_ptr< SketchPlugin_Feature > &theFeature)
 Adds or updates a constraint or an entity in the suitable group. More...
 
bool updateSketch (const std::shared_ptr< ModelAPI_CompositeFeature > &theSketch)
 Updates the sketch and related constraints, if the sketch plane is changed. More...
 
bool moveFeature (const std::shared_ptr< SketchPlugin_Feature > &theMovedFeature, const std::shared_ptr< GeomAPI_Pnt2d > &theFromPoint, const std::shared_ptr< GeomAPI_Pnt2d > &theToPoint)
 Move feature. More...
 
bool moveAttribute (const std::shared_ptr< ModelAPI_Attribute > &theMovedAttribute, const int theMovedPointIndex, const std::shared_ptr< GeomAPI_Pnt2d > &theFromPoint, const std::shared_ptr< GeomAPI_Pnt2d > &theToPoint)
 Move feature using its moved attribute. More...
 
bool removeConstraint (std::shared_ptr< SketchPlugin_Constraint > theConstraint)
 Removes a constraint from the manager. More...
 
bool resolveConstraints ()
 Goes through the list of groups and solve the constraints. More...
 
void groupWhileFlush (const std::shared_ptr< Events_Message > &theMessage)
 Allows to group messages while they are flushed (for flush for groupMessages=true listeners) More...
 
EVENTS_EXPORT void flushGrouped (const Events_ID &theID)
 Sends myGroups on flush finish. More...
 

Detailed Description

Listens the changes of SketchPlugin features and transforms the Constraint feature into the format understandable by sketch solver.

Remarks
This is a singleton.

Member Function Documentation

◆ instance()

SketchSolver_Manager * SketchSolver_Manager::instance ( )
static

Main method to create constraint manager.

Returns
pointer to the singleton

◆ processEvent()

void SketchSolver_Manager::processEvent ( const std::shared_ptr< Events_Message > &  theMessage)
virtual

Implementation of Event Listener method.

Parameters
[in]theMessagethe data of the event

Implements Events_Listener.

◆ groupMessages()

bool SketchSolver_Manager::groupMessages ( )
virtual

The solver needs all the updated objects are transfered in one group, not one by one.

This iscreases performance and avoids problems in resolve of only part of the made updates.

Reimplemented from Events_Listener.

◆ updateFeature()

bool SketchSolver_Manager::updateFeature ( const std::shared_ptr< SketchPlugin_Feature > &  theFeature)
protected

Adds or updates a constraint or an entity in the suitable group.

Parameters
[in]theFeaturesketch feature to be changed
Returns
true if the feature changed successfully

◆ updateSketch()

bool SketchSolver_Manager::updateSketch ( const std::shared_ptr< ModelAPI_CompositeFeature > &  theSketch)
protected

Updates the sketch and related constraints, if the sketch plane is changed.

Parameters
[in]theSketchsketch to be updated
Returns
true if the sketch plane is changed

◆ moveFeature()

bool SketchSolver_Manager::moveFeature ( const std::shared_ptr< SketchPlugin_Feature > &  theMovedFeature,
const std::shared_ptr< GeomAPI_Pnt2d > &  theFromPoint,
const std::shared_ptr< GeomAPI_Pnt2d > &  theToPoint 
)
protected

Move feature.

Parameters
[in]theMovedFeaturedragged sketch feature
[in]theFromPointoriginal position of the feature
[in]theToPointprefereble position of the feature (current position of the mouse)
Returns
true if the feature has been changed successfully

◆ moveAttribute()

bool SketchSolver_Manager::moveAttribute ( const std::shared_ptr< ModelAPI_Attribute > &  theMovedAttribute,
const int  theMovedPointIndex,
const std::shared_ptr< GeomAPI_Pnt2d > &  theFromPoint,
const std::shared_ptr< GeomAPI_Pnt2d > &  theToPoint 
)
protected

Move feature using its moved attribute.

Parameters
[in]theMovedAttributedragged point (array of points) attribute of sketch feature
[in]theMovedPointIndexindex of dragged point in an array (-1 otherwise)
[in]theFromPointoriginal position of the moved point
[in]theToPointprefereble position (current position of the mouse)
Returns
true if the attribute owner has been changed successfully

◆ removeConstraint()

bool SketchSolver_Manager::removeConstraint ( std::shared_ptr< SketchPlugin_Constraint theConstraint)
protected

Removes a constraint from the manager.

Parameters
[in]theConstraintconstraint to be removed
Returns
true if the constraint removed successfully

◆ resolveConstraints()

bool SketchSolver_Manager::resolveConstraints ( )
protected

Goes through the list of groups and solve the constraints.

Returns
true, if groups are resolved, and features should be updated (send the Update event)

◆ groupWhileFlush()

void Events_Listener::groupWhileFlush ( const std::shared_ptr< Events_Message > &  theMessage)
protectedinherited

Allows to group messages while they are flushed (for flush for groupMessages=true listeners)

◆ flushGrouped()

void Events_Listener::flushGrouped ( const Events_ID theID)
protectedinherited

Sends myGroups on flush finish.