0020501: EDF 1098 SMESH: Display only groups, edit a group: can't select face from other group

This commit is contained in:
dmv 2009-10-02 07:17:29 +00:00
parent 7af78cc3d0
commit 425391ca7c
4 changed files with 143 additions and 95 deletions

View File

@ -1245,6 +1245,16 @@ void SMESHGUI::EmitSignalCloseAllDialogs()
emit SignalCloseAllDialogs(); emit SignalCloseAllDialogs();
} }
//=============================================================================
/*!
*
*/
//=============================================================================
void SMESHGUI::EmitSignalVisibilityChanged()
{
emit SignalVisibilityChanged();
}
//============================================================================= //=============================================================================
/*! /*!
* *
@ -1541,8 +1551,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
for ( ; It.More(); It.Next()) { for ( ; It.More(); It.Next()) {
Handle(SALOME_InteractiveObject) IOS = It.Value(); Handle(SALOME_InteractiveObject) IOS = It.Value();
if (IOS->hasEntry()) { if (IOS->hasEntry()) {
if (!SMESH::UpdateView(anAction, IOS->getEntry())) if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
break; // PAL16774 (Crash after display of many groups) break; // PAL16774 (Crash after display of many groups)
}
if (anAction == SMESH::eDisplayOnly) if (anAction == SMESH::eDisplayOnly)
anAction = SMESH::eDisplay; anAction = SMESH::eDisplay;
} }
@ -1550,8 +1562,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
} }
// PAL13338 + PAL15161 --> // PAL13338 + PAL15161 -->
if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
SMESH::UpdateView(); SMESH::UpdateView();
SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
}
// PAL13338 + PAL15161 <-- // PAL13338 + PAL15161 <--
} }
catch (...) { // PAL16774 (Crash after display of many groups) catch (...) { // PAL16774 (Crash after display of many groups)

View File

@ -103,6 +103,7 @@ public :
void EmitSignalDeactivateDialog(); void EmitSignalDeactivateDialog();
void EmitSignalStudyFrameChanged(); void EmitSignalStudyFrameChanged();
void EmitSignalCloseAllDialogs(); void EmitSignalCloseAllDialogs();
void EmitSignalVisibilityChanged();
virtual void contextMenuPopup( const QString&, QMenu*, QString& ); virtual void contextMenuPopup( const QString&, QMenu*, QString& );
virtual void createPreferences(); virtual void createPreferences();
@ -131,6 +132,7 @@ signals:
void SignalDeactivateActiveDialog(); void SignalDeactivateActiveDialog();
void SignalStudyFrameChanged(); void SignalStudyFrameChanged();
void SignalCloseAllDialogs(); void SignalCloseAllDialogs();
void SignalVisibilityChanged();
protected: protected:
void createSMESHAction( const int, void createSMESHAction( const int,

View File

@ -109,8 +109,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ), mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ), myIsBusy( false ),
myNameChanged( false ), myNameChanged( false )
myActor( 0 )
{ {
initDialog( true ); initDialog( true );
if ( !theMesh->_is_nil() ) if ( !theMesh->_is_nil() )
@ -413,6 +412,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create)
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
connect(mySMESHGUI, SIGNAL(SignalVisibilityChanged()), this, SLOT(onVisibilityChanged()));
rb1->setChecked(true); // VSR !!! rb1->setChecked(true); // VSR !!!
onGrpTypeChanged(0); // VSR!!! onGrpTypeChanged(0); // VSR!!!
@ -552,11 +552,12 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
// actor of theGroup, if it is visible, else try // actor of theGroup, if it is visible, else try
// any visible actor of group or submesh of myMesh // any visible actor of group or submesh of myMesh
// commented, because an attempt to set selection on not displayed cells leads to error // commented, because an attempt to set selection on not displayed cells leads to error
//SetAppropriateActor(); SetAppropriateActor();
myActor = SMESH::FindActorByObject(myMesh);
if ( !myActor ) /* SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
myActor = SMESH::FindActorByObject(theGroup); if ( !anActor )
SMESH::SetPickable(myActor); anActor = SMESH::FindActorByObject(theGroup);
SMESH::SetPickable(anActor);*/
int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : 1)); int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : 1));
myGrpTypeGroup->button(grpType)->setChecked(true); myGrpTypeGroup->button(grpType)->setChecked(true);
@ -685,15 +686,21 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
if (mySelectionMode != theMode) { if (mySelectionMode != theMode) {
// [PAL10408] mySelectionMgr->clearSelected(); // [PAL10408] mySelectionMgr->clearSelected();
mySelectionMgr->clearFilters(); mySelectionMgr->clearFilters();
if (myActor) if (myActorsList.count() > 0) {
myActor->SetPointRepresentation(false); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() )
it.next()->SetPointRepresentation(false);
}
else else
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
if (theMode < 4) { if (theMode < 4) {
switch (theMode) { switch (theMode) {
case 0: case 0:
if (myActor) if (myActorsList.count() > 0) {
myActor->SetPointRepresentation(true); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() )
it.next()->SetPointRepresentation(true);
}
else else
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
@ -972,8 +979,8 @@ void SMESHGUI_GroupDlg::onOK()
//================================================================================= //=================================================================================
void SMESHGUI_GroupDlg::onListSelectionChanged() void SMESHGUI_GroupDlg::onListSelectionChanged()
{ {
// MESSAGE( "SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor); //MESSAGE( "SMESHGUI_GroupDlg::onListSelectionChanged(); myActorsList.count() = " << myActorsList.count());
if( myIsBusy || !myActor) return; if( myIsBusy || myActorsList.count() == 0 ) return;
myIsBusy = true; myIsBusy = true;
if (myCurrentLineEdit == 0) { if (myCurrentLineEdit == 0) {
@ -982,9 +989,9 @@ void SMESHGUI_GroupDlg::onListSelectionChanged()
QList<QListWidgetItem*> selItems = myElements->selectedItems(); QList<QListWidgetItem*> selItems = myElements->selectedItems();
QListWidgetItem* anItem; QListWidgetItem* anItem;
foreach(anItem, selItems) aIndexes.Add(anItem->text().toInt()); foreach(anItem, selItems) aIndexes.Add(anItem->text().toInt());
mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false); mySelector->AddOrRemoveIndex(myActorsList.first()->getIO(), aIndexes, false);
SALOME_ListIO aList; SALOME_ListIO aList;
aList.Append(myActor->getIO()); aList.Append(myActorsList.first()->getIO());
mySelectionMgr->setSelectedObjects(aList,false); mySelectionMgr->setSelectedObjects(aList,false);
} }
myIsBusy = false; myIsBusy = false;
@ -1218,13 +1225,12 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
} }
else // !myCurrentLineEdit: local selection of nodes or elements else // !myCurrentLineEdit: local selection of nodes or elements
{ {
if (aNbSel == 1 && myActor && myActor->hasIO()) if (aNbSel == 1 && myActorsList.count() > 0 )
{ {
#ifdef ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
// NPAL19389: create a group with a selection in another group // NPAL19389: create a group with a selection in another group
// Switch myActor to the newly selected one, if the last // Switch myActor to the newly selected one, if the last
// is visible and belongs to group or submesh of myMesh // is visible and belongs to group or submesh of myMesh
Handle(SALOME_InteractiveObject) curIO = myActor->getIO(); /* Handle(SALOME_InteractiveObject) curIO = myActor->getIO();
Handle(SALOME_InteractiveObject) selIO = aList.First(); Handle(SALOME_InteractiveObject) selIO = aList.First();
if (curIO->hasEntry() && selIO->hasEntry()) { if (curIO->hasEntry() && selIO->hasEntry()) {
const char* selEntry = selIO->getEntry(); const char* selEntry = selIO->getEntry();
@ -1251,16 +1257,25 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
} }
} }
} }
} }*/
// NPAL19389 END // NPAL19389 END
#endif // ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
QString aListStr = ""; QString aListStr = "";
int aNbItems = 0; int aNbItems = 0;
if (myTypeId == 0) { if (myTypeId == 0) {
aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedNodes(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
} else { } else {
aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedElements(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
} }
if (aNbItems > 0) { if (aNbItems > 0) {
QListWidgetItem* anItem; QListWidgetItem* anItem;
@ -1282,19 +1297,22 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
} }
} }
if (!myActor) { if (myActorsList.count() == 0) {
if (!myGroup->_is_nil()) if (!myGroup->_is_nil())
myActor = SMESH::FindActorByObject(myGroup); myActorsList.append( SMESH::FindActorByObject(myGroup) );
else if(!myGroupOnGeom->_is_nil()) else if(!myGroupOnGeom->_is_nil())
myActor = SMESH::FindActorByObject(myGroupOnGeom); myActorsList.append( SMESH::FindActorByObject(myGroupOnGeom) );
else else
myActor = SMESH::FindActorByObject(myMesh); myActorsList.append( SMESH::FindActorByObject(myMesh) );
} }
// somehow, if we display the mesh, while selecting from another actor, // somehow, if we display the mesh, while selecting from another actor,
// the mesh becomes pickable, and there is no way to select any element // the mesh becomes pickable, and there is no way to select any element
if (myActor) if (myActorsList.count() > 0) {
SMESH::SetPickable(myActor); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() )
it.next()->SetPickable(true);
}
myIsBusy = false; myIsBusy = false;
} }
@ -1469,7 +1487,7 @@ void SMESHGUI_GroupDlg::onAdd()
int aNbSel = aList.Extent(); int aNbSel = aList.Extent();
if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; if (aNbSel == 0 || myActorsList.count() == 0 || myMesh->_is_nil()) return;
myIsBusy = true; myIsBusy = true;
@ -1503,10 +1521,20 @@ void SMESHGUI_GroupDlg::onAdd()
QString aListStr = ""; QString aListStr = "";
int aNbItems = 0; int aNbItems = 0;
if (myTypeId == 0) { if (myTypeId == 0) {
aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedNodes(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
} }
else { else {
aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedElements(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
} }
if (aNbItems > 0) { if (aNbItems > 0) {
QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts); QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts);
@ -1836,6 +1864,15 @@ void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
onClose(); onClose();
} }
//=================================================================================
// function : onVisibilityChanged()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onVisibilityChanged()
{
SetAppropriateActor();
}
//================================================================================= //=================================================================================
// function : SMESHGUI_GroupDlg::onClose // function : SMESHGUI_GroupDlg::onClose
// purpose : SLOT called when "Close" button pressed. Close dialog // purpose : SLOT called when "Close" button pressed. Close dialog
@ -2158,48 +2195,40 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor()
bool SMESHGUI_GroupDlg::SetAppropriateActor() bool SMESHGUI_GroupDlg::SetAppropriateActor()
{ {
bool isActor = false; bool isActor = false;
myActorsList.clear();
if (myMesh->_is_nil()) return false; if (myMesh->_is_nil()) return false;
SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView(); SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
// try mesh actor if (myGeomGroupBtn->isChecked()) { // try current group on geometry actor
myActor = SMESH::FindActorByObject(myMesh);
if (myActor && myActor->hasIO())
{
isActor = true;
if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
isActor = false;
}
// try current group actor
if (!isActor) {
if (!myGroup->_is_nil()) {
myActor = SMESH::FindActorByObject(myGroup);
if (myActor && myActor->hasIO())
{
isActor = true;
if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
isActor = false;
}
}
}
// try current group on geometry actor
if (!isActor) { if (!isActor) {
if (!myGroupOnGeom->_is_nil()) { if (!myGroupOnGeom->_is_nil()) {
myActor = SMESH::FindActorByObject(myGroupOnGeom); SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom);
if (myActor && myActor->hasIO()) if (anActor && anActor->hasIO())
{ {
isActor = true; isActor = true;
if (aViewWindow && !aViewWindow->isVisible(myActor->getIO())) if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
isActor = false; isActor = false;
else
myActorsList.append(anActor);
} }
} }
} }
} else {
// try mesh actor
SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
if (anActor && anActor->hasIO())
{
isActor = true;
if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
isActor = false;
else
myActorsList.append(anActor);
}
// try any visible actor of group or submesh of current mesh // try any visible actor of group or submesh of current mesh
if (!isActor && aViewWindow) { if (aViewWindow) {
// mesh entry // mesh entry
_PTR(SObject) aSObject = SMESH::FindSObject(myMesh); _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
if (aSObject) { if (aSObject) {
@ -2217,9 +2246,8 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor()
if (anActor && anActor->hasIO()) { if (anActor && anActor->hasIO()) {
Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
if (aViewWindow->isVisible(anIO)) { if (aViewWindow->isVisible(anIO)) {
if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0) { if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0)
myActor = anActor; myActorsList.append(anActor);
isActor = true;
} }
} }
} }
@ -2227,10 +2255,13 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor()
} }
} }
if (isActor) if (myActorsList.count() > 0) {
SMESH::SetPickable(myActor); QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() )
it.next()->SetPickable(true);
}
return isActor; return ( isActor || (myActorsList.count() > 0) );
} }
//======================================================================= //=======================================================================

