From: nds Date: Fri, 31 Jan 2014 08:11:06 +0000 (+0000) Subject: refs #327 - Polyline is not shown during creation X-Git-Tag: BR_hydro_v_1_0~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e51216afb474af543769020e872004dadf295d89;p=modules%2Fhydro.git refs #327 - Polyline is not shown during creation Fix for polyline presentation only. --- diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index c9aa1704..ff22583a 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -42,6 +42,7 @@ #include "HYDROGUI_PolylineOp.h" #include "HYDROGUI_SetColorOp.h" #include "HYDROGUI_ImportGeomObjectOp.h" +#include "HYDROGUI_ShowHideOp.h" #include #include @@ -1519,3 +1520,30 @@ int HYDROGUI_Module::getObjectDisplayOrder( return anObjectEntries.indexOf( anEntry ); } + +/** + * Returns stack of active operations; + */ +QStack& HYDROGUI_Module::getActiveOperations() +{ + return myActiveOperationMap; +} + +/** + * Returns the module active operation. If the active operation is show/hide, + * the method returns the previous operation if it is. + */ +HYDROGUI_Operation* HYDROGUI_Module::activeOperation() +{ + HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0; + + if ( dynamic_cast( anOp ) ) + { + QVectorIterator aVIt( myActiveOperationMap ); + aVIt.toBack(); + aVIt.previous(); // skip the top show/hide operation + anOp = aVIt.hasPrevious() ? aVIt.previous() : 0; + } + + return anOp; +} diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 3ffc7113..97ae84b0 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -28,6 +28,7 @@ #include #include +#include class QGraphicsSceneMouseEvent; @@ -45,6 +46,7 @@ class HYDROGUI_VTKPrsDisplayer; class HYDROGUI_AbstractDisplayer; class HYDROGUI_Shape; class HYDROGUI_VTKPrs; +class HYDROGUI_Operation; /**\class HYDROGUI_Module *\brief The class representing the HYDROGUI module @@ -173,7 +175,9 @@ public: int getObjectDisplayOrder( const int theViewId, const Handle(HYDROData_Entity)& theObject ) const; - QPoint getPopupPosition() const; + + QStack& getActiveOperations(); + HYDROGUI_Operation* activeOperation(); protected: CAM_DataModel* createDataModel(); @@ -243,6 +247,7 @@ private: ViewId2Entry2ObjectStateMap myObjectStateMap; QMap myObjectDisplayOrderMap; + QStack myActiveOperationMap; ViewId2ListOfShapes myShapesMap; ViewId2ListOfVTKPrs myVTKPrsMap; diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 46449869..14715ec8 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -26,6 +26,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_Shape.h" +#include "HYDROGUI_Operation.h" #include #include @@ -33,6 +34,9 @@ #include +#include +#include + #include #include #include @@ -67,6 +71,39 @@ void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theO } } +int HYDROGUI_OCCDisplayer::AddTopZLayer( OCCViewer_ViewManager* theMgr ) +{ + int aLayer = -1; + OCCViewer_Viewer* aViewer = theMgr->getOCCViewer(); + if ( !aViewer ) + return aLayer; + + Standard_Integer aNewId = -1; + if ( aViewer->getViewer3d()->AddZLayer( aNewId ) ) + aZLayer = aNewId; + + return aZLayer; +} + +void HYDROGUI_OCCDisplayer::RemoveZLayer( OCCViewer_ViewManager* theMgr, + const int theLayer ) +{ + if ( theLayer < 0 ) + return; + + OCCViewer_Viewer* aViewer = theMgr->getOCCViewer(); + if ( !aViewer ) + return; + + // Get existing Z layers + TColStd_SequenceOfInteger anExistingZLayers; + aViewer->getViewer3d()->GetAllZLayers( anExistingZLayers ); + int aNbLayers = anExistingZLayers.Length(); + + if ( theLayer < aNbLayers ) + aViewer->getViewer3d()->RemoveZLayer( theLayer ); +} + void HYDROGUI_OCCDisplayer::EraseAll( const int theViewerId ) { OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); @@ -148,7 +185,8 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, int aNbLayers = anExistingZLayers.Length(); // Display - for ( int i = 1, n = anObjects.Length(); i <= n; i++ ) + int i = 1; + for ( int n = anObjects.Length(); i <= n; i++ ) { Handle(HYDROData_Entity) anObj = anObjects.Value( i ); if ( anObj.IsNull() || anObj->IsRemoved() ) @@ -185,6 +223,22 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, } } } + // update Z layer of the active operation + HYDROGUI_Module* aModule = module(); + SUIT_Operation* anOp = aModule->activeOperation(); + HYDROGUI_Operation* aHOp = anOp ? dynamic_cast( anOp ) : 0; + if ( aHOp && aHOp->getPreviewZLayer() >= 0 ) { + Standard_Integer aLayerId = -1; + if ( i <= aNbLayers ) + aLayerId = anExistingZLayers.Value( i ); + else { + Standard_Integer aNewId = -1; + if ( aViewer->getViewer3d()->AddZLayer( aNewId ) ) { + aLayerId = aNewId; + } + } + aHOp->updatePreviewZLayer( aLayerId ); + } if ( theDoFitAll ) {