00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #ifndef INC_COMBSHPS
00101 #define INC_COMBSHPS
00102
00103
00104
00105
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
00135
00136
00137
00138
00139
00140
00141
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) {}
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;
00178 };
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
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
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;
00217 List ListOfSelObjPaths;
00218 BOOL ProducedPaths;
00219 };
00220
00221
00222
00223
00224
00225
00226
00227
00228
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
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;
00297 INT32 NumPaths;
00298 INT32 JobCount;
00299 INT32 NodeInsertCount;
00300
00301 Node* pContextNode;
00302 AttachNodeDirection AttachDir;
00303 };
00304
00305
00306
00307
00308
00309
00310
00311
00312
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
00327
00328
00329
00330
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
00346
00347
00348
00349
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
00365
00366
00367
00368
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
00384
00385
00386
00387
00388
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
00401 virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap);
00402
00403 BOOL IsCombineBecomeA() { return TRUE; }
00404
00405
00406
00407
00408
00409 void SetStrokeCreatedPassbackPath (BOOL newVal) { strokeCreatedPassbackPath = newVal; }
00410
00411 private:
00412 SelObjPathList* pSelObjPathList;
00413
00414 BOOL strokeCreatedPassbackPath;
00415 };
00416
00417
00418 #endif // INC_COMBSHPS
00419
00420