mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-02 21:00:34 +05:00
Bug 0019389: Impossible to create a group with a selection in another group.
This commit is contained in:
parent
4324ec1b43
commit
c174b59dd5
@ -63,6 +63,10 @@
|
|||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
|
// VTK Includes
|
||||||
|
#include <vtkRenderer.h>
|
||||||
|
#include <vtkActorCollection.h>
|
||||||
|
|
||||||
// OCCT Includes
|
// OCCT Includes
|
||||||
#include <TColStd_MapOfInteger.hxx>
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
|
||||||
@ -485,8 +489,10 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
|
|||||||
myGroup = SMESH::SMESH_Group::_nil();
|
myGroup = SMESH::SMESH_Group::_nil();
|
||||||
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
|
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
|
||||||
|
|
||||||
myActor = SMESH::FindActorByObject(myMesh);
|
// NPAL19389: create a group with a selection in another group
|
||||||
SMESH::SetPickable(myActor);
|
// set actor of myMesh, if it is visible, else try
|
||||||
|
// any visible actor of group or submesh of myMesh
|
||||||
|
SetAppropriateActor();
|
||||||
|
|
||||||
setDefaultGroupColor();
|
setDefaultGroupColor();
|
||||||
|
|
||||||
@ -536,6 +542,12 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
|
|||||||
|
|
||||||
if (!myGroup->_is_nil())
|
if (!myGroup->_is_nil())
|
||||||
{
|
{
|
||||||
|
// NPAL19389: create a group with a selection in another group
|
||||||
|
// set actor of myMesh, if it is visible, else set
|
||||||
|
// actor of myGroup, if it is visible, else try
|
||||||
|
// any visible actor of group or submesh of myMesh
|
||||||
|
// commented, because an attempt to set selection on not displayed cells leads to error
|
||||||
|
//SetAppropriateActor();
|
||||||
myActor = SMESH::FindActorByObject(myMesh);
|
myActor = SMESH::FindActorByObject(myMesh);
|
||||||
if ( !myActor )
|
if ( !myActor )
|
||||||
myActor = SMESH::FindActorByObject(myGroup);
|
myActor = SMESH::FindActorByObject(myGroup);
|
||||||
@ -549,6 +561,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
|
|||||||
setSelectionMode(aType);
|
setSelectionMode(aType);
|
||||||
myTypeId = aType;
|
myTypeId = aType;
|
||||||
|
|
||||||
|
setShowEntityMode(); // depends on myTypeId
|
||||||
|
|
||||||
myIdList.clear();
|
myIdList.clear();
|
||||||
if (!myGroup->IsEmpty()) {
|
if (!myGroup->IsEmpty()) {
|
||||||
SMESH::long_array_var anElements = myGroup->GetListOfID();
|
SMESH::long_array_var anElements = myGroup->GetListOfID();
|
||||||
@ -566,9 +580,15 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
|
|||||||
|
|
||||||
if ( !myGroupOnGeom->_is_nil() )
|
if ( !myGroupOnGeom->_is_nil() )
|
||||||
{
|
{
|
||||||
|
// NPAL19389: create a group with a selection in another group
|
||||||
|
// set actor of myMesh, if it is visible, else set
|
||||||
|
// actor of myGroupOnGeom, if it is visible, else try
|
||||||
|
// any visible actor of group or submesh of myMesh
|
||||||
|
// commented, because an attempt to set selection on not displayed cells leads to error
|
||||||
|
//SetAppropriateActor();
|
||||||
myActor = SMESH::FindActorByObject(myMesh);
|
myActor = SMESH::FindActorByObject(myMesh);
|
||||||
if ( !myActor )
|
if ( !myActor )
|
||||||
myActor = SMESH::FindActorByObject(myGroup);
|
myActor = SMESH::FindActorByObject(myGroupOnGeom);
|
||||||
SMESH::SetPickable(myActor);
|
SMESH::SetPickable(myActor);
|
||||||
|
|
||||||
myGrpTypeGroup->setButton(1);
|
myGrpTypeGroup->setButton(1);
|
||||||
@ -973,11 +993,13 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
int aNbSel = aList.Extent();
|
int aNbSel = aList.Extent();
|
||||||
myElements->clearSelection();
|
myElements->clearSelection();
|
||||||
|
|
||||||
if (myCurrentLineEdit) {
|
if (myCurrentLineEdit)
|
||||||
|
{
|
||||||
myCurrentLineEdit->setText("");
|
myCurrentLineEdit->setText("");
|
||||||
QString aString = "";
|
QString aString = "";
|
||||||
|
|
||||||
if (myCurrentLineEdit == myMeshGroupLine) {
|
if (myCurrentLineEdit == myMeshGroupLine)
|
||||||
|
{
|
||||||
mySelectSubMesh->setEnabled(false);
|
mySelectSubMesh->setEnabled(false);
|
||||||
mySelectGroup->setEnabled(false);
|
mySelectGroup->setEnabled(false);
|
||||||
myGroupLine->setText("");
|
myGroupLine->setText("");
|
||||||
@ -1021,8 +1043,10 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
}
|
}
|
||||||
myGroup = SMESH::SMESH_Group::_nil();
|
myGroup = SMESH::SMESH_Group::_nil();
|
||||||
|
|
||||||
myActor = SMESH::FindActorByObject(myMesh);
|
// NPAL19389: create a group with a selection in another group
|
||||||
SMESH::SetPickable(myActor);
|
// set actor of myMesh, if it is visible, else try
|
||||||
|
// any visible actor of group or submesh of myMesh
|
||||||
|
SetAppropriateActor();
|
||||||
|
|
||||||
aString = aList.First()->getName();
|
aString = aList.First()->getName();
|
||||||
myMeshGroupLine->setText(aString);
|
myMeshGroupLine->setText(aString);
|
||||||
@ -1069,9 +1093,9 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
|
|
||||||
myIsBusy = false;
|
myIsBusy = false;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} else if (myCurrentLineEdit == myGeomGroupLine) {
|
else if (myCurrentLineEdit == myGeomGroupLine)
|
||||||
|
{
|
||||||
myGeomObjects = new GEOM::ListOfGO();
|
myGeomObjects = new GEOM::ListOfGO();
|
||||||
|
|
||||||
// The mesh SObject
|
// The mesh SObject
|
||||||
@ -1092,8 +1116,8 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO anIt (aList);
|
SALOME_ListIteratorOfListIO anIt (aList);
|
||||||
for (; anIt.More(); anIt.Next()) {
|
for (; anIt.More(); anIt.Next())
|
||||||
|
{
|
||||||
testResult = Standard_False;
|
testResult = Standard_False;
|
||||||
aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
|
aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
|
||||||
|
|
||||||
@ -1101,7 +1125,6 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
if (!testResult || CORBA::is_nil(aGeomGroup))
|
if (!testResult || CORBA::is_nil(aGeomGroup))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
// Check if group constructed on the same shape as a mesh or on its child
|
// Check if group constructed on the same shape as a mesh or on its child
|
||||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||||
GEOM::GEOM_IGroupOperations_var anOp =
|
GEOM::GEOM_IGroupOperations_var anOp =
|
||||||
@ -1176,9 +1199,46 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
}
|
||||||
|
else // !myCurrentLineEdit: local selection of nodes or elements
|
||||||
|
{
|
||||||
|
if (aNbSel == 1 && myActor && myActor->hasIO())
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
|
||||||
|
// NPAL19389: create a group with a selection in another group
|
||||||
|
// Switch myActor to the newly selected one, if the last
|
||||||
|
// is visible and belongs to group or submesh of myMesh
|
||||||
|
Handle(SALOME_InteractiveObject) curIO = myActor->getIO();
|
||||||
|
Handle(SALOME_InteractiveObject) selIO = aList.First();
|
||||||
|
if (curIO->hasEntry() && selIO->hasEntry()) {
|
||||||
|
const char* selEntry = selIO->getEntry();
|
||||||
|
if (strcmp(curIO->getEntry(), selEntry) != 0) {
|
||||||
|
// different objects: selected and myActor
|
||||||
|
SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
|
||||||
|
if (aViewWindow && aViewWindow->isVisible(selIO)) {
|
||||||
|
// newly selected actor is visible
|
||||||
|
|
||||||
|
// mesh entry
|
||||||
|
_PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
|
||||||
|
if (aSObject) {
|
||||||
|
CORBA::String_var meshEntry = aSObject->GetID().c_str();
|
||||||
|
int len = strlen(meshEntry);
|
||||||
|
|
||||||
|
if (strncmp(selEntry, meshEntry, len) == 0) {
|
||||||
|
// selected object is myMesh or a part of it
|
||||||
|
SMESH_Actor* anActor = SMESH::FindActorByEntry(selEntry);
|
||||||
|
if (anActor) {
|
||||||
|
myActor = anActor;
|
||||||
|
SMESH::SetPickable(myActor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// NPAL19389 END
|
||||||
|
#endif // ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
|
||||||
|
|
||||||
} else {
|
|
||||||
if (aNbSel == 1 && myActor ) {
|
|
||||||
QString aListStr = "";
|
QString aListStr = "";
|
||||||
int aNbItems = 0;
|
int aNbItems = 0;
|
||||||
if (myTypeId == 0) {
|
if (myTypeId == 0) {
|
||||||
@ -1206,6 +1266,11 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
myActor = SMESH::FindActorByObject(myMesh);
|
myActor = SMESH::FindActorByObject(myMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// somehow, if we display the mesh, while selecting from another actor,
|
||||||
|
// the mesh becomes pickable, and there is no way to select any element
|
||||||
|
if (myActor)
|
||||||
|
SMESH::SetPickable(myActor);
|
||||||
|
|
||||||
myIsBusy = false;
|
myIsBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1398,7 +1463,6 @@ void SMESHGUI_GroupDlg::onAdd()
|
|||||||
mySelector->SetSelectionMode(ActorSelection);
|
mySelector->SetSelectionMode(ActorSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (myCurrentLineEdit == 0) {
|
if (myCurrentLineEdit == 0) {
|
||||||
//if (aNbSel != 1) { myIsBusy = false; return; }
|
//if (aNbSel != 1) { myIsBusy = false; return; }
|
||||||
QString aListStr = "";
|
QString aListStr = "";
|
||||||
@ -1716,7 +1780,8 @@ void SMESHGUI_GroupDlg::onHelp()
|
|||||||
{
|
{
|
||||||
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
||||||
if (app)
|
if (app)
|
||||||
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
|
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""),
|
||||||
|
myHelpFileName);
|
||||||
else {
|
else {
|
||||||
QString platform;
|
QString platform;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -1724,7 +1789,8 @@ void SMESHGUI_GroupDlg::onHelp()
|
|||||||
#else
|
#else
|
||||||
platform = "application";
|
platform = "application";
|
||||||
#endif
|
#endif
|
||||||
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
SUIT_MessageBox::warn1
|
||||||
|
(0, QObject::tr("WRN_WARNING"),
|
||||||
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
||||||
arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
|
||||||
QObject::tr("BUT_OK"));
|
QObject::tr("BUT_OK"));
|
||||||
@ -2002,11 +2068,95 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor()
|
|||||||
setGroupQColor( aQColor );
|
setGroupQColor( aQColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : SetAppropriateActor()
|
||||||
|
// purpose : Find more appropriate of visible actors, set it to myActor, allow picking
|
||||||
|
// NPAL19389: create a group with a selection in another group.
|
||||||
|
// if mesh actor is not visible - find any first visible group or submesh
|
||||||
|
//=================================================================================
|
||||||
|
bool SMESHGUI_GroupDlg::SetAppropriateActor()
|
||||||
|
{
|
||||||
|
bool isActor = false;
|
||||||
|
|
||||||
|
if (myMesh->_is_nil()) return false;
|
||||||
|
|
||||||
|
SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
|
||||||
|
|
||||||
|
// try mesh 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 (!myGroupOnGeom->_is_nil()) {
|
||||||
|
myActor = SMESH::FindActorByObject(myGroupOnGeom);
|
||||||
|
if (myActor && myActor->hasIO())
|
||||||
|
{
|
||||||
|
isActor = true;
|
||||||
|
if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
|
||||||
|
isActor = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// try any visible actor of group or submesh of current mesh
|
||||||
|
if (!isActor && aViewWindow) {
|
||||||
|
// mesh entry
|
||||||
|
_PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
|
||||||
|
if (aSObject) {
|
||||||
|
CORBA::String_var meshEntry = aSObject->GetID().c_str();
|
||||||
|
int len = strlen(meshEntry);
|
||||||
|
|
||||||
|
// iterate on all actors in current view window, search for
|
||||||
|
// any visible actor, that belongs to group or submesh of current mesh
|
||||||
|
vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors();
|
||||||
|
aCollection->InitTraversal();
|
||||||
|
for (vtkActor *anAct = aCollection->GetNextActor();
|
||||||
|
anAct && !isActor;
|
||||||
|
anAct = aCollection->GetNextActor())
|
||||||
|
{
|
||||||
|
SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct);
|
||||||
|
if (anActor && anActor->hasIO()) {
|
||||||
|
Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
|
||||||
|
if (aViewWindow->isVisible(anIO)) {
|
||||||
|
if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0) {
|
||||||
|
myActor = anActor;
|
||||||
|
isActor = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isActor)
|
||||||
|
SMESH::SetPickable(myActor);
|
||||||
|
|
||||||
|
return isActor;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : setShowEntityMode
|
//function : setShowEntityMode
|
||||||
//purpose : make shown only entity corresponding to my type
|
//purpose : make shown only entity corresponding to my type
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void SMESHGUI_GroupDlg::setShowEntityMode()
|
void SMESHGUI_GroupDlg::setShowEntityMode()
|
||||||
{
|
{
|
||||||
if ( !myMesh->_is_nil() ) {
|
if ( !myMesh->_is_nil() ) {
|
||||||
@ -2027,7 +2177,6 @@ void SMESHGUI_GroupDlg::setShowEntityMode()
|
|||||||
//function : restoreShowEntityMode
|
//function : restoreShowEntityMode
|
||||||
//purpose : restore ShowEntity mode of myActor
|
//purpose : restore ShowEntity mode of myActor
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void SMESHGUI_GroupDlg::restoreShowEntityMode()
|
void SMESHGUI_GroupDlg::restoreShowEntityMode()
|
||||||
{
|
{
|
||||||
if ( myStoredShownEntity && !myMesh->_is_nil() ) {
|
if ( myStoredShownEntity && !myMesh->_is_nil() ) {
|
||||||
|
@ -132,6 +132,7 @@ private:
|
|||||||
void setSelectionMode(int theMode);
|
void setSelectionMode(int theMode);
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
void updateGeomPopup();
|
void updateGeomPopup();
|
||||||
|
bool SetAppropriateActor();
|
||||||
void setShowEntityMode();
|
void setShowEntityMode();
|
||||||
void restoreShowEntityMode();
|
void restoreShowEntityMode();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user