00001 // $Id: beveler.h 751 2006-03-31 15:43:49Z alex $ 00003 // the bitmap beveler (for inner bevels) 00004 // DMc 2/6/98 00005 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00006 ================================XARAHEADERSTART=========================== 00007 00008 Xara LX, a vector drawing and manipulation program. 00009 Copyright (C) 1993-2006 Xara Group Ltd. 00010 Copyright on certain contributions may be held in joint with their 00011 respective authors. See AUTHORS file for details. 00012 00013 LICENSE TO USE AND MODIFY SOFTWARE 00014 ---------------------------------- 00015 00016 This file is part of Xara LX. 00017 00018 Xara LX is free software; you can redistribute it and/or modify it 00019 under the terms of the GNU General Public License version 2 as published 00020 by the Free Software Foundation. 00021 00022 Xara LX and its component source files are distributed in the hope 00023 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00024 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00025 See the GNU General Public License for more details. 00026 00027 You should have received a copy of the GNU General Public License along 00028 with Xara LX (see the file GPL in the root directory of the 00029 distribution); if not, write to the Free Software Foundation, Inc., 51 00030 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00031 00032 00033 ADDITIONAL RIGHTS 00034 ----------------- 00035 00036 Conditional upon your continuing compliance with the GNU General Public 00037 License described above, Xara Group Ltd grants to you certain additional 00038 rights. 00039 00040 The additional rights are to use, modify, and distribute the software 00041 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00042 library and any other such library that any version of Xara LX relased 00043 by Xara Group Ltd requires in order to compile and execute, including 00044 the static linking of that library to XaraLX. In the case of the 00045 "CDraw" library, you may satisfy obligation under the GNU General Public 00046 License to provide source code by providing a binary copy of the library 00047 concerned and a copy of the license accompanying it. 00048 00049 Nothing in this section restricts any of the rights you have under 00050 the GNU General Public License. 00051 00052 00053 SCOPE OF LICENSE 00054 ---------------- 00055 00056 This license applies to this program (XaraLX) and its constituent source 00057 files only, and does not necessarily apply to other Xara products which may 00058 in part share the same code base, and are subject to their own licensing 00059 terms. 00060 00061 This license does not apply to files in the wxXtra directory, which 00062 are built into a separate library, and are subject to the wxWindows 00063 license contained within that directory in the file "WXXTRA-LICENSE". 00064 00065 This license does not apply to the binary libraries (if any) within 00066 the "libs" directory, which are subject to a separate license contained 00067 within that directory in the file "LIBS-LICENSE". 00068 00069 00070 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00071 ---------------------------------------------- 00072 00073 Subject to the terms of the GNU Public License (see above), you are 00074 free to do whatever you like with your modifications. However, you may 00075 (at your option) wish contribute them to Xara's source tree. You can 00076 find details of how to do this at: 00077 http://www.xaraxtreme.org/developers/ 00078 00079 Prior to contributing your modifications, you will need to complete our 00080 contributor agreement. This can be found at: 00081 http://www.xaraxtreme.org/developers/contribute/ 00082 00083 Please note that Xara will not accept modifications which modify any of 00084 the text between the start and end of this header (marked 00085 XARAHEADERSTART and XARAHEADEREND). 00086 00087 00088 MARKS 00089 ----- 00090 00091 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00092 designs are registered or unregistered trademarks, design-marks, and/or 00093 service marks of Xara Group Ltd. All rights in these marks are reserved. 00094 00095 00096 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00097 http://www.xara.com/ 00098 00099 =================================XARAHEADEREND============================ 00100 */ 00101 00102 #ifndef _BEVELER_H 00103 #define _BEVELER_H 00104 00105 #include "pathtrap.h" 00106 //#include "bevtrap.h" 00107 //#include "wincoord.h" 00108 //#include "doccoord.h" 00109 //#include "bitmap.h" 00110 00111 #define BEVEL_FLATNESS 200 00112 00113 // macro to turn the system time into an INT32 value which can be used for timings 00114 #define LONGSYSTEMTIME(X) { SYSTEMTIME s; \ 00115 GetSystemTime(&s); \ 00116 X = s.wMilliseconds + s.wSecond * 1000 + \ 00117 s.wMinute * 60000 + \ 00118 s.wHour * 60000 * 60 ; } 00119 00120 #define WRITETIME(X, Y) { FILE * kxp = fopen("timings.txt", "a"); \ 00121 fprintf(kxp, X); fprintf(kxp, " %d\n", Y); \ 00122 fclose(kxp); } 00123 00124 class NodeBevel; 00125 struct BEVEL_FACE ; 00126 00127 #define BEVELBITMAPSCALE 4 00128 #define BEVELBITMAPSHIFT 2 00129 00130 /****************************************************************************************** 00131 00132 > class CBeveler : public SimpleCCObject 00133 00134 Author: David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> 00135 Created: 2/10/98 00136 00137 Purpose: Does the bevelling 00138 00139 ******************************************************************************************/ 00140 00141 class CBeveler : public CCObject 00142 { 00143 // Give my name out in memory dumps 00144 CC_DECLARE_DYNAMIC(CBeveler); 00145 00146 public: 00147 CBeveler(); 00148 CBeveler(Path * pPath); 00149 00150 ~CBeveler(); 00151 00152 void SetBevelType(INT32 t) { m_BevelType = t; } 00153 00154 BOOL SetUpBeveler(MILLIPOINT Indent, JointType jtype, NormCoord * lightVec, BOOL bOuter, 00155 INT32 Contrast, RenderRegion * pRegion, MILLIPOINT Flatness); 00156 /* 00157 BOOL SetUpBeveler(MILLIPOINT Indent, JointType jtype, NormCoord * lightVec, BOOL bOuter, 00158 INT32 width, INT32 height, INT32 Contrast, RenderRegion * pRegion, 00159 MILLIPOINT Flatness, double dpi, BOOL bFlat = TRUE); 00160 */ 00161 BOOL SetBevelerSize(INT32 Width, INT32 Height); 00162 00163 DocRect GetSelectionRect() { return m_SelectionBounds; } 00164 void SetBevelAngle(double LightAngle) { m_LightAngle = LightAngle; } 00165 void SetBevelTilt(double Tilt) { m_Tilt = Tilt; } 00166 00167 // gets the flatness to use depending on the document 00168 static INT32 GetBevelFlatness(); 00169 00170 // render the bevel to a given bitmap 00171 BOOL RenderToBitmap(KernelBitmap * pBitmap, BOOL bResample = FALSE, DocCoord* pSubPixOffSet = NULL); 00172 00173 private: 00174 MILLIPOINT m_Indent; 00175 INT32 m_Contrast; 00176 INT32 m_BevelType; 00177 double m_LightAngle; 00178 double m_Tilt; 00179 00180 // pointer to the path to be used in bevelling 00181 Path * m_pBevelPath; 00182 POINT* m_pBevelPoints ; 00183 BYTE * m_pBevelTypes ; 00184 UINT32 m_nBevelLength ; 00185 BYTE m_Transparency; 00186 00187 // the selection's bounding rect in document coordinates 00188 DocRect m_SelectionBounds; 00189 DocRect m_BevelBounds; 00190 00191 // sets up the above two scale factors 00192 void CalcSelectionBounds() ; 00193 void CalcInnerPath() ; 00194 void SetUpMapping(); 00195 00196 // transforms a win coord to a doc coord based on currently active spread and view 00197 void ToWinCoord(const DocCoord * dc, WinCoord * wc); 00198 00199 // the width and height of the bitmap that we are to return 00200 INT32 m_Width; 00201 INT32 m_Height; 00202 00203 KernelBitmap* m_pStrip32; 00204 KernelBitmap* m_pMaskBitmap; 00205 KernelBitmap* m_pNewMask; 00206 00207 JointType m_JointType; 00208 BOOL m_bOuter; 00209 00210 INT32 SetDIBitmap( BITMAPINFOHEADER* pHeader, BYTE* pBits ) ; 00211 00212 BEVEL_FACE* m_pFaceList; 00213 UINT32 m_NumFaces; 00214 00215 // resamples the bitmap given into destination 00216 void ResampleBitmap(BYTE * p32BitDIB, UINT32 Width, UINT32 Height, BYTE * pDestBits, 00217 BYTE * pMaskBitmap); 00218 00219 BOOL EmboldenBitmap(KernelBitmap* pImgBitmap, KernelBitmap* pMaskBitmap, KernelBitmap* pNewMaskBitmap); 00220 00221 double m_dBmpToWinX; 00222 double m_dBmpToWinY; 00223 00224 // renders the points list, resampling 00225 BOOL RenderWithResampling(KernelBitmap * pBitmap, INT32 OffsetX, INT32 OffsetY, DocCoord* pSubPixOffSet = NULL); 00226 00227 // copy bitmap fn 00228 void CopyBitmapIntoBitmap(const KernelBitmap * pSrcBitmap, KernelBitmap * pDestBitmap, 00229 INT32 DestX, INT32 DestY); 00230 00231 BOOL RenderInStripsToBitmap(KernelBitmap * pBitmap, DocCoord* pSubPixOffSet = NULL); 00232 } ; 00233 00234 00235 #endif