nodebev.h

Go to the documentation of this file.
00001 // $Id: nodebev.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_NODEBEVEL
00100 #define INC_NODEBEVEL
00101 
00102 #include "nodepath.h"
00103 #include "beveler.h"
00104 
00105 // file input & output stuff
00106 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "cxftags.h"
00108 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "attr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "grndbmp.h"
00113 
00114 //#ifdef BUILDSHADOWS
00115 
00116 class NodeBevelController;
00117 class ExtendParams;
00118 class SumAllPathsElem;
00119 class NodeCompound;
00120 class BitmapTranspFillAttribute;
00121 
00122 /***********************************************************************************************
00123 
00124 >   class NodeBevel : public NodePath
00125 
00126     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00127     Created:    6/10/98
00128     Purpose:    Does the bevelling
00129 
00130 ***********************************************************************************************/
00131 
00132 class NodeBevel : public NodeRenderableInk
00133 {
00134     // Give my name out in memory dumps
00135     CC_DECLARE_DYNCREATE(NodeBevel);
00136 
00137 public:
00138     NodeBevel();
00139     ~NodeBevel();
00140 
00141     NodeBevel(Node* ContextNode,  
00142                 AttachNodeDirection Direction,  
00143                 BOOL Locked = FALSE, 
00144                 BOOL Mangled = FALSE,  
00145                 BOOL Marked = FALSE, 
00146                 BOOL Selected = FALSE    
00147                 ) ;
00148 
00149     // copy this node
00150     virtual Node* SimpleCopy(); 
00151     void CopyNodeContents(NodeBevel* pNewNode);
00152     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00153 
00154     // just does bevelling (generation of paths & the bitmap)!
00155     BOOL GenerateBevel();
00156     
00157     // generates the bevel from a particular node list
00158     BOOL GenerateBevelForBlendStep(SumAllPathsElem* pElem, CCAttrMap * pMap);
00159 
00160     // set up all the variables on myself & my parent by finding the appropriate
00161     // attributes
00162     BOOL SetupVariables(CCAttrMap * pMap = NULL);
00163 
00164     // get the bounding rect of me
00165     virtual DocRect GetBoundingRect(BOOL DontUseAttrs = FALSE, BOOL HitTest = FALSE);
00166     virtual DocRect GetBlobBoundingRect();
00167     virtual void SetBoundingRect(DocRect rect) { m_SelectedRect = rect; }
00168 
00169     // rendering functions
00170     virtual void RenderBitmap(RenderRegion* pRender);
00171     virtual void Render(RenderRegion* pRender);
00172 
00173     virtual void Transform( TransformBase& Trans );
00174     
00175     // we don't want to have brush attrs applied to us.
00176     virtual BOOL RequiresAttrib(CCRuntimeClass* pAttribClass, BOOL Search = FALSE);
00177     virtual BOOL RequiresAttrib(NodeAttribute* pAttr, BOOL Search = FALSE);
00178     virtual BOOL CanAttrBeAppliedToMe(CCRuntimeClass* pAttribClass);
00179 
00180     virtual NodeCompound* GetParentController() const;
00181 
00182     // no, I'm actually a bevel node, even though I'm derived from the NodePath class
00183     virtual BOOL IsNodePath() const;
00184 
00185     virtual BOOL IsABevel() const { return TRUE; } 
00186 
00187     // deletes all data & bitmaps
00188     void DeleteCache();
00189     void DeleteCachedBitmap();
00190 
00191     // calculate all the bevel paths
00192     BOOL CreateBevelPaths();
00193 
00194     virtual void RenderEorDrag( RenderRegion* rr );
00195     
00196     // makes sure that on the next render, the bevel is regenerated
00197     void InvalidateMe() {};
00198 
00199     virtual BOOL NeedsTransparency() const;
00200 
00201     void DisableRendering() { m_bStopRender = TRUE; }
00202     void EnableRendering()  { m_bStopRender = FALSE; }
00203     BOOL IsRenderingStopped() { return m_bStopRender; }
00204 
00205     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00206     virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00207 
00208     virtual String Describe(BOOL Plural, BOOL Verbose = TRUE);
00209 
00210     virtual BOOL NeedsParent(Node* pNode) const;
00211 
00212     BOOL PostDuplicate(UndoableOperation* pOp);
00213 
00214     BOOL AllowOp(ObjChangeParam *pParam, BOOL SetOpPermissionState,
00215                                          BOOL DoPreTriggerEdit = TRUE);
00216 
00217     DocRect GetPathBoundingRect() { return m_Path.GetBoundingRect(); }
00218 
00219     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00220     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00221 
00222     virtual BOOL ExportRender ( RenderRegion *pRegion );
00223     virtual void PreExportRender ( RenderRegion *pRegion );
00224 
00225     virtual void RenderTinyBlobs(RenderRegion* pRender);
00226 
00227     BitmapFillAttribute* GetBitmapFillAttribute ( void );
00228 
00229     virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00230 
00231     BOOL AmICached() { return m_bCached; }
00232 
00233     // Karim MacDonald 25/11/1999
00234     // virtual Extend functions; see declaration/implementation in Node.
00235     virtual BOOL IsTypeExtendible() const { return TRUE; }
00236     virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00237     virtual void Extend(const ExtendParams& ExtParams);
00238 
00239     // used in the shadowing code to ensure that when the bitmap is created it's
00240     // just black-on-white
00241     void SetRenderBitmaps(BOOL b) { m_bRenderBitmaps = b; }
00242     BOOL GetRenderBitmaps() { return m_bRenderBitmaps; }
00243 
00244     // used by the glow shadow, to tell the node whether to zero the line width or not
00245     void SetZeroLineWidths(BOOL b) { m_bZeroLineWidth = b; }
00246 
00247     // gets the bounding rect of my original objects
00248     DocRect GetInsideBoundingRect();
00249 
00250     // re-renders the bevel bitmap given a particular light angle
00251     // - the beveler MUST be initialised !
00252     // the flag is to indicate whether to resample the bitmap i.e. to
00253     // generate the antialiased bitmap or not
00254     BOOL ReRenderBevelBitmap(BOOL bAntialias);
00255 
00256     virtual INT32 EstimateNodeComplexity (OpParam* details);
00257 
00258     // This returns the outer path for the bevel as a whole shape, NOT with the cut though!
00259     Path* GetOuterBevelPath() { return &m_OuterBevelPath; } 
00260     Path* GetBevelPath() { return &m_Path; }
00261 
00262     void DoRender(BOOL DoRender = TRUE) { m_DoRender = DoRender; }
00263 
00264     KernelBitmap* GetBevelBitmap() const { return m_pBevelBitmap; }
00265 
00266     KernelBitmap* CreateBitmapCopy(double DPI = -1.0, BOOL CheckFillFlags = TRUE);
00267 
00268     void SetConvertingFlag(BOOL Set = FALSE) { m_AmConvertingToShapes = Set; }
00269 
00270     void GetDebugDetails(StringBase* Str);
00271 
00272 public:
00273     // the data members for the bevel
00274     // public for easy access
00275     Path InkPath;
00276 
00277     BOOL m_MustRegenOnChildChange;
00278 
00279     INT32 m_BevelType;
00280     INT32 m_Indent;
00281     
00282     double m_LightAngle;
00283     BOOL m_bOuter;
00284     INT32 m_Contrast;
00285     double m_Tilt;
00286 
00287     BOOL m_IsABlendStepBevel;
00288 
00289     // points determining the fill control points
00290     DocCoord m_BMPCentre;
00291     DocCoord m_BMPPoint1;
00292     DocCoord m_BMPPoint2;
00293 
00294     // the rect of the (original) selection
00295     DocRect m_SelectedRect;
00296     JointType m_JointType;
00297 
00298 protected:
00299 
00300     KernelBitmap* CreateCombinedBMPAndTranspFill(RenderRegion* pRegion = NULL);
00301 
00302     // calculates the bitmap size out of m_Path etc
00303     void CalculateBitmapSize(INT32 * retnWid, INT32 * retnHei, RenderRegion * pRegion=NULL);
00304 
00305     // renders all the original nodes again
00306     void RenderNodesForPrinting(RenderRegion * pRender);
00307     
00308     // renders all the child nodes of the given node, and then renders the node
00309     void RenderNodeRecursively(Node * pNode, RenderRegion * pRender);
00310 
00311     // sets up the bitmap palette depending on contrast
00312     void SetUpBitmapPalette(RenderRegion* pRegion = NULL, DocColour FlatColour = COLOUR_BLACK);
00313     
00314     // final stage of bevel generation - creation of the bitmap
00315     // this is public so external processes can use it
00316     // e.g. contrast changes and light angle changes don't require
00317     // regeneration of the paths, just the bitmap
00318     BOOL CreateBevelBitmap();
00319 
00320     // re-renders the bitmap to the correct resolution for the zoom (dynamic)
00321     BOOL RenderBitmapForDisplay(RenderRegion * pRegion);
00322 
00323     // Reverses the bevel path and adds it to the original to create the new bevel path
00324     // Also shrinks/Expands the inner/outer path edge by a pixel to get rid of antialiasing
00325     // effects when overlapping the object
00326     BOOL ReverseAndShrinkBevelPathIntoInkPath(Path* pBevelPath = NULL, double ZoomValue = 1.0, BOOL IsAnOuter = TRUE);
00327 
00328 protected:
00329     // the bevel path
00330     Path  m_Path;
00331     BOOL m_DoRender;
00332 
00333     KernelBitmap * m_pBevelBitmap;
00334     KernelBitmap * m_pCombiBitmap;
00335 
00336     BitmapFillAttribute* m_pBMPFill;
00337     BitmapTranspFillAttribute* m_pTranspFill;
00338 
00339     INT32 m_BitmapWidth;
00340     INT32 m_BitmapHeight;
00341 
00342     DocCoord m_SubPixelOffset;
00343     DocRect m_PixelAllignedRect;
00344     BOOL m_IsFlatFilledOnly;
00345     BOOL m_IsAnAlphaBMP;
00346     BOOL m_HasTransparencyApplied;
00347     BOOL m_AmConvertingToShapes;
00348 
00349     double m_LastCachedPrintBMPDPI;
00350     double m_LastExportedDPI;
00351 
00352     // lock on rendering
00353     BOOL m_bStopRender;
00354     BOOL m_DoingRotation;
00355 
00356     // this is the bevel path generated by the path processor for outer bevels (without
00357     // the hole in it)
00358     Path m_OuterBevelPath;
00359 
00360     // the pixel sizes used to create the bevel bitmap
00361     UINT32 m_ViewScale;
00362 
00363     // the shrunk path used in rendering
00364     Path m_ShrunkPath;
00365     BOOL m_bLock;
00366     BOOL m_bRenderBitmaps;
00367 
00368     // indicates we should zero the line width of the path, or not (as the case might be)
00369     BOOL m_bZeroLineWidth;
00370 
00371     CBeveler * m_pBeveler;
00372 
00373     // whether the original path is closed or not
00374     // if not, don't do any path shrinking
00375     BOOL m_bPathIsClosed;
00376 
00377     // flag to indicate that when this node is inside of a blend there's
00378     // no need to regenerate it - it's already been cached
00379     BOOL m_bCached;
00380 
00381     // Reverses the bevel path and adds it to the original to create the new bevel path
00382     // Also shrinks/Expands the inner/outer path edge by a pixel to get rid of antialiasing
00383     // effects when overlapping the object
00384     double m_LastZoomFactor;
00385 
00386     // the last pixel size for the bitmap
00387     UINT32 m_LastPixelSize;
00388 } ;
00389 
00390 /***********************************************************************************************
00391 
00392 >   class BevelRecordHandler: public CamelotRecordHandler
00393 
00394     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00395     Created:    27/10/98
00396     Purpose:    Handles the reading of all bevel attribute records in the v2 file format
00397     SeeAlso:    -
00398 
00399 ***********************************************************************************************/
00400 
00401 class BevelRecordHandler : public CamelotRecordHandler
00402 {
00403     // Give my name out in memory dumps
00404     CC_DECLARE_DYNCREATE( BevelRecordHandler );
00405 
00406 public:
00407     // functions that must be implemented.
00408     BevelRecordHandler();
00409     ~BevelRecordHandler();
00410 
00411     virtual UINT32* GetTagList();
00412     virtual BOOL    HandleRecord(CXaraFileRecord* pCXaraFileRecord);
00413 
00414 private:
00415     NodeBevelController * m_pBevelController;
00416     NodeBevel           * m_pBevelInk;
00417 } ;
00418 
00419 /***********************************************************************************************
00420 
00421 >   class NodeBevelBegin : public NodeRenderableBounded
00422 
00423     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00424     Created:    27/10/98
00425     Purpose:    Denotes the beginning of a bevel
00426     SeeAlso:    -
00427 
00428 ***********************************************************************************************/
00429 
00430 class NodeBevelBegin : public NodeRenderableBounded
00431 {
00432     // Give my name out in memory dumps
00433     CC_DECLARE_DYNCREATE(NodeBevelBegin)
00434 
00435 public:
00436     // functions that must be implemented.
00437     NodeBevelBegin();
00438     NodeBevelBegin(Node* ContextNode,  
00439          AttachNodeDirection Direction, 
00440          BOOL Locked=FALSE, 
00441          BOOL Mangled=FALSE,  
00442          BOOL Marked=FALSE, 
00443          BOOL Selected=FALSE
00444          );
00445 
00446     void Render(RenderRegion * region);
00447 
00448     DocRect GetBoundingRect(BOOL DontUseAttrs, BOOL HitTest);
00449     DocRect GetBlobBoundingRect();
00450 
00451     // the bounding rect of me - set at creation !
00452     DocRect m_Rect;
00453 
00454     virtual void RenderEorDrag( RenderRegion* rr ) { };
00455     virtual void RenderObjectBlobs(RenderRegion* pRender) { };
00456     virtual void RenderTinyBlobs(RenderRegion* pRender) { } ;
00457     virtual BOOL ExportRender ( RenderRegion *pRegion );
00458 
00459     virtual BOOL NeedsParent(Node* pNode) const;
00460 
00461     // can never be selected
00462     void SetSelected(BOOL Status);
00463 
00464     // don't need to render if there's a bevel path processor already on the stack
00465     virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00466 
00467 protected:
00468     // copy this node
00469     virtual Node* SimpleCopy(); 
00470 
00471     // the clip rect of the render region passed to Render() before
00472     // it was altered to include all children
00473     DocRect m_RegionClipRect;
00474 } ;
00475 
00476 
00477 //#endif
00478 #endif

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