X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=5c473f329130f60745b98633ed4008434385e730;hp=5f7b9da9d6ab6ff4fd177efdab650a8b2a62625f;hb=104ff7b2818ce4d0f8a38d840abd3e5c70190668;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 5f7b9da9d..5c473f329 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -43,8 +43,11 @@ #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" #include "SalomeApp_Tools.h" +#include "LightApp_Application.h" #include "SALOMEDSClient_Study.hxx" #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" @@ -73,6 +76,8 @@ #include #include +#include + // STL includes #include #include @@ -89,8 +94,9 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, WStyle_Title | WStyle_SysMenu | WDestructiveClose), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + mySelector(SMESH::GetViewWindow( theModule )->GetSelector()), + myIsBusy( false ), + myActor( 0 ) { if (!name) setName("SMESHGUI_GroupDlg"); initDialog(true); @@ -102,11 +108,6 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name, myGeomGroupBtn->setEnabled(false); myGeomGroupLine->setEnabled(false); } - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); } //================================================================================= @@ -114,27 +115,26 @@ 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 ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + mySelector(SMESH::GetViewWindow( theModule )->GetSelector()), + myIsBusy( false ) { if (!name) setName("SMESHGUI_GroupDlg"); + initDialog(false); if (!theGroup->_is_nil()) init(theGroup); else { mySelectSubMesh->setEnabled(false); mySelectGroup->setEnabled(false); - } - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); + myCurrentLineEdit = myMeshGroupLine; + setSelectionMode(5); + } } //================================================================================= @@ -147,12 +147,16 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myCreate = create; myCurrentLineEdit = 0; - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); - if (create) + if (create) { setCaption(tr("SMESH_CREATE_GROUP_TITLE")); - else + myHelpFileName = "/files/creating_groups.htm"; + } + else { setCaption(tr("SMESH_EDIT_GROUP_TITLE")); + myHelpFileName = "/files/editing_groups.htm"; + } setSizeGripEnabled(TRUE); @@ -264,7 +268,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myGroupLine = new QLineEdit(aSelectBox, "group line"); myGroupLine->setReadOnly(true); onSelectGroup(false); - + /***************************************************************/ QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 ); wg1Layout->addWidget(aContentBox, 0, 0); @@ -281,6 +285,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); @@ -296,6 +306,21 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) ); /***************************************************************/ + QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box"); + aColorBox->setTitle(tr("SMESH_SET_COLOR")); + + mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox"); + mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR")); + + myColorSpinBox = new QtxIntSpinBox( aColorBox ); + myColorSpinBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + myColorSpinBox->setMinValue( 0 ); + myColorSpinBox->setMaxValue( 9999 ); + + onSelectColorGroup(false); + + /***************************************************************/ + QFrame* aButtons = new QFrame(this, "button box"); aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken); QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6); @@ -311,11 +336,15 @@ void SMESHGUI_GroupDlg::initDialog(bool create) QPushButton* aCloseBtn = new QPushButton(aButtons, "close"); aCloseBtn->setText(tr("SMESH_BUT_CLOSE")); aCloseBtn->setAutoDefault(true); + QPushButton* aHelpBtn = new QPushButton(aButtons, "help"); + aHelpBtn->setText(tr("SMESH_BUT_HELP")); + aHelpBtn->setAutoDefault(true); aBtnLayout->addWidget(aOKBtn); aBtnLayout->addWidget(aApplyBtn); aBtnLayout->addStretch(); aBtnLayout->addWidget(aCloseBtn); + aBtnLayout->addWidget(aHelpBtn); /***************************************************************/ aMainLayout->addWidget(meshGroupLab, 0, 0); @@ -327,7 +356,8 @@ void SMESHGUI_GroupDlg::initDialog(bool create) aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2); aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2); aMainLayout->setRowStretch( 5, 5 ); - aMainLayout->addMultiCellWidget(aButtons, 6, 6, 0, 2); + aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2); + aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2); /* signals and slots connections */ connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); @@ -349,10 +379,13 @@ void SMESHGUI_GroupDlg::initDialog(bool create) connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); - + connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool))); + connect(myColorSpinBox, SIGNAL(valueChanged(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())); + connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); /* Init selection */ mySMESHGUI->SetActiveDialogBox(this); @@ -396,18 +429,24 @@ SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg() //================================================================================= void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) { + mySelectionMgr->installFilter(myMeshFilter); + /* 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); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); - - QString aName = aList.First()->getName(); - myMeshGroupLine->setText(aName) ; - myMeshGroupLine->home( false ); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + if( !aList.IsEmpty() ) + { + QString aName = aList.First()->getName(); + myMeshGroupLine->setText(aName) ; + myMeshGroupLine->home( false ); + } myCurrentLineEdit = 0; @@ -419,15 +458,16 @@ 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); + + myName->setText(theGroup->GetName()); + myName->home(false); - myActor = SMESH::FindActorByObject(myMesh); - if ( !myActor ) - myActor = SMESH::FindActorByObject(myGroup); - SMESH::SetPickable(myActor); + myColorSpinBox->setValue( theGroup->GetColorNumber() ); + + myMeshGroupLine->setText(theGroup->GetName()); int aType = 0; switch(theGroup->GetType()) { @@ -436,27 +476,61 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup) case SMESH::FACE: aType = 2; break; case SMESH::VOLUME: aType = 3; break; } + myTypeGroup->setButton(aType); + + myGroup = SMESH::SMESH_Group::_narrow( theGroup ); - myName->setText(myGroup->GetName()); - myName->home(false); - myMeshGroupLine->setText(myGroup->GetName()); + if ( !myGroup->_is_nil() ) + { + myGrpTypeGroup->setButton(0); + onGrpTypeChanged(0); - 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])); + 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); - } } //================================================================================= @@ -470,7 +544,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); @@ -487,6 +564,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 @@ -525,7 +611,7 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) return; if (mySelectionMode != theMode) { - mySelectionMgr->clearSelected(); + // [PAL10408] mySelectionMgr->clearSelected(); mySelectionMgr->clearFilters(); SMESH::SetPointRepresentation(false); if (theMode < 4) { @@ -535,25 +621,30 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) myActor->SetPointRepresentation(true); else SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); break; case 1: - myViewWindow->SetSelectionMode(EdgeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(EdgeSelection); break; case 2: - myViewWindow->SetSelectionMode(FaceSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); break; default: - myViewWindow->SetSelectionMode(VolumeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(VolumeSelection); } } else { - myViewWindow->SetSelectionMode(ActorSelection); if (theMode == 4) mySelectionMgr->installFilter(mySubMeshFilter); else if (theMode == 5) mySelectionMgr->installFilter(myGroupFilter); else if (theMode == 6) mySelectionMgr->installFilter(myMeshFilter); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); } mySelectionMode = theMode; } @@ -590,14 +681,27 @@ bool SMESHGUI_GroupDlg::onApply() myGroup = SMESH::AddGroup(myMesh, aType, myName->text()); myGroup->Add(anIdList.inout()); - + + int aColorNumber = myColorSpinBox->value(); + myGroup->SetColorNumber(aColorNumber); + + _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup); + + SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) ); + + SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" ); + /* init for next operation */ myName->setText(""); + myColorSpinBox->setValue(0); myElements->clear(); myGroup = SMESH::SMESH_Group::_nil(); } else { myGroup->SetName(myName->text()); + + int aColorNumber = myColorSpinBox->value(); + myGroup->SetColorNumber(aColorNumber); QValueList aAddList; QValueList::iterator anIt; @@ -638,30 +742,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 = myColorSpinBox->value(); + myGroupOnGeom->SetColorNumber(aColorNumber); + + _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom); + + SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) ); + + SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" ); + + /* init for next operation */ + myName->setText(""); + myColorSpinBox->setValue(0); + 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); - + else + { + myGroupOnGeom->SetName(myName->text()); + + int aColorNumber = myColorSpinBox->value(); + myGroupOnGeom->SetColorNumber(aColorNumber); + } + mySMESHGUI->updateObjBrowser(true); mySelectionMgr->clearSelected(); - /* init for next operation */ - myName->setText(""); return true; } - + return false; } @@ -675,7 +799,6 @@ void SMESHGUI_GroupDlg::onOK() onClose(); } -static bool busy = false; //================================================================================= // function : onListSelectionChanged() // purpose : Called when selection in element list is changed @@ -683,8 +806,8 @@ static bool busy = false; void SMESHGUI_GroupDlg::onListSelectionChanged() { // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor); - if (busy || !myActor) return; - busy = true; + if( myIsBusy || !myActor) return; + myIsBusy = true; if (myCurrentLineEdit == 0) { mySelectionMgr->clearSelected(); @@ -700,9 +823,8 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() SALOME_ListIO aList; aList.Append(myActor->getIO()); mySelectionMgr->setSelectedObjects(aList,false); - myViewWindow->highlight( myActor->getIO(), true, true ); } - busy = false; + myIsBusy = false; } //================================================================================= @@ -711,11 +833,12 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() //================================================================================= void SMESHGUI_GroupDlg::onObjectSelectionChanged() { - if (busy || !isEnabled()) return; - busy = true; - - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + if ( myIsBusy || !isEnabled()) return; + myIsBusy = true; + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int aNbSel = aList.Extent(); myElements->clearSelection(); @@ -737,10 +860,11 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myElements->clear(); - if (aNbSel != 1) { + if (aNbSel != 1 ) { myGroup = SMESH::SMESH_Group::_nil(); + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); myMesh = SMESH::SMESH_Mesh::_nil(); - busy = false; + myIsBusy = false; return; } Handle(SALOME_InteractiveObject) IO = aList.First(); @@ -749,7 +873,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myMesh = SMESH::IObjectToInterface(IO); if (myMesh->_is_nil()) { - busy = false; + myIsBusy = false; return; } myGroup = SMESH::SMESH_Group::_nil(); @@ -767,28 +891,27 @@ 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()) { - busy = false; + myIsBusy = false; return; } - busy = false; + myIsBusy = false; myCurrentLineEdit = 0; + + myGroup = SMESH::SMESH_Group::_nil(); + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); + init(aGroup); - busy = true; + myIsBusy = true; mySelectSubMesh->setEnabled(true); mySelectGroup->setEnabled(true); - myGeomGroupBtn->setEnabled(true); - myGeomGroupLine->setEnabled(true); } myCurrentLineEdit = 0; - busy = false; + myIsBusy = false; if (!myCreate) - { - busy = false; return; - } if (myTypeId == -1) onTypeChanged(0); @@ -797,13 +920,13 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() setSelectionMode(myTypeId); } - busy = false; + myIsBusy = false; return; } else if (myCurrentLineEdit == myGeomGroupLine) { if (aNbSel != 1) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } @@ -813,7 +936,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() // Check if the object is a geometry group if (!testResult || CORBA::is_nil(myGeomGroup)) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } // Check if group constructed on the same shape as a mesh or on its child @@ -829,13 +952,13 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); _PTR(SObject) aGroupMainShapeSO = //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape)); - aStudy->FindObjectIOR(aGroupMainShape->GetStudyEntry()); + aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); // The mesh SObject _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); if (!aMeshSO) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } _PTR(SObject) anObj, aRef; @@ -859,16 +982,16 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() } if (!isRefOrSubShape) { myGeomGroup = GEOM::GEOM_Object::_nil(); - busy = false; + myIsBusy = false; return; } } - if (aNbSel >= 1) { - if (aNbSel > 1) { - if (myCurrentLineEdit == mySubMeshLine) + if(aNbSel >= 1) { + if(aNbSel > 1) { + if(myCurrentLineEdit == mySubMeshLine) aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel); - else if (myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) + else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel); } else { aString = aList.First()->getName(); @@ -881,7 +1004,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() updateButtons(); } else { - if (aNbSel == 1) { + if (aNbSel == 1 && myActor ) { QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { @@ -903,11 +1026,13 @@ 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); } - busy = false; + myIsBusy = false; } //================================================================================= @@ -985,6 +1110,17 @@ void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on) } } +//================================================================================= +// function : (onSelectColorGroup) +// purpose : Called when setting a color on group +//================================================================================= +void SMESHGUI_GroupDlg::onSelectColorGroup(bool on) +{ + if (!on) + myColorSpinBox->setValue(0); + + myColorSpinBox->setEnabled(on); +} //================================================================================= // function : setCurrentSelection() @@ -1070,23 +1206,40 @@ void SMESHGUI_GroupDlg::onFilterAccepted() //================================================================================= void SMESHGUI_GroupDlg::onAdd() { - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int aNbSel = aList.Extent(); if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; - busy = true; + myIsBusy = true; 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; + case 0: + aType = SMESH::NODE; + mySelector->SetSelectionMode(NodeSelection); + break; + case 1: + aType = SMESH::EDGE; + mySelector->SetSelectionMode(EdgeSelection); + break; + case 2: + aType = SMESH::FACE; + mySelector->SetSelectionMode(FaceSelection); + break; + case 3: + aType = SMESH::VOLUME; + mySelector->SetSelectionMode(VolumeSelection); + break; + default: + mySelector->SetSelectionMode(ActorSelection); } + if (myCurrentLineEdit == 0) { - //if (aNbSel != 1) { busy = false; return; } + //if (aNbSel != 1) { myIsBusy = false; return; } QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { @@ -1109,7 +1262,10 @@ void SMESHGUI_GroupDlg::onAdd() } } else if (myCurrentLineEdit == mySubMeshLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_subMesh_var aSubMesh = @@ -1138,12 +1294,14 @@ void SMESHGUI_GroupDlg::onAdd() } } mySelectSubMesh->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } else if (myCurrentLineEdit == myGroupLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_Group_var aGroup = @@ -1167,7 +1325,7 @@ void SMESHGUI_GroupDlg::onAdd() } } mySelectGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { @@ -1181,13 +1339,13 @@ void SMESHGUI_GroupDlg::onAdd() case 6: aGroupType = SMESH::EDGE; break; case 4: aGroupType = SMESH::FACE; break; case 2: aGroupType = SMESH::VOLUME; break; - default: busy = false; return; + default: myIsBusy = false; return; } if (aGroupType == aType) { _PTR(SObject) aGroupSO = //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup)); - aStudy->FindObjectIOR(myGeomGroup->GetStudyEntry()); + aStudy->FindObjectID(myGeomGroup->GetStudyEntry()); // Construct filter SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); @@ -1213,10 +1371,10 @@ void SMESHGUI_GroupDlg::onAdd() } //VSR: mySelectGeomGroup->setChecked(false); - busy = false; + myIsBusy = false; onListSelectionChanged(); } - busy = false; + myIsBusy = false; // mySelectionMgr->clearSelected(); updateButtons(); } @@ -1227,7 +1385,7 @@ void SMESHGUI_GroupDlg::onAdd() //================================================================================= void SMESHGUI_GroupDlg::onRemove() { - busy = true; + myIsBusy = true; if (myCurrentLineEdit == 0) { for (int i = myElements->count(); i > 0; i--) { if (myElements->isSelected(i-1)) { @@ -1235,10 +1393,12 @@ void SMESHGUI_GroupDlg::onRemove() } } } else { - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int aNbSel = aList.Extent(); - if (aNbSel == 0) { busy = false; return; } + if (aNbSel == 0) { myIsBusy = false; return; } SMESH::ElementType aType = SMESH::ALL; switch(myTypeId) { @@ -1250,7 +1410,9 @@ void SMESHGUI_GroupDlg::onRemove() if (myCurrentLineEdit == mySubMeshLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); @@ -1292,7 +1454,9 @@ void SMESHGUI_GroupDlg::onRemove() else if (myCurrentLineEdit == myGroupLine) { Standard_Boolean aRes; //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - const SALOME_ListIO& aList = mySelector->StoredIObjects(); + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); @@ -1311,7 +1475,7 @@ void SMESHGUI_GroupDlg::onRemove() } } } - busy = false; + myIsBusy = false; updateButtons(); } @@ -1326,7 +1490,7 @@ void SMESHGUI_GroupDlg::onSort() // myElements->update(); int i, k = myElements->count(); if (k > 0) { - busy = true; + myIsBusy = true; QStringList aSelected; std::vector anArray(k); // QMemArray anArray(k); @@ -1348,7 +1512,7 @@ void SMESHGUI_GroupDlg::onSort() anItem = myElements->findItem(*it, Qt::ExactMatch); if (anItem) myElements->setSelected(anItem, true); } - busy = false; + myIsBusy = false; } } @@ -1374,13 +1538,31 @@ void SMESHGUI_GroupDlg::onClose() } mySelectionMgr->clearSelected(); - myViewWindow->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); reject(); } +//================================================================================= +// function : onHelp() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName), + QObject::tr("BUT_OK")); + } +} + //================================================================================= // function : SMESHGUI_GroupDlg::onDeactivate // purpose : SLOT called when dialog must be deativated @@ -1417,3 +1599,20 @@ void SMESHGUI_GroupDlg::hideEvent (QHideEvent*) if (!isMinimized()) onClose(); } + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Key_F1 ) + { + e->accept(); + onHelp(); + } +}