View File

@ -90,6 +90,7 @@ private slots:
bool onApply(); bool onApply();
void onHelp(); void onHelp();
void onDeactivate(); void onDeactivate();
void onVisibilityChanged();
void onListSelectionChanged(); void onListSelectionChanged();
void onObjectSelectionChanged(); void onObjectSelectionChanged();
@ -137,7 +138,6 @@ private:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SMESH_Actor* myActor; /* Current mesh actor */
int myGrpTypeId; /* Current group type id : standalone or group on geometry */ int myGrpTypeId; /* Current group type id : standalone or group on geometry */
int myTypeId; /* Current type id = radio button id */ int myTypeId; /* Current type id = radio button id */
int myStoredShownEntity; /* Store ShowEntity mode of myMesh */ int myStoredShownEntity; /* Store ShowEntity mode of myMesh */
@ -180,6 +180,7 @@ private:
SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; SMESHGUI_ShapeByMeshOp* myShapeByMeshOp;
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
QList<SMESH_Actor*> myActorsList;
SMESH::SMESH_Group_var myGroup; SMESH::SMESH_Group_var myGroup;
SMESH::SMESH_GroupOnGeom_var myGroupOnGeom; SMESH::SMESH_GroupOnGeom_var myGroupOnGeom;
QList<int> myIdList; QList<int> myIdList;