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_PERSPECTIVE
00101 #define INC_PERSPECTIVE
00102
00103 #include "moldshap.h"
00104 #include "nodemold.h"
00105 #include "gmould.h"
00106
00107 #define PER_NUMCOORDS 4
00108 #define PER_UNDEFINED ((INT32)(0x80000000))
00109
00110 typedef enum PerspectiveClick
00111 {
00112 PClick_DoNothing,
00113 PClick_EditVPoint0,
00114 PClick_EditVPoint1
00115 };
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 class GPerspective : public GMould
00129 {
00130 CC_DECLARE_MEMDUMP(GPerspective)
00131
00132 public:
00133 GPerspective();
00134
00135 virtual BOOL Redefine( POINT *P ) ;
00136 virtual void CopyShape( POINT *P ) ;
00137 virtual BOOL FitPath(CONST POINT *IPoints,
00138 CONST BYTE *ITypes,
00139 DWORD ILength,
00140 LPPOINT OPoints,
00141 LPBYTE OTypes,
00142 DWORD OLength,
00143 BOOL Close = FALSE);
00144
00145 BOOL Valid() ;
00146 BOOL WhichVanishingPoint(POINT v, BOOL& b) ;
00147 void VanishingPoints( POINT& a, POINT& b ) ;
00148 INT32 GetVPointState();
00149 void DragVanishingPoints( POINT& NewI, BOOL Flag, LPPOINT P ) ;
00150
00151 private:
00152 virtual void ScaleView();
00153 virtual void CalcViewBBox();
00154 virtual void CalcViewConsts();
00155 virtual void Transform( DPOINT a, DPOINT& b ) ;
00156
00157 void Intersect( DPOINT I, DPOINT P0, DPOINT P1, DPOINT P2, POINT& O ) ;
00158
00159 private:
00160 POINT P0, P1, P2, P3 ;
00161 DPOINT V0, V1, V2, V3 ;
00162 BOOL I0flag, I1flag ;
00163 BOOL I0pos, I1pos ;
00164 DPOINT I0, I1 ;
00165 DPOINT A, B ;
00166 } ;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 class MouldPerspective: public MouldGeometry
00183 {
00184 friend class RecordPerspectiveAction;
00185
00186 CC_DECLARE_DYNAMIC(MouldPerspective);
00187
00188 public:
00189 MouldPerspective();
00190 ~MouldPerspective();
00191
00192
00193 virtual BOOL Validate(Path* const pPath, UINT32& errorID);
00194 virtual BOOL Define(Path* const pPath, DocRect* const pRect);
00195 virtual MouldSpace Describe() {return MOULDSPACE_PERSPECTIVE;}
00196
00197
00198 virtual BOOL MouldPathToPath(Path* pSourcePath, Path* PDestinPath);
00199 virtual BOOL MouldBitmapToTile(KernelBitmap* pSourceBlit, KernelBitmap* pDestinBlit);
00200 virtual BOOL MouldPoint(DocCoord p, DocCoord& q);
00201
00202
00203 virtual void MouldPathRender(Path* pPath, RenderRegion* pRegion);
00204 virtual void MouldBitmapRender(KernelBitmap* pBlit, DocCoord* pParallel, RenderRegion* pRegion);
00205
00206 virtual void RenderControlBlobs(RenderRegion* pRegion);
00207 virtual void RenderDragBlobs(Spread* pSpread);
00208 virtual void DisableControlBlobs();
00209 virtual void EnableControlBlobs();
00210 virtual void ToggleControlBlobs(Spread* pSpread);
00211 virtual DocRect GetBlobBoundingRect();
00212 virtual DocRect GetSourceRect();
00213 virtual UINT32 GetByteSize() const { return sizeof(MouldPerspective); };
00214
00215 virtual BOOL OnClick(DocCoord, ClickType, ClickModifiers, Spread*, NodeMould*);
00216 virtual BOOL OnMouseMove(DocCoord Coord, Spread* pSpread, ClickModifiers Mods, INT32* ctype, INT32* msgres);
00217 virtual void Transform(Path* const pPath, DocRect* const pRect, TransformBase& Trans );
00218 virtual MouldGeometry* MakeCopy();
00219 virtual ChangeCode RecordContext(UndoableOperation*);
00220 virtual ChangeCode RecordBlobs(UndoableOperation* pOp, Spread* pSpread);
00221
00222 public:
00223
00224 void GetVanishingPoints(DocCoord& p0, DocCoord& p1);
00225 void MoveVanishingPoints(DocCoord p0, DocCoord p1);
00226 void CopyShape(DocCoord* pCoords);
00227 BOOL MoveVanishingPoint(DocCoord OldPoint, DocCoord& NewPoint);
00228 DocRect CalcBlobClipRect(const DocCoord& p0);
00229
00230 static BOOL WillBeValid(POINT* P);
00231
00232 protected:
00233 BOOL CopyContents(MouldPerspective*);
00234 RECT BuildRectangle(DocRect* const pOrigBBox);
00235
00236 private:
00237 void RenderGrid(Spread* pSpread);
00238 void RenderGrid(RenderRegion* pRegion);
00239 void RenderGridPoints(RenderRegion* pRegion);
00240 void RenderVanishingPoints(Spread* pSpread);
00241 void RenderVanishingPoints(RenderRegion* pRegion);
00242 void RenderVanishingPoint(Spread* pSpread, const DocCoord& dcPos);
00243 BOOL BuildShape(POINT* pPoints, DocRect* const pOrigBBox);
00244 void ShowVPoints();
00245 PerspectiveClick DetermineClickEffect(DocCoord PointerPos,Spread* pSpread);
00246
00247 private:
00248 INT32 GridState;
00249 GPerspective Perspective;
00250
00251 };
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 class PerspectiveShapes
00268 {
00269 public:
00270 static BOOL Rectangular(Path* pPath);
00271 static BOOL LeftWall(Path* pPath);
00272 static BOOL RightWall(Path* pPath);
00273 static BOOL Floor(Path* pPath);
00274 static BOOL Ceiling(Path* pPath);
00275
00276 private:
00277 static BOOL MakeShape(Path* pPath, DocCoord* point);
00278
00279 };
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 class RecordPerspectiveAction : public Action
00293 {
00294 CC_DECLARE_DYNCREATE(RecordPerspectiveAction)
00295
00296 public:
00297 RecordPerspectiveAction();
00298 ~RecordPerspectiveAction();
00299 virtual ActionCode Execute();
00300 static ActionCode Init( Operation* pOp,
00301 ActionList* pActionList,
00302 MouldPerspective* pPerspective,
00303 Action** NewAction);
00304 private:
00305 MouldPerspective* pCPerspective;
00306 POINT RecordArray[PER_NUMCOORDS];
00307 };
00308
00309
00310 #endif