MouldPerspective Class Reference

The perspective mould class. This mould implements a rectangular transform with true perspective. More...

#include <moldpers.h>

Inheritance diagram for MouldPerspective:

MouldGeometry CCObject SimpleCCObject List of all members.

Public Member Functions

 MouldPerspective ()
 Perspective mould constructor.
 ~MouldPerspective ()
 Perspective mould destructor.
virtual BOOL Validate (Path *const pPath, UINT32 &errorID)
 This function checks whether the path given is suitabile for use as an perspective manifold. Valid paths at present are any set of 5 path elements starting with a moveto followed by 4 lineto elements which form a closed loop without crossings.
virtual BOOL Define (Path *const pPath, DocRect *const pRect)
 This function sets the low level perspective state ready for calls to various perspective path generation functions. It serves simply as a way of informing the low level perspectiviser of the shape of the current manifold.
virtual MouldSpace Describe ()
virtual BOOL MouldPathToPath (Path *pSourcePath, Path *PDestinPath)
 Using the defined Perspective, mould one path into another.
virtual BOOL MouldBitmapToTile (KernelBitmap *pSourceBlit, KernelBitmap *pDestinBlit)
 Create an Perspectived version of a bitmap, ready to be rendered to a device.
virtual BOOL MouldPoint (DocCoord p, DocCoord &q)
 Using the defined perspective, this function takes the input coordinate and calculates its transformed version.
virtual void MouldPathRender (Path *pPath, RenderRegion *pRegion)
 Render a given path using the current perspective settings, to the output region.
virtual void MouldBitmapRender (KernelBitmap *pBlit, DocCoord *pParallel, RenderRegion *pRegion)
virtual void RenderControlBlobs (RenderRegion *pRegion)
 Draw on the perspective grid points on if they are supposed to be shown.
virtual void RenderDragBlobs (Spread *pSpread)
 Draw on the perspective grid points on if they are supposed to be shown.
virtual void DisableControlBlobs ()
virtual void EnableControlBlobs ()
 Used when an perspective is undergoing a drag, we disable normal blob rendering.
virtual void ToggleControlBlobs (Spread *pSpread)
virtual DocRect GetBlobBoundingRect ()
 This calculates the bounding box of the mould and adds in the influence of the selection blobs. It does not consider if the blobs are visible or not, it just gives the bounding box that they would occupy if they were visible.
virtual DocRect GetSourceRect ()
 Return the current definition of the mould perspective source rectangle.
virtual UINT32 GetByteSize () const
virtual BOOL OnClick (DocCoord, ClickType, ClickModifiers, Spread *, NodeMould *)
 Checks to see if any of the perspective vanishing points have been clicked on. If not return FALSE.
virtual BOOL OnMouseMove (DocCoord Coord, Spread *pSpread, ClickModifiers Mods, INT32 *ctype, INT32 *msgres)
virtual void Transform (Path *const pPath, DocRect *const pRect, TransformBase &Trans)
 As the actual perspective mould shape is a nodepath inside the mould parent which this mouldperspecitive object is associated with, the path is passed into this function whenever the mould parent receives a transform call. The path has already been transformed so all we need to do here is update the low level perspective bits.
virtual MouldGeometryMakeCopy ()
 Make a copy of this mould perspective object and return it.
virtual ChangeCode RecordContext (UndoableOperation *)
 Record our context on the undo. In this overridden function we simply create an action to perform the undo/redo of our perspective shape.
virtual ChangeCode RecordBlobs (UndoableOperation *pOp, Spread *pSpread)
 Record our blobs on the undo. In this overridden function we simply store our blob rectangles so that they will redraw correctly during undo and redo.
void GetVanishingPoints (DocCoord &p0, DocCoord &p1)
 Reads the values of this defined perspectives vanishing points.
void MoveVanishingPoints (DocCoord p0, DocCoord p1)
void CopyShape (DocCoord *pCoords)
 Make a copy of the current perspective shape, placing the output coords in pCoords, most likely a path coordinate array. Note, the routine expects pCoords to point to an array of at least five coordinates.
BOOL MoveVanishingPoint (DocCoord OldPoint, DocCoord &NewPoint)
 Moves a vanishing point from OldPoint to NewPoint and redefines the perspective shape to suit. If the perspective moves into an invalid position the routine will return FALSE and leave the stored perspective as was.
DocRect CalcBlobClipRect (const DocCoord &p0)
 Constructs a rectangle that surrounds the given point.

Static Public Member Functions

static BOOL WillBeValid (POINT *P)
 Check whether the point array has any crossing and is thus unsuited for use as a manifold.

Protected Member Functions

BOOL CopyContents (MouldPerspective *)
 Make a copy of this mould perspective class private data.
RECT BuildRectangle (DocRect *const pOrigBBox)
 Build a RECT structure to pass to the low level perspective code.

Private Member Functions

 CC_DECLARE_DYNAMIC (MouldPerspective)
void RenderGrid (Spread *pSpread)
 Draw on the perspective grid points on if they are supposed to be shown.
void RenderGrid (RenderRegion *pRegion)
 Draw on the perspective vanishing points if they intersect the current region.
void RenderGridPoints (RenderRegion *pRegion)
 Draw all the prespective grid points on if they are supposed to be shown.
void RenderVanishingPoints (Spread *pSpread)
 Draw on the perspective vanishing points on.
void RenderVanishingPoints (RenderRegion *pRegion)
 Draws the prespective vanishing points on.
void RenderVanishingPoint (Spread *pSpread, const DocCoord &dcPos)
 Draws a particular prespective vanishing point on.
BOOL BuildShape (POINT *pPoints, DocRect *const pOrigBBox)
void ShowVPoints ()
PerspectiveClick DetermineClickEffect (DocCoord PointerPos, Spread *pSpread)
 Used when single clicking. This routine determines what effect a click will have. The perspective mould provides draggable vanishing point blobs so we need to check whether someones trying to click and drag one of these.

Private Attributes

INT32 GridState
GPerspective Perspective

Friends

class RecordPerspectiveAction

Detailed Description

The perspective mould class. This mould implements a rectangular transform with true perspective.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/12/94

Definition at line 182 of file moldpers.h.


Constructor & Destructor Documentation

