ModuleBase_IViewer.h
ModuleBase_WidgetLineEdit.h
ModuleBase_WidgetMultiSelector.h
+ ModuleBase_ViewerFilters.h
)
SET(PROJECT_SOURCES
ModuleBase_DoubleSpinBox.cpp
ModuleBase_WidgetLineEdit.cpp
ModuleBase_WidgetMultiSelector.cpp
+ ModuleBase_ViewerFilters.cpp
)
SET(PROJECT_LIBRARIES
#include "ModuleBase_Definitions.h"
#include <ModelAPI_Object.h>
+#include <GeomAPI_AISObject.h>
#include <QObject>
//! Returns currently active operation
virtual ModuleBase_Operation* currentOperation() const = 0;
+ //! Returns AIS opbject by data object
+ virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0;
+
+ //! Returns data object by AIS
+ virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
+
signals:
void selectionChanged();
--- /dev/null
+// File: ModuleBase_ViewerFilters.cpp
+// Created: 07 Okt 2014
+// Author: Vitaly SMETANNIKOV
+
+
+#include "ModuleBase_ViewerFilters.h"
+#include "ModuleBase_IWorkshop.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+
+#include <AIS_InteractiveObject.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
+
+
+//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
+Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+ if (theOwner->HasSelectable()) {
+ Handle(AIS_InteractiveObject) aAisObj =
+ Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+ if (!aAisObj.IsNull()) {
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+ ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+ if (aObj) {
+ DocumentPtr aDoc = aObj->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
+ }
+ }
+ }
+ return Standard_False;
+}
\ No newline at end of file
--- /dev/null
+// File: ModuleBase_ViewerFilters.h
+// Created: 07 Okt 2014
+// Author: Vitaly SMETANNIKOV
+
+
+#ifndef ModuleBase_ViewerFilters_H
+#define ModuleBase_ViewerFilters_H
+
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+class ModuleBase_IWorkshop;
+
+DEFINE_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
+
+class ModuleBase_ShapeDocumentFilter: public SelectMgr_Filter
+{
+public:
+ Standard_EXPORT ModuleBase_ShapeDocumentFilter(ModuleBase_IWorkshop* theWorkshop): SelectMgr_Filter(),
+ myWorkshop(theWorkshop) {}
+
+ Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+ DEFINE_STANDARD_RTTI(ModuleBase_ShapeDocumentFilter)
+
+private:
+ ModuleBase_IWorkshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
SLOT(onKeyRelease(QKeyEvent*)));
connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
SLOT(onMouseDoubleClick(QMouseEvent*)));
-
- myDocumentShapeFilter = new XGUI_ShapeDocumentFilter(aXWshop->displayer());
}
PartSet_Module::~PartSet_Module()
aDisplayer->setSelectionModes(aModes);
}
}
- } else {
- //TODO (VSV): We have to open Local context because at neutral point filters don't work (bug 25340)
- aDisplayer->addSelectionFilter(myDocumentShapeFilter);
}
}
// aDisplayer->activate(*aIt);
//}
- // The document limitation selection has to be only during operation
- aDisplayer->removeSelectionFilter(myDocumentShapeFilter);
+
+
}
// Clear selection done during operation
aDisplayer->clearSelected();
#include <ModuleBase_IModule.h>
#include <ModuleBase_Definitions.h>
#include <XGUI_Command.h>
-#include <XGUI_ViewerFilters.h>
#include <ModelAPI_Feature.h>
#include <StdSelect_FaceFilter.hxx>
std::map<std::string, std::string> myFeaturesInFiles;
- /// A filter which provides selection within a current document or whole PartSet
- Handle(XGUI_ShapeDocumentFilter) myDocumentShapeFilter;
Handle(StdSelect_FaceFilter) myPlaneFilter;
};
XGUI_Preferences.h
XGUI_IPrefMgr.h
XGUI_QtEvents.h
- XGUI_ViewerFilters.h
)
SET(PROJECT_AUTOMOC
XGUI_Selection.cpp
XGUI_Preferences.cpp
XGUI_QtEvents.cpp
- XGUI_ViewerFilters.cpp
)
SET(PROJECT_RESOURCES
if (isVisible(theObject)) {
redisplay(theObject, isUpdateViewer);
} else {
- boost::shared_ptr<GeomAPI_AISObject> anAIS;
+ AISObjectPtr anAIS;
GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
bool isShading = false;
if (aPrs) {
- anAIS = aPrs->getAISObject(boost::shared_ptr<GeomAPI_AISObject>());
+ anAIS = aPrs->getAISObject(AISObjectPtr());
} else {
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult) {
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (aShapePtr) {
- anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+ anAIS = AISObjectPtr(new GeomAPI_AISObject());
anAIS->createShape(aShapePtr);
isShading = true;
}
}
}
-void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS,
+void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
bool isShading, bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
return;
- boost::shared_ptr<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theObject];
+ AISObjectPtr anObject = myResult2AISObjectMap[theObject];
if (anObject) {
Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
return;
Handle(AIS_InteractiveObject) aAISIO;
- boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ AISObjectPtr aAISObj = getAISObject(theObject);
GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
if (aPrs) {
- boost::shared_ptr<GeomAPI_AISObject> aAIS_Obj = aPrs->getAISObject(aAISObj);
+ AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
if (aAISObj && !aAIS_Obj) {
erase(theObject, isUpdateViewer);
return;
if (aContext.IsNull())
return;
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+ AISObjectPtr anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
aContext->Deactivate(anAIS);
}
if (aContext.IsNull())
return;
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+ AISObjectPtr anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
if (aContext->HasOpenedContext()) {
aContext->Load(anAIS, -1, true);
if (!isVisible(theObject))
return false;
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap.at(theObject);
+ AISObjectPtr anObj = myResult2AISObjectMap.at(theObject);
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
TColStd_ListOfInteger aModes;
if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end())
continue;
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[aResult];
+ AISObjectPtr anObj = myResult2AISObjectMap[aResult];
if (anObj) {
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull())
ResultToAISMap::iterator aIt;
for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
// erase an object
- boost::shared_ptr<GeomAPI_AISObject> aAISObj = (*aIt).second;
+ AISObjectPtr aAISObj = (*aIt).second;
Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anIO.IsNull())
ic->Remove(anIO, false);
for (; aFIt != aFLast; aFIt++) {
ObjectPtr aFeature = (*aFIt).first;
if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
- boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
+ AISObjectPtr anObj = (*aFIt).second;
if (!anObj)
continue;
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
closeAllContexts(true);
}
-boost::shared_ptr<GeomAPI_AISObject> XGUI_Displayer::getAISObject(ObjectPtr theObject) const
+AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
{
- boost::shared_ptr<GeomAPI_AISObject> anIO;
+ AISObjectPtr anIO;
if (myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end())
anIO = (myResult2AISObjectMap.find(theObject))->second;
return anIO;
}
-ObjectPtr XGUI_Displayer::getObject(Handle(AIS_InteractiveObject) theIO) const
+ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
+{
+ Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
+ return getObject(aRefAIS);
+}
+
+ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
{
ObjectPtr aFeature;
ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
myResult2AISObjectMap.end();
for (; aFIt != aFLast && !aFeature; aFIt++) {
- boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
+ AISObjectPtr anObj = (*aFIt).second;
if (!anObj)
continue;
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
return myWorkshop->viewer()->AISContext();
}
-void XGUI_Displayer::display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate)
+void XGUI_Displayer::display(AISObjectPtr theAIS, bool isUpdate)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
aContext->Display(anAISIO, isUpdate);
}
-void XGUI_Displayer::erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate)
+void XGUI_Displayer::erase(AISObjectPtr theAIS, const bool isUpdate)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (aContext.IsNull())
return;
- boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ AISObjectPtr aAISObj = getAISObject(theObject);
if (!aAISObj)
return;
if (aContext.IsNull())
return NoMode;
- boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ AISObjectPtr aAISObj = getAISObject(theObject);
if (!aAISObj)
return NoMode;
void display(ObjectPtr theObject, bool isUpdateViewer = true);
/// Display the given AIS object. To hide this object use corresponde erase method
- void display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate = true);
+ void display(AISObjectPtr theAIS, bool isUpdate = true);
/// Stop the current selection and color the given features to the selection color
/// \param theFeatures a list of features to be disabled
void erase(ObjectPtr theObject, const bool isUpdateViewer = true);
/// Erase the given AIS object displayed by corresponded display method
- void erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate = true);
+ void erase(AISObjectPtr theAIS, const bool isUpdate = true);
/// Erase all presentations
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
/// Searches the interactive object by feature
/// \param theFeature the feature or NULL if it not visualized
/// \return theIO an interactive object
- boost::shared_ptr<GeomAPI_AISObject> getAISObject(ObjectPtr theFeature) const;
+ AISObjectPtr getAISObject(ObjectPtr theFeature) const;
/// Searches the feature by interactive object
/// \param theIO an interactive object
/// \return feature the feature or NULL if it not visualized
- ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const;
+ ObjectPtr getObject(const AISObjectPtr& theIO) const;
+ ObjectPtr getObject(const Handle(AIS_InteractiveObject)& theIO) const;
/// Deactivates the given object (not allow selection)
void deactivate(ObjectPtr theFeature);
/// \param theAIS AIS presentation
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
/// Returns true if the Feature succesfully displayed
- void display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isShading,
+ void display(ObjectPtr theObject, AISObjectPtr theAIS, bool isShading,
bool isUpdateViewer = true);
/// Display the shape and activate selection of sub-shapes
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
/// \returns true if the presentation is created
//bool redisplay(ObjectPtr theObject,
- // boost::shared_ptr<GeomAPI_AISObject> theAIS,
+ // AISObjectPtr theAIS,
// const bool isUpdateViewer = true);
/** Redisplay the shape if it was displayed
protected:
XGUI_Workshop* myWorkshop;
- typedef std::map<ObjectPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
+ typedef std::map<ObjectPtr, AISObjectPtr> ResultToAISMap;
ResultToAISMap myResult2AISObjectMap;
};
#include "XGUI_OperationMgr.h"
#include "XGUI_Displayer.h"
+#include <AIS_Shape.hxx>
+
+
XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
: ModuleBase_IWorkshop(theWorkshop),
myWorkshop(theWorkshop)
this, SIGNAL(operationStarted(ModuleBase_Operation*)));
connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SIGNAL(operationStopped(ModuleBase_Operation*)));
+
+ myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
}
XGUI_ModuleConnector::~XGUI_ModuleConnector()
{
+ myDocumentShapeFilter.Nullify();
}
ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
aDisp->openLocalContext();
- // Use empty list because we will use standard modes
- aDisp->activateObjectsOutOfContext(QIntList());
- aDisp->setSelectionModes(theTypes);
+ // Convert shape types to selection types
+ QIntList aModes;
+ foreach(int aType, theTypes) {
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
+ }
+ aDisp->activateObjectsOutOfContext(aModes);
+ //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
+ aDisp->addSelectionFilter(myDocumentShapeFilter);
}
void XGUI_ModuleConnector::deactivateSubShapesSelection()
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
+ // The document limitation selection has to be only during operation
+ aDisp->removeSelectionFilter(myDocumentShapeFilter);
aDisp->closeLocalContexts(false);
}
+
+AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
+{
+ XGUI_Displayer* aDisp = myWorkshop->displayer();
+ return aDisp->getAISObject(theObject);
+}
+
+ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
+{
+ XGUI_Displayer* aDisp = myWorkshop->displayer();
+ return aDisp->getObject(theAIS);
+}
\ No newline at end of file
#include "XGUI.h"
#include <ModuleBase_Definitions.h>
#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ViewerFilters.h>
class Handle_AIS_InteractiveContext;
class XGUI_Workshop;
//! Returns currently active operation
virtual ModuleBase_Operation* currentOperation() const;
+ //! Returns AIS opbject by data object
+ virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
+
+ //! Returns data object by AIS
+ virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
+
XGUI_Workshop* workshop() const { return myWorkshop; }
- private:
+private:
XGUI_Workshop* myWorkshop;
+
+ /// A filter which provides selection within a current document or whole PartSet
+ Handle(ModuleBase_ShapeDocumentFilter) myDocumentShapeFilter;
};
#endif
+++ /dev/null
-// File: XGUI_ViewerFilters.cpp
-// Created: 07 Okt 2014
-// Author: Vitaly SMETANNIKOV
-
-
-#include "XGUI_ViewerFilters.h"
-#include "XGUI_Displayer.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
-
-#include <AIS_InteractiveObject.hxx>
-
-IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
-IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
-
-
-//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
-Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
-{
- if (theOwner->HasSelectable()) {
- Handle(AIS_InteractiveObject) aAisObj =
- Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
- if (!aAisObj.IsNull()) {
- ObjectPtr aObj = myDisplayer->getObject(aAisObj);
- if (aObj) {
- DocumentPtr aDoc = aObj->document();
- SessionPtr aMgr = ModelAPI_Session::get();
- return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
- }
- }
- }
- return Standard_False;
-}
\ No newline at end of file
+++ /dev/null
-// File: XGUI_ViewerFilters.h
-// Created: 07 Okt 2014
-// Author: Vitaly SMETANNIKOV
-
-
-#ifndef XGUI_ViewerFilters_H
-#define XGUI_ViewerFilters_H
-
-#include <SelectMgr_Filter.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-
-class XGUI_Displayer;
-
-DEFINE_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
-
-class XGUI_ShapeDocumentFilter: public SelectMgr_Filter
-{
-public:
- Standard_EXPORT XGUI_ShapeDocumentFilter(XGUI_Displayer* myDisp): SelectMgr_Filter(),
- myDisplayer(myDisp) {}
-
- Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
-
- DEFINE_STANDARD_RTTI(XGUI_ShapeDocumentFilter)
-
-private:
- XGUI_Displayer* myDisplayer;
-};
-
-#endif
\ No newline at end of file