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 PPBRUSH
00102 #define PPBRUSH
00103
00104 #include "pathpcs.h"
00105 #include "brshcomp.h"
00106 #include "brshattr.h"
00107 #include "brpress.h"
00108
00109 class AttrBrushType;
00110 class BrushAttrValue;
00111 class Pathshape;
00112 class BlendPathOffset;
00113 class BaseCamelotFilter;
00114 class MTRand;
00115 class BrushData;
00116 class HandleBrushBecomeA;
00117 class AttrFlatTranspFill;
00118 class CNamedColourReplacer;
00119 class CHSVChanger;
00120 class CTransparencyReplacer;
00121 class CDistanceSampler;
00122 class ValueFunction;
00123 class CSampleItem;
00124
00125 typedef std::vector< UINT32 > UINTArray;
00126 const INT32 DEFAULT_ARRAY_SIZE = 500;
00127 typedef std::list< CPathPointInfo > CPathPointList;
00128
00129 #define USE_MTRNG // uncomment when we resolve the problems with the MTRand object
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 class PathProcessorBrush : public PathProcessor
00151 {
00152 #ifdef NEWFASTBRUSHES
00153 private:
00154 BrushAttrValue* pLinkedAttr;
00155 public:
00156 void SetLinkedAttribute (BrushAttrValue* attr) { pLinkedAttr = attr; }
00157 #endif
00158
00159 CC_DECLARE_DYNAMIC(PathProcessorBrush);
00160
00161 public:
00162 PathProcessorBrush();
00163 ~PathProcessorBrush();
00164
00165 public:
00166 virtual void ProcessPath(Path *pPath, RenderRegion *pRender,
00167 PathShape ShapePath = PATHSHAPE_PATH);
00168 virtual BOOL WillChangeFillAndBrushSeparately(void);
00169
00170 virtual BOOL IsAPathProcessorBrush();
00171 public:
00172 virtual BOOL IsDifferent(PathProcessorBrush *pOther);
00173
00174
00175 virtual PathProcessorBrush *Clone(void);
00176
00177
00178 virtual BOOL NeedsTransparency(void) const {return FALSE;};
00179
00180
00181 virtual BOOL IsBlended() { return FALSE;}
00182
00183 virtual BOOL DoBecomeA(BecomeA* pBecomeA, Path* pPath, Node* pParent);
00184
00185 virtual BOOL DoesActuallyDoAnything(RenderRegion* pRender);
00186
00187
00188 public:
00189 BOOL WriteNative(BaseCamelotFilter *pFilter);
00190
00191
00192 public:
00193 DocRect CalculateBoundingBox(Path* pPath, NodeRenderableInk* pParent);
00194 DocRect TimeStampBoundingBox();
00195
00196 void SetCalculateBoundingBox(BOOL Set);
00197 DocRect GetCachedRect();
00198
00199 public:
00200 INT32 GetObjectCountToDistance(MILLIPOINT Distance);
00201 MILLIPOINT GetDistanceToObject(UINT32 ObjectNum);
00202
00203
00204 MILLIPOINT GetSpacingAtDistance(MILLIPOINT Distance);
00205
00206 BOOL GetSpacingAndScalingAtDistance(MILLIPOINT Distance, MILLIPOINT* pSpacing,
00207 double* pScaling, UINT32* pPressure = NULL);
00208
00209
00210 BOOL AdvanceBrushToDistance(MILLIPOINT Distance);
00211 UINT32 GetLastObject();
00212
00213
00214 BOOL IsThisPathProcessorOnTheStack(RenderRegion* pRender);
00215
00216 void AdjustSpacingForClosedPath(NodeRenderableInk* pInk);
00217 void AdjustSpacingForClosedPath(Path* pPath, double dPathLength);
00218
00219 public:
00220
00221 void SetBrushDefinition(BrushHandle Handle);
00222 BrushHandle GetBrushDefinitionHandle(void);
00223
00224 virtual BrushDefinition* GetOurBrushDefinition();
00225 public:
00226
00227 MILLIPOINT GetSpacing(void);
00228 BOOL SetSpacing(MILLIPOINT Spacing);
00229 BOOL SetSpacingIncrProp(double Incr);
00230 double GetSpacingIncrProp();
00231 BOOL SetSpacingIncrConst(MILLIPOINT Incr);
00232 MILLIPOINT GetSpacingIncrConst();
00233 UINT32 GetSpacingMaxRand();
00234 BOOL SetSpacingMaxRand(UINT32 Value);
00235 UINT32 GetSpacingRandSeed();
00236 BOOL SetSpacingRandSeed(UINT32 Value);
00237 void SetSpacingRandCache(UINTArray* pArray);
00238 BOOL SetSpacingMaxPressure(UINT32 NewMax);
00239 UINT32 GetSpacingMaxPressure();
00240 MILLIPOINT GetLastSpacing();
00241
00242 public:
00243
00244 PathOffset GetPathOffsetType(void);
00245 MILLIPOINT GetPathOffsetValue(void);
00246 void SetPathOffsetType(PathOffset Offset);
00247 void SetPathOffsetValue(MILLIPOINT Value);
00248 BOOL SetPathOffsetIncrProp(double Incr);
00249 double GetPathOffsetIncrProp();
00250 BOOL SetPathOffsetIncrConst(MILLIPOINT Incr);
00251 MILLIPOINT GetPathOffsetIncrConst();
00252
00253 void SetOffsetTypeRandCache(UINTArray* pArray);
00254 UINT32 GetOffsetTypeRandSeed();
00255 BOOL SetOffsetTypeRandSeed(UINT32 Seed);
00256 UINT32 GetOffsetValueMaxRand();
00257 BOOL SetOffsetValueMaxRand(UINT32 Value);
00258 UINT32 GetOffsetValueRandSeed();
00259 BOOL SetOffsetValueRandSeed(UINT32 Seed);
00260 void SetOffsetValueRandCache(UINTArray* pArray);
00261 public:
00262
00263 void SetTiling(BOOL Value);
00264 BOOL IsTiled();
00265
00266 public:
00267 BOOL SetRotationAngle(double Angle);
00268 double GetRotationAngle();
00269 double GetRotationIncrConst();
00270 BOOL SetRotationIncrConst(double Value);
00271 double GetRotationIncrProp();
00272 BOOL SetRotationIncrProp(double Value);
00273 void SetRotated(BOOL Value);
00274 BOOL IsRotated();
00275 UINT32 GetRotationMaxRand();
00276 BOOL SetRotationMaxRand(UINT32 Value);
00277 UINT32 GetRotationRandSeed();
00278 void SetRotationRandSeed(UINT32 Seed);
00279 UINT32 GetRotationMaxPressure();
00280 BOOL SetRotationMaxPressure(UINT32 Value);
00281
00282 public:
00283 double GetBrushScaling();
00284 BOOL SetBrushScaling(double Scale);
00285 double GetBrushScalingIncr();
00286 BOOL SetBrushScalingIncr(double Incr);
00287 double GetBrushScalingIncrConst();
00288 BOOL SetBrushScalingIncrConst(double Value);
00289 UINT32 GetScalingMaxRand();
00290 BOOL SetScalingMaxRand(UINT32 Value);
00291 UINT32 GetScalingRandSeed();
00292 BOOL SetScalingRandSeed(UINT32 Value);
00293
00294 UINT32 GetScalingMaxPressure();
00295 BOOL SetScalingMaxPressure(UINT32 Max);
00296 double GetLastScaling();
00297
00298 void SetScaleToLineWidth(BOOL Value);
00299 BOOL IsScalingToLineWidth() { return m_bScaleToLineWidth;}
00300
00301 void ScaleToValue(MILLIPOINT Width, BOOL IgnorePressure = FALSE);
00302 double GetScaleValue(MILLIPOINT Width);
00303
00304 public:
00305 double GetHueIncrement();
00306 BOOL SetHueIncrement(double Incr);
00307 UINT32 GetHueMaxRand();
00308 BOOL SetHueMaxRand(UINT32 Max);
00309 UINT32 GetHueRandSeed();
00310 BOOL SetHueRandSeed(UINT32 Seed);
00311
00312 double GetSatIncrement();
00313 BOOL SetSatIncrement(double Incr);
00314 UINT32 GetSatMaxRand();
00315 BOOL SetSatMaxRand(UINT32 Max);
00316 UINT32 GetSatRandSeed();
00317 BOOL SetSatRandSeed(UINT32 Seed);
00318
00319
00320 public :
00321 SequenceType GetSequenceType();
00322 void SetSequenceType(SequenceType Type);
00323 UINT32 GetSequenceSeed();
00324 void SetSequenceSeed(UINT32 Seed);
00325
00326 public:
00327 BOOL GetUseLocalFillColour();
00328 void SetUseLocalFillColour(BOOL UseLocal);
00329
00330 BOOL GetUseLocalTransp();
00331 void SetUseLocalTransp(BOOL);
00332
00333 BOOL GetUseNamedColours();
00334 void SetUseNamedColours(BOOL Value);
00335
00336 public:
00337 INT32 GetBrushTransparency();
00338 BOOL SetBrushTransparency(INT32 Value);
00339 UINT32 GetTransparencyPressure();
00340 BOOL SetTransparencyPressure(UINT32 Value);
00341
00342 public:
00343
00344 UINT32 GetNumBrushObjects();
00345
00346
00347 void SetParentAttribute(AttrBrushType* pAttr);
00348 AttrBrushType* GetParentAttribute();
00349
00350 void SetMaxScaling(double Scale);
00351
00352 void SetCurrentPressure(UINT32 Pressure);
00353 UINT32 GetCurrentPressure();
00354
00355 void CopyBrushData(BrushData* pData);
00356 void CopyDataFromObject(BrushData* pData);
00357
00358 MILLIPOINT GetBrushSize(BOOL IgnorePressure = FALSE);
00359
00360 void SetStrokeColour(DocColour Col);
00361
00362 public:
00363
00364 void RenderBrushAtPoint(DocCoord Point, double Angle,
00365 UINT32 BrushObjectIndex, UINT32 Counter, RenderRegion* pRender,
00366 HandleBrushBecomeA* pBecomeA = NULL, BOOL RealtimeBrush = FALSE,
00367 BrushDefinition* pBrushDefinition = NULL);
00368
00369
00370 BOOL ResetRandomNumberGenerators();
00371
00372 CDistanceSampler* GetPressureCacheAndInitialise();
00373 CDistanceSampler* GetPressureCacheAndInitialise(RenderRegion* pRegion, ValueFunction** ppValFunc);
00374 CDistanceSampler* GetPressureCacheAndInitialise(NodeRenderableInk* pInkNode, ValueFunction** ppValFunc);
00375
00376 public:
00377
00378 void SwitchAlternateValue();
00379 void Reset();
00380
00381
00382 static void GetRandomLimits(UINT32 Base, UINT32 MaxRand, UINT32* pLower, UINT32* pUpper);
00383 static void GetRotationRandomLimits(UINT32 Base, UINT32 MaxRand, UINT32* pLower, UINT32* pUpper);
00384
00385 protected:
00386
00387
00388 void RenderAttributes(RenderRegion* pRender, CCAttrMap* pAttrMap,
00389 CHSVChanger* pReplacer, CTransparencyReplacer* pTranspRep);
00390
00391
00392 void AdjustFillAttributes(CCAttrMap* pAttrMap, CHSVChanger* pReplacer, CTransparencyReplacer* pTransRep);
00393
00394
00395 DocCoord AdjustPositionForOffset(DocCoord OriginalPosition, double Angle, double Scaling,
00396 MILLIPOINT, UINT32 OffsetType);
00397
00398
00399
00400 DocCoord AdjustPositionForBlendPathOffset(DocCoord OriginalPosition, BlendPathOffset* pOffset,
00401 double Scaling, double Angle);
00402
00403
00404 void AddPointsInRectToList(DocRect Rect, Path* pPath, CPathPointList * pList);
00405 void AddAllPointsToList(Path* pPath, CPathPointList* pList);
00406
00407
00408 BOOL GetPointAtDistance(Path* pPath, MILLIPOINT Distance, DocCoord* pPoint,
00409 double* pTangent);
00410
00411 void RenderTimeStampPoints(RenderRegion* pRender);
00412
00413
00414 INT32 HowManyObjectsInDistance(MILLIPOINT Distance);
00415
00416 UINT32 GetCurrentPressureEffect(UINT32 MaxEffect, BOOL FixedMax = FALSE);
00417
00418
00419
00420
00421
00422
00423
00424 void AdjustAndRenderTransparency(RenderRegion* pRender, AttrFillGeometry* pAttrTransp,
00425 CTransparencyReplacer* pRep);
00426
00427 protected:
00428
00429 double GetNextAngle();
00430 MILLIPOINT GetNextOffset();
00431 double GetNextSaturationMultiplier();
00432 double GetNextHueMultiplier();
00433 double GetNextTransparencyAdjust();
00434 double GetNextPressureTranspAdjust();
00435
00436
00437 BOOL ObjectIsWithinRect(DocRect Rect, DocCoord Centre, MILLIPOINT HalfWidth,
00438 MILLIPOINT HalfHeight, double Scaling, double Angle = 0);
00439
00440 CSampleItem GetNextSampleItem(CDistanceSampler* pSampler, ValueFunction* pValFunc, double PathProportion = 0);
00441
00442 public:
00443 double GetNextScaling(UINT32 Index);
00444 MILLIPOINT GetNextSpacing();
00445 UINT32 GetNextInkObject(UINT32 LastObject, UINT32 NumObjects);
00446 UINT32 GetNextOffsetType();
00447 void SetNextOffsetType();
00448
00449
00450 BOOL PrepareForRenderingLoop(UINT32 NumBrushObjects);
00451 void CleanUpAfterRender();
00452
00453 BOOL SetLastRenderedData(UINT32 BrushObject, double Scaling, double Tangent, double Rotation);
00454 void DecideWhetherToUseActualScaling(UINT32 BrushObject);
00455
00456
00457 protected:
00458 BrushHandle m_BrushHandle;
00459
00460
00461
00462
00463
00464 double m_LastScalingRendered;
00465
00466 BOOL* m_pObjectRendered;
00467 BOOL m_UseActualScaling;
00468
00469
00470 double* m_pLastScalingRendered;
00471
00472 double* m_pLastTangent;
00473 double* m_pLastRotation;
00474
00475 DocColour m_CurrentStrokeCol;
00476
00477 BOOL m_DisableMe;
00478
00479
00480
00481
00482
00483 MILLIPOINT m_BrushSpacing;
00484 double m_BrushSpacingIncrProp;
00485 MILLIPOINT m_BrushSpacingIncrConst;
00486 UINT32 m_BrushSpacingMaxRand;
00487 UINT32 m_BrushSpacingRandSeed;
00488 UINT32 m_SpacingMaxPressure;
00489 MILLIPOINT m_LastSpacing;
00490
00491 BOOL m_bTile;
00492 BOOL m_bRotate;
00493
00494
00495 double m_RotateAngle;
00496 double m_RotAngleIncrProp;
00497 double m_RotAngleIncrConst;
00498 double m_LastAngle;
00499 UINT32 m_RotationMaxRand;
00500 UINT32 m_RotationRandSeed;
00501 UINT32 m_RotationMaxPressure;
00502
00503
00504 PathOffset m_PathOffsetType;
00505 MILLIPOINT m_PathOffsetValue;
00506 double m_PathOffsetIncrProp;
00507 MILLIPOINT m_PathOffsetIncrConst;
00508 UINT32 m_OffsetMaxPressure;
00509 MILLIPOINT m_LastOffset;
00510 UINT32 m_LastOffsetType;
00511 UINT32 m_OffsetTypeRandSeed;
00512 UINT32 m_OffsetValueMaxRand;
00513 UINT32 m_OffsetValueRandSeed;
00514
00515
00516 double m_BrushScaling;
00517 double m_BrushScalingIncr;
00518 double m_BrushScalingIncrConst;
00519 double m_LastScaling;
00520 double m_CurrentScaling;
00521 UINT32 m_BrushScalingMaxRand;
00522 UINT32 m_BrushScalingRandSeed;
00523 UINT32 m_ScalingMaxPressure;
00524
00525
00526 double m_BrushHueIncrement;
00527 UINT32 m_BrushHueMaxRand;
00528 UINT32 m_BrushHueRandSeed;
00529 UINT32 m_HueMaxPressure;
00530 double m_LastHueMultiplier;
00531 double m_BrushSatIncrement;
00532 UINT32 m_BrushSatMaxRand;
00533 UINT32 m_BrushSatRandSeed;
00534 UINT32 m_SatMaxPressure;
00535 double m_LastSatMultiplier;
00536
00537
00538 SequenceType m_SequenceType;
00539 UINT32 m_SequenceRandSeed;
00540 BOOL m_MirrorSeqAscend;
00541
00542
00543 BOOL m_bUseLocalFillColour;
00544
00545 BOOL m_bUseLocalTransp;
00546
00547 BOOL m_bUseNamedColours;
00548
00549
00550 INT32 m_BrushTransparency;
00551 UINT32 m_TranspMaxPressure;
00552
00553 UINT32 m_TimeStampMaxPressure;
00554
00555 protected:
00556
00557 UINT32 m_AltValue;
00558
00559 MILLIPOINT m_LineWidth;
00560 BOOL m_bScaleToLineWidth;
00561
00562 BOOL m_bRenderAllAttributes;
00563
00564 AttrBrushType* m_pParentAttr;
00565
00566 PressureItem m_CurrentPressure;
00567
00568
00569 DocRect m_CachedRect;
00570 BOOL m_bCalculateRect;
00571
00572 BOOL m_bValidPressure;
00573
00574 AttrFlatTranspFill* m_pDefaultTransp;
00575
00576 MILLIPOINT m_LastSpacingNoRandom;
00577 MILLIPOINT m_LastOffsetNoRandom;
00578 double m_LastScalingNoRandom;
00579 double m_LastRotationNoRandom;
00580
00581 double m_MaxScaling;
00582
00583 UINT32 m_LastObject;
00584
00585 #ifdef USE_MTRNG // the random number generators
00586 MTRand* m_pSpacingRNG;
00587 MTRand* m_pScalingRNG;
00588 MTRand* m_pOffsetTypeRNG;
00589 MTRand* m_pOffsetValueRNG;
00590 MTRand* m_pRotationRNG;
00591 MTRand* m_pSaturationRNG;
00592 MTRand* m_pHueRNG;
00593 MTRand* m_pSequenceRNG;
00594 #endif
00595
00596 };
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611 PORTNOTE("other","SubRenderContext removed")
00612 #ifndef EXCLUDE_FROM_XARALX
00613 class BrushSubRenderContext: public SubRenderContext
00614 {
00615 CC_DECLARE_DYNCREATE(BrushSubRenderContext);
00616 public:
00617 BrushSubRenderContext() { m_Distance = 0; }
00618
00619 MILLIPOINT m_Distance;
00620 };
00621 #endif
00622
00623 #endif