-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
-#include <Basics_OCCTVersion.hxx>
-
#include <SalomeApp_Study.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <AIS_AngleDimension.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <Aspect_PolygonOffsetMode.hxx>
-#if OCC_VERSION_MAJOR < 7
- #include <Aspect_ColorScale.hxx>
-#endif
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <StdSelect_TypeOfEdge.hxx>
#include <TopoDS.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Map.hxx>
+#include <Graphic3d_Texture2Dmanual.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <vtkActorCollection.h>
#include <vtkProperty.h>
+#include <Basics_OCCTVersion.hxx>
// CORBA Headers
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
if ( aPixmap.IsNull() ) {
QPixmap px(":images/default_texture.png");
if ( !px.isNull() )
- aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
+ aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
}
return aPixmap;
}
if ( aAISShape.IsNull() )
continue;
-#ifdef USE_TEXTURED_SHAPE
- const Handle(Image_PixMap)& aPixmap = aAISShape->TexturePixMap();
+ const Handle(Graphic3d_TextureMap)& aTexture = aAISShape->Attributes()->ShadingAspect()->Aspect()->TextureMap();
+ if ( aTexture.IsNull() )
+ continue;
+
+ const Handle(Image_PixMap)& aPixmap = aTexture->GetImage();
if ( aPixmap.IsNull() )
continue;
aPixmapUsersMap.UnBind( aPixmap );
aPixmapCacheMap.remove( aPixmapCacheMap.key( aPixmap ) );
}
-#endif
}
}
* Constructor
*/
//=================================================================
-GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
-: myIsRedisplayed( false )
+GEOM_Displayer::GEOM_Displayer()
+ : myUpdateColorScale(true), myIsRedisplayed( false )
{
- if( st )
- myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
- else
- myApp = 0;
+ SUIT_Session* session = SUIT_Session::session();
+ myApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
/* Shading Color */
- SUIT_Session* session = SUIT_Session::session();
SUIT_ResourceMgr* resMgr = session->resourceMgr();
QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
myViewFrame = 0;
-#if OCC_VERSION_MAJOR >= 7
- myColorScale = new AIS_ColorScale;
- myColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
- myColorScale->SetTransformPersistence (
- Graphic3d_TransformPers::FromDeprecatedParams(Graphic3d_TMF_2d, gp_Pnt (-1,-1,0)));
-#endif
-
myFieldDataType = GEOM::FDT_Double;
myFieldDimension = 0;
myFieldStepRangeMin = 0;
QString entry = p->GetEntry();
if ( !entry.isEmpty() ) {
if ( vId != -1 )
- aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on );
+ aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on );
setVisibilityState( entry, on ? Qtx::ShownState : Qtx::HiddenState );
}
}
else if ( !myName.empty() ) {
// workaround to allow selection of temporary objects
static int tempId = 0;
- anIO = new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
+ anIO = new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toUtf8().data(), "GEOM", myName.c_str() );
AISShape->setIO( anIO );
AISShape->SetOwner( anIO );
}
int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
// get presentation properties
- PropMap propMap = getObjectProperties( study, entry, myViewFrame );
+ PropMap propMap = getObjectProperties( entry, myViewFrame );
// Temporary staff: vertex must be infinite for correct visualization
AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
// - free boundaries color
- anAspect = AISShape->Attributes()->FreeBoundaryAspect();
- anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
+ Handle(Prs3d_LineAspect) aFreeBoundaryAspect =
+ new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ *aFreeBoundaryAspect->Aspect() = *AISShape->Attributes()->FreeBoundaryAspect()->Aspect();
+ aFreeBoundaryAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>() ) );
- AISShape->Attributes()->SetFreeBoundaryAspect( anAspect );
+ AISShape->Attributes()->SetFreeBoundaryAspect( aFreeBoundaryAspect );
// - standalone edges color
anAspect = AISShape->Attributes()->WireAspect();
AISShape->SetLabelColor( qColorFromResources( "label_color", QColor( 255, 255, 255 ) ) );
// set display mode
- AISShape->SetDisplayMode( HasDisplayMode() ?
- // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
- GetDisplayMode() :
- // display mode from properties
- propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt() );
+ int displayMode = HasDisplayMode() ?
+ // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
+ GetDisplayMode() :
+ // display mode from properties
+ propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt();
+ AISShape->SetDisplayMode( displayMode );
// - face boundaries color and line width
anAspect = AISShape->Attributes()->FaceBoundaryAspect();
aImagePath = GetTexture().c_str();
if ( ! entry.isEmpty() ) {
// check that study is active
- SalomeApp_Study* study = getActiveStudy();
+ SalomeApp_Study* study = getStudy();
if ( study ) {
// Store the texture in object properties for next displays
study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::Texture ), QString( GetTexture().c_str() ) );
study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::DisplayMode ), 3 );
- // Update propeties map
- propMap = getObjectProperties( study, entry, myViewFrame );
+ // Update properties map
+ propMap = getObjectProperties( entry, myViewFrame );
}
}
}
aImagePath = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
}
-#ifdef USE_TEXTURED_SHAPE
Handle(Image_PixMap) aPixmap;
if ( !aImagePath.isEmpty() )
aPixmap = cacheTextureFor( aImagePath, AISShape );
// apply image to shape
if ( !aPixmap.IsNull() ) {
- AISShape->SetTexturePixMap( aPixmap );
- AISShape->SetTextureMapOn();
- AISShape->DisableTextureModulate();
+ AISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMap( new Graphic3d_Texture2Dmanual( aPixmap ) );
}
- else {
- AISShape->SetTextureMapOff();
- }
-#endif
+ if ( displayMode == GEOM_AISShape::TexturedShape )
+ AISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
+ else
+ AISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOff();
// set line width
AISShape->SetWidth( HasWidth() ?
int textureId = aList[0].toInt();
Standard_Integer aWidth, aHeight;
Handle(TColStd_HArray1OfByte) aTexture =
- GeometryGUI::getTexture( study, textureId, aWidth, aHeight );
+ GeometryGUI::getTexture( textureId, aWidth, aHeight );
if ( !aTexture.IsNull() ) {
Handle(Prs3d_PointAspect) aTextureAspect =
new Prs3d_PointAspect( HasColor() ?
- // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
- (Quantity_NameOfColor)GetColor() :
- // color from properties
+ // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
+ (Quantity_NameOfColor)GetColor() :
+ // color from properties
SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
aWidth, aHeight,
aTexture );
else if ( !myName.empty() ) {
// workaround to allow selection of temporary objects
static int tempId = 0;
- anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
+ anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toUtf8().data(), "GEOM", myName.c_str() );
actor->setIO( anIO );
}
int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
// get presentation properties
- PropMap propMap = getObjectProperties( study, entry, myViewFrame );
+ PropMap propMap = getObjectProperties( entry, myViewFrame );
QColor c;
/////////////////////////////////////////////////////////////////////////
}
else
{
- aRecords.LoadFromAttribute( getStudy(), theIO->getEntry() );
+ aRecords.LoadFromAttribute( theIO->getEntry() );
}
// create up-to-date dimension presentations
//=================================================================
/*!
* GEOM_Displayer::Update
- * Update OCC presentaion
+ * Update OCC presentation
* [ Reimplemented from SALOME_Displayer ]
*/
//=================================================================
//=================================================================
/*!
* GEOM_Displayer::Update
- * Update VTK presentaion
+ * Update VTK presentation
* [ Reimplemented from SALOME_Displayer ]
*/
//=================================================================
//=================================================================
/*!
* GEOM_Displayer::BuildPrs
- * Build presentation accordint to the current viewer type
+ * Build presentation according to the current viewer type
*/
//=================================================================
SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
//=================================================================
/*!
* GEOM_Displayer::BuildPrs
- * Build presentation accordint to the current viewer type
+ * Build presentation according to the current viewer type
*/
//=================================================================
SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
if ( prs )
{
Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
- theIO->setEntry( entry.toLatin1().constData() );
+ theIO->setEntry( entry.toUtf8().constData() );
if ( !theIO.IsNull() )
{
// set interactive object
setIO( theIO );
// Find SOBject (because shape should be published previously)
- SUIT_Session* session = SUIT_Session::session();
- SUIT_Application* app = session->activeApplication();
- if ( app )
+ if ( getStudy() )
{
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( study )
+ _PTR(SObject) SO ( getStudy()->studyDS()->FindObjectID( theIO->getEntry() ) );
+ if ( SO )
{
- _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
- if ( SO )
+ // get CORBA reference to data object
+ CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
+ if ( !CORBA::is_nil( object ) )
{
- // get CORBA reference to data object
- CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
- if ( !CORBA::is_nil( object ) )
+ // downcast to GEOM base object
+ GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object );
+ if ( !GeomBaseObject->_is_nil() )
{
- // downcast to GEOM base object
- GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object );
- if ( !GeomBaseObject->_is_nil() )
- {
- myType = GeomBaseObject->GetType();
+ myType = GeomBaseObject->GetType();
- // downcast to GEOM object
- GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
- if ( myType == GEOM_FIELD_STEP )
+ // downcast to GEOM object
+ GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
+ if ( myType == GEOM_FIELD_STEP )
+ {
+ // get the GEOM object from the field's shape
+ GEOM::GEOM_FieldStep_var GeomFieldStep = GEOM::GEOM_FieldStep::_narrow( GeomBaseObject );
+ if ( !GeomFieldStep->_is_nil() )
{
- // get the GEOM object from the field's shape
- GEOM::GEOM_FieldStep_var GeomFieldStep = GEOM::GEOM_FieldStep::_narrow( GeomBaseObject );
- if ( !GeomFieldStep->_is_nil() )
- {
- GEOM::GEOM_Field_var GeomField = GeomFieldStep->GetField();
- if ( !GeomField->_is_nil() )
- GeomObject = GeomField->GetShape();
- }
-
- // read the field step information
- readFieldStepInfo( GeomFieldStep );
+ GEOM::GEOM_Field_var GeomField = GeomFieldStep->GetField();
+ if ( !GeomField->_is_nil() )
+ GeomObject = GeomField->GetShape();
}
- if ( !GeomObject->_is_nil() )
- {
- theIO->setName( GeomObject->GetName() );
+ // read the field step information
+ readFieldStepInfo( GeomFieldStep );
+ }
+
+ if ( !GeomObject->_is_nil() )
+ {
+ CORBA::String_var name = GeomObject->GetName();
+ theIO->setName( name );
// finally set shape
setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
- }
}
}
}
if (prs)
{
Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
- theIO->setEntry(entry.toLatin1().constData());
+ theIO->setEntry(entry.toUtf8().constData());
if (!theIO.IsNull())
{
// set interactive object
if ( theModes.Contains( GEOM_ALLOBJECTS ) )
return;
- SUIT_SelectionFilter* aFilter;
- if ( theModes.Extent() == 1 )
- {
- int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
-
- if ( aMode == GEOM_COMPOUNDFILTER )
- aFilter = getComplexFilter( theSubShapes );
- else
- aFilter = getFilter( aMode );
- }
- else if ( theModes.Extent() > 1 )
+ SUIT_SelectionFilter* aFilter = NULL;
+ if ( theModes.Extent() > 0 )
{
TColStd_MapOfInteger aTopAbsModes;
TColStd_MapIteratorOfMapOfInteger anIter( theModes );
int aMode = anIter.Key();
if ( aMode == GEOM_COMPOUNDFILTER )
aFilter = getComplexFilter( theSubShapes );
+ if ( aMode == GEOM_COMPOUND ) {
+ // always add COMPSOLID filter together with COMPOUND filter
+ aFilter = new GEOM_TypeFilter( getStudy(), TopAbs_COMPSOLID, true );
+ aListOfFilters.append( aFilter );
+
+ // add the COMPOUND filter itself
+ aFilter = getFilter( aMode );
+ }
else
aFilter = getFilter( aMode );
aListOfFilters.append( aFilter );
}
- aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
+ if (aListOfFilters.size() > 1)
+ aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
}
else
return;
Handle(AIS_InteractiveContext) ic = vf->getAISContext();
if ( !ic.IsNull() )
{
+#if OCC_VERSION_LARGE <= 0x07030000
if ( ic->HasOpenedContext() )
- ic->CloseAllContexts();
+ ic->CloseAllContexts(Standard_True);
+#else
+ ic->Deactivate();
+ ic->Activate( 0 );
+#endif
}
}
}
void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
{
- UpdateColorScale(false,false);
+ UpdateColorScale();
// visualize annotations for displayed presentation
SUIT_Session* session = SUIT_Session::session();
void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
{
LightApp_Displayer::AfterErase( v, p );
- UpdateColorScale(false,false);
+ UpdateColorScale();
if ( !myIsRedisplayed ) {
// hide annotations for erased presentation
bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
{
- _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
+ _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toUtf8() );
GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects
GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps
GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component
return aSColor;
}
-PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study,
- const QString& entry,
+PropMap GEOM_Displayer::getObjectProperties( const QString& entry,
SALOME_View* view )
{
// get default properties for the explicitly specified default view type
PropMap propMap = GEOM_Displayer::getDefaultPropertyMap();
- if ( study && view ) {
+ if ( getStudy() && view ) {
SUIT_ViewModel* viewModel = dynamic_cast<SUIT_ViewModel*>( view );
SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0;
int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1;
if ( viewModel && viewId != -1 ) {
// get properties from the study
- PropMap storedMap = study->getObjectProperties( viewId, entry );
+ PropMap storedMap = getStudy()->getObjectProperties( viewId, entry );
// overwrite default properties from stored ones (that are specified)
for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) {
if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) )
if ( !entry.isEmpty() ) {
// get CORBA reference to geom object
- _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) );
+ _PTR(SObject) SO( getStudy()->studyDS()->FindObjectID( entry.toStdString() ) );
if ( SO ) {
CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO );
if ( !CORBA::is_nil( object ) ) {
// - transparency (opacity = 1-transparency)
propMap.insert( GEOM::propertyName( GEOM::Transparency ),
- resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. );
+ resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. );
// - display mode (take default value from preferences)
propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
- const bool eraseOnlyChildren) {
- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- if ( !app )
- return;
-
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( !appStudy )
- return;
-
- LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
+ const bool eraseOnlyChildren)
+{
+ LightApp_DataObject* parent = getStudy()->findObjectByEntry(theIO->getEntry());
if( !parent)
return;
// Erase from all views
QList<SALOME_View*> views;
SALOME_View* view;
- ViewManagerList vmans = app->viewManagers();
+ ViewManagerList vmans = myApp->viewManagers();
SUIT_ViewManager* vman;
foreach ( vman, vmans ) {
SUIT_ViewModel* vmod = vman->getViewModel();
if(l_obj)
foreach ( view, views ) {
Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
+ new SALOME_InteractiveObject(qUtf8Printable(l_obj->entry()), "GEOM", "");
Erase(anIO, false, false, view);
}
}
{
QColor aQColor;
Quantity_Color aColor;
- if( FindColor( aVariant.toDouble(), theFieldStepRangeMin, theFieldStepRangeMax, anIsBoolean ? 2 : aNbIntervals, aColor ) )
+ if( AIS_ColorScale::FindColor( aVariant.toDouble(), theFieldStepRangeMin, theFieldStepRangeMax, anIsBoolean ? 2 : aNbIntervals, aColor ) )
aQColor = QColor::fromRgbF( aColor.Red(), aColor.Green(), aColor.Blue() );
aResultList << aQColor;
}
return aResultList;
}
-// Note: the method is copied from AIS_ColorScale class
-Standard_Integer GEOM_Displayer::HueFromValue( const Standard_Integer aValue,
- const Standard_Integer aMin,
- const Standard_Integer aMax )
-{
- Standard_Integer minLimit( 0 ), maxLimit( 230 );
-
- Standard_Integer aHue = maxLimit;
- if ( aMin != aMax )
- aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( aValue - aMin ) / ( aMax - aMin ) );
-
- aHue = Min( Max( minLimit, aHue ), maxLimit );
-
- return aHue;
-}
-
-// Note: the method is copied from AIS_ColorScale class
-Standard_Boolean GEOM_Displayer::FindColor( const Standard_Real aValue,
- const Standard_Real aMin,
- const Standard_Real aMax,
- const Standard_Integer ColorsCount,
- Quantity_Color& aColor )
-{
- if( aValue<aMin || aValue>aMax || aMax<aMin )
- return Standard_False;
-
- else
- {
- Standard_Real IntervNumber = 0;
- if( aValue<aMin )
- IntervNumber = 0;
- else if( aValue>aMax )
- IntervNumber = ColorsCount-1;
- else if( Abs( aMax-aMin ) > Precision::Approximation() )
- IntervNumber = Floor( Standard_Real( ColorsCount ) * ( aValue - aMin ) / ( aMax - aMin ) ); // 'Ceiling' replaced with 'Floor'
-
- Standard_Integer Interv = Standard_Integer( IntervNumber );
-
- aColor = Quantity_Color( HueFromValue( Interv, 0, ColorsCount - 1 ), 1.0, 1.0, Quantity_TOC_HLS );
-
- return Standard_True;
- }
-}
-
-void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, const bool updateViewer )
+void GEOM_Displayer::UpdateColorScale()
{
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
- if( !aStudy )
- return;
-
- SOCC_Viewer* aViewModel = dynamic_cast<SOCC_Viewer*>( GetActiveView() );
- if( !aViewModel )
- return;
-
-#if OCC_VERSION_MAJOR < 7
- Handle(V3d_Viewer) aViewer = aViewModel->getViewer3d();
- if( aViewer.IsNull() )
+ if ( !myUpdateColorScale )
return;
- aViewer->InitActiveViews();
- if( !aViewer->MoreActiveViews() )
- return;
-
- Handle(V3d_View) aView = aViewer->ActiveView();
- if( aView.IsNull() )
- return;
-#endif
+ SUIT_Session* session = SUIT_Session::session();
+ SUIT_Application* app = session->activeApplication();
+ if ( !app ) return;
- Standard_Boolean anIsDisplayColorScale = Standard_False;
- TCollection_AsciiString aColorScaleTitle;
- Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
- Standard_Boolean anIsBoolean = Standard_False;
+ Handle(SALOME_InteractiveObject) io = myApp->selectionMgr()->soleSelectedObject();
- SALOME_ListIO aSelectedObjects;
- myApp->selectionMgr()->selectedObjects( aSelectedObjects );
- if( aSelectedObjects.Extent() == 1 )
+ QList<SUIT_ViewWindow*> windows = app->desktop()->windows();
+ foreach( SUIT_ViewWindow* window, windows )
{
- Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
- if( !anIO.IsNull() )
+ OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>( window );
+ if ( !occWindow ) continue;
+ if ( !occWindow->getViewManager() ) continue;
+ if ( !window->getViewManager() ) continue;
+ if ( !window->getViewManager()->getViewModel() ) continue;
+ SOCC_Viewer* view = dynamic_cast<SOCC_Viewer*>( window->getViewManager()->getViewModel() );
+ if ( !view ) continue;
+ Handle(V3d_Viewer) viewer = view->getViewer3d();
+ if ( !io.IsNull() && view->isVisible( io ) )
{
- SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
- if( aPrs )
+ bool visible = false;
+ SOCC_Prs* prs = dynamic_cast<SOCC_Prs*>( view->CreatePrs( io->getEntry() ) );
+ if ( prs )
{
- AIS_ListOfInteractive aList;
- aPrs->GetObjects( aList );
- AIS_ListIteratorOfListOfInteractive anIter( aList );
- for( ; anIter.More(); anIter.Next() )
+ AIS_ListOfInteractive presentations;
+ prs->GetObjects( presentations );
+ AIS_ListIteratorOfListOfInteractive iter( presentations );
+ for ( ; iter.More(); iter.Next() )
{
- Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
- if( !aShape.IsNull() )
+ Handle(GEOM_AISShape) shape = Handle(GEOM_AISShape)::DownCast( iter.Value() );
+ if ( shape.IsNull() ) continue;
+ GEOM::field_data_type fieldDataType;
+ int fieldDimension;
+ QList<QVariant> fieldStepData;
+ TCollection_AsciiString fieldStepName;
+ Standard_Real fieldStepRangeMin, fieldStepRangeMax;
+ shape->getFieldStepInfo( fieldDataType, fieldDimension, fieldStepData,
+ fieldStepName, fieldStepRangeMin, fieldStepRangeMax );
+ visible = !fieldStepData.isEmpty() && fieldDataType != GEOM::FDT_String;
+ if ( visible )
{
- GEOM::field_data_type aFieldDataType;
- int aFieldDimension;
- QList<QVariant> aFieldStepData;
- TCollection_AsciiString aFieldStepName;
- double aFieldStepRangeMin, aFieldStepRangeMax;
- aShape->getFieldStepInfo( aFieldDataType,
- aFieldDimension,
- aFieldStepData,
- aFieldStepName,
- aFieldStepRangeMin,
- aFieldStepRangeMax );
- if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
- {
- anIsDisplayColorScale = Standard_True;
- aColorScaleTitle = aFieldStepName;
- aColorScaleMin = aFieldStepRangeMin;
- aColorScaleMax = aFieldStepRangeMax;
- anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
- }
- }
+ SUIT_Session* session = SUIT_Session::session();
+ SUIT_ResourceMgr* resMgr = session->resourceMgr();
+
+ Standard_Real xPos = resMgr->doubleValue( "Geometry", "scalar_bar_x_position", 0.05 );
+ Standard_Real yPos = resMgr->doubleValue( "Geometry", "scalar_bar_y_position", 0.1 );
+ Standard_Real width = resMgr->doubleValue( "Geometry", "scalar_bar_width", 0.2 );
+ Standard_Real height = resMgr->doubleValue( "Geometry", "scalar_bar_height", 0.5 );
+ Standard_Integer textHeight = resMgr->integerValue( "Geometry", "scalar_bar_text_height", 14 );
+ Standard_Integer nbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
+
+ Standard_Integer viewWidth = 0, viewHeight = 0;
+ occWindow->getView(0)->getViewPort()->getView()->Window()->Size( viewWidth, viewHeight );
+
+ Handle(AIS_ColorScale) colorScale = view->getColorScale();
+
+ colorScale->SetPosition( viewWidth * xPos, viewHeight * yPos );
+ colorScale->SetBreadth( viewWidth * width );
+ colorScale->SetHeight( viewHeight * height );
+ colorScale->SetRange( fieldStepRangeMin, fieldStepRangeMax );
+ colorScale->SetNumberOfIntervals( fieldDataType == GEOM::FDT_Bool ? 2 : nbIntervals );
+ colorScale->SetTextHeight( textHeight );
+ colorScale->SetTitle( fieldStepName );
+ } // if ( visible )
}
}
- }
- }
-
- if( anIsDisplayColorScale )
- {
- SUIT_Session* session = SUIT_Session::session();
- SUIT_ResourceMgr* resMgr = session->resourceMgr();
-
- Standard_Real anXPos = resMgr->doubleValue( "Geometry", "scalar_bar_x_position", 0.05 );
- Standard_Real anYPos = resMgr->doubleValue( "Geometry", "scalar_bar_y_position", 0.1 );
- Standard_Real aWidth = resMgr->doubleValue( "Geometry", "scalar_bar_width", 0.2 );
- Standard_Real aHeight = resMgr->doubleValue( "Geometry", "scalar_bar_height", 0.5 );
- Standard_Integer aTextHeight = resMgr->integerValue( "Geometry", "scalar_bar_text_height", 14 );
- Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
-
-#if OCC_VERSION_MAJOR < 7
- Handle(Aspect_ColorScale) myColorScale = aView->ColorScale();
- if( !myColorScale.IsNull() )
+ view->setColorScaleShown( visible );
+ } // if ( view->isVisible( io ) )
+ else
{
-#endif
-
- myColorScale->SetXPosition( anXPos );
- myColorScale->SetYPosition( anYPos );
- myColorScale->SetWidth( aWidth );
- myColorScale->SetHeight( aHeight );
-
- myColorScale->SetTextHeight( aTextHeight );
- myColorScale->SetNumberOfIntervals( anIsBoolean ? 2 : aNbIntervals );
-
- myColorScale->SetTitle( aColorScaleTitle );
- myColorScale->SetRange( aColorScaleMin, aColorScaleMax );
-
-#if OCC_VERSION_MAJOR < 7
+ view->setColorScaleShown( false );
}
- if( !aView->ColorScaleIsDisplayed() )
- aView->ColorScaleDisplay();
- }
- else
- if( aView->ColorScaleIsDisplayed() )
- aView->ColorScaleErase();
-#else
- if( !aViewModel->getAISContext()->IsDisplayed( myColorScale ) )
- aViewModel->getAISContext()->Display( myColorScale );
- }
- else
- if( aViewModel->getAISContext()->IsDisplayed( myColorScale ) )
- aViewModel->getAISContext()->Erase( myColorScale );
-#endif
+ } // foreach( SUIT_ViewWindow* window, windows )
+}
- if( theIsRedisplayFieldSteps )
- {
- _PTR(Study) aStudyDS = aStudy->studyDS();
- QList<SUIT_ViewManager*> vmList;
- myApp->viewManagers( vmList );
- for( QList<SUIT_ViewManager*>::Iterator vmIt = vmList.begin(); vmIt != vmList.end(); vmIt++ )
- {
- if( SUIT_ViewManager* aViewManager = *vmIt )
- {
- const ObjMap& anObjects = aStudy->getObjectProperties( aViewManager->getGlobalId() );
- for( ObjMap::ConstIterator objIt = anObjects.begin(); objIt != anObjects.end(); objIt++ )
- {
- _PTR(SObject) aSObj( aStudyDS->FindObjectID( objIt.key().toLatin1().constData() ) );
- if( aSObj )
- {
- CORBA::Object_var anObject = GeometryGUI::ClientSObjectToObject( aSObj );
- if( !CORBA::is_nil( anObject ) )
- {
- GEOM::GEOM_FieldStep_var aFieldStep = GEOM::GEOM_FieldStep::_narrow( anObject );
- if( !aFieldStep->_is_nil() )
- {
- CORBA::String_var aStepEntry = aFieldStep->GetStudyEntry();
- Handle(SALOME_InteractiveObject) aStepIO =
- new SALOME_InteractiveObject( aStepEntry.in(), "GEOM", "TEMP_IO" );
- Redisplay( aStepIO, false, false );
- }
- }
- }
- }
- }
- }
- }
- if(updateViewer)
- UpdateViewer();
+bool GEOM_Displayer::SetUpdateColorScale( bool toUpdate ) // IPAL54049
+{
+ bool previous = myUpdateColorScale;
+ myUpdateColorScale = toUpdate;
+ if ( myUpdateColorScale && !previous )
+ UpdateColorScale();
+ return previous;
}
+