/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef __OD_EX_DIRECT_X_DEVICE__ #define __OD_EX_DIRECT_X_DEVICE__ #include "TD_PackPush.h" #include "ExGsWin32Device.h" #include "ExGiDirectXGeometry.h" #include "Gs/GsBaseInclude.h" #include "Gs/GsBaseMaterialView.h" #include "Gs/GsBaseModel.h" #include "Gs/GsProperties.h" #include "../ExFPPrecisionFix.h" #include "../TtfFontsCache.h" #include "../WinComposite/ExGsCompositeModuleInterface.h" //#include // included in ./ExGiDirectXGeometry.h #include "D3DInclude.h" #include "OdErrorContext.h" #include "OdLoggerBase.h" class OdGiLightTraitsData; /** \details This class defines a OdError class for the ExGsDirectXDevice class. Library: Source code provided. */ class DXError : public OdError { class DXErrorCtx : public OdErrorContext { protected: bool m_bDXAPI; HRESULT m_hrCode; public: /** \details Default constructor for the DXErrorCtx class. */ DXErrorCtx() : m_bDXAPI(false), m_hrCode(0) { } /** \details Returns human-readable text description of an error. \returns String containing error description. */ OdString description() const { return formatHRESULTErrorInfo(); } /** \details Returns code of the error. \returns Error code. */ OdResult code() const { return eExtendedError; } /** \details Sets error code. \param bDXAPI [in] Flag that indicates whether the error comes from DX API. \param hrCode [in] Error code. \returns Pointer to this DXErrorCtx. */ DXErrorCtx *setErrorCode(bool bDXAPI, HRESULT hrCode) { m_bDXAPI = bDXAPI; m_hrCode = hrCode; return this; } /** \details Returns information about currently stored HRESULT error. \returns String containing detailed information about an error. */ OdString formatHRESULTErrorInfo() const; }; public: /** \details Default constructor. */ DXError() : OdError(OdRxObjectImpl::createObject()) {} /** \details Throws a DirectX API error if and only if the specified value is less than zero. \param hr [in] Result value. */ static void check(HRESULT hr) { if(FAILED(hr)) throw OdError(OdRxObjectImpl::createObject()->setErrorCode(true, hr)); } /** \details Throws a DirectX API error. */ static void fail(HRESULT hr = S_OK) { if (hr != S_OK) throw OdError(OdRxObjectImpl::createObject()->setErrorCode(false, hr)); throw DXError(); } }; typedef ExGsCompositeClientDevice ExGsBaseDirectXDevice; /** \details This class implements Win32 DirectX Vectorizer Device objects. Library: Source code provided. */ class ExGsDirectXDevice : public ExGsBaseDirectXDevice, public ExGsWin32Device, public OdTtfFontsCacheCallback { bool m_bContextValid, m_bDiscardBackFaces, m_bLockableBackBuffer; bool m_bUseTTFCache, m_bLinesRepMode, m_bRefDevice; OdUInt32 m_nUseLutPalette; CComPtr m_pD3D; CComPtr m_pD3Ddevice; OdD3DStateManager m_stateManager; HINSTANCE m_d3dInst; D3dLostStateManager m_lsManager; OdGiMaterialTextureManagerPtr m_pTexManager; D3dResourceSharingProvider m_sharingProv; OdGsBaseDeviceMTHelpers m_deviceSync; OdTtfFontsCachePtr m_ttfFontsCache; mutable OdLoggerBase* m_pLogger; // Raster images cache public: /** \details Structure that represents a raster image cache entry. */ struct RasterImageEntry { D3dMaterialViewRedirect::RasterImageRef m_texture; const OdGiRasterImage *m_pImg; bool m_bTransparency; ODCOLORREF m_fgColor; bool m_bSecColor; ODCOLORREF m_bkColor; double m_fBrightness; double m_fContrast; double m_fFade; OdUInt32 m_uRefCounter; //RasterImageEntry() : m_uRefCounter(0) { } }; private: OdArray m_RasterImages; // protected: ExGsDirectXDevice(); virtual ~ExGsDirectXDevice(); void createContext(); void deleteContext(); void logResult(const OdString& sMethod, HRESULT res) const; ODRX_USING_HEAP_OPERATORS(ExGsBaseDirectXDevice); public: ODRX_DECLARE_DYNAMIC_PROPERTY_MAP(ExGsDirectXDevice); /** \details Sets the HInstance of the request handerer DLL for this Vectorizer device. \param hInst [in] Request handler DLL. */ void setD3DDllHInst(HINSTANCE hInst); /** \details Returns device properties. \returns Smart pointer to the dictionary with device properties. */ OdRxDictionaryPtr properties() { return this; } /** \details Represents the BlocksCacheEnabled property. \remarks This flag enables caching of a hierarchical blocks structure. If a drawing contains many block inserts with similar settings, it is possible to vectorize entities inside this block once and use a single metafile for each entity during rendering. In this case vectorization is faster and memory usage is lower, but it can cause some rendering performance slowdown since additional transformations are applied. This feature is also useful to enable the ability to highlight entities inside blocks. This property takes effect only if geometry cache is turned on. */ OD_COMMONDEVPROP_BlocksCacheEnabled_DevRedirect(); /** \details Represents the BlocksCacheEnabled property. \remarks The subentity highlighting mode enables caching geometry markers for entity geometry parts. These parts of the entity geometry can be highlighted independently from all other entity geometry. If the flag is turned on, a subentity marker is stored inside a metafile and the renderer is able to check whether the marked part of the geometry must be highlighted. This property takes effect only if geometry cache is turned on. */ OD_COMMONDEVPROP_DynamicSubEntHltEnabled_DevRedirect(); /** \details Updates the specified rectangle of this BitmapDevice object. \param pUpdatedRect [in] Pointer to the rectangle to receive the region updated by this function. */ void update(OdGsDCRect* pUpdatedRect); /** \details Updates screen display. */ void updateScreen(); /** \details Checks whether the device supports partial updating. \returns true if the device supports partial updating, false otherwise. */ bool supportPartialUpdate() const; /** \details Checks whether multithreading is supported. \returns true if multithreading is supported, false otherwise. */ bool supportMultithreading() const { return checkMtRegenEnabled(userGiContext()); } /** \details Notification function called whenever the size of the GUI window for the Device object has changed. \param outputRect [in] New size of the output rectangle in device coordinates (pixels). */ void onSize(const OdGsDCRect& outputRect); /** \details Returns the Direct3D device associated with this Vectorizer object. \returns Smart pointer to the Direct3D device. */ CComPtr d3dDevice(); /** \details Returns the Direct3D device state manager associated with this Vectorizer object. \returns Reference to OdD3DStateManager instance. */ OdD3DStateManager &d3dStateManager(); /** \details Checks whether the back faces are discarded. \returns true if back faces are discarded, false otherwise. \remarks The back-face culling process makes rendering quicker and more efficient by reducing the number of triangles for the program to draw. For convex geometry primitives it removes invisible faces on the primitive's back side. */ bool discardBackFaces() const { return m_bDiscardBackFaces; } /** \details Controls the discarding of back faces. \param discard [in] Controls discarding of back faces. \remarks The back-face culling process makes rendering quicker and more efficient by reducing the number of triangles for the program to draw. For convex geometry primitives it removes invisible faces on the primitive's back side. */ void setDiscardBackFaces(bool discard) { m_bDiscardBackFaces = discard; } /** \details Checks whether a lockable back buffer is enabled for this Vectorizer device. \returns true if a lockable back buffer is enabled, false otherwise. \remarks Lockable back buffer may decrease performance on some video-hardware. By default, a non-lockable back buffer is used. If lockable back buffer is strongly required, it can be enabled by this method. */ bool lockableBackBuffer() const { return m_bLockableBackBuffer; } /** \details Controls the lockable back buffer for this Vectorizer device. \note A lockable back buffer may decrease performance on some video-hardware By default a non non-lockable back buffer is used. If lockable back buffer is strongly required, it can be enabled by this method. */ void setLockableBackBuffer(bool enable) { m_bLockableBackBuffer = enable; } /** \details Returns current state of UseTTFCache flag. \returns true if the m_bUseTTFCache flag is enabled, false otherwise. \remarks TrueType fonts cache is useful for rendering drawings that contain a lot of text. If TrueType fonts cache is enabled, each font character used inside the drawing is cached as a separate metafile. This feature reduces memory usage, but rendering can be little bit slower. */ bool useTTFCache() const { return m_bUseTTFCache; } /** \details Sets new state of UseTTFCache flag. \param use [in] New flag state. \remarks TrueType fonts cache is useful for rendering drawings that contain a lot of text. If TrueType fonts cache is enabled, each font character used inside the drawing is cached as a separate metafile. This feature reduces memory usage, but rendering can be little bit slower. */ void setUseTTFCache(bool use) { m_bUseTTFCache = use; } /** \details Returns current state of UseLutPalette flags. \returns A set of flags that instruct a vectorization device how to process raster images with a palette. BitValue 1 Process monochrome raster images as 1 byte per pixel textures with palette. This reduces memory usage for monochrome raster images 2 Process 4 and 8 bits per pixel raster images as 1 byte per pixel textures with palette. This reduces memory usage for raster images with 16 and 256 color palettes
*/ OdUInt32 useLutPalette() const { return m_nUseLutPalette; } /** \details Sets new state of UseLutPalette flags. \param lutFlags [in] New flags state. \remarks A set of flags instruct a vectorization device how to process raster images with a palette. BitValue 1 Process monochrome raster images as 1 byte per pixel textures with palette. This reduces memory usage for monochrome raster images 2 Process 4 and 8 bits per pixel raster images as 1 byte per pixel textures with palette. This reduces memory usage for raster images with 16 and 256 color palettes
*/ void setUseLutPalette(OdUInt32 lutFlags) { m_nUseLutPalette = lutFlags; } /** \details Returns IDirect3DSurface pointer for WPF controls. \remarks Caller is responsible to call IUnknown->Release() method after using the Surface interface. */ OdIntPtr backBufferSurface() const; /** \details Sets the IDirect3DSurface pointer for WPF controls. \param pSurf [in] IDirect3DSurface pointer for WPF controls. \remarks Does nothing. */ void setBackBufferSurface(OdIntPtr /*pSurf*/) { } /** \details Returns common regeneration coefficient. \returns Regeneration coefficient value. \remarks Since 3D vectorization devices invoke with GPU's that typically don't support 64-bit floating point variables, a geometry which is placed on large coordinates can look broken because of truncation to 32-bit floating point variables. An application can use this device property to detect if truncation takes place and initiate geometry regeneration. */ double getRegenCoef() const; /** \details Sets common regeneration coefficient. \param val [in] Regeneration coefficient value. \remarks Since 3D vectorization devices invoke with GPU's that typically don't support 64-bit floating point variables, a geometry which is placed on large coordinates can look broken because of truncation to 32-bit floating point variables. An application can use this device property to detect if truncation takes place and initiate geometry regeneration. \remarks Does nothing. */ void setRegenCoef(double /*val*/) { } /** \details Sets new state of LinesRepMode flag. \param bSet [in] New flag state. \remarks If bSet flag is true then old-style detection of degenerate lines is enabled. */ void enableLinesRepMode(bool bSet) { m_bLinesRepMode = bSet; } /** \details Returns current state of LinesRepMode flag. \returns true if old-style detection of degenerate lines is enabled, false otherwise. */ bool isLinesRepModeEnabled() const { return m_bLinesRepMode; } /** \details Checks whether the lines anti-aliasing is supported on current hardware. \returns true if lines anti-aliasing is supported on current hardware, false otherwise. */ bool isLinesAntiAliasingSupported() const; /** \details Specifies whether the lines anti-aliasing is supported on current hardware. \param val [in] New flag state. \remarks Does nothing. */ void setLinesAntiAliasingSupported(bool /*val*/) { } /** \details Checks whether REF device is used instead of HAL. \returns true if REF device is enabled instead of HAL, false otherwise. \remarks Reference devices provide most DirectX functionality in software and do not depend on hardware. As a rule, reference devices are slower, so mainly they are used for testing purposes. For example, you can use a reference device to uses DirectX features that are not supported by a graphics card or investigate possible driver issues. */ bool isRefDevice() const { return m_bRefDevice; } /** \details Enables or disables usage of REF device instead of HAL. \param bSet [in] New flag state. \remarks Reference devices provide most DirectX functionality in software and do not depend on hardware. As a rule, reference devices are slower, so mainly they are used for testing purposes. For example, you can use a reference device to uses DirectX features that are not supported by a graphics card or investigate possible driver issues. */ void setRefDevice(bool bSet) { m_bRefDevice = bSet; } /** \details Returns logger. \returns IntPtr representing a logger. */ OdIntPtr logger() const; /** \details Set logger to device. \param pPtr [in] IntPtr representing a logger. */ void setLogger(OdIntPtr pPtr); /** \details Returns raster images cache. \returns Reference to an array of images representing the cache. */ OdArray &rasterImageCache() { return m_RasterImages; } /** \details Returns material textures cache. \returns Pointer to material texture manager. */ OdGiMaterialTextureManager *materialTextureManager() { return m_pTexManager; } /** \details Returns resource sharing provider. \returns Pointer to resource sharing provider. */ D3dResourceSharingProvider *sharingProvider() { return &m_sharingProv; } /** \details Returns MT synchronization helpers. \returns Reference to the OdGsBaseDeviceMTHelpers instance representing multithreading helpers. */ OdGsBaseDeviceMTHelpers &mtDeviceSync() { return m_deviceSync; } /** \details Returns TTF fonts cache. \returns Pointer to the OdTtfFontsCache instance containing information about character cache and other font-related data. */ OdTtfFontsCache *ttfFontsCache() { OdGsBaseDeviceMTSyncHelper __sync(mtDeviceSync(), OdGsBaseDeviceMTHelpers::kSyncDeviceResource); if (m_ttfFontsCache.isNull()) m_ttfFontsCache = OdTtfFontsCache::createObject(this); return m_ttfFontsCache.get(); } bool requireWindow() const { return true; } void makeBitBltOp(const ExWinCompositeBitBltOp &bitBltOp); /** \details Returns color converter used by the device. \returns Pointer to the OdColorConverterCallback object. \remarks For more information, see */ OdColorConverterCallback *getColorConverter(); /** \details Returns background color. \returns DirectX background color. */ DWORD getBackgroundColor(); // Snapshot support /** \details Gets a snapshot of the current device. \param pImage [out] Receives a snapshot image. \param region [in] Region from which to take a snapshot. */ void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect ®ion); /** \details Gets a snapshot of the graphics view that belongs in the current device. \param pImage [out] Receives a snapshot image. \param region [in] Region from which to take a snapshot. \param pView [in] Pointer to a graphics view from which to take a snapshot. */ void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect ®ion, OdGsView *pView); /** \details Gets snapshot parameters of the current device. \returns Smart pointer to the OdGiRasterImage instance that contains image-related parameters that are used for creating snapshots. */ virtual OdGiRasterImagePtr snapshotImageParams() const; /** \details Gets a snapshot of the current device. \param area [in] Area from which to take a snapshot. \returns Smart pointer to the OdGiRasterImage instance that represents the created snapshot. */ virtual OdGiRasterImagePtr snapshotRegion(const OdGsDCRect &area, bool bCrop) const; //DOM-IGNORE-BEGIN // TtfFonts cache support OdRxObjectPtr tfcNewMetafile(void *pSessionId); OdGiConveyorGeometry *tfcBeginMetafile(OdRxObject *pMetafile, void *pSessionId); void tfcFinalizeMetafile(OdRxObject *pMetafile, void *pSessionId); void tfcPlayMetafile(const OdGeMatrix3d &xForm, const OdRxObject *pMetafile, void *pSessionId) const; //DOM-IGNORE-END }; /** \details This class implements Win32 DirectX Vectorizer View objects. Library: Source code provided. */ class ExGsDirectXView : public OdGsBaseMaterialViewMT, protected OdGsPropertiesDirectRenderOutput, public D3dMaterialViewRedirect, public ExFPPrecisionFix { public: /** \details Returns the ExGsDirectXDevice object associated with this Vectorizer View object. \returns Pointer to the ExGsDirectXDevice instance representing an owning device. */ ExGsDirectXDevice* device() const { return static_cast(OdGsBaseVectorizeView::device()); } private: /** \details Returns the DirectX screen rectangle associated with this Vectorizer View object. \param left [out] Receives the left ordinate of the rectangle. \param bottom [out] Receives the bottom ordinate of the rectangle. \param width [out] Receives the width of the rectangle. \param height [out] Receives the height of the rectangle. */ void getDXScreenRect(double& left, double& bottom, double& width, double& height); /** \details Sets the pixels to DirectX transformation matrix for this Vectorizer View object. \param pixels2DxCoords [in] Transformation matrix. */ void setViewportClip(const OdGeMatrix3d& pixels2DxCoords); ExGiDirectXGeometryPtr m_pGeometry; // todo -- duplicated with Gl device bool m_bSelecting; // Number of non-default lights OdUInt32 m_numLights; // Enables geometry fading bool m_bFading; OdUInt8 m_nCurFading; // Enables transparencies rendering bool m_bDrawTransparency; protected: /** \details Returns the DirectX color corresponding to the specified color. \param color [in] Color. */ DWORD getD3DColor(const OdCmEntityColor& color); DWORD getD3DColor(ODCOLORREF color); /** \details Updates the lights attached to this VectorizeView object. */ void updateLights(); bool usesDept(double* pMinDeptSupported, double* pMaxDeptSupported) const; bool sceneDept(double& zNear, double& zFar) const; /** \details Returns all transformation matrices for current viewport. */ void viewportTransforms(D3DXMATRIX &matView, D3DXMATRIX &matProjection, OdGeMatrix3d &pixels2DxCoords, bool bNoDept = false); /** \details Returns current vectorizer state branch by type. \param branchType [in] Branch type. */ const OdGsStateBranch *getCurrentStateBranch(OdGsStateBranch::BranchType branchType) const { return currentStateBranch(branchType); } /** \details Returns true in case if any of state branch types is active. */ bool isAnyStateBranchActive() const { return hasAnyStateBranch(); } /** \details Returns true in case if dynamic subentities highlighting mode enabled. */ virtual bool dynamicSubEntHlt() const { return const_cast(this)->device()->supportDynamicSubhighlight(); } void resetFading(bool bFlag); public: /** \details Default constructor for the ExGsDirectXView class. */ ExGsDirectXView(); /** \details Destructor for the ExGsDirectXView class. */ virtual ~ExGsDirectXView(); /** \details Returns the matrix that transforms view space to normalized device space for this Vectorizer View object. \returns OdGeMatrix3d instance containing transformation data. */ OdGeMatrix3d projectionMatrix_D3D() const; /** \details Returns a reference to the OdGiDirectXGeometry object associated with this Vectorizer device. \returns Reference to the ExGiDirectXGeometry instance for processing geometry data. */ ExGiDirectXGeometry& geometry(); /** \details Creates a new GsMetafile (cache) object. \returns Returns a SmartPointer to the newly created object. */ OdRxObjectPtr newGsMetafile(); /** \details Begins vectorization of the specified GsMetafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void beginMetafile(OdRxObject* pMetafile); /** \details Ends vectorization of the specified GsMetafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void endMetafile(OdRxObject* pMetafile); /** \details Plays (draws) the specified Metafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void playMetafile(const OdRxObject* pMetafile); /** \details Pushes a transformation matrix for a metafile onto the stack. The resulting transformation is created by multiplying the specified transform matrix by the existing one. This allows you to easily adjust an entity coordinate system. Use the popMetafileTransform() to remove this transform matrix from the stack when you are finished with this transformation. \param xfm [in] Transformation matrix. \param uFlags [in] Metafile transform flags. \remarks This method takes effect only if the passed flags parameter has the OdGsBaseVectorizer::kSharedRefUpdate flag set to true. */ void pushMetafileTransform(const OdGeMatrix3d& mtx, OdUInt32 uFlags = 0); /** \details Pops a transformation from the stack. This method should be used after a successful pushMetafileTransform() method call to restore previous transform state. \param uFlags [in] Metafile transform flags. */ void popMetafileTransform(OdUInt32 uFlags = 0); /** \details Retrieves the block insert transform, which is the model-to-world coordinate transform. \returns Model-to-world transform matrix. */ const OdGeMatrix3d &metafileTransform() const; /** \details Transforms the specified matrix by the transformation matrix of a metafile. \param mtx [in/out] Matrix to transform. \param bInverse [in] Flag that specifies whether to use inverted transformation matrix of a metafile. \remarks Performs transformation: metafileMtx * mtx. */ void xformByMetafileTransform(OdGeMatrix3d &mtx, bool bInverse = true) const; /** \details Transforms the specified vector by the transformation matrix of a metafile. \param vec [in/out] Vector to transform. \param bInverse [in] Flag that specifies whether to use inverted transformation matrix of a metafile. \remarks Performs transformation: metafileMtx * vec. */ void xformByMetafileTransform(OdGeVector3d &vec, bool bInverse = true) const; //SEA protected: OdGiXformPtr m_pSelectXfm; OdGiConveyorConnector m_mfEntryPoint; public: bool useMetafileAsGeometry() const; OdGiConveyorOutput& outputForMetafileGeometry(); void setTransformForMetafileGeometry(const OdGeMatrix3d& mtx); OdGeMatrix3d getTransformForMetafileGeometry() const; OdGiConveyorGeometry &metafileEntryPoint() { return m_mfEntryPoint.geometry(); } /** \details Begins the view vectorization procedure. */ void beginViewVectorization(); /** \details Sets viewport's common data before display() call. */ void loadViewport(); /** \details Ends the view vectorization procedure. */ void endViewVectorization(); /** \details Passes to the visualization framework an object that can visualize itself. \param origin [in] Object origin. \param u [in] Object width vector. \param v [in] Object height vector. \param pDrawable [in] Pointer to the drawable. \param dcAligned [in] Reserved. \param allowClipping [in] Reserved. \remarks The visualization framework uses this function to visualize Ole2Frame entities. \remarks ownerDrawDc is not conveyor primitive, so the ODA visualization framework performs no processing (transformation, linetyping, or clipping) for this object. All coordinates are in Model coordinates. */ void ownerDrawDc(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiSelfGdiDrawable* pDrawable, bool dcAligned, bool allowClipping); /** \details Method that is called when entity traits are modified. */ void onTraitsModified(); /** \details Method that is called when render type is changed. \param renderType [in] Render type. \remarks mode must be one of the following: NameValueDescription kUserBg1 -3 User-defined background rendering type without Z-buffer kUserBg2 -2 User-defined background rendering type with own Z-buffer kUserBg3 -1 User-defined background rendering type with Z-buffer kMain 0 Use main Z-buffer kSprite 1 Use alternate Z-buffer (for sprites) kDirect 2 Render on device directly kHighlight 3 Render on device directly (skipping frame buffer and Z-buffer) kHighlightSelection 4 Render on device directly using highlighting style (skipping frame buffer and Z-buffer) kDirectTopmost 5 Render on top of all other render types without Z-buffer kContrast 6 Render with contrast style kCount 7 Number of primary predefined RenderType's kUserFg1 8 User-defined foreground rendering type with Z-buffer kUserFg2 9 User-defined foreground rendering type with own Z-buffer kUserFg3 10 Second user-defined foreground rendering type without Z-buffer
*/ void renderTypeOnChange(OdGsModel::RenderType renderType); /** \details Invokes the specified OdGsSelectionReactor object for the specified selection area (or point) in this view. \param points [in] Array of points. \param numPoints [in] Number of points. \param pReactor [in] Pointer to the reactor. \param mode [in] Selection mode. */ void select(const OdGePoint2d* points, int numPoints, OdGsSelectionReactor* pReactor, OdGsView::SelectionMode mode); bool forceMetafilesDependence() const; bool metafileTransformOverrided() const; const OdGeMatrix3d &metafileToWorldMatrix() const; const OdGeMatrix3d &worldToMetafileMatrix() const; const OdGeMatrix3d &viewportToOutputMatrix() const; const OdGeMatrix3d &outputToViewportMatrix() const; /** \details Returns common regeneration coefficient. \returns Regeneration coefficient value. \remarks Since 3D vectorization devices invoke with GPU's that typically don't support 64-bit floating point variables, a geometry which is placed on large coordinates can look broken because of truncation to 32-bit floating point variables. An application can use this device property to detect if truncation takes place and initiate geometry regeneration. */ double regenCoef(); /** \details Introduces a text into this vectorization context. \param position [in] Position of the text. \param normal [in] Normal to a plane where text lies. Used to define v parameter as normal.crossProduct(direction). \param direction [in] Direction vector that is interpreted as u parameter. \param msg [in] Message string. \param length [in] Message length. \param raw [in] If and only if true, escape sequences, such as %%P, will not be converted to special characters. \param pTextStyle [in] Pointer to the TextStyle for the text. \sa */ void text(const OdGePoint3d& position, const OdGeVector3d& normal, const OdGeVector3d& direction, const OdChar* msg, OdInt32 length, bool raw, const OdGiTextStyle* pTextStyle); /** \details Introduces a shell into this Vectorizer context. \param numVertices [in] Number of vertices. \param vertexList [in] Array of vertices. \param faceListSize [in] Number of entries in faceList. \param faceList [in] Array of numbers that define the faces. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \sa */ void shell( OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0); /** \details Introduces a mesh into this Vectorizer context. \param numRows [in] Number of rows. \param numColumns [in] Number of columns. \param vertexList [in] Array of vertices. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \sa */ void mesh( OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0); /** \details Introduces a pline into this Vectorizer context. \param polyline [in] Polyline data to be processed. \param fromIndex [in] Index of the first segment to be processed. \param numSegs [in] Number of segments to be processed. \sa */ void pline(const OdGiPolyline &polyline, OdUInt32 fromIndex = 0, OdUInt32 numSegs = 0); /** \details Adds a point light to this VectorizeView object. \param traits [in] Light traits data. */ void addPointLight(const OdGiPointLightTraitsData& traits); /** \details Adds a spotlight to this VectorizeView object. \param traits [in] Light traits data. */ void addSpotLight(const OdGiSpotLightTraitsData& traits); /** \details Adds a distant light to this VectorizeView object. \param traits [in] Light traits data. */ void addDistantLight(const OdGiDistantLightTraitsData& traits); /** \details Appends a light with the specified traits to this VectorizeView object. \param traits [in] Light traits data. \param light [in] Receives the specified traits. */ void appendLight(const OdGiLightTraitsData& traits, D3DLIGHT& light); /** \details Searches a raster image in the cache. \param pImg [in] Pointer to a raster image. \param bTransparency [in] Flag that specifies whether transparency is used. \param fgColor [in] Foreground color. \param bSecColor [in] Flag that specifies whether secondary color is used. \param bkColor [in] Background color. \param fBrightness [in] Image brightness value in range [0..100]. \param fContrast [in] Image contrast value in range [0..100]. \param fFade [in] Image fade value in range [0..100]. \returns Index of an entry in cache if found, otherwise returns 0xFFFFFFFF. The entry needs to have all parameters equal to the provided parameters. */ OdUInt32 findRasterImage(const OdGiRasterImage *pImg, bool bTransparency, ODCOLORREF fgColor, bool bSecColor, ODCOLORREF bkColor, double fBrightness, double fContrast, double fFade) const; /** \details Adds a raster image to the cache. \param pTexture [in] Texture definition. \param pImg [in] Pointer to a raster image. \param bTransparency [in] Flag that specifies whether transparency is used. \param fgColor [in] Foreground color. \param bSecColor [in] Flag that specifies whether secondary color is used. \param bkColor [in] Background color. \param fBrightness [in] Image brightness value in range [0..100]. \param fContrast [in] Image contrast value in range [0..100]. \param fFade [in] Image fade value in range [0..100]. \param bIncrement [in] Flag that specifies whether to increment reference counter. \returns Index of an added entry. */ OdUInt32 addRasterImage(RasterImageRef &pTexture, const OdGiRasterImage *pImg, bool bTransparency, ODCOLORREF fgColor, bool bSecColor, ODCOLORREF bkColor, double fBrightness, double fContrast, double fFade, bool bIncrement = true); /** \details Increments a reference counter for a cache entry at the specified index. \param uNum [in] Entry number. \returns Image texture at the specified index. */ RasterImageRef incrementRasterImageRef(OdUInt32 uNum); /** \details Increments a reference counter for a cache entry that has the specified texture. \param pTexture [in] Texture. \returns true if successful, false otherwise. */ bool incrementRasterImageRef(CComPtr pTexture); /** \details Decrements a reference counter for a cache entry at the specified index. \param uNum [in] Entry number. \returns true if the entry gets removed due to reaching to 0 reference count, false otherwise. */ bool decrementRasterImageRef(OdUInt32 uNum); /** \details Increments a reference counter for a cache entry that has the specified texture. \param pTexture [in] Texture. \returns true if the entry gets removed due to reaching 0 reference count, false otherwise. */ bool decrementRasterImageRef(CComPtr pTexture); bool isSecondaryColorNeed() const; ODCOLORREF getSecondaryColor() const; /** \details Returns material textures manager. \returns Pointer to the material textures manager. */ OdGiMaterialTextureManager *materialTextureManager(); /** \details Returns resource sharing provider. \returns Pointer to resource sharing provider. */ D3dResourceSharingProvider *sharingProvider(); /** \details Returns MT synchronization helpers. \returns Reference to the OdGsBaseDeviceMTHelpers instance representing multithreading helpers. */ OdGsBaseDeviceMTHelpers *mtDeviceSync(); // VisualStyle /** \details Sets the current visual style. \param visualStyle [in] Visual style to set. \sa */ void setVisualStyle(const OdGiVisualStyle &visualStyle); // Materials support /** \details Checks whether the current material needs to be skipped. \param visualStyle [in] Material id. \returns true if material needs to be skipped, false otherwise. */ bool skipMaterialProcess(OdDbStub *materialId) const; /** \details This method is called to initialize/reinitialize material cache. \param prevCache [in] Previous cache, if available. \param materialId [in] Material identifier. \param materialData [in] Current material traits. \returns Smart pointer to a material item. */ OdGiMaterialItemPtr fillMaterialCache(OdGiMaterialItemPtr prevCache, OdDbStub *materialId, const OdGiMaterialTraitsData &materialData); /** \details This method is called to render material cache. \param pCache [in] Material cache. \param materialId [in] Material identifier. */ void renderMaterialCache(OdGiMaterialItemPtr pCache, OdDbStub *materialId); /** \details This method is called by delay cache entry as default handler. \param pEntry [in] Material cache. */ void playDelayCacheEntry(const DelayCacheEntry *pEntry); /** \details This method is called by delay cache writer if mapping entry is changed. \remarks Can be used to link cache markers with texture coordinates that must be recalculated after extents are calculated. */ void mapperChangedForDelayCache(); OdGiMaterialItemPtr geometryCurrentMaterial() const; void geometryResetCurrentMaterial(OdGiMaterialItemPtr pMaterial); bool geometryIsMaterialEnabled() const; bool geometryIsMaterialAvailable() const; void geometryResetCurrentMaterial(); OdGiMapperItemPtr geometryCurrentMapper(bool bForCoords = true) const; void geometryResetCurrentMapper(OdGiMapperItemPtr pMapper); bool geometryIsMapperEnabled() const; bool geometryIsMapperAvailable() const; bool geometryIsMappingDelayed() const; void geometryAppendDelayCacheEntry(void *pEntry); // override viewport frame rendering /** \details Draws the frame (border) for the viewport. */ void drawViewportFrame(); // Snapshot support /** \details Gets a snapshot of the current device. \param pImage [out] Receives a snapshot image. \param region [in] Region from which to take a snapshot. */ void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect ®ion); //DOM-IGNORE-BEGIN // TtfFonts cache support OdRxObjectPtr tfcNewMetafile(); OdGiConveyorGeometry *tfcBeginMetafile(OdRxObject *pMetafile); void tfcFinalizeMetafile(OdRxObject *pMetafile); void tfcPlayMetafile(const OdGeMatrix3d &xForm, const OdRxObject *pMetafile) const; OdTtfFontsCache *getTtfFontsCache(); //DOM-IGNORE-END /** \details Returns color converter used by the device. \returns Pointer to the OdColorConverterCallback object. \remarks For more information, see */ OdColorConverterCallback *getColorConverter(); /** \details Returns the Background Color of the GUI window of the Device object. \returns Background color value. */ DWORD getBackgroundColor(); virtual void updatePaletteOverride(const OdGiPalette *pPalette); /** \details Checks whether vectorization device processes monochrome raster images as 1 byte per pixel textures with palette. \returns true if the UseLutPalette property has bit 1 set. \remarks This option reduces memory usage for monochrome raster images. If it isn't set, then monochrome images are processed as 4 bytes per pixel textures. */ bool useLutPaletteMonochrome() const; /** \details Checks whether vectorization device processes 4 and 8 bits per pixel raster images as 1 byte per pixel textures with palette. \returns true if the UseLutPalette property has bit 2 set. \remarks This option reduces memory usage for raster images with 16 and 256 color palettes. If it isn't set, then 4 and 8 bits per pixel images are processed as 3 or 4 bytes per pixel textures. */ bool useLutPaletteColor() const; int checkLineTopology(const OdGePoint3d &pt1, const OdGePoint3d &pt2) const; // Background rendering compatibility protected: void display(bool update); void setupDepthBias(bool bEnable); void setupDisplayOpts(bool bEnable); bool getDeviceMapperMatrix(OdGeMatrix3d &dm) const; void renderBackground(bool secondPass = false); void directRenderOutputImage(const OdGePoint3d *pRect, const OdGiRasterImage *pImage, const OdGsPropertiesDirectRenderOutput::DirectRenderImageParams &driParams); OdUInt32 directRenderOutputFlags() const; // directRenderImages cache struct DRICacheElement { DRICacheElement(); ~DRICacheElement(); void initialize(const OdGiDrawable *pDrawable, const OdGiRasterImage *pImage, ExGsDirectXView &view); void destroy(); bool isBackground() const; bool isInitialized() const; bool isEqual(const OdGiDrawable *pDrawable, const OdGiRasterImage *pImage) const; private: const OdGiDrawable* m_pDrawable; // For pointer compare only const OdGiRasterImage* m_pImage; // For pointer compare only public: OdGiDrawable::DrawableType dType; CComPtr pTexture; }; OdArray m_driCache; }; #include "TD_PackPop.h" #endif // __OD_EX_DIRECT_X_DEVICE__