X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ScaleDlg.cxx;h=9da433c69e549de8b2fd66354087949690232bed;hp=ef39d43731cee40668d2dcab5a34809309833221;hb=0fdf27b77bce6d48fa08a35ded5a5af3d13834e8;hpb=2cbc0e004d9802964be66ecb762c58c126cbb023 diff --git a/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx b/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx index ef39d4373..9da433c69 100644 --- a/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ScaleDlg.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -100,10 +100,6 @@ private: #define SPACING 6 #define MARGIN 11 -//To disable automatic genericobj management, the following line should be commented. -//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx -#define WITHGENERICOBJ - //================================================================================= // class : SMESHGUI_ScaleDlg() // purpose : @@ -429,6 +425,8 @@ void SMESHGUI_ScaleDlg::ConstructorsClicked (int constructorId) connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); QApplication::instance()->processEvents(); + myEditCurrentArgument->hide(); + myEditCurrentArgument->show(); updateGeometry(); resize(100,100); } @@ -481,82 +479,74 @@ bool SMESHGUI_ScaleDlg::ClickOnApply() switch ( actionButton ) { case MOVE_ELEMS_BUTTON: - 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); - } + 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(); + SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); + myMeshes[0]->SetParameters( aParameters.join( ":" ).toLatin1().constData() ); + aMeshEditor->Scale( src, aPoint, aScaleFact, false); + } break; case COPY_ELEMS_BUTTON: 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); - } + 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); - } - } + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->ScaleMakeGroups( src, 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); - } - } + 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); - } - } + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->Scale( src, aPoint, aScaleFact, true); + } + } break; case MAKE_MESH_BUTTON: { - 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()); + 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() ); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); + mesh = aMeshEditor->ScaleMakeMesh( src, aPoint, aScaleFact, 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; } @@ -716,7 +706,7 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() // get selected mesh SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + mySelectionMgr->selectedObjects(aList); int nbSel = aList.Extent(); if (nbSel < 1) @@ -734,25 +724,25 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() Handle(SALOME_InteractiveObject) IO = it.Value(); SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); if ( aMesh->_is_nil() ) - return; + return; myActor = SMESH::FindActorByObject( aMesh ); if ( !myActor ) - myActor = SMESH::FindActorByEntry( IO->getEntry() ); + myActor = SMESH::FindActorByEntry( IO->getEntry() ); if ( !myActor && !CheckBoxMesh->isChecked() ) - return; + 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; - } - } + 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; + } + } } } @@ -772,7 +762,7 @@ void SMESHGUI_ScaleDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); if (myMeshes.isEmpty()) - return; + return; // get IDs from mesh /* SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); @@ -1148,20 +1138,21 @@ void SMESHGUI_ScaleDlg::onDisplaySimulation( bool toDisplayPreview ) { bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || ActionGroup->checkedId() == MAKE_MESH_BUTTON ); SUIT_OverrideCursor aWaitCursor; - 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(); - } + 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); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); + SMESH::SMESH_IDSource_wrap src = aMeshEditor->MakeIDSource(anElementsId, SMESH::ALL); + aMeshEditor->Scale( src, aPoint, aScaleFact, copy); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + setSimulationPreview(aMeshPreviewStruct); } catch (...) { hidePreview(); }