MouldPerspective::MouldPerspective  ) 
 

Perspective mould constructor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
[INPUTS] 

Definition at line 144 of file moldpers.cpp.

00145 {
00146     GridState = 0;          // 0 = Grid off
00147                             // 1 = Grid on
00148                             // 2 = Grid on but temporarily disabled
00149 }

MouldPerspective::~MouldPerspective  ) 
 

Perspective mould destructor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
[INPUTS] 

Definition at line 164 of file moldpers.cpp.

00165 {
00166 }


Member Function Documentation

RECT MouldPerspective::BuildRectangle DocRect *const   pOrigBBox  )  [protected]
 

Build a RECT structure to pass to the low level perspective code.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/01/95
Parameters:
pOrigBBox = a pointer to the bounding box of the objects to be perspectivised [INPUTS] = NULL then the old bounding box will be assumed.
Returns:
a RECT structure.

Definition at line 391 of file moldpers.cpp.

00392 {
00393     RECT ObjRect;
00394     if (pOrigBBox!=NULL)
00395     {
00396         ObjRect.left    = pOrigBBox->lo.x;
00397         ObjRect.bottom  = pOrigBBox->lo.y;
00398         ObjRect.right   = pOrigBBox->hi.x;
00399         ObjRect.top     = pOrigBBox->hi.y;
00400     }
00401     else
00402         ObjRect = Perspective.GetSourceBBox();
00403 
00404     return ObjRect;
00405 }

BOOL MouldPerspective::BuildShape POINT pPoints,
DocRect *const   pOrigBBox
[private]
 

RECT MouldPerspective::BuildShape(POINT* pPoints, DocRect* const pOrigBBox)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/01/95
Parameters:
pPoints = a pointer to a array of INT32 coordinates [INPUTS] pOrigBBox = a pointer to the bounding box of the objects to be moulded = NULL then the old bounding box will be assumed.
Returns:
TRUE - then BuildShape has succeded FALSE - then BuildShape has failed to create the mould shape

Definition at line 365 of file moldpers.cpp.

00366 {
00367     ERROR2IF(pPoints==NULL,FALSE,"MouldPerspective::BuildShape() called with NULL point list");
00368 
00369     RECT ObjRect = BuildRectangle(pOrigBBox);
00370 
00371     Perspective.Define(pPoints,&ObjRect,MouldThreshold);
00372 
00373     return TRUE;
00374 }

DocRect MouldPerspective::CalcBlobClipRect const DocCoord dcPos  ) 
 

Constructs a rectangle that surrounds the given point.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
dcPos the centre of the blob that the clipping rectangle will surround [INPUTS]
- [OUTPUTS]
Returns:
A clipping rectangle for use by RenderDragBlobs.

Errors: -

Definition at line 962 of file moldpers.cpp.

00963 {
00964 #if !defined(EXCLUDE_FROM_RALPH)
00965     BlobManager* pBlobManager = GetApplication()->GetBlobManager();
00966     INT32 nSize = pBlobManager->GetBlobSize() + 2;
00967     return DocRect(DocCoord(dcPos.x - nSize, dcPos.y - nSize),
00968                    DocCoord(dcPos.x + nSize, dcPos.y + nSize));
00969 #else
00970     return DocRect(0,0,0,0);
00971 #endif
00972 }

MouldPerspective::CC_DECLARE_DYNAMIC MouldPerspective   )  [private]
 

BOOL MouldPerspective::CopyContents MouldPerspective pPerspective  )  [protected]
 

Make a copy of this mould perspective class private data.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/01/95
Parameters:
pPerspective = a pointer to a copy of a perspective object. [INPUTS]
[OUTPUTS] 
Returns:
TRUE if the data has been copied correctly FALSE if failed

Definition at line 1177 of file moldpers.cpp.

01178 {
01179     ERROR3IF(pPerspective==NULL, "MouldPerspective::CopyContents() passed a null pointer");
01180     // ask the base class to copy its bits first
01181     if (!MouldGeometry::CopyContents(pPerspective))
01182         return FALSE;
01183 
01184     // now lets copy data about ourselves
01185     POINT TempArray[PER_NUMCOORDS];
01186     RECT TempRect = Perspective.GetSourceBBox();
01187     DocRect Rect = ConvRectToDocRect(TempRect);
01188     Perspective.CopyShape(TempArray);
01189 
01190     // define this shape with the details
01191     return (pPerspective->BuildShape(TempArray, &Rect));
01192 }

void MouldPerspective::CopyShape DocCoord pCoords  ) 
 

Make a copy of the current perspective shape, placing the output coords in pCoords, most likely a path coordinate array. Note, the routine expects pCoords to point to an array of at least five coordinates.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/01/95
Parameters:
pCoords = A pointer to an array of doc coords [INPUTS]
pCoords contains the five coordinates of the perspective shape [OUTPUTS]

Definition at line 1114 of file moldpers.cpp.

01115 {
01116     POINT TempArray[PER_NUMCOORDS];
01117     Perspective.CopyShape(TempArray);
01118 
01119     INT32               i;
01120     for( i = 0; i < PER_NUMCOORDS; i++ )
01121     {
01122         pCoords[i].x = TempArray[i].x;
01123         pCoords[i].y = TempArray[i].y;
01124     }
01125 
01126     // copy the last coordinate in to.
01127     pCoords[i].x=TempArray[0].x;
01128     pCoords[i].y=TempArray[0].y;
01129 }

BOOL MouldPerspective::Define Path *const   pPath,
DocRect *const   pOrigBBox
[virtual]
 

This function sets the low level perspective state ready for calls to various perspective path generation functions. It serves simply as a way of informing the low level perspectiviser of the shape of the current manifold.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pPath = the path to use for moulding [INPUTS] pOrigBBox = a pointer to the bounding box of the objects to be moulded = NULL then the old bounding box will be assumed. returns: TRUE - then Define has succeded FALSE - then Define has failed to initialise the perspective mould

Reimplemented from MouldGeometry.

Definition at line 318 of file moldpers.cpp.

