X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=2313c768ce438035762520a9727d1bf47be37bf1;hp=54a1a5c700770693bcfc528ca14a3b566080f644;hb=e85e13ee2a8e2484050471ff8e4dea298abe481a;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 54a1a5c70..2313c768c 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 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 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,6 @@ #include #include -#include #include @@ -74,6 +74,7 @@ #include // OCCT includes +#include #include // Qt includes @@ -128,8 +129,8 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ), myIsBusy( false ), myNameChanged( false ), - myIsApplyAndClose( false ), - myNbChangesOfContents(0) + myNbChangesOfContents(0), + myIsApplyAndClose( false ) { initDialog( true ); if ( !theMesh->_is_nil() ) @@ -192,7 +193,7 @@ void SMESHGUI_GroupDlg::initDialog( bool create) QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); setWindowTitle( create ? tr( "SMESH_CREATE_GROUP_TITLE" ) : tr( "SMESH_EDIT_GROUP_TITLE" ) ); - myHelpFileName = create ? "creating_groups_page.html" : "editing_groups_page.html"; + myHelpFileName = create ? "creating_groups.html" : "editing_groups.html"; setSizeGripEnabled( true); @@ -444,24 +445,25 @@ void SMESHGUI_GroupDlg::initDialog( bool create) /* Init selection */ 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())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); connect(mySMESHGUI, SIGNAL(SignalVisibilityChanged()), this, SLOT(onVisibilityChanged())); - + connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView())); rb1->setChecked(true); // VSR !!! onGrpTypeChanged(0); // VSR!!! @@ -497,10 +499,7 @@ 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(); + _PTR(Study) aStudy = SMESH::getStudy(); std::set aSet; _PTR(SComponent) aMeshCompo (aStudy->FindComponent( "SMESH" )); @@ -518,26 +517,44 @@ 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(aName.toUtf8().constData())) == 0); } return aName; } +//======================================================================= +//function : setDefaultName +//purpose : +//======================================================================= + void SMESHGUI_GroupDlg::setDefaultName() const { QString aResName; - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - int i=1; - QString aPrefix ="Group_"; - _PTR(SObject) anObj; - do + const QString aPrefix ="Group_"; + + if ( myMesh->_is_nil() ) { - aResName = aPrefix + QString::number( i++ ); - anObj = aStudy->FindObject( aResName.toLatin1().data() ); + aResName = aPrefix + "1"; } - while ( anObj ); - myName->setText(aResName); + else + { + SMESH::ListOfGroups_var allGroups = myMesh->GetGroups(); + TColStd_MapOfAsciiString allNames( allGroups->length() ); + for ( CORBA::ULong i = 0; i < allGroups->length(); ++i ) + { + CORBA::String_var name = allGroups[i]->GetName(); + allNames.Add( name.in() ); + } + int i = 1; + while ( true ) + { + aResName = aPrefix + QString::number( i++ ); + if ( !allNames.Contains( aResName.toUtf8().constData() )) + break; + } + } + myName->setText(aResName); } //================================================================================= @@ -570,7 +587,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,7 +610,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); myName->home(false); @@ -610,6 +627,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, case SMESH::EDGE: aType = grpEdgeSelection; break; case SMESH::FACE: aType = grpFaceSelection; break; case SMESH::VOLUME: aType = grpVolumeSelection; break; + case SMESH::ALL: + case SMESH::NB_ELEMENT_TYPES: break; } myTypeGroup->button(aType)->setChecked(true); @@ -661,7 +680,7 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup, else if ( grpType == 1 ) // group on geom { QString aShapeName( "" ); - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(Study) aStudy = SMESH::getStudy(); GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape(); if (!aGroupShape->_is_nil()) { @@ -729,6 +748,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); } @@ -901,7 +931,7 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode) //================================================================================= bool SMESHGUI_GroupDlg::onApply() { - if (mySMESHGUI->isActiveStudyLocked()) + if (SMESHGUI::isStudyLocked()) return false; if (myName->text().trimmed().isEmpty()) @@ -921,8 +951,10 @@ bool SMESHGUI_GroupDlg::onApply() QStringList anEntryList; SMESH::SMESH_GroupBase_var resultGroup; - bool isCreation, isConversion = false; + bool isCreation = false, isConversion = false; + SUIT_OverrideCursor wc; + if (myGrpTypeId == 0) // standalone { if (!mySelectAll->isChecked() && !myElements->count() && myAllowElemsModif->isChecked()) @@ -932,7 +964,8 @@ bool SMESHGUI_GroupDlg::onApply() if (myGroup->_is_nil()) { // creation or conversion // check if group on geometry is not null - if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) { + if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) + { if (myMesh->_is_nil()) return false; if ( myGroupOnGeom->_is_nil() ) @@ -946,7 +979,8 @@ bool SMESHGUI_GroupDlg::onApply() } } - if (myGroup->_is_nil()) { // creation + if (myGroup->_is_nil()) // creation + { if (myMesh->_is_nil()) return false; @@ -978,10 +1012,10 @@ bool SMESHGUI_GroupDlg::onApply() myGroup->Add(anIdList.inout()); } } + } - - } else { // edition - + else // edition + { resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup ); isCreation = false; @@ -1034,37 +1068,36 @@ bool SMESHGUI_GroupDlg::onApply() if (myMesh->_is_nil() || !myGeomObjects->length()) return false; - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(Study) aStudy = SMESH::getStudy(); if (myGeomObjects->length() == 1) { myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toLatin1().data(), + myName->text().toUtf8(), myGeomObjects[0]); } else { SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen(); - if ( aSMESHGen->_is_nil() ) + if ( aSMESHGen->_is_nil() || myGeomObjects->length() == 0 ) return false; // create a geometry group - GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - - if (geomGen->_is_nil() || !aStudy) + GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( myGeomObjects[0] ); + if (geomGen->_is_nil()) return false; - GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId()); + GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(); if (op->_is_nil()) return false; // check and add all selected GEOM objects: they must be // a sub-shapes of the main GEOM and must be of one type TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE; - for ( int i =0; i < myGeomObjects->length(); i++) { + for ( CORBA::ULong i =0; i < myGeomObjects->length(); i++) + { TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType(); - if (i == 0) + if ( i == 0 ) aGroupType = aSubShapeType; - else if (aSubShapeType != aGroupType) { + else if ( aSubShapeType != aGroupType ) { aGroupType = TopAbs_SHAPE; break; } @@ -1072,6 +1105,8 @@ bool SMESHGUI_GroupDlg::onApply() GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType); + if ( aGroupVar->_is_nil() ) + return false; op->UnionList(aGroupVar, myGeomObjects); if (op->IsDone()) { @@ -1079,12 +1114,12 @@ bool SMESHGUI_GroupDlg::onApply() QString aNewGeomGroupName ( "Auto_group_for_" ); aNewGeomGroupName += myName->text(); SALOMEDS::SObject_var aNewGroupSO = - geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, - aNewGeomGroupName.toLatin1().data(), aMeshShape); + geomGen->AddInStudy(aGroupVar, + aNewGeomGroupName.toUtf8(), aMeshShape); } myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toLatin1().data(), + myName->text().toUtf8(), aGroupVar); } resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); @@ -1095,21 +1130,22 @@ bool SMESHGUI_GroupDlg::onApply() resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); isCreation = false; - } + } anIsOk = true; } + if (myGrpTypeId == 2) // group on filter { if ( myFilter->_is_nil() ) return false; - if (CORBA::is_nil(myGroupOnFilter)) { // creation + if (CORBA::is_nil(myGroupOnFilter)) // creation + { if (myMesh->_is_nil()) return false; myGroupOnFilter = myMesh->CreateGroupFromFilter(aType, - myName->text().toLatin1().data(), + myName->text().toUtf8(), myFilter); - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); isCreation = true; } @@ -1123,7 +1159,7 @@ bool SMESHGUI_GroupDlg::onApply() anIsOk = true; } - if( anIsOk ) + if ( anIsOk ) { SALOMEDS::Color aColor = getGroupColor(); resultGroup->SetColor(aColor); @@ -1132,6 +1168,8 @@ bool SMESHGUI_GroupDlg::onApply() if( aMeshGroupSO ) anEntryList.append( aMeshGroupSO->GetID().c_str() ); + resultGroup->SetName(myName->text().trimmed().toUtf8()); + if ( isCreation ) { SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" ); @@ -1148,21 +1186,20 @@ 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); + SMESH::Update( anIO, true ); myActorsList.clear(); anActor = SMESH::FindActorByEntry( anIO->getEntry() ); if ( !anActor ) return false; myActorsList.append( anActor ); } - anActor->setName(myName->text().toLatin1().data()); + anActor->setName(myName->text().toUtf8()); QColor c; int delta; switch ( myTypeId ) { @@ -1180,12 +1217,17 @@ bool SMESHGUI_GroupDlg::onApply() anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break; break; } + // update a visible group according 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 +1351,10 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() // any visible actor of group or submesh of myMesh SetAppropriateActor(); + setDefaultGroupColor(); + if (myName->text().isEmpty()) + setDefaultName(); + aString = aList.First()->getName(); myMeshGroupLine->setText(aString); myMeshGroupLine->home( false ); @@ -1379,29 +1425,33 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { - aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value()); - + CORBA::Object_var aGroupObj = SMESH::IObjectToObject(anIt.Value()); + if (CORBA::is_nil(aGroupObj)) + continue; // Check if the object is a geometry group + aGeomGroup = GEOM::GEOM_Object::_narrow(aGroupObj); if (CORBA::is_nil(aGeomGroup)) continue; // Check if group constructed on the same shape as a mesh or on its child - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); // 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); + SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations(); + aGroupMainShape = anOp->GetMainShape( aGeomGroup ); // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap } - else { + else + { aGroupMainShape = aGeomGroup; aGroupMainShape->Register(); } + CORBA::String_var entry = aGroupMainShape->GetStudyEntry(); _PTR(SObject) aGroupMainShapeSO = - aStudy->FindObjectID(aGroupMainShape->GetStudyEntry()); + SMESH::getStudy()->FindObjectID( entry.in() ); _PTR(SObject) anObj, aRef; bool isRefOrSubShape = false; @@ -1425,10 +1475,10 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myGeomObjects->length(i); if ( i == 0 ) - { - myIsBusy = false; - return; - } + { + myIsBusy = false; + return; + } aNbSel = i; } @@ -1582,6 +1632,8 @@ void SMESHGUI_GroupDlg::onSelectAll() mySortBtn->setEnabled ( !noElemsModif ); mySelectBox->setEnabled ( !noElemsModif ); myAllowElemsModif->setEnabled( !mySelectAll->isChecked() ); + if ( noElemsModif ) mySMESHGUI->ResetState(); + else mySMESHGUI->SetState(800); int selMode = mySelectionMode; mySelectionMode = grpNoSelection; @@ -1642,7 +1694,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 +1705,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 +1793,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 ); @@ -1780,6 +1836,10 @@ void SMESHGUI_GroupDlg::onFilterAccepted() mesh = myGroupOnFilter->GetMesh(); } myFilter->SetMesh( mesh ); + + // highlight ids if selection changed in the Viewer (IPAL52924) + myCurrentLineEdit = 0; + onObjectSelectionChanged(); } updateButtons(); @@ -1798,6 +1858,8 @@ void SMESHGUI_GroupDlg::onAdd() if (aNbSel == 0 || myActorsList.count() == 0 || myMesh->_is_nil()) return; + SUIT_OverrideCursor wc; + myIsBusy = true; int sizeBefore = myElements->count(); @@ -1834,7 +1896,8 @@ void SMESHGUI_GroupDlg::onAdd() QListWidgetItem* anItem = 0; QList listItemsToSel; - if (myCurrentLineEdit == 0) { + if ( myCurrentLineEdit == 0 ) + { //if (aNbSel != 1) { myIsBusy = false; return; } QString aListStr = ""; int aNbItems = 0; @@ -1877,7 +1940,9 @@ void SMESHGUI_GroupDlg::onAdd() onListSelectionChanged(); listItemsToSel.clear(); } - } else if (myCurrentLineEdit == mySubMeshLine) { + } + else if ( myCurrentLineEdit == mySubMeshLine ) + { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); SALOME_ListIO aList; @@ -1925,7 +1990,9 @@ void SMESHGUI_GroupDlg::onAdd() myIsBusy = false; onListSelectionChanged(); - } else if (myCurrentLineEdit == myGroupLine) { + } + else if ( myCurrentLineEdit == myGroupLine ) + { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); SALOME_ListIO aList; mySelectionMgr->selectedObjects( aList ); @@ -1967,10 +2034,11 @@ void SMESHGUI_GroupDlg::onAdd() myIsBusy = false; onListSelectionChanged(); - } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) { - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + } + else if ( myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1 ) + { GEOM::GEOM_IGroupOperations_wrap aGroupOp = - SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + SMESH::GetGEOMGen( myGeomObjects[0] )->GetIGroupOperations(); SMESH::ElementType aGroupType = SMESH::ALL; switch(aGroupOp->GetType(myGeomObjects[0])) { @@ -1983,8 +2051,8 @@ void SMESHGUI_GroupDlg::onAdd() if (aGroupType == aType) { _PTR(SObject) aGroupSO = - //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup)); - aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry()); + //SMESH::getStudy()->FindObjectIOR(SMESH::getStudy()->ConvertObjectToIOR(myGeomGroup)); + SMESH::getStudy()->FindObjectID(myGeomObjects[0]->GetStudyEntry()); // Construct filter SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); @@ -2108,15 +2176,13 @@ void SMESHGUI_GroupDlg::onRemove() } } else if (myCurrentLineEdit == myGroupLine) { - Standard_Boolean aRes; - //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->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()); - if (aRes && !aGroup->_is_nil()) { + if (!aGroup->_is_nil()) { // check if mesh is the same if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { SMESH::long_array_var anElements = aGroup->GetListOfID(); @@ -2220,6 +2286,32 @@ void SMESHGUI_GroupDlg::reject() if ( myFilterDlg ) myFilterDlg->UnRegisterFilters(); } +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onOpenView() +{ + if ( mySelector ) { + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onCloseView() +{ + onDeactivate(); + mySelector = 0; +} + //================================================================================= // function : onHelp() // purpose : @@ -2228,25 +2320,27 @@ 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 { - QString platform; + { + app->onHelpContextModule + ( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) : QString(""), myHelpFileName ); + } + else + { #ifdef WIN32 - platform = "winapplication"; + QString platform = "winapplication"; #else - platform = "application"; + QString platform = "application"; #endif SUIT_MessageBox::warning(this, tr( "WRN_WARNING" ), tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). - arg(app->resourceMgr()->stringValue( "ExternalBrowser", - platform)). + arg(app->resourceMgr()->stringValue( "ExternalBrowser", platform)). arg(myHelpFileName)); } } //================================================================================= // function : SMESHGUI_GroupDlg::onDeactivate -// purpose : SLOT called when dialog must be deativated +// purpose : SLOT called when dialog must be deactivated //================================================================================= void SMESHGUI_GroupDlg::onDeactivate() { @@ -2261,13 +2355,17 @@ void SMESHGUI_GroupDlg::onDeactivate() void SMESHGUI_GroupDlg::enterEvent (QEvent*) { if (!isEnabled()) { + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if ( aViewWindow && !mySelector) { + mySelector = aViewWindow->GetSelector(); + } mySMESHGUI->EmitSignalDeactivateDialog(); setEnabled(true); mySelectionMode = grpNoSelection; setSelectionMode(myTypeId); - //mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox(this); - mySMESHGUI->SetState(800); + if ( mySelectBox->isEnabled() ) mySMESHGUI->SetState(800); + else mySMESHGUI->ResetState(); } } @@ -2282,16 +2380,16 @@ void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e ) return; if ( e->key() == Qt::Key_F1 ) - { - e->accept(); - onHelp(); - } + { + e->accept(); + onHelp(); + } } //================================================================================ /*! * \brief Enable showing of the popup when Geometry selection btn is clicked - * \param enable - true to enable + * \param enable - true to enable */ //================================================================================ @@ -2327,17 +2425,17 @@ void SMESHGUI_GroupDlg::updateGeomPopup() void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn) { if ( myGeomPopup && isBtnOn ) - { - myCurrentLineEdit = myGeomGroupLine; - QAction* a = myGeomPopup->exec( QCursor::pos() ); - if (!a || myActions[a] == DIRECT_GEOM_INDEX) - setSelectionMode(grpGeomSelection); - } + { + myCurrentLineEdit = myGeomGroupLine; + QAction* a = myGeomPopup->exec( QCursor::pos() ); + if (!a || myActions[a] == DIRECT_GEOM_INDEX) + setSelectionMode(grpGeomSelection); + } else if (!isBtnOn) - { - myCurrentLineEdit = 0; - setSelectionMode(grpAllSelection); - } + { + myCurrentLineEdit = 0; + setSelectionMode(grpAllSelection); + } } //================================================================================= @@ -2348,26 +2446,26 @@ void SMESHGUI_GroupDlg::onGeomPopup( QAction* a ) { int index = myActions[a]; if ( index == GEOM_BY_MESH_INDEX ) - { - mySelectionMode = grpNoSelection; - if ( !myShapeByMeshOp ) { - myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true); - connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)), - SLOT(onPublishShapeByMeshDlg(SUIT_Operation*))); - connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)), - SLOT(onCloseShapeByMeshDlg(SUIT_Operation*))); - } - // set mesh object to SMESHGUI_ShapeByMeshOp and start it - if ( !myMesh->_is_nil() ) { - myIsBusy = true; - hide(); // stop processing selection - myIsBusy = false; - myShapeByMeshOp->setModule( mySMESHGUI ); - myShapeByMeshOp->setStudy( 0 ); // it's really necessary - myShapeByMeshOp->SetMesh( myMesh ); - myShapeByMeshOp->start(); - } + { + mySelectionMode = grpNoSelection; + if ( !myShapeByMeshOp ) { + myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true); + connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)), + SLOT(onPublishShapeByMeshDlg(SUIT_Operation*))); + connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)), + SLOT(onCloseShapeByMeshDlg(SUIT_Operation*))); + } + // set mesh object to SMESHGUI_ShapeByMeshOp and start it + if ( !myMesh->_is_nil() ) { + myIsBusy = true; + hide(); // stop processing selection + myIsBusy = false; + myShapeByMeshOp->setModule( mySMESHGUI ); + myShapeByMeshOp->setStudy( 0 ); // it's really necessary + myShapeByMeshOp->SetMesh( myMesh ); + myShapeByMeshOp->start(); } + } } //================================================================================ @@ -2386,8 +2484,7 @@ void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op) if ( !aGeomVar->_is_nil() ) { QString ID = aGeomVar->GetStudyEntry(); - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.toLatin1().data() )) { + if ( _PTR(SObject) aGeomSO = SMESH::getStudy()->FindObjectID( ID.toLatin1().data() )) { SALOME_ListIO anIOList; Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() ); @@ -2408,10 +2505,10 @@ void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op) void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op) { if ( myShapeByMeshOp == op ) - { - show(); - setSelectionMode(grpGeomSelection); - } + { + show(); + setSelectionMode(grpGeomSelection); + } } //================================================================================= @@ -2512,7 +2609,7 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor() // function : SetAppropriateActor() // purpose : Find more appropriate of visible actors, set it to myActor, allow picking // NPAL19389: create a group with a selection in another group. -// if mesh actor is not visible - find any first visible group or submesh +// if mesh actor is not visible - find any first visible group or sub-mesh //================================================================================= bool SMESHGUI_GroupDlg::SetAppropriateActor() { @@ -2523,21 +2620,23 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor() SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView(); - if (myGeomGroupBtn->isChecked()) { // try current group on geometry actor - if (!isActor) { - if (!myGroupOnGeom->_is_nil()) { - SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom); - if (anActor && anActor->hasIO()) - { - isActor = true; - if (aViewWindow && !aViewWindow->isVisible(anActor->getIO())) - isActor = false; - else - myActorsList.append(anActor); - } - } + if (myGrpTypeGroup->checkedId() > 0) { // try current group on geometry actor + SMESH_Actor* anActor = 0; + if (!myGroupOnGeom->_is_nil()) + anActor = SMESH::FindActorByObject(myGroupOnGeom); + if (!myGroupOnFilter->_is_nil()) + anActor = SMESH::FindActorByObject(myGroupOnFilter); + if (anActor && anActor->hasIO()) + { + isActor = true; + if (aViewWindow && !aViewWindow->isVisible(anActor->getIO())) + isActor = false; + else + myActorsList.append(anActor); } - } else { + return anActor; + } + else { // try mesh actor SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); if (anActor && anActor->hasIO()) { @@ -2547,42 +2646,50 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor() else myActorsList.append(anActor); } - + // try group actor + SMESH_Actor* aGroupActor = 0; if (!isActor && !myGroup->_is_nil()) { - SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup); - if (anActor && anActor->hasIO()) - myActorsList.append(anActor); + aGroupActor = SMESH::FindActorByObject(myGroup); + if (aGroupActor && aGroupActor->hasIO()) + myActorsList.append(aGroupActor); } - - // try any visible actor of group or submesh of current mesh + + // try any visible actor of group or sub-mesh of current mesh if (aViewWindow) { // mesh entry _PTR(SObject) aSObject = SMESH::FindSObject(myMesh); if (aSObject) { CORBA::String_var meshEntry = aSObject->GetID().c_str(); int len = strlen(meshEntry); - + // iterate on all actors in current view window, search for // any visible actor, that belongs to group or submesh of current mesh VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors()); vtkActorCollection *aCollection = aCopy.GetActors(); int nbItems = aCollection->GetNumberOfItems(); for (int i=0; i(aCollection->GetItemAsObject(i)); - if (anActor && anActor->hasIO()) { - Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); - if (aViewWindow->isVisible(anIO)) { - if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) ) - myActorsList.append(anActor); - } + { + SMESH_Actor *anActor = dynamic_cast(aCollection->GetItemAsObject(i)); + if (anActor && anActor->hasIO()) { + Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); + if (aViewWindow->isVisible(anIO)) { + if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) ) + myActorsList.append(anActor); } } + } } } + + // Show a standalone group if nothing else is visible (IPAL52227) + if ( myActorsList.count() == 1 && + myActorsList[0] == aGroupActor && + aViewWindow && !aViewWindow->isVisible(aGroupActor->getIO())) + SMESH::UpdateView( aViewWindow, SMESH::eDisplay, aGroupActor->getIO()->getEntry() ); } - + + if (myActorsList.count() > 0) { QListIterator it( myActorsList ); while ( it.hasNext() ) { @@ -2591,10 +2698,10 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor() anActor->SetPickable(true); } } - + return ( isActor || (myActorsList.count() > 0) ); } - + //======================================================================= //function : setShowEntityMode //purpose : make shown only entity corresponding to my type