From f7c91a241b174bed2137eab82b37c399d4886c82 Mon Sep 17 00:00:00 2001 From: mzn Date: Mon, 13 Mar 2006 10:18:53 +0000 Subject: [PATCH] Fix for bug Bug IPAL11402 ( Group on geometry isn't editable ). --- src/SMESHGUI/SMESHGUI.cxx | 6 +- src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 187 +++++++++++++++++++---------- src/SMESHGUI/SMESHGUI_GroupDlg.h | 6 +- 3 files changed, 130 insertions(+), 69 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index fed0714ab..b8d0b6bd8 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1592,8 +1592,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) int nbSelectedGroups = 0; for ( ; It.More(); It.Next() ) { - SMESH::SMESH_Group_var aGroup = - SMESH::IObjectToInterface(It.Value()); + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(It.Value()); if (!aGroup->_is_nil()) { nbSelectedGroups++; SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup); @@ -1602,7 +1602,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } if (nbSelectedGroups == 0) { - SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_Group::_nil()); + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil()); aDlg->show(); } break; diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 1c2009ff9..84c05cac3 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -110,7 +110,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, // purpose : //================================================================================= SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, - SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl) + SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl) : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), mySMESHGUI( theModule ), @@ -276,6 +276,12 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myGeomGroupLine->setReadOnly(true); //VSR ??? onSelectGeomGroup(false); + if (!create) + { + myGeomGroupBtn->setEnabled(false); + myGeomGroupLine->setEnabled(false); + } + /***************************************************************/ QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 ); wg2Layout->addWidget(geomObject, 0, 0); @@ -366,8 +372,8 @@ void SMESHGUI_GroupDlg::initDialog(bool create) connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool))); - - + connect(myColorGroupLine, SIGNAL(textChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&))); + connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); @@ -419,6 +425,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) /* init data from current selection */ myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); myGroup = SMESH::SMESH_Group::_nil(); + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); myActor = SMESH::FindActorByObject(myMesh); SMESH::SetPickable(myActor); @@ -442,15 +449,17 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) // function : Init() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup) +void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup) { myMesh = theGroup->GetMesh(); - myGroup = SMESH::SMESH_Group::_duplicate(theGroup); - myActor = SMESH::FindActorByObject(myMesh); - if ( !myActor ) - myActor = SMESH::FindActorByObject(myGroup); - SMESH::SetPickable(myActor); + myName->setText(theGroup->GetName()); + myName->home(false); + + myColorGroupLine->setText(QString::number(theGroup->GetColorNumber())); + myColorGroupLine->home(false); + + myMeshGroupLine->setText(theGroup->GetName()); int aType = 0; switch(theGroup->GetType()) { @@ -459,31 +468,61 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup) case SMESH::FACE: aType = 2; break; case SMESH::VOLUME: aType = 3; break; } - - myName->setText(myGroup->GetName()); - myName->home(false); - - myColorGroupLine->setText(QString::number(myGroup->GetColorNumber())); - myColorGroupLine->home(false); + myTypeGroup->setButton(aType); - myMeshGroupLine->setText(myGroup->GetName()); + myGroup = SMESH::SMESH_Group::_narrow( theGroup ); - myCurrentLineEdit = 0; - myTypeGroup->setButton(aType); - myElements->clear(); - setSelectionMode(aType); - myTypeId = aType; - - myIdList.clear(); - if (!theGroup->IsEmpty()) { - SMESH::long_array_var anElements = myGroup->GetListOfID(); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - myIdList.append(anElements[i]); - myElements->insertItem(QString::number(anElements[i])); + if ( !myGroup->_is_nil() ) + { + myGrpTypeGroup->setButton(0); + onGrpTypeChanged(0); + + myActor = SMESH::FindActorByObject(myMesh); + if ( !myActor ) + myActor = SMESH::FindActorByObject(myGroup); + SMESH::SetPickable(myActor); + + myCurrentLineEdit = 0; + myElements->clear(); + setSelectionMode(aType); + myTypeId = aType; + + myIdList.clear(); + if (!myGroup->IsEmpty()) { + SMESH::long_array_var anElements = myGroup->GetListOfID(); + int k = anElements->length(); + for (int i = 0; i < k; i++) { + myIdList.append(anElements[i]); + myElements->insertItem(QString::number(anElements[i])); + } + myElements->selectAll(true); + } + } + else + { + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup ); + + if ( !myGroupOnGeom->_is_nil() ) + { + myGrpTypeGroup->setButton(1); + onGrpTypeChanged(1); + + myActor = SMESH::FindActorByObject(myMesh); + if ( !myActor ) + myActor = SMESH::FindActorByObject(myGroup); + SMESH::SetPickable(myActor); + + QString aShapeName(""); + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape(); + if (!aGroupShape->_is_nil()) + { + _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry()); + aShapeName = aGroupShapeSO->GetName().c_str(); + } + myGeomGroupLine->setText( aShapeName ); + } } - myElements->selectAll(true); - } } //================================================================================= @@ -497,7 +536,10 @@ void SMESHGUI_GroupDlg::updateButtons() if (myGrpTypeId == 0) enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0; else if (myGrpTypeId == 1) - enable = !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup ); + { + bool isEditMode = !CORBA::is_nil( myGroupOnGeom ); + enable = !myName->text().stripWhiteSpace().isEmpty() && (!CORBA::is_nil( myGeomGroup ) || isEditMode); + } QPushButton* aBtn; aBtn = (QPushButton*) child("ok", "QPushButton"); if (aBtn) aBtn->setEnabled(enable); @@ -514,6 +556,15 @@ void SMESHGUI_GroupDlg::onNameChanged (const QString& text) updateButtons(); } +//================================================================================= +// function : onNbColorsChanged() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text) +{ + updateButtons(); +} + //================================================================================= // function : onTypeChanged() // purpose : Group elements type radio button management @@ -634,11 +685,7 @@ bool SMESHGUI_GroupDlg::onApply() /* init for next operation */ myName->setText(""); - myColorGroupLine->setText(""); - - /* init for next operation */ - myName->setText(""); myElements->clear(); myGroup = SMESH::SMESH_Group::_nil(); @@ -687,40 +734,50 @@ bool SMESHGUI_GroupDlg::onApply() return true; } else if (myGrpTypeId == 1 && !myName->text().stripWhiteSpace().isEmpty() && - !CORBA::is_nil(myGeomGroup)) + (!CORBA::is_nil(myGeomGroup) || !CORBA::is_nil(myGroupOnGeom))) { - 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; + if (myGroupOnGeom->_is_nil()) { + 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; + } + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); + + int aColorNumber = myColorGroupLine->text().toInt(); + myGroupOnGeom->SetColorNumber(aColorNumber); + + _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom); + + SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text()); + + SMESH::setFileType (aMeshGroupSO,"COULEURGROUP"); + + /* init for next operation */ + myName->setText(""); + myColorGroupLine->setText(""); + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); } - - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = - SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); - - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = - myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); - - int aColorNumber = myColorGroupLine->text().toInt(); - aGroupOnGeom->SetColorNumber(aColorNumber); - - _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(aGroupOnGeom); - - SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text()); - - SMESH::setFileType (aMeshGroupSO,"COULEURGROUP"); + else + { + myGroupOnGeom->SetName(myName->text()); + + int aColorNumber = myColorGroupLine->text().toInt(); + myGroupOnGeom->SetColorNumber(aColorNumber); + } mySMESHGUI->updateObjBrowser(true); mySelectionMgr->clearSelected(); - /* init for next operation */ - myName->setText(""); - myColorGroupLine->setText(""); return true; } - + return false; } @@ -825,7 +882,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myGeomGroupLine->setEnabled(true); updateButtons(); } else { - SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); + SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface(IO); if (aGroup->_is_nil()) { myIsBusy = false; @@ -958,6 +1015,8 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() if (!myActor) { if (!myGroup->_is_nil()) myActor = SMESH::FindActorByObject(myGroup); + else if(!myGroupOnGeom->_is_nil()) + myActor = SMESH::FindActorByObject(myGroupOnGeom); else myActor = SMESH::FindActorByObject(myMesh); } diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.h b/src/SMESHGUI/SMESHGUI_GroupDlg.h index e33e84639..3d741d43d 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.h @@ -69,7 +69,7 @@ public: bool modal = FALSE, WFlags fl = 0 ); SMESHGUI_GroupDlg( SMESHGUI*, const char* name, - SMESH::SMESH_Group_ptr theGroup, + SMESH::SMESH_GroupBase_ptr theGroup, bool modal = FALSE, WFlags fl = 0 ); ~SMESHGUI_GroupDlg(); @@ -102,12 +102,13 @@ private slots: void onSort(); void onNameChanged(const QString& text); + void onNbColorsChanged(const QString& text); void onFilterAccepted(); private: void initDialog(bool create); void init(SMESH::SMESH_Mesh_ptr theMesh); - void init(SMESH::SMESH_Group_ptr theGroup); + void init(SMESH::SMESH_GroupBase_ptr theGroup); void closeEvent(QCloseEvent* e); void enterEvent (QEvent*); void hideEvent (QHideEvent*); /* ESC key */ @@ -151,6 +152,7 @@ private: SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Group_var myGroup; + SMESH::SMESH_GroupOnGeom_var myGroupOnGeom; QValueList myIdList; GEOM::GEOM_Object_var myGeomGroup; -- 2.39.2