Scenario: select a line, start distance constraint operation, activate a point widget, the object is not selected in the viewer, but click 'Esc', the first control is filled by this object.
/// \returns true if the action is processed\r
virtual bool deleteObjects() { return false; };\r
\r
+ /// Returns a list of modes, where the AIS objects should be activated\r
+ /// \param theModes a list of modes\r
+ virtual void activeSelectionModes(QIntList& theModes) {};\r
+\r
public slots:\r
/// Called on call of command corresponded to a feature\r
void onFeatureTriggered();\r
return myMenuMgr->addViewerItems(theMenu, theStdActions);
}
+void PartSet_Module::activeSelectionModes(QIntList& theModes)
+{
+ theModes.clear();
+ if (mySketchMgr->activeSketch().get())
+ PartSet_SketcherMgr::sketchSelectionModes(theModes);
+}
+
bool PartSet_Module::isMouseOverWindow()
{
return mySketchMgr->isMouseOverWindow();
/// \return true if items are added and there is no necessity to provide standard menu
virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
+ /// Returns a list of modes, where the AIS objects should be activated
+ /// \param theModes a list of modes
+ virtual void activeSelectionModes(QIntList& theModes);
+
/// Returns whether the mouse enter the viewer's window
/// \return true if items are added and there is no necessity to provide standard menu
bool isMouseOverWindow();
return aIds;
}
+void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
+{
+ theModes.clear();
+
+ theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
+ theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
+ theModes.append(SketcherPrs_Tools::Sel_Constraint);
+ theModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+ theModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+}
bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
{
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
QIntList aModes;
- if (isActive) {
- aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
- aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
- aModes.append(SketcherPrs_Tools::Sel_Constraint);
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
- }
+ if (isActive)
+ sketchSelectionModes(aModes);
aDisplayer->activateObjects(aModes);
}
/// Returns list of strings which contains id's of constraints operations
static const QStringList& constraintsIdList();
+ /// Returns a list of modes, where the AIS objects should be activated
+ /// \param theModes a list of modes
+ static void sketchSelectionModes(QIntList& theModes);
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
//#define DEBUG_ACTIVATE
//#define DEBUG_FEATURE_REDISPLAY
//#define DEBUG_SELECTION_FILTERS
+//#define DEBUG_USE_CLEAR_OUTDATED_SELECTION
// Workaround for bug #25637
void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
AISObjectPtr anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
aContext->Deactivate(anAIS);
+#ifdef DEBUG_USE_CLEAR_OUTDATED_SELECTION
+ aContext->LocalContext()->ClearOutdatedSelection(anAIS, true);
+ updateViewer();
+#endif
}
}
for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
anAISIO = aLIt.Value();
aContext->Deactivate(anAISIO);
+#ifdef DEBUG_USE_CLEAR_OUTDATED_SELECTION
+ aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true);
+ updateViewer();
+#endif
}
}
return aWasEnabled;
}
-void XGUI_Displayer::updateViewer()
+void XGUI_Displayer::updateViewer() const
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (!aContext.IsNull() && myEnableUpdateViewer)
aContext->ActivatedModes(theIO, aTColModes);
TColStd_ListIteratorOfListOfInteger itr( aTColModes );
QIntList aModesActivatedForIO;
+ //bool isDeactivated = false;
for (; itr.More(); itr.Next() ) {
Standard_Integer aMode = itr.Value();
if (!theModes.contains(aMode)) {
qDebug(QString("deactivate: %1").arg(aMode).toStdString().c_str());
#endif
aContext->Deactivate(theIO, aMode);
+ //isDeactivated = true;
}
else {
aModesActivatedForIO.append(aMode);
#endif
}
}
+#ifdef DEBUG_USE_CLEAR_OUTDATED_SELECTION
+ if (isDeactivated) {
+ aContext->LocalContext()->ClearOutdatedSelection(theIO, true);
+ updateViewer();
+ }
+#endif
// loading the interactive object allowing the decomposition
if (aTColModes.IsEmpty())
aContext->Load(theIO, -1, true);
bool enableUpdateViewer(const bool isEnabled);
/// Updates the viewer
- void updateViewer();
+ void updateViewer() const;
/// Searches the interactive object by feature
/// \param theObject the object or presentable feature
#include "XGUI_Displayer.h"
#include "XGUI_PropertyPanel.h"
+#include <ModuleBase_IModule.h>
+
#include <AIS_Shape.hxx>
XGUI_Displayer* aDisp = myWorkshop->displayer();
// Clear selection modes
QIntList aModes;
+ // TODO: check on OCC6.9.0
+ // the module current active modes should not be deactivated in order to save the objects selected
+ // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
+ // But, in OCC6.8.0 this deselection does not happened automatically. It is necessary to call
+ // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
+ // the OCC6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
+ // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
+ module()->activeSelectionModes(aModes);
aDisp->activateObjects(aModes);
// The document limitation selection has to be only during operation
//aDisp->removeSelectionFilter(myDocumentShapeFilter);
//myDisplayer->activateObjects(aModes);
myModule->operationStopped(theOperation);
- if (myOperationMgr->operationsCount() == 0) {
+ // if the operation is nested, do not deactivate objects
+ //if (myOperationMgr->operationsCount() == 0) {
// Activate selection mode for all objects
- QIntList aModes;
- myDisplayer->activateObjects(aModes);
- }
+ QIntList aModes;
+ // TODO: check on OCC_6.9.0
+ // the module current active modes should not be deactivated in order to save the objects selected
+ // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
+ // But, in OCC_6.8.0 this deselection does not happened automatically. It is necessary to call
+ // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
+ // the OCC_6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
+ // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
+ module()->activeSelectionModes(aModes);
+ myDisplayer->activateObjects(aModes);
+ //}
}