00319 {
00320     ERROR2IF(pPath==NULL && pOrigBBox==NULL, FALSE,"MouldPerspective::Define() called with NULL parameters");
00321 
00322     RECT ObjRect = BuildRectangle(pOrigBBox);
00323     
00324     // Save the current state incase we fail
00325     POINT TempArray[PER_NUMCOORDS];
00326     RECT TempRect=Perspective.GetSourceBBox();
00327     Perspective.CopyShape(TempArray);
00328 
00329     // if we're defining a new path then point at it
00330     POINT* pPoints = TempArray;
00331     if (pPath!=NULL)
00332         pPoints=(POINT*)pPath->GetCoordArray();
00333 
00334     // Define the new shape
00335     Perspective.Define(pPoints,&ObjRect,MouldThreshold);
00336 
00337     // now check it for validity
00338     if (!Perspective.Valid())
00339     {
00340         // if not valid replace the old data
00341         Perspective.Define(TempArray,&TempRect,MouldThreshold);
00342         return FALSE;
00343     }
00344         
00345     return TRUE;
00346 }

virtual MouldSpace MouldPerspective::Describe  )  [inline, virtual]
 

Reimplemented from MouldGeometry.

Definition at line 195 of file moldpers.h.

00195 {return MOULDSPACE_PERSPECTIVE;}

PerspectiveClick MouldPerspective::DetermineClickEffect DocCoord  PointerPos,
Spread pSpread
[private]
 

Used when single clicking. This routine determines what effect a click will have. The perspective mould provides draggable vanishing point blobs so we need to check whether someones trying to click and drag one of these.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/1/95
Parameters:
PointerPos is the mouse position [INPUTS] pSpread is a pointer to the spread containing the mouse position
- [OUTPUTS]
Returns:
A click type, which defines what edit action should be taken.

Definition at line 1356 of file moldpers.cpp.

01357 {
01358 #if !defined(EXCLUDE_FROM_RALPH)
01359     DocRect Rect;
01360     DocCoord v0,v1;
01361 
01362     GetVanishingPoints(v0,v1);
01363 
01364     if (v0.x!=PER_UNDEFINED)
01365     {
01366         Rect=CalcBlobClipRect(v0);
01367         if (Rect.ContainsCoord(PointerPos))
01368             return PClick_EditVPoint0;
01369     }
01370 
01371     if (v1.x!=PER_UNDEFINED)
01372     {
01373         Rect=CalcBlobClipRect(v1);
01374         if (Rect.ContainsCoord(PointerPos))
01375             return PClick_EditVPoint1;
01376     }
01377 
01378 #endif
01379     return PClick_DoNothing;    
01380 }

void MouldPerspective::DisableControlBlobs  )  [virtual]
 

Reimplemented from MouldGeometry.

Definition at line 690 of file moldpers.cpp.

00691 {
00692     if (GridState>0) GridState++;
00693 }

void MouldPerspective::EnableControlBlobs  )  [virtual]
 

Used when an perspective is undergoing a drag, we disable normal blob rendering.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
- [INPUTS]

Reimplemented from MouldGeometry.

Definition at line 685 of file moldpers.cpp.

00686 {
00687     if (GridState>1) GridState--;
00688 }

DocRect MouldPerspective::GetBlobBoundingRect  )  [virtual]
 

This calculates the bounding box of the mould and adds in the influence of the selection blobs. It does not consider if the blobs are visible or not, it just gives the bounding box that they would occupy if they were visible.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/12/94
Returns:
DocRect - Returns the bounding rect of the path and its blobs

Reimplemented from MouldGeometry.

Definition at line 988 of file moldpers.cpp.

00989 {
00990 #if !defined(EXCLUDE_FROM_RALPH)
00991     DocCoord v0,v1;
00992     GetVanishingPoints(v0,v1);
00993 
00994     DocRect Rect;
00995 
00996     if (v0.x!=PER_UNDEFINED)
00997         Rect=Rect.Union(CalcBlobClipRect(v0));
00998 
00999     if (v1.x!=PER_UNDEFINED)
01000         Rect=Rect.Union(CalcBlobClipRect(v1));
01001 
01002     return Rect;
01003 #else
01004     return DocRect(0,0,0,0);
01005 #endif
01006 }

virtual UINT32 MouldPerspective::GetByteSize  )  const [inline, virtual]
 

Reimplemented from MouldGeometry.

Definition at line 213 of file moldpers.h.

00213 { return sizeof(MouldPerspective); };

DocRect MouldPerspective::GetSourceRect  )  [virtual]
 

Return the current definition of the mould perspective source rectangle.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/01/95
Parameters:
[INPUTS] 
Returns:
a doc rect.

Reimplemented from MouldGeometry.

Definition at line 1207 of file moldpers.cpp.

01208 { 
01209     RECT Rect = Perspective.GetSourceBBox();
01210     return ConvRectToDocRect(Rect);
01211 }

void MouldPerspective::GetVanishingPoints DocCoord p0,
DocCoord p1
 

Reads the values of this defined perspectives vanishing points.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
[INPUTS] 
p0 = the first vanishing point position (0x80000000 if none existant) [OUTPUTS] p1 = the second vanishing point position (0x80000000 if none existant)
Returns:

Definition at line 1023 of file moldpers.cpp.

01024 {
01025     POINT v0,v1;
01026     Perspective.VanishingPoints(v0,v1);
01027     p0.x=v0.x; p0.y=v0.y;
01028     p1.x=v1.x; p1.y=v1.y;
01029 }

MouldGeometry * MouldPerspective::MakeCopy  )  [virtual]
 

Make a copy of this mould perspective object and return it.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/12/94
Parameters:
[INPUTS] 
a pointer to a new mould perspective object [OUTPUTS] NULL if unable to create the object.

Reimplemented from MouldGeometry.

Definition at line 1145 of file moldpers.cpp.

01146 {
01147     // create a new shape
01148     MouldPerspective* pShape = new MouldPerspective;
01149     if (pShape == NULL)
01150         return NULL;
01151 
01152     BOOL ok = CopyContents(pShape);
01153     if (!ok)
01154     {
01155         delete pShape;
01156         return NULL;
01157     }
01158 
01159     return (pShape);
01160 }

void MouldPerspective::MouldBitmapRender KernelBitmap pBlit,
DocCoord Parallel,
RenderRegion pRegion
[virtual]
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pBlit = pointer to a kernel bitmap [INPUTS] pParallel = pointer to a four point parallelogram pRegion = pointer to a region to render into

