-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 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
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <SMESH_TypeFilter.hxx>
#include <SMESH_Actor.h>
-#include <SMESH_ActorUtils.h>
+//#include <SMESH_ActorUtils.h>
#include <SMESH_LogicalFilter.hxx>
// SALOME GEOM includes
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
#include <SalomeApp_Tools.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
#include <SVTK_ViewWindow.h>
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 ),
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->SetActiveDialogBox(this);
mySMESHGUI->SetState(800);
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
mySelectionMode = grpNoSelection;
- myMeshFilter = new SMESH_TypeFilter(SMESH::MESH);
+
+ myMeshFilter = new SMESH_TypeFilter(SMESH::MESH);
mySubMeshFilter = new SMESH_LogicalFilter(QList<SUIT_SelectionFilter*>(),
SMESH_LogicalFilter::LO_OR,
/*takeOwnership=*/true);
- myGroupFilter = new SMESH_LogicalFilter(QList<SUIT_SelectionFilter*>(),
- SMESH_LogicalFilter::LO_OR,
- /*takeOwnership=*/true);
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
- myGeomFilter = new GEOM_SelectionFilter( aStudy, true );
+ myGroupFilter = 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()));
bool isUnique = false;
while (!isUnique) {
aName = theOperation + "_" + QString::number(++aNumber);
- isUnique = (aSet.count(aName.toLatin1().data()) == 0);
+ isUnique = (aSet.count(std::string(SMESH::toUtf8(aName))) == 0);
}
return aName;
do
{
aResName = aPrefix + QString::number( i++ );
- anObj = aStudy->FindObject( aResName.toLatin1().data() );
+ anObj = aStudy->FindObject( SMESH::toUtf8(aResName) );
}
while ( anObj );
myName->setText(aResName);
if( !aList.IsEmpty() )
{
QString aName = aList.First()->getName();
- myMeshGroupLine->setText(aName);
+ myMeshGroupLine->setText(aName);//??????
myMeshGroupLine->home( false );
}
myNameChanged = true;
myName->blockSignals(true);
- myName->setText(theGroup->GetName());
+ myName->setText(SMESH::fromUtf8(theGroup->GetName()));
myName->blockSignals(false);
myName->home(false);
SALOMEDS::Color aColor = theGroup->GetColor();
setGroupColor( aColor );
- myMeshGroupLine->setText(theGroup->GetName());
+ myMeshGroupLine->setText(SMESH::fromUtf8(theGroup->GetName()));
int aType = 0;
switch(theGroup->GetType()) {
{
myNameChanged = true;
myName->blockSignals(true);
- myName->setText(theGroup->GetName());
+ myName->setText(SMESH::fromUtf8(theGroup->GetName()));
myName->blockSignals(false);
}
}
}
+ bool meshHasGeom = ( myMesh->_is_nil() || myMesh->HasShapeToMesh() );
+ if ( myGrpTypeId != 1 )
+ {
+ myGrpTypeGroup->button(1)->setEnabled( meshHasGeom );
+ }
+ else
+ {
+ myGeomGroupBtn->setEnabled( meshHasGeom );
+ myGeomGroupLine->setEnabled( meshHasGeom );
+ }
+
myOKBtn->setEnabled(enable);
myApplyBtn->setEnabled(enable);
}
QStringList anEntryList;
SMESH::SMESH_GroupBase_var resultGroup;
- bool isCreation;
+ bool isCreation, isConversion = false;
+ SUIT_OverrideCursor wc;
+
if (myGrpTypeId == 0) // standalone
{
if (!mySelectAll->isChecked() && !myElements->count() && myAllowElemsModif->isChecked())
else
myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
- myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
+ isConversion = true;
}
}
if (myGeomObjects->length() == 1) {
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
- myName->text().toLatin1().data(),
+ SMESH::toUtf8(myName->text()),
myGeomObjects[0]);
}
else {
aNewGeomGroupName += myName->text();
SALOMEDS::SObject_var aNewGroupSO =
geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar,
- aNewGeomGroupName.toLatin1().data(), aMeshShape);
+ SMESH::toUtf8(aNewGeomGroupName), aMeshShape);
}
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
- myName->text().toLatin1().data(),
+ SMESH::toUtf8(myName->text()),
aGroupVar);
}
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom );
return false;
myGroupOnFilter = myMesh->CreateGroupFromFilter(aType,
- myName->text().toLatin1().data(),
+ SMESH::toUtf8(myName->text()),
myFilter);
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter );
if( aMeshGroupSO )
anEntryList.append( aMeshGroupSO->GetID().c_str() );
+ resultGroup->SetName(SMESH::toUtf8(myName->text().trimmed()));
+
if ( isCreation )
{
SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
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())) {
- anActor->setName(myName->text().toLatin1().data());
+ {
+ if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str()))
+ {
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ if ( isConversion ) { // need to reset TVisualObj and actor
+ 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(SMESH::toUtf8(myName->text()));
QColor c;
int delta;
switch ( myTypeId ) {
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;
+ 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;
+ SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100");
+ anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break;
+ break;
+ }
+ // update a visible group accoding to a changed contents
+ if ( !isConversion && anActor->GetVisibility() )
+ {
+ SMESH::Update( anIO, true );
+ SMESH::RepaintCurrentView();
}
}
+ }
}
SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
- SMESH::UpdateView(); // asv: fix of BUG PAL5515
mySelectionMgr->clearSelected();
if( LightApp_Application* anApp =
{
setIsApplyAndClose( true );
if ( onApply() )
- onClose();
+ reject();
setIsApplyAndClose( false );
+
+ if ( myFilterDlg ) myFilterDlg->UnRegisterFilters();
}
//=================================================================================
// any visible actor of group or submesh of myMesh
SetAppropriateActor();
+ setDefaultGroupColor();
+ if (myName->text().isEmpty())
+ setDefaultName();
+
aString = aList.First()->getName();
myMeshGroupLine->setText(aString);
myMeshGroupLine->home( false );
myElementsLab->setEnabled( !noElemsModif );
myElements->setEnabled ( !noElemsModif );
- myFilterBtn->setEnabled ( !mySelectAll->isChecked() );
+ myFilterBtn->setEnabled ( !noElemsModif );
myAddBtn->setEnabled ( !noElemsModif );
myRemoveBtn->setEnabled ( !noElemsModif );
mySortBtn->setEnabled ( !noElemsModif );
//=================================================================================
// function : (onSelectGeomGroup)
-// purpose : Called when group type changed. on == "on group" or "on filter"
+// purpose : Called when group type changed. on == "on geometry" or "on filter"
//=================================================================================
void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
{
else if (mySelectGroup->isChecked()) {
mySelectGroup->setChecked(false);
}
- if ( myGrpTypeId == 1 ) { // on group
+ if ( myGrpTypeId == 1 ) { // on geometry
myCurrentLineEdit = myGeomGroupLine;
updateGeomPopup();
}
myFilterDlg->Init( aType );
}
- myFilterDlg->SetSelection();
+ bool isStandalone = ( sender() == myFilterBtn );
+ myFilterDlg->SetEnabled( /*setInViewer=*/isStandalone,
+ /*diffSources=*/isStandalone );
myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetGroup( myGroupOnFilter );
+ myFilterDlg->SetSelection();
myFilterDlg->SetSourceWg( myElements, false );
myFilterDlg->show();
}
}
-//=================================================================================
-// 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", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) );
- 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 ) );