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
00101 #ifndef INC_BRSHATTR
00102 #define INC_BRSHATTR
00103
00104
00105
00106
00107 #include "brshdata.h"
00108 #include "brpress.h"
00109 #include "samplist.h"
00110
00111 class BrushPointInfo;
00112 class FreeHandTool;
00113 class CDistanceSampler;
00114
00115
00116
00117
00118 #define BRUSHPOINTSCACHE
00119 #define PRESSURE_INVALID 65536
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 class BrushAttrValue : public AttributeValue
00137 {
00138 CC_DECLARE_DYNAMIC(BrushAttrValue)
00139
00140 #ifdef NEWFASTBRUSHES
00141 private:
00142 NodeBitmap* pCachedBitmap;
00143 Node* pBoundsParent;
00144 public:
00145 NodeBitmap* GetCachedBitmap () { return (pCachedBitmap); }
00146 void SetBoundsParent (Node* parent) { pBoundsParent = parent; }
00147 Node* GetBoundsParent () { return (pBoundsParent); }
00148 void SetCachedBitmap (NodeBitmap* pBitmap) { pCachedBitmap = pBitmap; }
00149 #endif
00150
00151 public:
00152 BrushAttrValue();
00153 BrushAttrValue(PathProcessorBrush *pPathProcessor);
00154 ~BrushAttrValue();
00155
00156 static BOOL Init(void);
00157
00158
00159 public:
00160 virtual void Render(RenderRegion *pRegion, BOOL Temp = FALSE);
00161 virtual void Restore(RenderRegion *pRegion, BOOL Temp);
00162 virtual void GoingOutOfScope(RenderRegion *pRegion);
00163
00164 virtual void SimpleCopy(AttributeValue *pValue);
00165 virtual NodeAttribute *MakeNode();
00166
00167 virtual BOOL IsDifferent(AttributeValue *pAttr);
00168
00169 virtual BrushAttrValue &operator=(BrushAttrValue &Attrib);
00170 virtual INT32 operator==(const BrushAttrValue &Attrib);
00171
00172 virtual BOOL Blend(BlendAttrParam* pBlendParam);
00173
00174 BOOL DoBecomeA(BecomeA* pBecomeA, Node* pParent);
00175
00176
00177 BOOL EffectsParentBounds();
00178 DocRect GetAttrBoundingRect(NodeRenderableInk* pParent = NULL, CCAttrMap* pAttribMap = NULL);
00179 static BOOL RotateBounds(double Angle, DocRect* pBounds, DocCoord* pCentre = NULL );
00180
00181 void SetCachedRect(DocRect Rect);
00182 void TransformCachedRect(TransformBase& Trans);
00183
00184 public:
00185 void SetPathProcessor(PathProcessorBrush *pNewProcessor);
00186 PathProcessorBrush *GetPathProcessor(void) const { return(m_pProcessor); };
00187
00188
00189
00190
00191 public:
00192 void FlushCache();
00193 void TransformCache(TransformBase& Trans);
00194 void SetCache(PointsMap* pMap);
00195 PointsMap* GetCache() {return m_pCachedPoints;}
00196
00197 public:
00198 TimeStampList* GetTimeStampList() { return m_pTimeStampList;}
00199 void SetTimeStampList(TimeStampList* pList);
00200 BOOL IsTimeStamping();
00201
00202
00203 void SetTimeStampUpdateType(ListUpdateType Update);
00204 ListUpdateType GetTimeStampUpdateType();
00205
00206
00207 void CalculateProportionalDistances(MILLIPOINT PathLength);
00208 void TransformTimeStampList(TransformBase& Trans);
00209 BOOL DeleteTimeStampPoints(MILLIPOINT StartDistance, MILLIPOINT EndDistance,
00210 TimeStampList* pRemovedPoints = NULL);
00211 BOOL DeleteTimeStampPoints(MILLIPOINT StartDistance, UINT32 NumPoints,
00212 TimeStampList* pRemovedPoints = NULL);
00213 BOOL AddTimeStampPoints(TimeStampList* pNewPoints, MILLIPOINT StartDistance);
00214 BOOL RecalculateTimeStampList(Path* pPath);
00215 BOOL RepositionPointsByProportion(Path* pPath);
00216 BOOL RepositionPointsByPosition(Path* pPath);
00217
00218 TimeStampList* CopyTimeStampList();
00219
00220 BOOL WriteTimeStampList(BaseCamelotFilter *pFilter);
00221
00222 public:
00223 void SetPresssureCache(CDistanceSampler* pPress);
00224 CDistanceSampler* GetPressureCache();
00225 UINT32 GetPressureValue(UINT32 Index);
00226 BOOL SetPressureValue(UINT32 Index, PressureItem Value);
00227
00228 void CalculatePressureArrayProportions(MILLIPOINT PathLength);
00229
00230 public:
00231
00232 void PressureSpacingChange(MILLIPOINT OldSpacing, MILLIPOINT NewSpacing);
00233 void FlushPressureCache();
00234
00235 INT32 GetPressureListIndexAtDistance(MILLIPOINT Distance);
00236
00237 BOOL DeletePressurePoints(MILLIPOINT StartDistance, MILLIPOINT EndDistance,
00238 SampleArray* pRemovedPoints = NULL);
00239 BOOL DeletePressurePoints(UINT32 StartIndex, size_t NumPoints,
00240 SampleArray* pRemovedPoints = NULL);
00241 BOOL AddPressurePoints(CSampleData* pNewPoints, MILLIPOINT StartDistance);
00242 BOOL AddPressurePoints(CSampleData* pNewPoints, UINT32 StartIndex);
00243
00244
00245
00246 void SetPressureUpdateType(ListUpdateType Update);
00247 ListUpdateType GetPressureUpdateType();
00248
00249 CDistanceSampler* CopyPressureCache();
00250
00251 BOOL WritePressureData(BaseCamelotFilter *pFilter);
00252
00253 protected:
00254 BOOL RepositionPressureDataByPosition(Path* pPath);
00255
00256 public:
00257
00258 void ScaleToLineWidth(MILLIPOINT Width);
00259 MILLIPOINT GetDefaultLineWidth(BOOL IgnorePressure = FALSE);
00260
00261
00262 BrushDefinition* GetBrushDefinition(void);
00263 BrushHandle GetBrushHandle(void);
00264
00265 protected:
00266 void InitialisePointsCache();
00267 void FlushTimeStampCache();
00268
00269 static void ShuffleArrayUp(PressureArray* pPressure, UINT32 StartIndex);
00270 static void ShuffleArrayDown(PressureArray* pPressure, UINT32 StartIndex);
00271
00272 static UINT32 BlendUINT32(UINT32 First, UINT32 Second, double BlendRatio);
00273 static INT32 BlendINT32(INT32 First, INT32 Second, double BlendRatio);
00274 static double BlendDouble(double First, double Second, double BlendRatio);
00275
00276
00277 BOOL RecalculateDistances(Path* pPath);
00278 BOOL RecalculateTangents(Path* pPath);
00279 BOOL SortTimeStampingList();
00280 BOOL GetRidOfCrapFromList(Path* pPath);
00281
00282
00283 private:
00284 PathProcessorBrush *m_pProcessor;
00285
00286
00287 #ifdef BRUSHPOINTSCACHE
00288 PointsMap* m_pCachedPoints;
00289 #endif
00290
00291 TimeStampList* m_pTimeStampList;
00292
00293 PressureArray* m_pPressureVals;
00294
00295 CDistanceSampler* m_pPressureSampler;
00296 DocRect m_CachedBRect;
00297
00298 ListUpdateType m_TimeStampUpdateType;
00299
00300 ListUpdateType m_PressureUpdateType;
00301
00302 };
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 class AttrBrushType : public NodeAttribute
00321 {
00322 CC_DECLARE_DYNCREATE(AttrBrushType)
00323
00324 public:
00325 AttrBrushType();
00326 AttrBrushType(Node *ContextNode,
00327 AttachNodeDirection Direction,
00328 BOOL Locked = FALSE,
00329 BOOL Mangled = FALSE,
00330 BOOL Marked = FALSE,
00331 BOOL Selected = FALSE);
00332 ~AttrBrushType();
00333
00334 public:
00335 virtual void Render(RenderRegion *pRender);
00336 virtual void CopyNodeContents(AttrBrushType *NodeCopy);
00337 virtual INT32 operator==(const NodeAttribute& NodeAttrib);
00338 virtual Node *SimpleCopy();
00339 virtual UINT32 GetAttrNameID(void);
00340 virtual void GetDebugDetails(StringBase *Str);
00341 virtual UINT32 GetNodeSize() const;
00342 virtual void Transform( TransformBase& );
00343 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00344 virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFilter);
00345
00346 virtual AttributeValue* GetAttributeValue() { return(&m_Value); };
00347
00348 virtual BOOL NeedsTransparency() const;
00349
00350 virtual BOOL Blend(BlendAttrParam* pBlendParam);
00351
00352 virtual SubtreeRenderState RenderSubtree(RenderRegion *pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00353
00354 BOOL DoBecomeA(BecomeA* pBecomeA, Node* pParent);
00355 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00356
00357
00358 virtual BOOL EffectsParentBounds();
00359 virtual DocRect GetAttrBoundingRect(NodeRenderableInk* pParent = NULL, CCAttrMap* pAttribMap = NULL);
00360
00361 virtual BOOL IsABrush() const;
00362 virtual BOOL ShouldBeOptimized() { return TRUE;}
00363
00364 void NodePathUpdated(Path* pPath);
00365
00366 BOOL OnReplaceAttribute(AttrBrushType* pOther);
00367
00368
00369 public:
00370
00371 String_32 GetBrushName();
00372 BOOL SetSpacing(MILLIPOINT NewSpacing);
00373 BOOL SetScaling(double NewScale);
00374 BOOL SetPathOffsetType(PathOffset NewOffsetType);
00375 BOOL SetPathOffsetValue(MILLIPOINT NewOffsetValue);
00376 BOOL SetTiled(BOOL Tiled);
00377 BOOL SetRotated(BOOL Rotated);
00378 BOOL SetRotateAngle(double NewAngle);
00379 PathProcessorBrush* GetPathProcessor();
00380 BrushDefinition* GetBrushDefinition();
00381 BrushHandle GetBrushHandle(void);
00382 MILLIPOINT GetSpacing();
00383 MILLIPOINT GetDefaultLineWidth(BOOL IgnorePressure = FALSE);
00384
00385 void SetUseLocalTransp(BOOL UseTransp);
00386 public:
00387
00388 void FlushCache();
00389 void SetCache(PointsMap* pMap);
00390 PointsMap* GetCache();
00391
00392
00393 TimeStampList* GetTimeStampList();
00394 BOOL IsTimeStamping();
00395
00396
00397 void SetPressureCache(CDistanceSampler* pSamp);
00398 CDistanceSampler* GetPressureCache();
00399 BOOL ContainsPressureCache();
00400
00401 BOOL ReversePressureCache();
00402
00403
00404 BOOL CanUsePointsCache();
00405
00406
00407 MILLIPOINT GetAppliedLineWidth();
00408 void SetValueToScaleTo(MILLIPOINT LineWidth);
00409 DocColour GetLocalStrokeColour();
00410 void SetBlendedStrokeColour(DocColour* pCol);
00411
00412 UINT32 GetLocalTranspValue();
00413 UINT32 GetLocalTranspType();
00414
00415 static BOOL RotateBounds(double Angle, DocRect* pBounds) ;
00416 void ClearCachedRect();
00417
00418 void SetFreeHandTool(FreeHandTool* pTool);
00419 public:
00420 void InitialiseBrushData();
00421 BrushData GetBrushData();
00422 void SetBrushData(BrushData NewData);
00423
00424 public:
00425 void GetMaxScalingFromDefinition();
00426 BOOL IsParentSelected();
00427
00428 protected:
00429 void FindNearestStrokeColour();
00430 void FindNearestStrokeTransp();
00431
00432 protected:
00433 BrushAttrValue m_Value;
00434
00435 DocColour* m_pLocalStrokeColour;
00436 DocColour* m_pBlendedStrokeColour;
00437 BrushData m_BrushData;
00438
00439 FreeHandTool* m_pFreeTool;
00440
00441 UINT32 m_LocalTranspValue;
00442 UINT32 m_LocalTranspType;
00443 };
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 class CXaraFileRecord;
00457
00458 class BrushAttrRecordHandler : public CamelotRecordHandler
00459 {
00460 CC_DECLARE_DYNAMIC(BrushAttrRecordHandler);
00461
00462 public:
00463 BrushAttrRecordHandler() : CamelotRecordHandler() { m_pLastAttribute = NULL;}
00464 ~BrushAttrRecordHandler() {}
00465
00466
00467 virtual UINT32 *GetTagList();
00468 virtual BOOL HandleRecord(CXaraFileRecord *pCXaraFileRecord);
00469
00470
00471 virtual BOOL BeginSubtree(UINT32 Tag);
00472 virtual BOOL EndSubtree(UINT32 Tag);
00473
00474
00475
00476 protected:
00477 BOOL HandleBrushAttributeRecord(CXaraFileRecord* pRecord);
00478 BOOL HandleBrushDataRecord(CXaraFileRecord* pRecord);
00479 BOOL HandleMoreBrushDataRecord(CXaraFileRecord* pRecord);
00480 BOOL HandleMoreBrushAttrRecord(CXaraFileRecord* pRecord);
00481 BOOL HandleEvenMoreBrushData(CXaraFileRecord* pRecord);
00482 BOOL HandleEvenMoreBrushAttr(CXaraFileRecord* pRecord);
00483 BOOL HandleTimeStampData(CXaraFileRecord* pRecord);
00484 BOOL HandlePressureInfo(CXaraFileRecord* pRecord);
00485 BOOL HandleAttrPressureInfo(CXaraFileRecord* pRecord);
00486 BOOL HandlePressureData(CXaraFileRecord* pRecord);
00487 BOOL HandlePressureSampleData(CXaraFileRecord* pRecord);
00488 BOOL HandleAttrFillFlags(CXaraFileRecord* pRecord);
00489 BOOL HandleTranspInfo(CXaraFileRecord* pRecord);
00490 BOOL HandleAttrTranspInfo(CXaraFileRecord* pRecord);
00491
00492
00493 #ifdef XAR_TREE_DIALOG
00494 virtual void GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase* pStr);
00495 #endif
00496
00497 protected:
00498
00499 static AttrBrushType* m_pLastAttribute;
00500
00501 };
00502
00503 #endif