Several bug fixes

This commit is contained in:
apl 2016-11-08 19:29:55 +03:00
parent 4e2afd4cf1
commit d61dfb05a3
8 changed files with 691 additions and 582 deletions

File diff suppressed because it is too large Load Diff

View File

@ -174,6 +174,12 @@ public:
//! to the world frame of reference.
GEOMGUI_EXPORT void Append( const Properties& theProps, const gp_Ax3& theShapeLCS );
//! Removes annotation definition by the given index.
//! This methods performs iterative reindexing of elements starting
//! from the given index, so sequential removal should be performed
//! from the last element, or avoided at all.
GEOMGUI_EXPORT void Remove( const Standard_Integer theIndex );
//! Sets complete properties of an annotation definition.
//! @param theIndex [in] the index of the annotation definition.
//! @param theProps [in] the structure containing the properties.

View File

@ -39,6 +39,7 @@
#include <SOCC_Prs.h>
#include <SOCC_ViewModel.h>
#include <SOCC_ViewWindow.h>
#include <Quantity_Color.hxx>
#include <TCollection_AsciiString.hxx>
@ -58,7 +59,7 @@ GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplicat
QString GEOMGUI_AnnotationMgr::GetEntrySeparator()
{
return "_annotation:";
return "_annotation:";
}
//================================================================
@ -78,48 +79,14 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
aPresentation->SetOwner( anIO );
}
//aPresentation->SetOwner( new SALOME_InteractiveObject( getEntry( theObject ).c_str(), "GEOM", getName( theObject ).c_str() ) );
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<Aspect_TypeOfLine>( aLineStyle ) );
aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
aPresentation->SetIsScreenFixed( theProperty.IsScreenFixed );
setDisplayProperties( aPresentation, theView, getEntry( 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 );
SALOME_View* aView = viewOrActiveView( theView );
if ( aView ) {
// set top-level flag correspondingly
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
int aMgrId = dynamic_cast< SUIT_ViewModel* >( aView )->getViewManager()->getGlobalId();
QVariant aVal = aStudy->getObjectProperty( aMgrId, QString( getEntry( theObject ).c_str() ), GEOM::propertyName( GEOM::TopLevel ), QVariant() );
bool isBringToFront = aVal.isValid() ? aVal.toBool() : false;
if( isBringToFront ) {
aPresentation->SetZLayer( Graphic3d_ZLayerId_Topmost );
}
}
// add Prs to preview
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs =
@ -156,13 +123,13 @@ bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theI
//=======================================================================
void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex, SALOME_View* theView )
{
if ( IsDisplayed( theEntry, theIndex ) )
return;
SALOME_View* aView = viewOrActiveView( theView );
if ( !aView )
return;
if ( IsDisplayed( theEntry, theIndex, aView ) )
return;
GEOMGUI_AnnotationAttrs::Properties aProperty;
GEOM::GEOM_Object_ptr anObject;
getObject( theEntry, theIndex, anObject, aProperty );
@ -276,6 +243,43 @@ void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SA
myVisualized[aView] = anEntryToAnnotation;
}
//=======================================================================
// function : GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations
// purpose :
//=======================================================================
void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, SALOME_View* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
if ( !myVisualized.contains( aView ) )
return;
EntryToAnnotations& anEntryToAnnotation = myVisualized[aView];
if ( !anEntryToAnnotation.contains( theEntry ) )
return;
AnnotationToPrs& anAnnotationToPrs = anEntryToAnnotation[theEntry];
AnnotationToPrs::iterator anIt = anAnnotationToPrs.begin();
for (; anIt != anAnnotationToPrs.end(); ++anIt ) {
SOCC_Prs* aPrs =
dynamic_cast<SOCC_Prs*> (anIt.value());
AIS_ListOfInteractive aIObjects;
aPrs->GetObjects( aIObjects );
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
for ( ; aIOIt.More(); aIOIt.Next() ) {
Handle(GEOM_Annotation) aPresentation =
Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
if ( aPresentation.IsNull() )
continue;
setDisplayProperties( aPresentation, aView, theEntry );
}
}
getDisplayer()->UpdateViewer();
}
Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( const QString& theEntry,
const int theIndex,
SALOME_View* theView ) const
@ -406,14 +410,17 @@ GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const
SALOME_View* GEOMGUI_AnnotationMgr::viewOrActiveView(SALOME_View* theView) const
{
SALOME_View* aView = theView;
if ( !aView ) {
if ( theView ) {
return dynamic_cast<SOCC_Viewer*>( theView );
}
else {
SalomeApp_Application* anApp = getApplication();
SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
if (anActiveWindow)
aView = dynamic_cast<SALOME_View*>(anActiveWindow->getViewManager()->getViewModel());
if ( anActiveWindow ) {
return dynamic_cast<SOCC_Viewer*>( anActiveWindow->getViewManager()->getViewModel() );
}
}
return aView;
return NULL;
}
void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,
@ -503,3 +510,50 @@ std::string GEOMGUI_AnnotationMgr::getName( const GEOM::GEOM_Object_ptr theObjec
}
return std::string();
}
//=======================================================================
// function : GEOMGUI_AnnotationMgr::setDisplayProperties
// purpose :
//=======================================================================
void GEOMGUI_AnnotationMgr::setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
SALOME_View* theView,
const QString& theEntry )
{
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();
thePrs->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) );
thePrs->SetTextHeight( aFontHeight );
thePrs->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) );
thePrs->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) );
thePrs->SetLineWidth( aLineWidth );
thePrs->SetLineStyle( static_cast<Aspect_TypeOfLine>( aLineStyle ) );
thePrs->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
SALOME_View* aView = viewOrActiveView( theView );
if ( aView && !theEntry.isEmpty() ) {
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
int aMgrId = dynamic_cast< SUIT_ViewModel* >( aView )->getViewManager()->getGlobalId();
QVariant aVal = aStudy->getObjectProperty( aMgrId, theEntry, GEOM::propertyName( GEOM::TopLevel ), QVariant() );
bool isBringToFront = aVal.isValid() ? aVal.toBool() : false;
if( isBringToFront ) {
thePrs->SetZLayer( Graphic3d_ZLayerId_Topmost );
}
else {
thePrs->SetDefaultZLayer();
}
}
else {
thePrs->SetDefaultZLayer();
}
}

