X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_CalculationOp.cxx;h=3dab9422c0eb0fecebb2a2df68669719be3c1248;hb=5cae7e874afd2fc1b6f61023e8ebd33a933db3c7;hp=621d9d755a6badbc11402614253e9f0ca8b6e174;hpb=acc1c9db1a80ae3f0152c5b88b8b8b658e05dbf0;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 621d9d75..3dab9422 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -27,10 +27,12 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_Zone.h" #include #include #include +#include #include #include @@ -84,22 +86,7 @@ void HYDROGUI_CalculationOp::startOperation() if ( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); - - HYDROData_SequenceOfObjects aRefObjects = myEditedObject->GetGeometryObjects(); - HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Object) aRefbject = - Handle(HYDROData_Object)::DownCast( anIter.Value() ); - if ( aRefbject.IsNull() ) - continue; - - QString aRefObjectName = aRefbject->GetName(); - if ( aRefObjectName.isEmpty() ) - continue; - - aSelectedObjects.append( aRefObjectName ); - } + updateGeomObjectsList(aPanel); } } else @@ -111,11 +98,34 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->setObjectName( anObjectName ); aPanel->setEditedObject( myEditedObject ); - aPanel->setSelectedGeomObjects( aSelectedObjects ); +// aPanel->setSelectedGeomObjects( aSelectedObjects ); createPreview(); } +void HYDROGUI_CalculationOp::updateGeomObjectsList( HYDROGUI_CalculationDlg* thePanel ) const +{ + Handle(HYDROData_Object) anObject; + Handle(HYDROData_Entity) anEntity; + QStringList aList; + // Update the list in the dialog + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); + for ( ; anIter.More(); anIter.Next() ) + { + anEntity = anIter.Value(); + if ( !anEntity.IsNull() ) + { + anObject = Handle(HYDROData_Object)::DownCast( anEntity ); + if ( !anObject.IsNull() ) + { + aList.append( anObject->GetName() ); + } + } + } + thePanel->setSelectedGeomObjects( aList ); +} + void HYDROGUI_CalculationOp::abortOperation() { closePreview(); @@ -137,10 +147,86 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() ); // Connect signals and slots + connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) ); + connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) ); + connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) ); + connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) ); + connect( aPanel, SIGNAL( setMergeType( int, QString ) ), SLOT( onSetMergeType( int, QString ) ) ); return aPanel; } +void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString theBathymetryName ) +{ + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( aPanel ) + { + HYDROGUI_Zone* aZone = aPanel->getCurrentZone(); + if ( aZone ) + { + aZone->setMergeType( theMergeType, theBathymetryName ); + } + aPanel->refreshZonesBrowser(); + } +} + +void HYDROGUI_CalculationOp::onAddObjects() +{ + // Add geometry objects selected in the module browser to the calculation case + Handle(HYDROData_Object) anObject; + Handle(HYDROData_Entity) anEntity; + QStringList aList; + HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); + for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) + { + anEntity = aSeq.Value( anIndex ); + if ( !anEntity.IsNull() ) + { + anObject = Handle(HYDROData_Object)::DownCast( anEntity ); + if( !anObject.IsNull() ) + { + if (myEditedObject->AddGeometryObject( anObject )) + { + aList.append( anObject->GetName() ); + } + } + } + } + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( aPanel ) + { + updateGeomObjectsList( aPanel ); + } +} + +void HYDROGUI_CalculationOp::onRemoveObjects() +{ + // Remove selected objects from the calculation case + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( aPanel ) + { + QStringList aList = aPanel->getSelectedGeomObjects(); + Handle(HYDROData_Object) anObject; + Handle(HYDROData_Entity) anEntity; + for (int i = 0; i < aList.length(); i++) + { + anEntity = HYDROGUI_Tool::FindObjectByName( module(), aList.at(i) ); + if ( !anEntity.IsNull() ) + { + anObject = Handle(HYDROData_Object)::DownCast( anEntity ); + if ( !anObject.IsNull() ) + { + myEditedObject->RemoveGeometryObject( anObject ); + } + } + } + updateGeomObjectsList( aPanel ); + } +} + bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, QString& theErrorMsg ) { @@ -230,7 +316,7 @@ void HYDROGUI_CalculationOp::onApply() void HYDROGUI_CalculationOp::onSplitZones() { - myRegionsList.clear(); + //myRegionsList.clear(); HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -239,35 +325,38 @@ void HYDROGUI_CalculationOp::onSplitZones() QApplication::setOverrideCursor( Qt::WaitCursor ); - QStringList aGeomObjectNames = aPanel->getSelectedGeomObjects(); - HYDROData_SequenceOfObjects aGeomObjects = - HYDROGUI_Tool::FindObjectsByNames( module(), aGeomObjectNames ); + //QStringList aGeomObjectNames = aPanel->getSelectedGeomObjects(); + //HYDROData_SequenceOfObjects aGeomObjects = + // HYDROGUI_Tool::FindObjectsByNames( module(), aGeomObjectNames ); - QStringList aResSplittedZones; + //QStringList aResSplittedZones; - HYDROData_SplitToZonesTool::SplitDataList aSplittedZones = - HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects ); + //HYDROData_SplitToZonesTool::SplitDataList aSplittedZones = + // HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects ); - QStringList aUsedNames; + //QStringList aUsedNames; - HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplittedZones ); - while( anIter.hasNext() ) - { - Region aRegion; - aRegion.SplitData = anIter.next(); + //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.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aRegion.SplitData.ObjectNames ); + // aRegion.BorderColor = QColor( HYDROData_ImmersibleZone::DefaultBorderColor() ); - aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), "Region", aUsedNames ); + // aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), "Region", aUsedNames ); - aUsedNames.append( aRegion.RegionName ); + // aUsedNames.append( aRegion.RegionName ); - aResSplittedZones.append( aRegion.RegionName ); + // aResSplittedZones.append( aRegion.RegionName ); - myRegionsList.append( aRegion ); - } - + // myRegionsList.append( aRegion ); + //} + // + + myEditedObject->SplitGeometryObjects(); + aPanel->setEditedObject( myEditedObject ); createPreview(); QApplication::restoreOverrideCursor();