opgrad.cpp File Reference

(r1785/r1282)

#include "camtypes.h"
#include "opgrad.h"
#include "filltool.h"
#include "lineattr.h"
#include "blobs.h"
#include "toollist.h"
#include "bitmpinf.h"
#include "progress.h"
#include "ndoptmz.h"
#include "csrstack.h"
#include "objchge.h"
#include "keypress.h"
#include "nodeblnd.h"
#include "fillramp.h"
#include "nodecont.h"

Go to the source code of this file.

Defines

#define new   CAM_DEBUG_NEW

Functions

void MakeMeshArrow (Path *ArrowPath, DocCoord &Start, DocCoord &End, DocCoord *LineEnd)
 Makes an Arrow for the Fill Mesh. This is a Tempory Function, used until ArrowHeads work properly.
void MakeMeshDottedLine (Path *ArrowPath, DocCoord &Start, DocCoord &End)
 Makes a Dotted Line for the Fill Mesh. This is a Tempory Function, used until Stroke Providers work properly.
void MakeMeshSemiCircle (Path *EllipsePath, DocCoord Start, DocCoord End, DocCoord ArrowPoint)
 Make a Semi-Circle for the Conical Fill Mesh.
DocRect GetMeshSemiCircleBounds (DocCoord Start, DocCoord End, DocCoord EndPoint)
 Gets the Bounding rect of the Conical Fill Mesh.
void MakeMeshEllipse (Path *EllipsePath, DocCoord Start, DocCoord End, DocCoord End2)
 Makes an Elliptical Fill Mesh.
void CalcMeshEllipseEdge (const DocCoord &P0, const DocCoord &P1, DocCoord *NewCoordA, DocCoord *NewCoordB, DocCoord *NewCoordC)
 Used when making an Elliptical Fill Mesh.
DocRect GetMeshEllipseBounds (DocCoord Start, DocCoord End, DocCoord End2)
 Gets the Bounding rect of the Radial Fill Mesh.
void MakePerpendicularMeshLines (DocCoord Start, DocCoord End, DocRect Bounds, DocCoord *PointArray)
 Makes lines perpendicular to a fill line.
DocCoord MakeLineAtAngle (DocCoord Start, DocCoord End, ANGLE Offset, INT32 Length)
 Make a line at a givel angle to another line.
ANGLE CalcLineAngle (DocCoord Start, DocCoord End)
 Calculates the Angle of a Line. 0 is Straight Down.
DocCoord CentreOf (DocRect Rect)
 Calculates the centre of a rectangle.
void MakeMeshParallelagram (Path *ParaPath, DocCoord Start, DocCoord End, DocCoord End2)
 Makes a Parallelagram for the Bitmap fill mesh.
void GetMeshParallelagram (DocCoord Start, DocCoord End, DocCoord End2, DocCoord *P1, DocCoord *P2, DocCoord *P3, DocCoord *P4)
 Makes a Parallelagram for the Bitmap fill mesh. Not used any more.
DocRect GetParallelagramBounds (DocCoord Start, DocCoord End, DocCoord End2)
 Gets the Bounding rect of the Bitmap Fill Mesh.
void GetBitmapVirtualPoints (DocCoord Start, DocCoord End, DocCoord End2, DocCoord *P1, DocCoord *P2, DocCoord *P3)
 Calculates the Virtual points of a bitmap from the actual bitmap control points given.
void GetBitmapRealPoints (DocCoord Start, DocCoord End, DocCoord End2, DocCoord *P1, DocCoord *P2, DocCoord *P3)
 Calculates the Real Control points of a bitmap from the vitual points given.
void IncludeArrowHead (DocRect *Bounds, DocCoord Start, DocCoord End)
 Includes the Arrow head in the bounds calculations.
BOOL AreLinesPerpendicular (DocCoord *Start, DocCoord *End, DocCoord *End2)
 Tests to see if two fill control lines are perpendicular or not. Uses the 'Similar Triangles' method, but allows a 5 millipoint error.

Variables

static BOOL EditFinished = FALSE
static NodeRenderableInkpParentOfFill = NULL
static AttrFillGeometrypTheFill = NULL


Define Documentation

#define new   CAM_DEBUG_NEW
 

NOTE:

OpCreateFill is no longer used. OpEditFill, is now used for fill Creation and Editing.

Definition at line 155 of file opgrad.cpp.


Function Documentation

BOOL AreLinesPerpendicular DocCoord Start,
DocCoord End,
DocCoord End2
 

Tests to see if two fill control lines are perpendicular or not. Uses the 'Similar Triangles' method, but allows a 5 millipoint error.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3830 of file opgrad.cpp.

