X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=4b33a586b5462396fb917097c7853be4b042fdcf;hp=832ac1c8d4bb31f0ec965a847601068307101f88;hb=38a77c4a9810f4715212368ac53315689ba9150f;hpb=997c16d89decd85389b313bc11f071b3e47f7fc4 diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 832ac1c8d..4b33a586b 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 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 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,6 @@ #include #include -#include #include @@ -446,16 +446,17 @@ void SMESHGUI_GroupDlg::initDialog( bool create) mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetState(800); + SalomeApp_Study* aStudy = dynamic_cast( mySMESHGUI->application()->activeStudy() ); mySelectionMode = grpNoSelection; - myMeshFilter = new SMESH_TypeFilter(SMESH::MESH); + + myMeshFilter = new SMESH_TypeFilter(SMESH::MESH); mySubMeshFilter = new SMESH_LogicalFilter(QList(), SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true); - myGroupFilter = new SMESH_LogicalFilter(QList(), - SMESH_LogicalFilter::LO_OR, - /*takeOwnership=*/true); - SalomeApp_Study* aStudy = dynamic_cast( mySMESHGUI->application()->activeStudy() ); - myGeomFilter = new GEOM_SelectionFilter( aStudy, true ); + myGroupFilter = new SMESH_LogicalFilter(QList(), + SMESH_LogicalFilter::LO_OR, + /*takeOwnership=*/true); + myGeomFilter = new GEOM_SelectionFilter( aStudy, true ); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject())); @@ -518,7 +519,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(std::string(SMESH::toUtf8(aName))) == 0); } return aName; @@ -534,7 +535,7 @@ void SMESHGUI_GroupDlg::setDefaultName() const do { aResName = aPrefix + QString::number( i++ ); - anObj = aStudy->FindObject( aResName.toLatin1().data() ); + anObj = aStudy->FindObject( SMESH::toUtf8(aResName) ); } while ( anObj ); myName->setText(aResName); @@ -570,7 +571,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 ); } @@ -593,14 +594,14 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, myNameChanged = true; myName->blockSignals(true); - myName->setText(theGroup->GetName()); + myName->setText(SMESH::fromUtf8(theGroup->GetName())); myName->blockSignals(false); myName->home(false); SALOMEDS::Color aColor = theGroup->GetColor(); setGroupColor( aColor ); - myMeshGroupLine->setText(theGroup->GetName()); + myMeshGroupLine->setText(SMESH::fromUtf8(theGroup->GetName())); int aType = 0; switch(theGroup->GetType()) { @@ -685,7 +686,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, { myNameChanged = true; myName->blockSignals(true); - myName->setText(theGroup->GetName()); + myName->setText(SMESH::fromUtf8(theGroup->GetName())); myName->blockSignals(false); } @@ -729,6 +730,17 @@ void SMESHGUI_GroupDlg::updateButtons() } } + bool meshHasGeom = ( myMesh->_is_nil() || myMesh->HasShapeToMesh() ); + if ( myGrpTypeId != 1 ) + { + myGrpTypeGroup->button(1)->setEnabled( meshHasGeom ); + } + else + { + myGeomGroupBtn->setEnabled( meshHasGeom ); + myGeomGroupLine->setEnabled( meshHasGeom ); + } + myOKBtn->setEnabled(enable); myApplyBtn->setEnabled(enable); } @@ -923,6 +935,8 @@ bool SMESHGUI_GroupDlg::onApply() SMESH::SMESH_GroupBase_var resultGroup; bool isCreation, isConversion = false; + SUIT_OverrideCursor wc; + if (myGrpTypeId == 0) // standalone { if (!mySelectAll->isChecked() && !myElements->count() && myAllowElemsModif->isChecked()) @@ -1038,7 +1052,7 @@ bool SMESHGUI_GroupDlg::onApply() if (myGeomObjects->length() == 1) { myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toLatin1().data(), + SMESH::toUtf8(myName->text()), myGeomObjects[0]); } else { @@ -1080,11 +1094,11 @@ bool SMESHGUI_GroupDlg::onApply() aNewGeomGroupName += myName->text(); SALOMEDS::SObject_var aNewGroupSO = geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, - aNewGeomGroupName.toLatin1().data(), aMeshShape); + SMESH::toUtf8(aNewGeomGroupName), aMeshShape); } myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toLatin1().data(), + SMESH::toUtf8(myName->text()), aGroupVar); } resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); @@ -1107,7 +1121,7 @@ bool SMESHGUI_GroupDlg::onApply() return false; myGroupOnFilter = myMesh->CreateGroupFromFilter(aType, - myName->text().toLatin1().data(), + SMESH::toUtf8(myName->text()), myFilter); resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); @@ -1132,6 +1146,8 @@ bool SMESHGUI_GroupDlg::onApply() if( aMeshGroupSO ) anEntryList.append( aMeshGroupSO->GetID().c_str() ); + resultGroup->SetName(SMESH::toUtf8(myName->text().trimmed())); + if ( isCreation ) { SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" ); @@ -1148,13 +1164,12 @@ bool SMESHGUI_GroupDlg::onApply() } else { - resultGroup->SetName(myName->text().toLatin1().data()); - if ( aMeshGroupSO ) { - if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) { + if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) + { + Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); 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(); @@ -1162,7 +1177,7 @@ bool SMESHGUI_GroupDlg::onApply() if ( !anActor ) return false; myActorsList.append( anActor ); } - anActor->setName(myName->text().toLatin1().data()); + anActor->setName(SMESH::toUtf8(myName->text())); QColor c; int delta; switch ( myTypeId ) { @@ -1180,12 +1195,17 @@ bool SMESHGUI_GroupDlg::onApply() anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break; break; } + // update a visible group accoding to a changed contents + if ( !isConversion && anActor->GetVisibility() ) + { + SMESH::Update( anIO, true ); + SMESH::RepaintCurrentView(); + } } } } SMESHGUI::Modified(); mySMESHGUI->updateObjBrowser(true); - SMESH::UpdateView(); // asv: fix of BUG PAL5515 mySelectionMgr->clearSelected(); if( LightApp_Application* anApp = @@ -1309,6 +1329,9 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() // any visible actor of group or submesh of myMesh SetAppropriateActor(); + setDefaultGroupColor(); + setDefaultName(); + aString = aList.First()->getName(); myMeshGroupLine->setText(aString); myMeshGroupLine->home( false ); @@ -1642,7 +1665,7 @@ void SMESHGUI_GroupDlg::onSelectGroup(bool on) //================================================================================= // function : (onSelectGeomGroup) -// purpose : Called when group type changed. on == "on group" or "on filter" +// purpose : Called when group type changed. on == "on geometry" or "on filter" //================================================================================= void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on) { @@ -1653,7 +1676,7 @@ void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on) else if (mySelectGroup->isChecked()) { mySelectGroup->setChecked(false); } - if ( myGrpTypeId == 1 ) { // on group + if ( myGrpTypeId == 1 ) { // on geometry myCurrentLineEdit = myGeomGroupLine; updateGeomPopup(); } @@ -1741,7 +1764,11 @@ void SMESHGUI_GroupDlg::setFilters() myFilterDlg->Init( aType ); } + bool isStandalone = ( sender() == myFilterBtn ); + myFilterDlg->SetEnabled( /*setInViewer=*/isStandalone, + /*diffSources=*/isStandalone ); myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetGroup( myGroupOnFilter ); myFilterDlg->SetSelection(); myFilterDlg->SetSourceWg( myElements, false );