connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
}
+bool ModuleBase_IModule::canEraseObject(const ObjectPtr& theObject) const
+{
+ return true;
+}
+
bool ModuleBase_IModule::canDisplayObject(const ObjectPtr& theObject) const
{
return true;
/// \return a boolean value\r
virtual bool canCommitOperation() const;\r
\r
+ /// Returns whether the object can be erased. The default realization returns true.\r
+ /// \param theObject a model object\r
+ virtual bool canEraseObject(const ObjectPtr& theObject) const;\r
+\r
/// Returns whether the object can be displayed. The default realization returns true.\r
/// \param theObject a model object\r
virtual bool canDisplayObject(const ObjectPtr& theObject) const;\r
return mySketchMgr->canCommitOperation();
}
+bool PartSet_Module::canEraseObject(const ObjectPtr& theObject) const
+{
+ // the sketch manager put the restriction to the objects erase
+ return mySketchMgr->canEraseObject(theObject);
+}
+
bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
{
// the sketch manager put the restriction to the objects display
/// \return a boolean value
virtual bool canCommitOperation() const;
+ /// Returns whether the object can be erased at the bounds of the active operation.
+ /// The sub-objects of the current operation can not be erased
+ /// \param theObject a model object
+ virtual bool canEraseObject(const ObjectPtr& theObject) const;
+
/// Returns whether the object can be displayed at the bounds of the active operation.
/// Display only current operation results for usual operation and ask the sketcher manager
/// if it is a sketch operation
return aCanCommit;
}
+bool PartSet_SketcherMgr::canEraseObject(const ObjectPtr& theObject) const
+{
+ bool aCanErase = true;
+ // when the sketch operation is active, results of sketch sub-feature can not be hidden
+ if (myCurrentSketch.get()) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ // Display sketcher objects
+ for (int i = 0; i < myCurrentSketch->numberOfSubs() && aCanErase; i++) {
+
+ FeaturePtr aFeature = myCurrentSketch->subFeature(i);
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator anIt;
+ for (anIt = aResults.begin(); anIt != aResults.end() && aCanErase; ++anIt) {
+ aCanErase = *anIt != aResult;
+ }
+ }
+ }
+ }
+ return aCanErase;
+}
+
bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
{
bool aCanDisplay = true;
/// \return a boolean value
bool canCommitOperation() const;
+ /// Returns whether the object can be erased at the bounds of the active operation.
+ /// Sketch sub-entities can not be erased during the sketch operation
+ /// \param theObject a model object
+ bool canEraseObject(const ObjectPtr& theObject) const;
+
/// Returns whether the object can be displayed at the bounds of the active operation.
/// Display only current operation results for usual operation and ask the sketcher manager
/// if it is a sketch operation
setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
else if (theId == "HIDEALL_CMD") {
QObjectPtrList aList = myDisplayer->displayedObjects();
- foreach (ObjectPtr aObj, aList)
- aObj->setDisplayed(false);
+ foreach (ObjectPtr aObj, aList) {
+ if (module()->canEraseObject(aObj))
+ aObj->setDisplayed(false);
+ }
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
}
{
// Hide all displayed objects
QObjectPtrList aList = myDisplayer->displayedObjects();
- foreach (ObjectPtr aObj, aList)
- aObj->setDisplayed(false);
+ foreach (ObjectPtr aObj, aList) {
+ if (module()->canEraseObject(aObj))
+ aObj->setDisplayed(false);
+ }
// Show only objects from the list
foreach (ObjectPtr aObj, theList) {