03831 {
03832     INT32 dx1 = (*End).x - (*Start).x;
03833     INT32 dy1 = (*End).y - (*Start).y;
03834 
03835     INT32 dx2 = (*End2).x - (*Start).x;
03836     INT32 dy2 = (*End2).y - (*Start).y;
03837 
03838     if ( (ABS(dx1 - dy2)) > 5 ) // Allow a few millipoints error
03839         return FALSE;
03840 
03841     if ( (ABS(dy1 + dx2)) > 5 ) // Allow a few millipoints error
03842         return FALSE;
03843     
03844     return TRUE;
03845 }

ANGLE CalcLineAngle DocCoord  Start,
DocCoord  End
 

Calculates the Angle of a Line. 0 is Straight Down.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3552 of file opgrad.cpp.

03553 {
03554     const INT32 dx = End.x - Start.x;
03555     const INT32 dy = End.y - Start.y;
03556 
03557     if ( (dy==0) && (dx==0) )
03558     {
03559         return 0;
03560     }
03561 
03562     double LineAngle=0;
03563 
03564     if ( (dx>=0) && (dy>=0) )
03565         LineAngle = PI - atan2( (double)dx, (double)dy );
03566     else if ( (dx<0) && (dy>=0) )
03567         LineAngle = -PI + atan2( (double)-dx, (double)dy );
03568     else if ( (dx<0) && (dy<0) )
03569         LineAngle = -atan2( (double)-dx, (double)-dy );
03570     else if ( (dx>=0) && (dy<0) )
03571         LineAngle = atan2( (double)dx, (double)-dy );
03572 
03573     return 360 * (LineAngle / (2*PI));  // Convert from radians to degrees
03574 }

void CalcMeshEllipseEdge const DocCoord P0,
const DocCoord P1,
DocCoord NewCoordA,
DocCoord NewCoordB,
DocCoord NewCoordC
 

Used when making an Elliptical Fill Mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3333 of file opgrad.cpp.

03335 {
03336 #if !defined(EXCLUDE_FROM_RALPH)
03337     // Do the maths. This is described in the document camelot\docs\ellipse.doc
03338     // Find the length of the first side (pythag)
03339     INT32 dx = P1.x - P0.x;
03340     INT32 dy = P1.y - P0.y;
03341     //double SideLength = sqrt(dx*dx + dy*dy);
03342     //ENSURE(SideLength!=0.0, "CalcMeshEllipseEdge was thinking of doing a div 0!");
03343 
03344     // This would be different if we were calculating a rounded rectangle
03345     //double ArcRadius = SideLength / 2.0;
03346     //double ControlDist = ArcRadius/(SideLength*2.2336);
03347     // This is equivalent to the above 2 lines, only less maths is needed
03348     // (ie none as the compiler should do it)
03349     double ControlDist = 1.0 / (2 * 2.2336);
03350 
03351     // Find the control point closest to P0
03352     NewCoordA->x = (INT32) (P0.x + (dx * ControlDist));
03353     NewCoordA->y = (INT32) (P0.y + (dy * ControlDist));
03354 
03355     // Find the mid point of the side, for the middle control point
03356     NewCoordB->x = (INT32) (P0.x + (dx / 2));
03357     NewCoordB->y = (INT32) (P0.y + (dy / 2));
03358 
03359     // Find the Control point closest to p1
03360     NewCoordC->x = (INT32) (P1.x - dx * ControlDist);
03361     NewCoordC->y = (INT32) (P1.y - dy * ControlDist);
03362 #endif
03363 }

DocCoord CentreOf DocRect  Rect  ) 
 

Calculates the centre of a rectangle.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3588 of file opgrad.cpp.

03589 {
03590     return DocCoord(Rect.lo.x + (Rect.Width()/2), Rect.lo.y + (Rect.Height()/2));
03591 }

void GetBitmapRealPoints DocCoord  Start,
DocCoord  End,
DocCoord  End2,
DocCoord P1,
DocCoord P2,
DocCoord P3
 

Calculates the Real Control points of a bitmap from the vitual points given.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3733 of file opgrad.cpp.

03735 {
03736 #if !defined(EXCLUDE_FROM_RALPH)
03737     INT32 dx1 = (End2 == DocCoord(0,0)) ? 0 : (End2.x - Start.x);
03738     INT32 dy1 = (End2 == DocCoord(0,0)) ? 0 : (End2.y - Start.y);
03739 
03740     INT32 dx2 = (End.x - Start.x);
03741     INT32 dy2 = (Start.y - End.y);
03742 
03743     if (P1 != NULL && (Start != DocCoord(0,0)))
03744         *P1 = DocCoord(Start.x - dx1 - dx2, Start.y - dy1 + dy2);
03745     if (P2 != NULL && (End != DocCoord(0,0)))
03746         *P2 = DocCoord(Start.x - dx1 + dx2, Start.y - dy1 - dy2);
03747     if (P3 != NULL && (End2 != DocCoord(0,0)))
03748         *P3 = DocCoord(Start.x + dx1 - dx2, Start.y + dy1 + dy2);
03749 #endif
03750 }

