From b647266461fb2c92d199ff6d04ed6424514cf23b Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 13 Jul 2016 19:36:20 +0300 Subject: [PATCH] 0027670: Visualization - avoid duplication of structures defining primitive array presentation aspects Quantity_ColorRGBA has been introduced as convenient structure holding Vec4 for OpenGL. Graphic3d_PolygonOffset has been added as replacement for TEL_POFFSET_PARAM. Duplicating definition of Hatch Styles TEL_HS_*** has been removed; Aspect_HatchStyle enum now follows values of TEL_HS_*** for compatibility. TelCullMode enum has been removed. Aspect_AspectLine has been merged into Graphic3d_AspectLine3d. Aspect_AspectMarker has been merged into Graphic3d_AspectMarker3d. Aspect_AspectFillArea has been merged into Graphic3d_AspectFillArea3d. Graphic3d_CAspectFillArea have been removed. OpenGl_AspectLine now stores Graphic3d_AspectLine3d as class field. OpenGl_AspectMarker now stores Graphic3d_AspectMarker3d as class field. OpenGl_AspectText now stores Graphic3d_AspectText3d as class field. OpenGl_AspectFace now stores Graphic3d_AspectFillArea3d as class field. Graphic3d_AspectFillArea3d - back face culling is now enabled by default. TKOpenGl now relies on Graphic3d_Group::IsClosed() flag to disable face culling. StdPrs_ShadedShape now does not modify aspect for different culling modes. Headers InterfaceGraphic_Graphic3d.hxx, InterfaceGraphic_telem.hxx, InterfaceGraphic_tgl_all.hxx defining obsolete structures CALL_DEF_COLOR, CALL_DEF_POINT, CALL_DEF_MATERIAL, CALL_DEF_TRANSFORM_PERSISTENCE, TEL_POINT, TEL_COLOUR have been removed. Useless and broken test case bugs/vis/buc60821 has been removed. OpenGl_Workspace::myAspectFaceApplied and myAspectMarkerApplied have been replaced from OpenGl_AspectFace*/OpenGl_AspectMarker* to Handle(Graphic3d_AspectFillArea3d)/Handle(Graphic3d_AspectMarker3d). This eliminates reading from freed memory (e.g. when OpenGl_AspectFace is allocated on stack like in OpenGl_Trihedron). OpenGl_PrimitiveArray::drawEdges() - fix drawing non-indexed array from VBO (access violation due to NULL handle). AIS_Dimension::DrawArrow() - added missing initialization of 3D arrow aspect. AIS_Manipulator::Compute() now creates dedicated Face Aspect for each axis. V3d_CircularGrid, V3d_RectangularGrid now create dedicated line aspects with different color. AIS_InteractiveObject::SetMaterial() - do not modify global ShadingAspect. --- dox/dev_guides/upgrade/upgrade.md | 4 + samples/mfc/standard/Common/StdAfx.h | 1 - src/AIS/AIS_Dimension.cxx | 40 +- src/AIS/AIS_GraphicTool.cxx | 37 +- src/AIS/AIS_InteractiveObject.cxx | 34 +- src/AIS/AIS_Manipulator.cxx | 8 +- src/AIS/AIS_Plane.cxx | 4 +- src/AIS/AIS_Point.cxx | 22 +- src/AIS/AIS_PointCloud.cxx | 11 +- src/AIS/AIS_RubberBand.cxx | 24 +- src/AIS/AIS_TextLabel.cxx | 11 +- src/AIS/AIS_TextLabel.hxx | 6 + src/AIS/AIS_TexturedShape.cxx | 10 - src/Aspect/Aspect_AspectFillArea.cxx | 147 ---- src/Aspect/Aspect_AspectFillArea.hxx | 158 ---- src/Aspect/Aspect_AspectLine.cxx | 94 --- src/Aspect/Aspect_AspectLine.hxx | 100 --- src/Aspect/Aspect_AspectMarker.cxx | 94 --- src/Aspect/Aspect_AspectMarker.hxx | 106 --- src/Aspect/Aspect_HatchStyle.hxx | 38 +- src/Aspect/FILES | 6 - src/DsgPrs/DsgPrs.cxx | 7 +- src/DsgPrs/DsgPrs_AnglePresentation.cxx | 7 +- src/DsgPrs/DsgPrs_DatumPrs.cxx | 5 - src/DsgPrs/DsgPrs_DiameterPresentation.cxx | 10 +- .../DsgPrs_EllipseRadiusPresentation.cxx | 7 +- .../DsgPrs_FilletRadiusPresentation.cxx | 7 +- src/DsgPrs/DsgPrs_FixPresentation.cxx | 13 +- src/DsgPrs/DsgPrs_IdenticPresentation.cxx | 6 +- src/DsgPrs/DsgPrs_LengthPresentation.cxx | 7 +- src/DsgPrs/DsgPrs_OffsetPresentation.cxx | 19 +- src/DsgPrs/DsgPrs_RadiusPresentation.cxx | 9 +- src/DsgPrs/DsgPrs_SymmetricPresentation.cxx | 10 +- src/Graphic3d/FILES | 5 +- src/Graphic3d/Graphic3d_AspectFillArea3d.cxx | 219 ++--- src/Graphic3d/Graphic3d_AspectFillArea3d.hxx | 370 ++++++--- src/Graphic3d/Graphic3d_AspectLine3d.cxx | 58 +- src/Graphic3d/Graphic3d_AspectLine3d.hxx | 127 +-- src/Graphic3d/Graphic3d_AspectMarker3d.cxx | 83 +- src/Graphic3d/Graphic3d_AspectMarker3d.hxx | 115 ++- src/Graphic3d/Graphic3d_AspectText3d.cxx | 270 ++---- src/Graphic3d/Graphic3d_AspectText3d.hxx | 286 ++++--- src/Graphic3d/Graphic3d_CAspectFillArea.hxx | 84 -- src/Graphic3d/Graphic3d_CAspectMarker.hxx | 51 -- src/Graphic3d/Graphic3d_CAspectText.hxx | 44 - src/Graphic3d/Graphic3d_CLight.hxx | 1 - src/Graphic3d/Graphic3d_CStructure.hxx | 3 +- src/Graphic3d/Graphic3d_ClipPlane.cxx | 7 +- src/Graphic3d/Graphic3d_Group.cxx | 769 +----------------- src/Graphic3d/Graphic3d_Group.hxx | 69 +- ...ctLine.hxx => Graphic3d_PolygonOffset.hxx} | 31 +- src/Graphic3d/Graphic3d_Structure.cxx | 9 +- src/Graphic3d/Graphic3d_Vertex.hxx | 9 +- src/InterfaceGraphic/FILES | 3 - .../InterfaceGraphic_Graphic3d.hxx | 87 -- .../InterfaceGraphic_telem.hxx | 88 -- .../InterfaceGraphic_tgl_all.hxx | 35 - .../MeshVS_ElementalColorPrsBuilder.cxx | 12 +- src/MeshVS/MeshVS_MeshPrsBuilder.cxx | 60 +- src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx | 7 +- src/OpenGl/OpenGl_AspectFace.cxx | 356 +------- src/OpenGl/OpenGl_AspectFace.hxx | 203 +---- src/OpenGl/OpenGl_AspectLine.cxx | 35 +- src/OpenGl/OpenGl_AspectLine.hxx | 28 +- src/OpenGl/OpenGl_AspectMarker.cxx | 70 +- src/OpenGl/OpenGl_AspectMarker.hxx | 68 +- src/OpenGl/OpenGl_AspectText.cxx | 46 +- src/OpenGl/OpenGl_AspectText.hxx | 107 +-- src/OpenGl/OpenGl_BackgroundArray.cxx | 6 +- src/OpenGl/OpenGl_Context.cxx | 48 +- src/OpenGl/OpenGl_Context.hxx | 7 + src/OpenGl/OpenGl_GlFunctions.hxx | 2 - src/OpenGl/OpenGl_GraduatedTrihedron.cxx | 27 +- src/OpenGl/OpenGl_GraduatedTrihedron.hxx | 2 +- src/OpenGl/OpenGl_GraphicDriver.cxx | 18 +- src/OpenGl/OpenGl_Group.cxx | 163 ++-- src/OpenGl/OpenGl_Group.hxx | 70 +- src/OpenGl/OpenGl_Layer.cxx | 18 +- src/OpenGl/OpenGl_Layer.hxx | 2 - src/OpenGl/OpenGl_LayerList.cxx | 1 - src/OpenGl/OpenGl_LayerList.hxx | 2 - src/OpenGl/OpenGl_LineAttributes.cxx | 26 +- src/OpenGl/OpenGl_LineAttributes.hxx | 2 + src/OpenGl/OpenGl_Matrix.hxx | 2 +- src/OpenGl/OpenGl_PrimitiveArray.cxx | 61 +- src/OpenGl/OpenGl_PrimitiveArray.hxx | 3 +- src/OpenGl/OpenGl_ShaderProgram.hxx | 2 - src/OpenGl/OpenGl_ShaderStates.hxx | 1 - src/OpenGl/OpenGl_Structure.cxx | 22 +- src/OpenGl/OpenGl_Structure.hxx | 3 +- src/OpenGl/OpenGl_Text.cxx | 51 +- src/OpenGl/OpenGl_Text.hxx | 4 +- src/OpenGl/OpenGl_TextParam.hxx | 1 - src/OpenGl/OpenGl_Trihedron.cxx | 46 +- src/OpenGl/OpenGl_View.cxx | 15 +- src/OpenGl/OpenGl_View.hxx | 8 +- src/OpenGl/OpenGl_View_Raytrace.cxx | 121 +-- src/OpenGl/OpenGl_View_Redraw.cxx | 9 +- src/OpenGl/OpenGl_Workspace.cxx | 278 +++---- src/OpenGl/OpenGl_Workspace.hxx | 57 +- src/QABugs/FILES | 2 - src/QABugs/QABugs_17.cxx | 30 - src/QABugs/QABugs_MyText.cxx | 82 -- src/QABugs/QABugs_MyText.hxx | 82 -- src/Quantity/FILES | 1 + src/Quantity/Quantity_Color.cxx | 13 + src/Quantity/Quantity_Color.hxx | 11 +- src/Quantity/Quantity_ColorRGBA.hxx | 84 ++ src/StdPrs/StdPrs_BndBox.cxx | 7 +- src/StdPrs/StdPrs_ShadedShape.cxx | 9 +- src/StdPrs/StdPrs_ShadedSurface.cxx | 9 +- src/V3d/V3d_CircularGrid.cxx | 15 +- src/V3d/V3d_RectangularGrid.cxx | 24 +- src/ViewerTest/ViewerTest.cxx | 12 +- src/ViewerTest/ViewerTest_OpenGlCommands.cxx | 8 +- tests/bugs/vis/buc60821 | 23 - tests/bugs/vis/bug24837_2 | 2 +- 117 files changed, 1850 insertions(+), 4519 deletions(-) delete mode 100644 src/Aspect/Aspect_AspectFillArea.cxx delete mode 100644 src/Aspect/Aspect_AspectFillArea.hxx delete mode 100644 src/Aspect/Aspect_AspectLine.cxx delete mode 100644 src/Aspect/Aspect_AspectLine.hxx delete mode 100644 src/Aspect/Aspect_AspectMarker.cxx delete mode 100644 src/Aspect/Aspect_AspectMarker.hxx delete mode 100644 src/Graphic3d/Graphic3d_CAspectFillArea.hxx delete mode 100644 src/Graphic3d/Graphic3d_CAspectMarker.hxx delete mode 100644 src/Graphic3d/Graphic3d_CAspectText.hxx rename src/Graphic3d/{Graphic3d_CAspectLine.hxx => Graphic3d_PolygonOffset.hxx} (50%) delete mode 100644 src/InterfaceGraphic/InterfaceGraphic_Graphic3d.hxx delete mode 100644 src/InterfaceGraphic/InterfaceGraphic_telem.hxx delete mode 100644 src/InterfaceGraphic/InterfaceGraphic_tgl_all.hxx delete mode 100644 src/QABugs/QABugs_MyText.cxx delete mode 100644 src/QABugs/QABugs_MyText.hxx create mode 100644 src/Quantity/Quantity_ColorRGBA.hxx delete mode 100755 tests/bugs/vis/buc60821 diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index e2095b08fd..8e31eb3f8a 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1006,3 +1006,7 @@ Within this OCCT release, this first level of aspects has been completely remove Note that the 3rd level (defining several different aspects within the same graphic group) is also should be avoided in application code since it is deprecated functionality which can be removed in further releases. Graphic3d_Group::SetGroupPrimitivesAspect() should be the main method defining presentation attributes. + +The implementation of Graphic3d_Group::SetGroupPrimitivesAspect() has been changed from copying aspect values to keeping passed object. +Although it was not documented, previosly it was possible to modify single aspects instance (like Graphic3d_AspectFillArea3d) and set it to multiple groups. +Now such code would produce unexpected result and therefore should be updated to create dedicated aspect instance. diff --git a/samples/mfc/standard/Common/StdAfx.h b/samples/mfc/standard/Common/StdAfx.h index 41f11867a6..b9d73fb59b 100755 --- a/samples/mfc/standard/Common/StdAfx.h +++ b/samples/mfc/standard/Common/StdAfx.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/src/AIS/AIS_Dimension.cxx b/src/AIS/AIS_Dimension.cxx index fd6f5f4a54..8139c0579f 100755 --- a/src/AIS/AIS_Dimension.cxx +++ b/src/AIS/AIS_Dimension.cxx @@ -293,14 +293,7 @@ TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidt } // Get text style parameters - Quantity_Color aColor; - Standard_CString aFontName; - Standard_Real aFactor; - Standard_Real aSpace; - myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, aFactor, aSpace); - Font_FontAspect aFontAspect = myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect(); - Standard_Real aFontHeight = myDrawer->DimensionAspect()->TextAspect()->Height(); - + Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect(); NCollection_Utf8String anUTFString = (Standard_Utf16Char* )aValueStr.ToExtString(); theWidth = 0.0; @@ -308,7 +301,9 @@ TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidt if (myDrawer->DimensionAspect()->IsText3d()) { // text width produced by BRepFont - Font_BRepFont aFont (aFontName, aFontAspect, aFontHeight); + Font_BRepFont aFont (aTextAspect->Aspect()->Font().ToCString(), + aTextAspect->Aspect()->GetTextFontAspect(), + aTextAspect->Height()); for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; ) { @@ -321,7 +316,10 @@ TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidt { // Text width for 1:1 scale 2D case Handle(Font_FTFont) aFont = new Font_FTFont(); - aFont->Init (aFontName, aFontAspect, (const unsigned int)aFontHeight, THE_2D_TEXT_RESOLUTION); + aFont->Init (aTextAspect->Aspect()->Font().ToCString(), + aTextAspect->Aspect()->GetTextFontAspect(), + (const unsigned int)aTextAspect->Height(), + THE_2D_TEXT_RESOLUTION); for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; ) { @@ -354,6 +352,8 @@ void AIS_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentation theDirection, anAngle, aLength); + + Prs3d_Root::CurrentGroup (thePresentation)->SetGroupPrimitivesAspect (myDrawer->DimensionAspect()->ArrowAspect()->Aspect()); } else { @@ -370,17 +370,13 @@ void AIS_Dimension::DrawArrow (const Handle(Prs3d_Presentation)& thePresentation anArrow->AddVertex (aRightPoint); // Set aspect for arrow triangles - Quantity_Color aColor; - Aspect_TypeOfLine aTOL; - Standard_Real aWidth; - myDrawer->DimensionAspect()->ArrowAspect()->Aspect()->Values (aColor, aTOL, aWidth); Graphic3d_MaterialAspect aShadeMat (Graphic3d_NOM_DEFAULT); aShadeMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT); aShadeMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE); aShadeMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); Handle(Prs3d_ShadingAspect) aShadingStyle = new Prs3d_ShadingAspect(); - aShadingStyle->SetColor (aColor); + aShadingStyle->SetColor (myDrawer->DimensionAspect()->ArrowAspect()->Aspect()->Color()); aShadingStyle->SetMaterial (aShadeMat); Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aShadingStyle->Aspect()); @@ -405,16 +401,14 @@ void AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation, if (myDrawer->DimensionAspect()->IsText3d()) { // getting font parameters - Quantity_Color aColor; - Standard_CString aFontName; - Standard_Real anExpansionFactor; - Standard_Real aSpace; - myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, anExpansionFactor, aSpace); - Font_FontAspect aFontAspect = myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect(); - Standard_Real aFontHeight = myDrawer->DimensionAspect()->TextAspect()->Height(); + Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect(); + Quantity_Color aColor = aTextAspect->Aspect()->Color(); + Font_FontAspect aFontAspect = aTextAspect->Aspect()->GetTextFontAspect(); + Standard_Real aFontHeight = aTextAspect->Height(); // creating TopoDS_Shape for text - Font_BRepFont aFont (aFontName, aFontAspect, aFontHeight); + Font_BRepFont aFont (aTextAspect->Aspect()->Font().ToCString(), + aFontAspect, aFontHeight); NCollection_Utf8String anUTFString = (Standard_Utf16Char* )theText.ToExtString(); Font_BRepTextBuilder aBuilder; diff --git a/src/AIS/AIS_GraphicTool.cxx b/src/AIS/AIS_GraphicTool.cxx index 7a3354b796..faf7198bff 100644 --- a/src/AIS/AIS_GraphicTool.cxx +++ b/src/AIS/AIS_GraphicTool.cxx @@ -16,7 +16,6 @@ #include -#include #include #include #include @@ -89,36 +88,20 @@ Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor) { - Standard_Real W; - Aspect_TypeOfLine TYP; - GetLineAspect(Dr,Att)->Aspect()->Values(aColor,TYP,W); + aColor = GetLineAspect(Dr,Att)->Aspect()->Color(); } Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att) { -// Quantity_NameOfColor Col; - Standard_Real W; - Aspect_TypeOfLine TYP; - Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); - - Quantity_Color QCol; - LA->Aspect()->Values(QCol,TYP,W); - return W; + return LA->Aspect()->Width(); } Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att) { -// Quantity_NameOfColor Col; - Standard_Real W; - Aspect_TypeOfLine TYP; - Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); - - Quantity_Color QCol; - LA->Aspect()->Values(QCol,TYP,W); - return TYP; + return LA->Aspect()->Type();; } @@ -128,12 +111,10 @@ void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr, Standard_Real& W, Aspect_TypeOfLine& TYP) { - Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); - - Quantity_Color QCol; - LA->Aspect()->Values(QCol,TYP,W); - Col = QCol.Name(); + Col = LA->Aspect()->Color().Name(); + W = LA->Aspect()->Width(); + TYP = LA->Aspect()->Type(); } Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr) @@ -146,11 +127,7 @@ Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor) { Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect(); - Aspect_InteriorStyle IS; - Aspect_TypeOfLine T; - Standard_Real W; - Quantity_Color EC; - AFA->Values(IS,aColor,EC,T,W); + aColor = AFA->InteriorColor(); } Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr) diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index 2440bdaa05..d58f159619 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -266,21 +266,21 @@ void AIS_InteractiveObject::UnsetWidth() //======================================================================= -//function : -//purpose : +//function : SetMaterial +//purpose : //======================================================================= -void AIS_InteractiveObject::SetMaterial(const Graphic3d_NameOfMaterial aName) +void AIS_InteractiveObject::SetMaterial (const Graphic3d_NameOfMaterial theName) { - if( HasColor() || IsTransparent() || HasMaterial() ) - { - myDrawer->ShadingAspect()->SetMaterial(aName); - } - else + if (!myDrawer->HasOwnShadingAspect()) { - myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); - myDrawer->ShadingAspect()->SetMaterial(aName); + myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); + if (myDrawer->HasLink()) + { + *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect(); + } } - myOwnMaterial = aName; + myDrawer->ShadingAspect()->SetMaterial (theName); + myOwnMaterial = theName; hasOwnMaterial = Standard_True; } @@ -290,13 +290,15 @@ void AIS_InteractiveObject::SetMaterial(const Graphic3d_NameOfMaterial aName) //======================================================================= void AIS_InteractiveObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { - if (!HasColor() && !IsTransparent() && !HasMaterial()) + if (!myDrawer->HasOwnShadingAspect()) { - myDrawer->SetShadingAspect (new Prs3d_ShadingAspect); + myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); + if (myDrawer->HasLink()) + { + *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect(); + } } - myDrawer->ShadingAspect()->SetMaterial (theMaterial); - hasOwnMaterial = Standard_True; } @@ -343,7 +345,7 @@ void AIS_InteractiveObject::UnsetMaterial() //======================================================================= void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue) { - if(!HasColor() && !IsTransparent() && !HasMaterial()) + if (!myDrawer->HasOwnShadingAspect()) { myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); if(myDrawer->HasLink()) diff --git a/src/AIS/AIS_Manipulator.cxx b/src/AIS/AIS_Manipulator.cxx index 6bc3bb09eb..370ec76a44 100644 --- a/src/AIS/AIS_Manipulator.cxx +++ b/src/AIS/AIS_Manipulator.cxx @@ -809,9 +809,11 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePr { // Display axes aGroup = Prs3d_Root::NewGroup (thePrs); - anAspect->SetColor (myAxes[anIt].Color()); - aGroup->SetGroupPrimitivesAspect (anAspect->Aspect()); - myAxes[anIt].Compute (thePrsMgr, thePrs, anAspect); + + Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect())); + anAspectAx->SetColor (myAxes[anIt].Color()); + aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect()); + myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx); myAxes[anIt].SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint()); } diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index 9566f5f735..087cf1e28d 100644 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -502,9 +502,7 @@ void AIS_Plane::UnsetColor() const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() : new Prs3d_PlaneAspect(); // const Handle(Prs3d_DatumAspect)& DA = myDrawer->Link()->DatumAspect(); - Quantity_Color C;Aspect_TypeOfLine T;Standard_Real W; - PA->EdgesAspect()->Aspect()->Values(C,T,W); - Quantity_NameOfColor Col = C.Name(); + Quantity_NameOfColor Col = PA->EdgesAspect()->Aspect()->Color().Name(); myDrawer->PlaneAspect()->EdgesAspect()->SetColor(Col); myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(Col); diff --git a/src/AIS/AIS_Point.cxx b/src/AIS/AIS_Point.cxx index 959fe9bd21..7d752ee8a4 100644 --- a/src/AIS/AIS_Point.cxx +++ b/src/AIS/AIS_Point.cxx @@ -219,20 +219,16 @@ void AIS_Point::UpdatePointValues() myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)()); return; } - Quantity_Color aCol; - Quantity_Color QCO; - Aspect_TypeOfMarker aTOM; - Standard_Real aScale; - - if(myDrawer->HasLink()){ - myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale); - aCol = QCO.Name(); - } - else{ - aCol = Quantity_NOC_YELLOW; - aTOM = Aspect_TOM_PLUS; - aScale = 1; + Quantity_Color aCol (Quantity_NOC_YELLOW); + Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS; + Standard_Real aScale = 1.0; + if (myDrawer->HasLink()) + { + aCol = myDrawer->Link()->PointAspect()->Aspect()->Color(); + aTOM = myDrawer->Link()->PointAspect()->Aspect()->Type(); + aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale(); } + if(hasOwnColor) aCol = myOwnColor; if(myOwnWidth!=0.0) aScale = myOwnWidth; if(myHasTOM) aTOM = myTOM; diff --git a/src/AIS/AIS_PointCloud.cxx b/src/AIS/AIS_PointCloud.cxx index 75a87aa568..a9f89022ae 100644 --- a/src/AIS/AIS_PointCloud.cxx +++ b/src/AIS/AIS_PointCloud.cxx @@ -224,14 +224,9 @@ void AIS_PointCloud::UnsetColor() } else { - Quantity_Color aColor = Quantity_NOC_YELLOW; - Aspect_TypeOfMarker aType = Aspect_TOM_POINT; - Standard_Real aScale = 1.0; - if (myDrawer->HasLink()) - { - myDrawer->Link()->PointAspect()->Aspect()->Values (aColor, aType, aScale); - } - myDrawer->PointAspect()->SetColor (aColor); + myDrawer->PointAspect()->SetColor (myDrawer->HasLink() + ? myDrawer->Link()->PointAspect()->Aspect()->Color() + : Quantity_Color (Quantity_NOC_YELLOW)); } if (HasMaterial() diff --git a/src/AIS/AIS_RubberBand.cxx b/src/AIS/AIS_RubberBand.cxx index 4fbbaf7163..b9ccdb3f1b 100644 --- a/src/AIS/AIS_RubberBand.cxx +++ b/src/AIS/AIS_RubberBand.cxx @@ -149,11 +149,7 @@ const NCollection_Sequence& AIS_RubberBand::Points() const //======================================================================= Quantity_Color AIS_RubberBand::LineColor() const { - Quantity_Color aColor; - Standard_Real aWidth; - Aspect_TypeOfLine aTOL; - myDrawer->LineAspect()->Aspect()->Values (aColor, aTOL, aWidth); - return aColor; + return myDrawer->LineAspect()->Aspect()->Color(); } //======================================================================= @@ -198,11 +194,7 @@ void AIS_RubberBand::SetLineWidth (const Standard_Real theWidth) const //======================================================================= Standard_Real AIS_RubberBand::LineWidth() const { - Quantity_Color aColor; - Standard_Real aWidth; - Aspect_TypeOfLine aTOL; - myDrawer->LineAspect()->Aspect()->Values (aColor, aTOL, aWidth); - return aWidth; + return myDrawer->LineAspect()->Aspect()->Width(); } //======================================================================= @@ -220,11 +212,7 @@ void AIS_RubberBand::SetLineType (const Aspect_TypeOfLine theType) //======================================================================= Aspect_TypeOfLine AIS_RubberBand::LineType() const { - Quantity_Color aColor; - Standard_Real aWidth; - Aspect_TypeOfLine aTOL; - myDrawer->LineAspect()->Aspect()->Values (aColor, aTOL, aWidth); - return aTOL; + return myDrawer->LineAspect()->Aspect()->Type(); } //======================================================================= @@ -271,11 +259,7 @@ void AIS_RubberBand::SetFilling (const Quantity_Color theColor, const Standard_R //======================================================================= Standard_Boolean AIS_RubberBand::IsFilling() const { - Aspect_InteriorStyle aStyle; - Quantity_Color anIntColor, anEdgeColor; - Aspect_TypeOfLine aTOL; - Standard_Real aWidth; - myDrawer->ShadingAspect()->Aspect()->Values (aStyle, anIntColor, anEdgeColor, aTOL, aWidth); + Aspect_InteriorStyle aStyle = myDrawer->ShadingAspect()->Aspect()->InteriorStyle(); return aStyle != Aspect_IS_EMPTY; } diff --git a/src/AIS/AIS_TextLabel.cxx b/src/AIS/AIS_TextLabel.cxx index 8c35450142..863ec5f052 100644 --- a/src/AIS/AIS_TextLabel.cxx +++ b/src/AIS/AIS_TextLabel.cxx @@ -120,7 +120,7 @@ void AIS_TextLabel::SetAngle (const Standard_Real theAngle) //======================================================================= void AIS_TextLabel::SetZoomable (const Standard_Boolean theIsZoomable) { - myDrawer->TextAspect()->Aspect()->SetTextZoomable (theIsZoomable); + myDrawer->TextAspect()->Aspect()->SetTextZoomable (theIsZoomable == Standard_True); } //======================================================================= @@ -256,14 +256,9 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr { // Get width and height of text Font_FTFont aFont; - Quantity_Color aColor; - Standard_CString aName; - Standard_Real anExpFactor; - Standard_Real aSpace; - - anAsp->Aspect()->Values (aColor, aName, anExpFactor, aSpace); unsigned int aResolution = GetContext()->CurrentViewer()->DefaultRenderingParams().Resolution; - if (aFont.Init (aName, anAsp->Aspect()->GetTextFontAspect(), (unsigned int)anAsp->Height(), aResolution)) + if (aFont.Init (anAsp->Aspect()->Font().ToCString(), + anAsp->Aspect()->GetTextFontAspect(), (unsigned int)anAsp->Height(), aResolution)) { isInit = Standard_True; const NCollection_String aText ((Standard_Utf16Char* )myText.ToExtString()); diff --git a/src/AIS/AIS_TextLabel.hxx b/src/AIS/AIS_TextLabel.hxx index 3293c95572..4f88154684 100644 --- a/src/AIS/AIS_TextLabel.hxx +++ b/src/AIS/AIS_TextLabel.hxx @@ -38,6 +38,12 @@ public: //! Setup color of entire text. Standard_EXPORT virtual void SetColor (const Quantity_NameOfColor theColor) Standard_OVERRIDE; + //! Material has no effect for text label. + virtual void SetMaterial (const Graphic3d_NameOfMaterial ) Standard_OVERRIDE {} + + //! Material has no effect for text label. + virtual void SetMaterial (const Graphic3d_MaterialAspect& ) Standard_OVERRIDE {} + //! Setup text. Standard_EXPORT void SetText (const TCollection_ExtendedString& theText); diff --git a/src/AIS/AIS_TexturedShape.cxx b/src/AIS/AIS_TexturedShape.cxx index 362362dbce..2e249ef2ac 100644 --- a/src/AIS/AIS_TexturedShape.cxx +++ b/src/AIS/AIS_TexturedShape.cxx @@ -384,16 +384,6 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP { continue; } - - if (aGroup->IsClosed()) - { - myAspect->SuppressBackFace(); - } - else - { - myAspect->AllowBackFace(); - } - aGroup->SetGroupPrimitivesAspect (myAspect); } } diff --git a/src/Aspect/Aspect_AspectFillArea.cxx b/src/Aspect/Aspect_AspectFillArea.cxx deleted file mode 100644 index 57a248a140..0000000000 --- a/src/Aspect/Aspect_AspectFillArea.cxx +++ /dev/null @@ -1,147 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// Modified: 15/01/98 ; FMN : Ajout Hidden Line -//-Version -//-Design Declaration of variables specific to the context -// of tracing facets -//-Warning Context of tracing facets id defined by: -// - the style of the interior of the facet -// - the style of the border of the facet -// - the color -//-References -//-Language C++ 2.0 -//-Declarations -// for the class - -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Aspect_AspectFillArea,MMgt_TShared) - -//-Aliases -//-Global data definitions -// -- interior -// MyInteriorStyle : InteriorStyle; -// MyInteriorColor : Color; -// -- border -// MyEdgeColor : Color; -// MyEdgeType : TypeOfLine; -// MyEdgeWidth : Standard_Real; -// -- shading -// MyHatchStyle : HatchStyle; -//-Constructors -//-Destructors -//-Methods, in order -Aspect_AspectFillArea::Aspect_AspectFillArea () { - - MyInteriorStyle = Aspect_IS_EMPTY; - MyInteriorColor = Quantity_NOC_CYAN1; - MyBackInteriorColor = Quantity_NOC_CYAN1; - MyEdgeColor = Quantity_NOC_WHITE; - MyEdgeType = Aspect_TOL_SOLID; - MyEdgeWidth = 1.0; - MyHatchStyle = Aspect_HS_VERTICAL; - -} - -Aspect_AspectFillArea::Aspect_AspectFillArea (const Aspect_InteriorStyle InteriorStyle, const Quantity_Color& InteriorColor, const Quantity_Color& EdgeColor, const Aspect_TypeOfLine EdgeLineType, const Standard_Real EdgeLineWidth) { - - if (EdgeLineWidth <= 0.0) - Aspect_AspectFillAreaDefinitionError::Raise - ("Bad value for EdgeLineWidth"); - - MyInteriorStyle = InteriorStyle; - MyInteriorColor = InteriorColor; - MyEdgeColor = EdgeColor; - MyEdgeType = EdgeLineType; - MyEdgeWidth = EdgeLineWidth; - MyHatchStyle = Aspect_HS_VERTICAL; - -} - -void Aspect_AspectFillArea::SetInteriorStyle (const Aspect_InteriorStyle AStyle) { - - MyInteriorStyle = AStyle; - -} - -void Aspect_AspectFillArea::SetInteriorColor (const Quantity_Color& AColor) { - - MyInteriorColor = AColor; - -} - -void Aspect_AspectFillArea::SetBackInteriorColor( const Quantity_Color& color ) -{ - MyBackInteriorColor = color; -} - -void Aspect_AspectFillArea::SetEdgeColor (const Quantity_Color& AColor) { - - MyEdgeColor = AColor; - -} - -void Aspect_AspectFillArea::SetEdgeLineType (const Aspect_TypeOfLine AType) { - - MyEdgeType = AType; - -} - -void Aspect_AspectFillArea::SetEdgeWidth (const Standard_Real AWidth) { - - if (AWidth <= 0.0) - Aspect_AspectFillAreaDefinitionError::Raise - ("Bad value for EdgeLineWidth"); - - MyEdgeWidth = AWidth; - -} - -void Aspect_AspectFillArea::SetHatchStyle (const Aspect_HatchStyle AStyle) { - - MyHatchStyle = AStyle; - -} - -Aspect_HatchStyle Aspect_AspectFillArea::HatchStyle () const { - - return (MyHatchStyle); - -} - -void Aspect_AspectFillArea::Values (Aspect_InteriorStyle& AStyle, Quantity_Color& AIntColor, Quantity_Color& AEdgeColor, Aspect_TypeOfLine& AType, Standard_Real& AWidth) const { - - AStyle = MyInteriorStyle; - AIntColor = MyInteriorColor; - AEdgeColor = MyEdgeColor; - AType = MyEdgeType; - AWidth = MyEdgeWidth; - -} - -void Aspect_AspectFillArea::Values (Aspect_InteriorStyle& AStyle, Quantity_Color& AIntColor, Quantity_Color& BackIntColor, Quantity_Color& AEdgeColor, Aspect_TypeOfLine& AType, Standard_Real& AWidth) const { - - AStyle = MyInteriorStyle; - AIntColor = MyInteriorColor; - BackIntColor = MyBackInteriorColor; - AEdgeColor = MyEdgeColor; - AType = MyEdgeType; - AWidth = MyEdgeWidth; - -} diff --git a/src/Aspect/Aspect_AspectFillArea.hxx b/src/Aspect/Aspect_AspectFillArea.hxx deleted file mode 100644 index c9a47cfc9a..0000000000 --- a/src/Aspect/Aspect_AspectFillArea.hxx +++ /dev/null @@ -1,158 +0,0 @@ -// Created on: 1991-11-04 -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Aspect_AspectFillArea_HeaderFile -#define _Aspect_AspectFillArea_HeaderFile - -#include -#include - -#include -#include -#include -#include -#include -#include -class Aspect_AspectFillAreaDefinitionError; -class Quantity_Color; - - -class Aspect_AspectFillArea; -DEFINE_STANDARD_HANDLE(Aspect_AspectFillArea, MMgt_TShared) - -//! Group of attributes for the FACE primitives. -//! The attributes are: -//! * type of interior -//! * type of hatch -//! * interior colour -//! * border colour -//! * type of border -//! * thickness of border -//! when the value of the group is modified, all graphic -//! objects using this group are modified. -class Aspect_AspectFillArea : public MMgt_TShared -{ - -public: - - - //! Modifies the colour of the edge of the face - Standard_EXPORT void SetEdgeColor (const Quantity_Color& AColor); - - //! Modifies the edge line type - Standard_EXPORT void SetEdgeLineType (const Aspect_TypeOfLine AType); - - //! Modifies the edge thickness - //! - //! Category: Methods to modify the class definition - //! - //! Warning: Raises AspectFillAreaDefinitionError if the - //! width is a negative value. - Standard_EXPORT void SetEdgeWidth (const Standard_Real AWidth); - - //! Modifies the hatch type used when InteriorStyle - //! is IS_HATCH - Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle AStyle); - - //! Modifies the colour of the interior of the face - Standard_EXPORT void SetInteriorColor (const Quantity_Color& AColor); - - //! Modifies the colour of the interior of the back face - Standard_EXPORT void SetBackInteriorColor (const Quantity_Color& color); - - //! Modifies the interior type used for rendering - //! - //! InteriorStyle : IS_EMPTY no interior - //! IS_HOLLOW display the boundaries of the surface - //! IS_HATCH display hatching - //! IS_SOLID display interior entirely filled - Standard_EXPORT void SetInteriorStyle (const Aspect_InteriorStyle AStyle); - - //! Returns the hatch type used when InteriorStyle - //! is IS_HATCH - Standard_EXPORT Aspect_HatchStyle HatchStyle() const; - - Standard_EXPORT void Values (Aspect_InteriorStyle& AStyle, Quantity_Color& AIntColor, Quantity_Color& AEdgeColor, Aspect_TypeOfLine& AType, Standard_Real& AWidth) const; - - //! Returns the current values of the group. - Standard_EXPORT void Values (Aspect_InteriorStyle& AStyle, Quantity_Color& AIntColor, Quantity_Color& BackIntColor, Quantity_Color& AEdgeColor, Aspect_TypeOfLine& AType, Standard_Real& AWidth) const; - - - - - DEFINE_STANDARD_RTTIEXT(Aspect_AspectFillArea,MMgt_TShared) - -protected: - - - //! Initialise the constructor - //! of Graphic3d_AspectFillArea3d. - //! - //! default values : - //! - //! InteriorStyle = Aspect_IS_EMPTY; - //! InteriorColor = Quantity_NOC_CYAN1; - //! EdgeColor = Quantity_NOC_WHITE; - //! EdgeType = Aspect_TOL_SOLID; - //! EdgeWidth = 1.0; - //! HatchStyle = Aspect_HS_VERTICAL; - Standard_EXPORT Aspect_AspectFillArea(); - - //! Initialise the values for the constructor of - //! Graphic3d_AspectFillArea3d. - //! - //! InteriorStyle : - //! 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. - //! - //! EdgeLineType : - //! TOL_SOLID continuous - //! TOL_DASH dashed - //! TOL_DOT dotted - //! TOL_DOTDASH mixed - //! - //! default values : - //! HatchStyle = Aspect_HS_VERTICAL; - //! - //! Warning: Raises AspectFillAreaDefinitionError if the - //! width is a negative value. - Standard_EXPORT Aspect_AspectFillArea(const Aspect_InteriorStyle InteriorStyle, const Quantity_Color& InteriorColor, const Quantity_Color& EdgeColor, const Aspect_TypeOfLine EdgeLineType, const Standard_Real EdgeLineWidth); - - - -private: - - - Aspect_InteriorStyle MyInteriorStyle; - Quantity_Color MyInteriorColor; - Quantity_Color MyBackInteriorColor; - Quantity_Color MyEdgeColor; - Aspect_TypeOfLine MyEdgeType; - Standard_Real MyEdgeWidth; - Aspect_HatchStyle MyHatchStyle; - - -}; - - - - - - - -#endif // _Aspect_AspectFillArea_HeaderFile diff --git a/src/Aspect/Aspect_AspectLine.cxx b/src/Aspect/Aspect_AspectLine.cxx deleted file mode 100644 index 2a875d0e1f..0000000000 --- a/src/Aspect/Aspect_AspectLine.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//-Version -//-Design Declaration of variables specific to the context -// of line tracing -//-Warning A context of line tracing is defined by : -// - the color -// - the type of line -// - the thickness -//-References -//-Language C++ 2.0 -//-Declarations -// for the class - -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Aspect_AspectLine,MMgt_TShared) - -//-Aliases -//-Global data definitions -// -- color -// MyColor : Color; -// -- type of line -// MyType : TypeOfLine; -// -- thickness -// MyWidth : Standard_Real; -//-Constructors -//-Destructors -//-Methods, in order -Aspect_AspectLine::Aspect_AspectLine () { - - MyColor = Quantity_NOC_YELLOW; - MyType = Aspect_TOL_SOLID; - MyWidth = 1.0; - -} - -Aspect_AspectLine::Aspect_AspectLine (const Quantity_Color& AColor, const Aspect_TypeOfLine AType, const Standard_Real AWidth) { - - if (AWidth <= 0.0) - Aspect_AspectLineDefinitionError::Raise - ("Bad value for LineWidth"); - - MyColor = AColor; - MyType = AType; - MyWidth = AWidth; - -} - -void Aspect_AspectLine::SetColor (const Quantity_Color& AColor) { - - MyColor = AColor; - -} - -void Aspect_AspectLine::SetType (const Aspect_TypeOfLine AType) { - - MyType = AType; - -} - -void Aspect_AspectLine::SetWidth (const Standard_Real AWidth) { - - if (AWidth <= 0.0) - Aspect_AspectLineDefinitionError::Raise - ("Bad value for LineWidth"); - - MyWidth = AWidth; - -} - -void Aspect_AspectLine::Values (Quantity_Color& AColor, Aspect_TypeOfLine& AType, Standard_Real& AWidth) const { - - AColor = MyColor; - AType = MyType; - AWidth = MyWidth; - -} diff --git a/src/Aspect/Aspect_AspectLine.hxx b/src/Aspect/Aspect_AspectLine.hxx deleted file mode 100644 index 237e8a4724..0000000000 --- a/src/Aspect/Aspect_AspectLine.hxx +++ /dev/null @@ -1,100 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Aspect_AspectLine_HeaderFile -#define _Aspect_AspectLine_HeaderFile - -#include -#include - -#include -#include -#include -#include -class Aspect_AspectLineDefinitionError; -class Quantity_Color; - - -class Aspect_AspectLine; -DEFINE_STANDARD_HANDLE(Aspect_AspectLine, MMgt_TShared) - -//! This class allows the definition of a group -//! of attributes for the LINE primitive -//! The attributes are: -//! * Colour -//! * Type -//! * Thickness -//! When any value of the group is modified -//! all graphic objects using the group are modified. -class Aspect_AspectLine : public MMgt_TShared -{ - -public: - - - //! Modifies the colour of . - Standard_EXPORT void SetColor (const Quantity_Color& AColor); - - //! Modifies the type of . - Standard_EXPORT void SetType (const Aspect_TypeOfLine AType); - - //! Modifies the thickness of . - //! Category: Methods to modify the class definition - //! Warning: Raises AspectLineDefinitionError if the - //! width is a negative value. - Standard_EXPORT void SetWidth (const Standard_Real AWidth); - - //! Returns the current values of the group . - Standard_EXPORT void Values (Quantity_Color& AColor, Aspect_TypeOfLine& AType, Standard_Real& AWidth) const; - - - - - DEFINE_STANDARD_RTTIEXT(Aspect_AspectLine,MMgt_TShared) - -protected: - - - //! Initialise the constructor for Graphic3d_AspectLine3d. - //! - //! Default values : - //! Color = Quantity_NOC_YELLOW; - //! Type = Aspect_TOL_SOLID; - //! Width = 1.0; - Standard_EXPORT Aspect_AspectLine(); - - //! Initialise the values for the - //! constructor of Graphic3d_AspectLine3d. - Standard_EXPORT Aspect_AspectLine(const Quantity_Color& AColor, const Aspect_TypeOfLine AType, const Standard_Real AWidth); - - - -protected: - - - Quantity_Color MyColor; - Aspect_TypeOfLine MyType; - Standard_Real MyWidth; - - -}; - - - - - - - -#endif // _Aspect_AspectLine_HeaderFile diff --git a/src/Aspect/Aspect_AspectMarker.cxx b/src/Aspect/Aspect_AspectMarker.cxx deleted file mode 100644 index c68ea940ab..0000000000 --- a/src/Aspect/Aspect_AspectMarker.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//-Version -//-Design Declaration of variables specific to the context -// of tracing of markers -//-Warning Context of tracing of markers is defined by : -// - the color -// - the type -// - the scale -//-References -//-Language C++ 2.0 -//-Declarations -// for the class - -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Aspect_AspectMarker,MMgt_TShared) - -//-Aliases -//-Global data definitions -// -- color -// MyColor : Color; -// -- type -// MyType : TypeOfMarker; -// -- scale -// MyScale : Standard_Real; -//-Constructors -//-Destructors -//-Methods, in order -Aspect_AspectMarker::Aspect_AspectMarker () { - - MyColor = Quantity_NOC_YELLOW; - MyType = Aspect_TOM_X; - MyScale = 1.0; - -} - -Aspect_AspectMarker::Aspect_AspectMarker (const Quantity_Color& AColor, const Aspect_TypeOfMarker AType, const Standard_Real AScale) { - - if (AScale <= 0.0) - Aspect_AspectMarkerDefinitionError::Raise - ("Bad value for MarkerScale"); - - MyColor = AColor; - MyType = AType; - MyScale = AScale; - -} - -void Aspect_AspectMarker::SetColor (const Quantity_Color& AColor) { - - MyColor = AColor; - -} - -void Aspect_AspectMarker::SetType (const Aspect_TypeOfMarker AType) { - - MyType = AType; - -} - -void Aspect_AspectMarker::SetScale (const Standard_Real AScale) { - - if (AScale <= 0.0) - Aspect_AspectMarkerDefinitionError::Raise - ("Bad value for MarkerScale"); - - MyScale = AScale; - -} - -void Aspect_AspectMarker::Values (Quantity_Color& AColor, Aspect_TypeOfMarker& AType, Standard_Real& AScale) const { - - AColor = MyColor; - AType = MyType; - AScale = MyScale; - -} diff --git a/src/Aspect/Aspect_AspectMarker.hxx b/src/Aspect/Aspect_AspectMarker.hxx deleted file mode 100644 index ed64b68374..0000000000 --- a/src/Aspect/Aspect_AspectMarker.hxx +++ /dev/null @@ -1,106 +0,0 @@ -// Created on: 1991-09-02 -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Aspect_AspectMarker_HeaderFile -#define _Aspect_AspectMarker_HeaderFile - -#include -#include - -#include -#include -#include -#include -class Aspect_AspectMarkerDefinitionError; -class Quantity_Color; - - -class Aspect_AspectMarker; -DEFINE_STANDARD_HANDLE(Aspect_AspectMarker, MMgt_TShared) - -//! This class allows the definition of a group -//! of attributes for the primitive MARKER. -//! the attributes are: -//! * Colour -//! * Type -//! * Scale factor -//! When any value of the group is modified -//! all graphic objects using the group are modified -class Aspect_AspectMarker : public MMgt_TShared -{ - -public: - - - //! Modifies the colour of . - Standard_EXPORT void SetColor (const Quantity_Color& AColor); - - //! Modifies the scale factor of . - //! Marker type Aspect_TOM_POINT is not affected - //! by the marker size scale factor. It is always - //! the smallest displayable dot. - //! Warning: Raises AspectMarkerDefinitionError if the - //! scale is a negative value. - Standard_EXPORT void SetScale (const Standard_Real AScale); - - //! Modifies the type of marker . - Standard_EXPORT void SetType (const Aspect_TypeOfMarker AType); - - //! Returns the current values of the group . - Standard_EXPORT void Values (Quantity_Color& AColor, Aspect_TypeOfMarker& AType, Standard_Real& AScale) const; - - - - - DEFINE_STANDARD_RTTIEXT(Aspect_AspectMarker,MMgt_TShared) - -protected: - - - //! Initialise the constructor for Graphic3d_AspectMarker3d. - //! - //! defaults values : - //! - //! Color = Quantity_NOC_YELLOW; - //! Type = Aspect_TOM_X; - //! Scale = 1.0; - Standard_EXPORT Aspect_AspectMarker(); - - //! Initialise the values for the - //! constructor of Graphic3d_AspectMarker3d. - //! Warning: Raises AspectMarkerDefinitionError if the - //! scale is a negative value. - Standard_EXPORT Aspect_AspectMarker(const Quantity_Color& AColor, const Aspect_TypeOfMarker AType, const Standard_Real AScale); - - - -private: - - - Quantity_Color MyColor; - Aspect_TypeOfMarker MyType; - Standard_Real MyScale; - - -}; - - - - - - - -#endif // _Aspect_AspectMarker_HeaderFile diff --git a/src/Aspect/Aspect_HatchStyle.hxx b/src/Aspect/Aspect_HatchStyle.hxx index bb57fd56b3..49128ce186 100644 --- a/src/Aspect/Aspect_HatchStyle.hxx +++ b/src/Aspect/Aspect_HatchStyle.hxx @@ -17,33 +17,21 @@ #define _Aspect_HatchStyle_HeaderFile //! Definition of all available hatch styles. -//! -//! HS_HORIZONTAL -//! HS_HORIZONTAL_WIDE -//! HS_VERTICAL -//! HS_VERTICAL_WIDE -//! HS_DIAGONAL_45 -//! HS_DIAGONAL_45_WIDE -//! HS_DIAGONAL_135 -//! HS_DIAGONAL_135_WIDE -//! HS_GRID -//! HS_GRID_WIDE -//! HS_GRID_DIAGONAL -//! HS_GRID_DIAGONAL_WIDE enum Aspect_HatchStyle { -Aspect_HS_HORIZONTAL, -Aspect_HS_HORIZONTAL_WIDE, -Aspect_HS_VERTICAL, -Aspect_HS_VERTICAL_WIDE, -Aspect_HS_DIAGONAL_45, -Aspect_HS_DIAGONAL_45_WIDE, -Aspect_HS_DIAGONAL_135, -Aspect_HS_DIAGONAL_135_WIDE, -Aspect_HS_GRID, -Aspect_HS_GRID_WIDE, -Aspect_HS_GRID_DIAGONAL, -Aspect_HS_GRID_DIAGONAL_WIDE + Aspect_HS_SOLID = 0, // TEL_HS_SOLID (no hatching) + Aspect_HS_HORIZONTAL = 7, // TEL_HS_HORIZONTAL + Aspect_HS_HORIZONTAL_WIDE = 11, // TEL_HS_HORIZONTAL_SPARSE + Aspect_HS_VERTICAL = 8, // TEL_HS_VERTICAL + Aspect_HS_VERTICAL_WIDE = 12, // TEL_HS_VERTICAL_SPARSE + Aspect_HS_DIAGONAL_45 = 5, // TEL_HS_DIAG_45 + Aspect_HS_DIAGONAL_45_WIDE = 9, // TEL_HS_DIAG_45_SPARSE + Aspect_HS_DIAGONAL_135 = 6, // TEL_HS_DIAG_135 + Aspect_HS_DIAGONAL_135_WIDE = 10, // TEL_HS_DIAG_135_SPARSE + Aspect_HS_GRID = 3, // TEL_HS_GRID + Aspect_HS_GRID_WIDE = 4, // TEL_HS_GRID_SPARSE + Aspect_HS_GRID_DIAGONAL = 1, // TEL_HS_CROSS + Aspect_HS_GRID_DIAGONAL_WIDE = 2, // TEL_HS_CROSS_SPARSE }; #endif // _Aspect_HatchStyle_HeaderFile diff --git a/src/Aspect/FILES b/src/Aspect/FILES index fd0ad1f64b..f17e1b0a11 100755 --- a/src/Aspect/FILES +++ b/src/Aspect/FILES @@ -1,11 +1,5 @@ -Aspect_AspectFillArea.cxx -Aspect_AspectFillArea.hxx Aspect_AspectFillAreaDefinitionError.hxx -Aspect_AspectLine.cxx -Aspect_AspectLine.hxx Aspect_AspectLineDefinitionError.hxx -Aspect_AspectMarker.cxx -Aspect_AspectMarker.hxx Aspect_AspectMarkerDefinitionError.hxx Aspect_Background.cxx Aspect_Background.hxx diff --git a/src/DsgPrs/DsgPrs.cxx b/src/DsgPrs/DsgPrs.cxx index 99917f0c86..bbb3d5b350 100644 --- a/src/DsgPrs/DsgPrs.cxx +++ b/src/DsgPrs/DsgPrs.cxx @@ -12,8 +12,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include #include #include #include @@ -60,10 +58,7 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, { Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); + Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); diff --git a/src/DsgPrs/DsgPrs_AnglePresentation.cxx b/src/DsgPrs/DsgPrs_AnglePresentation.cxx index deca386d4f..d85b2046ec 100644 --- a/src/DsgPrs/DsgPrs_AnglePresentation.cxx +++ b/src/DsgPrs/DsgPrs_AnglePresentation.cxx @@ -13,12 +13,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include -#include -#include -#include #include -#include #include #include #include @@ -35,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/src/DsgPrs/DsgPrs_DatumPrs.cxx b/src/DsgPrs/DsgPrs_DatumPrs.cxx index be964ee45d..13e5dd89e9 100755 --- a/src/DsgPrs/DsgPrs_DatumPrs.cxx +++ b/src/DsgPrs/DsgPrs_DatumPrs.cxx @@ -31,11 +31,6 @@ void DsgPrs_DatumPrs::Add (const Handle(Prs3d_Presentation)& thePresentation, Handle(Prs3d_DatumAspect) aDatumAspect = theDrawer->DatumAspect(); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation); - Quantity_Color aColor; - Aspect_TypeOfLine aTypeOfLine; - Standard_Real aWidth; - aDatumAspect->FirstAxisAspect()->Aspect()->Values(aColor, aTypeOfLine, aWidth); - gp_Ax2 anAxis(theDatum); gp_Pnt anOrigin = anAxis.Location(); gp_Dir aXDir = anAxis.XDirection(); diff --git a/src/DsgPrs/DsgPrs_DiameterPresentation.cxx b/src/DsgPrs/DsgPrs_DiameterPresentation.cxx index 5e01671197..c13f8da3ec 100644 --- a/src/DsgPrs/DsgPrs_DiameterPresentation.cxx +++ b/src/DsgPrs/DsgPrs_DiameterPresentation.cxx @@ -14,15 +14,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// modified 12-january-98 -// Sergey ZARITCHNY -// szy +#include -#include -#include -#include #include -#include #include #include #include @@ -32,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +33,6 @@ #include #include #include -#include #include //========================================================================== diff --git a/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx index 405c299da2..110ab77099 100644 --- a/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx @@ -14,12 +14,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include -#include -#include -#include #include -#include #include #include #include @@ -35,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +39,6 @@ #include #include #include -#include #include #include diff --git a/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx index feedd30f81..ca3818306a 100644 --- a/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx @@ -14,12 +14,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include -#include -#include -#include #include -#include #include #include #include @@ -33,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +37,6 @@ #include #include #include -#include #include #include diff --git a/src/DsgPrs/DsgPrs_FixPresentation.cxx b/src/DsgPrs/DsgPrs_FixPresentation.cxx index b6c572f651..32f717ff75 100644 --- a/src/DsgPrs/DsgPrs_FixPresentation.cxx +++ b/src/DsgPrs/DsgPrs_FixPresentation.cxx @@ -14,11 +14,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include -#include -#include #include + #include #include #include @@ -28,12 +25,10 @@ #include #include #include -#include #include #include #include #include -#include //======================================================================= //function : Add @@ -97,13 +92,9 @@ void DsgPrs_FixPresentation::Add( Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - // On ajoute un rond au point d'attache Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); + Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); diff --git a/src/DsgPrs/DsgPrs_IdenticPresentation.cxx b/src/DsgPrs/DsgPrs_IdenticPresentation.cxx index 5ea378ee49..67d4aa077d 100644 --- a/src/DsgPrs/DsgPrs_IdenticPresentation.cxx +++ b/src/DsgPrs/DsgPrs_IdenticPresentation.cxx @@ -50,13 +50,9 @@ void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresent aPrims->AddVertex(aPntOffset); Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - // On ajoute un rond au point d'attache Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); + Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); diff --git a/src/DsgPrs/DsgPrs_LengthPresentation.cxx b/src/DsgPrs/DsgPrs_LengthPresentation.cxx index 7cfd2b9bc3..cae16ab1da 100644 --- a/src/DsgPrs/DsgPrs_LengthPresentation.cxx +++ b/src/DsgPrs/DsgPrs_LengthPresentation.cxx @@ -12,12 +12,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include -#include -#include -#include #include -#include #include #include #include @@ -31,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/src/DsgPrs/DsgPrs_OffsetPresentation.cxx b/src/DsgPrs/DsgPrs_OffsetPresentation.cxx index dee546b0ef..a650414856 100644 --- a/src/DsgPrs/DsgPrs_OffsetPresentation.cxx +++ b/src/DsgPrs/DsgPrs_OffsetPresentation.cxx @@ -14,11 +14,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include -#include -#include #include + #include #include #include @@ -29,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -37,7 +33,6 @@ #include #include #include -#include #include #include @@ -121,10 +116,7 @@ void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // ball 1 : 3eme groupe - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); + Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); @@ -167,10 +159,9 @@ void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPres gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2); Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); - Quantity_Color acolor; - Aspect_TypeOfLine atype; - Standard_Real awidth; - LA->LineAspect()->Aspect()->Values(acolor, atype, awidth); + Quantity_Color acolor = LA->LineAspect()->Aspect()->Color(); + Aspect_TypeOfLine atype = LA->LineAspect()->Aspect()->Type(); + Standard_Real awidth = LA->LineAspect()->Aspect()->Width(); Handle(Graphic3d_AspectLine3d) AxeAsp = new Graphic3d_AspectLine3d (acolor, atype, awidth); AxeAsp->SetType( Aspect_TOL_DOTDASH); diff --git a/src/DsgPrs/DsgPrs_RadiusPresentation.cxx b/src/DsgPrs/DsgPrs_RadiusPresentation.cxx index 225aee3a4f..dc60814ec8 100644 --- a/src/DsgPrs/DsgPrs_RadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_RadiusPresentation.cxx @@ -14,14 +14,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -//modified 20-feb-98 by -// Sergei Zaritchny +#include -#include -#include -#include #include -#include #include #include #include @@ -33,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +35,6 @@ #include #include #include -#include #include static Standard_Boolean DsgPrs_InDomain(const Standard_Real fpar, diff --git a/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx b/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx index f0bf2559bc..d1aba850bb 100644 --- a/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx +++ b/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx @@ -689,10 +689,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // SYMMETRY WHEN THE REFERENCE POINT IS ON THE AXIS OF SYM.: //============================================================== //Marker of localisation of the face - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - LA->LineAspect()->Aspect()->Values(aColor, aType, aWidth); + Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); @@ -810,10 +807,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); + Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); Handle(Graphic3d_AspectMarker3d) aMarkerAspAtt = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAspAtt); Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1); diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 258ff60536..0603ed871d 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -40,10 +40,6 @@ Graphic3d_Buffer.hxx Graphic3d_BufferType.hxx Graphic3d_Camera.cxx Graphic3d_Camera.hxx -Graphic3d_CAspectFillArea.hxx -Graphic3d_CAspectLine.hxx -Graphic3d_CAspectMarker.hxx -Graphic3d_CAspectText.hxx Graphic3d_CBitFields4.hxx Graphic3d_CBitFields8.hxx Graphic3d_CBitFields16.hxx @@ -94,6 +90,7 @@ Graphic3d_NameOfTextureEnv.hxx Graphic3d_NameOfTexturePlane.hxx Graphic3d_NListOfHAsciiString.hxx Graphic3d_NMapOfTransient.hxx +Graphic3d_PolygonOffset.hxx Graphic3d_PriorityDefinitionError.hxx Graphic3d_RenderingMode.hxx Graphic3d_RenderingParams.hxx diff --git a/src/Graphic3d/Graphic3d_AspectFillArea3d.cxx b/src/Graphic3d/Graphic3d_AspectFillArea3d.cxx index 75727db894..1591213801 100644 --- a/src/Graphic3d/Graphic3d_AspectFillArea3d.cxx +++ b/src/Graphic3d/Graphic3d_AspectFillArea3d.cxx @@ -13,178 +13,57 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -//-Design Declaration of variables specific to the context -// of tracing of facets 3D -//-Warning Ccontext of tracing of facets 3d inherits the context -// defined by : -// - the style of the interior of the facet -// - the style of the facet border -// - the color -// Additionally, it has more than one definition of material -// for internal and external faces. -// for the class - -#include #include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d,Aspect_AspectFillArea) - -Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (): -DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial () -{ - // By default, aspect do not change current polygon offset parameters - MyPolygonOffsetMode = Aspect_POM_Fill; - MyPolygonOffsetFactor = 1.; - MyPolygonOffsetUnits = 0.; -} - -// (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth) -// because AspectFillArea3d inherits AspectFillArea and it is necessary to call -// initialisation of AspectFillArea with InteriorStyle, InteriorColor, -// EdgeColor, EdgeLineType and EdgeLineWidth. - -Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorStyle InteriorStyle, const Quantity_Color& InteriorColor, const Quantity_Color& EdgeColor, const Aspect_TypeOfLine EdgeLineType, const Standard_Real EdgeLineWidth, const Graphic3d_MaterialAspect& FrontMaterial, const Graphic3d_MaterialAspect& BackMaterial): -Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) { - // By default, aspect do not change current polygon offset parameters - MyPolygonOffsetMode = Aspect_POM_Fill; - MyPolygonOffsetFactor = 1.; - MyPolygonOffsetUnits = 0.; -} - -void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) { - - MyBackMaterial = AMaterial; - -} - -void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) { - - MyFrontMaterial = AMaterial; -} - -const Graphic3d_MaterialAspect& Graphic3d_AspectFillArea3d::BackMaterial() const +IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient) + +// ======================================================================= +// function : Graphic3d_AspectFillArea3d +// purpose : +// ======================================================================= +Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d() +: myInteriorColor (Quantity_NOC_CYAN1), + myBackInteriorColor (Quantity_NOC_CYAN1), + myEdgeColor (Quantity_NOC_WHITE), + myInteriorStyle (Aspect_IS_EMPTY), + myEdgeType (Aspect_TOL_SOLID), + myEdgeWidth (1.0f), + myHatchStyle (Aspect_HS_VERTICAL), + myToDistinguishMaterials (false), + myToDrawEdges (false), + myToSuppressBackFaces (true), + myToMapTexture (false) { - return MyBackMaterial; -} - -const Graphic3d_MaterialAspect& Graphic3d_AspectFillArea3d::FrontMaterial() const -{ - return MyFrontMaterial; -} - -void Graphic3d_AspectFillArea3d::AllowBackFace () { - - BackFaceRemovalActive = Standard_False; - -} - -void Graphic3d_AspectFillArea3d::SuppressBackFace () { - - BackFaceRemovalActive = Standard_True; - -} - -Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const { - - return (BackFaceRemovalActive); - -} - -void Graphic3d_AspectFillArea3d::SetDistinguishOn () { - - DistinguishModeActive = Standard_True; - -} - -void Graphic3d_AspectFillArea3d::SetDistinguishOff () { - - DistinguishModeActive = Standard_False; - -} - -Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const { - - return (DistinguishModeActive); - -} - -void Graphic3d_AspectFillArea3d::SetEdgeOn () { - - EdgeModeActive = Standard_True; - -} - -void Graphic3d_AspectFillArea3d::SetEdgeOff () { - - EdgeModeActive = Standard_False; - -} - - -void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture) -{ - MyTextureMap = ATexture; -} - - -void Graphic3d_AspectFillArea3d::SetTextureMapOn() -{ - MyTextureMapState = Standard_True; -} - - -void Graphic3d_AspectFillArea3d::SetTextureMapOff() -{ - MyTextureMapState = Standard_False; -} - - -Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const { - - return (EdgeModeActive); - -} - - -Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const -{ - return MyTextureMap; -} - - -Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const -{ - return MyTextureMapState; -} - -void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode, - const Standard_ShortReal aFactor, - const Standard_ShortReal aUnits) { - MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask ); - MyPolygonOffsetFactor = aFactor; - MyPolygonOffsetUnits = aUnits; -} - -void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode, - Standard_ShortReal& aFactor, - Standard_ShortReal& aUnits) const { - aMode = MyPolygonOffsetMode; - aFactor = MyPolygonOffsetFactor; - aUnits = MyPolygonOffsetUnits; -} - -void Graphic3d_AspectFillArea3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) -{ - MyShaderProgram = theProgram; -} - -const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectFillArea3d::ShaderProgram() const + // +} + +// ======================================================================= +// function : Graphic3d_AspectFillArea3d +// purpose : +// ======================================================================= +Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorStyle theInteriorStyle, + const Quantity_Color& theInteriorColor, + const Quantity_Color& theEdgeColor, + const Aspect_TypeOfLine theEdgeLineType, + const Standard_Real theEdgeLineWidth, + const Graphic3d_MaterialAspect& theFrontMaterial, + const Graphic3d_MaterialAspect& theBackMaterial) +: myFrontMaterial (theFrontMaterial), + myBackMaterial (theBackMaterial), + myInteriorColor (theInteriorColor), + myBackInteriorColor (theInteriorColor), + myEdgeColor (theEdgeColor), + myInteriorStyle (theInteriorStyle), + myEdgeType (theEdgeLineType), + myEdgeWidth ((float )theEdgeLineWidth), + myHatchStyle (Aspect_HS_VERTICAL), + myToDistinguishMaterials (false), + myToDrawEdges (false), + myToSuppressBackFaces (true), + myToMapTexture (false) { - return MyShaderProgram; + if (theEdgeLineWidth <= 0.0) + { + Aspect_AspectFillAreaDefinitionError::Raise ("Bad value for EdgeLineWidth"); + } } diff --git a/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx b/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx index 9ba2b47c4d..035b6bd928 100644 --- a/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx +++ b/src/Graphic3d/Graphic3d_AspectFillArea3d.hxx @@ -17,110 +17,165 @@ #ifndef _Graphic3d_AspectFillArea3d_HeaderFile #define _Graphic3d_AspectFillArea3d_HeaderFile +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include - #include -#include #include #include -#include -#include -#include -#include #include -class Graphic3d_TextureMap; -class Quantity_Color; -class Graphic3d_MaterialAspect; - - -class Graphic3d_AspectFillArea3d; -DEFINE_STANDARD_HANDLE(Graphic3d_AspectFillArea3d, Aspect_AspectFillArea) - -//! This class permits the creation and updating of -//! a graphic attribute context for opaque 3d -//! primitives (polygons, triangles, quadrilaterals) -//! Keywords: Face, FillArea, Triangle, Quadrangle, Polygon, -//! TriangleMesh, QuadrangleMesh, Edge, Border, Interior, -//! Color, Type, Width, Style, Hatch, Material, -//! BackFaceRemoval, DistinguishMode -class Graphic3d_AspectFillArea3d : public Aspect_AspectFillArea -{ +#include +#include +//! This class defines graphic attributes for opaque 3d primitives (polygons, triangles, quadrilaterals). +class Graphic3d_AspectFillArea3d : public Standard_Transient +{ + DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient) public: - - //! Creates a context table for fill area primitives - //! defined with the following default values: + //! Creates a context table for fill area primitives defined with the following default values: //! - //! InteriorStyle : IS_EMPTY - //! InteriorColor : NOC_CYAN1 - //! EdgeColor : NOC_WHITE - //! EdgeLineType : TOL_SOLID - //! EdgeWidth : 1.0 - //! FrontMaterial : NOM_BRASS - //! BackMaterial : NOM_BRASS + //! InteriorStyle : Aspect_IS_EMPTY + //! InteriorColor : Quantity_NOC_CYAN1 + //! EdgeColor : Quantity_NOC_WHITE + //! EdgeLineType : Aspect_TOL_SOLID + //! EdgeWidth : 1.0 + //! FrontMaterial : NOM_BRASS + //! BackMaterial : NOM_BRASS + //! HatchStyle : Aspect_HS_VERTICAL //! //! Display of back-facing filled polygons. - //! No distinction between external and internal - //! faces of FillAreas. + //! No distinction between external and internal faces of FillAreas. //! The edges are not drawn. //! Polygon offset parameters: mode = Aspect_POM_None, factor = 1., units = 0. Standard_EXPORT Graphic3d_AspectFillArea3d(); - //! Creates a context table for fill area primitives - //! defined with the specified values. - //! + //! Creates a context table for fill area primitives defined with the specified values. //! Display of back-facing filled polygons. - //! No distinction between external and internal - //! faces of FillAreas. + //! No distinction between external and internal faces of FillAreas. //! The edges are not drawn. //! Polygon offset parameters: mode = Aspect_POM_None, factor = 1., units = 0. - //! Warning - //! EdgeWidth is the "line width scale factor". The - //! nominal line width is 1 pixel. The width of the line is - //! determined by applying the line width scale factor to - //! this nominal line width. The supported line widths - //! vary by 1-pixel units. - Standard_EXPORT Graphic3d_AspectFillArea3d(const Aspect_InteriorStyle Interior, const Quantity_Color& InteriorColor, const Quantity_Color& EdgeColor, const Aspect_TypeOfLine EdgeLineType, const Standard_Real EdgeWidth, const Graphic3d_MaterialAspect& FrontMaterial, const Graphic3d_MaterialAspect& BackMaterial); - - //! Allows the display of back-facing filled - //! polygons. - Standard_EXPORT void AllowBackFace(); - - //! Modifies the surface material of internal faces - Standard_EXPORT void SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial); - - //! Allows distinction between external and internal - //! faces of FillAreas. - Standard_EXPORT void SetDistinguishOn(); - - //! Forbids distinction between external and internal - //! faces of FillAreas. - Standard_EXPORT void SetDistinguishOff(); - - //! The edges of FillAreas are drawn. - Standard_EXPORT void SetEdgeOn(); - - //! The edges of FillAreas are not drawn. - Standard_EXPORT void SetEdgeOff(); - + Standard_EXPORT Graphic3d_AspectFillArea3d (const Aspect_InteriorStyle theInterior, + const Quantity_Color& theInteriorColor, + const Quantity_Color& theEdgeColor, + const Aspect_TypeOfLine theEdgeLineType, + const Standard_Real theEdgeWidth, + const Graphic3d_MaterialAspect& theFrontMaterial, + const Graphic3d_MaterialAspect& theBackMaterial); + + //! Return interior rendering style (Aspect_IS_EMPTY by default, which means nothing will be rendered!). + Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; } + + //! Modifies the interior type used for rendering + void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; } + + //! Return interior color. + const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); } + + //! Return interior color. + const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; } + + //! Modifies the color of the interior of the face + void SetInteriorColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); } + + //! Return back interior color. + const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); } + + //! Return back interior color. + const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; } + + //! Modifies the color of the interior of the back face + void SetBackInteriorColor (const Quantity_Color& theColor) { myBackInteriorColor.SetRGB (theColor); } + + //! Returns the surface material of external faces + const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; } + //! Modifies the surface material of external faces - Standard_EXPORT void SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial); - - //! Suppress the display of back-facing filled - //! polygons. + void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; } + + //! Returns the surface material of internal faces + const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; } + + //! Modifies the surface material of internal faces + void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; } + + //! Returns true if back faces should be suppressed (true by default). + bool ToSuppressBackFaces() const { return myToSuppressBackFaces; } + + //! Assign back faces culling flag. + void SetSuppressBackFaces (bool theToSuppress) { myToSuppressBackFaces = theToSuppress; } + + //! Returns true if back faces should be suppressed (true by default). + bool BackFace() const { return myToSuppressBackFaces; } + + //! Allows the display of back-facing filled polygons. + void AllowBackFace() { myToSuppressBackFaces = false; } + + //! Suppress the display of back-facing filled polygons. //! A back-facing polygon is defined as a polygon whose - //! vertices are in a clockwise order with respect - //! to screen coordinates. - Standard_EXPORT void SuppressBackFace(); - - Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& ATexture); - - Standard_EXPORT void SetTextureMapOn(); - - Standard_EXPORT void SetTextureMapOff(); - + //! vertices are in a clockwise order with respect to screen coordinates. + void SuppressBackFace() { myToSuppressBackFaces = true; } + + //! Returns true if material properties should be distinguished for back and front faces (false by default). + bool Distinguish() const { return myToDistinguishMaterials; } + + //! Set material distinction between front and back faces. + void SetDistinguish (bool toDistinguish) { myToDistinguishMaterials = toDistinguish; } + + //! Allows material distinction between front and back faces. + void SetDistinguishOn() { myToDistinguishMaterials = true; } + + //! Forbids material distinction between front and back faces. + void SetDistinguishOff() { myToDistinguishMaterials = false; } + + //! Return shader program. + const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; } + + //! Sets up OpenGL/GLSL shader program. + void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; } + + //! Return texture to be mapped. + const Handle(Graphic3d_TextureMap)& TextureMap() const { return myTextureMap; } + + //! Assign texture to be mapped. + //! See also SetTextureMap() to actually activate texture mapping. + void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture) { myTextureMap = theTexture; } + + //! Return true if texture mapping is enabled (false by default). + bool ToMapTexture() const { return myToMapTexture; } + + //! Return true if texture mapping is enabled (false by default). + bool TextureMapState() const { return myToMapTexture; } + + //! Set texture mapping flag. + void SetTextureMap (bool theToEnable) { myToMapTexture = theToEnable; } + + //! Enable texture mapping (has no effect if texture is not set). + void SetTextureMapOn() { myToMapTexture = true; } + + //! Disable texture mapping. + void SetTextureMapOff() { myToMapTexture = false; } + + //! Returns current polygon offsets settings. + const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; } + + //! Returns current polygon offsets settings. + void PolygonOffsets (Standard_Integer& theMode, + Standard_ShortReal& theFactor, + Standard_ShortReal& theUnits) const + { + theMode = myPolygonOffset.Mode; + theFactor = myPolygonOffset.Factor; + theUnits = myPolygonOffset.Units; + } + //! Sets up OpenGL polygon offsets mechanism. //! parameter can contain various combinations of //! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means @@ -132,74 +187,129 @@ public: //! m - maximum depth slope for the polygon currently being displayed, //! r - minimum window coordinates depth resolution (implementation-specific) //! - //! Deafult settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0. + //! Default settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0. //! //! Negative offset values move polygons closer to the viewport, //! while positive values shift polygons away. //! Consult OpenGL reference for details (glPolygonOffset function description). - Standard_EXPORT void SetPolygonOffsets (const Standard_Integer aMode, const Standard_ShortReal aFactor = 1.0, const Standard_ShortReal aUnits = 0.0); - - //! Sets up OpenGL/GLSL shader program. - Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram); - - //! Returns the Back Face Removal status. - //! Standard_True if SuppressBackFace is activated. - Standard_EXPORT Standard_Boolean BackFace() const; - - //! Returns the Distinguish Mode status. - Standard_EXPORT Standard_Boolean Distinguish() const; - - //! Returns Standard_True if the edges are drawn and - //! Standard_False if the edges are not drawn. - Standard_EXPORT Standard_Boolean Edge() const; - - //! Returns the surface material of internal faces - Standard_EXPORT const Graphic3d_MaterialAspect& BackMaterial() const; - - //! Returns the surface material of external faces - Standard_EXPORT const Graphic3d_MaterialAspect& FrontMaterial() const; - - Standard_EXPORT Handle(Graphic3d_TextureMap) TextureMap() const; - - Standard_EXPORT Standard_Boolean TextureMapState() const; - - //! Returns current polygon offsets settings. - Standard_EXPORT void PolygonOffsets (Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const; - - Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const; + void SetPolygonOffsets (const Standard_Integer theMode, + const Standard_ShortReal theFactor = 1.0f, + const Standard_ShortReal theUnits = 0.0f) + { + myPolygonOffset.Mode = (Aspect_PolygonOffsetMode )(theMode & Aspect_POM_Mask); + myPolygonOffset.Factor = theFactor; + myPolygonOffset.Units = theUnits; + } + +public: + //! Returns true if edges should be drawn (false by default). + bool ToDrawEdges() const { return myToDrawEdges; } + //! Set if edges should be drawn or not. + void SetDrawEdges (bool theToDraw) { myToDrawEdges = theToDraw; } + //! Returns true if edges should be drawn. + bool Edge() const { return myToDrawEdges; } - DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d,Aspect_AspectFillArea) + //! The edges of FillAreas are drawn. + void SetEdgeOn() { myToDrawEdges = true; } -protected: + //! The edges of FillAreas are not drawn. + void SetEdgeOff() { myToDrawEdges = false; } + //! Return color of edges. + const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); } + //! Return color of edges. + const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; } + //! Modifies the color of the edge of the face + void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); } -private: + //! Return edges line type. + Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; } + //! Modifies the edge line type + void SetEdgeLineType (const Aspect_TypeOfLine theType) { myEdgeType = theType; } - Standard_Boolean DistinguishModeActive; - Standard_Boolean EdgeModeActive; - Standard_Boolean BackFaceRemovalActive; - Handle(Graphic3d_TextureMap) MyTextureMap; - Standard_Boolean MyTextureMapState; - Graphic3d_MaterialAspect MyFrontMaterial; - Graphic3d_MaterialAspect MyBackMaterial; - Standard_Integer MyPolygonOffsetMode; - Standard_ShortReal MyPolygonOffsetFactor; - Standard_ShortReal MyPolygonOffsetUnits; - Handle(Graphic3d_ShaderProgram) MyShaderProgram; + //! Return width for edges in pixels. + Standard_ShortReal EdgeWidth() const { return myEdgeWidth; } + //! Modifies the edge thickness + //! Warning: Raises AspectFillAreaDefinitionError if the width is a negative value. + void SetEdgeWidth (const Standard_Real theWidth) + { + if (theWidth <= 0.0) + { + Aspect_AspectFillAreaDefinitionError::Raise ("Bad value for EdgeLineWidth"); + } + myEdgeWidth = (float )theWidth; + } -}; +public: + //! Returns the hatch type used when InteriorStyle is IS_HATCH + Aspect_HatchStyle HatchStyle() const { return myHatchStyle; } + //! Modifies the hatch type used when InteriorStyle is IS_HATCH + void SetHatchStyle (const Aspect_HatchStyle theStyle) { myHatchStyle = theStyle; } + //! Returns the current values. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Aspect_InteriorStyle& theStyle, + Quantity_Color& theIntColor, + Quantity_Color& theEdgeColor, + Aspect_TypeOfLine& theType, + Standard_Real& theWidth) const + { + theStyle = myInteriorStyle; + theIntColor = myInteriorColor.GetRGB(); + theEdgeColor= myEdgeColor.GetRGB(); + theType = myEdgeType; + theWidth = myEdgeWidth; + } + //! Returns the current values. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Aspect_InteriorStyle& theStyle, + Quantity_Color& theIntColor, + Quantity_Color& theBackIntColor, + Quantity_Color& theEdgeColor, + Aspect_TypeOfLine& theType, + Standard_Real& theWidth) const + { + theStyle = myInteriorStyle; + theIntColor = myInteriorColor.GetRGB(); + theBackIntColor= myBackInteriorColor.GetRGB(); + theEdgeColor = myEdgeColor.GetRGB(); + theType = myEdgeType; + theWidth = myEdgeWidth; + } +protected: + + Handle(Graphic3d_ShaderProgram) myProgram; + Handle(Graphic3d_TextureMap) myTextureMap; + Graphic3d_MaterialAspect myFrontMaterial; + Graphic3d_MaterialAspect myBackMaterial; + + Quantity_ColorRGBA myInteriorColor; + Quantity_ColorRGBA myBackInteriorColor; + Quantity_ColorRGBA myEdgeColor; + Aspect_InteriorStyle myInteriorStyle; + Aspect_TypeOfLine myEdgeType; + Standard_ShortReal myEdgeWidth; + Aspect_HatchStyle myHatchStyle; + + Graphic3d_PolygonOffset myPolygonOffset; + bool myToDistinguishMaterials; + bool myToDrawEdges; + bool myToSuppressBackFaces; + bool myToMapTexture; + +}; +DEFINE_STANDARD_HANDLE(Graphic3d_AspectFillArea3d, Standard_Transient) #endif // _Graphic3d_AspectFillArea3d_HeaderFile diff --git a/src/Graphic3d/Graphic3d_AspectLine3d.cxx b/src/Graphic3d/Graphic3d_AspectLine3d.cxx index df1c48013e..38655d47d8 100644 --- a/src/Graphic3d/Graphic3d_AspectLine3d.cxx +++ b/src/Graphic3d/Graphic3d_AspectLine3d.cxx @@ -13,45 +13,35 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -//-Version -//-Design Declaration of variables specific to the context -// of tracing of lines 3d -//-Warning Context of tracing of lines 3d inherits the context -// defined by : -// - the color -// - the type of trait -// - the thickness -//-References -//-Language C++ 2.0 -//-Declarations -// for the class - #include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectLine3d,Aspect_AspectLine) - -//-Aliases -//-Global data definitions -//-Constructors -//-Destructors -//-Methods, in order -Graphic3d_AspectLine3d::Graphic3d_AspectLine3d () { -} - -// (AColor, AType, AWidth) -// because AspectLine3d inherits AspectLine and it is necessary to call -// initialisation of AspectLine with AColor, AType, AWidth. -Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& AColor, const Aspect_TypeOfLine AType, const Standard_Real AWidth):Aspect_AspectLine (AColor, AType, AWidth) {} +IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Standard_Transient) -void Graphic3d_AspectLine3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) +// ======================================================================= +// function : Graphic3d_AspectLine3d +// purpose : +// ======================================================================= +Graphic3d_AspectLine3d::Graphic3d_AspectLine3d() +: myColor (Quantity_NOC_YELLOW), + myType (Aspect_TOL_SOLID), + myWidth (1.0f) { - MyShaderProgram = theProgram; + // } -const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectLine3d::ShaderProgram() const +// ======================================================================= +// function : Graphic3d_AspectLine3d +// purpose : +// ======================================================================= +Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& theColor, + const Aspect_TypeOfLine theType, + const Standard_Real theWidth) +: myColor (theColor), + myType (theType), + myWidth ((float )theWidth) { - return MyShaderProgram; + if (myWidth <= 0.0f) + { + Aspect_AspectLineDefinitionError::Raise ("Graphic3d_AspectLine3d, Bad value for LineWidth"); + } } diff --git a/src/Graphic3d/Graphic3d_AspectLine3d.hxx b/src/Graphic3d/Graphic3d_AspectLine3d.hxx index 45dad22d3b..dfe513d617 100644 --- a/src/Graphic3d/Graphic3d_AspectLine3d.hxx +++ b/src/Graphic3d/Graphic3d_AspectLine3d.hxx @@ -16,49 +16,76 @@ #ifndef _Graphic3d_AspectLine3d_HeaderFile #define _Graphic3d_AspectLine3d_HeaderFile -#include -#include - -#include -#include +#include #include +#include +#include #include -class Quantity_Color; - - -class Graphic3d_AspectLine3d; -DEFINE_STANDARD_HANDLE(Graphic3d_AspectLine3d, Aspect_AspectLine) +#include +#include -//! Creates and updates a group of attributes -//! for 3d line primitives. This group contains the -//! colour, the type of line, and its thickness. -class Graphic3d_AspectLine3d : public Aspect_AspectLine +//! Creates and updates a group of attributes for 3d line primitives. +//! This group contains the color, the type of line, and its thickness. +class Graphic3d_AspectLine3d : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Standard_Transient) public: - //! Creates a context table for line primitives //! defined with the following default values: //! - //! Colour : NOC_YELLOW - //! Line type : TOL_SOLID - //! Width : 1.0 + //! Color = Quantity_NOC_YELLOW; + //! Type = Aspect_TOL_SOLID; + //! Width = 1.0; Standard_EXPORT Graphic3d_AspectLine3d(); - //! Creates a context table for line primitives - //! defined with the specified values. - //! Warning: is the "linewidth scale factor". - //! The nominal line width is 1 pixel. The width of - //! the line is determined by applying the linewidth scale - //! factor to this nominal line width. - //! The supported linewidths vary by 1-pixel units. - Standard_EXPORT Graphic3d_AspectLine3d(const Quantity_Color& AColor, const Aspect_TypeOfLine AType, const Standard_Real AWidth); - + //! Creates a context table for line primitives defined with the specified values. + //! Warning: theWidth is the "line width scale factor". + //! The nominal line width is 1 pixel. + //! The width of the line is determined by applying the line width scale factor to this nominal line width. + //! The supported line widths vary by 1-pixel units. + Standard_EXPORT Graphic3d_AspectLine3d (const Quantity_Color& theColor, + const Aspect_TypeOfLine theType, + const Standard_Real theWidth); + + //! Return color. + const Quantity_ColorRGBA& ColorRGBA() const { return myColor; } + + //! Return color. + const Quantity_Color& Color() const { return myColor.GetRGB(); } + + //! Modifies the color. + void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); } + + //! Return line type. + Aspect_TypeOfLine Type() const { return myType; } + + //! Modifies the type of line. + void SetType (const Aspect_TypeOfLine theType) { myType = theType; } + + //! Return line width. + Standard_ShortReal Width() const { return myWidth; } + + //! Modifies the line thickness. + //! Warning: Raises AspectLineDefinitionError if the width is a negative value. + void SetWidth (const Standard_Real theWidth) { SetWidth ((float )theWidth); } + + //! Modifies the line thickness. + //! Warning: Raises AspectLineDefinitionError if the width is a negative value. + void SetWidth (const Standard_ShortReal theWidth) + { + if (theWidth <= 0.0f) + { + Aspect_AspectLineDefinitionError::Raise ("Graphic3d_AspectLine3d, Bad value for LineWidth"); + } + myWidth = theWidth; + } + + //! Return shader program. + const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; } + //! Sets up OpenGL/GLSL shader program. - Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram); - - Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const; + void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; } //! Check for equality with another line aspect. bool IsEqual (const Graphic3d_AspectLine3d& theOther) @@ -68,32 +95,34 @@ public: return true; } - return MyShaderProgram == theOther.MyShaderProgram - && MyType == theOther.MyType - && MyColor == theOther.MyColor - && MyWidth == theOther.MyWidth; + return myProgram == theOther.myProgram + && myType == theOther.myType + && myColor == theOther.myColor + && myWidth == theOther.myWidth; } +public: - DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectLine3d,Aspect_AspectLine) + //! Returns the current values of the group. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Quantity_Color& theColor, + Aspect_TypeOfLine& theType, + Standard_Real& theWidth) const + { + theColor = myColor.GetRGB(); + theType = myType; + theWidth = myWidth; + } protected: - - - -private: - - - Handle(Graphic3d_ShaderProgram) MyShaderProgram; - + Handle(Graphic3d_ShaderProgram) myProgram; + Quantity_ColorRGBA myColor; + Aspect_TypeOfLine myType; + Standard_ShortReal myWidth; }; - - - - - +DEFINE_STANDARD_HANDLE(Graphic3d_AspectLine3d, Standard_Transient) #endif // _Graphic3d_AspectLine3d_HeaderFile diff --git a/src/Graphic3d/Graphic3d_AspectMarker3d.cxx b/src/Graphic3d/Graphic3d_AspectMarker3d.cxx index f0b24e67c3..141f9b4926 100644 --- a/src/Graphic3d/Graphic3d_AspectMarker3d.cxx +++ b/src/Graphic3d/Graphic3d_AspectMarker3d.cxx @@ -13,23 +13,21 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include -#include -#include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d,Aspect_AspectMarker) +IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient) // ======================================================================= // function : Graphic3d_AspectMarker3d // purpose : // ======================================================================= Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d() -: Aspect_AspectMarker() -{} +: myColor (Quantity_NOC_YELLOW), + myType (Aspect_TOM_X), + myScale (1.0f) +{ + // +} // ======================================================================= // function : Graphic3d_AspectMarker3d @@ -38,8 +36,15 @@ Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d() Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker theType, const Quantity_Color& theColor, const Standard_Real theScale) -: Aspect_AspectMarker (theColor, theType, theScale) -{} +: myColor (theColor), + myType (theType), + myScale ((float )theScale) +{ + if (theScale <= 0.0) + { + Aspect_AspectMarkerDefinitionError::Raise ("Bad value for MarkerScale"); + } +} // ======================================================================= // function : Graphic3d_AspectMarker3d @@ -49,18 +54,26 @@ Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Quantity_Color& theCo const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTextureBitMap) -: Aspect_AspectMarker (theColor, Aspect_TOM_USERDEFINED, 1.0), - myMarkerImage (new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight)) -{} +: myMarkerImage (new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight)), + myColor (theColor), + myType (Aspect_TOM_USERDEFINED), + myScale (1.0f) +{ + // +} // ======================================================================= // function : Graphic3d_AspectMarker3d // purpose : // ======================================================================= Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Handle(Image_PixMap)& theTextureImage) -: Aspect_AspectMarker (Quantity_NOC_YELLOW, Aspect_TOM_USERDEFINED, 1.0), - myMarkerImage (new Graphic3d_MarkerImage (theTextureImage)) -{} +: myMarkerImage (new Graphic3d_MarkerImage (theTextureImage)), + myColor (Quantity_NOC_YELLOW), + myType (Aspect_TOM_USERDEFINED), + myScale (1.0f) +{ + // +} // ======================================================================= // function : GetTextureSize @@ -80,24 +93,6 @@ void Graphic3d_AspectMarker3d::GetTextureSize (Standard_Integer& theWidth, } } -// ======================================================================= -// function : GetMarkerImage -// purpose : -// ======================================================================= -const Handle(Graphic3d_MarkerImage)& Graphic3d_AspectMarker3d::GetMarkerImage() const -{ - return myMarkerImage; -} - -// ======================================================================= -// function : SetMarkerImage -// purpose : -// ======================================================================= -void Graphic3d_AspectMarker3d::SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) -{ - myMarkerImage = theImage; -} - // ======================================================================= // function : SetBitMap // purpose : @@ -109,21 +104,3 @@ void Graphic3d_AspectMarker3d::SetBitMap (const Standard_Integer theWidth, myMarkerImage.Nullify(); myMarkerImage = new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight); } - -// ======================================================================= -// function : SetShaderProgram -// purpose : -// ======================================================================= -void Graphic3d_AspectMarker3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) -{ - MyShaderProgram = theProgram; -} - -// ======================================================================= -// function : ShaderProgram -// purpose : -// ======================================================================= -const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectMarker3d::ShaderProgram() const -{ - return MyShaderProgram; -} diff --git a/src/Graphic3d/Graphic3d_AspectMarker3d.hxx b/src/Graphic3d/Graphic3d_AspectMarker3d.hxx index 5945001a89..410f7d8b64 100644 --- a/src/Graphic3d/Graphic3d_AspectMarker3d.hxx +++ b/src/Graphic3d/Graphic3d_AspectMarker3d.hxx @@ -16,37 +16,30 @@ #ifndef _Graphic3d_AspectMarker3d_HeaderFile #define _Graphic3d_AspectMarker3d_HeaderFile -#include -#include - +#include +#include #include #include -#include -#include -#include +#include +#include #include +#include +#include #include -#include -class Quantity_Color; +#include - -class Graphic3d_AspectMarker3d; -DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Aspect_AspectMarker) - -//! Creates and updates an attribute group for -//! marker type primitives. This group contains the type -//! of marker, its colour, and its scale factor. -class Graphic3d_AspectMarker3d : public Aspect_AspectMarker +//! Creates and updates an attribute group for marker type primitives. +//! This group contains the type of marker, its color, and its scale factor. +class Graphic3d_AspectMarker3d : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient) public: - //! Creates a context table for marker primitives //! defined with the following default values: //! //! Marker type : TOM_X - //! Colour : YELLOW + //! Color : YELLOW //! Scale factor: 1.0 Standard_EXPORT Graphic3d_AspectMarker3d(); @@ -59,48 +52,82 @@ public: //! Creates a context table for marker primitives //! defined with the specified values. Standard_EXPORT Graphic3d_AspectMarker3d(const Handle(Image_PixMap)& theTextureImage); - - //! Returns marker's texture size. - Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const; - - //! Returns marker's image texture. - //! Could be null handle if marker aspect has been initialized as - //! default type of marker. - Standard_EXPORT const Handle(Graphic3d_MarkerImage)& GetMarkerImage() const; - - //! Set marker's image texture. - Standard_EXPORT void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage); - - Standard_EXPORT void SetBitMap (const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTexture); - - //! Sets up OpenGL/GLSL shader program. - Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram); - - Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const; - + //! Return color. + const Quantity_ColorRGBA& ColorRGBA() const { return myColor; } + //! Return the color. + const Quantity_Color& Color() const { return myColor.GetRGB(); } - DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d,Aspect_AspectMarker) + //! Modifies the color. + void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); } -protected: + //! Return scale factor. + Standard_ShortReal Scale() const { return myScale; } + //! Modifies the scale factor. + //! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor. + //! It is always the smallest displayable dot. + //! Warning: Raises AspectMarkerDefinitionError if the scale is a negative value. + void SetScale (const Standard_ShortReal theScale) + { + if (theScale <= 0.0f) + { + Aspect_AspectMarkerDefinitionError::Raise ("Bad value for MarkerScale"); + } + myScale = theScale; + } - Handle(Graphic3d_MarkerImage) myMarkerImage; + //! Assign scale factor. + void SetScale (const Standard_Real theScale) { SetScale ((float )theScale); } + //! Return marker type. + Aspect_TypeOfMarker Type() const { return myType; } -private: + //! Modifies the type of marker. + void SetType (const Aspect_TypeOfMarker theType) { myType = theType; } + //! Returns marker's texture size. + Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const; + + //! Returns marker's image texture. + //! Could be null handle if marker aspect has been initialized as default type of marker. + const Handle(Graphic3d_MarkerImage)& GetMarkerImage() const { return myMarkerImage; } + + //! Set marker's image texture. + void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; } - Handle(Graphic3d_ShaderProgram) MyShaderProgram; + Standard_EXPORT void SetBitMap (const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTexture); + //! Return the program. + const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; } -}; + //! Sets up OpenGL/GLSL shader program. + void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; } +public: + //! Returns the current values of the group. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Quantity_Color& theColor, + Aspect_TypeOfMarker& theType, + Standard_Real& theScale) const + { + theColor = myColor.GetRGB(); + theType = myType; + theScale = myScale; + } +protected: + Handle(Graphic3d_ShaderProgram) myProgram; + Handle(Graphic3d_MarkerImage) myMarkerImage; + Quantity_ColorRGBA myColor; + Aspect_TypeOfMarker myType; + Standard_ShortReal myScale; +}; +DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Standard_Transient) #endif // _Graphic3d_AspectMarker3d_HeaderFile diff --git a/src/Graphic3d/Graphic3d_AspectText3d.cxx b/src/Graphic3d/Graphic3d_AspectText3d.cxx index 00dfc9bcc5..0cfe9a5a75 100644 --- a/src/Graphic3d/Graphic3d_AspectText3d.cxx +++ b/src/Graphic3d/Graphic3d_AspectText3d.cxx @@ -13,229 +13,57 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// 30/11/98 ; FMN : S3819. Textes always visible. -//-Version -//-Design Declaration of variables specific to the context -// of trace of texts 3d -//-Warning A context of trace of text is defined by : -// - the font used -// - the color -// - the scale -// - the space between characters -//-References -//-Language C++ 2.0 -//-Declarations -// for the class - -#include #include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d,MMgt_TShared) - -//-Aliases -//-Global data definitions -// -- la font utilisee -// MyFont : NameOfFont; -// -- la couleur -// MyColor : Color; -// -- l'echelle -// MyFactor : Standard_Real; -// -- l'espace entre caracteres -// MySpace : Standard_Real; -// -- le style -// MyStyle : TypeOfStyleText; -// -- le display type -// MyDisplayType : TypeOfDisplayText; -// -- la couleur du sous-titrage et pour le fond en mode decalage. -// MyColorSubTitle : Color; -//-Constructors -//-Destructors -//-Methods, in order -Graphic3d_AspectText3d::Graphic3d_AspectText3d (): -MyFont (Font_NOF_ASCII_MONO), MyColor (Quantity_NOC_YELLOW), MyFactor (1.0), MySpace (0.0), MyStyle (Aspect_TOST_NORMAL), MyDisplayType (Aspect_TODT_NORMAL), MyColorSubTitle (Quantity_NOC_WHITE) { - MyTextZoomable = Standard_False; - MyTextAngle = 0.0; - MyTextFontAspect = Font_FA_Regular; -} - -Graphic3d_AspectText3d::Graphic3d_AspectText3d ( - const Quantity_Color& AColor, - const Standard_CString AFont, - const Standard_Real AFactor, - const Standard_Real ASpace, - const Aspect_TypeOfStyleText AStyle, - const Aspect_TypeOfDisplayText ADisplayType): -MyFont(AFont), MyColor (AColor), MyFactor (AFactor), MySpace (ASpace), MyStyle (AStyle), MyDisplayType(ADisplayType), MyColorSubTitle (Quantity_NOC_WHITE) { - MyTextZoomable = Standard_False; - MyTextAngle = 0.0; - MyTextFontAspect = Font_FA_Regular; - if(MyFont.Length() == 0) - MyFont.AssignCat(Font_NOF_ASCII_MONO); - - if (AFactor <= 0.0) - Graphic3d_AspectTextDefinitionError::Raise - ("Bad value for TextScaleFactor"); - -} - -void Graphic3d_AspectText3d::SetColor (const Quantity_Color& AColor) { - - MyColor = AColor; - -} - -void Graphic3d_AspectText3d::SetExpansionFactor (const Standard_Real AFactor) { - - if (AFactor <= 0.0) - Graphic3d_AspectTextDefinitionError::Raise - ("Bad value for TextScaleFactor"); - - MyFactor = AFactor; - -} - -void Graphic3d_AspectText3d::SetFont (const Standard_CString AFont) { - - - TCollection_AsciiString aTemp(""); - if( !strlen(AFont)) - aTemp.AssignCat(Font_NOF_ASCII_MONO); - else - aTemp.AssignCat(AFont); - MyFont = aTemp; -} - -void Graphic3d_AspectText3d::SetSpace (const Standard_Real ASpace) { - - MySpace = ASpace; - -} - -void Graphic3d_AspectText3d::SetStyle(const Aspect_TypeOfStyleText AStyle) { - - MyStyle = AStyle; - -} - -void Graphic3d_AspectText3d::SetDisplayType(const Aspect_TypeOfDisplayText ADisplayType) { - - MyDisplayType = ADisplayType; - -} - -void Graphic3d_AspectText3d::SetColorSubTitle (const Quantity_Color& AColor) { - - MyColorSubTitle = AColor; - - -} - - -void Graphic3d_AspectText3d::SetTextZoomable(const Standard_Boolean AFlag) -{ - - MyTextZoomable = AFlag; - -} - -Standard_Boolean Graphic3d_AspectText3d::GetTextZoomable() const -{ - return MyTextZoomable; -} - -void Graphic3d_AspectText3d::SetTextAngle(const Standard_Real AAngle) -{ - MyTextAngle = AAngle; -} - -Standard_Real Graphic3d_AspectText3d::GetTextAngle() const -{ - return MyTextAngle; -} - -void Graphic3d_AspectText3d::SetTextFontAspect(const Font_FontAspect AFontAspect) -{ - MyTextFontAspect = AFontAspect; -} - -Font_FontAspect Graphic3d_AspectText3d::GetTextFontAspect() const -{ - return MyTextFontAspect; -} - - -void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace) const { - - AColor = MyColor; - AFont = MyFont.ToCString(); - AFactor = MyFactor; - ASpace = MySpace; - -} -void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle,Aspect_TypeOfDisplayText& ADisplayType,Quantity_Color& AColorSubTitle) const { - - AColor = MyColor; - AFont = MyFont.ToCString(); - AFactor = MyFactor; - ASpace = MySpace; - AStyle = MyStyle; - ADisplayType = MyDisplayType; - AColorSubTitle = MyColorSubTitle; - -} -void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle,Aspect_TypeOfDisplayText& ADisplayType,Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable,Standard_Real& ATextAngle ) const { - - AColor = MyColor; - AFont = MyFont.ToCString(); - AFactor = MyFactor; - ASpace = MySpace; - AStyle = MyStyle; - ADisplayType = MyDisplayType; - AColorSubTitle = MyColorSubTitle; - - ATextZoomable = MyTextZoomable; - ATextAngle = MyTextAngle; - -} - -void Graphic3d_AspectText3d::Values ( Quantity_Color& AColor, - Standard_CString& AFont, - Standard_Real& AFactor, - Standard_Real& ASpace, - Aspect_TypeOfStyleText& AStyle, - Aspect_TypeOfDisplayText& ADisplayType, - Quantity_Color& AColorSubTitle, - Standard_Boolean& ATextZoomable, - Standard_Real& ATextAngle, - Font_FontAspect& ATextFontAspect ) const -{ - - AColor = MyColor; - AFont = MyFont.ToCString(); - AFactor = MyFactor; - ASpace = MySpace; - AStyle = MyStyle; - ADisplayType = MyDisplayType; - AColorSubTitle = MyColorSubTitle; - - ATextZoomable = MyTextZoomable; - ATextAngle = MyTextAngle; - ATextFontAspect = MyTextFontAspect; - -} - -void Graphic3d_AspectText3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) +IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient) + +// ======================================================================= +// function : Graphic3d_AspectText3d +// purpose : +// ======================================================================= +Graphic3d_AspectText3d::Graphic3d_AspectText3d() +: myFont (Font_NOF_ASCII_MONO), + myColor (Quantity_NOC_YELLOW), + myFactor (1.0), + mySpace (0.0), + myStyle (Aspect_TOST_NORMAL), + myDisplayType (Aspect_TODT_NORMAL), + myColorSubTitle (Quantity_NOC_WHITE), + myTextZoomable (false), + myTextAngle (0.0), + myTextFontAspect(Font_FA_Regular) { - MyShaderProgram = theProgram; -} - -const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectText3d::ShaderProgram() const + // +} + +// ======================================================================= +// function : Graphic3d_AspectText3d +// purpose : +// ======================================================================= +Graphic3d_AspectText3d::Graphic3d_AspectText3d (const Quantity_Color& theColor, + const Standard_CString theFont, + const Standard_Real theExpansionFactor, + const Standard_Real theSpace, + const Aspect_TypeOfStyleText theStyle, + const Aspect_TypeOfDisplayText theDisplayType) +: myFont (theFont), + myColor (theColor), + myFactor (theExpansionFactor), + mySpace (theSpace), + myStyle (theStyle), + myDisplayType (theDisplayType), + myColorSubTitle (Quantity_NOC_WHITE), + myTextZoomable (false), + myTextAngle (0.0), + myTextFontAspect(Font_FA_Regular) { - return MyShaderProgram; + if (myFont.IsEmpty()) + { + myFont = Font_NOF_ASCII_MONO; + } + + if (theExpansionFactor <= 0.0) + { + Graphic3d_AspectTextDefinitionError::Raise ("Bad value for TextScaleFactor"); + } } diff --git a/src/Graphic3d/Graphic3d_AspectText3d.hxx b/src/Graphic3d/Graphic3d_AspectText3d.hxx index 4bb65b4537..2d480c5b06 100644 --- a/src/Graphic3d/Graphic3d_AspectText3d.hxx +++ b/src/Graphic3d/Graphic3d_AspectText3d.hxx @@ -16,28 +16,22 @@ #ifndef _Graphic3d_AspectText3d_HeaderFile #define _Graphic3d_AspectText3d_HeaderFile -#include -#include - -#include -#include -#include #include #include -#include -#include +#include #include +#include +#include #include -#include -class Graphic3d_AspectTextDefinitionError; -class Quantity_Color; - - -class Graphic3d_AspectText3d; -DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, MMgt_TShared) +#include +#include +#include +#include +#include +#include //! Creates and updates a group of attributes for -//! text primitives. This group contains the colour, +//! text primitives. This group contains the color, //! font, expansion factor (height/width ratio), and //! inter-character space. //! @@ -46,52 +40,91 @@ DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, MMgt_TShared) //! without copying the string. However, the aspect should not //! be deleted until the text drawn using this aspect is no longer //! visible. The best practice is to keep the aspect in the object's drawer. -class Graphic3d_AspectText3d : public MMgt_TShared +class Graphic3d_AspectText3d : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient) public: - //! Creates a context table for text primitives //! defined with the following default values: //! - //! Colour : NOC_YELLOW + //! Color : NOC_YELLOW //! Font : NOF_ASCII_MONO //! Expansion factor : 1. //! Space between characters : 0. //! The style : TOST_NORMAL //! The display type : TODT_NORMAL Standard_EXPORT Graphic3d_AspectText3d(); - + //! Creates a context table for text primitives //! defined with the specified values. //! AFont may be to take means from User(example "Courier New") //! or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO) //! or use default font("Courier") - Standard_EXPORT Graphic3d_AspectText3d(const Quantity_Color& AColor, const Standard_CString AFont, const Standard_Real AExpansionFactor, const Standard_Real ASpace, const Aspect_TypeOfStyleText AStyle = Aspect_TOST_NORMAL, const Aspect_TypeOfDisplayText ADisplayType = Aspect_TODT_NORMAL); - - //! Modifies the colour of . - Standard_EXPORT void SetColor (const Quantity_Color& AColor); - + Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor, + const Standard_CString theFont, + const Standard_Real theExpansionFactor, + const Standard_Real theSpace, + const Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL, + const Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL); + + //! Return the text color. + const Quantity_Color& Color() const { return myColor.GetRGB(); } + + //! Return the text color. + const Quantity_ColorRGBA& ColorRGBA() const { return myColor; } + + //! Modifies the color. + void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); } + //! Modifies the expansion factor (height/width ratio) //! If the factor is less than 1, the characters will //! be higher than they are wide. - Standard_EXPORT void SetExpansionFactor (const Standard_Real AFactor); - - //! Modifies the font of . - Standard_EXPORT void SetFont (const Standard_CString AFont); - + void SetExpansionFactor (const Standard_Real theFactor) + { + if (theFactor <= 0.0) + { + Graphic3d_AspectTextDefinitionError::Raise ("Bad value for TextScaleFactor"); + } + myFactor = theFactor; + } + + //! Return the font. + const TCollection_AsciiString& Font() const { return myFont; } + + //! Modifies the font. + void SetFont (const TCollection_AsciiString& theFont) + { + myFont = !theFont.IsEmpty() ? theFont : TCollection_AsciiString (Font_NOF_ASCII_MONO); + } + + //! Modifies the font. + void SetFont (const Standard_CString theFont) + { + SetFont (TCollection_AsciiString (theFont)); + } + + //! Return the space between characters. + Standard_Real Space() const { return mySpace; } + //! Modifies the space between the characters. - Standard_EXPORT void SetSpace (const Standard_Real ASpace); - + void SetSpace (const Standard_Real theSpace) { mySpace = theSpace; } + + //! Return the text style. + Aspect_TypeOfStyleText Style() const { return myStyle; } + //! Modifies the style of the text. - //! TOST_NORMAL Default text. The text is displayed like any other graphic object. - //! This text can be hidden by another object that is nearest from the - //! point of view. - //! TOST_ANNOTATION The text is always visible. The texte is displayed - //! over the other object according to the priority. - Standard_EXPORT void SetStyle (const Aspect_TypeOfStyleText AStyle); - + //! * TOST_NORMAL + //! Default text. The text is displayed like any other graphic object. + //! This text can be hidden by another object that is nearest from the point of view. + //! * TOST_ANNOTATION + //! The text is always visible. + //! The text is displayed over the other object according to the priority. + void SetStyle (const Aspect_TypeOfStyleText theStyle) { myStyle = theStyle; } + + //! Return display type. + Aspect_TypeOfDisplayText DisplayType() const { return myDisplayType; } + //! Define the display type of the text. //! //! TODT_NORMAL Default display. Text only. @@ -99,79 +132,142 @@ public: //! TODT_DEKALE The text is displayed with a 3D style. //! TODT_BLEND The text is displayed in XOR. //! TODT_DIMENSION Dimension line under text will be invisible. - Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText ADisplayType); - - //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType - //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType. - Standard_EXPORT void SetColorSubTitle (const Quantity_Color& AColor); - - //! Turns usage of text zoomable on/off - Standard_EXPORT void SetTextZoomable (const Standard_Boolean AFlag); - - //! Returns TRUE when the Text Zoomable is on. - Standard_EXPORT Standard_Boolean GetTextZoomable() const; - - //! Turns usage of text rotated - Standard_EXPORT void SetTextAngle (const Standard_Real AAngle); - - //! Returns Angle of degree - Standard_EXPORT Standard_Real GetTextAngle() const; - - //! Turns usage of Aspect text - Standard_EXPORT void SetTextFontAspect (const Font_FontAspect AFontAspect); - - //! Returns text FontAspect - Standard_EXPORT Font_FontAspect GetTextFontAspect() const; - - //! Sets up OpenGL/GLSL shader program. - Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram); - - //! Returns the current values of the group . - Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace) const; - - //! Returns the current values of the group . - Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle, Aspect_TypeOfDisplayText& ADisplayType, Quantity_Color& AColorSubTitle) const; - - //! Returns the current values of the group . - Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle, Aspect_TypeOfDisplayText& ADisplayType, Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable, Standard_Real& ATextAngle) const; - - //! Returns the current values of the group . - Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle, Aspect_TypeOfDisplayText& ADisplayType, Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable, Standard_Real& ATextAngle, Font_FontAspect& ATextFontAspect) const; - - Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const; + void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType) { myDisplayType = theDisplayType; } + //! Return subtitle color. + const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myColorSubTitle; } + //! Return subtitle color. + const Quantity_Color& ColorSubTitle() const { return myColorSubTitle.GetRGB(); } + //! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType + //! and the color of background for the TODT_DEKALE TextDisplayType. + void SetColorSubTitle (const Quantity_Color& theColor) { myColorSubTitle.SetRGB (theColor); } - DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d,MMgt_TShared) + //! Returns TRUE when the Text Zoomable is on. + bool GetTextZoomable() const { return myTextZoomable; } -protected: + //! Turns usage of text zoomable on/off + void SetTextZoomable (const bool theFlag) { myTextZoomable = theFlag; } + //! Returns Angle of degree + Standard_Real GetTextAngle() const { return myTextAngle; } + //! Turns usage of text rotated + void SetTextAngle (const Standard_Real theAngle) { myTextAngle = theAngle; } + //! Returns text FontAspect + Font_FontAspect GetTextFontAspect() const { return myTextFontAspect; } -private: + //! Turns usage of Aspect text + void SetTextFontAspect (const Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; } + //! Return the shader program. + const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; } - TCollection_AsciiString MyFont; - Quantity_Color MyColor; - Standard_Real MyFactor; - Standard_Real MySpace; - Aspect_TypeOfStyleText MyStyle; - Aspect_TypeOfDisplayText MyDisplayType; - Quantity_Color MyColorSubTitle; - Standard_Boolean MyTextZoomable; - Standard_Real MyTextAngle; - Font_FontAspect MyTextFontAspect; - Handle(Graphic3d_ShaderProgram) MyShaderProgram; + //! Sets up OpenGL/GLSL shader program. + void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; } +public: -}; + //! Returns the current values of the group. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Quantity_Color& theColor, + Standard_CString& theFont, + Standard_Real& theExpansionFactor, + Standard_Real& theSpace) const + { + theColor = myColor.GetRGB(); + theFont = myFont.ToCString(); + theExpansionFactor = myFactor; + theSpace = mySpace; + } + + //! Returns the current values of the group. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Quantity_Color& theColor, + Standard_CString& theFont, + Standard_Real& theExpansionFactor, + Standard_Real& theSpace, + Aspect_TypeOfStyleText& theStyle, + Aspect_TypeOfDisplayText& theDisplayType, + Quantity_Color& theColorSubTitle) const + { + theColor = myColor.GetRGB(); + theFont = myFont.ToCString(); + theExpansionFactor= myFactor; + theSpace = mySpace; + theStyle = myStyle; + theDisplayType = myDisplayType; + theColorSubTitle = myColorSubTitle.GetRGB(); + } + + //! Returns the current values of the group. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Quantity_Color& theColor, + Standard_CString& theFont, + Standard_Real& theExpansionFactor, + Standard_Real& theSpace, + Aspect_TypeOfStyleText& theStyle, + Aspect_TypeOfDisplayText& theDisplayType, + Quantity_Color& theColorSubTitle, + Standard_Boolean& theTextZoomable, + Standard_Real& theTextAngle) const + { + theColor = myColor.GetRGB(); + theFont = myFont.ToCString(); + theExpansionFactor= myFactor; + theSpace = mySpace; + theStyle = myStyle; + theDisplayType = myDisplayType; + theColorSubTitle = myColorSubTitle.GetRGB(); + theTextZoomable = myTextZoomable; + theTextAngle = myTextAngle; + } + //! Returns the current values of the group. + Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters") + void Values (Quantity_Color& theColor, + Standard_CString& theFont, + Standard_Real& theExpansionFactor, + Standard_Real& theSpace, + Aspect_TypeOfStyleText& theStyle, + Aspect_TypeOfDisplayText& theDisplayType, + Quantity_Color& theColorSubTitle, + Standard_Boolean& theTextZoomable, + Standard_Real& theTextAngle, + Font_FontAspect& theTextFontAspect) const + { + theColor = myColor.GetRGB(); + theFont = myFont.ToCString(); + theExpansionFactor= myFactor; + theSpace = mySpace; + theStyle = myStyle; + theDisplayType = myDisplayType; + theColorSubTitle = myColorSubTitle.GetRGB(); + theTextZoomable = myTextZoomable; + theTextAngle = myTextAngle; + theTextFontAspect = myTextFontAspect; + } +protected: + + TCollection_AsciiString myFont; + Quantity_ColorRGBA myColor; + Standard_Real myFactor; + Standard_Real mySpace; + Aspect_TypeOfStyleText myStyle; + Aspect_TypeOfDisplayText myDisplayType; + Quantity_ColorRGBA myColorSubTitle; + bool myTextZoomable; + Standard_Real myTextAngle; + Font_FontAspect myTextFontAspect; + Handle(Graphic3d_ShaderProgram) myProgram; +}; +DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Standard_Transient) #endif // _Graphic3d_AspectText3d_HeaderFile diff --git a/src/Graphic3d/Graphic3d_CAspectFillArea.hxx b/src/Graphic3d/Graphic3d_CAspectFillArea.hxx deleted file mode 100644 index ad29d59f45..0000000000 --- a/src/Graphic3d/Graphic3d_CAspectFillArea.hxx +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Graphic3d_CAspectFillArea_HeaderFile -#define _Graphic3d_CAspectFillArea_HeaderFile - -#include -#include -#include - -class Graphic3d_CAspectFillArea -{ - -public: - - Graphic3d_CAspectFillArea() - : IsDef (0), - IsSet (0), - Style (0), - LineType (0), - Width (0.0f), - Hatch (0), - Distinguish (0), - BackFace (0), - Edge (0), - PolygonOffsetMode (0), - PolygonOffsetFactor (0.0f), - PolygonOffsetUnits (0.0f) - { - memset (&IntColor, 0, sizeof(IntColor)); - memset (&BackIntColor, 0, sizeof(BackIntColor)); - memset (&EdgeColor, 0, sizeof(EdgeColor)); - memset (&Front, 0, sizeof(Front)); - memset (&Back, 0, sizeof(Back)); - } - -public: - - int IsDef; - int IsSet; - int Style; - - CALL_DEF_COLOR IntColor; - CALL_DEF_COLOR BackIntColor; - CALL_DEF_COLOR EdgeColor; - - int LineType; - - float Width; - - int Hatch; - - int Distinguish; - int BackFace; - - int Edge; - - CALL_DEF_MATERIAL Front; - CALL_DEF_MATERIAL Back; - - Graphic3d_CTexture Texture; - - int PolygonOffsetMode; - float PolygonOffsetFactor; - float PolygonOffsetUnits; - - Handle(Graphic3d_ShaderProgram) ShaderProgram; - -}; - -typedef Graphic3d_CAspectFillArea CALL_DEF_CONTEXTFILLAREA; - -#endif // _Graphic3d_CAspectFillArea_HeaderFile diff --git a/src/Graphic3d/Graphic3d_CAspectMarker.hxx b/src/Graphic3d/Graphic3d_CAspectMarker.hxx deleted file mode 100644 index 3378f15ad9..0000000000 --- a/src/Graphic3d/Graphic3d_CAspectMarker.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Graphic3d_CAspectMarker_HeaderFile -#define _Graphic3d_CAspectMarker_HeaderFile - -#include -#include -#include -#include -#include - -class Graphic3d_CAspectMarker -{ -public: - - Graphic3d_CAspectMarker() - : IsDef (0), - IsSet (0), - MarkerType (Aspect_TOM_POINT), - Scale (0) - { - memset (&Color, 0, sizeof(Color)); - } - -public: - - Standard_Integer IsDef; - Standard_Integer IsSet; - CALL_DEF_COLOR Color; - Aspect_TypeOfMarker MarkerType; - Standard_ShortReal Scale; - Handle(Graphic3d_MarkerImage) MarkerImage; - Handle(Graphic3d_ShaderProgram) ShaderProgram; - -}; - -typedef Graphic3d_CAspectMarker CALL_DEF_CONTEXTMARKER; - -#endif // _Graphic3d_AspectMarker_HeaderFile diff --git a/src/Graphic3d/Graphic3d_CAspectText.hxx b/src/Graphic3d/Graphic3d_CAspectText.hxx deleted file mode 100644 index 572e5beaf1..0000000000 --- a/src/Graphic3d/Graphic3d_CAspectText.hxx +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Graphic3d_CAspectText_HeaderFile -#define _Graphic3d_CAspectText_HeaderFile - -#include -#include -#include - -class Graphic3d_CAspectText -{ -public: - - int IsDef; - int IsSet; - const char* Font; - float Space; - float Expan; - CALL_DEF_COLOR Color; - int Style; - int DisplayType; - CALL_DEF_COLOR ColorSubTitle; - int TextZoomable; - float TextAngle; - int TextFontAspect; - Handle(Graphic3d_ShaderProgram) ShaderProgram; - -}; - -typedef Graphic3d_CAspectText CALL_DEF_CONTEXTTEXT; - -#endif // _Graphic3d_CAspectText_HeaderFile diff --git a/src/Graphic3d/Graphic3d_CLight.hxx b/src/Graphic3d/Graphic3d_CLight.hxx index c11200bd90..c1d16cc5b3 100644 --- a/src/Graphic3d/Graphic3d_CLight.hxx +++ b/src/Graphic3d/Graphic3d_CLight.hxx @@ -16,7 +16,6 @@ #include #include -#include #include //! Light definition diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index 5735fc9587..5040ac5ce3 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -24,7 +24,6 @@ #include #include #include -#include class Graphic3d_GraphicDriver; class Graphic3d_StructureManager; @@ -119,7 +118,7 @@ public: int Priority; int PreviousPriority; - CALL_DEF_COLOR HighlightColor; + Quantity_Color HighlightColor; Graphic3d_Mat4 Transformation; diff --git a/src/Graphic3d/Graphic3d_ClipPlane.cxx b/src/Graphic3d/Graphic3d_ClipPlane.cxx index 7b5b54c443..46bff71527 100755 --- a/src/Graphic3d/Graphic3d_ClipPlane.cxx +++ b/src/Graphic3d/Graphic3d_ClipPlane.cxx @@ -236,10 +236,7 @@ Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const anAspect->SetHatchStyle (myHatch); anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID); anAspect->SetInteriorColor (myMaterial.Color()); - if (!myTexture.IsNull()) - anAspect->SetTextureMapOn(); - else - anAspect->SetTextureMapOff(); - + anAspect->SetSuppressBackFaces (false); + anAspect->SetTextureMap (!myTexture.IsNull()); return anAspect; } diff --git a/src/Graphic3d/Graphic3d_Group.cxx b/src/Graphic3d/Graphic3d_Group.cxx index c4d99e1112..26aa68ccc9 100644 --- a/src/Graphic3d/Graphic3d_Group.cxx +++ b/src/Graphic3d/Graphic3d_Group.cxx @@ -63,17 +63,7 @@ Graphic3d_Group::Graphic3d_Group (const Handle(Graphic3d_Structure)& theStruct) myStructure = theStruct.operator->(); - MyContainsFacet = Standard_False, - - ContextLine.IsDef = 0; - ContextText.IsDef = 0; - ContextMarker.IsDef = 0; - ContextFillArea.IsDef = 0; - - ContextLine.IsSet = 0; - ContextText.IsSet = 0; - ContextMarker.IsSet = 0; - ContextFillArea.IsSet = 0; + MyContainsFacet = Standard_False; } // ======================================================================= @@ -87,16 +77,6 @@ void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr) return; } - ContextLine.IsSet = 0, - ContextText.IsSet = 0, - ContextMarker.IsSet = 0, - ContextFillArea.IsSet = 0; - - ContextLine.IsDef = 0, - ContextText.IsDef = 0, - ContextMarker.IsDef = 0, - ContextFillArea.IsDef = 0; - myBounds.Clear(); if (MyContainsFacet) @@ -264,536 +244,6 @@ void Graphic3d_Group::Update() const myStructure->StructureManager()->Update (myStructure->StructureManager()->UpdateMode()); } -// ======================================================================= -// function : SetGroupPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real aWidth; - Quantity_Color aColor; - Aspect_TypeOfLine aLType; - theAspLine->Values (aColor, aLType, aWidth); - - ContextLine.IsDef = 1; - ContextLine.Color.r = float (aColor.Red()); - ContextLine.Color.g = float (aColor.Green()); - ContextLine.Color.b = float (aColor.Blue()); - ContextLine.LineType = aLType; - ContextLine.Width = float (aWidth); - ContextLine.ShaderProgram = theAspLine->ShaderProgram(); - - UpdateAspectLine (Standard_True); - - ContextLine.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetGroupPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real anRGB[3]; - Standard_Real aWidth; - Quantity_Color anIntColor; - Quantity_Color aBackIntColor; - Quantity_Color anEdgeColor; - Aspect_TypeOfLine aLType; - Aspect_InteriorStyle aStyle; - theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth); - - anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB); - ContextFillArea.Style = aStyle; - ContextFillArea.IntColor.r = float (anRGB[0]); - ContextFillArea.IntColor.g = float (anRGB[1]); - ContextFillArea.IntColor.b = float (anRGB[2]); - - if (theAspFill->Distinguish()) - { - aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB); - } - ContextFillArea.BackIntColor.r = float (anRGB[0]); - ContextFillArea.BackIntColor.g = float (anRGB[1]); - ContextFillArea.BackIntColor.b = float (anRGB[2]); - - // Edges - ContextFillArea.Edge = theAspFill->Edge() ? 1 : 0; - ContextFillArea.EdgeColor.r = float (anEdgeColor.Red()); - ContextFillArea.EdgeColor.g = float (anEdgeColor.Green()); - ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue()); - ContextFillArea.LineType = aLType; - ContextFillArea.Width = float (aWidth); - ContextFillArea.Hatch = theAspFill->HatchStyle(); - - // Front and Back face - ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0; - ContextFillArea.BackFace = theAspFill->BackFace() ? 1 : 0; - - // Back Material - const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial(); - - // Material properties - ContextFillArea.Back.Shininess = float (aBack.Shininess()); - ContextFillArea.Back.Ambient = float (aBack.Ambient()); - ContextFillArea.Back.Diffuse = float (aBack.Diffuse()); - ContextFillArea.Back.Specular = float (aBack.Specular()); - ContextFillArea.Back.Transparency = float (aBack.Transparency()); - ContextFillArea.Back.Emission = float (aBack.Emissive()); - ContextFillArea.Back.RefractionIndex = float (aBack.RefractionIndex()); - ContextFillArea.Back.BSDF = aBack.BSDF(); - - // Reflection mode - ContextFillArea.Back.IsAmbient = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0; - ContextFillArea.Back.IsDiffuse = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0; - ContextFillArea.Back.IsSpecular = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0; - ContextFillArea.Back.IsEmission = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0; - - // Material type - ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0; - - // Specular color - ContextFillArea.Back.ColorSpec.r = float (aBack.SpecularColor().Red()); - ContextFillArea.Back.ColorSpec.g = float (aBack.SpecularColor().Green()); - ContextFillArea.Back.ColorSpec.b = float (aBack.SpecularColor().Blue()); - - // Ambient color - ContextFillArea.Back.ColorAmb.r = float (aBack.AmbientColor().Red()); - ContextFillArea.Back.ColorAmb.g = float (aBack.AmbientColor().Green()); - ContextFillArea.Back.ColorAmb.b = float (aBack.AmbientColor().Blue()); - - // Diffuse color - ContextFillArea.Back.ColorDif.r = float (aBack.DiffuseColor().Red()); - ContextFillArea.Back.ColorDif.g = float (aBack.DiffuseColor().Green()); - ContextFillArea.Back.ColorDif.b = float (aBack.DiffuseColor().Blue()); - - // Emissive color - ContextFillArea.Back.ColorEms.r = float (aBack.EmissiveColor().Red()); - ContextFillArea.Back.ColorEms.g = float (aBack.EmissiveColor().Green()); - ContextFillArea.Back.ColorEms.b = float (aBack.EmissiveColor().Blue()); - - ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion()); - - // Front Material - const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial(); - - // Material properties - ContextFillArea.Front.Shininess = float (aFront.Shininess()); - ContextFillArea.Front.Ambient = float (aFront.Ambient()); - ContextFillArea.Front.Diffuse = float (aFront.Diffuse()); - ContextFillArea.Front.Specular = float (aFront.Specular()); - ContextFillArea.Front.Transparency = float (aFront.Transparency()); - ContextFillArea.Front.Emission = float (aFront.Emissive()); - ContextFillArea.Front.RefractionIndex = float (aFront.RefractionIndex()); - ContextFillArea.Front.BSDF = aFront.BSDF(); - - // Reflection mode - ContextFillArea.Front.IsAmbient = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0; - ContextFillArea.Front.IsDiffuse = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0; - ContextFillArea.Front.IsSpecular = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0; - ContextFillArea.Front.IsEmission = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0; - - // Material type - ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0; - - // Specular color - ContextFillArea.Front.ColorSpec.r = float (aFront.SpecularColor().Red()); - ContextFillArea.Front.ColorSpec.g = float (aFront.SpecularColor().Green()); - ContextFillArea.Front.ColorSpec.b = float (aFront.SpecularColor().Blue()); - - // Ambient color - ContextFillArea.Front.ColorAmb.r = float (aFront.AmbientColor().Red()); - ContextFillArea.Front.ColorAmb.g = float (aFront.AmbientColor().Green()); - ContextFillArea.Front.ColorAmb.b = float (aFront.AmbientColor().Blue()); - - // Diffuse color - ContextFillArea.Front.ColorDif.r = float (aFront.DiffuseColor().Red()); - ContextFillArea.Front.ColorDif.g = float (aFront.DiffuseColor().Green()); - ContextFillArea.Front.ColorDif.b = float (aFront.DiffuseColor().Blue()); - - // Emissive color - ContextFillArea.Front.ColorEms.r = float (aFront.EmissiveColor().Red()); - ContextFillArea.Front.ColorEms.g = float (aFront.EmissiveColor().Green()); - ContextFillArea.Front.ColorEms.b = float (aFront.EmissiveColor().Blue()); - - ContextFillArea.Front.EnvReflexion = float (aFront.EnvReflexion()); - - ContextFillArea.IsDef = 1; // Definition material ok - - // Texture map - ContextFillArea.Texture.TextureMap = theAspFill->TextureMap(); - ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0; - - Standard_Integer aPolyMode; - Standard_ShortReal aPolyFactor, aPolyUnits; - theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits); - ContextFillArea.PolygonOffsetMode = aPolyMode; - ContextFillArea.PolygonOffsetFactor = aPolyFactor; - ContextFillArea.PolygonOffsetUnits = aPolyUnits; - - ContextFillArea.ShaderProgram = theAspFill->ShaderProgram(); - - UpdateAspectFace (Standard_True); - - ContextFillArea.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetGroupPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real aScale; - Quantity_Color aColor; - Aspect_TypeOfMarker aMarkerType; - theAspMarker->Values (aColor, aMarkerType, aScale); - - ContextMarker.IsDef = 1; - ContextMarker.Color.r = Standard_ShortReal (aColor.Red()); - ContextMarker.Color.g = Standard_ShortReal (aColor.Green()); - ContextMarker.Color.b = Standard_ShortReal (aColor.Blue()); - ContextMarker.MarkerType = aMarkerType; - ContextMarker.Scale = Standard_ShortReal (aScale); - ContextMarker.MarkerImage = theAspMarker->GetMarkerImage(); - ContextMarker.ShaderProgram = theAspMarker->ShaderProgram(); - - UpdateAspectMarker (Standard_True); - - ContextMarker.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetGroupPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real anExpansion, aSpace, aTextAngle; - Quantity_Color aColor, aColorSubTitle; - Standard_CString aFont; - Aspect_TypeOfStyleText aStyle; - Aspect_TypeOfDisplayText aDisplayType; - Standard_Boolean isTextZoomable; - Font_FontAspect aTextFontAspect; - theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType, - aColorSubTitle, isTextZoomable, aTextAngle, aTextFontAspect); - - ContextText.IsDef = 1; - ContextText.Color.r = float (aColor.Red()); - ContextText.Color.g = float (aColor.Green()); - ContextText.Color.b = float (aColor.Blue()); - ContextText.Font = (char* )aFont; - ContextText.Expan = float (anExpansion); - ContextText.Space = float (aSpace); - ContextText.Style = aStyle; - ContextText.DisplayType = aDisplayType; - ContextText.ColorSubTitle.r = float (aColorSubTitle.Red()); - ContextText.ColorSubTitle.g = float (aColorSubTitle.Green()); - ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue()); - ContextText.TextZoomable = isTextZoomable; - ContextText.TextAngle = float (aTextAngle); - ContextText.TextFontAspect = aTextFontAspect; - ContextText.ShaderProgram = theAspText->ShaderProgram(); - - UpdateAspectText (Standard_True); - - ContextText.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real aWidth; - Quantity_Color aColor; - Aspect_TypeOfLine aLType; - theAspLine->Values (aColor, aLType, aWidth); - - ContextLine.IsDef = 1; - ContextLine.Color.r = float (aColor.Red()); - ContextLine.Color.g = float (aColor.Green()); - ContextLine.Color.b = float (aColor.Blue()); - ContextLine.LineType = aLType; - ContextLine.Width = float (aWidth); - ContextLine.ShaderProgram = theAspLine->ShaderProgram(); - - UpdateAspectLine (Standard_False); - - ContextLine.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real anRGB[3]; - Standard_Real aWidth; - Quantity_Color anIntColor; - Quantity_Color aBackIntColor; - Quantity_Color anEdgeColor; - Aspect_TypeOfLine aLType; - Aspect_InteriorStyle aStyle; - theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth); - - anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB); - ContextFillArea.Style = aStyle; - ContextFillArea.IntColor.r = float (anRGB[0]); - ContextFillArea.IntColor.g = float (anRGB[1]); - ContextFillArea.IntColor.b = float (anRGB[2]); - - if (theAspFill->Distinguish()) - { - aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB); - } - ContextFillArea.BackIntColor.r = float(anRGB[0]); - ContextFillArea.BackIntColor.g = float(anRGB[1]); - ContextFillArea.BackIntColor.b = float(anRGB[2]); - - // Edges - ContextFillArea.Edge = theAspFill->Edge() ? 1 : 0; - ContextFillArea.EdgeColor.r = float (anEdgeColor.Red()); - ContextFillArea.EdgeColor.g = float (anEdgeColor.Green()); - ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue()); - ContextFillArea.LineType = aLType; - ContextFillArea.Width = float (aWidth); - ContextFillArea.Hatch = theAspFill->HatchStyle(); - - // Front and Back face - ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0; - ContextFillArea.BackFace = theAspFill->BackFace() ? 1 : 0; - - // Back Material - const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial(); - // Material state - ContextFillArea.Back.Shininess = float (aBack.Shininess()); - ContextFillArea.Back.Ambient = float (aBack.Ambient()); - ContextFillArea.Back.Diffuse = float (aBack.Diffuse()); - ContextFillArea.Back.Specular = float (aBack.Specular()); - ContextFillArea.Back.Transparency = float (aBack.Transparency()); - ContextFillArea.Back.Emission = float (aBack.Emissive()); - - // Reflection mode - ContextFillArea.Back.IsAmbient = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0; - ContextFillArea.Back.IsDiffuse = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0; - ContextFillArea.Back.IsSpecular = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0; - ContextFillArea.Back.IsEmission = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0; - - // Material type - ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0; - - // Specular color - ContextFillArea.Back.ColorSpec.r = float (aBack.SpecularColor().Red()); - ContextFillArea.Back.ColorSpec.g = float (aBack.SpecularColor().Green()); - ContextFillArea.Back.ColorSpec.b = float (aBack.SpecularColor().Blue()); - - // Ambient color - ContextFillArea.Back.ColorAmb.r = float (aBack.AmbientColor().Red()); - ContextFillArea.Back.ColorAmb.g = float (aBack.AmbientColor().Green()); - ContextFillArea.Back.ColorAmb.b = float (aBack.AmbientColor().Blue()); - - // Diffuse color - ContextFillArea.Back.ColorDif.r = float (aBack.DiffuseColor().Red()); - ContextFillArea.Back.ColorDif.g = float (aBack.DiffuseColor().Green()); - ContextFillArea.Back.ColorDif.b = float (aBack.DiffuseColor().Blue()); - - // Emissive color - ContextFillArea.Back.ColorEms.r = float (aBack.EmissiveColor().Red()); - ContextFillArea.Back.ColorEms.g = float (aBack.EmissiveColor().Green()); - ContextFillArea.Back.ColorEms.b = float (aBack.EmissiveColor().Blue()); - - ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion()); - - ContextFillArea.Back.RefractionIndex = float (aBack.RefractionIndex()); - ContextFillArea.Back.BSDF = aBack.BSDF(); - - // Front Material - const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial(); - // Light specificity - ContextFillArea.Front.Shininess = float (aFront.Shininess()); - ContextFillArea.Front.Ambient = float (aFront.Ambient()); - ContextFillArea.Front.Diffuse = float (aFront.Diffuse()); - ContextFillArea.Front.Specular = float (aFront.Specular()); - ContextFillArea.Front.Transparency = float (aFront.Transparency()); - ContextFillArea.Front.Emission = float (aFront.Emissive()); - - // Reflection mode - ContextFillArea.Front.IsAmbient = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0; - ContextFillArea.Front.IsDiffuse = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0; - ContextFillArea.Front.IsSpecular = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0; - ContextFillArea.Front.IsEmission = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0; - - // Material type - ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0; - - // Specular color - ContextFillArea.Front.ColorSpec.r = float (aFront.SpecularColor().Red()); - ContextFillArea.Front.ColorSpec.g = float (aFront.SpecularColor().Green()); - ContextFillArea.Front.ColorSpec.b = float (aFront.SpecularColor().Blue()); - - // Ambient color - ContextFillArea.Front.ColorAmb.r = float (aFront.AmbientColor().Red()); - ContextFillArea.Front.ColorAmb.g = float (aFront.AmbientColor().Green()); - ContextFillArea.Front.ColorAmb.b = float (aFront.AmbientColor().Blue()); - - // Diffuse color - ContextFillArea.Front.ColorDif.r = float (aFront.DiffuseColor().Red()); - ContextFillArea.Front.ColorDif.g = float (aFront.DiffuseColor().Green()); - ContextFillArea.Front.ColorDif.b = float (aFront.DiffuseColor().Blue()); - - // Emissive color - ContextFillArea.Front.ColorEms.r = float (aFront.EmissiveColor().Red()); - ContextFillArea.Front.ColorEms.g = float (aFront.EmissiveColor().Green()); - ContextFillArea.Front.ColorEms.b = float (aFront.EmissiveColor().Blue()); - - ContextFillArea.Front.EnvReflexion = float (aFront.EnvReflexion()); - - ContextFillArea.Front.RefractionIndex = float (aFront.RefractionIndex()); - ContextFillArea.Front.BSDF = aFront.BSDF(); - - ContextFillArea.IsDef = 1; // Material definition ok - - ContextFillArea.Texture.TextureMap = theAspFill->TextureMap(); - ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0; - - Standard_Integer aPolyMode; - Standard_ShortReal aPolyFactor, aPolyUnits; - theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits); - ContextFillArea.PolygonOffsetMode = aPolyMode; - ContextFillArea.PolygonOffsetFactor = aPolyFactor; - ContextFillArea.PolygonOffsetUnits = aPolyUnits; - - ContextFillArea.ShaderProgram = theAspFill->ShaderProgram(); - - UpdateAspectFace (Standard_False); - - ContextFillArea.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker) -{ - if (IsDeleted()) - { - return; - } - - Standard_Real aScale; - Quantity_Color aColor; - Aspect_TypeOfMarker aMarkerType; - theAspMarker->Values (aColor, aMarkerType, aScale); - - ContextMarker.IsDef = 1; - ContextMarker.Color.r = Standard_ShortReal (aColor.Red()); - ContextMarker.Color.g = Standard_ShortReal (aColor.Green()); - ContextMarker.Color.b = Standard_ShortReal (aColor.Blue()); - ContextMarker.MarkerType = aMarkerType; - ContextMarker.Scale = Standard_ShortReal (aScale); - ContextMarker.MarkerImage = theAspMarker->GetMarkerImage(); - - ContextMarker.ShaderProgram = theAspMarker->ShaderProgram(); - - UpdateAspectMarker (Standard_False); - - ContextMarker.IsSet = 1; - - Update(); -} - -// ======================================================================= -// function : SetPrimitivesAspect -// purpose : -// ======================================================================= -void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText) -{ - if (IsDeleted()) - { - return; - } - - Standard_CString aFont; - Standard_Real aSpace, anExpansion, aTextAngle; - Quantity_Color aColor, aColorSubTitle; - Aspect_TypeOfStyleText aStyle; - Aspect_TypeOfDisplayText aDisplayType; - Standard_Boolean aTextZoomable; - Font_FontAspect aTextFontAspect; - theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType, - aColorSubTitle, aTextZoomable, aTextAngle, aTextFontAspect); - - ContextText.IsDef = 1; - ContextText.Color.r = float (aColor.Red()); - ContextText.Color.g = float (aColor.Green()); - ContextText.Color.b = float (aColor.Blue()); - ContextText.Font = (char* )aFont; - ContextText.Expan = float (anExpansion); - ContextText.Space = float (aSpace); - ContextText.Style = aStyle; - ContextText.DisplayType = aDisplayType; - ContextText.ColorSubTitle.r = float (aColorSubTitle.Red()); - ContextText.ColorSubTitle.g = float (aColorSubTitle.Green()); - ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue()); - ContextText.TextZoomable = aTextZoomable; - ContextText.TextAngle = float (aTextAngle); - ContextText.TextFontAspect = aTextFontAspect; - ContextText.ShaderProgram = theAspText->ShaderProgram(); - - UpdateAspectText (Standard_False); - - ContextText.IsSet = 1; - - Update(); -} - // ======================================================================= // function : IsGroupPrimitivesAspectSet // purpose : @@ -802,10 +252,10 @@ Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_Gr { switch (theAspect) { - case Graphic3d_ASPECT_LINE: return ContextLine.IsSet; - case Graphic3d_ASPECT_TEXT: return ContextText.IsSet; - case Graphic3d_ASPECT_MARKER: return ContextMarker.IsSet; - case Graphic3d_ASPECT_FILL_AREA: return ContextFillArea.IsSet; + case Graphic3d_ASPECT_LINE: return !LineAspect().IsNull(); + case Graphic3d_ASPECT_TEXT: return !TextAspect().IsNull(); + case Graphic3d_ASPECT_MARKER: return !MarkerAspect().IsNull(); + case Graphic3d_ASPECT_FILL_AREA: return !FillAreaAspect().IsNull(); default: return Standard_False; } } @@ -819,154 +269,41 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d const Handle(Graphic3d_AspectMarker3d)& theAspMarker, const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const { - Quantity_Color aColor; - Graphic3d_MaterialAspect aFront, aBack; - - const CALL_DEF_CONTEXTLINE& anAspLine = ContextLine; - aColor.SetValues (Standard_Real (anAspLine.Color.r), - Standard_Real (anAspLine.Color.g), - Standard_Real (anAspLine.Color.b), Quantity_TOC_RGB); - theAspLine->SetColor (aColor); - theAspLine->SetType (Aspect_TypeOfLine (anAspLine.LineType)); - theAspLine->SetWidth (Standard_Real (anAspLine.Width)); - theAspLine->SetShaderProgram (anAspLine.ShaderProgram); - - const CALL_DEF_CONTEXTTEXT& anAspText = ContextText; - aColor.SetValues (Standard_Real (anAspText.Color.r), - Standard_Real (anAspText.Color.g), - Standard_Real (anAspText.Color.b), Quantity_TOC_RGB); - theAspText->SetColor (aColor); - aColor.SetValues (Standard_Real (anAspText.ColorSubTitle.r), - Standard_Real (anAspText.ColorSubTitle.g), - Standard_Real (anAspText.ColorSubTitle.b), Quantity_TOC_RGB); - theAspText->SetColorSubTitle (aColor); - theAspText->SetFont (anAspText.Font); - theAspText->SetSpace (Standard_Real (anAspText.Space)); - theAspText->SetExpansionFactor (Standard_Real (anAspText.Expan)); - theAspText->SetStyle (Aspect_TypeOfStyleText (anAspText.Style)); - theAspText->SetDisplayType (Aspect_TypeOfDisplayText (anAspText.DisplayType)); - theAspText->SetShaderProgram (anAspText.ShaderProgram); - - const CALL_DEF_CONTEXTMARKER& anAspMarker = ContextMarker; - aColor.SetValues (Standard_Real (anAspMarker.Color.r), - Standard_Real (anAspMarker.Color.g), - Standard_Real (anAspMarker.Color.b), Quantity_TOC_RGB); - theAspMarker->SetColor (aColor); - theAspMarker->SetType (anAspMarker.MarkerType); - theAspMarker->SetScale (Standard_Real (anAspMarker.Scale)); - theAspMarker->SetShaderProgram (anAspMarker.ShaderProgram); - if (anAspMarker.MarkerType == Aspect_TOM_USERDEFINED) + if (!theAspLine.IsNull()) { - theAspMarker->SetMarkerImage (ContextMarker.MarkerImage); + Handle(Graphic3d_AspectLine3d) aLineAspect = LineAspect(); + if (!aLineAspect.IsNull()) + { + *theAspLine.operator->() = *aLineAspect; + } } - const CALL_DEF_CONTEXTFILLAREA& anAspFill = ContextFillArea; - // Interior - theAspFill->SetInteriorStyle (Aspect_InteriorStyle (anAspFill.Style)); - aColor.SetValues (Standard_Real (anAspFill.IntColor.r), - Standard_Real (anAspFill.IntColor.g), - Standard_Real (anAspFill.IntColor.b), Quantity_TOC_RGB); - theAspFill->SetInteriorColor (aColor); - - // Edges - aColor.SetValues (Standard_Real (anAspFill.EdgeColor.r), - Standard_Real (anAspFill.EdgeColor.g), - Standard_Real (anAspFill.EdgeColor.b), Quantity_TOC_RGB); - theAspFill->SetEdgeColor (aColor); - theAspFill->SetEdgeLineType (Aspect_TypeOfLine (anAspFill.LineType)); - theAspFill->SetEdgeWidth (Standard_Real (anAspFill.Width)); - - // Back Material - aBack.SetShininess (Standard_Real (anAspFill.Back.Shininess)); - aBack.SetAmbient (Standard_Real (anAspFill.Back.Ambient)); - aBack.SetDiffuse (Standard_Real (anAspFill.Back.Diffuse)); - aBack.SetSpecular (Standard_Real (anAspFill.Back.Specular)); - aBack.SetTransparency (Standard_Real (anAspFill.Back.Transparency)); - aBack.SetEmissive (Standard_Real (anAspFill.Back.Emission)); - anAspFill.Back.IsAmbient == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_AMBIENT) : aBack.SetReflectionModeOff (Graphic3d_TOR_AMBIENT); - anAspFill.Back.IsDiffuse == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE) : aBack.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE); - anAspFill.Back.IsSpecular == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aBack.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); - anAspFill.Back.IsEmission == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aBack.SetReflectionModeOff (Graphic3d_TOR_EMISSION); - - aColor.SetValues (Standard_Real (anAspFill.Back.ColorSpec.r), - Standard_Real (anAspFill.Back.ColorSpec.g), - Standard_Real (anAspFill.Back.ColorSpec.b), Quantity_TOC_RGB); - aBack.SetSpecularColor (aColor); - - aColor.SetValues (Standard_Real (anAspFill.Back.ColorAmb.r), - Standard_Real (anAspFill.Back.ColorAmb.g), - Standard_Real (anAspFill.Back.ColorAmb.b), Quantity_TOC_RGB); - aBack.SetAmbientColor (aColor); - - aColor.SetValues (Standard_Real (anAspFill.Back.ColorDif.r), - Standard_Real (anAspFill.Back.ColorDif.g), - Standard_Real (anAspFill.Back.ColorDif.b), Quantity_TOC_RGB); - aBack.SetDiffuseColor (aColor); - - aColor.SetValues (Standard_Real (anAspFill.Back.ColorEms.r), - Standard_Real (anAspFill.Back.ColorEms.g), - Standard_Real (anAspFill.Back.ColorEms.b), Quantity_TOC_RGB); - aBack.SetEmissiveColor (aColor); - - aBack.SetEnvReflexion (anAspFill.Back.EnvReflexion); - - aBack.SetRefractionIndex (Standard_Real (anAspFill.Back.RefractionIndex)); - aBack.SetBSDF (anAspFill.Back.BSDF); - - // Front Material - aFront.SetShininess (Standard_Real (anAspFill.Front.Shininess)); - aFront.SetAmbient (Standard_Real (anAspFill.Front.Ambient)); - aFront.SetDiffuse (Standard_Real (anAspFill.Front.Diffuse)); - aFront.SetSpecular (Standard_Real (anAspFill.Front.Specular)); - aFront.SetTransparency (Standard_Real (anAspFill.Front.Transparency)); - aFront.SetEmissive (Standard_Real (anAspFill.Back.Emission)); - anAspFill.Front.IsAmbient == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_AMBIENT) : aFront.SetReflectionModeOff (Graphic3d_TOR_AMBIENT); - anAspFill.Front.IsDiffuse == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE) : aFront.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE); - anAspFill.Front.IsSpecular == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aFront.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); - anAspFill.Front.IsEmission == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aFront.SetReflectionModeOff (Graphic3d_TOR_EMISSION); - - aColor.SetValues (Standard_Real (anAspFill.Front.ColorSpec.r), - Standard_Real (anAspFill.Front.ColorSpec.g), - Standard_Real (anAspFill.Front.ColorSpec.b), Quantity_TOC_RGB); - aFront.SetSpecularColor (aColor); - - aColor.SetValues (Standard_Real (anAspFill.Front.ColorAmb.r), - Standard_Real (anAspFill.Front.ColorAmb.g), - Standard_Real (anAspFill.Front.ColorAmb.b), Quantity_TOC_RGB); - aFront.SetAmbientColor (aColor); - - aColor.SetValues (Standard_Real (anAspFill.Front.ColorDif.r), - Standard_Real (anAspFill.Front.ColorDif.g), - Standard_Real (anAspFill.Front.ColorDif.b), Quantity_TOC_RGB); - aFront.SetDiffuseColor (aColor); - - aColor.SetValues (Standard_Real (anAspFill.Front.ColorEms.r), - Standard_Real (anAspFill.Front.ColorEms.g), - Standard_Real (anAspFill.Front.ColorEms.b), Quantity_TOC_RGB); - aFront.SetEmissiveColor (aColor); - - aFront.SetEnvReflexion (anAspFill.Front.EnvReflexion); + if (!theAspText.IsNull()) + { + Handle(Graphic3d_AspectText3d) aTextAspect = TextAspect(); + if (!aTextAspect.IsNull()) + { + *theAspText.operator->() = *aTextAspect; + } + } - aFront.SetRefractionIndex (Standard_Real (anAspFill.Front.RefractionIndex)); - aFront.SetBSDF (anAspFill.Front.BSDF); + if (!theAspMarker.IsNull()) + { + Handle(Graphic3d_AspectMarker3d) aMarkerAspect = MarkerAspect(); + if (!aMarkerAspect.IsNull()) + { + *theAspMarker.operator->() = *aMarkerAspect; + } + } - // Edges - anAspFill.Edge == 1 ? theAspFill->SetEdgeOn() : theAspFill->SetEdgeOff(); - // Hatch - theAspFill->SetHatchStyle (Aspect_HatchStyle (anAspFill.Hatch)); - // Materials - // Front and Back face - anAspFill.Distinguish == 1 ? theAspFill->SetDistinguishOn() : theAspFill->SetDistinguishOff(); - anAspFill.BackFace == 1 ? theAspFill->SuppressBackFace() : theAspFill->AllowBackFace(); - // Texture - theAspFill->SetTextureMap (anAspFill.Texture.TextureMap); - anAspFill.Texture.doTextureMap == 1 ? theAspFill->SetTextureMapOn() : theAspFill->SetTextureMapOff(); - theAspFill->SetShaderProgram (anAspFill.ShaderProgram); - theAspFill->SetPolygonOffsets (anAspFill.PolygonOffsetMode, - anAspFill.PolygonOffsetFactor, - anAspFill.PolygonOffsetUnits); - theAspFill->SetBackMaterial (aBack); - theAspFill->SetFrontMaterial (aFront); + if (!theAspFill.IsNull()) + { + Handle(Graphic3d_AspectFillArea3d) aFillAspect = FillAreaAspect(); + if (!aFillAspect.IsNull()) + { + *theAspFill.operator->() = *aFillAspect; + } + } } // ======================================================================= @@ -1207,39 +544,3 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText, Text (aText.ToCString(), thePoint, theHeight, 0.0, Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax); } - -// ======================================================================= -// function : SetClosed -// purpose : -// ======================================================================= -void Graphic3d_Group::SetClosed (const Standard_Boolean theIsClosed) -{ - myIsClosed = theIsClosed; -} - -// ======================================================================= -// function : IsClosed -// purpose : -// ======================================================================= -Standard_Boolean Graphic3d_Group::IsClosed() const -{ - return myIsClosed; -} - -//======================================================================= -//function : BoundingBox -//purpose : -//======================================================================= -const Graphic3d_BndBox4f& Graphic3d_Group::BoundingBox() const -{ - return myBounds; -} - -//======================================================================= -//function : ChangeBoundingBox -//purpose : -//======================================================================= -Graphic3d_BndBox4f& Graphic3d_Group::ChangeBoundingBox() -{ - return myBounds; -} diff --git a/src/Graphic3d/Graphic3d_Group.hxx b/src/Graphic3d/Graphic3d_Group.hxx index 1207b927a8..d527aaa985 100644 --- a/src/Graphic3d/Graphic3d_Group.hxx +++ b/src/Graphic3d/Graphic3d_Group.hxx @@ -24,10 +24,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -103,14 +99,6 @@ public: //! cross-reference); Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True); - Standard_EXPORT virtual void UpdateAspectLine (const Standard_Boolean theIsGlobal) = 0; - - Standard_EXPORT virtual void UpdateAspectFace (const Standard_Boolean theIsGlobal) = 0; - - Standard_EXPORT virtual void UpdateAspectMarker (const Standard_Boolean theIsGlobal) = 0; - - Standard_EXPORT virtual void UpdateAspectText (const Standard_Boolean theIsGlobal) = 0; - //! Supress the group in the structure. Standard_EXPORT void Destroy(); ~Graphic3d_Group() @@ -124,41 +112,49 @@ public: //! Get the current modelling transform persistence (pan, zoom or rotate) Standard_EXPORT void Remove(); - //! Modifies the context for all the line primitives - //! of the group. - Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX); + //! Return line aspect. + virtual Handle(Graphic3d_AspectLine3d) LineAspect() const = 0; + + //! Assign line aspect to the group. + virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) = 0; - //! Modifies the context for all the face primitives - //! of the group. - Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX); + //! Return fill area aspect. + virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const = 0; - //! Modifies the context for all the text primitives - //! of the group. - Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX); + //! Modifies the context for all the face primitives of the group. + virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) = 0; - //! Modifies the context for all the marker primitives - //! of the group. - Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX); + //! Return text aspect. + virtual Handle(Graphic3d_AspectText3d) TextAspect() const = 0; + + //! Modifies the context for all the text primitives of the group. + virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) = 0; + + //! Return marker aspect. + virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const = 0; + + //! Modifies the context for all the marker primitives of the group. + virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0; //! Modifies the current context of the group to give //! another aspect for all the line primitives created //! after this call in the group. - Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX); + virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) = 0; //! Modifies the current context of the group to give //! another aspect for all the face primitives created //! after this call in the group. - Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX); + virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) = 0; //! Modifies the current context of the group to give //! another aspect for all the text primitives created //! after this call in the group. - Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX); + virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) = 0; //! Modifies the current context of the group to give //! another aspect for all the marker primitives created //! after this call in the group. - Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX); + virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0; //! Sets the coordinates of the boundary box of the //! group . @@ -283,19 +279,19 @@ public: Standard_EXPORT void MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const; //! Returns boundary box of the group without transformation applied, - Standard_EXPORT const Graphic3d_BndBox4f& BoundingBox() const; + const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; } //! Returns non-const boundary box of the group without transformation applied, - Standard_EXPORT Graphic3d_BndBox4f& ChangeBoundingBox(); + Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; } //! Returns the structure containing the group . Standard_EXPORT Handle(Graphic3d_Structure) Structure() const; //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells). - Standard_EXPORT void SetClosed (const Standard_Boolean theIsClosed); + void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; } //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells). - Standard_EXPORT Standard_Boolean IsClosed() const; + bool IsClosed() const { return myIsClosed; } friend class Graphic3d_Structure; @@ -311,14 +307,9 @@ protected: Graphic3d_CBitFields4 myCBitFields; Graphic3d_StructurePtr myStructure; Graphic3d_BndBox4f myBounds; - Standard_Boolean myIsClosed; - Graphic3d_CAspectLine ContextLine; - Graphic3d_CAspectFillArea ContextFillArea; - Graphic3d_CAspectMarker ContextMarker; - Graphic3d_CAspectText ContextText; + bool myIsClosed; - -private: +protected: //! Returns the extreme coordinates found in the group. diff --git a/src/Graphic3d/Graphic3d_CAspectLine.hxx b/src/Graphic3d/Graphic3d_PolygonOffset.hxx similarity index 50% rename from src/Graphic3d/Graphic3d_CAspectLine.hxx rename to src/Graphic3d/Graphic3d_PolygonOffset.hxx index 2a2315348f..74c9ed1618 100644 --- a/src/Graphic3d/Graphic3d_CAspectLine.hxx +++ b/src/Graphic3d/Graphic3d_PolygonOffset.hxx @@ -1,5 +1,4 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2016 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -12,26 +11,20 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _Graphic3d_CAspectLine_HeaderFile -#define _Graphic3d_CAspectLine_HeaderFile +#ifndef _Graphic3d_PolygonOffset_HeaderFile +#define _Graphic3d_PolygonOffset_HeaderFile -#include -#include -#include +#include -class Graphic3d_CAspectLine +//! Polygon offset parameters. +struct Graphic3d_PolygonOffset { -public: - - int IsDef; - int IsSet; - CALL_DEF_COLOR Color; - int LineType; - float Width; - Handle(Graphic3d_ShaderProgram) ShaderProgram; + Aspect_PolygonOffsetMode Mode; + Standard_ShortReal Factor; + Standard_ShortReal Units; + //! Empty constructor. + Graphic3d_PolygonOffset() : Mode(Aspect_POM_Fill), Factor (1.0f), Units (0.0f) {} }; -typedef Graphic3d_CAspectLine CALL_DEF_CONTEXTLINE; - -#endif // _Graphic3d_CAspectLine_HeaderFile +#endif // _Graphic3d_PolygonOffset_HeaderFile diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index ba62c2bb08..d783b22017 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -1471,23 +1471,18 @@ void Graphic3d_Structure::Update (const bool theUpdateLayer) const //============================================================================= void Graphic3d_Structure::GraphicHighlight (const Aspect_TypeOfHighlightMethod theMethod) { - Standard_Real anRGB[3]; myCStructure->highlight = 1; myHighlightMethod = theMethod; switch (theMethod) { case Aspect_TOHM_COLOR: { - myHighlightColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB); - myCStructure->HighlightWithColor (Graphic3d_Vec3 (float (anRGB[0]), float (anRGB[1]), float (anRGB[2])), Standard_True); + myCStructure->HighlightWithColor (myHighlightColor, Standard_True); break; } case Aspect_TOHM_BOUNDBOX: { - myHighlightColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB); - myCStructure->HighlightColor.r = float (anRGB[0]); - myCStructure->HighlightColor.g = float (anRGB[1]); - myCStructure->HighlightColor.b = float (anRGB[2]); + myCStructure->HighlightColor = myHighlightColor; myCStructure->HighlightWithBndBox (this, Standard_True); break; } diff --git a/src/Graphic3d/Graphic3d_Vertex.hxx b/src/Graphic3d/Graphic3d_Vertex.hxx index 339a7f295b..41484973f6 100644 --- a/src/Graphic3d/Graphic3d_Vertex.hxx +++ b/src/Graphic3d/Graphic3d_Vertex.hxx @@ -16,16 +16,19 @@ #ifndef _Graphic3d_Vertex_HeaderFile #define _Graphic3d_Vertex_HeaderFile +#include +#include #include -#include #include #include //! This class represents a graphical 3D point. -class Graphic3d_Vertex : public TEL_POINT +class Graphic3d_Vertex { public: + DEFINE_STANDARD_ALLOC + //! Creates a point with 0.0, 0.0, 0.0 coordinates. Graphic3d_Vertex() { @@ -106,6 +109,8 @@ public: //! Returns the distance between two points. Standard_EXPORT Standard_ShortReal Distance (const Graphic3d_Vertex& theOther) const; + float xyz[3]; + }; #endif diff --git a/src/InterfaceGraphic/FILES b/src/InterfaceGraphic/FILES index 6d9bfeb378..68a1aa85b6 100755 --- a/src/InterfaceGraphic/FILES +++ b/src/InterfaceGraphic/FILES @@ -1,4 +1 @@ InterfaceGraphic.hxx -InterfaceGraphic_Graphic3d.hxx -InterfaceGraphic_telem.hxx -InterfaceGraphic_tgl_all.hxx diff --git a/src/InterfaceGraphic/InterfaceGraphic_Graphic3d.hxx b/src/InterfaceGraphic/InterfaceGraphic_Graphic3d.hxx deleted file mode 100644 index 175d789bef..0000000000 --- a/src/InterfaceGraphic/InterfaceGraphic_Graphic3d.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef InterfaceGraphic_Graphic3dHeader -#define InterfaceGraphic_Graphic3dHeader - -#include -#include -#include -#include - -/* COULEUR */ - -typedef struct { - - Standard_ShortReal r; - Standard_ShortReal g; - Standard_ShortReal b; - -} CALL_DEF_COLOR; - -/* POINT */ - -typedef struct { - - Standard_ShortReal x; - Standard_ShortReal y; - Standard_ShortReal z; - -} CALL_DEF_POINT; - -/* MATERIAL */ - -typedef struct { - - Standard_ShortReal Ambient; - Standard_Integer IsAmbient; - - Standard_ShortReal Diffuse; - Standard_Integer IsDiffuse; - - Standard_ShortReal Specular; - Standard_Integer IsSpecular; - - Standard_ShortReal Emission; - Standard_Integer IsEmission; - - Graphic3d_BSDF BSDF; - - Standard_ShortReal Shininess; - Standard_ShortReal Transparency; - Standard_ShortReal RefractionIndex; - - Standard_ShortReal EnvReflexion; - - Standard_Integer IsPhysic; - - /* Color attributes */ - CALL_DEF_COLOR ColorAmb; - CALL_DEF_COLOR ColorDif; - CALL_DEF_COLOR ColorSpec; - CALL_DEF_COLOR ColorEms; - CALL_DEF_COLOR Color; - -} CALL_DEF_MATERIAL; - -/* Transform persistence struct */ -typedef struct -{ - Standard_Integer IsSet; - Standard_Integer IsDef; - Standard_Integer Flag; - CALL_DEF_POINT Point; -} CALL_DEF_TRANSFORM_PERSISTENCE; - -#endif /* InterfaceGraphic_Graphic3dHeader */ diff --git a/src/InterfaceGraphic/InterfaceGraphic_telem.hxx b/src/InterfaceGraphic/InterfaceGraphic_telem.hxx deleted file mode 100644 index 0f4c3ddb19..0000000000 --- a/src/InterfaceGraphic/InterfaceGraphic_telem.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef INTERFACEGRAPHIC_TELEM_H -#define INTERFACEGRAPHIC_TELEM_H - -#include -#include -#include -#include - -struct TEL_TEXTURE_COORD -{ - float xy[2]; - DEFINE_STANDARD_ALLOC -}; - -typedef TEL_TEXTURE_COORD* tel_texture_coord; - -class TEL_POINT -{ - public: - float xyz[3]; - DEFINE_STANDARD_ALLOC -}; -typedef TEL_POINT* tel_point; - -struct TEL_COLOUR -{ - /* OCC8854: san -- number of color components increased to include alpha value */ - float rgb[4]; - DEFINE_STANDARD_ALLOC -}; -typedef TEL_COLOUR* tel_colour; - -typedef enum -{ - TelCullUndefined = -1, - TelCullNone = 0, - TelCullFront, - TelCullBack -} TelCullMode; - -/* Standard Hatch Styles */ -#define TEL_HS_SOLID 0 -#define TEL_HS_CROSS 1 -#define TEL_HS_CROSS_SPARSE 2 -#define TEL_HS_GRID 3 -#define TEL_HS_GRID_SPARSE 4 -#define TEL_HS_DIAG_45 5 -#define TEL_HS_DIAG_135 6 -#define TEL_HS_HORIZONTAL 7 -#define TEL_HS_VERTICAL 8 -#define TEL_HS_DIAG_45_SPARSE 9 -#define TEL_HS_DIAG_135_SPARSE 10 -#define TEL_HS_HORIZONTAL_SPARSE 11 -#define TEL_HS_VERTICAL_SPARSE 12 - -#define TEL_HS_USER_DEF_START 15 - -/* Standard Lighting Models */ -#define TEL_FRONT_BACK_LM 1 - -/* Standard Materials */ -#define TEL_FRONT_MATERIAL 1 -#define TEL_BACK_MATERIAL 2 - -struct TEL_POFFSET_PARAM -{ - int mode; - float factor; - float units; - DEFINE_STANDARD_ALLOC -}; -typedef TEL_POFFSET_PARAM* tel_poffset_param; - -#endif /* INTERFACEGRAPHIC_TELEM_H */ diff --git a/src/InterfaceGraphic/InterfaceGraphic_tgl_all.hxx b/src/InterfaceGraphic/InterfaceGraphic_tgl_all.hxx deleted file mode 100644 index cc8918048f..0000000000 --- a/src/InterfaceGraphic/InterfaceGraphic_tgl_all.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef INTERFACEGRAPHIC_TGL_ALL_H -#define INTERFACEGRAPHIC_TGL_ALL_H - -typedef int Tint; -typedef float Tfloat; -typedef double Tdouble; -/* Tchar is treated as a signed char in visualization code, -therefore it should be made signed explicitly, as on Linux --funsigned-char option is specified when building OCCT */ -typedef signed char Tchar; -typedef char Tbool; -typedef unsigned int Tuint; -/* szv: Techar is an Extended character */ -typedef unsigned short Techar; - -#define TOn 1 -#define TOff 0 - -typedef Tfloat Tmatrix3[4][4]; - -#endif /* INTERFACEGRAPHIC_TGL_ALL_H */ diff --git a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx index c3b63ea345..c246e845c7 100644 --- a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx @@ -340,10 +340,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& aFillAspect->SetDistinguishOff (); aFillAspect->SetInteriorColor ( aColIter.Key() ); - if (anEdgeOn) - aFillAspect->SetEdgeOn(); - else - aFillAspect->SetEdgeOff(); + aFillAspect->SetEdgeOff(); for (it.Reset(); it.More(); it.Next()) { @@ -449,27 +446,20 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& if (IsPolyG) { - aFillAspect->SetEdgeOff(); aGGroup->SetPrimitivesAspect (aFillAspect); aGGroup->AddPrimitiveArray (aFaceTriangles); if (anEdgeOn) { - aFillAspect->SetEdgeOff(); aSGroup->AddPrimitiveArray (anEdgeSegments); aSGroup->SetGroupPrimitivesAspect (anEdgeAspect); } } if (IsPolyL) { - aFillAspect->SetEdgeOff(); aLGroup->SetPrimitivesAspect (aFillAspect); aLGroup->SetPrimitivesAspect (aLinkAspect); aLGroup->AddPrimitiveArray (aLinkSegments); - if (anEdgeOn) - aFillAspect->SetEdgeOn(); - else - aFillAspect->SetEdgeOff(); } if (!aCustomElements.IsEmpty()) diff --git a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx index 1253884018..99cb9c5c82 100644 --- a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx @@ -332,15 +332,8 @@ void MeshVS_MeshPrsBuilder::BuildElements( const Handle(Prs3d_Presentation)& Prs TColStd_PackedMapOfInteger aCustomElements; - Quantity_Color anOldEdgeColor; - Quantity_Color anEdgeColor; - Quantity_Color anIntColor; - Aspect_InteriorStyle anIntType; - Aspect_TypeOfLine aLine; - Standard_Real aWidth; - - aFill->Values (anIntType, anIntColor, anEdgeColor, aLine, aWidth); - + Quantity_Color anOldEdgeColor; + Quantity_Color anEdgeColor = aFill->EdgeColor(); MeshVS_MapOfTwoNodes aLinkNodes; // Forbid drawings of edges which overlap with some links @@ -1057,12 +1050,10 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, IsPolylines = ( !theLines.IsNull() && theLines->ItemNumber() > 0 ), IsLinkPolylines = ( !theLinkLines.IsNull() && theLinkLines->ItemNumber() > 0 ); - Aspect_InteriorStyle aStyle; - Quantity_Color anIntColor, aBackColor, anEdgeColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - - theFillAsp->Values( aStyle, anIntColor, aBackColor, anEdgeColor, aType, aWidth ); + Quantity_Color anIntColor = theFillAsp->InteriorColor(); + Quantity_Color aBackColor = theFillAsp->BackInteriorColor(); + Quantity_Color anEdgeColor = theFillAsp->EdgeColor(); + Standard_Real aWidth = theFillAsp->EdgeWidth(); Standard_Boolean isSupressBackFaces = Standard_False; Handle(MeshVS_Drawer) aDrawer = GetDrawer(); @@ -1075,23 +1066,18 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, { Prs3d_Root::NewGroup ( Prs ); Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup ( Prs ); - + aGroup->SetClosed (isSupressBackFaces == Standard_True); + Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*theFillAsp); //if ( IsPolygonsEdgesOff ) - theFillAsp->SetEdgeOff (); + aFillAsp->SetEdgeOff (); //else - // theFillAsp->SetEdgeOn (); + // aFillAsp->SetEdgeOn (); if( anIntColor!=aBackColor ) - theFillAsp->SetDistinguishOn(); + aFillAsp->SetDistinguishOn(); else - theFillAsp->SetDistinguishOff(); + aFillAsp->SetDistinguishOff(); - aGroup->SetClosed (isSupressBackFaces); - Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->())); - if (isSupressBackFaces) - { - aFillAsp->SuppressBackFace(); - } aGroup->SetPrimitivesAspect (aFillAsp); if( IsFacePolygons ) @@ -1110,7 +1096,6 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, Prs3d_Root::NewGroup ( Prs ); Handle (Graphic3d_Group) aLGroup = Prs3d_Root::CurrentGroup ( Prs ); - theFillAsp->SetEdgeOff(); if ( IsSelected ) aLGroup->SetPrimitivesAspect ( theLineAsp ); else @@ -1120,43 +1105,34 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, ( anEdgeColor, Aspect_TOL_SOLID, aWidth ) ); } aLGroup->AddPrimitiveArray ( theLines ); - theFillAsp->SetEdgeOn(); } if ( IsLinkPolylines ) { Prs3d_Root::NewGroup ( Prs ); Handle (Graphic3d_Group) aBeamGroup = Prs3d_Root::CurrentGroup ( Prs ); - - theFillAsp->SetEdgeOff(); if ( !IsSelected ) aBeamGroup->SetPrimitivesAspect ( theFillAsp ); aBeamGroup->SetPrimitivesAspect ( theLineAsp ); aBeamGroup->AddPrimitiveArray ( theLinkLines ); - theFillAsp->SetEdgeOn(); } if ( IsPolygons && theFillAsp->FrontMaterial().Transparency()>=0.01 ) { Prs3d_Root::NewGroup ( Prs ); Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup ( Prs ); - + aGroup->SetClosed (isSupressBackFaces == Standard_True); + Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*theFillAsp); //if ( IsPolygonsEdgesOff ) - theFillAsp->SetEdgeOff (); + aFillAsp->SetEdgeOff (); //else - // theFillAsp->SetEdgeOn (); + // aFillAsp->SetEdgeOn (); if( anIntColor!=aBackColor ) - theFillAsp->SetDistinguishOn(); + aFillAsp->SetDistinguishOn(); else - theFillAsp->SetDistinguishOff(); + aFillAsp->SetDistinguishOff(); - aGroup->SetClosed (isSupressBackFaces); - Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->())); - if (isSupressBackFaces) - { - aFillAsp->SuppressBackFace(); - } aGroup->SetPrimitivesAspect (aFillAsp); if( IsFacePolygons ) diff --git a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx index d83cc63628..e582c5470e 100644 --- a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx @@ -485,12 +485,11 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, Prs3d_Root::NewGroup ( Prs ); Handle(Graphic3d_Group) aGroup2 = Prs3d_Root::CurrentGroup ( Prs ); - anAsp->SetEdgeOff(); - anAsp->SetTextureMapOff(); - aGroup2->SetPrimitivesAspect( anAsp ); + Handle(Graphic3d_AspectFillArea3d) anAspCopy = new Graphic3d_AspectFillArea3d (*anAsp); + anAspCopy->SetTextureMapOff(); + aGroup2->SetPrimitivesAspect( anAspCopy ); aGroup2->SetPrimitivesAspect( anLAsp ); aGroup2->AddPrimitiveArray( anEdgeSegments ); - anAsp->SetEdgeOn(); } } diff --git a/src/OpenGl/OpenGl_AspectFace.cxx b/src/OpenGl/OpenGl_AspectFace.cxx index bd4519903c..2200dfc18d 100644 --- a/src/OpenGl/OpenGl_AspectFace.cxx +++ b/src/OpenGl/OpenGl_AspectFace.cxx @@ -33,354 +33,84 @@ namespace { - static OPENGL_SURF_PROP THE_DEFAULT_MATERIAL = - { - 0.2F, 0.8F, 0.1F, 0.0F, // amb, diff, spec, emsv - 1.0F, 10.0F, 1.0F, 0.0F, // trans, shine, index, env_reflexion - 0, // isphysic - (OPENGL_AMBIENT_MASK | OPENGL_DIFFUSE_MASK | OPENGL_SPECULAR_MASK), // color_mask - {{ 1.0F, 1.0F, 1.0F, 1.0F }}, // ambient color - {{ 1.0F, 1.0F, 1.0F, 1.0F }}, // diffuse color - {{ 1.0F, 1.0F, 1.0F, 1.0F }}, // specular color - {{ 1.0F, 1.0F, 1.0F, 1.0F }}, // emissive color - {{ 1.0F, 1.0F, 1.0F, 1.0F }}, // material color - Graphic3d_BSDF() - }; + //! Initialize default material in this way for backward compatibility. + inline Graphic3d_MaterialAspect initDefaultMaterial() + { + Graphic3d_MaterialAspect aMat; + aMat.SetMaterialType (Graphic3d_MATERIAL_ASPECT); + aMat.SetAmbient (0.2); + aMat.SetDiffuse (0.8); + aMat.SetSpecular (0.1); + aMat.SetEmissive (0.0); + aMat.SetAmbientColor (Quantity_NOC_WHITE); + aMat.SetDiffuseColor (Quantity_NOC_WHITE); + aMat.SetEmissiveColor(Quantity_NOC_WHITE); + aMat.SetSpecularColor(Quantity_NOC_WHITE); + aMat.SetShininess (10.0 / 128.0); + aMat.SetRefractionIndex (1.0); + return aMat; + } - static const TCollection_AsciiString THE_EMPTY_KEY; + static const TCollection_AsciiString THE_EMPTY_KEY; + static const Graphic3d_MaterialAspect THE_DEFAULT_MATERIAL = initDefaultMaterial(); } // ======================================================================= -// function : convertMaterial +// function : OpenGl_AspectFace // purpose : // ======================================================================= -void OpenGl_AspectFace::convertMaterial (const CALL_DEF_MATERIAL& theMat, - OPENGL_SURF_PROP& theSurf) +OpenGl_AspectFace::OpenGl_AspectFace() +: myAspect (new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE, + Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0, + THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)), + myIsNoLighting (false) { - theSurf.amb = theMat.IsAmbient ? theMat.Ambient : 0.0f; - theSurf.diff = theMat.IsDiffuse ? theMat.Diffuse : 0.0f; - theSurf.spec = theMat.IsSpecular ? theMat.Specular : 0.0f; - theSurf.emsv = theMat.IsEmission ? theMat.Emission : 0.0f; - - theSurf.isphysic = theMat.IsPhysic ? 1 : 0; // type of material - - // color of material - theSurf.color_mask = 0; - if (theMat.IsAmbient) - { - theSurf.color_mask |= OPENGL_AMBIENT_MASK; - } - if (theMat.IsDiffuse) - { - theSurf.color_mask |= OPENGL_DIFFUSE_MASK; - } - if (theMat.IsSpecular) - { - theSurf.color_mask |= OPENGL_SPECULAR_MASK; - } - if (theMat.IsEmission) - { - theSurf.color_mask |= OPENGL_EMISSIVE_MASK; - } - - // ambient color - theSurf.ambcol.rgb[0] = theMat.ColorAmb.r; - theSurf.ambcol.rgb[1] = theMat.ColorAmb.g; - theSurf.ambcol.rgb[2] = theMat.ColorAmb.b; - theSurf.ambcol.rgb[3] = 1.0f; - - // diffuse color - theSurf.difcol.rgb[0] = theMat.ColorDif.r; - theSurf.difcol.rgb[1] = theMat.ColorDif.g; - theSurf.difcol.rgb[2] = theMat.ColorDif.b; - theSurf.difcol.rgb[3] = 1.0f; - - // specular color - theSurf.speccol.rgb[0] = theMat.ColorSpec.r; - theSurf.speccol.rgb[1] = theMat.ColorSpec.g; - theSurf.speccol.rgb[2] = theMat.ColorSpec.b; - theSurf.speccol.rgb[3] = 1.0f; - - // emission color - theSurf.emscol.rgb[0] = theMat.ColorEms.r; - theSurf.emscol.rgb[1] = theMat.ColorEms.g; - theSurf.emscol.rgb[2] = theMat.ColorEms.b; - theSurf.emscol.rgb[3] = 1.0f; - - theSurf.shine = 128.0f * float(theMat.Shininess); - theSurf.env_reflexion = theMat.EnvReflexion; - - // trans = 0. => opaque - // trans = 1. => transparent - // in OpenGl it is opposite. - theSurf.trans = 1.0f - theMat.Transparency; - theSurf.index = theMat.RefractionIndex; - - // material BSDF (for physically-based rendering) - theSurf.BSDF = theMat.BSDF; + myAspect->SetHatchStyle (Aspect_HS_SOLID); } // ======================================================================= // function : OpenGl_AspectFace // purpose : // ======================================================================= -OpenGl_AspectFace::OpenGl_AspectFace() -: myInteriorStyle (Aspect_IS_SOLID), - myEdge (TOff), - myHatch (TEL_HS_SOLID), - myDistinguishingMode (TOff), - myCullingMode (TelCullNone), - myIntFront (THE_DEFAULT_MATERIAL), - myIntBack (THE_DEFAULT_MATERIAL), - myPolygonOffset (THE_DEFAULT_POFFSET), - myDoTextureMap (false) -{} +OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect) +: myIsNoLighting (false) +{ + SetAspect (theAspect); +} // ======================================================================= // function : SetAspect // purpose : // ======================================================================= -void OpenGl_AspectFace::SetAspect (const CALL_DEF_CONTEXTFILLAREA& theAspect) +void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { - myInteriorStyle = (Aspect_InteriorStyle )theAspect.Style; - myEdge = theAspect.Edge ? TOn : TOff; - - //TelInteriorStyleIndex - switch (theAspect.Hatch) - { - case 0: /* Aspect_HS_HORIZONTAL */ - myHatch = TEL_HS_HORIZONTAL; - break; - case 1: /* Aspect_HS_HORIZONTAL_WIDE */ - myHatch = TEL_HS_HORIZONTAL_SPARSE; - break; - case 2: /* Aspect_HS_VERTICAL */ - myHatch = TEL_HS_VERTICAL; - break; - case 3: /* Aspect_HS_VERTICAL_WIDE */ - myHatch = TEL_HS_VERTICAL_SPARSE; - break; - case 4: /* Aspect_HS_DIAGONAL_45 */ - myHatch = TEL_HS_DIAG_45; - break; - case 5: /* Aspect_HS_DIAGONAL_45_WIDE */ - myHatch = TEL_HS_DIAG_45_SPARSE; - break; - case 6: /* Aspect_HS_DIAGONAL_135 */ - myHatch = TEL_HS_DIAG_135; - break; - case 7: /* Aspect_HS_DIAGONAL_135_WIDE */ - myHatch = TEL_HS_DIAG_135_SPARSE; - break; - case 8: /* Aspect_HS_GRID */ - myHatch = TEL_HS_GRID; - break; - case 9: /* Aspect_HS_GRID_WIDE */ - myHatch = TEL_HS_GRID_SPARSE; - break; - case 10: /* Aspect_HS_GRID_DIAGONAL */ - myHatch = TEL_HS_CROSS; - break; - case 11: /* Aspect_HS_GRID_DIAGONAL_WIDE */ - myHatch = TEL_HS_CROSS_SPARSE; - break; - default: - myHatch = 0; - break; - } - - myDistinguishingMode = theAspect.Distinguish ? TOn : TOff; - myCullingMode = theAspect.BackFace ? TelCullBack : TelCullNone; - - convertMaterial (theAspect.Front, myIntFront); - convertMaterial (theAspect.Back, myIntBack); - - //TelInteriorColour - myIntFront.matcol.rgb[0] = (float )theAspect.IntColor.r; - myIntFront.matcol.rgb[1] = (float )theAspect.IntColor.g; - myIntFront.matcol.rgb[2] = (float )theAspect.IntColor.b; - myIntFront.matcol.rgb[3] = 1.0f; - - //TelBackInteriorColour - myIntBack.matcol.rgb[0] = (float )theAspect.BackIntColor.r; - myIntBack.matcol.rgb[1] = (float )theAspect.BackIntColor.g; - myIntBack.matcol.rgb[2] = (float )theAspect.BackIntColor.b; - myIntBack.matcol.rgb[3] = 1.0f; + myAspect = theAspect; - //TelPolygonOffset - myPolygonOffset.mode = (Aspect_PolygonOffsetMode )theAspect.PolygonOffsetMode; - myPolygonOffset.factor = theAspect.PolygonOffsetFactor; - myPolygonOffset.units = theAspect.PolygonOffsetUnits; + const Graphic3d_MaterialAspect& aMat = theAspect->FrontMaterial(); + myIsNoLighting = !aMat.ReflectionMode (Graphic3d_TOR_AMBIENT) + && !aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE) + && !aMat.ReflectionMode (Graphic3d_TOR_SPECULAR) + && !aMat.ReflectionMode (Graphic3d_TOR_EMISSION); - CALL_DEF_CONTEXTLINE anEdgeAspect; - anEdgeAspect.Color.r = (float )theAspect.EdgeColor.r; - anEdgeAspect.Color.g = (float )theAspect.EdgeColor.g; - anEdgeAspect.Color.b = (float )theAspect.EdgeColor.b; - anEdgeAspect.LineType = (Aspect_TypeOfLine )theAspect.LineType; - anEdgeAspect.Width = (float )theAspect.Width; - myAspectEdge.SetAspect (anEdgeAspect); - - myDoTextureMap = (theAspect.Texture.doTextureMap != 0); + myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor()); + myAspectEdge.Aspect()->SetType (theAspect->EdgeLineType()); + myAspectEdge.Aspect()->SetWidth (theAspect->EdgeWidth()); // update texture binding - myTexture = theAspect.Texture.TextureMap; - - const TCollection_AsciiString& aTextureKey = myTexture.IsNull() ? THE_EMPTY_KEY : myTexture->GetId(); + const TCollection_AsciiString& aTextureKey = myAspect->TextureMap().IsNull() ? THE_EMPTY_KEY : myAspect->TextureMap()->GetId(); if (aTextureKey.IsEmpty() || myResources.TextureId != aTextureKey) { myResources.ResetTextureReadiness(); } // update shader program binding - myShaderProgram = theAspect.ShaderProgram; - - const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId(); + const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId(); if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) { myResources.ResetShaderReadiness(); } } -// ======================================================================= -// function : SetAspect -// purpose : -// ======================================================================= -void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) -{ - CALL_DEF_CONTEXTFILLAREA aFaceContext; - Standard_Real aWidth; - Quantity_Color aBackIntColor; - Quantity_Color aEdgeColor; - Aspect_TypeOfLine aLType; - Quantity_Color aIntColor; - Aspect_InteriorStyle aIntStyle; - NCollection_Vec3 aColor; - - theAspect->Values (aIntStyle, aIntColor, aBackIntColor, aEdgeColor, aLType, aWidth); - aIntColor.Values (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB); - - aFaceContext.Style = int (aIntStyle); - aFaceContext.IntColor.r = float (aColor.r()); - aFaceContext.IntColor.g = float (aColor.g()); - aFaceContext.IntColor.b = float (aColor.b()); - - if (theAspect->Distinguish()) - { - aBackIntColor.Values (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB); - } - - aFaceContext.BackIntColor.r = float (aColor.r()); - aFaceContext.BackIntColor.g = float (aColor.g()); - aFaceContext.BackIntColor.b = float (aColor.b()); - - aFaceContext.Edge = theAspect->Edge () ? 1:0; - aEdgeColor.Values (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB); - - aFaceContext.EdgeColor.r = float (aColor.r()); - aFaceContext.EdgeColor.g = float (aColor.g()); - aFaceContext.EdgeColor.b = float (aColor.b()); - aFaceContext.LineType = int (aLType); - aFaceContext.Width = float (aWidth); - aFaceContext.Hatch = int (theAspect->HatchStyle ()); - - aFaceContext.Distinguish = theAspect->Distinguish () ? 1:0; - aFaceContext.BackFace = theAspect->BackFace () ? 1:0; - - aFaceContext.Back.Shininess = float ((theAspect->BackMaterial ()).Shininess ()); - aFaceContext.Back.Ambient = float ((theAspect->BackMaterial ()).Ambient ()); - aFaceContext.Back.Diffuse = float ((theAspect->BackMaterial ()).Diffuse ()); - aFaceContext.Back.Specular = float ((theAspect->BackMaterial ()).Specular ()); - aFaceContext.Back.Transparency = float ((theAspect->BackMaterial ()).Transparency ()); - aFaceContext.Back.Emission = float ((theAspect->BackMaterial ()).Emissive ()); - - // Reflection mode - aFaceContext.Back.IsAmbient = ((theAspect->BackMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0 ); - aFaceContext.Back.IsDiffuse = ((theAspect->BackMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0 ); - aFaceContext.Back.IsSpecular = ((theAspect->BackMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0 ); - aFaceContext.Back.IsEmission = ((theAspect->BackMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0 ); - - // Material type - const Graphic3d_MaterialAspect aBackMat = theAspect->BackMaterial (); - Standard_Boolean isBackPhys = aBackMat.MaterialType (Graphic3d_MATERIAL_PHYSIC); - aFaceContext.Back.IsPhysic = (isBackPhys ? 1 : 0 ); - - // Specular Color - aFaceContext.Back.ColorSpec.r = float (((theAspect->BackMaterial ()).SpecularColor ()).Red ()); - aFaceContext.Back.ColorSpec.g = float (((theAspect->BackMaterial ()).SpecularColor ()).Green ()); - aFaceContext.Back.ColorSpec.b = float (((theAspect->BackMaterial ()).SpecularColor ()).Blue ()); - - // Ambient color - aFaceContext.Back.ColorAmb.r = float (((theAspect->BackMaterial ()).AmbientColor ()).Red ()); - aFaceContext.Back.ColorAmb.g = float (((theAspect->BackMaterial ()).AmbientColor ()).Green ()); - aFaceContext.Back.ColorAmb.b = float (((theAspect->BackMaterial ()).AmbientColor ()).Blue ()); - - // Diffuse color - aFaceContext.Back.ColorDif.r = float (((theAspect->BackMaterial ()).DiffuseColor ()).Red ()); - aFaceContext.Back.ColorDif.g = float (((theAspect->BackMaterial ()).DiffuseColor ()).Green ()); - aFaceContext.Back.ColorDif.b = float (((theAspect->BackMaterial ()).DiffuseColor ()).Blue ()); - - // Emissive color - aFaceContext.Back.ColorEms.r = float (((theAspect->BackMaterial ()).EmissiveColor ()).Red ()); - aFaceContext.Back.ColorEms.g = float (((theAspect->BackMaterial ()).EmissiveColor ()).Green ()); - aFaceContext.Back.ColorEms.b = float (((theAspect->BackMaterial ()).EmissiveColor ()).Blue ()); - - aFaceContext.Back.EnvReflexion = float ((theAspect->BackMaterial ()).EnvReflexion()); - - aFaceContext.Front.Shininess = float ((theAspect->FrontMaterial ()).Shininess ()); - aFaceContext.Front.Ambient = float ((theAspect->FrontMaterial ()).Ambient ()); - aFaceContext.Front.Diffuse = float ((theAspect->FrontMaterial ()).Diffuse ()); - aFaceContext.Front.Specular = float ((theAspect->FrontMaterial ()).Specular ()); - aFaceContext.Front.Transparency = float ((theAspect->FrontMaterial ()).Transparency ()); - aFaceContext.Front.Emission = float ((theAspect->FrontMaterial ()).Emissive ()); - - // Reflection mode - aFaceContext.Front.IsAmbient = ((theAspect->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0); - aFaceContext.Front.IsDiffuse = ((theAspect->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0); - aFaceContext.Front.IsSpecular = ((theAspect->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0); - aFaceContext.Front.IsEmission = ((theAspect->FrontMaterial ()).ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0); - - // Material type - const Graphic3d_MaterialAspect aFrontMat = theAspect->FrontMaterial (); - Standard_Boolean isFrontPhys = aFrontMat.MaterialType (Graphic3d_MATERIAL_PHYSIC); - aFaceContext.Front.IsPhysic = (isFrontPhys ? 1 : 0 ); - - // Specular Color - aFaceContext.Front.ColorSpec.r = float (((theAspect->FrontMaterial ()).SpecularColor ()).Red ()); - aFaceContext.Front.ColorSpec.g = float (((theAspect->FrontMaterial ()).SpecularColor ()).Green ()); - aFaceContext.Front.ColorSpec.b = float (((theAspect->FrontMaterial ()).SpecularColor ()).Blue ()); - - // Ambient color - aFaceContext.Front.ColorAmb.r = float (((theAspect->FrontMaterial ()).AmbientColor ()).Red ()); - aFaceContext.Front.ColorAmb.g = float (((theAspect->FrontMaterial ()).AmbientColor ()).Green ()); - aFaceContext.Front.ColorAmb.b = float (((theAspect->FrontMaterial ()).AmbientColor ()).Blue ()); - - // Diffuse color - aFaceContext.Front.ColorDif.r = float (((theAspect->FrontMaterial ()).DiffuseColor ()).Red ()); - aFaceContext.Front.ColorDif.g = float (((theAspect->FrontMaterial ()).DiffuseColor ()).Green ()); - aFaceContext.Front.ColorDif.b = float (((theAspect->FrontMaterial ()).DiffuseColor ()).Blue ()); - - // Emissive color - aFaceContext.Front.ColorEms.r = float (((theAspect->FrontMaterial ()).EmissiveColor ()).Red ()); - aFaceContext.Front.ColorEms.g = float (((theAspect->FrontMaterial ()).EmissiveColor ()).Green ()); - aFaceContext.Front.ColorEms.b = float (((theAspect->FrontMaterial ()).EmissiveColor ()).Blue ()); - - aFaceContext.Front.EnvReflexion = float ((theAspect->FrontMaterial ()).EnvReflexion()); - aFaceContext.IsDef = 1; - aFaceContext.Texture.TextureMap = theAspect->TextureMap(); - aFaceContext.Texture.doTextureMap = theAspect->TextureMapState() ? 1 : 0; - - Standard_Integer aPolyMode; - Standard_ShortReal aPolyFactor, aPolyUnits; - theAspect->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits); - aFaceContext.PolygonOffsetMode = aPolyMode; - aFaceContext.PolygonOffsetFactor = (Standard_ShortReal)aPolyFactor; - aFaceContext.PolygonOffsetUnits = (Standard_ShortReal)aPolyUnits; - - aFaceContext.ShaderProgram = theAspect->ShaderProgram(); - - SetAspect (aFaceContext); -} - // ======================================================================= // function : Render // purpose : diff --git a/src/OpenGl/OpenGl_AspectFace.hxx b/src/OpenGl/OpenGl_AspectFace.hxx index d6e8a32be9..dde2e67148 100644 --- a/src/OpenGl/OpenGl_AspectFace.hxx +++ b/src/OpenGl/OpenGl_AspectFace.hxx @@ -16,190 +16,48 @@ #ifndef _OpenGl_AspectFace_Header #define _OpenGl_AspectFace_Header -#include -#include -#include -#include - #include -#include - #include -#include #include #include #include class OpenGl_Texture; -#define OPENGL_AMBIENT_MASK (1<<0) -#define OPENGL_DIFFUSE_MASK (1<<1) -#define OPENGL_SPECULAR_MASK (1<<2) -#define OPENGL_EMISSIVE_MASK (1<<3) - -static const TEL_POFFSET_PARAM THE_DEFAULT_POFFSET = { Aspect_POM_Fill, 1.0F, 0.0F }; - -struct OPENGL_SURF_PROP -{ - Standard_ShortReal amb; - Standard_ShortReal diff; - Standard_ShortReal spec; - Standard_ShortReal emsv; - - Standard_ShortReal trans; - Standard_ShortReal shine; - Standard_ShortReal index; - - Standard_ShortReal env_reflexion; - Standard_Integer isphysic; - - unsigned int color_mask; - - TEL_COLOUR speccol; - TEL_COLOUR difcol; - TEL_COLOUR ambcol; - TEL_COLOUR emscol; - TEL_COLOUR matcol; - - Graphic3d_BSDF BSDF; - - DEFINE_STANDARD_ALLOC -}; - +//! The element holding Graphic3d_AspectFillArea3d. class OpenGl_AspectFace : public OpenGl_Element { public: + //! Empty constructor. Standard_EXPORT OpenGl_AspectFace(); - //! Copy parameters - Standard_EXPORT void SetAspect (const CALL_DEF_CONTEXTFILLAREA& theAspect); + //! Create and assign parameters. + Standard_EXPORT OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect); + + //! Return aspect. + const Handle(Graphic3d_AspectFillArea3d)& Aspect() const { return myAspect; } + + //! Assign parameters. Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect); //! Set edge aspect. - void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) - { - myAspectEdge = *theAspectEdge; - } + void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; } //! @return edge aspect. - const OpenGl_AspectLine* AspectEdge() const - { - return &myAspectEdge; - } + const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; } - //! @return interior style - Aspect_InteriorStyle InteriorStyle() const - { - return myInteriorStyle; - } - - Aspect_InteriorStyle& ChangeInteriorStyle() - { - return myInteriorStyle; - } - - //! @return edge on flag. - int Edge() const - { - return myEdge; - } - - //! @return edge on flag. - int& ChangeEdge() - { - return myEdge; - } - - //! @return hatch type. - int Hatch() const - { - return myHatch; - } - - //! @return hatch type variable. - int& ChangeHatch() - { - return myHatch; - } + //! Returns true if lighting should be disabled. + bool IsNoLighting() const { return myIsNoLighting; } - //! @return distinguishing mode. - int DistinguishingMode() const - { - return myDistinguishingMode; - } - - //! @return distinguishing mode. - int& ChangeDistinguishingMode() - { - return myDistinguishingMode; - } - - //! @return culling mode. - int CullingMode() const - { - return myCullingMode; - } - - //! @return culling mode. - int& ChangeCullingMode() - { - return myCullingMode; - } - - //! @return front material properties. - const OPENGL_SURF_PROP& IntFront() const - { - return myIntFront; - } - - //! @return front material properties. - OPENGL_SURF_PROP& ChangeIntFront() - { - return myIntFront; - } - - //! @return back material properties. - const OPENGL_SURF_PROP& IntBack() const - { - return myIntBack; - } - - //! @return back material properties. - OPENGL_SURF_PROP& ChangeIntBack() - { - return myIntBack; - } - - //! @return polygon offset parameters. - const TEL_POFFSET_PARAM& PolygonOffset() const - { - return myPolygonOffset; - } - - //! @return polygon offset parameters. - TEL_POFFSET_PARAM& ChangePolygonOffset() - { - return myPolygonOffset; - } - - //! @return texture mapping flag. - bool DoTextureMap() const - { - return myDoTextureMap; - } - - //! @return texture mapping flag. - bool& ChangeDoTextureMap() - { - return myDoTextureMap; - } + //! Set if lighting should be disabled or not. + void SetNoLighting (bool theValue) { myIsNoLighting = theValue; } //! @return texture mapping parameters. const Handle(Graphic3d_TextureParams)& TextureParams() const { - return myTexture->GetParams(); + return myAspect->TextureMap()->GetParams(); } //! @return texture map. @@ -207,7 +65,7 @@ public: { if (!myResources.IsTextureReady()) { - myResources.BuildTexture (theCtx, myTexture); + myResources.BuildTexture (theCtx, myAspect->TextureMap()); myResources.SetTextureReady(); } @@ -220,7 +78,7 @@ public: { if (!myResources.IsShaderReady()) { - myResources.BuildShader (theCtx, myShaderProgram); + myResources.BuildShader (theCtx, myAspect->ShaderProgram()); myResources.SetShaderReady(); } @@ -230,25 +88,6 @@ public: Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; Standard_EXPORT virtual void Release (OpenGl_Context* theContext); -protected: - - Standard_EXPORT void convertMaterial (const CALL_DEF_MATERIAL& theMat, - OPENGL_SURF_PROP& theSurf); - -protected: //! @name ordinary aspect properties - - Aspect_InteriorStyle myInteriorStyle; - int myEdge; - int myHatch; - int myDistinguishingMode; - int myCullingMode; - OPENGL_SURF_PROP myIntFront; - OPENGL_SURF_PROP myIntBack; - TEL_POFFSET_PARAM myPolygonOffset; - bool myDoTextureMap; - Handle(Graphic3d_TextureMap) myTexture; - Handle(Graphic3d_ShaderProgram) myShaderProgram; - protected: //! OpenGl resources @@ -283,9 +122,9 @@ protected: } myResources; -protected: - - OpenGl_AspectLine myAspectEdge; + Handle(Graphic3d_AspectFillArea3d) myAspect; + OpenGl_AspectLine myAspectEdge; + bool myIsNoLighting; public: diff --git a/src/OpenGl/OpenGl_AspectLine.cxx b/src/OpenGl/OpenGl_AspectLine.cxx index ccc219ae0a..31fbe7d7e7 100644 --- a/src/OpenGl/OpenGl_AspectLine.cxx +++ b/src/OpenGl/OpenGl_AspectLine.cxx @@ -23,7 +23,6 @@ namespace { - static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }}; static const TCollection_AsciiString THE_EMPTY_KEY; } @@ -31,39 +30,29 @@ namespace // function : OpenGl_AspectLine // purpose : // ======================================================================= -OpenGl_AspectLine::OpenGl_AspectLine () - : myColor(myDefaultColor), - myType(Aspect_TOL_SOLID), - myWidth(1.0F) -{} +OpenGl_AspectLine::OpenGl_AspectLine() +: myAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0)) +{ + // +} // ======================================================================= // function : OpenGl_AspectLine // purpose : // ======================================================================= -OpenGl_AspectLine::OpenGl_AspectLine (const OpenGl_AspectLine &AnOther) - : myColor(AnOther.myColor), - myType(AnOther.myType), - myWidth(AnOther.myWidth) -{} +OpenGl_AspectLine::OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect) +{ + SetAspect (theAspect); +} // ======================================================================= // function : SetAspect // purpose : // ======================================================================= -void OpenGl_AspectLine::SetAspect (const CALL_DEF_CONTEXTLINE &theAspect) +void OpenGl_AspectLine::SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { - myColor.rgb[0] = (float) theAspect.Color.r; - myColor.rgb[1] = (float) theAspect.Color.g; - myColor.rgb[2] = (float) theAspect.Color.b; - myColor.rgb[3] = 1.0f; - myType = (Aspect_TypeOfLine) theAspect.LineType; - myWidth = (float) theAspect.Width; - - // update resource bindings - myShaderProgram = theAspect.ShaderProgram; - - const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId(); + myAspect = theAspect; + const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId(); if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) { myResources.ResetShaderReadiness(); diff --git a/src/OpenGl/OpenGl_AspectLine.hxx b/src/OpenGl/OpenGl_AspectLine.hxx index 9ce57dbc2d..bc35f9ba93 100644 --- a/src/OpenGl/OpenGl_AspectLine.hxx +++ b/src/OpenGl/OpenGl_AspectLine.hxx @@ -18,27 +18,27 @@ #include -#include -#include -#include +#include #include class OpenGl_ShaderProgram; +//! The element holding Graphic3d_AspectLine3d. class OpenGl_AspectLine : public OpenGl_Element { public: + //! Empty constructor. Standard_EXPORT OpenGl_AspectLine(); - Standard_EXPORT OpenGl_AspectLine (const OpenGl_AspectLine &AnOther); + //! Create and assign line aspect. + Standard_EXPORT OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect); - Standard_EXPORT void SetAspect (const CALL_DEF_CONTEXTLINE& theAspect); + //! Return line aspect. + const Handle(Graphic3d_AspectLine3d)& Aspect() const { return myAspect; } - const TEL_COLOUR& Color() const { return myColor; } - TEL_COLOUR& ChangeColor() { return myColor; } - Aspect_TypeOfLine Type() const { return myType; } - float Width() const { return myWidth; } + //! Assign line aspect. + Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect); //! Init and return OpenGl shader program resource. //! @return shader program resource. @@ -46,7 +46,7 @@ public: { if (!myResources.IsShaderReady()) { - myResources.BuildShader (theCtx, myShaderProgram); + myResources.BuildShader (theCtx, myAspect->ShaderProgram()); myResources.SetShaderReady(); } @@ -56,13 +56,6 @@ public: Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; Standard_EXPORT virtual void Release (OpenGl_Context* theContext); -protected: - - TEL_COLOUR myColor; - Aspect_TypeOfLine myType; - float myWidth; - Handle(Graphic3d_ShaderProgram) myShaderProgram; - protected: //! OpenGl resources @@ -86,6 +79,7 @@ protected: Standard_Boolean myIsShaderReady; } myResources; + Handle(Graphic3d_AspectLine3d) myAspect; public: DEFINE_STANDARD_ALLOC diff --git a/src/OpenGl/OpenGl_AspectMarker.cxx b/src/OpenGl/OpenGl_AspectMarker.cxx index 6227c16517..047eb093d3 100644 --- a/src/OpenGl/OpenGl_AspectMarker.cxx +++ b/src/OpenGl/OpenGl_AspectMarker.cxx @@ -29,7 +29,6 @@ namespace { - static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }}; static const TCollection_AsciiString THE_EMPTY_KEY; //! Draw inner point as filled rectangle @@ -54,8 +53,8 @@ namespace struct PM_FONT_INFO { - Tfloat width, height; - Tint offset; + float width, height; + int offset; }; typedef PM_FONT_INFO* pm_font_info; @@ -1461,43 +1460,44 @@ Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1, // purpose : // ======================================================================= OpenGl_AspectMarker::OpenGl_AspectMarker() - : myColor (myDefaultColor), - myType (Aspect_TOM_PLUS), - myScale (1.0f), - myMarkerSize (1.0f), - myMarkerImage(), - myShaderProgram() -{} +: myAspect (new Graphic3d_AspectMarker3d (Aspect_TOM_PLUS, Quantity_Color (Quantity_NOC_WHITE), 1.0f)), + myMarkerSize (1.0f) +{ + // +} + +// ======================================================================= +// function : OpenGl_AspectMarker +// purpose : +// ======================================================================= +OpenGl_AspectMarker::OpenGl_AspectMarker (const Handle(Graphic3d_AspectMarker3d)& theAspect) +: myMarkerSize (1.0f) +{ + SetAspect (theAspect); +} // ======================================================================= // function : SetAspect // purpose : // ======================================================================= -void OpenGl_AspectMarker::SetAspect (const CALL_DEF_CONTEXTMARKER& theAspect) +void OpenGl_AspectMarker::SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) { - myColor.rgb[0] = (float )theAspect.Color.r; - myColor.rgb[1] = (float )theAspect.Color.g; - myColor.rgb[2] = (float )theAspect.Color.b; - myColor.rgb[3] = 1.0f; - myMarkerImage = theAspect.MarkerImage; - myType = theAspect.MarkerType; - myScale = theAspect.Scale; - myShaderProgram = theAspect.ShaderProgram; + myAspect = theAspect; // update sprite resource bindings TCollection_AsciiString aSpriteKey = THE_EMPTY_KEY; TCollection_AsciiString aSpriteAKey = THE_EMPTY_KEY; - myResources.SpriteKeys (myMarkerImage, myType, myScale, myColor, aSpriteKey, aSpriteAKey); + myResources.SpriteKeys (theAspect->GetMarkerImage(), theAspect->Type(), theAspect->Scale(), theAspect->ColorRGBA(), aSpriteKey, aSpriteAKey); if (aSpriteKey.IsEmpty() || myResources.SpriteKey != aSpriteKey || aSpriteAKey.IsEmpty() || myResources.SpriteAKey != aSpriteAKey) { myResources.ResetSpriteReadiness(); - myMarkerSize = theAspect.Scale; + myMarkerSize = theAspect->Scale(); } // update shader program resource bindings - const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId(); + const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId(); if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) { @@ -1561,7 +1561,7 @@ void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Context)& const Handle(Graphic3d_MarkerImage)& theMarkerImage, const Aspect_TypeOfMarker theType, const Standard_ShortReal theScale, - const TEL_COLOUR& theColor, + const Graphic3d_Vec4& theColor, Standard_ShortReal& theMarkerSize) { // generate key for shared resource @@ -1705,10 +1705,10 @@ void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Context)& Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes; GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes); - NCollection_Vec4 aColor (Standard_Real (theColor.rgb[0]), - Standard_Real (theColor.rgb[1]), - Standard_Real (theColor.rgb[2]), - Standard_Real (theColor.rgb[3])); + NCollection_Vec4 aColor (Standard_Real (theColor.r()), + Standard_Real (theColor.g()), + Standard_Real (theColor.b()), + Standard_Real (theColor.a())); const Standard_Integer aSize = Max (aWidth + 2, aHeight + 2); // includes extra margin anImage = new Image_PixMap(); @@ -1849,10 +1849,10 @@ void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Context)& } case Aspect_TOM_BALL: { - NCollection_Vec4 aColor (Standard_Real (theColor.rgb[0]), - Standard_Real (theColor.rgb[1]), - Standard_Real (theColor.rgb[2]), - Standard_Real (theColor.rgb[3])); + NCollection_Vec4 aColor (Standard_Real (theColor.r()), + Standard_Real (theColor.g()), + Standard_Real (theColor.b()), + Standard_Real (theColor.a())); // we draw a set of circles while (aScale >= 1.0f) @@ -1935,7 +1935,7 @@ void OpenGl_AspectMarker::Resources::BuildShader (const Handle(OpenGl_Context)& void OpenGl_AspectMarker::Resources::SpriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage, const Aspect_TypeOfMarker theType, const Standard_ShortReal theScale, - const TEL_COLOUR& theColor, + const Graphic3d_Vec4& theColor, TCollection_AsciiString& theKey, TCollection_AsciiString& theKeyA) { @@ -1958,9 +1958,9 @@ void OpenGl_AspectMarker::Resources::SpriteKeys (const Handle(Graphic3d_MarkerIm { unsigned int aColor[3] = { - (unsigned int )(255.0f * theColor.rgb[0]), - (unsigned int )(255.0f * theColor.rgb[1]), - (unsigned int )(255.0f * theColor.rgb[2]) + (unsigned int )(255.0f * theColor.r()), + (unsigned int )(255.0f * theColor.g()), + (unsigned int )(255.0f * theColor.b()) }; char aBytes[8]; sprintf (aBytes, "%02X%02X%02X", aColor[0], aColor[1], aColor[2]); diff --git a/src/OpenGl/OpenGl_AspectMarker.hxx b/src/OpenGl/OpenGl_AspectMarker.hxx index a74227c78e..02ae41f00f 100644 --- a/src/OpenGl/OpenGl_AspectMarker.hxx +++ b/src/OpenGl/OpenGl_AspectMarker.hxx @@ -16,9 +16,8 @@ #ifndef OpenGl_AspectMarker_Header #define OpenGl_AspectMarker_Header -#include #include -#include +#include #include #include @@ -26,38 +25,25 @@ class OpenGl_PointSprite; class OpenGl_ShaderProgram; +//! The element holding Graphic3d_AspectMarker3d. class OpenGl_AspectMarker : public OpenGl_Element { public: + //! Empty constructor. Standard_EXPORT OpenGl_AspectMarker(); - //! Copy parameters - Standard_EXPORT void SetAspect (const CALL_DEF_CONTEXTMARKER& theAspect); + //! Create and assign parameters. + Standard_EXPORT OpenGl_AspectMarker (const Handle(Graphic3d_AspectMarker3d)& theAspect); - //! @return marker color - const TEL_COLOUR& Color() const - { - return myColor; - } - - //! @return maker type - Aspect_TypeOfMarker Type() const - { - return myType; - } + //! Return the aspect. + const Handle(Graphic3d_AspectMarker3d)& Aspect() const { return myAspect; } - //! @return marker scale - Standard_ShortReal Scale() const - { - return myScale; - } + //! Assign new aspect. + Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect); //! @return marker size - Standard_ShortReal MarkerSize() const - { - return myMarkerSize; - } + Standard_ShortReal MarkerSize() const { return myMarkerSize; } //! Init and return OpenGl point sprite resource. //! @return point sprite texture. @@ -65,7 +51,12 @@ public: { if (!myResources.IsSpriteReady()) { - myResources.BuildSprites (theCtx, myMarkerImage, myType, myScale, myColor, myMarkerSize); + myResources.BuildSprites (theCtx, + myAspect->GetMarkerImage(), + myAspect->Type(), + myAspect->Scale(), + myAspect->ColorRGBA(), + myMarkerSize); myResources.SetSpriteReady(); } @@ -78,7 +69,12 @@ public: { if (!myResources.IsSpriteReady()) { - myResources.BuildSprites (theCtx, myMarkerImage, myType, myScale, myColor, myMarkerSize); + myResources.BuildSprites (theCtx, + myAspect->GetMarkerImage(), + myAspect->Type(), + myAspect->Scale(), + myAspect->ColorRGBA(), + myMarkerSize); myResources.SetSpriteReady(); } @@ -91,7 +87,7 @@ public: { if (!myResources.IsShaderReady()) { - myResources.BuildShader (theCtx, myShaderProgram); + myResources.BuildShader (theCtx, myAspect->ShaderProgram()); myResources.SetShaderReady(); } @@ -101,16 +97,7 @@ public: Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; Standard_EXPORT virtual void Release (OpenGl_Context* theContext); -protected: //! @name ordinary aspect properties - - TEL_COLOUR myColor; - Aspect_TypeOfMarker myType; - Standard_ShortReal myScale; - mutable Standard_ShortReal myMarkerSize; - Handle(Graphic3d_MarkerImage) myMarkerImage; - Handle(Graphic3d_ShaderProgram) myShaderProgram; - -protected: //! @name OpenGl resources +protected: //! OpenGl resources mutable struct Resources @@ -134,7 +121,7 @@ protected: //! @name OpenGl resources const Handle(Graphic3d_MarkerImage)& theMarkerImage, const Aspect_TypeOfMarker theType, const Standard_ShortReal theScale, - const TEL_COLOUR& theColor, + const Graphic3d_Vec4& theColor, Standard_ShortReal& theMarkerSize); Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx, @@ -143,7 +130,7 @@ protected: //! @name OpenGl resources Standard_EXPORT void SpriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage, const Aspect_TypeOfMarker theType, const Standard_ShortReal theScale, - const TEL_COLOUR& theColor, + const Graphic3d_Vec4& theColor, TCollection_AsciiString& theKey, TCollection_AsciiString& theKeyA); @@ -163,6 +150,9 @@ protected: //! @name OpenGl resources } myResources; + Handle(Graphic3d_AspectMarker3d) myAspect; + mutable Standard_ShortReal myMarkerSize; + public: DEFINE_STANDARD_ALLOC diff --git a/src/OpenGl/OpenGl_AspectText.cxx b/src/OpenGl/OpenGl_AspectText.cxx index 000694b8e4..540c6ac97d 100755 --- a/src/OpenGl/OpenGl_AspectText.cxx +++ b/src/OpenGl/OpenGl_AspectText.cxx @@ -23,7 +23,6 @@ namespace { - static const TEL_COLOUR TheDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }}; static const TCollection_AsciiString THE_EMPTY_KEY; } @@ -32,19 +31,20 @@ namespace // purpose : // ======================================================================= OpenGl_AspectText::OpenGl_AspectText() -: myFont ("Courier") , - myColor (TheDefaultColor), - mySubtitleColor (TheDefaultColor), - myAngle (0.0f), - myStyleType (Aspect_TOST_NORMAL), - myDisplayType (Aspect_TODT_NORMAL), - myFontAspect (Font_FA_Regular), - myZoomable (false), - myShaderProgram() +: myAspect (new Graphic3d_AspectText3d (Quantity_Color (Quantity_NOC_WHITE), "Courier", 1.0, 0.0)) { // } +// ======================================================================= +// function : OpenGl_AspectText +// purpose : +// ======================================================================= +OpenGl_AspectText::OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect) +{ + SetAspect (theAspect); +} + // ======================================================================= // function : ~OpenGl_AspectText // purpose : @@ -58,30 +58,10 @@ OpenGl_AspectText::~OpenGl_AspectText() // function : SetAspect // purpose : // ======================================================================= -void OpenGl_AspectText::SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect) +void OpenGl_AspectText::SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { - myFont = theAspect.Font; - - myColor.rgb[0] = (float )theAspect.Color.r; - myColor.rgb[1] = (float )theAspect.Color.g; - myColor.rgb[2] = (float )theAspect.Color.b; - myColor.rgb[3] = 1.0f; - mySubtitleColor.rgb[0] = (float )theAspect.ColorSubTitle.r; - mySubtitleColor.rgb[1] = (float )theAspect.ColorSubTitle.g; - mySubtitleColor.rgb[2] = (float )theAspect.ColorSubTitle.b; - mySubtitleColor.rgb[3] = 1.0f; - - myAngle = (float )theAspect.TextAngle; - myStyleType = (Aspect_TypeOfStyleText )theAspect.Style; - myDisplayType = (Aspect_TypeOfDisplayText )theAspect.DisplayType; - myFontAspect = (Font_FontAspect )theAspect.TextFontAspect; - myZoomable = (theAspect.TextZoomable != 0); - - // update resource bindings - myShaderProgram = theAspect.ShaderProgram; - - const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId(); - + myAspect = theAspect; + const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId(); if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) { myResources.ResetShaderReadiness(); diff --git a/src/OpenGl/OpenGl_AspectText.hxx b/src/OpenGl/OpenGl_AspectText.hxx index b9efe35bde..0be8f3d74e 100755 --- a/src/OpenGl/OpenGl_AspectText.hxx +++ b/src/OpenGl/OpenGl_AspectText.hxx @@ -16,11 +16,8 @@ #ifndef OpenGl_AspectText_Header #define OpenGl_AspectText_Header -#include #include -#include -#include -#include +#include #include @@ -34,88 +31,20 @@ class OpenGl_AspectText : public OpenGl_Element public: + //! Empty constructor. Standard_EXPORT OpenGl_AspectText(); - Standard_EXPORT virtual ~OpenGl_AspectText(); - - //! Copy parameters - Standard_EXPORT void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect); - - //! @return font family name - const TCollection_AsciiString& FontName() const - { - return myFont; - } - - //! @return font family name - TCollection_AsciiString& ChangeFontName() - { - return myFont; - } - - //! @return is zoomable flag - bool IsZoomable() const - { - return myZoomable; - } - - //! @return rotation angle - float Angle() const - { - return myAngle; - } - - //! @return font aspect (regular/bold/italic) - Font_FontAspect FontAspect() const - { - return myFontAspect; - } - - //! @param theValue font aspect (regular/bold/italic) - void SetFontAspect (const Font_FontAspect theValue) - { - myFontAspect = theValue; - } - - //! @return text color - const TEL_COLOUR& Color() const - { - return myColor; - } - //! @return text color - TEL_COLOUR& ChangeColor() - { - return myColor; - } + //! Create and assign parameters. + Standard_EXPORT OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect); - //! @return annotation style - Aspect_TypeOfStyleText StyleType() const - { - return myStyleType; - } - - //! @return subtitle style (none/blend/decale/subtitle) - Aspect_TypeOfDisplayText DisplayType() const - { - return myDisplayType; - } - - void SetDisplayType (const Aspect_TypeOfDisplayText theType) - { - myDisplayType = theType; - } + //! Destructor. + Standard_EXPORT virtual ~OpenGl_AspectText(); - //! @return subtitle color - const TEL_COLOUR& SubtitleColor() const - { - return mySubtitleColor; - } + //! Return text aspect. + const Handle(Graphic3d_AspectText3d)& Aspect() const { return myAspect; } - //! @return subtitle color - TEL_COLOUR& ChangeSubtitleColor() - { - return mySubtitleColor; - } + //! Assign new parameters. + Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect); //! Init and return OpenGl shader program resource. //! @return shader program resource. @@ -123,7 +52,7 @@ public: { if (!myResources.IsShaderReady()) { - myResources.BuildShader (theCtx, myShaderProgram); + myResources.BuildShader (theCtx, myAspect->ShaderProgram()); myResources.SetShaderReady(); } @@ -133,18 +62,6 @@ public: Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; Standard_EXPORT virtual void Release (OpenGl_Context* theContext); -protected: - - TCollection_AsciiString myFont; - TEL_COLOUR myColor; - TEL_COLOUR mySubtitleColor; - float myAngle; - Aspect_TypeOfStyleText myStyleType; - Aspect_TypeOfDisplayText myDisplayType; - Font_FontAspect myFontAspect; - bool myZoomable; - Handle(Graphic3d_ShaderProgram) myShaderProgram; - protected: //! OpenGl resources @@ -169,6 +86,8 @@ protected: } myResources; + Handle(Graphic3d_AspectText3d) myAspect; + public: DEFINE_STANDARD_ALLOC diff --git a/src/OpenGl/OpenGl_BackgroundArray.cxx b/src/OpenGl/OpenGl_BackgroundArray.cxx index ae59c9f644..63f36bfc38 100644 --- a/src/OpenGl/OpenGl_BackgroundArray.cxx +++ b/src/OpenGl/OpenGl_BackgroundArray.cxx @@ -203,9 +203,9 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray() OpenGl_Vec2(-1.0f, 1.0f) }; - Tfloat* aCorners[4] = {}; - Tfloat aDiagCorner1[3] = {}; - Tfloat aDiagCorner2[3] = {}; + float* aCorners[4] = {}; + float aDiagCorner1[3] = {}; + float aDiagCorner2[3] = {}; switch (myGradientParams.type) { diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index f84875f98b..d15758682b 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -144,6 +144,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) myPointSpriteOrig (0), myRenderMode (0), #endif + myToCullBackFaces (false), myReadBuffer (0), myDrawBuffer (0), myDefaultVao (0), @@ -339,6 +340,29 @@ void OpenGl_Context::SetDrawBuffer (const Standard_Integer theDrawBuffer) #endif } +// ======================================================================= +// function : SetCullBackFaces +// purpose : +// ======================================================================= +void OpenGl_Context::SetCullBackFaces (bool theToEnable) +{ + if (myToCullBackFaces == theToEnable) + { + return; + } + + myToCullBackFaces = theToEnable; + if (theToEnable) + { + //glCullFace (GL_BACK); GL_BACK by default + core11fwd->glEnable (GL_CULL_FACE); + } + else + { + core11fwd->glDisable (GL_CULL_FACE); + } +} + // ======================================================================= // function : FetchState // purpose : @@ -2523,10 +2547,10 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect, { myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE), - theAspect->DoTextureMap()); + theAspect->Aspect()->ToMapTexture() ? 1 : 0); myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE), - theAspect->DistinguishingMode()); + theAspect->Aspect()->Distinguish() ? 1 : 0); OpenGl_Material aParams; for (Standard_Integer anIndex = 0; anIndex < 2; ++anIndex) @@ -2539,12 +2563,20 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect, continue; } - const OPENGL_SURF_PROP& aProp = anIndex == 0 || theAspect->DistinguishingMode() != TOn - ? theAspect->IntFront() - : theAspect->IntBack(); - aParams.Init (aProp); - aParams.Diffuse.a() = aProp.trans; - + if (anIndex == 0 || !theAspect->Aspect()->Distinguish()) + { + const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->FrontMaterial(); + const Quantity_Color& aSrcIntColor = theAspect->Aspect()->InteriorColor(); + aParams.Init (aSrcMat, aSrcIntColor); + aParams.Diffuse.a() = 1.0f - (float )aSrcMat.Transparency(); + } + else + { + const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->BackMaterial(); + const Quantity_Color& aSrcIntColor = theAspect->Aspect()->BackInteriorColor(); + aParams.Init (aSrcMat, aSrcIntColor); + aParams.Diffuse.a() = 1.0f - (float )aSrcMat.Transparency(); + } if (theHighlightColor != NULL) { aParams.SetColor (*theHighlightColor); diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 90d06b96a1..91c8833259 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -527,6 +527,12 @@ public: //! @name methods to alter or retrieve current state SetDrawBuffer (theBuffer); } + //! Return back face culling state. + bool ToCullBackFaces() const { return myToCullBackFaces; } + + //! Enable or disable back face culling (glEnable (GL_CULL_FACE)). + Standard_EXPORT void SetCullBackFaces (bool theToEnable); + //! Fetch OpenGl context state. This class tracks value of several OpenGl //! state variables. Consulting the cached values is quicker than //! doing the same via OpenGl API. Call this method if any of the controlled @@ -724,6 +730,7 @@ private: //! @name fields tracking current state Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object Standard_Integer myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default) Standard_Integer myRenderMode; //!< value for active rendering mode + bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE)) Standard_Integer myReadBuffer; //!< current read buffer Standard_Integer myDrawBuffer; //!< current draw buffer unsigned int myDefaultVao; //!< default Vertex Array Object diff --git a/src/OpenGl/OpenGl_GlFunctions.hxx b/src/OpenGl/OpenGl_GlFunctions.hxx index ee8f34483c..e974a6fc27 100644 --- a/src/OpenGl/OpenGl_GlFunctions.hxx +++ b/src/OpenGl/OpenGl_GlFunctions.hxx @@ -182,8 +182,6 @@ #endif #include -#include -#include // GL version can be defined by system gl.h header #if !defined(GL_ES_VERSION_2_0) diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx index 82ea7ba003..94dd4cbf75 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx @@ -14,7 +14,6 @@ // commercial license or contractual agreement. #include -#include #include @@ -112,16 +111,14 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t myLabelValues.SetFontSize (theCtx, myData.ValuesSize()); - myAspectLabels.SetFontAspect (myData.NamesFontAspect()); - myAspectLabels.ChangeFontName() = myData.NamesFont(); + myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect()); + myAspectLabels.Aspect()->SetFont (myData.NamesFont()); - myAspectValues.SetFontAspect (myData.ValuesFontAspect()); - myAspectValues.ChangeFontName() = myData.ValuesFont(); + myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect()); + myAspectValues.Aspect()->SetFont (myData.ValuesFont()); // Grid aspect - myGridLineAspect.ChangeColor().rgb[0] = (Standard_ShortReal) myData.GridColor().Red(); - myGridLineAspect.ChangeColor().rgb[1] = (Standard_ShortReal) myData.GridColor().Green(); - myGridLineAspect.ChangeColor().rgb[2] = (Standard_ShortReal) myData.GridColor().Blue(); + myGridLineAspect.Aspect()->SetColor (myData.GridColor()); } // ======================================================================= @@ -527,7 +524,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset)); - myAspectLabels.ChangeColor() = anAxis.NameColor; + myAspectLabels.Aspect()->SetColor (anAxis.NameColor); theWorkspace->SetAspectText (&myAspectLabels); anAxis.Label.SetPosition (aMiddle); anAxis.Label.Render (theWorkspace); @@ -535,7 +532,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0) { - myAspectValues.ChangeColor() = anAxis.LineAspect.Color(); + myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color()); theWorkspace->SetAspectText (&myAspectValues); Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength(); @@ -729,14 +726,8 @@ OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect, Line (NULL), Arrow (NULL) { - NameColor.rgb[0] = (Standard_ShortReal) theAspect.NameColor().Red(); - NameColor.rgb[1] = (Standard_ShortReal) theAspect.NameColor().Green(); - NameColor.rgb[2] = (Standard_ShortReal) theAspect.NameColor().Blue(); - NameColor.rgb[3] = 1.0f; - - LineAspect.ChangeColor().rgb[0] = (Standard_ShortReal) theAspect.Color().Red(); - LineAspect.ChangeColor().rgb[1] = (Standard_ShortReal) theAspect.Color().Green(); - LineAspect.ChangeColor().rgb[2] = (Standard_ShortReal) theAspect.Color().Blue(); + NameColor = theAspect.NameColor(); + LineAspect.Aspect()->SetColor (theAspect.Color()); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx index 00e686bb9c..ac1da0f960 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx @@ -69,7 +69,7 @@ private: public: OpenGl_Vec3 Direction; - TEL_COLOUR NameColor; + Quantity_Color NameColor; OpenGl_AspectLine LineAspect; mutable OpenGl_Text Label; mutable OpenGl_PrimitiveArray Tickmark; diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 604d455b24..2047328c5f 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -483,23 +483,7 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView, OpenGl_TextParam aTextParam; aTextParam.Height = (int )aHeight; OpenGl_AspectText aTextAspect; - CALL_DEF_CONTEXTTEXT aDefaultContextText = - { - 1, //IsDef - 1, //IsSet - "Courier", //Font - 0.3F, //Space - 1.F, //Expan - { 1.F, 1.F, 1.F }, //Color - (int)Aspect_TOST_NORMAL, //Style - (int)Aspect_TODT_NORMAL, //DisplayType - { 1.F, 1.F, 1.F }, //ColorSubTitle - 0, //TextZoomable - 0.F, //TextAngle - (int)Font_FA_Regular, //TextFontAspect - 0 //ShaderProgram - }; - aTextAspect.SetAspect(aDefaultContextText); + aTextAspect.Aspect()->SetSpace (0.3); TCollection_ExtendedString anExtText = theText; NCollection_String aText = (Standard_Utf16Char* )anExtText.ToExtString(); OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent); diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index cfa99571d8..babde6c0c8 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -61,56 +61,66 @@ OpenGl_Group::~OpenGl_Group() } // ======================================================================= -// function : UpdateAspectLine +// function : SetGroupPrimitivesAspect // purpose : // ======================================================================= -void OpenGl_Group::UpdateAspectLine (const Standard_Boolean theIsGlobal) +void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { - if (!ContextLine.IsDef) + if (IsDeleted()) { return; } - if (theIsGlobal || myFirst == NULL) + if (myAspectLine == NULL) { - if (myAspectLine == NULL) - { - myAspectLine = new OpenGl_AspectLine(); - } - myAspectLine->SetAspect (ContextLine); + myAspectLine = new OpenGl_AspectLine (theAspect); } else { - OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine(); - anAspectLine->SetAspect (ContextLine); - AddElement (anAspectLine); + myAspectLine->SetAspect (theAspect); } + Update(); } // ======================================================================= -// function : UpdateAspectFace +// function : SetPrimitivesAspect // purpose : // ======================================================================= -void OpenGl_Group::UpdateAspectFace (const Standard_Boolean theIsGlobal) +void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { - if (!ContextFillArea.IsDef) + if (myAspectLine == NULL) { + SetGroupPrimitivesAspect (theAspect); return; } + else if (IsDeleted()) + { + return; + } + + OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine (theAspect); + AddElement (anAspectLine); + Update(); +} - if (theIsGlobal || myFirst == NULL) +// ======================================================================= +// function : SetGroupPrimitivesAspect +// purpose : +// ======================================================================= +void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) +{ + if (IsDeleted()) { - if (myAspectFace == NULL) - { - myAspectFace = new OpenGl_AspectFace(); - } - myAspectFace->SetAspect (ContextFillArea); + return; + } + + if (myAspectFace == NULL) + { + myAspectFace = new OpenGl_AspectFace (theAspect); } else { - OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace(); - anAspectFace->SetAspect (ContextFillArea); - AddElement (anAspectFace); + myAspectFace->SetAspect (theAspect); } if (myIsRaytracable) @@ -121,60 +131,115 @@ void OpenGl_Group::UpdateAspectFace (const Standard_Boolean theIsGlobal) aStruct->UpdateStateIfRaytracable (Standard_False); } } + + Update(); } // ======================================================================= -// function : UpdateAspectMarker +// function : SetPrimitivesAspect // purpose : // ======================================================================= -void OpenGl_Group::UpdateAspectMarker (const Standard_Boolean theIsGlobal) +void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { - if (!ContextMarker.IsDef) + if (myAspectFace == NULL) + { + SetGroupPrimitivesAspect (theAspect); + return; + } + else if (IsDeleted()) { return; } - if (theIsGlobal || myFirst == NULL) + OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace (theAspect); + AddElement (anAspectFace); + Update(); +} + +// ======================================================================= +// function : SetGroupPrimitivesAspect +// purpose : +// ======================================================================= +void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker) +{ + if (IsDeleted()) { - if (myAspectMarker == NULL) - { - myAspectMarker = new OpenGl_AspectMarker(); - } - myAspectMarker->SetAspect (ContextMarker); + return; + } + + if (myAspectMarker == NULL) + { + myAspectMarker = new OpenGl_AspectMarker (theAspMarker); } else { - OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker(); - anAspectMarker->SetAspect (ContextMarker); - AddElement (anAspectMarker); + myAspectMarker->SetAspect (theAspMarker); } + Update(); } // ======================================================================= -// function : UpdateAspectText +// function : SetPrimitivesAspect // purpose : // ======================================================================= -void OpenGl_Group::UpdateAspectText (const Standard_Boolean theIsGlobal) +void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker) { - if (!ContextText.IsDef) + if (myAspectMarker == NULL) + { + SetGroupPrimitivesAspect (theAspMarker); + return; + } + else if (IsDeleted()) { return; } - if (theIsGlobal || myFirst == NULL) + OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker (theAspMarker); + AddElement (anAspectMarker); + Update(); +} + +// ======================================================================= +// function : SetGroupPrimitivesAspect +// purpose : +// ======================================================================= +void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText) +{ + if (IsDeleted()) { - if (myAspectText == NULL) - { - myAspectText = new OpenGl_AspectText(); - } - myAspectText->SetAspect (ContextText); + return; + } + + if (myAspectText == NULL) + { + myAspectText = new OpenGl_AspectText (theAspText); } else { - OpenGl_AspectText* anAspectText = new OpenGl_AspectText(); - anAspectText->SetAspect (ContextText); - AddElement (anAspectText); + myAspectText->SetAspect (theAspText); + } + Update(); +} + +// ======================================================================= +// function : SetPrimitivesAspect +// purpose : +// ======================================================================= +void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText) +{ + if (myAspectText == NULL) + { + SetGroupPrimitivesAspect (theAspText); + return; + } + else if (IsDeleted()) + { + return; } + + OpenGl_AspectText* anAspectText = new OpenGl_AspectText (theAspText); + AddElement (anAspectText); + Update(); } // ======================================================================= @@ -328,10 +393,10 @@ void OpenGl_Group::AddElement (OpenGl_Element* theElem) // ======================================================================= void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { - // Is rendering in ADD or IMMEDIATE mode? const Handle(OpenGl_RenderFilter)& aFilter = theWorkspace->GetRenderFilter(); // Setup aspects + theWorkspace->SetAllowFaceCulling (myIsClosed); const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine(); const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace(); const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker(); diff --git a/src/OpenGl/OpenGl_Group.hxx b/src/OpenGl/OpenGl_Group.hxx index ec711d3fb1..710eb03cce 100644 --- a/src/OpenGl/OpenGl_Group.hxx +++ b/src/OpenGl/OpenGl_Group.hxx @@ -16,7 +16,6 @@ #ifndef _OpenGl_Group_Header #define _OpenGl_Group_Header -#include #include #include @@ -48,17 +47,61 @@ public: Standard_EXPORT virtual void Clear (const Standard_Boolean theToUpdateStructureMgr) Standard_OVERRIDE; - //! Update line aspect - Standard_EXPORT virtual void UpdateAspectLine (const Standard_Boolean theIsGlobal) Standard_OVERRIDE; - - //! Update fill aspect - Standard_EXPORT virtual void UpdateAspectFace (const Standard_Boolean theIsGlobal) Standard_OVERRIDE; - - //! Update marker aspect - Standard_EXPORT virtual void UpdateAspectMarker (const Standard_Boolean theIsGlobal) Standard_OVERRIDE; - - //! Update text aspect - Standard_EXPORT virtual void UpdateAspectText (const Standard_Boolean theIsGlobal) Standard_OVERRIDE; + //! Return line aspect. + virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE + { + return myAspectLine != NULL + ? myAspectLine->Aspect() + : Handle(Graphic3d_AspectLine3d)(); + } + + //! Update line aspect. + Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) Standard_OVERRIDE; + + //! Append line aspect as an element. + Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) Standard_OVERRIDE; + + //! Return marker aspect. + virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE + { + return myAspectMarker != NULL + ? myAspectMarker->Aspect() + : Handle(Graphic3d_AspectMarker3d)(); + } + + //! Update marker aspect. + Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) Standard_OVERRIDE; + + //! Append marker aspect as an element. + Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) Standard_OVERRIDE; + + //! Return fill area aspect. + virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE + { + return myAspectFace != NULL + ? myAspectFace->Aspect() + : Handle(Graphic3d_AspectFillArea3d)(); + } + + //! Update face aspect. + Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) Standard_OVERRIDE; + + //! Append face aspect as an element. + Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) Standard_OVERRIDE; + + //! Return marker aspect. + virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE + { + return myAspectText != NULL + ? myAspectText->Aspect() + : Handle(Graphic3d_AspectText3d)(); + } + + //! Update text aspect. + Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE; + + //! Append text aspect as an element. + Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE; //! Add primitive array element Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, @@ -113,9 +156,6 @@ public: //! Is the group ray-tracable (contains ray-tracable elements)? Standard_Boolean IsRaytracable() const { return myIsRaytracable; } - //! Accessor to line aspect (to be removed) - CALL_DEF_CONTEXTLINE& ChangeContextLine() { return ContextLine; } - protected: Standard_EXPORT virtual ~OpenGl_Group(); diff --git a/src/OpenGl/OpenGl_Layer.cxx b/src/OpenGl/OpenGl_Layer.cxx index b3aa452832..bc624cf59f 100644 --- a/src/OpenGl/OpenGl_Layer.cxx +++ b/src/OpenGl/OpenGl_Layer.cxx @@ -590,7 +590,7 @@ Standard_Boolean OpenGl_Layer::Append (const OpenGl_Layer& theOther) void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace, const OpenGl_GlobalLayerSettings& theDefaultSettings) const { - TEL_POFFSET_PARAM anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset(); + Graphic3d_PolygonOffset anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset(); // separate depth buffers if (IsSettingEnabled (Graphic3d_ZLayerDepthClear)) @@ -619,15 +619,15 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace, // handle depth offset if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset)) { - theWorkspace->SetPolygonOffset (Aspect_POM_Fill, - myLayerSettings.DepthOffsetFactor, - myLayerSettings.DepthOffsetUnits); + Graphic3d_PolygonOffset aLayerPolygonOffset; + aLayerPolygonOffset.Mode = Aspect_POM_Fill; + aLayerPolygonOffset.Factor = myLayerSettings.DepthOffsetFactor; + aLayerPolygonOffset.Units = myLayerSettings.DepthOffsetUnits; + theWorkspace->SetPolygonOffset (aLayerPolygonOffset); } else { - theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode, - anAppliedOffsetParams.factor, - anAppliedOffsetParams.units); + theWorkspace->SetPolygonOffset (anAppliedOffsetParams); } // handle depth write @@ -638,9 +638,7 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace, theWorkspace->IsCullingEnabled() ? renderTraverse (theWorkspace) : renderAll (theWorkspace); // always restore polygon offset between layers rendering - theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode, - anAppliedOffsetParams.factor, - anAppliedOffsetParams.units); + theWorkspace->SetPolygonOffset (anAppliedOffsetParams); // restore environment texture if (!myLayerSettings.UseEnvironmentTexture) diff --git a/src/OpenGl/OpenGl_Layer.hxx b/src/OpenGl/OpenGl_Layer.hxx index a6eddd279f..09d8b16416 100644 --- a/src/OpenGl/OpenGl_Layer.hxx +++ b/src/OpenGl/OpenGl_Layer.hxx @@ -19,8 +19,6 @@ #include #include -#include - #include #include #include diff --git a/src/OpenGl/OpenGl_LayerList.cxx b/src/OpenGl/OpenGl_LayerList.cxx index dfa89b5353..c266a639a9 100644 --- a/src/OpenGl/OpenGl_LayerList.cxx +++ b/src/OpenGl/OpenGl_LayerList.cxx @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/src/OpenGl/OpenGl_LayerList.hxx b/src/OpenGl/OpenGl_LayerList.hxx index d54bbe4b59..a8fa966128 100644 --- a/src/OpenGl/OpenGl_LayerList.hxx +++ b/src/OpenGl/OpenGl_LayerList.hxx @@ -19,8 +19,6 @@ #include #include -#include - #include #include diff --git a/src/OpenGl/OpenGl_LineAttributes.cxx b/src/OpenGl/OpenGl_LineAttributes.cxx index d06ca3b522..be48861198 100644 --- a/src/OpenGl/OpenGl_LineAttributes.cxx +++ b/src/OpenGl/OpenGl_LineAttributes.cxx @@ -22,7 +22,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource) static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = { - //TEL_HS_SOLID + // Aspect_HS_SOLID { 0xFFFFFFFF, 0xFFFFFFFF, @@ -57,7 +57,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0xFFFFFFFF, 0xFFFFFFFF }, - //TEL_HS_CROSS + // Aspect_HS_GRID_DIAGONAL { 0xFFFFFFFF, 0xBBBBBBBB, @@ -92,7 +92,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0xEEEEEEEE, 0xBBBBBBBB }, - //TEL_HS_CROSS_SPARSE + // Aspect_HS_GRID_DIAGONAL_WIDE { 0x81818181, 0x24242424, @@ -127,7 +127,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x18181818, 0x42424242 }, - //TEL_HS_GRID + // Aspect_HS_GRID { 0xFFFFFFFF, 0x88888888, @@ -162,7 +162,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0xFFFFFFFF, 0x88888888 }, - //TEL_HS_GRID_SPARSE + // Aspect_HS_GRID_WIDE { 0xFFFFFFFF, 0x80808080, @@ -197,7 +197,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x80808080, 0x80808080 }, - //TEL_HS_DIAG_45 + // Aspect_HS_DIAGONAL_45 { 0x88888888, 0x22222222, @@ -232,7 +232,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x88888888, 0x22222222 }, - //TEL_HS_DIAG_135 + // Aspect_HS_DIAGONAL_135 { 0x11111111, 0x44444444, @@ -267,7 +267,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x11111111, 0x44444444 }, - //TEL_HS_HORIZONTAL + // Aspect_HS_HORIZONTAL { 0xFFFFFFFF, 0x00000000, @@ -302,7 +302,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0xFFFFFFFF, 0x00000000 }, - //TEL_HS_VERTICAL + // Aspect_HS_VERTICAL { 0x11111111, 0x11111111, @@ -337,7 +337,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x11111111, 0x11111111 }, - //TEL_HS_DIAG_45_SPARSE + // Aspect_HS_DIAGONAL_45_WIDE { 0x80808080, 0x20202020, @@ -372,7 +372,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x08080808, 0x02020202 }, - //TEL_HS_DIAG_135_SPARSE + // Aspect_HS_DIAGONAL_135_WIDE { 0x01010101, 0x04040404, @@ -407,7 +407,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x10101010, 0x40404040 }, - //TEL_HS_HORIZONTAL_SPARSE + // Aspect_HS_HORIZONTAL_WIDE { 0xFFFFFFFF, 0x00000000, @@ -442,7 +442,7 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] = 0x00000000, 0x00000000 }, - //TEL_HS_VERTICAL_SPARSE + // Aspect_HS_VERTICAL_WIDE { 0x10101010, 0x10101010, diff --git a/src/OpenGl/OpenGl_LineAttributes.hxx b/src/OpenGl/OpenGl_LineAttributes.hxx index 8cfca1d184..39392b2fd8 100644 --- a/src/OpenGl/OpenGl_LineAttributes.hxx +++ b/src/OpenGl/OpenGl_LineAttributes.hxx @@ -24,6 +24,8 @@ class OpenGl_Context; +#define TEL_HS_USER_DEF_START 15 + class OpenGl_LineAttributes : public OpenGl_Resource { public: diff --git a/src/OpenGl/OpenGl_Matrix.hxx b/src/OpenGl/OpenGl_Matrix.hxx index a81a3661f2..47b84af018 100644 --- a/src/OpenGl/OpenGl_Matrix.hxx +++ b/src/OpenGl/OpenGl_Matrix.hxx @@ -16,7 +16,7 @@ #ifndef OpenGl_Matrix_Header #define OpenGl_Matrix_Header -#include +#include struct OpenGl_Matrix { diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index fc31b70f61..5bab0c4bcc 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -440,7 +440,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp // function : drawEdges // purpose : // ======================================================================= -void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeColour, +void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeColour, const Handle(OpenGl_Workspace)& theWorkspace) const { const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext(); @@ -465,7 +465,11 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo if (aGlContext->core20fwd != NULL) { - aGlContext->ShaderManager()->BindLineProgram (NULL, anAspect->Type() != Aspect_TOL_SOLID, Standard_False, Standard_False, anAspect->ShaderProgramRes (aGlContext)); + aGlContext->ShaderManager()->BindLineProgram (NULL, + anAspect->Aspect()->Type() != Aspect_TOL_SOLID, + Standard_False, + Standard_False, + anAspect->ShaderProgramRes (aGlContext)); } /// OCC22236 NOTE: draw edges for all situations: @@ -474,9 +478,9 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo /// 3) draw primitive's edges by vertexes if no edges and bounds array is specified myVboAttribs->BindPositionAttribute (aGlContext); - aGlContext->SetColor4fv (*(const OpenGl_Vec4* )theEdgeColour->rgb); - aGlContext->SetTypeOfLine (anAspect->Type()); - aGlContext->SetLineWidth (anAspect->Width()); + aGlContext->SetColor4fv (theEdgeColour); + aGlContext->SetTypeOfLine (anAspect->Aspect()->Type()); + aGlContext->SetLineWidth (anAspect->Aspect()->Width()); if (!myVboIndices.IsNull()) { @@ -513,7 +517,7 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo } else { - glDrawArrays (myDrawMode, 0, myAttribs->NbElements); + glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements); } // unbind buffers @@ -561,7 +565,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork aCtx->SetPointSize (1.0f); return; } - else if (anAspectMarker->Type() == Aspect_TOM_POINT) + else if (anAspectMarker->Aspect()->Type() == Aspect_TOM_POINT) { aCtx->SetPointSize (anAspectMarker->MarkerSize()); aCtx->core11fwd->glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements); @@ -569,7 +573,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork } #if !defined(GL_ES_VERSION_2_0) // Textured markers will be drawn with the glBitmap - else if (anAspectMarker->Type() != Aspect_TOM_POINT + else if (anAspectMarker->Aspect()->Type() != Aspect_TOM_POINT && !aSpriteNorm.IsNull()) { /**if (!isHilight && (myPArray->vcolours != NULL)) @@ -712,12 +716,11 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace myIsVboInit = Standard_True; } - Tint aFrontLightingModel = anAspectFace->IntFront().color_mask; const Standard_Boolean hasColorAttrib = !myVboAttribs.IsNull() && myVboAttribs->HasColorAttribute(); - const Standard_Boolean isLightOn = aFrontLightingModel != 0 - && !myVboAttribs.IsNull() - && myVboAttribs->HasNormalAttribute(); + const Standard_Boolean isLightOn = !anAspectFace->IsNoLighting() + && !myVboAttribs.IsNull() + && myVboAttribs->HasNormalAttribute(); #if !defined(GL_ES_VERSION_2_0) // manage FFP lighting if (aCtx->core11 != NULL) @@ -739,7 +742,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace aTextureBack = theWorkspace->DisableTexture(); } - if ((myDrawMode > GL_LINE_STRIP && anAspectFace->InteriorStyle() != Aspect_IS_EMPTY) || + if ((myDrawMode > GL_LINE_STRIP && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_EMPTY) || (myDrawMode <= GL_LINE_STRIP)) { const bool toHilight = theWorkspace->ToHighlight(); @@ -769,7 +772,11 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace case GL_LINES: case GL_LINE_STRIP: { - aCtx->ShaderManager()->BindLineProgram (NULL, anAspectLine->Type() != Aspect_TOL_SOLID, isLightOn, hasVertColor, anAspectLine->ShaderProgramRes (aCtx)); + aCtx->ShaderManager()->BindLineProgram (NULL, + anAspectLine->Aspect()->Type() != Aspect_TOL_SOLID, + isLightOn, + hasVertColor, + anAspectLine->ShaderProgramRes (aCtx)); break; } default: @@ -792,7 +799,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace // All primitives should gather material properties from the AspectFace in shading mode if (isLightOn) { - aCtx->SetShadingMaterial (anAspectFace, theWorkspace->ToHighlight() ? (const OpenGl_Vec4* )theWorkspace->HighlightColor : NULL); + aCtx->SetShadingMaterial (anAspectFace, theWorkspace->ToHighlight() ? theWorkspace->HighlightColor : NULL); } if (!theWorkspace->ActiveTexture().IsNull() @@ -803,22 +810,22 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace if (myDrawMode <= GL_LINE_STRIP) { - const TEL_COLOUR& aLineColor = myDrawMode == GL_POINTS ? theWorkspace->MarkerColor() : theWorkspace->LineColor(); - aCtx->SetColor4fv (*(const OpenGl_Vec4* )aLineColor.rgb); + const OpenGl_Vec4& aLineColor = myDrawMode == GL_POINTS ? theWorkspace->MarkerColor() : theWorkspace->LineColor(); + aCtx->SetColor4fv (aLineColor); } else { - const TEL_COLOUR& anInteriorColor = theWorkspace->InteriorColor(); - aCtx->SetColor4fv (*(const OpenGl_Vec4* )anInteriorColor.rgb); + const OpenGl_Vec4& anInteriorColor = theWorkspace->InteriorColor(); + aCtx->SetColor4fv (anInteriorColor); } if (myDrawMode == GL_LINES || myDrawMode == GL_LINE_STRIP) { - aCtx->SetTypeOfLine (anAspectLine->Type()); - aCtx->SetLineWidth (anAspectLine->Width()); + aCtx->SetTypeOfLine (anAspectLine->Aspect()->Type()); + aCtx->SetLineWidth (anAspectLine->Aspect()->Width()); } - const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->InteriorStyle() != Aspect_IS_HIDDENLINE + const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_HIDDENLINE ? myBounds->Colors : NULL; drawArray (theWorkspace, aFaceColors, hasColorAttrib); @@ -830,18 +837,18 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace } else { - if (anAspectFace->Edge() - || anAspectFace->InteriorStyle() == Aspect_IS_HIDDENLINE) + if (anAspectFace->Aspect()->ToDrawEdges() + || anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE) { - const TEL_COLOUR* anEdgeColor = &theWorkspace->EdgeColor(); + const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor(); drawEdges (anEdgeColor, theWorkspace); // restore OpenGL polygon mode if needed #if !defined(GL_ES_VERSION_2_0) - if (anAspectFace->InteriorStyle() >= Aspect_IS_HATCH) + if (anAspectFace->Aspect()->InteriorStyle() >= Aspect_IS_HATCH) { glPolygonMode (GL_FRONT_AND_BACK, - anAspectFace->InteriorStyle() == Aspect_IS_POINT ? GL_POINT : GL_FILL); + anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_POINT ? GL_POINT : GL_FILL); } #endif } diff --git a/src/OpenGl/OpenGl_PrimitiveArray.hxx b/src/OpenGl/OpenGl_PrimitiveArray.hxx index 7b03f4fb01..167dfe2298 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.hxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.hxx @@ -18,7 +18,6 @@ #include -#include #include #include #include @@ -111,7 +110,7 @@ private: const Standard_Boolean theHasVertColor) const; //! Auxiliary procedures - void drawEdges (const TEL_COLOUR* theEdgeColour, + void drawEdges (const OpenGl_Vec4& theEdgeColour, const Handle(OpenGl_Workspace)& theWorkspace) const; void drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const; diff --git a/src/OpenGl/OpenGl_ShaderProgram.hxx b/src/OpenGl/OpenGl_ShaderProgram.hxx index 8d86d27687..a2b23fc175 100755 --- a/src/OpenGl/OpenGl_ShaderProgram.hxx +++ b/src/OpenGl/OpenGl_ShaderProgram.hxx @@ -23,8 +23,6 @@ #include #include -#include - #include #include #include diff --git a/src/OpenGl/OpenGl_ShaderStates.hxx b/src/OpenGl/OpenGl_ShaderStates.hxx index cda068e3f6..7ec45cd8f2 100755 --- a/src/OpenGl/OpenGl_ShaderStates.hxx +++ b/src/OpenGl/OpenGl_ShaderStates.hxx @@ -16,7 +16,6 @@ #ifndef _OpenGl_State_HeaderFile #define _OpenGl_State_HeaderFile -#include #include #include #include diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 05d0dd6b16..f20c254a26 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -73,7 +73,7 @@ public: glDisable (GL_LIGHTING); // Use highlight colors - theWorkspace->GetGlContext()->core11->glColor3fv (theWorkspace->LineColor().rgb); + theWorkspace->GetGlContext()->core11->glColor3fv (theWorkspace->LineColor().GetData()); glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts); @@ -209,12 +209,7 @@ void OpenGl_Structure::HighlightWithBndBox (const Handle(Graphic3d_Structure)& t myHighlightBox = new OpenGl_Group (theStruct); } - CALL_DEF_CONTEXTLINE& aContextLine = myHighlightBox->ChangeContextLine(); - aContextLine.IsDef = 1; - aContextLine.Color = HighlightColor; - aContextLine.LineType = Aspect_TOL_SOLID; - aContextLine.Width = 1.0f; - myHighlightBox->UpdateAspectLine (Standard_True); + myHighlightBox->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (HighlightColor, Aspect_TOL_SOLID, 1.0)); OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (myBndBox); myHighlightBox->AddElement (aBndBoxPrs); @@ -230,13 +225,12 @@ void OpenGl_Structure::setHighlightColor (const Handle(OpenGl_Context)& theGlCtx clearHighlightBox (theGlCtx); if (myHighlightColor == NULL) { - myHighlightColor = new TEL_COLOUR(); + myHighlightColor = new OpenGl_Vec4 (theColor, 1.0f); + } + else + { + myHighlightColor->xyz() = theColor; } - - myHighlightColor->rgb[0] = theColor.r(); - myHighlightColor->rgb[1] = theColor.g(); - myHighlightColor->rgb[2] = theColor.b(); - myHighlightColor->rgb[3] = 1.F; } // ======================================================================= @@ -529,7 +523,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con } // Apply highlight color - const TEL_COLOUR *aHighlightColor = theWorkspace->HighlightColor; + const OpenGl_Vec4* aHighlightColor = theWorkspace->HighlightColor; if (myHighlightColor) theWorkspace->HighlightColor = myHighlightColor; diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 222bfcb116..61560f8fa0 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -31,7 +31,6 @@ #include #include -#include class OpenGl_Structure; class OpenGl_GraphicDriver; @@ -196,7 +195,7 @@ protected: protected: Handle(OpenGl_Group) myHighlightBox; - TEL_COLOUR* myHighlightColor; + OpenGl_Vec4* myHighlightColor; OpenGl_Structure* myInstancedStructure; diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index aa40ca3a45..394c97a8f0 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -113,7 +113,7 @@ namespace { char aPsFont[64]; - getGL2PSFontName (theAspect.FontName().ToCString(), aPsFont); + getGL2PSFontName (theAspect.Aspect()->Font().ToCString(), aPsFont); #if !defined(GL_ES_VERSION_2_0) if (theIs2d) @@ -132,7 +132,7 @@ namespace // Standard GL2PS's alignment isn't used, because it doesn't work correctly // for all formats, therefore alignment is calculated manually relative // to the bottom-left corner, which corresponds to the GL2PS_TEXT_BL value - gl2psTextOpt (theText.ToCString(), aPsFont, (GLshort)theHeight, GL2PS_TEXT_BL, theAspect.Angle()); + gl2psTextOpt (theText.ToCString(), aPsFont, (GLshort)theHeight, GL2PS_TEXT_BL, (float )theAspect.Aspect()->GetTextAngle()); } #endif @@ -456,7 +456,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_PrinterContext)& thePrintCtx, const OpenGl_AspectText& theTextAspect, const unsigned int theResolution) const { - render (thePrintCtx, theCtx, theTextAspect, theTextAspect.Color(), theTextAspect.SubtitleColor(), theResolution); + render (thePrintCtx, theCtx, theTextAspect, + theTextAspect.Aspect()->ColorRGBA(), + theTextAspect.Aspect()->ColorSubTitleRGBA(), + theResolution); } // ======================================================================= @@ -483,7 +486,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, { Graphic3d_TransformUtils::Translate (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f); Graphic3d_TransformUtils::Scale (aModViewMat, 1.f, -1.f, 1.f); - Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect.Angle(), 0.f, 0.f, 1.f); + Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f); } else { @@ -525,10 +528,10 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, else { Graphic3d_TransformUtils::Translate (aModViewMat, anObjX, anObjY, anObjZ); - Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0); + Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0); } - if (!theTextAspect.IsZoomable()) + if (!theTextAspect.Aspect()->GetTextZoomable()) { #ifdef _WIN32 // if the context has assigned printer context, use it's parameters @@ -629,8 +632,10 @@ TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect const Standard_Integer theHeight, const unsigned int theResolution) { - const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular; - return theAspect.FontName() + const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined + ? theAspect.Aspect()->GetTextFontAspect() + : Font_FA_Regular; + return theAspect.Aspect()->Font() + TCollection_AsciiString(":") + Standard_Integer(anAspect) + TCollection_AsciiString(":") + Standard_Integer(theResolution) + TCollection_AsciiString(":") + theHeight; @@ -655,8 +660,10 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, if (!theCtx->GetResource (theKey, aFont)) { Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance(); - const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.FontName()); - const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular; + const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.Aspect()->Font()); + const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined + ? theAspect.Aspect()->GetTextFontAspect() + : Font_FA_Regular; Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight); Handle(Font_FTFont) aFontFt; if (!aRequestedFont.IsNull()) @@ -670,7 +677,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { TCollection_ExtendedString aMsg; aMsg += "Font '"; - aMsg += theAspect.FontName(); + aMsg += theAspect.Aspect()->Font(); aMsg += "' - initialization of GL resources has failed!"; theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); aFontFt.Nullify(); @@ -682,7 +689,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { TCollection_ExtendedString aMsg; aMsg += "Font '"; - aMsg += theAspect.FontName(); + aMsg += theAspect.Aspect()->Font(); aMsg += "' is broken or has incompatible format! File path: "; aMsg += aRequestedFont->FontPath()->ToCString(); theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); @@ -694,7 +701,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { TCollection_ExtendedString aMsg; aMsg += "Font '"; - aMsg += theAspect.FontName(); + aMsg += theAspect.Aspect()->Font(); aMsg += "' is not found in the system!"; theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); aFont = new OpenGl_Font (aFontFt, theKey); @@ -712,8 +719,8 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, const Handle(OpenGl_Context)& theCtx, const OpenGl_AspectText& theTextAspect, - const TEL_COLOUR& theColorText, - const TEL_COLOUR& theColorSubs, + const OpenGl_Vec4& theColorText, + const OpenGl_Vec4& theColorSubs, const unsigned int theResolution) const { if (myString.IsEmpty()) @@ -822,7 +829,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, z2); myScaleHeight = (y2 - y1) / h; - if (theTextAspect.IsZoomable()) + if (theTextAspect.Aspect()->GetTextZoomable()) { myExportHeight = (float )h; } @@ -838,7 +845,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, // setup depth test if (myIs2d - || theTextAspect.StyleType() == Aspect_TOST_ANNOTATION) + || theTextAspect.Aspect()->Style() == Aspect_TOST_ANNOTATION) { glDisable (GL_DEPTH_TEST); } @@ -871,7 +878,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // extra drawings - switch (theTextAspect.DisplayType()) + switch (theTextAspect.Aspect()->DisplayType()) { case Aspect_TODT_BLEND: { @@ -886,7 +893,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, #if !defined(GL_ES_VERSION_2_0) if (theCtx->core11 != NULL) { - theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorSubs.rgb); + theCtx->SetColor4fv (theColorSubs); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f)); glBindTexture (GL_TEXTURE_2D, 0); @@ -902,7 +909,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, } case Aspect_TODT_DEKALE: { - theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorSubs.rgb); + theCtx->SetColor4fv (theColorSubs); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, +1.0f, 0.00001f)); drawText (thePrintCtx, theCtx, theTextAspect); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, -1.0f, 0.00001f)); @@ -921,7 +928,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, } // main draw call - theCtx->SetColor4fv (*(const OpenGl_Vec4* )theColorText.rgb); + theCtx->SetColor4fv (theColorText); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f)); drawText (thePrintCtx, theCtx, theTextAspect); @@ -938,7 +945,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, } #endif - if (theTextAspect.DisplayType() == Aspect_TODT_DIMENSION) + if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION) { setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f)); diff --git a/src/OpenGl/OpenGl_Text.hxx b/src/OpenGl/OpenGl_Text.hxx index 224db5958c..2c75c6fb91 100755 --- a/src/OpenGl/OpenGl_Text.hxx +++ b/src/OpenGl/OpenGl_Text.hxx @@ -137,8 +137,8 @@ private: void render (const Handle(OpenGl_PrinterContext)& thePrintCtx, const Handle(OpenGl_Context)& theCtx, const OpenGl_AspectText& theTextAspect, - const TEL_COLOUR& theColorText, - const TEL_COLOUR& theColorSubs, + const OpenGl_Vec4& theColorText, + const OpenGl_Vec4& theColorSubs, const unsigned int theResolution) const; protected: diff --git a/src/OpenGl/OpenGl_TextParam.hxx b/src/OpenGl/OpenGl_TextParam.hxx index 8dc6279fca..14dd7de392 100644 --- a/src/OpenGl/OpenGl_TextParam.hxx +++ b/src/OpenGl/OpenGl_TextParam.hxx @@ -16,7 +16,6 @@ #ifndef _OpenGl_TextParam_Header #define _OpenGl_TextParam_Header -#include #include #include diff --git a/src/OpenGl/OpenGl_Trihedron.cxx b/src/OpenGl/OpenGl_Trihedron.cxx index 2cd0bf750d..a0b6167aa1 100644 --- a/src/OpenGl/OpenGl_Trihedron.cxx +++ b/src/OpenGl/OpenGl_Trihedron.cxx @@ -186,9 +186,10 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con OpenGl_AspectFace anAspectY; OpenGl_AspectFace anAspectZ; OpenGl_AspectLine anAspectLine; - memcpy (anAspectX.ChangeIntFront().matcol.rgb, myXColor.GetData(), sizeof (TEL_COLOUR)); - memcpy (anAspectY.ChangeIntFront().matcol.rgb, myYColor.GetData(), sizeof (TEL_COLOUR)); - memcpy (anAspectZ.ChangeIntFront().matcol.rgb, myZColor.GetData(), sizeof (TEL_COLOUR)); + anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb())); + anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb())); + anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb())); + OpenGl_Mat4d aModelMatrix; aModelMatrix.Convert (aContext->WorldViewState.Current()); OpenGl_Mat4d aModelViewX (aModelMatrix); @@ -197,11 +198,8 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con // Set line aspect const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->ApplyAspectLine(); - CALL_DEF_CONTEXTLINE aLineAspect = {1, 1, { 1.F, 1.F, 1.F }, aCurrentAspectLine->Type(), aCurrentAspectLine->Width(), 0}; - aLineAspect.Color.r = myZColor.r(); - aLineAspect.Color.g = myZColor.g(); - aLineAspect.Color.b = myZColor.b(); - anAspectLine.SetAspect (aLineAspect); + Handle(Graphic3d_AspectLine3d) anAspectLine3d = new Graphic3d_AspectLine3d (Quantity_Color(), aCurrentAspectLine->Aspect()->Type(), aCurrentAspectLine->Aspect()->Width()); + anAspectLine.SetAspect (anAspectLine3d); // Disable depth test and face culling GLboolean wasDepthMaskEnabled = GL_FALSE; @@ -231,6 +229,7 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con // Z axis const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace(&anAspectZ); + anAspectLine3d->SetColor (Quantity_Color (myZColor.rgb())); theWorkspace->SetAspectLine (&anAspectLine); myLine.Render (theWorkspace); Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aLineLength); @@ -245,10 +244,7 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con aContext->WorldViewState.SetCurrent (aModelViewX); aContext->ApplyWorldViewMatrix(); - aLineAspect.Color.r = myXColor.r(); - aLineAspect.Color.g = myXColor.g(); - aLineAspect.Color.b = myXColor.b(); - anAspectLine.SetAspect (aLineAspect); + anAspectLine3d->SetColor (Quantity_Color (myXColor.rgb())); theWorkspace->SetAspectLine (&anAspectLine); myLine.Render (theWorkspace); Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aLineLength); @@ -263,10 +259,7 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con aContext->WorldViewState.SetCurrent (aModelViewY); aContext->ApplyWorldViewMatrix(); - aLineAspect.Color.r = myYColor.r(); - aLineAspect.Color.g = myYColor.g(); - aLineAspect.Color.b = myYColor.b(); - anAspectLine.SetAspect (aLineAspect); + anAspectLine3d->SetColor (Quantity_Color (myYColor.rgb())); theWorkspace->SetAspectLine (&anAspectLine); myLine.Render (theWorkspace); Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aLineLength); @@ -326,7 +319,7 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa const GLdouble aScale = myScale * myRatio; const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine(); - const TEL_COLOUR& aLineColor = anAspectLine->Color(); + const OpenGl_Vec4& aLineColor = anAspectLine->Aspect()->ColorRGBA(); // Create the trihedron const Standard_Real THE_CYLINDER_LENGTH = 0.75; @@ -389,10 +382,10 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa OpenGl_AspectFace anAspectX; OpenGl_AspectFace anAspectY; OpenGl_AspectFace anAspectZ; - memcpy (anAspectX.ChangeIntFront().matcol.rgb, myXColor.GetData(), sizeof (TEL_COLOUR)); - memcpy (anAspectY.ChangeIntFront().matcol.rgb, myYColor.GetData(), sizeof (TEL_COLOUR)); - memcpy (anAspectZ.ChangeIntFront().matcol.rgb, myZColor.GetData(), sizeof (TEL_COLOUR)); - memcpy (anAspectC.ChangeIntFront().matcol.rgb, aLineColor.rgb, sizeof (TEL_COLOUR)); + anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb())); + anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb())); + anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb())); + anAspectC.Aspect()->SetInteriorColor (Quantity_Color (aLineColor.rgb())); OpenGl_Mat4d aModelMatrix; aModelMatrix.Convert (aContext->WorldViewState.Current()); @@ -501,10 +494,9 @@ OpenGl_Trihedron::OpenGl_Trihedron() myLine (NULL), // do not register arrays UID - trihedron is not intended to be drawn by Ray Tracing engine myCircle (NULL) { - const TEL_COLOUR aWhiteColor = {{ 1.0f, 1.0f, 1.0f, 1.0f }}; - myAspectLine.ChangeColor() = aWhiteColor; - myAspectText.ChangeColor() = aWhiteColor; - myAspectText.ChangeFontName() = "Courier"; + myAspectLine.SetAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0)); + myAspectText.Aspect()->SetColor (Quantity_NOC_WHITE); + myAspectText.Aspect()->SetFont ("Courier"); } // ======================================================================= @@ -607,9 +599,7 @@ void OpenGl_Trihedron::SetNbFacets (const Standard_Integer theNbFacets) // ======================================================================= void OpenGl_Trihedron::SetLabelsColor (const Quantity_Color& theColor) { - myAspectText.ChangeColor().rgb[0] = float(theColor.Red()); - myAspectText.ChangeColor().rgb[1] = float(theColor.Green()); - myAspectText.ChangeColor().rgb[2] = float(theColor.Blue()); + myAspectText.Aspect()->SetColor (theColor); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index 17280c126f..39037a70fb 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -45,8 +45,7 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView) namespace { static const OPENGL_ZCLIP myDefaultZClip = { { Standard_False, 0.F }, { Standard_False, 1.F } }; - static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } }; - static const TEL_COLOUR myDefaultBg = { { 0.F, 0.F, 0.F, 1.F } }; + static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f) }; } // ======================================================================= @@ -67,7 +66,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr, myCulling (Standard_True), myShadingModel (Graphic3d_TOSM_FACET), myBackfacing (Graphic3d_TOBM_AUTOMATIC), - myBgColor (myDefaultBg), + myBgColor (Quantity_NOC_BLACK), myFog (myDefaultFog), myZClip (myDefaultZClip), myCamera (new Graphic3d_Camera()), @@ -401,7 +400,7 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3 // ======================================================================= Aspect_Background OpenGl_View::Background() const { - return Aspect_Background (Quantity_Color (myBgColor.rgb[0], myBgColor.rgb[1], myBgColor.rgb[2], Quantity_TOC_RGB)); + return Aspect_Background (myBgColor.GetRGB()); } // ======================================================================= @@ -410,11 +409,8 @@ Aspect_Background OpenGl_View::Background() const // ======================================================================= void OpenGl_View::SetBackground (const Aspect_Background& theBackground) { - Quantity_Color aBgColor = theBackground.Color(); - myBgColor.rgb[0] = static_cast (aBgColor.Red()); - myBgColor.rgb[1] = static_cast (aBgColor.Green()); - myBgColor.rgb[2] = static_cast (aBgColor.Blue()); - myFog.Color = myBgColor; + myBgColor.SetRGB (theBackground.Color()); + myFog.Color = myBgColor; } // ======================================================================= @@ -461,6 +457,7 @@ void OpenGl_View::SetBackgroundImage (const TCollection_AsciiString& theFilePath Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f)); anAspect->SetTextureMap (aTextureMap); anAspect->SetInteriorStyle (Aspect_IS_SOLID); + anAspect->SetSuppressBackFaces (false); // Enable texture mapping if (aTextureMap->IsDone()) { diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 0b713c0195..2d51c1f19a 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -28,8 +28,6 @@ #include #include -#include - #include #include #include @@ -72,7 +70,7 @@ struct OPENGL_FOG Standard_Boolean IsOn; Standard_ShortReal Front; /* in the range [0., 1.] */ Standard_ShortReal Back; /* in the range [0., 1.] */ - TEL_COLOUR Color; + OpenGl_Vec4 Color; }; struct OpenGl_Matrix; @@ -414,7 +412,7 @@ public: public: //! Returns background color. - const TEL_COLOUR& BackgroundColor() const { return myBgColor; } + const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; } //! Change trihedron. OpenGl_Trihedron& ChangeTrihedron() { return myTrihedron; } @@ -569,7 +567,7 @@ protected: Standard_Boolean myCulling; Graphic3d_TypeOfShadingModel myShadingModel; Graphic3d_TypeOfBackfacingModel myBackfacing; - TEL_COLOUR myBgColor; + Quantity_ColorRGBA myBgColor; OPENGL_FOG myFog; OPENGL_ZCLIP myZClip; Graphic3d_SequenceOfHClipPlane myClipPlanes; diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 37ad4d9347..cc4d91c491 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -30,6 +30,12 @@ using namespace OpenGl_Raytrace; #include #endif +namespace +{ + static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f); + static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f); +} + // ======================================================================= // function : updateRaytraceGeometry // purpose : Updates 3D scene geometry for ray-tracing @@ -305,51 +311,73 @@ OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace* { OpenGl_RaytraceMaterial theMaterial; - const OPENGL_SURF_PROP& aProperties = theAspect->IntFront(); - - theMaterial.Ambient = BVH_Vec4f ( - (aProperties.isphysic ? aProperties.ambcol.rgb[0] : aProperties.matcol.rgb[0]) * aProperties.amb, - (aProperties.isphysic ? aProperties.ambcol.rgb[1] : aProperties.matcol.rgb[1]) * aProperties.amb, - (aProperties.isphysic ? aProperties.ambcol.rgb[2] : aProperties.matcol.rgb[2]) * aProperties.amb, - 1.f); - - theMaterial.Diffuse = BVH_Vec4f ( - (aProperties.isphysic ? aProperties.difcol.rgb[0] : aProperties.matcol.rgb[0]) * aProperties.diff, - (aProperties.isphysic ? aProperties.difcol.rgb[1] : aProperties.matcol.rgb[1]) * aProperties.diff, - (aProperties.isphysic ? aProperties.difcol.rgb[2] : aProperties.matcol.rgb[2]) * aProperties.diff, - -1.f /* no texture */); - - theMaterial.Specular = BVH_Vec4f ( - (aProperties.isphysic ? aProperties.speccol.rgb[0] : 1.f) * aProperties.spec, - (aProperties.isphysic ? aProperties.speccol.rgb[1] : 1.f) * aProperties.spec, - (aProperties.isphysic ? aProperties.speccol.rgb[2] : 1.f) * aProperties.spec, - aProperties.shine); - - theMaterial.Emission = BVH_Vec4f ( - (aProperties.isphysic ? aProperties.emscol.rgb[0] : aProperties.matcol.rgb[0]) * aProperties.emsv, - (aProperties.isphysic ? aProperties.emscol.rgb[1] : aProperties.matcol.rgb[1]) * aProperties.emsv, - (aProperties.isphysic ? aProperties.emscol.rgb[2] : aProperties.matcol.rgb[2]) * aProperties.emsv, - 1.f); - - theMaterial.Transparency = BVH_Vec4f (aProperties.trans, - 1.f - aProperties.trans, - aProperties.index == 0 ? 1.f : aProperties.index, - aProperties.index == 0 ? 1.f : 1.f / aProperties.index); - - const Standard_ShortReal aMaxRefl = Max (theMaterial.Diffuse.x() + theMaterial.Specular.x(), - Max (theMaterial.Diffuse.y() + theMaterial.Specular.y(), - theMaterial.Diffuse.z() + theMaterial.Specular.z())); - - const Standard_ShortReal aReflectionScale = 0.75f / aMaxRefl; - - theMaterial.Reflection = BVH_Vec4f ( - aProperties.speccol.rgb[0] * aProperties.spec * aReflectionScale, - aProperties.speccol.rgb[1] * aProperties.spec * aReflectionScale, - aProperties.speccol.rgb[2] * aProperties.spec * aReflectionScale, - 0.f); + const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->FrontMaterial(); + const OpenGl_Vec3& aMatCol = theAspect->Aspect()->InteriorColor(); + const float aShine = 128.0f * float(aSrcMat.Shininess()); + const bool isPhysic = aSrcMat.MaterialType (Graphic3d_MATERIAL_PHYSIC) == Standard_True; + + // ambient component + if (aSrcMat.ReflectionMode (Graphic3d_TOR_AMBIENT)) + { + const OpenGl_Vec3& aSrcAmb = isPhysic ? aSrcMat.AmbientColor() : aMatCol; + theMaterial.Ambient = BVH_Vec4f (aSrcAmb * (float )aSrcMat.Ambient(), 1.0f); + } + else + { + theMaterial.Ambient = THE_BLACK_COLOR; + } + + // diffusion component + if (aSrcMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)) + { + const OpenGl_Vec3& aSrcDif = isPhysic ? aSrcMat.DiffuseColor() : aMatCol; + theMaterial.Diffuse = BVH_Vec4f (aSrcDif * (float )aSrcMat.Diffuse(), -1.0f); // -1 is no texture + } + else + { + theMaterial.Diffuse = BVH_Vec4f (THE_BLACK_COLOR.rgb(), -1.0f); + } + + // specular component + if (aSrcMat.ReflectionMode (Graphic3d_TOR_SPECULAR)) + { + const OpenGl_Vec3& aSrcSpe = aSrcMat.SpecularColor(); + const OpenGl_Vec3& aSrcSpe2 = isPhysic ? aSrcSpe : THE_WHITE_COLOR.rgb(); + theMaterial.Specular = BVH_Vec4f (aSrcSpe2 * (float )aSrcMat.Specular(), aShine); + + const Standard_ShortReal aMaxRefl = Max (theMaterial.Diffuse.x() + theMaterial.Specular.x(), + Max (theMaterial.Diffuse.y() + theMaterial.Specular.y(), + theMaterial.Diffuse.z() + theMaterial.Specular.z())); + + const Standard_ShortReal aReflectionScale = 0.75f / aMaxRefl; + + // ignore isPhysic here + theMaterial.Reflection = BVH_Vec4f (aSrcSpe * (float )aSrcMat.Specular() * aReflectionScale, 0.0f); + } + else + { + theMaterial.Specular = BVH_Vec4f (THE_BLACK_COLOR.rgb(), aShine); + } + + // emission component + if (aSrcMat.ReflectionMode (Graphic3d_TOR_EMISSION)) + { + const OpenGl_Vec3& aSrcEms = isPhysic ? aSrcMat.EmissiveColor() : aMatCol; + theMaterial.Emission = BVH_Vec4f (aSrcEms * (float )aSrcMat.Emissive(), 1.0f); + } + else + { + theMaterial.Emission = THE_BLACK_COLOR; + } + + const float anIndex = (float )aSrcMat.RefractionIndex(); + theMaterial.Transparency = BVH_Vec4f (1.0f - (float )aSrcMat.Transparency(), + (float )aSrcMat.Transparency(), + anIndex == 0 ? 1.0f : anIndex, + anIndex == 0 ? 1.0f : 1.0f / anIndex); // Serialize physically-based material properties - const Graphic3d_BSDF& aBSDF = aProperties.BSDF; + const Graphic3d_BSDF& aBSDF = aSrcMat.BSDF(); theMaterial.BSDF.Le = BVH_Vec4f (aBSDF.Le, 0.f); theMaterial.BSDF.Kd = BVH_Vec4f (aBSDF.Kd, -1.f /* no tex */); @@ -363,7 +391,7 @@ OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace* aBSDF.AbsorptionCoeff); // Handle material textures - if (theAspect->DoTextureMap()) + if (theAspect->Aspect()->ToMapTexture()) { if (theGlContext->arbTexBindless != NULL) { @@ -2271,10 +2299,7 @@ Standard_Boolean OpenGl_View::setUniformState (const OpenGl_Vec3* the } else { - const OpenGl_Vec4 aBackColor (myBgColor.rgb[0], - myBgColor.rgb[1], - myBgColor.rgb[2], - 1.0f); + const OpenGl_Vec4& aBackColor = myBgColor; theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], aBackColor); theProgram->SetUniform (theGlContext, diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 2fbe6545a8..e6be3c81a9 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -181,7 +181,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace) // - gradient fill type is not Aspect_GFM_NONE and // - either background texture is no specified or it is drawn in Aspect_FM_CENTERED mode if (myBgGradientArray->IsDefined() - && (!myTextureParams->DoTextureMap() + && (!myTextureParams->Aspect()->ToMapTexture() || myBgTextureArray->TextureFillMethod() == Aspect_FM_CENTERED || myBgTextureArray->TextureFillMethod() == Aspect_FM_NONE)) { @@ -213,7 +213,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace) // Drawing background image if it is defined // (texture is defined and fill type is not Aspect_FM_NONE) if (myBgTextureArray->IsDefined() - && myTextureParams->DoTextureMap()) + && myTextureParams->Aspect()->ToMapTexture()) { aCtx->core11fwd->glDisable (GL_BLEND); @@ -688,7 +688,8 @@ void OpenGl_View::redraw (const Graphic3d_Camera::Projection theProjection, Open } else { - glClearColor (myBgColor.rgb[0], myBgColor.rgb[1], myBgColor.rgb[2], 0.0f); + const OpenGl_Vec4& aBgColor = myBgColor; + glClearColor (aBgColor.r(), aBgColor.g(), aBgColor.b(), 0.0f); } glClear (toClear); @@ -904,7 +905,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, glFogi(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_START, (Standard_ShortReal )aFogFrontConverted); glFogf(GL_FOG_END, (Standard_ShortReal )aFogBackConverted); - glFogfv(GL_FOG_COLOR, myFog.Color.rgb); + glFogfv(GL_FOG_COLOR, myFog.Color.GetData()); glEnable(GL_FOG); } else if (aContext->core11 != NULL) diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 8604545334..3ee7a41709 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -50,8 +50,8 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_RaytraceFilter,OpenGl_RenderFilter) namespace { - static const TEL_COLOUR THE_WHITE_COLOR = { { 1.0f, 1.0f, 1.0f, 1.0f } }; - static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f); + static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f); + static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f); static const OpenGl_AspectLine myDefaultAspectLine; static const OpenGl_AspectFace myDefaultAspectFace; @@ -72,16 +72,16 @@ namespace // function : Init // purpose : // ======================================================================= -void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp) +void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat, + const Quantity_Color& theInteriorColor) { + const bool isPhysic = theMat.MaterialType (Graphic3d_MATERIAL_PHYSIC) == Standard_True; + // ambient component - if (theProp.color_mask & OPENGL_AMBIENT_MASK) + if (theMat.ReflectionMode (Graphic3d_TOR_AMBIENT)) { - const float* aSrcAmb = theProp.isphysic ? theProp.ambcol.rgb : theProp.matcol.rgb; - Ambient = OpenGl_Vec4 (aSrcAmb[0] * theProp.amb, - aSrcAmb[1] * theProp.amb, - aSrcAmb[2] * theProp.amb, - 1.0f); + const OpenGl_Vec3& aSrcAmb = isPhysic ? theMat.AmbientColor() : theInteriorColor; + Ambient = OpenGl_Vec4 (aSrcAmb * (float )theMat.Ambient(), 1.0f); } else { @@ -89,13 +89,10 @@ void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp) } // diffusion component - if (theProp.color_mask & OPENGL_DIFFUSE_MASK) + if (theMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)) { - const float* aSrcDif = theProp.isphysic ? theProp.difcol.rgb : theProp.matcol.rgb; - Diffuse = OpenGl_Vec4 (aSrcDif[0] * theProp.diff, - aSrcDif[1] * theProp.diff, - aSrcDif[2] * theProp.diff, - 1.0f); + const OpenGl_Vec3& aSrcDif = isPhysic ? theMat.DiffuseColor() : theInteriorColor; + Diffuse = OpenGl_Vec4 (aSrcDif * (float )theMat.Diffuse(), 1.0f); } else { @@ -103,13 +100,10 @@ void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp) } // specular component - if (theProp.color_mask & OPENGL_SPECULAR_MASK) + if (theMat.ReflectionMode (Graphic3d_TOR_SPECULAR)) { - const float* aSrcSpe = theProp.isphysic ? theProp.speccol.rgb : THE_WHITE_COLOR.rgb; - Specular = OpenGl_Vec4 (aSrcSpe[0] * theProp.spec, - aSrcSpe[1] * theProp.spec, - aSrcSpe[2] * theProp.spec, - 1.0f); + const OpenGl_Vec3& aSrcSpe = isPhysic ? (const OpenGl_Vec3& )theMat.SpecularColor() : THE_WHITE_COLOR.rgb(); + Specular = OpenGl_Vec4 (aSrcSpe * (float )theMat.Specular(), 1.0f); } else { @@ -117,21 +111,18 @@ void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp) } // emission component - if (theProp.color_mask & OPENGL_EMISSIVE_MASK) + if (theMat.ReflectionMode (Graphic3d_TOR_EMISSION)) { - const float* aSrcEms = theProp.isphysic ? theProp.emscol.rgb : theProp.matcol.rgb; - Emission = OpenGl_Vec4 (aSrcEms[0] * theProp.emsv, - aSrcEms[1] * theProp.emsv, - aSrcEms[2] * theProp.emsv, - 1.0f); + const OpenGl_Vec3& aSrcEms = isPhysic ? theMat.EmissiveColor() : theInteriorColor; + Emission = OpenGl_Vec4 (aSrcEms * (float )theMat.Emissive(), 1.0f); } else { Emission = THE_BLACK_COLOR; } - ChangeShine() = theProp.shine; - ChangeTransparency() = theProp.trans; + ChangeShine() = 128.0f * float(theMat.Shininess()); + ChangeTransparency() = 1.0f - (float )theMat.Transparency(); } // ======================================================================= @@ -150,18 +141,15 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi // myAspectLineSet (&myDefaultAspectLine), myAspectFaceSet (&myDefaultAspectFace), - myAspectFaceApplied (NULL), myAspectMarkerSet (&myDefaultAspectMarker), - myAspectMarkerApplied (NULL), myAspectTextSet (&myDefaultAspectText), myAspectFaceAppliedWithHL (false), // ViewMatrix_applied (&myDefaultMatrix), StructureMatrix_applied (&myDefaultMatrix), - myCullingMode (TelCullUndefined), + myToAllowFaceCulling (false), myToHighlight (false), - myModelViewMatrix (myDefaultMatrix), - PolygonOffset_applied (THE_DEFAULT_POFFSET) + myModelViewMatrix (myDefaultMatrix) { if (!myGlContext.IsNull() && myGlContext->MakeCurrent()) { @@ -194,11 +182,12 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi #endif } - myDefaultCappingAlgoFilter = new OpenGl_CappingAlgoFilter(); - myNoneCulling.ChangeCullingMode() = TelCullNone; - myNoneCulling.ChangeEdge() = 0; - myFrontCulling.ChangeCullingMode() = TelCullBack; - myFrontCulling.ChangeEdge() = 0; + myDefaultCappingAlgoFilter = new OpenGl_CappingAlgoFilter(); + + myNoneCulling .Aspect()->SetSuppressBackFaces (false); + myNoneCulling .Aspect()->SetDrawEdges (false); + myFrontCulling.Aspect()->SetSuppressBackFaces (true); + myFrontCulling.Aspect()->SetDrawEdges (false); } // ======================================================================= @@ -243,22 +232,22 @@ void OpenGl_Workspace::ResetAppliedAspect() NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0; HighlightColor = &THE_WHITE_COLOR; + myToAllowFaceCulling = false; myAspectLineSet = &myDefaultAspectLine; myAspectFaceSet = &myDefaultAspectFace; - myAspectFaceApplied = NULL; + myAspectFaceApplied.Nullify(); myAspectMarkerSet = &myDefaultAspectMarker; - myAspectMarkerApplied = NULL; + myAspectMarkerApplied.Nullify(); myAspectTextSet = &myDefaultAspectText; - PolygonOffset_applied = THE_DEFAULT_POFFSET; - myCullingMode = TelCullUndefined; + myPolygonOffsetApplied= Graphic3d_PolygonOffset(); ApplyAspectLine(); ApplyAspectFace(); ApplyAspectMarker(); ApplyAspectText(); - myGlContext->SetTypeOfLine (myDefaultAspectLine.Type()); - myGlContext->SetLineWidth (myDefaultAspectLine.Width()); + myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type()); + myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width()); } // ======================================================================= @@ -600,44 +589,6 @@ Handle(OpenGl_Texture) OpenGl_Workspace::EnableTexture (const Handle(OpenGl_Text return aPrevTexture; } -// ======================================================================= -// function : TelUpdatePolygonOffsets -// purpose : -// ======================================================================= -static void TelUpdatePolygonOffsets (const TEL_POFFSET_PARAM& theOffsetData) -{ - if ((theOffsetData.mode & Aspect_POM_Fill) == Aspect_POM_Fill) - { - glEnable (GL_POLYGON_OFFSET_FILL); - } - else - { - glDisable (GL_POLYGON_OFFSET_FILL); - } - -#if !defined(GL_ES_VERSION_2_0) - if ((theOffsetData.mode & Aspect_POM_Line) == Aspect_POM_Line) - { - glEnable (GL_POLYGON_OFFSET_LINE); - } - else - { - glDisable (GL_POLYGON_OFFSET_LINE); - } - - if ((theOffsetData.mode & Aspect_POM_Point) == Aspect_POM_Point) - { - glEnable (GL_POLYGON_OFFSET_POINT); - } - else - { - glDisable (GL_POLYGON_OFFSET_POINT); - } -#endif - - glPolygonOffset (theOffsetData.factor, theOffsetData.units); -} - // ======================================================================= // function : updateMaterial // purpose : @@ -645,54 +596,57 @@ static void TelUpdatePolygonOffsets (const TEL_POFFSET_PARAM& theOffsetData) void OpenGl_Workspace::updateMaterial (const int theFlag) { // Case of hidden line - if (myAspectFaceSet->InteriorStyle() == Aspect_IS_HIDDENLINE) + if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE) { - myAspectFaceHl = *myAspectFaceSet; // copy all values including line edge aspect - myAspectFaceHl.ChangeIntFront().matcol = myView->BackgroundColor(); - myAspectFaceHl.ChangeIntFront().color_mask = 0; - myAspectFaceHl.ChangeIntFront().color_mask = 0; - + // copy all values including line edge aspect + *myAspectFaceHl.Aspect().operator->() = *myAspectFaceSet->Aspect(); + myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge()); + myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB()); + myAspectFaceHl.SetNoLighting (true); myAspectFaceSet = &myAspectFaceHl; return; } - const OPENGL_SURF_PROP* aProps = &myAspectFaceSet->IntFront(); + const Graphic3d_MaterialAspect* aSrcMat = &myAspectFaceSet->Aspect()->FrontMaterial(); + const Quantity_Color* aSrcIntColor = &myAspectFaceSet->Aspect()->InteriorColor(); GLenum aFace = GL_FRONT_AND_BACK; if (theFlag == TEL_BACK_MATERIAL) { - aFace = GL_BACK; - aProps = &myAspectFaceSet->IntBack(); + aFace = GL_BACK; + aSrcMat = &myAspectFaceSet->Aspect()->BackMaterial(); + aSrcIntColor = &myAspectFaceSet->Aspect()->BackInteriorColor(); } - else if (myAspectFaceSet->DistinguishingMode() == TOn + else if (myAspectFaceSet->Aspect()->Distinguish() && !(NamedStatus & OPENGL_NS_RESMAT)) { aFace = GL_FRONT; } - myMatTmp.Init (*aProps); + myMatTmp.Init (*aSrcMat, *aSrcIntColor); if (myToHighlight) { - myMatTmp.SetColor (*(const OpenGl_Vec4* )HighlightColor); + myMatTmp.SetColor (*HighlightColor); } // handling transparency if (NamedStatus & OPENGL_NS_2NDPASSDO) { // second pass - myMatTmp.Diffuse.a() = aProps->env_reflexion; + myMatTmp.Diffuse.a() = aSrcMat->EnvReflexion(); } else { - if (aProps->env_reflexion != 0.0f) + if (aSrcMat->EnvReflexion() != 0.0f) { // if the material reflects the environment scene, the second pass is needed NamedStatus |= OPENGL_NS_2NDPASSNEED; } - if (aProps->trans != 1.0f) + const float aTransp = (float )aSrcMat->Transparency(); + if (aTransp != 0.0f) { // render transparent - myMatTmp.Diffuse.a() = aProps->trans; + myMatTmp.Diffuse.a() = 1.0f - aTransp; glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_BLEND); if (myUseDepthWrite) @@ -717,7 +671,7 @@ void OpenGl_Workspace::updateMaterial (const int theFlag) // do not update material properties in case of zero reflection mode, // because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway. - if (aProps->color_mask == 0) + if (myAspectFaceSet->IsNoLighting()) { return; } @@ -848,47 +802,29 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC) { // manage back face culling mode, disable culling when clipping is enabled - TelCullMode aCullingMode = (myGlContext->Clipping().IsClippingOrCappingOn() - || myAspectFaceSet->InteriorStyle() == Aspect_IS_HATCH) - ? TelCullNone - : (TelCullMode )myAspectFaceSet->CullingMode(); - if (aCullingMode != TelCullNone - && !(NamedStatus & OPENGL_NS_2NDPASSDO)) + bool toSuppressBackFaces = myToAllowFaceCulling + && myAspectFaceSet->Aspect()->ToSuppressBackFaces(); + if (toSuppressBackFaces) { - // disable culling in case of translucent shading aspect - if (myAspectFaceSet->IntFront().trans != 1.0f) + if (myGlContext->Clipping().IsClippingOrCappingOn() + || myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH) { - aCullingMode = TelCullNone; + toSuppressBackFaces = false; } } - if (myCullingMode != aCullingMode) + if (toSuppressBackFaces) { - myCullingMode = aCullingMode; - switch (myCullingMode) + if (!(NamedStatus & OPENGL_NS_2NDPASSDO) + && (float )myAspectFaceSet->Aspect()->FrontMaterial().Transparency() != 0.0f) { - case TelCullNone: - case TelCullUndefined: - { - glDisable (GL_CULL_FACE); - break; - } - case TelCullFront: - { - glCullFace (GL_FRONT); - glEnable (GL_CULL_FACE); - break; - } - case TelCullBack: - { - glCullFace (GL_BACK); - glEnable (GL_CULL_FACE); - break; - } + // disable culling in case of translucent shading aspect + toSuppressBackFaces = false; } } + myGlContext->SetCullBackFaces (toSuppressBackFaces); } - if (myAspectFaceSet == myAspectFaceApplied + if (myAspectFaceSet->Aspect() == myAspectFaceApplied && myToHighlight == myAspectFaceAppliedWithHL) { return myAspectFaceSet; @@ -896,8 +832,8 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() myAspectFaceAppliedWithHL = myToHighlight; #if !defined(GL_ES_VERSION_2_0) - const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->InteriorStyle(); - if (myAspectFaceApplied == NULL + const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle(); + if (myAspectFaceApplied.IsNull() || myAspectFaceApplied->InteriorStyle() != anIntstyle) { switch (anIntstyle) @@ -911,7 +847,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() case Aspect_IS_HATCH: { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - myLineAttribs->SetTypeOfHatch (myAspectFaceApplied != NULL ? myAspectFaceApplied->Hatch() : TEL_HS_SOLID); + myLineAttribs->SetTypeOfHatch (!myAspectFaceApplied.IsNull() ? myAspectFaceApplied->HatchStyle() : Aspect_HS_SOLID); break; } case Aspect_IS_SOLID: @@ -934,9 +870,9 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() if (anIntstyle == Aspect_IS_HATCH) { - const Tint hatchstyle = myAspectFaceSet->Hatch(); - if (myAspectFaceApplied == NULL - || myAspectFaceApplied->Hatch() != hatchstyle) + const Aspect_HatchStyle hatchstyle = myAspectFaceSet->Aspect()->HatchStyle(); + if (myAspectFaceApplied.IsNull() + || myAspectFaceApplied->HatchStyle() != hatchstyle) { myLineAttribs->SetTypeOfHatch (hatchstyle); } @@ -944,25 +880,23 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() #endif // Aspect_POM_None means: do not change current settings - if ((myAspectFaceSet->PolygonOffset().mode & Aspect_POM_None) != Aspect_POM_None) + if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None) { - if (PolygonOffset_applied.mode != myAspectFaceSet->PolygonOffset().mode - || PolygonOffset_applied.factor != myAspectFaceSet->PolygonOffset().factor - || PolygonOffset_applied.units != myAspectFaceSet->PolygonOffset().units) + if (myPolygonOffsetApplied.Mode != myAspectFaceSet->Aspect()->PolygonOffset().Mode + || myPolygonOffsetApplied.Factor != myAspectFaceSet->Aspect()->PolygonOffset().Factor + || myPolygonOffsetApplied.Units != myAspectFaceSet->Aspect()->PolygonOffset().Units) { - SetPolygonOffset (myAspectFaceSet->PolygonOffset().mode, - myAspectFaceSet->PolygonOffset().factor, - myAspectFaceSet->PolygonOffset().units); + SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset()); } } updateMaterial (TEL_FRONT_MATERIAL); - if (myAspectFaceSet->DistinguishingMode() == TOn) + if (myAspectFaceSet->Aspect()->Distinguish()) { updateMaterial (TEL_BACK_MATERIAL); } - if (myAspectFaceSet->DoTextureMap()) + if (myAspectFaceSet->Aspect()->ToMapTexture()) { EnableTexture (myAspectFaceSet->TextureRes (myGlContext), myAspectFaceSet->TextureParams()); @@ -980,7 +914,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() } } - myAspectFaceApplied = myAspectFaceSet; + myAspectFaceApplied = myAspectFaceSet->Aspect(); return myAspectFaceSet; } @@ -988,15 +922,39 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() //function : SetPolygonOffset //purpose : //======================================================================= -void OpenGl_Workspace::SetPolygonOffset (int theMode, - Standard_ShortReal theFactor, - Standard_ShortReal theUnits) +void OpenGl_Workspace::SetPolygonOffset (const Graphic3d_PolygonOffset& theParams) { - PolygonOffset_applied.mode = theMode; - PolygonOffset_applied.factor = theFactor; - PolygonOffset_applied.units = theUnits; + myPolygonOffsetApplied = theParams; - TelUpdatePolygonOffsets (PolygonOffset_applied); + if ((theParams.Mode & Aspect_POM_Fill) == Aspect_POM_Fill) + { + glEnable (GL_POLYGON_OFFSET_FILL); + } + else + { + glDisable (GL_POLYGON_OFFSET_FILL); + } + +#if !defined(GL_ES_VERSION_2_0) + if ((theParams.Mode & Aspect_POM_Line) == Aspect_POM_Line) + { + glEnable (GL_POLYGON_OFFSET_LINE); + } + else + { + glDisable (GL_POLYGON_OFFSET_LINE); + } + + if ((theParams.Mode & Aspect_POM_Point) == Aspect_POM_Point) + { + glEnable (GL_POLYGON_OFFSET_POINT); + } + else + { + glDisable (GL_POLYGON_OFFSET_POINT); + } +#endif + glPolygonOffset (theParams.Factor, theParams.Units); } // ======================================================================= @@ -1005,19 +963,19 @@ void OpenGl_Workspace::SetPolygonOffset (int theMode, // ======================================================================= const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker() { - if (myAspectMarkerSet != myAspectMarkerApplied) + if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied) { - if (myAspectMarkerApplied == NULL - || (myAspectMarkerSet->Scale() != myAspectMarkerApplied->Scale())) + if (myAspectMarkerApplied.IsNull() + || (myAspectMarkerSet->Aspect()->Scale() != myAspectMarkerApplied->Scale())) { #if !defined(GL_ES_VERSION_2_0) - glPointSize (myAspectMarkerSet->Scale()); + glPointSize (myAspectMarkerSet->Aspect()->Scale()); #ifdef HAVE_GL2PS - gl2psPointSize (myAspectMarkerSet->Scale()); + gl2psPointSize (myAspectMarkerSet->Aspect()->Scale()); #endif #endif } - myAspectMarkerApplied = myAspectMarkerSet; + myAspectMarkerApplied = myAspectMarkerSet->Aspect(); } return myAspectMarkerSet; } diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index f41f4a0883..519ec7d22a 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -18,8 +18,6 @@ #include -#include - #include #include #include @@ -63,7 +61,8 @@ struct OpenGl_Material } //! Initialize material - void Init (const OPENGL_SURF_PROP& theProps); + void Init (const Graphic3d_MaterialAspect& theProp, + const Quantity_Color& theInteriorColor); //! Returns packed (serialized) representation of material properties const OpenGl_Vec4* Packed() const { return reinterpret_cast (this); } @@ -173,7 +172,15 @@ public: //// RELATED TO STATUS //// - const TEL_COLOUR* HighlightColor; + const OpenGl_Vec4* HighlightColor; + + //! Return true if active group might activate face culling (e.g. primitives are closed). + bool ToAllowFaceCulling() const { return myToAllowFaceCulling; } + + //! Allow or disallow face culling. + //! This call does NOT affect current state of back face culling; + //! ApplyAspectFace() should be called to update state. + void SetAllowFaceCulling (bool theToAllow) { myToAllowFaceCulling = theToAllow; } //! Return true if following structures should apply highlight color. bool ToHighlight() const { return myToHighlight; } @@ -182,51 +189,51 @@ public: void SetHighlight (bool theToHighlight) { myToHighlight = theToHighlight; } //! Return line color taking into account highlight flag. - const TEL_COLOUR& LineColor() const + const OpenGl_Vec4& LineColor() const { return myToHighlight ? *HighlightColor - : myAspectLineSet->Color(); + : myAspectLineSet->Aspect()->ColorRGBA(); } //! Return edge color taking into account highlight flag. - const TEL_COLOUR& EdgeColor() const + const OpenGl_Vec4& EdgeColor() const { return myToHighlight ? *HighlightColor - : myAspectFaceSet->AspectEdge()->Color(); + : myAspectFaceSet->AspectEdge()->Aspect()->ColorRGBA(); } //! Return marker color taking into account highlight flag. - const TEL_COLOUR& MarkerColor() const + const OpenGl_Vec4& MarkerColor() const { return myToHighlight ? *HighlightColor - : myAspectMarkerSet->Color(); + : myAspectMarkerSet->Aspect()->ColorRGBA(); } //! Return Interior color taking into account highlight flag. - const TEL_COLOUR& InteriorColor() const + const OpenGl_Vec4& InteriorColor() const { return myToHighlight ? *HighlightColor - : myAspectFaceSet->IntFront().matcol; + : myAspectFaceSet->Aspect()->InteriorColorRGBA(); } //! Return text color taking into account highlight flag. - const TEL_COLOUR& TextColor() const + const OpenGl_Vec4& TextColor() const { return myToHighlight ? *HighlightColor - : myAspectTextSet->Color(); + : myAspectTextSet->Aspect()->ColorRGBA(); } //! Return text Subtitle color taking into account highlight flag. - const TEL_COLOUR& TextSubtitleColor() const + const OpenGl_Vec4& TextSubtitleColor() const { return myToHighlight ? *HighlightColor - : myAspectTextSet->SubtitleColor(); + : myAspectTextSet->Aspect()->ColorSubTitleRGBA(); } //! Currently set line aspect (can differ from applied). @@ -300,10 +307,10 @@ public: inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; } //! Sets and applies current polygon offset. - void SetPolygonOffset (int theMode, Standard_ShortReal theFactor, Standard_ShortReal theUnits); + void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams); //! Returns currently applied polygon offset params. - const TEL_POFFSET_PARAM& AppliedPolygonOffset() { return PolygonOffset_applied; } + const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; } //! Returns capping algorithm rendering filter. const Handle(OpenGl_CappingAlgoFilter)& DefaultCappingAlgoFilter() const @@ -337,6 +344,12 @@ public: protected: + enum + { + TEL_FRONT_MATERIAL = 1, + TEL_BACK_MATERIAL = 2 + }; + void updateMaterial (const int theFlag); void setTextureParams (Handle(OpenGl_Texture)& theTexture, @@ -363,9 +376,9 @@ protected: //! @name fields related to status Handle(OpenGl_Texture) myTextureBound; //!< currently bound texture (managed by OpenGl_AspectFace and OpenGl_View environment texture) const OpenGl_AspectLine* myAspectLineSet; const OpenGl_AspectFace* myAspectFaceSet; - const OpenGl_AspectFace* myAspectFaceApplied; + Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied; const OpenGl_AspectMarker* myAspectMarkerSet; - const OpenGl_AspectMarker* myAspectMarkerApplied; + Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied; const OpenGl_AspectText* myAspectTextSet; bool myAspectFaceAppliedWithHL; @@ -375,12 +388,12 @@ protected: //! @name fields related to status OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates) OpenGl_Material myMatBack; //!< current back material state OpenGl_Material myMatTmp; //!< temporary variable - TelCullMode myCullingMode; //!< back face culling mode, applied from face aspect + bool myToAllowFaceCulling; //!< allow back face culling bool myToHighlight; //!< flag indicating highlighting mode OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations - TEL_POFFSET_PARAM PolygonOffset_applied; //!< Currently applied polygon offset. + Graphic3d_PolygonOffset myPolygonOffsetApplied; //!< currently applied polygon offset OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect diff --git a/src/QABugs/FILES b/src/QABugs/FILES index 319ab4a231..7e13b24803 100644 --- a/src/QABugs/FILES +++ b/src/QABugs/FILES @@ -20,7 +20,5 @@ QABugs_17.cxx QABugs_18.cxx QABugs_19.cxx QABugs_20.cxx -QABugs_MyText.cxx -QABugs_MyText.hxx QABugs_PresentableObject.cxx QABugs_PresentableObject.hxx diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 693e094105..c9b6811ad6 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -419,34 +418,6 @@ static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/ return 0; } -static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,const char ** argv ) -{ - - if(argc < 3){ - di << "Usage: " << argv[0] << " TextHight1 TextHight2 TextHight2"; - return(-1); - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - - if(aContext.IsNull()) - { - di << "use 'vinit' command before " << argv[0] << "\n"; - return -1; - } - - Handle(QABugs_MyText) txt1 = new QABugs_MyText("Gosha1",gp_Pnt(0,0,0),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,Draw::Atoi(argv[1])); - aContext->Display(txt1); - - Handle(QABugs_MyText) txt2 = new QABugs_MyText("Gosha2",gp_Pnt(0,0,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,Draw::Atoi(argv[2])); - aContext->Display(txt2); - - Handle(QABugs_MyText) txt3 = new QABugs_MyText("Gosha3",gp_Pnt(0,100,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,Draw::Atoi(argv[3])); - aContext->Display(txt3); - - return 0; -} - static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d) { int ret = 0; @@ -1780,7 +1751,6 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) { theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group); theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group); theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group); - theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group); theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group); theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group); theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group); diff --git a/src/QABugs/QABugs_MyText.cxx b/src/QABugs/QABugs_MyText.cxx deleted file mode 100644 index 06a20b1fa4..0000000000 --- a/src/QABugs/QABugs_MyText.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// Created on: 2002-04-10 -// 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(QABugs_MyText,AIS_InteractiveObject) - -/************************************************************************* -* -* CONSTRUCTION/DESTRUCTION -* -**************************************************************************/ -QABugs_MyText::QABugs_MyText(const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, - const Standard_CString aFont, const Quantity_NameOfColor aColor, const Standard_Real aHeight) -{ - myPosition = aPosition; - myText = TCollection_ExtendedString(aText); - myNameOfFont = aFont; - myNameOfColor = aColor; - myHeight = aHeight; -} - - -/************************************************************************* -* -* QUERY METHODS -* -**************************************************************************/ - -void QABugs_MyText::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer /*aMode*/ ) -{ - aPresentation->Clear(); - Handle(Prs3d_TextAspect) asp = myDrawer->TextAspect(); - - asp->SetFont(myNameOfFont); - asp->SetColor(myNameOfColor); - asp->SetHeight(myHeight); // I am changing the myHeight value - Prs3d_Text::Draw(aPresentation, asp, myText, myPosition); -} - -void QABugs_MyText::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer /*aMode*/) -{ - // This code is here to compute the selection, erase this code if you don't what selection. - - Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner(this, 7); - - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own, - myPosition.X(), - myPosition.Y(), - myPosition.Z(), - myPosition.X() + 20, - myPosition.Y() + 20, - myPosition.Z() + 20); - aSelection->Add(box); -} diff --git a/src/QABugs/QABugs_MyText.hxx b/src/QABugs/QABugs_MyText.hxx deleted file mode 100644 index fdc5343dcf..0000000000 --- a/src/QABugs/QABugs_MyText.hxx +++ /dev/null @@ -1,82 +0,0 @@ -// Created on: 2002-04-10 -// 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. - -#ifndef _QABugs_MyText_HeaderFile -#define _QABugs_MyText_HeaderFile - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -class TCollection_ExtendedString; -class gp_Pnt; -class Prs3d_Presentation; - - -class QABugs_MyText; -DEFINE_STANDARD_HANDLE(QABugs_MyText, AIS_InteractiveObject) - - -class QABugs_MyText : public AIS_InteractiveObject -{ - -public: - - - Standard_EXPORT QABugs_MyText(const TCollection_ExtendedString& aText, const gp_Pnt& aPosition); - - Standard_EXPORT QABugs_MyText(const TCollection_ExtendedString& aText, const gp_Pnt& aPosition, const Standard_CString aFont, const Quantity_NameOfColor aColor, const Standard_Real aHeight); - - - - - DEFINE_STANDARD_RTTIEXT(QABugs_MyText,AIS_InteractiveObject) - -protected: - - - Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE; - - Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE; - - - -private: - - - gp_Pnt myPosition; - TCollection_ExtendedString myText; - Quantity_NameOfColor myNameOfColor; - Standard_CString myNameOfFont; - Standard_Real myHeight; - - -}; - - - - - - - -#endif // _QABugs_MyText_HeaderFile diff --git a/src/Quantity/FILES b/src/Quantity/FILES index 5b32aa34fc..2c7f49d8a2 100755 --- a/src/Quantity/FILES +++ b/src/Quantity/FILES @@ -15,6 +15,7 @@ Quantity_CoefficientOfExpansion.hxx Quantity_Color.cxx Quantity_Color.hxx Quantity_Color_1.hxx +Quantity_ColorRGBA.hxx Quantity_ColorDefinitionError.hxx Quantity_Concentration.hxx Quantity_Conductivity.hxx diff --git a/src/Quantity/Quantity_Color.cxx b/src/Quantity/Quantity_Color.cxx index ca661a035b..a61ba9a819 100644 --- a/src/Quantity/Quantity_Color.cxx +++ b/src/Quantity/Quantity_Color.cxx @@ -114,6 +114,19 @@ Quantity_Color::Quantity_Color (const Quantity_Parameter R1, const Quantity_Para } +Quantity_Color::Quantity_Color (const NCollection_Vec3& theRgb) +: MyRed (theRgb.r()), + MyGreen(theRgb.g()), + MyBlue (theRgb.b()) +{ + if (theRgb.r() < 0.0f || theRgb.r() > 1.0f + || theRgb.g() < 0.0f || theRgb.g() > 1.0f + || theRgb.b() < 0.0f || theRgb.b() > 1.0f) + { + Standard_OutOfRange::Raise ("Color out"); + } +} + void Quantity_Color::ChangeContrast (const Quantity_Rate ADelta) { Standard_ShortReal MyHue, MyLight, MySaturation; diff --git a/src/Quantity/Quantity_Color.hxx b/src/Quantity/Quantity_Color.hxx index 70c82836bd..018d7c9a76 100644 --- a/src/Quantity/Quantity_Color.hxx +++ b/src/Quantity/Quantity_Color.hxx @@ -29,6 +29,7 @@ #include #include #include +#include class Quantity_ColorDefinitionError; @@ -69,7 +70,10 @@ public: //! is the lightness between 0. and 1. //! is the saturation between 0. and 1. Standard_EXPORT Quantity_Color(const Quantity_Parameter R1, const Quantity_Parameter R2, const Quantity_Parameter R3, const Quantity_TypeOfColor AType); - + + //! Define color from RGB values. + Standard_EXPORT explicit Quantity_Color (const NCollection_Vec3& theRgb); + //! Increases or decreases the contrast by . //! is a percentage. Any value greater than zero //! will increase the contrast. @@ -168,7 +172,10 @@ Standard_Boolean operator == (const Quantity_Color& Other) const //! Returns the Saturation component (value of the saturation) //! of the color . Standard_EXPORT Quantity_Parameter Saturation() const; - + + //! Return the color as vector of 3 float elements. + operator const NCollection_Vec3&() const { return *(const NCollection_Vec3* )this; } + //! Returns in R1, R2 and R3 the components of //! this color according to the color system definition AType. //! - if AType is Quantity_TOC_RGB R1 is the diff --git a/src/Quantity/Quantity_ColorRGBA.hxx b/src/Quantity/Quantity_ColorRGBA.hxx new file mode 100644 index 0000000000..5e5f9dadc0 --- /dev/null +++ b/src/Quantity/Quantity_ColorRGBA.hxx @@ -0,0 +1,84 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Quantity_ColorRGBA_HeaderFile +#define _Quantity_ColorRGBA_HeaderFile + +#include +#include + +//! The pair of Quantity_Color and Alpha component (1.0 opaque, 0.0 transparent). +class Quantity_ColorRGBA +{ +public: + + //! Creates a color with the default value. + Quantity_ColorRGBA() : myAlpha (1.0f) {} + + //! Creates the color with specified RGB value. + explicit Quantity_ColorRGBA (const Quantity_Color& theRgb) : myRgb (theRgb), myAlpha (1.0f) {} + + //! Creates the color from RGBA vector. + explicit Quantity_ColorRGBA (const NCollection_Vec4& theRgba) : myRgb (theRgba.rgb()), myAlpha (theRgba.a()) {} + + //! Return RGB color value. + const Quantity_Color& GetRGB() const { return myRgb; } + + //! Modify RGB color components without affecting alpha value. + Quantity_Color& ChangeRGB() { return myRgb; } + + //! Assign RGB color components without affecting alpha value. + void SetRGB (const Quantity_Color& theRgb) { myRgb = theRgb; } + + //! Return alpha value (1.0 means opaque, 0.0 means fully transparent). + Standard_ShortReal Alpha() const { return myAlpha; } + + //! Assign the alpha value. + void SetAlpha (const Standard_ShortReal theAlpha) { myAlpha = theAlpha; } + + //! Return the color as vector of 4 float elements. + operator const NCollection_Vec4&() const { return *(const NCollection_Vec4* )this; } + + //! Returns true if the distance between colors is greater than Epsilon(). + bool IsDifferent (const Quantity_ColorRGBA& theOther) const + { + return myRgb.IsDifferent (theOther.GetRGB()) + || Abs(myAlpha - theOther.myAlpha) > (float )Quantity_Color::Epsilon(); + } + + //! Returns true if the distance between colors is greater than Epsilon(). + bool operator!= (const Quantity_ColorRGBA& theOther) const { return IsDifferent (theOther); } + + //! Two colors are considered to be equal if their distance is no greater than Epsilon(). + bool IsEqual (const Quantity_ColorRGBA& theOther) const + { + return myRgb.IsEqual (theOther.GetRGB()) + && Abs(myAlpha - theOther.myAlpha) <= (float )Quantity_Color::Epsilon(); + } + + //! Two colors are considered to be equal if their distance is no greater than Epsilon(). + bool operator== (const Quantity_ColorRGBA& theOther) const { return IsEqual (theOther); } + +private: + + static void __testSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); } + static void __testSize4() { Standard_STATIC_ASSERT (sizeof(float) * 4 == sizeof(Quantity_ColorRGBA)); } + +private: + + Quantity_Color myRgb; + Standard_ShortReal myAlpha; + +}; + +#endif // _Quantity_ColorRGBA_HeaderFile diff --git a/src/StdPrs/StdPrs_BndBox.cxx b/src/StdPrs/StdPrs_BndBox.cxx index 73aecef00a..3c1cf15789 100644 --- a/src/StdPrs/StdPrs_BndBox.cxx +++ b/src/StdPrs/StdPrs_BndBox.cxx @@ -47,11 +47,8 @@ void StdPrs_BndBox::Add (const Handle(Prs3d_Presentation)& thePresentation, theBndBox.Get (X[0], Y[0], Z[0], X[1], Y[1], Z[1]); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); - Quantity_Color aColor; - Aspect_TypeOfLine aDummyLineType; - Standard_Real aWidth = 1.0; - theDrawer->LineAspect()->Aspect()->Values (aColor, aDummyLineType, aWidth); - + Quantity_Color aColor = theDrawer->LineAspect()->Aspect()->Color(); + Standard_Real aWidth = theDrawer->LineAspect()->Aspect()->Width(); aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (aColor, Aspect_TOL_DOTDASH, aWidth)); Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16); diff --git a/src/StdPrs/StdPrs_ShadedShape.cxx b/src/StdPrs/StdPrs_ShadedShape.cxx index 534d8a2225..a7bdad6ff6 100644 --- a/src/StdPrs/StdPrs_ShadedShape.cxx +++ b/src/StdPrs/StdPrs_ShadedShape.cxx @@ -280,7 +280,7 @@ namespace const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, - const Standard_Boolean theIsClosed) + const bool theIsClosed) { Handle(Graphic3d_ArrayOfTriangles) aPArray = fillTriangles (theShape, theHasTexels, theUVOrigin, theUVRepeat, theUVScale); if (aPArray.IsNull()) @@ -293,7 +293,6 @@ namespace if (!theDrawer->ShadingAspectGlobal()) { Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect(); - theIsClosed ? anAsp->SuppressBackFace() : anAsp->AllowBackFace(); aGroup->SetGroupPrimitivesAspect (anAsp); } aGroup->AddPrimitiveArray (aPArray); @@ -531,14 +530,14 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs, if (aShapeIter.More()) { shadeFromShape (aClosed, thePrs, theDrawer, - theHasTexels, theUVOrigin, theUVRepeat, theUVScale, Standard_True); + theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true); } aShapeIter.Initialize (anOpened); if (aShapeIter.More()) { shadeFromShape (anOpened, thePrs, theDrawer, - theHasTexels, theUVOrigin, theUVRepeat, theUVScale, Standard_False); + theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false); } } else @@ -546,7 +545,7 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs, // if the shape type is not compound, composolid or solid, use autodetection back-facing filled shadeFromShape (theShape, thePrs, theDrawer, theHasTexels, theUVOrigin, theUVRepeat, theUVScale, - (theVolume == StdPrs_Volume_Closed ? Standard_True : Standard_False)); + theVolume == StdPrs_Volume_Closed); } if (theDrawer->FaceBoundaryDraw()) diff --git a/src/StdPrs/StdPrs_ShadedSurface.cxx b/src/StdPrs/StdPrs_ShadedSurface.cxx index e0e7e4b522..868b01d0ee 100644 --- a/src/StdPrs/StdPrs_ShadedSurface.cxx +++ b/src/StdPrs/StdPrs_ShadedSurface.cxx @@ -45,15 +45,8 @@ void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs, { // If the surface is closed, the faces from back-side are not traced: Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect(); - if (theSurface.IsUClosed() && theSurface.IsVClosed()) - { - anAsp->SuppressBackFace(); - } - else - { - anAsp->AllowBackFace(); - } Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (anAsp); + Prs3d_Root::CurrentGroup (thePrs)->SetClosed (theSurface.IsUClosed() && theSurface.IsVClosed()); } Standard_Integer aNBUintv = theSurface.NbUIntervals (GeomAbs_C1); diff --git a/src/V3d/V3d_CircularGrid.cxx b/src/V3d/V3d_CircularGrid.cxx index c2275a07d9..412cf63f41 100644 --- a/src/V3d/V3d_CircularGrid.cxx +++ b/src/V3d/V3d_CircularGrid.cxx @@ -209,18 +209,13 @@ void V3d_CircularGrid::DefineLines () myGroup->Clear (); - Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); - LineAttrib->SetColor (myColor); - LineAttrib->SetType (Aspect_TOL_SOLID); - LineAttrib->SetWidth (1.0); - const Standard_Integer Division = (Standard_Integer )( (aDivision >= DIVISION ? aDivision : DIVISION)); Standard_Integer nbpnts = 2 * Division; // diametres Standard_Real alpha = M_PI / aDivision; - LineAttrib->SetColor (myTenthColor); - myGroup->SetGroupPrimitivesAspect (LineAttrib); + + myGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0)); Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments(2*nbpnts); const gp_Pnt p0(0., 0., -myOffSet); for (Standard_Integer i=1; i<=nbpnts; i++) { @@ -243,8 +238,7 @@ void V3d_CircularGrid::DefineLines () } if (aSeqTenth.Length()) { - LineAttrib->SetColor (myTenthColor); - myGroup->SetGroupPrimitivesAspect (LineAttrib); + myGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0)); Standard_Integer n, np; const Standard_Integer nbl = aSeqTenth.Length() / nbpnts; Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines(aSeqTenth.Length(),nbl); @@ -257,8 +251,7 @@ void V3d_CircularGrid::DefineLines () } if (aSeqLines.Length()) { - LineAttrib->SetColor (myColor); - myGroup->SetPrimitivesAspect (LineAttrib); + myGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (myColor, Aspect_TOL_SOLID, 1.0)); Standard_Integer n, np; const Standard_Integer nbl = aSeqLines.Length() / nbpnts; Handle(Graphic3d_ArrayOfPolylines) aPrims3 = new Graphic3d_ArrayOfPolylines(aSeqLines.Length(),nbl); diff --git a/src/V3d/V3d_RectangularGrid.cxx b/src/V3d/V3d_RectangularGrid.cxx index e97ea4d07b..7870bb1d0e 100644 --- a/src/V3d/V3d_RectangularGrid.cxx +++ b/src/V3d/V3d_RectangularGrid.cxx @@ -211,11 +211,6 @@ void V3d_RectangularGrid::DefineLines () myGroup->Clear(); - Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); - LineAttrib->SetColor (myColor); - LineAttrib->SetType (Aspect_TOL_SOLID); - LineAttrib->SetWidth (1.0); - Standard_Integer nblines; Standard_Real xl, yl, zl = myOffSet; @@ -247,8 +242,8 @@ void V3d_RectangularGrid::DefineLines () if (aSeqLines.Length()) { - LineAttrib->SetColor (myColor); - myGroup->SetPrimitivesAspect (LineAttrib); + Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d (myColor, Aspect_TOL_SOLID, 1.0); + myGroup->SetPrimitivesAspect (aLineAspect); const Standard_Integer nbv = aSeqLines.Length(); Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(nbv); Standard_Integer n = 1; @@ -258,8 +253,8 @@ void V3d_RectangularGrid::DefineLines () } if (aSeqTenth.Length()) { - LineAttrib->SetColor (myTenthColor); - myGroup->SetPrimitivesAspect (LineAttrib); + Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0); + myGroup->SetPrimitivesAspect (aLineAspect); const Standard_Integer nbv = aSeqTenth.Length(); Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(nbv); Standard_Integer n = 1; @@ -285,12 +280,7 @@ void V3d_RectangularGrid::DefinePoints () return; } - myGroup->Clear (); - - Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); - MarkerAttrib->SetColor (myColor); - MarkerAttrib->SetType (Aspect_TOM_POINT); - MarkerAttrib->SetScale (3.); + myGroup->Clear(); // horizontals Standard_Real xl, yl; @@ -316,7 +306,9 @@ void V3d_RectangularGrid::DefinePoints () aSeqPnts(i).Coord(X,Y,Z); Vertical->AddVertex (X,Y,Z); } - myGroup->SetGroupPrimitivesAspect (MarkerAttrib); + + Handle(Graphic3d_AspectMarker3d) aMarkerAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_POINT, myColor, 3.0); + myGroup->SetGroupPrimitivesAspect (aMarkerAspect); myGroup->AddPrimitiveArray (Vertical, Standard_False); } diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 92b741ac2d..b74cec6187 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -572,11 +572,9 @@ static Handle(Prs3d_IsoAspect) CopyIsoAspect (const Handle(Prs3d_IsoAspect) &theIsoAspect, const Standard_Integer theNbIsos) { - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - - theIsoAspect->Aspect()->Values(aColor, aType, aWidth); + Quantity_Color aColor = theIsoAspect->Aspect()->Color(); + Aspect_TypeOfLine aType = theIsoAspect->Aspect()->Type(); + Standard_Real aWidth = theIsoAspect->Aspect()->Width(); Handle(Prs3d_IsoAspect) aResult = new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos); @@ -2946,9 +2944,7 @@ inline void bndPresentation (Draw_Interpretor& theDI, case BndAction_Show: { Handle(Graphic3d_Structure) aPrs (thePrs->Presentation()); - aPrs->CStructure()->HighlightColor.r = 0.988235f; - aPrs->CStructure()->HighlightColor.g = 0.988235f; - aPrs->CStructure()->HighlightColor.b = 0.988235f; + aPrs->CStructure()->HighlightColor = Quantity_NOC_GRAY99; aPrs->CStructure()->HighlightWithBndBox (aPrs, Standard_True); break; } diff --git a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx index b4ace70a15..f11ef395ab 100644 --- a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx +++ b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx @@ -160,15 +160,15 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const // To test linking against OpenGl_Workspace and all aspect classes const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker(); - aMA->Type(); + aMA->Aspect()->Type(); const OpenGl_AspectText* aTA = theWorkspace->AspectText(); - aTA->FontName(); - TEL_COLOUR aColor = theWorkspace->LineColor(); + aTA->Aspect()->Font(); + OpenGl_Vec4 aColor = theWorkspace->LineColor(); // Finally draw something to make sure UserDraw really works glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); - glColor4fv(aColor.rgb); + glColor4fv(aColor.GetData()); glBegin(GL_LINE_LOOP); glVertex3f(myCoords[0], myCoords[1], myCoords[2]); glVertex3f(myCoords[3], myCoords[4], myCoords[2]); diff --git a/tests/bugs/vis/buc60821 b/tests/bugs/vis/buc60821 deleted file mode 100755 index 5f59092b6a..0000000000 --- a/tests/bugs/vis/buc60821 +++ /dev/null @@ -1,23 +0,0 @@ -puts "===========" -puts "BUC60821" -puts "===========" -puts "==================================" -puts "It takes visual check for this BUG" -puts "==================================" -puts "" - -vinit - -catch {BUC60821 100 200 300} - -set x_coord 206 -set y_coord 195 - -checkcolor $x_coord $y_coord 0 0 0 - -if {$stat != 1} { - puts "Error : The texts have identical height" -} - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png - diff --git a/tests/bugs/vis/bug24837_2 b/tests/bugs/vis/bug24837_2 index 1646095b95..01117fc1c2 100644 --- a/tests/bugs/vis/bug24837_2 +++ b/tests/bugs/vis/bug24837_2 @@ -28,7 +28,7 @@ vsetdispmode 1 set anImage ${imagedir}/${casename}_2_1.png vdump ${anImage} -vsetmaterial b1 b2 tb1 tb2 plastic +vsetmaterial b1 b2 plastic vsetcolor b1 tb1 RED vsetcolor b2 tb2 GREEN set anImage ${imagedir}/${casename}_2_2.png -- 2.20.1