MouldEnvelopeBase Class Reference

The envelope mould node. Provides control over a coons patch shape made from 4 connected 3rd order bezier splines. More...

#include <moldenv.h>

Inheritance diagram for MouldEnvelopeBase:

MouldGeometry CCObject SimpleCCObject MouldEnvelope MouldEnvelope2x2 List of all members.

Public Member Functions

 MouldEnvelopeBase ()
 EnvelopeBase mould constructor.
 ~MouldEnvelopeBase ()
 EnvelopeBase mould destructor.
virtual void RenderControlBlobs (RenderRegion *pRegion)
 Draw on the envelope grid points on if they are supposed to be shown.
virtual void RenderDragBlobs (Spread *pSpread)
 Draw on the envelope grid points on if they are supposed to be shown.
virtual void DisableControlBlobs ()
virtual void EnableControlBlobs ()
 Used when an envelope is undergoing a drag, we disable normal blob rendering.
virtual void ToggleControlBlobs (Spread *pSpread)
virtual BOOL MouldPathToPath (Path *pSourcePath, Path *PDestinPath)
 Using the defined envelope, this function takes the input path shape and generates a moulded output path. The output path may contain data on entry to this routine, the enveloped path will simply be added to the end of the data already there. If the input path is closed, the output path will be closed likewise.
virtual BOOL MouldBitmapToTile (KernelBitmap *pSourceBlit, KernelBitmap *pDestinBlit)
 Create an enveloped version of a bitmap, ready to be rendered to a device.
virtual BOOL MouldPoint (DocCoord p, DocCoord &q)
 Using the defined envelope, this function takes the input coordinate and calculates its transformed version.
virtual void MouldPathRender (Path *pPath, Spread *pSpread)
virtual void MouldBitmapRender (KernelBitmap *pBlit, DocCoord *pParallel, RenderRegion *pRegion)
virtual DocRect GetSourceRect ()
 Return the current definition of the mould envelope source rectangle.

Protected Member Functions

BOOL Define (Path *const pPath, DocRect *const pOrigBBox, INT32 ncoords)
 This function sets the low level envelope state ready for calls to various envelope path generation functions. It serves simply as a way of informing the low level enveloper of the shape of the current envelope.
RECT BuildRectangle (DocRect *const pOrigBBox)
 Build a RECT structure to pass to the low level envelope code.
BOOL BuildShape (POINT *pPoints, DocRect *const pOrigBBox)
BOOL ConvertShape (INT32 ncoords, POINT *dPoints, Path *const pPath, const INT32 numcoords)
 Converts a path into a shape suitable for use as a mould. This function can be used in two contexts, dependent on the value of dPoints. If this is NULL on entry, an output path will be calculated but not stored in the output buffer (obvoiusly). You could then use the return value of the function for input path validation ie if the function returns false to this type of call you can assume the input path is not valid ie cannot be converted. You could assume this of course whatever dPoints is set to but it gives you the ability to first try to convert the path and then allocate space for the output if you so wish.
void RenderGrid (Spread *pSpread)
 Draw on the envelope grid points on if they are supposed to be shown.
void RenderGrid (RenderRegion *pRegion)
 Draw on the envelope grid points on if they are supposed to be shown.
void RenderGridPoints (RenderRegion *pRegion)
 Draw on the envelope grid points on if they are supposed to be shown.
BOOL ValidMouldingPath (INT32 ncoords, INT32 nelements, Path *const pPath, UINT32 &errorID)
 Check to see whether a mould path is suitable for use.

Static Protected Member Functions

static BOOL WillBeValid (INT32 ncoords, POINT *P)
 Check whether the point array suited for use as a manifold.

Protected Attributes

GMouldpEnvelope

Private Member Functions

 CC_DECLARE_DYNAMIC (MouldEnvelopeBase)

Private Attributes

INT32 BlobState

Friends

class RecordEnvelopeAction

Detailed Description

The envelope mould node. Provides control over a coons patch shape made from 4 connected 3rd order bezier splines.

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

Definition at line 123 of file moldenv.h.


Constructor & Destructor Documentation

MouldEnvelopeBase::MouldEnvelopeBase  ) 
 

EnvelopeBase mould constructor.

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

Definition at line 140 of file moldenv.cpp.

00141 {
00142     BlobState = 0;
00143     pEnvelope = NULL;
00144 }

MouldEnvelopeBase::~MouldEnvelopeBase  ) 
 

EnvelopeBase mould destructor.

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

Definition at line 158 of file moldenv.cpp.

00159 {
00160     if (pEnvelope!=NULL)
00161     {
00162         delete pEnvelope;
00163         pEnvelope=NULL;
00164     }
00165 }


Member Function Documentation

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

Build a RECT structure to pass to the low level envelope 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 enveloped [INPUTS] = NULL then the old bounding box will be assumed.
Returns:
a RECT structure.

Definition at line 352 of file moldenv.cpp.

00353 {
00354     ERROR3IF(pEnvelope==NULL,"MouldEnvelopeBase::BuildRectangle() - pEnvelope is NULL!");
00355     RECT ObjRect;
00356 
00357     if (pOrigBBox!=NULL)
00358     {
00359         // set up the low level envelope data.
00360         ObjRect.left    = pOrigBBox->lo.x;
00361         ObjRect.bottom  = pOrigBBox->lo.y;
00362         ObjRect.right   = pOrigBBox->hi.x;
00363         ObjRect.top     = pOrigBBox->hi.y;
00364     }
00365     else
00366         ObjRect = pEnvelope->GetSourceBBox();
00367 
00368     return ObjRect;
00369 }

BOOL MouldEnvelopeBase::BuildShape POINT pPoints,
DocRect *const   pOrigBBox
[protected]
 

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 enveloped = 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 321 of file moldenv.cpp.

00322 {
00323     ERROR2IF(pPoints==NULL,FALSE,"MouldEnvelopeBase::BuildShape() called with NULL point list");
00324     ERROR3IF(pEnvelope==NULL,"MouldEnvelopeBase::BuildShape() - pEnvelope is NULL!");
00325 
00326     if (pOrigBBox!=NULL)
00327     {
00328         if (pOrigBBox->IsEmpty())
00329             return FALSE;
00330         if (!pOrigBBox->IsValid())
00331             return FALSE;
00332     }
00333 
00334     RECT ObjRect = BuildRectangle(pOrigBBox);
00335     return pEnvelope->Define(pPoints,&ObjRect,MouldThreshold);
00336 }

MouldEnvelopeBase::CC_DECLARE_DYNAMIC MouldEnvelopeBase   )  [private]
 

BOOL MouldEnvelopeBase::ConvertShape INT32  ncoords,
POINT dPoints,
Path *const   pPath,
const INT32  numcoords
[protected]
 

Converts a path into a shape suitable for use as a mould. This function can be used in two contexts, dependent on the value of dPoints. If this is NULL on entry, an output path will be calculated but not stored in the output buffer (obvoiusly). You could then use the return value of the function for input path validation ie if the function returns false to this type of call you can assume the input path is not valid ie cannot be converted. You could assume this of course whatever dPoints is set to but it gives you the ability to first try to convert the path and then allocate space for the output if you so wish.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/12/94
Parameters:
ncoords = number of output coordinates in this mould [INPUTS] dPoints = array of points to hold the calculated coordinates pPath = the path to use for enveloping numcoords = the number of coordinaties in pPath
dPoints = the destination point set. [OUTPUTS] returns: TRUE - then the shape has been converted. FALSE - then this convert has failed.

Definition at line 807 of file moldenv.cpp.

00808 {
00809     POINT* sPoints = (POINT*)pPath->GetCoordArray();
00810     PathVerb* sVerbs = pPath->GetVerbArray();
00811 
00812     INT32 out=(ncoords+1);
00813     INT32 i=0; 
00814     INT32 j=0;
00815 
00816     while ((i<numcoords) && (out>0))
00817     {
00818         switch ((sVerbs[i] & ~PT_CLOSEFIGURE))
00819         {
00820             case PT_MOVETO:
00821             case PT_BEZIERTO:
00822                 out--;
00823                 if (out>=0)
00824                 {
00825                     if (dPoints)
00826                     {
00827                         dPoints[j].x=sPoints[i].x;
00828                         dPoints[j].y=sPoints[i].y;
00829                     }
00830                     i++; j++;
00831                 }
00832                 break;
00833 
00834             case PT_LINETO:
00835                 out-=3;
00836                 if (out>=0)
00837                 {
00838                     if (dPoints)
00839                     {
00840                         dPoints[j+0].x = (2*sPoints[i-1].x + sPoints[i].x)/3;
00841                         dPoints[j+0].y = (2*sPoints[i-1].y + sPoints[i].y)/3;
00842                         dPoints[j+1].x = (sPoints[i-1].x + 2*sPoints[i].x)/3;
00843                         dPoints[j+1].y = (sPoints[i-1].y + 2*sPoints[i].y)/3;
00844                         dPoints[j+2].x = sPoints[i].x;
00845                         dPoints[j+2].y = sPoints[i].y;
00846                     }
00847                     i++; j+=3; 
00848                 }
00849                 break;
00850             default:
00851                 return FALSE;
00852                 break;
00853         }
00854     }
00855     return (out==0);
00856 }

BOOL MouldEnvelopeBase::Define Path *const   pPath,
DocRect *const   pOrigBBox,
INT32  ncoords
[protected]
 

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

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

Definition at line 285 of file moldenv.cpp.

00286 {
00287     ERROR2IF(pPath==NULL,FALSE,"MouldEnvelopeBase::Define() called with NULL path");
00288     ERROR2IF(ncoords>ENV_MAXCOORDS, FALSE, "MouldEnvelopeBase::Define() - ncoords too large");
00289     INT32 numc = pPath->GetNumCoords();
00290 
00291     POINT* pPoints = (POINT*)pPath->GetCoordArray();
00292     POINT  qPoints[ENV_MAXCOORDS+1];
00293     POINT* rPoints = pPoints;
00294 
00295     if (numc<(ncoords+1))
00296     {
00297         if (!ConvertShape(ncoords,qPoints,pPath,numc))
00298             return FALSE;
00299         rPoints = qPoints;
00300     }
00301 
00302     return BuildShape(rPoints,pOrigBBox);
00303 }

void MouldEnvelopeBase::DisableControlBlobs  )  [virtual]
 

Reimplemented from MouldGeometry.

Definition at line 412 of file moldenv.cpp.

00413 {
00414     if (BlobState>0) BlobState++;
00415 }

void MouldEnvelopeBase::EnableControlBlobs  )  [virtual]
 

Used when an envelope 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 407 of file moldenv.cpp.

00408 {
00409     if (BlobState>1) BlobState--;
00410 }

DocRect MouldEnvelopeBase::GetSourceRect  )  [virtual]
 

Return the current definition of the mould envelope 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 579 of file moldenv.cpp.

00580 { 
00581     ERROR3IF(pEnvelope==NULL,"MouldEnvelopeBase::GetSourceRect() - pEnvelope is NULL!");
00582 
00583     RECT Rect = pEnvelope->GetSourceBBox();
00584     return ConvRectToDocRect(Rect);
00585 }

void MouldEnvelopeBase::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 892 of file moldenv.cpp.

00895 {
00896     pRegion->SaveContext();
00897 
00898     // No lines on the rectangle
00899     pRegion->SetLineColour(COLOUR_TRANS);
00900 
00901     pRegion->RestoreContext();
00902 
00903 }

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

Create an enveloped 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 envelope [INPUTS] pDestinBlit = pointer to an output tile to mould into
pDestinBlit = enveloped 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 775 of file moldenv.cpp.

00776 {
00777     // currently not implemented
00778     return FALSE;
00779 }

void MouldEnvelopeBase::MouldPathRender Path pPath,
Spread pSpread
[virtual]
 

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

Definition at line 870 of file moldenv.cpp.

00871 {
00872 }

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

Using the defined envelope, this function takes the input path shape and generates a moulded output path. The output path may contain data on entry to this routine, the enveloped path will simply be added to the end of the data already there. If the input path is closed, the output path will be closed likewise.

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 this should be at least an initialise path.
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 609 of file moldenv.cpp.

00610 {
00611     ERROR2IF(pSourcePath==NULL, FALSE, "MouldEnvelopeBase::MouldPathToPath() passed a NULL source pointer");
00612     ERROR2IF(pDestinPath==NULL, FALSE, "MouldEnvelopeBase::MouldPathToPath() passed a NULL destin pointer");
00613 
00614     // get the source path data length
00615     DWORD ilength = (DWORD)pSourcePath->GetNumCoords();
00616 
00617     // if there's no input path, then there's no output path, and all is well.
00618     if (ilength<1)
00619         return TRUE;
00620 
00621     INT32 freespace = ilength*4;
00622     INT32 maxspace = ilength*16;
00623     BOOL ok;
00624     INT32 added;
00625 
00626     Path TempPath;
00627     if (!TempPath.Initialise(freespace,24))
00628         return FALSE;
00629 
00630     do
00631     {
00632         // get the source object and destin object path data
00633         POINT* icoords = (POINT*)pSourcePath->GetCoordArray();
00634         BYTE*  iverbs  = (BYTE*)pSourcePath->GetVerbArray();
00635         POINT* ocoords = (POINT*)TempPath.GetCoordArray();
00636         BYTE*  overbs  = (BYTE*)TempPath.GetVerbArray();
00637 
00638         // try to create an enveloped path
00639         added = pEnvelope->FitPath(icoords,iverbs,ilength,ocoords,overbs,freespace,FALSE);
00640 
00641         if (added==-1)
00642         {
00643             freespace*=2;
00644             // create what we think will be enough space for the output path
00645             ok = TempPath.EnsureVolume(freespace);
00646             if (!ok) 
00647                 return FALSE;
00648         }
00649 
00650     } while ((added==-1) && freespace<=maxspace);
00651 
00652     // if we've failed to create the enveloped object then tidy up
00653     if (added<=1)
00654         return FALSE;
00655 
00656     // now lets set up the new flags array
00657     ok = TempPath.ExternalArraysReplaced(added);
00658     if (ok)
00659         TempPath.InitialiseFlags(0,added);
00660 
00661     if (ok)
00662     {
00663 /*
00664         // Ok check for rampant null elements in this path
00665         DocCoord* Coords;
00666         PathVerb* Verbs;
00667         PathFlags* Flags;
00668         PathVerb CurVerb;
00669         INT32 i,lmi;
00670         DocCoord lm;
00671 
00672         TempPath.GetPathArrays(&Verbs,&Coords,&Flags);
00673 
00674         for (i=0; i<added; i++)
00675         {
00676             CurVerb = Verbs[i] & ~PT_CLOSEFIGURE;
00677             if (CurVerb==PT_MOVETO)
00678             {
00679                 lm=Coords[i];
00680                 lmi=i;
00681             }
00682 
00683             if (CurVerb==PT_BEZIERTO)
00684             {
00685                 if (Verbs[i+2] & PT_CLOSEFIGURE)
00686                 {
00687                     DocCoord p0,p1,p2;
00688                     p0 = Coords[i];
00689                     p1 = Coords[i+1];
00690                     p2 = Coords[i+2];
00691                     if ((p0.x==p1.x) && (p1.x==p2.x) && (p2.x==lm.x) &&
00692                         (p0.y==p1.y) && (p1.y==p2.y) && (p2.y==lm.y) && 
00693                         (i-lmi)>1)
00694                     {
00695                         // We can delete this element!
00696                         Verbs[i-1] |= PT_CLOSEFIGURE;
00697                         if (TempPath.DeleteSection(i,3))
00698                         {
00699                             added-=3;
00700                             i-=3;
00701                         }
00702                         else
00703                             i=added;
00704                     }
00705                 }
00706                 i+=2;
00707             }
00708         }
00709 */
00710 
00711         ok = pDestinPath->CloneFrom(TempPath);
00712     }
00713     return ok;
00714 }

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

Using the defined envelope, 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 732 of file moldenv.cpp.

00733 {
00734     // I aught to check that the point as contained within the source rectangle
00735     // bbox and do something about it if not. But what to do?
00736 
00737     RECT rect = pEnvelope->GetSourceBBox();
00738 
00739     if  ((p.x<rect.left) || (p.x>rect.right) ||
00740         (p.y<rect.bottom) || (p.y>rect.top))
00741     {
00742         q=p;
00743         return FALSE;
00744     }
00745 
00746     POINT r,s;
00747 
00748     r.x = p.x;
00749     r.y = p.y;
00750 
00751     pEnvelope->FitPoint(r,s);
00752 
00753     q.x = s.x;
00754     q.y = s.y;
00755 
00756     return TRUE;
00757 }

void MouldEnvelopeBase::RenderControlBlobs RenderRegion pRegion  )  [virtual]
 

Draw on the envelope 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 429 of file moldenv.cpp.

00430 {
00431     ERROR3IF(pRegion==NULL,"MouldEnvelopeBase::RenderControlBlobs passed a NULL region");
00432     if (pRegion==NULL) return;
00433     if (BlobState!=1) return;
00434 
00435     RenderGrid(pRegion);
00436 }

void MouldEnvelopeBase::RenderDragBlobs Spread pSpread  )  [virtual]
 

Draw on the envelope 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 450 of file moldenv.cpp.

00451 {
00452     ERROR3IF(pSpread==NULL,"MouldEnvelopeBase::RenderDragBlobs passed a NULL spread");
00453     if (pSpread==NULL) return;
00454     if (BlobState<1) return;
00455 
00456     RenderGrid(pSpread);
00457 }

void MouldEnvelopeBase::RenderGrid RenderRegion pRegion  )  [protected]
 

Draw on the envelope 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]

Definition at line 495 of file moldenv.cpp.

00496 {
00497     ERROR3IF(pRegion==NULL,"MouldEnvelopeBase::RenderControlBlobs() passed a NULL region");
00498     if (pRegion==NULL) return;
00499 
00500     // get the base class to render
00501     MouldGeometry::RenderControlBlobs(pRegion);
00502     // set the colour of our outline
00503     pRegion->SetLineWidth(0);                               // Means single-pixel lines
00504     pRegion->SetLineColour(COLOUR_XOREDIT);
00505     pRegion->SetFillColour(COLOUR_XOREDIT);
00506     // now render the grid
00507     RenderGridPoints(pRegion);
00508 }

void MouldEnvelopeBase::RenderGrid Spread pSpread  )  [protected]
 

Draw on the envelope 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 471 of file moldenv.cpp.

00472 {
00473     ERROR3IF(pEnvelope==NULL,"MouldEnvelopeBase::RenderGrid - no envelope pointer");
00474     DocRect Rect = pEnvelope->GetBoundingRect();
00475     RenderRegion* pRegion = DocView::RenderOnTop( &Rect, pSpread, ClippedEOR );
00476     while ( pRegion )
00477     {
00478         RenderGrid(pRegion);
00479         pRegion = DocView::GetNextOnTop(NULL);
00480     }   
00481 }

void MouldEnvelopeBase::RenderGridPoints RenderRegion pRegion  )  [protected]
 

Draw on the envelope 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 522 of file moldenv.cpp.

00523 {
00524     // We need to scan through the origin bounding rectangle, calculating
00525     // an MxN rectangle of points, transforming them all and rendering them to the region
00526 
00527     ERROR3IF(pEnvelope==NULL,"MouldEnvelopeBase::RenderGridPoints() - pEnvelope is NULL!");
00528 
00529     INT32 p0 = 8;
00530     INT32 p1 = 4*p0;
00531     INT32 a,b,x,y;
00532     POINT sU,dU;
00533     DocCoord pU;
00534     RECT Bounds = pEnvelope->GetSourceBBox();
00535     INT32 dX = Bounds.right - Bounds.left;
00536     INT32 dY = Bounds.top - Bounds.bottom;
00537 
00538     for (a=1; a<p0; a++)
00539     {
00540         x = Bounds.left + a*dX/p0;
00541         y = Bounds.bottom + a*dY/p0;
00542 
00543         for (b=1; b<p1; b++)
00544         {
00545             if (b % (p1/p0))
00546             {
00547                 sU.x = Bounds.left + b*dX/p1;
00548                 sU.y = y;
00549                 pEnvelope->FitPoint(sU,dU);
00550                 pU.x = dU.x;
00551                 pU.y = dU.y;
00552                 pRegion->DrawPixel(pU);
00553             }
00554 
00555             sU.x = x;
00556             sU.y = Bounds.bottom + b*dY/p1;
00557             pEnvelope->FitPoint(sU,dU);
00558             pU.x = dU.x;
00559             pU.y = dU.y;
00560             pRegion->DrawPixel(pU);
00561         }
00562     }
00563 }

void MouldEnvelopeBase::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 385 of file moldenv.cpp.

00386 {
00387     // if we're in a suspended state do nothing!
00388     if (BlobState>1) return;
00389     // toggle the grid state.
00390     BlobState ^= 1;
00391 
00392     if (pSpread!=NULL)
00393         RenderGrid(pSpread);
00394 }

BOOL MouldEnvelopeBase::ValidMouldingPath INT32  ncoords,
INT32  nelements,
Path *const   pPath,
UINT32 errorID
[protected]
 

Check to see whether a mould path is suitable for use.

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

Definition at line 179 of file moldenv.cpp.

00180 {
00181     // now we need a more complex check
00182     DocCoord* Coords = pPath->GetCoordArray();
00183     PathVerb* Verbs = pPath->GetVerbArray();
00184 
00185     // we need the first element to be a move to
00186     if (Verbs[0]!=PT_MOVETO)
00187     {
00188         errorID = _R(IDE_ENV_BADELEMENT);
00189         return FALSE;
00190     }
00191 
00192     // followed by either lineto or bezierto els
00193     INT32 nume=0;
00194     PathVerb V;
00195 
00196     for (INT32 i=1; i<ncoords; i++)
00197     {
00198         V = Verbs[i] & (~PT_CLOSEFIGURE);
00199         switch (V)
00200         {
00201             case PT_LINETO:
00202                 nume+=1;
00203                 break;
00204             case PT_BEZIERTO:
00205                 nume+=1; i+=2;
00206                 break;
00207             default:
00208                 errorID = _R(IDE_ENV_NUMCOORDERR);
00209                 return FALSE;
00210                 break;
00211         }
00212         if (nume>nelements)
00213         {
00214             errorID = _R(IDE_ENV_NUMCOORDERR);
00215             return FALSE;
00216         }
00217     }
00218 
00219     // And the last coordinate must close the loop
00220     if (Coords[0]!=Coords[ncoords-1])
00221     {
00222         errorID = _R(IDE_ENV_NOTCLOSED);
00223         return FALSE;
00224     }
00225 
00226     return TRUE;
00227 }

BOOL MouldEnvelopeBase::WillBeValid INT32  ncoords,
POINT P
[static, protected]
 

Check whether the point array suited for use as a manifold.

static BOOL MouldEnvelopeBase::WillBeValid(INT32 ncoords, POINT* P)

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

Definition at line 243 of file moldenv.cpp.

00244 {
00245     INT32 MinX, MaxX, MinY, MaxY, Width, Depth ;
00246 
00247     MinX = MaxX = P[0].x ;
00248     MinY = MaxY = P[0].y ;
00249 
00250     for (INT32 i=1; i<ncoords; i++)
00251     {
00252         MinX = min( MinX, INT32(P[i].x) );
00253         MaxX = max( MaxX, INT32(P[i].x) );
00254         MinY = min( MinY, INT32(P[i].y) );
00255         MaxY = max( MaxY, INT32(P[i].y) );
00256     }
00257 
00258     Width = MaxX-MinX ;
00259     Depth = MaxY-MinY ;
00260 
00261     if (Width==0 || Depth==0)
00262         return FALSE;
00263 
00264     return TRUE;
00265 }


Friends And Related Function Documentation

friend class RecordEnvelopeAction [friend]
 

Definition at line 125 of file moldenv.h.


Member Data Documentation

INT32 MouldEnvelopeBase::BlobState [private]
 

Definition at line 168 of file moldenv.h.

GMould* MouldEnvelopeBase::pEnvelope [protected]
 

Definition at line 165 of file moldenv.h.


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