Reimplemented from MouldGeometry.

Definition at line 641 of file moldpers.cpp.

00644 {
00645     pRegion->SaveContext();
00646 
00647     // No lines on the rectangle
00648     pRegion->SetLineColour(COLOUR_TRANS);
00649 
00650     pRegion->RestoreContext();
00651 }

BOOL MouldPerspective::MouldBitmapToTile KernelBitmap pSourceBlit,
KernelBitmap pDestinBlit
[virtual]
 

Create an Perspectived version of a bitmap, ready to be rendered to a device.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pSourceBlit = pointer to a bitmap to Perspective [INPUTS] pDestinBlit = pointer to an output tile to mould into
pDestinBlit = Perspectived version of the bitmap [OUTPUTS]
Returns:
TRUE - if the mould was successfull FALSE - if no room to create the mould

Reimplemented from MouldGeometry.

Definition at line 599 of file moldpers.cpp.

00600 {
00601     // currently not implemented
00602     return FALSE;
00603 }

void MouldPerspective::MouldPathRender Path pPath,
RenderRegion pRegion
[virtual]
 

Render a given path using the current perspective settings, to the output region.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pPath = pointer to a path to perspectivise [INPUTS] pRegion = pointer to a region to render into

Reimplemented from MouldGeometry.

Definition at line 619 of file moldpers.cpp.

00620 {
00621 }

BOOL MouldPerspective::MouldPathToPath Path pSourcePath,
Path pDestinPath
[virtual]
 

Using the defined Perspective, mould one path into another.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pSourcePath = pointer to a path object to mould [INPUTS] pDestinPath = pointer to a path buffer to put the resulting moulded path in
pDestinPath contains the moulded version of the path [OUTPUTS]
Returns:
TRUE - if the mould was successfull FALSE - if no room to create the mould

Reimplemented from MouldGeometry.

Definition at line 427 of file moldpers.cpp.

00428 {
00429     ERROR2IF(pSourcePath==NULL, FALSE, "MouldPerspective::MouldPathToPath() passed a NULL source pointer");
00430     ERROR2IF(pDestinPath==NULL, FALSE, "MouldPerspective::MouldPathToPath() passed a NULL destin pointer");
00431 
00432     // get the source path data length
00433     DWORD ilength = (DWORD)pSourcePath->GetNumCoords();
00434 
00435     // if there's no input path, then there's no output path, and all is well.
00436     if (ilength<1)
00437         return TRUE;
00438 
00439     INT32 freespace = ilength*4;
00440     INT32 maxspace = ilength*16;
00441     BOOL ok;
00442     INT32 added;
00443 
00444     Path TempPath;
00445     if (!TempPath.Initialise(freespace,24))
00446         return FALSE;
00447 
00448     do
00449     {
00450         // get the source object and destin object path data
00451         POINT* icoords = (POINT*)pSourcePath->GetCoordArray();
00452         BYTE*  iverbs  = (BYTE*)pSourcePath->GetVerbArray();
00453         POINT* ocoords = (POINT*)TempPath.GetCoordArray();
00454         BYTE*  overbs  = (BYTE*)TempPath.GetVerbArray();
00455 
00456         // try to create an enveloped path
00457         added = Perspective.FitPath(icoords,iverbs,ilength,ocoords,overbs,freespace);
00458 
00459         if (added==-1)
00460         {
00461             freespace*=2;
00462             // create what we think will be enough space for the output path
00463             ok = TempPath.EnsureVolume(freespace);
00464             if (!ok) 
00465                 return FALSE;
00466         }
00467 
00468     } while ((added==-1) && freespace<=maxspace);
00469 
00470     // if we've failed to create the perspectivised object then tidy up
00471     if (added<=1)
00472         return FALSE;
00473 
00474     // now lets set up the new flags array
00475     ok = TempPath.ExternalArraysReplaced(added);
00476     if (ok)
00477         TempPath.InitialiseFlags(0,added);
00478 
00479     if (ok)
00480     {
00481 
00482 /* Path trimming, temporarily removed as doesn't fix the showstopper.
00483 
00484         // Ok check for rampant null elements in this path
00485         DocCoord* Coords;
00486         PathVerb* Verbs;
00487         PathFlags* Flags;
00488         PathVerb CurVerb;
00489         INT32 i,lmi;
00490         DocCoord lm;
00491 
00492         TempPath.GetPathArrays(&Verbs,&Coords,&Flags);
00493 
00494         for (i=0; i<added; i++)
00495         {
00496             CurVerb = Verbs[i] & ~PT_CLOSEFIGURE;
00497             if (CurVerb==PT_MOVETO)
00498             {
00499                 lm=Coords[i];
00500                 lmi=i;
00501             }
00502 
00503             if (CurVerb==PT_BEZIERTO)
00504             {
00505                 if (Verbs[i+2] & PT_CLOSEFIGURE)
00506                 {
00507                     DocCoord p0,p1,p2;
00508                     p0 = Coords[i];
00509                     p1 = Coords[i+1];
00510                     p2 = Coords[i+2];
00511                     if ((p0.x==p1.x) && (p1.x==p2.x) && (p2.x==lm.x) &&
00512                         (p0.y==p1.y) && (p1.y==p2.y) && (p2.y==lm.y) && 
00513                         (i-lmi)>1)
00514                     {
00515                         // We can delete this element!
00516                         Verbs[i-1] |= PT_CLOSEFIGURE;
00517                         if (TempPath.DeleteSection(i,3))
00518                         {
00519                             added-=3;
00520                             i-=3;
00521                         }
00522                         else
00523                             i=added;
00524                     }
00525                 }
00526                 i+=2;
00527             }
00528         }
00529 */
00530         ok = pDestinPath->CloneFrom(TempPath);
00531     }
00532 
00533     return ok;
00534 }

BOOL MouldPerspective::MouldPoint DocCoord  p,
DocCoord q
[virtual]
 

Using the defined perspective, this function takes the input coordinate and calculates its transformed version.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
p = the coordinate to be transformed [INPUTS]
q = the transformed version of the coordinate [OUTPUTS]
Returns:
TRUE if the point has been transformed FALSE if q==p