void GetBitmapVirtualPoints DocCoord  Start,
DocCoord  End,
DocCoord  End2,
DocCoord P1,
DocCoord P2,
DocCoord P3
 

Calculates the Virtual points of a bitmap from the actual bitmap control points given.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3701 of file opgrad.cpp.

03703 {
03704 #if !defined(EXCLUDE_FROM_RALPH)
03705     double dx1 = (End2.x - Start.x);
03706     double dy1 = (End2.y - Start.y);
03707 
03708     double dx2 = (End.x - Start.x);
03709     double dy2 = (Start.y - End.y);
03710 
03711     if (P1 != NULL && (Start != DocCoord(0,0)))
03712         *P1 = DocCoord(INT32(double(Start.x) + dx1/2 + dx2/2), INT32(double(Start.y) + dy1/2 - dy2/2));
03713     if (P2 != NULL && (End != DocCoord(0,0)))
03714         *P2 = DocCoord(INT32(double(Start.x) + dx1/2 + dx2),   INT32(double(Start.y) + dy1/2 - dy2));
03715     if (P3 != NULL && (End2 != DocCoord(0,0)))
03716         *P3 = DocCoord(INT32(double(Start.x) + dx1   + dx2/2), INT32(double(Start.y) + dy1   - dy2/2));
03717 #endif
03718 }

DocRect GetMeshEllipseBounds DocCoord  Start,
DocCoord  End,
DocCoord  End2
 

Gets the Bounding rect of the Radial Fill Mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3377 of file opgrad.cpp.

03378 {
03379 #if !defined(EXCLUDE_FROM_RALPH)
03380     if (End2 == DocCoord(0,0))
03381     {
03382         End2 = MakeLineAtAngle(Start, End);
03383     }
03384 
03385     ANGLE LineAngle = CalcLineAngle(Start, End);
03386     Matrix Rotate = Matrix(-LineAngle);
03387 
03388     End.translate(-Start.x, -Start.y);
03389     End2.translate(-Start.x, -Start.y);
03390 
03391     Rotate.transform(&End);
03392     Rotate.transform(&End2);
03393 
03394     End.translate(Start.x, Start.y);
03395     End2.translate(Start.x, Start.y);
03396 
03397     DocCoord Parallel[4];
03398 
03399     INT32 dx = End2.x - Start.x;
03400     INT32 dy = Start.y - End.y;
03401 
03402     // Copy the rectangle into the parallelogram
03403     Parallel[0] = DocCoord(Start.x - dx, Start.y - dy);
03404     Parallel[1] = DocCoord(Start.x + dx, Start.y - dy);
03405     Parallel[2] = DocCoord(Start.x + dx, Start.y + dy);
03406     Parallel[3] = DocCoord(Start.x - dx, Start.y + dy);
03407 
03408     Matrix Rotate2 = Matrix(LineAngle);
03409 
03410     for (INT32 i=0; i<4; i++)
03411     {
03412         Parallel[i].translate(-Start.x, -Start.y);
03413         Rotate2.transform(&Parallel[i]);
03414         Parallel[i].translate(Start.x, Start.y);
03415     }
03416 
03417     DocRect Bounds = DocRect(Parallel[0], Parallel[0]);
03418     Bounds.IncludePoint(Parallel[1]);
03419     Bounds.IncludePoint(Parallel[2]);
03420     Bounds.IncludePoint(Parallel[3]);
03421 
03422     return Bounds;
03423 #else
03424     return DocRect(0,0,0,0);
03425 #endif
03426 }

void GetMeshParallelagram DocCoord  Start,
DocCoord  End,
DocCoord  End2,
DocCoord P1,
DocCoord P2,
DocCoord P3,
DocCoord P4
 

Makes a Parallelagram for the Bitmap fill mesh. Not used any more.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3640 of file opgrad.cpp.

