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);
+ //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
FeatureToAttributesMap::const_iterator anIt = myFeature2AttributeMap.begin(),
aLast = myFeature2AttributeMap.end();
+ FeatureToSelectionMap aCurrentSelection;
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = anIt.key();
AttributePtr anAttr;
}
// save the previous selection
- std::set<AttributePtr> aSelectedAttributes;
- std::set<ResultPtr> aSelectedResults;
- getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
- aSelectedResults);
+ getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, aCurrentSelection);
// save the previous selection: end
- // Process selection by attribute
+ // Process selection by attribute: the priority to the attribute
if (anAttr.get() != NULL) {
std::string aAttrId = anAttr->id();
DataPtr aData = aFeature->data();
if (aSketchFeature) {
aSketchFeature->move(dX, dY);
ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
- // TODO: the selection restore should be after the AIS presentation is rebuilt
}
}
- //Events_Loop::loop()->flush(aMoveEvent);
- //Events_Loop::loop()->flush(aUpdateEvent);
- // restore the previous selection
- //TODO: after the last flush
- //SelectMgr_IndexedMapOfOwner anOwnersToSelect;
- //getSelectionOwners(aFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
- // aSelectedResults, anOwnersToSelect);
- //TODO: after the last flush
- //aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
- // restore the previous selection
- ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent, true);
- Events_Loop::loop()->flush(aUpdateEvent);
}
- Events_Loop::loop()->flush(aMoveEvent);
- Events_Loop::loop()->flush(aUpdateEvent);
+ 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
+
+ // restore the previous selection
+ FeatureToSelectionMap::const_iterator aSIt = aCurrentSelection.begin(),
+ aSLast = aCurrentSelection.end();
+ SelectMgr_IndexedMapOfOwner anOwnersToSelect;
+ for (; aSIt != aSLast; aSIt++) {
+ anOwnersToSelect.Clear();
+ getSelectionOwners(aSIt->first, myCurrentSketch, aWorkshop, aCurrentSelection,
+ anOwnersToSelect);
+ aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
+ }
+ // restore the previous selection: end
aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
aDisplayer->updateViewer();
myCurY = aY;
}
}
- //if ((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<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
- // // Find corresponded widget to provide dragging
- // foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
- // if (aWgt->attributeID() == aAttrId) {
- // PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
- // if (aWgt2d) {
- // aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
- // break;
- // }
- // }
- // }
- //} else {
- // ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
- // XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
- // XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
- // bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
-
- // foreach(FeaturePtr aFeature, myEditingFeatures) {
- // std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- // std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- // if (aSketchFeature) {
- // // save the previous selection
-
- // std::set<AttributePtr> aSelectedAttributes;
- // std::set<ResultPtr> aSelectedResults;
- // getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
- // aSelectedResults);
- // // save the previous selection: end
-
- // aSketchFeature->move(dX, dY);
- // // 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
- // SelectMgr_IndexedMapOfOwner anOwnersToSelect;
- // getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
- // aSelectedResults, anOwnersToSelect);
- // aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
- // // restore the previous selection
- // }
- // ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent, true);
- // Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- // }
- // // 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(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- // aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
- // aDisplayer->updateViewer();
- //}
void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
// there should be activate the vertex selection mode because the edit can happens by the selected
// point
QIntList aModes;
- aModes << TopAbs_VERTEX;
+ aModes << TopAbs_VERTEX << TopAbs_EDGE;
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
aConnector->activateSubShapesSelection(aModes);
myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
}
-void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject,
+void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
const FeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop,
- std::set<AttributePtr>& theSelectedAttributes,
- std::set<ResultPtr>& theSelectedResults)
+ FeatureToSelectionMap& theSelection)
+ //std::set<AttributePtr>& theSelectedAttributes,
+ //std::set<ResultPtr>& theSelectedResults)
{
- FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (aFeature.get() == NULL)
+ if (theFeature.get() == NULL)
return;
+ std::set<AttributePtr> aSelectedAttributes;
+ std::set<ResultPtr> aSelectedResults;
+
ModuleBase_IViewer* aViewer = theWorkshop->viewer();
Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults = theFeature->results();
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
{
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.insert(aPntAttr);
+ aSelectedAttributes.insert(aPntAttr);
}
else if (aShapeType == TopAbs_EDGE &&
- theSelectedResults.find(aResult) == theSelectedResults.end()) {
- theSelectedResults.insert(aResult);
+ 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::set<AttributePtr>& theSelectedAttributes,
- const std::set<ResultPtr>& theSelectedResults,
+ //const std::set<AttributePtr>& theSelectedAttributes,
+ //const std::set<ResultPtr>& theSelectedResults,
+ 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<AttributePtr> aSelectedAttributes = anIt->second.first;
+ std::set<ResultPtr> aSelectedResults = anIt->second.second;
+
ModuleBase_IViewer* aViewer = theWorkshop->viewer();
Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
- std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr> aResults = theFeature->results();
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
{
const TopoDS_Shape& aShape = anOwner->Shape();
TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
if (aShapeType == TopAbs_VERTEX) {
- AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
+ AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
if (aPntAttr.get() != NULL &&
- theSelectedAttributes.find(aPntAttr) != theSelectedAttributes.end()) {
+ aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
anOwnersToSelect.Add(anOwner);
}
}
else if (aShapeType == TopAbs_EDGE) {
- bool aFound = theSelectedResults.find(aResult) != theSelectedResults.end();
- int anIndex = anOwnersToSelect.FindIndex(anOwner);
- if (theSelectedResults.find(aResult) != theSelectedResults.end()/* &&
- anOwnersToSelect.FindIndex(anOwner) < 0*/)
+ bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
+ if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
+ anOwnersToSelect.FindIndex(anOwner) <= 0)
anOwnersToSelect.Add(anOwner);
}
}
class ModuleBase_Operation;
class QMouseEvent;
-
/**
* A class for management of sketch operations
*/
void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
double& theX, double& theY);
+
+ typedef std::map<FeaturePtr, std::pair<std::set<AttributePtr>, std::set<ResultPtr> > >
+ FeatureToSelectionMap;
/// Obtains the current selection of the object in the workshop viewer
/// It includes the selection in all modes of activation, even local context - vertices, edges
/// It gets all results of the feature, find an AIS object in the viewer and takes all BRep
/// selection owners. If the owner is vertex, the corresponded attribute is seached in
/// the feature, if the owner is edge, the current result is added to the container of results.
- /// \param theObject a feature or result object
+ /// \param theFeature a feature or result object
/// \param theSketch a current sketch feature
/// \param theWorkshop a workshop to have an access to AIS context and displayer
- /// \param theSelectedAttributes an out list of selected attributes
- /// \param theSelectedResults an out list of selected results
- static void getCurrentSelection(const ObjectPtr& theObject,
+ /// \param theSelection a container for the selection, to save results and attributres for a feature
+ static void getCurrentSelection(const FeaturePtr& theFeature,
const FeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop,
- std::set<AttributePtr>& theSelectedAttributes,
- std::set<ResultPtr>& theSelectedResults);
+ FeatureToSelectionMap& theSelection);
/// Applyes the current selection to the object in the workshop viewer
/// It includes the selection in all modes of activation, even local context - vertexes, edges
/// the feature and if it is in the container of selected attributes, the owner is put in the
/// out container. If the owner is edge and the current result is in the container of selected
/// results, the owner is put in the out container.
- /// \param theObject a feature or result object
+ /// \param theFeature a feature or result object
/// \param theSketch a current sketch feature
/// \param theWorkshop a workshop to have an access to AIS context and displayer
- /// \param theSelectedAttributes an list of selected attributes
- /// \param theSelectedResults an list of selected results
+ /// \param theSelection a container of the selection, it has results and attributres for a feature
/// \param theOwnersToSelect an out container of found owners
- static void getSelectionOwners(const ObjectPtr& theObject,
+ static void getSelectionOwners(const FeaturePtr& theFeature,
const FeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop,
- const std::set<AttributePtr>& theSelectedAttributes,
- const std::set<ResultPtr>& theSelectedResults,
+ const FeatureToSelectionMap& theSelection,
SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
private: