From: vsr Date: Tue, 29 Jan 2013 05:23:35 +0000 (+0000) Subject: Improve GEOM_Displayer; required for features 0021391, 0021830 (part 2) X-Git-Tag: V6_main_FINAL~55 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=26f2b64fcebb41e994d6d277ad43e4694eb8c639;p=modules%2Fgeom.git Improve GEOM_Displayer; required for features 0021391, 0021830 (part 2) --- diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 67665f66e..0dc9455d4 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -577,10 +577,10 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow } } if(mode == 0 || mode == 1 || mode == 2) { - aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode); + aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),GEOM::propertyName( GEOM::DisplayMode ), mode); } else if (mode == 4) { - aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode); + aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),GEOM::propertyName( GEOM::EdgesDirection ), vectorMode); } } } @@ -625,10 +625,10 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow } } if(mode == 0 || mode == 1 || mode == 2 || mode == 3) { - aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode); + aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),GEOM::propertyName( GEOM::DisplayMode ), mode); } else if (mode == 4) { - aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode); + aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),GEOM::propertyName( GEOM::EdgesDirection ), vectorMode); } } } diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 912dd15f6..856cd6a1e 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -318,19 +318,16 @@ void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object, const int displayMode, const int color ) { + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + // Set color for preview shape getDisplayer()->SetColor( color == -1 ? Quantity_NOC_VIOLET : color ); // set width of displayed shape - int lw = lineWidth; - if(lw == -1) { - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - lw = resMgr->integerValue("Geometry", "preview_edge_width", -1); - } - getDisplayer()->SetWidth( lw ); + getDisplayer()->SetWidth( lineWidth == -1 ? resMgr->integerValue("Geometry", "preview_edge_width", -1) : lineWidth ); // set display mode of displayed shape - int aPrevDispMode = getDisplayer()->SetDisplayMode( displayMode ); + int aPrevDispMode = getDisplayer()->SetDisplayMode( displayMode == -1 ? resMgr->integerValue( "Geometry", "display_mode", 0 ) : displayMode ); // Disable activation of selection getDisplayer()->SetToActivate( activate ); diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 0aa1da20a..e6a016041 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -217,7 +217,7 @@ bool GEOMGUI_Selection::isVisible( const int index ) const #ifdef USE_VISUAL_PROP_MAP bool found = false; - QVariant v = visibleProperty( entry( index ), VISIBILITY_PROP ); + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Visibility ) ); if ( v.canConvert( QVariant::Bool ) ) { res = v.toBool(); found = true; @@ -289,7 +289,7 @@ QString GEOMGUI_Selection::displayMode( const int index ) const QString res; QString viewType = activeViewType(); #ifdef USE_VISUAL_PROP_MAP - QVariant v = visibleProperty( entry( index ), DISPLAY_MODE_PROP ); + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::DisplayMode ) ); if ( v.canConvert( QVariant::Int ) ) { int dm = v.toInt(); if ( viewType == OCCViewer_Viewer::Type() ) { @@ -361,7 +361,7 @@ bool GEOMGUI_Selection::isVectorsMode( const int index ) const #ifdef USE_VISUAL_PROP_MAP bool found = false; - QVariant v = visibleProperty( entry( index ), VECTOR_MODE_PROP ); + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::EdgesDirection ) ); if ( v.canConvert( QVariant::Bool ) ) { res = v.toBool(); found = true; @@ -553,7 +553,7 @@ bool GEOMGUI_Selection::topLevel( const int index ) const { #ifdef USE_VISUAL_PROP_MAP bool found = false; - QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP ); + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::TopLevel ) ); if ( v.canConvert() ) { res = v.toBool(); found = true; @@ -590,7 +590,7 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const{ #ifdef USE_VISUAL_PROP_MAP bool found = false; - QVariant v = visibleProperty( entry( idx ), MATERIAL_PROP ); + QVariant v = visibleProperty( entry( idx ), GEOM::propertyName( GEOM::Material ) ); if ( v.canConvert() ) { Material_Model material; material.fromProperties( v.toString() ); diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 873c61f7c..d1e65bc58 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -121,6 +121,9 @@ // of auto-color picking up #define SIMPLE_AUTOCOLOR +// Hard-coded value of shape deflection coefficient for VTK viewer +const double VTK_MIN_DEFLECTION = 0.001; + //================================================================ // Function : getActiveStudy // Purpose : Get active study, returns 0 if no open study frame @@ -323,6 +326,7 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) myShadingColor = SalomeApp_Tools::color( col ); myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0); + myHasDisplayMode = false; int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS); myWidth = resMgr->integerValue("Geometry", "edge_width", -1); @@ -393,7 +397,7 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, int aMgrId = getViewManagerId(vf); SalomeApp_Study* aStudy = getStudy(); - aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 1 ); + aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 1 ); setVisibilityState(theIO->getEntry(), Qtx::ShownState); @@ -449,7 +453,7 @@ void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, int aMgrId = getViewManagerId(vf); SalomeApp_Study* aStudy = getStudy(); - aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 0 ); + aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 0 ); setVisibilityState(theIO->getEntry(), Qtx::HiddenState); } @@ -546,335 +550,204 @@ QColor GEOM_Displayer::colorFromResources( const QString& property, const QColor return SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor ); } -bool GEOM_Displayer::setPointMarker( const Handle(GEOM_AISShape)& AISShape, const QString& markerData, const Quantity_Color color ) -{ - bool result = true; - - QStringList aList = markerData.split( DIGIT_SEPARATOR ); - if ( aList.size() == 2 ) { - // standard marker string contains "TypeOfMarker:ScaleOfMarker" - int aTypeOfMarker = aList[0].toInt(); - double aScaleOfMarker = aList[1].toDouble(); - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetScale( aScaleOfMarker ); - anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) ); - anAspect->SetColor( color ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } - else if ( aList.size() == 1 ) { - // custom marker string contains "IdOfTexture" - int textureId = aList[0].toInt(); - Standard_Integer aWidth, aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - Handle(TColStd_HArray1OfByte) aTexture = -#else - Handle(Graphic3d_HArray1OfBytes) aTexture = -#endif - GeometryGUI::getTexture( getStudy(), textureId, aWidth, aHeight ); - if ( !aTexture.IsNull() ) { - static int TextureId = 0; - Handle(Prs3d_PointAspect) aTextureAspect = - new Prs3d_PointAspect( color, - ++TextureId, - aWidth, aHeight, - aTexture ); - AISShape->Attributes()->SetPointAspect( aTextureAspect ); - } - else { - // texture is not loaded to GUI - result = false; - } - } - else { - // wrong point marker data stored - result = false; - } - return result; -} - -void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape ) +void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape, bool create ) { - // get study + // check that shape is not null + if ( AISShape.IsNull() ) return; + + // check that study is active SalomeApp_Study* study = getStudy(); if ( !study ) return; - // get resource manager - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if ( myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points !TopoDS_Iterator(myShape).More() ) return; // NPAL15983 (Bug when displaying empty groups) + // set interactive object + + Handle( SALOME_InteractiveObject ) anIO; + + if ( !myIO.IsNull() ) { + AISShape->setIO( myIO ); + AISShape->SetOwner( myIO ); + anIO = myIO; + } + 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() ); + AISShape->setIO( anIO ); + AISShape->SetOwner( anIO ); + } + // flag: only vertex or compound of vertices is processed (specific handling) - bool onlyVertex = (myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape )); + bool onlyVertex = myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ); // presentation study entry (empty for temporary objects like preview) - QString anEntry = !myIO.IsNull() ? QString( myIO->getEntry() ) : QString(); + QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString(); // flag: temporary object - bool isTemporary = anEntry.isEmpty() || anEntry.startsWith( "TEMP_" ); + bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" ); // currently active view window's ID (-1 if no active view) - int aMgrId = !myIO.IsNull() ? getViewManagerId( myViewFrame ) : -1; - - // stored properties - PropMap aPropMap = study->getObjectPropMap( aMgrId, anEntry ); - // default properties - PropMap aDefPropMap = getDefaultPropertyMap( SOCC_Viewer::Type() ); - - // use properties stored in study - bool useStudy = !isTemporary && aMgrId != -1; // anEntry.isEmpty() - // use GEOM object color (from engine side) - bool useObjColor = !aPropMap.contains( COLOR_PROP ); - // use GEOM object marker (rom engine side) - bool useObjMarker = !aPropMap.contains( MARKER_TYPE_PROP ); - - MergePropertyMaps( aPropMap, aDefPropMap ); - - // default properties - double transparency = 0.0; - int uIsos = 1; - int vIsos = 1; - int dispMode = myDisplayMode; // take from resource manager ??? - Quantity_Color shadingColor = myShadingColor; // take from resource manager ??? - Standard_Boolean isTopLevel = Standard_False; // bool ??? - bool isDisplayVectors = false; - double deflection = 0.001; - Material_Model material; + int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1; - if ( useStudy ) { - // take proprties from stored properties: - // - shading color - shadingColor = SalomeApp_Tools::color( aPropMap.value( COLOR_PROP ).value() ); - // - display mode - dispMode = aPropMap.value( DISPLAY_MODE_PROP ).toInt(); - // - nb of isos - uIsos = aPropMap.value( ISOS_PROP ).toString().split( DIGIT_SEPARATOR )[0].toInt(); - vIsos = aPropMap.value( ISOS_PROP ).toString().split( DIGIT_SEPARATOR )[1].toInt(); - // - transparency - transparency = aPropMap.value( TRANSPARENCY_PROP ).toDouble(); - // - top-level flag - isTopLevel = aPropMap.value( TOP_LEVEL_PROP ).value(); - // - display vectors flag - isDisplayVectors = aPropMap.value( VECTOR_MODE_PROP ).toBool(); - // - deflection coefficient - deflection = aPropMap.value( DEFLECTION_COEFF_PROP ).toDouble(); - // - line width - SetWidth( aPropMap.value( EDGE_WIDTH_PROP ).toInt() ); - // - isos width - SetIsosWidth( aPropMap.value( ISOS_WIDTH_PROP ).toInt() ); - // - material - material.fromProperties( aPropMap.value( MATERIAL_PROP ).toString() ); - } - else { - // take nb of isos from resources: - // - nb of isos - uIsos = aResMgr->integerValue( "Geometry", "iso_number_u", 1 ); - vIsos = aResMgr->integerValue( "Geometry", "iso_number_v", 1 ); - // - deflection coefficient - deflection = aResMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ); - // - material - QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" ); - material.fromResources( mname ); - } + // get presentation properties + PropMap propMap = getObjectProperties( study, 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) // set material + Material_Model material; + material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() ); // - set front material properties - AISShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE); + AISShape->SetCurrentFacingModel( Aspect_TOFM_FRONT_SIDE ); AISShape->SetMaterial( material.getMaterialOCCAspect( true ) ); // - set back material properties - AISShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE); + AISShape->SetCurrentFacingModel( Aspect_TOFM_BACK_SIDE ); AISShape->SetMaterial( material.getMaterialOCCAspect( false ) ); - // - switch default facing mode - AISShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE); + // - switch to default (both sides) facing mode + AISShape->SetCurrentFacingModel( Aspect_TOFM_BOTH_SIDE ); + + // set colors - // set shading color - if ( !material.isPhysical() ) - AISShape->SetShadingColor( shadingColor ); + // - shading color + if ( HasColor() ) { + // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function; + // we set it to the shape not taking into account material properties + AISShape->SetShadingColor( (Quantity_NameOfColor)GetColor() ); + } + else if ( !material.isPhysical() ) { + // shading color from properties is used only for non-physical materials + AISShape->SetShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value() ) ); + } + + // - wireframe color + Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value() ) ); + AISShape->Attributes()->SetLineAspect( anAspect ); + + // - unfree boundaries color + anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value() ) ); + AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); + + // - free boundaries color + anAspect = AISShape->Attributes()->FreeBoundaryAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value() ) ); + AISShape->Attributes()->SetFreeBoundaryAspect( anAspect ); + + // - standalone edges color + anAspect = AISShape->Attributes()->WireAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::LineColor ) ).value() ) ); + AISShape->Attributes()->SetWireAspect( anAspect ); + + // - color for edges in shading+edges mode + AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value() ) ); + + // ??? + AISShape->storeBoundaryColors(); // set display mode - AISShape->SetDisplayMode( dispMode ); + 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() ); + + // set display vectors flag + AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() ); + + // set transparency ???????????????????????????????????????????????????? + //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(); + int vIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[1].toInt(); + Quantity_Color isosColor = SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value() ); + int isosWidth = propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt(); Handle(Prs3d_IsoAspect) uIsoAspect = AISShape->Attributes()->UIsoAspect(); Handle(Prs3d_IsoAspect) vIsoAspect = AISShape->Attributes()->VIsoAspect(); - uIsoAspect->SetColor( qColorFromResources( "isos_color", QColor::fromRgbF( 0.5, 0.5, 0.5 ) ) ); - vIsoAspect->SetColor( qColorFromResources( "isos_color", QColor::fromRgbF( 0.5, 0.5, 0.5 ) ) ); - if ( HasIsosWidth() ) { - uIsoAspect->SetWidth( GetIsosWidth() ); - vIsoAspect->SetWidth( GetIsosWidth() ); - } + uIsoAspect->SetColor( isosColor ); + uIsoAspect->SetWidth( isosWidth ); uIsoAspect->SetNumber( uIsos ); + vIsoAspect->SetColor( isosColor ); + vIsoAspect->SetWidth( isosWidth ); vIsoAspect->SetNumber( vIsos ); AISShape->Attributes()->SetUIsoAspect( uIsoAspect ); AISShape->Attributes()->SetVIsoAspect( vIsoAspect ); - // set transparency - AISShape->SetTransparency( transparency ); - - // set top-level flag - AISShape->setTopLevel( isTopLevel ); - - // set display vectors flag - AISShape->SetDisplayVectors( isDisplayVectors ); - - // set point marker (for vertex / compound of vertices only) - if ( onlyVertex && !useObjMarker ) { - useObjMarker = !setPointMarker( AISShape, - aPropMap.value( MARKER_TYPE_PROP ).toString(), - HasColor() ? (Quantity_NameOfColor)GetColor() : qColorFromResources( "point_color", QColor( 255, 255, 0 ) ) ); - } - if ( HasColor() ) { - AISShape->SetShadingColor( (Quantity_NameOfColor)GetColor() ); - AISShape->SetColor( (Quantity_NameOfColor)GetColor() ); - } - else { - // Set line aspect - Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect(); - anAspect->SetColor( qColorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) ); - AISShape->Attributes()->SetLineAspect( anAspect ); - - // Set unfree boundaries aspect - anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); - anAspect->SetColor( qColorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) ); - AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); - AISShape->storeBoundaryColors(); - - // Set free boundaries aspect - anAspect = AISShape->Attributes()->FreeBoundaryAspect(); - anAspect->SetColor( qColorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) ); - AISShape->Attributes()->SetFreeBoundaryAspect( anAspect ); - - // Set wire aspect - anAspect = AISShape->Attributes()->WireAspect(); - anAspect->SetColor( qColorFromResources( "line_color", QColor( 255, 0, 0 ) ) ); - AISShape->Attributes()->SetWireAspect( anAspect ); - - // Set color for edges in shading - AISShape->SetEdgesInShadingColor( qColorFromResources( "edges_in_shading_color", QColor( 255, 255, 0 ) ) ); - - // Set deflection coefficient - AISShape->SetOwnDeviationCoefficient( qMax( deflection, DEFLECTION_MIN ) ); // to avoid to small values of the coefficient - } + // set deflection coefficient + // ... to avoid to small values of the coefficient, its lower value is limited + AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) ); // set texture if ( HasTexture() ) { - AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str())); + // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function + AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) ); AISShape->SetTextureMapOn(); AISShape->DisableTextureModulate(); - AISShape->SetDisplayMode(3); + AISShape->SetDisplayMode( 3 ); } // set line width - if ( HasWidth() ) - AISShape->SetWidth( GetWidth() ); + AISShape->SetWidth( HasWidth() ? + // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function + GetWidth() : + // libe width from properties + propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() ); - // set interactive object - if ( !myIO.IsNull() ) { - AISShape->setIO( myIO ); - AISShape->SetOwner( myIO ); - } - else if ( !myName.empty() ) { - // Workaround to allow selection of temporary objects - static int tempId = 0; - Handle( SALOME_InteractiveObject ) anObj = - new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() ); - AISShape->setIO( anObj ); - AISShape->SetOwner( anObj ); - } - - 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 ); - bool hasColor = false; - SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor); - if ( hasColor && useObjColor ) { - Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); - if ( !material.isPhysical() ) { - AISShape->SetColor( aQuanColor ); - AISShape->SetShadingColor( aQuanColor ); - } - if ( onlyVertex ) { - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetColor( aQuanColor ); - anAspect->SetScale( myScaleOfMarker ); - anAspect->SetTypeOfMarker( myTypeOfMarker ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } - study->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, SalomeApp_Tools::color( aQuanColor ) ); - } - else if ( !hasColor && !isTemporary ) { - //In case if color wasn't defined in the property map of the object - //and GEOM_Object color also wasn't defined get default color from Resource Mgr. - QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ); - Quantity_Color aQuanColor = SalomeApp_Tools::color( col ); - if ( !material.isPhysical() ) { - AISShape->SetShadingColor( aQuanColor ); - } - study->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, col ); - } + // set top-level flag + AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() ); - // ... marker type - if ( useObjMarker ) { - 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; + // set point marker (for vertex / compound of vertices only) + if ( onlyVertex ) { + QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() ); + if ( aList.size() == 2 ) { + // standard marker string contains "TypeOfMarker:ScaleOfMarker" + int aTypeOfMarker = aList[0].toInt(); + double aScaleOfMarker = (aList[1].toInt() + 1) * 0.5; + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); + anAspect->SetScale( aScaleOfMarker ); + anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) ); + anAspect->SetColor( HasColor() ? + // 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() ) ); + AISShape->Attributes()->SetPointAspect( anAspect ); + } + else if ( aList.size() == 1 ) { + // custom marker string contains "IdOfTexture" + int textureId = aList[0].toInt(); + Standard_Integer aWidth, aHeight; #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - Handle(TColStd_HArray1OfByte) aTexture = + Handle(TColStd_HArray1OfByte) aTexture = #else - Handle(Graphic3d_HArray1OfBytes) aTexture = + Handle(Graphic3d_HArray1OfBytes) aTexture = #endif - GeometryGUI::getTexture( study, 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 ); - } - } - else { //Use marker from the preferences - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetScale( myScaleOfMarker ); - anAspect->SetTypeOfMarker( myTypeOfMarker ); - 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 ); - } - } + GeometryGUI::getTexture( study, textureId, aWidth, aHeight ); + if ( !aTexture.IsNull() ) { + static int TextureId = 0; + 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 + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value() ), + ++TextureId, + aWidth, aHeight, + aTexture ); + AISShape->Attributes()->SetPointAspect( aTextureAspect ); } } + } - if ( !isTemporary ) - study->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, material.toProperties() ); - - if ( HasWidth() ) - study->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() ); - if ( HasIsosWidth() ) - study->setObjectProperty( aMgrId, anIO->getEntry(), ISOS_WIDTH_PROP, GetIsosWidth() ); + if ( create && !isTemporary && aMgrId != -1 ) { + // set properties to the study + study->setObjectPropMap( aMgrId, entry, propMap ); } // AISShape->SetName(???); ??? necessary to set name ??? @@ -986,7 +859,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" ) : new GEOM_AISShape ( myShape, "" ); // update shape properties - updateShapeProperties( AISShape ); + updateShapeProperties( AISShape, true ); // add shape to the presentation occPrs->AddObject( AISShape ); @@ -1023,7 +896,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) if ( AISShape->Shape() != myShape ) AISShape->Set( myShape ); // update shape properties - updateShapeProperties( AISShape ); + updateShapeProperties( AISShape, false ); // re-set interactive object if ( !myIO.IsNull() ) { @@ -1091,7 +964,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) theActors->AddItem( aTrh ); } else { - PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type()); + PropMap aDefPropMap = getDefaultPropertyMap(); if(!myIO.IsNull()) { aMgrId = getViewManagerId(myViewFrame); @@ -1101,13 +974,18 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) theActors = vtkActorCollection::New(); GEOM_Actor* aGeomActor = GEOM_Actor::New(); - aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR); + ///////////////////////////////////////////////////////////////////////// + // VSR: for VTK viewer currently deflection coefficient is hardcoded + // due to performance problem + // aGeomActor->SetShape(myShape,aDefPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble(),myType == GEOM_VECTOR); + ///////////////////////////////////////////////////////////////////////// + aGeomActor->SetShape(myShape, VTK_MIN_DEFLECTION, myType == GEOM_VECTOR); theActors->AddItem(aGeomActor); aGeomActor->Delete(); if(useStudy) { aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry); - if(!aPropMap.contains(COLOR_PROP)) + if(!aPropMap.contains(GEOM::propertyName( GEOM::Color ))) useObjCol = true; MergePropertyMaps(aPropMap, aDefPropMap); } @@ -1160,15 +1038,15 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) int aIsos[2]= { 1, 1 }; if(useStudy) { - QString anIsos = aPropMap.value(ISOS_PROP).toString(); - QStringList uv = anIsos.split(DIGIT_SEPARATOR); + QString anIsos = aPropMap.value(GEOM::propertyName( GEOM::NbIsos )).toString(); + QStringList uv = anIsos.split( GEOM::subSectionSeparator() ); aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt(); aGeomGActor->SetNbIsos(aIsos); - aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble()); - SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt()); - SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt()); - aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toBool()); - int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt(); + aGeomGActor->SetOpacity(1.0 - aPropMap.value(GEOM::propertyName( GEOM::Transparency )).toDouble()); + SetWidth(aPropMap.value(GEOM::propertyName( GEOM::LineWidth )).toInt()); + SetIsosWidth(aPropMap.value(GEOM::propertyName( GEOM::IsosWidth )).toInt()); + aGeomGActor->SetVectorMode(aPropMap.value(GEOM::propertyName( GEOM::EdgesDirection )).toBool()); + int aDispModeId = aPropMap.value(GEOM::propertyName( GEOM::DisplayMode )).toInt(); // Specially processing of 'Shading with edges' mode from preferences, // because there is the following enum in VTK viewer: // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4 @@ -1179,13 +1057,18 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) // enum in GEOM_Actor (and further to VTKViewer::Representation enum) aDispModeId++; aGeomGActor->setDisplayMode(aDispModeId); - aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble()); + ///////////////////////////////////////////////////////////////////////// + // VSR: for VTK viewer currently deflection coefficient is hardcoded + // due to performance problem; + // aGeomGActor->SetDeflection(aPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble()); + ///////////////////////////////////////////////////////////////////////// + aGeomGActor->SetDeflection(VTK_MIN_DEFLECTION); // Create material model Material_Model material; - material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() ); + material.fromProperties( aPropMap.value(GEOM::propertyName( GEOM::Material )).toString() ); // Set material properties for the object - aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() ); + aStudy->setObjectProperty( aMgrId, anEntry, GEOM::propertyName( GEOM::Material ), material.toProperties() ); // Set the same front and back materials for the selected shape std::vector aProps; aProps.push_back( material.getMaterialVTKProperty( true ) ); @@ -1214,12 +1097,12 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.; } } - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, QColor( aColor[0] *255, aColor[1] * 255, aColor[2]* 255) ); + aStudy->setObjectProperty( aMgrId, anIO->getEntry(), GEOM::propertyName( GEOM::Color ), QColor( aColor[0] *255, aColor[1] * 255, aColor[2]* 255) ); } } } } else { - QColor c = aPropMap.value(COLOR_PROP).value(); + QColor c = aPropMap.value(GEOM::propertyName( GEOM::Color )).value(); aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.; } @@ -1235,7 +1118,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" ); material.fromResources( mname ); // Set material properties for the object - aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() ); + aStudy->setObjectProperty( aMgrId, anEntry, GEOM::propertyName( GEOM::Material ), material.toProperties() ); // Set material for the selected shape std::vector aProps; aProps.push_back( material.getMaterialVTKProperty( true ) ); @@ -1624,8 +1507,8 @@ void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p ) Handle(SALOME_InteractiveObject) IO = sh->getIO(); if ( IO.IsNull() ) continue; PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() ); - if ( aPropMap.contains( TRANSPARENCY_PROP ) ) { - double transparency = aPropMap.value(TRANSPARENCY_PROP).toDouble(); + if ( aPropMap.contains( GEOM::propertyName( GEOM::Transparency ) ) ) { + double transparency = aPropMap.value(GEOM::propertyName( GEOM::Transparency )).toDouble(); ic->SetTransparency( sh, transparency, true ); } } @@ -1806,12 +1689,12 @@ bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer int GEOM_Displayer::SetDisplayMode( const int theMode ) { int aPrevMode = myDisplayMode; - if ( theMode != -1 ) + if ( theMode != -1 ) { myDisplayMode = theMode; - else - { - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 ); + myHasDisplayMode = true; + } + else { + UnsetDisplayMode(); } return aPrevMode; } @@ -1826,9 +1709,15 @@ int GEOM_Displayer::UnsetDisplayMode() int aPrevMode = myDisplayMode; SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 ); + myHasDisplayMode = false; return aPrevMode; } +bool GEOM_Displayer::HasDisplayMode() const +{ + return myHasDisplayMode; +} + SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor() { static QList colors; @@ -1917,121 +1806,228 @@ SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList& th return aSColor; } +PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study, + const QString& entry, + SALOME_View* view ) +{ + // get default properties for the explicitly specified default view type + PropMap propMap = GEOM_Displayer::getDefaultPropertyMap(); + + if ( study && view ) { + SUIT_ViewModel* viewModel = dynamic_cast( 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->getObjectPropMap( 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 ) ) ) + propMap.insert( GEOM::propertyName( (GEOM::Property)prop ), + storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) ); + } + // ... specific processing for color + // ... current implementation is to use same stored color for all aspects + // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here + if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) { + propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + } + if ( !entry.isEmpty() ) { + // get CORBA reference to geom object + _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) ); + if ( SO ) { + CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO ); + if ( !CORBA::is_nil( object ) ) { + GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object ); + // check that geom object has color properly set + bool hasColor = false; + SALOMEDS::Color aSColor = getColor( geomObject, hasColor ); + // set color from geometry object (only once, if it is not yet set in GUI) + // current implementation is to use same color for all aspects + // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here + if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) { + QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B ); + propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor ); + } + // check that object has point marker properly set + GEOM::marker_type mType = geomObject->GetMarkerType(); + GEOM::marker_size mSize = geomObject->GetMarkerSize(); + int mTextureId = geomObject->GetMarkerTexture(); + bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) || + ( mType == GEOM::MT_USER && mTextureId > 0 ); + // set point marker from geometry object (only once, if it is not yet set in GUI) + if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) { + if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) { + // standard type + propMap.insert( GEOM::propertyName( GEOM::PointMarker ), + QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) ); + } + else if ( mType == GEOM::MT_USER ) { + // custom texture + propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) ); + } + } + } + } + } + } + } + return propMap; +} -PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) +PropMap GEOM_Displayer::getDefaultPropertyMap() { - PropMap aDefaultMap; - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + PropMap propMap; + + // get resource manager + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - //1. Visibility - aDefaultMap.insert( VISIBILITY_PROP, 1 ); + // fill in the properties map with default values - //2. Nb Isos - aDefaultMap.insert( ISOS_PROP, - QString( "%1%2%3" ). - arg( aResMgr->integerValue( "Geometry", "iso_number_u", 1 ) ). - arg( DIGIT_SEPARATOR ). - arg( aResMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) ); + // - visibility (false by default) + propMap.insert( GEOM::propertyName( GEOM::Visibility ), false ); - //3. Transparency - aDefaultMap.insert( TRANSPARENCY_PROP, 0.0 ); + // - nb isos (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::NbIsos ), + QString( "%1%2%3" ). + arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ). + arg( GEOM::subSectionSeparator() ). + arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) ); - //4. Display Mode - aDefaultMap.insert( DISPLAY_MODE_PROP, - aResMgr->integerValue( "Geometry", "display_mode", 0 ) ); + // - transparency (opacity = 1-transparency) + propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 ); - //5. Vector Mode - aDefaultMap.insert( VECTOR_MODE_PROP, false ); + // - display mode (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::DisplayMode ), + resMgr->integerValue( "Geometry", "display_mode", 0 ) ); - //6. Color - aDefaultMap.insert( COLOR_PROP, - aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ) ); + // - show edges direction flag (false by default) + propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false ); - //7. Deflection Coeff - if ( viewer_type == SOCC_Viewer::Type() ) { - aDefaultMap.insert( DEFLECTION_COEFF_PROP, - aResMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) ); - } - else { - aDefaultMap.insert( DEFLECTION_COEFF_PROP, 0.001 ); - } + // - shading color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), + colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) ); + + // - wireframe color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), + colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) ); + + // - standalone edges color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::LineColor ), + colorFromResources( "line_color", QColor( 255, 0, 0 ) ) ); - //8. Material + // - free boundaries color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), + colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) ); + + // - points color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::PointColor ), + colorFromResources( "point_color", QColor( 255, 255, 0 ) ) ); + + // - isos color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::IsosColor ), + colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) ); + + // - outlines color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::OutlineColor ), + colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) ); + + // - deflection coefficient (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::Deflection ), + resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) ); + + // - material (take default value from preferences) Material_Model material; - material.fromResources( aResMgr->stringValue( "Geometry", "material", "Plastic" ) ); - aDefaultMap.insert( MATERIAL_PROP, material.toProperties() ); + material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) ); + propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() ); + + // - edge width (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::LineWidth ), + resMgr->integerValue( "Geometry", "edge_width", 1 ) ); - //9. Width of the edges - aDefaultMap.insert( EDGE_WIDTH_PROP, - aResMgr->integerValue( "Geometry", "edge_width", 1 ) ); + // - isos width (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::IsosWidth ), + resMgr->integerValue( "Geometry", "isolines_width", 1 ) ); - //10. Width of iso-lines - aDefaultMap.insert( ISOS_WIDTH_PROP, - aResMgr->integerValue( "Geometry", "isolines_width", 1 ) ); + // - point marker (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::PointMarker ), + QString( "%1%2%3" ). + arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ). + arg( GEOM::subSectionSeparator() ). + arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) ); - //11. Top-level flag - aDefaultMap.insert( TOP_LEVEL_PROP, Standard_False ); + // - top-level flag (false by default) + propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false ); - return aDefaultMap; + return propMap; } bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault) { int nbInserted = 0; - if(!theOrigin.contains(VISIBILITY_PROP)) { - theOrigin.insert(VISIBILITY_PROP, 0); + if(!theOrigin.contains(GEOM::propertyName( GEOM::Visibility ))) { + theOrigin.insert(GEOM::propertyName( GEOM::Visibility ), 0); nbInserted++; } - if(!theOrigin.contains(TRANSPARENCY_PROP)) { - theOrigin.insert(TRANSPARENCY_PROP, theDefault.value(TRANSPARENCY_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::Transparency ))) { + theOrigin.insert(GEOM::propertyName( GEOM::Transparency ), theDefault.value(GEOM::propertyName( GEOM::Transparency ))); nbInserted++; } - if(!theOrigin.contains(DISPLAY_MODE_PROP)) { - theOrigin.insert(DISPLAY_MODE_PROP, theDefault.value(DISPLAY_MODE_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::DisplayMode ))) { + theOrigin.insert(GEOM::propertyName( GEOM::DisplayMode ), theDefault.value(GEOM::propertyName( GEOM::DisplayMode ))); nbInserted++; } - if(!theOrigin.contains(ISOS_PROP)) { - theOrigin.insert(ISOS_PROP, theDefault.value(ISOS_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::NbIsos ))) { + theOrigin.insert(GEOM::propertyName( GEOM::NbIsos ), theDefault.value(GEOM::propertyName( GEOM::NbIsos ))); nbInserted++; } - if(!theOrigin.contains(VECTOR_MODE_PROP)) { - theOrigin.insert(VECTOR_MODE_PROP, theDefault.value(VECTOR_MODE_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::EdgesDirection ))) { + theOrigin.insert(GEOM::propertyName( GEOM::EdgesDirection ), theDefault.value(GEOM::propertyName( GEOM::EdgesDirection ))); nbInserted++; } - if(!theOrigin.contains(DEFLECTION_COEFF_PROP)) { - theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::Deflection ))) { + theOrigin.insert(GEOM::propertyName( GEOM::Deflection ), theDefault.value(GEOM::propertyName( GEOM::Deflection ))); nbInserted++; } - if(!theOrigin.contains(MATERIAL_PROP)) { - theOrigin.insert(MATERIAL_PROP, theDefault.value(MATERIAL_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::Material ))) { + theOrigin.insert(GEOM::propertyName( GEOM::Material ), theDefault.value(GEOM::propertyName( GEOM::Material ))); nbInserted++; } - if(!theOrigin.contains(EDGE_WIDTH_PROP)) { - theOrigin.insert(EDGE_WIDTH_PROP, theDefault.value(EDGE_WIDTH_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::LineWidth ))) { + theOrigin.insert(GEOM::propertyName( GEOM::LineWidth ), theDefault.value(GEOM::propertyName( GEOM::LineWidth ))); nbInserted++; } - if(!theOrigin.contains(ISOS_WIDTH_PROP)) { - theOrigin.insert(ISOS_WIDTH_PROP, theDefault.value(ISOS_WIDTH_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::IsosWidth ))) { + theOrigin.insert(GEOM::propertyName( GEOM::IsosWidth ), theDefault.value(GEOM::propertyName( GEOM::IsosWidth ))); nbInserted++; } - if(!theOrigin.contains(COLOR_PROP)) { - theOrigin.insert(COLOR_PROP, theDefault.value(COLOR_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::Color ))) { + theOrigin.insert(GEOM::propertyName( GEOM::Color ), theDefault.value(GEOM::propertyName( GEOM::Color ))); nbInserted++; } - if(!theOrigin.contains(TOP_LEVEL_PROP)) { - theOrigin.insert(TOP_LEVEL_PROP, theDefault.value(TOP_LEVEL_PROP)); + if(!theOrigin.contains(GEOM::propertyName( GEOM::TopLevel ))) { + theOrigin.insert(GEOM::propertyName( GEOM::TopLevel ), theDefault.value(GEOM::propertyName( GEOM::TopLevel ))); nbInserted++; } diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index be3fc0477..62d98f62e 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -145,7 +145,7 @@ public: int SetDisplayMode( const int ); int GetDisplayMode() const; int UnsetDisplayMode(); - + bool HasDisplayMode() const; /* Sets name - for temporary objects only */ void SetName( const char* theName ); @@ -172,10 +172,6 @@ public: static SALOMEDS::Color getUniqueColor( const QList& ); static SALOMEDS::Color getPredefinedUniqueColor(); - static PropMap getDefaultPropertyMap(const QString& viewer_type); - - static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault); - /*Get color of the geom object*/ static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor); @@ -213,7 +209,13 @@ protected: Quantity_Color qColorFromResources( const QString&, const QColor& ); QColor colorFromResources( const QString&, const QColor& ); bool setPointMarker( const Handle(GEOM_AISShape)&, const QString&, const Quantity_Color ); - void updateShapeProperties( const Handle(GEOM_AISShape)& ); + void updateShapeProperties( const Handle(GEOM_AISShape)&, bool ); + + PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 ); + PropMap getDefaultPropertyMap(); + + static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault); + protected: Handle(SALOME_InteractiveObject) myIO; @@ -230,6 +232,7 @@ protected: int myIsosWidth; bool myToActivate; int myDisplayMode; + bool myHasDisplayMode; Aspect_TypeOfMarker myTypeOfMarker; double myScaleOfMarker; diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 73caf9f34..048e9d3ea 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1728,7 +1728,7 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& if ( anApp && anApp->activeViewManager() ) { LightApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); if( aStudy ) { - v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), MATERIAL_PROP, QVariant() ); + v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() ); } } QString curModel = ""; @@ -1934,7 +1934,7 @@ void GeometryGUI::createPreferences() setPreferenceProperty( step, "precision", 3 ); // Set property for deflection value for spinboxes - setPreferenceProperty( defl, "min", DEFLECTION_MIN ); + setPreferenceProperty( defl, "min", GEOM::minDeflection() ); setPreferenceProperty( defl, "max", 1.0 ); setPreferenceProperty( defl, "step", 1.0e-04 ); setPreferenceProperty( defl, "precision", 6 ); @@ -2083,83 +2083,82 @@ void GeometryGUI::storeVisualParameters (int savePoint) if (!obj->FindAttribute(anAttr, "AttributeIOR")) continue; - std::string param,occParam = vType.toLatin1().data(); - occParam += NAME_SEPARATOR; - occParam += QString::number(aMgrId).toLatin1().data(); - occParam += NAME_SEPARATOR; + QString param, occParam = vType; + occParam += GEOM::sectionSeparator(); + occParam += QString::number(aMgrId); + occParam += GEOM::sectionSeparator(); - if (aProps.contains(VISIBILITY_PROP)) { - param = occParam + VISIBILITY_PROP; - ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off"); + if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) { + param = occParam + GEOM::propertyName( GEOM::Visibility ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off"); } - if (aProps.contains(DISPLAY_MODE_PROP)) { - param = occParam + DISPLAY_MODE_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) { + param = occParam + GEOM::propertyName( GEOM::DisplayMode ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString()); } - if (aProps.contains(COLOR_PROP)) { - QColor c = aProps.value(COLOR_PROP).value(); - QString colorStr = QString::number(c.red()/255.); - colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.); - colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.); - param = occParam + COLOR_PROP; - ip->setParameter(entry, param, colorStr.toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Color ))) { + QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value(); + QStringList val; + val << QString::number(c.redF()); + val << QString::number(c.greenF()); + val << QString::number(c.blueF()); + param = occParam + GEOM::propertyName( GEOM::Color ); + ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString()); } if (vType == SVTK_Viewer::Type()) { - if (aProps.contains(OPACITY_PROP)) { - param = occParam + OPACITY_PROP; - ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) { + param = occParam + GEOM::propertyName( GEOM::Opacity ); + ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString()); } } else if (vType == SOCC_Viewer::Type()) { - if (aProps.contains(TRANSPARENCY_PROP)) { - param = occParam + TRANSPARENCY_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) { + param = occParam + GEOM::propertyName( GEOM::Transparency ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString()); } - if (aProps.contains(TOP_LEVEL_PROP)) { - param = occParam + TOP_LEVEL_PROP; - Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value(); - if (val == Standard_True) - ip->setParameter(entry, param, "1"); + if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) { + param = occParam + GEOM::propertyName( GEOM::TopLevel ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString()); } } - if (aProps.contains(ISOS_PROP)) { - param = occParam + ISOS_PROP; - ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) { + param = occParam + GEOM::propertyName( GEOM::NbIsos ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString()); } - if (aProps.contains(VECTOR_MODE_PROP)) { - param = occParam + VECTOR_MODE_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) { + param = occParam + GEOM::propertyName( GEOM::EdgesDirection ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString()); } - if (aProps.contains(DEFLECTION_COEFF_PROP)) { - param = occParam + DEFLECTION_COEFF_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) { + param = occParam + GEOM::propertyName( GEOM::Deflection ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString()); } //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex" - if (aProps.contains(MARKER_TYPE_PROP)) { - param = occParam + MARKER_TYPE_PROP; - ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) { + param = occParam + GEOM::propertyName( GEOM::PointMarker ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString()); } - if (aProps.contains(MATERIAL_PROP)) { - param = occParam + MATERIAL_PROP; - ip->setParameter(entry, param, aProps.value(MATERIAL_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Material ))) { + param = occParam + GEOM::propertyName( GEOM::Material ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString()); } - if (aProps.contains(EDGE_WIDTH_PROP)) { - param = occParam + EDGE_WIDTH_PROP; - ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) { + param = occParam + GEOM::propertyName( GEOM::LineWidth ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString()); } - if (aProps.contains(ISOS_WIDTH_PROP)) { - param = occParam + ISOS_WIDTH_PROP; - ip->setParameter(entry, param, aProps.value(ISOS_WIDTH_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) { + param = occParam + GEOM::propertyName( GEOM::IsosWidth ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString()); } } // object iterator } // for (views) @@ -2222,7 +2221,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) { // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName. // '_' is used as separator and should not be used in viewer type or parameter names. - QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts); + QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts); if (lst.size() != 3) continue; @@ -2240,36 +2239,36 @@ void GeometryGUI::restoreVisualParameters (int savePoint) } QString val((*valuesIt).c_str()); - if (paramNameStr == VISIBILITY_PROP) { - aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0); - } else if (paramNameStr == OPACITY_PROP) { - aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble()); - } else if (paramNameStr == TRANSPARENCY_PROP) { - aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val.toDouble() ); - } else if (paramNameStr == TOP_LEVEL_PROP) { - aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False ); - } else if (paramNameStr == DISPLAY_MODE_PROP) { - aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt()); - } else if (paramNameStr == ISOS_PROP) { - aListOfMap[viewIndex].insert( ISOS_PROP, val); - } else if (paramNameStr == COLOR_PROP) { - QStringList rgb = val.split(DIGIT_SEPARATOR); + if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) { + aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On"); + } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) { + aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble()); + } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() ); + } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val.toInt() ? Standard_True : Standard_False ); + } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt()); + } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val); + } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) { + QStringList rgb = val.split(GEOM::subSectionSeparator()); if (rgb.count() == 3) { - QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255)); - aListOfMap[viewIndex].insert( COLOR_PROP, c); + QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble()); + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c); } - } else if (paramNameStr == VECTOR_MODE_PROP) { - aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt()); - } else if (paramNameStr == DEFLECTION_COEFF_PROP) { - aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble()); - } else if (paramNameStr == MARKER_TYPE_PROP) { - aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val); - } else if (paramNameStr == MATERIAL_PROP) { - aListOfMap[viewIndex].insert( MATERIAL_PROP, val); - } else if (paramNameStr == EDGE_WIDTH_PROP) { - aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP, val); - } else if (paramNameStr == ISOS_WIDTH_PROP) { - aListOfMap[viewIndex].insert( ISOS_WIDTH_PROP, val); + } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val.toInt()); + } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble()); + } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val); + } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val); + } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt()); + } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt()); } } // for names/parameters iterator @@ -2280,7 +2279,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) appStudy->setObjectPropMap(index, entry, aListOfMap[index]); //Get Visibility property of the current PropMap - if (aListOfMap[index].value(VISIBILITY_PROP) == 1) { + if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) { SUIT_ViewManager* vman = lst.at(index); SUIT_ViewModel* vmodel = vman->getViewModel(); displayer()->Display(entry, true, dynamic_cast(vmodel)); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index ac3e8f5b4..a7d0252cc 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -301,8 +301,8 @@ void GEOMToolsGUI::SetColor( const QString& entry, const QColor& color, bool upd SUIT_ViewWindow* window = app->desktop()->activeWindow(); if ( !window ) return; - bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); - bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); + bool isOCC = window->getViewManager()->getType() == OCCViewer_Viewer::Type(); + bool isVTK = window->getViewManager()->getType() == SVTK_Viewer::Type(); // get view id int mgrId = window->getViewManager()->getGlobalId(); @@ -357,7 +357,7 @@ void GEOMToolsGUI::OnColor() bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); // get view id - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; if ( isVTK ) { SVTK_ViewWindow* vtkVW = dynamic_cast( window ); @@ -366,7 +366,7 @@ void GEOMToolsGUI::OnColor() // get initial color (use first object from selection) SVTK_View* aView = vtkVW->getView(); QColor color = aView->GetColor( selected.First() ); - QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color ); + QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color ); // show Choose Color dialog box color = QColorDialog::getColor( v.value(), app->desktop() ); @@ -390,7 +390,7 @@ void GEOMToolsGUI::OnColor() QColor color = QColor((int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 )); - QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color ); + QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color ); // show Choose Color dialog box color = QColorDialog::getColor( v.value(), app->desktop() ); @@ -422,14 +422,14 @@ void GEOMToolsGUI::setVtkColor( SalomeApp_Study* study, // s { // get material property QString matProp; - matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString(); + matProp = study->getObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Material ), matProp ).toString(); Material_Model material; material.fromProperties( matProp ); // change color only for shapes with not physical type of material if ( !material.isPhysical() ) { view->SetColor( IO, color ); - study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color ); + study->setObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Color ), color ); } // store color to GEOM_Object @@ -462,7 +462,7 @@ void GEOMToolsGUI::setOccColor( SalomeApp_Study* study, // s // get material property QString matProp; - matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString(); + matProp = study->getObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Material ), matProp ).toString(); Material_Model material; material.fromProperties( matProp ); @@ -507,7 +507,7 @@ void GEOMToolsGUI::setOccColor( SalomeApp_Study* study, // s io->Redisplay( Standard_True ); - study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color ); + study->setObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Color ), color ); } // store color to GEOM_Object @@ -664,6 +664,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + int aMgrId = window->getViewManager()->getGlobalId(); ic->InitCurrent(); if ( ic->MoreCurrent() ) { @@ -705,12 +706,11 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) } for(; ic->MoreCurrent(); ic->NextCurrent()) { - int aMgrId = window->getViewManager()->getGlobalId(); CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); - QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() ); + QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ) , QVariant() ); int width = v.isValid() ? v.toInt() : 1; @@ -722,8 +722,8 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) ic->SetLocalAttributes(CurObject, CurDrawer); ic->Redisplay(CurObject); - QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso); - aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_PROP, anIsos); + QString anIsos = QString("%1%2%3").arg(newNbUIso).arg(GEOM::subSectionSeparator()).arg(newNbVIso); + aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos); } } GeometryGUI::Modified(); @@ -748,6 +748,8 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) if ( !vtkVW ) return; + int aMgrId = window->getViewManager()->getGlobalId(); + SALOME_View* view = GEOM_Displayer::GetActiveView(); vtkActorCollection* aCollection = vtkActorCollection::New(); @@ -817,9 +819,8 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) anActor->SetNbIsos(aIsos); anActor->StoreIsoNumbers(); - QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso); - int aMgrId = window->getViewManager()->getGlobalId(); - aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos); + QString anIsos = QString("%1%2%3").arg(newNbUIso).arg(GEOM::subSectionSeparator()).arg(newNbVIso); + aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos); } anAct = aCollection->GetNextActor(); } @@ -836,7 +837,7 @@ void GEOMToolsGUI::OnDeflection() bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; if (isOCC) { // if is OCCViewer OCCViewer_Viewer* vm = dynamic_cast(window->getViewManager()->getViewModel()); @@ -866,7 +867,7 @@ void GEOMToolsGUI::OnDeflection() CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True); ic->Redisplay(CurObject); - appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC); + appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::Deflection ), aNewDC); } } } @@ -935,7 +936,7 @@ void GEOMToolsGUI::OnDeflection() if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { // There are no casting to needed actor. anActor->SetDeflection(aDC); - appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC); + appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::Deflection ), aDC); } anAct = aCollection->GetNextActor(); } @@ -1103,7 +1104,7 @@ void GEOMToolsGUI::OnEdgeWidth() bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; if (isOCC) { // if is OCCViewer OCCViewer_Viewer* vm = dynamic_cast(window->getViewManager()->getViewModel()); @@ -1136,7 +1137,7 @@ void GEOMToolsGUI::OnEdgeWidth() ic->Redisplay(cur); } } - appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth); + appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aNewWidth); } } } @@ -1205,7 +1206,7 @@ void GEOMToolsGUI::OnEdgeWidth() if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { // There are no casting to needed actor. anActor->SetWidth(aWidth); - appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth); + appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aWidth); } anAct = aCollection->GetNextActor(); } @@ -1228,6 +1229,7 @@ void GEOMToolsGUI::OnIsosWidth() { OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + int aMgrId = window->getViewManager()->getGlobalId(); ic->InitCurrent(); if ( ic->MoreCurrent() ) { @@ -1256,7 +1258,6 @@ void GEOMToolsGUI::OnIsosWidth() { return; for(; ic->MoreCurrent(); ic->NextCurrent()) { - int aMgrId = window->getViewManager()->getGlobalId(); CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); @@ -1266,7 +1267,7 @@ void GEOMToolsGUI::OnIsosWidth() { ic->Redisplay(CurObject); - aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth); + aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth); } GeometryGUI::Modified(); } @@ -1291,6 +1292,8 @@ void GEOMToolsGUI::OnIsosWidth() { if ( !vtkVW ) return; + int aMgrId = window->getViewManager()->getGlobalId(); + SALOME_View* view = GEOM_Displayer::GetActiveView(); vtkActorCollection* aCollection = vtkActorCollection::New(); @@ -1335,8 +1338,7 @@ void GEOMToolsGUI::OnIsosWidth() { if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { // There are no casting to needed actor. anActor->SetIsosWidth(aWidth); - int aMgrId = window->getViewManager()->getGlobalId(); - aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth); + aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth); } anAct = aCollection->GetNextActor(); } @@ -1387,15 +1389,15 @@ void GEOMToolsGUI::OnBringToFront() { if ( isOCC ) { GEOMBase* gb = new GEOMBase(); Handle(GEOM_AISShape) aisShape; + int aMgrId = window->getViewManager()->getGlobalId(); Handle(AIS_InteractiveContext) ic = vm->getAISContext(); SALOME_ListIO anIOlst; for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true ); if ( !aisShape.IsNull() ) { + appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), GEOM::propertyName( GEOM::TopLevel ), checked ); aisShape->setTopLevel(checked); - int aMgrId = window->getViewManager()->getGlobalId(); - appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked ); anIOlst.Append(aisShape->getIO()); } } // for... @@ -1432,6 +1434,7 @@ void GEOMToolsGUI::OnClsBringToFront() { OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + int aMgrId = window->getViewManager()->getGlobalId(); SALOME_ListIO anIOlst; AIS_ListOfInteractive aList; @@ -1443,10 +1446,8 @@ void GEOMToolsGUI::OnClsBringToFront() { if(CurObject.IsNull()) continue; + appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), GEOM::propertyName( GEOM::TopLevel ), Standard_False ); CurObject->setTopLevel(Standard_False); - - int aMgrId = window->getViewManager()->getGlobalId(); - appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False ); anIOlst.Append(CurObject->getIO()); } disp->Redisplay(anIOlst); @@ -1476,7 +1477,7 @@ void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam ) if ( selected.IsEmpty() ) return; SUIT_ViewWindow* window = app->desktop()->activeWindow(); - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; // convert needed material properties to the string representation Material_Model aModel; @@ -1501,7 +1502,7 @@ void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam ) // set material property to the presentation aView->SetMaterial( It.Value(), vtkPropF, vtkPropB ); // store chosen material in the property map - study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); // set correct color for the non-physical material } aView->Repaint(); @@ -1533,7 +1534,7 @@ void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam ) // Return to the default facing mode aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE); // store chosen material in the property map - study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); //if ( aisShape->DisplayMode() != AIS_Shaded) ic->Redisplay( aisShape, Standard_False ); } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx index 428c91c47..48cfb2b0b 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx @@ -78,7 +78,7 @@ GEOMToolsGUI_DeflectionDlg::GEOMToolsGUI_DeflectionDlg (QWidget* parent) SpinBox->setAcceptNames( false ); SpinBox->setPrecision( aPrecision ); SpinBox->setDecimals( aPrecision ); - SpinBox->setRange( DEFLECTION_MIN, 1.0 ); + SpinBox->setRange( GEOM::minDeflection(), 1.0 ); SpinBox->setSingleStep( 1.0e-04 ); // Add a hint for the user saying how to tune precision QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx index 4ba147b78..7a1952ad6 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx @@ -228,13 +228,13 @@ void GEOMToolsGUI_MarkerDlg::accept() anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() ); QString aMarker = "%1%2%3"; aMarker = aMarker.arg(getMarkerType()); - aMarker = aMarker.arg(DIGIT_SEPARATOR); + aMarker = aMarker.arg(GEOM::subSectionSeparator()); aMarker = aMarker.arg(getStandardMarkerScale()); - getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, aMarker); + getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),GEOM::propertyName( GEOM::PointMarker ), aMarker); } else if ( getCustomMarkerID() > 0 ) { anObject->SetMarkerTexture( getCustomMarkerID() ); - getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, QString::number(getCustomMarkerID())); + getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),GEOM::propertyName( GEOM::PointMarker ), QString::number(getCustomMarkerID())); } } } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx index dc00889c8..61c7c763d 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx @@ -329,10 +329,10 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* if ( window ) { int mgrId = window->getViewManager()->getGlobalId(); PropMap propMap = study->getObjectPropMap( mgrId, io->getEntry() ); - QString matProp = propMap.value(MATERIAL_PROP).toString(); + QString matProp = propMap.value(GEOM::propertyName( GEOM::Material )).toString(); if ( !matProp.isEmpty() ) myCurrentModel.fromProperties( matProp ); - QColor c = propMap.value(COLOR_PROP).value(); + QColor c = propMap.value(GEOM::propertyName( GEOM::Color )).value(); if ( c.isValid() ) myColor->setColor( c ); } @@ -500,11 +500,11 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply() // set material property to the presentation aView->SetMaterial( It.Value(), vtkPropF, vtkPropB ); // store chosen material in the property map - study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); // set correct color for the non-physical material if ( !myCurrentModel.isPhysical() ) { aView->SetColor( It.Value(), myColor->color() ); - study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Color ), myColor->color() ); } } aView->Repaint(); @@ -536,11 +536,11 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply() // Return to the default facing mode aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE); // store chosen material in the property map - study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); // set correct color for the non-physical material if ( !myCurrentModel.isPhysical() ) { aisShape->SetShadingColor( SalomeApp_Tools::color( myColor->color() ) ); - study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Color ), myColor->color() ); ic->RecomputePrsOnly( aisShape, Standard_False ); } //if ( aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/) diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx index 3bcbc16ea..55f7c92d2 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx @@ -286,7 +286,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() SUIT_OverrideCursor(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { aView->SetTransparency( It.Value(), newValue ); - aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue ); + aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), GEOM::propertyName( GEOM::Transparency ) , newValue ); } GeometryGUI::Modified(); aView->Repaint(); @@ -317,7 +317,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() if ( !aisShape.IsNull() ) { ic->SetTransparency( aisShape, newValue, false ); ic->Redisplay( aisShape, Standard_False, Standard_True ); - aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue ); + aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), GEOM::propertyName( GEOM::Transparency ) , newValue ); } } // for... ic->UpdateCurrentViewer(); diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index 6e731d256..63e8d187b 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -166,8 +166,6 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect); myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect); } - myCurrentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - myCurrentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); } void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){ @@ -207,7 +205,7 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent Handle(AIS_InteractiveContext) anIC = GetContext(); // StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode; - bool isTopLev = (isTopLevel() && topLevelDisplayMode() != TopShowAdditionalWActor); + bool isTopLev = isTopLevel() && switchTopLevel(); switch (aMode) { case 0://StdSelect_DM_Wireframe: { @@ -317,26 +315,6 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent // aPrs->ReCompute(); // for hidden line recomputation if necessary... } -void GEOM_AISShape::SetTransparency(const Standard_Real aValue) -{ - if(aValue<0.0 || aValue>1.0) return; - - if(aValue<=0.05) - { - UnsetTransparency(); - return; - } - - Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); - FMat.SetTransparency(aValue); - myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat); - myCurrentFrontMaterial = FMat; - myCurrentBackMaterial = BMat; - myTransparency = aValue; -} - void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol) { myShadingColor = aCol; @@ -390,17 +368,13 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn(); Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC); - aMatAspect.SetTransparency(myTransparency); - myCurrentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - myCurrentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); - myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : myCurrentFrontMaterial ); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial( isTopLevel() ? aMatAspect : myCurrentBackMaterial ); - - //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); - // P->SetPrimitivesAspect(a4bis); - // G->SetGroupPrimitivesAspect(a4bis); - //a4bis->SetInteriorColor(myShadingColor); - if( isTopLevel() && topLevelDisplayMode() != TopShowAdditionalWActor ) + aMatAspect.SetTransparency(Transparency()); + Graphic3d_MaterialAspect currentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); + Graphic3d_MaterialAspect currentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); + myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : currentFrontMaterial ); + myDrawer->ShadingAspect()->Aspect()->SetBackMaterial ( isTopLevel() ? aMatAspect : currentBackMaterial ); + + if( isTopLevel() && switchTopLevel() ) myDrawer->ShadingAspect()->SetColor( topLevelColor() ); else { if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT )) diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx index 437193822..5bd38ac77 100644 --- a/src/OBJECT/GEOM_AISShape.hxx +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -116,7 +116,6 @@ public: void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); ~GEOM_AISShape(); - void SetTransparency(const Standard_Real aValue); void SetShadingColor(const Quantity_Color &aCol); void SetEdgesInShadingColor(const Quantity_Color &aCol); void SetDisplayVectors(bool isShow); @@ -172,8 +171,6 @@ private: TCollection_AsciiString myName; bool myDisplayVectors; Standard_Boolean myTopLevel; - Graphic3d_MaterialAspect myCurrentFrontMaterial; - Graphic3d_MaterialAspect myCurrentBackMaterial; Standard_Integer myPrevDisplayMode; static TopLevelDispMode myTopLevelDm; diff --git a/src/OBJECT/GEOM_Constants.cxx b/src/OBJECT/GEOM_Constants.cxx new file mode 100644 index 000000000..aa1b7ec04 --- /dev/null +++ b/src/OBJECT/GEOM_Constants.cxx @@ -0,0 +1,102 @@ +// Copyright (C) 2007-2012 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 +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOM_Constants.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "GEOM_Constants.h" + +namespace GEOM +{ + + /*! + \brief Get minimal allowed value for deflection coefficient + */ + double minDeflection() + { + return 1e-06; // DEFLECTION_MIN + } + + /*! + \brief Get character used to separate parameter names + */ + QString sectionSeparator() + { + return "_"; // NAME_SEPARATOR + } + + /*! + \brief Get character used to separate numeric parameter values (color = r:g:b) + */ + QString subSectionSeparator() + { + return ":"; // DIGIT_SEPARATOR + } + + QString propertyName( Property type ) + { + static const char* names[] = { + // visibility + "Visibility", // VISIBILITY_PROP + // transparency + "Transparency", // TRANSPARENCY_PROP + // display mode + "DisplayMode", // DISPLAY_MODE_PROP + // number of the iso lines (along u and v directions) + "Isos", // ISOS_PROP + // main / shading color + "Color", // COLOR_PROP + // "show edges direction" flag + "VectorMode", // VECTOR_MODE_PROP + // deflection coefficient + "DeflectionCoeff", // DEFLECTION_COEFF_PROP + // point marker data + "MarkerType", // MARKER_TYPE_PROP + // material + "Material", // MATERIAL_PROP + // general line width + "EdgeWidth", // EDGE_WIDTH_PROP + // isos width + "IsosWidth", // ISOS_WIDTH_PROP + // top-level flag + "TopLevelFlag", // TOP_LEVEL_PROP + // opacity + "Opacity", // OPACITY_PROP + // shading color + "ShadingColor", // - + // wireframe color + "WireframeColor", // - + // standalone edges color + "LineColor", // - + // free boundaries color + "FreeBndColor", // - + // points color + "PointColor", // - + // isos color + "IsosColor", // - + // outlines color + "OutlineColor", // - + }; + return ( type >= GEOM::Visibility && type <= GEOM::LastProperty ) ? names[type] : QString(); + } + +} // namespace GEOM diff --git a/src/OBJECT/GEOM_Constants.h b/src/OBJECT/GEOM_Constants.h index b890379e3..178ea2bfe 100644 --- a/src/OBJECT/GEOM_Constants.h +++ b/src/OBJECT/GEOM_Constants.h @@ -21,31 +21,47 @@ // // File : GEOM_Constants.h -// Author : Margarita KARPUNINA -// Module : GEOM -// +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + #ifndef GEOM_CONSTANTS_H #define GEOM_CONSTANTS_H -// minimum allowed value for deflection coefficient -#define DEFLECTION_MIN 1e-06 +#include + +namespace GEOM +{ + enum Property { + Visibility, + Transparency, + DisplayMode, + NbIsos, + Color, + EdgesDirection, + Deflection, + PointMarker, + Material, + LineWidth, + IsosWidth, + TopLevel, + LastStudyProperty = TopLevel, + Opacity, + ShadingColor, + WireframeColor, + LineColor, + FreeBndColor, + PointColor, + IsosColor, + OutlineColor, + LastProperty = OutlineColor, + }; -//Define separators -#define NAME_SEPARATOR '_' // character used to separate parameter names -#define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b) + double minDeflection(); + + QString sectionSeparator(); + QString subSectionSeparator(); -#define VISIBILITY_PROP "Visibility" //Object visibility property -#define OPACITY_PROP "Opacity" //Object opacity property -#define TRANSPARENCY_PROP "Transparency" //Object transparency property -#define DISPLAY_MODE_PROP "DisplayMode" //Object display mode property -#define ISOS_PROP "Isos" //Number of the Isos property of the object -#define COLOR_PROP "Color" //Color of the object -#define VECTOR_MODE_PROP "VectorMode" //Vector mode property -#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property -#define MARKER_TYPE_PROP "MarkerType" //Marker type property -#define MATERIAL_PROP "Material" //Object material property -#define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge -#define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines -#define TOP_LEVEL_PROP "TopLevelFlag" //Top level flag + QString propertyName( Property ); +} + #endif //GEOM_CONSTANTS_H diff --git a/src/OBJECT/GEOM_TopWireframeShape.cxx b/src/OBJECT/GEOM_TopWireframeShape.cxx index f22b3197f..4729ecfda 100755 --- a/src/OBJECT/GEOM_TopWireframeShape.cxx +++ b/src/OBJECT/GEOM_TopWireframeShape.cxx @@ -56,6 +56,10 @@ GEOM_TopWireframeShape::GEOM_TopWireframeShape(const TopoDS_Shape& shape) SetColor(GEOM_AISShape::topLevelColor()); } +GEOM_TopWireframeShape::~GEOM_TopWireframeShape() +{ +} + Handle(SALOME_InteractiveObject) GEOM_TopWireframeShape::getIO(){ Handle(SALOME_InteractiveObject) IO; if ( !GetOwner().IsNull() ) diff --git a/src/OBJECT/GEOM_TopWireframeShape.ixx b/src/OBJECT/GEOM_TopWireframeShape.ixx index 1fd891967..a4f1408d6 100755 --- a/src/OBJECT/GEOM_TopWireframeShape.ixx +++ b/src/OBJECT/GEOM_TopWireframeShape.ixx @@ -30,8 +30,6 @@ #include #endif -GEOM_TopWireframeShape::~GEOM_TopWireframeShape() {} - Standard_EXPORT Handle_Standard_Type& GEOM_TopWireframeShape_Type_() { diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index ae48a97f8..b59d98914 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -65,7 +65,8 @@ dist_libGEOMObject_la_SOURCES = \ GEOM_VTKPropertyMaterial.cxx \ GEOM_AISVector.cxx \ GEOM_PainterPolyDataMapper.cxx \ - GEOM_DeviceActor.cxx + GEOM_DeviceActor.cxx \ + GEOM_Constants.cxx libGEOMObject_la_CPPFLAGS = \