-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
\r
#ifndef ModuleBase_IModule_H\r
#define ModuleBase_IModule_H\r
/// Called on call of command corresponded to a feature\r
void onFeatureTriggered();\r
\r
+ /// Slolt called on object display\r
+ /// \param theObject a data object\r
+ /// \param theAIS a presentation object\r
+ virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) {}\r
+\r
+ /// Slot called on before object erase\r
+ /// \param theObject a data object\r
+ /// \param theAIS a presentation object\r
+ virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {}\r
+\r
protected slots:\r
/// Called on selection changed event\r
virtual void onSelectionChanged() {}\r
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <BRep_Tool.hxx>
+#include <AIS_Dimension.hxx>
#include <QObject>
#include <QMouseEvent>
PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
: ModuleBase_IModule(theWshop),
- myRestartingMode(RM_None)
+ myRestartingMode(RM_None), myVisualLayerId(0)
{
//myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
mySketchMgr = new PartSet_SketcherMgr(this);
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
{
if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
+ Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
+ aViewer->AddZLayer(myVisualLayerId);
mySketchMgr->startSketch(theOperation);
}
else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
{
if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->stopSketch(theOperation);
+ Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
+ aViewer->RemoveZLayer(myVisualLayerId);
+ myVisualLayerId = 0;
}
else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
mySketchMgr->stopNestedSketch(theOperation);
return true;
}
+
+
+void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
+{
+ Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull()) {
+ Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
+ if (!aDim.IsNull()) {
+ Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
+ aCtx->SetZLayer(aDim, myVisualLayerId);
+ }
+ }
+}
+
/// \param isChecked a state of toggle if the action is checkable
void onAction(bool isChecked);
+ /// Slolt called on object display
+ /// \param theObject a data object
+ /// \param theAIS a presentation object
+ virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
+
protected slots:
/// Called when previous operation is finished
virtual void onSelectionChanged();
PartSet_SketcherMgr* mySketchMgr;
QMap<QString, QAction*> myActions; // the popup menu actions
+
+ int myVisualLayerId;
};
#endif
closeLocalContexts(false);
}
aContext->Display(anAISIO, false);
-
aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
+ emit objectDisplayed(theObject, theAIS);
bool isCustomized = customizeObject(theObject);
if (isCustomized)
if (anObject) {
Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
+ emit beforeObjectErase(theObject, anObject);
aContext->Remove(anAIS, isUpdateViewer);
}
}
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (!aContext.IsNull()) {
- foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
- // erase an object
- Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
- if (!anIO.IsNull())
- aContext->Remove(anIO, false);
- }
- if (isUpdateViewer)
- updateViewer();
+ foreach (ObjectPtr aObj, myResult2AISObjectMap.keys()) {
+ AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
+ // erase an object
+ Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anIO.IsNull()) {
+ emit beforeObjectErase(aObj, aAISObj);
+ aContext->Remove(anIO, false);
+ }
+ }
+ if (isUpdateViewer)
+ updateViewer();
}
myResult2AISObjectMap.clear();
}
#include <QString>
#include <QMap>
+#include <QObject>
class ModelAPI_Feature;
class XGUI_Workshop;
* \ingroup GUI
* \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
*/
-class XGUI_EXPORT XGUI_Displayer
+class XGUI_EXPORT XGUI_Displayer: public QObject
{
+ Q_OBJECT
public:
/// \enum DisplayMode display mode
enum DisplayMode {
/// \param theObject object to check
bool canBeShaded(ObjectPtr theObject) const;
+
+signals:
+ /// Signal on object display
+ /// \param theObject a data object
+ /// \param theAIS a presentation object
+ void objectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
+
+ /// Signal on before object erase
+ /// \param theObject a data object
+ /// \param theAIS a presentation object
+ void beforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS);
+
protected:
/// Returns currently installed AIS_InteractiveContext
Handle(AIS_InteractiveContext) AISContext() const;
myModule = loadModule(moduleName);
if (!myModule)
return false;
+
+ connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
+ myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
+ connect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)),
+ myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr)));
+
myModule->createFeatures();
myActionsMgr->update();
return true;