From: vsv Date: Wed, 25 Mar 2015 16:13:58 +0000 (+0300) Subject: Put dimensions presentations on a layer 1 X-Git-Tag: V_1.1.0~84^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=751f5f2da2af0ad48d4716d9aaf589464296c9dc;p=modules%2Fshaper.git Put dimensions presentations on a layer 1 --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index ffe513947..b29b4e51d 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // Copyright (C) 2014-20xx CEA/DEN, EDF R&D #ifndef ModuleBase_IModule_H #define ModuleBase_IModule_H @@ -122,6 +122,16 @@ public slots: /// Called on call of command corresponded to a feature void onFeatureTriggered(); + /// Slolt called on object display + /// \param theObject a data object + /// \param theAIS a presentation object + virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) {} + + /// Slot called on before object erase + /// \param theObject a data object + /// \param theAIS a presentation object + virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {} + protected slots: /// Called on selection changed event virtual void onSelectionChanged() {} diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 0b2e410b1..ad9296bc8 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -91,7 +92,7 @@ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) : ModuleBase_IModule(theWshop), - myRestartingMode(RM_None) + myRestartingMode(RM_None), myVisualLayerId(0) { //myWorkshop = dynamic_cast(theWshop); mySketchMgr = new PartSet_SketcherMgr(this); @@ -211,6 +212,8 @@ void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation) 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)) { @@ -226,6 +229,9 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* 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); @@ -651,3 +657,17 @@ bool PartSet_Module::deleteObjects() return true; } + + +void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) +{ + Handle(AIS_InteractiveObject) anAIS = theAIS->impl(); + 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); + } + } +} + diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 11214c096..6bacf2d77 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -113,6 +113,11 @@ public slots: /// \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(); @@ -173,6 +178,8 @@ protected slots: PartSet_SketcherMgr* mySketchMgr; QMap myActions; // the popup menu actions + + int myVisualLayerId; }; #endif diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 7d4ae0012..fef7ed06d 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -158,8 +158,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, closeLocalContexts(false); } aContext->Display(anAISIO, false); - aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false); + emit objectDisplayed(theObject, theAIS); bool isCustomized = customizeObject(theObject); if (isCustomized) @@ -189,6 +189,7 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer) if (anObject) { Handle(AIS_InteractiveObject) anAIS = anObject->impl(); if (!anAIS.IsNull()) { + emit beforeObjectErase(theObject, anObject); aContext->Remove(anAIS, isUpdateViewer); } } @@ -444,14 +445,17 @@ void XGUI_Displayer::eraseAll(const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); if (!aContext.IsNull()) { - foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) { - // erase an object - Handle(AIS_InteractiveObject) anIO = aAISObj->impl(); - 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(); + if (!anIO.IsNull()) { + emit beforeObjectErase(aObj, aAISObj); + aContext->Remove(anIO, false); + } + } + if (isUpdateViewer) + updateViewer(); } myResult2AISObjectMap.clear(); } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index da11c4d8e..dc3dd6cba 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -26,6 +26,7 @@ #include #include +#include class ModelAPI_Feature; class XGUI_Workshop; @@ -34,8 +35,9 @@ 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 { @@ -185,6 +187,18 @@ class XGUI_EXPORT XGUI_Displayer /// \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; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 6100b9ecf..2997907c0 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1053,6 +1053,12 @@ bool XGUI_Workshop::activateModule() 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;