03642 {
03643 #if !defined(EXCLUDE_FROM_RALPH)
03644     INT32 dx1 = (End2.x - Start.x);
03645     INT32 dy1 = (End2.y - Start.y);
03646 
03647     INT32 dx2 = (End.x - Start.x);
03648     INT32 dy2 = (Start.y - End.y);
03649 
03650     *P1 = DocCoord(Start.x + dx1 + dx2, Start.y + dy1 - dy2);
03651     *P2 = DocCoord(Start.x - dx1 + dx2, Start.y - dy1 - dy2);
03652     *P3 = DocCoord(Start.x - dx1 - dx2, Start.y - dy1 + dy2);
03653     *P4 = DocCoord(Start.x + dx1 - dx2, Start.y + dy1 + dy2);
03654 #endif
03655 }

DocRect GetMeshSemiCircleBounds DocCoord  Start,
DocCoord  End,
DocCoord  EndPoint
 

Gets the Bounding rect of the Conical Fill Mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3183 of file opgrad.cpp.

03184 {
03185 #if !defined(EXCLUDE_FROM_RALPH)
03186     DocCoord End2 = MakeLineAtAngle(Start, End);
03187 
03188     ANGLE LineAngle = CalcLineAngle(Start, End);
03189     Matrix Rotate = Matrix(-LineAngle);
03190 
03191     End.translate(-Start.x, -Start.y);
03192     End2.translate(-Start.x, -Start.y);
03193 
03194     Rotate.transform(&End);
03195     Rotate.transform(&End2);
03196 
03197     End.translate(Start.x, Start.y);
03198     End2.translate(Start.x, Start.y);
03199 
03200     DocCoord Parallel[4];
03201 
03202     INT32 dx = End2.x - Start.x;
03203     INT32 dy = Start.y - End.y;
03204 
03205     // Copy the rectangle into the parallelogram
03206     Parallel[0] = DocCoord(Start.x - dx, Start.y - dy);
03207     Parallel[1] = DocCoord(Start.x + dx, Start.y - dy);
03208     Parallel[2] = DocCoord(Start.x + dx, Start.y + dy);
03209     Parallel[3] = DocCoord(Start.x - dx, Start.y + dy);
03210 
03211     // Get an array to put the 12 different coords needed to specify an ellipse
03212     DocCoord NewCoords[12];
03213 
03214     // Calculate the 3 coordinates along each side of the parallelogram
03215     CalcMeshEllipseEdge(Parallel[0], Parallel[1], &NewCoords[11], &NewCoords[0], &NewCoords[1]);
03216     CalcMeshEllipseEdge(Parallel[1], Parallel[2], &NewCoords[2], &NewCoords[3], &NewCoords[4]);
03217     CalcMeshEllipseEdge(Parallel[2], Parallel[3], &NewCoords[5], &NewCoords[6], &NewCoords[7]);
03218     CalcMeshEllipseEdge(Parallel[3], Parallel[0], &NewCoords[8], &NewCoords[9], &NewCoords[10]);
03219 
03220     Matrix Rotate2 = Matrix(LineAngle);
03221 
03222     for (INT32 i=0; i<12; i++)
03223     {
03224         NewCoords[i].translate(-Start.x, -Start.y);
03225         Rotate2.transform(&NewCoords[i]);
03226         NewCoords[i].translate(Start.x, Start.y);
03227     }
03228 
03229     DocRect Bounds = DocRect(EndPoint, EndPoint);
03230     Bounds.IncludePoint(NewCoords[6]);
03231     Bounds.IncludePoint(NewCoords[7]);
03232     Bounds.IncludePoint(NewCoords[8]);
03233     Bounds.IncludePoint(NewCoords[9]);
03234     Bounds.IncludePoint(NewCoords[10]);
03235     Bounds.IncludePoint(NewCoords[11]);
03236 
03237     return Bounds;
03238 #else
03239     return DocRect(0,0,0,0);
03240 #endif
03241 }

DocRect GetParallelagramBounds DocCoord  Start,
DocCoord  End,
DocCoord  End2
 

Gets the Bounding rect of the Bitmap Fill Mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3669 of file opgrad.cpp.

03670 {
03671     DocCoord P1(0,0);
03672     DocCoord P2;
03673     DocCoord P3;
03674     DocCoord P4;
03675 
03676     GetMeshParallelagram(Start, End, End2, &P1, &P2, &P3, &P4);
03677 
03678     DocRect Bounds = DocRect(P1, P1);
03679 
03680     Bounds.IncludePoint(P2);
03681     Bounds.IncludePoint(P3);
03682     Bounds.IncludePoint(P4);
03683     
03684     return Bounds;
03685 }

void IncludeArrowHead DocRect Bounds,
DocCoord  Start,
DocCoord  End
 

Includes the Arrow head in the bounds calculations.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/9/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3764 of file opgrad.cpp.