Reimplemented from MouldGeometry.

Definition at line 553 of file moldpers.cpp.

00554 {
00555     // I aught to check that the point as contained within the source rectangle
00556     // bbox and do something about it if not. But what to do?
00557     // It turns out that perspective transforms behave sensibly for points
00558     // outside the source bbox so we can remove the following checks.
00559 /*
00560     RECT rect = Perspective.GetSourceBBox();
00561     if  ((p.x<rect.left) || (p.x>rect.right) ||
00562         (p.y<rect.bottom) || (p.y>rect.top))
00563     {
00564         q=p;
00565         return;
00566     }
00567 */
00568     POINT r,s;
00569 
00570     r.x = p.x;
00571     r.y = p.y;
00572 
00573     Perspective.FitPoint(r,s);
00574 
00575     q.x = s.x;
00576     q.y = s.y;
00577 
00578     return TRUE;
00579 }

BOOL MouldPerspective::MoveVanishingPoint DocCoord  OldPoint,
DocCoord NewPoint
 

Moves a vanishing point from OldPoint to NewPoint and redefines the perspective shape to suit. If the perspective moves into an invalid position the routine will return FALSE and leave the stored perspective as was.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
OldPoint = A last known vanishing point position [INPUTS] NewPoint = What should hopefully become a new position
NewPoint = The new point will be updated to hold the actual position of [OUTPUTS] the vanishing point. It may be slightly different from NewPoint due to rounding error.
Returns:
TRUE if the mould vanishing point has been altered, FALSE if no change has occured, due to either (1) the old vanishing point could not be located (2) the new vanishing point causes the perspective map to become invalid

Definition at line 1054 of file moldpers.cpp.

01055 {
01056 #if !defined(EXCLUDE_FROM_RALPH)
01057     BOOL Flag;
01058     if (OldPoint.x==PER_UNDEFINED || OldPoint.y==PER_UNDEFINED)
01059         return FALSE;
01060 
01061     POINT p;
01062     p.x=OldPoint.x;
01063     p.y=OldPoint.y;
01064 
01065     if (!Perspective.WhichVanishingPoint(p, Flag))
01066         return FALSE;
01067 
01068     // Save the current state incase we fail
01069     POINT TempArray[PER_NUMCOORDS];
01070     Perspective.CopyShape(TempArray);
01071     POINT TempArray1[PER_NUMCOORDS];
01072     Perspective.CopyShape(TempArray1);
01073     INT32 SCode = Perspective.GetVPointState();
01074 
01075     p.x=NewPoint.x;
01076     p.y=NewPoint.y;
01077 
01078     Perspective.DragVanishingPoints(p,Flag,TempArray1);
01079     BuildShape(TempArray1,NULL);
01080     INT32 ECode = Perspective.GetVPointState();
01081 
01082     // now check it for validity
01083     if ((!Perspective.Valid()) || (SCode!=ECode))
01084     {
01085         // if not valid replace the old data
01086         BuildShape(TempArray,NULL);
01087         return FALSE;
01088     }
01089 
01090     DocCoord v0,v1;
01091     GetVanishingPoints(v0,v1);
01092     Flag ? (NewPoint=v1) : (NewPoint=v0);
01093 #endif
01094     return TRUE;
01095 }

void MouldPerspective::MoveVanishingPoints DocCoord  p0,
DocCoord  p1
 

BOOL MouldPerspective::OnClick DocCoord  PointerPos,
ClickType  CType,
ClickModifiers  Mods,
Spread pSpread,
NodeMould pNodeMould
[virtual]
 

Checks to see if any of the perspective vanishing points have been clicked on. If not return FALSE.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
Coord = coordinate of mouse [INPUTS] CType = the type of click (single, double, drag) Mods = the click modifiers pSpread = a pointer to the spread the click occured over Returns TRUE if we processed the click FALSE if none of the vanishing points were under the click position

Reimplemented from MouldGeometry.

Definition at line 1236 of file moldpers.cpp.

01241 {
01242     BOOL Claimed=FALSE;
01243 
01244 #ifndef STANDALONE
01245 
01246     // we only handle the click if we can confirm that object blobs are being displayed.
01247     BlobManager* pBlobMgr = GetApplication()->GetBlobManager();
01248     if (pBlobMgr == NULL)
01249         return FALSE;
01250     if (!pBlobMgr->GetCurrentInterest().Object)
01251         return FALSE;
01252 
01253     PerspectiveClick WhatToDo = DetermineClickEffect(PointerPos,pSpread);
01254 
01255     switch (CType)
01256     {
01257         case CLICKTYPE_SINGLE:
01258             switch (WhatToDo)
01259             {
01260                 case PClick_EditVPoint0:
01261                 {
01262                     Claimed=TRUE;                   
01263                     OpDragOrigin* pOpDragOrigin = new OpDragOrigin;
01264                     if (pOpDragOrigin!=NULL)
01265                         pOpDragOrigin->DoDragVanishPoint(pSpread,PointerPos,Mods,pNodeMould,FALSE);
01266                 }
01267                 break;
01268 
01269                 case PClick_EditVPoint1:
01270                 {
01271                     Claimed=TRUE;
01272                     OpDragOrigin* pOpDragOrigin = new OpDragOrigin;
01273                     if (pOpDragOrigin!=NULL)
01274                         pOpDragOrigin->DoDragVanishPoint(pSpread,PointerPos,Mods,pNodeMould,TRUE);
01275                 }
01276                 break;
01277                 default: break;
01278             }                   
01279             break;
01280 
01281         case CLICKTYPE_DOUBLE:
01282             break;
01283         case CLICKTYPE_DRAG:
01284             break;
01285         default: break;
01286     }                   
01287 
01288 #endif
01289 
01290     return Claimed;
01291 }

BOOL MouldPerspective::OnMouseMove DocCoord  Coord,
Spread pSpread,
ClickModifiers  Mods,
INT32 *  ctype,
INT32 *  msgres
[virtual]
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
Coord = coordinate of mouse [INPUTS] Mods = the click modifiers pSpread = a pointer to the spread the click occured over
Returns:
ctype = the tool cursor type to use over this point msgres = the message resource type to use over this point

