+ onCreatePreview();
+ }
+ }
+}
+
+void HYDROGUI_LandCoverMapOp::onPolylineFaceChanged()
+{
+ HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ LightApp_DataOwner* aPolylineFaceDataOwner = NULL;
+ Handle(HYDROData_Entity) aPolylineFace = aPanel->getPolylineFace();
+ if ( !aPolylineFace.IsNull() )
+ {
+ // Select chosen polyline/face in the Object Browser, if it is not selected yet
+ // (i.e. object was chosen not in the Object Browser or 3d Viewer, but in combo-box)
+ aPolylineFaceDataOwner = new LightApp_DataOwner( HYDROGUI_DataObject::dataObjectEntry( aPolylineFace ) );
+ LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr();
+ if ( aSelectionMgr )
+ {
+ bool bIsAlreadySelected = false;
+ SUIT_DataOwnerPtrList aSelectedOwners;
+ aSelectionMgr->selected( aSelectedOwners );
+ foreach( SUIT_DataOwner* aSUITOwner, aSelectedOwners )
+ {
+ if ( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+ {
+ if ( anOwner->entry() == aPolylineFaceDataOwner->entry() )
+ {
+ bIsAlreadySelected = true;
+ break;
+ }
+ }
+ }
+ if ( !bIsAlreadySelected )
+ {
+ SUIT_DataOwnerPtrList aList( true );
+ aList.append( SUIT_DataOwnerPtr( aPolylineFaceDataOwner ) );
+ aSelectionMgr->setSelected( aList );
+ }
+ }
+
+ // Show Preview of selected polyline/face
+ Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aPolylineFace );
+ Handle(HYDROData_Object) aFace = Handle(HYDROData_Object)::DownCast( aPolylineFace );
+ if ( !aPolyline.IsNull() || !aFace.IsNull() )
+ {
+ TopoDS_Shape aTopoDSShape;
+ if ( !aPolyline.IsNull() )
+ aTopoDSShape = aPolyline->GetShape();
+ else
+ aTopoDSShape = aFace->GetTopShape();
+
+ OCCViewer_ViewManager* aViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
+ module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) );
+ if ( aViewManager )
+ {
+ if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
+ {
+ if ( myPolylineFacePreviewPrs )
+ {
+ delete myPolylineFacePreviewPrs;
+ myPolylineFacePreviewPrs = 0;
+ }
+
+ int aViewerId = (size_t)aViewer;
+ if ( !module()->isObjectVisible( aViewerId, aPolylineFace ) )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ myPolylineFacePreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
+ aCtx->ClearSelected();
+
+ myPolylineFacePreviewPrs->setBorderColor( Qt::white, false, false );
+ myPolylineFacePreviewPrs->setShape( aTopoDSShape, true, true, !aPolyline.IsNull() ? AIS_WireFrame : AIS_Shaded );
+
+ module()->update( UF_OCCViewer | UF_FitAll );
+ }
+ }
+ }
+ }