ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const std::string& theParentId)
-: ModuleBase_ModelWidget(theParent, theData, theParentId), isValidateBlocked(false),
+: ModuleBase_ModelWidget(theParent, theData, theParentId),
myWorkshop(theWorkshop)
{
}
return aValid;
}
- if (isValidateBlocked)
- return true;
- isValidateBlocked = true;
-
DataPtr aData = myFeature->data();
AttributePtr anAttribute = myFeature->attribute(attributeID());
aLoop->flush(aRedispEvent);
storeValidState(theValue, aValid);
- isValidateBlocked = false;
return aValid;
}
ObjectPtr myPresentedObject; /// back up of the filtered object
QList<ModuleBase_ViewerPrs> myValidPrs;
QList<ModuleBase_ViewerPrs> myInvalidPrs;
- bool isValidateBlocked;
};
#endif /* MODULEBASE_WIDGETVALIDATED_H_ */
#include "PartSet_Tools.h"
#include <XGUI_Workshop.h>
+#include <XGUI_ModuleConnector.h>
#include <SketchPlugin_Feature.h>
//********************************************************************
void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature)
+ const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop)
{
QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
for (; anIt != aLast; anIt++) {
// to delete this feature. Test case is creation of a constraint on external point,
// use in this control after an external point, the point of the sketch.
anIgnoredFeatures.insert(theFeature);
- XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
+ workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures);
}
}
//removeExternalObject(anObject, theSketch, theFeature);
//********************************************************************
void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature)
+ const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop)
{
// TODO(nds): unite with removeExternal(), remove parameters
- removeExternalObject(myExternalObjectValidated, theSketch, theFeature);
+ removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop);
myExternalObjectValidated = ObjectPtr();
}
void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject,
const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature)
+ const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop)
{
if (theObject.get()) {
DocumentPtr aDoc = theObject->document();
// to delete this feature. Test case is creation of a constraint on external point,
// use in this control after an external point, the point of the sketch.
anIgnoredFeatures.insert(theFeature);
- XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
+ workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures);
}
}
}
+
+XGUI_Workshop* PartSet_ExternalObjectsMgr::workshop(ModuleBase_IWorkshop* theWorkshop)
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
+ return aConnector->workshop();
+}
#include <string>
+class ModuleBase_IWorkshop;
+class XGUI_Workshop;
+
/**
* \ingroup Modules
* Customosation of ModuleBase_WidgetShapeSelector in order to provide
// Removes the external presentation from the model
/// \param theSketch a current sketch
/// \param theFeature a current feature
+ /// \param theFeature a current workshop
void removeExternal(const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature);
+ const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop);
void removeExternalValidated(const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature);
+ const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop);
void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
const CompositeFeaturePtr& theSketch,
protected:
void removeExternalObject(const ObjectPtr& theObject,
const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature);
+ const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop);
+
+ /// Returns the workshop
+ static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
protected:
/// An external object
myIsInVaildate = false;
ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid);
- myExternalObjectMgr->removeExternalValidated(sketch(), myFeature);
+ myExternalObjectMgr->removeExternalValidated(sketch(), myFeature, myWorkshop);
}
void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
void PartSet_WidgetShapeSelector::restoreAttributeValue(const bool theValid)
{
ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid);
- myExternalObjectMgr->removeExternal(sketch(), myFeature);
+ myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop);
}
//********************************************************************
}
return aMenu;
}
+
+QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
+{
+ QStringList aGroups;
+
+ QMap<std::string, QActionsList>::const_iterator anIt = myObjBrowserMenus.begin(),
+ aLast = myObjBrowserMenus.end();
+ for (; anIt != aLast; anIt++) {
+ QString aGroupName(anIt.key().c_str());
+ if (aGroups.contains(aGroupName))
+ continue;
+ QActionsList anActions = anIt.value();
+ QActionsList::const_iterator anAIt = anActions.begin(), anALast = anActions.end();
+ bool aFound = false;
+ for (; anAIt != anALast && !aFound; anAIt++)
+ aFound = (*anAIt)->data().toString() == theName;
+ if (aFound)
+ aGroups.append(aGroupName);
+ }
+ return aGroups;
+}
QMenu* objBrowserMenu() const;
QMenu* viewerMenu() const;
+ /// Returns a list of object group names of the action
+ /// \param theName a name of the action
+ /// \return a list of group names
+ QStringList actionObjectGroups(const QString& theName);
signals:
/// Signal aabout triggered action
//**************************************************************
bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList,
- std::set<FeaturePtr> theIgnoredFeatures,
+ const std::set<FeaturePtr>& theIgnoredFeatures,
QWidget* theParent,
const bool theAskAboutDeleteReferences)
{
anInfo.clear();
#endif
+ QString anId = QString::fromStdString("DELETE_CMD");
+ QStringList anObjectGroups = contextMenuMgr()->actionObjectGroups(anId);
// 4. remove the parameter features
foreach (ObjectPtr aObj, theList) {
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
- if (aResult.get() != NULL) { // results could not be removed,
- // they are removed by a corresponded feature remove
+ // features and parameters can be removed here,
+ // the results are removed only by a corresponded feature remove
+ std::string aGroupName = aObj->groupName();
+ if (!anObjectGroups.contains(aGroupName.c_str()))
continue;
- }
+
FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
if (aFeature) {
// TODO: to learn the workshop to delegate the Part object deletion to the PartSet module
//! \param theAskAboutDeleteReferences if true, the message box with a list of references to the
//! objects features appear. If the user chose do not continue, the deletion is not performed
//! \return the success of the delete
- static bool deleteFeatures(const QObjectPtrList& theList,
- std::set<FeaturePtr> theIgnoredFeatures = std::set<FeaturePtr>(),
- QWidget* theParent = 0,
- const bool theAskAboutDeleteReferences = false);
+ bool deleteFeatures(const QObjectPtrList& theList,
+ const std::set<FeaturePtr>& theIgnoredFeatures,
+ QWidget* theParent = 0,
+ const bool theAskAboutDeleteReferences = false);
/// Deactivates the object, if it is active and the module returns that the activation
/// of selection for the object is not possible currently(the current operation uses it)