From: vsr Date: Wed, 22 May 2013 15:25:18 +0000 (+0000) Subject: 0022099: EDF 2307 SMESH: Apply a transformation to several meshes, sub-meshes or... X-Git-Tag: V7_3_0a1~419 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b07f27826ffb84e44809d777897f4d59befd7fd6;p=modules%2Fsmesh.git 0022099: EDF 2307 SMESH: Apply a transformation to several meshes, sub-meshes or groups --- diff --git a/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx b/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx index abbe1d00d..254e8b0fa 100644 --- a/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx @@ -123,3 +123,107 @@ bool SMESHGUI_PreviewDlg::isApplyAndClose() const { return myIsApplyAndClose; } + + +//================================================================================= +// class : SMESHGUI_SMESHGUI_MultiPreviewDlg() +// purpose : +//================================================================================= +SMESHGUI_MultiPreviewDlg::SMESHGUI_MultiPreviewDlg( SMESHGUI* theModule ) : + mySMESHGUI( theModule ), + QDialog( SMESH::GetDesktop( theModule ) ), + myIsApplyAndClose( false ) +{ +} + +//================================================================================= +// function : ~SMESHGUI_MultiPreviewDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MultiPreviewDlg::~SMESHGUI_MultiPreviewDlg() +{ + qDeleteAll( mySimulationList ); +} + +//================================================================================= +// function : showPreview +// purpose : Show preview in the viewer +//================================================================================= +void SMESHGUI_MultiPreviewDlg::showPreview() +{ + for ( int i = 0; i < mySimulationList.count(); i++ ) + mySimulationList[i]->SetVisibility( true ); +} + +//================================================================================= +// function : hidePreview +// purpose : Hide preview in the viewer +//================================================================================= +void SMESHGUI_MultiPreviewDlg::hidePreview() +{ + for ( int i = 0; i < mySimulationList.count(); i++ ) + mySimulationList[i]->SetVisibility( false ); +} + +//================================================================================= +// function : connectPreviewControl +// purpose : Connect the preview check box +//================================================================================= +void SMESHGUI_MultiPreviewDlg::connectPreviewControl() +{ + connect( myPreviewCheckBox, SIGNAL( toggled( bool ) ), this, SLOT( onDisplaySimulation( bool ) ) ); +} + + +//================================================================================= +// function : toDisplaySimulation +// purpose : +//================================================================================= +void SMESHGUI_MultiPreviewDlg::toDisplaySimulation() +{ + onDisplaySimulation( true ); +} + +//================================================================================= +// function : onDisplaySimulation +// purpose : +//================================================================================= +void SMESHGUI_MultiPreviewDlg::onDisplaySimulation( bool toDisplayPreview ) +{ + //Empty implementation here +} + +//================================================================ +// Function : setIsApplyAndClose +// Purpose : Set value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +void SMESHGUI_MultiPreviewDlg::setIsApplyAndClose( const bool theFlag ) +{ + myIsApplyAndClose = theFlag; +} + +//================================================================ +// Function : isApplyAndClose +// Purpose : Get value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +bool SMESHGUI_MultiPreviewDlg::isApplyAndClose() const +{ + return myIsApplyAndClose; +} + +//================================================================ +// Function : setSimulationPreview +// Purpose : +//================================================================ +void SMESHGUI_MultiPreviewDlg::setSimulationPreview( QList& theMeshPreviewStruct ) +{ + hidePreview(); + qDeleteAll( mySimulationList ); + mySimulationList.clear(); + for ( int i = 0; i < theMeshPreviewStruct.count(); i++ ) { + mySimulationList << new SMESHGUI_MeshEditPreview( SMESH::GetViewWindow( mySMESHGUI ) ); + mySimulationList[i]->SetData( theMeshPreviewStruct[i].operator->() ); + } +} diff --git a/src/SMESHGUI/SMESHGUI_PreviewDlg.h b/src/SMESHGUI/SMESHGUI_PreviewDlg.h index a5035c1b9..5d125c673 100644 --- a/src/SMESHGUI/SMESHGUI_PreviewDlg.h +++ b/src/SMESHGUI/SMESHGUI_PreviewDlg.h @@ -33,6 +33,10 @@ // Qt includes #include +// IDL includes +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + class SMESHGUI; class SMESHGUI_MeshEditPreview; class QCheckBox; @@ -64,4 +68,33 @@ protected: bool myIsApplyAndClose; }; +class SMESHGUI_EXPORT SMESHGUI_MultiPreviewDlg : public QDialog { + Q_OBJECT +public: + SMESHGUI_MultiPreviewDlg( SMESHGUI* ); + ~SMESHGUI_MultiPreviewDlg(); + + void showPreview(); + void hidePreview(); + + void setSimulationPreview( QList& ); + +protected: + void connectPreviewControl(); + + virtual void setIsApplyAndClose( const bool theFlag ); + virtual bool isApplyAndClose() const; + +protected slots: + void toDisplaySimulation(); + virtual void onDisplaySimulation( bool ); + + +protected: + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ + QList mySimulationList; + QCheckBox* myPreviewCheckBox; + bool myIsApplyAndClose; +}; + #endif diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index 4128a8763..4c495d65e 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -52,8 +52,10 @@ #include #include #include +#include // SALOME KERNEL includes +#include #include // OCCT includes @@ -92,10 +94,9 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action // purpose : //================================================================================= SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule ) : - SMESHGUI_PreviewDlg( theModule ), + SMESHGUI_MultiPreviewDlg( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0), - mySelectedObject(SMESH::SMESH_IDSource::_nil()) + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -351,6 +352,9 @@ SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg() void SMESHGUI_RotationDlg::Init (bool ResetControls) { myBusy = false; + myMeshes.clear(); + myObjects.clear(); + myObjectsNames.clear(); myEditCurrentArgument = (QWidget*)LineEditElements; LineEditElements->setFocus(); @@ -361,7 +365,6 @@ void SMESHGUI_RotationDlg::Init (bool ResetControls) buttonApply->setEnabled(false); myActor = 0; - myMesh = SMESH::SMESH_Mesh::_nil(); if (ResetControls) { SpinBox_X->SetValue(0.0); @@ -432,57 +435,99 @@ bool SMESHGUI_RotationDlg::ClickOnApply() QStringList anEntryList; try { SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - - myMesh->SetParameters(aParameters.join(":").toLatin1().constData()); switch ( actionButton ) { case MOVE_ELEMS_BUTTON: - if(CheckBoxMesh->isChecked()) - aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, false); - else - aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false); + if(CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->RotateObject(myObjects[i], anAxis, anAngle, false); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false); + } break; case COPY_ELEMS_BUTTON: if ( makeGroups ) { SMESH::ListOfGroups_var groups; - if(CheckBoxMesh->isChecked()) - groups = aMeshEditor->RotateObjectMakeGroups(mySelectedObject, anAxis, anAngle); - else + if(CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->RotateObjectMakeGroups(myObjects[i], anAxis, anAngle); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); groups = aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle); + } } else { - if(CheckBoxMesh->isChecked()) - aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, true); - else - aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true); + if(CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->RotateObject(myObjects[i], anAxis, anAngle, true); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true); + } } break; case MAKE_MESH_BUTTON: { SMESH::SMESH_Mesh_var mesh; - if (CheckBoxMesh->isChecked()) - mesh = aMeshEditor->RotateObjectMakeMesh(mySelectedObject, anAxis, anAngle, makeGroups, - LineEditNewMesh->text().toLatin1().data()); - else + if (CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->RotateObjectMakeMesh(myObjects[i], anAxis, anAngle, makeGroups, + aName.toLatin1().data()); + if (!mesh->_is_nil()) { + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) + anEntryList.append( aSObject->GetID().c_str() ); +#ifdef WITHGENERICOBJ + // obj has been published in study. Its refcount has been incremented. + // It is safe to decrement its refcount + // so that it will be destroyed when the entry in study will be removed + mesh->UnRegister(); +#endif + } + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); mesh = aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups, LineEditNewMesh->text().toLatin1().data()); - if (!mesh->_is_nil()) { - if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) - anEntryList.append( aSObject->GetID().c_str() ); + if (!mesh->_is_nil()) { + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) + anEntryList.append( aSObject->GetID().c_str() ); #ifdef WITHGENERICOBJ - // obj has been published in study. Its refcount has been incremented. - // It is safe to decrement its refcount - // so that it will be destroyed when the entry in study will be removed - mesh->UnRegister(); + // obj has been published in study. Its refcount has been incremented. + // It is safe to decrement its refcount + // so that it will be destroyed when the entry in study will be removed + mesh->UnRegister(); #endif - } + } + } break; } } } catch (...) { } - SMESH::UpdateView(); + for ( int i = 0; i < myMeshes.count(); i++ ) + SMESH::Update( (SMESH::FindActorByObject( myMeshes[i] ))->getIO(), true ); + if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) || actionButton == MAKE_MESH_BUTTON ) { mySMESHGUI->updateObjBrowser(true); // new groups may appear @@ -491,7 +536,6 @@ bool SMESHGUI_RotationDlg::ClickOnApply() anApp->browseObjects( anEntryList, isApplyAndClose() ); } Init(false); - mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); SMESHGUI::Modified(); @@ -617,6 +661,7 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() // clear myActor = 0; QString aString = ""; + onDisplaySimulation(false); myBusy = true; if (myEditCurrentArgument == (QWidget*)LineEditElements) { @@ -635,27 +680,48 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); int nbSel = aList.Extent(); - if (nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) IO = aList.First(); - myMesh = SMESH::GetMeshByIO(IO); - if (myMesh->_is_nil()) - return; - - myActor = SMESH::FindActorByObject(myMesh); - if (!myActor) - myActor = SMESH::FindActorByEntry(IO->getEntry()); - if (!myActor && !CheckBoxMesh->isChecked()) + if (nbSel < 1) return; int aNbUnits = 0; if (myEditCurrentArgument == (QWidget*)LineEditElements) { myElementsId = ""; + myObjects.clear(); + myObjectsNames.clear(); + myMeshes.clear(); + + for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { + Handle(SALOME_InteractiveObject) IO = it.Value(); + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); + if ( aMesh->_is_nil() ) + return; + + myActor = SMESH::FindActorByObject( aMesh ); + if ( !myActor ) + myActor = SMESH::FindActorByEntry( IO->getEntry() ); + if ( !myActor && !CheckBoxMesh->isChecked() ) + return; + + if ( !SMESH::IObjectToInterface( IO )->_is_nil() ) { + if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { + _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); + _PTR(GenericAttribute) anAttr; + if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { + _PTR(AttributeName) aNameAttr( anAttr ); + myObjects << SMESH::IObjectToInterface( IO ); + myObjectsNames << aNameAttr->Value().c_str(); + myMeshes << aMesh; + } + } + } + } // MakeGroups is available if there are groups and "Copy" - if ( myMesh->NbGroups() == 0 ) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + if ( aNbGroups == 0 ) { MakeGroupsCheck->setChecked(false); MakeGroupsCheck->setEnabled(false); } @@ -665,12 +731,9 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - mySelectedObject = SMESH::IObjectToInterface(IO); - } - else - return; - // get IDs from mesh + if ( myMeshes.isEmpty() ) + return; + // get IDs from mesh /* SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); if (!aSMDSMesh) @@ -711,7 +774,7 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() } */ } else { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString); myElementsId = aString; if (aNbUnits < 1) return; @@ -720,11 +783,21 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() myNbOkElements = true; } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + if ((SMESH::GetMeshByIO(IO))->_is_nil()) + return; + + SMESH_Actor* anActor = SMESH::FindActorByObject(SMESH::GetMeshByIO(IO)); + if (!anActor) + anActor = SMESH::FindActorByEntry(IO->getEntry()); + if (!anActor && !CheckBoxMesh->isChecked()) + return; + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); if (aNbUnits != 1) return; - SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); if (!aMesh) return; @@ -929,6 +1002,10 @@ void SMESHGUI_RotationDlg::onVectorChanged() void SMESHGUI_RotationDlg::onActionClicked(int button) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + switch ( button ) { case MOVE_ELEMS_BUTTON: MakeGroupsCheck->setEnabled(false); @@ -937,18 +1014,12 @@ void SMESHGUI_RotationDlg::onActionClicked(int button) case COPY_ELEMS_BUTTON: LineEditNewMesh->setEnabled(false); MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 ); break; case MAKE_MESH_BUTTON: LineEditNewMesh->setEnabled(true); MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 ); break; } setNewMeshName(); @@ -963,13 +1034,13 @@ void SMESHGUI_RotationDlg::onActionClicked(int button) void SMESHGUI_RotationDlg::setNewMeshName() { LineEditNewMesh->setText(""); - if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) { + if ( LineEditNewMesh->isEnabled() && !myMeshes.isEmpty() ) { QString name; if ( CheckBoxMesh->isChecked() ) { - name = LineEditElements->text(); + name = myMeshes.count() > 1 ? "*" : LineEditElements->text(); } else { - _PTR(SObject) meshSO = SMESH::FindSObject( myMesh ); + _PTR(SObject) meshSO = SMESH::FindSObject( myMeshes[0] ); name = meshSO->GetName().c_str(); } if ( !name.isEmpty() ) @@ -999,7 +1070,7 @@ void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e ) //================================================================================= void SMESHGUI_RotationDlg::setFilters() { - if(myMesh->_is_nil()) { + if ( myMeshes.isEmpty() ) { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), tr("NO_MESH_SELECTED")); @@ -1009,7 +1080,7 @@ void SMESHGUI_RotationDlg::setFilters() myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); myFilterDlg->SetSelection(); - myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetMesh( myMeshes[0] ); myFilterDlg->SetSourceWg( LineEditElements ); myFilterDlg->show(); @@ -1071,14 +1142,19 @@ void SMESHGUI_RotationDlg::onDisplaySimulation( bool toDisplayPreview ) { SUIT_OverrideCursor aWaitCursor; bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || ActionGroup->checkedId() == MAKE_MESH_BUTTON ); - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); + QList aMeshPreviewStruct; if(CheckBoxMesh->isChecked()) - aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, copy); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); + aMeshEditor->RotateObject(myObjects[i], anAxis, anAngle, copy); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); aMeshEditor->Rotate(anElementsId, anAxis, anAngle, copy); - - SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); - mySimulation->SetData(aMeshPreviewStruct._retn()); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + setSimulationPreview( aMeshPreviewStruct ); } catch (...) { hidePreview(); } diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h index 02e7d48b5..97131cb57 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.h +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -56,7 +56,7 @@ class SMESH_LogicalFilter; // class : SMESHGUI_RotationDlg // purpose : //================================================================================= -class SMESHGUI_EXPORT SMESHGUI_RotationDlg : public SMESHGUI_PreviewDlg +class SMESHGUI_EXPORT SMESHGUI_RotationDlg : public SMESHGUI_MultiPreviewDlg { Q_OBJECT @@ -82,10 +82,11 @@ private: QWidget* myEditCurrentArgument; /* Current LineEdit */ int myConstructorId; bool myBusy; - SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; - SMESH::SMESH_IDSource_var mySelectedObject; + QList myObjects; + QList myObjectsNames; + QList myMeshes; QGroupBox* GroupConstructors; QRadioButton* RadioButton1; diff --git a/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx b/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx index 074cdea2b..859c5a783 100644 --- a/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx @@ -49,8 +49,10 @@ #include #include #include +#include // SALOME KERNEL includes +#include #include // OCCT includes @@ -107,10 +109,9 @@ private: // purpose : //================================================================================= SMESHGUI_ScaleDlg::SMESHGUI_ScaleDlg( SMESHGUI* theModule ) : - SMESHGUI_PreviewDlg( theModule ), + SMESHGUI_MultiPreviewDlg( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0), - mySelectedObject(SMESH::SMESH_IDSource::_nil()) + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_SCALE"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SCALE_ALONG_AXES"))); @@ -353,6 +354,9 @@ SMESHGUI_ScaleDlg::~SMESHGUI_ScaleDlg() void SMESHGUI_ScaleDlg::Init (bool ResetControls) { myBusy = false; + myObjects.clear(); + myObjectsNames.clear(); + myMeshes.clear(); myEditCurrentArgument = 0; LineEditElements->clear(); @@ -363,7 +367,6 @@ void SMESHGUI_ScaleDlg::Init (bool ResetControls) buttonApply->setEnabled(false); myActor = 0; - myMesh = SMESH::SMESH_Mesh::_nil(); if (ResetControls) { SpinBox1_1->SetValue(0.0); @@ -474,35 +477,78 @@ bool SMESHGUI_ScaleDlg::ClickOnApply() QStringList anEntryList; try { SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - - myMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); - - SMESH::SMESH_IDSource_var obj; - if ( CheckBoxMesh->isChecked() ) - obj = mySelectedObject; - else - obj = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); - + switch ( actionButton ) { case MOVE_ELEMS_BUTTON: - aMeshEditor->Scale(obj, aPoint, aScaleFact, false); + if ( CheckBoxMesh->isChecked() ) + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters( aParameters.join( ":" ).toLatin1().constData() ); + aMeshEditor->Scale(myObjects[i], aPoint, aScaleFact, false); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() ); + aMeshEditor->Scale(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, false); + } break; case COPY_ELEMS_BUTTON: - if ( makeGroups ) - SMESH::ListOfGroups_var groups = - aMeshEditor->ScaleMakeGroups(obj, aPoint, aScaleFact); - else - aMeshEditor->Scale(obj, aPoint, aScaleFact, true); + if ( makeGroups ) { + SMESH::ListOfGroups_var groups; + if(CheckBoxMesh->isChecked()) + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->ScaleMakeGroups(myObjects[i], aPoint, aScaleFact); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->ScaleMakeGroups(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact); + } + } + else { + if(CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->Scale(myObjects[i], aPoint, aScaleFact, true); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->Scale(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, true); + } + } break; case MAKE_MESH_BUTTON: { - SMESH::SMESH_Mesh_var mesh = - aMeshEditor->ScaleMakeMesh(obj, aPoint, aScaleFact, makeGroups, - LineEditNewMesh->text().toLatin1().data()); - if (!mesh->_is_nil()) { + SMESH::SMESH_Mesh_var mesh; + if (CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->ScaleMakeMesh(myObjects[i], aPoint, aScaleFact, makeGroups, + aName.toLatin1().data()); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) + anEntryList.append( aSObject->GetID().c_str() ); +#ifdef WITHGENERICOBJ + // obj has been published in study. Its refcount has been incremented. + // It is safe to decrement its refcount + // so that it will be destroyed when the entry in study will be removed + mesh->UnRegister(); +#endif + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->ScaleMakeMesh(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, makeGroups, + LineEditNewMesh->text().toLatin1().data()); if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) anEntryList.append( aSObject->GetID().c_str() ); #ifdef WITHGENERICOBJ @@ -518,7 +564,9 @@ bool SMESHGUI_ScaleDlg::ClickOnApply() } catch (...) { } - SMESH::UpdateView(); + for ( int i = 0; i < myMeshes.count(); i++ ) + SMESH::Update( (SMESH::FindActorByObject( myMeshes[i] ))->getIO(), true ); + if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) || actionButton == MAKE_MESH_BUTTON ) { mySMESHGUI->updateObjBrowser(true); // new groups may appear @@ -528,7 +576,6 @@ bool SMESHGUI_ScaleDlg::ClickOnApply() } Init(false); ConstructorsClicked(GetConstructorId()); - mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); SMESHGUI::Modified(); @@ -653,6 +700,7 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() // clear myActor = 0; QString aString = ""; + onDisplaySimulation(false); if (myEditCurrentArgument == (QWidget*)LineEditElements) { LineEditElements->setText(aString); @@ -669,27 +717,49 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); int nbSel = aList.Extent(); - if (nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) IO = aList.First(); - myMesh = SMESH::GetMeshByIO(IO); - if (myMesh->_is_nil()) - return; - - myActor = SMESH::FindActorByObject(myMesh); - if (!myActor) - myActor = SMESH::FindActorByEntry(IO->getEntry()); - if (!myActor && !CheckBoxMesh->isChecked()) + if (nbSel < 1) return; int aNbUnits = 0; if (myEditCurrentArgument == (QWidget*)LineEditElements) { myElementsId = ""; - + myObjects.clear(); + myObjectsNames.clear(); + myMeshes.clear(); + + for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { + Handle(SALOME_InteractiveObject) IO = it.Value(); + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); + if ( aMesh->_is_nil() ) + return; + + myActor = SMESH::FindActorByObject( aMesh ); + if ( !myActor ) + myActor = SMESH::FindActorByEntry( IO->getEntry() ); + if ( !myActor && !CheckBoxMesh->isChecked() ) + return; + + if ( !SMESH::IObjectToInterface( IO )->_is_nil() ) { + if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { + _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); + _PTR(GenericAttribute) anAttr; + if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { + _PTR(AttributeName) aNameAttr( anAttr ); + myObjects << SMESH::IObjectToInterface( IO ); + myObjectsNames << aNameAttr->Value().c_str(); + myMeshes << aMesh; + } + } + } + } + // MakeGroups is available if there are groups and "Copy" - if ( myMesh->NbGroups() == 0 ) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + + if ( aNbGroups == 0 ) { MakeGroupsCheck->setChecked(false); MakeGroupsCheck->setEnabled(false); } @@ -699,12 +769,8 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); - - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP - mySelectedObject = SMESH::IObjectToInterface(IO); - } - else - return; + if (myMeshes.isEmpty()) + return; // get IDs from mesh /* SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); @@ -746,7 +812,7 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() } */ } else { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString); myElementsId = aString; if (aNbUnits < 1) return; @@ -754,11 +820,21 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() myNbOkElements = true; } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + if ((SMESH::GetMeshByIO(IO))->_is_nil()) + return; + + SMESH_Actor* anActor = SMESH::FindActorByObject(SMESH::GetMeshByIO(IO)); + if (!anActor) + anActor = SMESH::FindActorByEntry(IO->getEntry()); + if (!anActor && !CheckBoxMesh->isChecked()) + return; + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); if (aNbUnits != 1) return; - SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); if (!aMesh) return; @@ -926,6 +1002,10 @@ void SMESHGUI_ScaleDlg::onSelectMesh (bool toSelectMesh) void SMESHGUI_ScaleDlg::onActionClicked(int button) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + switch ( button ) { case MOVE_ELEMS_BUTTON: MakeGroupsCheck->setEnabled(false); @@ -934,18 +1014,12 @@ void SMESHGUI_ScaleDlg::onActionClicked(int button) case COPY_ELEMS_BUTTON: LineEditNewMesh->setEnabled(false); MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 ); break; case MAKE_MESH_BUTTON: LineEditNewMesh->setEnabled(true); MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 ); break; } setNewMeshName(); @@ -960,13 +1034,13 @@ void SMESHGUI_ScaleDlg::onActionClicked(int button) void SMESHGUI_ScaleDlg::setNewMeshName() { LineEditNewMesh->setText(""); - if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) { + if ( LineEditNewMesh->isEnabled() && !myMeshes.isEmpty() ) { QString name; if ( CheckBoxMesh->isChecked() ) { - name = LineEditElements->text(); + name = myObjects.count() > 1 ? "*" : LineEditElements->text(); } else { - _PTR(SObject) meshSO = SMESH::FindSObject( myMesh ); + _PTR(SObject) meshSO = SMESH::FindSObject( myMeshes[0] ); name = meshSO->GetName().c_str(); } if ( !name.isEmpty() ) @@ -1005,7 +1079,7 @@ void SMESHGUI_ScaleDlg::keyPressEvent( QKeyEvent* e ) //================================================================================= void SMESHGUI_ScaleDlg::setFilters() { - if(myMesh->_is_nil()) { + if(myMeshes.isEmpty()) { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), tr("NO_MESH_SELECTED")); @@ -1015,7 +1089,7 @@ void SMESHGUI_ScaleDlg::setFilters() myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); myFilterDlg->SetSelection(); - myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetMesh( myMeshes[0] ); myFilterDlg->SetSourceWg( LineEditElements ); myFilterDlg->show(); @@ -1072,17 +1146,20 @@ void SMESHGUI_ScaleDlg::onDisplaySimulation( bool toDisplayPreview ) { bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || ActionGroup->checkedId() == MAKE_MESH_BUTTON ); SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); - SMESH::SMESH_IDSource_var obj; - if ( CheckBoxMesh->isChecked() ) - obj = mySelectedObject; - else - obj = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); - aMeshEditor->Scale(obj, aPoint, aScaleFact, copy); - - SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); - mySimulation->SetData(aMeshPreviewStruct._retn()); - + QList aMeshPreviewStruct; + + if(CheckBoxMesh->isChecked()) + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); + aMeshEditor->Scale(myObjects[i], aPoint, aScaleFact, copy); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); + aMeshEditor->Scale(aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL), aPoint, aScaleFact, copy); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + setSimulationPreview(aMeshPreviewStruct); } catch (...) { hidePreview(); } diff --git a/src/SMESHGUI/SMESHGUI_ScaleDlg.h b/src/SMESHGUI/SMESHGUI_ScaleDlg.h index da684c355..aee598be9 100644 --- a/src/SMESHGUI/SMESHGUI_ScaleDlg.h +++ b/src/SMESHGUI/SMESHGUI_ScaleDlg.h @@ -52,7 +52,7 @@ class SMESH_LogicalFilter; // class : SMESHGUI_ScaleDlg // purpose : //================================================================================= -class SMESHGUI_EXPORT SMESHGUI_ScaleDlg : public SMESHGUI_PreviewDlg +class SMESHGUI_EXPORT SMESHGUI_ScaleDlg : public SMESHGUI_MultiPreviewDlg { Q_OBJECT @@ -81,11 +81,13 @@ private: QWidget* myEditCurrentArgument; bool myBusy; - SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; - SMESH::SMESH_IDSource_var mySelectedObject; + QList myObjects; + QList myObjectsNames; + QList myMeshes; + QGroupBox* ConstructorsBox; QButtonGroup* GroupConstructors; diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index c9aeb4168..64d335709 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -52,8 +52,10 @@ #include #include #include +#include // SALOME KERNEL includes +#include #include // OCCT includes @@ -93,10 +95,9 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action //================================================================================= SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule ) - : SMESHGUI_PreviewDlg( theModule ), + : SMESHGUI_MultiPreviewDlg( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0), - mySelectedObject(SMESH::SMESH_IDSource::_nil()) + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); @@ -355,6 +356,9 @@ SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg() void SMESHGUI_SymmetryDlg::Init (bool ResetControls) { myBusy = false; + myMeshes.clear(); + myObjects.clear(); + myObjectsNames.clear(); myEditCurrentArgument = 0; LineEditElements->clear(); @@ -365,7 +369,6 @@ void SMESHGUI_SymmetryDlg::Init (bool ResetControls) buttonApply->setEnabled(false); myActor = 0; - myMesh = SMESH::SMESH_Mesh::_nil(); if (ResetControls) { SpinBox_X->SetValue(0.0); @@ -496,41 +499,73 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply() QStringList anEntryList; try { SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - - myMesh->SetParameters(aParameters.join(":").toLatin1().constData()); switch ( actionButton ) { case MOVE_ELEMS_BUTTON: { if(CheckBoxMesh->isChecked()) - aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, false ); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->MirrorObject(myObjects[i], aMirror, aMirrorType, false ); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); - + } break; } case COPY_ELEMS_BUTTON: { SMESH::ListOfGroups_var groups; if ( makeGroups ) { if(CheckBoxMesh->isChecked()) - groups = aMeshEditor->MirrorObjectMakeGroups(mySelectedObject, aMirror, aMirrorType); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->MirrorObjectMakeGroups(myObjects[i], aMirror, aMirrorType); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); groups = aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); + } } else { if(CheckBoxMesh->isChecked()) - aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, true); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->MirrorObject(myObjects[i], aMirror, aMirrorType, true); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true); + } } break; } case MAKE_MESH_BUTTON: { SMESH::SMESH_Mesh_var mesh; if (CheckBoxMesh->isChecked()) - mesh = aMeshEditor->MirrorObjectMakeMesh(mySelectedObject, aMirror, aMirrorType, makeGroups, - LineEditNewMesh->text().toLatin1().data()); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->MirrorObjectMakeMesh(myObjects[i], aMirror, aMirrorType, makeGroups, + aName.toLatin1().data()); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) + anEntryList.append( aSObject->GetID().c_str() ); +#ifdef WITHGENERICOBJ + // obj has been published in study. Its refcount has been incremented. + // It is safe to decrement its refcount + // so that it will be destroyed when the entry in study will be removed + mesh->UnRegister(); +#endif + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, LineEditNewMesh->text().toLatin1().data()); if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) @@ -541,13 +576,16 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply() // so that it will be destroyed when the entry in study will be removed mesh->UnRegister(); #endif + } } break; } } catch (...) { } - SMESH::UpdateView(); + for ( int i = 0; i < myMeshes.count(); i++ ) + SMESH::Update( (SMESH::FindActorByObject( myMeshes[i] ))->getIO(), true ); + if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) || actionButton == MAKE_MESH_BUTTON ) { mySMESHGUI->updateObjBrowser(true); // new groups may appear @@ -557,7 +595,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply() } Init(false); ConstructorsClicked(GetConstructorId()); - mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); SMESHGUI::Modified(); @@ -683,6 +720,7 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() // clear myActor = 0; QString aString = ""; + onDisplaySimulation(false); myBusy = true; if (myEditCurrentArgument == (QWidget*)LineEditElements) { @@ -701,27 +739,50 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); int nbSel = aList.Extent(); - if (nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) IO = aList.First(); - myMesh = SMESH::GetMeshByIO(IO); - if(myMesh->_is_nil()) - return; - - myActor = SMESH::FindActorByObject(myMesh); - if (!myActor) - myActor = SMESH::FindActorByEntry(IO->getEntry()); - if (!myActor && !CheckBoxMesh->isChecked()) + if (nbSel < 1) return; int aNbUnits = 0; if (myEditCurrentArgument == (QWidget*)LineEditElements) { myElementsId = ""; + myObjects.clear(); + myObjectsNames.clear(); + myMeshes.clear(); + + for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { + Handle(SALOME_InteractiveObject) IO = it.Value(); + + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); + if( aMesh->_is_nil() ) + return; + + myActor = SMESH::FindActorByObject( aMesh ); + if ( !myActor ) + myActor = SMESH::FindActorByEntry( IO->getEntry() ); + if ( !myActor && !CheckBoxMesh->isChecked() ) + return; + + if ( !SMESH::IObjectToInterface( IO )->_is_nil() ) { + if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { + _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); + _PTR(GenericAttribute) anAttr; + if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { + _PTR(AttributeName) aNameAttr( anAttr ); + myObjects << SMESH::IObjectToInterface( IO ); + myObjectsNames << aNameAttr->Value().c_str(); + myMeshes << aMesh; + } + } + } + } // MakeGroups is available if there are groups and "Copy" - if ( myMesh->NbGroups() == 0 ) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + + if ( aNbGroups == 0 ) { MakeGroupsCheck->setChecked(false); MakeGroupsCheck->setEnabled(false); } @@ -731,11 +792,8 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - mySelectedObject = SMESH::IObjectToInterface(IO); - } - else - return; + if ( myObjects.isEmpty() ) + return; // get IDs from mesh /* SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); @@ -778,7 +836,7 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() } */ } else { - aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString); + aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, aList.First(), aString); myElementsId = aString; if (aNbUnits < 1) return; @@ -786,11 +844,21 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() myNbOkElements = true; } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + if ((SMESH::GetMeshByIO(IO))->_is_nil()) + return; + + SMESH_Actor* anActor = SMESH::FindActorByObject(SMESH::GetMeshByIO(IO)); + if (!anActor) + anActor = SMESH::FindActorByEntry(IO->getEntry()); + if (!anActor && !CheckBoxMesh->isChecked()) + return; + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); if (aNbUnits != 1) return; - SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); if (!aMesh) return; @@ -1002,6 +1070,10 @@ void SMESHGUI_SymmetryDlg::onVectorChanged() void SMESHGUI_SymmetryDlg::onActionClicked(int button) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + switch ( button ) { case MOVE_ELEMS_BUTTON: MakeGroupsCheck->setEnabled(false); @@ -1010,18 +1082,12 @@ void SMESHGUI_SymmetryDlg::onActionClicked(int button) case COPY_ELEMS_BUTTON: LineEditNewMesh->setEnabled(false); MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled(myMeshes.isEmpty() || aNbGroups > 0); break; case MAKE_MESH_BUTTON: LineEditNewMesh->setEnabled(true); MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled(myMeshes.isEmpty() || aNbGroups > 0); break; } setNewMeshName(); @@ -1036,13 +1102,13 @@ void SMESHGUI_SymmetryDlg::onActionClicked(int button) void SMESHGUI_SymmetryDlg::setNewMeshName() { LineEditNewMesh->setText(""); - if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) { + if ( LineEditNewMesh->isEnabled() && !myMeshes.isEmpty() ) { QString name; if ( CheckBoxMesh->isChecked() ) { - name = LineEditElements->text(); + name = myObjects.count() > 1 ? "*" : LineEditElements->text(); } else { - _PTR(SObject) meshSO = SMESH::FindSObject( myMesh ); + _PTR(SObject) meshSO = SMESH::FindSObject( myMeshes[0] ); name = meshSO->GetName().c_str(); } if ( !name.isEmpty() ) @@ -1072,7 +1138,7 @@ void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e ) //================================================================================= void SMESHGUI_SymmetryDlg::setFilters() { - if(myMesh->_is_nil()) { + if(myMeshes.isEmpty()) { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), tr("NO_MESH_SELECTED")); @@ -1082,7 +1148,7 @@ void SMESHGUI_SymmetryDlg::setFilters() myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); myFilterDlg->SetSelection(); - myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetMesh( myMeshes[0] ); myFilterDlg->SetSourceWg( LineEditElements ); myFilterDlg->show(); @@ -1139,14 +1205,19 @@ void SMESHGUI_SymmetryDlg::onDisplaySimulation( bool toDisplayPreview ) { bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || ActionGroup->checkedId() == MAKE_MESH_BUTTON ); SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); + QList aMeshPreviewStruct; if(CheckBoxMesh->isChecked()) - aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, copy ); - else - aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, copy ); - - SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); - mySimulation->SetData(aMeshPreviewStruct._retn()); + for ( int i = 0; i < myMeshes.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); + aMeshEditor->MirrorObject(myObjects[i], aMirror, aMirrorType, copy ); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); + aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, copy ); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + setSimulationPreview(aMeshPreviewStruct); } catch (...) { hidePreview(); } diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h index d5a221a2f..bb7b4ecd3 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -56,7 +56,7 @@ class SMESH_LogicalFilter; // class : SMESHGUI_SymmetryDlg // purpose : //================================================================================= -class SMESHGUI_EXPORT SMESHGUI_SymmetryDlg : public SMESHGUI_PreviewDlg +class SMESHGUI_EXPORT SMESHGUI_SymmetryDlg : public SMESHGUI_MultiPreviewDlg { Q_OBJECT @@ -84,10 +84,11 @@ private: QWidget* myEditCurrentArgument; /* Current LineEdit */ - SMESH::SMESH_IDSource_var mySelectedObject; + QList myObjects; + QList myObjectsNames; + QList myMeshes; bool myBusy; - SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index e3946ac21..ca047bcb8 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -52,8 +52,10 @@ #include #include #include +#include // SALOME KERNEL includes +#include #include // OCCT includes @@ -110,10 +112,9 @@ private: // purpose : //================================================================================= SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) : - SMESHGUI_PreviewDlg( theModule ), + SMESHGUI_MultiPreviewDlg( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0), - mySelectedObject(SMESH::SMESH_IDSource::_nil()) + myFilterDlg(0) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR"))); @@ -328,7 +329,6 @@ SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) : connect(SpinBox2_1, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); connect(SpinBox2_2, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); connect(SpinBox2_3, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); - connect(SpinBox2_3, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); //To Connect preview check box @@ -359,6 +359,9 @@ SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg() void SMESHGUI_TranslationDlg::Init (bool ResetControls) { myBusy = false; + myObjects.clear(); + myObjectsNames.clear(); + myMeshes.clear(); myEditCurrentArgument = 0; LineEditElements->clear(); @@ -369,7 +372,6 @@ void SMESHGUI_TranslationDlg::Init (bool ResetControls) buttonApply->setEnabled(false); myActor = 0; - myMesh = SMESH::SMESH_Mesh::_nil(); if (ResetControls) { SpinBox1_1->SetValue(0.0); @@ -503,54 +505,96 @@ bool SMESHGUI_TranslationDlg::ClickOnApply() QStringList anEntryList; try { SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - - myMesh->SetParameters(aParameters.join(":").toLatin1().constData()); switch ( actionButton ) { case MOVE_ELEMS_BUTTON: if(CheckBoxMesh->isChecked()) - aMeshEditor->TranslateObject(mySelectedObject, aVector, false); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->TranslateObject(myObjects[i], aVector, false); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); aMeshEditor->Translate(anElementsId, aVector, false); + } break; case COPY_ELEMS_BUTTON: if ( makeGroups ) { SMESH::ListOfGroups_var groups; - if(CheckBoxMesh->isChecked()) - groups = aMeshEditor->TranslateObjectMakeGroups(mySelectedObject,aVector); - else + if(CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->TranslateObjectMakeGroups(myObjects[i],aVector); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector); + } } else { - if(CheckBoxMesh->isChecked()) - aMeshEditor->TranslateObject(mySelectedObject, aVector, true); - else + if(CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->TranslateObject(myObjects[i], aVector, true); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); aMeshEditor->Translate(anElementsId, aVector, true); + } } break; case MAKE_MESH_BUTTON: { SMESH::SMESH_Mesh_var mesh; - if (CheckBoxMesh->isChecked()) - mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups, - LineEditNewMesh->text().toLatin1().data()); - else - mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups, + if (CheckBoxMesh->isChecked()) { + for ( int i = 0; i < myObjects.count(); i++ ) { + QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->TranslateObjectMakeMesh(myObjects[i], aVector, makeGroups, + aName.toLatin1().data()); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) + anEntryList.append( aSObject->GetID().c_str() ); + +#ifdef WITHGENERICOBJ + // obj has been published in study. Its refcount has been incremented. + // It is safe to decrement its refcount + // so that it will be destroyed when the entry in study will be removed + mesh->UnRegister(); +#endif + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups, LineEditNewMesh->text().toLatin1().data()); if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) anEntryList.append( aSObject->GetID().c_str() ); + #ifdef WITHGENERICOBJ // obj has been published in study. Its refcount has been incremented. // It is safe to decrement its refcount // so that it will be destroyed when the entry in study will be removed mesh->UnRegister(); #endif - } + } + break; + } } } catch (...) { } - SMESH::UpdateView(); + for ( int i = 0; i < myMeshes.count(); i++ ) + SMESH::Update( (SMESH::FindActorByObject( myMeshes[i] ))->getIO(), true ); + if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) || actionButton == MAKE_MESH_BUTTON ) { mySMESHGUI->updateObjBrowser(true); // new groups may appear @@ -561,7 +605,6 @@ bool SMESHGUI_TranslationDlg::ClickOnApply() Init(false); ConstructorsClicked(GetConstructorId()); - mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); SMESHGUI::Modified(); @@ -686,6 +729,7 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() // clear myActor = 0; QString aString = ""; + onDisplaySimulation(false); if (myEditCurrentArgument == (QWidget*)LineEditElements) { LineEditElements->setText(aString); @@ -702,32 +746,51 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); int nbSel = aList.Extent(); - if (nbSel != 1) + if (nbSel < 1) return; - Handle(SALOME_InteractiveObject) IO = aList.First(); - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO); - if (aMesh->_is_nil()) - return; - - SMESH_Actor* anActor = SMESH::FindActorByObject(aMesh); - if (!anActor) - anActor = SMESH::FindActorByEntry(IO->getEntry()); - - if (!anActor && !CheckBoxMesh->isChecked()) - return; - int aNbUnits = 0; - - if (myEditCurrentArgument == (QWidget*)LineEditElements) - { - myMesh = aMesh; - myActor = anActor; - + if (myEditCurrentArgument == (QWidget*)LineEditElements) { myElementsId = ""; + myObjects.clear(); + myObjectsNames.clear(); + myMeshes.clear(); + + for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { + Handle(SALOME_InteractiveObject) IO = it.Value(); + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); + if ( aMesh->_is_nil() ) + return; + + SMESH_Actor* anActor = SMESH::FindActorByObject( aMesh ); + if ( !anActor ) + anActor = SMESH::FindActorByEntry( IO->getEntry() ); + + if ( !anActor && !CheckBoxMesh->isChecked() ) + return; + + if ( !SMESH::IObjectToInterface( IO )->_is_nil() ) { + if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { + _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); + _PTR(GenericAttribute) anAttr; + if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { + _PTR(AttributeName) aNameAttr( anAttr ); + myObjects << SMESH::IObjectToInterface( IO ); + myObjectsNames << aNameAttr->Value().c_str(); + myMeshes << aMesh; + } + } + } + myActor = anActor; + } + // MakeGroups is available if there are groups and "Copy" - if ( myMesh->NbGroups() == 0 ) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + + if ( aNbGroups == 0 ) { MakeGroupsCheck->setChecked(false); MakeGroupsCheck->setEnabled(false); } @@ -737,14 +800,10 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); - - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP - mySelectedObject = SMESH::IObjectToInterface(IO); - } - else - return; + if (myMeshes.isEmpty()) + return; } else { - aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); + aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString); myElementsId = aString; if (aNbUnits < 1) return; @@ -752,6 +811,16 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() myNbOkElements = true; } else { + Handle(SALOME_InteractiveObject) IO = aList.First(); + if ((SMESH::GetMeshByIO(IO))->_is_nil()) + return; + + SMESH_Actor* anActor = SMESH::FindActorByObject(SMESH::GetMeshByIO(IO)); + if (!anActor) + anActor = SMESH::FindActorByEntry(IO->getEntry()); + if (!anActor && !CheckBoxMesh->isChecked()) + return; + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); if (aNbUnits != 1) return; @@ -928,6 +997,10 @@ void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh) void SMESHGUI_TranslationDlg::onActionClicked(int button) { + int aNbGroups = 0; + for ( int i = 0; i < myMeshes.count(); i++ ) + aNbGroups += myMeshes[i]->NbGroups(); + switch ( button ) { case MOVE_ELEMS_BUTTON: MakeGroupsCheck->setEnabled(false); @@ -936,18 +1009,12 @@ void SMESHGUI_TranslationDlg::onActionClicked(int button) case COPY_ELEMS_BUTTON: LineEditNewMesh->setEnabled(false); MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 ); break; case MAKE_MESH_BUTTON: LineEditNewMesh->setEnabled(true); MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS")); - if ( myMesh->_is_nil() || myMesh->NbGroups() > 0) - MakeGroupsCheck->setEnabled(true); - else - MakeGroupsCheck->setEnabled(false); + MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 ); break; } setNewMeshName(); @@ -962,13 +1029,13 @@ void SMESHGUI_TranslationDlg::onActionClicked(int button) void SMESHGUI_TranslationDlg::setNewMeshName() { LineEditNewMesh->setText(""); - if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) { + if ( LineEditNewMesh->isEnabled() && !myMeshes.isEmpty() ) { QString name; if ( CheckBoxMesh->isChecked() ) { - name = LineEditElements->text(); + name = myObjects.count() > 1 ? "*" : LineEditElements->text(); } else { - _PTR(SObject) meshSO = SMESH::FindSObject( myMesh ); + _PTR(SObject) meshSO = SMESH::FindSObject( myMeshes[0] ); name = meshSO->GetName().c_str(); } if ( !name.isEmpty() ) @@ -1007,7 +1074,7 @@ void SMESHGUI_TranslationDlg::keyPressEvent( QKeyEvent* e ) //================================================================================= void SMESHGUI_TranslationDlg::setFilters() { - if(myMesh->_is_nil()) { + if(myMeshes.isEmpty()) { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), tr("NO_MESH_SELECTED")); @@ -1017,7 +1084,7 @@ void SMESHGUI_TranslationDlg::setFilters() myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); myFilterDlg->SetSelection(); - myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetMesh( myMeshes[0] ); myFilterDlg->SetSourceWg( LineEditElements ); myFilterDlg->show(); @@ -1082,14 +1149,19 @@ void SMESHGUI_TranslationDlg::onDisplaySimulation( bool toDisplayPreview ) { bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || ActionGroup->checkedId() == MAKE_MESH_BUTTON ); SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); + QList aMeshPreviewStruct; if(CheckBoxMesh->isChecked()) - aMeshEditor->TranslateObject(mySelectedObject, aVector, copy); - else + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); + aMeshEditor->TranslateObject(myObjects[i], aVector, copy); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); aMeshEditor->Translate(anElementsId, aVector, copy); - - SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); - mySimulation->SetData(aMeshPreviewStruct._retn()); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + setSimulationPreview( aMeshPreviewStruct ); } catch (...) { } diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.h b/src/SMESHGUI/SMESHGUI_TranslationDlg.h index 3fc170444..8b11e0f1e 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.h +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.h @@ -55,7 +55,7 @@ class SMESH_LogicalFilter; // class : SMESHGUI_TranslationDlg // purpose : //================================================================================= -class SMESHGUI_EXPORT SMESHGUI_TranslationDlg : public SMESHGUI_PreviewDlg +class SMESHGUI_EXPORT SMESHGUI_TranslationDlg : public SMESHGUI_MultiPreviewDlg { Q_OBJECT @@ -82,11 +82,12 @@ private: QWidget* myEditCurrentArgument; bool myBusy; - SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; - SMESH::SMESH_IDSource_var mySelectedObject; + QList myMeshes; + QList myObjects; + QList myObjectsNames; QGroupBox* ConstructorsBox; QButtonGroup* GroupConstructors;