anOperation->setFeature(theFeature);
sendOperation(anOperation);
}
+
+bool ModuleBase_IModule::canActivateSelection(const ObjectPtr& theObject) const
+{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ return !(aOperation && (!aOperation->isEditOperation()) && aOperation->hasObject(theObject));
+}
\ No newline at end of file
/// \param theObject a model object\r
virtual bool canDisplayObject(const ObjectPtr& theObject) const;\r
\r
+ /// Returns true if selection for the object can be activate.\r
+ /// By default a result or feature of the current operation can not be activated\r
+ /// \param theObject a model object\r
+ virtual bool canActivateSelection(const ObjectPtr& theObject) const;\r
+\r
/// Reacts to the delete action in module\r
/// \returns true if the action is processed\r
virtual bool deleteObjects() { return false; };\r
}
}
-void XGUI_Displayer::activateObjects(const QIntList& theModes)
+void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList)
{
#ifdef DEBUG_ACTIVATE
qDebug(QString("activate all features: theModes: %2, myActiveSelectionModes: %3").
//aContext->UseDisplayedObjects();
//myUseExternalObjects = true;
+ Handle(AIS_InteractiveObject) anAISIO;
AIS_ListOfInteractive aPrsList;
- ::displayedObjects(aContext, aPrsList);
+ if (theObjList.isEmpty())
+ ::displayedObjects(aContext, aPrsList);
+ else {
+ foreach(ObjectPtr aObj, theObjList) {
+ if (myResult2AISObjectMap.contains(aObj))
+ aPrsList.Append(myResult2AISObjectMap[aObj]->impl<Handle(AIS_InteractiveObject)>());
+ }
+ }
Handle(AIS_Trihedron) aTrihedron;
AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
- Handle(AIS_InteractiveObject) anAISIO;
for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
anAISIO = aLIt.Value();
- activate(anAISIO, myActiveSelectionModes);
+ aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
+ if (aTrihedron.IsNull())
+ activate(anAISIO, myActiveSelectionModes);
}
}
if (aTColModes.IsEmpty())
aContext->Load(theIO, -1, true);
- Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
- //Deactivate trihedron which can be activated in local selector
- if (aTrihedron.IsNull()) {
//aContext->Load(anAISIO, -1, true);
// In order to clear active modes list
- if (theModes.size() == 0) {
- //aContext->Load(anAISIO, 0, true);
- aContext->Activate(theIO);
+ if (theModes.size() == 0) {
+ //aContext->Load(anAISIO, 0, true);
+ aContext->Activate(theIO);
#ifdef DEBUG_ACTIVATE
- qDebug("activate in all modes");
+ qDebug("activate in all modes");
#endif
- } else {
- foreach(int aMode, theModes) {
- //aContext->Load(anAISIO, aMode, true);
- if (!aModesActivatedForIO.contains(aMode)) {
- aContext->Activate(theIO, aMode);
+ } else {
+ foreach(int aMode, theModes) {
+ //aContext->Load(anAISIO, aMode, true);
+ if (!aModesActivatedForIO.contains(aMode)) {
+ aContext->Activate(theIO, aMode);
#ifdef DEBUG_ACTIVATE
- qDebug(QString("activate: %1").arg(aMode).toStdString().c_str());
+ qDebug(QString("activate: %1").arg(aMode).toStdString().c_str());
#endif
- }
}
}
}
/// Activates in local context displayed outside of the context.
/// \param theModes - modes on which it has to be activated (can be empty)
- void activateObjects(const QIntList& theModes);
+ /// \param theObjList - list of objects which has to be activated. Can be empty. In this case all displayed objects will be used.
+ void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList = QObjectPtrList());
/// Activates in local context displayed outside of the context.
void deactivateObjects();
}
+QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
+{
+ QObjectPtrList aActiveOPbjects;
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ // Activate objects only which can be activated
+ foreach (ObjectPtr aObj, theObjList) {
+ if (aModule->canActivateSelection(aObj))
+ aActiveOPbjects.append(aObj);
+ }
+ return aActiveOPbjects;
+}
+
void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
else
aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
}
- aDisp->activateObjects(aModes);
+ aDisp->activateObjects(aModes, activeObjects(aDisp->displayedObjects()));
//TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
//aDisp->addSelectionFilter(myDocumentShapeFilter);
}
// 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);
+ aDisp->activateObjects(aModes, activeObjects(aDisp->displayedObjects()));
// The document limitation selection has to be only during operation
//aDisp->removeSelectionFilter(myDocumentShapeFilter);
//aDisp->closeLocalContexts(false);
XGUI_Workshop* workshop() const { return myWorkshop; }
private:
+ QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
+
/// Reference to workshop
XGUI_Workshop* myWorkshop;
// of redisplay is called. This modification is made in order to have the line is updated
// by creation of a horizontal constraint on the line by preselection
myDisplayer->redisplay(aObj, false);
- if (myOperationMgr->hasOperation()) {
- ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if (!aOperation->isEditOperation() &&
- aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+ //if (myOperationMgr->hasOperation()) {
+ // ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ // if (!aOperation->isEditOperation() &&
+ // aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+ if (!myModule->canActivateSelection(aObj)) {
+ if (myDisplayer->isActive(aObj))
myDisplayer->deactivate(aObj);
}
} else { // display object if the current operation has it
if (displayObject(aObj)) {
- ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if (aOperation && aOperation->hasObject(aObj)) {
- ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ //ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ //if (aOperation && aOperation->hasObject(aObj)) {
+ if (!myModule->canActivateSelection(aObj)) {
#ifdef DEBUG_FEATURE_REDISPLAY
QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
qDebug(QString(" display object = %1").arg(anObjInfo).toStdString().c_str());