X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=be401f774e99ce65b61b4e26e34fa79842b7ade3;hp=10995de1942a6c74074942ad7e8ebf7c27e5fddd;hb=4cd2499bddcd3da3ec8900fe825bc98669b789b5;hpb=1d17e561d72445f7f4f818de637ae0272a204780 diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 10995de19..be401f774 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -44,6 +44,7 @@ // SALOME GEOM includes #include #include +#include // SALOME GUI includes #include @@ -103,15 +104,16 @@ enum grpSelectionMode { grpNoSelection = -1, grpNodeSelection = 0, - grpBallSelection = 1, - grpEdgeSelection = 2, - grpFaceSelection = 3, - grpVolumeSelection = 4, - grpSubMeshSelection = 5, - grpGroupSelection = 6, - grpMeshSelection = 7, - grpGeomSelection = 8, - grpAllSelection = 9, + grp0DSelection = 1, + grpBallSelection = 2, + grpEdgeSelection = 3, + grpFaceSelection = 4, + grpVolumeSelection = 5, + grpSubMeshSelection = 6, + grpGroupSelection = 7, + grpMeshSelection = 8, + grpGeomSelection = 9, + grpAllSelection = 10, }; //================================================================================= @@ -214,6 +216,7 @@ 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" ) ); @@ -436,7 +439,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); - connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); + connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); /* Init selection */ @@ -444,7 +447,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); @@ -455,7 +458,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) myGeomFilter = new GEOM_SelectionFilter( aStudy, true ); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); connect(mySMESHGUI, SIGNAL(SignalVisibilityChanged()), this, SLOT(onVisibilityChanged())); @@ -521,6 +524,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 : @@ -543,6 +562,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) SetAppropriateActor(); setDefaultGroupColor(); + setDefaultName(); + SALOME_ListIO aList; mySelectionMgr->selectedObjects( aList ); @@ -583,11 +604,12 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, int aType = 0; switch(theGroup->GetType()) { - case SMESH::NODE: aType = 0; break; - case SMESH::BALL: aType = 1; break; - case SMESH::EDGE: aType = 2; break; - case SMESH::FACE: aType = 3; break; - case SMESH::VOLUME: aType = 4; 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); @@ -805,7 +827,10 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection); break; case grpBallSelection: - //if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection); + 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); @@ -817,15 +842,15 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) SMESH_TypeFilter* f = 0; switch (myTypeId) { - case grpNodeSelection: f = new SMESH_TypeFilter(SUBMESH); break; - case grpEdgeSelection: f = new SMESH_TypeFilter(SUBMESH_EDGE); break; - case grpFaceSelection: f = new SMESH_TypeFilter(SUBMESH_FACE); break; - case grpVolumeSelection: 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 ); @@ -837,12 +862,13 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) SMESH_TypeFilter* f = 0; switch (myTypeId) { - case grpNodeSelection: f = new SMESH_TypeFilter(GROUP_NODE); break; - case grpBallSelection: f = new SMESH_TypeFilter(GROUP_BALL); break; - case grpEdgeSelection: f = new SMESH_TypeFilter(GROUP_EDGE); break; - case grpFaceSelection: f = new SMESH_TypeFilter(GROUP_FACE); break; - case grpVolumeSelection: 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 ); @@ -883,10 +909,11 @@ bool SMESHGUI_GroupDlg::onApply() SMESH::ElementType aType = SMESH::ALL; switch (myTypeId) { - case grpNodeSelection: aType = SMESH::NODE; break; - case grpBallSelection: aType = SMESH::BALL; break; - case grpEdgeSelection: aType = SMESH::EDGE; break; - case grpFaceSelection: aType = SMESH::FACE; 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; } @@ -1007,8 +1034,6 @@ bool SMESHGUI_GroupDlg::onApply() return false; _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = - SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); if (myGeomObjects->length() == 1) { myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, @@ -1027,8 +1052,7 @@ bool SMESHGUI_GroupDlg::onApply() if (geomGen->_is_nil() || !aStudy) return false; - GEOM::GEOM_IGroupOperations_var op = - geomGen->GetIGroupOperations(aStudy->StudyId()); + GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId()); if (op->_is_nil()) return false; @@ -1045,8 +1069,8 @@ bool SMESHGUI_GroupDlg::onApply() } } - GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); - GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType); + GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); + GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType); op->UnionList(aGroupVar, myGeomObjects); if (op->IsDone()) { @@ -1112,7 +1136,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(); @@ -1126,17 +1150,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 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 grpFaceSelection: 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: - QColor c; - int delta; SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100"); anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break; + break; } } } @@ -1160,7 +1189,7 @@ void SMESHGUI_GroupDlg::onOK() { setIsApplyAndClose( true ); if ( onApply() ) - onClose(); + reject(); setIsApplyAndClose( false ); } @@ -1342,15 +1371,19 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() // Check if group constructed on the same shape as a mesh or on its child _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var anOp = - SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); // The main shape of the group GEOM::GEOM_Object_var aGroupMainShape; - if (aGeomGroup->GetType() == 37) + if (aGeomGroup->GetType() == 37) { + GEOM::GEOM_IGroupOperations_wrap anOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); aGroupMainShape = anOp->GetMainShape(aGeomGroup); - else - aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup); + // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap + } + else { + aGroupMainShape = aGeomGroup; + aGroupMainShape->Register(); + } _PTR(SObject) aGroupMainShapeSO = aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); @@ -1669,10 +1702,11 @@ void SMESHGUI_GroupDlg::setFilters() SMESH::ElementType aType = SMESH::ALL; switch ( myTypeId ) { - case grpNodeSelection: aType = SMESH::NODE; break; - case grpBallSelection: aType = SMESH::BALL; break; - case grpEdgeSelection: aType = SMESH::EDGE; break; - case grpFaceSelection: aType = SMESH::FACE; 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; default: return; } @@ -1759,7 +1793,11 @@ void SMESHGUI_GroupDlg::onAdd() break; case grpBallSelection: aType = SMESH::BALL; - //mySelector->SetSelectionMode(BallSelection); + mySelector->SetSelectionMode(BallSelection); + break; + case grp0DSelection: + aType = SMESH::ELEM0D; + mySelector->SetSelectionMode(Elem0DSelection); break; case grpEdgeSelection: aType = SMESH::EDGE; @@ -1915,7 +1953,7 @@ void SMESHGUI_GroupDlg::onAdd() } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) { _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = + GEOM::GEOM_IGroupOperations_wrap aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); SMESH::ElementType aGroupType = SMESH::ALL; @@ -2000,10 +2038,11 @@ void SMESHGUI_GroupDlg::onRemove() SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { - case grpNodeSelection: aType = SMESH::NODE; break; - case grpBallSelection: aType = SMESH::BALL; break; - case grpEdgeSelection: aType = SMESH::EDGE; break; - case grpFaceSelection: aType = SMESH::FACE; 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; } @@ -2126,15 +2165,6 @@ void SMESHGUI_GroupDlg::onSort() } } -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*) -{ - onClose(); -} - //================================================================================= // function : onVisibilityChanged() // purpose : @@ -2145,10 +2175,10 @@ void SMESHGUI_GroupDlg::onVisibilityChanged() } //================================================================================= -// function : SMESHGUI_GroupDlg::onClose +// function : SMESHGUI_GroupDlg::reject // purpose : SLOT called when "Close" button pressed. Close dialog //================================================================================= -void SMESHGUI_GroupDlg::onClose() +void SMESHGUI_GroupDlg::reject() { if (SMESH::GetCurrentVtkView()) { SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters @@ -2169,7 +2199,7 @@ void SMESHGUI_GroupDlg::onClose() mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); - reject(); + QDialog::reject(); } //================================================================================= @@ -2223,16 +2253,6 @@ void SMESHGUI_GroupDlg::enterEvent (QEvent*) } } -//================================================================================= -// function : hideEvent -// purpose : caused by ESC key -//================================================================================= -void SMESHGUI_GroupDlg::hideEvent (QHideEvent*) -{ - if (!isMinimized() && !myIsBusy) - onClose(); -} - //================================================================================= // function : keyPressEvent() // purpose : @@ -2438,7 +2458,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 @@ -2561,11 +2581,12 @@ void SMESHGUI_GroupDlg::setShowEntityMode() if (!myStoredShownEntity) myStoredShownEntity = actor->GetEntityMode(); switch ( myTypeId ) { - case grpNodeSelection: restoreShowEntityMode(); 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; + 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; } } }