X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_SketcherMgr.cpp;h=a6ae7a8a5bcb4f656210a239a4d08275dbb4878f;hb=0b503091623876eda1ae9214e32f8831ef03778b;hp=a2303017c011a052de5755bd21540c5a0e3e3dae;hpb=ea9b3a766e6401626c170e3ae5f591f67af22271;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index a2303017c..a6ae7a8a5 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -6,14 +6,24 @@ #include "PartSet_SketcherMgr.h" #include "PartSet_Module.h" -#include "PartSet_WidgetPoint2D.h" +#include "PartSet_WidgetPoint2d.h" +#include "PartSet_WidgetPoint2dDistance.h" #include "PartSet_Tools.h" +#include + #include #include #include +#include #include #include +#include +#include +#include +#include + +#include #include #include @@ -23,6 +33,8 @@ #include #include +#include + #include #include @@ -36,42 +48,85 @@ #include #include #include +#include +#include +#include +#include #include #include +//#include +//#include + #include +#include #include #include - - /// Returns list of unique objects by sum of objects from List1 and List2 -QList getSumList(const QList& theList1, +/*QList getSumList(const QList& theList1, const QList& theList2) { - QList aRes; + QList aRes; foreach (ModuleBase_ViewerPrs aPrs, theList1) { - if (!aRes.contains(aPrs.object())) - aRes.append(aPrs.object()); + if (!aRes.contains(aPrs)) + aRes.append(aPrs); } foreach (ModuleBase_ViewerPrs aPrs, theList2) { - if (!aRes.contains(aPrs.object())) - aRes.append(aPrs.object()); + if (!aRes.contains(aPrs)) + aRes.append(aPrs); } return aRes; +}*/ + +void fillFeature2Attribute(const QList& theList, + QMap >& theFeature2AttributeMap, + const FeaturePtr theSketch) +{ + QList aRes; + + QList::const_iterator anIt = theList.begin(), + aLast = theList.end(); + for (; anIt != aLast; anIt++) + { + ModuleBase_ViewerPrs aPrs = *anIt; + FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object()); + if (aFeature.get() == NULL) + continue; + + QList anAttributes; + if (theFeature2AttributeMap.contains(aFeature)) { + anAttributes = theFeature2AttributeMap[aFeature]; + } + AttributePtr anAttr; + TopoDS_Shape aShape = aPrs.shape(); + if (!aShape.IsNull()) { + if (aShape.ShapeType() == TopAbs_VERTEX) { + anAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch); + if (anAttr.get() != NULL && !anAttributes.contains(anAttr)) + anAttributes.push_back(anAttr); + } + } + theFeature2AttributeMap[aFeature] = anAttributes; + } } PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) - : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false) + : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false), + myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false), + myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true), + myIsPopupMenuActive(false) { - ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - ModuleBase_IViewer* aViewer = aWorkshop->viewer(); + ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); + ModuleBase_IViewer* aViewer = anIWorkshop->viewer(); + + myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled(); connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*))); @@ -84,6 +139,10 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*))); + + XGUI_ModuleConnector* aConnector = dynamic_cast(anIWorkshop); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + connect(aWorkshop, SIGNAL(applicationStarted()), this, SLOT(onApplicationStarted())); } PartSet_SketcherMgr::~PartSet_SketcherMgr() @@ -92,21 +151,128 @@ PartSet_SketcherMgr::~PartSet_SketcherMgr() myPlaneFilter.Nullify(); } +void PartSet_SketcherMgr::onEnterViewPort() +{ + if (!isNestedCreateOperation(getCurrentOperation())) + return; + // 1. if the mouse over window, update the next flag. Do not perform update visibility of + // created feature because it should be done in onMouseMove(). Some widgets watch + // the mouse move and use the cursor position to update own values. If the presentaion is + // redisplayed before this update, the feature presentation jumps from reset value to current. + myIsMouseOverWindow = true; + myIsPropertyPanelValueChanged = false; +} + +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; + + // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + // disable the viewer update in order to avoid visualization of redisplayed feature in viewer + // obtained after reset value + bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false); + ModuleBase_Operation* aOperation = getCurrentOperation(); + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); + if (aActiveWgt) { + aActiveWgt->reset(); + } + aDisplayer->enableUpdateViewer(isEnableUpdateViewer); + + // hides the presentation of the current operation feature + myIsPropertyPanelValueChanged = false; + // the feature is to be erased here, but it is correct to call canDisplayObject because + // there can be additional check (e.g. editor widget in distance constraint) + visualizeFeature(aOperation, canDisplayObject()); +} + +void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel() +{ + if (isNestedCreateOperation(getCurrentOperation())) + return; + // it is necessary to save current selection in order to restore it after the values are modifed + storeSelection(); + + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false); +} + +void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel() +{ + if (isNestedCreateOperation(getCurrentOperation())) + return; + // it is necessary to restore current selection in order to restore it after the values are modified + restoreSelection(); + myCurrentSelection.clear(); + + // 3. the flag to disable the update viewer should be set in order to avoid blinking in the + // viewer happens by deselect/select the modified objects. The flag should be restored after + // the selection processing. The update viewer should be also called. + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled); + aDisplayer->updateViewer(); +} + +void PartSet_SketcherMgr::onValuesChangedInPropertyPanel() +{ + if (!isNestedCreateOperation(getCurrentOperation())) + return; + + // visualize the current operation feature + myIsPropertyPanelValueChanged = true; + ModuleBase_Operation* aOperation = getCurrentOperation(); + // the feature is to be erased here, but it is correct to call canDisplayObject because + // there can be additional check (e.g. editor widget in distance constraint) + visualizeFeature(aOperation, canDisplayObject()); +} + void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { - // + get2dPoint(theWnd, theEvent, myClickedPoint); + if (!(theEvent->buttons() & Qt::LeftButton)) return; + // Clear dragging mode + myIsDragging = false; + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - ModuleBase_Operation* aOperation = aWorkshop->currentOperation(); + ModuleBase_IViewer* aViewer = aWorkshop->viewer(); + if (!aViewer->canDragByMouse()) + return; + + ModuleBase_Operation* aOperation = getCurrentOperation(); + if (aOperation && aOperation->isEditOperation()) { + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); + // If the current widget is a selector, do do nothing, it processes the mouse press + if(aActiveWgt && aActiveWgt->isViewerSelector()) { + return; + } + } + // Use only for sketch operations if (aOperation && myCurrentSketch) { if (!PartSet_Tools::sketchPlane(myCurrentSketch)) return; - bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()); - bool isSketchOpe = sketchOperationIdList().contains(aOperation->id()); + bool isSketcher = isSketchOperation(aOperation); + bool isSketchOpe = isNestedSketchOperation(aOperation); // Avoid non-sketch operations if ((!isSketchOpe) && (!isSketcher)) @@ -118,81 +284,36 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE if ((!isSketcher) && (!isEditing)) return; - if (theEvent->modifiers()) { - // If user performs multiselection - if (isSketchOpe /* && (!isSketcher)*/) - if (!aOperation->commit()) - aOperation->abort(); - return; - } + // MoveTo in order to highlight current object + aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView()); + // Remember highlighted objects for editing ModuleBase_ISelection* aSelect = aWorkshop->selection(); - QList aHighlighted = aSelect->getHighlighted(); - QList aSelected = aSelect->getSelected(); - myEditingFeatures.clear(); - myEditingAttr.clear(); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - QObjectPtrList aSelObjects; - if (aHasShift) - aSelObjects = getSumList(aHighlighted, aSelected); - else { - foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) { - aSelObjects.append(aPrs.object()); - } - } - if ((aSelObjects.size() == 0)) { + storeSelection(!aHasShift); + + if (myCurrentSelection.empty()) { if (isSketchOpe && (!isSketcher)) // commit previous operation if (!aOperation->commit()) aOperation->abort(); return; } - if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) { - // Move by selected shape (vertex). Can be used only for single selection - foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object()); - if (aFeature) { - myEditingFeatures.append(aFeature); - TopoDS_Shape aShape = aPrs.shape(); - if (!aShape.IsNull()) { - if (aShape.ShapeType() == TopAbs_VERTEX) { - AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(), - aShape, myCurrentSketch); - if (aAttr) - myEditingAttr.append(aAttr); - } - } - } - } - } else { - // Provide multi-selection. Can be used only for features - foreach (ObjectPtr aObj, aSelObjects) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - if (aFeature && (!myEditingFeatures.contains(aFeature))) - myEditingFeatures.append(aFeature); - } - - } - // If nothing highlighted - return - if (myEditingFeatures.size() == 0) - return; if (isSketcher) { myIsDragging = true; - get2dPoint(theWnd, theEvent, myCurX, myCurY); + get2dPoint(theWnd, theEvent, myCurrentPoint); myDragDone = false; - aWorkshop->viewer()->enableMultiselection(false); launchEditing(); } else if (isSketchOpe && isEditing) { - // If selected another object - aOperation->abort(); + // If selected another object commit current result + aOperation->commit(); myIsDragging = true; - get2dPoint(theWnd, theEvent, myCurX, myCurY); + get2dPoint(theWnd, theEvent, myCurrentPoint); myDragDone = false; - aWorkshop->viewer()->enableMultiselection(false); // This is necessary in order to finalize previous operation QApplication::processEvents(); @@ -204,129 +325,149 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - ModuleBase_Operation* aOp = aWorkshop->currentOperation(); - if (!aOp) - return; - if (!sketchOperationIdList().contains(aOp->id())) - return; - - // Only for sketcher operations ModuleBase_IViewer* aViewer = aWorkshop->viewer(); - if (myIsDragging) { - myIsDragging = false; - if (myDragDone) { - aViewer->enableMultiselection(true); - aOp->commit(); - myEditingFeatures.clear(); - myEditingAttr.clear(); - return; + if (!aViewer->canDragByMouse()) + return; + ModuleBase_Operation* aOp = getCurrentOperation(); + if (aOp) { + if (isNestedSketchOperation(aOp)) { + get2dPoint(theWnd, theEvent, myClickedPoint); + + // Only for sketcher operations + if (myIsDragging) { + if (myDragDone) { + //aOp->commit(); + myCurrentSelection.clear(); + // Reselect edited object + /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView()); + if (theEvent->modifiers() & Qt::ShiftModifier) + aViewer->AISContext()->ShiftSelect(); + else + aViewer->AISContext()->Select(); + */ + } + } } } - if (!aViewer->isMultiSelectionEnabled()) { - aViewer->enableMultiselection(true); - } - //aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView()); - //if (theEvent->modifiers() & Qt::ShiftModifier) - // aViewer->AISContext()->ShiftSelect(); - //else - // aViewer->AISContext()->Select(); + aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled); + myIsDragging = false; } void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { + if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) { + myIsMouseOverViewProcessed = true; + // 1. perform the widget mouse move functionality and display the presentation + ModuleBase_Operation* aOperation = getCurrentOperation(); + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget(); + // the mouse move should be processed in the widget, if it can in order to visualize correct + // presentation. These widgets correct the feature attribute according to the mouse position + PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(anActiveWdg); + if (aPoint2DWdg) { + aPoint2DWdg->onMouseMove(theWnd, theEvent); + } + PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast + (anActiveWdg); + if (aDistanceWdg) { + aDistanceWdg->onMouseMove(theWnd, theEvent); + } + // the feature is to be erased here, but it is correct to call canDisplayObject because + // there can be additional check (e.g. editor widget in distance constraint) + visualizeFeature(aOperation, canDisplayObject()); + } + + myClickedPoint.clear(); + if (myIsDragging) { - ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation(); - if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()) + // 1. the current selection is saved in the mouse press method in order to restore it after moving + // 2. the enable selection in the viewer should be temporary switched off in order to ignore + // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are + // deselected). This flag should be restored in the slot, processed the mouse release signal. + ModuleBase_IViewer* aViewer = myModule->workshop()->viewer(); + aViewer->enableSelection(false); + + ModuleBase_Operation* aOperation = getCurrentOperation(); + if (!aOperation) + return; + if (isSketchOperation(aOperation)) return; // No edit operation activated - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); Handle(V3d_View) aView = theWnd->v3dView(); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); double aX, aY; PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY); - double dX = aX - myCurX; - double dY = aY - myCurY; - - if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) && - (myEditingAttr.size() == 1) && - myEditingAttr.first()) { - // probably we have prehighlighted point - AttributePtr aAttr = myEditingAttr.first(); - std::string aAttrId = aAttr->id(); - ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); - QList aWidgets = aPanel->modelWidgets(); - // Find corresponded widget to provide dragging - foreach (ModuleBase_ModelWidget* aWgt, aWidgets) { - if (aWgt->attributeID() == aAttrId) { - PartSet_WidgetPoint2D* aWgt2d = dynamic_cast(aWgt); - if (aWgt2d) { - aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY); - break; + double dX = aX - myCurrentPoint.myCurX; + double dY = aY - myCurrentPoint.myCurY; + + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + // 3. the flag to disable the update viewer should be set in order to avoid blinking in the + // viewer happens by deselect/select the modified objects. The flag should be restored after + // the selection processing. The update viewer should be also called. + bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false); + + static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); + //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(), + aLast = myCurrentSelection.end(); + // 4. the features and attributes modification(move) + for (; anIt != aLast; anIt++) { + FeaturePtr aFeature = anIt.key(); + + std::set anAttributes = anIt.value().first; + // Process selection by attribute: the priority to the attribute + if (!anAttributes.empty()) { + std::set::const_iterator anAttIt = anAttributes.begin(), + anAttLast = anAttributes.end(); + for (; anAttIt != anAttLast; anAttIt++) { + AttributePtr anAttr = *anAttIt; + if (anAttr.get() == NULL) + continue; + std::string aAttrId = anAttr->id(); + DataPtr aData = aFeature->data(); + if (aData.get() != NULL) { + std::shared_ptr aPoint = + std::dynamic_pointer_cast(aData->attribute(aAttrId)); + if (aPoint.get() != NULL) { + bool isImmutable = aPoint->setImmutable(true); + aPoint->move(dX, dY); + ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent); + aPoint->setImmutable(isImmutable); + } } } - } - } else { - foreach(FeaturePtr aFeature, myEditingFeatures) { + } else { + // Process selection by feature std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(aFeature); - if (aSketchFeature) { - // save the previous selection - /*ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - QIntList anActivatedModes; - - ResultPtr aResult = aSketchFeature->firstResult(); - - aDisplayer->getModesOfActivation(aResult, anActivatedModes); - - std::list aSelectedAttributes; - getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes);*/ - // save the previous selection: end - - + if (aSketchFeature) { aSketchFeature->move(dX, dY); - ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent); - /* - // TODO: the selection restore should be after the AIS presentation is rebuilt - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED)); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - - // restore the previous selection - aResult = aSketchFeature->firstResult(); - aDisplayer->activate(aResult, anActivatedModes); - - SelectMgr_IndexedMapOfOwner anOwnersToSelect; - getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes, - anOwnersToSelect); - - ModuleBase_IViewer* aViewer = aWorkshop->viewer(); - Handle(AIS_InteractiveContext) aContext = aViewer->AISContext(); - for (Standard_Integer i = 1, n = anOwnersToSelect.Extent(); i <= n; i++) - aContext->AddOrRemoveSelected(anOwnersToSelect(i), false); // SetSelected() - - aContext->UpdateCurrentViewer(); - // restore the previous selection*/ + ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent); } } - // TODO: set here - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED)); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } + Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver + //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations + + // 5. it is necessary to save current selection in order to restore it after the features moving + restoreSelection(); + // 6. restore the update viewer flag and call this update + aDisplayer->enableUpdateViewer(isEnableUpdateViewer); + aDisplayer->updateViewer(); + myDragDone = true; - myCurX = aX; - myCurY = aY; + myCurrentPoint.setValue(aX, aY); } } void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { - ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation(); + ModuleBase_Operation* aOperation = getCurrentOperation(); if (aOperation && aOperation->isEditOperation()) { std::string aId = aOperation->id().toStdString(); - if ((aId == SketchPlugin_ConstraintLength::ID()) || - (aId == SketchPlugin_ConstraintDistance::ID()) || - (aId == SketchPlugin_ConstraintRadius::ID())) + if (isDistanceOperation(aOperation)) { // Activate dimension value editing on double click ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); @@ -342,24 +483,88 @@ void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMo } } +void PartSet_SketcherMgr::onApplicationStarted() +{ + ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(anIWorkshop); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel(); + if (aPropertyPanel) { + connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)), + this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*))); + } + + 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) +{ + if (!myClickedPoint.myIsInitialized) + return; + + ModuleBase_Operation* aOperation = getCurrentOperation(); + // the distance constraint feature should not use the clickedd point + // this is workaround in order to don't throw down the flyout point value, + // set by execute() method of these type of features + if (isDistanceOperation(aOperation)) + return; + + PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast(theWidget); + if (aPnt2dWgt) { + aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY); + } +} + +void PartSet_SketcherMgr::onBeforeContextMenu() +{ + myIsPopupMenuActive = true; +} + +void PartSet_SketcherMgr::onAfterContextMenu() +{ + myIsPopupMenuActive = false; +} + void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, - double& theX, double& theY) + Point& thePoint) { Handle(V3d_View) aView = theWnd->v3dView(); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY); + double aX, anY; + PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY); + thePoint.setValue(aX, anY); } void PartSet_SketcherMgr::launchEditing() { - if (myEditingFeatures.size() > 0) { - FeaturePtr aFeature = myEditingFeatures.first(); + // there should be activate the vertex selection mode because the edit can happens by the selected + // point + QIntList aModes; + aModes << TopAbs_VERTEX << TopAbs_EDGE; + // TODO: #391 - to be uncommented + /*aModes.append(AIS_DSM_Text); + aModes.append(AIS_DSM_Line); + aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX)); + aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));*/ + + XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); + aConnector->activateSubShapesSelection(aModes); + + if (!myCurrentSelection.empty()) { + FeaturePtr aFeature = myCurrentSelection.begin().key(); std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aFeature); if (aSPFeature) { myModule->editFeature(aSPFeature); } } + } @@ -377,10 +582,49 @@ 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; } +bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation) +{ + return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID(); +} + +bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation) +{ + return theOperation && + PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id()); +} + +bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation) +{ + return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation); +} + +bool PartSet_SketcherMgr::isEntityOperation(ModuleBase_Operation* theOperation) +{ + std::string aId = theOperation ? theOperation->id().toStdString() : ""; + + return (aId == SketchPlugin_Line::ID()) || + (aId == SketchPlugin_Point::ID()) || + (aId == SketchPlugin_Arc::ID()) || + (aId == SketchPlugin_Circle::ID()); +} + +bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation) +{ + std::string aId = theOperation ? theOperation->id().toStdString() : ""; + + return (aId == SketchPlugin_ConstraintLength::ID()) || + (aId == SketchPlugin_ConstraintDistance::ID()) || + (aId == SketchPlugin_ConstraintRadius::ID()); +} + void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) { // Display all sketcher sub-Objects @@ -421,16 +665,28 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) { + myIsMouseOverWindow = false; + + XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + DataPtr aData = myCurrentSketch->data(); if ((!aData) || (!aData->isValid())) { // The sketch was aborted myCurrentSketch = CompositeFeaturePtr(); myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter); + + // Erase all sketcher objects + QStringList aSketchIds = sketchOperationIdList(); + QObjectPtrList aObjects = aDisplayer->displayedObjects(); + foreach (ObjectPtr aObj, aObjects) { + DataPtr aObjData = aObj->data(); + if ((!aObjData) || (!aObjData->isValid())) + aDisplayer->erase(aObj); + } return; } // Hide all sketcher sub-Objects - XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); - XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); std::list aResults = aFeature->results(); @@ -453,84 +709,271 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) aDisplayer->updateViewer(); } +void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* ) +{ + connectToPropertyPanel(true); +} + +void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation) +{ + connectToPropertyPanel(false); + myIsPropertyPanelValueChanged = false; + myIsMouseOverViewProcessed = true; +} + +void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation) +{ + if (isNestedCreateOperation(theOperation)) + visualizeFeature(theOperation, true); +} + +bool PartSet_SketcherMgr::canUndo() const +{ + return isNestedCreateOperation(getCurrentOperation()); +} + +bool PartSet_SketcherMgr::canRedo() const +{ + return isNestedCreateOperation(getCurrentOperation()); +} + +bool PartSet_SketcherMgr::canDisplayObject() const +{ + bool aCanDisplay = true; + if (!isNestedCreateOperation(getCurrentOperation())) + return aCanDisplay; + + ModuleBase_Operation* aOperation = getCurrentOperation(); + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0; + // the active widget editor should not influence here. The presentation should be visible always + // when this widget is active. + if (anActiveWdg) { + ModuleBase_WidgetEditor* anEditorWdg = dynamic_cast(anActiveWdg); + if (anEditorWdg) { + return aCanDisplay; + } + } + if (myIsPopupMenuActive) + return aCanDisplay; + + // during a nested create operation, the feature is redisplayed only if the mouse over view + // of there was a value modified in the property panel after the mouse left the view + aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow; + return aCanDisplay; +} + +bool PartSet_SketcherMgr::canSetAuxiliary(bool& theValue) const +{ + bool anEnabled = false; + ModuleBase_Operation* anOperation = getCurrentOperation(); + + bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) || + PartSet_SketcherMgr::isNestedSketchOperation(anOperation); + if (!isActiveSketch) + return anEnabled; + + QObjectPtrList anObjects; + // 1. change auxiliary type of a created feature + if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) && + PartSet_SketcherMgr::isEntityOperation(anOperation) ) { + anObjects.append(anOperation->feature()); + } + else { + /// 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 isNotAuxiliaryFound = false; + if (anObjects.size() > 0) { + QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end(); + 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::AUXILIARY_ID(); + + std::shared_ptr anAuxiliaryAttr = + std::dynamic_pointer_cast(aSketchFeature->data()->attribute(anAttribute)); + if (anAuxiliaryAttr) + isNotAuxiliaryFound = !anAuxiliaryAttr->value(); + } + } + } + } + theValue = anObjects.size() && !isNotAuxiliaryFound; + return anEnabled; +} + +void PartSet_SketcherMgr::setAuxiliary(const bool isChecked) +{ + ModuleBase_Operation* anOperation = getCurrentOperation(); + + bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) || + PartSet_SketcherMgr::isNestedSketchOperation(anOperation); + if (!isActiveSketch) + return; + + QObjectPtrList anObjects; + bool isUseTransaction = false; + // 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 auxiliary type of selected sketch entities + ModuleBase_ISelection* aSelection = myModule->workshop()->selection(); + anObjects = aSelection->selectedPresentations(); + } + + QAction* anAction = myModule->action("AUXILIARY_CMD"); + SessionPtr aMgr = ModelAPI_Session::get(); + if (isUseTransaction) { + if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) + anOperation->abort(); + aMgr->startOperation(anAction->text().toStdString()); + } + storeSelection(); + + if (anObjects.size() > 0) { + QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end(); + for (; anIt != aLast; 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::AUXILIARY_ID(); + + std::shared_ptr anAuxiliaryAttr = + std::dynamic_pointer_cast(aSketchFeature->data()->attribute(anAttribute)); + if (anAuxiliaryAttr) + anAuxiliaryAttr->setValue(isChecked); + } + } + } + } + if (isUseTransaction) { + aMgr->finishOperation(); + } + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + restoreSelection(); +} void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& thePln) { myPlaneFilter->setPlane(thePln->impl()); } -void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject, +void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature, const FeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop, - std::list& theSelectedAttributes) + FeatureToSelectionMap& theSelection) { - FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - if (aFeature.get() == NULL) + if (theFeature.get() == NULL) return; + std::set aSelectedAttributes; + std::set aSelectedResults; + ModuleBase_IViewer* aViewer = theWorkshop->viewer(); Handle(AIS_InteractiveContext) aContext = aViewer->AISContext(); XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - // TODO: check all results and IPresentable feature - ResultPtr aResult = aFeature->firstResult(); - - bool isVisibleSketch = aDisplayer->isVisible(aResult); - AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); - - if (aAISObj.get() != NULL) { + std::list aResults = theFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) + { + ResultPtr aResult = *aIt; + AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); + if (aAISObj.get() == NULL) + continue; Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl(); for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast( aContext->SelectedOwner()); - if (aBRepOwner.IsNull()) continue; - + if (aBRepOwner.IsNull()) + continue; Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast( - aBRepOwner->Selectable()); - if (anIO != anAISIO) continue; + aBRepOwner->Selectable()); + if (anIO != anAISIO) + continue; if (aBRepOwner->HasShape()) { const TopoDS_Shape& aShape = aBRepOwner->Shape(); TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); if (aShapeType == TopAbs_VERTEX) { - AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theObject, + AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch); if (aPntAttr.get() != NULL) - theSelectedAttributes.push_back(aPntAttr); + aSelectedAttributes.insert(aPntAttr); + } + else if (aShapeType == TopAbs_EDGE && + aSelectedResults.find(aResult) == aSelectedResults.end()) { + aSelectedResults.insert(aResult); } } } } + theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults); } -void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject, +void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature, const FeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop, - const std::list& theSelectedAttributes, + const FeatureToSelectionMap& theSelection, SelectMgr_IndexedMapOfOwner& anOwnersToSelect) { - FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - if (aFeature.get() == NULL) + if (theFeature.get() == NULL) return; + FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature); + std::set aSelectedAttributes = anIt.value().first; + std::set aSelectedResults = anIt.value().second; + ModuleBase_IViewer* aViewer = theWorkshop->viewer(); Handle(AIS_InteractiveContext) aContext = aViewer->AISContext(); XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - // TODO: check all results and IPresentable feature - ResultPtr aResult = aFeature->firstResult(); + // 1. found the feature's owners. Check the AIS objects of the constructions + AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature); + if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) { + Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl(); - bool isVisibleSketch = aDisplayer->isVisible(aResult); - AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); + SelectMgr_IndexedMapOfOwner aSelectedOwners; + aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners); + for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) { + Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i); + if (!anOwner.IsNull()) + anOwnersToSelect.Add(anOwner); + } + } - if (aAISObj.get() != NULL) { + // 2. found the feature results's owners + std::list aResults = theFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) + { + ResultPtr aResult = *aIt; + AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); + if (aAISObj.get() == NULL) + continue; Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl(); - SelectMgr_IndexedMapOfOwner aSelectedOwners; - + SelectMgr_IndexedMapOfOwner aSelectedOwners; aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners); for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) { Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i)); @@ -539,18 +982,126 @@ void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject, const TopoDS_Shape& aShape = anOwner->Shape(); TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); if (aShapeType == TopAbs_VERTEX) { - AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch); - if (aPntAttr.get() != NULL) { - std::list::const_iterator anIt = theSelectedAttributes.begin(), - aLast = theSelectedAttributes.end(); - for (; anIt != aLast; anIt++) { - AttributePtr anAttrIt = *anIt; - if (anAttrIt.get() == aPntAttr.get()) { - anOwnersToSelect.Add(anOwner); - } - } + AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch); + if (aPntAttr.get() != NULL && + aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) { + anOwnersToSelect.Add(anOwner); } } + else if (aShapeType == TopAbs_EDGE) { + bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end(); + if (aSelectedResults.find(aResult) != aSelectedResults.end() && + anOwnersToSelect.FindIndex(anOwner) <= 0) + anOwnersToSelect.Add(anOwner); + } + } + } +} + +void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect) +{ + ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(anIWorkshop); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel(); + if (aPropertyPanel) { + const QList& aWidgets = aPropertyPanel->modelWidgets(); + foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { + if (isToConnect) { + connect(aWidget, SIGNAL(beforeValuesChanged()), + this, SLOT(onBeforeValuesChangedInPropertyPanel())); + connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); + connect(aWidget, SIGNAL(afterValuesChanged()), + this, SLOT(onAfterValuesChangedInPropertyPanel())); + } + else { + disconnect(aWidget, SIGNAL(beforeValuesChanged()), + this, SLOT(onBeforeValuesChangedInPropertyPanel())); + disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); + disconnect(aWidget, SIGNAL(afterValuesChanged()), + this, SLOT(onAfterValuesChangedInPropertyPanel())); + } } } } + +ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const +{ + return myModule->workshop()->currentOperation(); +} + +void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation, + const bool isToDisplay) +{ + if (!theOperation || theOperation->isEditOperation()) + return; + + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + + // 1. change visibility of the object itself, here the presentable object is processed, + // e.g. constraints features + FeaturePtr aFeature = theOperation->feature(); + std::list aResults = aFeature->results(); + if (isToDisplay) + aDisplayer->display(aFeature, false); + else + aDisplayer->erase(aFeature, false); + + // change visibility of the object results, e.g. non-constraint features + std::list::const_iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { + if (isToDisplay) { + aDisplayer->display(*aIt, false); + } + else { + aDisplayer->erase(*aIt, false); + } + } + aDisplayer->updateViewer(); +} + +void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) +{ + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + ModuleBase_ISelection* aSelect = aWorkshop->selection(); + QList aHighlighted = aSelect->getHighlighted(); + + QMap > aFeature2AttributeMap; + if (theHighlightedOnly) { + fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch); + } + else { + fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch); + + QList aSelected = aSelect->getSelected(); + fillFeature2Attribute(aSelected, aFeature2AttributeMap, myCurrentSketch); + } + + // 1. it is necessary to save current selection in order to restore it after the features moving + myCurrentSelection.clear(); + QMap >::const_iterator anIt = aFeature2AttributeMap.begin(), + aLast = aFeature2AttributeMap.end(); + for (; anIt != aLast; anIt++) { + FeaturePtr aFeature = anIt.key(); + getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, myCurrentSelection); + } + //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str()); +} + +void PartSet_SketcherMgr::restoreSelection() +{ + //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str()); + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(), + aSLast = myCurrentSelection.end(); + SelectMgr_IndexedMapOfOwner anOwnersToSelect; + for (; aSIt != aSLast; aSIt++) { + anOwnersToSelect.Clear(); + getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection, + anOwnersToSelect); + aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false); + } +}