if ( !myViewManager || !myPreviewPrs )
return;
- myPreviewPrs->update();
+ myPreviewPrs->update( true, true );
}
void HYDROGUI_ChannelOp::erasePreview()
foreach ( const int anId, anObsoleteIds ) {
myViewManagerMap.remove( anId );
myObjectStateMap.remove( anId );
+ myObjectDisplayOrderMap.remove( anId );
myShapesMap.remove( anId );
myVTKPrsMap.remove( anId );
}
ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
anObjectState.Visibility = theState;
+
+ // Remember the display order ( needed for Z layers assignment only )
+ QStringList& anObjectEntries = myObjectDisplayOrderMap[ theViewId ];
+ anObjectEntries.removeAll( anEntry );
+ if ( theState ) {
+ anObjectEntries.append( anEntry );
+ }
}
}
aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
}
}
+}
+
+/**
+ * Get the object display order. Needed for Z layers assignment only.
+ */
+int HYDROGUI_Module::getObjectDisplayOrder(
+ const int theViewId, const Handle(HYDROData_Entity)& theObject) const
+{
+ if( theObject.IsNull() )
+ return -1;
+
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
+ QStringList anObjectEntries = myObjectDisplayOrderMap.value( theViewId );
+
+ return anObjectEntries.indexOf( anEntry );
}
\ No newline at end of file
*/
virtual bool renameObject( const QString& theEntry, const QString& theName );
+ int getObjectDisplayOrder( const int theViewId,
+ const Handle(HYDROData_Entity)& theObject ) const;
+
protected:
CAM_DataModel* createDataModel();
HYDROGUI_VTKPrsDisplayer* myVTKDisplayer;
ViewManagerMap myViewManagerMap;
- ViewId2Entry2ObjectStateMap myObjectStateMap;
+ ViewId2Entry2ObjectStateMap myObjectStateMap;
+
+ QMap<int, QStringList> myObjectDisplayOrderMap;
ViewId2ListOfShapes myShapesMap;
ViewId2ListOfVTKPrs myVTKPrsMap;
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <TColStd_SequenceOfInteger.hxx>
+
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
if( aCtx.IsNull() )
return;
- for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
- {
+ // Sort objects by display order ( needed for Z layers assignment only )
+ HYDROData_SequenceOfObjects anObjects;
+ int aMaxIndex = -1;
+ for ( int i = 1, n = theObjs.Length(); i <= n; i++ ) {
Handle(HYDROData_Entity) anObj = theObjs.Value( i );
+ if ( anObj.IsNull() || anObj->IsRemoved() ) {
+ continue;
+ }
+
+ int aDisplayOrderIndex = module()->getObjectDisplayOrder( (size_t)aViewer, anObj );
+ if ( aDisplayOrderIndex > aMaxIndex ) {
+ anObjects.Append( anObj );
+ aMaxIndex = aDisplayOrderIndex;
+ } else {
+ anObjects.Prepend( anObj );
+ }
+ }
+
+ // Get existing Z layers
+ TColStd_SequenceOfInteger anExistingZLayers;
+ aViewer->getViewer3d()->GetAllZLayers( anExistingZLayers );
+ int aNbLayers = anExistingZLayers.Length();
+
+ // Display
+ for ( int i = 1, n = anObjects.Length(); i <= n; i++ )
+ {
+ Handle(HYDROData_Entity) anObj = anObjects.Value( i );
if ( anObj.IsNull() || anObj->IsRemoved() )
continue;
{
bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj );
anObjShape->setVisible( anIsVisible, false );
+
+ // Set Z layer
+ Standard_Integer aLayerId = -1;
+ if ( i <= aNbLayers ) {
+ aLayerId = anExistingZLayers.Value( i );
+ } else {
+ Standard_Integer aNewId = -1;
+ if ( aViewer->getViewer3d()->AddZLayer( aNewId ) ) {
+ aLayerId = aNewId;
+ }
+ }
+ if ( aLayerId >= 0 ) {
+ aCtx->SetZLayer( anObjShape->getAISShape(), aLayerId );
+ }
}
}
#include <AIS_Drawer.hxx>
#include <AIS_TexturedShape.hxx>
+#include <V3d_Viewer.hxx>
+
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
myContext->Erase( myShape, theIsUpdateViewer );
}
-void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
+void HYDROGUI_Shape::update( const bool theIsUpdateViewer,
+ const bool theIsDisplayOnTop )
{
setIsToUpdate( false );
return;
myContext->Display( myShape, theIsUpdateViewer );
+
+ if ( theIsDisplayOnTop ) {
+ // Display the shape on the top Z layer
+ Standard_Integer aNewLayerId = -1;
+ if ( myContext->CurrentViewer() &&
+ myContext->CurrentViewer()->AddZLayer( aNewLayerId ) &&
+ aNewLayerId > 0 ) {
+ myContext->SetZLayer( myShape, aNewLayerId );
+ }
+ }
+
if (isDeactivateSelection)
myContext->Deactivate(myShape);
}
Handle(HYDROData_Entity) getObject() const { return myObject; }
- virtual void update( const bool theIsUpdateViewer = true );
+ virtual void update( const bool theIsUpdateViewer = true,
+ const bool theIsDisplayOnTop = false );
virtual bool getIsToUpdate() const { return myIsToUpdate; }
virtual void setIsToUpdate( bool theState ) { myIsToUpdate = theState; }
const bool theIsUpdateViewer = true );
virtual QString getTextureFileName() const;
+ virtual Handle(AIS_Shape) getAISShape() const { return myShape; }
+
protected:
virtual void buildShape();
virtual void updateShape( const bool theToDisplay = true,
}
if ( myPreviewPrs ) {
- myPreviewPrs->update();
+ myPreviewPrs->update( true, true );
}
}