From: mpa Date: Mon, 8 Sep 2014 06:30:44 +0000 (+0400) Subject: 0022672: SMESH: Add a "Reset" in the "Controls" menu of smesh X-Git-Tag: V7_5_0a1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d0cb9e8d04012519ce1a30cf238275cb645a9294;p=modules%2Fsmesh.git 0022672: SMESH: Add a "Reset" in the "Controls" menu of smesh --- diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 8723415cd..cccf51ff6 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1566,111 +1566,124 @@ namespace void Control( int theCommandID ) { + SMESH_Actor::eControl aControl = SMESH_Actor::eNone; + switch ( theCommandID ){ + case SMESHOp::OpFreeNode: + aControl = SMESH_Actor::eFreeNodes; + break; + case SMESHOp::OpEqualNode: + aControl = SMESH_Actor::eCoincidentNodes; + break; + case SMESHOp::OpFreeEdge: + aControl = SMESH_Actor::eFreeEdges; + break; + case SMESHOp::OpFreeBorder: + aControl = SMESH_Actor::eFreeBorders; + break; + case SMESHOp::OpLength: + aControl = SMESH_Actor::eLength; + break; + case SMESHOp::OpConnection: + aControl = SMESH_Actor::eMultiConnection; + break; + case SMESHOp::OpEqualEdge: + aControl = SMESH_Actor::eCoincidentElems1D; + break; + case SMESHOp::OpFreeFace: + aControl = SMESH_Actor::eFreeFaces; + break; + case SMESHOp::OpBareBorderFace: + aControl = SMESH_Actor::eBareBorderFace; + break; + case SMESHOp::OpOverConstrainedFace: + aControl = SMESH_Actor::eOverConstrainedFace; + break; + case SMESHOp::OpLength2D: + aControl = SMESH_Actor::eLength2D; + break; + case SMESHOp::OpConnection2D: + aControl = SMESH_Actor::eMultiConnection2D; + break; + case SMESHOp::OpArea: + aControl = SMESH_Actor::eArea; + break; + case SMESHOp::OpTaper: + aControl = SMESH_Actor::eTaper; + break; + case SMESHOp::OpAspectRatio: + aControl = SMESH_Actor::eAspectRatio; + break; + case SMESHOp::OpMinimumAngle: + aControl = SMESH_Actor::eMinimumAngle; + break; + case SMESHOp::OpWarpingAngle: + aControl = SMESH_Actor::eWarping; + break; + case SMESHOp::OpSkew: + aControl = SMESH_Actor::eSkew; + break; + case SMESHOp::OpMaxElementLength2D: + aControl = SMESH_Actor::eMaxElementLength2D; + break; + case SMESHOp::OpEqualFace: + aControl = SMESH_Actor:: eCoincidentElems2D; + break; + case SMESHOp::OpAspectRatio3D: + aControl = SMESH_Actor::eAspectRatio3D; + break; + case SMESHOp::OpVolume: + aControl = SMESH_Actor::eVolume3D; + break; + case SMESHOp::OpMaxElementLength3D: + aControl = SMESH_Actor::eMaxElementLength3D; + break; + case SMESHOp::OpBareBorderVolume: + aControl = SMESH_Actor::eBareBorderVolume; + break; + case SMESHOp::OpOverConstrainedVolume: + aControl = SMESH_Actor::eOverConstrainedVolume; + break; + case SMESHOp::OpEqualVolume: + aControl = SMESH_Actor::eCoincidentElems3D; + break; + } + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); SALOME_ListIO selected; if( aSel ) aSel->selectedObjects( selected ); if( !selected.IsEmpty() ){ - Handle(SALOME_InteractiveObject) anIO = selected.First(); - if(!anIO.IsNull()){ - SMESH_Actor::eControl aControl = SMESH_Actor::eNone; - if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) { - switch ( theCommandID ){ - case SMESHOp::OpFreeNode: - aControl = SMESH_Actor::eFreeNodes; - break; - case SMESHOp::OpEqualNode: - aControl = SMESH_Actor::eCoincidentNodes; - break; - case SMESHOp::OpFreeEdge: - aControl = SMESH_Actor::eFreeEdges; - break; - case SMESHOp::OpFreeBorder: - aControl = SMESH_Actor::eFreeBorders; - break; - case SMESHOp::OpLength: - aControl = SMESH_Actor::eLength; - break; - case SMESHOp::OpConnection: - aControl = SMESH_Actor::eMultiConnection; - break; - case SMESHOp::OpEqualEdge: - aControl = SMESH_Actor::eCoincidentElems1D; - break; - case SMESHOp::OpFreeFace: - aControl = SMESH_Actor::eFreeFaces; - break; - case SMESHOp::OpBareBorderFace: - aControl = SMESH_Actor::eBareBorderFace; - break; - case SMESHOp::OpOverConstrainedFace: - aControl = SMESH_Actor::eOverConstrainedFace; - break; - case SMESHOp::OpLength2D: - aControl = SMESH_Actor::eLength2D; - break; - case SMESHOp::OpConnection2D: - aControl = SMESH_Actor::eMultiConnection2D; - break; - case SMESHOp::OpArea: - aControl = SMESH_Actor::eArea; - break; - case SMESHOp::OpTaper: - aControl = SMESH_Actor::eTaper; - break; - case SMESHOp::OpAspectRatio: - aControl = SMESH_Actor::eAspectRatio; - break; - case SMESHOp::OpMinimumAngle: - aControl = SMESH_Actor::eMinimumAngle; - break; - case SMESHOp::OpWarpingAngle: - aControl = SMESH_Actor::eWarping; - break; - case SMESHOp::OpSkew: - aControl = SMESH_Actor::eSkew; - break; - case SMESHOp::OpMaxElementLength2D: - aControl = SMESH_Actor::eMaxElementLength2D; - break; - case SMESHOp::OpEqualFace: - aControl = SMESH_Actor:: eCoincidentElems2D; - break; - case SMESHOp::OpAspectRatio3D: - aControl = SMESH_Actor::eAspectRatio3D; - break; - case SMESHOp::OpVolume: - aControl = SMESH_Actor::eVolume3D; - break; - case SMESHOp::OpMaxElementLength3D: - aControl = SMESH_Actor::eMaxElementLength3D; - break; - case SMESHOp::OpBareBorderVolume: - aControl = SMESH_Actor::eBareBorderVolume; - break; - case SMESHOp::OpOverConstrainedVolume: - aControl = SMESH_Actor::eOverConstrainedVolume; - break; - case SMESHOp::OpEqualVolume: - aControl = SMESH_Actor::eCoincidentElems3D; - break; - } - - anActor->SetControlMode(aControl); - anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() ); - SMESH::RepaintCurrentView(); + SALOME_ListIteratorOfListIO It(selected); + for ( ; It.More(); It.Next()) + { + Handle(SALOME_InteractiveObject) anIO = It.Value(); + if(!anIO.IsNull()){ + _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() ); + if ( SO ) { + CORBA::Object_var aObject = SMESH::SObjectToObject( SO ); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject ); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject ); + if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) { + if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) { + anActor->SetControlMode(aControl); + anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() ); + SMESH::RepaintCurrentView(); #ifndef DISABLE_PLOT2DVIEWER - if(anActor->GetPlot2Histogram()) { - SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram(); - QString functorName = functorToString( anActor->GetFunctor()); - QString aHistogramName("%1 : %2"); - aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName); - aHistogram->setName(aHistogramName); - aHistogram->setHorTitle(functorName); - SMESH::ProcessIn2DViewers(anActor); - } + if(anActor->GetPlot2Histogram()) { + SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram(); + QString functorName = functorToString( anActor->GetFunctor()); + QString aHistogramName("%1 : %2"); + aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName); + aHistogram->setName(aHistogramName); + aHistogram->setHorTitle(functorName); + SMESH::ProcessIn2DViewers(anActor); + } #endif + } + } + } } } } @@ -3530,19 +3543,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) LightApp_SelectionMgr* mgr = selectionMgr(); SALOME_ListIO selected; mgr->selectedObjects( selected ); - if ( selected.Extent() == 1 && selected.First()->hasEntry() ) { - _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() ); - if ( SO ) { - CORBA::Object_var aObject = SMESH::SObjectToObject( SO ); - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject ); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject ); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject ); - if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) { - SUIT_OverrideCursor wc; - ::Control( theCommandID ); - break; - } - } + if( !selected.IsEmpty() ) { + SUIT_OverrideCursor wc; + ::Control( theCommandID ); + break; } SUIT_MessageBox::warning(desktop(), tr( "SMESH_WRN_WARNING" ), @@ -3927,6 +3931,23 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" ); + QList aCtrlActions; + aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode // node controls + << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder + << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls + << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D + << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio + << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew + << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace + << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls + << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume + << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume + << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls + QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() ); + aCtrlGroup->setExclusive( true ); + for( int i = 0; i < aCtrlActions.size(); i++ ) + aCtrlGroup->addAction( action( aCtrlActions[i] ) ); + // ----- create menu -------------- int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ), editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ), @@ -4031,6 +4052,8 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 ); createMenu( SMESHOp::OpEqualVolume, volumeId, -1 ); createMenu( separator(), ctrlId, -1 ); + createMenu( SMESHOp::OpReset, ctrlId, -1 ); + createMenu( separator(), ctrlId, -1 ); createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 ); createMenu( SMESHOp::OpNode, addId, -1 ); diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 80ca03466..94331c901 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -80,8 +80,10 @@ void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr return; _PTR(Study) aStudy = aSStudy->studyDS(); - for( int i=0, n=count(); i 0 ) { + QString mode = myControls[0]; + for( int ind = 1; ind < myControls.count(); ind++ ) { + if( mode != myControls[ind] ) + return "eNone"; + } + return mode; + } + return "eNone"; +} + bool SMESHGUI_Selection::isNumFunctor( int ind ) const { bool result = false; diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 0a9d46ccc..3ba1bf4cb 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -49,6 +49,7 @@ public: virtual void init( const QString&, LightApp_SelectionMgr* ); virtual QVariant parameter( const int, const QString& ) const; + virtual QVariant parameter( const QString& ) const; virtual bool processOwner( const LightApp_DataOwner* ); // got from object, not from actor @@ -74,6 +75,7 @@ public: virtual QString shrinkMode( int ) const; virtual QList entityMode( int ) const; virtual QString controlMode( int ) const; + virtual QString controlMode() const; virtual bool isNumFunctor( int ) const; virtual QString facesOrientationMode( int ) const; virtual QString groupType( int ) const; @@ -87,6 +89,7 @@ public: private: QStringList myTypes; + QStringList myControls; QList myActors; };