03765 {
03766 #if !defined(EXCLUDE_FROM_RALPH)
03767     // First we Must caculate the angle of the arrow from the line angle
03768     const INT32 dx = Start.x - End.x;
03769     const INT32 dy = Start.y - End.y;
03770 
03771     if ( (dy==0) && (dx==0) )
03772     {
03773         return;                             // draw nothing as too small
03774     }
03775 
03776     double ArrowAngle;
03777 
03778     if ( (dx>=0) && (dy>=0) )
03779         ArrowAngle = PI - atan2( (double)dx, (double)dy );
03780     else if ( (dx<0) && (dy>=0) )
03781         ArrowAngle = -PI + atan2( (double)-dx, (double)dy );
03782     else if ( (dx<0) && (dy<0) )
03783         ArrowAngle = -atan2( (double)-dx, (double)-dy );
03784     else if ( (dx>=0) && (dy<0) )
03785         ArrowAngle = atan2( (double)dx, (double)-dy );
03786     else
03787     {
03788         TRACE( _T("invalid angle on arrowhead\n"));     // this should be impossible
03789         return;
03790     }
03791 
03792     ANGLE RotateAngle = 360 * (ArrowAngle / (2*PI));    // Convert from radians to degrees
03793 
03794     Matrix ArrowMatrix = Matrix(RotateAngle);           // Rotate it
03795     ArrowMatrix *= Matrix(End);                         // Move it to the line point
03796 
03797     const UINT32 PointCount = 3;
03798     Coord ArrowPts[PointCount];
03799 
03800     INT32 BlobSize = (Camelot.GetBlobManager())->GetBlobSize();
03801 
03802     INT32 ArrowWidth  = (BlobSize  * 3)/2;
03803     INT32 ArrowHeight = (BlobSize  * 3)/2;
03804     
03805     ArrowPts[0] = Coord(             0,            0);
03806     ArrowPts[1] = Coord( -ArrowWidth/2, -ArrowHeight);
03807     ArrowPts[2] = Coord(  ArrowWidth/2, -ArrowHeight);
03808 
03809     ArrowMatrix.transform(ArrowPts, PointCount);
03810 
03811     Bounds->IncludePoint(DocCoord(ArrowPts[0].x, ArrowPts[0].y));
03812     Bounds->IncludePoint(DocCoord(ArrowPts[1].x, ArrowPts[1].y));
03813     Bounds->IncludePoint(DocCoord(ArrowPts[2].x, ArrowPts[2].y));
03814 #endif
03815 }

DocCoord MakeLineAtAngle DocCoord  Start,
DocCoord  End,
ANGLE  Offset,
INT32  Length
 

Make a line at a givel angle to another line.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3467 of file opgrad.cpp.

03468 {
03469     const INT32 dx = End.x - Start.x;
03470     const INT32 dy = End.y - Start.y;
03471 
03472     if ( (dy==0) && (dx==0) )
03473     {
03474         return End;
03475     }
03476 
03477     DocCoord End2;
03478 
03479     if (Length == 0 && Offset == ANGLE(90))
03480     {
03481         End2.x = Start.x - (End.y - Start.y);
03482         End2.y = Start.y + (End.x - Start.x);
03483 
03484         return End2;
03485     }
03486     else if (Length == 0 && Offset == ANGLE(-90))
03487     {
03488         End2.x = Start.x + (End.y - Start.y);
03489         End2.y = Start.y - (End.x - Start.x);
03490 
03491         return End2;
03492     }
03493     else if (Length == 0 && (Offset == ANGLE(180) || Offset == ANGLE(-180)))
03494     {
03495         End2.x = Start.x - (End.x - Start.x);
03496         End2.y = Start.y - (End.y - Start.y);
03497 
03498         return End2;
03499     }
03500 
03501     double LineAngle=0;
03502 
03503     if ( (dx>=0) && (dy>=0) )
03504         LineAngle = PI - atan2( (double)dx, (double)dy );
03505     else if ( (dx<0) && (dy>=0) )
03506         LineAngle = -PI + atan2( (double)-dx, (double)dy );
03507     else if ( (dx<0) && (dy<0) )
03508         LineAngle = -atan2( (double)-dx, (double)-dy );
03509     else if ( (dx>=0) && (dy<0) )
03510         LineAngle = atan2( (double)dx, (double)-dy );
03511 
03512     ANGLE RotateAngle = 360 * (LineAngle / (2*PI)); // Convert from radians to degrees
03513 
03514     double Length1 = Length;
03515     double Length2 = Start.Distance(End);
03516 
03517     if ( INT32(Length2) == 0)
03518         return End;
03519 
03520     if ( INT32(Length1) == 0)
03521         Length1 = Length2;
03522 
03523     FIXED16 LineScale = FIXED16(Length1/Length2);
03524 
03525     Matrix Rotate1 = Matrix(-RotateAngle);
03526     Matrix Rotate2 = Matrix(RotateAngle + Offset);
03527     Matrix Scale = Matrix(LineScale, LineScale);
03528 
03529     End2 = End;
03530 
03531     End2.translate(-Start.x, -Start.y);
03532     Rotate1.transform(&End2);
03533     Scale.transform(&End2);
03534     Rotate2.transform(&End2);
03535     End2.translate(Start.x, Start.y);
03536 
03537     return End2;
03538 }