Reimplemented from MouldGeometry.

Definition at line 1312 of file moldpers.cpp.

01317 {
01318 #ifndef STANDALONE
01319 
01320     ERROR2IF(ctype==NULL,FALSE,"MouldPerspective::OnMouseMove passed a null cursor type ptr");
01321     ERROR2IF(msgres==NULL,FALSE,"MouldPerspective::OnMouseMove passed a null msg res ptr");
01322 
01323     PerspectiveClick Click = DetermineClickEffect(Coord, pSpread);
01324     switch (Click)
01325     {
01326         case PClick_EditVPoint0:
01327         case PClick_EditVPoint1:
01328             *ctype = 2;
01329             *msgres = 2;
01330             return TRUE;
01331             break;
01332         default: break;
01333     }
01334 
01335 #endif
01336 
01337     return FALSE;
01338 }

ChangeCode MouldPerspective::RecordBlobs UndoableOperation pOp,
Spread pSpread
[virtual]
 

Record our blobs on the undo. In this overridden function we simply store our blob rectangles so that they will redraw correctly during undo and redo.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/01/95
Parameters:
pOp = pointer to a running undoable operation [INPUTS]
- [OUTPUTS]

Reimplemented from MouldGeometry.

Definition at line 1459 of file moldpers.cpp.

01460 {
01461 #ifndef STANDALONE
01462 
01463     if (pOp!=NULL)
01464     {
01465         ActionCode  Act;
01466         DocCoord    v0,v1;
01467         DocRect     Rect;
01468 
01469         GetVanishingPoints(v0,v1);
01470 
01471         if (v0.x!=PER_UNDEFINED)
01472         {
01473             Rect=CalcBlobClipRect(v0);
01474             Act=InvalidateRectAction::DoRecord(pOp,Rect,pSpread);
01475 
01476             if (Act == AC_FAIL) 
01477                 return CC_FAIL;
01478             if (Act == AC_NORECORD)
01479                 return CC_NORECORD;
01480         }
01481 
01482         if (v1.x!=PER_UNDEFINED)
01483         {
01484             Rect=CalcBlobClipRect(v1);
01485             Act=InvalidateRectAction::DoRecord(pOp,Rect,pSpread);
01486 
01487             if (Act == AC_FAIL)
01488                 return CC_FAIL;
01489             if (Act == AC_NORECORD)
01490                 return CC_NORECORD;
01491         }
01492 
01493     }
01494 #endif
01495 
01496     return CC_OK;
01497 }

ChangeCode MouldPerspective::RecordContext UndoableOperation pOp  )  [virtual]
 

Record our context on the undo. In this overridden function we simply create an action to perform the undo/redo of our perspective shape.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/01/95
Parameters:
pOp = pointer to a running undoable operation [INPUTS]
- [OUTPUTS]

Reimplemented from MouldGeometry.

Definition at line 1426 of file moldpers.cpp.

01427 {
01428     if (pOp!=NULL)
01429     {
01430         RecordPerspectiveAction* PerAction;
01431         ActionCode Act;
01432 
01433         // call the actions static init function to get the action going.
01434         Act = RecordPerspectiveAction::Init(pOp, pOp->GetUndoActionList(), this, (Action**)(&PerAction));
01435 
01436         if (Act == AC_FAIL)
01437             return CC_FAIL;
01438         if (Act == AC_NORECORD)
01439             return CC_NORECORD;
01440     }
01441     return CC_OK;
01442 }

void MouldPerspective::RenderControlBlobs RenderRegion pRegion  )  [virtual]
 

Draw on the perspective grid points on if they are supposed to be shown.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pRegion = pointer to a region to render into [INPUTS]

Reimplemented from MouldGeometry.

Definition at line 707 of file moldpers.cpp.

00708 {
00709 #if !defined(EXCLUDE_FROM_RALPH)
00710     ERROR3IF(pRegion==NULL,"MouldPerspective::RenderControlBlobs passed a NULL region");
00711     if (pRegion==NULL)
00712         return;
00713     if (GridState==1)
00714         RenderGrid(pRegion);
00715 
00716     RenderVanishingPoints(pRegion);
00717 #endif
00718 }

void MouldPerspective::RenderDragBlobs Spread pSpread  )  [virtual]
 

Draw on the perspective grid points on if they are supposed to be shown.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pRegion = pointer to a region to render into [INPUTS]

Reimplemented from MouldGeometry.

Definition at line 732 of file moldpers.cpp.

00733 {
00734 #if !defined(EXCLUDE_FROM_RALPH)
00735     ERROR3IF(pSpread==NULL,"MouldPerspective::RenderControlBlobs passed a NULL spread");
00736     if (pSpread==NULL)
00737         return;
00738     if (GridState>0)
00739         RenderGrid(pSpread);
00740 
00741     RenderVanishingPoints(pSpread);
00742 #endif
00743 }

void MouldPerspective::RenderGrid RenderRegion pRegion  )  [private]
 

Draw on the perspective vanishing points if they intersect the current region.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pRegion = pointer to a region to render into [INPUTS]

Definition at line 783 of file moldpers.cpp.

00784 {
00785 #if !defined(EXCLUDE_FROM_RALPH)
00786     ERROR3IF(pRegion==NULL,"MouldPerspective::RenderBlobs() passed a NULL region");
00787     if (pRegion==NULL) return;
00788 
00789     // get the base class to render
00790     MouldGeometry::RenderControlBlobs(pRegion);
00791     // Now render any vanishing points
00792     pRegion->SetLineWidth(0);                               // Means single-pixel lines
00793     pRegion->SetLineColour(GREEN);
00794     pRegion->SetFillColour(GREEN);
00795     // now render the grid
00796     RenderGridPoints(pRegion);
00797 #endif
00798 }

void MouldPerspective::RenderGrid Spread pSpread  )  [private]
 

Draw on the perspective grid points on if they are supposed to be shown.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pSpread = pointer to a spread to render into [INPUTS]

Definition at line 756 of file moldpers.cpp.

