CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisViewportDef.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23// GLES2 device viewport definition
24
25#ifndef ODTRVISVIEWPORTDEF
26#define ODTRVISVIEWPORTDEF
27
28#include "TD_PackPush.h"
29
30#include "Ge/GeMatrix3d.h"
31#include "IntArray.h"
32#include "Ge/GePoint2dArray.h"
33#include "UInt8Array.h"
34
35#include "TrVisRenderMode.h"
36#include "TrVisOverlayDef.h"
37
42{
43 // Flags
45 {
46 kPSOverallViewport = (1 << 0), // Overall PaperSpace viewport
47 kPSModelViewport = (1 << 1), // ModelSpace viewport in PaperSpace
48 kPSHelperViewport = (1 << 2), // Helper PaperSpace viewport
49 kVpVisible = (1 << 3), // Viewport is visible
50 // Store last definition flag for extensibility
52 };
53
56
57 // Reset viewport flags
58 void resetViewportFlags(OdUInt16 vpFlags = 0) { m_vpFlags = vpFlags; }
59
60 // PSOverallViewport flag
63
64 // PSModelViewport flag
67
68 // PSHelperViewport flag
71
72 // VpVisible flag
73 bool isViewportVisible() const { return GETBIT(m_vpFlags, kVpVisible); }
74 void setViewportVisible(bool bSet) { SETBIT(m_vpFlags, kVpVisible, bSet); }
75
76 // Setup default values
78 {
81 }
82
83 // Overall viewport Id
86};
87
92{
95
96 void reset()
97 {
100 }
101 bool hasRegion() const { return !m_counts.isEmpty(); }
102
103 bool hasCounts() const { return !m_counts.isEmpty(); }
104 bool hasPoints() const { return !m_points.isEmpty(); }
105
106 OdUInt32 numCounts() const { return m_counts.size(); }
107 OdUInt32 numPoints() const { return m_points.size() / 2; }
108
109 void setCounts(const OdIntArray &aCounts) { m_counts = aCounts; }
110 void setPoints(const OdFloatArray &aPoints) { m_points = aPoints; }
111
112 const int *counts() const { return m_counts.getPtr(); }
113 const float *points() const { return m_points.getPtr(); }
114};
115
120{
121 // Full (non-clipped) viewport rectangle in screen coordinates
123 // Screen coordinates to local coordinates transform
125
126 void reset()
127 {
128 m_viewportRect.m_min = OdGePoint2d(0.0, 1.0);
129 m_viewportRect.m_max = OdGePoint2d(1.0, 0.0);
131 }
132
134 void setViewportRect(const OdGsDCRectDouble &vptRect) { m_viewportRect = vptRect; }
135
136 const OdGeMatrix3d &regionXform() const { return m_regionXform; }
137 void setRegionXform(const OdGeMatrix3d &regXform) { m_regionXform = regXform; }
138
140 { rectOut = m_viewportRect; xform2d(rectOut.m_min); xform2d(rectOut.m_max); }
143
144 OdGePoint2d localPoint(const OdGePoint2d &screenPt) const
145 { OdGePoint2d pt(screenPt); xform2d(pt); return pt; }
146 void localPoint(float *ptOut, const float *ptIn) const
147 { ptOut[0] = ptIn[0]; ptOut[1] = ptIn[1]; xform2d(ptOut); }
148
149 void localRegion(OdTrVisViewportRegionDef &regionOut, const OdTrVisViewportRegionDef &regionIn) const
150 { regionOut = regionIn; const OdUInt32 nPoints = regionOut.m_points.size();
151 float *pPtOut = regionOut.m_points.asArrayPtr();
152 for (OdUInt32 nPoint = 0; nPoint < nPoints; nPoint++, pPtOut += 2)
153 xform2d(pPtOut); }
155 { OdTrVisViewportRegionDef regionOut; localRegion(regionOut, region); return regionOut; }
156protected:
157 inline void xform2d(OdGePoint2d &pt) const
158 { pt = OdGePoint3d(pt.x, pt.y, 0.0).transformBy(m_regionXform).convert2d(); }
159 inline void xform2d(float *pPt) const
160 { OdGePoint3d transformPt(pPt[0], pPt[1], 0.0); transformPt.transformBy(m_regionXform);
161 pPt[0] = (float)transformPt.x; pPt[1] = (float)transformPt.y; }
162};
163
168{
172
174 {
175 m_color = 0;
176 m_width = 1;
177 m_region.reset();
178 }
179
181 ODCOLORREF color() const { return m_color; }
182
183 void setWidth(int nWidth) { m_width = nWidth; }
184 int width() const { return m_width; }
185
187 const OdTrVisViewportRegionDef &region() const { return m_region; }
189};
190
195{
196 enum Flags
197 {
198 // Enable non-rectangular clipping.
199 kEnableNrcClip = (1 << 0),
200 // Enable borders rendering.
201 kEnableBorder = (1 << 1)
202 };
203 // Viewport clipping flags.
205 // Viewport clipping rectangle in screen coordinates.
207 // Viewport local data convertions.
209 // Non-rectangular clipping region in screen coordinates.
211 // Border in screen coordinates.
213
214 void resetFlags(OdUInt16 nFlags = 0)
215 {
216 m_flags = nFlags;
217 }
219 {
220 resetFlags();
221 m_screenRect.m_min = OdGePoint2d(0.0, 1.0);
222 m_screenRect.m_max = OdGePoint2d(1.0, 0.0);
226 }
227
228 void apply(const OdTrVisViewportClipDef &pDef, bool bApplyNrcClip, bool bApplyBorder)
229 {
232 if (bApplyNrcClip)
234 m_nrcClip = pDef.m_nrcClip;
235 if (bApplyBorder)
237 m_border = pDef.m_border;
238 }
239
240 void enableNrcClip(bool bSet) { SETBIT(m_flags, kEnableNrcClip, bSet); }
242
243 void enableBorder(bool bSet) { SETBIT(m_flags, kEnableBorder, bSet); }
245
247 const OdGsDCRectDouble &screenRect() const { return m_screenRect; }
248
249 void setLocalXform(const OdTrVisViewportRegionXform &locXform) { m_localXform = locXform; }
253
254 void setNrcClipRegion(const OdTrVisViewportRegionDef &nrcClip) { m_nrcClip = nrcClip; }
257
259 const OdTrVisViewportBorderDef &border() const { return m_border; }
261};
262
267{
272
274 {
278 m_faceFillColor = 0;
279 }
280
281 void setRenderProgram(OdTrVisProgramId programId) { m_rmShader = programId; }
283 bool hasRenderProgram() const { return m_rmShader != kTrVisNegativeId; }
284
285 void setVisualStyle(OdTrVisVisualStyleId visualStyleId) { m_visualStyle = visualStyleId; }
288
290 const OdTrVisRenderMode &renderMode() const { return m_renderMode; }
292
293 void setFaceFillColor(ODCOLORREF fillColor) { m_faceFillColor = fillColor; }
295};
296
301{
303
305 {
306 m_lineStyleConfig = ODRGBA(1, 2, 2, 1);
307 }
308
311
312 void enablePointsLineweight(bool bEnable)
315
320
323
324 void setLineStyle(OdUInt32 nCapStyle, OdUInt32 nJoinStyle)
326 void setLineStyleConfig(bool bPointLwds = true, OdUInt32 nCapStyle = 2, OdUInt32 nJoinStyle = 2)
327 { m_lineStyleConfig = ODRGBA((bPointLwds) ? 1 : 0, nCapStyle, nJoinStyle, 0xFF); updateDefStyle(); }
328
330 bool isDefStyle() const { return ODGETALPHA(m_lineStyleConfig) != 0; }
331
334};
335
340{
342
344 {
345 m_fadingConfig = ODRGBA(0, 0, 0, 7);
346 }
347
348 void setAsCref(ODCOLORREF cref) { m_fadingConfig = cref; }
350
354 void setFading(OdUInt8 nLayerFade = 0, OdUInt8 nXrefFade = 0, OdUInt8 nMfFade = 0) { m_fadingConfig = ODRGBA(nLayerFade, nXrefFade, nMfFade, 0); }
355
359
362 ((ODGETGREEN(m_fadingConfig) != 0xFF) ? 2 : 0) |
363 ((ODGETBLUE(m_fadingConfig) != 0xFF) ? 4 : 0)); }
365
366 bool operator ==(const OdTrVisViewportFadingDef &def) const { return m_fadingConfig == def.m_fadingConfig; }
367 bool operator !=(const OdTrVisViewportFadingDef &def) const { return m_fadingConfig != def.m_fadingConfig; }
368};
369
374{
377
379 {
381 m_lineweightsCoef = 1.0;
382 }
383
384 void setLineweightsEnum(const OdUInt8Array &lwdEnum) { m_lineweightsEnum = lwdEnum; }
385 const OdUInt8 *lineweightsEnum() const { return m_lineweightsEnum.getPtr(); }
387 bool hasLineweightsEnum() const { return !m_lineweightsEnum.isEmpty(); }
388
389 void setLineweightsCoef(double lwdCoef) { m_lineweightsCoef = lwdCoef; }
390 double lineweightsCoef() const { return m_lineweightsCoef; }
391};
392
397{
404
405 void setDefault(bool bInitVpDef = true)
406 {
407 if (bInitVpDef) OdTrVisViewportDef::setDefault();
414 }
415
416 void setViewportDef(const OdTrVisViewportDef &vpDef) { *static_cast<OdTrVisViewportDef*>(this) = vpDef; }
417 const OdTrVisViewportDef &viewportDef() const { return *this; }
418 OdTrVisViewportDef &viewportDef() { return *this; }
419
420 void setViewParams(const OdTrVisViewParamsDef &viewProps) { m_viewParams = viewProps; }
423
424 void setViewportClip(const OdTrVisViewportClipDef &vpClip, bool bSetNrcClip = true, bool bSetBorder = true)
425 { m_clip.apply(vpClip, bSetNrcClip, bSetBorder); }
426 const OdTrVisViewportClipDef &viewportClip() const { return m_clip; }
428
432
436
437 void setViewportFading(const OdTrVisViewportFadingDef &vpFade) { m_fading = vpFade; }
440
444};
445
446#include "TD_PackPop.h"
447
448#endif // ODTRVISVIEWPORTDEF
#define ODGETBLUE(rgb)
Definition: OdPlatform.h:939
#define ODCOLORREF
Definition: OdPlatform.h:933
#define ODGETGREEN(rgb)
Definition: OdPlatform.h:938
#define ODRGBA(r, g, b, a)
Definition: OdPlatform.h:935
#define ODGETALPHA(rgba)
Definition: OdPlatform.h:940
#define ODGETRED(rgb)
Definition: OdPlatform.h:937
unsigned int OdUInt32
unsigned short OdUInt16
unsigned char OdUInt8
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
const OdTrVisId kTrVisNegativeId
Definition: TrVisDefs.h:128
const OdTrVisId kTrVisNullId
Definition: TrVisDefs.h:134
#define OD_TRVIS_SETALPHA(color, alpha)
Definition: TrVisDefs.h:237
const T * asArrayPtr() const
Definition: OdArray.h:1590
OdArray & setPhysicalLength(size_type physLength)
Definition: OdArray.h:2223
bool isEmpty() const
Definition: OdArray.h:1547
size_type size() const
Definition: OdArray.h:1247
const T * getPtr() const
Definition: OdArray.h:1600
bool isEqualTo(const OdGeMatrix3d &matrix, const OdGeTol &tol=OdGeContext::gTol) const
static GE_STATIC_EXPORT const OdGeMatrix3d kIdentity
Definition: GeMatrix3d.h:97
double x
Definition: GePoint2d.h:409
double y
Definition: GePoint2d.h:410
OdGePoint3d & transformBy(const OdGeMatrix3d &xfm)
double y
Definition: GePoint3d.h:496
double x
Definition: GePoint3d.h:495
OdGePoint2d convert2d(const OdGePlanarEnt &plane) const
OdGePoint2d m_min
Definition: GsDefs.h:468
OdGePoint2d m_max
Definition: GsDefs.h:470
GLint GLenum GLsizei GLsizei GLint border
Definition: gles2_ext.h:110
void setRegion(const OdTrVisViewportRegionDef &region)
const OdTrVisViewportRegionDef & region() const
OdTrVisViewportRegionDef & region()
ODCOLORREF color() const
OdTrVisViewportRegionDef m_region
void setColor(ODCOLORREF color)
OdTrVisViewportRegionXform & localXform()
void enableNrcClip(bool bSet)
void setNrcClipRegion(const OdTrVisViewportRegionDef &nrcClip)
void setLocalXform(const OdTrVisViewportRegionXform &locXform)
const OdTrVisViewportBorderDef & border() const
OdGsDCRectDouble m_screenRect
OdTrVisViewportRegionDef m_nrcClip
const OdTrVisViewportRegionXform & localXform() const
void setBorder(const OdTrVisViewportBorderDef &border)
OdTrVisViewportRegionDef & nrcClipRegion()
void apply(const OdTrVisViewportClipDef &pDef, bool bApplyNrcClip, bool bApplyBorder)
const OdGsDCRectDouble & screenRect() const
OdTrVisViewportRegionXform m_localXform
void enableBorder(bool bSet)
void resetFlags(OdUInt16 nFlags=0)
void setScreenRect(const OdGsDCRectDouble &screenRect)
OdTrVisViewportBorderDef & border()
const OdTrVisViewportRegionDef & nrcClipRegion() const
OdTrVisViewportBorderDef m_border
OdTrVisViewportLineweightsDef m_lineweights
const OdTrVisViewportLineStyleDef & viewportLinestyles() const
void setViewportLineweights(const OdTrVisViewportLineweightsDef &vpLwd)
OdTrVisViewportClipDef m_clip
void setViewportFading(const OdTrVisViewportFadingDef &vpFade)
OdTrVisViewportFadingDef & viewportFading()
OdTrVisViewportShadingDef m_shading
OdTrVisViewportFadingDef m_fading
OdTrVisViewportDef & viewportDef()
OdTrVisViewportShadingDef & viewportShading()
void setViewportDef(const OdTrVisViewportDef &vpDef)
void setViewportLinestyles(const OdTrVisViewportLineStyleDef &vpLs)
const OdTrVisViewParamsDef & viewParams() const
OdTrVisViewportLineStyleDef & viewportLinestyles()
OdTrVisViewParamsDef & viewParams()
const OdTrVisViewportFadingDef & viewportFading() const
const OdTrVisViewportShadingDef & viewportShading() const
void setViewportClip(const OdTrVisViewportClipDef &vpClip, bool bSetNrcClip=true, bool bSetBorder=true)
void setDefault(bool bInitVpDef=true)
OdTrVisViewParamsDef m_viewParams
const OdTrVisViewportDef & viewportDef() const
const OdTrVisViewportClipDef & viewportClip() const
const OdTrVisViewportLineweightsDef & viewportLineweights() const
void setViewParams(const OdTrVisViewParamsDef &viewProps)
OdTrVisViewportClipDef & viewportClip()
OdTrVisViewportLineweightsDef & viewportLineweights()
void setViewportShading(const OdTrVisViewportShadingDef &vpShad)
OdTrVisViewportLineStyleDef m_linestyle
bool isPSModelViewport() const
OdTrVisViewportId overallViewportId() const
bool isPSOverallViewport() const
bool isPSHelperViewport() const
bool isViewportVisible() const
void setViewportVisible(bool bSet)
void setOverallViewportId(OdTrVisViewportId vpId)
void resetViewportFlags(OdUInt16 vpFlags=0)
OdTrVisViewportId m_overallViewportId
void setPSOverallViewport(bool bSet)
void setPSHelperViewport(bool bSet)
void setPSModelViewport(bool bSet)
OdUInt8 effectiveFlags() const
bool operator!=(const OdTrVisViewportFadingDef &def) const
bool operator==(const OdTrVisViewportFadingDef &def) const
void setAsCref(ODCOLORREF cref)
OdUInt8 metafileFade() const
void setXrefFade(OdUInt8 nFade)
void setFading(OdUInt8 nLayerFade=0, OdUInt8 nXrefFade=0, OdUInt8 nMfFade=0)
void setMetafileFade(OdUInt8 nFade)
void setLayerFade(OdUInt8 nFade)
ODCOLORREF getAsCref() const
ODCOLORREF getAsCref() const
bool operator==(const OdTrVisViewportLineStyleDef &def) const
void setLineStyle(OdUInt32 nCapStyle, OdUInt32 nJoinStyle)
void enablePointsLineweight(bool bEnable)
bool operator!=(const OdTrVisViewportLineStyleDef &def) const
void setLineStyleConfig(bool bPointLwds=true, OdUInt32 nCapStyle=2, OdUInt32 nJoinStyle=2)
void setLineCapStyle(OdUInt32 nStyle)
void setAsCref(ODCOLORREF cref)
void setLineJoinStyle(OdUInt32 nStyle)
void setLineweightsCoef(double lwdCoef)
const OdUInt8 * lineweightsEnum() const
void setLineweightsEnum(const OdUInt8Array &lwdEnum)
OdUInt32 numPoints() const
void setPoints(const OdFloatArray &aPoints)
const int * counts() const
OdUInt32 numCounts() const
void setCounts(const OdIntArray &aCounts)
const float * points() const
void localViewportRect(OdGsDCRectDouble &rectOut) const
void xform2d(OdGePoint2d &pt) const
void setRegionXform(const OdGeMatrix3d &regXform)
void xform2d(float *pPt) const
OdGsDCRectDouble m_viewportRect
void setViewportRect(const OdGsDCRectDouble &vptRect)
void localRegion(OdTrVisViewportRegionDef &regionOut, const OdTrVisViewportRegionDef &regionIn) const
void localPoint(float *ptOut, const float *ptIn) const
const OdGsDCRectDouble & viewportRect() const
OdGsDCRectDouble localViewportRect() const
const OdGeMatrix3d & regionXform() const
OdGePoint2d localPoint(const OdGePoint2d &screenPt) const
OdTrVisViewportRegionDef localRegion(const OdTrVisViewportRegionDef &region) const
OdTrVisProgramId renderProgram() const
OdTrVisRenderMode & renderMode()
ODCOLORREF faceFillColor() const
OdTrVisRenderMode m_renderMode
OdTrVisVisualStyleId visualStyle() const
void setRenderProgram(OdTrVisProgramId programId)
const OdTrVisRenderMode & renderMode() const
OdTrVisVisualStyleId m_visualStyle
void setFaceFillColor(ODCOLORREF fillColor)
void setRenderMode(const OdTrVisRenderMode &rm)
void setVisualStyle(OdTrVisVisualStyleId visualStyleId)