From: dmv Date: Thu, 22 Nov 2007 07:12:52 +0000 (+0000) Subject: NPAL 13421 X-Git-Tag: V3_2_9rc2~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c53e1fb6e51d028e7d4d9b7e6507c79fd82b50a6;p=modules%2Fsmesh.git NPAL 13421 --- diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 8c0cd520a..3a575049c 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -88,6 +88,7 @@ // STL includes #include #include +#include using namespace std; @@ -421,6 +422,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myTypeGroup->setButton(0); updateButtons(); + //myName->setText(GetDefaultName(tr("SMESH_GROUP"))); } //================================================================================= @@ -437,6 +439,43 @@ 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( SUIT_Session::session()->activeApplication()->activeStudy() ); + if ( !appStudy ) return aName; + _PTR(Study) aStudy = appStudy->studyDS(); + + std::set 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() // purpose : @@ -478,6 +517,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup) myName->setText(theGroup->GetName()); myName->home(false); + myOldName = myName->text(); myColorSpinBox->setValue( theGroup->GetColorNumber() ); @@ -543,6 +583,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup) aShapeName = aGroupShapeSO->GetName().c_str(); } myGeomGroupLine->setText( aShapeName ); + myName->setText("Group On " + aShapeName); + cout << aShapeName << endl; } } } @@ -612,6 +654,8 @@ void SMESHGUI_GroupDlg::onGrpTypeChanged (int id) { if (myGrpTypeId != id) { myWGStack->raiseWidget( id ); + if (id == 0) + myName->setText(myOldName); onSelectGeomGroup(id == 1); } myGrpTypeId = id; @@ -1108,6 +1152,8 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() } myCurrentLineEdit->setText(aString); + myOldName = myName->text(); + myName->setText(aString); myCurrentLineEdit->home(false); updateButtons(); diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.h b/src/SMESHGUI/SMESHGUI_GroupDlg.h index 13297cc94..7d39e4248 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.h @@ -78,6 +78,8 @@ public: bool modal = FALSE, WFlags fl = 0 ); ~SMESHGUI_GroupDlg(); + static QString GetDefaultName(const QString& theOperation); + public slots: void onAdd(); @@ -142,6 +144,7 @@ private: QButtonGroup* myTypeGroup; QLineEdit* myName; + QString myOldName; QButtonGroup* myGrpTypeGroup; diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index 1c1c76186..155df11d0 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -2506,7 +2506,7 @@ msgid "MEN_HIDE" msgstr "Hide" msgid "MEN_DISPLAY_ONLY" -msgstr "Display only" +msgstr "Show only" #------ TOP -----#