00757 {
00758 #if !defined(EXCLUDE_FROM_RALPH)
00759     ERROR3IF(pSpread==NULL,"MouldPerspective::RenderGrid() passed a NULL spread");
00760     DocRect Rect = Perspective.GetBoundingRect();
00761     RenderRegion* pRegion = DocView::RenderOnTop( &Rect, pSpread, ClippedEOR );
00762     while ( pRegion )
00763     {
00764         RenderGrid(pRegion);
00765         pRegion = DocView::GetNextOnTop(NULL);
00766     }   
00767 #endif
00768 }

void MouldPerspective::RenderGridPoints RenderRegion pRegion  )  [private]
 

Draw all the prespective grid points on if they are supposed to be shown.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/01/95
Parameters:
pRegion = pointer to a region to render into [INPUTS]

Definition at line 813 of file moldpers.cpp.

00814 {
00815 #if !defined(EXCLUDE_FROM_RALPH)
00816     // We need to scan through the origin bounding rectangle, calculating
00817     // an MxN rectangle of points, transforming them all and rendering them to the region
00818 
00819     INT32 p0 = 8;
00820     INT32 p1 = 4*p0;
00821     INT32 a,b,x,y;
00822     POINT sU,dU;
00823     DocCoord pU;
00824     RECT Bounds = Perspective.GetSourceBBox();
00825     INT32 dX = Bounds.right - Bounds.left;
00826     INT32 dY = Bounds.top - Bounds.bottom;
00827 
00828     for (a=1; a<p0; a++)
00829     {
00830         x = Bounds.left + a*dX/p0;
00831         y = Bounds.bottom + a*dY/p0;
00832 
00833         for (b=1; b<p1; b++)
00834         {
00835             if (b % (p1/p0))
00836             {
00837                 sU.x = Bounds.left + b*dX/p1;
00838                 sU.y = y;
00839                 Perspective.FitPoint(sU,dU);
00840                 pU.x = dU.x;
00841                 pU.y = dU.y;
00842                 pRegion->DrawPixel(pU); 
00843             }
00844 
00845             sU.x = x;
00846             sU.y = Bounds.bottom + b*dY/p1;
00847             Perspective.FitPoint(sU,dU);
00848             pU.x = dU.x;
00849             pU.y = dU.y;
00850             pRegion->DrawPixel(pU);
00851         }
00852     }
00853 #endif
00854 }

void MouldPerspective::RenderVanishingPoint Spread pSpread,
const DocCoord dcPos
[private]
 

Draws a particular prespective vanishing point on.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
dcPos = a doc coord at which to display the vanish point [INPUTS]

Definition at line 891 of file moldpers.cpp.

00892 {
00893 #if !defined(EXCLUDE_FROM_RALPH)
00894     DocRect Rect;
00895     if (dcPos.x!=PER_UNDEFINED)
00896     {
00897         Rect=CalcBlobClipRect(dcPos);
00898         RenderRegion* pRegion = DocView::RenderOnTop(&Rect, pSpread, ClippedEOR );
00899         while ( pRegion )
00900         {
00901             pRegion->SetLineColour(COLOUR_XORSELECT);
00902 PORTNOTE("other", "DrawBitmapBlob removed");
00903 //          pRegion->DrawBitmapBlob(dcPos, _R(IDBMP_HANDLE_CENTRE));
00904             pRegion = DocView::GetNextOnTop(NULL);
00905         }   
00906     }
00907 #endif
00908 }

void MouldPerspective::RenderVanishingPoints RenderRegion pRegion  )  [private]
 

Draws the prespective vanishing points on.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
pRegion = pointer to a region to render into [INPUTS]

Definition at line 921 of file moldpers.cpp.

00922 {
00923 #if !defined(EXCLUDE_FROM_RALPH)
00924     pRegion->SetLineColour(COLOUR_XORSELECT);
00925 
00926     // first read the vanishing point positions
00927     DocCoord v0,v1;
00928     GetVanishingPoints(v0,v1);
00929 
00930 PORTNOTE("other", "DrawBitmapBlob removed");
00931 //  if (v0.x!=PER_UNDEFINED)
00932 //      pRegion->DrawBitmapBlob(v0, _R(IDBMP_HANDLE_CENTRE));
00933 //  if (v1.x!=PER_UNDEFINED)
00934 //      pRegion->DrawBitmapBlob(v1, _R(IDBMP_HANDLE_CENTRE));
00935 #endif
00936 }

void MouldPerspective::RenderVanishingPoints Spread pSpread  )  [private]
 

Draw on the perspective vanishing points on.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
pSpread = pointer to a spread to render into [INPUTS]

Definition at line 868 of file moldpers.cpp.

00869 {
00870 #if !defined(EXCLUDE_FROM_RALPH)
00871     ERROR3IF(pSpread==NULL,"MouldPerspective::RenderVanishingPoints() passed a NULL spread");
00872     DocCoord v0,v1;
00873     GetVanishingPoints(v0,v1);
00874     RenderVanishingPoint(pSpread,v0);
00875     RenderVanishingPoint(pSpread,v1);
00876 #endif
00877 }

void MouldPerspective::ShowVPoints  )  [private]
 

Definition at line 939 of file moldpers.cpp.

00940 {
00941     DocCoord v0,v1;
00942     GetVanishingPoints(v0,v1);
00943     // TRACEUSER( "Mike", _T("V0=(%d,%d)\n"),v0.x,v0.y);
00944     // TRACEUSER( "Mike", _T("V1=(%d,%d)\n"),v1.x,v1.y);
00945 }

void MouldPerspective::ToggleControlBlobs Spread pSpread  )  [virtual]
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pSpread = pointer to a spread to render into [INPUTS]

Reimplemented from MouldGeometry.

Definition at line 664 of file moldpers.cpp.

00665 {
00666     // if we're in a suspended state do nothing!
00667     if (GridState>1) return;
00668     // toggle the grid state.
00669     GridState ^= 1;
00670     if (pSpread!=NULL)
00671         RenderGrid(pSpread);
00672 }

void MouldPerspective::Transform Path *const   pNewGeom,
DocRect *const   pRect,
TransformBase Trans
[virtual]
 

As the actual perspective mould shape is a nodepath inside the mould parent which this mouldperspecitive object is associated with, the path is passed into this function whenever the mould parent receives a transform call. The path has already been transformed so all we need to do here is update the low level perspective bits.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
pNewGeom = a new mould shape to use. [INPUTS] Trans = The transform to be applied.

