+ //QStringList aGeomObjectNames = aPanel->getSelectedGeomObjects();
+ //HYDROData_SequenceOfObjects aGeomObjects =
+ // HYDROGUI_Tool::FindObjectsByNames( module(), aGeomObjectNames );
+
+ //QStringList aResSplittedZones;
+
+ //HYDROData_SplitToZonesTool::SplitDataList aSplittedZones =
+ // HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects );
+
+ //QStringList aUsedNames;
+
+ //HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplittedZones );
+ //while( anIter.hasNext() )
+ //{
+ // Region aRegion;
+ // aRegion.SplitData = anIter.next();
+
+ // aRegion.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aRegion.SplitData.ObjectNames );
+ // aRegion.BorderColor = QColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
+
+ // aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), "Region", aUsedNames );
+
+ // aUsedNames.append( aRegion.RegionName );
+
+ // aResSplittedZones.append( aRegion.RegionName );
+
+ // myRegionsList.append( aRegion );
+ //}
+ //
+
+ myEditedObject->SplitGeometryObjects();
+ aPanel->setEditedObject( myEditedObject );
+ createPreview();
+
+ QApplication::restoreOverrideCursor();
+}
+
+void HYDROGUI_CalculationOp::createPreview()
+{
+ LightApp_Application* anApp = module()->getApp();
+
+ if ( !myActiveViewManager )
+ {
+ if ( myRegionsList.isEmpty() )
+ return;
+
+ myActiveViewManager = anApp->activeViewManager();
+ }
+
+ if ( !myPreviewViewManager )
+ {
+ myPreviewViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
+ anApp->createViewManager( OCCViewer_Viewer::Type() ) );
+ if ( myPreviewViewManager )
+ {
+ connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+ module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewCaseZones );
+ myPreviewViewManager->setTitle( tr( "PREVIEW_CASE_ZONES" ) );
+ }
+ }
+
+ if ( !myPreviewViewManager )
+ return;
+
+ if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ RegionsList::iterator anIter = myRegionsList.begin();
+ for ( ; anIter != myRegionsList.end(); ++anIter )
+ {
+ Region& aRegion = *anIter;
+ if ( aRegion.Shape )
+ {
+ aRegion.Shape->erase( false );
+ delete aRegion.Shape;
+ }
+
+ aRegion.Shape = new HYDROGUI_Shape( aCtx, NULL );
+
+ aRegion.Shape->setFillingColor( aRegion.FillingColor, false, false );
+ aRegion.Shape->setBorderColor( aRegion.BorderColor, false, false );
+ aRegion.Shape->setFace( aRegion.SplitData.Face(), true, false );
+ }
+
+ //Process the draw events for viewer
+ QApplication::processEvents();
+ if ( OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView() )
+ vw->onTopView();
+ }
+ }
+}
+
+void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+ closePreview();
+}
+
+void HYDROGUI_CalculationOp::closePreview()
+{
+ RegionsList::iterator anIter= myRegionsList.begin();
+ for ( ; anIter != myRegionsList.end(); ++anIter )
+ {
+ Region& aRegion = *anIter;
+ if ( aRegion.Shape )
+ {
+ aRegion.Shape->erase( false );
+ delete aRegion.Shape;
+ aRegion.Shape = NULL;
+ }
+ }
+
+ if( myPreviewViewManager )
+ {
+ disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+ module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
+ myPreviewViewManager = NULL;
+ }
+
+ if( myActiveViewManager )
+ {
+ HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
+ myActiveViewManager = NULL;
+ }