#include <ModelAPI_Tools.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_AttributeReference.h>
return false;
}
}
+ // Check that object belongs to active document or PartSet
+ DocumentPtr aDoc = aResult->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()))
+ return false;
+
+ // Check that the shape of necessary type
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (!aShapePtr)
return false;
connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
SLOT(onOperationStopped(ModuleBase_Operation*)));
- XGUI_ContextMenuMgr* aContextMenuMgr = xWorkshop()->contextMenuMgr();
+ XGUI_Workshop* aXWshop = xWorkshop();
+ XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
SLOT(onContextMenuCommand(const QString&, bool)));
SLOT(onKeyRelease(QKeyEvent*)));
connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
SLOT(onMouseDoubleClick(QMouseEvent*)));
+
+ myDocumentShapeFilter = new XGUI_ShapeDocumentFilter(aXWshop->displayer());
}
PartSet_Module::~PartSet_Module()
*/
void PartSet_Module::onFeatureTriggered()
{
- //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
- // myWorkshop->viewer()->activeView());
-
- //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
- // myWorkshop->viewer()->activeView());
QAction* aCmd = dynamic_cast<QAction*>(sender());
//Do nothing on uncheck
if (aCmd->isCheckable() && !aCmd->isChecked())
launchOperation(aCmd->data().toString());
}
-//void PartSet_Module::launchOperation(const QString& theCmdId)
-//{
-// ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
-// //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-// //if (aPreviewOp) {
-// XGUI_Selection* aSelection = myWorkshop->selector()->selection();
-// // Initialise operation with preliminary selection
-// std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
-// std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-// anOperation->initSelection(aSelected, aHighlighted);
-// //}
-// sendOperation(anOperation);
-//}
void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
{
XGUI_Displayer* aDisplayer = aXWshp->displayer();
aDisplayer->openLocalContext();
aDisplayer->deactivateObjectsOutOfContext();
+ } else {
+ Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+ aAIS->AddFilter(myDocumentShapeFilter);
}
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
- //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
- // this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
} else {
// Activate results of current feature for selection
FeaturePtr aFeature = theOperation->feature();
for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
aDisplayer->activate(*aIt);
}
+
+ Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+ aAIS->RemoveFilter(myDocumentShapeFilter);
}
}
#include <ModuleBase_IModule.h>
#include <ModuleBase_Definitions.h>
#include <XGUI_Command.h>
+#include <XGUI_ViewerFilters.h>
#include <ModelAPI_Feature.h>
#include <QMap>
PartSet_Listener* myListener;
std::map<std::string, std::string> myFeaturesInFiles;
+
+ /// A filter which provides selection within a current document or whole PartSet
+ Handle(XGUI_ShapeDocumentFilter) myDocumentShapeFilter;
};
#endif
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
/// Destructor
virtual ~XGUI_Displayer();
- /// Set AIS_InteractiveContext object in case if it was changed
- /// or can not be initialized in constructor
- void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
-
/// Returns the feature visibility state.
/// \param theFeature a feature instance
bool isVisible(ObjectPtr theObject) const;
--- /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
+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