0022672: SMESH: Add a "Reset" in the "Controls" menu of smesh

This commit is contained in:
mpa 2014-09-08 10:30:44 +04:00
parent 9230651287
commit d0cb9e8d04
3 changed files with 171 additions and 112 deletions

View File

@ -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<int> 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 );

View File

@ -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<n; i++ )
for( int i=0, n=count(); i<n; i++ ) {
myTypes.append( typeName( type( entry( i ), aStudy ) ) );
myControls.append( controlMode( i ) );
}
}
}
@ -122,7 +124,6 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
else if ( p=="labeledTypes" ) val = QVariant( labeledTypes( ind ) );
else if ( p=="shrinkMode" ) val = QVariant( shrinkMode( ind ) );
else if ( p=="entityMode" ) val = QVariant( entityMode( ind ) );
else if ( p=="controlMode" ) val = QVariant( controlMode( ind ) );
else if ( p=="isNumFunctor" ) val = QVariant( isNumFunctor( ind ) );
else if ( p=="displayMode" ) val = QVariant( displayMode( ind ) );
else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) );
@ -143,6 +144,21 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
return LightApp_Selection::parameter( ind, p );
}
//=======================================================================
//function : parameter
//purpose :
//=======================================================================
QVariant SMESHGUI_Selection::parameter( const QString& p ) const
{
QVariant val;
if ( p=="controlMode" ) val = QVariant( controlMode() );
if ( val.isValid() )
return val;
else
return LightApp_Selection::parameter( p );
}
//=======================================================================
//function : getVtkOwner
//purpose :
@ -318,6 +334,23 @@ QString SMESHGUI_Selection::controlMode( int ind ) const
return mode;
}
//=======================================================================
//function : controlMode
//purpose : gets global control mode; return SMESH_Actor::eControl
//=======================================================================
QString SMESHGUI_Selection::controlMode() const
{
if( myControls.count() > 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;

View File

@ -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<QVariant> 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<SMESH_Actor*> myActors;
};