Aspect_IS_HOLLOW now an alias to Aspect_IS_EMPTY and Aspect_IS_HIDDENLINE does not implicitly enables mesh edges,
so that Graphic3d_AspectFillArea3d::SetDrawEdges() should be set independently.
OpenGl_ShaderManager now provides built-in GLSL programs for drawing mesh edges
in single pass (and on OpenGL ES which does not provide glPolygonMode()).
Graphic3d_RenderingParams::ToEnableAlphaToCoverage is now enabled by default
and properly handled at TKOpenGl level - enables coverage for Graphic3d_AlphaMode_Mask primitives.
OpenGl_PrimitiveArray now uses GLSL programs instead of glPolygonMode() by default,
which can be managed by OpenGl_Caps::usePolygonMode flag (desktop OpenGL only).
glPolygonMode() is also used as fallback regardless OpenGl_Caps::usePolygonMode flag
when GLSL programs are not supported (Geometry Shaders are required)
or stipple line style is required (not implemented within Face GLSL).
vaspects command has been extended by -setInterior -setDrawEdges -setEdgeColor -setEdgeType -setEdgeWidth
arguments replacing vsetinteriorstyle/vsetedgetype/vunsetedgetype commands.
vaspects now accepts arguments without "set" prefix.
ViewerTest::ParseColor() now parses RGBA color.
Redundant command BUC60738 has been removed.
AIS_ColorScale - fixed usage of uninitialized FillArea aspects.
Some public methods of the class BRepFilletAPI_MakeChamfer are released from excess arguments:
- method Add for symmetric chamfer now takes only 2 arguments: distance and edge;
- method GetDistAngle now takes only 3 arguments: index of contour, distance and angle.
+
+@subsection upgrade_740_interiorstyles Interior styles
+
+* *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore.
+ Specify Graphic3d_AspectFillArea3d::SetDrawEdges(true) with Graphic3d_AspectFillArea3d::SetInteriorStyle(Aspect_IS_EMPTY) to get previous behavior of Aspect_IS_HOLLOW style.
+* *Aspect_IS_HIDDENLINE* does not implicitly enables drawing mesh edges anymore.
+ Specify Graphic3d_AspectFillArea3d::SetDrawEdges(true) with Graphic3d_AspectFillArea3d::SetInteriorStyle(Aspect_IS_HIDDENLINE) to get previous behavior of Aspect_IS_HIDDENLINE style.
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = new Graphic3d_AspectFillArea3d();
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NOM_BRASS);
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NOM_GOLD);
-aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID);
+aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID_WIREFRAME);
aFaceAspect->SetInteriorColor (aMyColor);
aFaceAspect->SetDistinguishOn ();
aFaceAspect->SetFrontMaterial (aGoldMaterial);
aFaceAspect->SetBackMaterial (aBrassMaterial);
-aFaceAspect->SetEdgeOn();
~~~~~
Create text attributes.
myTextHeight (20)
{
SetDisplayMode (0);
+ myDrawer->SetupOwnShadingAspect();
+ myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
+ myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
+ myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (Quantity_NOC_WHITE);
}
//=======================================================================
const Standard_Integer aBarTop = myYPos + myHeight - aTitleOffset - aBarYOffset;
const Standard_Integer aBarHeight = aBarTop - aBarBottom;
- // draw title
- if (!myTitle.IsEmpty())
- {
- drawText (Prs3d_Root::CurrentGroup (thePrs), myTitle,
- myXPos + mySpacing,
- aBarTop + aBarYOffset,
- Graphic3d_VTA_BOTTOM);
- }
-
TColStd_SequenceOfExtendedString aLabels;
if (myLabelType == Aspect_TOCSD_USER)
{
aColorBreadth += aTextWidth;
}
+ // draw title
+ Handle(Graphic3d_Group) aLabelsGroup;
+ if (!myTitle.IsEmpty()
+ || !aLabels.IsEmpty())
+ {
+ aLabelsGroup = thePrs->NewGroup();
+ aLabelsGroup->SetGroupPrimitivesAspect (myDrawer->TextAspect()->Aspect());
+ }
+ if (!myTitle.IsEmpty())
+ {
+ drawText (aLabelsGroup, myTitle,
+ myXPos + mySpacing,
+ aBarTop + aBarYOffset,
+ Graphic3d_VTA_BOTTOM);
+ }
+
// draw colors
drawColorBar (thePrs, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
// draw Labels
- drawLabels (thePrs, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
+ drawLabels (aLabelsGroup, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
}
//=======================================================================
}
}
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
+ Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+ aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (aTriangles);
const Quantity_Color aFgColor (hasOwnColor ? myDrawer->Color() : Quantity_NOC_WHITE);
//function : drawLabels
//purpose :
//=======================================================================
-void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
+void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
const TColStd_SequenceOfExtendedString& theLabels,
const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight,
Standard_Integer aPos2 = aNbLabels - 1 - i2;
if (aFilter && !(aPos1 % aFilter))
{
- drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i1 + 1),
+ drawText (theGroup, theLabels.Value (i1 + 1),
anXLeft, anYBottom + Standard_Integer(i1 * aStepY + anAscent),
Graphic3d_VTA_CENTER);
aLast1 = i1;
}
if (aFilter && !(aPos2 % aFilter))
{
- drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i2 + 1),
+ drawText (theGroup, theLabels.Value (i2 + 1),
anXLeft, anYBottom + Standard_Integer(i2 * aStepY + anAscent),
Graphic3d_VTA_CENTER);
aLast2 = i2;
if (i0 != -1)
{
- drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i0 + 1),
+ drawText (theGroup, theLabels.Value (i0 + 1),
anXLeft, anYBottom + Standard_Integer(i0 * aStepY + anAscent),
Graphic3d_VTA_CENTER);
}
aPrim->AddVertex (theX, theY, 0.0);
Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d (theColor, Aspect_TOL_SOLID, 1.0);
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
- aGroup->SetPrimitivesAspect (anAspect);
+ Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+ aGroup->SetGroupPrimitivesAspect (anAspect);
aGroup->AddPrimitiveArray (aPrim);
}
const Graphic3d_VerticalTextAlignment theVertAlignment)
{
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
- theGroup->SetPrimitivesAspect (anAspect->Aspect());
theGroup->Text (theText,
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
anAspect->Height(),
Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const;
//! Draw labels.
- void drawLabels (const Handle(Prs3d_Presentation)& thePrs,
+ void drawLabels (const Handle(Graphic3d_Group)& theGroup,
const TColStd_SequenceOfExtendedString& theLabels,
const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight,
const Quantity_Color& theColor) const
{
bool toRecompute = false;
- if (!theDrawer->HasOwnShadingAspect())
- {
- toRecompute = true;
- theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- if (theDrawer->HasLink())
- {
- *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnLineAspect())
- {
- toRecompute = true;
- theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnWireAspect())
- {
- toRecompute = true;
- theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnPointAspect())
- {
- toRecompute = true;
- theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnFreeBoundaryAspect())
- {
- toRecompute = true;
- theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnUnFreeBoundaryAspect())
- {
- toRecompute = true;
- theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnSeenLineAspect())
- {
- toRecompute = true;
- theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnFaceBoundaryAspect())
+ toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
+ toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+
+ if (theDrawer->SetupOwnPointAspect())
{
toRecompute = true;
- theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
- }
}
// override color
bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theLineWidth) const
{
- bool toRecompute = false;
- if (!theDrawer->HasOwnLineAspect())
- {
- toRecompute = true;
- theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnWireAspect())
- {
- toRecompute = true;
- theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnFreeBoundaryAspect())
- {
- toRecompute = true;
- theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnUnFreeBoundaryAspect())
- {
- toRecompute = true;
- theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnSeenLineAspect())
- {
- toRecompute = true;
- theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnFaceBoundaryAspect())
- {
- toRecompute = true;
- theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
- }
- }
+ bool toRecompute = theDrawer->SetOwnLineAspects();
// override width
theDrawer->LineAspect()->SetWidth (theLineWidth);
{
const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
- if (!theDrawer->HasOwnShadingAspect())
- {
- theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- if (theDrawer->HasLink())
- {
- *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
- }
- }
+ theDrawer->SetupOwnShadingAspect();
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
if (theToKeepColor)
void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theValue) const
{
- if (!theDrawer->HasOwnShadingAspect())
- {
- theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- if (theDrawer->HasLink())
- {
- *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
- }
- }
-
+ theDrawer->SetupOwnShadingAspect();
// override transparency
theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
}
//! To generate texture coordinates, appropriate shading attribute should be set before computing presentation in AIS_Shaded display mode:
//! @code
//! Handle(AIS_Shape) aPrs = new AIS_Shape();
-//! aPrs->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
+//! aPrs->Attributes()->SetupOwnShadingAspect();
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
//! @endcode
#ifndef _Aspect_InteriorStyle_HeaderFile
#define _Aspect_InteriorStyle_HeaderFile
-//! Definition of interior types for primitive
-//! faces.
-//!
-//! IS_EMPTY no interior.
-//! IS_HOLLOW display the boundaries of the surface.
-//! IS_HATCH display hatched with a hatch style.
-//! IS_SOLID display the interior entirely filled.
-//! IS_HIDDENLINE display in hidden lines removed.
-//! IS_POINT display only vertices.
+//! Interior types for primitive faces.
enum Aspect_InteriorStyle
{
-Aspect_IS_EMPTY,
-Aspect_IS_HOLLOW,
-Aspect_IS_HATCH,
-Aspect_IS_SOLID,
-Aspect_IS_HIDDENLINE,
-Aspect_IS_POINT
+ Aspect_IS_EMPTY = -1, //!< no interior
+ Aspect_IS_SOLID = 0, //!< normally filled surface interior
+ Aspect_IS_HATCH, //!< hatched surface interior
+ Aspect_IS_HIDDENLINE, //!< interior is filled with viewer background color
+ Aspect_IS_POINT, //!< display only vertices of surface (obsolete)
+
+ // obsolete aliases
+ Aspect_IS_HOLLOW = Aspect_IS_EMPTY, //!< transparent surface interior
};
#endif // _Aspect_InteriorStyle_HeaderFile
myEdgeType (Aspect_TOL_SOLID),
myEdgeWidth (1.0f),
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
+ myToSkipFirstEdge (false),
myToDistinguishMaterials (false),
myToDrawEdges (false),
myToSuppressBackFaces (true),
myEdgeType (theEdgeLineType),
myEdgeWidth ((float )theEdgeLineWidth),
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
+ myToSkipFirstEdge (false),
myToDistinguishMaterials (false),
myToDrawEdges (false),
myToSuppressBackFaces (true),
public:
//! Returns true if edges should be drawn (false by default).
- bool ToDrawEdges() const { return myToDrawEdges; }
+ bool ToDrawEdges() const { return myToDrawEdges && myEdgeType != Aspect_TOL_EMPTY; }
//! Set if edges should be drawn or not.
- void SetDrawEdges (bool theToDraw) { myToDrawEdges = theToDraw; }
+ void SetDrawEdges (bool theToDraw)
+ {
+ myToDrawEdges = theToDraw;
+ if (myEdgeType == Aspect_TOL_EMPTY)
+ {
+ myEdgeType = Aspect_TOL_SOLID;
+ }
+ }
//! Returns true if edges should be drawn.
- bool Edge() const { return myToDrawEdges; }
+ bool Edge() const { return ToDrawEdges(); }
//! The edges of FillAreas are drawn.
- void SetEdgeOn() { myToDrawEdges = true; }
+ void SetEdgeOn() { SetDrawEdges (true); }
//! The edges of FillAreas are not drawn.
- void SetEdgeOff() { myToDrawEdges = false; }
+ void SetEdgeOff() { SetDrawEdges (false); }
//! Return color of edges.
const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
//! Modifies the color of the edge of the face
void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
+ //! Modifies the color of the edge of the face
+ void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
+
//! Return edges line type.
Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
myEdgeWidth = (float )theWidth;
}
+ //! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
+ //! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
+ //! This flag allows rendering wireframe presentation of quad-only array split into triangles.
+ //! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
+ //! 1------2
+ //! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3
+ //! 0------3
+ bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
+
+ //! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
+ void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
+
public:
//! Returns the hatch type used when InteriorStyle is IS_HATCH
Handle(Graphic3d_HatchStyle) myHatchStyle;
Graphic3d_PolygonOffset myPolygonOffset;
+ bool myToSkipFirstEdge;
bool myToDistinguishMaterials;
bool myToDrawEdges;
bool myToSuppressBackFaces;
Graphic3d_RenderingParams()
: Method (Graphic3d_RM_RASTERIZATION),
TransparencyMethod (Graphic3d_RTM_BLEND_UNORDERED),
+ LineFeather (1.0f),
OitDepthFactor (0.0f),
NbMsaaSamples (0),
RenderResolutionScale (1.0f),
ToEnableDepthPrepass (Standard_False),
- ToEnableAlphaToCoverage (Standard_False),
+ ToEnableAlphaToCoverage (Standard_True),
// ray tracing parameters
IsGlobalIlluminationEnabled (Standard_False),
RaytracingDepth (THE_DEFAULT_DEPTH),
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
Graphic3d_RenderTransparentMethod TransparencyMethod; //!< specifies rendering method for transparent graphics
+ Standard_ShortReal LineFeather; //!< line feater width in pixels (> 0.0), 1.0 by default;
+ //! high values produce blurred results, small values produce sharp (aliased) edges
Standard_ShortReal OitDepthFactor; //!< scalar factor [0-1] controlling influence of depth of a fragment to its final coverage
Standard_Integer NbMsaaSamples; //!< number of MSAA samples (should be within 0..GL_MAX_SAMPLES, power-of-two number), 0 by default
Standard_ShortReal RenderResolutionScale; //!< rendering resolution scale factor, 1 by default;
//! incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
Standard_Boolean ToEnableDepthPrepass; //!< enables/disables depth pre-pass, False by default
- Standard_Boolean ToEnableAlphaToCoverage; //!< enables/disables alpha to coverage, False by default
+ Standard_Boolean ToEnableAlphaToCoverage; //!< enables/disables alpha to coverage, True by default
Standard_Boolean IsGlobalIlluminationEnabled; //!< enables/disables global illumination effects (path tracing)
Standard_Integer SamplesPerPixel; //!< number of samples per pixel (SPP)
Graphic3d_TypeOfLimit_HasBlendedOit, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (without MSAA).
Graphic3d_TypeOfLimit_HasBlendedOitMsaa, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (with MSAA).
Graphic3d_TypeOfLimit_HasFlatShading, //!< indicates whether Flat shading (Graphic3d_TOSM_FACET) is supported
+ Graphic3d_TypeOfLimit_HasMeshEdges, //!< indicates whether advanced mesh edges presentation is supported
Graphic3d_TypeOfLimit_IsWorkaroundFBO, //!< indicates whether workaround for Intel driver problem with empty FBO for images with big width is applyed.
Graphic3d_TypeOfLimit_NB //!< number of elements in this enumeration
};
: vboDisable (Standard_False),
pntSpritesDisable (Standard_False),
keepArrayData (Standard_False),
-#if !defined(GL_ES_VERSION_2_0)
ffpEnable (Standard_False),
+ usePolygonMode (Standard_False),
+#if !defined(GL_ES_VERSION_2_0)
useSystemBuffer (Standard_False),
#else
- ffpEnable (Standard_False),
useSystemBuffer (Standard_True),
#endif
swapInterval (1),
Standard_Boolean vboDisable; //!< flag permits VBO usage, will significantly affect performance (OFF by default)
Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
Standard_Boolean keepArrayData; //!< Disables freeing CPU memory after building VBOs (OFF by default)
- Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (ON by default on desktop OpenGL and OFF on OpenGL ES)
+ Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (OFF by default)
+ Standard_Boolean usePolygonMode; //!< Enables Polygon Mode instead of built-in GLSL programs (OFF by default; unsupported on OpenGL ES)
Standard_Boolean useSystemBuffer; //!< Enables usage of system backbuffer for blitting (OFF by default on desktop OpenGL and ON on OpenGL ES for testing)
Standard_Integer swapInterval; //!< controls swap interval - 0 for VSync off and 1 for VSync on, 1 by default
hasFloatBuffer (OpenGl_FeatureNotAvailable),
hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
hasSampleVariables (OpenGl_FeatureNotAvailable),
+ hasGeometryStage (OpenGl_FeatureNotAvailable),
arbDrawBuffers (Standard_False),
arbNPTW (Standard_False),
arbTexRG (Standard_False),
myResolution (Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION),
myResolutionRatio (1.0f),
myLineWidthScale (1.0f),
+ myLineFeather (1.0f),
myRenderScale (1.0f),
myRenderScaleInv (1.0f)
{
// dFdx/dFdy are completely broken on tested Adreno devices with versions below OpenGl ES 3.1
hasFlatShading = OpenGl_FeatureNotAvailable;
}
+
+ hasGeometryStage = IsGlGreaterEqual (3, 2)
+ ? OpenGl_FeatureInCore
+ : (CheckExtension ("GL_EXT_geometry_shader") && CheckExtension ("GL_EXT_shader_io_blocks")
+ ? OpenGl_FeatureInExtensions
+ : OpenGl_FeatureNotAvailable);
#else
myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
+ hasGeometryStage = IsGlGreaterEqual (3, 2)
+ ? OpenGl_FeatureInCore
+ : OpenGl_FeatureNotAvailable;
+
hasSampleVariables = IsGlGreaterEqual (4, 0) ? OpenGl_FeatureInCore :
arbSampleShading ? OpenGl_FeatureInExtensions
: OpenGl_FeatureNotAvailable;
// do not update material properties in case of zero reflection mode,
// because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
const OpenGl_MaterialState& aMatState = myShaderManager->MaterialState();
- const float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
- ? anAspect->AlphaCutoff()
- : ShortRealLast();
+ float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
+ ? anAspect->AlphaCutoff()
+ : ShortRealLast();
+ if (anAspect->ToDrawEdges())
+ {
+ if (anAspect->InteriorStyle() == Aspect_IS_EMPTY
+ || (anAspect->InteriorStyle() == Aspect_IS_SOLID
+ && anAspect->EdgeColorRGBA().Alpha() < 1.0f))
+ {
+ anAlphaCutoff = 0.285f;
+ }
+ }
if (theAspect->ShadingModel() == Graphic3d_TOSM_UNLIT)
{
if (anAlphaCutoff == aMatState.AlphaCutoff())
// =======================================================================
bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
{
- if (myAlphaToCoverage == theToEnable)
+ bool toEnable = myAllowAlphaToCov && theToEnable;
+ if (myAlphaToCoverage == toEnable)
{
return myAlphaToCoverage;
}
if (core15fwd != NULL)
{
- if (theToEnable)
+ if (toEnable)
{
//core15fwd->core15fwd->glSampleCoverage (1.0f, GL_FALSE);
core15fwd->glEnable (GL_SAMPLE_ALPHA_TO_COVERAGE);
}
const bool anOldValue = myAlphaToCoverage;
- myAlphaToCoverage = theToEnable;
+ myAlphaToCoverage = toEnable;
return anOldValue;
}
//! Enable/disable writing into color buffer (wrapper for glColorMask).
Standard_EXPORT bool SetColorMask (bool theToWriteColor);
+ //! Return TRUE if GL_SAMPLE_ALPHA_TO_COVERAGE usage is allowed.
+ bool AllowSampleAlphaToCoverage() const { return myAllowAlphaToCov; }
+
+ //! Allow GL_SAMPLE_ALPHA_TO_COVERAGE usage.
+ void SetAllowSampleAlphaToCoverage (bool theToEnable) { myAllowAlphaToCov = theToEnable; }
+
//! Return GL_SAMPLE_ALPHA_TO_COVERAGE state.
bool SampleAlphaToCoverage() const { return myAlphaToCoverage; }
//! Rendering scale factor (inverted value).
Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; }
+ //! Return scale factor for line width.
+ Standard_ShortReal LineWidthScale() const { return myLineWidthScale; }
+
//! Set resolution ratio.
//! Note that this method rounds @theRatio to nearest integer.
void SetResolution (unsigned int theResolution,
myLineWidthScale = Max (1.0f, std::floor (theRatio + 0.5f));
}
+ //! Return line feater width in pixels.
+ Standard_ShortReal LineFeather() const { return myLineFeather; }
+
+ //! Set line feater width.
+ void SetLineFeather(Standard_ShortReal theValue) { myLineFeather = theValue; }
+
//! Return Graphics Driver's vendor.
const TCollection_AsciiString& Vendor() const { return myVendor; }
OpenGl_FeatureFlag hasFloatBuffer; //!< Complex flag indicating support of float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_float)
OpenGl_FeatureFlag hasHalfFloatBuffer; //!< Complex flag indicating support of half-float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_half_float)
OpenGl_FeatureFlag hasSampleVariables; //!< Complex flag indicating support of MSAA variables in GLSL shader (desktop OpenGL 4.0, GL_ARB_sample_shading)
+ OpenGl_FeatureFlag hasGeometryStage; //!< Complex flag indicating support of Geometry shader (desktop OpenGL 3.2, OpenGL ES 3.2, GL_EXT_geometry_shader)
Standard_Boolean arbDrawBuffers; //!< GL_ARB_draw_buffers
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
myDrawBuffers; //!< current draw buffers
unsigned int myDefaultVao; //!< default Vertex Array Object
Standard_Boolean myColorMask; //!< flag indicating writing into color buffer is enabled or disabled (glColorMask)
+ Standard_Boolean myAllowAlphaToCov; //!< flag allowing GL_SAMPLE_ALPHA_TO_COVERAGE usage
Standard_Boolean myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size
//! to be properly displayed on device (screen / printer)
Standard_ShortReal myLineWidthScale; //!< scaling factor for line width
+ Standard_ShortReal myLineFeather; //!< line feater width in pixels
Standard_ShortReal myRenderScale; //!< scaling factor for rendering resolution
Standard_ShortReal myRenderScaleInv; //!< scaling factor for rendering resolution (inverted value)
OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable ? 1 : 0;
case Graphic3d_TypeOfLimit_IsWorkaroundFBO:
return !aCtx.IsNull() && aCtx->MaxTextureSize() != aCtx->MaxDumpSizeX() ? 1 : 0;
+ case Graphic3d_TypeOfLimit_HasMeshEdges:
+ return !aCtx.IsNull() && aCtx->hasGeometryStage != OpenGl_FeatureNotAvailable ? 1 : 0;
case Graphic3d_TypeOfLimit_NB:
return 0;
}
}
#if !defined(GL_ES_VERSION_2_0)
- if (theStyle->HatchType() != 0)
+ if (theGlCtx->core11 == NULL)
+ {
+ return 0;
+ }
+ else if (theStyle->HatchType() != 0)
{
theGlCtx->core11->glCallList ((GLuint)aGpuListId);
const bool anOldIsEnabled = myIsEnabled;
#if !defined(GL_ES_VERSION_2_0)
- if (theToEnable)
+ if (theGlCtx->core11 == NULL)
+ {
+ return 0;
+ }
+ else if (theToEnable)
{
if (myTypeOfHatch != 0)
{
//! Alpha cutoff value.
float AlphaCutoff() const { return myAlphaCutoff; }
+ //! Return TRUE if alpha test should be enabled.
+ bool HasAlphaCutoff() const { return myAlphaCutoff <= 1.0f; }
+
//! Distinguish front/back flag.
bool ToDistinguish() const { return myToDistinguish; }
const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
-
#if !defined(GL_ES_VERSION_2_0)
- glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+ const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
#endif
if (aGlContext->core20fwd != NULL)
// restore line context
theWorkspace->SetAspectLine (anAspectLineOld);
+#if !defined(GL_ES_VERSION_2_0)
+ aGlContext->SetPolygonMode (aPolyModeOld);
+#endif
}
// =======================================================================
// Temporarily disable environment mapping
Handle(OpenGl_TextureSet) aTextureBack;
bool toDrawArray = true;
+ int toDrawInteriorEdges = 0; // 0 - no edges, 1 - glsl edges, 2 - polygonMode
if (myDrawMode > GL_LINE_STRIP)
{
toDrawArray = anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_EMPTY;
+ if (anAspectFace->Aspect()->ToDrawEdges())
+ {
+ toDrawInteriorEdges = 1;
+ toDrawArray = true;
+ #if !defined(GL_ES_VERSION_2_0)
+ if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID
+ || aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable
+ || aCtx->caps->usePolygonMode)
+ {
+ toDrawInteriorEdges = 2;
+ if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_EMPTY)
+ {
+ if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID)
+ {
+ toDrawArray = false;
+ }
+ else
+ {
+ aCtx->SetPolygonMode (GL_LINE);
+ }
+ }
+ }
+ #endif
+ }
}
else if (myDrawMode <= GL_LINE_STRIP)
{
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
aCtx->ShaderManager()->BindFaceProgram (aTextures,
aShadingModel,
- anAspectFace->Aspect()->AlphaMode(),
+ aCtx->ShaderManager()->MaterialState().HasAlphaCutoff() ? Graphic3d_AlphaMode_Mask : Graphic3d_AlphaMode_Opaque,
+ toDrawInteriorEdges == 1 ? anAspectFace->Aspect()->InteriorStyle() : Aspect_IS_SOLID,
hasVertColor,
toEnableEnvMap,
+ toDrawInteriorEdges == 1,
anAspectFace->ShaderProgramRes (aCtx));
+ if (toDrawInteriorEdges == 1)
+ {
+ aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect());
+ }
break;
}
}
{
aCtx->BindTextures (aTextureBack);
}
- else
+#if !defined(GL_ES_VERSION_2_0)
+ else if (toDrawInteriorEdges == 2)
{
- if (anAspectFace->Aspect()->ToDrawEdges()
- || anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
+ if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HOLLOW
+ && anAspectFace->Aspect()->EdgeLineType() == Aspect_TOL_SOLID)
+ {
+ aCtx->SetPolygonMode (GL_FILL);
+ }
+ else
{
const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
drawEdges (anEdgeColor, theWorkspace);
-
- // restore OpenGL polygon mode if needed
- #if !defined(GL_ES_VERSION_2_0)
- if (anAspectFace->Aspect()->InteriorStyle() >= Aspect_IS_HATCH)
- {
- glPolygonMode (GL_FRONT_AND_BACK,
- anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_POINT ? GL_POINT : GL_FILL);
- }
- #endif
}
}
+#endif
}
// =======================================================================
//! Standard GLSL program combination bits.
enum OpenGl_ProgramOptions
{
- OpenGl_PO_Point = 0x001, //!< point marker
- OpenGl_PO_VertColor = 0x002, //!< per-vertex color
- OpenGl_PO_TextureRGB = 0x004, //!< handle RGB texturing
- OpenGl_PO_TextureA = 0x008, //!< handle Alpha texturing
- OpenGl_PO_TextureEnv = 0x010, //!< handle environment map
- OpenGl_PO_StippleLine = 0x020, //!< stipple line
- OpenGl_PO_ClipPlanes1 = 0x040, //!< handle 1 clipping plane
- OpenGl_PO_ClipPlanes2 = 0x080, //!< handle 2 clipping planes
- //OpenGl_PO_ClipPlanes3 = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle 3 clipping planes - not implemented
- OpenGl_PO_ClipPlanesN = 0x100, //!< handle N clipping planes
- OpenGl_PO_ClipChains = 0x200, //!< handle chains of clipping planes
- OpenGl_PO_AlphaTest = 0x400, //!< discard fragment by alpha test (defined by cutoff value)
- OpenGl_PO_WriteOit = 0x800, //!< write coverage buffer for Blended Order-Independent Transparency
- OpenGl_PO_NB = 0x1000 //!< overall number of combinations
+ OpenGl_PO_Point = 0x0001, //!< point marker
+ OpenGl_PO_VertColor = 0x0002, //!< per-vertex color
+ OpenGl_PO_TextureRGB = 0x0004, //!< handle RGB texturing
+ OpenGl_PO_TextureA = 0x0008, //!< handle Alpha texturing
+ OpenGl_PO_TextureEnv = 0x0010, //!< handle environment map
+ OpenGl_PO_StippleLine = 0x0020, //!< stipple line
+ OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
+ OpenGl_PO_ClipPlanes2 = 0x0080, //!< handle 2 clipping planes
+ OpenGl_PO_ClipPlanesN = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
+ OpenGl_PO_ClipChains = 0x0100, //!< handle chains of clipping planes
+ OpenGl_PO_MeshEdges = 0x0200, //!< draw mesh edges (wireframe)
+ OpenGl_PO_AlphaTest = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
+ OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
+ //
+ OpenGl_PO_NB = 0x1000, //!< overall number of combinations
+ OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
};
//! Alias to programs array of predefined length
EOL" discard;"
EOL" }";
+//! Modify color for Wireframe presentation.
+const char THE_FRAG_WIREFRAME_COLOR[] =
+EOL"vec4 getFinalColor(void)"
+EOL"{"
+EOL" float aDistance = min (min (EdgeDistance[0], EdgeDistance[1]), EdgeDistance[2]);"
+EOL" bool isHollow = occWireframeColor.a < 0.0;"
+EOL" float aMixVal = smoothstep (occLineWidth - occLineFeather * 0.5, occLineWidth + occLineFeather * 0.5, aDistance);"
+EOL" vec4 aMixColor = isHollow"
+EOL" ? vec4 (getColor().rgb, 1.0 - aMixVal)" // edges only (of interior color)
+EOL" : mix (occWireframeColor, getColor(), aMixVal);" // interior + edges
+EOL" return aMixColor;"
+EOL"}";
+
#if !defined(GL_ES_VERSION_2_0)
static const GLfloat THE_DEFAULT_AMBIENT[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
return;
}
+ myContext->SetSampleAlphaToCoverage (false);
if (myMaterialState.AlphaCutoff() < ShortRealLast())
{
glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
return;
}
+ myContext->SetSampleAlphaToCoverage (myMaterialState.HasAlphaCutoff());
theProgram->SetUniform (myContext,
theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
myMaterialState.AlphaCutoff());
theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
myMaterialState.ToDistinguish() ? 1 : 0);
- const GLint aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL);
- if (aLocFront != OpenGl_ShaderProgram::INVALID_LOCATION)
+ if (const OpenGl_ShaderUniformLocation aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL))
{
theProgram->SetUniform (myContext, aLocFront, OpenGl_Material::NbOfVec4(),
aFrontMat.Packed());
}
-
- const GLint aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL);
- if (aLocBack != OpenGl_ShaderProgram::INVALID_LOCATION)
+ if (const OpenGl_ShaderUniformLocation aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL))
{
theProgram->SetUniform (myContext, aLocBack, OpenGl_Material::NbOfVec4(),
aBackMat.Packed());
}
}
+// =======================================================================
+// function : PushInteriorState
+// purpose :
+// =======================================================================
+void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
+ const Handle(Graphic3d_AspectFillArea3d)& theAspect) const
+{
+ if (theProgram.IsNull()
+ || !theProgram->IsValid())
+ {
+ return;
+ }
+
+ if (const OpenGl_ShaderUniformLocation aLocViewPort = theProgram->GetStateLocation (OpenGl_OCCT_VIEWPORT))
+ {
+ theProgram->SetUniform (myContext, aLocViewPort, OpenGl_Vec4 ((float )myContext->Viewport()[0], (float )myContext->Viewport()[1], (float )myContext->Viewport()[2], (float )myContext->Viewport()[3]));
+ }
+ if (const OpenGl_ShaderUniformLocation aLocLineWidth = theProgram->GetStateLocation (OpenGl_OCCT_LINE_WIDTH))
+ {
+ theProgram->SetUniform (myContext, aLocLineWidth, theAspect->EdgeWidth() * myContext->LineWidthScale());
+ theProgram->SetUniform (myContext, theProgram->GetStateLocation (OpenGl_OCCT_LINE_FEATHER), myContext->LineFeather() * myContext->LineWidthScale());
+ }
+ if (const OpenGl_ShaderUniformLocation aLocWireframeColor = theProgram->GetStateLocation (OpenGl_OCCT_WIREFRAME_COLOR))
+ {
+ if (theAspect->InteriorStyle() == Aspect_IS_HOLLOW)
+ {
+ theProgram->SetUniform (myContext, aLocWireframeColor, OpenGl_Vec4 (-1.0f, -1.0f, -1.0f, -1.0f));
+ }
+ else
+ {
+ theProgram->SetUniform (myContext, aLocWireframeColor, theAspect->EdgeColorRGBA());
+ }
+ }
+ if (const OpenGl_ShaderUniformLocation aLocQuadModeState = theProgram->GetStateLocation (OpenGl_OCCT_QUAD_MODE_STATE))
+ {
+ theProgram->SetUniform (myContext, aLocQuadModeState, theAspect->ToSkipFirstEdge() ? 1 : 0);
+ }
+}
+
// =======================================================================
// function : PushState
// purpose : Pushes state of OCCT graphics parameters to the program
EOL"}";
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
-#if !defined(GL_ES_VERSION_2_0)
- if (myContext->core32 != NULL)
- {
- aProgramSrc->SetHeader ("#version 150");
- }
-#else
- if (myContext->IsGlGreaterEqual (3, 1))
- {
- // prefer "100 es" on OpenGL ES 3.0 devices
- // and "300 es" on newer devices (3.1+)
- aProgramSrc->SetHeader ("#version 300 es");
- }
-#endif
+ defaultGlslVersion (aProgramSrc, 0);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
}
+// =======================================================================
+// function : defaultGlslVersion
+// purpose :
+// =======================================================================
+int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgram)& theProgram,
+ int theBits,
+ bool theUsesDerivates) const
+{
+ int aBits = theBits;
+#if !defined(GL_ES_VERSION_2_0)
+ if (myContext->core32 != NULL)
+ {
+ theProgram->SetHeader ("#version 150");
+ }
+ else
+ {
+ if ((theBits & OpenGl_PO_StippleLine) != 0)
+ {
+ if (myContext->IsGlGreaterEqual (3, 0))
+ {
+ theProgram->SetHeader ("#version 130");
+ }
+ else if (myContext->CheckExtension ("GL_EXT_gpu_shader4"))
+ {
+ theProgram->SetHeader ("#extension GL_EXT_gpu_shader4 : enable");
+ }
+ else
+ {
+ aBits = aBits & ~OpenGl_PO_StippleLine;
+ }
+ }
+ }
+ (void )theUsesDerivates;
+#else
+ // prefer "100 es" on OpenGL ES 3.0- devices (save the features unavailable before "300 es")
+ // and "300 es" on OpenGL ES 3.1+ devices
+ if (myContext->IsGlGreaterEqual (3, 1))
+ {
+ if ((theBits & OpenGl_PO_NeedsGeomShader) != 0)
+ {
+ theProgram->SetHeader (myContext->hasGeometryStage != OpenGl_FeatureInExtensions ? "#version 320 es" : "#version 310 es");
+ }
+ else
+ {
+ theProgram->SetHeader ("#version 300 es");
+ }
+ }
+ else
+ {
+ if ((theBits & OpenGl_PO_WriteOit) != 0
+ || (theBits & OpenGl_PO_StippleLine) != 0)
+ {
+ if (myContext->IsGlGreaterEqual (3, 0))
+ {
+ theProgram->SetHeader ("#version 300 es");
+ }
+ else
+ {
+ aBits = aBits & ~OpenGl_PO_WriteOit;
+ aBits = aBits & ~OpenGl_PO_StippleLine;
+ }
+ }
+ if (theUsesDerivates)
+ {
+ if (myContext->IsGlGreaterEqual (3, 0))
+ {
+ theProgram->SetHeader ("#version 300 es");
+ }
+ else if (myContext->oesStdDerivatives)
+ {
+ theProgram->SetHeader ("#extension GL_OES_standard_derivatives : enable");
+ }
+ }
+ }
+#endif
+ return aBits;
+}
+
+// =======================================================================
+// function : prepareGeomMainSrc
+// purpose :
+// =======================================================================
+TCollection_AsciiString OpenGl_ShaderManager::prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList& theUnifoms,
+ OpenGl_ShaderObject::ShaderVariableList& theStageInOuts,
+ Standard_Integer theBits)
+{
+ if ((theBits & OpenGl_PO_NeedsGeomShader) == 0)
+ {
+ return TCollection_AsciiString();
+ }
+
+ TCollection_AsciiString aSrcMainGeom =
+ EOL"void main()"
+ EOL"{";
+
+ if ((theBits & OpenGl_PO_MeshEdges) != 0)
+ {
+ theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 occViewport", Graphic3d_TOS_GEOMETRY));
+ theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("bool occIsQuadMode", Graphic3d_TOS_GEOMETRY));
+ theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("float occLineWidth", Graphic3d_TOS_GEOMETRY));
+ theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("float occLineWidth", Graphic3d_TOS_FRAGMENT));
+ theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("float occLineFeather", Graphic3d_TOS_FRAGMENT));
+ theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 occWireframeColor", Graphic3d_TOS_FRAGMENT));
+ theStageInOuts.Append(OpenGl_ShaderObject::ShaderVariable ("vec3 EdgeDistance", Graphic3d_TOS_GEOMETRY | Graphic3d_TOS_FRAGMENT));
+
+ aSrcMainGeom = TCollection_AsciiString()
+ + EOL"vec3 ViewPortTransform (vec4 theVec)"
+ EOL"{"
+ EOL" vec3 aWinCoord = theVec.xyz / theVec.w;"
+ EOL" aWinCoord = aWinCoord * 0.5 + 0.5;"
+ EOL" aWinCoord.xy = aWinCoord.xy * occViewport.zw + occViewport.xy;"
+ EOL" return aWinCoord;"
+ EOL"}"
+ + aSrcMainGeom
+ + EOL" vec3 aSideA = ViewPortTransform (gl_in[2].gl_Position) - ViewPortTransform (gl_in[1].gl_Position);"
+ EOL" vec3 aSideB = ViewPortTransform (gl_in[2].gl_Position) - ViewPortTransform (gl_in[0].gl_Position);"
+ EOL" vec3 aSideC = ViewPortTransform (gl_in[1].gl_Position) - ViewPortTransform (gl_in[0].gl_Position);"
+ EOL" float aQuadArea = abs (aSideB.x * aSideC.y - aSideB.y * aSideC.x);"
+ EOL" vec3 aLenABC = vec3 (length (aSideA), length (aSideB), length (aSideC));"
+ EOL" vec3 aHeightABC = vec3 (aQuadArea) / aLenABC;"
+ EOL" aHeightABC = max (aHeightABC, vec3 (10.0 * occLineWidth));" // avoid shrunk presentation disappearing at distance
+ EOL" float aQuadModeHeightC = occIsQuadMode ? occLineWidth + 1.0 : 0.0;";
+ }
+
+ for (Standard_Integer aVertIter = 0; aVertIter < 3; ++aVertIter)
+ {
+ const TCollection_AsciiString aVertIndex (aVertIter);
+ // pass variables from Vertex shader to Fragment shader through Geometry shader
+ for (OpenGl_ShaderObject::ShaderVariableList::Iterator aVarListIter (theStageInOuts); aVarListIter.More(); aVarListIter.Next())
+ {
+ if (aVarListIter.Value().Stages == (Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT))
+ {
+ const TCollection_AsciiString aVarName = aVarListIter.Value().Name.Token (" ", 2);
+ aSrcMainGeom += TCollection_AsciiString()
+ + EOL" geomOut." + aVarName + " = geomIn[" + aVertIndex + "]." + aVarName + ";";
+ }
+ }
+
+ if ((theBits & OpenGl_PO_MeshEdges) != 0)
+ {
+ switch (aVertIter)
+ {
+ case 0: aSrcMainGeom += EOL" EdgeDistance = vec3 (aHeightABC[0], 0.0, aQuadModeHeightC);"; break;
+ case 1: aSrcMainGeom += EOL" EdgeDistance = vec3 (0.0, aHeightABC[1], aQuadModeHeightC);"; break;
+ case 2: aSrcMainGeom += EOL" EdgeDistance = vec3 (0.0, 0.0, aHeightABC[2]);"; break;
+ }
+ }
+ aSrcMainGeom += TCollection_AsciiString()
+ + EOL" gl_Position = gl_in[" + aVertIndex + "].gl_Position;"
+ EOL" EmitVertex();";
+ }
+ aSrcMainGeom +=
+ EOL" EndPrimitive();"
+ EOL"}";
+
+ return aSrcMainGeom;
+}
+
// =======================================================================
// function : prepareStdProgramUnlit
// purpose :
const Standard_Integer theBits)
{
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
- TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha;
- TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
+ TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha, aSrcVertEndMain;
+ TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return occColor; }";
- TCollection_AsciiString aSrcFragMainGetColor = EOL" occSetFragColor (getColor());";
+ TCollection_AsciiString aSrcFragMainGetColor = EOL" occSetFragColor (getFinalColor());";
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
+
if ((theBits & OpenGl_PO_Point) != 0)
{
#if defined(GL_ES_VERSION_2_0)
EOL" PositionWorld = occModelWorldMatrix * occVertex;"
EOL" Position = occWorldViewMatrix * PositionWorld;";
- if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
+ if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
+ {
+ aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
+ aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
+ ? THE_FRAG_CLIP_CHAINS_N
+ : THE_FRAG_CLIP_PLANES_N;
+ }
+ else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
{
aNbClipPlanes = 1;
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
? THE_FRAG_CLIP_CHAINS_2
: THE_FRAG_CLIP_PLANES_2;
}
- else
- {
- aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
- aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
- ? THE_FRAG_CLIP_CHAINS_N
- : THE_FRAG_CLIP_PLANES_N;
- }
}
if ((theBits & OpenGl_PO_WriteOit) != 0)
{
aProgramSrc->SetNbFragmentOutputs (2);
aProgramSrc->SetWeightOitOutput (true);
- #if defined(GL_ES_VERSION_2_0)
- if (myContext->IsGlGreaterEqual (3, 0))
- {
- aProgramSrc->SetHeader ("#version 300 es");
- }
- #endif
}
- TCollection_AsciiString aSrcVertEndMain;
if ((theBits & OpenGl_PO_StippleLine) != 0)
{
- bool hasGlslBitOps = false;
- #if defined(GL_ES_VERSION_2_0)
- if (myContext->IsGlGreaterEqual (3, 0))
- {
- aProgramSrc->SetHeader ("#version 300 es");
- hasGlslBitOps = true;
- }
- #else
- if (myContext->IsGlGreaterEqual (3, 0))
- {
- aProgramSrc->SetHeader ("#version 130");
- hasGlslBitOps = true;
- }
- else if(myContext->CheckExtension("GL_EXT_gpu_shader4"))
- {
- aProgramSrc->SetHeader ("#extension GL_EXT_gpu_shader4 : enable");
- hasGlslBitOps = true;
- }
- #endif
-
- if (hasGlslBitOps)
+ const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, theBits);
+ if ((aBits & OpenGl_PO_StippleLine) != 0)
{
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern", Graphic3d_TOS_FRAGMENT));
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor", Graphic3d_TOS_FRAGMENT));
EOL" float aRotatePoint = gl_FragCoord.x * sin (anAngle) + gl_FragCoord.y * cos (anAngle);"
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
- EOL" vec4 aColor = getColor();"
+ EOL" vec4 aColor = getFinalColor();"
EOL" if (aColor.a <= 0.1) discard;"
EOL" occSetFragColor (aColor);";
}
+ aSrcVertEndMain
+ EOL"}";
+ TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
+ aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
+ ? THE_FRAG_WIREFRAME_COLOR
+ : EOL"#define getFinalColor getColor";
+
aSrcFrag =
aSrcFragGetColor
+ aSrcGetAlpha
EOL"{"
+ aSrcFragExtraMain
+ aSrcFragMainGetColor
- + aSrcFragWriteOit
+ EOL"}";
-#if !defined(GL_ES_VERSION_2_0)
- if (myContext->core32 != NULL)
- {
- aProgramSrc->SetHeader ("#version 150");
- }
-#else
- if (myContext->IsGlGreaterEqual (3, 1))
- {
- // prefer "100 es" on OpenGL ES 3.0 devices
- // and "300 es" on newer devices (3.1+)
- aProgramSrc->SetHeader ("#version 300 es");
- }
-#endif
+ defaultGlslVersion (aProgramSrc, theBits);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
- aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
- aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
-
+ const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
TCollection_AsciiString aKey;
if (!Create (aProgramSrc, aKey, theProgram))
{
{
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
TCollection_AsciiString aSrcVert, aSrcVertColor, aSrcVertExtraMain;
- TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
+ TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return gl_FrontFacing ? FrontColor : BackColor; }";
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
EOL" PositionWorld = aPositionWorld;"
EOL" Position = aPosition;";
- if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
+ if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
+ {
+ aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
+ aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
+ ? THE_FRAG_CLIP_CHAINS_N
+ : THE_FRAG_CLIP_PLANES_N;
+ }
+ else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
{
aNbClipPlanes = 1;
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
? THE_FRAG_CLIP_CHAINS_2
: THE_FRAG_CLIP_PLANES_2;
}
- else
- {
- aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
- aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
- ? THE_FRAG_CLIP_CHAINS_N
- : THE_FRAG_CLIP_PLANES_N;
- }
}
if ((theBits & OpenGl_PO_WriteOit) != 0)
{
aProgramSrc->SetNbFragmentOutputs (2);
aProgramSrc->SetWeightOitOutput (true);
- #if defined(GL_ES_VERSION_2_0)
- if (myContext->IsGlGreaterEqual (3, 0))
- {
- aProgramSrc->SetHeader ("#version 300 es");
- }
- #endif
}
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 FrontColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
+ EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
EOL"}";
+ TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
+ aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
+ ? THE_FRAG_WIREFRAME_COLOR
+ : EOL"#define getFinalColor getColor";
+
aSrcFrag = TCollection_AsciiString()
+ aSrcFragGetColor
+ EOL"void main()"
EOL"{"
+ aSrcFragExtraMain
- + EOL" occSetFragColor (getColor());"
- + aSrcFragWriteOit
+ + EOL" occSetFragColor (getFinalColor());"
+ EOL"}";
-#if !defined(GL_ES_VERSION_2_0)
- if (myContext->core32 != NULL)
- {
- aProgramSrc->SetHeader ("#version 150");
- }
-#else
- if (myContext->IsGlGreaterEqual (3, 1))
- {
- // prefer "100 es" on OpenGL ES 3.0 devices
- // and "300 es" on newer devices (3.1+)
- aProgramSrc->SetHeader ("#version 300 es");
- }
-#endif
+ defaultGlslVersion (aProgramSrc, theBits);
aProgramSrc->SetNbLightsMax (aNbLights);
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
- aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
- aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
+ const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
TCollection_AsciiString aKey;
if (!Create (aProgramSrc, aKey, theProgram))
{
"Warning: applied workaround for flat shading normal computation using dFdx/dFdy on Adreno");
}
#endif
-
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
TCollection_AsciiString aSrcVert, aSrcVertExtraFunc, aSrcVertExtraMain;
- TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain, aSrcFragWriteOit;
+ TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain;
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return " thePhongCompLight "; }";
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
if ((theBits & OpenGl_PO_Point) != 0)
int aNbClipPlanes = 0;
if ((theBits & OpenGl_PO_ClipPlanesN) != 0)
{
- if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
+ if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
+ {
+ aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
+ aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
+ ? THE_FRAG_CLIP_CHAINS_N
+ : THE_FRAG_CLIP_PLANES_N;
+ }
+ else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
{
aNbClipPlanes = 1;
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
? THE_FRAG_CLIP_CHAINS_2
: THE_FRAG_CLIP_PLANES_2;
}
- else
- {
- aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
- aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
- ? THE_FRAG_CLIP_CHAINS_N
- : THE_FRAG_CLIP_PLANES_N;
- }
}
if ((theBits & OpenGl_PO_WriteOit) != 0)
{
+ EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
EOL"}";
+ TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
+ aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
+ ? THE_FRAG_WIREFRAME_COLOR
+ : EOL"#define getFinalColor getColor";
+
Standard_Integer aNbLights = 0;
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
aSrcFrag = TCollection_AsciiString()
EOL"void main()"
EOL"{"
+ aSrcFragExtraMain
- + EOL" occSetFragColor (getColor());"
- + aSrcFragWriteOit
+ + EOL" occSetFragColor (getFinalColor());"
+ EOL"}";
-#if !defined(GL_ES_VERSION_2_0)
- if (myContext->core32 != NULL)
- {
- aProgramSrc->SetHeader ("#version 150");
- }
-#else
- if (myContext->IsGlGreaterEqual (3, 1))
- {
- // prefer "100 es" on OpenGL ES 3.0 devices
- // and "300 es" on newer devices (3.1+)
- aProgramSrc->SetHeader ("#version 300 es");
- }
- else if (isFlatNormal)
- {
- if (myContext->IsGlGreaterEqual (3, 0))
- {
- aProgramSrc->SetHeader ("#version 300 es");
- }
- else if (myContext->oesStdDerivatives)
- {
- aProgramSrc->SetHeader ("#extension GL_OES_standard_derivatives : enable");
- }
- }
-#endif
+ defaultGlslVersion (aProgramSrc, theBits, isFlatNormal);
aProgramSrc->SetNbLightsMax (aNbLights);
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
- aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
- aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
+ const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
+ aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
TCollection_AsciiString aKey;
if (!Create (aProgramSrc, aKey, theProgram))
{
}
}
-#if !defined(GL_ES_VERSION_2_0)
- if (myContext->core32 != NULL)
- {
- aProgramSrc->SetHeader ("#version 150");
- }
-#else
- if (myContext->IsGlGreaterEqual (3, 1))
- {
- // prefer "100 es" on OpenGL ES 3.0 devices
- // and "300 es" on newer devices (3.1+)
- aProgramSrc->SetHeader ("#version 300 es");
- }
-#endif
-
+ defaultGlslVersion (aProgramSrc, 0);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
EOL" occSetFragColor (occColor);"
EOL"}";
-#if !defined(GL_ES_VERSION_2_0)
- if (myContext->core32 != NULL)
- {
- aProgramSrc->SetHeader ("#version 150");
- }
-#else
- if (myContext->IsGlGreaterEqual (3, 1))
- {
- // prefer "100 es" on OpenGL ES 3.0 devices
- // and "300 es" on newer devices (3.1+)
- aProgramSrc->SetHeader ("#version 300 es");
- }
-#endif
-
+ defaultGlslVersion (aProgramSrc, 0);
aProgramSrc->SetNbLightsMax (0);
aProgramSrc->SetNbClipPlanesMax (0);
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
//! Bind program for filled primitives rendering
Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
- const Graphic3d_TypeOfShadingModel theShadingModel,
- const Graphic3d_AlphaMode theAlphaMode,
- const Standard_Boolean theHasVertColor,
- const Standard_Boolean theEnableEnvMap,
+ Graphic3d_TypeOfShadingModel theShadingModel,
+ Graphic3d_AlphaMode theAlphaMode,
+ Standard_Boolean theHasVertColor,
+ Standard_Boolean theEnableEnvMap,
+ const Handle(OpenGl_ShaderProgram)& theCustomProgram)
+ {
+ return BindFaceProgram (theTextures, theShadingModel, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, theEnableEnvMap, false, theCustomProgram);
+ }
+
+ //! Bind program for filled primitives rendering
+ Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
+ Graphic3d_TypeOfShadingModel theShadingModel,
+ Graphic3d_AlphaMode theAlphaMode,
+ Aspect_InteriorStyle theInteriorStyle,
+ Standard_Boolean theHasVertColor,
+ Standard_Boolean theEnableEnvMap,
+ Standard_Boolean theEnableMeshEdges,
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
{
if (!theCustomProgram.IsNull()
&& (theTextures.IsNull() || theTextures->IsModulate())
? theShadingModel
: Graphic3d_TOSM_UNLIT;
- const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, theEnableEnvMap);
+ const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theInteriorStyle, theHasVertColor, theEnableEnvMap, theEnableMeshEdges);
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
return bindProgramWithState (aProgram);
}
return bindProgramWithState (theCustomProgram);
}
- Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, false);
+ Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false);
if (theLineType != Aspect_TOL_SOLID)
{
aBits |= OpenGl_PO_StippleLine;
return bindProgramWithState (theCustomProgram);
}
- const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, false) | OpenGl_PO_Point;
+ const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false) | OpenGl_PO_Point;
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
return bindProgramWithState (aProgram);
}
//! Pushes current state of material to specified program.
void PushMaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
+public:
+
+ //! Setup interior style line edges variables.
+ Standard_EXPORT void PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
+ const Handle(Graphic3d_AspectFillArea3d)& theAspect) const;
+
public:
//! Returns state of OIT uniforms.
protected:
+ //! Define clipping planes program bits.
+ Standard_Integer getClipPlaneBits() const
+ {
+ const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
+ if (aNbPlanes <= 0)
+ {
+ return 0;
+ }
+
+ Standard_Integer aBits = 0;
+ if (myContext->Clipping().HasClippingChains())
+ {
+ aBits |= OpenGl_PO_ClipChains;
+ }
+
+ if (aNbPlanes == 1)
+ {
+ aBits |= OpenGl_PO_ClipPlanes1;
+ }
+ else if (aNbPlanes == 2)
+ {
+ aBits |= OpenGl_PO_ClipPlanes2;
+ }
+ else
+ {
+ aBits |= OpenGl_PO_ClipPlanesN;
+ }
+ return aBits;
+ }
+
//! Define program bits.
Standard_Integer getProgramBits (const Handle(OpenGl_TextureSet)& theTextures,
Graphic3d_AlphaMode theAlphaMode,
+ Aspect_InteriorStyle theInteriorStyle,
Standard_Boolean theHasVertColor,
- Standard_Boolean theEnableEnvMap)
-
+ Standard_Boolean theEnableEnvMap,
+ Standard_Boolean theEnableMeshEdges) const
{
Standard_Integer aBits = 0;
if (theAlphaMode == Graphic3d_AlphaMode_Mask)
aBits |= OpenGl_PO_AlphaTest;
}
- const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
- if (aNbPlanes > 0)
+ aBits |= getClipPlaneBits();
+ if (theEnableMeshEdges
+ && myContext->hasGeometryStage != OpenGl_FeatureNotAvailable)
{
- aBits |= OpenGl_PO_ClipPlanesN;
- if (myContext->Clipping().HasClippingChains())
- {
- aBits |= OpenGl_PO_ClipChains;
- }
-
- if (aNbPlanes == 1)
- {
- aBits |= OpenGl_PO_ClipPlanes1;
- }
- else if (aNbPlanes == 2)
+ aBits |= OpenGl_PO_MeshEdges;
+ if (theInteriorStyle == Aspect_IS_HOLLOW)
{
- aBits |= OpenGl_PO_ClipPlanes2;
+ aBits |= OpenGl_PO_AlphaTest;
}
}
{
aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
}
- if (theHasVertColor)
+ if (theHasVertColor
+ && theInteriorStyle != Aspect_IS_HIDDENLINE)
{
aBits |= OpenGl_PO_VertColor;
}
//! Prepare standard GLSL program for bounding box.
Standard_EXPORT Standard_Boolean prepareStdProgramBoundBox();
+ //! Prepare GLSL version header.
+ Standard_EXPORT Standard_Integer defaultGlslVersion (const Handle(Graphic3d_ShaderProgram)& theProgram,
+ Standard_Integer theBits,
+ bool theUsesDerivates = false) const;
+
+ //! Prepare GLSL source for geometry shader according to parameters.
+ Standard_EXPORT TCollection_AsciiString prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList& theUnifoms,
+ OpenGl_ShaderObject::ShaderVariableList& theStageInOuts,
+ Standard_Integer theBits);
+
protected:
//! Packed properties of light source
const TCollection_AsciiString& theOutName,
Standard_Integer theNbGeomInputVerts)
{
+ if (theSource.IsEmpty())
+ {
+ return Handle(Graphic3d_ShaderObject)();
+ }
+
TCollection_AsciiString aSrcUniforms, aSrcInOuts, aSrcInStructs, aSrcOutStructs;
for (ShaderVariableList::Iterator anUniformIter (theUniforms); anUniformIter.More(); anUniformIter.Next())
{
const Standard_Boolean hasGeomStage = theNbGeomInputVerts > 0
&& aStageLower < Graphic3d_TOS_GEOMETRY
&& aStageUpper >= Graphic3d_TOS_GEOMETRY;
+ const Standard_Boolean isAllStagesVar = aStageLower == Graphic3d_TOS_VERTEX
+ && aStageUpper == Graphic3d_TOS_FRAGMENT;
if (hasGeomStage
|| !theInName.IsEmpty()
|| !theOutName.IsEmpty())
{
if (aSrcInStructs.IsEmpty()
- && aSrcOutStructs.IsEmpty())
+ && aSrcOutStructs.IsEmpty()
+ && isAllStagesVar)
{
if (theType == aStageLower)
{
}
}
- if (!aSrcInStructs.IsEmpty()
- || !aSrcOutStructs.IsEmpty())
+ if (isAllStagesVar
+ && (!aSrcInStructs.IsEmpty()
+ || !aSrcOutStructs.IsEmpty()))
{
if (!aSrcInStructs.IsEmpty())
{
}
}
+ if (theType == Graphic3d_TOS_GEOMETRY)
+ {
+ aSrcUniforms.Prepend (TCollection_AsciiString()
+ + "\nlayout (triangles) in;"
+ "\nlayout (triangle_strip, max_vertices = " + theNbGeomInputVerts + ") out;");
+ }
if (!aSrcInStructs.IsEmpty()
&& theType == Graphic3d_TOS_GEOMETRY)
{
}
aSrcInStructs += ";";
}
- else if (!aSrcOutStructs.IsEmpty())
+ if (!aSrcOutStructs.IsEmpty())
{
aSrcOutStructs += "\n}";
- if (!theInName.IsEmpty())
+ if (!theOutName.IsEmpty())
{
aSrcOutStructs += " ";
aSrcOutStructs += theOutName;
"occOitDepthFactor", // OpenGl_OCCT_OIT_DEPTH_FACTOR
"occTexTrsf2d", // OpenGl_OCCT_TEXTURE_TRSF2D
- "occPointSize" // OpenGl_OCCT_POINT_SIZE
+ "occPointSize", // OpenGl_OCCT_POINT_SIZE
+
+ "occViewport", // OpenGl_OCCT_VIEWPORT
+ "occLineWidth", // OpenGl_OCCT_LINE_WIDTH
+ "occLineFeather", // OpenGl_OCCT_LINE_FEATHER
+ "occWireframeColor", // OpenGl_OCCT_WIREFRAME_COLOR
+ "occIsQuadMode", // OpenGl_OCCT_QUAD_MODE_STATE
};
namespace
myHasTessShader (false)
{
memset (myCurrentState, 0, sizeof (myCurrentState));
- for (GLint aVar = 0; aVar < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES; ++aVar)
- {
- myStateLocations[aVar] = INVALID_LOCATION;
- }
}
// =======================================================================
// detect the minimum GLSL version required for defined Shader Objects
#if defined(GL_ES_VERSION_2_0)
- if (myHasTessShader
- || (aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
+ if (myHasTessShader)
{
if (!theCtx->IsGlGreaterEqual (3, 2))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
- "Error! Geometry and Tessellation shaders require OpenGL ES 3.2+");
+ "Error! Tessellation shader requires OpenGL ES 3.2+");
return false;
}
else if (aHeaderVer.IsEmpty())
aHeaderVer = "#version 320 es";
}
}
+ else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
+ {
+ switch (theCtx->hasGeometryStage)
+ {
+ case OpenGl_FeatureNotAvailable:
+ {
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+ "Error! Geometry shader requires OpenGL ES 3.2+ or GL_EXT_geometry_shader");
+ return false;
+ }
+ case OpenGl_FeatureInExtensions:
+ {
+ if (aHeaderVer.IsEmpty())
+ {
+ aHeaderVer = "#version 310 es";
+ }
+ break;
+ }
+ case OpenGl_FeatureInCore:
+ {
+ if (aHeaderVer.IsEmpty())
+ {
+ aHeaderVer = "#version 320 es";
+ }
+ break;
+ }
+ }
+ }
else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
{
if (!theCtx->IsGlGreaterEqual (3, 1))
}
#endif
}
+#if defined(GL_ES_VERSION_2_0)
+ if (theCtx->hasGeometryStage == OpenGl_FeatureInExtensions)
+ {
+ anExtensions += "#extension GL_EXT_geometry_shader : enable\n"
+ "#extension GL_EXT_shader_io_blocks : enable\n";
+ }
+#endif
TCollection_AsciiString aPrecisionHeader;
if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT)
// set uniform defaults
const Handle(OpenGl_ShaderProgram)& anOldProgram = theCtx->ActiveProgram();
theCtx->core20fwd->glUseProgram (myProgramID);
+ if (const OpenGl_ShaderUniformLocation aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE))
{
- const GLint aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE);
- if (aLocTexEnable != INVALID_LOCATION)
- {
- SetUniform (theCtx, aLocTexEnable, 0); // Off
- }
+ SetUniform (theCtx, aLocTexEnable, 0); // Off
}
+ if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, "occActiveSampler"))
{
- const GLint aLocSampler = GetUniformLocation (theCtx, "occActiveSampler");
- if (aLocSampler != INVALID_LOCATION)
- {
- SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
- }
+ SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
}
const TCollection_AsciiString aSamplerNamePrefix ("occSampler");
for (GLint aUnitIter = 0; aUnitIter < aNbUnitsMax; ++aUnitIter)
{
const TCollection_AsciiString aName = aSamplerNamePrefix + aUnitIter;
- const GLint aLocSampler = GetUniformLocation (theCtx, aName.ToCString());
- if (aLocSampler != INVALID_LOCATION)
+ if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, aName.ToCString()))
{
SetUniform (theCtx, aLocSampler, aUnitIter);
}
// function : GetUniformLocation
// purpose : Returns location (index) of the specific uniform variable
// =======================================================================
-GLint OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
- const GLchar* theName) const
+OpenGl_ShaderUniformLocation OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
+ const GLchar* theName) const
{
- return myProgramID != NO_PROGRAM
- ? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
- : INVALID_LOCATION;
+ return OpenGl_ShaderUniformLocation (myProgramID != NO_PROGRAM
+ ? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
+ : INVALID_LOCATION);
}
// =======================================================================
: INVALID_LOCATION;
}
-// =======================================================================
-// function : GetStateLocation
-// purpose : Returns location of the OCCT state uniform variable
-// =======================================================================
-GLint OpenGl_ShaderProgram::GetStateLocation (const GLuint theVariable) const
-{
- if (theVariable < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES)
- {
- return myStateLocations[theVariable];
- }
- return INVALID_LOCATION;
-}
-
// =======================================================================
// function : GetUniform
// purpose : Returns the value of the integer uniform variable
OpenGl_OCCT_TEXTURE_TRSF2D,
OpenGl_OCCT_POINT_SIZE,
+ // Wireframe state
+ OpenGl_OCCT_VIEWPORT,
+ OpenGl_OCCT_LINE_WIDTH,
+ OpenGl_OCCT_LINE_FEATHER,
+ OpenGl_OCCT_WIREFRAME_COLOR,
+ OpenGl_OCCT_QUAD_MODE_STATE,
+
// DON'T MODIFY THIS ITEM (insert new items before it)
OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES
};
OpenGl_UniformStateType_NB
};
+//! Simple class represents GLSL program variable location.
+class OpenGl_ShaderUniformLocation
+{
+public:
+ //! Invalid location of uniform/attribute variable.
+ static const GLint INVALID_LOCATION = -1;
+public:
+
+ //! Construct an invalid location.
+ OpenGl_ShaderUniformLocation() : myLocation (INVALID_LOCATION) {}
+
+ //! Constructor with initialization.
+ explicit OpenGl_ShaderUniformLocation (GLint theLocation) : myLocation (theLocation) {}
+
+ //! Note you may safely put invalid location in functions like glUniform* - the data passed in will be silently ignored.
+ //! @return true if location is not equal to -1.
+ bool IsValid() const { return myLocation != INVALID_LOCATION; }
+
+ //! Return TRUE for non-invalid location.
+ operator bool() const { return myLocation != INVALID_LOCATION; }
+
+ //! Convert operators help silently put object to GL functions like glUniform*.
+ operator GLint() const { return myLocation; }
+
+private:
+ GLint myLocation;
+};
+
//! Wrapper for OpenGL program object.
class OpenGl_ShaderProgram : public OpenGl_NamedResource
{
public:
//! Returns location of the specific uniform variable.
- Standard_EXPORT GLint GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
- const GLchar* theName) const;
+ Standard_EXPORT OpenGl_ShaderUniformLocation GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
+ const GLchar* theName) const;
//! Returns index of the generic vertex attribute by variable name.
Standard_EXPORT GLint GetAttributeLocation (const Handle(OpenGl_Context)& theCtx,
const GLchar* theName) const;
//! Returns location of the OCCT state uniform variable.
- Standard_EXPORT GLint GetStateLocation (const GLuint theVariable) const;
+ const OpenGl_ShaderUniformLocation& GetStateLocation (OpenGl_StateVariable theVariable) const { return myStateLocations[theVariable]; }
public:
Standard_Size myCurrentState[OpenGl_UniformStateType_NB]; //!< defines last modification for variables of each state type
//! Stores locations of OCCT state uniform variables.
- GLint myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
+ OpenGl_ShaderUniformLocation myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
};
const OpenGl_AspectText& theTextAspect,
const unsigned int theResolution) const
{
+ const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
+#if !defined(GL_ES_VERSION_2_0)
+ const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
+ const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
+#endif
+
render (theCtx, theTextAspect,
theTextAspect.Aspect()->ColorRGBA(),
theTextAspect.Aspect()->ColorSubTitleRGBA(),
theResolution);
+
+#if !defined(GL_ES_VERSION_2_0)
+ theCtx->SetPolygonMode (aPrevPolygonMode);
+ theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
+#endif
+ theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
}
// =======================================================================
{
glDisable (GL_LIGHTING);
}
-
- const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
- const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
#endif
// setup depth test
// setup blending
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
// extra drawings
switch (theTextAspect.Aspect()->DisplayType())
glDisable (GL_STENCIL_TEST);
#if !defined(GL_ES_VERSION_2_0)
glDisable (GL_COLOR_LOGIC_OP);
-
- theCtx->SetPolygonMode (aPrevPolygonMode);
- theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
#endif
- theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
// model view matrix was modified
theCtx->WorldViewState.Pop();
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
+ aCtx->SetLineFeather (myRenderParams.LineFeather);
// release pending GL resources
aCtx->ReleaseDelayed();
// ==================================
const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
- aContext->SetSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage);
+ aContext->SetAllowSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage
+ && theOutputFBO != NULL
+ && theOutputFBO->NbSamples() != 0);
#if !defined(GL_ES_VERSION_2_0)
// Disable current clipping planes
}
myWorkspace->ResetAppliedAspect();
+ aContext->SetAllowSampleAlphaToCoverage (false);
aContext->SetSampleAlphaToCoverage (false);
// reset FFP state for safety
#endif
}
- myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
+ myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend, 0.285f);
myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
{
myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
}
+
+#if !defined(GL_ES_VERSION_2_0)
+ // font GLSL program has embedded discard, while FFP needs alpha test
+ myFontFaceAspect.Aspect()->SetAlphaMode ((!myGlContext->caps->ffpEnable && myGlContext->core11 != NULL)
+ ? Graphic3d_AlphaMode_Blend
+ : Graphic3d_AlphaMode_Mask,
+ 0.285f);
+#endif
return Standard_True;
}
}
myAspectFaceAppliedWithHL = myHighlightStyle;
-#if !defined(GL_ES_VERSION_2_0)
+ // Aspect_POM_None means: do not change current settings
+ if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
+ {
+ myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
+ }
+
const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
if (myAspectFaceApplied.IsNull()
|| myAspectFaceApplied->InteriorStyle() != anIntstyle)
{
- switch (anIntstyle)
- {
- case Aspect_IS_EMPTY:
- case Aspect_IS_HOLLOW:
- {
- myGlContext->SetPolygonMode (GL_LINE);
- break;
- }
- case Aspect_IS_HATCH:
- {
- myGlContext->SetPolygonMode (GL_FILL);
- myGlContext->SetPolygonHatchEnabled (true);
- break;
- }
- case Aspect_IS_SOLID:
- case Aspect_IS_HIDDENLINE:
- {
- myGlContext->SetPolygonMode (GL_FILL);
- myGlContext->SetPolygonHatchEnabled (false);
- break;
- }
- case Aspect_IS_POINT:
- {
- myGlContext->SetPolygonMode (GL_POINT);
- break;
- }
- }
+ #if !defined(GL_ES_VERSION_2_0)
+ myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL);
+ myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH);
+ #endif
}
+#if !defined(GL_ES_VERSION_2_0)
if (anIntstyle == Aspect_IS_HATCH)
{
myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
}
#endif
- // Aspect_POM_None means: do not change current settings
- if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
- {
- myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
- }
-
// Case of hidden line
- if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
+ if (anIntstyle == Aspect_IS_HIDDENLINE)
{
// copy all values including line edge aspect
*myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
+ myAspectFaceHl.Aspect()->SetDistinguish (false);
myAspectFaceHl.SetNoLighting();
myAspectFaceSet = &myAspectFaceHl;
}
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
+namespace
+{
+ static const Quantity_NameOfColor THE_DEF_COLOR_FreeBoundary = Quantity_NOC_GREEN;
+ static const Quantity_NameOfColor THE_DEF_COLOR_UnFreeBoundary = Quantity_NOC_YELLOW;
+ static const Quantity_NameOfColor THE_DEF_COLOR_FaceBoundary = Quantity_NOC_BLACK;
+ static const Quantity_NameOfColor THE_DEF_COLOR_Wire = Quantity_NOC_RED;
+ static const Quantity_NameOfColor THE_DEF_COLOR_Line = Quantity_NOC_YELLOW;
+ static const Quantity_NameOfColor THE_DEF_COLOR_SeenLine = Quantity_NOC_YELLOW;
+ static const Quantity_NameOfColor THE_DEF_COLOR_HiddenLine = Quantity_NOC_YELLOW;
+ static const Quantity_NameOfColor THE_DEF_COLOR_Vector = Quantity_NOC_SKYBLUE;
+ static const Quantity_NameOfColor THE_DEF_COLOR_Section = Quantity_NOC_ORANGE;
+}
+
// =======================================================================
// function : Prs3d_Drawer
// purpose :
}
if (myFreeBoundaryAspect.IsNull())
{
- myFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
+ myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
}
}
return myFreeBoundaryAspect;
}
if (myUnFreeBoundaryAspect.IsNull())
{
- myUnFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
+ myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
}
}
return myUnFreeBoundaryAspect;
}
if (myFaceBoundaryAspect.IsNull())
{
- myFaceBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
+ myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
}
}
return myFaceBoundaryAspect;
}
if (myWireAspect.IsNull())
{
- myWireAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
}
}
return myWireAspect;
return myPointAspect;
}
+// =======================================================================
+// function : SetupOwnPointAspect
+// purpose :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults)
+{
+ if (myHasOwnPointAspect)
+ {
+ return Standard_False;
+ }
+
+ myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
+ if (!theDefaults.IsNull() && theDefaults != this)
+ {
+ *myPointAspect->Aspect() = *theDefaults->PointAspect()->Aspect();
+ }
+ else if (!myLink.IsNull())
+ {
+ *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
+ }
+ myHasOwnPointAspect = Standard_True;
+ return Standard_True;
+}
+
// =======================================================================
// function : SetPointAspect
// purpose :
}
if (myLineAspect.IsNull())
{
- myLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
+ myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
}
}
return myLineAspect;
return myShadingAspect;
}
+// =======================================================================
+// function : SetupOwnShadingAspect
+// purpose :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults)
+{
+ if (myHasOwnShadingAspect)
+ {
+ return Standard_False;
+ }
+
+ myShadingAspect = new Prs3d_ShadingAspect();
+ if (!theDefaults.IsNull() && theDefaults != this)
+ {
+ *myShadingAspect->Aspect() = *theDefaults->ShadingAspect()->Aspect();
+ }
+ else if (!myLink.IsNull())
+ {
+ *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
+ }
+ myHasOwnShadingAspect = Standard_True;
+ return Standard_True;
+}
+
// =======================================================================
// function : SetShadingAspect
// purpose :
}
if (mySeenLineAspect.IsNull())
{
- mySeenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
+ mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
}
}
return mySeenLineAspect;
}
if (myHiddenLineAspect.IsNull())
{
- myHiddenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_DASH, 1.0);
+ myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
}
}
return myHiddenLineAspect;
}
if (myVectorAspect.IsNull())
{
- myVectorAspect = new Prs3d_LineAspect (Quantity_NOC_SKYBLUE, Aspect_TOL_SOLID, 1.0);
+ myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
}
}
return myVectorAspect;
}
if (mySectionAspect.IsNull())
{
- mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
+ mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
}
}
return mySectionAspect;
myTypeOfHLR = Prs3d_TOH_NotSet;
}
-//! Copy line aspect defaults from the Link.
-inline void copyLineAspect (const Handle(Prs3d_Drawer)& theLink,
- Handle(Prs3d_LineAspect)& theAspect,
- const Handle(Prs3d_LineAspect)& theBaseAspect)
+// =======================================================================
+// function : SetOwnLineAspects
+// purpose :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults)
+{
+ bool isUpdateNeeded = false;
+ const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
+ if (!myHasOwnUIsoAspect)
+ {
+ isUpdateNeeded = true;
+ myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
+ if (!aLink.IsNull())
+ {
+ *myUIsoAspect->Aspect() = *aLink->UIsoAspect()->Aspect();
+ myUIsoAspect->SetNumber (aLink->UIsoAspect()->Number());
+ }
+ myHasOwnUIsoAspect = true;
+ }
+ if (!myHasOwnVIsoAspect)
+ {
+ isUpdateNeeded = true;
+ myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
+ if (!aLink.IsNull())
+ {
+ *myVIsoAspect->Aspect() = *aLink->VIsoAspect()->Aspect();
+ myUIsoAspect->SetNumber (aLink->VIsoAspect()->Number());
+ }
+ myHasOwnVIsoAspect = true;
+ }
+ if (!myHasOwnWireAspect)
+ {
+ isUpdateNeeded = true;
+ myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
+ myHasOwnWireAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myWireAspect->Aspect() = *aLink->WireAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnLineAspect)
+ {
+ isUpdateNeeded = true;
+ myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
+ myHasOwnLineAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myLineAspect->Aspect() = *aLink->LineAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnSeenLineAspect)
+ {
+ isUpdateNeeded = true;
+ mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
+ myHasOwnSeenLineAspect = true;
+ if (!aLink.IsNull())
+ {
+ *mySeenLineAspect->Aspect() = *aLink->SeenLineAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnHiddenLineAspect)
+ {
+ isUpdateNeeded = true;
+ myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
+ myHasOwnHiddenLineAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myHiddenLineAspect->Aspect() = *aLink->HiddenLineAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnFreeBoundaryAspect)
+ {
+ isUpdateNeeded = true;
+ myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
+ myHasOwnFreeBoundaryAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myFreeBoundaryAspect->Aspect() = *aLink->FreeBoundaryAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnUnFreeBoundaryAspect)
+ {
+ isUpdateNeeded = true;
+ myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
+ myHasOwnUnFreeBoundaryAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myUnFreeBoundaryAspect->Aspect() = *aLink->UnFreeBoundaryAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnFaceBoundaryAspect)
+ {
+ isUpdateNeeded = true;
+ myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
+ myHasOwnFaceBoundaryAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myFaceBoundaryAspect->Aspect() = *aLink->FaceBoundaryAspect()->Aspect();
+ }
+ }
+ return isUpdateNeeded;
+}
+
+// =======================================================================
+// function : SetOwnDatumAspects
+// purpose :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults)
{
- Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect;
- if (!theLink.IsNull())
+ bool isUpdateNeeded = false;
+ const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
+ if (!myHasOwnVectorAspect)
+ {
+ isUpdateNeeded = true;
+ myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
+ myHasOwnVectorAspect = true;
+ if (!aLink.IsNull())
+ {
+ *myVectorAspect->Aspect() = *aLink->VectorAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnSectionAspect)
+ {
+ isUpdateNeeded = true;
+ mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
+ myHasOwnSectionAspect = true;
+ if (!aLink.IsNull())
+ {
+ *mySectionAspect->Aspect() = *aLink->SectionAspect()->Aspect();
+ }
+ }
+ if (!myHasOwnPlaneAspect)
+ {
+ isUpdateNeeded = true;
+ myPlaneAspect = new Prs3d_PlaneAspect();
+ myHasOwnPlaneAspect = true;
+ }
+ if (!myHasOwnArrowAspect)
+ {
+ isUpdateNeeded = true;
+ myArrowAspect = new Prs3d_ArrowAspect();
+ myHasOwnArrowAspect = true;
+ }
+ if (!myHasOwnDatumAspect)
{
- theAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
- *theAspect->Aspect() = *aBaseAspect->Aspect();
+ isUpdateNeeded = true;
+ myDatumAspect = new Prs3d_DatumAspect();
+ myHasOwnDatumAspect = true;
}
+ return isUpdateNeeded;
}
//! Assign the shader program.
{
if (theToOverrideDefaults)
{
- if (!myHasOwnUIsoAspect)
- {
- isUpdateNeeded = true;
- Handle(Prs3d_IsoAspect) anAspect = UIsoAspect();
- if (!myLink.IsNull())
- {
- myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
- *myUIsoAspect->Aspect() = *anAspect->Aspect();
- myUIsoAspect->SetNumber (anAspect->Number());
- }
- myHasOwnUIsoAspect = true;
- }
- if (!myHasOwnVIsoAspect)
- {
- isUpdateNeeded = true;
- Handle(Prs3d_IsoAspect) anAspect = VIsoAspect();
- if (!myLink.IsNull())
- {
- myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
- *myVIsoAspect->Aspect() = *anAspect->Aspect();
- myUIsoAspect->SetNumber (anAspect->Number());
- }
- myHasOwnVIsoAspect = true;
- }
- if (!myHasOwnWireAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myWireAspect, WireAspect());
- myHasOwnWireAspect = true;
- }
- if (!myHasOwnLineAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myLineAspect, LineAspect());
- myHasOwnLineAspect = true;
- }
- if (!myHasOwnSeenLineAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect());
- myHasOwnSeenLineAspect = true;
- }
- if (!myHasOwnHiddenLineAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect());
- myHasOwnHiddenLineAspect = true;
- }
- if (!myHasOwnVectorAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myVectorAspect, VectorAspect());
- myHasOwnVectorAspect = true;
- }
- if (!myHasOwnSectionAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, mySectionAspect, SectionAspect());
- myHasOwnSectionAspect = true;
- }
- if (!myHasOwnFreeBoundaryAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect());
- myHasOwnFreeBoundaryAspect = true;
- }
- if (!myHasOwnUnFreeBoundaryAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect());
- myHasOwnUnFreeBoundaryAspect = true;
- }
- if (!myHasOwnFaceBoundaryAspect)
- {
- isUpdateNeeded = true;
- copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect());
- myHasOwnFaceBoundaryAspect = true;
- }
-
- if (!myHasOwnPlaneAspect)
- {
- isUpdateNeeded = true;
- myPlaneAspect = new Prs3d_PlaneAspect();
- myHasOwnPlaneAspect = true;
- }
- if (!myHasOwnArrowAspect)
- {
- isUpdateNeeded = true;
- myArrowAspect = new Prs3d_ArrowAspect();
- myHasOwnArrowAspect = true;
- }
- if (!myHasOwnDatumAspect)
- {
- isUpdateNeeded = true;
- myDatumAspect = new Prs3d_DatumAspect();
- myHasOwnDatumAspect = true;
- }
+ isUpdateNeeded = SetOwnLineAspects() || isUpdateNeeded;
+ isUpdateNeeded = SetOwnDatumAspects() || isUpdateNeeded;
}
setAspectProgram (theProgram, myHasOwnUIsoAspect, myUIsoAspect);
case Graphic3d_ASPECT_MARKER:
{
if (theToOverrideDefaults
- && !myHasOwnPointAspect)
+ && SetupOwnPointAspect())
{
isUpdateNeeded = true;
- myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
- myHasOwnPointAspect = true;
- if (!myLink.IsNull())
- {
- *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
- }
}
setAspectProgram (theProgram, myHasOwnPointAspect, myPointAspect);
case Graphic3d_ASPECT_FILL_AREA:
{
if (theToOverrideDefaults
- && !myHasOwnShadingAspect)
+ && SetupOwnShadingAspect())
{
isUpdateNeeded = true;
- myShadingAspect = new Prs3d_ShadingAspect();
- myHasOwnShadingAspect = true;
- if (!myLink.IsNull())
- {
- *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
- }
}
setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
return isUpdateNeeded;
bool isUpdateNeeded = false;
if (theToOverrideDefaults
- && !myHasOwnShadingAspect)
+ && SetupOwnShadingAspect())
{
isUpdateNeeded = true;
- myShadingAspect = new Prs3d_ShadingAspect();
- myHasOwnShadingAspect = true;
- if (!myLink.IsNull())
- {
- *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
- }
}
if (!myShadingAspect.IsNull()
//! point aspect that overrides the one in the link.
Standard_Boolean HasOwnPointAspect() const { return myHasOwnPointAspect; }
+ //! Sets own point aspect.
+ //! Returns FALSE if the drawer already has its own attribute for point aspect.
+ Standard_EXPORT Standard_Boolean SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
//! Returns settings for line aspects.
//! These settings can be edited. The default values are:
//! Color: Quantity_NOC_YELLOW
//! line aspect that overrides the one in the link.
Standard_Boolean HasOwnLineAspect() const { return myHasOwnLineAspect; }
+ //! Sets own line aspects.
+ //! Returns FALSE if own line aspect are already set.
+ Standard_EXPORT Standard_Boolean SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
+ //! Sets own line aspects for datums.
+ //! Returns FALSE if own line for datums are already set.
+ Standard_EXPORT Standard_Boolean SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
//! Returns settings for text aspect.
//! These settings can be edited. The default value is:
//! - Color: Quantity_NOC_YELLOW
//! shading aspect that overrides the one in the link.
Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
+ //! Sets own shading aspect.
+ //! Returns FALSE if the drawer already has its own attribute for shading aspect.
+ Standard_EXPORT Standard_Boolean SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
//! Returns settings for seen line aspects.
//! These settings can be edited. The default values are:
//! Color: Quantity_NOC_YELLOW
QABugs_1.cxx
QABugs_2.cxx
QABugs_3.cxx
-QABugs_4.cxx
QABugs_5.cxx
QABugs_6.cxx
QABugs_7.cxx
QABugs::Commands_1(theCommands);
QABugs::Commands_2(theCommands);
QABugs::Commands_3(theCommands);
- QABugs::Commands_4(theCommands);
QABugs::Commands_5(theCommands);
QABugs::Commands_6(theCommands);
QABugs::Commands_7(theCommands);
Standard_EXPORT static void Commands_2 (Draw_Interpretor& DI);
Standard_EXPORT static void Commands_3 (Draw_Interpretor& DI);
-
- Standard_EXPORT static void Commands_4 (Draw_Interpretor& DI);
-
+
Standard_EXPORT static void Commands_5 (Draw_Interpretor& DI);
Standard_EXPORT static void Commands_6 (Draw_Interpretor& DI);
+++ /dev/null
-// Created on: 2002-03-19
-// Created by: QA Admin
-// Copyright (c) 2002-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 <QABugs.hxx>
-
-#include <Draw_Interpretor.hxx>
-#include <DBRep.hxx>
-#include <DrawTrSurf.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <ViewerTest.hxx>
-#include <AIS_Shape.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <BRepPrimAPI_MakeSphere.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-
-//#include <AcisData_AcisModel.hxx>
-#include <TopTools_HSequenceOfShape.hxx>
-
-static Standard_Integer BUC60738 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
-{
-
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull()) {
- di << "use 'vinit' command before " << argv[0] << "\n";
- return -1;
- }
-
- TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(-40,0,0),20).Shape();
- Handle(AIS_Shape) theAISShape = new AIS_Shape(theSphere);
-
- //display mode = Shading
- theAISShape->SetDisplayMode(1);
-
- //get the drawer
- Handle(Prs3d_Drawer) theDrawer = theAISShape->Attributes();
- Handle(Prs3d_ShadingAspect) theShadingAspect = theDrawer->ShadingAspect();
- Handle(Graphic3d_AspectFillArea3d) theAspectFillArea3d = theShadingAspect->Aspect();
-
- //allow to display the edges
- theAspectFillArea3d->SetEdgeOn();
- //set the style to Dash
-
- //but the style is not set to dash : it is always solid
- theAspectFillArea3d->SetEdgeLineType (Aspect_TOL_DASH);
- theAspectFillArea3d->SetEdgeColor(Quantity_Color(Quantity_NOC_GREEN));
- theAspectFillArea3d->SetInteriorStyle(Aspect_IS_EMPTY);
- theShadingAspect->SetAspect(theAspectFillArea3d);
- theDrawer->SetShadingAspect(theShadingAspect);
- theAISShape->SetAttributes(theDrawer);
-
- aContext->Display (theAISShape, Standard_True);
-
- return 0;
-}
-
-void QABugs::Commands_4(Draw_Interpretor& theCommands) {
- const char *group = "QABugs";
-
- theCommands.Add("BUC60738","BUC60738",__FILE__,BUC60738,group);
-
- return;
-}
return aColor;
}
+
//=======================================================================
-//function : ParseColor
+//function : parseColor
//purpose :
//=======================================================================
-
-Standard_Integer ViewerTest::ParseColor (Standard_Integer theArgNb,
+Standard_Integer ViewerTest::parseColor (Standard_Integer theArgNb,
const char** theArgVec,
- Quantity_Color& theColor)
+ Quantity_ColorRGBA& theColor,
+ bool theToParseAlpha)
{
Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
if (theArgNb >= 1
&& Quantity_Color::ColorFromName (theArgVec[0], aColor))
{
- theColor = aColor;
+ theColor = Quantity_ColorRGBA (aColor);
+ if (theArgNb >= 2
+ && theToParseAlpha)
+ {
+ const TCollection_AsciiString anAlphaStr (theArgVec[1]);
+ if (anAlphaStr.IsRealValue())
+ {
+ float anAlpha = (float )anAlphaStr.RealValue();
+ if (anAlpha < 0.0f || anAlpha > 1.0f)
+ {
+ std::cout << "Syntax error: alpha should be within range 0..1!\n";
+ return 0;
+ }
+ return 2;
+ }
+ }
return 1;
}
else if (theArgNb >= 3)
{
- const TCollection_AsciiString anRgbStr[3] =
- {
- theArgVec[0],
- theArgVec[1],
- theArgVec[2]
- };
- if (!anRgbStr[0].IsRealValue()
- || !anRgbStr[1].IsRealValue()
- || !anRgbStr[2].IsRealValue())
+ Graphic3d_Vec4 anRgba;
+ Standard_Integer aNbComps = Min (theArgNb, theToParseAlpha ? 4 : 3);
+ for (int aCompIter = 0; aCompIter < aNbComps; ++aCompIter)
{
- return 0;
- }
+ const TCollection_AsciiString anRgbaStr (theArgVec[aCompIter]);
+ if (!anRgbaStr.IsRealValue())
+ {
+ if (aCompIter == 3)
+ {
+ anRgba.a() = 1.0f;
+ aNbComps = 3;
+ break;
+ }
+ return 0;
+ }
- Graphic3d_Vec4d anRgb;
- anRgb.x() = anRgbStr[0].RealValue();
- anRgb.y() = anRgbStr[1].RealValue();
- anRgb.z() = anRgbStr[2].RealValue();
- if (anRgb.x() < 0.0 || anRgb.x() > 1.0
- || anRgb.y() < 0.0 || anRgb.y() > 1.0
- || anRgb.z() < 0.0 || anRgb.z() > 1.0)
- {
- std::cout << "Error: RGB color values should be within range 0..1!\n";
- return 0;
+ anRgba[aCompIter] = (float )anRgbaStr.RealValue();
+ if (anRgba[aCompIter] < 0.0 || anRgba[aCompIter] > 1.0)
+ {
+ std::cout << "Error: RGBA color values should be within range 0..1!\n";
+ return 0;
+ }
}
-
- theColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
- return 3;
+ theColor = Quantity_ColorRGBA (anRgba);
+ return aNbComps;
}
return 0;
{
theType = Aspect_TOL_DOTDASH;
}
- else
+ else if (aTypeStr.IsIntegerValue())
{
- const int aTypeInt = Draw::Atoi (theArg);
+ const int aTypeInt = aTypeStr.IntegerValue();
if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
{
return Standard_False;
}
theType = (Aspect_TypeOfLine )aTypeInt;
}
+ else
+ {
+ return Standard_False;
+ }
return Standard_True;
}
};
-//==============================================================================
-//function : VInteriorStyle
-//purpose : sets interior style of the a selected or named or displayed shape
-//==============================================================================
-static int VSetInteriorStyle (Draw_Interpretor& theDI,
- Standard_Integer theArgNb,
- const char** theArgVec)
+//! Parse interior style name.
+static bool parseInteriorStyle (const TCollection_AsciiString& theArg,
+ Aspect_InteriorStyle& theStyle)
{
- const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
- ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
- if (aCtx.IsNull())
- {
- std::cerr << "Error: no active view!\n";
- return 1;
- }
-
- Standard_Integer anArgIter = 1;
- for (; anArgIter < theArgNb; ++anArgIter)
- {
- if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
- {
- break;
- }
- }
- TCollection_AsciiString aName;
- if (theArgNb - anArgIter == 2)
- {
- aName = theArgVec[anArgIter++];
- }
- else if (theArgNb - anArgIter != 1)
- {
- std::cout << "Error: wrong number of arguments! See usage:\n";
- theDI.PrintHelp (theArgVec[0]);
- return 1;
- }
- Aspect_InteriorStyle anInterStyle = Aspect_IS_SOLID;
- TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
- aStyleArg.LowerCase();
- if (aStyleArg == "empty")
+ TCollection_AsciiString anArg (theArg);
+ anArg.LowerCase();
+ if (anArg == "empty")
{
- anInterStyle = Aspect_IS_EMPTY;
+ theStyle = Aspect_IS_EMPTY;
}
- else if (aStyleArg == "hollow")
+ else if (anArg == "hollow")
{
- anInterStyle = Aspect_IS_HOLLOW;
+ theStyle = Aspect_IS_HOLLOW;
}
- else if (aStyleArg == "hatch")
+ else if (anArg == "solid")
{
- anInterStyle = Aspect_IS_HATCH;
+ theStyle = Aspect_IS_SOLID;
}
- else if (aStyleArg == "solid")
+ else if (anArg == "hatch")
{
- anInterStyle = Aspect_IS_SOLID;
+ theStyle = Aspect_IS_HATCH;
}
- else if (aStyleArg == "hiddenline")
+ else if (anArg == "hiddenline"
+ || anArg == "hidden-line"
+ || anArg == "hidden_line")
{
- anInterStyle = Aspect_IS_HIDDENLINE;
+ theStyle = Aspect_IS_HIDDENLINE;
}
- else if (aStyleArg == "point")
+ else if (anArg == "point")
{
- anInterStyle = Aspect_IS_POINT;
+ theStyle = Aspect_IS_POINT;
}
- else
+ else if (theArg.IsIntegerValue())
{
- const Standard_Integer anIntStyle = aStyleArg.IntegerValue();
- if (anIntStyle < Aspect_IS_EMPTY
- || anIntStyle > Aspect_IS_POINT)
+ const Standard_Integer anIntStyle = theArg.IntegerValue();
+ if (anIntStyle < Aspect_IS_EMPTY || anIntStyle > Aspect_IS_POINT)
{
- std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
- << Aspect_IS_POINT << " (Aspect_IS_POINT)]\n";
- return 1;
+ return false;
}
- anInterStyle = (Aspect_InteriorStyle )anIntStyle;
+ theStyle = (Aspect_InteriorStyle)anIntStyle;
}
-
- if (!aName.IsEmpty()
- && !GetMapOfAIS().IsBound2 (aName))
- {
- std::cout << "Error: object " << aName << " is not displayed!\n";
- return 1;
- }
-
- for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
+ else
{
- const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
- if (!anIO.IsNull())
- {
- const Handle(Prs3d_Drawer)& aDrawer = anIO->Attributes();
- Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
- Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
- aFillAspect->SetInteriorStyle (anInterStyle);
- if (anInterStyle == Aspect_IS_HATCH
- && aFillAspect->HatchStyle().IsNull())
- {
- aFillAspect->SetHatchStyle (Aspect_HS_VERTICAL);
- }
- aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
- }
+ return false;
}
- return 0;
+ return true;
}
//! Auxiliary structure for VAspects
Graphic3d_TypeOfShadingModel ShadingModel;
TCollection_AsciiString ShadingModelName;
+ Standard_Integer ToSetInterior;
+ Aspect_InteriorStyle InteriorStyle;
+
+ Standard_Integer ToSetDrawEdges;
+ Standard_Integer ToSetQuadEdges;
+
+ Standard_Integer ToSetEdgeColor;
+ Quantity_ColorRGBA EdgeColor;
+
+ Standard_Integer ToSetEdgeWidth;
+ Standard_Real EdgeWidth;
+
+ Standard_Integer ToSetTypeOfEdge;
+ Aspect_TypeOfLine TypeOfEdge;
+
//! Empty constructor
ViewerTest_AspectsChangeSet()
: ToSetVisibility (0),
ToSetHatch (0),
StdHatchStyle (-1),
ToSetShadingModel (0),
- ShadingModel (Graphic3d_TOSM_DEFAULT)
+ ShadingModel (Graphic3d_TOSM_DEFAULT),
+ ToSetInterior (0),
+ InteriorStyle (Aspect_IS_SOLID),
+ ToSetDrawEdges (0),
+ ToSetQuadEdges (0),
+ ToSetEdgeColor (0),
+ ToSetEdgeWidth (0),
+ EdgeWidth (1.0),
+ ToSetTypeOfEdge (0),
+ TypeOfEdge (Aspect_TOL_SOLID)
{}
//! @return true if no changes have been requested
&& ToSetMaxParamValue == 0
&& ToSetSensitivity == 0
&& ToSetHatch == 0
- && ToSetShadingModel == 0;
+ && ToSetShadingModel == 0
+ && ToSetInterior == 0
+ && ToSetDrawEdges == 0
+ && ToSetQuadEdges == 0
+ && ToSetEdgeColor == 0
+ && ToSetEdgeWidth == 0
+ && ToSetTypeOfEdge == 0;
}
//! @return true if properties are valid
return isOk;
}
+ //! Apply aspects to specified drawer.
+ bool Apply (const Handle(Prs3d_Drawer)& theDrawer)
+ {
+ bool toRecompute = false;
+ const Handle(Prs3d_Drawer)& aDefDrawer = ViewerTest::GetAISContext()->DefaultDrawer();
+ if (ToSetShowFreeBoundary != 0)
+ {
+ theDrawer->SetFreeBoundaryDraw (ToSetShowFreeBoundary == 1);
+ toRecompute = true;
+ }
+ if (ToSetFreeBoundaryWidth != 0)
+ {
+ if (ToSetFreeBoundaryWidth != -1
+ || theDrawer->HasOwnFreeBoundaryAspect())
+ {
+ if (!theDrawer->HasOwnFreeBoundaryAspect())
+ {
+ Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+ theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+ toRecompute = true;
+ }
+ theDrawer->FreeBoundaryAspect()->SetWidth (FreeBoundaryWidth);
+ }
+ }
+ if (ToSetFreeBoundaryColor != 0)
+ {
+ Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+ aBoundaryAspect->SetColor (FreeBoundaryColor);
+ theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+ toRecompute = true;
+ }
+ if (ToSetTypeOfLine != 0)
+ {
+ if (ToSetTypeOfLine != -1
+ || theDrawer->HasOwnLineAspect()
+ || theDrawer->HasOwnWireAspect()
+ || theDrawer->HasOwnFreeBoundaryAspect()
+ || theDrawer->HasOwnUnFreeBoundaryAspect()
+ || theDrawer->HasOwnSeenLineAspect())
+ {
+ toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+ theDrawer->LineAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->WireAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->FreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
+ theDrawer->SeenLineAspect()->SetTypeOfLine (TypeOfLine);
+ }
+ }
+ if (ToSetTypeOfMarker != 0)
+ {
+ if (ToSetTypeOfMarker != -1
+ || theDrawer->HasOwnPointAspect())
+ {
+ toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+ theDrawer->PointAspect()->SetTypeOfMarker (TypeOfMarker);
+ theDrawer->PointAspect()->Aspect()->SetMarkerImage (MarkerImage.IsNull() ? Handle(Graphic3d_MarkerImage)() : new Graphic3d_MarkerImage (MarkerImage));
+ }
+ }
+ if (ToSetMarkerSize != 0)
+ {
+ if (ToSetMarkerSize != -1
+ || theDrawer->HasOwnPointAspect())
+ {
+ toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+ theDrawer->PointAspect()->SetScale (MarkerSize);
+ toRecompute = true;
+ }
+ }
+ if (ToSetMaxParamValue != 0)
+ {
+ if (ToSetMaxParamValue != -1
+ || theDrawer->HasOwnMaximalParameterValue())
+ {
+ theDrawer->SetMaximalParameterValue (MaxParamValue);
+ toRecompute = true;
+ }
+ }
+ if (ToSetShadingModel != 0)
+ {
+ if (ToSetShadingModel != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
+ }
+ }
+ if (ToSetAlphaMode != 0)
+ {
+ if (ToSetAlphaMode != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff);
+ }
+ }
+ if (ToSetHatch != 0)
+ {
+ if (ToSetHatch != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ theDrawer->SetupOwnShadingAspect (aDefDrawer);
+ Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
+ if (ToSetHatch == -1)
+ {
+ anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+ }
+ else
+ {
+ anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+ if (!PathToHatchPattern.IsEmpty())
+ {
+ Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+ if (anImage->Load (TCollection_AsciiString (PathToHatchPattern.ToCString())))
+ {
+ anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+ }
+ else
+ {
+ std::cout << "Error: cannot load the following image: " << PathToHatchPattern << "\n";
+ }
+ }
+ else if (StdHatchStyle != -1)
+ {
+ anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)StdHatchStyle));
+ }
+ }
+ toRecompute = true;
+ }
+ }
+ if (ToSetInterior != 0)
+ {
+ if (ToSetInterior != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (InteriorStyle);
+ if (InteriorStyle == Aspect_IS_HATCH
+ && theDrawer->ShadingAspect()->Aspect()->HatchStyle().IsNull())
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetHatchStyle (Aspect_HS_VERTICAL);
+ }
+ }
+ }
+ if (ToSetDrawEdges != 0)
+ {
+ if (ToSetDrawEdges != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetDrawEdges == 1);
+ }
+ }
+ if (ToSetQuadEdges != 0)
+ {
+ if (ToSetQuadEdges != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetSkipFirstEdge (ToSetQuadEdges == 1);
+ }
+ }
+ if (ToSetEdgeWidth != 0)
+ {
+ if (ToSetEdgeWidth != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeWidth (EdgeWidth);
+ }
+ }
+ if (ToSetTypeOfEdge != 0)
+ {
+ if (ToSetTypeOfEdge != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeLineType (TypeOfEdge);
+ if (ToSetInterior == 0)
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetTypeOfEdge == 1
+ && TypeOfEdge != Aspect_TOL_EMPTY);
+ }
+ }
+ }
+ if (ToSetEdgeColor != 0)
+ {
+ if (ToSetEdgeColor != -1
+ || theDrawer->HasOwnShadingAspect())
+ {
+ toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+ if (ToSetEdgeColor == -1)
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (theDrawer->ShadingAspect()->Aspect()->InteriorColor());
+ }
+ else
+ {
+ theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (EdgeColor);
+ }
+ }
+ }
+ return toRecompute;
+ }
};
//==============================================================================
ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
// parse syntax of legacy commands
+ bool toParseAliasArgs = false;
if (aCmdName == "vsetwidth")
{
if (aNames.IsEmpty()
}
else if (aNames.Length() >= 3)
{
- const TCollection_AsciiString anRgbStr[3] =
+ const char* anArgVec[3] =
{
- aNames.Value (aNames.Upper() - 2),
- aNames.Value (aNames.Upper() - 1),
- aNames.Value (aNames.Upper() - 0)
+ aNames.Value (aNames.Upper() - 2).ToCString(),
+ aNames.Value (aNames.Upper() - 1).ToCString(),
+ aNames.Value (aNames.Upper() - 0).ToCString(),
};
- isOk = anRgbStr[0].IsRealValue()
- && anRgbStr[1].IsRealValue()
- && anRgbStr[2].IsRealValue();
- if (isOk)
- {
- Graphic3d_Vec4d anRgb;
- anRgb.x() = anRgbStr[0].RealValue();
- anRgb.y() = anRgbStr[1].RealValue();
- anRgb.z() = anRgbStr[2].RealValue();
- if (anRgb.x() < 0.0 || anRgb.x() > 1.0
- || anRgb.y() < 0.0 || anRgb.y() > 1.0
- || anRgb.z() < 0.0 || anRgb.z() > 1.0)
- {
- std::cout << "Error: RGB color values should be within range 0..1!\n";
- return 1;
- }
- aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
- aNames.Remove (aNames.Length());
- aNames.Remove (aNames.Length());
- aNames.Remove (aNames.Length());
- }
+
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (3, anArgVec, aChangeSet->Color);
+ isOk = aNbParsed == 3;
+ aNames.Remove (aNames.Length());
+ aNames.Remove (aNames.Length());
+ aNames.Remove (aNames.Length());
}
if (!isOk)
{
{
aChangeSet->ToSetMaterial = -1;
}
+ else if (aCmdName == "vsetinteriorstyle")
+ {
+ if (aNames.IsEmpty()
+ || !aNames.Last().IsRealValue())
+ {
+ std::cout << "Error: not enough arguments!\n";
+ return 1;
+ }
+ aChangeSet->ToSetInterior = 1;
+ if (!parseInteriorStyle (aNames.Last(), aChangeSet->InteriorStyle))
+ {
+ std::cout << "Error: wrong syntax at " << aNames.Last() << "\n";
+ return 1;
+ }
+ aNames.Remove (aNames.Length());
+ }
+ else if (aCmdName == "vsetedgetype")
+ {
+ aChangeSet->ToSetDrawEdges = 1;
+ toParseAliasArgs = true;
+ }
+ else if (aCmdName == "vunsetedgetype")
+ {
+ aChangeSet->ToSetDrawEdges = -1;
+ aChangeSet->ToSetEdgeColor = -1;
+ aChangeSet->ToSetTypeOfEdge = -1;
+ aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+ }
else if (anArgIter >= theArgNb)
{
std::cout << "Error: not enough arguments!\n";
return 1;
}
- if (!aChangeSet->IsEmpty())
+ if (!aChangeSet->IsEmpty()
+ && !toParseAliasArgs)
{
anArgIter = theArgNb;
}
TCollection_AsciiString anArg = theArgVec[anArgIter];
anArg.LowerCase();
if (anArg == "-setwidth"
- || anArg == "-setlinewidth")
+ || anArg == "-width"
+ || anArg == "-setlinewidth"
+ || anArg == "-linewidth"
+ || anArg == "-setedgewidth"
+ || anArg == "-setedgeswidth"
+ || anArg == "-edgewidth"
+ || anArg == "-edgeswidth")
{
if (++anArgIter >= theArgNb)
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
- aChangeSet->ToSetLineWidth = 1;
- aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+ if (anArg == "-setedgewidth"
+ || anArg == "-setedgeswidth"
+ || anArg == "-edgewidth"
+ || anArg == "-edgeswidth"
+ || aCmdName == "vsetedgetype")
+ {
+ aChangeSet->ToSetEdgeWidth = 1;
+ aChangeSet->EdgeWidth = Draw::Atof (theArgVec[anArgIter]);
+ }
+ else
+ {
+ aChangeSet->ToSetLineWidth = 1;
+ aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+ }
}
else if (anArg == "-unsetwidth"
- || anArg == "-unsetlinewidth")
+ || anArg == "-unsetlinewidth"
+ || anArg == "-unsetedgewidth")
{
- aChangeSet->ToSetLineWidth = -1;
- aChangeSet->LineWidth = 1.0;
+ if (anArg == "-unsetedgewidth")
+ {
+ aChangeSet->ToSetEdgeWidth = -1;
+ aChangeSet->EdgeWidth = 1.0;
+ }
+ else
+ {
+ aChangeSet->ToSetLineWidth = -1;
+ aChangeSet->LineWidth = 1.0;
+ }
}
else if (anArg == "-settransp"
- || anArg == "-settransparency")
+ || anArg == "-settransparency"
+ || anArg == "-transparency"
+ || anArg == "-transp")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->Transparency = 0.0;
}
}
- else if (anArg == "-setalphamode")
+ else if (anArg == "-setalphamode"
+ || anArg == "-alphamode")
{
if (++anArgIter >= theArgNb)
{
}
}
else if (anArg == "-setvis"
- || anArg == "-setvisibility")
+ || anArg == "-setvisibility"
+ || anArg == "-visibility")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetVisibility = 1;
aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]);
}
- else if (anArg == "-setalpha")
+ else if (anArg == "-setalpha"
+ || anArg == "-alpha")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetTransparency = -1;
aChangeSet->Transparency = 0.0;
}
- else if (anArg == "-setcolor")
+ else if (anArg == "-setcolor"
+ || anArg == "-color")
{
- Standard_Integer aNbComps = 0;
- Standard_Integer aCompIter = anArgIter + 1;
- for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aColor);
+ if (aNbParsed == 0)
{
- if (theArgVec[aCompIter][0] == '-')
- {
- break;
- }
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
}
- switch (aNbComps)
+ anArgIter += aNbParsed;
+ if (aCmdName == "vsetedgetype")
{
- case 1:
- {
- Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
- Standard_CString aName = theArgVec[anArgIter + 1];
- if (!Quantity_Color::ColorFromName (aName, aColor))
- {
- std::cout << "Error: unknown color name '" << aName << "'\n";
- return 1;
- }
- aChangeSet->Color = aColor;
- break;
- }
- case 3:
- {
- Graphic3d_Vec3d anRgb;
- anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
- anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
- anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
- if (anRgb.x() < 0.0 || anRgb.x() > 1.0
- || anRgb.y() < 0.0 || anRgb.y() > 1.0
- || anRgb.z() < 0.0 || anRgb.z() > 1.0)
- {
- std::cout << "Error: RGB color values should be within range 0..1!\n";
- return 1;
- }
- aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
- break;
- }
- default:
- {
- std::cout << "Error: wrong syntax at " << anArg << "\n";
- return 1;
- }
+ aChangeSet->ToSetEdgeColor = 1;
+ aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor);
+ }
+ else
+ {
+ aChangeSet->ToSetColor = 1;
+ aChangeSet->Color = aColor;
}
- aChangeSet->ToSetColor = 1;
- anArgIter += aNbComps;
}
- else if (anArg == "-setlinetype")
+ else if (anArg == "-setlinetype"
+ || anArg == "-linetype"
+ || anArg == "-setedgetype"
+ || anArg == "-setedgestype"
+ || anArg == "-edgetype"
+ || anArg == "-edgestype"
+ || anArg == "-type")
{
if (++anArgIter >= theArgNb)
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
- if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
+ Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY;
+ if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType))
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
return 1;
}
-
- aChangeSet->ToSetTypeOfLine = 1;
+ if (anArg == "-setedgetype"
+ || anArg == "-setedgestype"
+ || anArg == "-edgetype"
+ || anArg == "-edgestype"
+ || aCmdName == "vsetedgetype")
+ {
+ aChangeSet->TypeOfEdge = aLineType;
+ aChangeSet->ToSetTypeOfEdge = 1;
+ }
+ else
+ {
+ aChangeSet->TypeOfLine = aLineType;
+ aChangeSet->ToSetTypeOfLine = 1;
+ }
}
- else if (anArg == "-unsetlinetype")
+ else if (anArg == "-unsetlinetype"
+ || anArg == "-unsetedgetype"
+ || anArg == "-unsetedgestype")
{
- aChangeSet->ToSetTypeOfLine = -1;
+ if (anArg == "-unsetedgetype"
+ || anArg == "-unsetedgestype")
+ {
+ aChangeSet->ToSetTypeOfEdge = -1;
+ }
+ else
+ {
+ aChangeSet->ToSetTypeOfLine = -1;
+ }
}
else if (anArg == "-setmarkertype"
- || anArg == "-setpointtype")
+ || anArg == "-markertype"
+ || anArg == "-setpointtype"
+ || anArg == "-pointtype")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetTypeOfMarker = -1;
}
else if (anArg == "-setmarkersize"
- || anArg == "-setpointsize")
+ || anArg == "-markersize"
+ || anArg == "-setpointsize"
+ || anArg == "-pointsize")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->Color = DEFAULT_COLOR;
}
else if (anArg == "-setmat"
- || anArg == "-setmaterial")
+ || anArg == "-mat"
+ || anArg == "-setmaterial"
+ || anArg == "-material")
{
if (++anArgIter >= theArgNb)
{
return 1;
}
}
- else if (anArg == "-freeboundary"
+ else if (anArg == "-setfreeboundary"
+ || anArg == "-freeboundary"
+ || anArg == "-setfb"
|| anArg == "-fb")
{
if (++anArgIter >= theArgNb)
}
}
else if (anArg == "-setfreeboundarywidth"
- || anArg == "-setfbwidth")
+ || anArg == "-freeboundarywidth"
+ || anArg == "-setfbwidth"
+ || anArg == "-fbwidth")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->FreeBoundaryWidth = 1.0;
}
else if (anArg == "-setfreeboundarycolor"
- || anArg == "-setfbcolor")
+ || anArg == "-freeboundarycolor"
+ || anArg == "-setfbcolor"
+ || anArg == "-fbcolor")
{
- Standard_Integer aNbComps = 0;
- Standard_Integer aCompIter = anArgIter + 1;
- for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aChangeSet->FreeBoundaryColor);
+ if (aNbParsed == 0)
{
- if (theArgVec[aCompIter][0] == '-')
- {
- break;
- }
- }
- switch (aNbComps)
- {
- case 1:
- {
- Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
- Standard_CString aName = theArgVec[anArgIter + 1];
- if (!Quantity_Color::ColorFromName (aName, aColor))
- {
- std::cout << "Error: unknown free boundary color name '" << aName << "'\n";
- return 1;
- }
- aChangeSet->FreeBoundaryColor = aColor;
- break;
- }
- case 3:
- {
- Graphic3d_Vec3d anRgb;
- anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
- anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
- anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
- if (anRgb.x() < 0.0 || anRgb.x() > 1.0
- || anRgb.y() < 0.0 || anRgb.y() > 1.0
- || anRgb.z() < 0.0 || anRgb.z() > 1.0)
- {
- std::cout << "Error: free boundary RGB color values should be within range 0..1!\n";
- return 1;
- }
- aChangeSet->FreeBoundaryColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
- break;
- }
- default:
- {
- std::cout << "Error: wrong syntax at " << anArg << "\n";
- return 1;
- }
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
}
+ anArgIter += aNbParsed;
aChangeSet->ToSetFreeBoundaryColor = 1;
- anArgIter += aNbComps;
}
else if (anArg == "-unsetfreeboundarycolor"
|| anArg == "-unsetfbcolor")
aChangeSet->ToSetFreeBoundaryColor = -1;
aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
}
- else if (anArg == "-unset")
- {
- aChangeSet->ToSetVisibility = 1;
- aChangeSet->Visibility = 1;
- aChangeSet->ToSetLineWidth = -1;
- aChangeSet->LineWidth = 1.0;
- aChangeSet->ToSetTypeOfLine = -1;
- aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
- aChangeSet->ToSetTypeOfMarker = -1;
- aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
- aChangeSet->ToSetMarkerSize = -1;
- aChangeSet->MarkerSize = 1.0;
- aChangeSet->ToSetTransparency = -1;
- aChangeSet->Transparency = 0.0;
- aChangeSet->ToSetAlphaMode = -1;
- aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
- aChangeSet->AlphaCutoff = 0.5f;
- aChangeSet->ToSetColor = -1;
- aChangeSet->Color = DEFAULT_COLOR;
- aChangeSet->ToSetMaterial = -1;
- aChangeSet->Material = Graphic3d_NOM_DEFAULT;
- aChangeSet->ToSetShowFreeBoundary = -1;
- aChangeSet->ToSetFreeBoundaryColor = -1;
- aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
- aChangeSet->ToSetFreeBoundaryWidth = -1;
- aChangeSet->FreeBoundaryWidth = 1.0;
- aChangeSet->ToSetHatch = -1;
- aChangeSet->StdHatchStyle = -1;
- aChangeSet->PathToHatchPattern.Clear();
- aChangeSet->ToSetShadingModel = -1;
- aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
- }
- else if (anArg == "-isoontriangulation"
+ else if (anArg == "-setisoontriangulation"
+ || anArg == "-isoontriangulation"
+ || anArg == "-setisoontriang"
|| anArg == "-isoontriang")
{
if (++anArgIter >= theArgNb)
return 1;
}
}
- else if (anArg == "-setmaxparamvalue")
+ else if (anArg == "-setmaxparamvalue"
+ || anArg == "-maxparamvalue")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetMaxParamValue = 1;
aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
}
- else if (anArg == "-setsensitivity")
+ else if (anArg == "-setsensitivity"
+ || anArg == "-sensitivity")
{
if (isDefaults)
{
aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
}
- else if (anArg == "-sethatch")
+ else if (anArg == "-sethatch"
+ || anArg == "-hatch")
{
if (isDefaults)
{
aChangeSet->PathToHatchPattern = anArgHatch;
}
}
- else if (anArg == "-setshadingmodel")
+ else if (anArg == "-setshadingmodel"
+ || anArg == "-setshading"
+ || anArg == "-shadingmodel"
+ || anArg == "-shading")
{
if (++anArgIter >= theArgNb)
{
aChangeSet->ToSetShadingModel = -1;
aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
}
+ else if (anArg == "-setinterior"
+ || anArg == "-setinteriorstyle"
+ || anArg == "-interior"
+ || anArg == "-interiorstyle")
+ {
+ if (++anArgIter >= theArgNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ aChangeSet->ToSetInterior = 1;
+ if (!parseInteriorStyle (theArgVec[anArgIter], aChangeSet->InteriorStyle))
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ }
+ else if (anArg == "-unsetinterior")
+ {
+ aChangeSet->ToSetInterior = -1;
+ aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+ }
+ else if (anArg == "-setdrawedges"
+ || anArg == "-setdrawedge"
+ || anArg == "-drawedges"
+ || anArg == "-drawedge"
+ || anArg == "-edges")
+ {
+ bool toDrawEdges = true;
+ if (anArgIter + 1 < theArgNb
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
+ {
+ ++anArgIter;
+ }
+ aChangeSet->ToSetDrawEdges = toDrawEdges ? 1 : -1;
+ }
+ else if (anArg == "-setquadedges"
+ || anArg == "-setquads"
+ || anArg == "-quads"
+ || anArg == "-skipfirstedge")
+ {
+ bool isQuadMode = true;
+ if (anArgIter + 1 < theArgNb
+ && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
+ {
+ ++anArgIter;
+ }
+ aChangeSet->ToSetQuadEdges = isQuadMode ? 1 : -1;
+ }
+ else if (anArg == "-setedgecolor"
+ || anArg == "-setedgescolor"
+ || anArg == "-edgecolor"
+ || anArg == "-edgescolor")
+ {
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb - anArgIter - 1,
+ theArgVec + anArgIter + 1,
+ aChangeSet->EdgeColor);
+ if (aNbParsed == 0)
+ {
+ std::cout << "Syntax error at '" << anArg << "'\n";
+ return 1;
+ }
+ anArgIter += aNbParsed;
+ aChangeSet->ToSetEdgeColor = 1;
+ }
+ else if (anArg == "-unset")
+ {
+ aChangeSet->ToSetVisibility = 1;
+ aChangeSet->Visibility = 1;
+ aChangeSet->ToSetLineWidth = -1;
+ aChangeSet->LineWidth = 1.0;
+ aChangeSet->ToSetTypeOfLine = -1;
+ aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
+ aChangeSet->ToSetTypeOfMarker = -1;
+ aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
+ aChangeSet->ToSetMarkerSize = -1;
+ aChangeSet->MarkerSize = 1.0;
+ aChangeSet->ToSetTransparency = -1;
+ aChangeSet->Transparency = 0.0;
+ aChangeSet->ToSetAlphaMode = -1;
+ aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
+ aChangeSet->AlphaCutoff = 0.5f;
+ aChangeSet->ToSetColor = -1;
+ aChangeSet->Color = DEFAULT_COLOR;
+ aChangeSet->ToSetMaterial = -1;
+ aChangeSet->Material = Graphic3d_NOM_DEFAULT;
+ aChangeSet->ToSetShowFreeBoundary = -1;
+ aChangeSet->ToSetFreeBoundaryColor = -1;
+ aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
+ aChangeSet->ToSetFreeBoundaryWidth = -1;
+ aChangeSet->FreeBoundaryWidth = 1.0;
+ aChangeSet->ToSetHatch = -1;
+ aChangeSet->StdHatchStyle = -1;
+ aChangeSet->PathToHatchPattern.Clear();
+ aChangeSet->ToSetShadingModel = -1;
+ aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
+ aChangeSet->ToSetInterior = -1;
+ aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+ aChangeSet->ToSetDrawEdges = -1;
+ aChangeSet->ToSetQuadEdges = -1;
+ aChangeSet->ToSetEdgeColor = -1;
+ aChangeSet->EdgeColor = Quantity_ColorRGBA (DEFAULT_COLOR);
+ aChangeSet->ToSetEdgeWidth = -1;
+ aChangeSet->EdgeWidth = 1.0;
+ aChangeSet->ToSetTypeOfEdge = -1;
+ aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+ }
else
{
std::cout << "Error: wrong syntax at " << anArg << "\n";
if (isDefaults)
{
const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer();
-
+ aChangeSet->Apply (aDrawer);
if (aChangeSet->ToSetLineWidth != 0)
{
aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth);
aDrawer->WireAspect()->SetColor (aChangeSet->Color);
aDrawer->PointAspect()->SetColor (aChangeSet->Color);
}
- if (aChangeSet->ToSetTypeOfLine != 0)
- {
- aDrawer->LineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->WireAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->FreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- }
- if (aChangeSet->ToSetTypeOfMarker != 0)
- {
- aDrawer->PointAspect()->SetTypeOfMarker (aChangeSet->TypeOfMarker);
- aDrawer->PointAspect()->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
- ? Handle(Graphic3d_MarkerImage)()
- : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
- }
- if (aChangeSet->ToSetMarkerSize != 0)
- {
- aDrawer->PointAspect()->SetScale (aChangeSet->MarkerSize);
- }
if (aChangeSet->ToSetTransparency != 0)
{
aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency);
}
- if (aChangeSet->ToSetAlphaMode != 0)
- {
- aDrawer->ShadingAspect()->Aspect()->SetAlphaMode (aChangeSet->AlphaMode, aChangeSet->AlphaCutoff);
- }
if (aChangeSet->ToSetMaterial != 0)
{
aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material);
}
- if (aChangeSet->ToSetShowFreeBoundary == 1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_True);
- }
- else if (aChangeSet->ToSetShowFreeBoundary == -1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_False);
- }
- if (aChangeSet->ToSetFreeBoundaryWidth != 0)
- {
- aDrawer->FreeBoundaryAspect()->SetWidth (aChangeSet->FreeBoundaryWidth);
- }
- if (aChangeSet->ToSetFreeBoundaryColor != 0)
- {
- aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor);
- }
if (aChangeSet->ToEnableIsoOnTriangulation != -1)
{
aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
}
- if (aChangeSet->ToSetMaxParamValue != 0)
- {
- aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
- }
- if (aChangeSet->ToSetShadingModel == 1)
- {
- aDrawer->ShadingAspect()->Aspect()->SetShadingModel (aChangeSet->ShadingModel);
- }
// redisplay all objects in context
for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
}
if (!aDrawer.IsNull())
{
- if (aChangeSet->ToSetShowFreeBoundary == 1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_True);
- toRedisplay = Standard_True;
- }
- else if (aChangeSet->ToSetShowFreeBoundary == -1)
- {
- aDrawer->SetFreeBoundaryDraw (Standard_False);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetFreeBoundaryWidth != 0)
- {
- Handle(Prs3d_LineAspect) aBoundaryAspect =
- new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
- *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
- aBoundaryAspect->SetWidth (aChangeSet->FreeBoundaryWidth);
- aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetFreeBoundaryColor != 0)
- {
- Handle(Prs3d_LineAspect) aBoundaryAspect =
- new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
- *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
- aBoundaryAspect->SetColor (aChangeSet->FreeBoundaryColor);
- aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetTypeOfLine != 0)
- {
- aDrawer->LineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->WireAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->FreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- aDrawer->SeenLineAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetTypeOfMarker != 0)
- {
- Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
- *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
- aMarkerAspect->SetTypeOfMarker (aChangeSet->TypeOfMarker);
- aMarkerAspect->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
- ? Handle(Graphic3d_MarkerImage)()
- : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
- aDrawer->SetPointAspect (aMarkerAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetMarkerSize != 0)
- {
- Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
- *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
- aMarkerAspect->SetScale (aChangeSet->MarkerSize);
- aDrawer->SetPointAspect (aMarkerAspect);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetMaxParamValue != 0)
- {
- aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
- }
- if (aChangeSet->ToSetHatch != 0)
- {
- if (!aDrawer->HasOwnShadingAspect())
- {
- aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
- }
-
- Handle(Graphic3d_AspectFillArea3d) anAsp = aDrawer->ShadingAspect()->Aspect();
- if (aChangeSet->ToSetHatch == -1)
- {
- anAsp->SetInteriorStyle (Aspect_IS_SOLID);
- }
- else
- {
- anAsp->SetInteriorStyle (Aspect_IS_HATCH);
- if (!aChangeSet->PathToHatchPattern.IsEmpty())
- {
- Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
- if (anImage->Load (TCollection_AsciiString (aChangeSet->PathToHatchPattern.ToCString())))
- {
- anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
- }
- else
- {
- std::cout << "Error: cannot load the following image: " << aChangeSet->PathToHatchPattern << std::endl;
- return 1;
- }
- }
- else if (aChangeSet->StdHatchStyle != -1)
- {
- anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)aChangeSet->StdHatchStyle));
- }
- }
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetShadingModel != 0)
- {
- aDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
- toRedisplay = Standard_True;
- }
- if (aChangeSet->ToSetAlphaMode != 0)
- {
- if (!aDrawer->HasOwnShadingAspect())
- {
- aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
- }
- aDrawer->ShadingAspect()->Aspect()->SetAlphaMode (aChangeSet->AlphaMode, aChangeSet->AlphaCutoff);
- toRedisplay = Standard_True;
- }
+ toRedisplay = aChangeSet->Apply (aDrawer) || toRedisplay;
}
for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
aSubShapeIter.More(); aSubShapeIter.Next())
{
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
+ if (!aChangeSet->IsEmpty())
+ {
+ Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
+ aChangeSet->Apply (aCurColDrawer);
+ }
if (aChangeSet->ToSetVisibility == 1)
{
Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
{
aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
}
- if (aChangeSet->ToSetMaxParamValue != 0)
- {
- Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
- aCurColDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
- }
if (aChangeSet->ToSetSensitivity != 0)
{
aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
}
- if (aChangeSet->ToSetShadingModel != 0)
- {
- Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
- aCurColDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
- }
}
}
if (toDisplay)
{
aCtx->Redisplay (aColoredPrs, Standard_False);
}
+ else
+ {
+ aPrs->SynchronizeAspects();
+ }
}
}
return 0;
aTextureSetNew = aTextureSetOld;
}
- if (!aTexturedIO->Attributes()->HasOwnShadingAspect())
+ if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
+ && aTexturedShape.IsNull())
{
- if (aTexturedShape.IsNull())
- {
- aTexturedIO->SetToUpdate();
- }
- aTexturedIO->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
- *aTexturedIO->Attributes()->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
+ aTexturedIO->SetToUpdate();
}
toComputeUV = !aTextureSetNew.IsNull() && aTextureSetOld.IsNull();
"\n\t\t: [-isoontriangulation 0|1]"
"\n\t\t: [-setMaxParamValue {value}]"
"\n\t\t: [-setSensitivity {selection_mode} {value}]"
- "\n\t\t: [-setHatch HatchStyle]"
"\n\t\t: [-setShadingModel {color|flat|gouraud|phong}]"
"\n\t\t: [-unsetShadingModel]"
+ "\n\t\t: [-setInterior {solid|hatch|hidenline|point}]"
+ "\n\t\t: [-unsetInterior] [-setHatch HatchStyle]"
+ "\n\t\t: [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]"
"\n\t\t: [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
"\n\t\t: Manage presentation properties of all, selected or named objects."
"\n\t\t: When -subshapes is specified than following properties will be"
theCommands.Add("vunsetwidth",
"vunsetwidth [-noupdate|-update] [name]"
- "\n\t\t: Alias for vaspects -unsetwidth [name] width.",
+ "\n\t\t: Alias for vaspects -unsetwidth [name].",
__FILE__,VAspects,group);
theCommands.Add("vsetinteriorstyle",
- "vsetinteriorstyle [-noupdate|-update] [name] style"
- "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.",
- __FILE__,VSetInteriorStyle,group);
+ "vsetinteriorstyle [-noupdate|-update] [name] Style"
+ "\n\t\t: Alias for vaspects -setInterior [name] Style.",
+ __FILE__,VAspects,group);
+
+ theCommands.Add ("vsetedgetype",
+ "vsetedgetype [name] [-type {solid, dash, dot}] [-color R G B] [-width value]"
+ "\n\t\t: Alias for vaspects [name] -setEdgeType Type.",
+ __FILE__, VAspects, group);
+
+ theCommands.Add ("vunsetedgetype",
+ "vunsetedgetype [name]"
+ "\n\t\t: Alias for vaspects [name] -unsetEdgeType.",
+ __FILE__, VAspects, group);
theCommands.Add("vsensdis",
"vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
#include <TColStd_HArray1OfTransient.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_HArray1OfShape.hxx>
-#include <Quantity_Color.hxx>
+#include <Quantity_ColorRGBA.hxx>
class AIS_InteractiveContext;
class AIS_InteractiveObject;
Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
- //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
+ //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
//! Handles either color specified by name (single argument)
- //! or by RGB components (3 arguments) in range 0..1.
+ //! or by RGB(A) components (3-4 arguments) in range 0..1.
//! The result is stored in theColor on success.
+ //! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
+ static Standard_Integer ParseColor (Standard_Integer theArgNb,
+ const char** theArgVec,
+ Quantity_ColorRGBA& theColor)
+ {
+ return parseColor (theArgNb, theArgVec, theColor, true);
+ }
+
+ //! Parses RGB color argument(s).
//! Returns number of handled arguments (1 or 3) or 0 on syntax error.
- Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
- const char** theArgVec,
- Quantity_Color& theColor);
+ static Standard_Integer ParseColor (Standard_Integer theArgNb,
+ const char** theArgVec,
+ Quantity_Color& theColor)
+ {
+ Quantity_ColorRGBA anRgba;
+ Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false);
+ if (aNbParsed != 0)
+ {
+ theColor = anRgba.GetRGB();
+ }
+ return aNbParsed;
+ }
//! redraws all defined views.
Standard_EXPORT static void RedrawAllViews();
private:
+ //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
+ //! Handles either color specified by name (single argument)
+ //! or by RGB(A) components (3-4 arguments) in range 0..1.
+ //! The result is stored in theColor on success.
+ //! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
+ Standard_EXPORT static Standard_Integer parseColor (Standard_Integer theArgNb,
+ const char** theArgVec,
+ Quantity_ColorRGBA& theColor,
+ bool theToParseAlpha);
+
//! Returns a window class that implements standard behavior of
//! all windows of the ViewerTest. This includes usual Open CASCADE
//! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
aMat,
aMat);
Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
- if (toShowEdges)
- {
- anAspect->SetEdgeOn();
- }
- else
- {
- anAspect->SetEdgeOff();
- }
+ anAspect->SetDrawEdges (toShowEdges);
aShAsp->SetAspect (anAspect);
aShape->Attributes()->SetShadingAspect (aShAsp);
return 0;
}
-//=======================================================================
-//function : VSetEdgeType
-//purpose : Edges type management
-//=======================================================================
-
-static int VSetEdgeType (Draw_Interpretor& theDI,
- Standard_Integer theArgNum,
- const char** theArgs)
-{
- if (theArgNum < 4 || theArgNum > 9)
- {
- theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
- << theArgs[0] << "' for more information.\n";
- return 1;
- }
-
- Standard_Boolean isForceRedisplay = Standard_False;
-
- // Get shape name
- TCollection_AsciiString aName(theArgs[1]);
- Handle(AIS_InteractiveObject) anObject;
- if (!GetMapOfAIS().Find2 (aName, anObject))
- {
- theDI << theArgs[0] << " error: wrong object name.\n";
- return 1;
- }
-
- // Enable triangle edge mode
- if (!anObject->Attributes()->HasOwnShadingAspect())
- {
- anObject->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
- *anObject->Attributes()->ShadingAspect()->Aspect() = *anObject->Attributes()->Link()->ShadingAspect()->Aspect();
- }
- const Handle(Prs3d_ShadingAspect)& aFillAreaAspect = anObject->Attributes()->ShadingAspect();
- aFillAreaAspect->Aspect()->SetEdgeOn();
-
- // Parse parameters
- for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
- {
- TCollection_AsciiString aParam ((theArgs[anIt]));
- if (aParam.Value (1) == '-' && !aParam.IsRealValue())
- {
- if (aParam.IsEqual ("-type"))
- {
- if (theArgNum <= anIt + 1)
- {
- theDI << theArgs[0] << " error: wrong number of values for parameter '"
- << aParam.ToCString() << "'.\n";
- return 1;
- }
-
- ++anIt;
- Aspect_TypeOfLine aTypeEnum = Aspect_TOL_SOLID;
- if (!ViewerTest::ParseLineType (theArgs[anIt], aTypeEnum))
- {
- std::cout << "Syntax error: wrong line type: '" << theArgs[anIt] << "'.\n";
- return 1;
- }
- anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType (aTypeEnum);
- }
- else if (aParam.IsEqual ("-color"))
- {
- if (theArgNum <= anIt + 3)
- {
- theDI << theArgs[0] << " error: wrong number of values for parameter '"
- << aParam.ToCString() << "'.\n";
- return 1;
- }
-
- Standard_Real aR = Draw::Atof(theArgs[++anIt]);
- Standard_Real aG = Draw::Atof(theArgs[++anIt]);
- Standard_Real aB = Draw::Atof(theArgs[++anIt]);
- Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
- aG > 1 ? aG / 255.0 : aG,
- aB > 1 ? aB / 255.0 : aB,
- Quantity_TOC_RGB);
-
- aFillAreaAspect->Aspect()->SetEdgeColor (aColor);
- }
- else if (aParam.IsEqual ("-force"))
- {
- isForceRedisplay = Standard_True;
- }
- else
- {
- theDI << theArgs[0] << " error: unknown parameter '"
- << aParam.ToCString() << "'.\n";
- return 1;
- }
- }
- }
-
- // Update shape presentation as aspect parameters were changed
- if (isForceRedisplay)
- {
- ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
- }
- else
- {
- anObject->SetAspect (aFillAreaAspect);
- }
-
- //Update view
- ViewerTest::CurrentView()->Redraw();
-
- return 0;
-}
-
-//=======================================================================
-//function : VUnsetEdgeType
-//purpose : Unsets edges visibility in shading mode
-//=======================================================================
-
-static int VUnsetEdgeType (Draw_Interpretor& theDI,
- Standard_Integer theArgNum,
- const char** theArgs)
-{
- if (theArgNum != 2 && theArgNum != 3)
- {
- theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
- << theArgs[0] << "' for more information.\n";
- return 1;
- }
-
- Standard_Boolean isForceRedisplay = Standard_False;
-
- // Get shape name
- TCollection_AsciiString aName (theArgs[1]);
- Handle(AIS_InteractiveObject) anObject;
- if (!GetMapOfAIS().Find2 (aName, anObject))
- {
- theDI << theArgs[0] << " error: wrong object name.\n";
- return 1;
- }
-
- // Enable trianle edge mode
- anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
-
- // Parse parameters
- if (theArgNum == 3)
- {
- TCollection_AsciiString aParam ((theArgs[2]));
- if (aParam.IsEqual ("-force"))
- {
- isForceRedisplay = Standard_True;
- }
- else
- {
- theDI << theArgs[0] << " error: unknown parameter '"
- << aParam.ToCString() << "'.\n";
- return 1;
- }
- }
-
- // Update shape presentation as aspect parameters were changed
- if (isForceRedisplay)
- {
- ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
- }
- else
- {
- anObject->SetAspect (anObject->Attributes()->ShadingAspect());
- }
-
- //Update view
- ViewerTest::CurrentView()->Redraw();
-
- return 0;
-}
-
-
//=======================================================================
//function : VVertexMode
//purpose : Switches vertex display mode for AIS_Shape or displays the current value
"vfont [-add pathToFont [fontName] [regular,bold,italic,boldItalic=undefined] [singleStroke]]"
"\n\t\t: [-find fontName [regular,bold,italic,boldItalic=undefined]] [-verbose {on|off}]",
__FILE__, VFont, group);
-
- theCommands.Add ("vsetedgetype",
- "vsetedgetype usage:\n"
- "vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
- "\n\t\t: Sets edges type and color for input shape",
- __FILE__, VSetEdgeType, group);
-
- theCommands.Add ("vunsetedgetype",
- "vunsetedgetype usage:\n"
- "vunsetedgetype ShapeName [-force]"
- "\n\t\t: Unsets edges type and color for input shape",
- __FILE__, VUnsetEdgeType, group);
theCommands.Add ("vvertexmode",
"vvertexmode [name | -set {isolated | all | inherited} [name1 name2 ...]]\n"
theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
+ theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
theDI << "VSync: " << aCaps->swapInterval << "\n";
theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
}
aCaps->ffpEnable = toEnable;
}
+ else if (anArgCase == "-polygonmode")
+ {
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aCaps->usePolygonMode = toEnable;
+ }
else if (anArgCase == "-vbo")
{
Standard_Boolean toEnable = Standard_True;
aParams.NbMsaaSamples = aNbSamples;
}
}
+ else if (aFlag == "-linefeather"
+ || aFlag == "-edgefeather"
+ || aFlag == "-feather")
+ {
+ if (toPrint)
+ {
+ theDI << " " << aParams.LineFeather << " ";
+ continue;
+ }
+ else if (++anArgIter >= theArgNb)
+ {
+ std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
+ return 1;
+ }
+
+ TCollection_AsciiString aParam = theArgVec[anArgIter];
+ const Standard_ShortReal aFeather = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
+ if (aFeather <= 0.0f)
+ {
+ std::cerr << "Error: invalid value of line width feather " << aFeather << ". Should be > 0\n";
+ return 1;
+ }
+ aParams.LineFeather = aFeather;
+ }
else if (aFlag == "-oit")
{
if (toPrint)
"\n\t\t: greenMagentaSimple",
__FILE__, VStereo, group);
theCommands.Add ("vcaps",
- "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
+ "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
"\n\t\t: [-compatibleProfile {0|1}]"
"\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
"\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
"\n\t\t: FFP - use fixed-function pipeline instead of"
"\n\t\t: built-in GLSL programs"
"\n\t\t: (requires compatible profile)"
+ "\n\t\t: polygonMode - use Polygon Mode instead of built-in GLSL programs"
"\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
"\n\t\t: arrays to GPU memory)"
"\n\t\t: sprite - use textured sprites instead of bitmaps"
"\n Manages rendering parameters: "
"\n '-raster' Disables GPU ray-tracing"
"\n '-msaa 0..4' Specifies number of samples for MSAA"
+ "\n '-lineFeather > 0' Sets line feather factor"
"\n '-oit off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
"\n '-depthPrePass on|off' Enables/disables depth pre-pass"
"\n '-alphatocoverage on|off' Enables/disables alpha to coverage (needs MSAA)"
trotate result 0 0 0 1 0 0 45
incmesh result 0.1
-vinit
+vclear
+vinit View1
+vaxo
vdefaults -autoTriang 0
-vdisplay result
-vsetinteriorstyle 1
-vsetdispmode 1
+vdisplay -dispMode 1 result
+vaspects result -setInteriorStyle HOLLOW -setDrawEdges 1
vfit
set log [tricheck result]
puts "BUC60738"
puts "========================"
puts ""
-puts "=================================="
-puts "It takes visual check for this BUG"
-puts "=================================="
-
-vinit
-BUC60738
-vfit
-vsetdispmode 1
-
-set x_coord 261
-set y_coord 314
+vclear
+vinit View1
+vaxo
-checkcolor $x_coord $y_coord 0 1 0
-
-if {$stat != 1} {
- puts "Error : The style of edge is NOT dash"
-}
+psphere s 20
+ttranslate s -40 0 0
+vdisplay -dispMode 1 s
+vfit
+vaspects s -setInteriorStyle HOLLOW -setDrawEdges 1 -setEdgeType DASH -setEdgeColor GREEN
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
+checkcolor 261 314 0 1 0
+if {$stat != 1} { puts "Error : The style of edge is NOT dash" }
+vdump $imagedir/${casename}.png
puts "============"
-puts "OCC23363"
+puts "0023363: Lost gradient background when switching to the hollow interior style"
puts "============"
puts ""
-####################################################################################
-# [Regression] Lost gradient background when switching to the hollow interior style
-####################################################################################
-set BugNumber OCC23363
-
-vinit
+vclear
+vinit View1
+vaxo
vsetgradientbg 250 0 0 0 255 0 2
pcylinder p 100 200
-vdisplay p
-vsetdispmode p 1
-vsetinteriorstyle p 1
+vdisplay -dispMode 1 p
+vaspects p -setInteriorStyle HOLLOW -setDrawEdges 1
-puts ""
set color1 [vreadpixel 10 0 rgb]
set rd1 [lindex $color1 0]
-if { $rd1 == 0 } {
- puts "Faulty ${BugNumber}"
-} else {
- puts "OK ${BugNumber}"
-}
+if { $rd1 == 0 } { puts "Faulty ${BugNumber}" }
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
vinit View1
pload MODELING VISUALIZATION
box b 10 10 10
-vclear
-vinit View1
vdisplay -dispMode 1 b
vfit
-vsetinteriorstyle b 2
+vaspects b -setInteriorStyle HATCH
vdump $imagedir/${casename}.png
puts "============"
-puts "CR6987"
+puts "0006897: Impossible to change edge line type in 3D View"
puts "============"
puts ""
-#######################################################################
-# Impossible to change edge line type in 3D View
-#######################################################################
-pload VISUALIZATION
+pload MODELING VISUALIZATION
+vclear
+vinit View1
+vaxo
-set anImage1 $imagedir/${casename}_1.png
-set anImage2 $imagedir/${casename}_2.png
-set anImage3 $imagedir/${casename}_3.png
-
-vinit
box b 1 1 1
-vdisplay b
+vdisplay -dispMode 1 b
vfit
-vsetdispmode b 1
-vsetedgetype b -type DASH -color 10 255 10
-vdump $anImage1
-
-vsetinteriorstyle b EMPTY
-vdump $anImage2
-vsetinteriorstyle b SOLID
-vunsetedgetype b
-vdump $anImage3
+vaspects b -setInteriorStyle SOLID
+vdump $imagedir/${casename}_3.png
+vaspects b -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeType DASH -setEdgeColor 0.392 1.0 0.392
+vdump $imagedir/${casename}_1.png
+vaspects b -setInteriorStyle HOLLOW -setDrawEdges 1
+vdump $imagedir/${casename}_2.png
+++ /dev/null
-puts "============"
-puts "CR6987"
-puts "============"
-puts ""
-##########################################################################
-# Impossible to change edge line type in 3D View
-# Tests forced redisplay of object after aspect parameter's been changed
-##########################################################################
-
-pload VISUALIZATION
-
-set anImage1 $imagedir/${casename}_1.png
-set anImage2 $imagedir/${casename}_2.png
-
-vinit
-box b 1 1 1
-vdisplay b
-vfit
-vsetdispmode b 1
-vsetedgetype b -type DASH -color 10 255 10 -force
-vdump $anImage1
-
-vunsetedgetype b -force
-vdump $anImage2
\ No newline at end of file
cpulimit 300
set group "v3d"
-pload VISUALIZATION
-pload TOPTEST
+pload VISUALIZATION TOPTEST
+vgldebug -glslWarn 1
if { [info exists imagedir] == 0 } {
set imagedir .
vrenderparams -msaa 2 -alphaToCoverage 1
vdump $::imagedir/${::casename}_msaa2_cov.png
-vrenderparams -msaa 8 -alphaToCoverage 1
+vrenderparams -msaa 8 -alphaToCoverage 0
vdump $::imagedir/${::casename}_msaa8.png
vrenderparams -msaa 8 -alphaToCoverage 1
--- /dev/null
+puts "============"
+puts "0029076: Visualization - implement element shrinking Shader"
+puts "Test case on spheres"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+vclear
+vclose ALL
+vinit View1 -width 768 -height 409
+vdefaults -autoTriang 0
+vzbufftrihedron
+psphere s1 2
+psphere s2 1
+psphere s3 1
+psphere s4 1
+psphere s5 1
+compound s1 s2 s3 s4 s5 c
+incmesh c 1.0
+vdisplay -dispMode 1 s1 s2 s3 s4 s5
+vsetlocation s2 -1.3 -1.3 1.3
+vsetlocation s3 1.3 1.3 1.3
+vsetlocation s4 1.3 -1.3 0.0
+vsetlocation s5 -1.3 -1.3 -1.3
+vrotate 0.0 0.5 0.0
+vrotate 0.4 0.0 0.0
+vfit
+
+vaspects s1 -setShadingModel PHONG -setInteriorStyle HOLLOW -setDrawEdges 1 -color GRAY80
+vdrawtext t1 " s1: phong hollow-edges " -pos 2 0 0 -disptype SUBTITLE -color BLACK -subColor GRAY80
+
+vaspects s2 -setShadingModel GOURAUD -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor YELLOW
+vdrawtext t2 " s2: gouraud solid-edges " -pos -1.3 -1.3 2.5 -halign CENTER -disptype SUBTITLE -color BLACK -subColor YELLOW
+
+vaspects s3 -setShadingModel PHONG -setInteriorStyle SOLID -setDrawEdges 1 -edgeWidth 2 -setEdgeColor BLUE1
+vdrawtext t3 " s3: phong solid-edges " -pos 1.3 1.3 2.5 -halign CENTER -disptype SUBTITLE -color WHITE -subColor BLUE1
+
+vaspects s4 -setShadingModel GOURAUD -setInteriorStyle HIDDENLINE -setDrawEdges 1 -setEdgeColor RED
+vdrawtext t4 " s4: hiddenline-edges " -pos 1.3 -1.3 -1.3 -halign CENTER -disptype SUBTITLE -color BLACK -subColor RED
+
+vaspects s5 -setShadingModel FLAT -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor 0 1 0 0 -edgeWidth 3
+vdrawtext t5 " s5: flat solid-edges " -pos -1.3 -1.3 -2.5 -halign CENTER -disptype SUBTITLE -color BLACK -subColor GREEN
+
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl_msaa.png
+
+vcamera -persp
+vzoom 0.8
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl_msaa.png
--- /dev/null
+puts "============"
+puts "0029076: Visualization - implement element shrinking Shader"
+puts "Test case on boxes"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+vclear
+vclose ALL
+vinit View1 -width 768 -height 409
+vzbufftrihedron
+vsetgradientbg 180 200 255 180 180 180 2
+box b1 -2 0 2 1 0.2 1
+box b2 2 0 2 1 0.2 1
+box b3 0 0 0 1 0.2 1
+box b4 -2 0 -2 1 0.2 1
+box b5 2 0 -2 1 0.2 1
+vdisplay -dispMode 1 b1 b2 b3 b4 b5
+vfit
+
+vaspects b1 -setShadingModel PHONG -setInteriorStyle HOLLOW -setDrawEdges 1 -color BLACK
+vdrawtext t1 " b1: phong hollow-edges " -pos -2 0 2 -halign RIGHT -disptype SUBTITLE -color WHITE -subColor BLACK
+
+vaspects b2 -setShadingModel GOURAUD -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor YELLOW
+vdrawtext t2 " b2: gouraud solid-edges " -pos 2 0 2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor YELLOW
+
+vaspects b3 -setShadingModel PHONG -setInteriorStyle SOLID -setDrawEdges 1 -edgeWidth 2 -setEdgeColor BLUE1
+vdrawtext t3 " b3: phong solid-edges " -pos 0 0 0 -halign RIGHT -disptype SUBTITLE -color WHITE -subColor BLUE1
+
+vaspects b4 -setShadingModel GOURAUD -setInteriorStyle HIDDENLINE -setDrawEdges 1 -setEdgeColor RED
+vdrawtext t4 " b4: hiddenline-edges " -pos -2 0 -2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor RED
+
+vaspects b5 -setShadingModel FLAT -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor 0 1 0 0 -edgeWidth 3
+vdrawtext t5 " b5: flat solid-edges " -pos 2 0 -2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor GREEN
+
+vdrawparray p6 triangles v 0 0 0 v 0 1 0 v 1 1 0 v 1 0 0 v 2 1 0 v 2 0 0 e 3 e 1 e 2 e 1 e 3 e 4 e 5 e 4 e 3 e 4 e 5 e 6
+vlocation p6 -setLocation 2 1 0
+vaspects p6 -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor FIREBRICK -setEdgeWidth 4 -setQuadEdges 1
+vdrawtext t6 " p6: quads " -pos 2 1 -0.4 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor FIREBRICK
+
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl_msaa.png
+
+vcamera -persp
+vzoom 0.7
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl_msaa.png