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
00102
00103 #ifndef INC_NODEREGSHAPE
00104 #define INC_NODEREGSHAPE
00105
00106
00107
00108
00109
00110
00111
00112
00113 const UINT32 REGULARSHAPE_MINSIDES = 3;
00114 const UINT32 REGULARSHAPE_MAXSIDES = 99;
00115
00116 const double QUICKSHAPE_RADIUS_TOLERANCE=100.0;
00117 const double QUICKSHAPE_ANGLE_TOLERANCE=0.02;
00118 const INT32 QUICKSHAPE_SCALARPRODUCT_TOLERANCE=1000;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 enum ShapeClickEffect { SHAPECLICK_NONE, SHAPECLICK_EDGE1, SHAPECLICK_EDGE2, SHAPECLICK_CURVECHORD,
00130 SHAPECLICK_CENTRE, SHAPECLICK_ELLIPSE, SHAPECLICK_RECTANGLE, SHAPECLICK_PRIMARY,
00131 SHAPECLICK_STELLATION, SHAPECLICK_PRIMARYCURVE, SHAPECLICK_STELLATIONCURVE };
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 class NodeRegularShape : public NodeRenderableInk
00146 {
00147
00148 CC_DECLARE_DYNCREATE(NodeRegularShape);
00149
00150
00151
00152
00153
00154
00155
00156
00157 public:
00158 NodeRegularShape();
00159 ~NodeRegularShape();
00160
00161 NodeRegularShape(Node* ContextNode,
00162 AttachNodeDirection Direction,
00163 BOOL Locked = FALSE,
00164 BOOL Mangled = FALSE,
00165 BOOL Marked = FALSE,
00166 BOOL Selected = FALSE
00167 );
00168
00169
00170 BOOL SetUpShape();
00171 virtual Node* SimpleCopy();
00172 void CopyNodeContents(NodeRegularShape* NodeCopy);
00173 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00174
00175
00176 virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00177 virtual DocRect GetBlobBoundingRect();
00178
00179
00180 BOOL BuildShapePath(Path** RenderPath);
00181 virtual void Render( RenderRegion* pRender );
00182 virtual void RenderEorDrag( RenderRegion* );
00183 virtual void PreExportRender( RenderRegion* pRender );
00184 virtual BOOL ExportRender( RenderRegion* pRender );
00185
00186
00187 virtual void RenderObjectBlobs(RenderRegion* pRender);
00188 virtual void RenderTinyBlobs(RenderRegion* pRender);
00189
00190
00191 virtual void Transform( TransformBase& );
00192 virtual void TransformCentreAndAxes( TransformBase& );
00193
00194
00195 virtual UINT32 GetNodeSize() const;
00196 virtual String Describe(BOOL Plural, BOOL Verbose);
00197 ShapeClickEffect DetermineClickEffect(DocCoord* PointerPos, Spread* pSpread, INT32* pPointNum, DocCoord* pStart = NULL, DocCoord* pEnd = NULL);
00198
00199
00200 virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00201 virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00202
00203
00204 virtual NodePath* GetVariableWidthStrokePath();
00205 virtual NodePath* GetSmoothVariableWidthStrokePath();
00206
00207
00208 #ifdef _DEBUG
00209 void ShowDebugTreeDetails() const;
00210 #endif
00211 void GetDebugDetails( StringBase* Str );
00212
00213
00214 virtual BOOL OnClick( DocCoord, ClickType, ClickModifiers, Spread*);
00215 BOOL OnToolClick( DocCoord, ClickType, ClickModifiers, Spread*);
00216 virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00217
00218
00219 virtual BOOL Snap(DocCoord* pDocCoord);
00220 virtual BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00221 virtual BOOL SnapToCoords(DocCoord* pDocCoord);
00222
00223 virtual BOOL IsARegularShape() const;
00224 virtual double GetRotationAngle();
00225
00226
00227 public:
00228 void PositionPointFromRatio(DocCoord* PosPoint, const DocCoord* EndPoint, const double Ratio);
00229 BOOL BuildPolygonPoints(DocCoord** pArray, INT32* NumPoints = NULL);
00230
00231 BOOL MakeRectangle(const INT32 Width, const INT32 Height, const INT32 CurvatureRadius);
00232 BOOL MakeEllipse(const INT32 Width, const INT32 Height);
00233
00234
00235 double GetMajorRadiusSize();
00236
00237 protected:
00238 void DeleteCachedPath();
00239 void InitialiseMemberVars();
00240
00241 private:
00242 BOOL MakeRegular(DocCoord RegularPoint);
00243 BOOL MakeStraight(BOOL StraightenOne);
00244 BOOL ToggleCurvature();
00245 BOOL InsertShapeEdge(Path* RenderPath, Path* Edge, DocCoord NewEnd);
00246 BOOL BuildEllipsePath(Path* RenderPath);
00247 BOOL BuildPolygonPath(Path* RenderPath, DocCoord* PointsArray);
00248 BOOL SmoothCurvatureJoin(Path* RenderPath, DocCoord* Coords, INT32 Index, BOOL MoveLeft);
00249 void EmergencyFixShape();
00250
00251 BOOL ClickEllipse(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread, BOOL DragCentre);
00252 BOOL ClickCentre(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread);
00253 BOOL ClickPrimary(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread, BOOL DragCentre);
00254 BOOL ClickStellation(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread);
00255 BOOL ClickPCurve(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread, DocCoord Start, DocCoord End);
00256 BOOL ClickSCurve(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread, DocCoord Start, DocCoord End);
00257 BOOL ClickEdge(DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread, BOOL EdgeOne);
00258
00259 public:
00260
00261 UINT32 GetNumSides() const;
00262 void SetNumSides(UINT32 NewNumSides);
00263 BOOL IsCircular() const;
00264 void SetCircular(BOOL Value);
00265 BOOL IsStellated() const;
00266 void SetStellated(BOOL Value);
00267 BOOL IsPrimaryCurvature() const;
00268 void SetPrimaryCurvature(BOOL Value);
00269 BOOL IsStellationCurvature() const;
00270 void SetStellationCurvature(BOOL Value);
00271 double GetStellRadiusToPrimary() const;
00272 void SetStellRadiusToPrimary(double Value);
00273 double GetPrimaryCurveToPrimary() const;
00274 void SetPrimaryCurveToPrimary(double Value);
00275 double GetStellCurveToStell() const;
00276 void SetStellCurveToStell(double Value);
00277 double GetStellationRatio() const;
00278 void SetStellationRatio(double Value);
00279 void SetCentrePoint(DocCoord Value);
00280 void SetMinorAxes(DocCoord Value);
00281 void SetMajorAxes(DocCoord Value);
00282 DocCoord GetCentrePoint();
00283 DocCoord GetMajorAxes();
00284 DocCoord GetMinorAxes();
00285 DocCoord GetUTCentrePoint() const {return UTCentrePoint;};
00286 DocCoord GetUTMajorAxes() const {return UTMajorAxes;};
00287 DocCoord GetUTMinorAxes() const {return UTMinorAxes;};
00288 void GetTransformMatrix(Matrix* store) const;
00289 void SetTransformMatrix(const Matrix* newmatrix);
00290
00291 BOOL IsARectangle() const;
00292
00293 INT32 GetRectWidth();
00294 INT32 GetRectHeight();
00295
00296 inline void InvalidateCache() {PathCacheInvalid = TRUE;};
00297 BOOL IsReformed();
00298
00299
00300 public:
00301
00302 Path EdgePath1;
00303 Path EdgePath2;
00304
00305 protected:
00306 UINT32 NumSides;
00307 BOOL Circular : 1;
00308 BOOL Stellated : 1;
00309 BOOL PrimaryCurvature : 1;
00310 BOOL StellationCurvature : 1;
00311 double StellRadiusToPrimary;
00312 double PrimaryCurveToPrimary;
00313 double StellCurveToStell;
00314 double StellOffsetRatio;
00315
00316
00317 DocCoord UTCentrePoint;
00318 DocCoord UTMajorAxes;
00319 DocCoord UTMinorAxes;
00320 Path* CachedRenderPath;
00321 BOOL PathCacheInvalid : 1;
00322 Matrix TransformMatrix;
00323
00324
00325 public:
00326 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00327 virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00328
00329
00330 public:
00331 PathShape GetPathShape();
00332
00333 BOOL IsRotated();
00334 BOOL AxesAreEqual();
00335 BOOL AxesArePerpendicular();
00336
00337 virtual INT32 EstimateNodeComplexity (OpParam* details);
00338
00339
00340
00341
00342
00343
00344 public:
00345 virtual BOOL IsTypeExtendible() const { return TRUE; }
00346 virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00347 virtual void Extend(const ExtendParams& ExtParams);
00348 };
00349
00350
00351 #endif // NODEREGSHAPE