Edit/Delete popup menues enable on presentation selected in OCC viewer.

This commit is contained in:
nds 2016-11-15 21:20:03 +03:00
parent fa65931a8c
commit 8aa2876800
3 changed files with 16 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include "GEOMGUI_Selection.h" #include "GEOMGUI_Selection.h"
#include <GEOMGUI_DimensionProperty.h> #include <GEOMGUI_DimensionProperty.h>
#include <GEOMGUI_AnnotationAttrs.h> #include <GEOMGUI_AnnotationAttrs.h>
#include <GEOMGUI_AnnotationMgr.h>
#include "GeometryGUI.h" #include "GeometryGUI.h"
#include "GEOM_Displayer.h" #include "GEOM_Displayer.h"
@ -152,6 +153,8 @@ QVariant GEOMGUI_Selection::parameter( const QString& p ) const
v = hasImported(); v = hasImported();
else if ( p == "allImported" ) else if ( p == "allImported" )
v = allImported(); v = allImported();
else if (p == "annotationsCount")
v = annotationsCount();
else else
v = LightApp_Selection::parameter( p ); v = LightApp_Selection::parameter( p );
return v; return v;
@ -212,6 +215,9 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
// the method to skip temporary objects from selection (called from LightApp) // the method to skip temporary objects from selection (called from LightApp)
bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner ) bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
{ {
if ( theOwner->entry().contains( GEOMGUI_AnnotationMgr::GetEntrySeparator() ) ) {
myAnnotationEntries.append( theOwner->entry() );
}
return !theOwner->entry().contains("_"); return !theOwner->entry().contains("_");
} }
@ -858,6 +864,11 @@ bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const
return isAnyVisible; return isAnyVisible;
} }
int GEOMGUI_Selection::annotationsCount() const
{
return myAnnotationEntries.size();
}
bool GEOMGUI_Selection::hasAnnotations( const int theIndex, bool& theHidden, bool& theVisible ) const bool GEOMGUI_Selection::hasAnnotations( const int theIndex, bool& theHidden, bool& theVisible ) const
{ {
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );

View File

@ -85,6 +85,8 @@ private:
bool hasHiddenDimensions( const int ) const; bool hasHiddenDimensions( const int ) const;
bool hasVisibleDimensions( const int ) const; bool hasVisibleDimensions( const int ) const;
int annotationsCount() const;
bool hasAnnotations( const int, bool&, bool& ) const; bool hasAnnotations( const int, bool&, bool& ) const;
bool hasHiddenAnnotations( const int ) const; bool hasHiddenAnnotations( const int ) const;
bool hasVisibleAnnotations( const int ) const; bool hasVisibleAnnotations( const int ) const;
@ -102,6 +104,7 @@ private:
private: private:
GeomObjectVector myObjects; GeomObjectVector myObjects;
QStringList myAnnotationEntries;
}; };
#endif #endif

View File

@ -1623,9 +1623,9 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
mgr->setRule( action( GEOMOp::OpEditAnnotation ), QString("($component={'GEOM'}) and type='Shape' and selcount=1"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), QString("($component={'GEOM'}) and type='Shape' and selcount=1"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and (annotationsCount>1)", QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ", QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",