From: nds Date: Fri, 31 Jan 2014 09:53:27 +0000 (+0000) Subject: refs #327 - Polyline is not shown during creation X-Git-Tag: BR_hydro_v_1_0~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff20e1dd36e9bd6e9c6a394d18b740cd5ea63393;p=modules%2Fhydro.git refs #327 - Polyline is not shown during creation Fix for immersible zone. --- diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index 41f539a2..13fd5202 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -51,7 +51,6 @@ HYDROGUI_ImmersibleZoneOp::HYDROGUI_ImmersibleZoneOp( HYDROGUI_Module* theModule const bool theIsEdit ) : HYDROGUI_Operation( theModule ), myIsEdit( theIsEdit ), - myViewManager( 0 ), myPreviewPrs( 0 ) { setName( theIsEdit ? tr( "EDIT_IMMERSIBLE_ZONE" ) : tr( "CREATE_IMMERSIBLE_ZONE" ) ); @@ -260,21 +259,22 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName } LightApp_Application* anApp = module()->getApp(); - if ( !myViewManager ) - myViewManager = ::qobject_cast( - anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ); + if ( !getPreviewManager() ) + setPreviewManager( ::qobject_cast( + anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); - if ( myViewManager && !myPreviewPrs ) + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( aViewManager && !myPreviewPrs ) { - if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() ) + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if ( !aCtx.IsNull() ) - myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL ); + myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); } } - if ( myViewManager && myPreviewPrs ) + if ( aViewManager && myPreviewPrs ) { QColor aFillingColor = HYDROData_ImmersibleZone::DefaultFillingColor(); QColor aBorderColor = HYDROData_ImmersibleZone::DefaultBorderColor(); diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h index ba4410bd..20cddaca 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h @@ -27,8 +27,6 @@ #include -class OCCViewer_ViewManager; - class HYDROGUI_Shape; class HYDROGUI_ImmersibleZoneOp : public HYDROGUI_Operation @@ -48,6 +46,8 @@ protected: virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; }; + protected slots: void onCreatePreview( const QString& thePolylineName ); @@ -58,8 +58,6 @@ private: bool myIsEdit; Handle(HYDROData_ImmersibleZone) myEditedObject; - OCCViewer_ViewManager* myViewManager; - HYDROGUI_Shape* myPreviewPrs; }; diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 8b397f15..5fe07730 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -26,6 +26,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_OCCDisplayer.h" +#include "HYDROGUI_Shape.h" #include #include @@ -91,13 +92,26 @@ HYDROGUI_Module* HYDROGUI_Operation::module() const /** * Returns Z layer of the operation preview. - \ returns a layer position + \ returns a layer position */ int HYDROGUI_Operation::getPreviewZLayer() const { return myPreviewZLayer; } +/** + * Update Z layer for the operation preview. + \param theLayer a layer position + */ +void HYDROGUI_Operation::updatePreviewZLayer( int theLayer ) +{ + setPreviewZLayer( theLayer ); + + HYDROGUI_Shape* aPreview = getPreviewShape(); + if ( aPreview ) + aPreview->setZLayer( getPreviewZLayer() ); +} + /** * Set Z layer for the operation preview. \param theLayer a layer position @@ -108,6 +122,14 @@ void HYDROGUI_Operation::setPreviewZLayer( int theLayer ) myPreviewZLayer = theLayer; } +/** + * Returns a shape preview of the operation + */ +HYDROGUI_Shape* HYDROGUI_Operation::getPreviewShape() const +{ + return 0; +} + /** * Return the operation preview manager */ @@ -176,10 +198,8 @@ void HYDROGUI_Operation::stopOperation() anOperations.remove( anOperations.lastIndexOf( anOp ) ); } } - - // removes the Z layer, created for the operation preview - if ( myPreviewManager && getPreviewZLayer() >= 0 ) - module()->getOCCDisplayer()->RemoveZLayer( myPreviewManager, getPreviewZLayer() ); + // release the preview manager with removing the added preview Z layer + setPreviewManager( 0 ); } void HYDROGUI_Operation::setDialogActive( const bool active ) diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 5f037718..be5f8e7f 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -27,6 +27,7 @@ class HYDROGUI_Module; class HYDROGUI_InputPanel; +class HYDROGUI_Shape; class SUIT_SelectionMgr; class OCCViewer_ViewManager; @@ -53,7 +54,7 @@ public: HYDROGUI_Module* module() const; int getPreviewZLayer() const; - virtual void updatePreviewZLayer( int theLayer ) {}; + virtual void updatePreviewZLayer( int theLayer ); signals: void helpContextModule( const QString&, @@ -97,6 +98,7 @@ protected: QString getHelpContext() const; virtual void setPreviewZLayer( int theLayer ); + virtual HYDROGUI_Shape* getPreviewShape() const; OCCViewer_ViewManager* getPreviewManager(); void setPreviewManager( OCCViewer_ViewManager* theManager ); diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 2c299e2f..47b25a12 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -86,7 +86,7 @@ bool HYDROGUI_PolylineOp::deleteEnabled() */ void HYDROGUI_PolylineOp::updatePreviewZLayer( int theLayer ) { - setPreviewZLayer( theLayer ); + HYDROGUI_Operation::updatePreviewZLayer( theLayer ); int aZLayer = getPreviewZLayer(); if ( aZLayer >= 0 ) diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 3fed9548..9cfb65e1 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -73,9 +73,11 @@ #include HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext, - const Handle(HYDROData_Entity)& theObject ) + const Handle(HYDROData_Entity)& theObject, + const int theZLayer ) : myContext( theContext ), myObject( theObject ), + myZLayer( theZLayer ), myIsHighlight( false ), myFillingColor( Qt::transparent ), myBorderColor( Qt::black ), @@ -101,7 +103,7 @@ void HYDROGUI_Shape::display( const bool theIsUpdateViewer ) if ( myContext.IsNull() || myShape.IsNull() || !isVisible() ) return; - myContext->Display( myShape, theIsUpdateViewer ); + displayShape( theIsUpdateViewer ); } void HYDROGUI_Shape::erase( const bool theIsUpdateViewer ) @@ -389,9 +391,10 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer, if ( myShape.IsNull() || !isVisible() ) return; - myContext->Display( myShape, theIsUpdateViewer ); - - if ( theIsDisplayOnTop ) { + displayShape( theIsUpdateViewer ); + // the following code is not necessary if the Z layer is set for the shape + if ( myZLayer && theIsDisplayOnTop ) + { // Display the shape on the top Z layer Standard_Integer aNewLayerId = -1; if ( myContext->CurrentViewer() && @@ -417,8 +420,9 @@ void HYDROGUI_Shape::setVisible( const bool theState, ( !myIsVisible && !myContext->IsDisplayed( myShape ) ) ) return; - if ( myIsVisible ) - myContext->Display( myShape, theIsUpdateViewer ); + if ( myIsVisible ) { + displayShape( theIsUpdateViewer ); + } else myContext->Erase( myShape, theIsUpdateViewer ); } @@ -434,7 +438,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer ) return; colorShapeBorder( getActiveColor() ); - myContext->Display( myShape, isUpdateViewer ); + displayShape( isUpdateViewer ); } bool HYDROGUI_Shape::isHighlighted() const @@ -568,6 +572,16 @@ QString HYDROGUI_Shape::getTextureFileName() const return myTextureFileName; } +void HYDROGUI_Shape::setZLayer( const int theZLayer ) +{ + if ( myZLayer == theZLayer ) + return; + + myZLayer = theZLayer; + if ( !myShape.IsNull() && isVisible() && !myContext.IsNull() && myZLayer >= 0 ) + myContext->SetZLayer( myShape, myZLayer ); +} + void HYDROGUI_Shape::buildShape() { // Erase previously created shape @@ -681,7 +695,17 @@ void HYDROGUI_Shape::updateShape( const bool theToDisplay, if ( !theToDisplay || !isVisible() || myContext.IsNull() ) return; - myContext->Display( myShape, theIsUpdateViewer ); + displayShape( theIsUpdateViewer ); +} + +void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer ) +{ + myContext->Display( myShape, Standard_False ); + + if ( myZLayer >= 0 ) + myContext->SetZLayer( myShape, myZLayer ); + + myContext->UpdateCurrentViewer(); } QColor HYDROGUI_Shape::getActiveColor() const diff --git a/src/HYDROGUI/HYDROGUI_Shape.h b/src/HYDROGUI/HYDROGUI_Shape.h index b16161ce..333083ca 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.h +++ b/src/HYDROGUI/HYDROGUI_Shape.h @@ -39,7 +39,8 @@ class HYDROGUI_Shape { public: HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext, - const Handle(HYDROData_Entity)& theObject ); + const Handle(HYDROData_Entity)& theObject, + const int theZLayer = -1 ); ~HYDROGUI_Shape(); public: @@ -101,10 +102,14 @@ public: virtual Handle(AIS_Shape) getAISShape() const { return myShape; } + void setZLayer( const int theZLayer ); + protected: virtual void buildShape(); virtual void updateShape( const bool theToDisplay = true, const bool theIsUpdateViewer = true ); + void displayShape( const bool theIsUpdateViewer ); + virtual QColor getActiveColor() const; private: @@ -121,6 +126,8 @@ private: Handle(HYDROData_Entity) myObject; Handle(AIS_Shape) myShape; + int myZLayer; + bool myIsToUpdate; bool myIsVisible;