X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_SketcherMgr.cpp;h=a6ae7a8a5bcb4f656210a239a4d08275dbb4878f;hb=0b503091623876eda1ae9214e32f8831ef03778b;hp=8ecc6bde02b07a9e6968e518ac3558a97e61778f;hpb=70b63231279a083e2c9c0281b1ad28dd6d4fba82;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 8ecc6bde0..a6ae7a8a5 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -48,6 +48,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -163,6 +167,10 @@ void PartSet_SketcherMgr::onLeaveViewPort() { if (!isNestedCreateOperation(getCurrentOperation())) return; + // the method should be performed if the popup menu is called, + // the reset of the current widget should not happen + if (myIsPopupMenuActive) + return; myIsMouseOverViewProcessed = false; myIsMouseOverWindow = false; @@ -237,8 +245,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE { get2dPoint(theWnd, theEvent, myClickedPoint); - myIsPopupMenuActive = theEvent->buttons() & Qt::RightButton; - if (!(theEvent->buttons() & Qt::LeftButton)) return; @@ -318,9 +324,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { - if (myIsPopupMenuActive) - myIsPopupMenuActive = false; - ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_IViewer* aViewer = aWorkshop->viewer(); if (!aViewer->canDragByMouse()) @@ -494,6 +497,10 @@ void PartSet_SketcherMgr::onApplicationStarted() XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer(); connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort())); connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort())); + + XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr(); + connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu())); + connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu())); } void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget) @@ -514,6 +521,16 @@ void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWid } } +void PartSet_SketcherMgr::onBeforeContextMenu() +{ + myIsPopupMenuActive = true; +} + +void PartSet_SketcherMgr::onAfterContextMenu() +{ + myIsPopupMenuActive = false; +} + void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, Point& thePoint) { @@ -565,6 +582,10 @@ QStringList PartSet_SketcherMgr::sketchOperationIdList() aIds << SketchPlugin_ConstraintRadius::ID().c_str(); aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str(); aIds << SketchPlugin_ConstraintParallel::ID().c_str(); + aIds << SketchPlugin_ConstraintHorizontal::ID().c_str(); + aIds << SketchPlugin_ConstraintVertical::ID().c_str(); + aIds << SketchPlugin_ConstraintEqual::ID().c_str(); + aIds << SketchPlugin_ConstraintTangent::ID().c_str(); } return aIds; } @@ -742,7 +763,7 @@ bool PartSet_SketcherMgr::canDisplayObject() const return aCanDisplay; } -bool PartSet_SketcherMgr::canChangeConstruction(bool& isConstruction) const +bool PartSet_SketcherMgr::canSetAuxiliary(bool& theValue) const { bool anEnabled = false; ModuleBase_Operation* anOperation = getCurrentOperation(); @@ -753,43 +774,46 @@ bool PartSet_SketcherMgr::canChangeConstruction(bool& isConstruction) const return anEnabled; QObjectPtrList anObjects; - // 1. change construction type of a created feature + // 1. change auxiliary type of a created feature if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) && PartSet_SketcherMgr::isEntityOperation(anOperation) ) { anObjects.append(anOperation->feature()); } else { - if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) - anOperation->abort(); - // 2. change construction type of selected sketch entities + /// The operation should not be aborted here, because the method does not changed + /// the auxilliary state, but checks the possibility to perform this + ///if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) + /// anOperation->abort(); + // 2. change auxiliary type of selected sketch entities ModuleBase_ISelection* aSelection = myModule->workshop()->selection(); anObjects = aSelection->selectedPresentations(); } anEnabled = anObjects.size() > 0; - bool isNotConstructedFound = false; + bool isNotAuxiliaryFound = false; if (anObjects.size() > 0) { QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end(); - for (; anIt != aLast && !isNotConstructedFound; anIt++) { + for (; anIt != aLast && !isNotAuxiliaryFound; anIt++) { FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); if (aFeature.get() != NULL) { std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(aFeature); if (aSketchFeature.get() != NULL) { - std::string anAttribute = SketchPlugin_SketchEntity::CONSTRUCTION_ID(); + std::string anAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID(); - std::shared_ptr aConstructionAttr = + std::shared_ptr anAuxiliaryAttr = std::dynamic_pointer_cast(aSketchFeature->data()->attribute(anAttribute)); - isNotConstructedFound = !aConstructionAttr->value(); + if (anAuxiliaryAttr) + isNotAuxiliaryFound = !anAuxiliaryAttr->value(); } } } } - isConstruction = anObjects.size() && !isNotConstructedFound; + theValue = anObjects.size() && !isNotAuxiliaryFound; return anEnabled; } -void PartSet_SketcherMgr::setConstruction(const bool isChecked) +void PartSet_SketcherMgr::setAuxiliary(const bool isChecked) { ModuleBase_Operation* anOperation = getCurrentOperation(); @@ -800,19 +824,19 @@ void PartSet_SketcherMgr::setConstruction(const bool isChecked) QObjectPtrList anObjects; bool isUseTransaction = false; - // 1. change construction type of a created feature + // 1. change auxiliary type of a created feature if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) && PartSet_SketcherMgr::isEntityOperation(anOperation) ) { anObjects.append(anOperation->feature()); } else { isUseTransaction = true; - // 2. change construction type of selected sketch entities + // 2. change auxiliary type of selected sketch entities ModuleBase_ISelection* aSelection = myModule->workshop()->selection(); anObjects = aSelection->selectedPresentations(); } - QAction* anAction = myModule->action("CONSTRUCTION_CMD"); + QAction* anAction = myModule->action("AUXILIARY_CMD"); SessionPtr aMgr = ModelAPI_Session::get(); if (isUseTransaction) { if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) @@ -829,11 +853,12 @@ void PartSet_SketcherMgr::setConstruction(const bool isChecked) std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(aFeature); if (aSketchFeature.get() != NULL) { - std::string anAttribute = SketchPlugin_SketchEntity::CONSTRUCTION_ID(); + std::string anAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID(); - std::shared_ptr aConstructionAttr = + std::shared_ptr anAuxiliaryAttr = std::dynamic_pointer_cast(aSketchFeature->data()->attribute(anAttribute)); - aConstructionAttr->setValue(isChecked); + if (anAuxiliaryAttr) + anAuxiliaryAttr->setValue(isChecked); } } }