X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=f6d02c232a452648b4efcad933a2488a07b0b51a;hb=8255b5e32fbfda42463487d3e3699762adbacf82;hp=d61b9397ff193b61c205f5dfb42651dab36d9888;hpb=6426baa9f306e2eceed4e442a701773927038dc2;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index d61b9397f..f6d02c232 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 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 @@ -103,14 +103,16 @@ enum grpSelectionMode { grpNoSelection = -1, grpNodeSelection = 0, - grpEdgeSelection = 1, - grpFaceSelection = 2, - grpVolumeSelection = 3, - grpSubMeshSelection = 4, - grpGroupSelection = 5, - grpMeshSelection = 6, - grpGeomSelection = 7, - grpAllSelection = 8, + grp0DSelection = 1, + grpBallSelection = 2, + grpEdgeSelection = 3, + grpFaceSelection = 4, + grpVolumeSelection = 5, + grpSubMeshSelection = 6, + grpGroupSelection = 7, + grpMeshSelection = 8, + grpGeomSelection = 9, + grpAllSelection = 10, }; //================================================================================= @@ -213,6 +215,8 @@ void SMESHGUI_GroupDlg::initDialog( bool create) QStringList types; types.append( tr( "MESH_NODE" ) ); + types.append( tr( "SMESH_ELEM0D" ) ); + types.append( tr( "SMESH_BALL_ELEM" ) ); types.append( tr( "SMESH_EDGE" ) ); types.append( tr( "SMESH_FACE" ) ); types.append( tr( "SMESH_VOLUME" ) ); @@ -257,22 +261,22 @@ void SMESHGUI_GroupDlg::initDialog( bool create) QWidget* wg3 = new QWidget( myWGStack ); /***************************************************************/ - QGroupBox* aContentBox = new QGroupBox( tr( "SMESH_CONTENT" ), wg1 ); + QGroupBox* aContentBox = new QGroupBox( tr( "SMESH_CONTENT" ), wg1 ); QGridLayout* aContentBoxLayout = new QGridLayout( aContentBox ); aContentBoxLayout->setMargin( MARGIN ); aContentBoxLayout->setSpacing( SPACING ); - mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), aContentBox ); + mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), aContentBox ); myAllowElemsModif = new QCheckBox( tr( "ALLOW_ELEM_LIST_MODIF" ), aContentBox ); myElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox ); - myElements = new QListWidget( aContentBox ); + myElements = new QListWidget( aContentBox ); myElements->setSelectionMode( QListWidget::ExtendedSelection ); myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), aContentBox ); - myAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox ); + myAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox ); myRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox ); - mySortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox ); + mySortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox ); aContentBoxLayout->addWidget( mySelectAll, 0, 0 ); aContentBoxLayout->addWidget( myAllowElemsModif, 1, 0 ); @@ -416,7 +420,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&))); connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged())); - connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); + connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); connect(aFilter2, SIGNAL(clicked()), this, SLOT(setFilters())); connect(mySelectAll, SIGNAL(toggled(bool)), this, SLOT(onSelectAll())); connect(myAllowElemsModif,SIGNAL(toggled(bool)), this, SLOT(onSelectAll())); @@ -442,7 +446,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) mySMESHGUI->SetState(800); mySelectionMode = grpNoSelection; - myMeshFilter = new SMESH_TypeFilter(MESH); + myMeshFilter = new SMESH_TypeFilter(SMESH::MESH); mySubMeshFilter = new SMESH_LogicalFilter(QList(), SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true); @@ -519,6 +523,22 @@ QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation) return aName; } +void SMESHGUI_GroupDlg::setDefaultName() const +{ + QString aResName; + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + int i=1; + QString aPrefix ="Group_"; + _PTR(SObject) anObj; + do + { + aResName = aPrefix + QString::number( i++ ); + anObj = aStudy->FindObject( aResName.toLatin1().data() ); + } + while ( anObj ); + myName->setText(aResName); +} + //================================================================================= // function : Init() // purpose : @@ -541,6 +561,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) SetAppropriateActor(); setDefaultGroupColor(); + setDefaultName(); + SALOME_ListIO aList; mySelectionMgr->selectedObjects( aList ); @@ -562,7 +584,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) // purpose : //================================================================================= void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, - const bool theIsConvert) + const bool theIsConvert) { restoreShowEntityMode(); myMesh = theGroup->GetMesh(); @@ -581,17 +603,19 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, int aType = 0; switch(theGroup->GetType()) { - case SMESH::NODE: aType= 0; break; - case SMESH::EDGE: aType = 1; break; - case SMESH::FACE: aType = 2; break; - case SMESH::VOLUME: aType = 3; break; + case SMESH::NODE: aType = grpNodeSelection; break; + case SMESH::ELEM0D: aType = grp0DSelection; break; + case SMESH::BALL: aType = grpBallSelection; break; + case SMESH::EDGE: aType = grpEdgeSelection; break; + case SMESH::FACE: aType = grpFaceSelection; break; + case SMESH::VOLUME: aType = grpVolumeSelection; break; } myTypeGroup->button(aType)->setChecked(true); - myGroup = SMESH::SMESH_Group::_narrow( theGroup ); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup ); + myGroup = SMESH::SMESH_Group::_narrow( theGroup ); + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup ); myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_narrow( theGroup ); - myFilter = SMESH::Filter::_nil(); + myFilter = SMESH::Filter::_nil(); if (myGroup->_is_nil() && myGroupOnGeom->_is_nil() && myGroupOnFilter->_is_nil() ) return; @@ -778,6 +802,7 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) if (mySelectionMode != theMode) { // [PAL10408] mySelectionMgr->clearSelected(); mySelectionMgr->clearFilters(); + SMESH::RemoveFilters(); if (myActorsList.count() > 0) for (QListIterator it( myActorsList ); it.hasNext(); ) @@ -800,6 +825,12 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) case grpEdgeSelection: if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection); break; + case grpBallSelection: + if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection); + break; + case grp0DSelection: + if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : Elem0DSelection); + break; case grpFaceSelection: if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection); break; @@ -810,15 +841,15 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) SMESH_TypeFilter* f = 0; switch (myTypeId) { - case 0: f = new SMESH_TypeFilter(SUBMESH); break; - case 1: f = new SMESH_TypeFilter(SUBMESH_EDGE); break; - case 2: f = new SMESH_TypeFilter(SUBMESH_FACE); break; - case 3: f = new SMESH_TypeFilter(SUBMESH_SOLID); break; - default:f = new SMESH_TypeFilter(SUBMESH); + case grpNodeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH); break; + case grpEdgeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_EDGE); break; + case grpFaceSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_FACE); break; + case grpVolumeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_SOLID); break; + default: f = new SMESH_TypeFilter(SMESH::SUBMESH); } QList filtList; filtList.append( f ); - filtList.append( new SMESH_TypeFilter(SUBMESH_COMPOUND)); + filtList.append( new SMESH_TypeFilter(SMESH::SUBMESH_COMPOUND)); mySubMeshFilter->setFilters( filtList ); mySelectionMgr->installFilter( mySubMeshFilter ); @@ -830,11 +861,13 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) SMESH_TypeFilter* f = 0; switch (myTypeId) { - case 0: f = new SMESH_TypeFilter(GROUP_NODE); break; - case 1: f = new SMESH_TypeFilter(GROUP_EDGE); break; - case 2: f = new SMESH_TypeFilter(GROUP_FACE); break; - case 3: f = new SMESH_TypeFilter(GROUP_VOLUME); break; - default:f = new SMESH_TypeFilter(GROUP); + case grpNodeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_NODE); break; + case grp0DSelection: f = new SMESH_TypeFilter(SMESH::GROUP_0D); break; + case grpBallSelection: f = new SMESH_TypeFilter(SMESH::GROUP_BALL); break; + case grpEdgeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_EDGE); break; + case grpFaceSelection: f = new SMESH_TypeFilter(SMESH::GROUP_FACE); break; + case grpVolumeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_VOLUME); break; + default: f = new SMESH_TypeFilter(SMESH::GROUP); } QList filtList; filtList.append( f ); @@ -875,10 +908,12 @@ bool SMESHGUI_GroupDlg::onApply() SMESH::ElementType aType = SMESH::ALL; switch (myTypeId) { - case 0: aType = SMESH::NODE; break; - case 1: aType = SMESH::EDGE; break; - case 2: aType = SMESH::FACE; break; - case 3: aType = SMESH::VOLUME; break; + case grpNodeSelection: aType = SMESH::NODE; break; + case grp0DSelection: aType = SMESH::ELEM0D; break; + case grpBallSelection: aType = SMESH::BALL; break; + case grpEdgeSelection: aType = SMESH::EDGE; break; + case grpFaceSelection: aType = SMESH::FACE; break; + case grpVolumeSelection: aType = SMESH::VOLUME; break; } bool anIsOk = false; @@ -1103,7 +1138,7 @@ bool SMESHGUI_GroupDlg::onApply() SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" ); /* init for the next operation */ - myName->setText( "" ); + setDefaultName(); myElements->clear(); myGroup = SMESH::SMESH_Group::_nil(); myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); @@ -1117,11 +1152,22 @@ bool SMESHGUI_GroupDlg::onApply() if ( aMeshGroupSO ) if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) { anActor->setName(myName->text().toLatin1().data()); + QColor c; + int delta; 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; + case grpNodeSelection: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break; + case grp0DSelection: anActor->Set0DColor ( aColor.R, aColor.G, aColor.B ); break; + case grpBallSelection: anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break; + case grpEdgeSelection: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break; + case grpVolumeSelection: + SMESH::GetColor("SMESH", "volume_color", c , delta, "255,0,170|-100"); + anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break; + break; + case grpFaceSelection: + default: + SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100"); + anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break; + break; } } } @@ -1337,21 +1383,17 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() else aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup); _PTR(SObject) aGroupMainShapeSO = - //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape)); aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); _PTR(SObject) anObj, aRef; bool isRefOrSubShape = false; if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) { - //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) { if (aRef->GetID() == aGroupMainShapeSO->GetID()) { isRefOrSubShape = true; } else { _PTR(SObject) aFather = aGroupMainShapeSO->GetFather(); _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent(); - //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) { while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) { - //if (strcmp(aRef->GetID(), aFather->GetID()) == 0) if (aRef->GetID() == aFather->GetID()) isRefOrSubShape = true; else @@ -1658,11 +1700,13 @@ void SMESHGUI_GroupDlg::setFilters() SMESH::ElementType aType = SMESH::ALL; switch ( myTypeId ) { - case 0 : aType = SMESH::NODE; break; - case 1 : aType = SMESH::EDGE; break; - case 2 : aType = SMESH::FACE; break; - case 3 : aType = SMESH::VOLUME; break; - default: return; + case grpNodeSelection: aType = SMESH::NODE; break; + case grp0DSelection: aType = SMESH::ELEM0D; break; + case grpBallSelection: aType = SMESH::BALL; break; + case grpEdgeSelection: aType = SMESH::EDGE; break; + case grpFaceSelection: aType = SMESH::FACE; break; + case grpVolumeSelection: aType = SMESH::VOLUME; break; + default: return; } if ( myFilterDlg == 0 ) @@ -1741,19 +1785,27 @@ void SMESHGUI_GroupDlg::onAdd() SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { - case 0: + case grpNodeSelection: aType = SMESH::NODE; mySelector->SetSelectionMode(NodeSelection); break; - case 1: + case grpBallSelection: + aType = SMESH::BALL; + mySelector->SetSelectionMode(BallSelection); + break; + case grp0DSelection: + aType = SMESH::ELEM0D; + mySelector->SetSelectionMode(Elem0DSelection); + break; + case grpEdgeSelection: aType = SMESH::EDGE; mySelector->SetSelectionMode(EdgeSelection); break; - case 2: + case grpFaceSelection: aType = SMESH::FACE; mySelector->SetSelectionMode(FaceSelection); break; - case 3: + case grpVolumeSelection: aType = SMESH::VOLUME; mySelector->SetSelectionMode(VolumeSelection); break; @@ -1904,10 +1956,10 @@ void SMESHGUI_GroupDlg::onAdd() SMESH::ElementType aGroupType = SMESH::ALL; switch(aGroupOp->GetType(myGeomObjects[0])) { - case 7: aGroupType = SMESH::NODE; break; - case 6: aGroupType = SMESH::EDGE; break; - case 4: aGroupType = SMESH::FACE; break; - case 2: aGroupType = SMESH::VOLUME; break; + case TopAbs_VERTEX: aGroupType = SMESH::NODE; break; + case TopAbs_EDGE: aGroupType = SMESH::EDGE; break; + case TopAbs_FACE: aGroupType = SMESH::FACE; break; + case TopAbs_SOLID: aGroupType = SMESH::VOLUME; break; default: myIsBusy = false; return; } @@ -1984,10 +2036,12 @@ void SMESHGUI_GroupDlg::onRemove() SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { - case 0: aType = SMESH::NODE; break; - case 1: aType = SMESH::EDGE; break; - case 2: aType = SMESH::FACE; break; - case 3: aType = SMESH::VOLUME; break; + case grpNodeSelection: aType = SMESH::NODE; break; + case grp0DSelection: aType = SMESH::ELEM0D; break; + case grpBallSelection: aType = SMESH::BALL; break; + case grpEdgeSelection: aType = SMESH::EDGE; break; + case grpFaceSelection: aType = SMESH::FACE; break; + case grpVolumeSelection: aType = SMESH::VOLUME; break; } if (myCurrentLineEdit == mySubMeshLine) { @@ -2421,7 +2475,7 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor() if( !isAutoColor ) { int r = 0, g = 0, b = 0; - SMESH::GetColor( "SMESH", "fill_color", r, g, b, QColor( 0, 170, 255 ) ); + SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) ); aQColor.setRgb( r, g, b ); } else @@ -2544,10 +2598,12 @@ void SMESHGUI_GroupDlg::setShowEntityMode() if (!myStoredShownEntity) myStoredShownEntity = actor->GetEntityMode(); switch ( myTypeId ) { - case 0: restoreShowEntityMode(); break; - case 1: actor->SetEntityMode( SMESH_Actor::eEdges ); break; - case 2: actor->SetEntityMode( SMESH_Actor::eFaces ); break; - case 3: actor->SetEntityMode( SMESH_Actor::eVolumes ); break; + case grpNodeSelection: restoreShowEntityMode(); break; + case grp0DSelection: actor->SetEntityMode( SMESH_Actor::e0DElements ); break; + case grpBallSelection: actor->SetEntityMode( SMESH_Actor::eBallElem ); break; + case grpEdgeSelection: actor->SetEntityMode( SMESH_Actor::eEdges ); break; + case grpFaceSelection: actor->SetEntityMode( SMESH_Actor::eFaces ); break; + case grpVolumeSelection: actor->SetEntityMode( SMESH_Actor::eVolumes ); break; } } }