#include <ModelAPI_Validator.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_ShapeValidator.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point.h>
aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
+ aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
}
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
{
- if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->startSketch(theOperation);
}
+ else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ mySketchMgr->startNestedSketch(theOperation);
+ }
+
if (myDocumentShapeFilter.IsNull())
myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
{
- if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation) ||
+ PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
mySketchMgr->stopSketch(theOperation);
}
+ else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ mySketchMgr->stopNestedSketch(theOperation);
+ }
myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
}
bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
{
bool aCanDisplay = false;
- if (mySketchMgr->activeSketch()) {
+ if (!mySketchMgr->canDisplayObject(theObject))
+ return aCanDisplay;
+ CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
+ if (aSketchFeature.get() != NULL) {
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (aFeature.get() != NULL) {
- if (aFeature == mySketchMgr->activeSketch()) {
+ // MPV: the second and third conditions to avoid crash on exit for application
+ if (aFeature.get() != NULL && aFeature->data().get() && aFeature->data()->isValid()) {
+ if (aFeature == aSketchFeature) {
aCanDisplay = false;
}
- else {
- aCanDisplay = mySketchMgr->sketchOperationIdList().contains(aFeature->getKind().c_str());
+ else if (aSketchFeature.get() && aSketchFeature->data().get() &&
+ aSketchFeature->data()->isValid()) {
+ for (int i = 0; i < aSketchFeature->numberOfSubs() && !aCanDisplay; i++) {
+ FeaturePtr aSubFeature = aSketchFeature->subFeature(i);
+ std::list<ResultPtr> aResults = aSubFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end() && !aCanDisplay; ++aIt) {
+ if (theObject == (*aIt))
+ aCanDisplay = true;
+ }
+ if (aSubFeature == theObject)
+ aCanDisplay = true;
+ }
}
}
}
void PartSet_Module::addViewerItems(QMenu* theMenu) const
{
- if (!isSketchOperationActive() && !isSketchFeatureOperationActive())
+ if (!PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation()) &&
+ !isSketchFeatureOperationActive())
return;
ModuleBase_ISelection* aSelection = myWorkshop->selection();
QObjectPtrList aObjects = aSelection->selectedPresentations();
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
{
ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
- if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) &&
- (theOperation->isEditOperation())) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
// we have to manually activate the sketch label in edit mode
aPanel->activateWidget(aPanel->modelWidgets().first());
return;
if (theOperation->isEditOperation()) {
// TODO: #391 - to be removed
std::string aId = theOperation->id().toStdString();
- if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
- if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
- (aId == SketchPlugin_ConstraintLength::ID()) ||
- (aId == SketchPlugin_ConstraintDistance::ID())) {
- // Find and activate widget for management of point for dimension line position
- QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
- foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
- PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
- if (aPntWgt) {
- aPanel->activateWidget(aPntWgt);
- return;
- }
+ if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
+ PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
+ // Find and activate widget for management of point for dimension line position
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+ PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+ if (aPntWgt) {
+ aPanel->activateWidget(aPntWgt);
+ return;
}
- }
+ }
}
}
}
// An edit operation is enable only if the current opeation is the sketch operation
if (mySketchMgr->activeSketch()) {
if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
- isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
+ isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
}
if (isSketcherOp) {
// Editing of constraints can be done on selection
return 0;
}
-bool PartSet_Module::isSketchOperationActive() const
-{
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-
- bool isSketchOp = aOperation && aOperation->id().toStdString() == SketchPlugin_Sketch::ID();
- return isSketchOp;
-}
-
bool PartSet_Module::isSketchFeatureOperationActive() const
{
bool isCurrentSketchOp = false;
void PartSet_Module::deleteObjects()
{
- bool isSketchOp = isSketchOperationActive();
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation());
if (!isSketchOp && !isSketchFeatureOperationActive())
return;