From: vsv Date: Tue, 8 Oct 2019 15:41:57 +0000 (+0300) Subject: Task #2997: Show objects with DoF X-Git-Tag: V9_5_0a1~167^2~95 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=81f7aa2dd35db69a5da6c2698da62af56d79c007;p=modules%2Fshaper.git Task #2997: Show objects with DoF --- diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index 042c06a41..f424d4214 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -101,6 +101,12 @@ static const char * EVENT_STABILITY_CHANGED = "StabilityChanged"; /// Event ID that the sketch is prepared and all grouped messages for the solver may be flushed static const char * EVENT_SKETCH_PREPARED = "SketchPrepared"; +/// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0 +static const char * EVENT_GET_DOF_OBJECTS = "GetDoFObjects"; + +/// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0 +static const char * EVENT_DOF_OBJECTS = "DoFObjects"; + /// Message that feature was changed (used for Object Browser update): moved, updated and deleted class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup { diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 1c88fc4f6..aa639e247 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -118,6 +118,8 @@ #include #include +#include + //#define DEBUG_DO_NOT_BY_ENTER //#define DEBUG_SKETCHER_ENTITIES //#define DEBUG_SKETCH_ENTITIES_ON_MOVE @@ -201,6 +203,8 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) registerSelectionFilter(SF_SketchCirclePointFilter, new PartSet_CirclePointFilter(anIWorkshop)); registerSelectionFilter(SF_SketchPlaneFilter, new ModuleBase_ShapeInPlaneFilter()); + + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_DOF_OBJECTS)); } PartSet_SketcherMgr::~PartSet_SketcherMgr() @@ -2113,6 +2117,30 @@ void PartSet_SketcherMgr::onShowPoints(bool toShow) aViewer->update(); } +void PartSet_SketcherMgr::processEvent(const std::shared_ptr& theMessage) +{ + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOF_OBJECTS)) { + std::shared_ptr anUpdateMsg = + std::dynamic_pointer_cast(theMessage); + std::set aObjects = anUpdateMsg->objects(); + std::set::const_iterator aIt; + QList aPrsList; + for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) { + FeaturePtr aFeature = std::dynamic_pointer_cast(*aIt); + if (aFeature.get()) { + std::list aRes = aFeature->results(); + std::list::const_iterator aIt; + for (aIt = aRes.cbegin(); aIt != aRes.cend(); ++aIt) { + ModuleBase_ViewerPrsPtr aPrsPtr(new ModuleBase_ViewerPrs(*aIt)); + aPrsList.append(aPrsPtr); + } + } + } + if (aPrsList.size() > 0) { + myModule->workshop()->setSelected(aPrsList); + } + } +} void PartSet_Fitter::fitAll(Handle(V3d_View) theView) { diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 7259514a4..24e6347d1 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -97,7 +98,7 @@ private: displayed in the viewer. After the sketch create/edit operation is finished, the sub-feature are hidden, the sketch feature result is displayed */ -class PARTSET_EXPORT PartSet_SketcherMgr : public QObject +class PARTSET_EXPORT PartSet_SketcherMgr : public QObject, public Events_Listener { Q_OBJECT /// Struct to define gp point, with the state is the point is initialized @@ -371,6 +372,11 @@ public: PartSet_Module* module() const { return myModule; } + /** \brief Implementation of Event Listener method + * \param[in] theMessage the data of the event + */ + virtual void processEvent(const std::shared_ptr& theMessage); + public slots: /// Process sketch plane selected event void onPlaneSelected(const std::shared_ptr& thePln); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 2d9fd7d4f..1f969d0eb 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -761,7 +762,9 @@ bool PartSet_WidgetSketchLabel::restoreValueCustom() myShowDOFBtn->hide(); } else { myDoFLabel->setText(tr("DoF (degrees of freedom) = ") + aVal); - myShowDOFBtn->show(); + CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast(myFeature); + if (aCompFeature.get() && aCompFeature->numberOfSubs() > 1) + myShowDOFBtn->show(); } } } @@ -776,5 +779,10 @@ bool PartSet_WidgetSketchLabel::restoreValueCustom() void PartSet_WidgetSketchLabel::onShowDOF() { - -} \ No newline at end of file + CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast(myFeature); + if (aCompFeature.get() && aCompFeature->numberOfSubs() > 1) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_GET_DOF_OBJECTS); + ModelAPI_EventCreator::get()->sendUpdated(aCompFeature->subFeature(0), anEvent); + Events_Loop::loop()->flush(anEvent); + } +} diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 6404c4636..eb3542bdd 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -656,7 +656,7 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Storage::checkDegeneratedGeome } -void PlaneGCSSolver_Storage::getUnderconstrainedGeometry(std::set& theFeatures) const +void PlaneGCSSolver_Storage::getUnderconstrainedGeometry(std::set& theFeatures) const { std::vector aFreeParams; mySketchSolver->getFreeParameters(aFreeParams); diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h index 3c350e90d..8d452a857 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h @@ -96,7 +96,7 @@ public: virtual void adjustParametrizationOfArcs(); /// \brief Return list of features which are not fully constrained - virtual void getUnderconstrainedGeometry(std::set& theFeatures) const; + virtual void getUnderconstrainedGeometry(std::set& theFeatures) const; private: /// \brief Convert feature using specified builder. diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 2662f564d..96c0a2968 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -497,7 +497,7 @@ bool SketchSolver_Group::areConstraintsValid() const return true; } -void SketchSolver_Group::underconstrainedFeatures(std::set& theFeatures) const +void SketchSolver_Group::underconstrainedFeatures(std::set& theFeatures) const { myStorage->getUnderconstrainedGeometry(theFeatures); } diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index e76edf2d2..45407ddb8 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -116,7 +116,7 @@ class SketchSolver_Group bool resolveConstraints(); /// \brief Find the list of features, which are not fully constrained. - void underconstrainedFeatures(std::set& theFeatures) const; + void underconstrainedFeatures(std::set& theFeatures) const; /// \brief Block or unblock events sent by features in this group void blockEvents(bool isBlocked); diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 04fc59148..6f000ec6c 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -114,6 +114,7 @@ SketchSolver_Manager::SketchSolver_Manager() ////Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED)); ////Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)); Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_PREPARED)); + Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_GET_DOF_OBJECTS)); } SketchSolver_Manager::~SketchSolver_Manager() @@ -223,19 +224,35 @@ void SketchSolver_Manager::processEvent( } myIsComputed = false; } -//// else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURES_OF_FREEDOM)) { -//// FeaturePtr aComposite = theMessage->sketch(); -//// std::shared_ptr aSketch = -//// std::dynamic_pointer_cast(aComposite); -//// if (aSketch) { -//// SketchGroupPtr aGroup = findGroup(aSketch); -//// -//// std::set aFreeFeatures; -//// aGroup->underconstrainedFeatures(aFreeFeatures); -//// -//// // TODO: send features to GUI -//// } -//// } + else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_GET_DOF_OBJECTS)) { + std::shared_ptr anUpdateMsg = + std::dynamic_pointer_cast(theMessage); + std::set aObjects = anUpdateMsg->objects(); + if (aObjects.size() == 1) { + std::set::const_iterator aIt; + for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) { + std::shared_ptr aFeature = + std::dynamic_pointer_cast(*aIt); + if (aFeature) { + SketchGroupPtr aGroup = findGroup(aFeature); + + std::set aFreeFeatures; + aGroup->underconstrainedFeatures(aFreeFeatures); + + std::list aFeatures; + std::set::const_iterator aIt; + for (aIt = aFreeFeatures.cbegin(); aIt != aFreeFeatures.cend(); ++aIt) { + aFeatures.push_back(*aIt); + } + + // TODO: send features to GUI + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_DOF_OBJECTS); + ModelAPI_EventCreator::get()->sendUpdated(aFeatures, anEvent); + Events_Loop::loop()->flush(anEvent); + } + } + } + } // resolve constraints if needed bool needToUpdate = needToResolve && resolveConstraints(); diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index 0f518b2fa..8ef8aeb39 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -129,7 +129,7 @@ public: std::set getConflictingConstraints(SolverPtr theSolver) const; /// \brief Return list of features which are not fully constrained - virtual void getUnderconstrainedGeometry(std::set& theFeatures) const = 0; + virtual void getUnderconstrainedGeometry(std::set& theFeatures) const = 0; /// \brief Verify, the sketch contains degenerated geometry /// after resolving the set of constraints