mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +03:00
0028107: Visualization - provide a flexible interface to set custom hatch styles
- class Graphic3d_HatchStyle is added to provide a possibility to set up custom and predefined hatching; - added the ability to set custom hatch patterns through bitmaps; - test case for issue #28107
This commit is contained in:
@@ -59,6 +59,8 @@ Graphic3d_Group.cxx
|
||||
Graphic3d_Group.hxx
|
||||
Graphic3d_GroupAspect.hxx
|
||||
Graphic3d_GroupDefinitionError.hxx
|
||||
Graphic3d_HatchStyle.hxx
|
||||
Graphic3d_HatchStyle.cxx
|
||||
Graphic3d_HighlightStyle.hxx
|
||||
Graphic3d_HighlightStyle.cxx
|
||||
Graphic3d_HorizontalTextAlignment.hxx
|
||||
|
@@ -28,7 +28,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
|
||||
myInteriorStyle (Aspect_IS_EMPTY),
|
||||
myEdgeType (Aspect_TOL_SOLID),
|
||||
myEdgeWidth (1.0f),
|
||||
myHatchStyle (Aspect_HS_VERTICAL),
|
||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||
myToDistinguishMaterials (false),
|
||||
myToDrawEdges (false),
|
||||
myToSuppressBackFaces (true),
|
||||
@@ -56,7 +56,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
|
||||
myInteriorStyle (theInteriorStyle),
|
||||
myEdgeType (theEdgeLineType),
|
||||
myEdgeWidth ((float )theEdgeLineWidth),
|
||||
myHatchStyle (Aspect_HS_VERTICAL),
|
||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||
myToDistinguishMaterials (false),
|
||||
myToDrawEdges (false),
|
||||
myToSuppressBackFaces (true),
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include <Aspect_PolygonOffsetMode.hxx>
|
||||
#include <Aspect_InteriorStyle.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Graphic3d_PolygonOffset.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
@@ -247,10 +247,23 @@ public:
|
||||
public:
|
||||
|
||||
//! Returns the hatch type used when InteriorStyle is IS_HATCH
|
||||
Aspect_HatchStyle HatchStyle() const { return myHatchStyle; }
|
||||
const Handle(Graphic3d_HatchStyle)& HatchStyle() const { return myHatchStyle; }
|
||||
|
||||
//! Modifies the hatch type used when InteriorStyle is IS_HATCH
|
||||
void SetHatchStyle (const Aspect_HatchStyle theStyle) { myHatchStyle = theStyle; }
|
||||
void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle) { myHatchStyle = theStyle; }
|
||||
|
||||
//! Modifies the hatch type used when InteriorStyle is IS_HATCH
|
||||
//! @warning This method always creates a new handle for a given hatch style
|
||||
void SetHatchStyle (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
if (theStyle == Aspect_HS_SOLID)
|
||||
{
|
||||
myHatchStyle.Nullify();
|
||||
return;
|
||||
}
|
||||
|
||||
myHatchStyle = new Graphic3d_HatchStyle (theStyle);
|
||||
}
|
||||
|
||||
//! Returns the current values.
|
||||
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
|
||||
@@ -291,13 +304,13 @@ protected:
|
||||
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;
|
||||
Quantity_ColorRGBA myInteriorColor;
|
||||
Quantity_ColorRGBA myBackInteriorColor;
|
||||
Quantity_ColorRGBA myEdgeColor;
|
||||
Aspect_InteriorStyle myInteriorStyle;
|
||||
Aspect_TypeOfLine myEdgeType;
|
||||
Standard_ShortReal myEdgeWidth;
|
||||
Handle(Graphic3d_HatchStyle) myHatchStyle;
|
||||
|
||||
Graphic3d_PolygonOffset myPolygonOffset;
|
||||
bool myToDistinguishMaterials;
|
||||
|
@@ -200,6 +200,16 @@ void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingCustomHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOn
|
||||
// purpose :
|
||||
|
@@ -144,7 +144,14 @@ public: // @name user-defined graphical attributes
|
||||
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
Aspect_HatchStyle CappingHatch() const { return myAspect->HatchStyle(); }
|
||||
Aspect_HatchStyle CappingHatch() const { return (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
|
||||
|
||||
//! Set custom hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch pattern.
|
||||
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
|
||||
|
||||
//! Turn on hatching.
|
||||
Standard_EXPORT void SetCappingHatchOn();
|
||||
|
518
src/Graphic3d/Graphic3d_HatchStyle.cxx
Normal file
518
src/Graphic3d/Graphic3d_HatchStyle.cxx
Normal file
@@ -0,0 +1,518 @@
|
||||
// Created on: 2016-11-14
|
||||
// Created by: Varvara POSKONINA
|
||||
// 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.
|
||||
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <NCollection_AlignedAllocator.hxx>
|
||||
#include <Standard_Atomic.hxx>
|
||||
#include <Standard_ProgramError.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_HatchStyle, Standard_Transient)
|
||||
|
||||
static const unsigned int myPredefinedPatterns[Aspect_HS_NB][32] =
|
||||
{
|
||||
// Aspect_HS_SOLID
|
||||
{
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF
|
||||
},
|
||||
// Aspect_HS_GRID_DIAGONAL
|
||||
{
|
||||
0xFFFFFFFF,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB,
|
||||
0xEEEEEEEE,
|
||||
0xBBBBBBBB
|
||||
},
|
||||
// Aspect_HS_GRID_DIAGONAL_WIDE
|
||||
{
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242,
|
||||
0x81818181,
|
||||
0x24242424,
|
||||
0x18181818,
|
||||
0x42424242
|
||||
},
|
||||
// Aspect_HS_GRID
|
||||
{
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888,
|
||||
0xFFFFFFFF,
|
||||
0x88888888
|
||||
},
|
||||
// Aspect_HS_GRID_WIDE
|
||||
{
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0xFFFFFFFF,
|
||||
0x80808080,
|
||||
0x80808080,
|
||||
0x80808080
|
||||
},
|
||||
// Aspect_HS_DIAGONAL_45
|
||||
{
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222,
|
||||
0x88888888,
|
||||
0x22222222
|
||||
},
|
||||
// Aspect_HS_DIAGONAL_135
|
||||
{
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444,
|
||||
0x11111111,
|
||||
0x44444444
|
||||
},
|
||||
// Aspect_HS_HORIZONTAL
|
||||
{
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000
|
||||
},
|
||||
// Aspect_HS_VERTICAL
|
||||
{
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111,
|
||||
0x11111111
|
||||
},
|
||||
// Aspect_HS_DIAGONAL_45_WIDE
|
||||
{
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202,
|
||||
0x80808080,
|
||||
0x20202020,
|
||||
0x08080808,
|
||||
0x02020202
|
||||
},
|
||||
// Aspect_HS_DIAGONAL_135_WIDE
|
||||
{
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040,
|
||||
0x01010101,
|
||||
0x04040404,
|
||||
0x10101010,
|
||||
0x40404040
|
||||
},
|
||||
// Aspect_HS_HORIZONTAL_WIDE
|
||||
{
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000
|
||||
},
|
||||
// Aspect_HS_VERTICAL_WIDE
|
||||
{
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010,
|
||||
0x10101010
|
||||
}
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
static volatile Standard_Integer THE_HATCH_STYLE_COUNTER = Aspect_HS_NB - 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Graphic3d_HatchStyle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Graphic3d_HatchStyle::Graphic3d_HatchStyle (const Handle(Image_PixMap)& thePattern)
|
||||
{
|
||||
Standard_ProgramError_Raise_if (thePattern.IsNull(), "Null pointer to a hatch pattern image");
|
||||
Standard_ProgramError_Raise_if (
|
||||
thePattern->SizeX() != 32 || thePattern->SizeY() != 32 || thePattern->Format() != Image_PixMap::ImgGray,
|
||||
"Hatch pattern must be a 32*32 bitmap (Image_PixMap::ImgGray format)");
|
||||
|
||||
const Standard_Size aByteSize = thePattern->SizeBytes();
|
||||
Handle(NCollection_AlignedAllocator) anAllocator = new NCollection_AlignedAllocator (16);
|
||||
myPattern = new NCollection_Buffer (anAllocator);
|
||||
myPattern->Allocate (aByteSize);
|
||||
std::memcpy (myPattern->ChangeData(), thePattern->Data(), aByteSize);
|
||||
|
||||
myHatchType = Standard_Atomic_Increment (&THE_HATCH_STYLE_COUNTER);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Pattern
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Standard_Byte* Graphic3d_HatchStyle::Pattern() const
|
||||
{
|
||||
return !myPattern.IsNull()
|
||||
? myPattern->Data()
|
||||
: (myHatchType < Aspect_HS_NB
|
||||
? (const Standard_Byte*)myPredefinedPatterns[myHatchType]
|
||||
: NULL);
|
||||
}
|
60
src/Graphic3d/Graphic3d_HatchStyle.hxx
Normal file
60
src/Graphic3d/Graphic3d_HatchStyle.hxx
Normal file
@@ -0,0 +1,60 @@
|
||||
// Created on: 2016-11-14
|
||||
// Created by: Varvara POSKONINA
|
||||
// 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 _Graphic3d_HatchStyle_HeaderFile
|
||||
#define _Graphic3d_HatchStyle_HeaderFile
|
||||
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <Image_PixMap.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
//! A class that provides an API to use standard OCCT hatch styles
|
||||
//! defined in Aspect_HatchStyle enum or to create custom styles
|
||||
//! from a user-defined bitmap
|
||||
class Graphic3d_HatchStyle : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT (Graphic3d_HatchStyle, Standard_Transient) // Type definition
|
||||
|
||||
public:
|
||||
|
||||
//! Creates a new custom hatch style with the given pattern and unique style id
|
||||
//! @warning Raises a program error if given pattern image is not a valid 32*32 bitmap
|
||||
Standard_EXPORT Graphic3d_HatchStyle (const Handle(Image_PixMap)& thePattern);
|
||||
|
||||
//! Creates a new predefined hatch style with the given id in Aspect_HatchStyle enum.
|
||||
//! GPU memory for the pattern will not be allocated.
|
||||
Graphic3d_HatchStyle (const Aspect_HatchStyle theType)
|
||||
: myHatchType (theType) {}
|
||||
|
||||
//! Returns the pattern of custom hatch style
|
||||
Standard_EXPORT const Standard_Byte* Pattern() const;
|
||||
|
||||
//! In case if predefined OCCT style is used, returns
|
||||
//! index in Aspect_HatchStyle enumeration. If the style
|
||||
//! is custom, returns unique index of the style
|
||||
Standard_Integer HatchType() const
|
||||
{
|
||||
return myHatchType;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Handle(NCollection_Buffer) myPattern; //!< Image bitmap with custom hatch pattern
|
||||
Standard_Integer myHatchType; //!< Index of used style
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_HatchStyle, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_HatchStyle_HeaderFile
|
Reference in New Issue
Block a user