fthrattr.h

Go to the documentation of this file.
00001 // $Id: fthrattr.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 #ifndef INC_FEATHRATTR
00100 #define INC_FEATHRATTR
00101 
00102 // structs, typedefs, defines
00103 //#include "unittype.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 
00105 // class definitions
00106 //  1 - call classes member functions,
00107 //  2 - use the class type for one of the members (not required if have pointer to class ??)
00108 //  3 - to derive a superclass??
00109 #include "offattr.h"
00110 //#include "biasgain.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 
00113 // for MAX_SHADOW_BLUR
00114 #include "bshadow.h"
00115 
00117 // class predeclarations
00119 class BitmapTranspFillAttribute;
00120 class TranspFillMappingLinearAttribute;
00121 class PaintingModeAttributeValue;
00122 class KernelBitmap;
00123 class BitmapFillAttribute;
00124 class BitmapTranspFillAttribute;
00125 class GRenderRegion;
00126 class CCAttrMap;
00127 
00129 // feather defaults (for zoom 100%; ie 750 MP per PIXEL == PX_MP_VAL)
00131 #define DEFAULT_FEATHERSIZE_PIX             2
00132 #define DEFAULT_FEATHERSIZE_MP              ((MILLIPOINT) (DEFAULT_FEATHERSIZE_PIX * PX_MP_VAL))
00133 #define MAX_FEATHERSIZE_MP MAX_SHADOW_BLUR * PX_MP_VAL      // MAX_SHADOW_BLUR defined in bshadow.h .
00134                                                             // PX_MP_VAL defined in units.h = mp per pixels @ 100% zoom
00135 #define DEFAULT_GAP_TOLERANCE_MP            ((MILLIPOINT) (PX_MP_VAL * 0.75))
00136                                                             // gaps less than 1.5 pixels wide @ 100% zoom 
00137                                                             // will not have feathering along their edges
00138                                                             // NB used as contour width hence min gap = 2*GapToleranceMP wide.
00139 
00140 // NB Implications of MAX_FEATHERSIZE_MP:-
00141 //  1   can't ever have greater than 40pixel feather size
00142 //  2   at low zoom can't acheive full 40pix onscreen zoom
00143 //      max pix @ view < 100% = 40pix * ViewScale
00144 //      max pix @ view > 100% = 40pix
00145 
00147 // debugging
00149 // Create a bitmap copy of the feathered object for comparison with the bitmap generated
00150 // via the offscreen rendering system (ie m_pOffscreenBitmapInfo/Bits inside OffscreenRenderingCompleted)
00151 // NB Set _DEBUG_OFFSCREEN_PIXEL_WIDTH, leave _DEBUG_OFFSCREEN_MP_WIDTH as is
00152 // ( See notes in fthrattr.cpp for useage guidelines )
00153 //#define _DEBUG_OFFSCREEN_PIXEL_WIDTH      44
00154 //#define _DEBUG_OFFSCREEN_MP_WIDTH         _DEBUG_OFFSCREEN_PIXEL_WIDTH * 750
00155 
00157 //
00158 //                              Helper functions
00159 //
00161 // Conversion between millipoints and pixels at current view scale
00162 FIXED16 GetCurrentViewScale();
00163 MILLIPOINT ConvertMeasurementToMillipointsAtCurrentViewScale(INT32 Width, UnitType type);
00164 UINT32 ConvertMillipointsToPixelsAtCurrentViewScale(MILLIPOINT mp);
00165 INT32 PixelsPerMeterAtCurrentViewScale();
00166 
00167 // Ensuring contour code works correctly
00168 BOOL CheckLineAttrs(CCAttrMap* pAttrMap);
00169 BOOL MakeLineAttributeCompleteForContouring(Node* Context, Node* NodeToModify, CCAttrMap* pAttrMap);
00170 
00172 //
00173 //                              AttributeValue classes
00174 //
00176 
00177 /********************************************************************************************
00178 >   class FeatherAttrValue : public AttributeValue
00179     Author:     Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com>
00180     Created:    24/01/2000
00181     Purpose:    
00182     SeeAlso:    
00183  ********************************************************************************************/
00184 
00185 class FeatherAttrValue : public OffscreenAttrValue
00186 {
00187     CC_DECLARE_DYNCREATE( FeatherAttrValue )
00188 
00189 public:
00190 
00191     FeatherAttrValue();
00192     ~FeatherAttrValue();
00193 
00194     // Standard functions required by Attribute framework 
00195     static BOOL Init();
00196     virtual void SimpleCopy(AttributeValue *);
00197 //  virtual BOOL IsDifferent(AttributeValue*);  Not applicable
00198     virtual NodeAttribute *MakeNode();
00199 
00200     // Blending offscreen attrs
00201     virtual BOOL Blend(BlendAttrParam* pBlendParam);
00202 
00203     // Generic attr rendering functions
00204     // (rely on GRenderRegion offscreen rendering system create and swap bitmaps)
00205     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00206     virtual void Restore(RenderRegion *, BOOL);
00207 
00208     // Allow derived classes to overide integral parts of the offscreen bmp setup process
00209     virtual void GetMinimumOffscreenBmpDimensions(UINT32* RequiredWidth, UINT32* RequiredHeight);
00210 
00211     // Offscreen rendering functions.
00212     virtual void OffscreenRenderingCompleted(RenderRegion *pRender, LPBITMAPINFO lpBitmapInfo, LPBYTE lpBits, DocRect BitmapRect);
00213     virtual BOOL DoesOffscreenBmpRequireTransp(GRenderRegion* pGRR);
00214     virtual BOOL DoesOffscreenBMPCaptureBackground() {return TRUE;}     // Return TRUE if you can make this work
00215                                                                         // During rotated printing (it works on screen)
00216     virtual BOOL CreateFeatherTransp(GRenderRegion* pGRR,
00217                                      Path* pPath,
00218                                      double dPixelWidth,
00219                                      BitmapTranspFillAttribute** ppFeatherTransp,
00220                                      KernelBitmap** ppFeatherBitmap);
00221 
00222 private:
00223     // Internal helper functions used in rendering the feather bitmap
00224     KernelBitmap*   CreateFeatherBitmap(GRenderRegion* pGRR, double pixBlurDiameter);
00225     LPBITMAPINFO    CreateSilhouetteBitmap(GRenderRegion* GRR, LPBYTE* ppBmpBits, Path* pOutline = NULL);
00226 
00227     void SetupFeatherBitmapPalette(KernelBitmap* pFeatherBMP);
00228     void CreateBitmapFill(KernelBitmap* pBitmap, DocRect* dr, BitmapFillAttribute* BmpFill);
00229     void CreateBitmapFillRot90(KernelBitmap* pBitmap, DocRect* dr, BitmapFillAttribute* BmpFill);
00230     void CreateBitmapTranspFill(KernelBitmap* pFeather, DocRect* dr, BitmapTranspFillAttribute* BmpTranspFill);
00231     Path* GetVisibleBoundingPath();
00232 
00233 public:
00234     // Creation/modification triggered by Feather Ops
00235     BOOL SetupFeather(Node* pNode, INT32 Width = DEFAULT_FEATHERSIZE_MP, UnitType type = MILLIPOINTS);
00236     BOOL ChangeFeatherProfile(CProfileBiasGain &biasgain);
00237     BOOL ChangeFeatherSize(INT32 , UnitType );
00238 
00239 public:
00240     // Queries to support feather control UI updating (feather only)
00241 
00242     MILLIPOINT GetFeatherSize();
00243     double GetFeatherPixelSize(double fPixelWidth);
00244     CProfileBiasGain GetProfile() { return m_Profile; }
00245     CProfileBiasGain* GetProfilePtr() { return &m_Profile; }        // return pointer to profile
00246 
00247     // Set functions for saving/loading feather attrs and change operations
00248     MILLIPOINT SetFeatherSize(MILLIPOINT sz);
00249     void SetFeatherProfile(CProfileBiasGain &biasgain);
00250     virtual void SetLinkedNode(NodeRenderableBounded* pNode);
00251 
00252 public:
00253     //-------------------------------------------------------------------------------------------------------------
00254     //                                  New attribute systems support
00255     //
00256     // Feather attributes are linked to the objects geometry in the following ways:-
00257     //      need bounding rects of objects to determine offscreen bitmap size
00258     //      need bounding/outer contour path of objects to create feather mask
00259     //
00260 
00261     virtual BOOL CanBeRenderedDirectly();
00262 
00263     // Caching and regenerating objects outercontour.
00264     BOOL GenerateOuterContour();
00265     Path* GetOuterContour() { return m_pOuterContour; }
00266     BOOL RegenerateOuterContourOnNextRedraw(UndoableOperation* pOp=NULL);
00267     void SetOuterContour(Path* pNewOuterContour) { m_pOuterContour = pNewOuterContour; }
00268     //-------------------------------------------------------------------------------------------------------------
00269 
00270 private:
00271     //-------------------------------------------------------------------------------------------------------------
00272     //                                      Member Variables
00273     // Feather Attribute state members:
00274     CProfileBiasGain            m_Profile;
00275     MILLIPOINT                  m_FeatherSize;
00276     MILLIPOINT                  m_GapSize;
00277     Path*                       m_pOuterContour;        // used only in rendering but is cached
00278                                                         // updated by AllowOps
00279     DocRect                     m_drFeatherBB;          // the rect we render the feather transp bmp through.
00280 
00281     BOOL                        m_bCached;
00282 
00283     // The maximum feather size which we allow the user to play with.
00284     // This constant is defined at the top of fthrattr.cpp .
00285     static const MILLIPOINT MaxUserFeatherSize;
00286 
00287 #ifdef _DEBUG_OFFSCREEN_PIXEL_WIDTH
00288     // Debugging
00289     KernelBitmap*               md_ShadBmp; 
00290 #endif
00291 };
00292 
00293 
00295 //
00296 //                              NodeAttribute classes
00297 //
00299 
00300 
00301 /********************************************************************************************
00302 >   class AttrFeather : public NodeAttribute
00303     Author:     Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com>
00304     Created:    24/01/2000
00305     Purpose:    
00306     SeeAlso:    
00307  ********************************************************************************************/
00308 
00309 class AttrFeather : public NodeAttribute
00310 {
00311     CC_DECLARE_DYNAMIC( AttrFeather )
00312     
00313 public:
00314     AttrFeather() {}
00315     ~AttrFeather() {}
00316     AttrFeather(Node* ContextNode,  
00317                  AttachNodeDirection Direction,    
00318                  BOOL Locked=FALSE, 
00319                  BOOL Mangled=FALSE,  
00320                  BOOL Marked=FALSE, 
00321                  BOOL Selected=FALSE) : 
00322         NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected) {}
00323 
00324     // Traditional Node functionality
00325     virtual void Render( RenderRegion* pRender );
00326 #ifdef _DEBUG
00327     void GetDebugDetails(StringBase* Str);
00328 #endif
00329 
00330     // Traditional NodeAttribute functionality
00331     virtual AttributeValue* GetAttributeValue() { return &Value; }
00332     Node* SimpleCopy();
00333     virtual UINT32 GetAttrNameID();
00334     virtual AttrIndex GetAttributeIndex () { return ATTR_FEATHER; }
00335     virtual UINT32 GetNodeSize();
00336     virtual INT32 operator==(const NodeAttribute& NodeAttrib);
00337     // nb op== is also involved in redundant attribute removal
00338 
00339     // Node charateristics tests
00340     virtual BOOL NeedsTransparency() const { return TRUE; }
00341     virtual BOOL IsAFeatherAttr() const;
00342 
00343     // OpFeather triggered functions
00344     BOOL DoFeather(Node* pNode, INT32 size = DEFAULT_FEATHERSIZE_MP, UnitType type = MILLIPOINTS);
00345     BOOL DoSetProfile(CProfileBiasGain bg);
00346 
00347     // prevent feathering in incompatible circumstances
00348     virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00349 
00350     // support layering and remove redundant attrs
00351     virtual BOOL CanBeMultiplyApplied()     { return TRUE; }
00352     virtual BOOL ShouldBeOptimized();
00353 
00354     // dynamic attribute functions and flags
00355     virtual void Transform(TransformBase& Trans);
00356     virtual BOOL Blend(BlendAttrParam* pBlendParam);
00357     virtual BOOL IsLinkedToNodeGeometry() { return TRUE; }
00358     virtual BOOL IsLinkedToThisNode(Node* pNode);
00359 
00360     // support dynamic attribute creation
00361     virtual BOOL PostDynCreateInit(CCAttrMap* pMap, Path* InkPath, CCRuntimeClass* pCreatorClass);
00362     virtual BOOL PostDynCreateInit(CCAttrMap* pMap, Node* pNode, CCRuntimeClass* pCreatorClass);
00363     virtual void PostDynCreateDeInit();
00364 
00365     // gla support
00366     virtual BOOL LinkedNodeGeometryHasChanged(UndoableOperation* pOp);
00367     virtual void NewlyCreatedDefaultAttr(NodeDocument* pNode);
00368     virtual BOOL LinkToGeometry(Node* pContext);
00369     virtual BOOL ContainsAttributeValue(AttributeValue* pVal);
00370 
00371     // Karim 15/11/2000
00372     // ID function for attributes which divert rendering offscreen, such as ourself.
00373     virtual BOOL IsAnOffscreenAttribute() { return TRUE; }
00374     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00375 
00376     // Version 2 file format functions
00377     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00378     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00379 
00380 private:
00381     void CopyNodeContents(NodeAttribute *pCopy);
00382 
00383 public:
00384 
00385     FeatherAttrValue Value;
00386 
00387 };
00388 
00389 
00391 //
00392 //                              Saving and loading
00393 //
00395 
00396 
00397 /***********************************************************************************************
00398 
00399 >   class FeatherRecordHandler : public CamelotRecordHandler
00400 
00401     Author:     Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
00402     Created:    30/5/96
00403     Purpose:    Handles the reading of all feather records in the v2 file format
00404     SeeAlso:    -
00405 
00406 ***********************************************************************************************/
00407 
00408 class FeatherRecordHandler : public CamelotRecordHandler
00409 {
00410     // Give my name in memory dumps
00411     CC_DECLARE_DYNAMIC(FeatherRecordHandler);
00412 
00413 public:
00414     FeatherRecordHandler() : CamelotRecordHandler() {}
00415     ~FeatherRecordHandler() {}
00416 
00417     virtual UINT32* GetTagList();
00418     virtual BOOL    HandleRecord(CXaraFileRecord* pCXaraFileRecord);
00419 
00420 private:
00421     BOOL HandleFeatherRecord(CXaraFileRecord* pCXaraFileRecord);
00422 };
00423 
00424 #endif //INC_FEATHRATTR

Generated on Sat Nov 10 03:45:24 2007 for Camelot by  doxygen 1.4.4