nodeshad.h

Go to the documentation of this file.
00001 // $Id: nodeshad.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 #ifndef INC_NODESHADOW
00099 #define INC_NODESHADOW
00100 
00101 #ifdef BUILDSHADOWS
00102 
00103 #include "nodecont.h"
00104 #include "nodebmp.h"
00105 
00106 //#include "combshps.h"
00107 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "biasgain.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "becomea.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "pathpcs.h"
00113 //#include "biasgain.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "gconsts.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 
00116 class NodeShadowController;
00117 class TrapsList;
00118 class CShadowerFlat;
00119 class CBitmapShadow;
00120 class ExtendParams;
00121 class NodeShadowPassback;
00122 
00123 class GRenderRegion;
00124 class GRenderRegionWrapper;
00125 class BitmapTranspFillAttribute;
00126 
00127 
00128 /***********************************************************************************************
00129 
00130 >   class NodeShadow : public NodeRenderableInk
00131 
00132     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00133     Created:    16/11/94
00134     Purpose:    
00135 
00136 ***********************************************************************************************/
00137 
00138 class NodeShadow : public NodeRenderableInk
00139 {
00140 // Give my name out in memory dumps
00141 CC_DECLARE_DYNCREATE(NodeShadow);
00142 
00143 public:
00144     NodeShadow(); 
00145     ~NodeShadow(); 
00146     
00147     NodeShadow(Node* ContextNode,  
00148                 AttachNodeDirection Direction,  
00149                 BOOL Locked = FALSE, 
00150                 BOOL Mangled = FALSE,  
00151                 BOOL Marked = FALSE, 
00152                 BOOL Selected = FALSE    
00153               );
00154 
00155     // Initialise the shape
00156     BOOL SetUpShape();
00157     virtual Node* SimpleCopy();
00158     void CopyNodeContents(NodeShadow* NodeCopy);
00159     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00160 
00161     virtual BOOL IsAShadow() const { return TRUE; } 
00162 
00163     // we don't want to have brush attrs applied to us.
00164     virtual BOOL CanAttrBeAppliedToMe(CCRuntimeClass* pAttribClass);
00165 
00166     // virtual Functions to deal with bounding boxes
00167     virtual DocRect GetBoundingRect(BOOL DontUseAttrs = FALSE, BOOL HitTest = FALSE);
00168     virtual DocRect GetBlobBoundingRect();
00169 
00170     // Rendering Functions
00171     virtual void Render( RenderRegion* pRender );
00172     virtual void RenderEorDrag( RenderRegion* );
00173 
00174     virtual void PreExportRender( RenderRegion* pRender ); 
00175     virtual BOOL ExportRender( RenderRegion* pRender ); 
00176 
00177     // Version 2 file format functions
00178     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00179     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00180     virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00181     virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00182 
00183     // Selection functions.
00184     virtual void RenderObjectBlobs(RenderRegion* pRender);
00185     virtual void RenderTinyBlobs(RenderRegion* pRender);
00186 
00187     // Functions to transform the shape
00188     virtual void Transform( TransformBase& );
00189 
00190     // Information functions
00191     virtual UINT32 GetNodeSize() const;             // Returns size of node in bytes
00192     virtual String Describe(BOOL Plural, BOOL Verbose);
00193     virtual BOOL NeedsTransparency() const {return TRUE;}
00194  
00195     // Make Shapes functions
00196     virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00197     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00198 
00199     // Debugging function
00200     void ShowDebugTreeDetails() const;
00201     void GetDebugDetails( StringBase* Str );
00202 
00203     // Functions to deal with messages
00204     virtual BOOL OnClick( DocCoord, ClickType, ClickModifiers, Spread*);
00205     virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00206 
00207     // The natty Snap functions
00208     virtual BOOL Snap(DocCoord* pDocCoord);
00209     virtual BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00210     virtual BOOL SnapToCoords(DocCoord* pDocCoord);
00211 
00212     void DeleteCurrentShadowStuff();
00213     void DeleteCache();
00214     void DeleteAndRefreshCache();
00215     virtual NodeCompound* GetParentController() const;
00216 
00217     virtual BOOL PostImport();
00218     BOOL PostDuplicate(UndoableOperation* pOp);     // function called after node has been copied.
00219 
00220     virtual BOOL NeedsParent(Node* pNode) const;
00221 
00222     virtual BOOL AllowOp(ObjChangeParam *pParam, BOOL SetOpPermissionState = TRUE,
00223                                                  BOOL DoPreTriggerEdit = TRUE);
00224 
00225     virtual BOOL MarqueeSelectNode() const { return FALSE; }
00226 
00227     virtual BOOL ReleaseCached( BOOL bAndParents = TRUE,
00228                                 BOOL bAndChildren = TRUE,
00229                                 BOOL bSelf = TRUE,
00230                                 BOOL bAndDerived = TRUE);
00231 
00232 protected:
00233     void InitialiseMemberVars();
00234     virtual void RenderBitmap(RenderRegion* pRender);
00235 
00236 public:
00237     BOOL GenerateShadow();
00238 
00239     BOOL GenerateShadowForBlends(List * pList, RenderRegion * pRegion);
00240 
00241     void UpdateAfterWallOffset();
00242 
00243     BOOL GenerateShadowBitmap(KernelBitmap* pSilhouetteBmp, const double pixBlurDiameter);
00244     BOOL GenerateSelectionBitmap(Range * pSelRng);
00245     void HaveChangedShadow() { m_bHaveTransformed = TRUE; }
00246     void SetBitmapShadowRendering(BOOL OnOrOff) { m_RenderBitmaps = OnOrOff; }
00247     BOOL AmDoingACopy() { return m_bAmCopying; }
00248     void SetAmCopying() { m_bAmCopying = TRUE; }
00249     void SetAmLoading() { m_bAmLoading = TRUE; }
00250 
00251     // Get shadow darkness, from 0.0 (transparent) to 1.0 (opaque).
00252     double  GetDarkness()               { return m_dDarkness; }
00253 
00254     void    SetDarkness(double Darkness);
00255 
00256     // Get shadow transparency, from 0 (opaque) to 255 (transparent).
00257     UINT32 GetTransp()          { return (UINT32)(0.5 + 255.0 * (1.0 - m_dDarkness)); }
00258 
00259     // Set shadow transparency, from 0 (opaque) to 255 (transparent).
00260     void SetTransp(UINT32 Transp)   { SetDarkness( (double)(255 - Transp) / 255.0 ); }
00261 
00262     void SetBiasGain(CProfileBiasGain &gain);
00263     CProfileBiasGain &GetBiasGain();
00264     CProfileBiasGain* GetBiasGainPtr();
00265 
00266     // Karim MacDonald 25/11/1999
00267     // virtual Extend functions; see declaration/implementation in Node.
00268 public:
00269     virtual BOOL IsTypeExtendible() const { return TRUE; }
00270     virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00271     virtual void Extend(const ExtendParams& ExtParams);
00272 
00273     virtual INT32 EstimateNodeComplexity (OpParam* details);
00274 
00275 #ifdef NEW_SHADOW_RENDER
00276 public:
00277     BOOL    MakeShadow(LPBITMAPINFO lpInfo, LPBYTE lpBits, DocRect orect);
00278     BOOL    RenderShadow(RenderRegion* pRender);
00279     BOOL    NeedsRemake();
00280     BOOL    TransformShadow(TransformBase& Trans);
00281 
00282 #endif
00283 
00284 protected:
00285     KernelBitmap*               m_ShadowBitmap;
00286     BitmapTranspFillAttribute*  m_pBMPTransFill;
00287     Path                        m_Path;
00288     Path                        m_NonTranslatedPath;
00289     
00290     INT32   m_ShadowWidth;
00291     INT32   m_ShadowHeight;
00292 
00293     BOOL    m_bHaveTransformed;
00294     BOOL    m_RenderBitmaps;
00295     BOOL    m_bAmCopying;
00296     BOOL    m_bAmLoading;
00297     double  m_dDarkness;
00298 
00299     DocRect m_SelectedRect;
00300     INT32       m_PreviousBlur;
00301     
00302     BOOL SetupTransFill();
00303 
00304     // turns the 24 - bit kernel bitmap into an 8 bit greyscale
00305     BOOL Create8BitBitmap(KernelBitmap * pSrcBitmap, KernelBitmap ** ppDestBitmap);
00306 
00307     void CreateBitmapPath(const DocRect& drInkForShadowing, double PixelWidth, const double pixBlurDiameter);
00308 
00309     // DMc the bitmap shadower (not the COM shadower flat)
00310     CBitmapShadow * m_pShadower;
00311 
00312     // the bitmap offset for floor shadows
00313     INT32 m_BitmapXOffset;
00314 
00315     CProfileBiasGain m_BiasGain;
00316 
00317     NodePath * CreateShadowPassbackNode();
00318 
00319     BOOL RenderBitmapForDisplay(RenderRegion* pRegion, List* pList = NULL);
00320     BOOL RenderBitmapForDisplay();
00321 
00322     BOOL ApplyProfileToShadowBitmap();
00323 
00324     // shadow cache state information.
00325     // a note of the pixel width which was requested the last time we generated a shadow.
00326     MILLIPOINT m_LastRequestedPixWidth;
00327 
00328     // shadow cache state information.
00329     // a note of the quality setting at which our last shadow was generated.
00330     enum Quality::Fill m_LastQualitySetting;
00331 
00332     // we need to store the actual width (in millipoints) of a pixel
00333     // from our shadow bitmap. this takes into account any scaling
00334     // of the bitmap if there is not enough memory to do a full scale shadow.
00335     double m_LastActualPixWidth;
00336 };
00337 
00338 
00339 
00340 /********************************************************************************************
00341 
00342 >   class BitmapShadower
00343 
00344     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00345     Created:    26/10/2000
00346 
00347     Purpose:    Encapsulates the shadow silhouette bitmap creation process.
00348 
00349     See also:   NodeShadow::RenderBitmapForDisplay(), NodeShadow::GenerateShadowBitmap().
00350 
00351 ********************************************************************************************/
00352 class BitmapShadower
00353 {
00354 public:
00355     static BitmapShadower* CreateSilhouetteBitmap(  NodeShadowController* pControl,
00356                                                     GRenderRegion* pGRR = NULL,
00357                                                     List* pList = NULL );
00358 
00359     // get a ptr to the shadow bitmap.
00360     // the caller of this function takes responsibility for deleting the returned KernelBitmap.
00361     KernelBitmap* GetSilhouetteBitmap()
00362     {
00363         KernelBitmap* pBmp = m_pSilhouetteBitmap;
00364         m_pSilhouetteBitmap = NULL;
00365         return pBmp;
00366     }
00367 
00368     // get the blur diameter (in pixels) for the shadow bitmap.
00369     double          GetPixBlurDiameter()    const { return m_pixBlurDiameter; }
00370 
00371     // get actual pixel width at which the shadow bitmap should be rendered, to come out the right size.
00372     double          GetActualPixelWidth()   const { return m_ActualPixelWidth; }
00373 
00374     // get the onscreen bounds of the shadow bitmap.
00375     DocRect         GetBitmapBounds()       const { return m_drShadowedBounds; }
00376 
00377     ~BitmapShadower();
00378 
00379 private:
00380     BitmapShadower();
00381 
00382     BOOL Initialise(NodeShadowController* pControl, GRenderRegion* pGRR, List* pList);
00383     BOOL DoCreateSilhouetteBitmap();
00384 
00385     BOOL CalculateBoundsAndScale1();
00386     BOOL CalculateBoundsAndScale2WithGRR();
00387     BOOL CalculateBoundsAndScale2NoGRR();
00388     BOOL CreateOffscreenRR();
00389     BOOL RenderShadowedNodeOffscreen();
00390 
00391     GRenderRegion*          m_pGRR;
00392 
00393     NodeShadowController*   m_pControl;
00394     NodeShadow*             m_pShadow;
00395     NodeRenderableInk*      m_pShadowedNode;
00396     List*                   m_pShadowedList;
00397     enum ShadowType         m_ShadowType;
00398 
00399     DocRect                 m_drShadowedBounds;
00400     double                  m_ShadowScaleFactor;
00401     double                  m_ActualPixelWidth;
00402     double                  m_pixBlurDiameter;
00403 
00404     GRenderRegionWrapper*   m_pRendWrap;
00405     GRenderRegion*          m_pOffscreenRR;
00406 
00407     KernelBitmap*           m_pSilhouetteBitmap;
00408 };
00409 
00410 
00411 
00412 /***********************************************************************************************
00413 
00414 >   class NodeShadowBecomeA : public BecomeA
00415 
00416     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00417     Created:    11/12/199
00418     Purpose:    Does the become A for generating all the path so that the NodeShadowPassback
00419                 will work
00420 
00421 ***********************************************************************************************/
00422 class NodeShadowBecomeA : public BecomeA
00423 {
00424 public:
00425     NodeShadowBecomeA(  BecomeAReason Reason,
00426                     CCRuntimeClass* pClass, 
00427                     UndoableOperation* pOp, 
00428                     BOOL Sel,
00429                     Path * pSummedPath) : BecomeA( Reason, pClass, pOp, Sel)
00430     {
00431         m_pPath = pSummedPath;
00432     }
00433 
00434     virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap);
00435 private:
00436     Path * m_pPath;
00437 };
00438 
00439 
00440 
00441 #endif  // BUILDSHADOWS
00442 
00443 #endif  // NODESHADOW

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