mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-15 04:10:33 +05:00
Create annotation interaction and "hidden line" mode
This commit is contained in:
parent
71725ed92f
commit
2e7629270a
@ -65,6 +65,8 @@ public:
|
||||
static SUIT_ViewWindow* getActiveView();
|
||||
|
||||
protected:
|
||||
typedef std::list<SALOME_Prs*> PrsList;
|
||||
|
||||
static GEOM::GEOM_Gen_ptr getGeomEngine();
|
||||
|
||||
void display ( const ObjectList&, const bool = true );
|
||||
@ -97,6 +99,8 @@ protected:
|
||||
const bool = true );
|
||||
void erasePreview ( const bool = true );
|
||||
|
||||
const PrsList& getPreview() const { return myPreview; }
|
||||
|
||||
void localSelection( const ObjectList&, const std::list<int> );
|
||||
void localSelection( const ObjectList&, const int );
|
||||
void localSelection( GEOM::GEOM_Object_ptr, const std::list<int> );
|
||||
@ -210,7 +214,6 @@ private:
|
||||
void clearShapeBuffer( GEOM::GEOM_Object_ptr );
|
||||
|
||||
private:
|
||||
typedef std::list<SALOME_Prs*> PrsList;
|
||||
|
||||
PrsList myPreview;
|
||||
GEOM_Displayer* myDisplayer;
|
||||
|
@ -29,9 +29,6 @@
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <SALOMEDSImpl_AttributeParameter.hxx>
|
||||
|
||||
// OCCT includes
|
||||
#include <gp_Ax3.hxx>
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -353,10 +350,19 @@ void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )
|
||||
{
|
||||
this->Append( theProps, gp_Ax3() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Append
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps, const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
this->SetNbAnnotation( aCount + 1 );
|
||||
this->SetProperties( aCount, theProps );
|
||||
this->SetProperties( aCount, theProps, theShapeLCS );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -365,13 +371,27 @@ void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps )
|
||||
{
|
||||
this->SetProperties( theIndex, theProps, gp_Ax3() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetProperties
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps,
|
||||
const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
gp_Trsf aToShapeLCS;
|
||||
aToShapeLCS.SetTransformation( gp_Ax3(), theShapeLCS );
|
||||
|
||||
this->SetName( theIndex, theProps.Name );
|
||||
this->SetText( theIndex, theProps.Text );
|
||||
this->SetIsVisible( theIndex, theProps.IsVisible );
|
||||
this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed );
|
||||
this->SetPosition( theIndex, theProps.Position );
|
||||
this->SetAttach( theIndex, theProps.Attach );
|
||||
this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
|
||||
this->SetAttach( theIndex, theProps.Attach.Transformed( aToShapeLCS ) );
|
||||
this->SetPosition( theIndex, (theProps.IsScreenFixed) ?
|
||||
theProps.Position : theProps.Position.Transformed( aToShapeLCS ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -396,19 +416,20 @@ void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& the
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const Properties& theProps,
|
||||
const gp_Ax3& theLCS )
|
||||
const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
gp_Trsf aToLCS;
|
||||
aToLCS.SetTransformation( theLCS, gp_Ax3() );
|
||||
gp_Trsf aFromShapeLCS;
|
||||
aFromShapeLCS.SetTransformation( theShapeLCS, gp_Ax3() );
|
||||
|
||||
TCollection_ExtendedString aText;
|
||||
for (int i = 0; i < (int)theProps.Text.length(); i++ )
|
||||
aText.Insert( i + 1, theProps.Text[ i ].unicode() );
|
||||
//
|
||||
|
||||
thePresentation->SetText( aText );
|
||||
thePresentation->SetScreenFixed( theProps.IsScreenFixed );
|
||||
thePresentation->SetPosition( theProps.Position );
|
||||
thePresentation->SetAttachPoint( theProps.Attach.Transformed( aToLCS ) );
|
||||
thePresentation->SetAttachPoint( theProps.Attach.Transformed( aFromShapeLCS ) );
|
||||
thePresentation->SetPosition( (theProps.IsScreenFixed) ?
|
||||
theProps.Position : theProps.Position.Transformed( aFromShapeLCS ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -417,9 +438,9 @@ void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)&
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const int theIndex,
|
||||
const gp_Ax3& theLCS )
|
||||
const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
Properties aProps;
|
||||
this->GetProperties( theIndex, aProps );
|
||||
this->SetupPresentation( thePresentation, aProps, theLCS );
|
||||
this->SetupPresentation( thePresentation, aProps, theShapeLCS );
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
// OCCT includes
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
@ -80,18 +81,18 @@ public:
|
||||
//! Setup parameters of the annotation presentation with the properties given.
|
||||
//! @param thePresentation [in] the presentation to setup.
|
||||
//! @param theProps [in] the set of properties.
|
||||
//! @param theLCS [in] the local coordinate system of the shape.
|
||||
//! @param theShapeLCS [in] the local coordinate system of the shape.
|
||||
GEOMGUI_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const Properties& theProps,
|
||||
const gp_Ax3& theLCS );
|
||||
const gp_Ax3& theShapeLCS );
|
||||
|
||||
//! Setup parameters of the annotation presentation with the properties of a definition.
|
||||
//! @param thePresentation [in] the presentation to setup.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theLCS [in] the local coordinate system of the shape.
|
||||
//! @param theShapeLCS [in] the local coordinate system of the shape.
|
||||
GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const int theIndex,
|
||||
const gp_Ax3& theLCS );
|
||||
const gp_Ax3& theShapeLCS );
|
||||
|
||||
public:
|
||||
|
||||
@ -168,11 +169,26 @@ public:
|
||||
//! Appends new annotation definition with the given properties.
|
||||
GEOMGUI_EXPORT void Append( const Properties& theProps );
|
||||
|
||||
//! Appends new annotation definition with the given properties and converts
|
||||
//! position and attachment points to the given shape's local frame of reference.
|
||||
//! @param theShapeLCS [in] the position of shape's local frame of reference with respect
|
||||
//! to the world frame of reference.
|
||||
GEOMGUI_EXPORT void Append( const Properties& theProps, const gp_Ax3& theShapeLCS );
|
||||
|
||||
//! Sets complete properties of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [in] the structure containing the properties.
|
||||
GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps );
|
||||
|
||||
//! Sets complete properties of an annotation definition with converting
|
||||
//! position and attachment points to the given shape's local frame
|
||||
//! of reference.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [in] the structure containing the properties.
|
||||
//! @param theShapeLCS [in] the position of shape's local frame of reference with respect
|
||||
//! to the world frame of reference.
|
||||
GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps, const gp_Ax3& theShapeLCS );
|
||||
|
||||
//! Returns complete properties of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [out] the structure containing the properties.
|
||||
|
@ -1444,6 +1444,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje
|
||||
aPresentation->SetLineWidth( aLineWidth );
|
||||
aPresentation->SetLineStyle( static_cast<Aspect_TypeOfLine>( aLineStyle ) );
|
||||
aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
|
||||
aPresentation->SetDepthCulling( Standard_True );
|
||||
|
||||
aListOfIO.Append( aPresentation );
|
||||
}
|
||||
|
92
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
Normal file → Executable file
92
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
Normal file → Executable file
@ -31,7 +31,6 @@
|
||||
#include <GEOMBase_Skeleton.h>
|
||||
#include <GEOM_Displayer.h>
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_Annotation.hxx>
|
||||
|
||||
#include <SOCC_Prs.h>
|
||||
#include <SOCC_ViewModel.h>
|
||||
@ -210,6 +209,9 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI,
|
||||
myInteractor = new MeasureGUI_AnnotationInteractor( theGeometryGUI, parent );
|
||||
myInteractor->Enable();
|
||||
|
||||
connect( myInteractor, SIGNAL( SignalInteractionFinished( Handle_GEOM_Annotation ) ),
|
||||
this, SLOT( onDragged( Handle_GEOM_Annotation ) ) );
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
@ -438,12 +440,19 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
||||
activateSelection();
|
||||
|
||||
if ( !aNullShape ) {
|
||||
if ( !getPickedPoint( anAttachPoint ) )
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
GEOMBase::GetShape( myShape.get(), aShape );
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
GEOMBase::GetShape( myShape.get(), aShape );
|
||||
|
||||
if ( !getPickedPoint( anAttachPoint ) ) {
|
||||
|
||||
anAttachPoint = getAttachPoint( aShape );
|
||||
}
|
||||
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
gp_Trsf aToShapeLCS;
|
||||
aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS );
|
||||
anAttachPoint.Transform( aToShapeLCS );
|
||||
}
|
||||
} else if ( myEditCurrentArgument == mySubShapeName ) {
|
||||
if ( !myShape->_is_nil() ) {
|
||||
@ -467,12 +476,20 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
||||
aSubShapeIndex = aMainMap.FindIndex( aSubShape );
|
||||
}
|
||||
|
||||
if ( !aSubShape.IsNull() )
|
||||
{
|
||||
if ( !getPickedPoint( anAttachPoint ) )
|
||||
{
|
||||
if ( !aSubShape.IsNull() ) {
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
GEOMBase::GetShape( myShape.get(), aShape );
|
||||
|
||||
if ( !getPickedPoint( anAttachPoint ) ) {
|
||||
|
||||
anAttachPoint = getAttachPoint( aSubShape );
|
||||
}
|
||||
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
gp_Trsf aToShapeLCS;
|
||||
aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS );
|
||||
anAttachPoint.Transform( aToShapeLCS );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -483,6 +500,18 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
||||
redisplayPreview();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : closeEvent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void MeasureGUI_AnnotationDlg::closeEvent( QCloseEvent* theEv )
|
||||
{
|
||||
if ( myInteractor ) {
|
||||
myInteractor->Disable();
|
||||
}
|
||||
GEOMBase_Skeleton::closeEvent( theEv );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : onTextChange
|
||||
//purpose : change annotation text
|
||||
@ -530,6 +559,42 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
|
||||
redisplayPreview();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : onDragged
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationDlg::onDragged( Handle_GEOM_Annotation theAnnotation )
|
||||
{
|
||||
const PrsList& aPreview = getPreview();
|
||||
PrsList::const_iterator anIt = aPreview.cbegin();
|
||||
for ( ; anIt != aPreview.cend(); ++anIt ) {
|
||||
|
||||
AIS_ListOfInteractive aIObjects;
|
||||
((SOCC_Prs*)(*anIt))->GetObjects( aIObjects );
|
||||
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
|
||||
for ( ; aIOIt.More(); aIOIt.Next() ) {
|
||||
|
||||
if ( aIOIt.Value() == theAnnotation ) {
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
GEOMBase::GetShape( myShape.get(), aShape );
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
gp_Trsf aToShapeLCS;
|
||||
aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS );
|
||||
|
||||
if ( !myAnnotationProperties.IsScreenFixed ) {
|
||||
myAnnotationProperties.Position = theAnnotation->GetPosition().Transformed( aToShapeLCS );
|
||||
}
|
||||
else {
|
||||
myAnnotationProperties.Position = theAnnotation->GetPosition();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define RETURN_WITH_MSG( a, b ) \
|
||||
if ( ( a ) ) { \
|
||||
theMessage += ( b ); \
|
||||
@ -638,7 +703,8 @@ SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
|
||||
aPresentation->SetLineStyle( static_cast<Aspect_TypeOfLine>( 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() );
|
||||
@ -771,9 +837,9 @@ gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint( const TopoDS_Shape& theShape )
|
||||
BRepBndLib::Add( aAttachShape, aBox );
|
||||
const gp_Pnt aMin = aBox.CornerMin();
|
||||
const gp_Pnt aMax = aBox.CornerMax();
|
||||
return gp_Pnt( aMin.X() + aMax.X() / 2.0,
|
||||
aMin.Y() + aMax.Y() / 2.0,
|
||||
aMin.Z() + aMax.Z() / 2.0 );
|
||||
return gp_Pnt( (aMin.X() + aMax.X()) / 2.0,
|
||||
(aMin.Y() + aMax.Y()) / 2.0,
|
||||
(aMin.Z() + aMax.Z()) / 2.0 );
|
||||
}
|
||||
else if ( aAttachShape.ShapeType() == TopAbs_FACE )
|
||||
{
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <GEOMBase_Skeleton.h>
|
||||
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <GEOM_Constants.h>
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
|
||||
@ -73,6 +74,8 @@ protected:
|
||||
void updateSubShapeEnableState();
|
||||
void redisplayPreview();
|
||||
|
||||
void closeEvent( QCloseEvent* theEv );
|
||||
|
||||
private slots:
|
||||
void ClickOnOk();
|
||||
bool ClickOnApply();
|
||||
@ -83,6 +86,8 @@ private slots:
|
||||
void onTypeChange();
|
||||
void onSubShapeTypeChange();
|
||||
|
||||
void onDragged( Handle_GEOM_Annotation theAnnotation );
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
|
10
src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx
Normal file → Executable file
10
src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx
Normal file → Executable file
@ -137,7 +137,11 @@ void MeasureGUI_AnnotationInteractor::Disable()
|
||||
myActiveViewPort = NULL;
|
||||
}
|
||||
|
||||
myActiveIO.Nullify();
|
||||
if ( !myActiveIO.IsNull() )
|
||||
{
|
||||
emit SignalInteractionFinished( myActiveIO );
|
||||
myActiveIO.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -245,6 +249,8 @@ bool MeasureGUI_AnnotationInteractor::eventFilter( QObject* theObject, QEvent* t
|
||||
myActiveIO = aAnnotation;
|
||||
myActiveIO->BeginDrag();
|
||||
|
||||
emit SignalInteractionStarted( myActiveIO );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -304,6 +310,8 @@ bool MeasureGUI_AnnotationInteractor::eventFilter( QObject* theObject, QEvent* t
|
||||
anAISContext->UpdateCurrentViewer();
|
||||
anAISContext->MoveTo( aMouseEv->pos().x(), aMouseEv->pos().y(), aView3d );
|
||||
|
||||
emit SignalInteractionFinished( myActiveIO );
|
||||
|
||||
mySelection.Clear();
|
||||
myActiveIO.Nullify();
|
||||
return (theEvent->type() == QEvent::MouseButtonRelease);
|
||||
|
8
src/MeasureGUI/MeasureGUI_AnnotationInteractor.h
Normal file → Executable file
8
src/MeasureGUI/MeasureGUI_AnnotationInteractor.h
Normal file → Executable file
@ -78,6 +78,14 @@ protected:
|
||||
//! Disconnect interactor's event handler from the view window given.
|
||||
void DisconnectView( SUIT_ViewWindow* theWindow );
|
||||
|
||||
signals:
|
||||
|
||||
//! Emitted when interactor begins modification of the interactive object.
|
||||
void SignalInteractionStarted( Handle_GEOM_Annotation theIO );
|
||||
|
||||
//! Emitted when interactor finished modification of the interactive object.
|
||||
void SignalInteractionFinished( Handle_GEOM_Annotation theIO );
|
||||
|
||||
protected slots:
|
||||
|
||||
//! Handler for signal coming from GUI layer.
|
||||
|
@ -67,6 +67,7 @@ GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject()
|
||||
SetAutoHide( Standard_True );
|
||||
SetHilightMode( HighlightAll );
|
||||
SetMutable( Standard_True );
|
||||
SetDepthCulling( Standard_True );
|
||||
|
||||
Handle(Prs3d_TextAspect) aTextAspect = new Prs3d_TextAspect();
|
||||
aTextAspect->SetHeight( 20.0 );
|
||||
@ -77,6 +78,10 @@ GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject()
|
||||
new Prs3d_LineAspect( Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0 );
|
||||
myDrawer->SetLineAspect( aLineAspect );
|
||||
|
||||
Handle(Prs3d_LineAspect) aHiddenLineAspect =
|
||||
new Prs3d_LineAspect( Quantity_NOC_WHITE, Aspect_TOL_DOT, 1.0 );
|
||||
myDrawer->SetHiddenLineAspect( aHiddenLineAspect );
|
||||
|
||||
Handle(Prs3d_PointAspect) aPointAspect =
|
||||
new Prs3d_PointAspect( Aspect_TOM_POINT, Quantity_NOC_WHITE, 4.0 );
|
||||
myDrawer->SetPointAspect( aPointAspect );
|
||||
@ -188,22 +193,66 @@ void GEOM_Annotation::SetTextColor( const Quantity_Color& theColor )
|
||||
void GEOM_Annotation::SetLineColor( const Quantity_Color& theColor )
|
||||
{
|
||||
myDrawer->LineAspect()->SetColor( theColor );
|
||||
myDrawer->HiddenLineAspect()->SetColor( theColor );
|
||||
myDrawer->PointAspect()->SetColor( theColor );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineWidth
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineWidth( const Standard_Real theLineWidth )
|
||||
{
|
||||
if ( GetLineWidth() != theLineWidth )
|
||||
{
|
||||
myDrawer->LineAspect()->SetWidth( theLineWidth );
|
||||
myDrawer->HiddenLineAspect()->SetWidth( theLineWidth );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineStyle( const Aspect_TypeOfLine theStyle )
|
||||
{
|
||||
if ( GetLineStyle() != theStyle )
|
||||
{
|
||||
myDrawer->LineAspect()->SetTypeOfLine( theStyle );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHiddenLineStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetHiddenLineStyle( const Aspect_TypeOfLine theStyle )
|
||||
{
|
||||
if ( GetHiddenLineStyle() != theStyle )
|
||||
{
|
||||
myDrawer->HiddenLineAspect()->SetTypeOfLine( theStyle );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetTextHeight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetTextHeight( const Standard_Real theHeight )
|
||||
{
|
||||
if (GetTextHeight() != theHeight)
|
||||
if ( GetTextHeight() != theHeight )
|
||||
{
|
||||
myDrawer->TextAspect()->SetHeight( theHeight );
|
||||
|
||||
SetToUpdate ();
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +262,7 @@ void GEOM_Annotation::SetTextHeight( const Standard_Real theHeight )
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetFontAspect( const Font_FontAspect theFontAspect )
|
||||
{
|
||||
if (GetFontAspect() != theFontAspect)
|
||||
if ( GetFontAspect() != theFontAspect )
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetTextFontAspect( theFontAspect );
|
||||
|
||||
@ -227,7 +276,7 @@ void GEOM_Annotation::SetFontAspect( const Font_FontAspect theFontAspect )
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetFont( const TCollection_AsciiString& theFont )
|
||||
{
|
||||
if (GetFont() != theFont)
|
||||
if ( GetFont() != theFont )
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetFont( theFont );
|
||||
|
||||
@ -236,28 +285,14 @@ void GEOM_Annotation::SetFont( const TCollection_AsciiString& theFont )
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineWidth
|
||||
// function : SetDepthCulling
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineWidth( const Standard_Real theLineWidth )
|
||||
void GEOM_Annotation::SetDepthCulling( const Standard_Boolean theToEnable )
|
||||
{
|
||||
if (GetLineWidth() != theLineWidth)
|
||||
if ( GetDepthCulling() != theToEnable )
|
||||
{
|
||||
myDrawer->LineAspect()->SetWidth( theLineWidth );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineStyle( const Aspect_TypeOfLine theStyle )
|
||||
{
|
||||
if (GetLineStyle() != theStyle)
|
||||
{
|
||||
myDrawer->LineAspect()->SetTypeOfLine( theStyle );
|
||||
myIsDepthCulling = theToEnable;
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
@ -289,10 +324,23 @@ void GEOM_Annotation::Compute( const Handle(PrsMgr_PresentationManager3d)& /*the
|
||||
OpenGl_Annotation* aAnnotationDraw =
|
||||
new OpenGl_Annotation( this, static_cast<Standard_Integer>( anAsp->Height() ), aGroup->GlStruct()->GlDriver() );
|
||||
|
||||
aGroup->AddElement( aAnnotationDraw );
|
||||
aAnnotationDraw->SetDepthMode( 0 );
|
||||
aGroup->SetGroupPrimitivesAspect( myDrawer->TextAspect()->Aspect() );
|
||||
aGroup->SetGroupPrimitivesAspect( myDrawer->LineAspect()->Aspect() );
|
||||
aGroup->SetGroupPrimitivesAspect( myDrawer->PointAspect()->Aspect() );
|
||||
aGroup->AddElement( aAnnotationDraw );
|
||||
|
||||
if ( !myIsDepthCulling )
|
||||
{
|
||||
OpenGl_Annotation* aAnnotationDraw =
|
||||
new OpenGl_Annotation( this, static_cast<Standard_Integer>( anAsp->Height() ), aGroup->GlStruct()->GlDriver() );
|
||||
|
||||
aAnnotationDraw->SetDepthMode( GL_GREATER );
|
||||
aGroup->SetPrimitivesAspect( myDrawer->TextAspect()->Aspect() );
|
||||
aGroup->SetPrimitivesAspect( myDrawer->HiddenLineAspect()->Aspect() );
|
||||
aGroup->SetPrimitivesAspect( myDrawer->PointAspect()->Aspect() );
|
||||
aGroup->AddElement( aAnnotationDraw );
|
||||
}
|
||||
|
||||
Bnd_Box aBox = TextBoundingBox();
|
||||
if ( myIsScreenFixed )
|
||||
@ -427,6 +475,7 @@ GEOM_Annotation::OpenGl_Annotation::OpenGl_Annotation( GEOM_Annotation* theAnnot
|
||||
const Standard_Integer theTextHeight,
|
||||
const OpenGl_GraphicDriver* theDriver )
|
||||
: OpenGl_Element(),
|
||||
myDepthMode( 0 ),
|
||||
myAISObject( theAnnotation ),
|
||||
myText( theAnnotation->myText.ToExtString() ),
|
||||
myTextLineY( 0.f ),
|
||||
@ -566,6 +615,14 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)&
|
||||
theWorkspace->ApplyAspectLine();
|
||||
}
|
||||
|
||||
GLint myOldDepthMode = 0;
|
||||
|
||||
if ( myDepthMode )
|
||||
{
|
||||
aContext->core11fwd->glGetIntegerv( GL_DEPTH_FUNC, &myOldDepthMode );
|
||||
aContext->core11fwd->glDepthFunc( myDepthMode );
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// render text label in current persistence matrix and underline
|
||||
// -------------------------------------------------------------
|
||||
@ -658,14 +715,19 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)&
|
||||
aContext->ModelWorldState.Pop();
|
||||
aContext->WorldViewState.Pop();
|
||||
|
||||
if (myAISObject->myIsScreenFixed)
|
||||
if ( myOldDepthMode )
|
||||
{
|
||||
aContext->core11fwd->glDepthFunc( myOldDepthMode );
|
||||
}
|
||||
|
||||
if ( myAISObject->myIsScreenFixed )
|
||||
{
|
||||
aContext->WorldViewState.Pop();
|
||||
}
|
||||
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
if (toHighlight != theWorkspace->ToHighlight())
|
||||
if ( toHighlight != theWorkspace->ToHighlight() )
|
||||
{
|
||||
theWorkspace->SetHighlight( toHighlight );
|
||||
}
|
||||
|
@ -126,6 +126,24 @@ public:
|
||||
//! Returns color for the connection line.
|
||||
Quantity_Color GetLineColor() const { return myDrawer->LineAspect()->Aspect()->Color(); }
|
||||
|
||||
//! Sets line width to be used for drawing the annotation's extension line and underline.
|
||||
Standard_EXPORT void SetLineWidth( const Standard_Real theLineWidth );
|
||||
|
||||
//! Returns line width for drawing the annotation's extension line and underline.
|
||||
Standard_Real GetLineWidth() const { return myDrawer->LineAspect()->Aspect()->Width(); }
|
||||
|
||||
//! Sets style of connection line.
|
||||
Standard_EXPORT void SetLineStyle( const Aspect_TypeOfLine theStyle );
|
||||
|
||||
//! Retusn style of connection line.
|
||||
Aspect_TypeOfLine GetLineStyle() const { return myDrawer->LineAspect()->Aspect()->Type(); }
|
||||
|
||||
//! Sets style of hidden connection line.
|
||||
Standard_EXPORT void SetHiddenLineStyle( const Aspect_TypeOfLine theStyle );
|
||||
|
||||
//! Retusn style of hidden connection line.
|
||||
Aspect_TypeOfLine GetHiddenLineStyle() const { return myDrawer->HiddenLineAspect()->Aspect()->Type(); }
|
||||
|
||||
//! Sets text height in pixels.
|
||||
Standard_EXPORT void SetTextHeight( const Standard_Real theHeight );
|
||||
|
||||
@ -144,18 +162,6 @@ public:
|
||||
//! Returns font used for drawing the label.
|
||||
TCollection_AsciiString GetFont() const { return myDrawer->TextAspect()->Aspect()->Font(); }
|
||||
|
||||
//! Sets line width to be used for drawing the annotation's extension line and underline.
|
||||
Standard_EXPORT void SetLineWidth( const Standard_Real theLineWidth );
|
||||
|
||||
//! Returns line width for drawing the annotation's extension line and underline.
|
||||
Standard_Real GetLineWidth() const { return myDrawer->LineAspect()->Aspect()->Width(); }
|
||||
|
||||
//! Sets style of connection line.
|
||||
Standard_EXPORT void SetLineStyle( const Aspect_TypeOfLine theStyle );
|
||||
|
||||
//! Retusn style of connection line.
|
||||
Aspect_TypeOfLine GetLineStyle() const { return myDrawer->LineAspect()->Aspect()->Type(); }
|
||||
|
||||
//! Sets annotation auto-hiding option.
|
||||
//! \param theIsEnable [in] the option flag. If passed true, the annotation
|
||||
//! will be automatically hidden in the view if the attachment point
|
||||
@ -172,6 +178,16 @@ public:
|
||||
//! Returns highlight mode
|
||||
HighlightMode GetHilightMode() const { return myHilightMode; }
|
||||
|
||||
//! Sets special flag that allows disabling depth testing when rendering
|
||||
//! the graphical presentation. When disable the hidden parts such as
|
||||
//! 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);
|
||||
|
||||
//! Returns depth culling state.
|
||||
Standard_Boolean GetDepthCulling() const { return myIsDepthCulling; }
|
||||
|
||||
// Interactive dragging:
|
||||
public:
|
||||
|
||||
@ -216,6 +232,7 @@ private:
|
||||
gp_Pnt myStartPosition; //!< Position before starting dragging operation.
|
||||
Standard_Boolean myIsScreenFixed; //!< Flag indicating whether "screen fixed" positioning mode is turned on or off.
|
||||
Standard_Boolean myIsAutoHide; //!< Flag indicating whether "auto-hiding" option is turned on.
|
||||
Standard_Boolean myIsDepthCulling; //!< Flag indiciating whether the "depth culling" is turned on.
|
||||
HighlightMode myHilightMode; //!< Highlight mode for presentation.
|
||||
TCollection_ExtendedString myText; //!< Text string of the label presentation.
|
||||
|
||||
@ -245,6 +262,8 @@ private:
|
||||
//! Renders the annotation graphical elements.
|
||||
virtual void Render( const Handle(OpenGl_Workspace)& theWorkspace ) const Standard_OVERRIDE;
|
||||
|
||||
void SetDepthMode( const int theMode ) { myDepthMode = theMode; }
|
||||
|
||||
private:
|
||||
|
||||
struct TextSize {
|
||||
@ -261,6 +280,7 @@ private:
|
||||
OpenGl_PrimitiveArray* myTextLineDraw; //!< Text underline draw element.
|
||||
OpenGl_PrimitiveArray* myExtLineDraw; //!< Extension line draw element.
|
||||
OpenGl_PrimitiveArray* myExtMarkerDraw; //!< Extension marker draw element.
|
||||
int myDepthMode; //!< Depth mode for drawing hidden line presentation.
|
||||
mutable float myTextLineY; //!< Text's underlines relative position.
|
||||
mutable TextSize myTextSize; //!< Text's size parameters
|
||||
mutable Graphic3d_Vec2 myTextUnderline; //!< Text's underline position.
|
||||
|
Loading…
Reference in New Issue
Block a user