From 5218291db413b71dd88a5590a40a961703ceb826 Mon Sep 17 00:00:00 2001 From: imn Date: Fri, 19 Feb 2016 15:40:34 +0300 Subject: [PATCH] INT PAL 0053058: '2D Quadratic' item is shown in VTK context menu for non-quadratic mesh --- src/SMESHGUI/SMESHGUI.cxx | 4 ++-- src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx | 2 +- src/SMESHGUI/SMESHGUI_ConvToQuadOp.h | 4 ++-- src/SMESHGUI/SMESHGUI_Selection.cxx | 20 ++++++++++++++++++++ src/SMESHGUI/SMESHGUI_Selection.h | 1 + 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index d72312ddb..2b367eb97 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -4487,11 +4487,11 @@ void SMESHGUI::initialize( CAM_Application* app ) //------------------------------------------------- anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 ); popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 ); - popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule ); + popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule ); popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 ); - popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule ); + popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule ); //------------------------------------------------- diff --git a/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx b/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx index cc60fc471..b79102f05 100644 --- a/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx +++ b/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx @@ -326,7 +326,7 @@ void SMESHGUI_ConvToQuadOp::onWarningWinFinished() SMESHGUI_ConvToQuadOp::MeshDestinationType SMESHGUI_ConvToQuadOp::DestinationMesh( const SMESH::SMESH_IDSource_var& idSource, - bool* isMixOrder) const + bool* isMixOrder) { SMESH::long_array_var nbElemOfType = idSource->GetMeshInfo(); diff --git a/src/SMESHGUI/SMESHGUI_ConvToQuadOp.h b/src/SMESHGUI/SMESHGUI_ConvToQuadOp.h index e700c8f09..305ded865 100644 --- a/src/SMESHGUI/SMESHGUI_ConvToQuadOp.h +++ b/src/SMESHGUI/SMESHGUI_ConvToQuadOp.h @@ -52,12 +52,12 @@ public: virtual LightApp_Dialog* dlg() const; + static MeshDestinationType DestinationMesh( const SMESH::SMESH_IDSource_var& , + bool* isMixOrder = 0); protected: virtual void startOperation(); virtual void selectionDone(); virtual SUIT_SelectionFilter* createFilter( const int ) const; - MeshDestinationType DestinationMesh( const SMESH::SMESH_IDSource_var& , - bool* isMixOrder = 0) const; protected slots: virtual bool onApply(); diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 3d446d96d..8c12c817b 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_ComputeDlg.h" +#include "SMESHGUI_ConvToQuadOp.h" #include #include @@ -133,6 +134,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const else if ( p=="isImported" ) val = QVariant( isImported( ind ) ); else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) ); else if ( p=="groupType" ) val = QVariant( groupType( ind ) ); + else if ( p=="isQuadratic" ) val = QVariant( isQuadratic( ind ) ); else if ( p=="quadratic2DMode") val = QVariant( quadratic2DMode( ind ) ); else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) ); else if ( p=="isScalarBarVisible") val = QVariant( isScalarBarVisible( ind ) ); @@ -231,6 +233,24 @@ QString SMESHGUI_Selection::displayMode( int ind ) const return "Unknown"; } +//======================================================================= +//function : isQuadratic +//purpose : return true if the mesh has quadratic/bi-quadratic type +//======================================================================= + +bool SMESHGUI_Selection::isQuadratic( int ind ) const +{ + _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + if ( !so ) + return false; + SMESH::SMESH_IDSource_var idSource = SMESH::SObjectToInterface( so ); + if ( idSource->_is_nil() ) + return false; + SMESHGUI_ConvToQuadOp::MeshDestinationType meshTgtType = SMESHGUI_ConvToQuadOp::DestinationMesh( idSource ); + if ( meshTgtType & SMESHGUI_ConvToQuadOp::MeshDestinationType::Linear ) + return true; + return false; +} //======================================================================= //function : quadratic2DMode diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index e3146cad3..c62f14a5d 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -62,6 +62,7 @@ public: virtual bool isEditableHyp( int ) const; virtual bool isVisible( int ) const; + virtual bool isQuadratic( int ) const; virtual QString quadratic2DMode( int ) const; virtual bool isDistributionVisible( int ) const; -- 2.39.2