From 71725ed92f430789d8ee9d84124e275b91e6da38 Mon Sep 17 00:00:00 2001 From: apl Date: Wed, 19 Oct 2016 20:04:31 +0300 Subject: [PATCH] Update of tree wdg from dialog; Show/Hide all pop-up menu. --- src/GEOMGUI/GEOMGUI_Selection.cxx | 60 ++++++++++++ src/GEOMGUI/GEOMGUI_Selection.h | 4 + src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx | 39 ++++++-- src/GEOMGUI/GEOMGUI_TextTreeWdg.h | 4 +- src/GEOMGUI/GEOM_Displayer.cxx | 8 +- src/GEOMGUI/GEOM_msg_en.ts | 24 +++++ src/GEOMGUI/GEOM_msg_fr.ts | 51 ++++++++-- src/GEOMGUI/GEOM_msg_ja.ts | 57 ++++++++--- src/GEOMGUI/GeometryGUI.cxx | 42 +++++--- src/GEOMGUI/GeometryGUI.h | 2 + src/GEOMGUI/GeometryGUI_Operations.h | 2 + src/MeasureGUI/MeasureGUI.cxx | 103 +++++++++++++++----- src/MeasureGUI/MeasureGUI.h | 12 +++ src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx | 2 +- 14 files changed, 344 insertions(+), 66 deletions(-) mode change 100755 => 100644 src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx mode change 100755 => 100644 src/GEOMGUI/GEOMGUI_TextTreeWdg.h mode change 100755 => 100644 src/GEOMGUI/GeometryGUI.cxx mode change 100755 => 100644 src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 51fd17889..48ac374d6 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -25,6 +25,7 @@ #include "GEOMGUI_Selection.h" #include +#include #include "GeometryGUI.h" #include "GEOM_Displayer.h" @@ -198,6 +199,10 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const v = hasHiddenDimensions(idx); else if ( p == "hasVisibleDimensions" ) v = hasVisibleDimensions(idx); + else if ( p == "hasHiddenAnnotations" ) + v = hasHiddenAnnotations(idx); + else if ( p == "hasVisibleAnnotations" ) + v = hasVisibleAnnotations(idx); else v = LightApp_Selection::parameter( idx, p ); @@ -853,3 +858,58 @@ bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const return isAnyVisible; } +bool GEOMGUI_Selection::hasAnnotations( const int theIndex, bool& theHidden, bool& theVisible ) const +{ + SalomeApp_Study* appStudy = dynamic_cast( study() ); + if ( !appStudy ) + return false; + + QString anEntry = entry( theIndex ); + _PTR(Study) aStudy = appStudy->studyDS(); + if ( !aStudy || anEntry.isNull() ) + return false; + + _PTR(SObject) aSObj = appStudy->studyDS()->FindObjectID( anEntry.toStdString() ); + + const Handle(GEOMGUI_AnnotationAttrs) + aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj ); + + if ( aShapeAnnotations.IsNull() ) + return false; + + theHidden = false; + theVisible = false; + + const int aCount = aShapeAnnotations->GetNbAnnotation(); + for ( int anI = 0; anI < aCount; ++anI ) + { + if ( aShapeAnnotations->GetIsVisible( anI ) ) + theVisible = true; + else + theHidden = true; + } + + return aCount > 0; +} + +bool GEOMGUI_Selection::hasHiddenAnnotations( const int theIndex ) const +{ + bool isAnyVisible, isAnyHidden = false; + if ( !hasAnnotations( theIndex, isAnyHidden, isAnyVisible ) ) + { + return false; + } + + return isAnyHidden; +} + +bool GEOMGUI_Selection::hasVisibleAnnotations( const int theIndex ) const +{ + bool isAnyVisible, isAnyHidden = false; + if ( !hasAnnotations( theIndex, isAnyHidden, isAnyVisible ) ) + { + return false; + } + + return isAnyVisible; +} diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index c5d229aa8..d5f6ba23b 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -85,6 +85,10 @@ private: bool hasHiddenDimensions( const int ) const; bool hasVisibleDimensions( const int ) const; + bool hasAnnotations( const int, bool&, bool& ) const; + bool hasHiddenAnnotations( const int ) const; + bool hasVisibleAnnotations( const int ) const; + GEOM::GEOM_Object_ptr getObject( const int ) const; GEOM::GEOM_BaseObject_ptr getBaseObject( const int ) const; diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx old mode 100755 new mode 100644 index 20b147d5b..99d08dc48 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx @@ -124,6 +124,11 @@ namespace // ---------------------------------------------------------------------------- // Text tree widget implementation // ---------------------------------------------------------------------------- + +//================================================================================= +// function : Constructor +// purpose : +//================================================================================= GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app ) : myDisplayer(NULL) { @@ -181,12 +186,19 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app ) connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) ); GeometryGUI* aGeomGUI = dynamic_cast( app->module( "Geometry" ) ); - connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) ); + connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), + this, SLOT( updateDimensionBranch( const QString& ) ) ); + connect( aGeomGUI, SIGNAL( SignalAnnotationsUpdated( const QString& ) ), + this, SLOT( updateAnnotationBranch( const QString& ) ) ); connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) ); } +//================================================================================= +// function : Destructor +// purpose : +//================================================================================= GEOMGUI_TextTreeWdg::~GEOMGUI_TextTreeWdg() { //std::cout<<"~GEOMGUI_TextTreeWdg"<ReferencedObject( refSO ) ) { // update tree of object's dimensions QString anEntry = valSO->GetID().c_str(); - updateBranch( anEntry ); + updateBranches( anEntry ); aDimensionObjEntries.removeAll( anEntry ); anAnnotationObjEntries.removeAll( anEntry ); } @@ -245,15 +257,30 @@ void GEOMGUI_TextTreeWdg::updateTree() } //================================================================================= -// function : updateBranch +// function : updateBranches // purpose : //================================================================================= -void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry ) +void GEOMGUI_TextTreeWdg::updateBranches( const QString& theEntry ) +{ + updateDimensionBranch( theEntry ); + updateAnnotationBranch( theEntry ); +} + +//================================================================================= +// function : updateDimensionBranch +// purpose : +//================================================================================= +void GEOMGUI_TextTreeWdg::updateDimensionBranch( const QString& theEntry ) { - // dimension property branch fillBranch( DimensionShape, theEntry ); +} - // annotation property branch +//================================================================================= +// function : updateAnnotationBranch +// purpose : +//================================================================================= +void GEOMGUI_TextTreeWdg::updateAnnotationBranch( const QString& theEntry ) +{ fillBranch( AnnotationShape, theEntry ); } diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h old mode 100755 new mode 100644 index a5f03ff8a..99830c8ef --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h @@ -72,7 +72,9 @@ protected: public slots: void updateTree(); - void updateBranch( const QString& theEntry ); + void updateBranches( const QString& theEntry ); + void updateDimensionBranch( const QString& theEntry ); + void updateAnnotationBranch( const QString& theEntry ); private slots: void onItemClicked(QTreeWidgetItem*, int ); diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 7e5d1caad..de6d1bf2d 100755 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -1417,7 +1417,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje if ( !aShapeAnnotations.IsNull() ) { - gp_Trsf aToLCS; + gp_Trsf aToLCS; aToLCS.SetTransformation( theShapeLCS, gp_Ax3() ); for ( int anI = 0; anI < aShapeAnnotations->GetNbAnnotation(); ++anI ) @@ -1427,9 +1427,9 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje continue; } - Handle(GEOM_Annotation) aPresentation = new GEOM_Annotation(); - - aShapeAnnotations->SetupPresentation( aPresentation, anI, theShapeLCS ); + Handle(GEOM_Annotation) aPresentation = new GEOM_Annotation(); + + aShapeAnnotations->SetupPresentation( aPresentation, anI, theShapeLCS ); aPresentation->SetOwner( theIO ); diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 8cd44f2a4..28a048ae1 100755 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -5056,6 +5056,30 @@ Please, select face, shell or solid and try again TOP_POP_HIDE_ALL_DIMENSIONS Show all visible measures (dimension) created for the object + + MEN_POP_SHOW_ALL_ANNOTATIONS + Show all annotations + + + STB_POP_SHOW_ALL_ANNOTATIONS + Show all shape annotations for the object + + + TOP_POP_SHOW_ALL_ANNOTATIONS + Show all shape annotations for the object + + + MEN_POP_HIDE_ALL_ANNOTATIONS + Hide all annotations + + + STB_POP_HIDE_ALL_ANNOTATIONS + Hide all shape annotations for the object + + + TOP_POP_HIDE_ALL_ANNOTATIONS + Hide all shape annotations for the object + TOP_POP_AUTO_COLOR Auto color diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index dbf97b228..c6fa83356 100755 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -3493,37 +3493,48 @@ Choisissez une face, une coque ou un solide et essayez de nouveau Utiliser du texte 3D - PREF_SHAPE_ANNOTATIONS + PREF_SHAPE_ANNOTATIONS + Shape annotations PREF_SHAPE_ANNOTATIONS_FONT + Font PREF_SHAPE_ANNOTATIONS_FONT_COLOR + Font color PREF_SHAPE_ANNOTATIONS_LINE_COLOR + Line color - PREF_SHAPE_ANNOTATIONS_LINE_WIDTH + PREF_SHAPE_ANNOTATIONS_LINE_WIDTH + Line width - PREF_SHAPE_ANNOTATIONS_LINE_STYLE + PREF_SHAPE_ANNOTATIONS_LINE_STYLE + Line style - PREF_SHAPE_ANNOTATIONS_AUTOHIDE + PREF_SHAPE_ANNOTATIONS_AUTOHIDE + Hide when attachment is invisible - PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID + PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID + Solid - PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH + PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH + Dashed - PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT + PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT + Dotted - PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH + PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH + Mixed PREF_HIDE_INPUT_OBJECT @@ -5021,6 +5032,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau TOP_POP_HIDE_ALL_DIMENSIONS Afficher toutes les cotations visibles créées sur l'objet + + MEN_POP_SHOW_ALL_ANNOTATIONS + Show all annotations + + + STB_POP_SHOW_ALL_ANNOTATIONS + Show all shape annotations for the object + + + TOP_POP_SHOW_ALL_ANNOTATIONS + Show all shape annotations for the object + + + MEN_POP_HIDE_ALL_ANNOTATIONS + Hide all annotations + + + STB_POP_HIDE_ALL_ANNOTATIONS + Hide all shape annotations for the object + + + TOP_POP_HIDE_ALL_ANNOTATIONS + Hide all shape annotations for the object + TOP_POP_AUTO_COLOR Couleur automatique diff --git a/src/GEOMGUI/GEOM_msg_ja.ts b/src/GEOMGUI/GEOM_msg_ja.ts index 0fb693805..e2ef6e60e 100755 --- a/src/GEOMGUI/GEOM_msg_ja.ts +++ b/src/GEOMGUI/GEOM_msg_ja.ts @@ -3496,37 +3496,48 @@ 3Dテキストの使用 - PREF_SHAPE_ANNOTATIONS + PREF_SHAPE_ANNOTATIONS + Shape annotations - PREF_SHAPE_ANNOTATIONS_FONT + PREF_SHAPE_ANNOTATIONS_FONT + Font - PREF_SHAPE_ANNOTATIONS_FONT_COLOR + PREF_SHAPE_ANNOTATIONS_FONT_COLOR + Font color - PREF_SHAPE_ANNOTATIONS_LINE_COLOR + PREF_SHAPE_ANNOTATIONS_LINE_COLOR + Line color - PREF_SHAPE_ANNOTATIONS_LINE_WIDTH + PREF_SHAPE_ANNOTATIONS_LINE_WIDTH + Line width - PREF_SHAPE_ANNOTATIONS_LINE_STYLE + PREF_SHAPE_ANNOTATIONS_LINE_STYLE + Line style - PREF_SHAPE_ANNOTATIONS_AUTOHIDE + PREF_SHAPE_ANNOTATIONS_AUTOHIDE + Hide when attachment is invisible - PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID + PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID + Solid - PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH + PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH + Dashed - PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT + PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT + Dotted - PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH + PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH + Mixed PREF_HIDE_INPUT_OBJECT @@ -5024,6 +5035,30 @@ TOP_POP_HIDE_ALL_DIMENSIONS オブジェクトのために作成されたすべての見える基準寸法を表示 + + MEN_POP_SHOW_ALL_ANNOTATIONS + Show all annotations + + + STB_POP_SHOW_ALL_ANNOTATIONS + Show all shape annotations for the object + + + TOP_POP_SHOW_ALL_ANNOTATIONS + Show all shape annotations for the object + + + MEN_POP_HIDE_ALL_ANNOTATIONS + Hide all annotations + + + STB_POP_HIDE_ALL_ANNOTATIONS + Hide all shape annotations for the object + + + TOP_POP_HIDE_ALL_ANNOTATIONS + Hide all shape annotations for the object + TOP_POP_AUTO_COLOR 自動色 diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx old mode 100755 new mode 100644 index 7a65a48d8..27e1aa711 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -667,6 +667,8 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) #endif case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS + case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS + case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS libName = "MeasureGUI"; break; case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE @@ -1117,9 +1119,11 @@ void GeometryGUI::initialize( CAM_Application* app ) #ifndef DISABLE_GRAPHICSVIEW createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" ); #endif - createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" ); - createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" ); - createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" ); + createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" ); + createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" ); + createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" ); + createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" ); + createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" ); // Create actions for increase/decrease transparency shortcuts createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false, @@ -1645,6 +1649,10 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule ); + mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations + mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule ); + mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations + mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object @@ -2759,14 +2767,21 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par aDisplayer.UpdateColorScale( anIsRedisplayFieldSteps, true ); } } - else if ( param == QString("dimensions_color") || - param == QString("dimensions_line_width") || - param == QString("dimensions_font") || - param == QString("dimensions_arrow_length") || - param == QString("dimensions_show_units") || - param == QString("dimensions_length_units") || - param == QString("dimensions_angle_units") || - param == QString("dimensions_use_text3d") || + else if ( param == QString("dimensions_color") || + param == QString("dimensions_line_width") || + param == QString("dimensions_font") || + param == QString("dimensions_arrow_length") || + param == QString("dimensions_show_units") || + param == QString("dimensions_length_units") || + param == QString("dimensions_angle_units") || + param == QString("dimensions_use_text3d") || + param == QString("shape_annotation_font_color") || + param == QString("shape_annotation_line_color") || + param == QString("shape_annotation_font") || + param == QString("shape_annotation_line_width") || + param == QString("shape_annotation_autohide") || + param == QString("shape_annotation_line_style") || + param == QString("shape_annotation_line_style") || param == QString("label_color") ) { SalomeApp_Application* anApp = getApp(); @@ -3590,3 +3605,8 @@ void GeometryGUI::emitDimensionsUpdated( QString entry ) { emit DimensionsUpdated( entry ); } + +void GeometryGUI::emitAnnotationsUpdated( QString entry ) +{ + emit SignalAnnotationsUpdated( entry ); +} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index f92d92ab7..1b64827c5 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -150,6 +150,7 @@ public: const int row, Qt::DropAction action ); void emitDimensionsUpdated( QString entry ); + void emitAnnotationsUpdated( QString entry ); public slots: virtual bool deactivateModule( SUIT_Study* ); @@ -179,6 +180,7 @@ signals : void SignalDefaultStepValueChanged( double newVal ); void SignalDependencyTreeParamChanged( const QString&, const QString& ); void SignalDependencyTreeRenameObject( const QString& ); + void SignalAnnotationsUpdated( const QString& ); void DimensionsUpdated( const QString& ); protected: diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index b045f5c15..caa75d779 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -209,6 +209,8 @@ namespace GEOMOp { #endif OpAnnotation = 5020, // MENU MEASURES - ANNOTATION OpEditAnnotation = 5021, // POPUP MENU - EDIT ANNOTATION + OpShowAllAnnotations = 5022, // POPUP MENU - SHOW ALL ANNOTATIONS + OpHideAllAnnotations = 5023, // POPUP MENU - HIDE ALL ANNOTATIONS // GroupGUI --------------------//-------------------------------- OpGroupCreate = 6000, // MENU GROUP - CREATE OpGroupEdit = 6001, // MENU GROUP - EDIT diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index f4ec47d14..b2371f945 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -30,6 +30,7 @@ #include "GeometryGUI_Operations.h" #include +#include #include #include @@ -163,6 +164,12 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case GEOMOp::OpHideAllDimensions: ChangeDimensionsVisibility( false ); break; // HIDE ALL DIMENSIONS + case GEOMOp::OpShowAllAnnotations: + ChangeAnnotationsVisibility( true ); + break; // SHOW ALL ANNOTATIONS + case GEOMOp::OpHideAllAnnotations: + ChangeAnnotationsVisibility( false ); + break; // HIDE ALL ANNOTATIONS default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; @@ -182,42 +189,23 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible ) { SalomeApp_Application* anApp = getGeometryGUI()->getApp(); - if (!anApp) - { + if ( !anApp ) return; - } SalomeApp_Study* anActiveStudy = dynamic_cast( anApp->activeStudy() ); if ( !anActiveStudy ) - { return; - } - LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); - if ( !aSelMgr ) - { + Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO(); + if ( anIObject.IsNull() + || !anIObject->hasEntry() ) return; - } - - SALOME_ListIO aListIO; - aSelMgr->selectedObjects( aListIO ); - if ( aListIO.Extent() != 1 ) - { - return; - } - - Handle(SALOME_InteractiveObject) anIObject = aListIO.First(); - if ( !anIObject->hasEntry() ) - { - return; - } SUIT_OverrideCursor wc; GEOMGUI_DimensionProperty aDimensions( anActiveStudy, anIObject->getEntry() ); - for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt ) - { + for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt ) { aDimensions.SetVisible( anIt, theIsVisible ); } @@ -226,6 +214,73 @@ void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible ) GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true ); } +//======================================================================= +// function : ChangeAnnotationsVisibility +// purpose : +//======================================================================= +void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible ) +{ + SalomeApp_Application* anApp = getGeometryGUI()->getApp(); + if ( !anApp ) + return; + + SalomeApp_Study* anActiveStudy = dynamic_cast( anApp->activeStudy() ); + if ( !anActiveStudy ) + return; + + Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO(); + if ( anIObject.IsNull() + || !anIObject->hasEntry() ) + return; + + _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ); + + const Handle(GEOMGUI_AnnotationAttrs) + aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj ); + + if ( aShapeAnnotations.IsNull() ) + return; + + const int aCount = aShapeAnnotations->GetNbAnnotation(); + + if ( aCount > 0 ) { + + SUIT_OverrideCursor wc; + + for ( int anI = 0; anI <= aCount; ++anI ) { + + aShapeAnnotations->SetIsVisible( anI, theIsVisible ); + } + + GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true ); + } +} + +//======================================================================= +// function : getSingleSelectedIO +// purpose : returns selected interactive object for single selection. +//======================================================================= +Handle(SALOME_InteractiveObject) MeasureGUI::getSingleSelectedIO() +{ + SalomeApp_Application* anApp = getGeometryGUI()->getApp(); + if ( !anApp ) { + return Handle(SALOME_InteractiveObject)(); + } + + LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + if ( !aSelMgr ) { + return Handle(SALOME_InteractiveObject)(); + } + + SALOME_ListIO aListIO; + aSelMgr->selectedObjects( aListIO ); + if ( aListIO.Extent() != 1 ) { + return Handle(SALOME_InteractiveObject)(); + } + + return aListIO.First(); +} + //======================================================================= // function : onFinished // purpose : called then "Manage Dimension" dialog is closed. diff --git a/src/MeasureGUI/MeasureGUI.h b/src/MeasureGUI/MeasureGUI.h index 3067bbcc2..03a3bf51c 100644 --- a/src/MeasureGUI/MeasureGUI.h +++ b/src/MeasureGUI/MeasureGUI.h @@ -27,8 +27,12 @@ #ifndef MEASUREGUI_H #define MEASUREGUI_H +// GEOM includes #include +// GUI includes +#include + class QDialog; //================================================================================= @@ -52,6 +56,14 @@ public: // Show/hide all dimension created for object void ChangeDimensionsVisibility( const bool theIsVisible ); + + // Show/hide all shape annotations created for GEOM object + void ChangeAnnotationsVisibility( const bool theIsVisible ); + +private: + // Returns selected interactive object for single selection + Handle(SALOME_InteractiveObject) getSingleSelectedIO(); + private: QDialog* myManageDimensionDlg; private slots: diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx old mode 100755 new mode 100644 index 1e2f31a66..4a7042971 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx @@ -596,7 +596,7 @@ bool MeasureGUI_AnnotationDlg::execute() aShapeAnnotations->Append( myAnnotationProperties ); - /* myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) ); */ + myGeomGUI->emitAnnotationsUpdated( QString( myShape->GetStudyEntry() ) ); } else { /*SalomeApp_Study* aStudy = getStudy(); -- 2.39.2