QList<ModuleBase_ViewerPrsPtr> aPreSelected =
aSelection->getSelected(ModuleBase_ISelection::AllControls);
+ ModuleBase_OperationFeature* aCurOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (myWorkshop->currentOperation());
+ QString anOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : "";
+
+
bool isCommitted;
if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
return;
if (aMessage.get()) {
setReentrantPreSelection(aMessage);
}
- else
+ else if (anOperationKind == theCmdId) // restore of selection only if the kind is the same
aFOperation->initSelection(aPreSelected);
workshop()->processLaunchOperation(aFOperation);
#ifdef DEBUG_WIDGET_INSTANCE
qDebug("ModuleBase_ModelWidget::updateObject");
#endif
- ModuleBase_Tools::flushUpdated(theObject);
+ ModuleBase_Tools::blockUpdateViewer(true);
+ // Fix the problem of not previewed results of constraints applied. Flush Create/Delete
+ // (for the sketch result) to start processing of the sketch in the solver.
+ // TODO: these flushes should be moved in a separate method provided by Model
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+
+ ModuleBase_Tools::blockUpdateViewer(false);
emit objectUpdated();
}
}
// cash is used only to restore selection, so it should be filled in storeSelection and
// after applying immediatelly cleared in restoreSelection
myCurrentSelection.clear();
- sketchMgr()->storeSelection(false, myCurrentSelection);
+ sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection);
}
void PartSet_Module::restoreSelection()
myModule->sketchReentranceMgr()->isInternalEditActive())
return;
// it is necessary to save current selection in order to restore it after the values are modifed
- storeSelection(false);
+ storeSelection(ST_SelectAndHighlightType);
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
ModuleBase_ISelection* aSelect = aWorkshop->selection();
bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
- storeSelection(!aHasShift, myCurrentSelection);
+ storeSelection(aHasShift ? ST_SelectAndHighlightType : ST_HighlightType, myCurrentSelection);
if (myCurrentSelection.empty()) {
if (isSketchOpe && (!isSketcher))
if (aResults.size() > 0) {
ResultPtr aFirstResult = theFeature->firstResult();
if (aFirstResult.get() && aFirstResult->shape().get()) {
- const TopoDS_Shape& aFirstShape = aFirstResult->shape()->impl<TopoDS_Shape>();
+ TopoDS_Shape aFirstShape = aFirstResult->shape()->impl<TopoDS_Shape>();
isSameShape = aFirstShape.IsEqual(anInfo.myFirstResultShape);
}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
-void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly,
+void PartSet_SketcherMgr::storeSelection(const SelectionType theType,
PartSet_SketcherMgr::FeatureToSelectionMap& theCurrentSelection)
{
if (!myCurrentSketch.get())
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_ISelection* aSelect = aWorkshop->selection();
- QList<ModuleBase_ViewerPrsPtr> aStoredPrs = aSelect->getHighlighted();
+ QList<ModuleBase_ViewerPrsPtr> aStoredPrs;
+
+ if (theType == ST_HighlightType || theType == ST_SelectAndHighlightType)
+ aStoredPrs = aSelect->getHighlighted();
QList<FeaturePtr> aFeatureList;
- if (!theHighlightedOnly) {
+ if (theType == ST_SelectAndHighlightType || theType == ST_SelectType) {
QList<ModuleBase_ViewerPrsPtr> aSelected = aSelect->getSelected(
ModuleBase_ISelection::AllControls);
aStoredPrs.append(aSelected);
/// \return boolean value
bool isObjectOfSketch(const ObjectPtr& theObject) const;
+ /// Enumeration for selection mode used
+ enum SelectionType {
+ ST_HighlightType, /// Only highlighted objects
+ ST_SelectType, /// Only selected objects
+ ST_SelectAndHighlightType /// Both, highlighted and selected objects
+ };
+
/// Saves the current selection in the viewer into an internal container
/// It obtains the selected attributes.
/// The highlighted objects can be processes as the selected ones
/// \param theHighlightedOnly a boolean flag
/// \param theCurrentSelection a container filled by the current selection
- void storeSelection(const bool theHighlightedOnly, FeatureToSelectionMap& theCurrentSelection);
+ void storeSelection(const SelectionType theType, FeatureToSelectionMap& theCurrentSelection);
/// Restores previously saved selection state
/// \param theCurrentSelection a container filled by the current selection
// set as current also after it becomes sub to set correctly enabled for other sketch subs
document()->setCurrentFeature(aNew, false);
- static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
- aLoop->flush(aDeleteEvent);
-
return aNew;
}