From 52e50564f3f6998ad930925e0ce904f58af74dd3 Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 29 Jan 2014 14:00:16 +0000 Subject: [PATCH] Apply object transparency to the preview of the free faces. --- src/GEOMGUI/GEOM_Displayer.cxx | 41 ++++++++++++++++++++++-- src/GEOMGUI/GEOM_Displayer.h | 6 ++++ src/RepairGUI/RepairGUI_FreeFacesDlg.cxx | 26 +++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 252880f56..c205a8505 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -355,7 +355,7 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) myWidth = -1; myType = -1; - + myTransparency = -1.0; myToActivate = true; // This parameter is used for activisation/deactivisation of objects to be displayed @@ -702,7 +702,11 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() ); // set transparency - AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() ); + if( HasTransparency() ) { + AISShape->SetTransparency( GetTransparency() ); + } else { + AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() ); + } // set iso properties int uIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[0].toInt(); @@ -941,7 +945,11 @@ void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create ) actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() ); // set opacity - actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() ); + if( HasTransparency() ) { + actor->SetOpacity( 1.0 - GetTransparency() ); + } else { + actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() ); + } // set line width actor->SetWidth( HasWidth() ? @@ -1858,6 +1866,33 @@ void GEOM_Displayer::UnsetColor() myShadingColor = SalomeApp_Tools::color( col ); } +//================================================================= +/*! + * GEOM_Displayer::SetTransparency + * Set transparency for shape displaying. + */ +//================================================================= +void GEOM_Displayer::SetTransparency( const double transparency ) +{ + myTransparency = transparency; +} + +double GEOM_Displayer::GetTransparency() const +{ + return myTransparency; +} + +bool GEOM_Displayer::HasTransparency() const +{ + return myTransparency != -1.0; +} + +void GEOM_Displayer::UnsetTransparency() +{ + myTransparency = -1.0; +} + + //================================================================= /*! * GEOM_Displayer::SetTexture diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index c26eca72a..db91131fb 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -138,6 +138,11 @@ public: void UnsetColor(); int GetColor () const; bool HasColor () const; + + void SetTransparency ( const double ); + void UnsetTransparency(); + double GetTransparency () const; + bool HasTransparency () const; /* Set texture for shape displaying. */ void SetTexture ( const std::string& ); @@ -285,6 +290,7 @@ protected: bool myHasDisplayMode; Aspect_TypeOfMarker myTypeOfMarker; double myScaleOfMarker; + double myTransparency; private: SalomeApp_Application* myApp; diff --git a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx index 75501bb93..05ff25b10 100644 --- a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx +++ b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx @@ -30,14 +30,18 @@ #include #include #include +#include #include #include #include #include #include +#include +#include #include +#include #include #include @@ -325,11 +329,33 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects ) TopExp::MapShapes( aSelShape, anIndices); SALOME_Prs* aPrs = 0; + //Get object trancparency and set it to preview + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + double transparency = 1.0; + if( app ) { + SUIT_ViewWindow* window = app->desktop( )->activeWindow( ); + if( window && window->getViewManager() ) { + if ( app ) { + SalomeApp_Study* aStudy = dynamic_cast( app->activeStudy() ); + if( aStudy ) { + int aMgrId = window->getViewManager()->getGlobalId(); + CORBA::String_var aMainEntry = myObj->GetStudyEntry(); + QString anEntry = aMainEntry.in(); + QVariant v = aStudy->getObjectProperty( aMgrId , anEntry , GEOM::propertyName( GEOM::Transparency ) , transparency ); + if( v.canConvert( QVariant::Double ) ) { + transparency = v.toDouble(); + } + } + } + } + } + for ( int i = 0, n = aFaceLst->length(); i < n; i++ ) { aFace = anIndices.FindKey( aFaceLst[i] ); try { getDisplayer()->SetColor( Quantity_NOC_RED ); getDisplayer()->SetToActivate( false ); + getDisplayer()->SetTransparency( transparency ); aPrs = !aFace.IsNull() ? getDisplayer()->BuildPrs( aFace ) : 0; if ( aPrs ) displayPreview( aPrs, true ); -- 2.39.2