View File

@ -32,6 +32,7 @@
#include <SALOME_InteractiveObject.hxx>
class SalomeApp_Application;
class GEOM_Annotation;
class GEOM_Displayer;
/*!
@ -61,6 +62,7 @@ public:
void DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void UpdateVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void RemoveView( SALOME_View* theView);
@ -92,6 +94,10 @@ protected:
std::string getName( const GEOM::GEOM_Object_ptr theObject );
void setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
SALOME_View* theView = 0,
const QString& theEntry = QString() );
private:
SalomeApp_Application* myApplication;

View File

@ -702,10 +702,12 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule ) {
if ( !theViewFrame->isVisible( theIO ) )
if ( !theViewFrame->isVisible( theIO ) ) {
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), theViewFrame);
else
}
else {
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), theViewFrame);
}
}
}
@ -2073,13 +2075,17 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
{
UpdateColorScale(false,false);
if ( !myIsRedisplayed ) {
// visualize annotations for displayed presentation
SUIT_Session* session = SUIT_Session::session();
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule )
// visualize annotations for displayed presentation
SUIT_Session* session = SUIT_Session::session();
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule ) {
if ( !myIsRedisplayed ) {
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), v);
} else {
aModule->GetAnnotationMgr()->UpdateVisibleAnnotations(QString(p->GetEntry()), v);
}
}
}

View File

@ -249,7 +249,7 @@ void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
SUIT_OverrideCursor wc;
for ( int anI = 0; anI <= aCount; ++anI ) {
for ( int anI = 0; anI < aCount; ++anI ) {
if ( !theIsVisible ) {
getGeometryGUI()->GetAnnotationMgr()->Erase( aEntry, anI );

View File

@ -63,7 +63,7 @@ GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject()
SetIsScreenFixed( Standard_False );
SetAttachPoint( gp_Pnt( 0.0, 0.0, 0.0 ) );
SetDisplayMode( 0 );
SetZLayer( Graphic3d_ZLayerId_Top );
SetZLayer( Graphic3d_ZLayerId_Default );
SetAutoHide( Standard_True );
SetHilightMode( HighlightAll );
SetMutable( Standard_True );
@ -149,7 +149,7 @@ void GEOM_Annotation::SetIsScreenFixed( const Standard_Boolean theIsFixed )
AIS_InteractiveObject::SetTransformPersistence( Graphic3d_TMF_2d );
}
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Top );
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
SetToUpdate();
@ -334,6 +334,17 @@ void GEOM_Annotation::SetDepthCulling( const Standard_Boolean theToEnable )
}
}
// =======================================================================
// function : SetDefaultZLayer
// purpose :
// =======================================================================
void GEOM_Annotation::SetDefaultZLayer()
{
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
SetToUpdate();
}
// =======================================================================
// function : GetDefaultPosition
// purpose :

View File

@ -203,6 +203,9 @@ public:
// Helper tools:
public:
//! Restores default z-layer for this presentation.
Standard_EXPORT void SetDefaultZLayer();
//! 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.