From: jfa Date: Fri, 31 Aug 2007 08:28:40 +0000 (+0000) Subject: Join modifications from V3_2_0_maintainance branch X-Git-Tag: V4_1_0a1~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f32c96d19e545dbfd3ef2bd01bf27ad7747b2f7;p=modules%2Fsmesh.git Join modifications from V3_2_0_maintainance branch --- diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index db2265289..f37734ac7 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -1190,9 +1190,9 @@ void SMESH_ActorDef::UpdateHighlight(){ myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); }else if(myRepresentation == ePoint || GetPointRepresentation()){ myHighlitableActor->SetHighlited(anIsVisible); - myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->GetExtractUnstructuredGrid()-> SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); + myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint); } } diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index aa7779d0f..2fa4c0fdb 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -305,7 +305,6 @@ void SMESHGUI_ExtrusionDlg::Init (bool ResetControls) myBusy = false; LineEditElements->clear(); - myElementsId = ""; myNbOkElements = 0; myActor = 0; @@ -391,13 +390,6 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() return false; if (myNbOkElements) { - QStringList aListElementsId = QStringList::split(" ", myElementsId, false); - - SMESH::long_array_var anElementsId = new SMESH::long_array; - - anElementsId->length(aListElementsId.count()); - for (int i = 0; i < aListElementsId.count(); i++) - anElementsId[i] = aListElementsId[i].toInt(); SMESH::DirStruct aVector; aVector.PS.x = SpinBox_Dx->GetValue(); @@ -409,7 +401,7 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() try { SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); QApplication::setOverrideCursor(Qt::waitCursor); - aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps); + aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); QApplication::restoreOverrideCursor(); } catch (...) { } @@ -490,26 +482,37 @@ void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText) myNbOkElements = 0; // hilight entered elements/nodes - SMDS_Mesh* aMesh = 0; - if (myActor) - aMesh = myActor->GetObject()->GetMesh(); - if (aMesh) { + if (!myIO.IsNull()) { QStringList aListId = QStringList::split(" ", theNewText, false); - if (send == LineEditElements) { - const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO(); + if (send == LineEditElements) + { + SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0; + SMESH::ElementType SMESHType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE; + SMDSAbs_ElementType SMDSType = GetConstructorId() ? SMDSAbs_Face: SMDSAbs_Edge; + + myElementsId = new SMESH::long_array; + myElementsId->length( aListId.count() ); TColStd_MapOfInteger newIndices; for (int i = 0; i < aListId.count(); i++) { - const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); - if (e) - newIndices.Add(e->GetID()); - myNbOkElements++; + int id = aListId[ i ].toInt(); + bool validId = false; + if ( id > 0 ) { + if ( aMesh ) { + const SMDS_MeshElement * e = aMesh->FindElement( id ); + validId = ( e && e->GetType() == SMDSType ); + } else { + validId = ( myMesh->GetElementType( id, true ) == SMESHType ); + } + } + if ( validId && newIndices.Add( id )) + myElementsId[ newIndices.Extent()-1 ] = id; } - mySelector->AddOrRemoveIndex(anIO, newIndices, false); + myElementsId->length( myNbOkElements = newIndices.Extent() ); + mySelector->AddOrRemoveIndex(myIO, newIndices, false); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->highlight( anIO, true, true ); - myElementsId = theNewText; + aViewWindow->highlight( myIO, true, true ); } } @@ -532,6 +535,7 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() // clear myActor = 0; + myIO.Nullify(); QString aString = ""; // set busy flag @@ -552,81 +556,53 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() myMesh = SMESH::GetMeshByIO(IO); if (myMesh->_is_nil()) return; - + myIO = IO; myActor = SMESH::FindActorByObject(myMesh); - if (!myActor) - return; if (myEditCurrentArgument == LineEditElements) { int aNbElements = 0; - myElementsId = ""; if (CheckBoxMesh->isChecked()) { - int aConstructorId = GetConstructorId(); + SMESH::ElementType neededType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE; SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - if (aConstructorId == 0) { - SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); - - while (anIter->more()) { - const SMDS_MeshEdge * edge = anIter->next(); - if (edge) { - myElementsId += QString(" %1").arg(edge->GetID()); - aNbElements++; - } - } - } else if (aConstructorId == 1) { - SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); - while (anIter->more()) { - const SMDS_MeshFace * face = anIter->next(); - if (face) { - myElementsId += QString(" %1").arg(face->GetID()); - aNbElements++; - } + SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface(IO); + + if (!mesh->_is_nil()) { //MESH + // get elements from mesh + myElementsId = mesh->GetElementsByType(neededType); + aNbElements = myElementsId->length(); + } else { + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::IObjectToInterface(IO); + + if (!aSubMesh->_is_nil()) { //SUBMESH + // get IDs from submesh + myElementsId = aSubMesh->GetElementsByType(neededType); + aNbElements = myElementsId->length(); + } else { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + + if (!aGroup->_is_nil() && aGroup->GetType() == neededType) { // GROUP + // get IDs from smesh group + myElementsId = aGroup->GetListOfID(); + aNbElements = myElementsId->length(); } } - } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - if (aConstructorId == 0) - anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (aConstructorId == 1) - anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); - - for (int i = 0; i < anElementsIds->length(); i++) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbElements = anElementsIds->length(); - } else { // GROUP - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - if ((aConstructorId == 0 && aGroup->GetType() != SMESH::EDGE) || - (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE)) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for (int i = 0; i < anElementsIds->length(); i++) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbElements = anElementsIds->length(); } } else { - aNbElements = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); - myElementsId = aString; + // get indices of selcted elements + TColStd_IndexedMapOfInteger aMapIndex; + mySelector->GetIndex(IO,aMapIndex); + aNbElements = aMapIndex.Extent(); + + myElementsId = new SMESH::long_array; + myElementsId->length( aNbElements ); + aString = ""; + for ( int i = 0; i < aNbElements; ++i ) + aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) ); } if (aNbElements < 1) diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index d1fe0f2b7..51530ef47 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -33,6 +33,7 @@ #include "LightApp_SelectionMgr.h" #include "SUIT_SelectionFilter.h" +#include "Handle_SALOME_InteractiveObject.hxx" // QT Includes #include @@ -81,13 +82,15 @@ private: SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - QString myElementsId; + //QString myElementsId; int myNbOkElements; /* to check when elements are defined */ SVTK_Selector* mySelector; bool myBusy; SMESH::SMESH_Mesh_var myMesh; + SMESH::long_array_var myElementsId; SMESH_Actor* myActor; + Handle(SALOME_InteractiveObject) myIO; SUIT_SelectionFilter* myMeshOrSubMeshOrGroupFilter; // widgets