void MakeMeshArrow Path ArrowPath,
DocCoord Start,
DocCoord End,
DocCoord LineEnd
 

Makes an Arrow for the Fill Mesh. This is a Tempory Function, used until ArrowHeads work properly.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3010 of file opgrad.cpp.

03011 {
03012 #if !defined(EXCLUDE_FROM_RALPH)
03013     // First we Must caculate the angle of the arrow from the line angle
03014     const INT32 dx = Start.x - End.x;
03015     const INT32 dy = Start.y - End.y;
03016 
03017     if ( (dy==0) && (dx==0) )
03018     {
03019         ArrowPath->InsertMoveTo(End);
03020         ArrowPath->InsertLineTo(End);
03021         ArrowPath->TryToClose();
03022 
03023         *LineEnd = End;
03024         return;                             // draw nothing as too small
03025     }
03026 
03027     double ArrowAngle;
03028 
03029     if ( (dx>=0) && (dy>=0) )
03030         ArrowAngle = PI - atan2( (double)dx, (double)dy );
03031     else if ( (dx<0) && (dy>=0) )
03032         ArrowAngle = -PI + atan2( (double)-dx, (double)dy );
03033     else if ( (dx<0) && (dy<0) )
03034         ArrowAngle = -atan2( (double)-dx, (double)-dy );
03035     else if ( (dx>=0) && (dy<0) )
03036         ArrowAngle = atan2( (double)dx, (double)-dy );
03037     else
03038     {
03039         TRACE( _T("invalid angle on arrowhead\n"));     // this should be impossible
03040         return;
03041     }
03042 
03043     ANGLE RotateAngle = 360 * (ArrowAngle / (2*PI));    // Convert from radians to degrees
03044 
03045     Matrix ArrowMatrix = Matrix(RotateAngle);           // Rotate it
03046     ArrowMatrix *= Matrix(End);                         // Move it to the line point
03047 
03048     const UINT32 PointCount = 4;
03049     Coord ArrowPts[PointCount];
03050 
03051     INT32 BlobSize = (Camelot.GetBlobManager())->GetBlobSize();
03052 
03053     INT32 ArrowWidth  = (BlobSize  * 3)/2;
03054     INT32 ArrowHeight = (BlobSize  * 3)/2;
03055     
03056     ArrowPts[0] = Coord(             0,            0);
03057     ArrowPts[1] = Coord( -ArrowWidth/2, -ArrowHeight);
03058     ArrowPts[2] = Coord(  ArrowWidth/2, -ArrowHeight);
03059     ArrowPts[3] = Coord(             0, -ArrowHeight);
03060 
03061     ArrowMatrix.transform(ArrowPts, PointCount);
03062 
03063     ArrowPath->InsertMoveTo(DocCoord(ArrowPts[0].x, ArrowPts[0].y));
03064     ArrowPath->InsertLineTo(DocCoord(ArrowPts[1].x, ArrowPts[1].y));
03065     ArrowPath->InsertLineTo(DocCoord(ArrowPts[2].x, ArrowPts[2].y));
03066     ArrowPath->InsertLineTo(DocCoord(ArrowPts[0].x, ArrowPts[0].y));
03067     ArrowPath->TryToClose();
03068 
03069     *LineEnd = DocCoord(ArrowPts[3].x, ArrowPts[3].y);
03070 #endif
03071 }

void MakeMeshDottedLine Path ArrowPath,
DocCoord Start,
DocCoord End
 

Makes a Dotted Line for the Fill Mesh. This is a Tempory Function, used until Stroke Providers work properly.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3086 of file opgrad.cpp.

03087 {
03088 #if !defined(EXCLUDE_FROM_RALPH)
03089     ArrowPath->InsertMoveTo(Start);
03090     ArrowPath->InsertLineTo(End);
03091 #endif
03092 }

void MakeMeshEllipse Path EllipsePath,
DocCoord  Start,
DocCoord  End,
DocCoord  End2
 

Makes an Elliptical Fill Mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3255 of file opgrad.cpp.

