-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SMESH SMESHGUI : GUI for SMESH component
-// File : SMESHGUI_GroupDlg.cxx
-// Author : Natalia KOPNOVA, Open CASCADE S.A.S.
-// SMESH includes
+
+// SMESH SMESHGUI : GUI for SMESH component
+// File : SMESHGUI_GroupDlg.cxx
+// Author : Natalia KOPNOVA, Open CASCADE S.A.S.
+// SMESH includes
//
#include "SMESHGUI_GroupDlg.h"
#include <SVTK_ViewWindow.h>
+#include <VTKViewer_Algorithm.h>
+
// SALOME KERNEL includes
#include <SALOMEDSClient_Study.hxx>
#define SPACING 6
#define MARGIN 11
+enum grpSelectionMode {
+ grpNoSelection = -1,
+ grpNodeSelection = 0,
+ grpEdgeSelection = 1,
+ grpFaceSelection = 2,
+ grpVolumeSelection = 3,
+ grpSubMeshSelection = 4,
+ grpGroupSelection = 5,
+ grpMeshSelection = 6,
+ grpGeomSelection = 7,
+ grpAllSelection = 8,
+};
+
//=================================================================================
// function : SMESHGUI_GroupDlg()
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
- SMESH::SMESH_Mesh_ptr theMesh )
+ SMESH::SMESH_Mesh_ptr theMesh )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ),
- myNameChanged( false ),
- myActor( 0 )
+ myNameChanged( false )
{
initDialog( true );
if ( !theMesh->_is_nil() )
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
- SMESH::SMESH_GroupBase_ptr theGroup,
+ SMESH::SMESH_GroupBase_ptr theGroup,
const bool theIsConvert )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectGroup->setEnabled( false );
myCurrentLineEdit = myMeshGroupLine;
- setSelectionMode( 5 );
+ setSelectionMode( grpGroupSelection );
}
}
aContentBoxLayout->setMargin( MARGIN );
aContentBoxLayout->setSpacing( SPACING );
- QLabel* aLabel = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox );
+ mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), aContentBox );
+
+ myElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox );
myElements = new QListWidget( aContentBox );
myElements->setSelectionMode( QListWidget::ExtendedSelection );
myFilter = new QPushButton( tr( "SMESH_BUT_FILTER" ), aContentBox );
- QPushButton* aAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox );
- QPushButton* aRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox );
- QPushButton* aSortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox );
-
- aContentBoxLayout->addWidget( aLabel, 0, 0 );
- aContentBoxLayout->addWidget( myElements, 1, 0, 6, 1 );
- aContentBoxLayout->addWidget( myFilter, 1, 1 );
- aContentBoxLayout->addWidget( aAddBtn, 3, 1 );
- aContentBoxLayout->addWidget( aRemoveBtn, 4, 1 );
- aContentBoxLayout->addWidget( aSortBtn, 6, 1 );
+ myAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox );
+ myRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox );
+ mySortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox );
+
+ aContentBoxLayout->addWidget( mySelectAll, 0, 0 );
+ aContentBoxLayout->addWidget( myElementsLab, 1, 0 );
+ aContentBoxLayout->addWidget( myElements, 2, 0, 6, 1 );
+ aContentBoxLayout->addWidget( myFilter, 2, 1 );
+ aContentBoxLayout->addWidget( myAddBtn, 4, 1 );
+ aContentBoxLayout->addWidget( myRemoveBtn, 5, 1 );
+ aContentBoxLayout->addWidget( mySortBtn, 7, 1 );
aContentBoxLayout->setColumnStretch( 0, 1 );
- aContentBoxLayout->setRowStretch( 2, 1 );
- aContentBoxLayout->setRowStretch( 5, 1 );
+ aContentBoxLayout->setRowStretch( 3, 1 );
+ aContentBoxLayout->setRowStretch( 6, 1 );
/***************************************************************/
- QGroupBox* aSelectBox = new QGroupBox( tr( "SMESH_SELECT_FROM" ), wg1 );
- QGridLayout* aSelectBoxLayout = new QGridLayout( aSelectBox );
- aSelectBoxLayout->setMargin( MARGIN );
- aSelectBoxLayout->setSpacing( SPACING );
+ mySelectBox = new QGroupBox( tr( "SMESH_SELECT_FROM" ), wg1 );
+ QGridLayout* mySelectBoxLayout = new QGridLayout( mySelectBox );
+ mySelectBoxLayout->setMargin( MARGIN );
+ mySelectBoxLayout->setSpacing( SPACING );
- mySelectSubMesh = new QCheckBox( tr( "SMESH_SUBMESH" ), aSelectBox );
- mySubMeshBtn = new QPushButton( aSelectBox );
+ mySelectSubMesh = new QCheckBox( tr( "SMESH_SUBMESH" ), mySelectBox );
+ mySubMeshBtn = new QPushButton( mySelectBox );
mySubMeshBtn->setIcon( image0 );
- mySubMeshLine = new QLineEdit( aSelectBox );
+ mySubMeshLine = new QLineEdit( mySelectBox );
mySubMeshLine->setReadOnly( true );
onSelectSubMesh( false );
- mySelectGroup = new QCheckBox( tr( "SMESH_GROUP" ), aSelectBox );
- myGroupBtn = new QPushButton( aSelectBox );
+ mySelectGroup = new QCheckBox( tr( "SMESH_GROUP" ), mySelectBox );
+ myGroupBtn = new QPushButton( mySelectBox );
myGroupBtn->setIcon( image0 );
- myGroupLine = new QLineEdit( aSelectBox );
+ myGroupLine = new QLineEdit( mySelectBox );
myGroupLine->setReadOnly( true );
onSelectGroup( false );
- aSelectBoxLayout->addWidget( mySelectSubMesh, 0, 0 );
- aSelectBoxLayout->addWidget( mySubMeshBtn, 0, 1 );
- aSelectBoxLayout->addWidget( mySubMeshLine, 0, 2 );
- aSelectBoxLayout->addWidget( mySelectGroup, 1, 0 );
- aSelectBoxLayout->addWidget( myGroupBtn, 1, 1 );
- aSelectBoxLayout->addWidget( myGroupLine, 1, 2 );
+ mySelectBoxLayout->addWidget( mySelectSubMesh, 0, 0 );
+ mySelectBoxLayout->addWidget( mySubMeshBtn, 0, 1 );
+ mySelectBoxLayout->addWidget( mySubMeshLine, 0, 2 );
+ mySelectBoxLayout->addWidget( mySelectGroup, 1, 0 );
+ mySelectBoxLayout->addWidget( myGroupBtn, 1, 1 );
+ mySelectBoxLayout->addWidget( myGroupLine, 1, 2 );
/***************************************************************/
QVBoxLayout* wg1Layout = new QVBoxLayout( wg1 );
wg1Layout->setMargin( 0 );
wg1Layout->setSpacing( SPACING );
wg1Layout->addWidget( aContentBox );
- wg1Layout->addWidget( aSelectBox );
+ wg1Layout->addWidget( mySelectBox );
wg1Layout->setStretchFactor( aContentBox, 10 );
/***************************************************************/
QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox );
myColorBtn = new QtxColorButton(aColorBox);
myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding,
- myColorBtn->sizePolicy().verticalPolicy() );
+ myColorBtn->sizePolicy().verticalPolicy() );
aColorBoxLayout->addWidget(aColorLab);
aColorBoxLayout->addWidget(myColorBtn);
aMainLayout->addWidget(aButtons, 6, 0, 1, 3);
/* signals and slots connections */
- connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
- connect(myGrpTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onGrpTypeChanged(int)));
- connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int)));
+ connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+ connect(myGrpTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onGrpTypeChanged(int)));
+ connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int)));
- connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
- connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
+ connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
+ connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
- connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
- connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
- connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
- connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
+ connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
+ connect(mySelectAll, SIGNAL(toggled(bool)), this, SLOT(onSelectAll()));
+ connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
+ connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
+ connect(mySortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
- connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
- connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+ connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+ connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
- connect(myColorBtn, SIGNAL(changed( QColor )), this, SLOT(onColorChanged( QColor )));
+ connect(myColorBtn, SIGNAL(changed( QColor )), this, SLOT(onColorChanged( QColor )));
- connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
- connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
- connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
- connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
+ connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
+ connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
+ connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
+ connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
/* Init selection */
mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800);
- mySelectionMode = -1;
+ mySelectionMode = grpNoSelection;
myMeshFilter = new SMESH_TypeFilter(MESH);
mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
myGroupFilter = new SMESH_TypeFilter(GROUP);
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
+ connect(mySMESHGUI, SIGNAL(SignalVisibilityChanged()), this, SLOT(onVisibilityChanged()));
rb1->setChecked(true); // VSR !!!
onGrpTypeChanged(0); // VSR!!!
// actor of theGroup, 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);
- if ( !myActor )
- myActor = SMESH::FindActorByObject(theGroup);
- SMESH::SetPickable(myActor);
+ SetAppropriateActor();
+
+ /* SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
+ if ( !anActor )
+ anActor = SMESH::FindActorByObject(theGroup);
+ SMESH::SetPickable(anActor);*/
int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : 1));
myGrpTypeGroup->button(grpType)->setChecked(true);
onGrpTypeChanged(grpType);
+ myTypeId = aType;
if ( grpType == 0 ) {
myCurrentLineEdit = 0;
myElements->clear();
setSelectionMode(aType);
- myTypeId = aType;
setShowEntityMode(); // depends on myTypeId
if (!aGroupShape->_is_nil())
{
_PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
- aShapeName = aGroupShapeSO->GetName().c_str();
+ if ( aGroupShapeSO )
+ aShapeName = aGroupShapeSO->GetName().c_str();
}
myGeomGroupLine->setText( aShapeName );
myNameChanged = true;
myName->blockSignals(true);
- myName->setText( "Group On " + aShapeName);
+ myName->setText(theGroup->GetName());
myName->blockSignals(false);
}
updateButtons();
bool enable = !myName->text().trimmed().isEmpty();
if (myGrpTypeId == 0) {
- enable = enable && myElements->count() > 0;
+ enable = enable && (mySelectAll->isChecked() || myElements->count() > 0);
enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil());
}
else if (myGrpTypeId == 1) {
enable = enable && myGeomObjects->length() > 0 && !myMesh->_is_nil();
}
}
-
+
myOKBtn->setEnabled(enable);
myApplyBtn->setEnabled(enable);
}
// PAL7314
if (myMesh->_is_nil())
return;
+ SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+ bool isSelectAll = mySelectAll->isChecked();
if (mySelectionMode != theMode) {
// [PAL10408] mySelectionMgr->clearSelected();
mySelectionMgr->clearFilters();
- if (myActor)
- myActor->SetPointRepresentation(false);
- else
+ if (myActorsList.count() > 0) {
+ QListIterator<SMESH_Actor*> it( myActorsList );
+ while ( it.hasNext() )
+ it.next()->SetPointRepresentation(false);
+ }
+ else {
SMESH::SetPointRepresentation(false);
- if (theMode < 4) {
- switch (theMode) {
- case 0:
- if (myActor)
- myActor->SetPointRepresentation(true);
- else
- SMESH::SetPointRepresentation(true);
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(NodeSelection);
- break;
- case 1:
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(EdgeSelection);
- break;
- case 2:
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(FaceSelection);
- break;
- default:
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(VolumeSelection);
+ }
+ switch (theMode) {
+ case grpNodeSelection:
+ if (myActorsList.count() > 0) {
+ QListIterator<SMESH_Actor*> it( myActorsList );
+ while ( it.hasNext() )
+ it.next()->SetPointRepresentation(true);
}
- } else {
- if (theMode == 4)
- mySelectionMgr->installFilter(mySubMeshFilter);
- else if (theMode == 5)
- mySelectionMgr->installFilter(myGroupFilter);
- else if (theMode == 6)
- mySelectionMgr->installFilter(myMeshFilter);
- else if (theMode == 7)
- mySelectionMgr->installFilter(myGeomFilter);
-
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(ActorSelection);
+ else {
+ SMESH::SetPointRepresentation(true);
+ }
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : NodeSelection);
+ break;
+ case grpEdgeSelection:
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection);
+ break;
+ case grpFaceSelection:
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection);
+ break;
+ case grpVolumeSelection:
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : VolumeSelection);
+ break;
+ case grpSubMeshSelection:
+ mySelectionMgr->installFilter(mySubMeshFilter);
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
+ break;
+ case grpGroupSelection:
+ mySelectionMgr->installFilter(myGroupFilter);
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
+ break;
+ case grpMeshSelection:
+ mySelectionMgr->installFilter(myMeshFilter);
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
+ break;
+ case grpGeomSelection:
+ mySelectionMgr->installFilter(myGeomFilter);
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
+ break;
+ default:
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
+ break;
}
+ if ( aViewWindow ) aViewWindow->Repaint();
mySelectionMode = theMode;
}
}
return false;
if (myGrpTypeId == 0) { // on mesh elements
- if (!myElements->count())
+ if (!mySelectAll->isChecked() && !myElements->count())
return false;
mySelectionMgr->clearSelected();
if (myMesh->_is_nil())
return false;
myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
- // nullify pointer, because object become dead
+ // nullify pointer, because object become dead
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
}
}
case 3: aType = SMESH::VOLUME; break;
}
- SMESH::long_array_var anIdList = new SMESH::long_array;
- int i, k = myElements->count();
- anIdList->length(k);
- for (i = 0; i < k; i++) {
- anIdList[i] = myElements->item(i)->text().toInt();
- }
-
myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
- myGroup->Add(anIdList.inout());
+
+ if ( mySelectAll->isChecked() ) {
+ // select all
+ myGroup->AddFrom(myMesh.in());
+ }
+ else {
+ // select manually
+ SMESH::long_array_var anIdList = new SMESH::long_array;
+ int i, k = myElements->count();
+ anIdList->length(k);
+ for (i = 0; i < k; i++) {
+ anIdList[i] = myElements->item(i)->text().toInt();
+ }
+
+ myGroup->Add(anIdList.inout());
+ }
SALOMEDS::Color aColor = getGroupColor();
myGroup->SetColor(aColor);
_PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
- switch ( myTypeId ) {
- case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
- case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
- case 2:
- case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
- }
+ anActor->setName(myName->text().toLatin1().data());
+ switch ( myTypeId ) {
+ case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
+ case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
+ case 2:
+ case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
+ }
}
- QList<int> aAddList;
-
- int i, total = myElements->count();
- for (i = 0; i < total; i++) {
- int anId = myElements->item(i)->text().toInt();
- int idx = myIdList.indexOf(anId);
- if ( idx == -1 )
- aAddList.append(anId);
- else
- myIdList.removeAt(idx);
- }
- if (!aAddList.empty()) {
- SMESH::long_array_var anIdList = new SMESH::long_array;
- int added = aAddList.count();
- anIdList->length(added);
- for (i = 0; i < added; i++)
- anIdList[i] = aAddList[i];
- myGroup->Add(anIdList.inout());
+ if ( mySelectAll->isChecked() ) {
+ // select all
+ myGroup->Clear();
+ myGroup->AddFrom(myMesh.in());
}
- if (!myIdList.empty()) {
- SMESH::long_array_var anIdList = new SMESH::long_array;
- int removed = myIdList.count();
- anIdList->length(removed);
- for (i = 0; i < removed; i++)
- anIdList[i] = myIdList[i];
- myGroup->Remove(anIdList.inout());
- }
- /* init for next operation */
- myIdList.clear();
- for (i = 0; i < total; i++) {
- myIdList.append(myElements->item(i)->text().toInt());
+ else {
+ QList<int> aAddList;
+
+ int i, total = myElements->count();
+ for (i = 0; i < total; i++) {
+ int anId = myElements->item(i)->text().toInt();
+ int idx = myIdList.indexOf(anId);
+ if ( idx == -1 )
+ aAddList.append(anId);
+ else
+ myIdList.removeAt(idx);
+ }
+ if (!aAddList.empty()) {
+ SMESH::long_array_var anIdList = new SMESH::long_array;
+ int added = aAddList.count();
+ anIdList->length(added);
+ for (i = 0; i < added; i++)
+ anIdList[i] = aAddList[i];
+ myGroup->Add(anIdList.inout());
+ }
+ if (!myIdList.empty()) {
+ SMESH::long_array_var anIdList = new SMESH::long_array;
+ int removed = myIdList.count();
+ anIdList->length(removed);
+ for (i = 0; i < removed; i++)
+ anIdList[i] = myIdList[i];
+ myGroup->Remove(anIdList.inout());
+ }
+ /* init for next operation */
+ myIdList.clear();
+ for (i = 0; i < total; i++) {
+ myIdList.append(myElements->item(i)->text().toInt());
+ }
}
}
+ SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
SMESH::UpdateView(); // asv: fix of BUG PAL5515
mySelectionMgr->clearSelected();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
GEOM::GEOM_IGroupOperations_var aGroupOp =
- SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
+ SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
if (myGeomObjects->length() == 1) {
- myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
- myName->text().toLatin1().data(),
- myGeomObjects[0]);
+ myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
+ myName->text().toLatin1().data(),
+ myGeomObjects[0]);
}
else {
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
aNewGeomGroupName += myName->text();
SALOMEDS::SObject_var aNewGroupSO =
geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar,
- aNewGeomGroupName.toLatin1().data(), aMeshShape);
+ aNewGeomGroupName.toLatin1().data(), aMeshShape);
}
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
- myName->text().toLatin1().data(),
- aGroupVar);
+ myName->text().toLatin1().data(),
+ aGroupVar);
}
SALOMEDS::Color aColor = getGroupColor();
_PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
- switch ( myTypeId ) {
- case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
- case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
- case 2:
- case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
- }
+ anActor->setName(myName->text().toLatin1().data());
+ switch ( myTypeId ) {
+ case 0: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
+ case 1: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
+ case 2:
+ case 3: anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B ); break;
+ }
}
}
+ SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
mySelectionMgr->clearSelected();
return true;
//=================================================================================
void SMESHGUI_GroupDlg::onListSelectionChanged()
{
- // MESSAGE( "SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
- if( myIsBusy || !myActor) return;
- myIsBusy = true;
+ //MESSAGE( "SMESHGUI_GroupDlg::onListSelectionChanged(); myActorsList.count() = " << myActorsList.count());
+ if( myIsBusy || myActorsList.count() == 0 ) return;
+ myIsBusy = true;
if (myCurrentLineEdit == 0) {
mySelectionMgr->clearSelected();
QList<QListWidgetItem*> selItems = myElements->selectedItems();
QListWidgetItem* anItem;
foreach(anItem, selItems) aIndexes.Add(anItem->text().toInt());
- mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
+ mySelector->AddOrRemoveIndex(myActorsList.first()->getIO(), aIndexes, false);
SALOME_ListIO aList;
- aList.Append(myActor->getIO());
+ aList.Append(myActorsList.first()->getIO());
mySelectionMgr->setSelectedObjects(aList,false);
}
myIsBusy = false;
myGeomObjects->length(0);
if (myGeomGroupBtn->isChecked())
- myGeomGroupBtn->setChecked(false);
+ myGeomGroupBtn->setChecked(false);
if (!myCreate)
myName->setText( "" );
Handle(SALOME_InteractiveObject) IO = aList.First();
if (myCreate) {
- restoreShowEntityMode();
- myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
+ restoreShowEntityMode();
+ myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
setShowEntityMode();
updateGeomPopup();
if (myMesh->_is_nil())
- {
+ {
updateButtons();
- myIsBusy = false;
- return;
- }
+ myIsBusy = false;
+ return;
+ }
+
+ if ( myFilterDlg && !myMesh->_is_nil()){
+ myFilterDlg->SetMesh( myMesh );
+ }
myGroup = SMESH::SMESH_Group::_nil();
// NPAL19389: create a group with a selection in another group
else {
SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
if (aGroup->_is_nil())
- {
- myIsBusy = false;
+ {
+ myIsBusy = false;
return;
- }
+ }
myIsBusy = false;
- myCurrentLineEdit = 0;
- myGroup = SMESH::SMESH_Group::_nil();
- myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
+ myGroup = SMESH::SMESH_Group::_nil();
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
init(aGroup);
myIsBusy = true;
if (myGrpTypeId == 0)
{
- if (myTypeId == -1)
- onTypeChanged(0);
- else
- {
- myElements->clear();
- setSelectionMode(myTypeId);
- }
+ if (myTypeId == -1)
+ onTypeChanged(0);
+ else
+ {
+ myElements->clear();
+ setSelectionMode(myTypeId);
+ }
}
myIsBusy = false;
if (aNbSel == 0 || !aMeshSO)
{
- myGeomObjects->length(0);
- updateButtons();
- myIsBusy = false;
- return;
+ myGeomObjects->length(0);
+ updateButtons();
+ myIsBusy = false;
+ return;
}
myGeomObjects->length(aNbSel);
GEOM::GEOM_Object_var aGeomGroup;
- Standard_Boolean testResult;
int i = 0;
SALOME_ListIteratorOfListIO anIt (aList);
for (; anIt.More(); anIt.Next())
{
- testResult = Standard_False;
- aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
+ aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value());
// Check if the object is a geometry group
- if (!testResult || CORBA::is_nil(aGeomGroup))
+ if (CORBA::is_nil(aGeomGroup))
continue;
// Check if group constructed on the same shape as a mesh or on its child
myGeomObjects->length(i);
if ( i == 0 )
- {
- myIsBusy = false;
- return;
- }
+ {
+ myIsBusy = false;
+ return;
+ }
aNbSel = i;
}
}
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
// 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) curIO = myActor->getIO();
Handle(SALOME_InteractiveObject) selIO = aList.First();
if (curIO->hasEntry() && selIO->hasEntry()) {
const char* selEntry = selIO->getEntry();
}
}
}
- }
+ }*/
// NPAL19389 END
-#endif // ENABLE_SWITCH_ACTOR_DURING_ELEMENTS_SELECTION
QString aListStr = "";
int aNbItems = 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 {
- 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) {
- QListWidgetItem* anItem;
- QList<QListWidgetItem*> listItemsToSel;
- QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts);
- for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
- QList<QListWidgetItem*> found = myElements->findItems(*it, Qt::MatchExactly);
- foreach(anItem, found)
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
- bool blocked = myElements->signalsBlocked();
- myElements->blockSignals(true);
- foreach(anItem, listItemsToSel) anItem->setSelected(true);
- myElements->blockSignals(blocked);
- onListSelectionChanged();
- listItemsToSel.clear();
+ QListWidgetItem* anItem;
+ QList<QListWidgetItem*> listItemsToSel;
+ QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts);
+ for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
+ QList<QListWidgetItem*> found = myElements->findItems(*it, Qt::MatchExactly);
+ foreach(anItem, found)
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
+ bool blocked = myElements->signalsBlocked();
+ myElements->blockSignals(true);
+ foreach(anItem, listItemsToSel) anItem->setSelected(true);
+ myElements->blockSignals(blocked);
+ onListSelectionChanged();
+ listItemsToSel.clear();
}
}
}
-
- if (!myActor) {
- if (!myGroup->_is_nil())
- myActor = SMESH::FindActorByObject(myGroup);
- else if(!myGroupOnGeom->_is_nil())
- myActor = SMESH::FindActorByObject(myGroupOnGeom);
- else
- myActor = SMESH::FindActorByObject(myMesh);
+
+ if (myActorsList.count() == 0) {
+ if (!myGroup->_is_nil()) {
+ SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup);
+ if ( anActor )
+ myActorsList.append( anActor );
+ }
+ else if(!myGroupOnGeom->_is_nil()) {
+ SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom);
+ if ( anActor )
+ myActorsList.append( anActor );
+ }
+ else {
+ SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
+ if ( anActor )
+ myActorsList.append( anActor );
+ }
}
// 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);
+ if (myActorsList.count() > 0) {
+ QListIterator<SMESH_Actor*> it( myActorsList );
+ while ( it.hasNext() ) {
+ SMESH_Actor* anActor = it.next();
+ if ( IsActorVisible(anActor) )
+ anActor->SetPickable(true);
+ }
+ }
myIsBusy = false;
}
+//=================================================================================
+// function : onSelectSubMesh()
+// purpose : Called when selection in 3D view or ObjectBrowser is changed
+//=================================================================================
+void SMESHGUI_GroupDlg::onSelectAll()
+{
+ myElementsLab->setEnabled( !mySelectAll->isChecked() );
+ myElements->setEnabled( !mySelectAll->isChecked() );
+ myFilter->setEnabled( !mySelectAll->isChecked() );
+ myAddBtn->setEnabled( !mySelectAll->isChecked() );
+ myRemoveBtn->setEnabled( !mySelectAll->isChecked() );
+ mySortBtn->setEnabled( !mySelectAll->isChecked() );
+ mySelectBox->setEnabled( !mySelectAll->isChecked() );
+ int selMode = mySelectionMode;
+ mySelectionMode = grpNoSelection;
+ setSelectionMode( selMode );
+}
+
//=================================================================================
// function : onSelectSubMesh()
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//VSR: mySelectGeomGroup->setChecked(false);
//VSR: }
myCurrentLineEdit = mySubMeshLine;
- setSelectionMode(4);
+ setSelectionMode(grpSubMeshSelection);
}
else {
mySubMeshLine->setText( "" );
mySelectSubMesh->setChecked(false);
}
myCurrentLineEdit = myGroupLine;
- setSelectionMode(5);
+ setSelectionMode(grpGroupSelection);
}
else {
myGroupLine->setText( "" );
}
myCurrentLineEdit = myGeomGroupLine;
updateGeomPopup();
- setSelectionMode(8);
+ setSelectionMode(grpAllSelection);
}
else {
myGeomGroupBtn->setChecked(false);
QPushButton* send = (QPushButton*)sender();
myCurrentLineEdit = 0;
if (send == myMeshGroupBtn) {
- myCurrentLineEdit = myMeshGroupLine;
+ disconnect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+ mySelectionMgr->clearSelected();
if (myCreate)
- setSelectionMode(6);
+ setSelectionMode(grpMeshSelection);
else
- setSelectionMode(5);
+ setSelectionMode(grpGroupSelection);
+ connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+ myCurrentLineEdit = myMeshGroupLine;
onObjectSelectionChanged();
}
else if (send == mySubMeshBtn) {
{
if(myMesh->_is_nil()) {
SUIT_MessageBox::critical(this,
- tr("SMESH_ERROR"),
- tr("NO_MESH_SELECTED"));
+ tr("SMESH_ERROR"),
+ tr("NO_MESH_SELECTED"));
return;
}
int aNbSel = aList.Extent();
- if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
+ if (aNbSel == 0 || myActorsList.count() == 0 || myMesh->_is_nil()) return;
myIsBusy = true;
QString aListStr = "";
int aNbItems = 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 {
- 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) {
QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts);
for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
- QList<QListWidgetItem*> found = myElements->findItems(*it, Qt::MatchExactly);
- if (found.count() == 0) {
- anItem = new QListWidgetItem(*it);
- myElements->addItem(anItem);
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
- else {
- foreach(anItem, found)
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
+ QList<QListWidgetItem*> found = myElements->findItems(*it, Qt::MatchExactly);
+ if (found.count() == 0) {
+ anItem = new QListWidgetItem(*it);
+ myElements->addItem(anItem);
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
+ else {
+ foreach(anItem, found)
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
}
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
SMESH::SMESH_subMesh_var aSubMesh =
SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
if (!aSubMesh->_is_nil()) {
- // check if mesh is the same
- if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
+ // check if mesh is the same
+ if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
try {
SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
int k = anElements->length();
if (found.count() == 0) {
anItem = new QListWidgetItem(aText);
myElements->addItem(anItem);
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
+ else {
+ foreach(anItem, found)
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
}
- else {
- foreach(anItem, found)
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
}
- bool blocked = myElements->signalsBlocked();
- myElements->blockSignals(true);
- foreach(anItem, listItemsToSel) anItem->setSelected(true);
- myElements->blockSignals(blocked);
- onListSelectionChanged();
- listItemsToSel.clear();
+ bool blocked = myElements->signalsBlocked();
+ myElements->blockSignals(true);
+ foreach(anItem, listItemsToSel) anItem->setSelected(true);
+ myElements->blockSignals(blocked);
+ onListSelectionChanged();
+ listItemsToSel.clear();
}
catch (const SALOME::SALOME_Exception& ex) {
SalomeApp_Tools::QtCatchCorbaException(ex);
SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIt.Value());
if (!aGroup->_is_nil()) {
- // check if mesh is the same
- if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
- SMESH::long_array_var anElements = aGroup->GetListOfID();
- int k = anElements->length();
- for (int i = 0; i < k; i++) {
- QString aText = QString::number(anElements[i]);
- QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
- if (found.count() == 0) {
- anItem = new QListWidgetItem(aText);
- myElements->addItem(anItem);
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
- else {
- foreach(anItem, found)
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
- }
- bool blocked = myElements->signalsBlocked();
- myElements->blockSignals(true);
- foreach(anItem, listItemsToSel) anItem->setSelected(true);
- myElements->blockSignals(blocked);
- onListSelectionChanged();
- listItemsToSel.clear();
- }
+ // check if mesh is the same
+ if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
+ SMESH::long_array_var anElements = aGroup->GetListOfID();
+ int k = anElements->length();
+ for (int i = 0; i < k; i++) {
+ QString aText = QString::number(anElements[i]);
+ QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
+ if (found.count() == 0) {
+ anItem = new QListWidgetItem(aText);
+ myElements->addItem(anItem);
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
+ else {
+ foreach(anItem, found)
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
+ }
+ bool blocked = myElements->signalsBlocked();
+ myElements->blockSignals(true);
+ foreach(anItem, listItemsToSel) anItem->setSelected(true);
+ myElements->blockSignals(blocked);
+ onListSelectionChanged();
+ listItemsToSel.clear();
+ }
}
}
mySelectGroup->setChecked(false);
int k = anElements->length();
for (int i = 0; i < k; i++) {
- QString aText = QString::number(anElements[i]);
- QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
- if (found.count() == 0) {
- anItem = new QListWidgetItem(aText);
- myElements->addItem(anItem);
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
- else {
- foreach(anItem, found)
- if (!anItem->isSelected())
- listItemsToSel.push_back(anItem);
- }
+ QString aText = QString::number(anElements[i]);
+ QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
+ if (found.count() == 0) {
+ anItem = new QListWidgetItem(aText);
+ myElements->addItem(anItem);
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
+ else {
+ foreach(anItem, found)
+ if (!anItem->isSelected())
+ listItemsToSel.push_back(anItem);
+ }
}
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
SALOME_ListIteratorOfListIO anIt (aList);
for ( ; anIt.More(); anIt.Next()) {
- SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
- if (!aSubMesh->_is_nil()) {
- // check if mesh is the same
- if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
- if (aType == SMESH::NODE) {
- try {
- SMESH::long_array_var anElements = aSubMesh->GetNodesId();
- int k = anElements->length();
- for (int i = 0; i < k; i++) {
- QList<QListWidgetItem*> found =
- myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
- QListWidgetItem* anItem;
- foreach(anItem, found) delete anItem;
- }
- }
- catch (const SALOME::SALOME_Exception& ex) {
- SalomeApp_Tools::QtCatchCorbaException(ex);
- }
- }
- else {
- try {
- SMESH::long_array_var anElements = aSubMesh->GetElementsId();
- int k = anElements->length();
- for (int i = 0; i < k; i++) {
- QList<QListWidgetItem*> found =
- myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
- QListWidgetItem* anItem;
- foreach(anItem, found) delete anItem;
- }
- }
- catch (const SALOME::SALOME_Exception& ex) {
- SalomeApp_Tools::QtCatchCorbaException(ex);
- }
- }
- }
- }
+ SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
+ if (!aSubMesh->_is_nil()) {
+ // check if mesh is the same
+ if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
+ if (aType == SMESH::NODE) {
+ try {
+ SMESH::long_array_var anElements = aSubMesh->GetNodesId();
+ int k = anElements->length();
+ for (int i = 0; i < k; i++) {
+ QList<QListWidgetItem*> found =
+ myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
+ QListWidgetItem* anItem;
+ foreach(anItem, found) delete anItem;
+ }
+ }
+ catch (const SALOME::SALOME_Exception& ex) {
+ SalomeApp_Tools::QtCatchCorbaException(ex);
+ }
+ }
+ else {
+ try {
+ SMESH::long_array_var anElements = aSubMesh->GetElementsId();
+ int k = anElements->length();
+ for (int i = 0; i < k; i++) {
+ QList<QListWidgetItem*> found =
+ myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
+ QListWidgetItem* anItem;
+ foreach(anItem, found) delete anItem;
+ }
+ }
+ catch (const SALOME::SALOME_Exception& ex) {
+ SalomeApp_Tools::QtCatchCorbaException(ex);
+ }
+ }
+ }
+ }
}
}
else if (myCurrentLineEdit == myGroupLine) {
SALOME_ListIteratorOfListIO anIt (aList);
for ( ; anIt.More(); anIt.Next()) {
- SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
- if (aRes && !aGroup->_is_nil()) {
- // check if mesh is the same
- if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
- SMESH::long_array_var anElements = aGroup->GetListOfID();
- int k = anElements->length();
- for (int i = 0; i < k; i++) {
- QList<QListWidgetItem*> found =
- myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
- QListWidgetItem* anItem;
- foreach(anItem, found) delete anItem;
- }
- }
- }
+ SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
+ if (aRes && !aGroup->_is_nil()) {
+ // check if mesh is the same
+ if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
+ SMESH::long_array_var anElements = aGroup->GetListOfID();
+ int k = anElements->length();
+ for (int i = 0; i < k; i++) {
+ QList<QListWidgetItem*> found =
+ myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
+ QListWidgetItem* anItem;
+ foreach(anItem, found) delete anItem;
+ }
+ }
+ }
}
}
}
int id = myElements->item(i)->text().toInt();
anArray[i] = id;
if (myElements->item(i)->isSelected())
- aSelected.append(id);
+ aSelected.append(id);
}
// sort & update list
std::sort(anArray.begin(), anArray.end());
anItem = new QListWidgetItem(QString::number(anArray[i]));
myElements->addItem(anItem);
if (aSelected.contains(anArray[i]))
- listItemsToSel.push_back(anItem);
+ listItemsToSel.push_back(anItem);
}
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
onClose();
}
+//=================================================================================
+// function : onVisibilityChanged()
+// purpose :
+//=================================================================================
+void SMESHGUI_GroupDlg::onVisibilityChanged()
+{
+ SetAppropriateActor();
+}
+
//=================================================================================
// function : SMESHGUI_GroupDlg::onClose
// purpose : SLOT called when "Close" button pressed. Close dialog
platform = "application";
#endif
SUIT_MessageBox::warning(this, tr( "WRN_WARNING" ),
- tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
- arg(app->resourceMgr()->stringValue( "ExternalBrowser",
- platform)).
- arg(myHelpFileName));
+ tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
+ arg(app->resourceMgr()->stringValue( "ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
}
}
if (!isEnabled()) {
mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true);
- mySelectionMode = -1;
+ mySelectionMode = grpNoSelection;
setSelectionMode(myTypeId);
//mySMESHGUI->SetActiveDialogBox((QDialog*)this);
mySMESHGUI->SetActiveDialogBox(this);
myCurrentLineEdit = myGeomGroupLine;
QAction* a = myGeomPopup->exec( QCursor::pos() );
if (!a || myActions[a] == DIRECT_GEOM_INDEX)
- setSelectionMode(7);
+ setSelectionMode(grpGeomSelection);
}
else if (!isBtnOn)
{
myCurrentLineEdit = 0;
- setSelectionMode(8);
+ setSelectionMode(grpAllSelection);
}
}
int index = myActions[a];
if ( index == GEOM_BY_MESH_INDEX )
{
- mySelectionMode = -1;
+ mySelectionMode = grpNoSelection;
if ( !myShapeByMeshOp ) {
- myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
- connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
- SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
- connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
- SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
+ myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
+ connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
+ SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
+ connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
+ SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
}
// set mesh object to SMESHGUI_ShapeByMeshOp and start it
if ( !myMesh->_is_nil() ) {
- myIsBusy = true;
+ myIsBusy = true;
hide(); // stop processing selection
- myIsBusy = false;
+ myIsBusy = false;
myShapeByMeshOp->setModule( mySMESHGUI );
myShapeByMeshOp->setStudy( 0 ); // it's really necessary
myShapeByMeshOp->SetMesh( myMesh );
QString ID = aGeomVar->GetStudyEntry();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.toLatin1().data() )) {
- SALOME_ListIO anIOList;
- Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
- ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
- anIOList.Append( anIO );
- mySelectionMgr->setSelectedObjects( anIOList, false );
- onObjectSelectionChanged();
+ SALOME_ListIO anIOList;
+ Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
+ ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
+ anIOList.Append( anIO );
+ mySelectionMgr->setSelectedObjects( anIOList, false );
+ onObjectSelectionChanged();
}
}
}
if ( myShapeByMeshOp == op )
{
show();
- setSelectionMode(7);
+ setSelectionMode(grpGeomSelection);
}
}
void SMESHGUI_GroupDlg::setGroupColor( const SALOMEDS::Color& theColor )
{
QColor aQColor( (int)( theColor.R * 255.0 ),
- (int)( theColor.G * 255.0 ),
- (int)( theColor.B * 255.0 ) );
+ (int)( theColor.G * 255.0 ),
+ (int)( theColor.B * 255.0 ) );
setGroupQColor( aQColor );
}
SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
aQColor.setRgb( (int)( aColor.R * 255.0 ),
- (int)( aColor.G * 255.0 ),
- (int)( aColor.B * 255.0 ) );
+ (int)( aColor.G * 255.0 ),
+ (int)( aColor.B * 255.0 ) );
}
bool SMESHGUI_GroupDlg::SetAppropriateActor()
{
bool isActor = false;
+ myActorsList.clear();
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;
+ if (myGeomGroupBtn->isChecked()) { // try current group on geometry actor
+ if (!isActor) {
+ if (!myGroupOnGeom->_is_nil()) {
+ SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom);
+ if (anActor && anActor->hasIO())
+ {
+ isActor = true;
+ if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
+ isActor = false;
+ else
+ myActorsList.append(anActor);
+ }
}
}
- }
-
- // 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;
- }
+ } 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
- 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();
- int nbItems = aCollection->GetNumberOfItems();
- for (int i=0; i<nbItems; i++)
- {
- SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(aCollection->GetItemAsObject(i));
- 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;
+
+ // try group actor
+ if (!isActor && !myGroup->_is_nil()) {
+ SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup);
+ if (anActor && anActor->hasIO())
+ myActorsList.append(anActor);
+ }
+
+ // try any visible actor of group or submesh of current mesh
+ if (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
+ VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
+ int nbItems = aCollection->GetNumberOfItems();
+ for (int i=0; i<nbItems && !isActor; i++)
+ {
+ SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(aCollection->GetItemAsObject(i));
+ if (anActor && anActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ if (aViewWindow->isVisible(anIO)) {
+ if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) )
+ myActorsList.append(anActor);
+ }
}
}
- }
}
}
}
-
- if (isActor)
- SMESH::SetPickable(myActor);
-
- return isActor;
+
+ if (myActorsList.count() > 0) {
+ QListIterator<SMESH_Actor*> it( myActorsList );
+ while ( it.hasNext() ) {
+ SMESH_Actor* anActor = it.next();
+ if ( IsActorVisible(anActor) )
+ anActor->SetPickable(true);
+ }
+ }
+
+ return ( isActor || (myActorsList.count() > 0) );
}
-
+
//=======================================================================
//function : setShowEntityMode
//purpose : make shown only entity corresponding to my type
}
myStoredShownEntity = 0;
}
+
+//=======================================================================
+//function : IsActorVisible
+//purpose : return visibility of the actor
+//=======================================================================
+bool SMESHGUI_GroupDlg::IsActorVisible( SMESH_Actor* theActor )
+{
+ SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
+ if (theActor && aViewWindow)
+ return aViewWindow->isVisible(theActor->getIO());
+ return false;
+}