combshps.h

Go to the documentation of this file.
00001 // $Id: combshps.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 // Header for the shape combining operations
00099 
00100 #ifndef INC_COMBSHPS
00101 #define INC_COMBSHPS
00102 
00103 //#include "selop.h"
00104 //#include "becomea.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "nodepath.h"
00107 #include "effects_stack.h"
00108 
00109 class UndoableOperaton;
00110 class NodeRenderableInk;
00111 class CCAttrMap;
00112 
00113 #define OPTOKEN_COMBINESHAPES   _T("CombineShapes")
00114 
00115 #define OPTOKEN_ADDSHAPES       _T("AddShapes")
00116 #define OPTOKEN_SUBTRACTSHAPES  _T("SubtractShapes")
00117 #define OPTOKEN_INTERSECTSHAPES _T("IntersectShapes")
00118 #define OPTOKEN_SLICESHAPES     _T("SliceShapes")
00119 
00120 enum CombineReason {    COMBINE_NONE, 
00121                         COMBINE_ADD, 
00122                         COMBINE_SUBTRACT, 
00123                         COMBINE_INTERSECT, 
00124                         COMBINE_SLICE 
00125                     };
00126 
00127 enum ClipStyle      {   CLIP_STYLE_ADD, 
00128                         CLIP_STYLE_SUBTRACT, 
00129                         CLIP_STYLE_INTERSECT
00130                     };
00131 
00132 /********************************************************************************************
00133 
00134 >   class SelObjPathListItem : public ListItem
00135 
00136     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00137     Created:    12/1/95
00138     Purpose:    This class encapsulates all the data needed for each path generated by the objects
00139                 that are being combined.
00140                 A list of all the paths that each of the selected object generates is made, and
00141                 each path generated creates an instance of this class
00142 
00143 ********************************************************************************************/
00144 
00145 class SelObjPathListItem : public ListItem
00146 {
00147     CC_DECLARE_DYNCREATE(SelObjPathListItem)
00148 
00149 public:
00150     SelObjPathListItem() : pNodePath(NULL), pCreatedByNode(NULL), pAttrMap(NULL), strokeCreatedPassbackPath(FALSE) {}   // For CC_IMPLEMENT_...
00151 
00152     SelObjPathListItem(NodePath* pThisNodePath,NodeRenderableInk* pThisCreatedByNode,CCAttrMap* pThisAttrMap, BOOL createdByStroke = FALSE);
00153     ~SelObjPathListItem();
00154     
00155     Path*               GetPath();
00156     NodePath*           GetNodePath()       { return pNodePath; }
00157     NodeRenderableInk*  GetCreatedByNode()  { return pCreatedByNode; }
00158     CCAttrMap*          GetAttrMap()        { return pAttrMap; }
00159 
00160     ListRange*          GetEffectStack()
00161     {
00162         if (pEffectStack==NULL && pCreatedByNode->FindParent()!=NULL)
00163             pEffectStack = EffectsStack::GetEffectsStackFromNode(pCreatedByNode);
00164         if (pEffectStack==NULL && pNodePath->FindParent()!=NULL)
00165             pEffectStack = EffectsStack::GetEffectsStackFromNode(pNodePath);
00166         return pEffectStack;
00167     }
00168 
00169     BOOL GetStrokeCreatedPassbackPath ()    { return (strokeCreatedPassbackPath); }
00170 
00171 private:
00172     NodePath*           pNodePath;
00173     NodeRenderableInk*  pCreatedByNode;
00174     CCAttrMap*          pAttrMap;
00175     ListRange*          pEffectStack;
00176 
00177     BOOL strokeCreatedPassbackPath;     // was this item created by a stroke being passed back?
00178 };
00179 
00180 
00181 /********************************************************************************************
00182 
00183 >   class SelObjPathList : public ListItem
00184 
00185     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00186     Created:    12/1/95
00187     Purpose:    This class encapsulates all the data needed for each selected object.
00188 
00189                 One instance of this class is generated for each selected object.
00190 
00191 ********************************************************************************************/
00192 
00193 class SelObjPathList : public ListItem
00194 {
00195     CC_DECLARE_DYNCREATE(SelObjPathList)
00196 
00197 public:
00198     SelObjPathList() : pSelNode(NULL) { ProducedPaths = FALSE; }
00199     SelObjPathList(Node* pThisSelNode) : pSelNode(pThisSelNode) { ProducedPaths = FALSE; }
00200 
00201     // Destroy the list on destruction
00202     ~SelObjPathList() { ListOfSelObjPaths.DeleteAll(); }
00203 
00204     Node* GetSelNode()          { return pSelNode; }
00205     INT32  GetCount()           { return ListOfSelObjPaths.GetCount(); }
00206     BOOL  HasProducedPaths()    { return ProducedPaths; }
00207     
00208     void SetProducedPaths(BOOL state) { ProducedPaths = state; }
00209 
00210     SelObjPathListItem* GetFirstItem()                          { return (SelObjPathListItem*) ListOfSelObjPaths.GetHead(); }
00211     SelObjPathListItem* GetLastItem()                           { return (SelObjPathListItem*) ListOfSelObjPaths.GetTail(); }
00212     SelObjPathListItem* GetNextItem(SelObjPathListItem* pItem)  { return (SelObjPathListItem*) ListOfSelObjPaths.GetNext(pItem); }
00213     void                AddTailItem(SelObjPathListItem* pItem)  { ListOfSelObjPaths.AddTail(pItem); }
00214 
00215 private:
00216     Node*   pSelNode;           // ptr to the selected object
00217     List    ListOfSelObjPaths;  // List of paths generated by the object
00218     BOOL    ProducedPaths;      // TRUE if any of the paths in the above list produced one or more new paths
00219 };
00220 
00221 
00222 /********************************************************************************************
00223 
00224 >   class OpCombineShapes : public SelOperation
00225 
00226     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00227     Created:    11/1/95
00228     Purpose:    Base class op that does all the shape combining ops, like add, subtract and intersect,etc
00229 
00230 ********************************************************************************************/
00231 
00232 class OpCombineShapes : public SelOperation
00233 {
00234     CC_DECLARE_DYNCREATE( OpCombineShapes )   
00235 
00236 public:
00237     OpCombineShapes();
00238     ~OpCombineShapes();
00239 
00240     static BOOL     Init();             
00241     static OpState  GetState(String_256*, OpDescriptor*);
00242 
00243     virtual void Do(OpDescriptor*);
00244     virtual void GetOpName(String_256*);
00245 
00246 protected:
00247     CombineReason   Reason;
00248 
00249 private:
00250     BOOL ConvertToShapes(Range* pRange, BOOL bCombineEffectBitmaps);
00251     BOOL CreateSelObjPathLists(BOOL bCombineEffectBitmaps);
00252     BOOL CreateSelObjPathList(Node* pNode,
00253                                 SelObjPathList* pSelObjPathList,
00254                                 BOOL IsFirstNode = TRUE,
00255                                 BOOL bCombineEffectBitmaps = TRUE,
00256                                 BecomeAReason reason = BECOMEA_PASSBACK);
00257 
00258     BOOL DoAddShapes();
00259     BOOL AddPathsFromList(Path* pPath,SelObjPathList* pSelObjPathList);
00260     BOOL AddPaths(Path* pPath1,Path* pPath2);
00261     BOOL AddOrMergePaths(Path* pPath1, Path* pPath2);
00262 
00263     BOOL DoCombineShapes(ClipStyle Style, BOOL bCombineEffectBitmaps);
00264     BOOL CombinePathsFromList(  ClipStyle Style,
00265                                 Path* pClipPath,
00266                                 Path* pStrokedClipPath,
00267                                 SelObjPathList* pSelObjPathList,
00268                                 BOOL bCombineEffectBitmaps = TRUE);
00269     BOOL CombinePaths(ClipStyle Style,Path* pClipPath,Path* pStrokedClipPath,Path* pSrcPath,Path* pDestPath);
00270 
00271     BOOL DoHideListedNodes(BOOL bCombineEffectBitmaps);
00272     BOOL DoSelectResultNodes(BOOL bCombineEffectBitmaps);
00273     BOOL ApplyAttributes(NodeRenderableInk* pSrcNode,NodeRenderableInk* pDestNode,CCAttrMap* pAttrMap, SelObjPathListItem* pListItem = NULL);
00274     BOOL ApplyEffects(SelObjPathListItem* pListItem, NodeRenderableInk* pDestNode, NodeRenderableInk* pParentEffect);
00275 
00276     BOOL    StrokePathToPath(Path* pPath,Path* pDest);
00277     BOOL    ConvertClipLineToShape(Path* pClipPath,Path* pSrcPath,Path* pDestPath);
00278     DocRect GetBoundingRect(Path* pPath);
00279 
00280     BOOL DoInsertNewNode(NodeRenderableBounded* pNewNode);
00281 
00282     UINT32 AdjustAttributesForStroke(CCAttrMap* pAttrMap, SelObjPathListItem* pListItem = NULL);
00283 //  void DeleteExtraStrokeAttributes(CCAttrMap* pAttrMap, SelObjPathListItem* pListItem = NULL);
00284 
00285     BOOL BeginSlowJob();
00286 
00287     SelObjPathList* GetFirstList()                      { return (SelObjPathList*) ListOfSelObjPathLists.GetHead(); }
00288     SelObjPathList* GetLastList()                       { return (SelObjPathList*) ListOfSelObjPathLists.GetTail(); }
00289     SelObjPathList* GetNextList(SelObjPathList* pItem)  { return (SelObjPathList*) ListOfSelObjPathLists.GetNext(pItem); }
00290 
00291     ListRange* CopyRange(Range* pRange);
00292 
00293     List        ListOfSelObjPathLists;
00294     ListRange*  pListOfResults;
00295     DocRect     OriginalBoundingRect;
00296     SelRange*   pSelRange;  // Set up at the start of Do()
00297     INT32       NumPaths;
00298     INT32       JobCount;
00299     INT32       NodeInsertCount;
00300 
00301     Node*               pContextNode;
00302     AttachNodeDirection AttachDir;
00303 };
00304 
00305 
00306 /********************************************************************************************
00307 
00308 >   class OpAddShapes : public OpCombineShapes
00309 
00310     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00311     Created:    11/1/95
00312     Purpose:    Op that invokes the Add Shapes operation performed by OpCombineShapes
00313 
00314 ********************************************************************************************/
00315 
00316 class OpAddShapes : public OpCombineShapes
00317 {
00318     CC_DECLARE_DYNCREATE( OpAddShapes )   
00319 
00320 public:
00321     OpAddShapes()   { Reason = COMBINE_ADD; }
00322 };
00323 
00324 /********************************************************************************************
00325 
00326 >   class OpSubtractShapes : public OpCombineShapes
00327 
00328     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00329     Created:    11/1/95
00330     Purpose:    Op that invokes the Add Shapes operation performed by OpCombineShapes
00331 
00332 ********************************************************************************************/
00333 
00334 class OpSubtractShapes : public OpCombineShapes
00335 {
00336     CC_DECLARE_DYNCREATE( OpSubtractShapes )   
00337 
00338 public:
00339     OpSubtractShapes()  { Reason = COMBINE_SUBTRACT; }
00340 };
00341 
00342 
00343 /********************************************************************************************
00344 
00345 >   class OpIntersectShapes : public OpCombineShapes
00346 
00347     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00348     Created:    11/1/95
00349     Purpose:    Op that invokes the Add Shapes operation performed by OpCombineShapes
00350 
00351 ********************************************************************************************/
00352 
00353 class OpIntersectShapes : public OpCombineShapes
00354 {
00355     CC_DECLARE_DYNCREATE( OpIntersectShapes )   
00356 
00357 public:
00358     OpIntersectShapes() { Reason = COMBINE_INTERSECT; }
00359 };
00360 
00361 
00362 /********************************************************************************************
00363 
00364 >   class OpSliceShapes : public OpCombineShapes
00365 
00366     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00367     Created:    11/1/95
00368     Purpose:    Op that invokes the Add Shapes operation performed by OpCombineShapes
00369 
00370 ********************************************************************************************/
00371 
00372 class OpSliceShapes : public OpCombineShapes
00373 {
00374     CC_DECLARE_DYNCREATE( OpSliceShapes )   
00375 
00376 public:
00377     OpSliceShapes() { Reason = COMBINE_SLICE; }
00378 };
00379 
00380 
00381 /***********************************************************************************************
00382 
00383 >   class CombineBecomeA: public BecomeA
00384 
00385     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00386     Created:    12/1/95
00387     Purpose:    This is the class that is passed to other nodes when the combine op gets them to 
00388                 to turn into other types via their DoBecomeA() method
00389 
00390 ***********************************************************************************************/
00391 
00392 class CombineBecomeA : public BecomeA
00393 {
00394 CC_DECLARE_MEMDUMP(CombineBecomeA);
00395 public:
00396     CombineBecomeA(BecomeAReason ThisReason, UndoableOperation* pOp, SelObjPathList* pThisSelObjPathList,Node* pThisSelNode, BOOL IsFirstNode = FALSE) :
00397                 BecomeA(ThisReason,CC_RUNTIME_CLASS(NodePath),pOp,TRUE,IsFirstNode), pSelObjPathList(pThisSelObjPathList)
00398                 { strokeCreatedPassbackPath = FALSE; }
00399 
00400     // This function should be called when Reason == BECOMEA_PASSBACK 
00401     virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap);
00402 
00403     BOOL IsCombineBecomeA() { return TRUE; }
00404 
00405     // CGS (13/12/2000):  allows us to flag whether the path that is being passed back was created within
00406     // PathProcessorStroke::DoBecomeA ().  This allows us to apply attributes correctly to objects when
00407     // using OpCombineShapes.  The value is used to set the corresponding value within SelObjPathListItem's,
00408     // so that we can control the flow of execution within OpCombineShapes::AdjustAttributesForStroke ()
00409     void SetStrokeCreatedPassbackPath (BOOL newVal) { strokeCreatedPassbackPath = newVal; }
00410 
00411 private:
00412     SelObjPathList* pSelObjPathList;
00413 
00414     BOOL strokeCreatedPassbackPath;     // is the next path being passed back being created by a stroke?
00415 };
00416 
00417 
00418 #endif  // INC_COMBSHPS
00419 
00420 

Generated on Sat Nov 10 03:44:54 2007 for Camelot by  doxygen 1.4.4