File indexing completed on 2026-05-30 08:46:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef OpenGl_GraduatedTrihedron_HeaderFile
0017 #define OpenGl_GraduatedTrihedron_HeaderFile
0018
0019 #include <Graphic3d_GraduatedTrihedron.hxx>
0020 #include <NCollection_Array1.hxx>
0021 #include <OpenGl_Aspects.hxx>
0022 #include <OpenGl_Element.hxx>
0023 #include <OpenGl_PrimitiveArray.hxx>
0024 #include <OpenGl_Text.hxx>
0025
0026
0027
0028
0029
0030 class OpenGl_GraduatedTrihedron : public OpenGl_Element
0031 {
0032 public:
0033 DEFINE_STANDARD_ALLOC
0034
0035 public:
0036
0037 Standard_EXPORT OpenGl_GraduatedTrihedron();
0038
0039
0040 Standard_EXPORT virtual ~OpenGl_GraduatedTrihedron();
0041
0042
0043 Standard_EXPORT virtual void Render(const Handle(OpenGl_Workspace)& theWorkspace) const
0044 Standard_OVERRIDE;
0045
0046
0047 Standard_EXPORT virtual void Release(OpenGl_Context* theCtx) Standard_OVERRIDE;
0048
0049
0050 Standard_EXPORT void SetValues(const Graphic3d_GraduatedTrihedron& theData);
0051
0052
0053
0054
0055 Standard_EXPORT void SetMinMax(const OpenGl_Vec3& theMin, const OpenGl_Vec3& theMax);
0056
0057
0058 Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0059 Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0060
0061 private:
0062
0063 class Axis
0064 {
0065 public:
0066 OpenGl_Vec3 Direction;
0067 Quantity_Color NameColor;
0068 OpenGl_Aspects LineAspect;
0069 mutable OpenGl_Text Label;
0070 mutable OpenGl_PrimitiveArray Tickmark;
0071 mutable OpenGl_PrimitiveArray Line;
0072 mutable OpenGl_PrimitiveArray Arrow;
0073
0074 public:
0075 Axis(const Graphic3d_GraduatedTrihedron::AxisAspect& theAspect =
0076 Graphic3d_GraduatedTrihedron::AxisAspect(),
0077 const OpenGl_Vec3& theDirection = OpenGl_Vec3(1.0f, 0.0f, 0.0f));
0078
0079 ~Axis();
0080
0081 Axis& operator=(const Axis& theOther);
0082
0083 void InitArrow(const Handle(OpenGl_Context)& theContext,
0084 const Standard_ShortReal theLength,
0085 const OpenGl_Vec3& theNormal) const;
0086
0087 void InitTickmark(const Handle(OpenGl_Context)& theContext, const OpenGl_Vec3& theDir) const;
0088
0089 void InitLine(const Handle(OpenGl_Context)& theContext, const OpenGl_Vec3& theDir) const;
0090
0091 void Release(OpenGl_Context* theCtx);
0092 };
0093
0094 private:
0095
0096
0097
0098 struct GridAxes
0099 {
0100 public:
0101 GridAxes()
0102 : Origin(0, 0, 0)
0103 {
0104 Axes[0] = OpenGl_Vec3(1.0f, 0.0f, 0.0f);
0105 Axes[1] = OpenGl_Vec3(0.0f, 1.0f, 0.0f);
0106 Axes[2] = OpenGl_Vec3(0.0f, 0.0f, 1.0f);
0107
0108 Ticks[0] = OpenGl_Vec3(0.0f, 0.0f, 0.0f);
0109 Ticks[1] = OpenGl_Vec3(0.0f, 0.0f, 0.0f);
0110 Ticks[2] = OpenGl_Vec3(0.0f, 0.0f, 0.0f);
0111 }
0112
0113 public:
0114 OpenGl_Vec3 Origin;
0115 OpenGl_Vec3 Axes[3];
0116
0117 public:
0118 OpenGl_Vec3 Ticks[3];
0119 };
0120
0121 private:
0122
0123
0124 void initGlResources(const Handle(OpenGl_Context)& theContext) const;
0125
0126
0127
0128
0129
0130 Standard_ShortReal getNormal(const Handle(OpenGl_Context)& theContext,
0131 OpenGl_Vec3& theNormal) const;
0132
0133
0134
0135
0136
0137
0138
0139 Standard_ShortReal getDistanceToCorner(const OpenGl_Vec3& theNormal,
0140 const OpenGl_Vec3& theCenter,
0141 const Standard_ShortReal theX,
0142 const Standard_ShortReal theY,
0143 const Standard_ShortReal theZ) const;
0144
0145
0146
0147
0148 Standard_ExtCharacter getGridAxes(const Standard_ShortReal theCorners[8],
0149 GridAxes& theGridAxes) const;
0150
0151
0152
0153
0154
0155
0156
0157
0158 void renderLine(const OpenGl_PrimitiveArray& theLine,
0159 const Handle(OpenGl_Workspace)& theWorkspace,
0160 const OpenGl_Mat4& theMat,
0161 const Standard_ShortReal theXt,
0162 const Standard_ShortReal theYt,
0163 const Standard_ShortReal theZt) const;
0164
0165
0166
0167
0168
0169
0170
0171 void renderGridPlane(const Handle(OpenGl_Workspace)& theWorkspace,
0172 const Standard_Integer& theIndex,
0173 const GridAxes& theGridAxes,
0174 OpenGl_Mat4& theMat) const;
0175
0176
0177
0178
0179
0180
0181 void renderAxis(const Handle(OpenGl_Workspace)& theWorkspace,
0182 const Standard_Integer& theIndex,
0183 const OpenGl_Mat4& theMat) const;
0184
0185
0186
0187
0188
0189
0190
0191
0192 void renderTickmarkLabels(const Handle(OpenGl_Workspace)& theWorkspace,
0193 const OpenGl_Mat4& theMat,
0194 const Standard_Integer theIndex,
0195 const GridAxes& theGridAxes,
0196 const Standard_ShortReal theDpix) const;
0197
0198 protected:
0199 OpenGl_Vec3 myMin;
0200 OpenGl_Vec3 myMax;
0201
0202 protected:
0203 mutable Axis myAxes[3];
0204 mutable Graphic3d_GraduatedTrihedron myData;
0205 mutable OpenGl_Aspects myGridLineAspect;
0206
0207 protected:
0208 mutable OpenGl_Text myLabelValues;
0209 mutable OpenGl_Aspects myAspectLabels;
0210 mutable OpenGl_Aspects myAspectValues;
0211
0212 private:
0213 mutable Standard_Boolean myIsInitialized;
0214
0215 enum AxisFlags
0216 {
0217 XOO_XYO = 1 << 1,
0218 XOO_XOZ = 1 << 2,
0219 OYO_OYZ = 1 << 3,
0220 OYO_XYO = 1 << 4,
0221 OOZ_XOZ = 1 << 5,
0222 OOZ_OYZ = 1 << 6,
0223 OYZ_XYZ = 1 << 7,
0224 XOZ_XYZ = 1 << 8,
0225 XYO_XYZ = 1 << 9
0226 };
0227 };
0228
0229 #endif