-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "GEOMGUI_Selection.h"
#include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOMGUI_AnnotationMgr.h>
#include "GeometryGUI.h"
#include "GEOM_Displayer.h"
#include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_GraphicTool.hxx>
-#include <AIS_Drawer.hxx>
#include <Aspect_TypeOfFacingModel.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include<Graphic3d_MaterialAspect.hxx>
v = hasImported();
else if ( p == "allImported" )
v = allImported();
+ else if (p == "annotationsCount")
+ v = annotationsCount();
else
v = LightApp_Selection::parameter( p );
return v;
v = isVectorsMode( idx );
else if ( p == "isVerticesMode" )
v = isVerticesMode( idx );
+ else if ( p == "isNameMode" )
+ v = isNameMode( idx );
else if ( p == "topLevel" )
v = topLevel( idx );
else if ( p == "autoBringToFront" )
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("_");
}
GEOM::GEOM_Object_var obj = getObject( index );
SALOME_View* view = GEOM_Displayer::GetActiveView();
if ( !CORBA::is_nil( obj ) && view ) {
- Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toLatin1().constData(), "GEOM", "TEMP_IO" );
+ Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toUtf8().constData(), "GEOM", "TEMP_IO" );
res = view->isVisible( io );
}
SALOME_View* view = GEOM_Displayer::GetActiveView();
if ( view /*fix for 9320==>*/&& ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
- SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
+ SALOME_Prs* prs = view->CreatePrs( entry( index ).toUtf8().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const
{
- return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" );
+ return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
}
bool GEOMGUI_Selection::isVectorsMode( const int index ) const
SALOME_View* view = GEOM_Displayer::GetActiveView();
QString viewType = activeViewType();
if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
- SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
+ SALOME_Prs* prs = view->CreatePrs( entry( index ).toUtf8().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
SALOME_View* view = GEOM_Displayer::GetActiveView();
QString viewType = activeViewType();
if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
- SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
+ SALOME_Prs* prs = view->CreatePrs( entry( index ).toUtf8().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
return res;
}
-bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
+bool GEOMGUI_Selection::isNameMode( const int index ) const
{
- if ( obj ) {
- // as soon as Use Case browser data tree was added
- return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
+#ifdef USE_VISUAL_PROP_MAP
+ QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::ShowName ) );
+ if ( v.canConvert( QVariant::Bool ) )
+ return v.toBool();
+#endif
+
+ bool res = false;
+
+ SALOME_View* view = GEOM_Displayer::GetActiveView();
+ QString viewType = activeViewType();
+ if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
+ SALOME_Prs* prs = view->CreatePrs( entry( index ).toUtf8().constData() );
+ if ( prs ) {
+ if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
+ SOCC_Prs* occPrs = (SOCC_Prs*) prs;
+ AIS_ListOfInteractive lst;
+ occPrs->GetObjects( lst );
+ if ( lst.Extent() ) {
+ Handle(AIS_InteractiveObject) io = lst.First();
+ if ( !io.IsNull() ) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
+ if ( !aSh.IsNull() )
+ res = aSh->isShowName();
+ }
+ }
+ }
+ else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
+ SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
+ vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
+ if ( lst ) {
+ lst->InitTraversal();
+ vtkActor* actor = lst->GetNextActor();
+ if ( actor ) {
+ GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
+ if ( aGeomActor )
+ res = aGeomActor->GetNameMode();
+ }
+ }
+ }
+ }
}
+
+ return res;
+}
+
+bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
+{
+ // as soon as Use Case browser data tree was added
+ return obj ? SalomeApp_Application::getStudy()->GetUseCaseBuilder()->HasChildren( obj ) : false;
}
bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
_PTR(Study) study = appStudy->studyDS();
if ( study && !anEntry.isEmpty() ) {
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
- if ( aSO && aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
- _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
+ if ( aSO && study->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
+ _PTR(UseCaseIterator) it = study->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
for (it->Init(false); it->More(); it->Next()) nb++;
}
}
SALOME_View* view = GEOM_Displayer::GetActiveView();
QString viewType = activeViewType();
if ( view && viewType == OCCViewer_Viewer::Type() ) {
- SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
+ SALOME_Prs* prs = view->CreatePrs( entry( index ).toUtf8().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
SALOME_View* view = GEOM_Displayer::GetActiveView();
QString viewType = activeViewType();
if ( view ) {
- SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() );
+ SALOME_Prs* prs = view->CreatePrs( entry( idx ).toUtf8().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
bool GEOMGUI_Selection::hasDimensions( 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() )
+ if ( anEntry.isNull() )
{
return false;
}
- GEOMGUI_DimensionProperty aDimensions( appStudy, anEntry.toStdString() );
+ GEOMGUI_DimensionProperty aDimensions( anEntry.toStdString() );
theHidden = false;
theVisible = false;
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() );
+
+ 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;
+}