X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=1293f3e0d37d95c12dea5f6edbc379f453f01313;hp=f6d02c232a452648b4efcad933a2488a07b0b51a;hb=8f57b2cfd33d6d41539b00f3665f184266c297be;hpb=1067ffa6e7e5c394e3a1b17219d8b355a57607cd diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index f6d02c232..1293f3e0d 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 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 @@ -6,7 +6,7 @@ // 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 @@ -38,12 +38,13 @@ #include #include -#include +//#include #include // SALOME GEOM includes #include #include +#include // SALOME GUI includes #include @@ -123,7 +124,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, 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 ), @@ -151,7 +152,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, 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 ), @@ -438,7 +439,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) 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 */ @@ -457,7 +458,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) 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())); @@ -517,7 +518,7 @@ QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation) bool isUnique = false; while (!isUnique) { aName = theOperation + "_" + QString::number(++aNumber); - isUnique = (aSet.count(aName.toLatin1().data()) == 0); + isUnique = (aSet.count(aName.toUtf8().data()) == 0); } return aName; @@ -533,7 +534,7 @@ void SMESHGUI_GroupDlg::setDefaultName() const do { aResName = aPrefix + QString::number( i++ ); - anObj = aStudy->FindObject( aResName.toLatin1().data() ); + anObj = aStudy->FindObject( aResName.toUtf8().data() ); } while ( anObj ); myName->setText(aResName); @@ -569,7 +570,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh) if( !aList.IsEmpty() ) { QString aName = aList.First()->getName(); - myMeshGroupLine->setText(aName); + myMeshGroupLine->setText(aName);//?????? myMeshGroupLine->home( false ); } @@ -592,14 +593,14 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, myNameChanged = true; myName->blockSignals(true); - myName->setText(theGroup->GetName()); + myName->setText(QString::fromUtf8(theGroup->GetName())); myName->blockSignals(false); myName->home(false); SALOMEDS::Color aColor = theGroup->GetColor(); setGroupColor( aColor ); - myMeshGroupLine->setText(theGroup->GetName()); + myMeshGroupLine->setText(QString::fromUtf8(theGroup->GetName())); int aType = 0; switch(theGroup->GetType()) { @@ -684,7 +685,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, { myNameChanged = true; myName->blockSignals(true); - myName->setText(theGroup->GetName()); + myName->setText(QString::fromUtf8(theGroup->GetName())); myName->blockSignals(false); } @@ -920,7 +921,7 @@ bool SMESHGUI_GroupDlg::onApply() QStringList anEntryList; SMESH::SMESH_GroupBase_var resultGroup; - bool isCreation; + bool isCreation, isConversion = false; if (myGrpTypeId == 0) // standalone { @@ -939,8 +940,9 @@ bool SMESHGUI_GroupDlg::onApply() else myGroup = myMesh->ConvertToStandalone( myGroupOnGeom ); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); + myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil(); + isConversion = true; } } @@ -1033,12 +1035,10 @@ bool SMESHGUI_GroupDlg::onApply() return false; _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = - SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); if (myGeomObjects->length() == 1) { myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toLatin1().data(), + myName->text().toUtf8().data(), myGeomObjects[0]); } else { @@ -1053,8 +1053,7 @@ bool SMESHGUI_GroupDlg::onApply() if (geomGen->_is_nil() || !aStudy) return false; - GEOM::GEOM_IGroupOperations_var op = - geomGen->GetIGroupOperations(aStudy->StudyId()); + GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId()); if (op->_is_nil()) return false; @@ -1071,8 +1070,8 @@ bool SMESHGUI_GroupDlg::onApply() } } - GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); - GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType); + GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); + GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType); op->UnionList(aGroupVar, myGeomObjects); if (op->IsDone()) { @@ -1081,11 +1080,11 @@ bool SMESHGUI_GroupDlg::onApply() aNewGeomGroupName += myName->text(); SALOMEDS::SObject_var aNewGroupSO = geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, - aNewGeomGroupName.toLatin1().data(), aMeshShape); + aNewGeomGroupName.toUtf8().data(), aMeshShape); } myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toLatin1().data(), + myName->text().toUtf8().data(), aGroupVar); } resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); @@ -1108,7 +1107,7 @@ bool SMESHGUI_GroupDlg::onApply() return false; myGroupOnFilter = myMesh->CreateGroupFromFilter(aType, - myName->text().toLatin1().data(), + myName->text().toUtf8().data(), myFilter); resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); @@ -1144,14 +1143,26 @@ bool SMESHGUI_GroupDlg::onApply() 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()); + resultGroup->SetName(myName->text().toUtf8().data()); if ( aMeshGroupSO ) + { if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) { - anActor->setName(myName->text().toLatin1().data()); + if ( isConversion ) { // need to reset TVisualObj and actor + Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); + 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(myName->text().toUtf8().data()); QColor c; int delta; switch ( myTypeId ) { @@ -1160,16 +1171,17 @@ bool SMESHGUI_GroupDlg::onApply() 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; } } + } } SMESHGUI::Modified(); mySMESHGUI->updateObjBrowser(true); @@ -1191,8 +1203,10 @@ void SMESHGUI_GroupDlg::onOK() { setIsApplyAndClose( true ); if ( onApply() ) - onClose(); + reject(); setIsApplyAndClose( false ); + + if ( myFilterDlg ) myFilterDlg->UnRegisterFilters(); } //================================================================================= @@ -1373,15 +1387,19 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() // Check if group constructed on the same shape as a mesh or on its child _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var anOp = - SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); // The main shape of the group GEOM::GEOM_Object_var aGroupMainShape; - if (aGeomGroup->GetType() == 37) + if (aGeomGroup->GetType() == 37) { + GEOM::GEOM_IGroupOperations_wrap anOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); aGroupMainShape = anOp->GetMainShape(aGeomGroup); - else - aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup); + // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap + } + else { + aGroupMainShape = aGeomGroup; + aGroupMainShape->Register(); + } _PTR(SObject) aGroupMainShapeSO = aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); @@ -1558,7 +1576,7 @@ void SMESHGUI_GroupDlg::onSelectAll() myElementsLab->setEnabled( !noElemsModif ); myElements->setEnabled ( !noElemsModif ); - myFilterBtn->setEnabled ( !mySelectAll->isChecked() ); + myFilterBtn->setEnabled ( !noElemsModif ); myAddBtn->setEnabled ( !noElemsModif ); myRemoveBtn->setEnabled ( !noElemsModif ); mySortBtn->setEnabled ( !noElemsModif ); @@ -1723,8 +1741,8 @@ void SMESHGUI_GroupDlg::setFilters() myFilterDlg->Init( aType ); } - myFilterDlg->SetSelection(); myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSelection(); myFilterDlg->SetSourceWg( myElements, false ); myFilterDlg->show(); @@ -1951,7 +1969,7 @@ void SMESHGUI_GroupDlg::onAdd() } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) { _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IGroupOperations_var aGroupOp = + GEOM::GEOM_IGroupOperations_wrap aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); SMESH::ElementType aGroupType = SMESH::ALL; @@ -2163,15 +2181,6 @@ void SMESHGUI_GroupDlg::onSort() } } -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*) -{ - onClose(); -} - //================================================================================= // function : onVisibilityChanged() // purpose : @@ -2182,10 +2191,10 @@ void SMESHGUI_GroupDlg::onVisibilityChanged() } //================================================================================= -// 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 @@ -2206,7 +2215,9 @@ void SMESHGUI_GroupDlg::onClose() mySelectionMgr->clearFilters(); mySMESHGUI->ResetState(); - reject(); + QDialog::reject(); + + if ( myFilterDlg ) myFilterDlg->UnRegisterFilters(); } //================================================================================= @@ -2260,16 +2271,6 @@ void SMESHGUI_GroupDlg::enterEvent (QEvent*) } } -//================================================================================= -// function : hideEvent -// purpose : caused by ESC key -//================================================================================= -void SMESHGUI_GroupDlg::hideEvent (QHideEvent*) -{ - if (!isMinimized() && !myIsBusy) - onClose(); -} - //================================================================================= // function : keyPressEvent() // purpose : @@ -2471,15 +2472,20 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor() 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 aReservedColors; @@ -2491,6 +2497,8 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor() } 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 ) );