mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-15 10:08:34 +05:00
0021176: EDF 1697 SMESH: Smoothing: impossible to select elements of a group
This commit is contained in:
parent
2fee37828a
commit
36ec1b3d2f
@ -85,6 +85,24 @@
|
|||||||
#define SPACING 6
|
#define SPACING 6
|
||||||
#define MARGIN 11
|
#define MARGIN 11
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class BusyLocker
|
||||||
|
\brief Simple 'busy state' flag locker.
|
||||||
|
\internal
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BusyLocker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor. Sets passed boolean flag to \c true.
|
||||||
|
BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
|
||||||
|
//! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
|
||||||
|
~BusyLocker() { myBusy = false; }
|
||||||
|
private:
|
||||||
|
bool& myBusy; //! External 'busy state' boolean flag
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : SMESHGUI_SmoothingDlg()
|
// function : SMESHGUI_SmoothingDlg()
|
||||||
// purpose : constructor
|
// purpose : constructor
|
||||||
@ -244,12 +262,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
|
|||||||
mySMESHGUI->SetActiveDialogBox(this);
|
mySMESHGUI->SetActiveDialogBox(this);
|
||||||
|
|
||||||
// Costruction of the logical filter for the elements: mesh/sub-mesh/group
|
// Costruction of the logical filter for the elements: mesh/sub-mesh/group
|
||||||
SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
|
|
||||||
SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
|
|
||||||
|
|
||||||
QList<SUIT_SelectionFilter*> aListOfFilters;
|
QList<SUIT_SelectionFilter*> aListOfFilters;
|
||||||
if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
|
aListOfFilters << new SMESH_TypeFilter(MESHorSUBMESH) << new SMESH_TypeFilter(GROUP);
|
||||||
if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
|
|
||||||
|
|
||||||
myMeshOrSubMeshOrGroupFilter =
|
myMeshOrSubMeshOrGroupFilter =
|
||||||
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
|
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
|
||||||
@ -309,10 +323,10 @@ void SMESHGUI_SmoothingDlg::Init()
|
|||||||
LineEditElements->setFocus();
|
LineEditElements->setFocus();
|
||||||
LineEditElements->clear();
|
LineEditElements->clear();
|
||||||
LineEditNodes->clear();
|
LineEditNodes->clear();
|
||||||
myElementsId = "";
|
|
||||||
myNbOkElements = 0;
|
myNbOkElements = 0;
|
||||||
myNbOkNodes = 0;
|
myNbOkNodes = 0;
|
||||||
myActor = 0;
|
myActor = 0;
|
||||||
|
myIO.Nullify();
|
||||||
myMesh = SMESH::SMESH_Mesh::_nil();
|
myMesh = SMESH::SMESH_Mesh::_nil();
|
||||||
|
|
||||||
CheckBoxMesh->setChecked(false);
|
CheckBoxMesh->setChecked(false);
|
||||||
@ -332,7 +346,7 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
|
if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
|
||||||
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
|
QStringList aListElementsId = LineEditElements->text().split(" ", QString::SkipEmptyParts);
|
||||||
QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
|
QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
|
||||||
|
|
||||||
SMESH::long_array_var anElementsId = new SMESH::long_array;
|
SMESH::long_array_var anElementsId = new SMESH::long_array;
|
||||||
@ -389,14 +403,7 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aResult) {
|
if (aResult) {
|
||||||
if ( myActor ) {
|
SMESH::Update(myIO, SMESH::eDisplay);
|
||||||
Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
|
|
||||||
SALOME_ListIO aList;
|
|
||||||
aList.Append(anIO);
|
|
||||||
mySelectionMgr->setSelectedObjects(aList, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
SMESH::UpdateView();
|
|
||||||
SMESHGUI::Modified();
|
SMESHGUI::Modified();
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
@ -470,10 +477,10 @@ void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
|
|||||||
QLineEdit* send = (QLineEdit*)sender();
|
QLineEdit* send = (QLineEdit*)sender();
|
||||||
|
|
||||||
// return if busy
|
// return if busy
|
||||||
if (myBusy) return;
|
if (myBusy || myIO.IsNull()) return;
|
||||||
|
|
||||||
// set busy flag
|
// set busy flag
|
||||||
myBusy = true;
|
BusyLocker lock( myBusy );
|
||||||
|
|
||||||
if (send == LineEditElements)
|
if (send == LineEditElements)
|
||||||
myNbOkElements = 0;
|
myNbOkElements = 0;
|
||||||
@ -484,40 +491,37 @@ void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
|
|||||||
buttonApply->setEnabled(false);
|
buttonApply->setEnabled(false);
|
||||||
|
|
||||||
// hilight entered elements/nodes
|
// hilight entered elements/nodes
|
||||||
SMDS_Mesh* aMesh = 0;
|
SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
|
||||||
if (myActor)
|
QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
|
||||||
aMesh = myActor->GetObject()->GetMesh();
|
|
||||||
|
|
||||||
if (aMesh) {
|
if (send == LineEditElements) {
|
||||||
|
TColStd_MapOfInteger newIndices;
|
||||||
QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
|
for (int i = 0; i < aListId.count(); i++) {
|
||||||
|
int id = aListId[ i ].toInt();
|
||||||
if (send == LineEditElements) {
|
if ( id > 0 ) {
|
||||||
const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
|
bool validId = aMesh ? ( aMesh->FindElement( id ) != 0 ) : ( myMesh->GetElementType( id, true ) != SMESH::EDGE );
|
||||||
TColStd_MapOfInteger newIndices;
|
if ( validId )
|
||||||
for (int i = 0; i < aListId.count(); i++) {
|
newIndices.Add( id );
|
||||||
const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
|
|
||||||
if (e)
|
|
||||||
newIndices.Add(e->GetID());
|
|
||||||
myNbOkElements++;
|
|
||||||
}
|
}
|
||||||
mySelector->AddOrRemoveIndex(anIO, newIndices, false);
|
myNbOkElements = newIndices.Extent();
|
||||||
|
mySelector->AddOrRemoveIndex(myIO, newIndices, false);
|
||||||
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
||||||
aViewWindow->highlight( anIO, true, true );
|
aViewWindow->highlight( myIO, true, true );
|
||||||
myElementsId = theNewText;
|
}
|
||||||
|
}
|
||||||
} else if (send == LineEditNodes) {
|
else if (send == LineEditNodes) {
|
||||||
TColStd_MapOfInteger newIndices;
|
TColStd_MapOfInteger newIndices;
|
||||||
|
for (int i = 0; i < aListId.count(); i++) {
|
||||||
for (int i = 0; i < aListId.count(); i++) {
|
int id = aListId[ i ].toInt();
|
||||||
const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
|
if ( id > 0 ) {
|
||||||
if (n)
|
bool validId = aMesh ? ( aMesh->FindNode( id ) != 0 ) : ( myMesh->GetElementType( id, false ) != SMESH::EDGE );
|
||||||
newIndices.Add(n->GetID());
|
if ( validId )
|
||||||
myNbOkNodes++;
|
newIndices.Add( id );
|
||||||
}
|
}
|
||||||
mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
|
myNbOkNodes = newIndices.Extent();
|
||||||
|
mySelector->AddOrRemoveIndex(myIO, newIndices, false);
|
||||||
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
||||||
aViewWindow->highlight( myActor->getIO(), true, true );
|
aViewWindow->highlight( myIO, true, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,8 +529,6 @@ void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
|
|||||||
buttonOk->setEnabled(true);
|
buttonOk->setEnabled(true);
|
||||||
buttonApply->setEnabled(true);
|
buttonApply->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
myBusy = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -540,19 +542,23 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
|
|||||||
// clear
|
// clear
|
||||||
QString aString = "";
|
QString aString = "";
|
||||||
|
|
||||||
myBusy = true;
|
// set busy flag
|
||||||
|
BusyLocker lock( myBusy );
|
||||||
|
|
||||||
if (myEditCurrentArgument == LineEditElements ||
|
if (myEditCurrentArgument == LineEditElements ||
|
||||||
myEditCurrentArgument == LineEditNodes) {
|
myEditCurrentArgument == LineEditNodes) {
|
||||||
myEditCurrentArgument->setText(aString);
|
myEditCurrentArgument->setText(aString);
|
||||||
if (myEditCurrentArgument == LineEditElements)
|
if (myEditCurrentArgument == LineEditElements) {
|
||||||
myNbOkElements = 0;
|
myNbOkElements = 0;
|
||||||
else
|
myActor = 0;
|
||||||
|
myIO.Nullify();
|
||||||
|
}
|
||||||
|
else {
|
||||||
myNbOkNodes = 0;
|
myNbOkNodes = 0;
|
||||||
|
}
|
||||||
buttonOk->setEnabled(false);
|
buttonOk->setEnabled(false);
|
||||||
buttonApply->setEnabled(false);
|
buttonApply->setEnabled(false);
|
||||||
myActor = 0;
|
|
||||||
}
|
}
|
||||||
myBusy = false;
|
|
||||||
|
|
||||||
if (!GroupButtons->isEnabled()) // inactive
|
if (!GroupButtons->isEnabled()) // inactive
|
||||||
return;
|
return;
|
||||||
@ -565,50 +571,45 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Handle(SALOME_InteractiveObject) IO = aList.First();
|
Handle(SALOME_InteractiveObject) IO = aList.First();
|
||||||
myMesh = SMESH::GetMeshByIO(IO);
|
|
||||||
if (myMesh->_is_nil())
|
|
||||||
return;
|
|
||||||
|
|
||||||
myActor = SMESH::FindActorByObject(myMesh);
|
|
||||||
if (!myActor && !CheckBoxMesh->isChecked())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int aNbUnits = 0;
|
|
||||||
|
|
||||||
if (myEditCurrentArgument == LineEditElements) {
|
if (myEditCurrentArgument == LineEditElements) {
|
||||||
myElementsId = "";
|
myMesh = SMESH::GetMeshByIO(IO);
|
||||||
|
if (myMesh->_is_nil())
|
||||||
|
return;
|
||||||
|
myIO = IO;
|
||||||
|
myActor = SMESH::FindActorByObject(myMesh);
|
||||||
|
|
||||||
if (CheckBoxMesh->isChecked()) {
|
if (CheckBoxMesh->isChecked()) {
|
||||||
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
|
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
|
||||||
|
|
||||||
if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
|
SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( myIO );
|
||||||
mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
|
if ( !CORBA::is_nil( obj ) )
|
||||||
|
mySelectedObject = obj;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
myNbOkElements = true;
|
||||||
} else {
|
} else {
|
||||||
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
|
// get indices of selected elements
|
||||||
myElementsId = aString;
|
TColStd_IndexedMapOfInteger aMapIndex;
|
||||||
if (aNbUnits < 1)
|
mySelector->GetIndex(IO,aMapIndex);
|
||||||
|
myNbOkElements = aMapIndex.Extent();
|
||||||
|
|
||||||
|
if (myNbOkElements < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QStringList elements;
|
||||||
|
for ( int i = 0; i < myNbOkElements; ++i )
|
||||||
|
elements << QString::number( aMapIndex( i+1 ) );
|
||||||
|
aString = elements.join(" ");
|
||||||
}
|
}
|
||||||
} else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
|
} else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myIO == IO ) {
|
||||||
myNbOkNodes = 0;
|
myNbOkNodes = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
|
||||||
aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
|
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myBusy = true;
|
|
||||||
myEditCurrentArgument->setText(aString);
|
myEditCurrentArgument->setText(aString);
|
||||||
myEditCurrentArgument->repaint();
|
myEditCurrentArgument->repaint();
|
||||||
myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
|
myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
|
||||||
myEditCurrentArgument->setEnabled(true);
|
myEditCurrentArgument->setEnabled(true);
|
||||||
myBusy = false;
|
|
||||||
|
|
||||||
// OK
|
|
||||||
if (myEditCurrentArgument == LineEditElements)
|
|
||||||
myNbOkElements = true;
|
|
||||||
else if (myEditCurrentArgument == LineEditNodes)
|
|
||||||
myNbOkNodes = true;
|
|
||||||
|
|
||||||
if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
|
if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
|
||||||
buttonOk->setEnabled(true);
|
buttonOk->setEnabled(true);
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
// SALOME GUI includes
|
||||||
|
#include <SALOME_InteractiveObject.hxx>
|
||||||
|
|
||||||
// IDL includes
|
// IDL includes
|
||||||
#include <SALOMEconfig.h>
|
#include <SALOMEconfig.h>
|
||||||
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
||||||
@ -79,7 +82,6 @@ private:
|
|||||||
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
|
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
|
||||||
SMESHGUI_IdValidator* myIdValidator;
|
SMESHGUI_IdValidator* myIdValidator;
|
||||||
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
|
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
|
||||||
QString myElementsId;
|
|
||||||
int myNbOkElements; /* to check when elements are defined */
|
int myNbOkElements; /* to check when elements are defined */
|
||||||
int myNbOkNodes; /* to check when fixed nodes are defined */
|
int myNbOkNodes; /* to check when fixed nodes are defined */
|
||||||
int myConstructorId; /* Current constructor id = radio button id */
|
int myConstructorId; /* Current constructor id = radio button id */
|
||||||
@ -91,6 +93,7 @@ private:
|
|||||||
bool myBusy;
|
bool myBusy;
|
||||||
SMESH::SMESH_Mesh_var myMesh;
|
SMESH::SMESH_Mesh_var myMesh;
|
||||||
SMESH_Actor* myActor;
|
SMESH_Actor* myActor;
|
||||||
|
Handle(SALOME_InteractiveObject) myIO;
|
||||||
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
|
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
|
||||||
|
|
||||||
QGroupBox* GroupConstructors;
|
QGroupBox* GroupConstructors;
|
||||||
|
Loading…
Reference in New Issue
Block a user