mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
0027670: Visualization - avoid duplication of structures defining primitive array presentation aspects
Quantity_ColorRGBA has been introduced as convenient structure holding Vec4 for OpenGL. Graphic3d_PolygonOffset has been added as replacement for TEL_POFFSET_PARAM. Duplicating definition of Hatch Styles TEL_HS_*** has been removed; Aspect_HatchStyle enum now follows values of TEL_HS_*** for compatibility. TelCullMode enum has been removed. Aspect_AspectLine has been merged into Graphic3d_AspectLine3d. Aspect_AspectMarker has been merged into Graphic3d_AspectMarker3d. Aspect_AspectFillArea has been merged into Graphic3d_AspectFillArea3d. Graphic3d_CAspectFillArea have been removed. OpenGl_AspectLine now stores Graphic3d_AspectLine3d as class field. OpenGl_AspectMarker now stores Graphic3d_AspectMarker3d as class field. OpenGl_AspectText now stores Graphic3d_AspectText3d as class field. OpenGl_AspectFace now stores Graphic3d_AspectFillArea3d as class field. Graphic3d_AspectFillArea3d - back face culling is now enabled by default. TKOpenGl now relies on Graphic3d_Group::IsClosed() flag to disable face culling. StdPrs_ShadedShape now does not modify aspect for different culling modes. Headers InterfaceGraphic_Graphic3d.hxx, InterfaceGraphic_telem.hxx, InterfaceGraphic_tgl_all.hxx defining obsolete structures CALL_DEF_COLOR, CALL_DEF_POINT, CALL_DEF_MATERIAL, CALL_DEF_TRANSFORM_PERSISTENCE, TEL_POINT, TEL_COLOUR have been removed. Useless and broken test case bugs/vis/buc60821 has been removed. OpenGl_Workspace::myAspectFaceApplied and myAspectMarkerApplied have been replaced from OpenGl_AspectFace*/OpenGl_AspectMarker* to Handle(Graphic3d_AspectFillArea3d)/Handle(Graphic3d_AspectMarker3d). This eliminates reading from freed memory (e.g. when OpenGl_AspectFace is allocated on stack like in OpenGl_Trihedron). OpenGl_PrimitiveArray::drawEdges() - fix drawing non-indexed array from VBO (access violation due to NULL handle). AIS_Dimension::DrawArrow() - added missing initialization of 3D arrow aspect. AIS_Manipulator::Compute() now creates dedicated Face Aspect for each axis. V3d_CircularGrid, V3d_RectangularGrid now create dedicated line aspects with different color. AIS_InteractiveObject::SetMaterial() - do not modify global ShadingAspect.
This commit is contained in:
@@ -15,6 +15,7 @@ Quantity_CoefficientOfExpansion.hxx
|
||||
Quantity_Color.cxx
|
||||
Quantity_Color.hxx
|
||||
Quantity_Color_1.hxx
|
||||
Quantity_ColorRGBA.hxx
|
||||
Quantity_ColorDefinitionError.hxx
|
||||
Quantity_Concentration.hxx
|
||||
Quantity_Conductivity.hxx
|
||||
|
@@ -114,6 +114,19 @@ Quantity_Color::Quantity_Color (const Quantity_Parameter R1, const Quantity_Para
|
||||
|
||||
}
|
||||
|
||||
Quantity_Color::Quantity_Color (const NCollection_Vec3<float>& theRgb)
|
||||
: MyRed (theRgb.r()),
|
||||
MyGreen(theRgb.g()),
|
||||
MyBlue (theRgb.b())
|
||||
{
|
||||
if (theRgb.r() < 0.0f || theRgb.r() > 1.0f
|
||||
|| theRgb.g() < 0.0f || theRgb.g() > 1.0f
|
||||
|| theRgb.b() < 0.0f || theRgb.b() > 1.0f)
|
||||
{
|
||||
Standard_OutOfRange::Raise ("Color out");
|
||||
}
|
||||
}
|
||||
|
||||
void Quantity_Color::ChangeContrast (const Quantity_Rate ADelta) {
|
||||
|
||||
Standard_ShortReal MyHue, MyLight, MySaturation;
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
class Quantity_ColorDefinitionError;
|
||||
|
||||
|
||||
@@ -69,7 +70,10 @@ public:
|
||||
//! <R2> is the lightness between 0. and 1.
|
||||
//! <R3> is the saturation between 0. and 1.
|
||||
Standard_EXPORT Quantity_Color(const Quantity_Parameter R1, const Quantity_Parameter R2, const Quantity_Parameter R3, const Quantity_TypeOfColor AType);
|
||||
|
||||
|
||||
//! Define color from RGB values.
|
||||
Standard_EXPORT explicit Quantity_Color (const NCollection_Vec3<float>& theRgb);
|
||||
|
||||
//! Increases or decreases the contrast by <ADelta>.
|
||||
//! <ADelta> is a percentage. Any value greater than zero
|
||||
//! will increase the contrast.
|
||||
@@ -168,7 +172,10 @@ Standard_Boolean operator == (const Quantity_Color& Other) const
|
||||
//! Returns the Saturation component (value of the saturation)
|
||||
//! of the color <me>.
|
||||
Standard_EXPORT Quantity_Parameter Saturation() const;
|
||||
|
||||
|
||||
//! Return the color as vector of 3 float elements.
|
||||
operator const NCollection_Vec3<float>&() const { return *(const NCollection_Vec3<float>* )this; }
|
||||
|
||||
//! Returns in R1, R2 and R3 the components of
|
||||
//! this color according to the color system definition AType.
|
||||
//! - if AType is Quantity_TOC_RGB R1 is the
|
||||
|
84
src/Quantity/Quantity_ColorRGBA.hxx
Normal file
84
src/Quantity/Quantity_ColorRGBA.hxx
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright (c) 2016 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 _Quantity_ColorRGBA_HeaderFile
|
||||
#define _Quantity_ColorRGBA_HeaderFile
|
||||
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
//! The pair of Quantity_Color and Alpha component (1.0 opaque, 0.0 transparent).
|
||||
class Quantity_ColorRGBA
|
||||
{
|
||||
public:
|
||||
|
||||
//! Creates a color with the default value.
|
||||
Quantity_ColorRGBA() : myAlpha (1.0f) {}
|
||||
|
||||
//! Creates the color with specified RGB value.
|
||||
explicit Quantity_ColorRGBA (const Quantity_Color& theRgb) : myRgb (theRgb), myAlpha (1.0f) {}
|
||||
|
||||
//! Creates the color from RGBA vector.
|
||||
explicit Quantity_ColorRGBA (const NCollection_Vec4<float>& theRgba) : myRgb (theRgba.rgb()), myAlpha (theRgba.a()) {}
|
||||
|
||||
//! Return RGB color value.
|
||||
const Quantity_Color& GetRGB() const { return myRgb; }
|
||||
|
||||
//! Modify RGB color components without affecting alpha value.
|
||||
Quantity_Color& ChangeRGB() { return myRgb; }
|
||||
|
||||
//! Assign RGB color components without affecting alpha value.
|
||||
void SetRGB (const Quantity_Color& theRgb) { myRgb = theRgb; }
|
||||
|
||||
//! Return alpha value (1.0 means opaque, 0.0 means fully transparent).
|
||||
Standard_ShortReal Alpha() const { return myAlpha; }
|
||||
|
||||
//! Assign the alpha value.
|
||||
void SetAlpha (const Standard_ShortReal theAlpha) { myAlpha = theAlpha; }
|
||||
|
||||
//! Return the color as vector of 4 float elements.
|
||||
operator const NCollection_Vec4<float>&() const { return *(const NCollection_Vec4<float>* )this; }
|
||||
|
||||
//! Returns true if the distance between colors is greater than Epsilon().
|
||||
bool IsDifferent (const Quantity_ColorRGBA& theOther) const
|
||||
{
|
||||
return myRgb.IsDifferent (theOther.GetRGB())
|
||||
|| Abs(myAlpha - theOther.myAlpha) > (float )Quantity_Color::Epsilon();
|
||||
}
|
||||
|
||||
//! Returns true if the distance between colors is greater than Epsilon().
|
||||
bool operator!= (const Quantity_ColorRGBA& theOther) const { return IsDifferent (theOther); }
|
||||
|
||||
//! Two colors are considered to be equal if their distance is no greater than Epsilon().
|
||||
bool IsEqual (const Quantity_ColorRGBA& theOther) const
|
||||
{
|
||||
return myRgb.IsEqual (theOther.GetRGB())
|
||||
&& Abs(myAlpha - theOther.myAlpha) <= (float )Quantity_Color::Epsilon();
|
||||
}
|
||||
|
||||
//! Two colors are considered to be equal if their distance is no greater than Epsilon().
|
||||
bool operator== (const Quantity_ColorRGBA& theOther) const { return IsEqual (theOther); }
|
||||
|
||||
private:
|
||||
|
||||
static void __testSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); }
|
||||
static void __testSize4() { Standard_STATIC_ASSERT (sizeof(float) * 4 == sizeof(Quantity_ColorRGBA)); }
|
||||
|
||||
private:
|
||||
|
||||
Quantity_Color myRgb;
|
||||
Standard_ShortReal myAlpha;
|
||||
|
||||
};
|
||||
|
||||
#endif // _Quantity_ColorRGBA_HeaderFile
|
Reference in New Issue
Block a user