]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #594: create preview for land covers.
authormkr <mkr@opencascade.com>
Tue, 23 Jun 2015 08:23:59 +0000 (11:23 +0300)
committermkr <mkr@opencascade.com>
Tue, 23 Jun 2015 08:23:59 +0000 (11:23 +0300)
src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx
src/HYDROGUI/HYDROGUI_LandCoverDlg.h
src/HYDROGUI/HYDROGUI_LandCoverOp.cxx

index a88666170c177fcadcbd4cd6311480323e8866e0..a0c027becebd8e882c7fa6ff8e10ccf2aa416d93 100644 (file)
@@ -101,23 +101,33 @@ void HYDROGUI_LandCoverDlg::reset()
   onZoneDefChanged();
 }
 
-void HYDROGUI_LandCoverDlg::includePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines )
+bool HYDROGUI_LandCoverDlg::includePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines )
 {
   QStringList anIncludedPolylinesNames = myPolylines->getAllNames();
 
+  bool aSetOfPolylinesChanged = false;
   foreach ( const HYDROGUI_ListModel::Object2Visible& aSelectedPolyline, theSelectedPolylines )
   {
     if ( !anIncludedPolylinesNames.contains( aSelectedPolyline.first->GetName() ) )
+    {
       myPolylines->addObject( aSelectedPolyline );
+      aSetOfPolylinesChanged = true;
+    }
   }
   myPolylines->setOrderingEnabled( myPolylines->getObjects().count() > 1 );
+
+  return aSetOfPolylinesChanged;
 }
 
-void HYDROGUI_LandCoverDlg::excludePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines )
+bool HYDROGUI_LandCoverDlg::excludePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines )
 {
+  bool aSetOfPolylinesChanged = !theSelectedPolylines.isEmpty();
+
   foreach ( const HYDROGUI_ListModel::Object2Visible& aSelectedPolyline, theSelectedPolylines )
     myPolylines->removeObjectByName( aSelectedPolyline.first->GetName() );
   myPolylines->setOrderingEnabled( myPolylines->getObjects().count() > 1 );
+
+  return aSetOfPolylinesChanged;
 }
 
 QStringList HYDROGUI_LandCoverDlg::getPolylineNames() const
index 5c5aa3d8f8aef3922c6e28734180f4b4e62242a9..26b97ba503061a8882c289179805334df34aa9df 100644 (file)
@@ -37,8 +37,8 @@ public:
 
   virtual void               reset();
 
-  void                       includePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines );
-  void                       excludePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines );
+  bool                       includePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines );
+  bool                       excludePolylines( const HYDROGUI_ListModel::Object2VisibleList& theSelectedPolylines );
   QStringList                getPolylineNames() const;
   QStringList                getSelectedPolylineNames() const;
 
index 00b32548846d5db87d1f9a82b87997da5af6e189..9cf2567e4ea5aa58380c420f8a81de0adfd1106b 100644 (file)
@@ -247,7 +247,7 @@ void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames
 
   QApplication::setOverrideCursor( Qt::WaitCursor );  
 
-  QList<Handle(HYDROData_PolylineXY)> aZonePolylines;
+  HYDROData_SequenceOfObjects aZonePolylines;
   QStringList::const_iterator anIt = thePolylineNames.begin(), aLast = thePolylineNames.end();
   for( ; anIt!=aLast; anIt++ )
   {
@@ -255,14 +255,11 @@ void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames
     Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast(
       HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) );
     if ( !aPolyline.IsNull() )
-      aZonePolylines.append( aPolyline );
+      aZonePolylines.Append( aPolyline );
   }
-
-  // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method  
-  TopoDS_Shape aZoneShape;/* = HYDROData_LandCover::generateTopShape( aZonePolylines );
-  if( aZoneShape.IsNull() )
-    printErrorMessage( tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ) );
-  */
+  
+  TCollection_AsciiString anError;
+  TopoDS_Shape aZoneShape = HYDROData_LandCover::buildShape( aZonePolylines, anError );  
 
   LightApp_Application* anApp = module()->getApp();
   if ( !getPreviewManager() )
@@ -291,10 +288,8 @@ void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames
     myPreviewPrs->setFillingColor( aFillingColor, false, false );
     myPreviewPrs->setBorderColor( aBorderColor, false, false );
 
-    TopoDS_Face aFace;
     if( !aZoneShape.IsNull() )
-      aFace = TopoDS::Face( aZoneShape );
-    myPreviewPrs->setFace( aFace, true, true, "" );
+      myPreviewPrs->setShape( aZoneShape );
   }
 
   QApplication::restoreOverrideCursor();
@@ -321,8 +316,11 @@ void HYDROGUI_LandCoverOp::onAddPolylines()
       aSelectedPolylines.append( HYDROGUI_ListModel::Object2Visible( aPolyXY, true ) );
   }
   
-  aPanel->includePolylines( aSelectedPolylines );
-  // TODO: create preview of included polylines
+  if ( aPanel->includePolylines( aSelectedPolylines ) )
+  {
+    closePreview();
+    onCreatePreview( aPanel->getPolylineNames() );
+  }  
 }
 
 void HYDROGUI_LandCoverOp::onRemovePolylines()
@@ -348,7 +346,12 @@ void HYDROGUI_LandCoverOp::onRemovePolylines()
   }
 
   module()->update( UF_OCCViewer );
-  aPanel->excludePolylines( aSelectedPolylines );
+  
+  if ( aPanel->excludePolylines( aSelectedPolylines ) )
+  {
+    closePreview();
+    onCreatePreview( aPanel->getPolylineNames() );
+  }
 }
 
 void HYDROGUI_LandCoverOp::closePreview()