]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Boundary polyline can be selected now in the Calculation case dialog.
authorrkv <rkv@opencascade.com>
Mon, 11 Nov 2013 09:11:49 +0000 (09:11 +0000)
committerrkv <rkv@opencascade.com>
Mon, 11 Nov 2013 09:11:49 +0000 (09:11 +0000)
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h

index 76c0a83d071d33b2eb886a79c36a080127366f4c..7694feb6bf154fc6e2a9587c05c093fe1b691729 100644 (file)
@@ -77,6 +77,8 @@ void HYDROGUI_CalculationDlg::reset()
 {
   myObjectName->clear();
   myGeomObjects->clear();
+  myPolylineName->clear();
+  myAvailableGeomObjects->clear();
 }
 
 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
@@ -92,6 +94,8 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
   connect( myValidator, SIGNAL( alreadyExists( QString ) ), SLOT( onAlreadyExists( QString ) ) );
 
   myPolylineName = new QComboBox( aPage );
+  connect( myPolylineName, SIGNAL( activated( const QString & ) ), 
+    SIGNAL( boundarySelected( const QString & ) ) );
 
   myGeomObjects = new QListWidget( aPage );
   myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
@@ -348,6 +352,23 @@ void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects
   }
 }
 
+void HYDROGUI_CalculationDlg::setBoundary( QString& theObjName )
+{
+  bool isBlocked = myPolylineName->blockSignals( true );
+  myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
+  myPolylineName->blockSignals( isBlocked );
+}
+
+void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
+{
+  myPolylineName->clear();
+  myPolylineName->addItem( "", "" ); // No boundary item
+
+  for ( int i = 0, n = theObjects.length(); i < n; ++i )
+  {
+    myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
+  }
+}
 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
 {
   myAvailableGeomObjects->clear();
index d13c665121506edfd34f00e0455ee1e1581ad7f4..8a9fdfb8275f5b71ea3562f30f2319a3b2c81514 100644 (file)
@@ -54,11 +54,13 @@ public:
   void                       setEditedObject( const Handle(HYDROData_CalculationCase) theCase );
 
   void                       setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries );
+  void                       setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
   QStringList                getSelectedGeomObjects() const;
   QStringList                getSelectedAvailableGeomObjects() const;
   HYDROGUI_Zone*             getCurrentZone() const;
 
 public slots:
+  void                       setBoundary( QString& theObjName );
   void                       includeGeomObjects( const QStringList& theObjects );
   void                       excludeGeomObjects( const QStringList& theObjects );
   void                       onEmptyName();
@@ -82,6 +84,7 @@ signals:
   void                       addObjects();
   void                       removeObjects();
   void                       objectSelected( const QString & theObjName );
+  void                       boundarySelected( const QString & theObjName );
   void                       splitZones();
   void                       hideZones();
   void                       setMergeType( int theMergeType, QString& theBathymetryName );
index 2e5b2de48ea287f78f7c1750d764d9def52a432d..bfdfecd607790cddcafdbfd1fe86527dcedd0cb6 100644 (file)
@@ -82,9 +82,29 @@ void HYDROGUI_CalculationOp::startOperation()
   getNamesAndEntries( aSeq, aList, anEntryList );
   aPanel->setAllGeomObjects( aList, anEntryList );
 
-  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
+  // Get all polylines
+  aList.clear();
+  anEntryList.clear();
+  HYDROData_Iterator anIter( doc(), KIND_POLYLINE );
+  Handle(HYDROData_Polyline) aPolylineObj;
+  QString aPolylineName;
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    aPolylineObj = Handle(HYDROData_Polyline)::DownCast( anIter.Current() );
+
+    if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() )
+    {
+      aPolylineName = aPolylineObj->GetName();
+      if ( !aPolylineName.isEmpty() )
+      {
+        aList.append( aPolylineName );
+        anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
+      }
+    }
+  }
+  aPanel->setPolylineNames( aList, anEntryList );
 
-  QStringList aSelectedObjects;
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
 
   myEditedObject.Nullify();
   if ( myIsEdit )
@@ -93,6 +113,16 @@ void HYDROGUI_CalculationOp::startOperation()
     if ( !myEditedObject.IsNull() )
     {
       anObjectName = myEditedObject->GetName();
+      aPolylineObj = myEditedObject->GetBoundaryPolyline();
+      if ( aPolylineObj.IsNull() )
+      {
+        aPanel->setBoundary( QString() );
+      }
+      else
+      {
+        aPolylineName = aPolylineObj->GetName();
+        aPanel->setBoundary( aPolylineName );
+      }
       aSeq = myEditedObject->GetGeometryObjects();
       getNamesAndEntries( aSeq, aList, anEntryList );
       aPanel->includeGeomObjects( aList );
@@ -169,10 +199,35 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
     SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
   connect( aPanel, SIGNAL( objectSelected( const QString & ) ), 
     SLOT( onObjectSelected( const QString & ) ) );
+  connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), 
+    SLOT( onBoundarySelected( const QString & ) ) );
 
   return aPanel;
 }
 
+void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
+{
+  // Set the selected boundary polyline to the calculation case
+  if ( theObjName.trimmed().isEmpty() )
+  {
+    // No polyline is selected
+    myEditedObject->RemoveBoundaryPolyline();
+  }
+  else
+  {
+    Handle(HYDROData_Entity) anEntity = 
+      HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINE );
+    if ( !anEntity.IsNull() )
+    {
+      Handle(HYDROData_Polyline) anObject = Handle(HYDROData_Polyline)::DownCast( anEntity );
+      if ( !anObject.IsNull() )
+      {
+        myEditedObject->SetBoundaryPolyline( anObject );
+      }
+    }
+  }
+}
+
 void HYDROGUI_CalculationOp::onObjectSelected ( const QString & theObjName )
 {
   // Select the appropriate geometry object shape in the viewer
index 19dce657c11d2ac53e299f36b1ae67874a77ccad..274f144c3e6f3d8b79f519a4ba32065762633726 100644 (file)
@@ -93,6 +93,10 @@ protected slots:
    * Geometry object is selected in the list on the first wizard page
    */
   void                            onObjectSelected ( const QString & theObjName );
+  /** 
+   * Boundary polyline is selected in the list on the first wizard page
+   */
+  void                            onBoundarySelected ( const QString & theObjName );
 
 private:
   void                            createPreview();