- for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
- {
- Handle(HYDROData_Object) anObj = theObjs.Value( i );
- if ( anObj.IsNull() || anObj->IsRemoved() )
- continue;
-
- HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj );
-
- if ( !anObjShape || anObjShape->getIsToUpdate() || theIsForced )
- {
- if ( !anObjShape )
- anObjShape = createShape( (size_t)aViewer, aCtx, anObj );
+ // Get the document
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( module()->getStudyId() );
+ if ( !aDoc )
+ return;
+
+ // Assign Z layer indexes to the objects
+ aDoc->Show( theObjs );
+
+ // Sort objects by display order ( needed for Z layers assignment only )
+ HYDROData_SequenceOfObjects anUnorderedToDisplay = theObjs;
+ HYDROData_SequenceOfObjects anOrderedToDisplay;
+ HYDROData_SequenceOfObjects anAllOrderedObjects = aDoc->GetObjectsLayerOrder();
+
+ HYDROData_SequenceOfObjects::Iterator anAllOrderedIter( anAllOrderedObjects );
+ for ( ; anAllOrderedIter.More(); anAllOrderedIter.Next() ) {
+ QString anOrderedEntry =
+ HYDROGUI_DataObject::dataObjectEntry( anAllOrderedIter.Value() );
+
+ HYDROData_SequenceOfObjects::Iterator aToDisplayIter( anUnorderedToDisplay );
+ for ( ; aToDisplayIter.More(); aToDisplayIter.Next() ) {
+ Handle(HYDROData_Entity) anObjToDisplay = aToDisplayIter.Value();
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObjToDisplay );
+ if ( anEntry == anOrderedEntry ) {
+ anOrderedToDisplay.Prepend( anObjToDisplay );
+ anUnorderedToDisplay.Remove( aToDisplayIter );
+ break;
+ }
+ }
+ }
+
+ // Get 3d viewer
+ Handle(V3d_Viewer) aViewer3d = aViewer->getViewer3d();
+
+ // Display objects:
+ HYDROGUI_ZLayersIterator aZLayersIt( aViewer->getViewer3d() );
+ if ( !aZLayersIt.More() ) {
+ aZLayersIt.Next();
+ }