mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-05 06:10:33 +05:00
NPAL 13421 Default name for group from geometry
This commit is contained in:
parent
415771a7d5
commit
418f13af92
@ -90,6 +90,7 @@
|
|||||||
// STL includes
|
// STL includes
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -416,6 +417,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create)
|
|||||||
myTypeGroup->setButton(0);
|
myTypeGroup->setButton(0);
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
//myName->setText(GetDefaultName(tr("SMESH_GROUP")));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -432,6 +434,42 @@ SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : GetDefaultName()
|
||||||
|
// purpose : Get the Group Name if Create new Group
|
||||||
|
//=================================================================================
|
||||||
|
QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
|
||||||
|
{
|
||||||
|
QString aName = "";
|
||||||
|
|
||||||
|
// collect all object names of SMESH component
|
||||||
|
SalomeApp_Study* appStudy =
|
||||||
|
dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||||
|
if ( !appStudy ) return aName;
|
||||||
|
_PTR(Study) aStudy = appStudy->studyDS();
|
||||||
|
|
||||||
|
std::set<std::string> aSet;
|
||||||
|
_PTR(SComponent) aMeshCompo (aStudy->FindComponent("SMESH"));
|
||||||
|
if (aMeshCompo) {
|
||||||
|
_PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo));
|
||||||
|
_PTR(SObject) obj;
|
||||||
|
for (it->InitEx(true); it->More(); it->Next()) {
|
||||||
|
obj = it->Value();
|
||||||
|
aSet.insert(obj->GetName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// build a unique name
|
||||||
|
int aNumber = 0;
|
||||||
|
bool isUnique = false;
|
||||||
|
while (!isUnique) {
|
||||||
|
aName = theOperation + "_" + QString::number(++aNumber);
|
||||||
|
isUnique = (aSet.count(aName.latin1()) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return aName;
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : Init()
|
// function : Init()
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -475,6 +513,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
|
|||||||
|
|
||||||
myName->setText(theGroup->GetName());
|
myName->setText(theGroup->GetName());
|
||||||
myName->home(false);
|
myName->home(false);
|
||||||
|
myOldName = myName->text();
|
||||||
|
|
||||||
SALOMEDS::Color aColor = theGroup->GetColor();
|
SALOMEDS::Color aColor = theGroup->GetColor();
|
||||||
setGroupColor( aColor );
|
setGroupColor( aColor );
|
||||||
@ -541,6 +580,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
|
|||||||
aShapeName = aGroupShapeSO->GetName().c_str();
|
aShapeName = aGroupShapeSO->GetName().c_str();
|
||||||
}
|
}
|
||||||
myGeomGroupLine->setText( aShapeName );
|
myGeomGroupLine->setText( aShapeName );
|
||||||
|
myName->setText("Group On " + aShapeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,6 +641,8 @@ void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
|
|||||||
{
|
{
|
||||||
if (myGrpTypeId != id) {
|
if (myGrpTypeId != id) {
|
||||||
myWGStack->raiseWidget( id );
|
myWGStack->raiseWidget( id );
|
||||||
|
if (id == 0)
|
||||||
|
myName->setText(myOldName);
|
||||||
onSelectGeomGroup(id == 1);
|
onSelectGeomGroup(id == 1);
|
||||||
}
|
}
|
||||||
myGrpTypeId = id;
|
myGrpTypeId = id;
|
||||||
@ -1115,6 +1157,8 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
myCurrentLineEdit->setText(aString);
|
myCurrentLineEdit->setText(aString);
|
||||||
|
myOldName = myName->text();
|
||||||
|
myName->setText(aString);
|
||||||
myCurrentLineEdit->home(false);
|
myCurrentLineEdit->home(false);
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
@ -80,6 +80,8 @@ public:
|
|||||||
bool modal = FALSE, WFlags fl = 0 );
|
bool modal = FALSE, WFlags fl = 0 );
|
||||||
~SMESHGUI_GroupDlg();
|
~SMESHGUI_GroupDlg();
|
||||||
|
|
||||||
|
static QString GetDefaultName(const QString& theOperation);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onAdd();
|
void onAdd();
|
||||||
@ -152,6 +154,7 @@ private:
|
|||||||
|
|
||||||
QButtonGroup* myTypeGroup;
|
QButtonGroup* myTypeGroup;
|
||||||
QLineEdit* myName;
|
QLineEdit* myName;
|
||||||
|
QString myOldName;
|
||||||
|
|
||||||
QButtonGroup* myGrpTypeGroup;
|
QButtonGroup* myGrpTypeGroup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user