aZonesLayout->addWidget( myGeomObjects, 1, 1, 2, 1 );
aZonesLayout->addWidget( aBtnsFrame, 2, 0, Qt::AlignHCenter );
- //QBoxLayout* aMainLayout = new QVBoxLayout( aFrame );
- //aMainLayout->setMargin( 0 );
- //aMainLayout->setSpacing( 5 );
- //aMainLayout->addWidget( myObjectNameGroup );
- //aMainLayout->addWidget( anObjectsFrame );
- //aMainLayout->addStretch();
-
- //aPage->setLayout( aMainLayout );
aPage->setLayout( aZonesLayout );
+ connect( anAddBtn, SIGNAL( clicked() ), this, SIGNAL( addObjects() ) );
+ connect( aRemoveBtn, SIGNAL( clicked() ), this, SIGNAL( removeObjects() ) );
+
return aPage;
}
QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
{
QStringList aResList;
-
- for ( int i = 0, n = myGeomObjects->count(); i < n; ++i )
+ QList<QListWidgetItem*> aList = myGeomObjects->selectedItems();
+ for ( int i = 0, n = aList.length(); i < n; ++i )
{
- QListWidgetItem* aListItem = myGeomObjects->item( i );
- if ( !aListItem )
- continue;
-
- QString aSelObjName = aListItem->text();
- aResList.append( aSelObjName );
+ aResList.append( aList.at( i )->text() );
}
-
return aResList;
}
#include <HYDROData_Polyline.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_Object.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
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
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();
HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() );
// Connect signals and slots
+ connect( aPanel, SIGNAL( addObjects() ), this, SLOT( onAddObjects() ) );
+ connect( aPanel, SIGNAL( removeObjects() ), this, SLOT( onRemoveObjects() ) );
return aPanel;
}
+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<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
+ {
+ updateGeomObjectsList( aPanel );
+ }
+}
+
+void HYDROGUI_CalculationOp::onRemoveObjects()
+{
+ // Remove selected objects from the calculation case
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( 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 )
{