#include "GEOMGUI_Selection.h"
#include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOMGUI_AnnotationMgr.h>
#include "GeometryGUI.h"
#include "GEOM_Displayer.h"
v = hasImported();
else if ( p == "allImported" )
v = allImported();
+ else if (p == "annotationsCount")
+ v = annotationsCount();
else
v = LightApp_Selection::parameter( p );
return v;
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 );
// the method to skip temporary objects from selection (called from LightApp)
bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
{
+ if ( theOwner->entry().contains( GEOMGUI_AnnotationMgr::GetEntrySeparator() ) ) {
+ myAnnotationEntries.append( theOwner->entry() );
+ }
return !theOwner->entry().contains("_");
}
bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
{
- if ( obj ) {
- // as soon as Use Case browser data tree was added
- return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
- }
+ // as soon as Use Case browser data tree was added
+ return obj ? obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj ) : false;
}
bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
return isAnyVisible;
}
+int GEOMGUI_Selection::annotationsCount() const
+{
+ return myAnnotationEntries.size();
+}
+
+bool GEOMGUI_Selection::hasAnnotations( const int theIndex, bool& theHidden, bool& theVisible ) const
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( 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() );\r
+
+ const Handle(GEOMGUI_AnnotationAttrs)\r
+ aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );\r
+
+ if ( aShapeAnnotations.IsNull() )\r
+ return false;\r
+
+ 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;
+}