Salome HOME
Provide local selection for operations outside of sketcher
[modules/shaper.git] / src / XGUI / XGUI_ViewerFilters.cpp
1 // File:        XGUI_ViewerFilters.cpp
2 // Created:     07 Okt 2014
3 // Author:      Vitaly SMETANNIKOV
4
5
6 #include "XGUI_ViewerFilters.h"
7 #include "XGUI_Displayer.h"
8
9 #include <ModelAPI_Session.h>
10 #include <ModelAPI_Document.h>
11
12 #include <AIS_InteractiveObject.hxx>
13
14 IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
15 IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
16
17
18 //TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
19 Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
20 {
21   if (theOwner->HasSelectable()) {
22     Handle(AIS_InteractiveObject) aAisObj = 
23       Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
24     if (!aAisObj.IsNull()) {
25       ObjectPtr aObj = myDisplayer->getObject(aAisObj);
26       if (aObj) {
27         DocumentPtr aDoc = aObj->document();
28         SessionPtr aMgr = ModelAPI_Session::get();
29         return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
30       }
31     }
32   }
33   return Standard_False;
34 }