diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index 33408d64b2..52ef7c6cd6 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -300,9 +300,9 @@ void AIS_InteractiveObject::UnsetMaterial() //======================================================================= //function : SetTransparency -//purpose : +//purpose : //======================================================================= -void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue) +void AIS_InteractiveObject::SetTransparency (const Standard_Real theValue) { if (!myDrawer->HasOwnShadingAspect()) { @@ -310,12 +310,10 @@ void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue) if(myDrawer->HasLink()) myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link())); } - Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); - FMat.SetTransparency(aValue); BMat.SetTransparency(aValue); - myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat); - myDrawer->SetTransparency ((Standard_ShortReal )aValue); + + myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue)); + myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (Standard_ShortReal(theValue)); + myDrawer->SetTransparency (Standard_ShortReal(theValue)); } //======================================================================= @@ -326,11 +324,8 @@ void AIS_InteractiveObject::UnsetTransparency() { if(HasColor() || HasMaterial() ) { - Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); - FMat.SetTransparency(0.); BMat.SetTransparency(0.); - myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat); + myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (0.0f); + myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (0.0f); } else{ Handle (Prs3d_ShadingAspect) SA; diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index bff45ce08f..0899a8308a 100644 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -611,18 +611,15 @@ void AIS_Plane::ComputeFields() void AIS_Plane::InitDrawerAttributes() { - Handle(Prs3d_ShadingAspect) shasp = new Prs3d_ShadingAspect(); shasp->SetMaterial(Graphic3d_NOM_PLASTIC); shasp->SetColor(Quantity_NOC_GRAY40); myDrawer->SetShadingAspect(shasp); Handle(Graphic3d_AspectFillArea3d) asf = shasp->Aspect(); Graphic3d_MaterialAspect asp = asf->FrontMaterial(); - asp.SetTransparency(0.8); + asp.SetTransparency (0.8f); asf->SetFrontMaterial(asp); asf->SetBackMaterial(asp); - - } //======================================================================= diff --git a/src/AIS/AIS_PointCloud.cxx b/src/AIS/AIS_PointCloud.cxx index 94460aa1ed..f603024f8d 100644 --- a/src/AIS/AIS_PointCloud.cxx +++ b/src/AIS/AIS_PointCloud.cxx @@ -250,7 +250,7 @@ void AIS_PointCloud::UnsetColor() if (IsTransparent()) { Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel); - aMat.SetTransparency (aTransp); + aMat.SetTransparency (Standard_ShortReal(aTransp)); } myDrawer->ShadingAspect()->SetMaterial (aMat, myCurrentFacingModel); } diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 484a33c968..f0a4dd698d 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -642,7 +642,7 @@ void AIS_Shape::UnsetColor() if (IsTransparent()) { Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel); - mat.SetTransparency (aTransp); + mat.SetTransparency (Standard_ShortReal(aTransp)); } myDrawer->ShadingAspect()->SetMaterial (mat ,myCurrentFacingModel); } diff --git a/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx b/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx index 0b86e3a883..01a5f1aeac 100644 --- a/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx +++ b/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx @@ -97,12 +97,18 @@ public: //! Returns the surface material of external faces const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; } + //! Returns the surface material of external faces + Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; } + //! Modifies the surface material of external faces void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; } //! Returns the surface material of internal faces const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; } + //! Returns the surface material of internal faces + Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; } + //! Modifies the surface material of internal faces void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; } diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.cxx b/src/Graphic3d/Graphic3d_MaterialAspect.cxx index 8ea28c3b16..1771846b76 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.cxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.cxx @@ -12,23 +12,478 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include + #include -#include #include #include +namespace +{ + //! Raw material for defining list of standard materials + struct RawMaterial + { + const char* StringName; + Graphic3d_BSDF BSDF; + Quantity_Color Colors [Graphic3d_TypeOfReflection_NB]; + Standard_ShortReal ColorCoef[Graphic3d_TypeOfReflection_NB]; + Standard_ShortReal TransparencyCoef; + Standard_ShortReal RefractionIndex; + Standard_ShortReal Shininess; + Standard_ShortReal EnvReflexion; + Graphic3d_TypeOfMaterial MaterialType; + Graphic3d_NameOfMaterial MaterialName; + Standard_Boolean ReflActivity[Graphic3d_TypeOfReflection_NB]; + + RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStringName); + + }; + + //! Name list of standard materials (defined within enumeration). + static const RawMaterial THE_MATERIALS[] = + { + RawMaterial (Graphic3d_NOM_BRASS, "Brass"), + RawMaterial (Graphic3d_NOM_BRONZE, "Bronze"), + RawMaterial (Graphic3d_NOM_COPPER, "Copper"), + RawMaterial (Graphic3d_NOM_GOLD, "Gold"), + RawMaterial (Graphic3d_NOM_PEWTER, "Pewter"), + RawMaterial (Graphic3d_NOM_PLASTER, "Plastered"), + RawMaterial (Graphic3d_NOM_PLASTIC, "Plastified"), + RawMaterial (Graphic3d_NOM_SILVER, "Silver"), + RawMaterial (Graphic3d_NOM_STEEL, "Steel"), + RawMaterial (Graphic3d_NOM_STONE, "Stone"), + RawMaterial (Graphic3d_NOM_SHINY_PLASTIC, "Shiny_plastified"), + RawMaterial (Graphic3d_NOM_SATIN, "Satined"), + RawMaterial (Graphic3d_NOM_METALIZED, "Metalized"), + RawMaterial (Graphic3d_NOM_NEON_GNC, "Ionized"), + RawMaterial (Graphic3d_NOM_CHROME, "Chrome"), + RawMaterial (Graphic3d_NOM_ALUMINIUM, "Aluminium"), + RawMaterial (Graphic3d_NOM_OBSIDIAN, "Obsidian"), + RawMaterial (Graphic3d_NOM_NEON_PHC, "Neon"), + RawMaterial (Graphic3d_NOM_JADE, "Jade"), + RawMaterial (Graphic3d_NOM_CHARCOAL, "Charcoal"), + RawMaterial (Graphic3d_NOM_WATER, "Water"), + RawMaterial (Graphic3d_NOM_GLASS, "Glass"), + RawMaterial (Graphic3d_NOM_DIAMOND, "Diamond"), + RawMaterial (Graphic3d_NOM_TRANSPARENT, "Transparent"), + RawMaterial (Graphic3d_NOM_DEFAULT, "Default"), + RawMaterial (Graphic3d_NOM_UserDefined, "UserDefined") + }; +} + +// ======================================================================= +// function : RawMaterial +// purpose : +// ======================================================================= +RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStringName) +: StringName (theStringName), + BSDF (Graphic3d_BSDF::CreateDiffuse (Graphic3d_Vec3 (0.0f))), + TransparencyCoef(0.0f), + RefractionIndex (1.0f), + Shininess (0.039f), + EnvReflexion (0.0f), + MaterialType (Graphic3d_MATERIAL_ASPECT), + MaterialName (theName) +{ + ReflActivity[Graphic3d_TOR_AMBIENT] = Standard_True; + ReflActivity[Graphic3d_TOR_DIFFUSE] = Standard_True; + ReflActivity[Graphic3d_TOR_SPECULAR] = Standard_True; + ReflActivity[Graphic3d_TOR_EMISSION] = Standard_False; + + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.3f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.65f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.0f; + ColorCoef[Graphic3d_TOR_EMISSION] = 0.0f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.2f, 0.2f, 0.2f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.2f, 0.2f, 0.2f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.0f, 1.0f, 1.0f)); + switch (theName) + { + case Graphic3d_NOM_PLASTIC: + Shininess = 0.0078125f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.50f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.24f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.06f; + + BSDF.Kd = (Graphic3d_Vec3 )Colors[Graphic3d_TOR_DIFFUSE]; + BSDF.Ks = Graphic3d_Vec3 (0.00784314f, 0.00784314f, 0.00784314f); + BSDF.Normalize(); + BSDF.Roughness = 0.25f; + break; + case Graphic3d_NOM_SHINY_PLASTIC: + Shininess = 1.00f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.44f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.50f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF.Kd = (Graphic3d_Vec3 )Colors[Graphic3d_TOR_DIFFUSE]; + BSDF.Ks = Graphic3d_Vec3 (0.145f, 0.145f, 0.145f); + BSDF.Normalize(); + BSDF.Roughness = 0.17f; + break; + case Graphic3d_NOM_SATIN: + Shininess = 0.09375f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.33f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.40f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.44f; + + BSDF.Kd = Graphic3d_Vec3 (0.2f); + BSDF.Ks = Graphic3d_Vec3 (0.6f); + BSDF.Roughness = 0.6f; + + break; + case Graphic3d_NOM_NEON_GNC: + Shininess = 0.05f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.62f; + ColorCoef[Graphic3d_TOR_EMISSION] = 1.00f; + ReflActivity[Graphic3d_TOR_AMBIENT] = Standard_False; + ReflActivity[Graphic3d_TOR_EMISSION] = Standard_True; + + BSDF.Kd = Graphic3d_Vec3 (0.0f); + BSDF.Kr = Graphic3d_Vec3 (0.5f); + BSDF.Le = (Graphic3d_Vec3 )Colors[Graphic3d_TOR_DIFFUSE]; + BSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (1.5f); + break; + case Graphic3d_NOM_METALIZED: + Shininess = 0.13f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.90f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.47f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.45f; + ReflActivity[Graphic3d_TOR_AMBIENT] = Standard_False; + { + const Graphic3d_Vec3 aColor = (Graphic3d_Vec3 )Colors[Graphic3d_TOR_DIFFUSE]; + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (aColor), 0.045f); + } + break; + // Ascending Compatibility physical materials. The same definition is taken as in the next constructor. + case Graphic3d_NOM_BRASS: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.65f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.58f, 0.42f, 0.20f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.329f, 0.224f, 0.027f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.780f, 0.569f, 0.114f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.992f, 0.941f, 0.808f)); + break; + case Graphic3d_NOM_BRONZE: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.65f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.65f, 0.35f, 0.15f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.213f, 0.128f, 0.054f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.714f, 0.428f, 0.181f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.590f, 0.408f, 0.250f)); + break; + case Graphic3d_NOM_COPPER: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.65f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.955008f, 0.637427f, 0.538163f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.191f, 0.074f, 0.023f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.604f, 0.270f, 0.083f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.950f, 0.640f, 0.540f)); + break; + case Graphic3d_NOM_GOLD: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.80f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (1.000000f, 0.765557f, 0.336057f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.300f, 0.230f, 0.095f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.752f, 0.580f, 0.100f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.000f, 0.710f, 0.290f)); + break; + case Graphic3d_NOM_PEWTER: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.50f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateConductor (1.8800f, 3.4900f), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.106f, 0.059f, 0.114f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.427f, 0.471f, 0.541f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.333f, 0.333f, 0.522f)); + break; + case Graphic3d_NOM_PLASTER: + Shininess = 0.01f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.26f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.75f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.05f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.192f, 0.192f, 0.192f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.508f, 0.508f, 0.508f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.508f, 0.508f, 0.508f)); + + BSDF.Kd = Graphic3d_Vec3 (0.482353f, 0.482353f, 0.482353f); + + break; + case Graphic3d_NOM_SILVER: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.75f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.971519f, 0.959915f, 0.915324f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.275f, 0.275f, 0.250f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.630f, 0.630f, 0.630f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.950f, 0.930f, 0.880f)); + break; + case Graphic3d_NOM_STEEL: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.90f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateConductor (Graphic3d_Vec3 (2.90f, 2.80f, 2.53f), Graphic3d_Vec3 (3.08f, 2.90f, 2.74f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.150f, 0.150f, 0.180f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.500f, 0.510f, 0.520f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.560f, 0.570f, 0.580f)); + break; + case Graphic3d_NOM_STONE: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.17f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 0.19f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 0.75f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.08f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (1.00f, 0.8f, 0.62f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (1.00f, 0.8f, 0.62f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.98f, 1.0f, 0.60f)); + + BSDF.Kd = Graphic3d_Vec3 (0.243137f, 0.243137f, 0.243137f); + BSDF.Ks = Graphic3d_Vec3 (0.00392157f, 0.00392157f, 0.00392157f); + + break; + // Ascending Compatibility of physical materials. Takes the same definition as in the next constructor. New materials + case Graphic3d_NOM_CHROME: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.90f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.549585f, 0.556114f, 0.554256f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.200f, 0.200f, 0.225f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.550f, 0.550f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.975f, 0.975f, 0.975f)); + break; + case Graphic3d_NOM_ALUMINIUM: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.75f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), + Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.913183f, 0.921494f, 0.924524f)), 0.045f); + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.300f, 0.300f, 0.300f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.600f, 0.600f, 0.600f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.910f, 0.920f, 0.920f)); + break; + case Graphic3d_NOM_NEON_PHC: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.05f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 0.62f; + ColorCoef[Graphic3d_TOR_EMISSION] = 0.90f; + ReflActivity[Graphic3d_TOR_AMBIENT] = Standard_False; + ReflActivity[Graphic3d_TOR_DIFFUSE] = Standard_False; + ReflActivity[Graphic3d_TOR_EMISSION] = Standard_True; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (1.0f, 1.0f, 1.0f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (1.0f, 1.0f, 1.0f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.0f, 1.0f, 1.0f)); + Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 1.0f, 0.46f)); + + BSDF.Kd = Graphic3d_Vec3 (0.0f); + BSDF.Kr = Graphic3d_Vec3 (0.5f); + BSDF.Le = Graphic3d_Vec3 (0.0f, 1.0f, 0.46f); + BSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (1.5f); + break; + case Graphic3d_NOM_OBSIDIAN: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.3f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.0f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.0f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.0f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.054f, 0.050f, 0.066f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.183f, 0.170f, 0.225f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.333f, 0.329f, 0.346f)); + + BSDF.Kd = Graphic3d_Vec3 (0.023f, 0.f, 0.023f); + BSDF.Ks = Graphic3d_Vec3 (0.0156863f, 0.0156863f, 0.0156863f); + BSDF.Roughness = 0.1f; + break; + case Graphic3d_NOM_JADE: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.10f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.135f, 0.223f, 0.158f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.540f, 0.890f, 0.630f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.316f, 0.316f, 0.316f)); + + BSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (1.5f); + BSDF.Kd = Graphic3d_Vec3 (0.208658f, 0.415686f, 0.218401f); + BSDF.Ks = Graphic3d_Vec3 (0.611765f, 0.611765f, 0.611765f); + BSDF.Roughness = 0.06f; + break; + case Graphic3d_NOM_CHARCOAL: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.01f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.050f, 0.050f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.150f, 0.150f, 0.150f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.000f, 0.000f, 0.000f)); + + BSDF.Kd = Graphic3d_Vec3 (0.02f, 0.02f, 0.02f); + BSDF.Ks = Graphic3d_Vec3 (0.1f, 0.1f, 0.1f); + BSDF.Roughness = 0.3f; + break; + case Graphic3d_NOM_WATER: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.90f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + RefractionIndex = 1.33f; + BSDF = Graphic3d_BSDF::CreateGlass (Graphic3d_Vec3 (1.f), + Graphic3d_Vec3 (0.7f, 0.75f, 0.85f), + 0.05f, + RefractionIndex); + TransparencyCoef = 0.80f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.450f, 0.450f, 0.475f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.050f, 0.075f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.380f, 0.380f, 0.380f)); + break; + case Graphic3d_NOM_GLASS: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.50f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + RefractionIndex = 1.62f; + BSDF = Graphic3d_BSDF::CreateGlass (Graphic3d_Vec3 (1.f), + Graphic3d_Vec3 (0.75f, 0.95f, 0.9f), + 0.05f, + RefractionIndex); + TransparencyCoef = 0.80f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.575f, 0.575f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.075f, 0.075f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.920f, 0.920f, 0.920f)); + break; + case Graphic3d_NOM_DIAMOND: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.90f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + RefractionIndex = 2.42f; + BSDF = Graphic3d_BSDF::CreateGlass (Graphic3d_Vec3 (1.f), + Graphic3d_Vec3 (0.95f, 0.95f, 0.95f), + 0.05f, + RefractionIndex); + TransparencyCoef = 0.80f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.550f, 0.550f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.100f, 0.100f, 0.100f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f, 0.970f, 0.970f)); + break; + + case Graphic3d_NOM_TRANSPARENT: + MaterialType = Graphic3d_MATERIAL_PHYSIC; + + Shininess = 0.90f; + ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f; + ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f; + ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f; + RefractionIndex = 1.0f; + + BSDF.Kd = Graphic3d_Vec3 (0.1f); + BSDF.Kt = Graphic3d_Vec3 (0.9f); + BSDF.Fresnel = Graphic3d_Fresnel::CreateConstant (0.0f); + TransparencyCoef = 0.80f; + + Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.550f, 0.550f)); + Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.100f, 0.100f, 0.100f)); + Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f, 0.970f, 0.970f)); + break; + case Graphic3d_NOM_UserDefined: + break; + case Graphic3d_NOM_DEFAULT: + break; + } +} + // ======================================================================= // function : Graphic3d_MaterialAspect // purpose : // ======================================================================= Graphic3d_MaterialAspect::Graphic3d_MaterialAspect() -: myDiffuseColor (0.2, 0.2, 0.2, Quantity_TOC_RGB), - myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB) +: myRequestedMaterialName (Graphic3d_NOM_DEFAULT) { - myRequestedMaterialName = Graphic3d_NOM_DEFAULT; - Init (myRequestedMaterialName); + init (Graphic3d_NOM_DEFAULT); } // ======================================================================= @@ -36,503 +491,50 @@ Graphic3d_MaterialAspect::Graphic3d_MaterialAspect() // purpose : // ======================================================================= Graphic3d_MaterialAspect::Graphic3d_MaterialAspect (const Graphic3d_NameOfMaterial theName) -: myDiffuseColor (0.2, 0.2, 0.2, Quantity_TOC_RGB), - myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB) +: myRequestedMaterialName (theName) { - myRequestedMaterialName = theName; - Init (myRequestedMaterialName); + init (theName); } // ======================================================================= -// function : Init +// function : init // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::Init (const Graphic3d_NameOfMaterial theName) +void Graphic3d_MaterialAspect::init (const Graphic3d_NameOfMaterial theName) { - myMaterialType = Graphic3d_MATERIAL_ASPECT; - myTransparencyCoef = 0.0f; - myRefractionIndex = 1.0f; - myDiffuseActivity = Standard_True; - myDiffuseCoef = 0.65f; - myAmbientActivity = Standard_True; - myAmbientCoef = 0.3f; - mySpecularActivity = Standard_True; - mySpecularCoef = 0.0f; - myEmissiveActivity = Standard_False; - myEmissiveCoef = 0.0f; - myEnvReflexion = 0.0f; - myShininess = 0.039f; - myDiffuseColor .SetValues (0.2, 0.2, 0.2, Quantity_TOC_RGB); - mySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB); + const RawMaterial& aMat = THE_MATERIALS[theName]; + myBSDF = aMat.BSDF; + myStringName = aMat.StringName; + myColors[Graphic3d_TOR_AMBIENT] = aMat.Colors[Graphic3d_TOR_AMBIENT]; + myColors[Graphic3d_TOR_DIFFUSE] = aMat.Colors[Graphic3d_TOR_DIFFUSE]; + myColors[Graphic3d_TOR_SPECULAR] = aMat.Colors[Graphic3d_TOR_SPECULAR]; + myColors[Graphic3d_TOR_EMISSION] = aMat.Colors[Graphic3d_TOR_EMISSION]; + myColorCoef[Graphic3d_TOR_AMBIENT] = aMat.ColorCoef[Graphic3d_TOR_AMBIENT]; + myColorCoef[Graphic3d_TOR_DIFFUSE] = aMat.ColorCoef[Graphic3d_TOR_DIFFUSE]; + myColorCoef[Graphic3d_TOR_SPECULAR] = aMat.ColorCoef[Graphic3d_TOR_SPECULAR]; + myColorCoef[Graphic3d_TOR_EMISSION] = aMat.ColorCoef[Graphic3d_TOR_EMISSION]; + myTransparencyCoef = aMat.TransparencyCoef; + myRefractionIndex = aMat.RefractionIndex; + myShininess = aMat.Shininess; + myEnvReflexion = aMat.EnvReflexion; + myMaterialType = aMat.MaterialType; myMaterialName = theName; - - myBSDF = Graphic3d_BSDF::CreateDiffuse (Graphic3d_Vec3 (0.0f)); - - Standard_Integer index = Standard_Integer (theName); - if (index < NumberOfMaterials()) - { - myStringName = MaterialName (index + 1); - } - - switch (theName) - { - case Graphic3d_NOM_PLASTIC: - myShininess = Standard_ShortReal (0.0078125); - myAmbientCoef = Standard_ShortReal (0.5); - myDiffuseCoef = Standard_ShortReal (0.24); - mySpecularCoef = Standard_ShortReal (0.06); - - myBSDF.Kd = Graphic3d_Vec3 (static_cast (myDiffuseColor.Red()), - static_cast (myDiffuseColor.Green()), - static_cast (myDiffuseColor.Blue())); - myBSDF.Ks = Graphic3d_Vec3 (0.00784314f, 0.00784314f, 0.00784314f); - myBSDF.Normalize(); - myBSDF.Roughness = 0.25f; - break; - case Graphic3d_NOM_SHINY_PLASTIC: - myShininess = Standard_ShortReal (1.0); - myAmbientCoef = Standard_ShortReal (0.44); - myDiffuseCoef = Standard_ShortReal (0.5); - mySpecularCoef = Standard_ShortReal (1.0); - - myBSDF.Kd = Graphic3d_Vec3 (static_cast (myDiffuseColor.Red()), - static_cast (myDiffuseColor.Green()), - static_cast (myDiffuseColor.Blue())); - myBSDF.Ks = Graphic3d_Vec3 (0.145f, 0.145f, 0.145f); - myBSDF.Normalize(); - myBSDF.Roughness = 0.17f; - break; - case Graphic3d_NOM_SATIN : - myShininess = Standard_ShortReal (0.09375); - myAmbientCoef = Standard_ShortReal (0.33); - myDiffuseCoef = Standard_ShortReal (0.4); - mySpecularCoef = Standard_ShortReal (0.44); - - myBSDF.Kd = Graphic3d_Vec3 (0.2f); - myBSDF.Ks = Graphic3d_Vec3 (0.6f); - myBSDF.Roughness = 0.6f; - - break; - case Graphic3d_NOM_NEON_GNC: - myShininess = Standard_ShortReal (0.05); - myAmbientCoef = Standard_ShortReal (1.0); - myDiffuseCoef = Standard_ShortReal (1.0); - mySpecularCoef = Standard_ShortReal (0.62); - myEmissiveCoef = Standard_ShortReal (1.0); - myEmissiveActivity = Standard_True; - myAmbientActivity = Standard_False; - - myBSDF.Kd = Graphic3d_Vec3 (0.0f); - myBSDF.Kr = Graphic3d_Vec3 (0.5f); - myBSDF.Le = Graphic3d_Vec3 (static_cast (myDiffuseColor.Red()), - static_cast (myDiffuseColor.Green()), - static_cast (myDiffuseColor.Blue())); - myBSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (1.5f); - break; - case Graphic3d_NOM_METALIZED: - myShininess = Standard_ShortReal (0.13); - myAmbientCoef = Standard_ShortReal (0.9); - myDiffuseCoef = Standard_ShortReal (0.47); - mySpecularCoef = Standard_ShortReal (0.45); - myAmbientActivity = Standard_False; - - { - Graphic3d_Vec3 aColor (static_cast (myDiffuseColor.Red()), - static_cast (myDiffuseColor.Green()), - static_cast (myDiffuseColor.Blue())); - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (aColor), 0.045f); - } - break; - // Ascending Compatibility physical materials. The same definition is taken as in the next constructor. - case Graphic3d_NOM_BRASS: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.65f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.58f, 0.42f, 0.20f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.329f, 0.224f, 0.027f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.780f, 0.569f, 0.114f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.992f, 0.941f, 0.808f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_BRONZE: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.65f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.65f, 0.35f, 0.15f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.213f, 0.128f, 0.054f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.714f, 0.428f, 0.181f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.590f, 0.408f, 0.250f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_COPPER: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.65f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.955008f, 0.637427f, 0.538163f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.191f, 0.074f, 0.023f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.604f, 0.270f, 0.083f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.950f, 0.640f, 0.540f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_GOLD: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.80f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (1.000000f, 0.765557f, 0.336057f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.300f, 0.230f, 0.095f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.752f, 0.580f, 0.100f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (1.000f, 0.710f, 0.290f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_PEWTER: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.50f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateConductor (1.8800f, 3.4900f), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.106f, 0.059f, 0.114f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.427f, 0.471f, 0.541f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.333f, 0.333f, 0.522f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_PLASTER: - myShininess = 0.01f; - myAmbientCoef = 0.26f; - myDiffuseCoef = 0.75f; - mySpecularCoef = 0.05f; - - // Color resulting from ambient - myAmbientColor .SetValues (0.192f, 0.192f, 0.192f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.508f, 0.508f, 0.508f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.508f, 0.508f, 0.508f, Quantity_TOC_RGB); - - myBSDF.Kd = Graphic3d_Vec3 (0.482353f, 0.482353f, 0.482353f); - - break; - case Graphic3d_NOM_SILVER: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.75f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.971519f, 0.959915f, 0.915324f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.275f, 0.275f, 0.250f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.630f, 0.630f, 0.630f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.950f, 0.930f, 0.880f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_STEEL: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.90f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateConductor (Graphic3d_Vec3 (2.90f, 2.80f, 2.53f), Graphic3d_Vec3 (3.08f, 2.90f, 2.74f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.150f, 0.150f, 0.180f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.500f, 0.510f, 0.520f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.560f, 0.570f, 0.580f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_STONE: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.17f; - myAmbientCoef = 0.19f; - myDiffuseCoef = 0.75f; - mySpecularCoef = 0.08f; - - // Color resulting from ambient - myAmbientColor .SetValues (1.0, 0.8, 0.62, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (1.0, 0.8, 0.62, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.98, 1.0, 0.60, Quantity_TOC_RGB); - - myBSDF.Kd = Graphic3d_Vec3 (0.243137f, 0.243137f, 0.243137f); - myBSDF.Ks = Graphic3d_Vec3 (0.00392157f, 0.00392157f, 0.00392157f); - - break; - // Ascending Compatibility of physical materials. Takes the same definition as in the next constructor. New materials - case Graphic3d_NOM_CHROME: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.90f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.549585f, 0.556114f, 0.554256f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.200f, 0.200f, 0.225f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.550f, 0.550f, 0.550f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.975f, 0.975f, 0.975f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_ALUMINIUM: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.75f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - myBSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f), - Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.913183f, 0.921494f, 0.924524f)), 0.045f); - - // Color resulting from ambient - myAmbientColor .SetValues (0.300f, 0.300f, 0.300f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.600f, 0.600f, 0.600f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.910f, 0.920f, 0.920f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_NEON_PHC: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.05f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 0.62f; - myEmissiveCoef = 0.90f; - myAmbientActivity = Standard_False; - myDiffuseActivity = Standard_False; - myEmissiveActivity = Standard_True; - - // Color resulting from ambient - myAmbientColor .SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB); - // Color resulting from specular - myEmissiveColor.SetValues (0.0, 1.0, 0.46, Quantity_TOC_RGB); - - myBSDF.Kd = Graphic3d_Vec3 (0.0f); - myBSDF.Kr = Graphic3d_Vec3 (0.5f); - myBSDF.Le = Graphic3d_Vec3 (0.0f, 1.0f, 0.46f); - myBSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (1.5f); - break; - case Graphic3d_NOM_OBSIDIAN: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.3f; - myAmbientCoef = 1.0f; - myDiffuseCoef = 1.0f; - mySpecularCoef = 1.0f; - - // Color resulting from ambient - myAmbientColor .SetValues (0.054f, 0.050f, 0.066f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.183f, 0.170f, 0.225f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.333f, 0.329f, 0.346f, Quantity_TOC_RGB); - - myBSDF.Kd = Graphic3d_Vec3 (0.023f, 0.f, 0.023f); - myBSDF.Ks = Graphic3d_Vec3 (0.0156863f, 0.0156863f, 0.0156863f); - myBSDF.Roughness = 0.1f; - break; - case Graphic3d_NOM_JADE: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.10f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - // Color resulting from ambient - myAmbientColor .SetValues (0.135f, 0.223f, 0.158f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.540f, 0.890f, 0.630f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.316f, 0.316f, 0.316f, Quantity_TOC_RGB); - - myBSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (1.5f); - myBSDF.Kd = Graphic3d_Vec3 (0.208658f, 0.415686f, 0.218401f); - myBSDF.Ks = Graphic3d_Vec3 (0.611765f, 0.611765f, 0.611765f); - myBSDF.Roughness = 0.06f; - break; - case Graphic3d_NOM_CHARCOAL: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.01f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - - // Color resulting from ambient - myAmbientColor .SetValues (0.050f, 0.050f, 0.050f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor .SetValues (0.150f, 0.150f, 0.150f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.000f, 0.000f, 0.000f, Quantity_TOC_RGB); - - myBSDF.Kd = Graphic3d_Vec3 (0.02f, 0.02f, 0.02f); - myBSDF.Ks = Graphic3d_Vec3 (0.1f, 0.1f, 0.1f); - myBSDF.Roughness = 0.3f; - break; - case Graphic3d_NOM_WATER: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.90f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - myRefractionIndex = 1.33f; - myBSDF = Graphic3d_BSDF::CreateGlass (Graphic3d_Vec3 (1.f), - Graphic3d_Vec3 (0.7f, 0.75f, 0.85f), - 0.05f, - myRefractionIndex); - myTransparencyCoef = 0.80f; - - // Color resulting from ambient - myAmbientColor.SetValues (0.450f, 0.450f, 0.475f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor.SetValues (0.050f, 0.050f, 0.075f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.380f, 0.380f, 0.380f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_GLASS: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.50f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - myRefractionIndex = 1.62f; - myBSDF = Graphic3d_BSDF::CreateGlass (Graphic3d_Vec3 (1.f), - Graphic3d_Vec3 (0.75f, 0.95f, 0.9f), - 0.05f, - myRefractionIndex); - myTransparencyCoef = 0.80f; - - // Color resulting from ambient - myAmbientColor.SetValues (0.550f, 0.575f, 0.575f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor.SetValues (0.050f, 0.075f, 0.075f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.920f, 0.920f, 0.920f, Quantity_TOC_RGB); - break; - case Graphic3d_NOM_DIAMOND: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.90f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - myRefractionIndex = 2.42f; - myBSDF = Graphic3d_BSDF::CreateGlass (Graphic3d_Vec3 (1.f), - Graphic3d_Vec3 (0.95f, 0.95f, 0.95f), - 0.05f, - myRefractionIndex); - myTransparencyCoef = 0.80f; - - // Color resulting from ambient - myAmbientColor.SetValues (0.550f, 0.550f, 0.550f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor.SetValues (0.100f, 0.100f, 0.100f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.970f, 0.970f, 0.970f, Quantity_TOC_RGB); - break; - - case Graphic3d_NOM_TRANSPARENT: - myMaterialType = Graphic3d_MATERIAL_PHYSIC; - - myShininess = 0.90f; - myAmbientCoef = 1.00f; - myDiffuseCoef = 1.00f; - mySpecularCoef = 1.00f; - myRefractionIndex = 1.0f; - - myBSDF.Kd = Graphic3d_Vec3 (0.1f); - myBSDF.Kt = Graphic3d_Vec3 (0.9f); - myBSDF.Fresnel = Graphic3d_Fresnel::CreateConstant (0.0f); - myTransparencyCoef = 0.80f; - - // Color resulting from ambient - myAmbientColor.SetValues (0.550f, 0.550f, 0.550f, Quantity_TOC_RGB); - // Color resulting from dispersed - myDiffuseColor.SetValues (0.100f, 0.100f, 0.100f, Quantity_TOC_RGB); - // Color resulting from specular - mySpecularColor.SetValues (0.970f, 0.970f, 0.970f, Quantity_TOC_RGB); - break; - - case Graphic3d_NOM_UserDefined: - myStringName = "UserDefined"; - break; - case Graphic3d_NOM_DEFAULT: - default: - myStringName = "Default"; - break; - } + myRequestedMaterialName = theName; + myReflActivity[Graphic3d_TOR_AMBIENT] = aMat.ReflActivity[Graphic3d_TOR_AMBIENT]; + myReflActivity[Graphic3d_TOR_DIFFUSE] = aMat.ReflActivity[Graphic3d_TOR_DIFFUSE]; + myReflActivity[Graphic3d_TOR_SPECULAR] = aMat.ReflActivity[Graphic3d_TOR_SPECULAR]; + myReflActivity[Graphic3d_TOR_EMISSION] = aMat.ReflActivity[Graphic3d_TOR_EMISSION]; } // ======================================================================= // function : IncreaseShine // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::IncreaseShine (const Standard_Real theDelta) +void Graphic3d_MaterialAspect::IncreaseShine (const Standard_ShortReal theDelta) { - Standard_ShortReal anOldShine = myShininess; - myShininess = Standard_ShortReal(myShininess + myShininess * theDelta / 100.0); - if (myShininess > 1.0 || myShininess < 0.0) + const Standard_ShortReal anOldShine = myShininess; + myShininess = myShininess + myShininess * theDelta / 100.0f; + if (myShininess > 1.0f || myShininess < 0.0f) { myShininess = anOldShine; } @@ -547,7 +549,7 @@ void Graphic3d_MaterialAspect::SetMaterialType (const Graphic3d_TypeOfMaterial t myMaterialType = theType; if (theType != myMaterialType) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -555,19 +557,19 @@ void Graphic3d_MaterialAspect::SetMaterialType (const Graphic3d_TypeOfMaterial t // function : SetAmbient // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetAmbient (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetAmbient (const Standard_ShortReal theValue) { - if (theValue < 0.0 - || theValue > 1.0) + if (theValue < 0.0f + || theValue > 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetAmbient < 0. or > 1.0"); } - myAmbientCoef = Standard_ShortReal (theValue); - if (myAmbientActivity + myColorCoef[Graphic3d_TOR_AMBIENT] = theValue; + if (myReflActivity[Graphic3d_TOR_AMBIENT] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -578,13 +580,14 @@ void Graphic3d_MaterialAspect::SetAmbient (const Standard_Real theValue) void Graphic3d_MaterialAspect::SetColor (const Quantity_Color& theColor) { const Standard_ShortReal anAmbientCoeff = 0.25f; - myAmbientColor.SetValues (theColor.Red() * anAmbientCoeff, - theColor.Green() * anAmbientCoeff, - theColor.Blue() * anAmbientCoeff, Quantity_TOC_RGB); - myDiffuseColor = theColor; - if (myAmbientActivity && myMaterialType == Graphic3d_MATERIAL_PHYSIC) + myColors[Graphic3d_TOR_AMBIENT].SetValues (theColor.Red() * anAmbientCoeff, + theColor.Green() * anAmbientCoeff, + theColor.Blue() * anAmbientCoeff, Quantity_TOC_RGB); + myColors[Graphic3d_TOR_DIFFUSE] = theColor; + if (myReflActivity[Graphic3d_TOR_AMBIENT] + && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -594,11 +597,11 @@ void Graphic3d_MaterialAspect::SetColor (const Quantity_Color& theColor) // ======================================================================= void Graphic3d_MaterialAspect::SetAmbientColor (const Quantity_Color& theColor) { - myAmbientColor = theColor; - if (myAmbientActivity + myColors[Graphic3d_TOR_AMBIENT] = theColor; + if (myReflActivity[Graphic3d_TOR_AMBIENT] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -608,11 +611,11 @@ void Graphic3d_MaterialAspect::SetAmbientColor (const Quantity_Color& theColor) // ======================================================================= void Graphic3d_MaterialAspect::SetDiffuseColor (const Quantity_Color& theColor) { - myDiffuseColor = theColor; - if (myDiffuseActivity + myColors[Graphic3d_TOR_DIFFUSE] = theColor; + if (myReflActivity[Graphic3d_TOR_DIFFUSE] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -622,11 +625,11 @@ void Graphic3d_MaterialAspect::SetDiffuseColor (const Quantity_Color& theColor) // ======================================================================= void Graphic3d_MaterialAspect::SetSpecularColor (const Quantity_Color& theColor) { - mySpecularColor = theColor; - if (mySpecularActivity + myColors[Graphic3d_TOR_SPECULAR] = theColor; + if (myReflActivity[Graphic3d_TOR_SPECULAR] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -636,11 +639,11 @@ void Graphic3d_MaterialAspect::SetSpecularColor (const Quantity_Color& theColor) // ======================================================================= void Graphic3d_MaterialAspect::SetEmissiveColor (const Quantity_Color& theColor) { - myEmissiveColor = theColor; - if (myEmissiveActivity + myColors[Graphic3d_TOR_EMISSION] = theColor; + if (myReflActivity[Graphic3d_TOR_EMISSION] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -648,19 +651,19 @@ void Graphic3d_MaterialAspect::SetEmissiveColor (const Quantity_Color& theColor) // function : SetDiffuse // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetDiffuse (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetDiffuse (const Standard_ShortReal theValue) { - if (theValue < 0.0 - || theValue > 1.0) + if (theValue < 0.0f + || theValue > 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetDiffuse < 0. or > 1.0"); } - myDiffuseCoef = Standard_ShortReal (theValue); - if (myDiffuseActivity + myColorCoef[Graphic3d_TOR_DIFFUSE] = theValue; + if (myReflActivity[Graphic3d_TOR_DIFFUSE] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -668,73 +671,33 @@ void Graphic3d_MaterialAspect::SetDiffuse (const Standard_Real theValue) // function : SetEmissive // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetEmissive (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetEmissive (const Standard_ShortReal theValue) { - if (theValue < 0.0 - || theValue > 1.0) + if (theValue < 0.0f + || theValue > 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetEmissive < 0. or > 1.0"); } - myEmissiveCoef = Standard_ShortReal (theValue); - if (myDiffuseActivity + myColorCoef[Graphic3d_TOR_EMISSION] = theValue; + if (myReflActivity[Graphic3d_TOR_DIFFUSE] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } // ======================================================================= -// function : SetReflectionModeOn +// function : SetReflectionMode // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetReflectionModeOn (const Graphic3d_TypeOfReflection theType) +void Graphic3d_MaterialAspect::SetReflectionMode (const Graphic3d_TypeOfReflection theType, + const Standard_Boolean theValue) { - switch (theType) - { - case Graphic3d_TOR_AMBIENT: - myAmbientActivity = Standard_True; - break; - case Graphic3d_TOR_DIFFUSE: - myDiffuseActivity = Standard_True; - break; - case Graphic3d_TOR_SPECULAR: - mySpecularActivity = Standard_True; - break; - case Graphic3d_TOR_EMISSION: - myEmissiveActivity = Standard_True; - break; - } + myReflActivity[theType] = theValue; if (myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); - } -} - -// ======================================================================= -// function : SetReflectionModeOff -// purpose : -// ======================================================================= -void Graphic3d_MaterialAspect::SetReflectionModeOff (const Graphic3d_TypeOfReflection theType) -{ - switch (theType) - { - case Graphic3d_TOR_AMBIENT: - myAmbientActivity = Standard_False; - break; - case Graphic3d_TOR_DIFFUSE: - myDiffuseActivity = Standard_False; - break; - case Graphic3d_TOR_SPECULAR: - mySpecularActivity = Standard_False; - break; - case Graphic3d_TOR_EMISSION: - myEmissiveActivity = Standard_False; - break; - } - if (myMaterialType == Graphic3d_MATERIAL_PHYSIC) - { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -742,19 +705,19 @@ void Graphic3d_MaterialAspect::SetReflectionModeOff (const Graphic3d_TypeOfRefle // function : SetSpecular // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetSpecular (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetSpecular (const Standard_ShortReal theValue) { - if (theValue < 0.0 - || theValue > 1.0) + if (theValue < 0.0f + || theValue > 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetSpecular < 0. or > 1.0"); } - mySpecularCoef = Standard_ShortReal (theValue); - if (mySpecularActivity + myColorCoef[Graphic3d_TOR_SPECULAR] = theValue; + if (myReflActivity[Graphic3d_TOR_SPECULAR] && myMaterialType == Graphic3d_MATERIAL_PHYSIC) { - SetMaterialName ("UserDefined"); + setUserMaterial(); } } @@ -762,316 +725,45 @@ void Graphic3d_MaterialAspect::SetSpecular (const Standard_Real theValue) // function : SetTransparency // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetTransparency (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetTransparency (const Standard_ShortReal theValue) { - if (theValue < 0.0 - || theValue > 1.0) + if (theValue < 0.0f + || theValue > 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetTransparency < 0. or > 1.0"); } - myTransparencyCoef = Standard_ShortReal (theValue); + myTransparencyCoef = theValue; } // ======================================================================= // function : SetRefractionIndex // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetRefractionIndex (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetRefractionIndex (const Standard_ShortReal theValue) { - if (theValue < 1.0) + if (theValue < 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for refraction index < 1.0"); } - myRefractionIndex = static_cast (theValue); -} - -// ======================================================================= -// function : SetBSDF -// purpose : -// ======================================================================= -void Graphic3d_MaterialAspect::SetBSDF (const Graphic3d_BSDF& theBSDF) -{ - myBSDF = theBSDF; -} - -// ======================================================================= -// function : Color -// purpose : -// ======================================================================= -const Quantity_Color& Graphic3d_MaterialAspect::Color() const -{ - // It is generally accepted to consider diffuse color as - // "general" color of a material when light shines on it - return myDiffuseColor; -} - -// ======================================================================= -// function : AmbientColor -// purpose : -// ======================================================================= -const Quantity_Color& Graphic3d_MaterialAspect::AmbientColor() const -{ - return myAmbientColor; -} - -// ======================================================================= -// function : DiffuseColor -// purpose : -// ======================================================================= -const Quantity_Color& Graphic3d_MaterialAspect::DiffuseColor() const -{ - return myDiffuseColor; -} - -// ======================================================================= -// function : SpecularColor -// purpose : -// ======================================================================= -const Quantity_Color& Graphic3d_MaterialAspect::SpecularColor() const -{ - return mySpecularColor; -} - -// ======================================================================= -// function : EmissiveColor -// purpose : -// ======================================================================= -const Quantity_Color& Graphic3d_MaterialAspect::EmissiveColor() const -{ - return myEmissiveColor; -} - -// ======================================================================= -// function : MaterialType -// purpose : -// ======================================================================= -Standard_Boolean Graphic3d_MaterialAspect::MaterialType (const Graphic3d_TypeOfMaterial theType) const -{ - return myMaterialType == theType; -} - -// ======================================================================= -// function : ReflectionMode -// purpose : -// ======================================================================= -Standard_Boolean Graphic3d_MaterialAspect::ReflectionMode (const Graphic3d_TypeOfReflection theType) const -{ - switch (theType) - { - case Graphic3d_TOR_AMBIENT: return myAmbientActivity; - case Graphic3d_TOR_DIFFUSE: return myDiffuseActivity; - case Graphic3d_TOR_SPECULAR: return mySpecularActivity; - case Graphic3d_TOR_EMISSION: return myEmissiveActivity; - } - return Standard_False; -} - -// ======================================================================= -// function : Ambient -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::Ambient() const -{ - return Standard_Real (myAmbientCoef); -} - -// ======================================================================= -// function : Diffuse -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::Diffuse() const -{ - return Standard_Real (myDiffuseCoef); -} - -// ======================================================================= -// function : Emissive -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::Emissive() const -{ - return Standard_Real (myEmissiveCoef); -} - -// ======================================================================= -// function : Specular -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::Specular() const -{ - return Standard_Real (mySpecularCoef); -} - -// ======================================================================= -// function : Transparency -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::Transparency() const -{ - return Standard_Real (myTransparencyCoef); -} - -// ======================================================================= -// function : RefractionIndex -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::RefractionIndex() const -{ - return myRefractionIndex; -} - -// ======================================================================= -// function : BSDF -// purpose : -// ======================================================================= -const Graphic3d_BSDF& Graphic3d_MaterialAspect::BSDF() const -{ - return myBSDF; -} - -// ======================================================================= -// function : Shininess -// purpose : -// ======================================================================= -Standard_Real Graphic3d_MaterialAspect::Shininess() const -{ - return Standard_Real (myShininess); + myRefractionIndex = theValue; } // ======================================================================= // function : SetShininess // purpose : // ======================================================================= -void Graphic3d_MaterialAspect::SetShininess (const Standard_Real theValue) +void Graphic3d_MaterialAspect::SetShininess (const Standard_ShortReal theValue) { - if (theValue < 0.0 - || theValue > 1.0) + if (theValue < 0.0f + || theValue > 1.0f) { Graphic3d_MaterialDefinitionError::Raise ("Bad value for Shininess < 0. or > 1.0"); } - myShininess = Standard_ShortReal (theValue); - SetMaterialName ("UserDefined"); -} - -// ======================================================================= -// function : SetEnvReflexion -// purpose : -// ======================================================================= -void Graphic3d_MaterialAspect::SetEnvReflexion (const Standard_ShortReal theValue) -{ - myEnvReflexion = theValue; -} - -// ======================================================================= -// function : EnvReflexion -// purpose : -// ======================================================================= -Standard_ShortReal Graphic3d_MaterialAspect::EnvReflexion() const -{ - return myEnvReflexion; -} - -// ======================================================================= -// function : Name -// purpose : -// ======================================================================= -Graphic3d_NameOfMaterial Graphic3d_MaterialAspect::Name() const -{ - return myMaterialName; -} - -// ======================================================================= -// function : Reset -// purpose : -// ======================================================================= -void Graphic3d_MaterialAspect::Reset() -{ - Init (myRequestedMaterialName); -} - -// ======================================================================= -// function : IsEqual -// purpose : -// ======================================================================= -Standard_Boolean Graphic3d_MaterialAspect::IsEqual (const Graphic3d_MaterialAspect& theOther) const -{ - return myAmbientCoef == theOther.myAmbientCoef - && myDiffuseCoef == theOther.myDiffuseCoef - && mySpecularCoef == theOther.mySpecularCoef - && myEmissiveCoef == theOther.myEmissiveCoef - && myTransparencyCoef == theOther.myTransparencyCoef - && myRefractionIndex == theOther.myRefractionIndex - && myBSDF == theOther.myBSDF - && myShininess == theOther.myShininess - && myEnvReflexion == theOther.myEnvReflexion - && myAmbientColor == theOther.myAmbientColor - && myDiffuseColor == theOther.myDiffuseColor - && mySpecularColor == theOther.mySpecularColor - && myEmissiveColor == theOther.myEmissiveColor - && myAmbientActivity == theOther.myAmbientActivity - && myDiffuseActivity == theOther.myDiffuseActivity - && mySpecularActivity == theOther.mySpecularActivity - && myEmissiveActivity == theOther.myEmissiveActivity; -} - -// ======================================================================= -// function : IsDifferent -// purpose : -// ======================================================================= -Standard_Boolean Graphic3d_MaterialAspect::IsDifferent (const Graphic3d_MaterialAspect& theOther) const -{ - return !IsEqual (theOther); -} - -typedef struct _Material -{ - const char* name; - Graphic3d_TypeOfMaterial type; -} Material; - -namespace -{ - static const Material theMaterials[] = - { - {"Brass", Graphic3d_MATERIAL_PHYSIC}, - {"Bronze", Graphic3d_MATERIAL_PHYSIC}, - {"Copper", Graphic3d_MATERIAL_PHYSIC}, - {"Gold", Graphic3d_MATERIAL_PHYSIC}, - {"Pewter", Graphic3d_MATERIAL_PHYSIC}, - {"Plastered", Graphic3d_MATERIAL_ASPECT}, - {"Plastified", Graphic3d_MATERIAL_ASPECT}, - {"Silver", Graphic3d_MATERIAL_PHYSIC}, - {"Steel", Graphic3d_MATERIAL_PHYSIC}, - {"Stone", Graphic3d_MATERIAL_PHYSIC}, - {"Shiny_plastified", Graphic3d_MATERIAL_ASPECT}, - {"Satined", Graphic3d_MATERIAL_ASPECT}, - {"Metalized", Graphic3d_MATERIAL_ASPECT}, - {"Ionized", Graphic3d_MATERIAL_ASPECT}, - {"Chrome", Graphic3d_MATERIAL_PHYSIC}, - {"Aluminium", Graphic3d_MATERIAL_PHYSIC}, - {"Obsidian", Graphic3d_MATERIAL_PHYSIC}, - {"Neon", Graphic3d_MATERIAL_PHYSIC}, - {"Jade", Graphic3d_MATERIAL_PHYSIC}, - {"Charcoal", Graphic3d_MATERIAL_PHYSIC}, - {"Water", Graphic3d_MATERIAL_PHYSIC}, - {"Glass", Graphic3d_MATERIAL_PHYSIC}, - {"Diamond", Graphic3d_MATERIAL_PHYSIC}, - {"Transparent", Graphic3d_MATERIAL_PHYSIC} - - }; -} - -// ======================================================================= -// function : NumberOfMaterials -// purpose : -// ======================================================================= -Standard_Integer Graphic3d_MaterialAspect::NumberOfMaterials() -{ - Standard_STATIC_ASSERT(sizeof(theMaterials)/sizeof(Material) == Graphic3d_NOM_DEFAULT); - return Graphic3d_NOM_DEFAULT; + myShininess = theValue; + setUserMaterial(); } // ======================================================================= @@ -1084,7 +776,8 @@ Standard_CString Graphic3d_MaterialAspect::MaterialName (const Standard_Integer { Standard_OutOfRange::Raise ("BAD index of material"); } - return theMaterials[theRank - 1].name; + const RawMaterial& aMat = THE_MATERIALS[theRank - 1]; + return aMat.StringName; } // ======================================================================= @@ -1097,11 +790,12 @@ Graphic3d_NameOfMaterial Graphic3d_MaterialAspect::MaterialFromName (const Stand aName.LowerCase(); aName.Capitalize(); const Standard_Integer aNbMaterials = Graphic3d_MaterialAspect::NumberOfMaterials(); - for (Standard_Integer aMatIter = 1; aMatIter <= aNbMaterials; ++aMatIter) + for (Standard_Integer aMatIter = 0; aMatIter < aNbMaterials; ++aMatIter) { - if (aName == Graphic3d_MaterialAspect::MaterialName (aMatIter)) + const RawMaterial& aMat = THE_MATERIALS[aMatIter]; + if (aName == aMat.StringName) { - return Graphic3d_NameOfMaterial(aMatIter - 1); + return Graphic3d_NameOfMaterial(aMatIter); } } @@ -1143,26 +837,6 @@ Graphic3d_TypeOfMaterial Graphic3d_MaterialAspect::MaterialType (const Standard_ { Standard_OutOfRange::Raise ("BAD index of material"); } - return theMaterials[theRank - 1].type; -} - -// ======================================================================= -// function : MaterialName -// purpose : -// ======================================================================= -Standard_CString Graphic3d_MaterialAspect::MaterialName() const -{ - return myStringName.ToCString(); -} - -// ======================================================================= -// function : SetMaterialName -// purpose : -// ======================================================================= -void Graphic3d_MaterialAspect::SetMaterialName (const Standard_CString theNewName) -{ - // if a component of a "standard" material change, the - // result is no more standard (a blue gold is not a gold) - myMaterialName = Graphic3d_NOM_UserDefined; - myStringName = theNewName; + const RawMaterial& aMat = THE_MATERIALS[theRank - 1]; + return aMat.MaterialType; } diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.hxx b/src/Graphic3d/Graphic3d_MaterialAspect.hxx index 0d2505252e..0c43a58ec8 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.hxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.hxx @@ -16,25 +16,12 @@ #ifndef _Graphic3d_MaterialAspect_HeaderFile #define _Graphic3d_MaterialAspect_HeaderFile -#include -#include -#include - -#include -#include -#include #include -#include #include -#include -#include +#include #include -#include -#include -class Graphic3d_MaterialDefinitionError; -class Standard_OutOfRange; -class Quantity_Color; - +#include +#include //! This class allows the definition of the type of a surface. //! Aspect attributes of a 3d face. @@ -44,105 +31,161 @@ class Quantity_Color; class Graphic3d_MaterialAspect { public: - DEFINE_STANDARD_ALLOC - + //! Returns the number of predefined textures. + static Standard_Integer NumberOfMaterials() { return Graphic3d_NOM_DEFAULT; } + + //! Returns the name of the predefined material of specified rank within range [1, NumberOfMaterials()]. + Standard_EXPORT static Standard_CString MaterialName (const Standard_Integer theRank); + + //! Returns the type of the predefined material of specified rank within range [1, NumberOfMaterials()]. + Standard_EXPORT static Graphic3d_TypeOfMaterial MaterialType (const Standard_Integer theRank); + + //! Returns the material for specified name or Graphic3d_NOM_DEFAULT if name is unknown. + Standard_EXPORT static Graphic3d_NameOfMaterial MaterialFromName (const Standard_CString theName); + +public: + //! Creates a material from default values. Standard_EXPORT Graphic3d_MaterialAspect(); - - //! Creates a generic material calls - Standard_EXPORT Graphic3d_MaterialAspect(const Graphic3d_NameOfMaterial AName); - - //! Increases or decreases the luminosity of . - //! is a signed percentage. - Standard_EXPORT void IncreaseShine (const Standard_Real ADelta); - + + //! Creates a generic material. + Standard_EXPORT Graphic3d_MaterialAspect (const Graphic3d_NameOfMaterial theName); + + //! Returns the material name (within predefined enumeration). + Graphic3d_NameOfMaterial Name() const { return myMaterialName; } + + //! Returns the material name within predefined enumeration which has been requested (before modifications). + Graphic3d_NameOfMaterial RequestedName() const { return myRequestedMaterialName; } + + //! Returns the given name of this material. This might be: + //! - given name set by method ::SetMaterialName() + //! - standard name for a material within enumeration + //! - "UserDefined" for non-standard material without name specified externally. + const TCollection_AsciiString& StringName() const { return myStringName; } + + //! Returns the given name of this material. This might be: + Standard_CString MaterialName() const { return myStringName.ToCString(); } + + //! The current material become a "UserDefined" material. + //! Set the name of the "UserDefined" material. + void SetMaterialName (const TCollection_AsciiString& theName) + { + // if a component of a "standard" material change, the + // result is no more standard (a blue gold is not a gold) + myMaterialName = Graphic3d_NOM_UserDefined; + myStringName = theName; + } + + //! Resets the material with the original values according to + //! the material name but leave the current color values untouched + //! for the material of type ASPECT. + void Reset() + { + init (myRequestedMaterialName); + } + + //! Returns the diffuse color of the surface. + const Quantity_Color& Color() const { return myColors[Graphic3d_TOR_DIFFUSE]; } + + //! Modifies the ambient and diffuse color of the surface. + Standard_EXPORT void SetColor (const Quantity_Color& theColor); + + //! Returns the transparency coefficient of the surface. + Standard_ShortReal Transparency() const { return myTransparencyCoef; } + + //! Modifies the transparency coefficient of the surface, where 0 is opaque and 1 is fully transparent. + //! Transparency is applicable to materials that have at least one of reflection modes (ambient, diffuse, specular or emissive) enabled. + //! See also SetReflectionModeOn() and SetReflectionModeOff() methods. + //! + //! Warning: Raises MaterialDefinitionError if given value is a negative value or greater than 1.0. + Standard_EXPORT void SetTransparency (const Standard_ShortReal theValue); + + //! Returns the ambient color of the surface. + const Quantity_Color& AmbientColor() const { return myColors[Graphic3d_TOR_AMBIENT]; } + + //! Modifies the ambient color of the surface. + Standard_EXPORT void SetAmbientColor (const Quantity_Color& theColor); + + //! Returns the diffuse color of the surface. + const Quantity_Color& DiffuseColor() const { return myColors[Graphic3d_TOR_DIFFUSE]; } + + //! Modifies the diffuse color of the surface. + Standard_EXPORT void SetDiffuseColor (const Quantity_Color& theColor); + + //! Returns the specular color of the surface. + const Quantity_Color& SpecularColor() const { return myColors[Graphic3d_TOR_SPECULAR]; } + + //! Modifies the specular color of the surface. + Standard_EXPORT void SetSpecularColor (const Quantity_Color& theColor); + + //! Returns the emissive color of the surface. + const Quantity_Color& EmissiveColor() const { return myColors[Graphic3d_TOR_EMISSION]; } + + //! Modifies the emissive color of the surface. + Standard_EXPORT void SetEmissiveColor (const Quantity_Color& theColor); + + //! Returns the reflection properties of the surface. + Standard_ShortReal Ambient() const { return myColorCoef[Graphic3d_TOR_AMBIENT]; } + //! Modifies the reflection properties of the surface. - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is - //! a negative value or greater than 1.0. - Standard_EXPORT void SetAmbient (const Standard_Real AValue); - + //! Warning: Raises MaterialDefinitionError if given value is a negative value or greater than 1.0. + Standard_EXPORT void SetAmbient (const Standard_ShortReal theValue); + + //! Returns the reflection properties of the surface. + Standard_ShortReal Diffuse() const { return myColorCoef[Graphic3d_TOR_DIFFUSE]; } + //! Modifies the reflection properties of the surface. - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is a - //! negative value or greater than 1.0. - Standard_EXPORT void SetDiffuse (const Standard_Real AValue); - + //! Warning: Raises MaterialDefinitionError if given value is a negative value or greater than 1.0. + Standard_EXPORT void SetDiffuse (const Standard_ShortReal theValue); + + //! Returns the reflection properties of the surface. + Standard_ShortReal Specular() const { return myColorCoef[Graphic3d_TOR_SPECULAR]; } + //! Modifies the reflection properties of the surface. - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is a - //! negative value or greater than 1.0. - Standard_EXPORT void SetEmissive (const Standard_Real AValue); - + //! Warning: Raises MaterialDefinitionError if given value is a negative value or greater than 1.0. + Standard_EXPORT void SetSpecular (const Standard_ShortReal theValue); + + //! Returns the emissive coefficient of the surface. + Standard_ShortReal Emissive() const { return myColorCoef[Graphic3d_TOR_EMISSION]; } + + //! Modifies the reflection properties of the surface. + //! Warning: Raises MaterialDefinitionError if given value is a negative value or greater than 1.0. + Standard_EXPORT void SetEmissive (const Standard_ShortReal theValue); + + //! Returns the luminosity of the surface. + Standard_ShortReal Shininess() const { return myShininess; } + //! Modifies the luminosity of the surface. - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is a - //! negative value or greater than 1.0. - Standard_EXPORT void SetShininess (const Standard_Real AValue); - - //! Modifies the reflection properties of the surface. - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is a - //! negative value or greater than 1.0. - Standard_EXPORT void SetSpecular (const Standard_Real AValue); - - //! Modifies the transparency coefficient of the surface. - //! = 0. opaque. (default) - //! = 1. transparent. - //! Transparency is applicable to materials that have at least - //! one of reflection modes (ambient, diffuse, specular or emissive) - //! enabled. See also SetReflectionModeOn() and SetReflectionModeOff() methods. - //! - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is a - //! negative value or greater than 1.0. - Standard_EXPORT void SetTransparency (const Standard_Real AValue); - + //! Warning: Raises MaterialDefinitionError if given value is a negative value or greater than 1.0. + Standard_EXPORT void SetShininess (const Standard_ShortReal theValue); + + //! Increases or decreases the luminosity. + //! @param theDelta a signed percentage + Standard_EXPORT void IncreaseShine (const Standard_ShortReal theDelta); + + //! Returns the refraction index of the material + Standard_ShortReal RefractionIndex() const { return myRefractionIndex; } + //! Modifies the refraction index of the material. - //! Category: Methods to modify the class definition - //! Warning: Raises MaterialDefinitionError if is a - //! lesser than 1.0. - Standard_EXPORT void SetRefractionIndex (const Standard_Real theValue); - + //! Warning: Raises MaterialDefinitionError if given value is a lesser than 1.0. + Standard_EXPORT void SetRefractionIndex (const Standard_ShortReal theValue); + + //! Returns BSDF (bidirectional scattering distribution function). + const Graphic3d_BSDF& BSDF() const { return myBSDF; } + //! Modifies the BSDF (bidirectional scattering distribution function). - //! Category: Methods to modify the class definition - Standard_EXPORT void SetBSDF (const Graphic3d_BSDF& theBSDF); - - //! Modifies the ambient and diffuse colour of the surface. - //! Category: Methods to modify the class definition - Standard_EXPORT void SetColor (const Quantity_Color& AColor); - - //! Modifies the ambient colour of the surface. - Standard_EXPORT void SetAmbientColor (const Quantity_Color& AColor); - - //! Modifies the difuse colour of the surface. - Standard_EXPORT void SetDiffuseColor (const Quantity_Color& AColor); - - //! Modifies the specular colour of the surface. - Standard_EXPORT void SetSpecularColor (const Quantity_Color& AColor); - - //! Modifies the emissive colour of the surface. - Standard_EXPORT void SetEmissiveColor (const Quantity_Color& AColor); - - //! Activates the reflective properties of the surface . + void SetBSDF (const Graphic3d_BSDF& theBSDF) { myBSDF = theBSDF; } + + //! Returns TRUE if the reflection mode is active, FALSE otherwise. + Standard_Boolean ReflectionMode (const Graphic3d_TypeOfReflection theType) const + { + return myReflActivity[theType]; + } + + //! Activates or deactivates the reflective properties of the surface with specified reflection type. //! - //! TypeOfReflection : TOR_AMBIENT - //! TOR_DIFFUSE - //! TOR_SPECULAR - //! TOR_EMISSION - //! 1, 2, 3 or 4 types of reflection can be set for a given surface. - Standard_EXPORT void SetReflectionModeOn (const Graphic3d_TypeOfReflection AType); - - //! Deactivates the reflective properties of - //! the surface . - //! - //! TypeOfReflection : TOR_AMBIENT - //! TOR_DIFFUSE - //! TOR_SPECULAR - //! TOR_EMISSION - //! 1, 2, 3 or 4 types of reflection can be set off for a given surface. //! Disabling diffuse and specular reflectance is useful for efficient visualization //! of large amounts of data as definition of normals for graphic primitives is not needed //! when only "all-directional" reflectance is active. @@ -150,159 +193,87 @@ public: //! NOTE: Disabling all four reflection modes also turns off the following effects: //! 1. Lighting. Colors of primitives are not affected by the material properties when lighting is off. //! 2. Transparency. - Standard_EXPORT void SetReflectionModeOff (const Graphic3d_TypeOfReflection AType); - - //! Set MyMaterialType to the value of parameter - //! - //! TypeOfMaterial : MATERIAL_ASPECT - //! MATERIAL_PHYSIC - Standard_EXPORT void SetMaterialType (const Graphic3d_TypeOfMaterial AType); - - //! The current matarial become a "UserDefined" material. - //! Set the name of the "UserDefined" material. - Standard_EXPORT void SetMaterialName (const Standard_CString AName); - - Standard_EXPORT void SetEnvReflexion (const Standard_ShortReal AValue); - - //! Resets the material with the original values according to - //! the material name but leave the current color values untouched - //! for the material of type ASPECT. - Standard_EXPORT void Reset(); - - //! Returns the diffuse colour of the surface. - Standard_EXPORT const Quantity_Color& Color() const; - - //! Returns the ambient colour of the surface. - Standard_EXPORT const Quantity_Color& AmbientColor() const; - - //! Returns the diffuse colour of the surface. - Standard_EXPORT const Quantity_Color& DiffuseColor() const; - - //! Returns the specular colour of the surface. - Standard_EXPORT const Quantity_Color& SpecularColor() const; - - //! Returns the emissive colour of the surface. - Standard_EXPORT const Quantity_Color& EmissiveColor() const; - - //! Returns the reflection properties of the surface. - Standard_EXPORT Standard_Real Ambient() const; - - //! Returns the reflection properties of the surface. - Standard_EXPORT Standard_Real Diffuse() const; - - //! Returns the reflection properties of the surface. - Standard_EXPORT Standard_Real Specular() const; - - //! Returns the transparency coefficient of the surface. - Standard_EXPORT Standard_Real Transparency() const; - - //! Returns the refraction index of the material - Standard_EXPORT Standard_Real RefractionIndex() const; - - //! Returns BSDF (bidirectional scattering distribution function). - Standard_EXPORT const Graphic3d_BSDF& BSDF() const; - - //! Returns the emissive coefficient of the surface. - Standard_EXPORT Standard_Real Emissive() const; - - //! Returns the luminosity of the surface. - Standard_EXPORT Standard_Real Shininess() const; - - //! Returns Standard_True if the reflection mode is active, - //! Standard_False otherwise. - Standard_EXPORT Standard_Boolean ReflectionMode (const Graphic3d_TypeOfReflection AType) const; - - //! Returns Standard_True if MyMaterialType equal the parameter AType, - //! Standard_False otherwise. - Standard_EXPORT Standard_Boolean MaterialType (const Graphic3d_TypeOfMaterial AType) const; - - Standard_EXPORT Standard_ShortReal EnvReflexion() const; - - //! Returns the material name. - Standard_EXPORT Graphic3d_NameOfMaterial Name() const; - - //! Returns Standard_True if the materials and - //! are different. - Standard_EXPORT Standard_Boolean IsDifferent (const Graphic3d_MaterialAspect& Other) const; -Standard_Boolean operator != (const Graphic3d_MaterialAspect& Other) const -{ - return IsDifferent(Other); -} - - //! Returns Standard_True if the materials and - //! are identical. - Standard_EXPORT Standard_Boolean IsEqual (const Graphic3d_MaterialAspect& Other) const; -Standard_Boolean operator == (const Graphic3d_MaterialAspect& Other) const -{ - return IsEqual(Other); -} - + Standard_EXPORT void SetReflectionMode (const Graphic3d_TypeOfReflection theType, + const Standard_Boolean theValue); - //! Returns the number of predefined textures. - Standard_EXPORT static Standard_Integer NumberOfMaterials(); + //! Activates the reflective properties of the surface with specified reflection type. + void SetReflectionModeOn (const Graphic3d_TypeOfReflection theType) { SetReflectionMode (theType, Standard_True); } + //! Deactivates the reflective properties of the surface with specified reflection type. + void SetReflectionModeOff (const Graphic3d_TypeOfReflection theType) { SetReflectionMode (theType, Standard_False); } - //! Returns the name of the predefined material of rank - //! Trigger: when is < 1 or > NumberOfMaterials. - Standard_EXPORT static Standard_CString MaterialName (const Standard_Integer aRank); + //! Returns TRUE if type of this material is equal to specified type. + Standard_Boolean MaterialType (const Graphic3d_TypeOfMaterial theType) const { return myMaterialType == theType; } + + //! Set material type. + Standard_EXPORT void SetMaterialType (const Graphic3d_TypeOfMaterial theType); + + Standard_ShortReal EnvReflexion() const { return myEnvReflexion; } + + void SetEnvReflexion (const Standard_ShortReal theValue) { myEnvReflexion = theValue; } + + //! Returns TRUE if this material differs from specified one. + Standard_Boolean IsDifferent (const Graphic3d_MaterialAspect& theOther) const { return !IsEqual (theOther); } + + //! Returns TRUE if this material differs from specified one. + Standard_Boolean operator!= (const Graphic3d_MaterialAspect& theOther) const { return IsDifferent (theOther); } + //! Returns TRUE if this material is identical to specified one. + Standard_Boolean IsEqual (const Graphic3d_MaterialAspect& theOther) const + { + return myColorCoef[Graphic3d_TOR_AMBIENT] == theOther.myColorCoef[Graphic3d_TOR_AMBIENT] + && myColorCoef[Graphic3d_TOR_DIFFUSE] == theOther.myColorCoef[Graphic3d_TOR_DIFFUSE] + && myColorCoef[Graphic3d_TOR_SPECULAR] == theOther.myColorCoef[Graphic3d_TOR_SPECULAR] + && myColorCoef[Graphic3d_TOR_EMISSION] == theOther.myColorCoef[Graphic3d_TOR_EMISSION] + && myTransparencyCoef == theOther.myTransparencyCoef + && myRefractionIndex == theOther.myRefractionIndex + && myBSDF == theOther.myBSDF + && myShininess == theOther.myShininess + && myEnvReflexion == theOther.myEnvReflexion + && myColors[Graphic3d_TOR_AMBIENT] == theOther.myColors[Graphic3d_TOR_AMBIENT] + && myColors[Graphic3d_TOR_DIFFUSE] == theOther.myColors[Graphic3d_TOR_DIFFUSE] + && myColors[Graphic3d_TOR_SPECULAR] == theOther.myColors[Graphic3d_TOR_SPECULAR] + && myColors[Graphic3d_TOR_EMISSION] == theOther.myColors[Graphic3d_TOR_EMISSION] + && myReflActivity[Graphic3d_TOR_AMBIENT] == theOther.myReflActivity[Graphic3d_TOR_AMBIENT] + && myReflActivity[Graphic3d_TOR_DIFFUSE] == theOther.myReflActivity[Graphic3d_TOR_DIFFUSE] + && myReflActivity[Graphic3d_TOR_SPECULAR] == theOther.myReflActivity[Graphic3d_TOR_SPECULAR] + && myReflActivity[Graphic3d_TOR_EMISSION] == theOther.myReflActivity[Graphic3d_TOR_EMISSION]; + } - //! Returns the name of this material - Standard_EXPORT Standard_CString MaterialName() const; - - - //! Returns the type of the predefined material of rank - //! Trigger: when is < 1 or > NumberOfMaterials. - Standard_EXPORT static Graphic3d_TypeOfMaterial MaterialType (const Standard_Integer aRank); - - - //! Returns the material for specified name or Graphic3d_NOM_DEFAULT if name is unknown. - Standard_EXPORT static Graphic3d_NameOfMaterial MaterialFromName (const Standard_CString theName); - - - - -protected: - - - - + //! Returns TRUE if this material is identical to specified one. + Standard_Boolean operator== (const Graphic3d_MaterialAspect& theOther) const { return IsEqual (theOther); } private: - - Standard_EXPORT void Init (const Graphic3d_NameOfMaterial AName); + //! Initialize the standard material. + Standard_EXPORT void init (const Graphic3d_NameOfMaterial theName); + //! Mark material as user defined. + void setUserMaterial() + { + // if a component of a "standard" material change, the + // result is no more standard (a blue gold is not a gold) + myMaterialName = Graphic3d_NOM_UserDefined; + myStringName = "UserDefined"; + } + +private: + + Graphic3d_BSDF myBSDF; + TCollection_AsciiString myStringName; + Quantity_Color myColors [Graphic3d_TypeOfReflection_NB]; + Standard_ShortReal myColorCoef[Graphic3d_TypeOfReflection_NB]; + Standard_ShortReal myTransparencyCoef; + Standard_ShortReal myRefractionIndex; + Standard_ShortReal myShininess; + Standard_ShortReal myEnvReflexion; - Standard_ShortReal myDiffuseCoef; - Quantity_Color myDiffuseColor; - Standard_Boolean myDiffuseActivity; - Standard_ShortReal myAmbientCoef; - Quantity_Color myAmbientColor; - Standard_Boolean myAmbientActivity; - Standard_ShortReal mySpecularCoef; - Quantity_Color mySpecularColor; - Standard_Boolean mySpecularActivity; - Standard_ShortReal myEmissiveCoef; - Quantity_Color myEmissiveColor; - Standard_Boolean myEmissiveActivity; - Standard_ShortReal myTransparencyCoef; - Standard_ShortReal myRefractionIndex; - Graphic3d_BSDF myBSDF; - Standard_ShortReal myShininess; - Standard_ShortReal myEnvReflexion; Graphic3d_TypeOfMaterial myMaterialType; Graphic3d_NameOfMaterial myMaterialName; Graphic3d_NameOfMaterial myRequestedMaterialName; - TCollection_AsciiString myStringName; + Standard_Boolean myReflActivity[Graphic3d_TypeOfReflection_NB]; }; - - - - - - #endif // _Graphic3d_MaterialAspect_HeaderFile diff --git a/src/Graphic3d/Graphic3d_TypeOfReflection.hxx b/src/Graphic3d/Graphic3d_TypeOfReflection.hxx index da4846fe4d..3ead37dea6 100644 --- a/src/Graphic3d/Graphic3d_TypeOfReflection.hxx +++ b/src/Graphic3d/Graphic3d_TypeOfReflection.hxx @@ -20,10 +20,15 @@ //! Nature of the reflection of a material. enum Graphic3d_TypeOfReflection { -Graphic3d_TOR_AMBIENT, -Graphic3d_TOR_DIFFUSE, -Graphic3d_TOR_SPECULAR, -Graphic3d_TOR_EMISSION + Graphic3d_TOR_AMBIENT = 0, + Graphic3d_TOR_DIFFUSE, + Graphic3d_TOR_SPECULAR, + Graphic3d_TOR_EMISSION +}; + +enum +{ + Graphic3d_TypeOfReflection_NB = 4 }; #endif // _Graphic3d_TypeOfReflection_HeaderFile diff --git a/src/OpenGl/OpenGl_AspectFace.cxx b/src/OpenGl/OpenGl_AspectFace.cxx index a085a4fe37..c262d76489 100644 --- a/src/OpenGl/OpenGl_AspectFace.cxx +++ b/src/OpenGl/OpenGl_AspectFace.cxx @@ -38,16 +38,16 @@ namespace { Graphic3d_MaterialAspect aMat; aMat.SetMaterialType (Graphic3d_MATERIAL_ASPECT); - aMat.SetAmbient (0.2); - aMat.SetDiffuse (0.8); - aMat.SetSpecular (0.1); - aMat.SetEmissive (0.0); + aMat.SetAmbient (0.2f); + aMat.SetDiffuse (0.8f); + aMat.SetSpecular (0.1f); + aMat.SetEmissive (0.0f); aMat.SetAmbientColor (Quantity_NOC_WHITE); aMat.SetDiffuseColor (Quantity_NOC_WHITE); aMat.SetEmissiveColor(Quantity_NOC_WHITE); aMat.SetSpecularColor(Quantity_NOC_WHITE); - aMat.SetShininess (10.0 / 128.0); - aMat.SetRefractionIndex (1.0); + aMat.SetShininess (10.0f / 128.0f); + aMat.SetRefractionIndex (1.0f); return aMat; } diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 43ae9fa763..723174dd3e 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -2877,8 +2877,8 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect, } // handling transparency - float aTranspFront = (float )aMatFrontSrc.Transparency(); - float aTranspBack = (float )aMatBackSrc .Transparency(); + float aTranspFront = aMatFrontSrc.Transparency(); + float aTranspBack = aMatBackSrc .Transparency(); if (!theHighlight.IsNull() && theHighlight->BasicFillAreaAspect().IsNull()) { diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index f059750646..2094fe1955 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -75,13 +75,13 @@ namespace void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat, const Quantity_Color& theInteriorColor) { - const bool isPhysic = theMat.MaterialType (Graphic3d_MATERIAL_PHYSIC) == Standard_True; + const bool isPhysic = theMat.MaterialType (Graphic3d_MATERIAL_PHYSIC); // ambient component if (theMat.ReflectionMode (Graphic3d_TOR_AMBIENT)) { const OpenGl_Vec3& aSrcAmb = isPhysic ? theMat.AmbientColor() : theInteriorColor; - Ambient = OpenGl_Vec4 (aSrcAmb * (float )theMat.Ambient(), 1.0f); + Ambient = OpenGl_Vec4 (aSrcAmb * theMat.Ambient(), 1.0f); } else { @@ -92,7 +92,7 @@ void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat, if (theMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)) { const OpenGl_Vec3& aSrcDif = isPhysic ? theMat.DiffuseColor() : theInteriorColor; - Diffuse = OpenGl_Vec4 (aSrcDif * (float )theMat.Diffuse(), 1.0f); + Diffuse = OpenGl_Vec4 (aSrcDif * theMat.Diffuse(), 1.0f); } else { @@ -103,7 +103,7 @@ void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat, if (theMat.ReflectionMode (Graphic3d_TOR_SPECULAR)) { const OpenGl_Vec3& aSrcSpe = isPhysic ? (const OpenGl_Vec3& )theMat.SpecularColor() : THE_WHITE_COLOR.rgb(); - Specular = OpenGl_Vec4 (aSrcSpe * (float )theMat.Specular(), 1.0f); + Specular = OpenGl_Vec4 (aSrcSpe * theMat.Specular(), 1.0f); } else { @@ -114,15 +114,15 @@ void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat, if (theMat.ReflectionMode (Graphic3d_TOR_EMISSION)) { const OpenGl_Vec3& aSrcEms = isPhysic ? theMat.EmissiveColor() : theInteriorColor; - Emission = OpenGl_Vec4 (aSrcEms * (float )theMat.Emissive(), 1.0f); + Emission = OpenGl_Vec4 (aSrcEms * theMat.Emissive(), 1.0f); } else { Emission = THE_BLACK_COLOR; } - ChangeShine() = 128.0f * float(theMat.Shininess()); - ChangeTransparency() = 1.0f - (float )theMat.Transparency(); + ChangeShine() = 128.0f * theMat.Shininess(); + ChangeTransparency() = 1.0f - theMat.Transparency(); } // ======================================================================= diff --git a/src/Prs3d/FILES b/src/Prs3d/FILES index d534f2e5c6..e6498f3831 100755 --- a/src/Prs3d/FILES +++ b/src/Prs3d/FILES @@ -13,7 +13,6 @@ Prs3d_DimensionAspect.cxx Prs3d_DimensionAspect.hxx Prs3d_DimensionTextHorizontalPosition.hxx Prs3d_DimensionTextVerticalPosition.hxx -Prs3d_DimensionUnits.cxx Prs3d_DimensionUnits.hxx Prs3d_Drawer.cxx Prs3d_Drawer.hxx @@ -26,8 +25,6 @@ Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx Prs3d_NListOfSequenceOfPnt.hxx Prs3d_PlaneAspect.cxx Prs3d_PlaneAspect.hxx -Prs3d_PlaneSet.cxx -Prs3d_PlaneSet.hxx Prs3d_Point.hxx Prs3d_PointAspect.cxx Prs3d_PointAspect.hxx diff --git a/src/Prs3d/Prs3d_ArrowAspect.cxx b/src/Prs3d/Prs3d_ArrowAspect.cxx index 49fff02c3a..f1eabad73d 100644 --- a/src/Prs3d/Prs3d_ArrowAspect.cxx +++ b/src/Prs3d/Prs3d_ArrowAspect.cxx @@ -12,72 +12,56 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include #include + #include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ArrowAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ArrowAspect, Prs3d_BasicAspect) -Prs3d_ArrowAspect::Prs3d_ArrowAspect () - : myAngle(M_PI/180.*10), myLength(1.) { - myArrowAspect = - new Graphic3d_AspectLine3d ( - Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0); -} - - -Prs3d_ArrowAspect::Prs3d_ArrowAspect (const Quantity_PlaneAngle anAngle, - const Quantity_Length aLength) - : myAngle(anAngle), myLength(aLength) { - myArrowAspect = - new Graphic3d_AspectLine3d ( - Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0); -} - -Prs3d_ArrowAspect::Prs3d_ArrowAspect( const Handle( Graphic3d_AspectLine3d )& theAspect ) - : myAngle(M_PI/180.*10), myLength(1.) +// ======================================================================= +// function : Prs3d_ArrowAspect +// purpose : +// ======================================================================= +Prs3d_ArrowAspect::Prs3d_ArrowAspect() +: myArrowAspect (new Graphic3d_AspectLine3d (Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0)), + myAngle (M_PI / 180.0 * 10.0), + myLength(1.0) { - myArrowAspect = theAspect; + // } -void Prs3d_ArrowAspect::SetAngle ( const Quantity_PlaneAngle anAngle) { - Prs3d_InvalidAngle_Raise_if ( anAngle <= 0. || - anAngle >= M_PI /2. , ""); - myAngle = anAngle; -} -Quantity_PlaneAngle Prs3d_ArrowAspect::Angle () const +// ======================================================================= +// function : Prs3d_ArrowAspect +// purpose : +// ======================================================================= +Prs3d_ArrowAspect::Prs3d_ArrowAspect (const Quantity_PlaneAngle theAngle, + const Quantity_Length theLength) +: myArrowAspect (new Graphic3d_AspectLine3d (Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0)), + myAngle (theAngle), + myLength(theLength) { -return myAngle; + // } -void Prs3d_ArrowAspect::SetLength ( const Quantity_Length aLength) +// ======================================================================= +// function : Prs3d_ArrowAspect +// purpose : +// ======================================================================= +Prs3d_ArrowAspect::Prs3d_ArrowAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) +: myArrowAspect (theAspect), + myAngle (M_PI / 180.0 * 10.0), + myLength(1.0) { - myLength = aLength; + // } -Quantity_Length Prs3d_ArrowAspect::Length () const + +// ======================================================================= +// function : SetAngle +// purpose : +// ======================================================================= +void Prs3d_ArrowAspect::SetAngle (const Quantity_PlaneAngle theAngle) { -return myLength; + Prs3d_InvalidAngle_Raise_if (theAngle <= 0.0 + || theAngle >= M_PI / 2.0, "Prs3d_ArrowAspect::SetAngle() - angle out of range"); + myAngle = theAngle; } - - -void Prs3d_ArrowAspect::SetColor(const Quantity_Color &aColor) { - myArrowAspect->SetColor(aColor); -} - -void Prs3d_ArrowAspect::SetColor(const Quantity_NameOfColor aColor) { - SetColor(Quantity_Color(aColor)); -} - -Handle(Graphic3d_AspectLine3d) Prs3d_ArrowAspect::Aspect() const { - return myArrowAspect; -} - - -void Prs3d_ArrowAspect::SetAspect( const Handle( Graphic3d_AspectLine3d )& theAspect ) -{ - myArrowAspect = theAspect; -} - diff --git a/src/Prs3d/Prs3d_ArrowAspect.hxx b/src/Prs3d/Prs3d_ArrowAspect.hxx index f1c448f48e..f4e355db4b 100644 --- a/src/Prs3d/Prs3d_ArrowAspect.hxx +++ b/src/Prs3d/Prs3d_ArrowAspect.hxx @@ -17,29 +17,18 @@ #ifndef _Prs3d_ArrowAspect_HeaderFile #define _Prs3d_ArrowAspect_HeaderFile -#include -#include - +#include +#include #include #include -#include #include -class Graphic3d_AspectLine3d; -class Prs3d_InvalidAngle; -class Quantity_Color; - -class Prs3d_ArrowAspect; -DEFINE_STANDARD_HANDLE(Prs3d_ArrowAspect, Prs3d_BasicAspect) - -//! A framework for displaying arrows in representations -//! of dimensions and relations. +//! A framework for displaying arrows in representations of dimensions and relations. class Prs3d_ArrowAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_ArrowAspect, Prs3d_BasicAspect) public: - //! Constructs an empty framework for displaying arrows //! in representations of lengths. The lengths displayed //! are either on their own or in chamfers, fillets, @@ -57,46 +46,30 @@ public: Standard_EXPORT void SetAngle (const Quantity_PlaneAngle anAngle); //! returns the current value of the angle used when drawing an arrow. - Standard_EXPORT Quantity_PlaneAngle Angle() const; - - //! defines the length of the arrows. - Standard_EXPORT void SetLength (const Quantity_Length aLength); - - //! returns the current value of the length used when drawing an arrow. - Standard_EXPORT Quantity_Length Length() const; - - Standard_EXPORT void SetColor (const Quantity_Color& aColor); - - Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor); - - Standard_EXPORT Handle(Graphic3d_AspectLine3d) Aspect() const; - - Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect); + Quantity_PlaneAngle Angle() const { return myAngle; } + //! Defines the length of the arrows. + void SetLength (const Quantity_Length theLength) { myLength = theLength; } + //! Returns the current value of the length used when drawing an arrow. + Quantity_Length Length() const { return myLength; } + void SetColor (const Quantity_Color& theColor) { myArrowAspect->SetColor (theColor); } - DEFINE_STANDARD_RTTIEXT(Prs3d_ArrowAspect,Prs3d_BasicAspect) + void SetColor (const Quantity_NameOfColor theColor) { SetColor (Quantity_Color (theColor)); } + + const Handle(Graphic3d_AspectLine3d)& Aspect() const { return myArrowAspect; } + + void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { myArrowAspect = theAspect; } protected: - - - -private: - - Handle(Graphic3d_AspectLine3d) myArrowAspect; Quantity_PlaneAngle myAngle; Quantity_Length myLength; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_ArrowAspect, Prs3d_BasicAspect) #endif // _Prs3d_ArrowAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_BasicAspect.cxx b/src/Prs3d/Prs3d_BasicAspect.cxx index 6e2216850e..29bf345d4b 100644 --- a/src/Prs3d/Prs3d_BasicAspect.cxx +++ b/src/Prs3d/Prs3d_BasicAspect.cxx @@ -11,8 +11,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_BasicAspect,MMgt_TShared) \ No newline at end of file +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_BasicAspect, Standard_Transient) diff --git a/src/Prs3d/Prs3d_BasicAspect.hxx b/src/Prs3d/Prs3d_BasicAspect.hxx index 6e41ea7c6b..7578c71a20 100644 --- a/src/Prs3d/Prs3d_BasicAspect.hxx +++ b/src/Prs3d/Prs3d_BasicAspect.hxx @@ -18,43 +18,15 @@ #include #include - -#include - - -class Prs3d_BasicAspect; -DEFINE_STANDARD_HANDLE(Prs3d_BasicAspect, MMgt_TShared) +#include //! All basic Prs3d_xxxAspect must inherits from this class -//! The aspect classes qualifies how to represent -//! a given kind of object. -class Prs3d_BasicAspect : public MMgt_TShared +//! The aspect classes qualifies how to represent a given kind of object. +class Prs3d_BasicAspect : public Standard_Transient { - -public: - - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_BasicAspect,MMgt_TShared) - -protected: - - - - -private: - - - - + DEFINE_STANDARD_RTTIEXT(Prs3d_BasicAspect, Standard_Transient) }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_BasicAspect, Standard_Transient) #endif // _Prs3d_BasicAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_DatumAspect.cxx b/src/Prs3d/Prs3d_DatumAspect.cxx index 4736cf515b..2a40147cd5 100644 --- a/src/Prs3d/Prs3d_DatumAspect.cxx +++ b/src/Prs3d/Prs3d_DatumAspect.cxx @@ -12,13 +12,14 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) +// ======================================================================= +// function : Prs3d_DatumAspect +// purpose : +// ======================================================================= Prs3d_DatumAspect::Prs3d_DatumAspect() : myDrawFirstAndSecondAxis (Standard_True), myDrawThirdAxis (Standard_True), @@ -31,86 +32,3 @@ Prs3d_DatumAspect::Prs3d_DatumAspect() mySecondAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0); myThirdAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0); } - -Handle(Prs3d_LineAspect) Prs3d_DatumAspect::FirstAxisAspect() const { - - return myFirstAxisAspect; -} - -Handle(Prs3d_LineAspect) Prs3d_DatumAspect::SecondAxisAspect() const { - - return mySecondAxisAspect; -} - -Handle(Prs3d_LineAspect) Prs3d_DatumAspect::ThirdAxisAspect() const { - - return myThirdAxisAspect; - -} -Standard_Boolean Prs3d_DatumAspect::DrawFirstAndSecondAxis () const { - - return myDrawFirstAndSecondAxis; - -} - -void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (const Standard_Boolean draw) -{ - myDrawFirstAndSecondAxis = draw; -} - -Standard_Boolean Prs3d_DatumAspect::DrawThirdAxis () const { - - return myDrawThirdAxis; - -} - -void Prs3d_DatumAspect::SetDrawThirdAxis (const Standard_Boolean draw) -{ - myDrawThirdAxis = draw; -} - -void Prs3d_DatumAspect::SetAxisLength (const Quantity_Length L1, - const Quantity_Length L2, - const Quantity_Length L3) { - - myFirstAxisLength = L1; - mySecondAxisLength = L2; - myThirdAxisLength = L3; -} - - -Quantity_Length Prs3d_DatumAspect::FirstAxisLength () const { - - return myFirstAxisLength; - -} - -Quantity_Length Prs3d_DatumAspect::SecondAxisLength () const { - - return mySecondAxisLength; - -} - -Quantity_Length Prs3d_DatumAspect::ThirdAxisLength () const { - - return myThirdAxisLength; - -} - -//======================================================================= -//function : SetToDrawLabels -//purpose : -//======================================================================= -void Prs3d_DatumAspect::SetToDrawLabels (const Standard_Boolean theToDraw) -{ - myToDrawLabels = theToDraw; -} - -//======================================================================= -//function : ToDrawLabels -//purpose : -//======================================================================= -Standard_Boolean Prs3d_DatumAspect::ToDrawLabels() const -{ - return myToDrawLabels; -} diff --git a/src/Prs3d/Prs3d_DatumAspect.hxx b/src/Prs3d/Prs3d_DatumAspect.hxx index 50f0b25f65..52e2d4647e 100644 --- a/src/Prs3d/Prs3d_DatumAspect.hxx +++ b/src/Prs3d/Prs3d_DatumAspect.hxx @@ -19,66 +19,64 @@ #include #include - #include #include #include +#include #include -class Prs3d_LineAspect; - - -class Prs3d_DatumAspect; -DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect) //! A framework to define the display of datums. class Prs3d_DatumAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) public: //! An empty framework to define the display of datums. Standard_EXPORT Prs3d_DatumAspect(); //! Returns the attributes for display of the first axis. - Standard_EXPORT Handle(Prs3d_LineAspect) FirstAxisAspect() const; + const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myFirstAxisAspect; } //! Returns the attributes for display of the second axis. - Standard_EXPORT Handle(Prs3d_LineAspect) SecondAxisAspect() const; + const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return mySecondAxisAspect; } //! Returns the attributes for display of the third axis. - Standard_EXPORT Handle(Prs3d_LineAspect) ThirdAxisAspect() const; + const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myThirdAxisAspect; } //! Sets the DrawFirstAndSecondAxis attributes to active. - Standard_EXPORT void SetDrawFirstAndSecondAxis (const Standard_Boolean draw); + void SetDrawFirstAndSecondAxis (const Standard_Boolean theToDraw) { myDrawFirstAndSecondAxis = theToDraw; } //! Returns true if the first and second axes can be drawn. - Standard_EXPORT Standard_Boolean DrawFirstAndSecondAxis() const; - + Standard_Boolean DrawFirstAndSecondAxis() const { return myDrawFirstAndSecondAxis; } + //! Sets the DrawThirdAxis attributes to active. - Standard_EXPORT void SetDrawThirdAxis (const Standard_Boolean draw); + void SetDrawThirdAxis (const Standard_Boolean theToDraw) { myDrawThirdAxis = theToDraw; } //! Returns true if the third axis can be drawn. - Standard_EXPORT Standard_Boolean DrawThirdAxis() const; - - //! Sets the lengths L1, L2 and L3 of the three axes. - Standard_EXPORT void SetAxisLength (const Standard_Real L1, const Standard_Real L2, const Standard_Real L3); - + Standard_Boolean DrawThirdAxis() const { return myDrawThirdAxis; } + + //! Sets the lengths of the three axes. + void SetAxisLength (const Standard_Real theL1, const Standard_Real theL2, const Standard_Real theL3) + { + myFirstAxisLength = theL1; + mySecondAxisLength = theL2; + myThirdAxisLength = theL3; + } + //! Returns the length of the displayed first axis. - Standard_EXPORT Quantity_Length FirstAxisLength() const; - + Quantity_Length FirstAxisLength() const { return myFirstAxisLength; } + //! Returns the length of the displayed second axis. - Standard_EXPORT Quantity_Length SecondAxisLength() const; + Quantity_Length SecondAxisLength() const { return mySecondAxisLength; } //! Returns the length of the displayed third axis. - Standard_EXPORT Quantity_Length ThirdAxisLength() const; + Quantity_Length ThirdAxisLength() const { return myThirdAxisLength; } //! Sets option to draw or not to draw text labels for axes - Standard_EXPORT void SetToDrawLabels (const Standard_Boolean theToDraw); + void SetToDrawLabels (const Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; } //! @return true if axes labels are drawn - Standard_EXPORT Standard_Boolean ToDrawLabels() const; - - DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect,Prs3d_BasicAspect) + Standard_Boolean ToDrawLabels() const { return myToDrawLabels; } private: @@ -94,10 +92,6 @@ private: }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect) #endif // _Prs3d_DatumAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_DimensionAspect.cxx b/src/Prs3d/Prs3d_DimensionAspect.cxx index 2e6af161ec..6e1141f9cd 100755 --- a/src/Prs3d/Prs3d_DimensionAspect.cxx +++ b/src/Prs3d/Prs3d_DimensionAspect.cxx @@ -14,42 +14,38 @@ #include -#include -#include -#include - #include #include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DimensionAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect) //======================================================================= //function : Constructor -//purpose : +//purpose : //======================================================================= - Prs3d_DimensionAspect::Prs3d_DimensionAspect() +: myLineAspect (new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN, Aspect_TOL_SOLID, 1.0)), + myTextAspect (new Prs3d_TextAspect()), + myArrowAspect (new Prs3d_ArrowAspect()), + myValueStringFormat ("%g"), + myExtensionSize (6.0), + myArrowTailSize (6.0), + myArrowOrientation (Prs3d_DAO_Fit), + myTextHPosition (Prs3d_DTHP_Fit), + myTextVPosition (Prs3d_DTVP_Center), + myToDisplayUnits (Standard_False), + myIsText3d (Standard_False), + myIsTextShaded (Standard_False), + myIsArrows3d (Standard_False) { - myTextHPosition = Prs3d_DTHP_Fit; - myTextVPosition = Prs3d_DTVP_Center; - myArrowOrientation = Prs3d_DAO_Fit; - - myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); - myTextAspect = new Prs3d_TextAspect; myTextAspect->Aspect()->SetTextZoomable (Standard_False); myTextAspect->SetColor (Quantity_NOC_LAWNGREEN); myTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER); - myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); - myArrowAspect = new Prs3d_ArrowAspect; + myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); + myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN); myArrowAspect->SetAngle (M_PI * 12.0 / 180.0); myArrowAspect->SetLength (6.0); - myExtensionSize = 6.0; - myArrowTailSize = 6.0; - myValueStringFormat = "%g"; - myToDisplayUnits = Standard_False; } //======================================================================= @@ -63,237 +59,3 @@ void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor) myTextAspect->SetColor (theColor); myArrowAspect->SetColor (theColor); } - -//======================================================================= -//function : LineAspect -//purpose : -//======================================================================= -Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const -{ - return myLineAspect; -} - -//======================================================================= -//function : SetLineAspect -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect) -{ - myLineAspect = theAspect; -} - -//======================================================================= -//function : TextAspect -//purpose : -//======================================================================= -Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const -{ - return myTextAspect; -} - -//======================================================================= -//function : SetTextAspect -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect) -{ - myTextAspect = theAspect; -} - -//======================================================================= -//function : MakeArrows3D -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d) -{ - myIsArrows3d = isArrows3d; -} - -//======================================================================= -//function : IsArrows3D -//purpose : -//======================================================================= -Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const -{ - return myIsArrows3d; -} - -//======================================================================= -//function : MakeText3D -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d) -{ - myIsText3d = isText3d; -} - -//======================================================================= -//function : IsText3D -//purpose : -//======================================================================= -Standard_Boolean Prs3d_DimensionAspect::IsText3d () const -{ - return myIsText3d; -} - -//======================================================================= -//function : IsUnitsDisplayed -//purpose : -//======================================================================= -Standard_Boolean Prs3d_DimensionAspect::IsUnitsDisplayed () const -{ - return myToDisplayUnits; -} - -//======================================================================= -//function : MakeUnitsDisplayed -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed) -{ - myToDisplayUnits = theIsDisplayed; -} - -//======================================================================= -//function : IsTextShaded -//purpose : -//======================================================================= -Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const -{ - return myIsTextShaded; -} - -//======================================================================= -//function : MakeTextShaded -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded) -{ - myIsTextShaded = isTextShaded; -} - -//======================================================================= -//function : SetArrowOrientation -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient) -{ - myArrowOrientation = theArrowOrient; -} - -//======================================================================= -//function : GetArrowOrientation -//purpose : -//======================================================================= -Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const -{ - return myArrowOrientation; -} - -//======================================================================= -//function : SetTextVerticalPosition -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition) -{ - myTextVPosition = thePosition; -} - -//======================================================================= -//function : TextVerticalPosition -//purpose : -//======================================================================= -Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const -{ - return myTextVPosition; -} - -//======================================================================= -//function : SetTextHorizontalPosition -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition) -{ - myTextHPosition = thePosition; -} - -//======================================================================= -//function : TextHorizontalPosition -//purpose : -//======================================================================= -Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const -{ - return myTextHPosition; -} - -//======================================================================= -//function : ArrowAspect -//purpose : -//======================================================================= -Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const -{ - return myArrowAspect; -} - -//======================================================================= -//function : SetArrowAspect -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) -{ - myArrowAspect = theAspect; -} - -//======================================================================= -//function : SetExtensioSize -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize) -{ - myExtensionSize = theSize; -} - -//======================================================================= -//function : ExtensionSize -//purpose : -//======================================================================= -Standard_Real Prs3d_DimensionAspect::ExtensionSize() const -{ - return myExtensionSize; -} - -//======================================================================= -//function : SetShortExtensionSize -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetArrowTailSize (const Standard_Real theSize) -{ - myArrowTailSize = theSize; -} - -//======================================================================= -//function : ShortExtensionSize -//purpose : -//======================================================================= -Standard_Real Prs3d_DimensionAspect::ArrowTailSize() const -{ - return myArrowTailSize; -} - -//======================================================================= -//function : SetValueStringFormat -//purpose : -//======================================================================= -void Prs3d_DimensionAspect::SetValueStringFormat (const TCollection_AsciiString& theFormat) -{ - myValueStringFormat = theFormat; -} - -//======================================================================= -//function : ValueStringFormat -//purpose : -//======================================================================= -TCollection_AsciiString Prs3d_DimensionAspect::ValueStringFormat() const -{ - return myValueStringFormat; -} diff --git a/src/Prs3d/Prs3d_DimensionAspect.hxx b/src/Prs3d/Prs3d_DimensionAspect.hxx index cafd3a4925..c6b80ac099 100644 --- a/src/Prs3d/Prs3d_DimensionAspect.hxx +++ b/src/Prs3d/Prs3d_DimensionAspect.hxx @@ -15,153 +15,124 @@ #ifndef _Prs3d_DimensionAspect_HeaderFile #define _Prs3d_DimensionAspect_HeaderFile -#include -#include - -#include +#include #include #include #include -#include +#include +#include #include -#include -class Prs3d_LineAspect; -class Prs3d_TextAspect; -class Prs3d_ArrowAspect; -class Quantity_Color; -class TCollection_AsciiString; - - -class Prs3d_DimensionAspect; -DEFINE_STANDARD_HANDLE(Prs3d_DimensionAspect, Prs3d_BasicAspect) //! defines the attributes when drawing a Length Presentation. class Prs3d_DimensionAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect) public: - //! Constructs an empty framework to define the display of dimensions. Standard_EXPORT Prs3d_DimensionAspect(); //! Returns the settings for the display of lines used in presentation of dimensions. - Standard_EXPORT Handle(Prs3d_LineAspect) LineAspect() const; - + const Handle(Prs3d_LineAspect)& LineAspect() const { return myLineAspect; } + //! Sets the display attributes of lines used in presentation of dimensions. - Standard_EXPORT void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect); - + void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect) { myLineAspect = theAspect; } + //! Returns the settings for the display of text used in presentation of dimensions. - Standard_EXPORT Handle(Prs3d_TextAspect) TextAspect() const; - + const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; } + //! Sets the display attributes of text used in presentation of dimensions. - Standard_EXPORT void SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect); - + void SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect) { myTextAspect = theAspect; } + //! Check if text for dimension label is 3d. - Standard_EXPORT Standard_Boolean IsText3d() const; - + Standard_Boolean IsText3d() const { return myIsText3d; } + //! Sets type of text. - Standard_EXPORT void MakeText3d (const Standard_Boolean isText3d); - + void MakeText3d (const Standard_Boolean isText3d) { myIsText3d = isText3d; } + //! Check if 3d text for dimension label is shaded. - Standard_EXPORT Standard_Boolean IsTextShaded() const; - + Standard_Boolean IsTextShaded() const { return myIsTextShaded; } + //! Turns on/off text shading for 3d text. - Standard_EXPORT void MakeTextShaded (const Standard_Boolean isTextShaded); - + void MakeTextShaded (const Standard_Boolean theIsTextShaded) { myIsTextShaded = theIsTextShaded; } + //! Gets type of arrows. - Standard_EXPORT Standard_Boolean IsArrows3d() const; - + Standard_Boolean IsArrows3d() const { return myIsArrows3d; } + //! Sets type of arrows. - Standard_EXPORT void MakeArrows3d (const Standard_Boolean isArrows3d); - + void MakeArrows3d (const Standard_Boolean theIsArrows3d) { myIsArrows3d = theIsArrows3d; } + //! Shows if Units are to be displayed along with dimension value. - Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const; + Standard_Boolean IsUnitsDisplayed() const { return myToDisplayUnits; } //! Specifies whether the units string should be displayed //! along with value label or not. - Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed); + void MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed) { myToDisplayUnits = theIsDisplayed; } //! Sets orientation of arrows (external or internal). //! By default orientation is chosen automatically according to situation and text label size. - Standard_EXPORT void SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient); - + void SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient) { myArrowOrientation = theArrowOrient; } + //! Gets orientation of arrows (external or internal). - Standard_EXPORT Prs3d_DimensionArrowOrientation ArrowOrientation() const; - + Prs3d_DimensionArrowOrientation ArrowOrientation() const { return myArrowOrientation; } + //! Sets vertical text alignment for text label. - Standard_EXPORT void SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition); - + void SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition) { myTextVPosition = thePosition; } + //! Gets vertical text alignment for text label. - Standard_EXPORT Prs3d_DimensionTextVerticalPosition TextVerticalPosition() const; - + Prs3d_DimensionTextVerticalPosition TextVerticalPosition() const { return myTextVPosition; } + //! Sets horizontal text alignment for text label. - Standard_EXPORT void SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition); - + void SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition) { myTextHPosition = thePosition; } + //! Gets horizontal text alignment for text label. - Standard_EXPORT Prs3d_DimensionTextHorizontalPosition TextHorizontalPosition() const; - + Prs3d_DimensionTextHorizontalPosition TextHorizontalPosition() const { return myTextHPosition; } + //! Returns the settings for displaying arrows. - Standard_EXPORT Handle(Prs3d_ArrowAspect) ArrowAspect() const; - + const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; } + //! Sets the display attributes of arrows used in presentation of dimensions. - Standard_EXPORT void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect); - + void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; } + //! Sets the same color for all parts of dimension: lines, arrows and text. Standard_EXPORT void SetCommonColor (const Quantity_Color& theColor); //! Sets extension size. - Standard_EXPORT void SetExtensionSize (const Standard_Real theSize); - + void SetExtensionSize (const Standard_Real theSize) { myExtensionSize = theSize; } + //! Returns extension size. - Standard_EXPORT Standard_Real ExtensionSize() const; - + Standard_Real ExtensionSize() const { return myExtensionSize; } + //! Set size for arrow tail (extension without text). - Standard_EXPORT void SetArrowTailSize (const Standard_Real theSize); - + void SetArrowTailSize (const Standard_Real theSize) { myArrowTailSize = theSize; } + //! Returns arrow tail size. - Standard_EXPORT Standard_Real ArrowTailSize() const; + Standard_Real ArrowTailSize() const { return myArrowTailSize; } //! Sets "sprintf"-syntax format for formatting dimension value labels. - Standard_EXPORT void SetValueStringFormat (const TCollection_AsciiString& theFormat); - + void SetValueStringFormat (const TCollection_AsciiString& theFormat) { myValueStringFormat = theFormat; } + //! Returns format. - Standard_EXPORT TCollection_AsciiString ValueStringFormat() const; - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_DimensionAspect,Prs3d_BasicAspect) + const TCollection_AsciiString& ValueStringFormat() const { return myValueStringFormat; } protected: - - - -private: - - - Handle(Prs3d_LineAspect) myLineAspect; - Handle(Prs3d_TextAspect) myTextAspect; + Handle(Prs3d_LineAspect) myLineAspect; + Handle(Prs3d_TextAspect) myTextAspect; Handle(Prs3d_ArrowAspect) myArrowAspect; + TCollection_AsciiString myValueStringFormat; + Standard_Real myExtensionSize; + Standard_Real myArrowTailSize; + Prs3d_DimensionArrowOrientation myArrowOrientation; + Prs3d_DimensionTextHorizontalPosition myTextHPosition; + Prs3d_DimensionTextVerticalPosition myTextVPosition; + Standard_Boolean myToDisplayUnits; Standard_Boolean myIsText3d; Standard_Boolean myIsTextShaded; Standard_Boolean myIsArrows3d; - Prs3d_DimensionArrowOrientation myArrowOrientation; - Prs3d_DimensionTextHorizontalPosition myTextHPosition; - Prs3d_DimensionTextVerticalPosition myTextVPosition; - Standard_Real myExtensionSize; - Standard_Real myArrowTailSize; - TCollection_AsciiString myValueStringFormat; - Standard_Boolean myToDisplayUnits; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_DimensionAspect, Prs3d_BasicAspect) #endif // _Prs3d_DimensionAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_DimensionUnits.cxx b/src/Prs3d/Prs3d_DimensionUnits.cxx deleted file mode 100644 index 59a583ccaa..0000000000 --- a/src/Prs3d/Prs3d_DimensionUnits.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// Created on: 2013-11-11 -// Created by: Anastasia BORISOVA -// Copyright (c) 2013-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -//======================================================================= -//function : SetLengthUnits -//purpose : -//======================================================================= -void Prs3d_DimensionUnits::SetLengthUnits (const TCollection_AsciiString& theUnits) -{ - myLengthUnits = theUnits; -} - -//======================================================================= -//function : SetAngleUnits -//purpose : -//======================================================================= -void Prs3d_DimensionUnits::SetAngleUnits (const TCollection_AsciiString& theUnits) -{ - myAngleUnits = theUnits; -} diff --git a/src/Prs3d/Prs3d_DimensionUnits.hxx b/src/Prs3d/Prs3d_DimensionUnits.hxx index d45c7a660a..a40e4af391 100644 --- a/src/Prs3d/Prs3d_DimensionUnits.hxx +++ b/src/Prs3d/Prs3d_DimensionUnits.hxx @@ -38,13 +38,13 @@ public: {} //! Sets angle units - Standard_EXPORT void SetAngleUnits (const TCollection_AsciiString& theUnits); + void SetAngleUnits (const TCollection_AsciiString& theUnits) { myAngleUnits = theUnits; } //! @return angle units const TCollection_AsciiString& GetAngleUnits() const { return myAngleUnits; } //! Sets length units - Standard_EXPORT void SetLengthUnits (const TCollection_AsciiString& theUnits); + void SetLengthUnits (const TCollection_AsciiString& theUnits) { myLengthUnits = theUnits; } //! @return length units const TCollection_AsciiString& GetLengthUnits() const { return myLengthUnits; } @@ -53,5 +53,7 @@ private: TCollection_AsciiString myLengthUnits; TCollection_AsciiString myAngleUnits; + }; + #endif diff --git a/src/Prs3d/Prs3d_IsoAspect.cxx b/src/Prs3d/Prs3d_IsoAspect.cxx index f6a4a97de0..4040735a0b 100644 --- a/src/Prs3d/Prs3d_IsoAspect.cxx +++ b/src/Prs3d/Prs3d_IsoAspect.cxx @@ -12,30 +12,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_IsoAspect,Prs3d_LineAspect) - -Prs3d_IsoAspect::Prs3d_IsoAspect(const Quantity_Color &aColor, - const Aspect_TypeOfLine aType, - const Standard_Real aWidth, - const Standard_Integer aNumber) - :Prs3d_LineAspect (aColor,aType,aWidth) { - myNumber = aNumber; -} - -Prs3d_IsoAspect::Prs3d_IsoAspect(const Quantity_NameOfColor aColor, - const Aspect_TypeOfLine aType, - const Standard_Real aWidth, - const Standard_Integer aNumber) - :Prs3d_LineAspect (aColor,aType,aWidth) { - myNumber = aNumber; -} -void Prs3d_IsoAspect::SetNumber (const Standard_Integer aNumber) { - myNumber = aNumber; -} - -Standard_Integer Prs3d_IsoAspect::Number () const {return myNumber;} +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_IsoAspect, Prs3d_LineAspect) diff --git a/src/Prs3d/Prs3d_IsoAspect.hxx b/src/Prs3d/Prs3d_IsoAspect.hxx index 867d3c15aa..3f4ab0df89 100644 --- a/src/Prs3d/Prs3d_IsoAspect.hxx +++ b/src/Prs3d/Prs3d_IsoAspect.hxx @@ -17,69 +17,50 @@ #ifndef _Prs3d_IsoAspect_HeaderFile #define _Prs3d_IsoAspect_HeaderFile -#include -#include - -#include #include -#include -#include -#include -class Quantity_Color; - - -class Prs3d_IsoAspect; -DEFINE_STANDARD_HANDLE(Prs3d_IsoAspect, Prs3d_LineAspect) //! A framework to define the display attributes of isoparameters. //! This framework can be used to modify the default //! setting for isoparameters in Prs3d_Drawer. class Prs3d_IsoAspect : public Prs3d_LineAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_IsoAspect, Prs3d_LineAspect) public: - //! Constructs a framework to define display attributes of isoparameters. //! These include: //! - the color attribute aColor //! - the type of line aType //! - the width value aWidth //! - aNumber, the number of isoparameters to be displayed. - Standard_EXPORT Prs3d_IsoAspect(const Quantity_NameOfColor aColor, const Aspect_TypeOfLine aType, const Standard_Real aWidth, const Standard_Integer aNumber); - - Standard_EXPORT Prs3d_IsoAspect(const Quantity_Color& aColor, const Aspect_TypeOfLine aType, const Standard_Real aWidth, const Standard_Integer aNumber); - + Prs3d_IsoAspect (const Quantity_NameOfColor theColor, + const Aspect_TypeOfLine theType, + const Standard_Real theWidth, + const Standard_Integer theNumber) + : Prs3d_LineAspect (theColor, theType, theWidth), + myNumber (theNumber) {} + + Prs3d_IsoAspect (const Quantity_Color& theColor, + const Aspect_TypeOfLine theType, + const Standard_Real theWidth, + const Standard_Integer theNumber) + : Prs3d_LineAspect (theColor, theType, theWidth), + myNumber (theNumber) {} + //! defines the number of U or V isoparametric curves //! to be drawn for a single face. //! Default value: 10 - Standard_EXPORT void SetNumber (const Standard_Integer aNumber); - + void SetNumber (const Standard_Integer theNumber) { myNumber = theNumber; } + //! returns the number of U or V isoparametric curves drawn for a single face. - Standard_EXPORT Standard_Integer Number() const; - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_IsoAspect,Prs3d_LineAspect) + Standard_Integer Number() const { return myNumber; } protected: - - - -private: - - Standard_Integer myNumber; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_IsoAspect, Prs3d_LineAspect) #endif // _Prs3d_IsoAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_LineAspect.cxx b/src/Prs3d/Prs3d_LineAspect.cxx index 8225e97b5d..48391dd3ba 100644 --- a/src/Prs3d/Prs3d_LineAspect.cxx +++ b/src/Prs3d/Prs3d_LineAspect.cxx @@ -12,56 +12,30 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include #include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_LineAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_LineAspect, Prs3d_BasicAspect) -Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_Color &aColor, - const Aspect_TypeOfLine aType, - const Standard_Real aWidth) { - myAspect = new Graphic3d_AspectLine3d(aColor,aType,aWidth); -} - -Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_NameOfColor aColor, - const Aspect_TypeOfLine aType, - const Standard_Real aWidth) { - - myAspect = new Graphic3d_AspectLine3d - (Quantity_Color(aColor),aType,aWidth); -} - -Prs3d_LineAspect::Prs3d_LineAspect( const Handle( Graphic3d_AspectLine3d )& theAspect ) +// ======================================================================= +// function : Prs3d_LineAspect +// purpose : +// ======================================================================= +Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_Color& theColor, + const Aspect_TypeOfLine theType, + const Standard_Real theWidth) +: myAspect (new Graphic3d_AspectLine3d (theColor, theType, theWidth)) { - myAspect = theAspect; + // } - - -void Prs3d_LineAspect::SetColor(const Quantity_Color &aColor) { - myAspect->SetColor(aColor); -} - -void Prs3d_LineAspect::SetColor(const Quantity_NameOfColor aColor) { - myAspect->SetColor(Quantity_Color(aColor)); -} - -void Prs3d_LineAspect::SetTypeOfLine(const Aspect_TypeOfLine aType){ - myAspect->SetType(aType); -} - -void Prs3d_LineAspect::SetWidth(const Standard_Real aWidth){ - myAspect->SetWidth(aWidth); -} - -Handle (Graphic3d_AspectLine3d) Prs3d_LineAspect::Aspect () const { - return myAspect; -} - -void Prs3d_LineAspect::SetAspect( const Handle( Graphic3d_AspectLine3d )& theAspect ) +// ======================================================================= +// function : Prs3d_LineAspect +// purpose : +// ======================================================================= +Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_NameOfColor theColor, + const Aspect_TypeOfLine theType, + const Standard_Real theWidth) +: myAspect (new Graphic3d_AspectLine3d (Quantity_Color (theColor), theType, theWidth)) { - myAspect = theAspect; + // } diff --git a/src/Prs3d/Prs3d_LineAspect.hxx b/src/Prs3d/Prs3d_LineAspect.hxx index bb49239919..f91edf1da5 100644 --- a/src/Prs3d/Prs3d_LineAspect.hxx +++ b/src/Prs3d/Prs3d_LineAspect.hxx @@ -17,19 +17,10 @@ #ifndef _Prs3d_LineAspect_HeaderFile #define _Prs3d_LineAspect_HeaderFile -#include -#include - -#include -#include #include #include - -class Quantity_Color; - - -class Prs3d_LineAspect; -DEFINE_STANDARD_HANDLE(Prs3d_LineAspect, Prs3d_BasicAspect) +#include +#include //! A framework for defining how a line will be displayed //! in a presentation. Aspects of line display include @@ -41,64 +32,47 @@ DEFINE_STANDARD_HANDLE(Prs3d_LineAspect, Prs3d_BasicAspect) //! as a substitute argument in the form of a field such as myDrawer for example. class Prs3d_LineAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_LineAspect, Prs3d_BasicAspect) public: - //! Constructs a framework for line aspect defined by //! - the color aColor //! - the type of line aType and //! - the line thickness aWidth. //! Type of line refers to whether the line is solid or dotted, for example. - Standard_EXPORT Prs3d_LineAspect(const Quantity_NameOfColor aColor, const Aspect_TypeOfLine aType, const Standard_Real aWidth); + Standard_EXPORT Prs3d_LineAspect (const Quantity_NameOfColor theColor, const Aspect_TypeOfLine theType, const Standard_Real theWidth); - Standard_EXPORT Prs3d_LineAspect(const Quantity_Color& aColor, const Aspect_TypeOfLine aType, const Standard_Real aWidth); + Standard_EXPORT Prs3d_LineAspect (const Quantity_Color& theColor, const Aspect_TypeOfLine theType, const Standard_Real theWidth); - Standard_EXPORT Prs3d_LineAspect(const Handle(Graphic3d_AspectLine3d)& theAspect); - - Standard_EXPORT void SetColor (const Quantity_Color& aColor); + Prs3d_LineAspect(const Handle(Graphic3d_AspectLine3d)& theAspect) : myAspect (theAspect) {} + + void SetColor (const Quantity_Color& theColor) { myAspect->SetColor (theColor); } //! Sets the line color defined at the time of construction. //! Default value: Quantity_NOC_YELLOW - Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor); + void SetColor (const Quantity_NameOfColor theColor) { myAspect->SetColor (Quantity_Color (theColor)); } //! Sets the type of line defined at the time of construction. //! This could, for example, be solid, dotted or made up of dashes. //! Default value: Aspect_TOL_SOLID - Standard_EXPORT void SetTypeOfLine (const Aspect_TypeOfLine aType); + void SetTypeOfLine (const Aspect_TypeOfLine theType) { myAspect->SetType (theType); } //! Sets the line width defined at the time of construction. //! Default value: 1. - Standard_EXPORT void SetWidth (const Standard_Real aWidth); - + void SetWidth (const Standard_Real theWidth) { myAspect->SetWidth (theWidth); } + //! Returns the line aspect. This is defined as the set of //! color, type and thickness attributes. - Standard_EXPORT Handle(Graphic3d_AspectLine3d) Aspect() const; + const Handle(Graphic3d_AspectLine3d)& Aspect() const { return myAspect; } - Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect); - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_LineAspect,Prs3d_BasicAspect) + void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { myAspect = theAspect; } protected: - - - -private: - - Handle(Graphic3d_AspectLine3d) myAspect; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_LineAspect, Prs3d_BasicAspect) #endif // _Prs3d_LineAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_PlaneAspect.cxx b/src/Prs3d/Prs3d_PlaneAspect.cxx index 262b13b81d..8d71bb33bc 100644 --- a/src/Prs3d/Prs3d_PlaneAspect.cxx +++ b/src/Prs3d/Prs3d_PlaneAspect.cxx @@ -12,150 +12,28 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include #include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PlaneAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PlaneAspect, Prs3d_BasicAspect) +// ======================================================================= +// function : Prs3d_PlaneAspect +// purpose : +// ======================================================================= Prs3d_PlaneAspect::Prs3d_PlaneAspect() +: myEdgesAspect (new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0)), + myIsoAspect (new Prs3d_LineAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5)), + myArrowAspect (new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF, Aspect_TOL_SOLID, 1.0)), + myArrowsLength(0.02), + myArrowsSize (0.1), + myArrowsAngle (M_PI / 8.0), + myPlaneXLength(1.0), + myPlaneYLength(1.0), + myIsoDistance (0.5), + myDrawCenterArrow (Standard_False), + myDrawEdgesArrows (Standard_False), + myDrawEdges (Standard_True), + myDrawIso (Standard_False) { - myEdgesAspect = new Prs3d_LineAspect(Quantity_NOC_GREEN,Aspect_TOL_SOLID,1.); - myIsoAspect = new Prs3d_LineAspect(Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5); - myArrowAspect = new Prs3d_LineAspect(Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID,1.); - myDrawCenterArrow = Standard_False; - myDrawEdgesArrows = Standard_False; - myDrawEdges = Standard_True; - myDrawIso = Standard_False; - myIsoDistance = 0.5; - myPlaneXLength= 1.; - myPlaneYLength= 1.; - myArrowsLength= 0.02; - myArrowsSize=0.1; - myArrowsAngle=M_PI/8.; + // } - -Handle(Prs3d_LineAspect) Prs3d_PlaneAspect::EdgesAspect() const -{ - return myEdgesAspect; -} - -Handle(Prs3d_LineAspect) Prs3d_PlaneAspect::IsoAspect() const -{ - return myIsoAspect; -} - -Handle(Prs3d_LineAspect) Prs3d_PlaneAspect::ArrowAspect() const -{ - return myArrowAspect; -} - -void Prs3d_PlaneAspect::SetDisplayCenterArrow(const Standard_Boolean draw) -{ - myDrawCenterArrow = draw; -} - -void Prs3d_PlaneAspect::SetDisplayEdgesArrows(const Standard_Boolean draw) -{ - myDrawEdgesArrows = draw; -} - -void Prs3d_PlaneAspect::SetDisplayEdges(const Standard_Boolean draw) -{ - myDrawEdges = draw; -} - -void Prs3d_PlaneAspect::SetDisplayIso(const Standard_Boolean draw) -{ - myDrawIso = draw; -} - -Standard_Boolean Prs3d_PlaneAspect::DisplayCenterArrow() const -{ - return myDrawCenterArrow; -} - -Standard_Boolean Prs3d_PlaneAspect::DisplayEdgesArrows() const -{ - return myDrawEdgesArrows; -} - -Standard_Boolean Prs3d_PlaneAspect::DisplayEdges() const -{ - return myDrawEdges; -} - -Standard_Boolean Prs3d_PlaneAspect::DisplayIso() const -{ - return myDrawIso; -} - -void Prs3d_PlaneAspect::SetPlaneLength(const Quantity_Length lX, - const Quantity_Length lY) -{ - myPlaneXLength = lX; - myPlaneYLength = lY; -} - -Quantity_Length Prs3d_PlaneAspect::PlaneXLength() const -{ - return myPlaneXLength; -} - -Quantity_Length Prs3d_PlaneAspect::PlaneYLength() const -{ - return myPlaneYLength; -} - -void Prs3d_PlaneAspect::SetIsoDistance(const Quantity_Length l) -{ - myIsoDistance = l; -} - -Quantity_Length Prs3d_PlaneAspect::IsoDistance() const -{ - return myIsoDistance; -} - -void Prs3d_PlaneAspect::SetArrowsLength(const Quantity_Length L) -{ - myArrowsLength = L; -} - -Quantity_Length Prs3d_PlaneAspect::ArrowsLength() const -{ - return myArrowsLength; -} - -void Prs3d_PlaneAspect::SetArrowsSize(const Quantity_Length L) -{ - myArrowsSize = L; -} - -Quantity_Length Prs3d_PlaneAspect::ArrowsSize() const -{ - return myArrowsSize; -} - -void Prs3d_PlaneAspect::SetArrowsAngle(const Quantity_PlaneAngle ang) -{ - myArrowsAngle = ang; -} - -Quantity_Length Prs3d_PlaneAspect::ArrowsAngle() const -{ - return myArrowsAngle; -} - - - - - - - - - - - - diff --git a/src/Prs3d/Prs3d_PlaneAspect.hxx b/src/Prs3d/Prs3d_PlaneAspect.hxx index afed7126fc..54cc3f3f24 100644 --- a/src/Prs3d/Prs3d_PlaneAspect.hxx +++ b/src/Prs3d/Prs3d_PlaneAspect.hxx @@ -17,127 +17,105 @@ #ifndef _Prs3d_PlaneAspect_HeaderFile #define _Prs3d_PlaneAspect_HeaderFile -#include -#include - #include #include -#include -#include -class Prs3d_LineAspect; - - -class Prs3d_PlaneAspect; -DEFINE_STANDARD_HANDLE(Prs3d_PlaneAspect, Prs3d_BasicAspect) +#include //! A framework to define the display of planes. class Prs3d_PlaneAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_PlaneAspect, Prs3d_BasicAspect) public: - //! Constructs an empty framework for the display of planes. Standard_EXPORT Prs3d_PlaneAspect(); //! Returns the attributes of displayed edges involved in the presentation of planes. - Standard_EXPORT Handle(Prs3d_LineAspect) EdgesAspect() const; - + const Handle(Prs3d_LineAspect)& EdgesAspect() const { return myEdgesAspect; } + //! Returns the attributes of displayed isoparameters involved in the presentation of planes. - Standard_EXPORT Handle(Prs3d_LineAspect) IsoAspect() const; + const Handle(Prs3d_LineAspect)& IsoAspect() const { return myIsoAspect; } //! Returns the settings for displaying an arrow. - Standard_EXPORT Handle(Prs3d_LineAspect) ArrowAspect() const; + const Handle(Prs3d_LineAspect)& ArrowAspect() const { return myArrowAspect; } - Standard_EXPORT void SetArrowsLength (const Quantity_Length L); + void SetArrowsLength (const Quantity_Length theLength) { myArrowsLength = theLength; } //! Returns the length of the arrow shaft used in the display of arrows. - Standard_EXPORT Quantity_Length ArrowsLength() const; + Quantity_Length ArrowsLength() const { return myArrowsLength; } //! Sets the angle of the arrowhead used in the display of planes. - Standard_EXPORT void SetArrowsSize (const Quantity_Length L); + void SetArrowsSize (const Quantity_Length theSize) { myArrowsSize = theSize; } //! Returns the size of arrows used in the display of planes. - Standard_EXPORT Quantity_Length ArrowsSize() const; - + Quantity_Length ArrowsSize() const { return myArrowsSize; } + //! Sets the angle of the arrowhead used in the display //! of arrows involved in the presentation of planes. - Standard_EXPORT void SetArrowsAngle (const Quantity_PlaneAngle ang); + void SetArrowsAngle (const Quantity_PlaneAngle theAngle) { myArrowsAngle = theAngle; } //! Returns the angle of the arrowhead used in the //! display of arrows involved in the presentation of planes. - Standard_EXPORT Quantity_PlaneAngle ArrowsAngle() const; + Quantity_PlaneAngle ArrowsAngle() const { return myArrowsAngle; } //! Sets the display attributes defined in DisplayCenterArrow to active. - Standard_EXPORT void SetDisplayCenterArrow (const Standard_Boolean draw); + void SetDisplayCenterArrow (const Standard_Boolean theToDraw) { myDrawCenterArrow = theToDraw; } //! Returns true if the display of center arrows is allowed. - Standard_EXPORT Standard_Boolean DisplayCenterArrow() const; + Standard_Boolean DisplayCenterArrow() const { return myDrawCenterArrow; } //! Sets the display attributes defined in DisplayEdgesArrows to active. - Standard_EXPORT void SetDisplayEdgesArrows (const Standard_Boolean draw); + void SetDisplayEdgesArrows (const Standard_Boolean theToDraw) { myDrawEdgesArrows = theToDraw; } //! Returns true if the display of edge arrows is allowed. - Standard_EXPORT Standard_Boolean DisplayEdgesArrows() const; + Standard_Boolean DisplayEdgesArrows() const { return myDrawEdgesArrows; } - Standard_EXPORT void SetDisplayEdges (const Standard_Boolean draw); + void SetDisplayEdges (const Standard_Boolean theToDraw) { myDrawEdges = theToDraw; } - Standard_EXPORT Standard_Boolean DisplayEdges() const; + Standard_Boolean DisplayEdges() const { return myDrawEdges; } //! Sets the display attributes defined in DisplayIso to active. - Standard_EXPORT void SetDisplayIso (const Standard_Boolean draw); + void SetDisplayIso (const Standard_Boolean theToDraw) { myDrawIso = theToDraw; } //! Returns true if the display of isoparameters is allowed. - Standard_EXPORT Standard_Boolean DisplayIso() const; + Standard_Boolean DisplayIso() const { return myDrawIso; } - Standard_EXPORT void SetPlaneLength (const Quantity_Length LX, const Quantity_Length LY); + void SetPlaneLength (const Quantity_Length theLX, const Quantity_Length theLY) + { + myPlaneXLength = theLX; + myPlaneYLength = theLY; + } //! Returns the length of the x axis used in the display of planes. - Standard_EXPORT Quantity_Length PlaneXLength() const; + Quantity_Length PlaneXLength() const { return myPlaneXLength; } //! Returns the length of the y axis used in the display of planes. - Standard_EXPORT Quantity_Length PlaneYLength() const; + Quantity_Length PlaneYLength() const { return myPlaneYLength; } //! Sets the distance L between isoparameters used in the display of planes. - Standard_EXPORT void SetIsoDistance (const Quantity_Length L); + void SetIsoDistance (const Quantity_Length theL) { myIsoDistance = theL; } //! Returns the distance between isoparameters used in the display of planes. - Standard_EXPORT Quantity_Length IsoDistance() const; - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_PlaneAspect,Prs3d_BasicAspect) + Quantity_Length IsoDistance() const { return myIsoDistance; } protected: - - - -private: - - Handle(Prs3d_LineAspect) myEdgesAspect; Handle(Prs3d_LineAspect) myIsoAspect; Handle(Prs3d_LineAspect) myArrowAspect; Quantity_Length myArrowsLength; Quantity_Length myArrowsSize; Quantity_PlaneAngle myArrowsAngle; + Quantity_Length myPlaneXLength; + Quantity_Length myPlaneYLength; + Quantity_Length myIsoDistance; Standard_Boolean myDrawCenterArrow; Standard_Boolean myDrawEdgesArrows; Standard_Boolean myDrawEdges; Standard_Boolean myDrawIso; - Quantity_Length myPlaneXLength; - Quantity_Length myPlaneYLength; - Quantity_Length myIsoDistance; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_PlaneAspect, Prs3d_BasicAspect) #endif // _Prs3d_PlaneAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_PlaneSet.cxx b/src/Prs3d/Prs3d_PlaneSet.cxx deleted file mode 100644 index c01222d7fc..0000000000 --- a/src/Prs3d/Prs3d_PlaneSet.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// Created on: 1993-10-20 -// Created by: Isabelle VERDURON -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PlaneSet,MMgt_TShared) - -Prs3d_PlaneSet::Prs3d_PlaneSet(const Standard_Real Xdir, - const Standard_Real Ydir, - const Standard_Real Zdir, - const Standard_Real Xloc, - const Standard_Real Yloc, - const Standard_Real Zloc, - const Quantity_Length anOffset) - - : myPlane(gp_Pln(gp_Pnt(Xloc,Yloc,Zloc),gp_Dir(Xdir,Ydir,Zdir))), - myOffset(anOffset) { -} - - -void Prs3d_PlaneSet::SetDirection(const Standard_Real X, - const Standard_Real Y, - const Standard_Real Z) { - - myPlane = gp_Pln(myPlane.Location(),gp_Dir(X,Y,Z)); -} - -void Prs3d_PlaneSet::SetLocation(const Standard_Real X, - const Standard_Real Y, - const Standard_Real Z) { - - myPlane.SetLocation(gp_Pnt(X,Y,Z)); -} - -void Prs3d_PlaneSet::SetOffset(const Quantity_Length anOffset) { - - myOffset = anOffset; -} - -gp_Pln Prs3d_PlaneSet::Plane() const { - - return myPlane; - -} -Quantity_Length Prs3d_PlaneSet::Offset () const { - - return myOffset; - -} - -void Prs3d_PlaneSet::Location(Quantity_Length& X,Quantity_Length& Y,Quantity_Length& Z) const { - - myPlane.Location().Coord(X,Y,Z); -} - -void Prs3d_PlaneSet::Direction(Quantity_Length& X,Quantity_Length& Y,Quantity_Length& Z) const { - - myPlane.Axis().Direction().Coord(X,Y,Z); -} - diff --git a/src/Prs3d/Prs3d_PlaneSet.hxx b/src/Prs3d/Prs3d_PlaneSet.hxx deleted file mode 100644 index 63e08a8814..0000000000 --- a/src/Prs3d/Prs3d_PlaneSet.hxx +++ /dev/null @@ -1,82 +0,0 @@ -// Created on: 1993-10-20 -// Created by: Jean-Louis FRENKEL -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Prs3d_PlaneSet_HeaderFile -#define _Prs3d_PlaneSet_HeaderFile - -#include -#include - -#include -#include -#include -#include -class gp_Pln; - - -class Prs3d_PlaneSet; -DEFINE_STANDARD_HANDLE(Prs3d_PlaneSet, MMgt_TShared) - -//! defines a set of planes used for a presentation -//! by sections. -class Prs3d_PlaneSet : public MMgt_TShared -{ - -public: - - - Standard_EXPORT Prs3d_PlaneSet(const Standard_Real Xdir, const Standard_Real Ydir, const Standard_Real Zdir, const Quantity_Length Xloc, const Quantity_Length Yloc, const Quantity_Length Zloc, const Quantity_Length anOffset); - - Standard_EXPORT void SetDirection (const Standard_Real X, const Standard_Real Y, const Standard_Real Z); - - Standard_EXPORT void SetLocation (const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Z); - - Standard_EXPORT void SetOffset (const Quantity_Length anOffset); - - Standard_EXPORT gp_Pln Plane() const; - - Standard_EXPORT Quantity_Length Offset() const; - - Standard_EXPORT void Location (Quantity_Length& X, Quantity_Length& Y, Quantity_Length& Z) const; - - Standard_EXPORT void Direction (Quantity_Length& X, Quantity_Length& Y, Quantity_Length& Z) const; - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_PlaneSet,MMgt_TShared) - -protected: - - - - -private: - - - gp_Pln myPlane; - Quantity_Length myOffset; - - -}; - - - - - - - -#endif // _Prs3d_PlaneSet_HeaderFile diff --git a/src/Prs3d/Prs3d_PointAspect.cxx b/src/Prs3d/Prs3d_PointAspect.cxx index 5fdf4a3397..9a06ed46af 100644 --- a/src/Prs3d/Prs3d_PointAspect.cxx +++ b/src/Prs3d/Prs3d_PointAspect.cxx @@ -12,75 +12,43 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include #include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PointAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PointAspect, Prs3d_BasicAspect) -Prs3d_PointAspect::Prs3d_PointAspect (const Aspect_TypeOfMarker aType, - const Quantity_Color &aColor, - const Standard_Real aScale) { - myAspect = new Graphic3d_AspectMarker3d(aType,aColor,aScale); -} - -Prs3d_PointAspect::Prs3d_PointAspect (const Aspect_TypeOfMarker aType, - const Quantity_NameOfColor aColor, - const Standard_Real aScale) { - myAspect = new Graphic3d_AspectMarker3d - (aType,Quantity_Color(aColor),aScale); -} - -Prs3d_PointAspect::Prs3d_PointAspect (const Quantity_Color &aColor, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Handle(TColStd_HArray1OfByte)& aTexture - ) +// ======================================================================= +// function : Prs3d_PointAspect +// purpose : +// ======================================================================= +Prs3d_PointAspect::Prs3d_PointAspect (const Aspect_TypeOfMarker theType, + const Quantity_Color& theColor, + const Standard_Real theScale) +: myAspect (new Graphic3d_AspectMarker3d (theType, theColor, theScale)) { - myAspect = new Graphic3d_AspectMarker3d - (aColor,aWidth,aHeight,aTexture); + // } -Prs3d_PointAspect::Prs3d_PointAspect( const Handle( Graphic3d_AspectMarker3d )& theAspect ) +// ======================================================================= +// function : Prs3d_PointAspect +// purpose : +// ======================================================================= +Prs3d_PointAspect::Prs3d_PointAspect (const Aspect_TypeOfMarker theType, + const Quantity_NameOfColor theColor, + const Standard_Real theScale) +: myAspect (new Graphic3d_AspectMarker3d (theType, Quantity_Color(theColor), theScale)) { - myAspect = theAspect; + // } - -void Prs3d_PointAspect::SetColor(const Quantity_Color &aColor) { - myAspect->SetColor(aColor); -} - - -void Prs3d_PointAspect::SetColor(const Quantity_NameOfColor aColor) { - myAspect->SetColor(Quantity_Color(aColor)); -} - -void Prs3d_PointAspect::SetTypeOfMarker(const Aspect_TypeOfMarker aType){ - myAspect->SetType(aType); -} - -void Prs3d_PointAspect::SetScale(const Standard_Real aScale){ - myAspect->SetScale(aScale); -} - -Handle (Graphic3d_AspectMarker3d) Prs3d_PointAspect::Aspect () const { - return myAspect; -} - -void Prs3d_PointAspect::SetAspect( const Handle( Graphic3d_AspectMarker3d )& theAspect ) +// ======================================================================= +// function : Prs3d_PointAspect +// purpose : +// ======================================================================= +Prs3d_PointAspect::Prs3d_PointAspect (const Quantity_Color& theColor, + const Standard_Integer theWidth, + const Standard_Integer theHeight, + const Handle(TColStd_HArray1OfByte)& theTexture) +: myAspect (new Graphic3d_AspectMarker3d (theColor, theWidth, theHeight, theTexture)) { - myAspect = theAspect; -} - -void Prs3d_PointAspect::GetTextureSize(Standard_Integer& AWidth, Standard_Integer& AHeight) -{ - myAspect->GetTextureSize( AWidth, AHeight); -} - -const Handle(Graphic3d_MarkerImage)& Prs3d_PointAspect::GetTexture() -{ - return myAspect->GetMarkerImage(); + // } diff --git a/src/Prs3d/Prs3d_PointAspect.hxx b/src/Prs3d/Prs3d_PointAspect.hxx index 25a42de494..4be436b307 100644 --- a/src/Prs3d/Prs3d_PointAspect.hxx +++ b/src/Prs3d/Prs3d_PointAspect.hxx @@ -17,87 +17,60 @@ #ifndef _Prs3d_PointAspect_HeaderFile #define _Prs3d_PointAspect_HeaderFile -#include -#include - #include -#include -#include -#include -#include -#include +#include #include -class Graphic3d_AspectMarker3d; -class Quantity_Color; - - -class Prs3d_PointAspect; -DEFINE_STANDARD_HANDLE(Prs3d_PointAspect, Prs3d_BasicAspect) //! This class defines attributes for the points //! The points are drawn using markers, whose size does not depend on //! the zoom value of the views. class Prs3d_PointAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_PointAspect, Prs3d_BasicAspect) public: + Standard_EXPORT Prs3d_PointAspect(const Aspect_TypeOfMarker theType, const Quantity_Color& theColor, const Standard_Real theScale); + + Standard_EXPORT Prs3d_PointAspect(const Aspect_TypeOfMarker theType, const Quantity_NameOfColor theColor, const Standard_Real theScale); - Standard_EXPORT Prs3d_PointAspect(const Aspect_TypeOfMarker aType, const Quantity_Color& aColor, const Standard_Real aScale); + //! Defines the user defined marker point. + Standard_EXPORT Prs3d_PointAspect (const Quantity_Color& theColor, + const Standard_Integer theWidth, + const Standard_Integer theHeight, + const Handle(TColStd_HArray1OfByte)& theTexture); - Standard_EXPORT Prs3d_PointAspect(const Aspect_TypeOfMarker aType, const Quantity_NameOfColor aColor, const Standard_Real aScale); - - //! defines only the urer defined marker point. - Standard_EXPORT Prs3d_PointAspect(const Quantity_Color& AColor, const Standard_Integer AWidth, const Standard_Integer AHeight, const Handle(TColStd_HArray1OfByte)& ATexture); - - Standard_EXPORT Prs3d_PointAspect(const Handle(Graphic3d_AspectMarker3d)& theAspect); - - Standard_EXPORT void SetColor (const Quantity_Color& aColor); + Prs3d_PointAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) : myAspect (theAspect) {} + + void SetColor (const Quantity_Color& theColor) { myAspect->SetColor (theColor); } //! defines the color to be used when drawing a point. //! Default value: Quantity_NOC_YELLOW - Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor); + void SetColor (const Quantity_NameOfColor theColor) { myAspect->SetColor (Quantity_Color (theColor)); } //! defines the type of representation to be used when drawing a point. //! Default value: Aspect_TOM_PLUS - Standard_EXPORT void SetTypeOfMarker (const Aspect_TypeOfMarker aType); + void SetTypeOfMarker (const Aspect_TypeOfMarker theType) { myAspect->SetType (theType); } //! defines the size of the marker used when drawing a point. //! Default value: 1. - Standard_EXPORT void SetScale (const Standard_Real aScale); - - Standard_EXPORT Handle(Graphic3d_AspectMarker3d) Aspect() const; - - Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect); + void SetScale (const Standard_Real theScale) { myAspect->SetScale (theScale); } + const Handle(Graphic3d_AspectMarker3d)& Aspect() const { return myAspect; } + + void SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) { myAspect = theAspect; } + //! Returns marker's texture size. - Standard_EXPORT void GetTextureSize (Standard_Integer& AWidth, Standard_Integer& AHeight); + void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const { myAspect->GetTextureSize (theWidth, theHeight); } //! Returns marker's texture. - Standard_EXPORT const Handle(Graphic3d_MarkerImage)& GetTexture(); - - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_PointAspect,Prs3d_BasicAspect) + const Handle(Graphic3d_MarkerImage)& GetTexture() const { return myAspect->GetMarkerImage(); } protected: - - - -private: - - Handle(Graphic3d_AspectMarker3d) myAspect; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_PointAspect, Prs3d_BasicAspect) #endif // _Prs3d_PointAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_ShadingAspect.cxx b/src/Prs3d/Prs3d_ShadingAspect.cxx index 0514b7fff8..102deb416a 100644 --- a/src/Prs3d/Prs3d_ShadingAspect.cxx +++ b/src/Prs3d/Prs3d_ShadingAspect.cxx @@ -12,74 +12,63 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include -#include #include #include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ShadingAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ShadingAspect, Prs3d_BasicAspect) //======================================================================= //function : Prs3d_ShadingAspect -//purpose : +//purpose : //======================================================================= -Prs3d_ShadingAspect::Prs3d_ShadingAspect () { - - - Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); - Quantity_Color Col; - // Ceci permet de recuperer la couleur associee - // au materiau defini par defaut. -//POP K4L - Col = aMat.AmbientColor (); -// Col = aMat.Color (); +Prs3d_ShadingAspect::Prs3d_ShadingAspect() +{ + const Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); + const Quantity_Color aColor = aMat.AmbientColor(); myAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, - Col, - Col, + aColor, + aColor, Aspect_TOL_SOLID, 1.0, aMat, aMat); } -Prs3d_ShadingAspect::Prs3d_ShadingAspect( const Handle( Graphic3d_AspectFillArea3d )& theAspect ) -{ - myAspect = theAspect; -} - //======================================================================= //function : SetColor -//purpose : +//purpose : //======================================================================= - -void Prs3d_ShadingAspect::SetColor(const Quantity_NameOfColor aColor, - const Aspect_TypeOfFacingModel aModel) { - - SetColor(Quantity_Color(aColor),aModel); -} - -void Prs3d_ShadingAspect::SetColor(const Quantity_Color &aColor, - const Aspect_TypeOfFacingModel aModel) { - if( aModel != Aspect_TOFM_BOTH_SIDE ) { +void Prs3d_ShadingAspect::SetColor (const Quantity_Color& theColor, + const Aspect_TypeOfFacingModel theModel) +{ + if (theModel != Aspect_TOFM_BOTH_SIDE) + { myAspect->SetDistinguishOn(); } - if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) { - Graphic3d_MaterialAspect front = myAspect->FrontMaterial(); - front.SetColor(aColor); - myAspect->SetFrontMaterial(front); - myAspect->SetInteriorColor( aColor ); + + if (theModel == Aspect_TOFM_FRONT_SIDE + || theModel == Aspect_TOFM_BOTH_SIDE) + { + myAspect->ChangeFrontMaterial().SetColor (theColor); + myAspect->SetInteriorColor (theColor); } - if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) { - Graphic3d_MaterialAspect back = myAspect->BackMaterial(); - back.SetColor(aColor); - myAspect->SetBackMaterial(back); - myAspect->SetBackInteriorColor( aColor ); + if (theModel == Aspect_TOFM_BACK_SIDE + || theModel == Aspect_TOFM_BOTH_SIDE) + { + myAspect->ChangeBackMaterial().SetColor (theColor); + myAspect->SetBackInteriorColor (theColor); } } +//======================================================================= +//function : Color +//purpose : +//======================================================================= const Quantity_Color& Prs3d_ShadingAspect::Color (const Aspect_TypeOfFacingModel theModel) const { switch (theModel) @@ -95,36 +84,32 @@ const Quantity_Color& Prs3d_ShadingAspect::Color (const Aspect_TypeOfFacingModel //======================================================================= //function : SetMaterial -//purpose : +//purpose : //======================================================================= - -void Prs3d_ShadingAspect::SetMaterial( - const Graphic3d_NameOfMaterial aMaterial, - const Aspect_TypeOfFacingModel aModel ) { - SetMaterial(Graphic3d_MaterialAspect(aMaterial),aModel); -} - -//======================================================================= -//function : SetMaterial -//purpose : -//======================================================================= - -void Prs3d_ShadingAspect::SetMaterial( - const Graphic3d_MaterialAspect& aMaterial, - const Aspect_TypeOfFacingModel aModel ) { - - if( aModel != Aspect_TOFM_BOTH_SIDE ) { +void Prs3d_ShadingAspect::SetMaterial (const Graphic3d_MaterialAspect& theMaterial, + const Aspect_TypeOfFacingModel theModel) +{ + if (theModel != Aspect_TOFM_BOTH_SIDE) + { myAspect->SetDistinguishOn(); } - if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) { - myAspect->SetFrontMaterial(aMaterial); + if (theModel == Aspect_TOFM_FRONT_SIDE + || theModel == Aspect_TOFM_BOTH_SIDE) + { + myAspect->SetFrontMaterial(theMaterial); } - if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) { - myAspect->SetBackMaterial(aMaterial); + if (theModel == Aspect_TOFM_BACK_SIDE + || theModel == Aspect_TOFM_BOTH_SIDE) + { + myAspect->SetBackMaterial (theMaterial); } } +//======================================================================= +//function : Material +//purpose : +//======================================================================= const Graphic3d_MaterialAspect& Prs3d_ShadingAspect::Material (const Aspect_TypeOfFacingModel theModel) const { switch (theModel) @@ -140,52 +125,42 @@ const Graphic3d_MaterialAspect& Prs3d_ShadingAspect::Material (const Aspect_Type //======================================================================= //function : SetTransparency -//purpose : +//purpose : //======================================================================= - -void Prs3d_ShadingAspect::SetTransparency(const Standard_Real aValue, - const Aspect_TypeOfFacingModel aModel ) { - - if( aModel != Aspect_TOFM_BOTH_SIDE ) { +void Prs3d_ShadingAspect::SetTransparency (const Standard_Real theValue, + const Aspect_TypeOfFacingModel theModel) +{ + if (theModel != Aspect_TOFM_BOTH_SIDE) + { myAspect->SetDistinguishOn(); } - if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) { - Graphic3d_MaterialAspect front = myAspect->FrontMaterial(); - front.SetTransparency(aValue); - myAspect->SetFrontMaterial(front); + + if (theModel == Aspect_TOFM_FRONT_SIDE + || theModel == Aspect_TOFM_BOTH_SIDE) + { + myAspect->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue)); } - if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) { - Graphic3d_MaterialAspect back = myAspect->BackMaterial(); - back.SetTransparency(aValue); - myAspect->SetBackMaterial(back); + if (theModel == Aspect_TOFM_BACK_SIDE + || theModel == Aspect_TOFM_BOTH_SIDE) + { + myAspect->ChangeBackMaterial().SetTransparency (Standard_ShortReal(theValue)); } } -Standard_Real Prs3d_ShadingAspect::Transparency(const Aspect_TypeOfFacingModel aModel ) const { -Standard_Real aValue(0.); - switch (aModel) { +//======================================================================= +//function : Transparency +//purpose : +//======================================================================= +Standard_Real Prs3d_ShadingAspect::Transparency (const Aspect_TypeOfFacingModel theModel) const +{ + switch (theModel) + { case Aspect_TOFM_BOTH_SIDE: case Aspect_TOFM_FRONT_SIDE: - aValue = myAspect->FrontMaterial().Transparency(); - break; + return myAspect->FrontMaterial().Transparency(); case Aspect_TOFM_BACK_SIDE: - aValue = myAspect->BackMaterial().Transparency(); - break; + return myAspect->BackMaterial().Transparency(); } - return aValue; -} - -//======================================================================= -//function : SetAspect -//purpose : -//======================================================================= - -void Prs3d_ShadingAspect::SetAspect( const Handle( Graphic3d_AspectFillArea3d )& theAspect ) -{ - myAspect = theAspect; -} - -Handle (Graphic3d_AspectFillArea3d) Prs3d_ShadingAspect::Aspect () const { - return myAspect; + return 0.0; } diff --git a/src/Prs3d/Prs3d_ShadingAspect.hxx b/src/Prs3d/Prs3d_ShadingAspect.hxx index e06e921043..95b529aa8d 100644 --- a/src/Prs3d/Prs3d_ShadingAspect.hxx +++ b/src/Prs3d/Prs3d_ShadingAspect.hxx @@ -17,21 +17,10 @@ #ifndef _Prs3d_ShadingAspect_HeaderFile #define _Prs3d_ShadingAspect_HeaderFile -#include -#include - -#include #include -#include -#include -#include -class Graphic3d_AspectFillArea3d; -class Quantity_Color; -class Graphic3d_MaterialAspect; - - -class Prs3d_ShadingAspect; -DEFINE_STANDARD_HANDLE(Prs3d_ShadingAspect, Prs3d_BasicAspect) +#include +#include +#include //! A framework to define the display of shading. //! The attributes which make up this definition include: @@ -40,25 +29,32 @@ DEFINE_STANDARD_HANDLE(Prs3d_ShadingAspect, Prs3d_BasicAspect) //! - material class Prs3d_ShadingAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_ShadingAspect, Prs3d_BasicAspect) public: - //! Constructs an empty framework to display shading. Standard_EXPORT Prs3d_ShadingAspect(); - - Standard_EXPORT Prs3d_ShadingAspect(const Handle(Graphic3d_AspectFillArea3d)& theAspect); + + //! Constructor with initialization. + Prs3d_ShadingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) : myAspect (theAspect) {} //! Change the polygons interior color and material ambient color. Standard_EXPORT void SetColor (const Quantity_Color& aColor, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE); //! Change the polygons interior color and material ambient color. - Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE); - + void SetColor (const Quantity_NameOfColor theColor, + const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE) + { + SetColor (Quantity_Color (theColor), theModel); + } + //! Change the polygons material aspect. Standard_EXPORT void SetMaterial (const Graphic3d_MaterialAspect& aMaterial, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE); - - Standard_EXPORT void SetMaterial (const Graphic3d_NameOfMaterial aMaterial, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE); + + void SetMaterial (const Graphic3d_NameOfMaterial theMaterial, const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE) + { + SetMaterial (Graphic3d_MaterialAspect (theMaterial), theModel); + } //! Change the polygons transparency value. //! Warning : aValue must be in the range 0,1. 0 is the default (NO transparent) @@ -74,32 +70,16 @@ public: Standard_EXPORT Standard_Real Transparency (const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_FRONT_SIDE) const; //! Returns the polygons aspect properties. - Standard_EXPORT Handle(Graphic3d_AspectFillArea3d) Aspect() const; - - Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect); + const Handle(Graphic3d_AspectFillArea3d)& Aspect() const { return myAspect; } - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_ShadingAspect,Prs3d_BasicAspect) + void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { myAspect = theAspect; } protected: - - - -private: - - Handle(Graphic3d_AspectFillArea3d) myAspect; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_ShadingAspect, Prs3d_BasicAspect) #endif // _Prs3d_ShadingAspect_HeaderFile diff --git a/src/Prs3d/Prs3d_TextAspect.cxx b/src/Prs3d/Prs3d_TextAspect.cxx index 80c874ce3a..70dfe7147b 100644 --- a/src/Prs3d/Prs3d_TextAspect.cxx +++ b/src/Prs3d/Prs3d_TextAspect.cxx @@ -14,97 +14,38 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include -#include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_TextAspect,Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect) -Prs3d_TextAspect::Prs3d_TextAspect () -: myAngle(0.), - myHeight(16.), - myHorizontalJustification(Graphic3d_HTA_LEFT), - myVerticalJustification(Graphic3d_VTA_BOTTOM), - myOrientation(Graphic3d_TP_RIGHT) { - - myTextAspect = new Graphic3d_AspectText3d ( - Quantity_Color(Quantity_NOC_YELLOW), - Font_NOF_ASCII_TRIPLEX, - 1., - 0.); -} - -Prs3d_TextAspect::Prs3d_TextAspect( const Handle( Graphic3d_AspectText3d )& theAspect ) -: myAngle(0.), - myHeight(16.), - myHorizontalJustification(Graphic3d_HTA_LEFT), - myVerticalJustification(Graphic3d_VTA_BOTTOM), - myOrientation(Graphic3d_TP_RIGHT) +// ======================================================================= +// function : Prs3d_TextAspect +// purpose : +// ======================================================================= +Prs3d_TextAspect::Prs3d_TextAspect() +: myTextAspect (new Graphic3d_AspectText3d (Quantity_Color (Quantity_NOC_YELLOW), Font_NOF_ASCII_TRIPLEX, 1.0, 0.0)), + myAngle (0.0), + myHeight(16.0), + myHorizontalJustification (Graphic3d_HTA_LEFT), + myVerticalJustification (Graphic3d_VTA_BOTTOM), + myOrientation (Graphic3d_TP_RIGHT) { - myTextAspect = theAspect; + // } - -void Prs3d_TextAspect::SetColor(const Quantity_Color &aColor) { - myTextAspect->SetColor(aColor); -} - -void Prs3d_TextAspect::SetColor(const Quantity_NameOfColor aColor) { - myTextAspect->SetColor(Quantity_Color(aColor)); -} - -void Prs3d_TextAspect::SetFont(const Standard_CString aFont) { - myTextAspect->SetFont(aFont); -} - -void Prs3d_TextAspect::SetHeightWidthRatio(const Standard_Real aRatio) { - myTextAspect->SetExpansionFactor(aRatio); -} - -void Prs3d_TextAspect::SetSpace(const Quantity_Length aSpace) { - myTextAspect->SetSpace(aSpace); -} - -void Prs3d_TextAspect::SetHeight(const Standard_Real aHeight) { - myHeight = aHeight; -} - -void Prs3d_TextAspect::SetAngle(const Quantity_PlaneAngle anAngle) { - myAngle = anAngle; -} - -void Prs3d_TextAspect::SetHorizontalJustification(const Graphic3d_HorizontalTextAlignment aJustification) { - myHorizontalJustification = aJustification; -} - - -void Prs3d_TextAspect::SetVerticalJustification(const Graphic3d_VerticalTextAlignment aJustification) { - myVerticalJustification = aJustification; -} - -void Prs3d_TextAspect::SetOrientation(const Graphic3d_TextPath anOrientation) { - - myOrientation = anOrientation; -} - -Standard_Real Prs3d_TextAspect::Height () const {return myHeight;} - -Quantity_PlaneAngle Prs3d_TextAspect::Angle () const {return myAngle;} - -Graphic3d_HorizontalTextAlignment Prs3d_TextAspect::HorizontalJustification () const { return myHorizontalJustification;} - -Graphic3d_VerticalTextAlignment Prs3d_TextAspect::VerticalJustification () const { return myVerticalJustification;} - -Graphic3d_TextPath Prs3d_TextAspect::Orientation () const {return myOrientation;} - -Handle(Graphic3d_AspectText3d) Prs3d_TextAspect::Aspect() const { - return myTextAspect; -} - -void Prs3d_TextAspect::SetAspect( const Handle( Graphic3d_AspectText3d )& theAspect ) +// ======================================================================= +// function : Prs3d_TextAspect +// purpose : +// ======================================================================= +Prs3d_TextAspect::Prs3d_TextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) +: myTextAspect (theAspect), + myAngle (0.0), + myHeight(16.0), + myHorizontalJustification (Graphic3d_HTA_LEFT), + myVerticalJustification (Graphic3d_VTA_BOTTOM), + myOrientation (Graphic3d_TP_RIGHT) { - myTextAspect = theAspect; + // } diff --git a/src/Prs3d/Prs3d_TextAspect.hxx b/src/Prs3d/Prs3d_TextAspect.hxx index 3410d4ecf5..cfc1d7f751 100644 --- a/src/Prs3d/Prs3d_TextAspect.hxx +++ b/src/Prs3d/Prs3d_TextAspect.hxx @@ -17,71 +17,59 @@ #ifndef _Prs3d_TextAspect_HeaderFile #define _Prs3d_TextAspect_HeaderFile -#include -#include - -#include -#include +#include +#include #include #include -#include #include -#include -#include #include -class Graphic3d_AspectText3d; -class Quantity_Color; - - -class Prs3d_TextAspect; -DEFINE_STANDARD_HANDLE(Prs3d_TextAspect, Prs3d_BasicAspect) +#include //! Defines the attributes when displaying a text. class Prs3d_TextAspect : public Prs3d_BasicAspect { - + DEFINE_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect) public: - //! Constructs an empty framework for defining display attributes of text. Standard_EXPORT Prs3d_TextAspect(); Standard_EXPORT Prs3d_TextAspect(const Handle(Graphic3d_AspectText3d)& theAspect); - Standard_EXPORT void SetColor (const Quantity_Color& aColor); + void SetColor (const Quantity_Color& theColor) { myTextAspect->SetColor (theColor); } //! Sets the color of the type used in text display. - Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor); + void SetColor (const Quantity_NameOfColor theColor) { myTextAspect->SetColor (Quantity_Color (theColor)); } //! Sets the font used in text display. - Standard_EXPORT void SetFont (const Standard_CString aFont); + void SetFont (const Standard_CString theFont) { myTextAspect->SetFont (theFont); } //! Returns the height-width ratio, also known as the expansion factor. - Standard_EXPORT void SetHeightWidthRatio (const Standard_Real aRatio); - + void SetHeightWidthRatio (const Standard_Real theRatio) { myTextAspect->SetExpansionFactor (theRatio); } + //! Sets the length of the box which text will occupy. - Standard_EXPORT void SetSpace (const Quantity_Length aSpace); + void SetSpace (const Quantity_Length theSpace) { myTextAspect->SetSpace (theSpace); } //! Sets the height of the text. - Standard_EXPORT void SetHeight (const Standard_Real aHeight); + void SetHeight (const Standard_Real theHeight) { myHeight = theHeight; } //! Sets the angle - Standard_EXPORT void SetAngle (const Quantity_PlaneAngle anAngle); + void SetAngle (const Quantity_PlaneAngle theAngle) { myAngle = theAngle; } //! Returns the height of the text box. - Standard_EXPORT Standard_Real Height() const; + Standard_Real Height() const { return myHeight; } //! Returns the angle - Standard_EXPORT Quantity_PlaneAngle Angle() const; + Quantity_PlaneAngle Angle() const { return myAngle; } //! Sets horizontal alignment of text. - Standard_EXPORT void SetHorizontalJustification (const Graphic3d_HorizontalTextAlignment aJustification); + void SetHorizontalJustification (const Graphic3d_HorizontalTextAlignment theJustification) { myHorizontalJustification = theJustification; } //! Sets the vertical alignment of text. - Standard_EXPORT void SetVerticalJustification (const Graphic3d_VerticalTextAlignment aJustification); + void SetVerticalJustification (const Graphic3d_VerticalTextAlignment theJustification) { myVerticalJustification = theJustification; } //! Sets the orientation of text. - Standard_EXPORT void SetOrientation (const Graphic3d_TextPath anOrientation); + void SetOrientation (const Graphic3d_TextPath theOrientation) { myOrientation = theOrientation; } //! Returns the horizontal alignment of the text. //! The range of values includes: @@ -89,7 +77,7 @@ public: //! - center //! - right, and //! - normal (justified). - Standard_EXPORT Graphic3d_HorizontalTextAlignment HorizontalJustification() const; + Graphic3d_HorizontalTextAlignment HorizontalJustification() const { return myHorizontalJustification; } //! Returns the vertical alignment of the text. //! The range of values includes: @@ -99,7 +87,7 @@ public: //! - half //! - base //! - bottom - Standard_EXPORT Graphic3d_VerticalTextAlignment VerticalJustification() const; + Graphic3d_VerticalTextAlignment VerticalJustification() const { return myVerticalJustification; } //! Returns the orientation of the text. //! Text can be displayed in the following directions: @@ -107,31 +95,20 @@ public: //! - down //! - left, or //! - right - Standard_EXPORT Graphic3d_TextPath Orientation() const; - + Graphic3d_TextPath Orientation() const { return myOrientation; } + //! Returns the purely textual attributes used in the display of text. //! These include: //! - color //! - font //! - height/width ratio, that is, the expansion factor, and //! - space between characters. - Standard_EXPORT Handle(Graphic3d_AspectText3d) Aspect() const; - - Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect); + const Handle(Graphic3d_AspectText3d)& Aspect() const { return myTextAspect; } - - - - DEFINE_STANDARD_RTTIEXT(Prs3d_TextAspect,Prs3d_BasicAspect) + void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect = theAspect; } protected: - - - -private: - - Handle(Graphic3d_AspectText3d) myTextAspect; Quantity_PlaneAngle myAngle; Standard_Real myHeight; @@ -139,13 +116,8 @@ private: Graphic3d_VerticalTextAlignment myVerticalJustification; Graphic3d_TextPath myOrientation; - }; - - - - - +DEFINE_STANDARD_HANDLE(Prs3d_TextAspect, Prs3d_BasicAspect) #endif // _Prs3d_TextAspect_HeaderFile diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 06e5df43d9..5f4f92b246 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -1320,7 +1320,7 @@ static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, front.SetDiffuseColor(colf); front.SetSpecularColor(colf); front.SetEmissiveColor(colf); - front.SetTransparency(0.4); + front.SetTransparency (0.4f); sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE); Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE); @@ -1328,7 +1328,7 @@ static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, back.SetDiffuseColor(colb); back.SetSpecularColor(colb); back.SetEmissiveColor(colb); - back.SetTransparency(0.2); + back.SetTransparency (0.2f); sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE); AISContext->Redisplay (ais, 1, 0); diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 358a35ae7d..3ef8ae7aab 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -2725,8 +2725,8 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c // Setting material properties, very important for desirable visual result! Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC); - aMat.SetAmbient (0.2); - aMat.SetSpecular (0.5); + aMat.SetAmbient (0.2f); + aMat.SetSpecular (0.5f); Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_RED, diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index f75712e23b..d1bfe2092e 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -425,7 +425,7 @@ static Standard_Integer meshmat if (argc == 4) { Standard_Real aTransparency = Draw::Atof(argv[3]); - aMatAsp.SetTransparency(aTransparency); + aMatAsp.SetTransparency (Standard_ShortReal (aTransparency)); } aMesh->GetDrawer()->SetMaterial( MeshVS_DA_FrontMaterial, aMatAsp ); aMesh->GetDrawer()->SetMaterial( MeshVS_DA_BackMaterial, aMatAsp );