-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013 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
#include <SMESH_TypeFilter.hxx>
#include <SMESH_Actor.h>
-#include <SMESH_ActorUtils.h>
+//#include <SMESH_ActorUtils.h>
#include <SMESH_LogicalFilter.hxx>
// 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,
- 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,
};
//=================================================================================
SMESH::SMESH_Mesh_ptr theMesh )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myStoredShownEntity(0),
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ),
myNameChanged( false ),
const bool theIsConvert )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myStoredShownEntity(0),
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ),
myNameChanged( false ),
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" ) );
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 */
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);
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()));
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 );
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);
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);
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<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 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<SUIT_SelectionFilter*> filtList;
filtList.append( f );
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;
}
QStringList anEntryList;
SMESH::SMESH_GroupBase_var resultGroup;
- bool isCreation;
+ bool isCreation, isConversion = false;
if (myGrpTypeId == 0) // standalone
{
else
myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
- myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
+ isConversion = true;
}
}
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();
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
myFilter = SMESH::Filter::_nil();
+
+ setDefaultGroupColor(); // reset color for case if 'auto-color' feature is enabled.
}
else
{
resultGroup->SetName(myName->text().toLatin1().data());
if ( aMeshGroupSO )
+ {
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
+ if ( isConversion ) { // need to reset TVisualObj and actor
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ SMESH::RemoveVisualObjectWithActors( anIO->getEntry(), true );
+ SMESH::Update( anIO,true);
+ myActorsList.clear();
+ anActor = SMESH::FindActorByEntry( anIO->getEntry() );
+ if ( !anActor ) return false;
+ myActorsList.append( anActor );
+ }
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;
+ SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100");
+ anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break;
+ break;
}
}
+ }
}
SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
{
setIsApplyAndClose( true );
if ( onApply() )
- onClose();
+ reject();
setIsApplyAndClose( false );
+
+ if ( myFilterDlg ) myFilterDlg->UnRegisterFilters();
}
//=================================================================================
// 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());
myElementsLab->setEnabled( !noElemsModif );
myElements->setEnabled ( !noElemsModif );
- myFilterBtn->setEnabled ( !mySelectAll->isChecked() );
+ myFilterBtn->setEnabled ( !noElemsModif );
myAddBtn->setEnabled ( !noElemsModif );
myRemoveBtn->setEnabled ( !noElemsModif );
mySortBtn->setEnabled ( !noElemsModif );
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;
}
myFilterDlg->Init( aType );
}
- myFilterDlg->SetSelection();
myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSelection();
myFilterDlg->SetSourceWg( myElements, false );
myFilterDlg->show();
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;
} 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;
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;
}
}
}
-//=================================================================================
-// function : closeEvent()
-// purpose :
-//=================================================================================
-void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
-{
- onClose();
-}
-
//=================================================================================
// function : onVisibilityChanged()
// purpose :
}
//=================================================================================
-// 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
mySelectionMgr->clearFilters();
mySMESHGUI->ResetState();
- reject();
+ QDialog::reject();
+
+ if ( myFilterDlg ) myFilterDlg->UnRegisterFilters();
}
//=================================================================================
}
}
-//=================================================================================
-// function : hideEvent
-// purpose : caused by ESC key
-//=================================================================================
-void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)
-{
- if (!isMinimized() && !myIsBusy)
- onClose();
-}
-
//=================================================================================
// function : keyPressEvent()
// purpose :
bool isAutoColor = myMesh->GetAutoColor();
- QColor aQColor;
+ QColor aQColor = myColorBtn->color();
if( !isAutoColor )
{
- int r = 0, g = 0, b = 0;
- SMESH::GetColor( "SMESH", "fill_color", r, g, b, QColor( 0, 170, 255 ) );
- aQColor.setRgb( r, g, b );
+ if ( !aQColor.isValid() ) {
+ int r = 0, g = 0, b = 0;
+ SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) );
+ aQColor.setRgb( r, g, b );
+ }
}
else
{
+#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
+ SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
+#else // old algorithm for auto-colors
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
QList<SALOMEDS::Color> aReservedColors;
}
SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
+#endif // SIMPLE_AUTOCOLOR
+
aQColor.setRgb( (int)( aColor.R * 255.0 ),
(int)( aColor.G * 255.0 ),
(int)( aColor.B * 255.0 ) );
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;
}
}
}