03256 {
03257 #if !defined(EXCLUDE_FROM_RALPH)
03258     if (End2 == DocCoord(0,0))
03259     {
03260         End2 = MakeLineAtAngle(Start, End);
03261     }
03262 
03263     ANGLE LineAngle = CalcLineAngle(Start, End);
03264     Matrix Rotate = Matrix(-LineAngle);
03265 
03266     End.translate(-Start.x, -Start.y);
03267     End2.translate(-Start.x, -Start.y);
03268 
03269     Rotate.transform(&End);
03270     Rotate.transform(&End2);
03271 
03272     End.translate(Start.x, Start.y);
03273     End2.translate(Start.x, Start.y);
03274 
03275     DocCoord Parallel[4];
03276 
03277     INT32 dx = End2.x - Start.x;
03278     INT32 dy = Start.y - End.y;
03279 
03280     // Copy the rectangle into the parallelogram
03281     Parallel[0] = DocCoord(Start.x - dx, Start.y - dy);
03282     Parallel[1] = DocCoord(Start.x + dx, Start.y - dy);
03283     Parallel[2] = DocCoord(Start.x + dx, Start.y + dy);
03284     Parallel[3] = DocCoord(Start.x - dx, Start.y + dy);
03285 
03286     // Get an array to put the 12 different coords needed to specify an ellipse
03287     DocCoord NewCoords[12];
03288 
03289     // Calculate the 3 coordinates along each side of the parallelogram
03290     CalcMeshEllipseEdge(Parallel[0], Parallel[1], &NewCoords[11], &NewCoords[0], &NewCoords[1]);
03291     CalcMeshEllipseEdge(Parallel[1], Parallel[2], &NewCoords[2], &NewCoords[3], &NewCoords[4]);
03292     CalcMeshEllipseEdge(Parallel[2], Parallel[3], &NewCoords[5], &NewCoords[6], &NewCoords[7]);
03293     CalcMeshEllipseEdge(Parallel[3], Parallel[0], &NewCoords[8], &NewCoords[9], &NewCoords[10]);
03294 
03295     Matrix Rotate2 = Matrix(LineAngle);
03296 
03297     for (INT32 i=0; i<12; i++)
03298     {
03299         NewCoords[i].translate(-Start.x, -Start.y);
03300         Rotate2.transform(&NewCoords[i]);
03301         NewCoords[i].translate(Start.x, Start.y);
03302     }
03303 
03304     // build a path
03305     EllipsePath->ClearPath();
03306     EllipsePath->FindStartOfPath();
03307             
03308     // Start at bottom left corner
03309     EllipsePath->InsertMoveTo(NewCoords[0]);
03310     EllipsePath->InsertCurveTo(NewCoords[1], NewCoords[2], NewCoords[3]);
03311     EllipsePath->InsertCurveTo(NewCoords[4], NewCoords[5], NewCoords[6]);
03312     EllipsePath->InsertCurveTo(NewCoords[7], NewCoords[8], NewCoords[9]);
03313     EllipsePath->InsertCurveTo(NewCoords[10], NewCoords[11], NewCoords[0]);
03314 
03315     // Close the path properly
03316     EllipsePath->CloseSubPath();
03317 #endif
03318 }

void MakeMeshParallelagram Path ParaPath,
DocCoord  Start,
DocCoord  End,
DocCoord  End2
 

Makes a Parallelagram for the Bitmap fill mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3605 of file opgrad.cpp.

03606 {
03607 #if !defined(EXCLUDE_FROM_RALPH)
03608     INT32 dx1 = (End2.x - Start.x);
03609     INT32 dy1 = (End2.y - Start.y);
03610 
03611     INT32 dx2 = (End.x - Start.x);
03612     INT32 dy2 = (Start.y - End.y);
03613 
03614     // build a path
03615     ParaPath->ClearPath();
03616     ParaPath->FindStartOfPath();
03617             
03618     ParaPath->InsertMoveTo(DocCoord(Start.x + dx1 + dx2, Start.y + dy1 - dy2));
03619     ParaPath->InsertLineTo(DocCoord(Start.x - dx1 + dx2, Start.y - dy1 - dy2));
03620     ParaPath->InsertLineTo(DocCoord(Start.x - dx1 - dx2, Start.y - dy1 + dy2));
03621     ParaPath->InsertLineTo(DocCoord(Start.x + dx1 - dx2, Start.y + dy1 + dy2));
03622     ParaPath->InsertLineTo(DocCoord(Start.x + dx1 + dx2, Start.y + dy1 - dy2));
03623 #endif
03624 }

void MakeMeshSemiCircle Path EllipsePath,
DocCoord  Start,
DocCoord  End,
DocCoord  ArrowPoint
 

