Fix for polyline presentation only.
Standard_Integer aNewId = -1;
if ( aViewer->getViewer3d()->AddZLayer( aNewId ) )
- aZLayer = aNewId;
+ aLayer = aNewId;
- return aZLayer;
+ return aLayer;
}
void HYDROGUI_OCCDisplayer::RemoveZLayer( OCCViewer_ViewManager* theMgr,
class HYDROGUI_Shape;
class Handle(AIS_InteractiveContext);
+class OCCViewer_ViewManager;
/**
* \class HYDROGUI_OCCDisplayer
*/
virtual QString GetType() const;
+ /**
+ * \brief Add the top z layer and returns its index.
+ * \param theMgr OCC view manager
+ */
+ int AddTopZLayer( OCCViewer_ViewManager* theMgr );
+
+ /**
+ * \brief Removes the z layer.
+ * \param theMgr OCC view manager
+ * \param theLayer a layer index
+ */
+ void RemoveZLayer( OCCViewer_ViewManager* theMgr,
+ const int theLayer );
+
protected:
/**
* \brief Erase all viewer objects.
#include "HYDROGUI_InputPanel.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_OCCDisplayer.h"
#include <HYDROData_Document.h>
#include <HYDROData_Iterator.h>
: LightApp_Operation(),
myModule( theModule ),
myPanel( 0 ),
- myIsPrintErrorMessage( true )
+ myIsPrintErrorMessage( true ),
+ myPreviewManager( 0 ),
+ myPreviewZLayer( -1 )
{
connect( this, SIGNAL( helpContextModule( const QString&, const QString&,
const QString& ) ),
return myModule;
}
+/**
+ * Returns Z layer of the operation preview.
+ \ returns a layer position
+ */
+int HYDROGUI_Operation::getPreviewZLayer() const
+{
+ return myPreviewZLayer;
+}
+
+/**
+ * Set Z layer for the operation preview.
+ \param theLayer a layer position
+ */
+void HYDROGUI_Operation::setPreviewZLayer( int theLayer )
+{
+ if ( theLayer != myPreviewZLayer )
+ myPreviewZLayer = theLayer;
+}
+
+/**
+ * Return the operation preview manager
+ */
+OCCViewer_ViewManager* HYDROGUI_Operation::getPreviewManager()
+{
+ return myPreviewManager;
+}
+
+/**
+ * Set the preview manager
+ */
+void HYDROGUI_Operation::setPreviewManager( OCCViewer_ViewManager* theManager )
+{
+ if ( !theManager && myPreviewManager )
+ module()->getOCCDisplayer()->RemoveZLayer( myPreviewManager, getPreviewZLayer() );
+
+ myPreviewManager = theManager;
+
+ if ( myPreviewManager )
+ setPreviewZLayer( module()->getOCCDisplayer()->AddTopZLayer( myPreviewManager ) );
+}
+
void HYDROGUI_Operation::startOperation()
{
LightApp_Operation::startOperation();
+ myModule->getActiveOperations().push( this );
if( inputPanel() )
{
closeInputPanel();
}
+void HYDROGUI_Operation::stopOperation()
+{
+ LightApp_Operation::stopOperation();
+
+ // pop the operation from the cached map of active operations
+ QStack<HYDROGUI_Operation*>& anOperations = myModule->getActiveOperations();
+ if ( anOperations.top() == this )
+ {
+ anOperations.pop();
+ }
+ else {
+ // find in the stack the current operation and remove it from the stack
+ QVectorIterator<HYDROGUI_Operation*> aVIt( anOperations );
+ aVIt.toBack();
+ aVIt.previous(); // skip the top show/hide operation
+ while ( aVIt.hasPrevious() )
+ {
+ HYDROGUI_Operation* anOp = aVIt.previous();
+ if ( anOp == this )
+ anOperations.remove( anOperations.lastIndexOf( anOp ) );
+ }
+ }
+
+ // removes the Z layer, created for the operation preview
+ if ( myPreviewManager && getPreviewZLayer() >= 0 )
+ module()->getOCCDisplayer()->RemoveZLayer( myPreviewManager, getPreviewZLayer() );
+}
+
void HYDROGUI_Operation::setDialogActive( const bool active )
{
LightApp_Operation::setDialogActive( active );
class HYDROGUI_Module;
class HYDROGUI_InputPanel;
+
class SUIT_SelectionMgr;
+class OCCViewer_ViewManager;
+
class Handle_HYDROData_Document;
class Handle_HYDROData_Object;
SUIT_SelectionMgr* selectionMgr() const;
HYDROGUI_Module* module() const;
+ int getPreviewZLayer() const;
+ virtual void updatePreviewZLayer( int theLayer ) {};
+
signals:
void helpContextModule( const QString&,
const QString&,
virtual void startOperation();
virtual void abortOperation();
virtual void commitOperation();
+ virtual void stopOperation();
virtual void setDialogActive( const bool );
virtual HYDROGUI_InputPanel* createInputPanel() const;
QString getHelpFile() const;
QString getHelpContext() const;
+ virtual void setPreviewZLayer( int theLayer );
+ OCCViewer_ViewManager* getPreviewManager();
+ void setPreviewManager( OCCViewer_ViewManager* theManager );
+
private:
HYDROGUI_Module* myModule;
HYDROGUI_InputPanel* myPanel;
+ OCCViewer_ViewManager* myPreviewManager;
QString myName;
bool myIsPrintErrorMessage;
+ int myPreviewZLayer;
};
#endif
HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
: HYDROGUI_Operation( theModule ),
myIsEdit( theIsEdit ),
- myCurve( NULL ),
- myViewManager( NULL )
+ myCurve( NULL )
{
setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
}
return aPanel->deleteEnabled();
}
+/**
+ * Set Z layer for the operation preview.
+ \param theLayer a layer position
+ */
+void HYDROGUI_PolylineOp::updatePreviewZLayer( int theLayer )
+{
+ setPreviewZLayer( theLayer );
+
+ int aZLayer = getPreviewZLayer();
+ if ( aZLayer >= 0 )
+ {
+ if( getPreviewManager() )
+ {
+ if ( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if( !aCtx.IsNull() )
+ {
+ Handle(AIS_InteractiveObject) anObject = myCurve->getAISObject( true );
+ aCtx->SetZLayer( anObject, aZLayer );
+ }
+ }
+ }
+ }
+}
+
void HYDROGUI_PolylineOp::startOperation()
{
if( myIsEdit )
aPanel->reset();
LightApp_Application* anApp = module()->getApp();
- myViewManager =
+ OCCViewer_ViewManager* aViewManager =
dynamic_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
- aPanel->setOCCViewer( myViewManager ? myViewManager->getOCCViewer() : 0 );
+ aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 );
+ setPreviewManager( aViewManager );
QString aPolylineName;
if( !myEditedObject.IsNull() )
void HYDROGUI_PolylineOp::displayPreview()
{
- if( myViewManager )
+ if( getPreviewManager() )
{
- if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+ if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
{
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if( !aCtx.IsNull() )
{
- CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
+ CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx, getPreviewZLayer() );
myCurve->setDisplayer( aDisplayer );
aDisplayer->display( myCurve->getAISObject( true ), true );
}
void HYDROGUI_PolylineOp::erasePreview()
{
CurveCreator_Displayer* aDisplayer = myCurve ? myCurve->getDisplayer() : 0;
- if( myViewManager && aDisplayer )
+ if( getPreviewManager() && aDisplayer )
{
- if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+ if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
{
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if( !aCtx.IsNull() )
}
}
- myViewManager = NULL;
+ setPreviewManager( NULL );
if ( myCurve )
{
delete myCurve;
#include <HYDROData_PolylineXY.h>
-class OCCViewer_ViewManager;
class CurveCreator_Curve;
class HYDROGUI_PolylineOp : public HYDROGUI_Operation
void deleteSelected();
bool deleteEnabled();
+ virtual void updatePreviewZLayer( int theLayer );
+
protected:
virtual void startOperation();
virtual void abortOperation();
void erasePreview();
private:
- OCCViewer_ViewManager* myViewManager;
-
bool myIsEdit;
Handle(HYDROData_PolylineXY) myEditedObject;
CurveCreator_Curve* myCurve;