nodecont.h

Go to the documentation of this file.
00001 // $Id: nodecont.h 751 2006-03-31 15:43: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 // NodeShadowController class
00099 
00100 #ifndef INC_NODESHADOWCONTROLLER
00101 #define INC_NODESHADOWCONTROLLER
00102 
00103 #ifdef BUILDSHADOWS
00104 
00105 // Define this variable to upgrade from X1-style shadow rendering
00106 // to X2-Capture-based rendering
00107 // Declare smart memory handling in Debug builds
00108 //#define NEW_SHADOW_RENDER
00109 
00110 // the bitmap shadow's type
00111 enum ShadowType
00112 {
00113     SHADOWTYPE_NONE = 0,
00114     SHADOWTYPE_WALL,
00115     SHADOWTYPE_FLOOR,
00116     SHADOWTYPE_GLOW,
00117     SHADOWTYPE_FEATHER
00118 } ;
00119 
00120 // The shadow field mask for our special version of CompareState
00121 typedef enum
00122 {
00123     smOFFSETX       = 0x0001,
00124     smOFFSETY       = 0x0002,
00125     smPENUMBRA      = 0x0004,
00126     smNAME          = 0x0008,
00127     smTYPE          = 0x0010,
00128     smFLOORANGLE    = 0x0020,
00129     smFLOORHEIGHT   = 0x0040,
00130     smSCALE         = 0x0080,
00131     smGLOWWIDTH     = 0x0100,
00132     smFEATHERWIDTH  = 0x0200,
00133     smBIASGAIN      = 0x0400,
00134     smDARKNESS      = 0x0800
00135 } ShadowMaskBits;
00136 
00137 const UINT32 SHADOWMASK_ALL = 0xFFF;
00138 
00139 typedef struct tagShadowFieldMask
00140 {
00141     tagShadowFieldMask()
00142     {
00143         OffsetX         = FALSE;
00144         OffsetY         = FALSE;
00145         Penumbra        = FALSE;
00146         Name            = FALSE;
00147         Type            = FALSE;
00148         FloorAngle      = FALSE;
00149         FloorHeight     = FALSE;
00150         Scale           = FALSE;
00151         GlowWidth       = FALSE;
00152         FeatherWidth    = FALSE;
00153         BiasGain        = FALSE;
00154         Darkness        = FALSE;
00155     }
00156 
00157     tagShadowFieldMask(UINT32 flagbits)
00158     {
00159         OffsetX         = ((flagbits & smOFFSETX) == smOFFSETX);
00160         OffsetY         = ((flagbits & smOFFSETY) == smOFFSETY);
00161         Penumbra        = ((flagbits & smPENUMBRA) == smPENUMBRA);
00162         Name            = ((flagbits & smNAME) == smNAME);
00163         Type            = ((flagbits & smTYPE) == smTYPE);
00164         FloorAngle      = ((flagbits & smFLOORANGLE) == smFLOORANGLE);
00165         FloorHeight     = ((flagbits & smFLOORHEIGHT) == smFLOORHEIGHT);
00166         Scale           = ((flagbits & smSCALE) == smSCALE);
00167         GlowWidth       = ((flagbits & smGLOWWIDTH) == smGLOWWIDTH);
00168         FeatherWidth    = ((flagbits & smFEATHERWIDTH) == smFEATHERWIDTH);
00169         BiasGain        = ((flagbits & smBIASGAIN) == smBIASGAIN);
00170         Darkness        = ((flagbits & smDARKNESS) == smDARKNESS);
00171     }
00172 
00173     BOOL OffsetX        : 1;
00174     BOOL OffsetY        : 1;
00175     BOOL Penumbra       : 1;
00176     BOOL Name           : 1;
00177     BOOL Type           : 1;
00178     BOOL FloorAngle     : 1;
00179     BOOL FloorHeight    : 1;
00180     BOOL Scale          : 1;
00181     BOOL GlowWidth      : 1;
00182     BOOL FeatherWidth   : 1;
00183     BOOL BiasGain       : 1;
00184     BOOL Darkness       : 1;
00185 } ShadowFieldMask;
00186 
00187 // constants for the maximum floor-shadow height and angle.
00188 #define MAXSHADOWHEIGHT 1.5
00189 #define MAXSHADOWANGLE (69 * (PI / 180.0))
00190 
00191 //#include "control.h"
00192 #include "pathpcs.h"
00193 #include "nodepostpro.h"
00194 
00195 class RenderRegion;
00196 class String_32;
00197 class NodeRect; 
00198 class CCAttrMap;
00199 
00200 class NodeShadow;
00201 
00202 class ExtendParams;
00203 
00204 class AttrFillGeometry;
00205 
00206 /********************************************************************************************
00207 
00208 >   class NodeShadowController : public NodeEffect
00209 
00210     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com> 
00211     Created:    20/11/96
00212     Purpose:    
00213 
00214 ********************************************************************************************/
00215 class NodeShadowController : public NodeEffect
00216 {
00217     CC_DECLARE_DYNAMIC( NodeShadowController )    
00218 public: 
00219     
00220     NodeShadowController(); 
00221     ~NodeShadowController();
00222     
00223     NodeShadowController(Node* ContextNode,  
00224               AttachNodeDirection Direction,    
00225               BOOL Locked=FALSE, 
00226               BOOL Mangled=FALSE,  
00227               BOOL Marked=FALSE, 
00228               BOOL Selected=FALSE    
00229              ); 
00230     
00231     // Copy functions
00232     virtual Node* SimpleCopy(); 
00233     void CopyNodeContents(NodeShadowController* pNewNode);
00234     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00235 
00236     // virtual Functions to deal with bounding boxes
00237     virtual DocRect GetBlobBoundingRect();
00238     virtual void Transform(TransformBase&);
00239 
00240     // Virtual rendering functions       
00241     virtual void PreExportRender( RenderRegion* pRender ); 
00242     virtual BOOL ExportRender( RenderRegion* pRender ); 
00243     virtual void RenderEorDrag( RenderRegion* );
00244     virtual BOOL ChildrenAreEorDragRenderedByMe() { return TRUE; }
00245 
00246     // Gets the bounding rect to be used when eor dragging
00247     DocRect GetEorDragBoundingRect() { return GetInsideBoundingRect(); }
00248     // virtual void RenderObjectBlobs(RenderRegion* pRender);
00249     virtual void RenderTinyBlobs(RenderRegion* pRender);
00250 
00251     // Other virtual functions
00252     virtual String Describe(BOOL Plural, BOOL Verbose); 
00253     virtual UINT32 GetNodeSize() const;             // Returns size of node in bytes
00254 
00255     // Fuctions that allows ops and other nodes to inform this node of events on it's children
00256     virtual ChangeCode OnChildChange(ObjChangeParam* pParam);
00257     virtual BOOL AllowOp(ObjChangeParam *pParam, BOOL SetOpPermissionState = TRUE,
00258                                                  BOOL DoPreTriggerEdit = TRUE);
00259 
00260     // Functions for converting nodes into other types
00261     virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00262     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00263 
00264     BOOL ApplyShadowTransform(Path* pTargetPath);
00265 
00266     // Functions to deal with messages
00267     virtual BOOL OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00268  
00269     // Version 2 file format functions
00270     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00271     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00272 
00273     NodeShadow* GetShadow() const;
00274     NodeRenderableInk* GetShadowedNode() const;
00275 
00276     // alternative virtual fn. to get shadowed node
00277     virtual NodeRenderableInk* GetInkNodeFromController() const;
00278 
00279 // Access functions for member variables
00280     MILLIPOINT GetPenumbraWidth() const {return m_PenumbraWidth;}
00281     void SetPenumbraWidth(MILLIPOINT NewWidth)  { if (NewWidth > 0) m_PenumbraWidth = NewWidth;
00282                                                   else m_PenumbraWidth = 0; }
00283 
00284     MILLIPOINT GetOffsetX() const { return m_OffsetX; }
00285     MILLIPOINT GetOffsetY() const { return m_OffsetY; }
00286     void SetOffsetX(MILLIPOINT xx) { m_OffsetX = xx; }
00287     void SetOffsetY(MILLIPOINT yy) { m_OffsetY = yy; }
00288 
00289     // The same idea at present, so return the same value
00290     // ShadowType   GetRenderMethod()   { return m_ShadowType; } 
00291     
00292     void SetShadowType(ShadowType NewType)      { m_ShadowType = NewType; }
00293     ShadowType GetShadowType() { return m_ShadowType; }
00294 
00295     String_256 GetShadowName() { return m_sShadowName; }
00296     void SetNewShadowName(String_256 sNewName) { m_sShadowName = sNewName; }
00297 
00298     BOOL HasShadowSelectionChanged() { return m_ShadowSelectionChanged; }
00299     void ResetShadowSelectionChange() { m_ShadowSelectionChanged = FALSE; }
00300 
00301     virtual BOOL PostImport();          // function called after import
00302     BOOL PostDuplicate(UndoableOperation* pOp);     // function called after node has been copied.
00303 
00304     BOOL RegenerateNode(UndoableOperation * pOp, BOOL bCacheRender = FALSE,
00305         BOOL bInformParents = TRUE);
00306 
00307     // hit testing on children isn't promoted
00308     virtual BOOL                PromoteHitTestOnChildrenToMe() const { return FALSE; }
00309     virtual BOOL                ShouldITransformWithChildren() const { return TRUE; }
00310     virtual BOOL                CanSelectAsCompoundParent() {return FALSE;}
00311     virtual BOOL                NeedsTransparency() const {return TRUE;}
00312     virtual BOOL                IsController() { return TRUE;}
00313     virtual BOOL                IsAShadowController() const { return TRUE;}
00314     virtual BOOL                AllowSelectInside() const {return TRUE;}
00315     virtual BOOL                IsPassThroughEffect() const {return TRUE;}  // User can see original object through this effect
00316 
00317     // Karim 14/04/2000 - helper method for marquee selection.
00318     virtual void SelectInRect(const DocRect& Rect, SelStateAction st);
00319 
00320     virtual BOOL                CompareState(NodeEffect* pPPNode);
00321     virtual BOOL                CompareState(NodeEffect* pPPNode, ShadowFieldMask mask);
00322     virtual DocRect             GetChildBoundingRect(BOOL bIncludeAttrs = TRUE);
00323     virtual void                InvalidateBoundingRect(BOOL InvalidateChildBounds = FALSE);
00324 
00325 #ifdef NEW_SHADOW_RENDER
00326 public:
00327     virtual SubtreeRenderState  RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00328     virtual void                RenderAfterSubtree(RenderRegion* pRender);
00329 //  virtual void                Render(RenderRegion* pRender);
00330     virtual BOOL                ReleaseCached(BOOL bAndParents = TRUE,
00331                                               BOOL bAndChildren = TRUE,
00332                                               BOOL bSelf = TRUE,
00333                                               BOOL bAndDerived = TRUE);
00334     virtual BOOL                IsCapturingChildren();
00335     virtual void                ReleaseStackedShadows();
00336     virtual double              GetPixelsPerInch();
00337     virtual double              GetPixelWidth();
00338     NodeShadowController*       FindBottomShadowController();
00339 
00340 protected:
00341     virtual BOOL                FindCachedEffect(CBitmapCache* pBitmapCache);
00342     virtual BOOL                RenderCachedEffect(CBitmapCache* pBitmapCache, RenderRegion* pRenderRegion);
00343 
00344 private:
00345     BOOL                        IsTopShadowController();
00346     NodeShadow*                 FindBottomShadow();
00347     NodeShadow*                 FindShadowAbove(NodeShadow* pCurrentShadow);
00348     BOOL                        IsInShadowStack();
00349 
00350 #endif
00351 
00352 
00353 public:
00354     // static ShadowType RenderMethod;
00355 
00356 //  #ifdef _DEBUG
00357     void ShowDebugTreeDetails() const;
00358     void GetDebugDetails( StringBase* Str );
00359 //  #endif
00360 
00361     // a couple of conversion functions for storing/retrieving the double value
00362     // of the floor-shadow angle in a INT32 without loss of too much precision.
00363     INT32       FloorAngleToINT32(double Angle);
00364     double      FloorAngleFromINT32(INT32 Angle);
00365 
00366     double      GetFloorShadowAngle()   { return m_FloorShadowAngle;    }
00367     float       GetFloorShadowHeight()  { return m_FloorShadowHeight;   }
00368     DocCoord    GetFloorShadowVector();
00369     void        SetFloorShadowAngle(double Angle)   { m_FloorShadowAngle = Angle;   }
00370     void        SetFloorShadowHeight(float Height)  { m_FloorShadowHeight = Height; }
00371     void        SetFloorShadowVector(const DocCoord& dcControlVector);
00372 
00373     DocCoord    GetWallShadowOffset();
00374     float       GetWallShadowScale()    { return m_Scale;   }
00375     void        SetWallShadowOffset(const DocCoord& dcOffset, BOOL UpdateNodeShadow);
00376     void        SetWallShadowScale(float NewScale)  { m_Scale = NewScale; }
00377 
00378     MILLIPOINT GetGlowWidth() { return m_GlowWidth; }
00379     void SetGlowWidth(MILLIPOINT NewWidth) { m_GlowWidth = NewWidth; }
00380 
00381     MILLIPOINT GetFeatherWidth() { return m_FeatherWidth; }
00382     void SetFeatherWidth(MILLIPOINT NewWidth) { m_FeatherWidth = NewWidth; }
00383 
00384     UINT32 GetShadowTransp();
00385 
00386     void ResetShadowSettings();
00387 
00388     INT32 ComplexHide(UndoableOperation* pOp, Node* pNextInRange);
00389 
00390 //  virtual BOOL IsValidEffectAttr(CCRuntimeClass* pAttrClass) const {return FALSE;}
00391     virtual BOOL IsValidEffectAttr(NodeAttribute* pAttr) const {return FALSE;}
00392     virtual NodeRenderableInk* GetObjectToApplyTo(CCRuntimeClass* AttrType);
00393 
00394     // Karim MacDonald 25/11/1999
00395     // virtual Extend functions; see declaration/implementation in Node.
00396 public:
00397     virtual BOOL IsTypeExtendible() const { return TRUE; }
00398     virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00399     virtual void Extend(const ExtendParams& ExtParams);
00400 
00401     // the blend stuff for shadows
00402     virtual BOOL EndBlendStep(BlendNodeParam* pParam);
00403     virtual NodeRenderableInk* CreateTreeFromNodeToBlend(NodeRenderableInk* pNode, CCAttrMap* pAttrMap);
00404 
00405 protected:
00406     // blends the parameters, given the start & end nodes
00407     BOOL BlendParameters (NodeShadowController * pStart, NodeShadowController * pEnd, BlendNodeParam * pParam, CCAttrMap* pMap);
00408     // blends the parameters, given the start node (NOTE:  where possible assumes sensible values)
00409     BOOL BlendParameters(NodeShadowController * pStart, BlendNodeParam * pParam);
00410 
00411 // Member variables
00412 protected:
00413     MILLIPOINT  m_OffsetX;
00414     MILLIPOINT  m_OffsetY;
00415     MILLIPOINT  m_PenumbraWidth;
00416     
00417     BOOL        m_ShadowSelectionChanged;
00418 
00419     String_256  m_sShadowName;
00420     ShadowType  m_ShadowType;
00421 
00422     DocRect     m_PreviousRect;
00423 
00424     double      m_FloorShadowAngle;
00425     
00426     // this is relative to the size of the original object
00427     // (i.e. 1.0 = full height of the original image)
00428     float   m_FloorShadowHeight;
00429     float   m_Scale;                        // the scale of the wall shadow
00430     MILLIPOINT m_GlowWidth;                 // the width of the glow
00431     MILLIPOINT m_FeatherWidth;              // The width of the feather
00432 
00433     BOOL m_PerformedExtend;
00434 
00436     // stuff to do with the rendering of eor dragged outlines for glows
00437     Path m_GlowDragPath;
00438 
00439 
00440 public:
00441     // the default settings which should be used when creating a shadow with no extra info.
00442 
00443     static const ShadowType DefaultType;
00444     static const MILLIPOINT DefaultWallOffsetX;
00445     static const MILLIPOINT DefaultWallOffsetY;
00446     static const MILLIPOINT DefaultGlowWidth;
00447     static const MILLIPOINT DefaultFeatherWidth;
00448     static const double     DefaultFloorAngle;
00449     static const float      DefaultFloorHeight;
00450     static const MILLIPOINT DefaultBlurSize;
00451     static const double     DefaultDarkness;
00452     static const double     DefaultScale;
00453 
00454     static MILLIPOINT       DefaultPixelsPerInch;
00455 };
00456 
00457 /***********************************************************************************************
00458 
00459 >   class ShadowNodeTreeFactory : public CompoundNodeTreeFactory
00460 
00461     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00462     Created:    11/5/99
00463     Purpose:    Creates a new shadow node with the given parameters
00464 
00465 ***********************************************************************************************/
00466 class ShadowNodeTreeFactory : public CompoundNodeTreeFactory
00467 {
00468     CC_DECLARE_DYNCREATE(ShadowNodeTreeFactory);
00469 
00470 public:
00471     ShadowNodeTreeFactory();
00472     ~ShadowNodeTreeFactory();
00473 
00474     // given a list of NodeListItems, shadows them
00475     virtual NodeCompound * CreateNode(List *pList, UndoableOperation * pOp = NULL);
00476 
00477     // access functions
00478     MILLIPOINT GetPenumbraWidth() const {return m_PenumbraWidth;}
00479     // CGS:  the penumbra should NEVER be able to go negative!
00480     void SetPenumbraWidth(MILLIPOINT NewWidth)  { if (NewWidth > 0) m_PenumbraWidth = NewWidth;
00481                                                   else m_PenumbraWidth = 0; }
00482 
00483     MILLIPOINT GetOffsetX() const { return m_OffsetX; }
00484     MILLIPOINT GetOffsetY() const { return m_OffsetY; }
00485     void SetOffsetX(MILLIPOINT xx) { m_OffsetX = xx; }
00486     void SetOffsetY(MILLIPOINT yy) { m_OffsetY = yy; }
00487 
00488     void SetShadowType(ShadowType NewType)      { m_ShadowType = NewType; }
00489     ShadowType GetShadowType() { return m_ShadowType; }
00490 
00491     void SetFloorShadowAngle(double Angle) { m_FloorShadowAngle = Angle; }
00492     void SetFloorShadowHeight(float Height) { m_FloorShadowHeight = Height; }
00493     double GetFloorShadowAngle() { return m_FloorShadowAngle; }
00494     float GetFloorShadowHeight() { return m_FloorShadowHeight; }
00495 
00496     float GetWallShadowScale() { return m_Scale; }
00497     void  SetWallShadowScale(float NewScale) { m_Scale = NewScale; }
00498 
00499     MILLIPOINT GetGlowWidth() { return m_GlowWidth; }
00500     void SetGlowWidth(MILLIPOINT GlowWidth) { m_GlowWidth = GlowWidth; }
00501 
00502     MILLIPOINT GetFeatherWidth() { return m_FeatherWidth; }
00503     void SetFeatherWidth(MILLIPOINT FeatherWidth) { m_FeatherWidth = FeatherWidth; }
00504 
00505     // sets up the attribute map for the shadow node
00506     void SetUpAttributeList(Node * pShadow);
00507 
00508 private:
00509     ShadowType  m_ShadowType;
00510 
00511     MILLIPOINT  m_OffsetX;
00512     MILLIPOINT  m_OffsetY;
00513     MILLIPOINT  m_PenumbraWidth;
00514     double      m_FloorShadowAngle;
00515     float       m_FloorShadowHeight;
00516     float       m_Scale;
00517     MILLIPOINT  m_GlowWidth;
00518     MILLIPOINT  m_FeatherWidth;
00519 
00520     List m_AttributeList;
00521 } ;
00522 
00523 #endif  // BUILDSHADOWS
00524  
00525 #endif  // include

Generated on Sat Nov 10 03:46:02 2007 for Camelot by  doxygen 1.4.4