From: rkv Date: Mon, 11 Nov 2013 09:11:49 +0000 (+0000) Subject: Boundary polyline can be selected now in the Calculation case dialog. X-Git-Tag: BR_hydro_v_0_3~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=676ac06ae10f045ffae7a56aacbd20f694b9a993;p=modules%2Fhydro.git Boundary polyline can be selected now in the Calculation case dialog. --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 76c0a83d..7694feb6 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -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(); diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index d13c6651..8a9fdfb8 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 2e5b2de4..bfdfecd6 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 19dce657..274f144c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -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();