-// 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
// SALOME GEOM includes
#include <GEOMBase.h>
#include <GEOM_SelectionFilter.h>
+#include <GEOM_wrap.hxx>
// SALOME GUI includes
#include <QtxColorButton.h>
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,
};
//=================================================================================
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" ) );
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 );
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()));
mySMESHGUI->SetState(800);
mySelectionMode = grpNoSelection;
- myMeshFilter = new SMESH_TypeFilter(MESH);
+ myMeshFilter = new SMESH_TypeFilter(SMESH::MESH);
mySubMeshFilter = new SMESH_LogicalFilter(QList<SUIT_SelectionFilter*>(),
SMESH_LogicalFilter::LO_OR,
/*takeOwnership=*/true);
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 :
SetAppropriateActor();
setDefaultGroupColor();
+ setDefaultName();
+
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
- const bool theIsConvert)
+ const bool theIsConvert)
{
restoreShowEntityMode();
myMesh = theGroup->GetMesh();
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;
if (mySelectionMode != theMode) {
// [PAL10408] mySelectionMgr->clearSelected();
mySelectionMgr->clearFilters();
+ SMESH::RemoveFilters();
if (myActorsList.count() > 0)
for (QListIterator<SMESH_Actor*> it( myActorsList ); it.hasNext(); )
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;
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<SUIT_SelectionFilter*> 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 );
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<SUIT_SelectionFilter*> filtList;
filtList.append( f );
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;
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,
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;
}
}
- 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()) {
SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
/* init for the next operation */
- myName->setText( "" );
+ setDefaultName();
myElements->clear();
myGroup = SMESH::SMESH_Group::_nil();
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
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:
- {
- QColor c;
- int delta;
+ 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;
}
}
}
// 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->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
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 )
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;
} 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;
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;
}
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) {
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
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;
}
}
}