#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_SetColorOp.h"
#include "HYDROGUI_ImportGeomObjectOp.h"
+#include "HYDROGUI_ShowHideOp.h"
#include <HYDROData_Image.h>
#include <HYDROData_Profile.h>
return anObjectEntries.indexOf( anEntry );
}
+
+/**
+ * Returns stack of active operations;
+ */
+QStack<HYDROGUI_Operation*>& 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<HYDROGUI_ShowHideOp*>( anOp ) )
+ {
+ QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
+ aVIt.toBack();
+ aVIt.previous(); // skip the top show/hide operation
+ anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
+ }
+
+ return anOp;
+}
#include <LightApp_Module.h>
#include <QEvent>
+#include <QStack>
class QGraphicsSceneMouseEvent;
class HYDROGUI_AbstractDisplayer;
class HYDROGUI_Shape;
class HYDROGUI_VTKPrs;
+class HYDROGUI_Operation;
/**\class HYDROGUI_Module
*\brief The class representing the HYDROGUI module
int getObjectDisplayOrder( const int theViewId,
const Handle(HYDROData_Entity)& theObject ) const;
- QPoint getPopupPosition() const;
+
+ QStack<HYDROGUI_Operation*>& getActiveOperations();
+ HYDROGUI_Operation* activeOperation();
protected:
CAM_DataModel* createDataModel();
ViewId2Entry2ObjectStateMap myObjectStateMap;
QMap<int, QStringList> myObjectDisplayOrderMap;
+ QStack<HYDROGUI_Operation*> myActiveOperationMap;
ViewId2ListOfShapes myShapesMap;
ViewId2ListOfVTKPrs myVTKPrsMap;
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_Operation.h"
#include <AIS_InteractiveContext.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <TColStd_SequenceOfInteger.hxx>
+#include <LightApp_Application.h>
+#include <SUIT_Study.h>
+
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
}
}
+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 );
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() )
}
}
}
+ // update Z layer of the active operation
+ HYDROGUI_Module* aModule = module();
+ SUIT_Operation* anOp = aModule->activeOperation();
+ HYDROGUI_Operation* aHOp = anOp ? dynamic_cast<HYDROGUI_Operation*>( 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 )
{