Make a Semi-Circle for the Conical Fill Mesh.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3106 of file opgrad.cpp.

03107 {
03108 #if !defined(EXCLUDE_FROM_RALPH)
03109     End  = MakeLineAtAngle(Start, End, 180);
03110     DocCoord End2 = MakeLineAtAngle(Start, End);
03111 
03112     ANGLE LineAngle = CalcLineAngle(Start, End);
03113     Matrix Rotate = Matrix(-LineAngle);
03114 
03115     End.translate(-Start.x, -Start.y);
03116     End2.translate(-Start.x, -Start.y);
03117 
03118     Rotate.transform(&End);
03119     Rotate.transform(&End2);
03120 
03121     End.translate(Start.x, Start.y);
03122     End2.translate(Start.x, Start.y);
03123 
03124     DocCoord Parallel[4];
03125 
03126     INT32 dx = End2.x - Start.x;
03127     INT32 dy = Start.y - End.y;
03128 
03129     // Copy the rectangle into the parallelogram
03130     Parallel[0] = DocCoord(Start.x - dx, Start.y - dy);
03131     Parallel[1] = DocCoord(Start.x + dx, Start.y - dy);
03132     Parallel[2] = DocCoord(Start.x + dx, Start.y + dy);
03133     Parallel[3] = DocCoord(Start.x - dx, Start.y + dy);
03134 
03135     // Get an array to put the 12 different coords needed to specify an ellipse
03136     DocCoord NewCoords[12];
03137 
03138     // Calculate the 3 coordinates along each side of the parallelogram
03139     CalcMeshEllipseEdge(Parallel[0], Parallel[1], &NewCoords[11], &NewCoords[0], &NewCoords[1]);
03140     CalcMeshEllipseEdge(Parallel[1], Parallel[2], &NewCoords[2], &NewCoords[3], &NewCoords[4]);
03141     CalcMeshEllipseEdge(Parallel[2], Parallel[3], &NewCoords[5], &NewCoords[6], &NewCoords[7]);
03142     CalcMeshEllipseEdge(Parallel[3], Parallel[0], &NewCoords[8], &NewCoords[9], &NewCoords[10]);
03143 
03144     Matrix Rotate2 = Matrix(LineAngle);
03145 
03146     for (INT32 i=0; i<12; i++)
03147     {
03148         NewCoords[i].translate(-Start.x, -Start.y);
03149         Rotate2.transform(&NewCoords[i]);
03150         NewCoords[i].translate(Start.x, Start.y);
03151     }
03152 
03153     // build a path
03154     EllipsePath->ClearPath();
03155     EllipsePath->FindStartOfPath();
03156             
03157     // Start at bottom left corner
03158 //  EllipsePath->InsertMoveTo(NewCoords[0]);
03159 //  EllipsePath->InsertCurveTo(NewCoords[1], NewCoords[2], NewCoords[3]);
03160 //  EllipsePath->InsertCurveTo(NewCoords[4], NewCoords[5], NewCoords[6]);
03161 
03162     EllipsePath->InsertMoveTo(ArrowPoint);
03163     EllipsePath->InsertCurveTo(NewCoords[7], NewCoords[8], NewCoords[9]);
03164     EllipsePath->InsertCurveTo(NewCoords[10], NewCoords[11], NewCoords[0]);
03165 
03166     // Close the path properly
03167 //  EllipsePath->CloseSubPath();
03168 #endif
03169 }

void MakePerpendicularMeshLines DocCoord  Start,
DocCoord  End,
DocRect  Bounds,
DocCoord PointArray
 

Makes lines perpendicular to a fill line.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/07/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 3441 of file opgrad.cpp.

03443 {
03444 #if !defined(EXCLUDE_FROM_RALPH)
03445     INT32 Infinity = max(Bounds.Width(), Bounds.Height());
03446 
03447     PointArray[0] = MakeLineAtAngle(Start, End,  90, Infinity);
03448     PointArray[1] = MakeLineAtAngle(Start, End, -90, Infinity);
03449     PointArray[2] = MakeLineAtAngle(End, Start,  90, Infinity);
03450     PointArray[3] = MakeLineAtAngle(End, Start, -90, Infinity);
03451 #endif
03452 }


Variable Documentation

BOOL EditFinished = FALSE [static]
 

Definition at line 164 of file opgrad.cpp.

NodeRenderableInk* pParentOfFill = NULL [static]
 

Definition at line 168 of file opgrad.cpp.

AttrFillGeometry* pTheFill = NULL [static]
 

Definition at line 169 of file opgrad.cpp.


Generated on Sat Nov 10 03:49:17 2007 for Camelot by  doxygen 1.4.4