/// 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
{
#include <QMessageBox>
#include <QMainWindow>
+#include <set>
+
//#define DEBUG_DO_NOT_BY_ENTER
//#define DEBUG_SKETCHER_ENTITIES
//#define DEBUG_SKETCH_ENTITIES_ON_MOVE
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()
aViewer->update();
}
+void PartSet_SketcherMgr::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOF_OBJECTS)) {
+ std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
+ std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+ std::set<ObjectPtr> aObjects = anUpdateMsg->objects();
+ std::set<ObjectPtr>::const_iterator aIt;
+ QList<ModuleBase_ViewerPrsPtr> aPrsList;
+ for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
+ if (aFeature.get()) {
+ std::list<ResultPtr> aRes = aFeature->results();
+ std::list<ResultPtr>::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)
{
#include <ModelAPI_Attribute.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Result.h>
+#include <Events_Listener.h>
#include <ModuleBase_SelectionFilterType.h>
#include <ModuleBase_Definitions.h>
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
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<Events_Message>& theMessage);
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Events.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
myShowDOFBtn->hide();
} else {
myDoFLabel->setText(tr("DoF (degrees of freedom) = ") + aVal);
- myShowDOFBtn->show();
+ CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature.get() && aCompFeature->numberOfSubs() > 1)
+ myShowDOFBtn->show();
}
}
}
void PartSet_WidgetSketchLabel::onShowDOF()
{
-
-}
\ No newline at end of file
+ CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(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);
+ }
+}
}
-void PlaneGCSSolver_Storage::getUnderconstrainedGeometry(std::set<FeaturePtr>& theFeatures) const
+void PlaneGCSSolver_Storage::getUnderconstrainedGeometry(std::set<ObjectPtr>& theFeatures) const
{
std::vector<double*> aFreeParams;
mySketchSolver->getFreeParameters(aFreeParams);
virtual void adjustParametrizationOfArcs();
/// \brief Return list of features which are not fully constrained
- virtual void getUnderconstrainedGeometry(std::set<FeaturePtr>& theFeatures) const;
+ virtual void getUnderconstrainedGeometry(std::set<ObjectPtr>& theFeatures) const;
private:
/// \brief Convert feature using specified builder.
return true;
}
-void SketchSolver_Group::underconstrainedFeatures(std::set<FeaturePtr>& theFeatures) const
+void SketchSolver_Group::underconstrainedFeatures(std::set<ObjectPtr>& theFeatures) const
{
myStorage->getUnderconstrainedGeometry(theFeatures);
}
bool resolveConstraints();
/// \brief Find the list of features, which are not fully constrained.
- void underconstrainedFeatures(std::set<FeaturePtr>& theFeatures) const;
+ void underconstrainedFeatures(std::set<ObjectPtr>& theFeatures) const;
/// \brief Block or unblock events sent by features in this group
void blockEvents(bool isBlocked);
////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()
}
myIsComputed = false;
}
-//// else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURES_OF_FREEDOM)) {
-//// FeaturePtr aComposite = theMessage->sketch();
-//// std::shared_ptr<SketchPlugin_Feature> aSketch =
-//// std::dynamic_pointer_cast<SketchPlugin_Feature>(aComposite);
-//// if (aSketch) {
-//// SketchGroupPtr aGroup = findGroup(aSketch);
-////
-//// std::set<FeaturePtr> aFreeFeatures;
-//// aGroup->underconstrainedFeatures(aFreeFeatures);
-////
-//// // TODO: send features to GUI
-//// }
-//// }
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_GET_DOF_OBJECTS)) {
+ std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
+ std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+ std::set<ObjectPtr> aObjects = anUpdateMsg->objects();
+ if (aObjects.size() == 1) {
+ std::set<ObjectPtr>::const_iterator aIt;
+ for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) {
+ std::shared_ptr<SketchPlugin_Feature> aFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(*aIt);
+ if (aFeature) {
+ SketchGroupPtr aGroup = findGroup(aFeature);
+
+ std::set<ObjectPtr> aFreeFeatures;
+ aGroup->underconstrainedFeatures(aFreeFeatures);
+
+ std::list<ObjectPtr> aFeatures;
+ std::set<ObjectPtr>::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();
std::set<ObjectPtr> getConflictingConstraints(SolverPtr theSolver) const;
/// \brief Return list of features which are not fully constrained
- virtual void getUnderconstrainedGeometry(std::set<FeaturePtr>& theFeatures) const = 0;
+ virtual void getUnderconstrainedGeometry(std::set<ObjectPtr>& theFeatures) const = 0;
/// \brief Verify, the sketch contains degenerated geometry
/// after resolving the set of constraints