Fix for immersible zone.
const bool theIsEdit )
: HYDROGUI_Operation( theModule ),
myIsEdit( theIsEdit ),
- myViewManager( 0 ),
myPreviewPrs( 0 )
{
setName( theIsEdit ? tr( "EDIT_IMMERSIBLE_ZONE" ) : tr( "CREATE_IMMERSIBLE_ZONE" ) );
}
LightApp_Application* anApp = module()->getApp();
- if ( !myViewManager )
- myViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
- anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+ if ( !getPreviewManager() )
+ setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>(
+ 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();
#include <HYDROData_ImmersibleZone.h>
-class OCCViewer_ViewManager;
-
class HYDROGUI_Shape;
class HYDROGUI_ImmersibleZoneOp : public HYDROGUI_Operation
virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+ virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; };
+
protected slots:
void onCreatePreview( const QString& thePolylineName );
bool myIsEdit;
Handle(HYDROData_ImmersibleZone) myEditedObject;
- OCCViewer_ViewManager* myViewManager;
-
HYDROGUI_Shape* myPreviewPrs;
};
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_OCCDisplayer.h"
+#include "HYDROGUI_Shape.h"
#include <HYDROData_Document.h>
#include <HYDROData_Iterator.h>
/**
* 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
myPreviewZLayer = theLayer;
}
+/**
+ * Returns a shape preview of the operation
+ */
+HYDROGUI_Shape* HYDROGUI_Operation::getPreviewShape() const
+{
+ return 0;
+}
+
/**
* Return the operation preview manager
*/
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 )
class HYDROGUI_Module;
class HYDROGUI_InputPanel;
+class HYDROGUI_Shape;
class SUIT_SelectionMgr;
class OCCViewer_ViewManager;
HYDROGUI_Module* module() const;
int getPreviewZLayer() const;
- virtual void updatePreviewZLayer( int theLayer ) {};
+ virtual void updatePreviewZLayer( int theLayer );
signals:
void helpContextModule( const QString&,
QString getHelpContext() const;
virtual void setPreviewZLayer( int theLayer );
+ virtual HYDROGUI_Shape* getPreviewShape() const;
OCCViewer_ViewManager* getPreviewManager();
void setPreviewManager( OCCViewer_ViewManager* theManager );
*/
void HYDROGUI_PolylineOp::updatePreviewZLayer( int theLayer )
{
- setPreviewZLayer( theLayer );
+ HYDROGUI_Operation::updatePreviewZLayer( theLayer );
int aZLayer = getPreviewZLayer();
if ( aZLayer >= 0 )
#include <QFile>
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 ),
if ( myContext.IsNull() || myShape.IsNull() || !isVisible() )
return;
- myContext->Display( myShape, theIsUpdateViewer );
+ displayShape( theIsUpdateViewer );
}
void HYDROGUI_Shape::erase( 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() &&
( !myIsVisible && !myContext->IsDisplayed( myShape ) ) )
return;
- if ( myIsVisible )
- myContext->Display( myShape, theIsUpdateViewer );
+ if ( myIsVisible ) {
+ displayShape( theIsUpdateViewer );
+ }
else
myContext->Erase( myShape, theIsUpdateViewer );
}
return;
colorShapeBorder( getActiveColor() );
- myContext->Display( myShape, isUpdateViewer );
+ displayShape( isUpdateViewer );
}
bool HYDROGUI_Shape::isHighlighted() 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
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
{
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:
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:
Handle(HYDROData_Entity) myObject;
Handle(AIS_Shape) myShape;
+ int myZLayer;
+
bool myIsToUpdate;
bool myIsVisible;