Reimplemented from MouldGeometry.

Definition at line 1403 of file moldpers.cpp.

01406 {
01407     // transform the blob origins, vanishing points etc
01408     Define(pNewGeom,pRect);
01409 }

BOOL MouldPerspective::Validate Path *const   pPath,
UINT32 errorID
[virtual]
 

This function checks whether the path given is suitabile for use as an perspective manifold. Valid paths at present are any set of 5 path elements starting with a moveto followed by 4 lineto elements which form a closed loop without crossings.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/02/95
Parameters:
pPath = the path to use for perspectivising [INPUTS]
errorID = an id of an error string reporting the problem when failed. [OUTPUTS]
Returns:
TRUE - then the path can be used as an perspective manifold FALSE - then the path is not suitable for use as an perspective manifold

Reimplemented from MouldGeometry.

Definition at line 185 of file moldpers.cpp.

00186 {
00187     // check for a reasonable number of coordinates
00188     INT32 numc=pPath->GetNumCoords();
00189     if ((numc!=PER_NUMCOORDS+1))
00190     {
00191         errorID = _R(IDE_PERS_NUMCOORDERR);
00192         return FALSE;
00193     }
00194 
00195     // now we need a more complex check
00196     DocCoord* Coords = pPath->GetCoordArray();
00197     PathVerb* Verbs = pPath->GetVerbArray();
00198 
00199     // we need the first element to be a move to
00200     if (Verbs[0]!=PT_MOVETO)
00201     {
00202         errorID = _R(IDE_PERS_BADELEMENT);
00203         return FALSE;
00204     }
00205 
00206     // And the last coordinate must close the loop
00207     if (Coords[0]!=Coords[numc-1])
00208     {
00209         errorID = _R(IDE_PERS_NOTCLOSED);
00210         return FALSE;
00211     }
00212 
00213     INT32 i,j;
00214     // followed by all linetos
00215     for (i=1; i<numc; i++)
00216     {
00217         if ( (Verbs[i] & (~PT_CLOSEFIGURE))!=PT_LINETO )
00218         {
00219             errorID = _R(IDE_PERS_NOTALLLINES);
00220             return FALSE;
00221         }
00222     }
00223 
00224     // check no coordinates are the same
00225     for (i=1; i<numc; i++)
00226     {
00227         for (j=i+1; j<numc; j++)
00228         {
00229             if (Coords[i] == Coords[j])
00230             {
00231                 errorID = _R(IDE_PERS_COINCIDENT);
00232                 return FALSE;
00233             }
00234         }
00235     }
00236 
00237     // Make sure there's no folds either
00238     POINT* p = (POINT*)(Coords);
00239     if (!WillBeValid(p))
00240     {
00241         errorID = _R(IDE_PERS_CROSSING);
00242         return FALSE;
00243     }
00244 
00245     // All is well
00246     return TRUE;
00247 }

BOOL MouldPerspective::WillBeValid POINT P  )  [static]
 

Check whether the point array has any crossing and is thus unsuited for use as a manifold.

BOOL MouldPerspective::WillBeValid(POINT* P)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
P a pointer to a POINT array of coordinates [INPUTS]
Returns:
TRUE if the point set is valid

Definition at line 263 of file moldpers.cpp.

00264 {
00265     INT32 MinX, MaxX, MinY, MaxY, Width, Depth ;
00266     DPOINT V0,V1,V2,V3;
00267 
00268     MinX = MaxX = P[0].x ;
00269     MinY = MaxY = P[0].y ;
00270     MinX = min( MinX, INT32(P[1].x) ) ; MaxX = max( MaxX, INT32(P[1].x) ) ;
00271     MinY = min( MinY, INT32(P[1].y) ) ; MaxY = max( MaxY, INT32(P[1].y) ) ;
00272     MinX = min( MinX, INT32(P[2].x) ) ; MaxX = max( MaxX, INT32(P[2].x) ) ;
00273     MinY = min( MinY, INT32(P[2].y) ) ; MaxY = max( MaxY, INT32(P[2].y) ) ;
00274     MinX = min( MinX, INT32(P[3].x) ) ; MaxX = max( MaxX, INT32(P[3].x) ) ;
00275     MinY = min( MinY, INT32(P[3].y) ) ; MaxY = max( MaxY, INT32(P[3].y) ) ;
00276     Width = MaxX-MinX ;
00277     Depth = MaxY-MinY ;
00278 
00279     if (Width==0 || Depth==0)
00280         return FALSE;
00281 
00282     V0.x = (double)(P[0].x-MinX)/Width ;
00283     V0.y = (double)(P[0].y-MinY)/Depth ;
00284     V1.x = (double)(P[1].x-MinX)/Width ;
00285     V1.y = (double)(P[1].y-MinY)/Depth ;
00286     V2.x = (double)(P[2].x-MinX)/Width ;
00287     V2.y = (double)(P[2].y-MinY)/Depth ;
00288     V3.x = (double)(P[3].x-MinX)/Width ;
00289     V3.y = (double)(P[3].y-MinY)/Depth ;
00290 
00291     BOOL F  =  (V1.x-V0.x)*(V3.y-V0.y) > (V1.y-V0.y)*(V3.x-V0.x) ;
00292     if ( F != ((V2.x-V1.x)*(V0.y-V1.y) > (V2.y-V1.y)*(V0.x-V1.x)) ) return FALSE ;
00293     if ( F != ((V3.x-V2.x)*(V1.y-V2.y) > (V3.y-V2.y)*(V1.x-V2.x)) ) return FALSE ;
00294     if ( F != ((V0.x-V3.x)*(V2.y-V3.y) > (V0.y-V3.y)*(V2.x-V3.x)) ) return FALSE ;
00295 
00296     return TRUE;
00297 }


Friends And Related Function Documentation

friend class RecordPerspectiveAction [friend]
 

Definition at line 184 of file moldpers.h.


Member Data Documentation

INT32 MouldPerspective::GridState [private]
 

Definition at line 248 of file moldpers.h.

GPerspective MouldPerspective::Perspective [private]
 

Definition at line 249 of file moldpers.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:19 2007 for Camelot by  doxygen 1.4.4