X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPartSet%2FPartSet_Module.cpp;h=e257113e774650107e5fafee31f5802c0bec8266;hb=bb77698cb96e6ea848443bab051b4e9ea885fee0;hp=3f2ef5ed89f1bbf75327f0f165b2ed3bb73562f9;hpb=4457a01fc445d79067555b37d88370116a373eb1;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 3f2ef5ed8..e257113e7 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -4,6 +4,7 @@ #include "PartSet_WidgetSketchLabel.h" #include "PartSet_Validators.h" #include "PartSet_Tools.h" +#include "PartSet_PreviewPlanes.h" #include "PartSet_WidgetPoint2d.h" #include "PartSet_WidgetPoint2dDistance.h" #include "PartSet_WidgetPoint2DFlyout.h" @@ -14,6 +15,7 @@ #include "PartSet_WidgetSketchCreator.h" #include "PartSet_SketcherMgr.h" #include "PartSet_SketcherReetntrantMgr.h" +#include "PartSet_ResultSketchPrs.h" #include "PartSet_MenuMgr.h" #include "PartSet_CustomPrs.h" #include "PartSet_IconFactory.h" @@ -39,6 +41,7 @@ #include #include #include +#include #include #include @@ -47,6 +50,7 @@ #include #include #include +#include #include #include @@ -145,6 +149,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) myHasConstraintShown[PartSet_Tools::Geometrical] = true; myHasConstraintShown[PartSet_Tools::Dimensional] = true; + myHasConstraintShown[PartSet_Tools::Expressions] = false; Config_PropManager::registerProp("Visualization", "operation_parameter_color", "Reference shape wireframe color in operation", Config_Prop::Color, @@ -220,7 +225,6 @@ void PartSet_Module::registerValidators() aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection); aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator); aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr); - aFactory->registerValidator("PartSet_SketchEntityValidator", new PartSet_SketchEntityValidator); } void PartSet_Module::registerFilters() @@ -401,7 +405,7 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation) aLast = myHasConstraintShown.end(); for (; anIt != aLast; anIt++) { myHasConstraintShown[anIt.key()]; - mySketchMgr->onShowConstraintsToggle(anIt.key(), anIt.value()); + mySketchMgr->updateBySketchParameters(anIt.key(), anIt.value()); } } @@ -562,17 +566,18 @@ bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation, if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) { ModuleBase_ISelection* aSelection = workshop()->selection(); // click on a point in sketch leads here with the point is highlighted, not yet selected - QList aPreselection = aSelection->getHighlighted(); + QList aPreselection = aSelection->getHighlighted(); if (aPreselection.size() == 1) { - ModuleBase_ViewerPrs aSelectedPrs = aPreselection[0]; - ObjectPtr anObject = aSelectedPrs.object(); + ModuleBase_ViewerPrsPtr aSelectedPrs = aPreselection[0]; + ObjectPtr anObject = aSelectedPrs->object(); FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); FeaturePtr anOpFeature = aFOperation->feature(); - TopoDS_Shape aShape = aSelectedPrs.shape(); + GeomShapePtr aShape = aSelectedPrs->shape(); // click on the digit of dimension constrain comes here with an empty shape, so we need the check - if (aFeature == anOpFeature && !aShape.IsNull()) { - AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aShape, + if (aFeature == anOpFeature && aShape.get() && !aShape->isNull()) { + const TopoDS_Shape& aTDShape = aShape->impl(); + AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aTDShape, mySketchMgr->activeSketch()); if (anAttribute.get()) { QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); @@ -608,10 +613,10 @@ void PartSet_Module::onSelectionChanged() if (isSketcherOp) { // Editing of constraints can be done on selection ModuleBase_ISelection* aSelect = myWorkshop->selection(); - QList aSelected = aSelect->getSelected(); + QList aSelected = aSelect->getSelected(); if (aSelected.size() == 1) { - ModuleBase_ViewerPrs aPrs = aSelected.first(); - ObjectPtr aObject = aPrs.object(); + ModuleBase_ViewerPrsPtr aPrs = aSelected.first(); + ObjectPtr aObject = aPrs->object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); if (aFeature) { std::string aId = aFeature->getKind(); @@ -675,7 +680,8 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th new PartSet_WidgetMultiSelector(theParent, aWorkshop, theWidgetApi); aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch()); aWgt = aShapeSelectorWgt; - } else if (theType == WDG_DOUBLEVALUE_EDITOR) { + } + else if (theType == WDG_DOUBLEVALUE_EDITOR) { aWgt = new PartSet_WidgetEditor(theParent, aWorkshop, theWidgetApi); } else if (theType == "export_file_selector") { aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi); @@ -683,7 +689,8 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi); } else if (theType == "module_choice") { aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi); - connect(aWgt, SIGNAL(itemSelected(int)), SLOT(onBooleanOperationChange(int))); + connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)), + this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int))); } return aWgt; } @@ -789,23 +796,40 @@ void PartSet_Module::onFeatureTriggered() ModuleBase_IModule::onFeatureTriggered(); } +void PartSet_Module::editFeature(FeaturePtr theFeature) +{ + storeConstraintsState(theFeature->getKind()); + ModuleBase_IModule::editFeature(theFeature); +} + +bool PartSet_Module::canCommitOperation() const +{ + return true; +} + void PartSet_Module::launchOperation(const QString& theCmdId) +{ + storeConstraintsState(theCmdId.toStdString()); + ModuleBase_IModule::launchOperation(theCmdId); +} + +void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind) { if (myWorkshop->currentOperation() && myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) { - const QMap& aShownStates = - mySketchMgr->showConstraintStates(); - myHasConstraintShown = aShownStates; + const QMap& aShownStates = + mySketchMgr->showConstraintStates(); + myHasConstraintShown = aShownStates; } - if (PartSet_SketcherMgr::constraintsIdList().contains(theCmdId)) { + if (PartSet_SketcherMgr::constraintsIdList().contains(theFeatureKind.c_str())) { // Show constraints if a constraint was anOperation - mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Geometrical, true); - mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Dimensional, true); + mySketchMgr->updateBySketchParameters(PartSet_Tools::Geometrical, true); + mySketchMgr->updateBySketchParameters(PartSet_Tools::Dimensional, true); + mySketchMgr->updateBySketchParameters(PartSet_Tools::Expressions, + myHasConstraintShown[PartSet_Tools::Expressions]); } - ModuleBase_IModule::launchOperation(theCmdId); } - void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) { Handle(AIS_InteractiveObject) anAIS = theAIS->impl(); @@ -910,7 +934,7 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the ObjectPtr anObject = aDisplayer->getObject(thePrs); if (anObject.get()) { bool isConflicting = myOverconstraintListener->isConflictingObject(anObject); - // customize sketcy symbol presentation + // customize sketch symbol presentation if (thePrs.get()) { Handle(AIS_InteractiveObject) anAISIO = thePrs->impl(); if (!anAISIO.IsNull()) { @@ -938,6 +962,9 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the aCustomized = true; } } + + // customize dimentional constrains + sketchMgr()->customizePresentation(anObject); } return aCustomized; @@ -985,6 +1012,11 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt) aMenu.exec(aHeader->mapToGlobal(thePnt)); } +Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ResultPtr& theResult) +{ + return mySketchMgr->createPresentation(theResult); +} + ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const { @@ -1008,6 +1040,17 @@ ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const return anObject; } +bool PartSet_Module::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const +{ + bool aCanBeShaged = true; + + Handle(PartSet_ResultSketchPrs) aPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theAIS); + if (!aPrs.IsNull()) + aCanBeShaged = false; + + return aCanBeShaged; +} + void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const { QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects(); @@ -1020,9 +1063,9 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const bool hasResult = false; bool hasFeature = false; bool hasParameter = false; - bool hasSubFeature = false; - ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, hasSubFeature); - + bool hasCompositeOwner = false; + ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, + hasCompositeOwner); ObjectPtr aObject = aObjects.first(); if (aObject) { ResultPartPtr aPart = std::dynamic_pointer_cast(aObject); @@ -1241,22 +1284,20 @@ AttributePtr PartSet_Module::findAttribute(const ObjectPtr& theObject, } //****************************************************** -void PartSet_Module::onBooleanOperationChange(int theOperation) +void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget, + int theIndex) { - ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); - if (!aOperation) + PartSet_WidgetChoice* aChoiceWidget = dynamic_cast(theWidget); + if (!aChoiceWidget) return; - ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); - switch (theOperation) { - case 0: - aPanel->setWindowTitle(tr("Cut")); - break; - case 1: - aPanel->setWindowTitle(tr("Fuse")); - break; - case 2: - aPanel->setWindowTitle(tr("Common")); - break; + + QString aChoiceTitle = aChoiceWidget->getPropertyPanelTitle(theIndex); + if (!aChoiceTitle.isEmpty()) { + ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); + if (!aOperation) + return; + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + aPanel->setWindowTitle(aChoiceTitle); } }