From: apl Date: Mon, 7 Nov 2016 14:20:36 +0000 (+0300) Subject: Minor corrections + annotation positioning X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=156afd89d0373ee282ca8a1720999584fd83d10d;p=modules%2Fgeom.git Minor corrections + annotation positioning --- diff --git a/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx index a5a656979..d378acd49 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx +++ b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx @@ -426,7 +426,7 @@ void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& aText.Insert( i + 1, theProps.Text[ i ].unicode() ); thePresentation->SetText( aText ); - thePresentation->SetScreenFixed( theProps.IsScreenFixed ); + thePresentation->SetIsScreenFixed( theProps.IsScreenFixed ); thePresentation->SetAttachPoint( theProps.Attach.Transformed( aFromShapeLCS ) ); thePresentation->SetPosition( (theProps.IsScreenFixed) ? theProps.Position : theProps.Position.Transformed( aFromShapeLCS ) ); diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx index 0ffd1d6ce..eb0b67b7d 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx @@ -48,7 +48,10 @@ #include #include - +//================================================================ +// Function : Constructor +// Purpose : +//================================================================ GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication ) : myApplication( theApplication ) { @@ -59,6 +62,10 @@ QString GEOMGUI_AnnotationMgr::GetEntrySeparator() return "_annotation:"; } +//================================================================ +// Function : CreatePresentation +// Purpose : +//================================================================ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty, GEOM::GEOM_Object_ptr theObject, const QString& theEntry ) @@ -71,32 +78,13 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA aPresentation->SetOwner( anIO ); } - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) ); - const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) ); - const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) ); - const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 ); - const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 ); - const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false ); - - const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ); - const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ); - const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize(); - - aPresentation->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) ); - aPresentation->SetTextHeight( aFontHeight ); - aPresentation->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) ); - aPresentation->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) ); - aPresentation->SetLineWidth( aLineWidth ); - aPresentation->SetLineStyle( static_cast( aLineStyle ) ); - aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False ); - aPresentation->SetScreenFixed( theProperty.IsScreenFixed ); + aPresentation->SetOwner( new SALOME_InteractiveObject( getEntry( theObject ).c_str(), "GEOM", getName( theObject ).c_str() ) ); TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject ); - //TopoDS_Shape aShape; - //GEOMBase::GetShape( theObject.get(), aShape ); + gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); - GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS ); + + setAISProperties( aPresentation, theProperty, aShapeLCS ); // add Prs to preview SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow(); @@ -110,6 +98,10 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA return aPrs; } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::IsDisplayed +// purpose : +//======================================================================= bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView ) const { SALOME_View* aView = viewOrActiveView( theView ); @@ -164,9 +156,13 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex myVisualized[aView] = anEntryToMap; // change persistent for the entry: set visible state in true for indices which presentations are shown - storeVisibleState( theEntry, theView ); + storeVisibleState( theEntry, aView ); } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::Erase +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SALOME_View* theView ) { SALOME_View* aView = viewOrActiveView( theView ); @@ -202,11 +198,19 @@ void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, myVisualized[aView] = anEntryToAnnotation; // change persistent for the entry: set visible state in true for indices which presentations are shown - storeVisibleState( theEntry, theView ); + storeVisibleState( theEntry, aView ); } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView ) { + SALOME_View* aView = viewOrActiveView( theView ); + if ( !aView ) + return; + SalomeApp_Study* aStudy = dynamic_cast( getApplication()->activeStudy() ); _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() ); const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj ); @@ -215,14 +219,21 @@ void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, for ( int anIndex = 0; anIndex < aCount; ++anIndex ) { if ( aShapeAnnotations->GetIsVisible( anIndex ) ) - Display( theEntry, anIndex, theView ); + Display( theEntry, anIndex, aView ); } } } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::EraseVisibleAnnotations +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView ) { SALOME_View* aView = viewOrActiveView( theView ); + if ( !aView ) + return; + if ( !myVisualized.contains( aView ) ) return; @@ -325,12 +336,20 @@ int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject) return anIndex; } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::RemoveView +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::RemoveView( SALOME_View* theView ) { if ( !theView && myVisualized.contains( theView ) ) myVisualized.remove( theView ); } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo +// purpose : +//======================================================================= QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView ) const { QString aDisplayedIndices; @@ -352,6 +371,10 @@ QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry, return aDisplayedIndices; } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView, const QString theIndicesInfo ) { @@ -364,17 +387,28 @@ void GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo( const QString& theEntry, SA } } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::getDisplayer +// purpose : +//======================================================================= GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const { LightApp_Module* aModule = dynamic_cast( getApplication()->activeModule() ); return dynamic_cast( aModule->displayer() ); } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::viewOrActiveView +// purpose : +//======================================================================= SALOME_View* GEOMGUI_AnnotationMgr::viewOrActiveView(SALOME_View* theView) const { SALOME_View* aView = theView; if ( !aView ) { SalomeApp_Application* anApp = getApplication(); + if (!anApp) + return theView; + SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow(); if (anActiveWindow) aView = dynamic_cast(anActiveWindow->getViewManager()->getViewModel()); @@ -382,6 +416,10 @@ SALOME_View* GEOMGUI_AnnotationMgr::viewOrActiveView(SALOME_View* theView) const return aView; } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::getObject +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex, GEOM::GEOM_Object_ptr& theObject, GEOMGUI_AnnotationAttrs::Properties& theProperty ) @@ -396,6 +434,10 @@ void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theInd } } +//======================================================================= +// function : GEOMGUI_AnnotationMgr::storeVisibleState +// purpose : +//======================================================================= void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SALOME_View* theView ) { SALOME_View* aView = viewOrActiveView( theView ); @@ -420,3 +462,86 @@ void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SALOME_V } } } + +//======================================================================= +// function : GEOMGUI_AnnotationMgr::getEntry +// purpose : +//======================================================================= +std::string GEOMGUI_AnnotationMgr::getEntry( const GEOM::GEOM_Object_ptr theObject ) +{ + SUIT_Session* session = SUIT_Session::session(); + SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); + if ( app ) + { + CORBA::String_var IOR = app->orb()->object_to_string( theObject ); + if ( strcmp(IOR.in(), "") != 0 ) + { + SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy(); + _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) ); + if ( SO ) + return SO->GetID(); + } + } + return std::string(); +} + +//======================================================================= +// function : GEOMGUI_AnnotationMgr::getName +// purpose : +//======================================================================= +std::string GEOMGUI_AnnotationMgr::getName( const GEOM::GEOM_Object_ptr theObject ) +{ + SUIT_Session* session = SUIT_Session::session(); + SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); + if ( app ) + { + CORBA::String_var IOR = app->orb()->object_to_string( theObject ); + if ( strcmp(IOR.in(), "") != 0 ) + { + SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy(); + _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) ); + + _PTR(GenericAttribute) anAttr; + + if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) + { + _PTR(AttributeName) aNameAttr( anAttr ); + return aNameAttr->Value(); + } + } + } + return std::string(); +} + +//======================================================================= +// function : GEOMGUI_AnnotationMgr::setAISProperties +// purpose : +//======================================================================= +void GEOMGUI_AnnotationMgr::setAISProperties( const Handle(GEOM_Annotation)& thePresentation, + const GEOMGUI_AnnotationAttrs::Properties& theProperty, + const gp_Ax3& theLCS ) +{ + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) ); + const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) ); + const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) ); + const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 ); + const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 ); + const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false ); + + const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ); + const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ); + const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize(); + + thePresentation->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) ); + thePresentation->SetTextHeight( aFontHeight ); + thePresentation->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) ); + thePresentation->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) ); + thePresentation->SetLineWidth( aLineWidth ); + thePresentation->SetLineStyle( static_cast( aLineStyle ) ); + thePresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False ); + thePresentation->SetIsScreenFixed( theProperty.IsScreenFixed ); + + GEOMGUI_AnnotationAttrs::SetupPresentation( thePresentation, theProperty, theLCS ); +} diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h index fe0339319..6ea2db9e6 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h @@ -32,6 +32,7 @@ #include class SalomeApp_Application; +class GEOM_Annotation; class GEOM_Displayer; /*! @@ -56,7 +57,7 @@ public: bool IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ) const; void Display( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ); void Erase( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ); - + void DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 ); void EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 ); @@ -73,6 +74,7 @@ public: void setDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView, const QString theIndicesInfo ); protected: + SalomeApp_Application* getApplication() const { return myApplication; } GEOM_Displayer* getDisplayer() const; @@ -85,6 +87,14 @@ protected: void storeVisibleState( const QString& theEntry, SALOME_View* theView ); + std::string getEntry( const GEOM::GEOM_Object_ptr theObject ); + + std::string getName( const GEOM::GEOM_Object_ptr theObject ); + + void setAISProperties( const Handle(GEOM_Annotation)& thePresentation, + const GEOMGUI_AnnotationAttrs::Properties& theProperty, + const gp_Ax3& theLCS ); + private: SalomeApp_Application* myApplication; diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx old mode 100644 new mode 100755 index c7aeee561..f42ab0ec1 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx @@ -103,7 +103,7 @@ namespace return !myAttr.IsNull() ? myAttr->GetNbAnnotation() : 0; } virtual QString GetName( const int theIndex ) Standard_OVERRIDE { - return !myAttr.IsNull() ? myAttr->GetName( theIndex ) : QString(); + return !myAttr.IsNull() ? myAttr->GetText( theIndex ) : QString(); } virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE { return annotationMgr()->IsDisplayed(myEntry, theIndex); diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index e2ab1e289..2371bf229 100755 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -1380,108 +1380,6 @@ void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& t } } -//================================================================= -/*! - * GEOM_Displayer::updateShapeAnnotations - * Creates or renews shape annotation presentation for the IO. - */ -//================================================================= -void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObject)& theIO, - SALOME_OCCPrs* thePrs, - const gp_Ax3& theShapeLCS ) -{ - return; - /* - SalomeApp_Study* aStudy = getStudy(); - if ( !aStudy ) - { - return; - } - - if ( theIO.IsNull() ) - { - return; - } - - SOCC_Prs* anOccPrs = dynamic_cast( thePrs ); - AIS_ListOfInteractive aListOfIO; - anOccPrs->GetObjects( aListOfIO ); - AIS_ListIteratorOfListOfInteractive aIterateIO( aListOfIO ); - - // remove existing presentations of shape annotations - bool isAnyRemoved = false; - for ( ; aIterateIO.More(); aIterateIO.Next() ) - { - const Handle(AIS_InteractiveObject)& anIO = aIterateIO.Value(); - if ( !anIO->IsKind( STANDARD_TYPE( GEOM_Annotation ) ) ) - continue; - - aListOfIO.Remove( aIterateIO ); - isAnyRemoved = true; - if ( !aIterateIO.More() ) - break; - } - - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - - const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) ); - const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) ); - const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) ); - const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 ); - const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 ); - const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false ); - - _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theIO->getEntry() ); - - const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj ); - - if ( !aShapeAnnotations.IsNull() ) - { - gp_Trsf aToLCS; - aToLCS.SetTransformation( theShapeLCS, gp_Ax3() ); - - for ( int anI = 0; anI < aShapeAnnotations->GetNbAnnotation(); ++anI ) - { - if ( !aShapeAnnotations->GetIsVisible( anI ) ) - { - continue; - } - - Handle(GEOM_Annotation) aPresentation = new GEOM_Annotation(); - - aShapeAnnotations->SetupPresentation( aPresentation, anI, theShapeLCS ); - - aPresentation->SetOwner( theIO ); - - const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ); - const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ); - const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize(); - - aPresentation->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) ); - aPresentation->SetTextHeight( aFontHeight ); - aPresentation->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) ); - aPresentation->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) ); - aPresentation->SetLineWidth( aLineWidth ); - aPresentation->SetLineStyle( static_cast( aLineStyle ) ); - aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False ); - aPresentation->SetDepthCulling( Standard_True ); - - aListOfIO.Append( aPresentation ); - } - } - else if ( !isAnyRemoved ) - { - return; - } - - anOccPrs->Clear(); - - for ( aIterateIO.Initialize( aListOfIO ); aIterateIO.More(); aIterateIO.Next() ) - { - anOccPrs->AddObject( aIterateIO.Value() ); - }*/ -} - //================================================================= /*! * GEOM_Displayer::Erase @@ -1672,7 +1570,6 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) } updateDimensions( myIO, occPrs, gp_Ax3().Transformed( myShape.Location().Transformation() ) ); - updateShapeAnnotations( myIO, occPrs, gp_Ax3().Transformed( myShape.Location().Transformation() ) ); } } diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx index 4ac600bf8..86c04cbed 100755 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -121,11 +122,9 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI, setWindowTitle( myIsCreation ? tr( "CREATE_ANNOTATION_TITLE" ) : tr( "EDIT_ANNOTATION_TITLE" ) ); // Shape type button group + mainFrame()->GroupBoxName->hide(); mainFrame()->GroupConstructors->hide(); - // Field name - mainFrame()->GroupBoxName->setTitle( tr( "ANNOTATION_NAME" ) ); - // Field properties QGroupBox* propGroup = new QGroupBox( tr( "ANNOTATION_PROPERTIES" ), centralWidget() ); QGridLayout* propLayout = new QGridLayout( propGroup ); @@ -183,21 +182,10 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI, propLayout->addWidget( mySubShapeSelBtn, 4, 1 ); propLayout->addWidget( mySubShapeName, 4, 2 ); - // Field properties - QGroupBox* styleGroup = new QGroupBox( tr( "ANNOTATION_STYLE" ), - centralWidget() ); - QGridLayout* styleLayout = new QGridLayout( styleGroup ); - styleLayout->setMargin( 9 ); - styleLayout->setSpacing( 6 ); - - QLabel* fontLabel = new QLabel( tr( "ANNOTATION_FONT" ), styleGroup ); - styleLayout->addWidget( fontLabel, 0, 0 ); - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( propGroup ); - layout->addWidget( styleGroup ); setHelpFileName( "annotation_page.html" ); @@ -232,11 +220,10 @@ MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg() { void MeasureGUI_AnnotationDlg::Init() { if ( myIsCreation ) { - initName( tr( "ANNOTATION_PREFIX" ) ); // default presentation values + myIsPositionDefined = false; myAnnotationProperties.Name = getNewObjectName(); - myAnnotationProperties.Position = gp_Pnt( 250, 250, 250 ); myAnnotationProperties.Text = tr( "ANNOTATION_PREFIX" ); myAnnotationProperties.IsVisible = false; myAnnotationProperties.IsScreenFixed = false; @@ -419,6 +406,7 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() GEOM::GeomObjPtr anObj = getSelected( mySelectionMode ); + bool hasAttachPoint = false; gp_Pnt anAttachPoint( 0, 0, 0 ); int aSubShapeIndex = -1; if ( myEditCurrentArgument == myShapeName ) { // Selection of a shape is active @@ -445,15 +433,16 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() TopoDS_Shape aShape; GEOMBase::GetShape( myShape.get(), aShape ); - if ( !getPickedPoint( anAttachPoint ) ) { + if ( !getPickedPoint( anAttachPoint, aShape ) ) { anAttachPoint = getAttachPoint( aShape ); } - gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); - gp_Trsf aToShapeLCS; - aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS ); - anAttachPoint.Transform( aToShapeLCS ); + hasAttachPoint = true; + } + else { + + myIsPositionDefined = false; } } else if ( myEditCurrentArgument == mySubShapeName ) { if ( !myShape->_is_nil() ) { @@ -482,21 +471,42 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() TopoDS_Shape aShape; GEOMBase::GetShape( myShape.get(), aShape ); - if ( !getPickedPoint( anAttachPoint ) ) { + if ( !getPickedPoint( anAttachPoint, aSubShape ) ) { anAttachPoint = getAttachPoint( aSubShape ); } - gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); - gp_Trsf aToShapeLCS; - aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS ); - anAttachPoint.Transform( aToShapeLCS ); + hasAttachPoint = true; + } + else { + + myIsPositionDefined = false; } } } myAnnotationProperties.ShapeIndex = aSubShapeIndex; } - myAnnotationProperties.Attach = anAttachPoint; + + gp_Trsf aToShapeLCS; + if ( !myShape->_is_nil() ) { + + TopoDS_Shape aShape; + GEOMBase::GetShape( myShape.get(), aShape ); + gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); + aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS ); + } + + myAnnotationProperties.Attach = anAttachPoint.Transformed( aToShapeLCS ); + + if ( hasAttachPoint && !myIsPositionDefined ) { + + gp_Pnt aPosition = getDefaultPosition( anAttachPoint ); + + myAnnotationProperties.Position = ( !myAnnotationProperties.IsScreenFixed ) ? + aPosition.Transformed( aToShapeLCS ) : aPosition; + + myIsPositionDefined = true; + } } redisplayPreview(); } @@ -532,7 +542,48 @@ void MeasureGUI_AnnotationDlg::onTextChange() //======================================================================= void MeasureGUI_AnnotationDlg::onTypeChange() { + const bool isScreenFixedBefore = myAnnotationProperties.IsScreenFixed; + myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1; + + // convert point position from screen space to 3D space + if ( myIsPositionDefined ) { + + SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView(); + OCCViewer_ViewWindow* anOccView = NULL; + if ( anActiveView ) { + + anOccView = qobject_cast( anActiveView ); + } + + if ( anOccView ) { + + TopoDS_Shape aShape; + GEOMBase::GetShape( myShape.get(), aShape ); + const gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); + + gp_Trsf aToShapeLCS, aFrShapeLCS; + aFrShapeLCS.SetTransformation( aShapeLCS, gp_Ax3() ); + aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS ); + + const Handle(V3d_View) aView3d = anOccView->getViewPort()->getView(); + const gp_Pnt aPosition = myAnnotationProperties.Position; + const gp_Pnt aAttach3d = myAnnotationProperties.Attach.Transformed( aFrShapeLCS ); + if ( !isScreenFixedBefore ) { + + gp_Pnt aPosition3d = aPosition.Transformed( aFrShapeLCS ); + gp_Pnt aPosition2d = GEOM_Annotation::ConvertPosition2d( aPosition3d, aAttach3d, aView3d ); + myAnnotationProperties.Position = aPosition2d; + } + else { + + gp_Pnt aPosition3d = GEOM_Annotation::ConvertPosition3d( aPosition, aAttach3d, aView3d ); + aPosition3d = aPosition3d.Transformed( aToShapeLCS ); + myAnnotationProperties.Position = aPosition3d; + } + } + } + redisplayPreview(); } @@ -665,6 +716,7 @@ bool MeasureGUI_AnnotationDlg::execute() myGeomGUI->emitAnnotationsUpdated( QString( myShape->GetStudyEntry() ) ); erasePreview( true ); + myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 ); } else { @@ -686,46 +738,19 @@ bool MeasureGUI_AnnotationDlg::execute() SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() { SALOME_Prs* aPrs = myGeomGUI->GetAnnotationMgr()->CreatePresentation( myAnnotationProperties, myShape.get() ); - /* - Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation(); - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) ); - const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) ); - const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) ); - const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 ); - const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 ); - const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false ); - - const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ); - const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ); - const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize(); - - aPresentation->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) ); - aPresentation->SetTextHeight( aFontHeight ); - aPresentation->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) ); - aPresentation->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) ); - aPresentation->SetLineWidth( aLineWidth ); - aPresentation->SetLineStyle( static_cast( aLineStyle ) ); - aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False ); - aPresentation->SetScreenFixed( myAnnotationProperties.IsScreenFixed ); - aPresentation->SetDepthCulling( Standard_False ); - - TopoDS_Shape aShape; - GEOMBase::GetShape( myShape.get(), aShape ); - gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() ); - GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, myAnnotationProperties, aShapeLCS ); - - // add Prs to preview - SUIT_ViewWindow* vw = - SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - SOCC_Prs* aPrs = - dynamic_cast( ( ( SOCC_Viewer* ) ( vw->getViewManager()->getViewModel() ) )->CreatePrs( - 0 ) ); - - if ( aPrs ) - aPrs->AddObject( aPresentation ); - */ + // set preview style for the created presentation + AIS_ListOfInteractive aIObjects; + ((SOCC_Prs*)aPrs)->GetObjects( aIObjects ); + AIS_ListOfInteractive::Iterator aIOIt( aIObjects ); + for ( ; aIOIt.More(); aIOIt.Next() ) { + + Handle( GEOM_Annotation ) aPresentation = Handle( GEOM_Annotation )::DownCast( aIOIt.Value() ); + aPresentation->SetTextColor( Quantity_NOC_VIOLET ); + aPresentation->SetLineColor( Quantity_NOC_VIOLET ); + aPresentation->SetDepthCulling( Standard_False ); + } + return aPrs; } @@ -771,8 +796,14 @@ void MeasureGUI_AnnotationDlg::redisplayPreview() // function : getPickedPoint // purpose : finds picked point in active viewer on the selected shape //================================================================================= -bool MeasureGUI_AnnotationDlg::getPickedPoint( gp_Pnt& thePnt ) +bool MeasureGUI_AnnotationDlg::getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape ) { + if ( theShape.ShapeType() == TopAbs_VERTEX ) + { + thePnt = getAttachPoint( theShape ); + return true; + } + const SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView(); if ( !anActiveView ) return false; @@ -877,3 +908,35 @@ gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint( const TopoDS_Shape& theShape ) return gp_Pnt( 0.0, 0.0, 0.0 ); } + +//================================================================================= +// function : getDefaultPosition +// purpose : computes default position for the given attachment point +//================================================================================= +gp_Pnt MeasureGUI_AnnotationDlg::getDefaultPosition( const gp_Pnt& theAttach ) +{ + SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView(); + if ( !anActiveView ) { + + return myAnnotationProperties.IsScreenFixed ? gp::Origin() : theAttach; + } + + OCCViewer_ViewWindow* anOccView = qobject_cast( anActiveView ); + if ( !anOccView ) { + + return myAnnotationProperties.IsScreenFixed ? gp::Origin() : theAttach; + } + + OCCViewer_ViewPort3d* aViewPort = anOccView->getViewPort(); + + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) ); + + const Handle(V3d_View) aView3d = aViewPort->getView(); + + const Standard_Real aFontHeight =( aFont.pixelSize() != -1 ) ? aFont.pixelSize() : aFont.pointSize(); + + return GEOM_Annotation::GetDefaultPosition( myAnnotationProperties.IsScreenFixed, + theAttach, aFontHeight * 1.5, aView3d ); +} diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h index 9932520f1..4ca12bc0b 100755 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h @@ -94,12 +94,15 @@ private: void activateSelectionArgument( QPushButton* theSelectionButton ); void activateSelection(); TopAbs_ShapeEnum getShapeType() const; - bool getPickedPoint(gp_Pnt& thePnt); + + bool getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape ); gp_Pnt getAttachPoint( const TopoDS_Shape& theShape ); + gp_Pnt getDefaultPosition( const gp_Pnt& theAttach ); private: TopAbs_ShapeEnum mySelectionMode; GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties; + bool myIsPositionDefined; /// an index of edited annotation in the list shape annotations, -1 in create operation bool myIsCreation; GEOM::GeomObjPtr myShape; diff --git a/src/OBJECT/GEOM_Annotation.cxx b/src/OBJECT/GEOM_Annotation.cxx index 4f79e508e..f95f26ed6 100755 --- a/src/OBJECT/GEOM_Annotation.cxx +++ b/src/OBJECT/GEOM_Annotation.cxx @@ -60,7 +60,7 @@ IMPLEMENT_STANDARD_RTTIEXT( GEOM_Annotation, AIS_InteractiveObject ) GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject() { SetPosition( gp_Pnt( 0.0, 0.0, 0.0 ) ); - SetScreenFixed( Standard_False ); + SetIsScreenFixed( Standard_False ); SetAttachPoint( gp_Pnt( 0.0, 0.0, 0.0 ) ); SetDisplayMode( 0 ); SetZLayer( Graphic3d_ZLayerId_Top ); @@ -133,10 +133,10 @@ void GEOM_Annotation::SetPosition( const gp_Pnt& thePosition, const Standard_Boo } // ======================================================================= -// function : SetScreenFixed +// function : SetIsScreenFixed // purpose : // ======================================================================= -void GEOM_Annotation::SetScreenFixed( const Standard_Boolean theIsFixed ) +void GEOM_Annotation::SetIsScreenFixed( const Standard_Boolean theIsFixed ) { myIsScreenFixed = theIsFixed; @@ -156,6 +156,42 @@ void GEOM_Annotation::SetScreenFixed( const Standard_Boolean theIsFixed ) UpdateSelection(); } +// ======================================================================= +// function : Set2dPosition +// purpose : +// ======================================================================= +void GEOM_Annotation::Set2dPosition( const Handle(V3d_View)& theView ) +{ + if ( myIsScreenFixed ) + { + return; + } + + gp_Pnt aPosition2d = ConvertPosition2d( myPosition, myAttach, theView ); + + SetIsScreenFixed( Standard_True ); + + SetPosition( aPosition2d ); +} + +// ======================================================================= +// function : Set3dPosition +// purpose : +// ======================================================================= +void GEOM_Annotation::Set3dPosition( const Handle(V3d_View)& theView ) +{ + if ( !myIsScreenFixed ) + { + return; + } + + gp_Pnt aPosition3d = ConvertPosition3d( myPosition, myAttach, theView ); + + SetIsScreenFixed( Standard_False ); + + SetPosition( aPosition3d ); +} + // ======================================================================= // function : SetAttachPoint // purpose : @@ -298,6 +334,75 @@ void GEOM_Annotation::SetDepthCulling( const Standard_Boolean theToEnable ) } } +// ======================================================================= +// function : GetDefaultPosition +// purpose : +// ======================================================================= +gp_Pnt GEOM_Annotation::GetDefaultPosition( const Standard_Boolean theIsScreenFixed, + const gp_Pnt& theAttachPnt, + const Standard_Real theOffset, + const Handle(V3d_View)& theView ) +{ + Standard_Integer aWinWidth = 0; + Standard_Integer aWinHeight = 0; + theView->Window()->Size( aWinWidth, aWinHeight ); + + gp_Pnt aPositionProj = theView->Camera()->Project( theAttachPnt ); + aPositionProj.SetX( (aPositionProj.X() / 2.) * aWinWidth + theOffset ); + aPositionProj.SetY( (aPositionProj.Y() / 2.) * aWinHeight + theOffset ); + aPositionProj.SetZ( 0.0 ); + + if ( theIsScreenFixed ) + { + return aPositionProj; + } + + gp_Pnt aAttachProj = theView->Camera()->Project ( theAttachPnt ); + gp_Pnt aPosition3d = theView->Camera()->UnProject ( gp_Pnt ( aPositionProj.X() / aWinWidth * 2., + aPositionProj.Y() / aWinHeight * 2., + aAttachProj.Z() )); + + return aPosition3d; +} + +// ======================================================================= +// function : ConvertPosition2d +// purpose : +// ======================================================================= +gp_Pnt GEOM_Annotation::ConvertPosition2d( const gp_Pnt& thePosition, + const gp_Pnt& /*theAttach*/, + const Handle(V3d_View)& theView ) +{ + Standard_Integer aWinWidth = 0; + Standard_Integer aWinHeight = 0; + theView->Window()->Size( aWinWidth, aWinHeight ); + + gp_Pnt aPositionProj = theView->Camera()->Project( thePosition ); + aPositionProj.SetX( (aPositionProj.X() / 2.) * aWinWidth ); + aPositionProj.SetY( (aPositionProj.Y() / 2.) * aWinHeight ); + aPositionProj.SetZ( 0.0 ); + return aPositionProj; +} + +// ======================================================================= +// function : ConvertPosition3d +// purpose : +// ======================================================================= +gp_Pnt GEOM_Annotation::ConvertPosition3d( const gp_Pnt& thePosition, + const gp_Pnt& theAttach, + const Handle(V3d_View)& theView ) +{ + Standard_Integer aWinWidth = 0; + Standard_Integer aWinHeight = 0; + theView->Window()->Size( aWinWidth, aWinHeight ); + + gp_Pnt aAttachProj = theView->Camera()->Project( theAttach ); + gp_Pnt aPosition3d = theView->Camera()->UnProject( + gp_Pnt ( thePosition.X() / aWinWidth * 2., thePosition.Y() / aWinHeight * 2., aAttachProj.Z() ) ); + + return aPosition3d; +} + // ======================================================================= // function : Compute // purpose : @@ -384,7 +489,9 @@ void GEOM_Annotation::ComputeSelection( const Handle(SelectMgr_Selection)& theSe } const Handle(GEOM_AnnotationOwner) anEntityOwner = new GEOM_AnnotationOwner( this, 10 ); - const Handle(Select3D_SensitiveBox) aSensitive = new Select3D_SensitiveBox( anEntityOwner, aBox ); + const Handle(GEOM_AnnotationSensEntity) aSensitive = + new GEOM_AnnotationSensEntity( anEntityOwner, aBox, myIsDepthCulling ); + theSelection->Add( aSensitive ); } diff --git a/src/OBJECT/GEOM_Annotation.hxx b/src/OBJECT/GEOM_Annotation.hxx index c98b2fda6..62a8a4dde 100755 --- a/src/OBJECT/GEOM_Annotation.hxx +++ b/src/OBJECT/GEOM_Annotation.hxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -96,11 +97,22 @@ public: //! is fixed at predefined pixel location in the window coordinate space. Other mode //! is "3D screen aligned" positioning, when the label is aligned in plane of the //! screen, while its position is a 3D point defined in world's coordinate system. - Standard_EXPORT void SetScreenFixed( const Standard_Boolean theIsFixed ); + Standard_EXPORT void SetIsScreenFixed( const Standard_Boolean theIsFixed ); //! Retuns value of "screen fixed" positioning mode. Standard_Boolean GetIsScreenFixed() const { return myIsScreenFixed; } + //! Converts annotation position to screen fixed coordinates and + //! modifies its "2D screen fixed" flag correspondingly. + //! @param theView [in] the view to perform projection of coordinates. + Standard_EXPORT void Set2dPosition( const Handle(V3d_View)& theView ); + + //! Converts annotation position from screen fixed coordinates + //! to 3D position and modifies its "2D screen fixed" flag + //! correspondingly. + //! @param theView [in] the view to perform projection of coordinates. + Standard_EXPORT void Set3dPosition( const Handle(V3d_View)& theView ); + //! Sets attachment point of extension line. //! \param thePoint [in] the 3D cartesian point defined in world's coordinate system //! (a point on annotated geometry). @@ -183,11 +195,41 @@ public: //! lines and text become visible and a rendered with another drawing //! aspect. This mode should be explicitly used with setting top layer //! for the presentation. Otherwise the behavior is undefined. - Standard_EXPORT void SetDepthCulling (const Standard_Boolean theToEnable); + Standard_EXPORT void SetDepthCulling( const Standard_Boolean theToEnable ); //! Returns depth culling state. Standard_Boolean GetDepthCulling() const { return myIsDepthCulling; } +// Helper tools: +public: + + //! Returns default position for placing annotation when its attachment point + //! has been determined. + //! @param theIsScreenFixed [in] the state of annotation's "2D screen fixed" mode. + //! @param theAttachPnt [in] the attachment point. + //! @param theOffset [in] the offset value for placing the position relative to attachment.s + //! @param theView [in] the view for projecting coordinates. + Standard_EXPORT static gp_Pnt GetDefaultPosition( const Standard_Boolean theIsScreenFixed, + const gp_Pnt& theAttachPnt, + const Standard_Real theOffset, + const Handle(V3d_View)& theView ); + + //! Converts 3d position to 2d on screen point. + //! @param thePosition [in] the 3d position. + //! @param theAttach [in] the attachment point. + //! @param theView [in] the view for projecting coordinates. + Standard_EXPORT static gp_Pnt ConvertPosition2d( const gp_Pnt& thePosition, + const gp_Pnt& theAttach, + const Handle(V3d_View)& theView ); + + //! Converts 2d position to 3d point. + //! @param thePosition [in] the 2d position. + //! @param theAttach [in] the attachment point. + //! @param theView [in] the view for projecting coordinates. + Standard_EXPORT static gp_Pnt ConvertPosition3d( const gp_Pnt& thePosition, + const gp_Pnt& theAttach, + const Handle(V3d_View)& theView ); + // Interactive dragging: public: @@ -310,6 +352,36 @@ private: const Quantity_NameOfColor theColor, const Standard_Integer theMode = 0 ) Standard_OVERRIDE; }; + + //! Custom sensitive entity with implementing option to support selection + //! with depth culling flag turned off. + class GEOM_AnnotationSensEntity : public Select3D_SensitiveBox + { + public: + + //! Constructor. + GEOM_AnnotationSensEntity( const Handle(SelectMgr_EntityOwner)& theOwner, + const Bnd_Box& theBox, + const Standard_Boolean theIsDepthCulling ) + : Select3D_SensitiveBox( theOwner, theBox ), + myIsDepthCulling( theIsDepthCulling ) {} + + //! Checks whether the box overlaps current selecting volume. + virtual Standard_Boolean Matches( SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult ) Standard_OVERRIDE + { + const Standard_Boolean isMatches = Select3D_SensitiveBox::Matches( theMgr, thePickResult ); + if ( !myIsDepthCulling ) + { + thePickResult = SelectBasics_PickResult( -DBL_MAX, thePickResult.DistToGeomCenter() ); + } + return isMatches; + } + + private: + + Standard_Boolean myIsDepthCulling; + }; }; DEFINE_STANDARD_HANDLE( GEOM_Annotation, AIS_InteractiveObject )