X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGEOM_Displayer.cxx;h=82853c712ff04441591de18bf7fd9352b4790a13;hb=32e56a241f21859130edcfcc7a9d9c452c8d00d4;hp=7f778b23e966187ef38ca1bc48325e3b0fa21b6a;hpb=a614e772f5a37ee9b2592075ff4deff38d577096;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 7f778b23e..82853c712 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 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 @@ -19,6 +19,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GEOM GEOMGUI : GUI for Geometry component // File : GEOM_Displayer.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) @@ -79,6 +80,7 @@ #include #include #include +#include // VTK Includes #include @@ -88,8 +90,8 @@ #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include +#include -using namespace std; //================================================================ // Function : getActiveStudy @@ -188,7 +190,7 @@ SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList* aSubSh // Function : getEntry // Purpose : //================================================================ -static string getEntry( GEOM::GEOM_Object_ptr object ) +static std::string getEntry( GEOM::GEOM_Object_ptr object ) { SUIT_Session* session = SUIT_Session::session(); SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); @@ -198,9 +200,9 @@ static string getEntry( GEOM::GEOM_Object_ptr object ) if ( strcmp(IOR.in(), "") != 0 ) { SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy(); - _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( string(IOR) ) ); + _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) ); if ( SO ) - return SO->GetID(); + return SO->GetID(); } } return ""; @@ -210,7 +212,7 @@ static string getEntry( GEOM::GEOM_Object_ptr object ) // Function : getName // Purpose : //================================================================ -static string getName( GEOM::GEOM_Object_ptr object ) +static std::string getName( GEOM::GEOM_Object_ptr object ) { SUIT_Session* session = SUIT_Session::session(); SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); @@ -220,7 +222,7 @@ static string getName( GEOM::GEOM_Object_ptr object ) if ( strcmp(IOR.in(), "") != 0 ) { SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy(); - _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( string(IOR) ) ); + _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) ); _PTR(GenericAttribute) anAttr; @@ -256,13 +258,10 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) myShadingColor = SalomeApp_Tools::color( col ); myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0); - myTypeOfMarker = (Aspect_TypeOfMarker)resMgr->integerValue("Geometry", "type_of_marker", Aspect_TOM_PLUS); - myScaleOfMarker = resMgr->doubleValue("Geometry", "marker_scale", 1.); - if(myScaleOfMarker < 1.0) - myScaleOfMarker = 1.0; - if(myScaleOfMarker > 7.) - myScaleOfMarker = 7.; - + int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS); + myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType))); + myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0; + myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker)); myColor = -1; // This color is used for shape displaying. If it is equal -1 then @@ -294,8 +293,8 @@ GEOM_Displayer::~GEOM_Displayer() */ //================================================================= void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, - const bool updateViewer, - SALOME_View* theViewFrame ) + const bool updateViewer, + SALOME_View* theViewFrame ) { SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); if ( vf ) @@ -328,7 +327,7 @@ void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateVie if ( theObj->_is_nil() ) return; - string entry = getEntry( theObj ); + std::string entry = getEntry( theObj ); if ( entry != "" ) { Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()), updateViewer); @@ -344,7 +343,7 @@ void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateVie void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, const bool forced, const bool updateViewer, - SALOME_View* theViewFrame ) + SALOME_View* theViewFrame ) { if ( theIO.IsNull() ) return; @@ -356,7 +355,7 @@ void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, if ( prs ) { vf->Erase( prs, forced ); if ( updateViewer ) - vf->Repaint(); + vf->Repaint(); delete prs; // delete presentation because displayer is its owner } } @@ -372,7 +371,7 @@ void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj, const bool forced, const bool updateViewer ) { - string entry = getEntry( theObj ); + std::string entry = getEntry( theObj ); if ( entry != "" ) { Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()), @@ -404,19 +403,19 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, SUIT_ViewManager* vman = wnd->getViewManager(); if ( vman ) { - SUIT_ViewModel* vmodel = vman->getViewModel(); - if ( vmodel ) - { - SALOME_View* view = dynamic_cast(vmodel); - if ( view ) - { - if ( view->isVisible( theIO ) || view == GetActiveView() ) - { - Erase( theIO, true, false, view ); - Display( theIO, updateViewer, view ); - } - } - } + SUIT_ViewModel* vmodel = vman->getViewModel(); + if ( vmodel ) + { + SALOME_View* view = dynamic_cast(vmodel); + if ( view ) + { + if ( view->isVisible( theIO ) || view == GetActiveView() ) + { + Erase( theIO, true, false, view ); + Display( theIO, updateViewer, view ); + } + } + } } } } @@ -551,91 +550,96 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) AISShape = new GEOM_AISShape (myShape, ""); } // Temporary staff: vertex must be infinite for correct visualization - AISShape->SetInfiniteState( myShape.Infinite() || myShape.ShapeType() == TopAbs_VERTEX ); + AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines) // Setup shape properties here ..., e.g. display mode, color, transparency, etc - AISShape->SetDisplayMode( myDisplayMode ); + AISShape->SetDisplayMode( myDisplayMode ); AISShape->SetShadingColor( myShadingColor ); - // Set color and number for iso lines - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - QColor col = aResMgr->colorValue( "Geometry", "isos_color", + // Set color and number for iso lines + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QColor col = aResMgr->colorValue( "Geometry", "isos_color", QColor(int(0.5*255), int(0.5*255), int(0.5*255)) ); - Quantity_Color aColor = SalomeApp_Tools::color( col ); - int anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1); - int aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1); + Quantity_Color aColor = SalomeApp_Tools::color( col ); + int anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1); + int aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1); - Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect(); - anAspect->SetNumber( anUIsoNumber ); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetUIsoAspect( anAspect ); + Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect(); + anAspect->SetNumber( anUIsoNumber ); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetUIsoAspect( anAspect ); - anAspect = AISShape->Attributes()->VIsoAspect(); - anAspect->SetNumber( aVIsoNumber ); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetVIsoAspect( anAspect ); + anAspect = AISShape->Attributes()->VIsoAspect(); + anAspect->SetNumber( aVIsoNumber ); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetVIsoAspect( anAspect ); if ( HasColor() ) { - AISShape->SetColor( (Quantity_NameOfColor)GetColor() ); + AISShape->SetColor( (Quantity_NameOfColor)GetColor() ); + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); + anAspect->SetColor( (Quantity_NameOfColor)GetColor() ); + if ( myShape.ShapeType() == TopAbs_VERTEX ) + { + anAspect->SetScale( myScaleOfMarker ); + anAspect->SetTypeOfMarker( myTypeOfMarker ); + } + AISShape->Attributes()->SetPointAspect( anAspect ); + } + else + { if ( myShape.ShapeType() == TopAbs_VERTEX ) { + col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetColor( (Quantity_NameOfColor)GetColor() ); + anAspect->SetColor( aColor ); anAspect->SetScale( myScaleOfMarker ); anAspect->SetTypeOfMarker( myTypeOfMarker ); AISShape->Attributes()->SetPointAspect( anAspect ); } + else + { + // Set line aspect + col = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetLineAspect( anAspect ); + + // Set unfree boundaries aspect + anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); + + // Set free boundaries aspect + col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + anAspect = AISShape->Attributes()->FreeBoundaryAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetFreeBoundaryAspect( anAspect ); + + // Set wire aspect + col = aResMgr->colorValue( "Geometry", "line_color", QColor( 255, 0, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + anAspect = AISShape->Attributes()->WireAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetWireAspect( anAspect ); + + // bug [SALOME platform 0019868] + // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18) + //AISShape->SetOwnDeviationAngle( 10*PI/180 ); + + // IMP 0020626 + double aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001); + aDC = std::max( aDC, DEFLECTION_MIN ); // to avoid to small values of the coefficient + AISShape->SetOwnDeviationCoefficient(aDC); + } } - else - { - if ( myShape.ShapeType() == TopAbs_VERTEX ) - { - col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetColor( aColor ); - anAspect->SetScale( myScaleOfMarker ); - anAspect->SetTypeOfMarker( myTypeOfMarker ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } - else - { - // Set line aspect - col = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetLineAspect( anAspect ); - - // Set unfree boundaries aspect - anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); - - // Set free boundaries aspect - col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - anAspect = AISShape->Attributes()->FreeBoundaryAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetFreeBoundaryAspect( anAspect ); - - // Set wire aspect - col = aResMgr->colorValue( "Geometry", "line_color", QColor( 255, 0, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - anAspect = AISShape->Attributes()->WireAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetWireAspect( anAspect ); - - // bug [SALOME platform 0019868] - // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18) - AISShape->SetOwnDeviationAngle( 10*PI/180 ); - } - } if ( HasWidth() ) AISShape->SetWidth( GetWidth() ); @@ -657,72 +661,72 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) AISShape->SetOwner( anObj ); } - // Get color from GEOM_Object - SUIT_Session* session = SUIT_Session::session(); - SUIT_Application* app = session->activeApplication(); - if ( app ) - { - SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); - if ( study ) - { - Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO(); - if ( !anIO.IsNull() ) - { - _PTR(SObject) SO ( study->studyDS()->FindObjectID( anIO->getEntry() ) ); - if ( SO ) - { - // get CORBA reference to data object - CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO); - if ( !CORBA::is_nil( object ) ) - { - // downcast to GEOM object - GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object ); - if ( !aGeomObject->_is_nil() ) - { - SALOMEDS::Color aSColor = aGeomObject->GetColor(); - bool hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0; - if( !hasColor && aGeomObject->GetType() == GEOM_GROUP ) // auto color for group - { - GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); - GEOM::GEOM_IGroupOperations_var anOperations = aGeomGen->GetIGroupOperations( study->id() ); - GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( aGeomObject ); - if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() ) - { - QList aReservedColors; - - SalomeApp_Application* app = dynamic_cast( app ); - CORBA::String_var IOR = app->orb()->object_to_string( aMainObject ); - if ( strcmp(IOR.in(), "") != 0 ) - { - _PTR(Study) aStudy = study->studyDS(); - _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( string(IOR) ) ); - _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); - for( ; it->More(); it->Next() ) - { - _PTR(SObject) aChildSObject( it->Value() ); - GEOM::GEOM_Object_var aChildObject = - GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject)); - if( CORBA::is_nil( aChildObject ) ) - continue; - - if( aChildObject->GetType() != GEOM_GROUP ) - continue; - - SALOMEDS::Color aReservedColor = aChildObject->GetColor(); - aReservedColors.append( aReservedColor ); - } - } - - aSColor = getUniqueColor( aReservedColors ); - hasColor = true; - } - } - - if( hasColor ) - { - Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); - AISShape->SetColor( aQuanColor ); - AISShape->SetShadingColor( aQuanColor ); + // Get color and other properties from GEOM_Object + SUIT_Session* session = SUIT_Session::session(); + SUIT_Application* app = session->activeApplication(); + if ( app ) + { + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( study ) + { + Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO(); + if ( !anIO.IsNull() ) + { + _PTR(SObject) SO ( study->studyDS()->FindObjectID( anIO->getEntry() ) ); + if ( SO ) + { + // get CORBA reference to data object + CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO); + if ( !CORBA::is_nil( object ) ) + { + // downcast to GEOM object + GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object ); + if ( !aGeomObject->_is_nil() ) + { + SALOMEDS::Color aSColor = aGeomObject->GetColor(); + bool hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0; + if( !hasColor && aGeomObject->GetType() == GEOM_GROUP ) // auto color for group + { + GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); + GEOM::GEOM_IGroupOperations_var anOperations = aGeomGen->GetIGroupOperations( study->id() ); + GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( aGeomObject ); + if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() ) + { + QList aReservedColors; + + SalomeApp_Application* app = dynamic_cast( app ); + CORBA::String_var IOR = app->orb()->object_to_string( aMainObject ); + if ( strcmp(IOR.in(), "") != 0 ) + { + _PTR(Study) aStudy = study->studyDS(); + _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( std::string(IOR) ) ); + _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); + for( ; it->More(); it->Next() ) + { + _PTR(SObject) aChildSObject( it->Value() ); + GEOM::GEOM_Object_var aChildObject = + GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject)); + if( CORBA::is_nil( aChildObject ) ) + continue; + + if( aChildObject->GetType() != GEOM_GROUP ) + continue; + + SALOMEDS::Color aReservedColor = aChildObject->GetColor(); + aReservedColors.append( aReservedColor ); + } + } + + aSColor = getUniqueColor( aReservedColors ); + hasColor = true; + } + } + + if( hasColor ) + { + Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); + AISShape->SetColor( aQuanColor ); + AISShape->SetShadingColor( aQuanColor ); if ( myShape.ShapeType() == TopAbs_VERTEX ) { Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); anAspect->SetColor( aQuanColor ); @@ -730,13 +734,43 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) anAspect->SetTypeOfMarker( myTypeOfMarker ); AISShape->Attributes()->SetPointAspect( anAspect ); } - } - } - } - } - } - } - } + } + // ... marker type + GEOM::marker_type aType = aGeomObject->GetMarkerType(); + GEOM::marker_size aSize = aGeomObject->GetMarkerSize(); + if ( aType > GEOM::MT_NONE && aType < GEOM::MT_USER && aSize > GEOM::MS_NONE && aSize <= GEOM::MS_70 ) { + Aspect_TypeOfMarker aMType = (Aspect_TypeOfMarker)( (int)aType-1 ); + double aMSize = ((int)aSize+1)*0.5; + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); + anAspect->SetScale( aMSize ); + anAspect->SetTypeOfMarker( aMType ); + Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) ); + if ( hasColor ) + aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); + anAspect->SetColor( aQuanColor ); + AISShape->Attributes()->SetPointAspect( anAspect ); + } + else if ( aType == GEOM::MT_USER ) { + int aTextureId = aGeomObject->GetMarkerTexture(); + Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) ); + if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); + Standard_Integer aWidth, aHeight; + Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTexture( getStudy(), aTextureId, aWidth, aHeight ); + if ( !aTexture.IsNull() ) { + static int TextureId = 0; + Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect(aQuanColor, + ++TextureId, + aWidth, aHeight, + aTexture ); + AISShape->Attributes()->SetPointAspect( aTextureAspect ); + } + } + } + } + } + } + } + } // AISShape->SetName(???); ??? necessary to set name ??? occPrs->AddObject( AISShape ); @@ -793,7 +827,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) { - myToActivate = false; + //myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657) GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New(); if ( HasColor() ) @@ -820,9 +854,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) } else { - bool isVector = false; - if (myType == GEOM_VECTOR) isVector = true; - theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, isVector ); + theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, myType == GEOM_VECTOR ); } theActors->InitTraversal(); @@ -946,7 +978,7 @@ SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape ) */ //================================================================= SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry, - SALOME_View* theViewFrame ) + SALOME_View* theViewFrame ) { SALOME_Prs* prs = 0; internalReset(); @@ -962,35 +994,35 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry, theIO->setEntry( entry.toLatin1().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 ) - { - SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); - if ( study ) - { - _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 ) ) - { - // downcast to GEOM object - GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object ); - if ( !GeomObject->_is_nil() ) - { - // finally set shape - setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) ); - myType = GeomObject->GetType(); - } - } - } - } - } + // 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 ) + { + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( study ) + { + _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 ) ) + { + // downcast to GEOM object + GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object ); + if ( !GeomObject->_is_nil() ) + { + // finally set shape + setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) ); + myType = GeomObject->GetType(); + } + } + } + } + } } UpdatePrs( prs ); // Update presentation by using of the double dispatch } @@ -998,6 +1030,44 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry, return prs; } +//================================================================= +/*! + * GEOM_Displayer::buildSubshapePresentation + * Builds/finds object's presentation for the current viewer + * Calls corresponding Update() method by means of double dispatch + * For not published objects (for Mantis issue 0020435) + */ +//================================================================= +SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape, + const QString& entry, + SALOME_View* theViewFrame) +{ + SALOME_Prs* prs = 0; + internalReset(); + + myViewFrame = theViewFrame ? theViewFrame : GetActiveView(); + + if (myViewFrame) + { + prs = LightApp_Displayer::buildPresentation(entry, theViewFrame); + if (prs) + { + Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject(); + theIO->setEntry(entry.toLatin1().constData()); + if (!theIO.IsNull()) + { + // set interactive object + setIO(theIO); + // finally set shape + setShape(aShape); + myType = GEOM_SUBSHAPE; + } + UpdatePrs(prs); // Update presentation by using of the double dispatch + } + } + return prs; +} + //================================================================= /*! * GEOM_Displayer::internalReset @@ -1062,7 +1132,7 @@ void GEOM_Displayer::GlobalSelection( const int theMode, const bool update ) */ //================================================================= void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, - const bool update, const QList* theSubShapes ) + const bool update, const QList* theSubShapes ) { SUIT_Session* session = SUIT_Session::session(); SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); @@ -1096,7 +1166,7 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, { ic = viewer->getAISContext(); if ( !ic.IsNull() ) - ic->RemoveFilters(); + ic->RemoveFilters(); } if ( theModes.Contains( GEOM_ALLOBJECTS ) ) @@ -1118,7 +1188,7 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, TColStd_MapIteratorOfMapOfInteger anIter( theModes ); QList aListOfFilters; for ( ; anIter.More(); anIter.Next() ) - { + { SUIT_SelectionFilter* aFilter; int aMode = anIter.Key(); if ( aMode == GEOM_COMPOUNDFILTER ) @@ -1126,9 +1196,9 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, else aFilter = getFilter( aMode ); - if ( aFilter ) - aListOfFilters.append( aFilter ); - } + if ( aFilter ) + aListOfFilters.append( aFilter ); + } aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR ); } @@ -1139,10 +1209,10 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, { sm->installFilter( aFilter ); if ( !ic.IsNull() ) - { - Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm ); - ic->AddFilter( anOCCFilter ); - } + { + Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm ); + ic->AddFilter( anOCCFilter ); + } } } @@ -1354,14 +1424,14 @@ SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList& th { aTolerance /= 2; if( aTolerance < 1 ) - break; + break; } - //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl; + //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl; aHue = (int)( 360.0 * rand() / RAND_MAX ); - //cout << "Hue = " << aHue << endl; + //std::cout << "Hue = " << aHue << std::endl; - //cout << "Auto colors : "; + //std::cout << "Auto colors : "; bool ok = true; QList::const_iterator it = theReservedColors.constBegin(); QList::const_iterator itEnd = theReservedColors.constEnd(); @@ -1372,21 +1442,21 @@ SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList& th int h, s, v; aQColor.getHsv( &h, &s, &v ); - //cout << h << " "; + //std::cout << h << " "; if( abs( h - aHue ) < aTolerance ) { - ok = false; - //cout << "break (diff = " << abs( h - aHue ) << ")"; - break; + ok = false; + //std::cout << "break (diff = " << abs( h - aHue ) << ")"; + break; } } - //cout << endl; + //std::cout << std::endl; if( ok ) break; } - //cout << "Hue of the returned color = " << aHue << endl; + //std::cout << "Hue of the returned color = " << aHue << std::endl; QColor aColor; aColor.setHsv( aHue, 255, 255 );