DocCoord Class Reference

#include <doccoord.h>

Inheritance diagram for DocCoord:

Coord List of all members.

Public Member Functions

 DocCoord (INT32 x, INT32 y)
 DocCoord ()
WorkCoord ToWork (Document *pDocument, View *pView)
 Converts a document coordinate to a work area coordnate - slowly! Note that if you are performing this conversion often and you want to do it fast then you should use the approriate "Compose" function to build a matrix which does the job and repeatedly apply that matrix.
WorkCoord ToWork (Spread *pSpread, View *pView)
 Convert a document coordinate to a Work Coordinate, given the spread that the coordinate is on.
DocCoord ToDoc (Spread *pSpread, View *pView)
 Convert SpreadCoord to a DocCoord.
DocCoord ToSpread (Spread *pSpread, View *pView)
 Convert DocCoord to a SpreadCoord.
UserCoord ToUser (Spread *pSpread)
 Convert SpreadCoord to a UserCoord.
OilCoord ToOil (Spread *pSpread, View *pView)
 Convert SpreadCoord (AKA DocCoord) to an OilCoord.
WorkCoord ToLogical (Spread *pSpread, View *pView)
ChapterFindEnclosingChapter (Document *pDocument, DocCoord *ChapterPos, XLONG *ChapterDepth, View *pView)
 For finding the enclosing chapter of a DocCoord, the position of the start of the enclosing chapter, and the chapters depth.
BOOL Pixelise ()
 Modifies this DocCoord to lie on an exact pixel boundary.
BOOL Pixelise (View *pView)
 Modifies this DocCoord to lie on an exact pixel boundary. Scope: Public.
BOOL IsPixelised (View *pView)
 Modifies this DocCoord to lie on an exact pixel boundary. Scope: Public.
const DocCoordoperator+= (const DocCoord &Other)
 Adds a DocCoord value onto the current object.
const DocCoordoperator-= (const DocCoord &Other)
 Subtracts a DocCoord value from the current object.
void Scale (const DocCoord dcOrigin, const double dDPI=96.0)
 Scales the DocCoord by the specified DPI and origin.
double AngleFromVertical () const

Static Public Member Functions

static BOOL IsJoinAcute (const DocCoord *pJoin, const DocCoord *pOtherEndOfJoin, const DocCoord *pOtherPoint)
 For seeing the perpendicual distance from pOtherPoint to the line pJoin-pOtherEndOfJoin end on the line or before pJoin. Used when dragging along a line to see if the drag point has gon back beyond the start of the line.
static DocCoord PositionPointFromRatio (const DocCoord &StartPoint, const DocCoord &EndPoint, const double Ratio)
 Gives the coordinate of a point specified by a ratio along a line defined by two other points. A ratio of zero gives the same point as the start of the line, 0.5 gives the mid point of the line, etc. Negative ratio give a point before the start, ratios greater than 1 give points beyond the end.
static double DistanceFromLine (const DocCoord &Line1, const DocCoord &Line2, const DocCoord &Point)
 Gets the shortest distance from the line to the point.
static DocCoord OneThird (const DocCoord &Start, const DocCoord &End)
 For getting a point one third of the way between two other points.
static DocCoord OneHalf (const DocCoord &Start, const DocCoord &End)
 For getting a point midway between two other points.
static DocCoord TwoThirds (const DocCoord &Start, const DocCoord &End)
 For getting a point two thirds of the way between two other points.

Friends

Matrix ComposeDocToOilMat (const DocCoord &ChapterPos, const XLONG &ChapterDepth, const FIXED16 &ViewScale, const WorkCoord &ScrollOffset)
XMatrix ComposeDocToWorkXMat (const DocCoord ChapterPos, const XLONG ChapterDepth, const FIXED16 ViewScale)
DocCoord operator+ (const DocCoord &, const DocCoord &)
 Adds two DocCoords together. ie One.x+Two.x, One.y+Two.y.
DocCoord operator- (const DocCoord &, const DocCoord &)
 Subtracts the two DocCoords. ie One.x-Two.x, One.y-Two.y.

Detailed Description

Definition at line 137 of file doccoord.h.


Constructor & Destructor Documentation

DocCoord::DocCoord INT32  x,
INT32  y
[inline]
 

Definition at line 141 of file doccoord.h.

00141 : Coord(x,y) {};

DocCoord::DocCoord  )  [inline]
 

Definition at line 142 of file doccoord.h.

00142 : Coord() {};


Member Function Documentation

double DocCoord::AngleFromVertical  )  const [inline]
 

Definition at line 198 of file doccoord.h.

00198 { return atan2( (double)x, (double)y ); }

double DocCoord::DistanceFromLine const DocCoord Line1,
const DocCoord Line2,
const DocCoord Point
[static]
 

Gets the shortest distance from the line to the point.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Parameters:
Line1 and Line2 are two points defining a line that passes through those points [INPUTS] Point is another point
- [OUTPUTS]
Returns:
The perpendicular distance from the line to the point.

Errors: Will return -1 if a division by zero case was detected

Definition at line 762 of file doccoord.cpp.

00763 {
00764     // Obtain perpendicular distance from the axes line (see A-Level maths page 24)
00765     const double X1 = Line1.x;
00766     const double Y1 = Line1.y;
00767     const double X2 = Line2.x;
00768     const double Y2 = Line2.y;
00769 
00770     const double a = -Y2+Y1;
00771     const double b =  X2-X1;
00772     const double c = -(Y1*X2) + (Y1*X1) + (X1*Y2) - (X1*Y1);
00773 
00774     const double divisor = sqrt( a*a + b*b );
00775     
00776     // We don't want any nasty floating point div 0, thank you
00777     double Distance = -1.0;
00778     if (divisor >= 0.0001)
00779         Distance = fabs(( a*Point.x + b*Point.y + c )/divisor);    
00780 
00781     return Distance;
00782 }

Chapter * DocCoord::FindEnclosingChapter Document pDocument,
DocCoord ChapterPos,
XLONG ChapterDepth,
View pView
 

For finding the enclosing chapter of a DocCoord, the position of the start of the enclosing chapter, and the chapters depth.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/93
Parameters:
pDocument - the document we are converting in. [INPUTS] pView - the View to use for pixelising.
ChapterPos,: The top left hand corner of the chapters pasteboard rectangle [OUTPUTS] ChapterDepth: The Sum of the lengths of all preceding chapters
Returns:
If this coord is enclosed within a chapter then the chapter is returned else NULL is returned (In the non DEBUG version).
Scope: Private

Returns:
Errors: An ERROR3 will occur if the DocCoord is not in any chapter NOTE: The Spread Coordinate Origin for a spread MAY NOT reside INSIDE a Chapter's Pasteboard bounds! See Spread::GetSpreadCoordOrigin for full details of this.
See also:
-

Definition at line 492 of file doccoord.cpp.

00496 {
00497     Chapter* CurrentChapter = Node::FindFirstChapter(pDocument);
00498     // Search all chapters
00499     *ChapterDepth = 0;
00500     DocRect CurrentChaptersPasteboardRect;
00501 
00502     while (CurrentChapter != NULL)
00503     {
00504         CurrentChaptersPasteboardRect = CurrentChapter->GetPasteboardRect(TRUE, pView);
00505 
00506         if (CurrentChaptersPasteboardRect.ContainsRectCoord(*this))
00507         {
00508             // Chapter position is the top left hand corner of the chapters pasteboard
00509             ChapterPos->x = CurrentChaptersPasteboardRect.LowCorner().x;
00510             ChapterPos->y = CurrentChaptersPasteboardRect.HighCorner().y;
00511             return (CurrentChapter);
00512         }
00513 
00514         (*ChapterDepth) += CurrentChaptersPasteboardRect.Height();
00515         CurrentChapter = CurrentChapter->FindNextChapter();
00516     }
00517 
00518     // The DocCoord was not found in any chapter
00519     ERROR3("DocCoord::FindEnclosingChapter: Coord wasn't in any chapter. See the function help for debugging tips");
00520     return(NULL);
00521 }

BOOL DocCoord::IsJoinAcute const DocCoord pJoin,
const DocCoord pOtherEndOfJoin,
const DocCoord pOtherPoint
[static]
 

For seeing the perpendicual distance from pOtherPoint to the line pJoin-pOtherEndOfJoin end on the line or before pJoin. Used when dragging along a line to see if the drag point has gon back beyond the start of the line.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/95
Parameters:
pJoin - the coordinate where two lines join [INPUTS] pOtherEndOfJoin - another point that with pJoin defines a line pOtherPoint - another point that with pJoin defines another line
- [OUTPUTS]
Returns:
TRUE if the angle between the two lines is an acute angle

Definition at line 867 of file doccoord.cpp.

00868 {
00869     // Translate the points so the join is on the origin and the other points are relative to that
00870     DocCoord OriginLine = *pOtherEndOfJoin - *pJoin;
00871     DocCoord OriginOther = *pOtherPoint - *pJoin;
00872     double LineAngle = atan2((double)OriginLine.y, (double)OriginLine.x);
00873     double OtherAngle = atan2((double)OriginOther.y, (double)OriginOther.x);
00874 
00875     double diff = OtherAngle - LineAngle;
00876     if (diff < -PI)
00877         diff += 2*PI;
00878     if (diff > PI)
00879         diff -= 2*PI;
00880 
00881     if ( (diff < -(PI/2)) || (diff > (PI/2)) )
00882         return FALSE;
00883     else
00884         return TRUE;
00885 }

BOOL DocCoord::IsPixelised View pView  ) 
 

Modifies this DocCoord to lie on an exact pixel boundary. Scope: Public.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/94
Parameters:
The view we are pixelising for. [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this DocCoord is already pixelised FALSE otherwise

Definition at line 593 of file doccoord.cpp.

00594 {
00595     // See if the view is ok
00596     if (pView==NULL)
00597         return FALSE;
00598 
00599     // Now pixelise a temp copy of this coord and see if it changed at all...
00600     DocCoord temp(x,y);
00601     temp.Pixelise(pView);
00602     return (x==temp.x && y==temp.y);
00603 }

DocCoord DocCoord::OneHalf const DocCoord Start,
const DocCoord End
[static]
 

For getting a point midway between two other points.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Parameters:
Start and End are two coordinates [INPUTS]
- [OUTPUTS]
Returns:
The point one half of the way from Start to End

Definition at line 840 of file doccoord.cpp.

00841 {
00842     DocCoord result;
00843 
00844     result.x = Start.x + (INT32)((End.x - Start.x)/2) ;
00845     result.y = Start.y + (INT32)((End.y - Start.y)/2) ;
00846 
00847     return result;
00848 }

DocCoord DocCoord::OneThird const DocCoord Start,
const DocCoord End
[static]
 

For getting a point one third of the way between two other points.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Parameters:
Start and End are two coordinates [INPUTS]
- [OUTPUTS]
Returns:
The point one third of the way from Start to End

Definition at line 796 of file doccoord.cpp.

00797 {
00798     DocCoord result;
00799 
00800     result.x = Start.x + (INT32)((End.x - Start.x)/3) ;
00801     result.y = Start.y + (INT32)((End.y - Start.y)/3) ;
00802 
00803     return result;
00804 }

const DocCoord & DocCoord::operator+= const DocCoord Other  ) 
 

Adds a DocCoord value onto the current object.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/00
Parameters:
Other - The other DocCoord value, that's being added to the original. [INPUTS]
Returns:
A reference to the current object, for concatentation

Definition at line 695 of file doccoord.cpp.

00696 {
00697     // Add the other DocCoord's values onto this object's.
00698     x += Other.x;
00699     y += Other.y;
00700 
00701     return *this;
00702 }

const DocCoord & DocCoord::operator-= const DocCoord Other  ) 
 

Subtracts a DocCoord value from the current object.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/00
Parameters:
Other - The other DocCoord value, that's being subtracted from this one. [INPUTS]
Returns:
A reference to the current object, for concatentation

Definition at line 716 of file doccoord.cpp.

00717 {
00718     // Add the other DocCoord's values onto this object's.
00719     x -= Other.x;
00720     y -= Other.y;
00721 
00722     return *this;
00723 }

BOOL DocCoord::Pixelise View pView  ) 
 

Modifies this DocCoord to lie on an exact pixel boundary. Scope: Public.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/94
Parameters:
The view we are pixelising for. [INPUTS]
See also:
DocCoord::SetScaledPixelSize()

Definition at line 564 of file doccoord.cpp.

00565 {
00566     // See if the view is ok
00567     if (pView==NULL)
00568         return FALSE;
00569 
00570     FIXED16 pw,ph;
00571     pView->GetScaledPixelSize(&pw,&ph);
00572     x = (INT32) ( (floor(0.5 + (double)x / pw.MakeDouble())) * pw.MakeDouble() );
00573     y = (INT32) ( (floor(0.5 + (double)y / ph.MakeDouble())) * ph.MakeDouble() );
00574 
00575     return TRUE;
00576 }

BOOL DocCoord::Pixelise  ) 
 

Modifies this DocCoord to lie on an exact pixel boundary.

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

Errors: - Scope: Public

See also:
DocCoord::SetScaledPixelSize()

Definition at line 624 of file doccoord.cpp.

00625 {
00626     // BODGE: ...until I can be bothered to get callers to pass view in...  (Tim)
00627     return Pixelise(View::GetCurrent());
00628 }

DocCoord DocCoord::PositionPointFromRatio const DocCoord StartPoint,
const DocCoord EndPoint,
const double  Ratio
[static]
 

Gives the coordinate of a point specified by a ratio along a line defined by two other points. A ratio of zero gives the same point as the start of the line, 0.5 gives the mid point of the line, etc. Negative ratio give a point before the start, ratios greater than 1 give points beyond the end.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Parameters:
StartPoint and EndPoint define the start and end of a line [INPUTS] Ratio is the ratio of the distance from start to end that you want the coordinate of
- [OUTPUTS]
Returns:
The coordinate of the position of the ratio (err, does that make sense?)

Definition at line 739 of file doccoord.cpp.

00740 {
00741     DocCoord result;
00742     
00743     result.x = StartPoint.x + (INT32)((EndPoint.x - StartPoint.x)*Ratio) ;
00744     result.y = StartPoint.y + (INT32)((EndPoint.y - StartPoint.y)*Ratio) ;
00745 
00746     return result;
00747 } 

void DocCoord::Scale const DocCoord  dcOrigin,
const double  dDPI = 96.0
 

Scales the DocCoord by the specified DPI and origin.

> void DocCoord::Scale(const DocCoord dcOrigin, const double dDPI=96.0)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/97
Parameters:
dDPI The DPI by which to scale the coord [INPUTS] dcOrigin The origin by which to scale the coord
That is, this function does the following to this DocCoord:

a. Subtracts the origin dcOrigin b. Inverts the y-axis c. Multiplies the coordinate to convert them to the number of DPI specified.

Used in imagemaps.

Note that, technically, what this function produces should be a WorkCoord. But that causes problems, because this function is called to scale paths to bitmap coordinates - and you can't specify a path in terms of WorkCoords.

SeeAlso: Path::Scale(), Imagemap::AddPolygon()

Definition at line 916 of file doccoord.cpp.

00917 {
00918     //Subtract the origin from this coord
00919     x-=dcOrigin.x;
00920     y-=dcOrigin.y;
00921 
00922     //And scale by the appropriate DPI, inverting the y-axis
00923     //and rounding to the nearest pixel
00924     x=INT32(x*(dDPI/72000.0)+0.5);
00925     y=INT32(-y*(dDPI/72000.0)+0.5);
00926     
00927 }

DocCoord DocCoord::ToDoc Spread pSpread,
View pView
 

Convert SpreadCoord to a DocCoord.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/9/95
Parameters:
pSpread - [INPUTS] pView -
Returns:
SpreadCoord
See also:
Spread::SpreadCoordToDocCoord

Definition at line 404 of file doccoord.cpp.

00405 {
00406     ERROR3IF(pSpread == NULL || pView == NULL, "DocCoord::ToDoc() - pSpread==NULL || pView==NULL");
00407 
00408     DocCoord temp(x, y);
00409 
00410     if (pSpread != NULL)
00411         pSpread->SpreadCoordToDocCoord(&temp);
00412 
00413     return(temp);
00414 }

WorkCoord DocCoord::ToLogical Spread pSpread,
View pView
 

Definition at line 340 of file doccoord.cpp.

00341 {
00342     // Check that we have not been fed garbage
00343     ENSURE( pSpread!=NULL, "DocCoord::ToLogical was passed a NULL spread" );
00344 
00345     // Find the chapter
00346     Chapter* pChapter = (Chapter*) pSpread->FindParent();
00347     ENSURE( pChapter!=NULL, "DocCoord::ToLogical. Spread did not have a parent chapter" );
00348     ENSURE( pChapter->IsKindOf(CC_RUNTIME_CLASS(Chapter)), "DocCoord::ToLogical. Chapter is not a chapter" );
00349 
00350     // Find out about the chapter
00351     DocRect ChapterRect = pChapter->GetPasteboardRect(TRUE, pView);
00352     XLONG   ChapterDepth = pChapter->GetChapterDepth();
00353 
00354     // Build the logical coord from the doccoord
00355     WorkCoord Result( MakeXLong(x), MakeXLong(y) );
00356     Result.x = Result.x - ChapterRect.lo.x;
00357     Result.y = Result.y - ChapterRect.hi.y;
00358     Result.y = Result.y - ChapterDepth;
00359 
00360     // return the coord
00361     return Result;
00362 }

OilCoord DocCoord::ToOil Spread pSpread,
View pView
 

Convert SpreadCoord (AKA DocCoord) to an OilCoord.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/95
Parameters:
pSpread - [INPUTS] pView -
Returns:
OilCoord

Definition at line 450 of file doccoord.cpp.

00451 {
00452     WorkCoord ScrollOffsets(0,0);
00453     if (pView!=NULL)
00454         ScrollOffsets=pView->GetScrollOffsets();
00455     else
00456         ERROR3("DocCoord::ToOil() - pView==NULL");
00457 
00458     return ToDoc(pSpread,pView).ToWork(pSpread,pView).ToOil(ScrollOffsets);
00459 }

DocCoord DocCoord::ToSpread Spread pSpread,
View pView
 

Convert DocCoord to a SpreadCoord.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/9/95
Parameters:
pSpread - [INPUTS] pView -
Returns:
SpreadCoord
See also:
Spread::SpreadCoordToDocCoord

Definition at line 378 of file doccoord.cpp.

00379 {
00380     ERROR3IF((pSpread==NULL || pView==NULL), "DocCoord::ToSpread() - pSpread==NULL || pView==NULL");
00381 
00382     DocCoord temp(x, y);
00383 
00384     if (pSpread != NULL)
00385         pSpread->DocCoordToSpreadCoord(&temp);
00386 
00387     return(temp);
00388 }

UserCoord DocCoord::ToUser Spread pSpread  ) 
 

Convert SpreadCoord to a UserCoord.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/95
Parameters:
pSpread - [INPUTS]
Returns:
UserCoord

Definition at line 427 of file doccoord.cpp.

00428 {
00429     DocCoord UserOrigin(0,0);
00430     if (pSpread!=NULL)
00431         UserOrigin=pSpread->GetUserOrigin();
00432     else
00433         ERROR3("DocCoord::ToUser() - pSpread==NULL");
00434 
00435     return UserCoord(this->x-UserOrigin.x, this->y-UserOrigin.y);
00436 }

WorkCoord DocCoord::ToWork Spread pSpread,
View pView
 

Convert a document coordinate to a Work Coordinate, given the spread that the coordinate is on.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 307 of file doccoord.cpp.

00308 {
00309     WorkCoord   WrkPoint(MakeXLong(this->x), MakeXLong(this->y));
00310     DocCoord    ChapterPos;             // To hold the top-left of the found chapter
00311     XLONG       ChapterDepth;           // To hold the accumulated depth of the chapter
00312     XMatrix     ConvertToWorkMat;       // Transformation matrix
00313     
00314     Chapter *pChapter = (Chapter *) pSpread->FindParent();
00315     ENSURE(pChapter->IsKindOf(CC_RUNTIME_CLASS(Chapter)), "Spread's parent is not a chapter");
00316 
00317 
00318     // Find top left of chapter pasteboard
00319     DocRect ChapterRect = pChapter->GetPasteboardRect(TRUE, pView);
00320     ChapterPos.x = ChapterRect.lo.x;
00321     ChapterPos.y = ChapterRect.hi.y;
00322 
00323     // Find chapter depth
00324     ChapterDepth = pChapter->GetChapterDepth();
00325     
00326     // This builds the 64-bit conversion matrix needed for Document To WorkArea 
00327     // coordinate mappings.
00328 
00329     ConvertToWorkMat = ComposeDocToWorkXMat(ChapterPos, 
00330                                             ChapterDepth,
00331                                             pView->GetViewScale());
00332     
00333     // Apply the matrix to the DocCoord...
00334     ConvertToWorkMat.transform(&WrkPoint, 1);
00335 
00336     return (WrkPoint);
00337 }

WorkCoord DocCoord::ToWork Document pDocument,
View pView
 

Converts a document coordinate to a work area coordnate - slowly! Note that if you are performing this conversion often and you want to do it fast then you should use the approriate "Compose" function to build a matrix which does the job and repeatedly apply that matrix.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (with modifications by Phil (and Tim))
Date:
26/5/93
Parameters:
The document we are converting within. [INPUTS] The view we are converting within.
None. [OUTPUTS]
Returns:
Returns a Workarea coordinate.

Errors: None.

Definition at line 269 of file doccoord.cpp.

00270 {
00271     WorkCoord   WrkPoint(MakeXLong(this->x), MakeXLong(this->y));
00272     DocCoord    ChapterPos;             // To hold the top-left of the found chapter
00273     XLONG       ChapterDepth;           // To hold the accumulated depth of the chapter
00274     XMatrix     ConvertToWorkMat;       // Transformation matrix
00275     
00276     // Find chapter and its log depth
00277     this->FindEnclosingChapter(pDocument, &ChapterPos, &ChapterDepth, pView);
00278     
00279     // This builds the 64-bit conversion matrix needed for Document To WorkArea 
00280     // coordinate mappings.
00281     ConvertToWorkMat = ComposeDocToWorkXMat(ChapterPos, 
00282                                             ChapterDepth,
00283                                             pView->GetViewScale());
00284     
00285     // Apply the matrix to the DocCoord...
00286     ConvertToWorkMat.transform(&WrkPoint, 1);
00287 
00288     return (WrkPoint);
00289 }

DocCoord DocCoord::TwoThirds const DocCoord Start,
const DocCoord End
[static]
 

For getting a point two thirds of the way between two other points.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Parameters:
Start and End are two coordinates [INPUTS]
- [OUTPUTS]
Returns:
The point two thirds of the way from Start to End

Definition at line 818 of file doccoord.cpp.

00819 {
00820     DocCoord result;
00821 
00822     result.x = Start.x + (INT32)((End.x - Start.x)*(2.0/3.0)) ;
00823     result.y = Start.y + (INT32)((End.y - Start.y)*(2.0/3.0)) ;
00824 
00825     return result;
00826 }


Friends And Related Function Documentation

Matrix ComposeDocToOilMat const DocCoord ChapterPos,
const XLONG ChapterDepth,
const FIXED16 ViewScale,
const WorkCoord ScrollOffset
[friend]
 

Definition at line 145 of file doccoord.cpp.

00150 {
00151 // Scale ChapterDepth into device units so that it can be combined with the scroll offset
00152 // BEFORE we build the scroll translation matrix. In this way we avoid storing 64-bit
00153 // translation values in our final matrix...
00154 //
00155 // If we COULD store 64-bit E and F values temporarilly during this composition then
00156 // we would not need to perform this trick at all. This would have the knock-on advantage
00157 // that the OSMapping matrix supplied by the OIL layer could contain the scroll offsets!
00158 //
00159 // NOTE: This adjustment can be removed when testing the system!
00160 
00161     Matrix DocToOil;
00162 
00163 //**********************************************************************
00164 // Is it just me or is there gunna be a problem with this ?
00165 // If ChapterDepth is big (atfer all it is an XLONG) and ViewScale
00166 // is big too (Say we are zoomed to 1000%) won't this go VERY wrong ?
00167 //
00168 // - Will.
00169 
00170     Matrix Scroll(  -ScrollOffset.x,
00171                     -(ScrollOffset.y + (ChapterDepth * (ViewScale)))
00172                  );
00173 
00174 //**********************************************************************
00175 
00176     Matrix ScaleMat(ViewScale,ViewScale);
00177     Matrix Translate(-((Coord)ChapterPos));
00178 
00179 // The following matrix compositions MUST be performed in this order. If you are tempted
00180 // to optimise this code MAKE SURE THAT THEY ARE STILL IN THIS ORDER WHEN YOU'VE FINISHED!
00181 //
00182 // Apply translation to get coordinates into logical column...
00183     DocToOil *= Translate;
00184 
00185 // Apply scale factors to convert from millipoint distances to pixel distances...
00186     DocToOil *= ScaleMat;
00187 
00188 // Apply scroll-offset translation to move origin to viewing position...
00189     DocToOil *= Scroll;
00190 
00191     return DocToOil;
00192 }

XMatrix ComposeDocToWorkXMat const DocCoord  ChapterPos,
const XLONG  ChapterDepth,
const FIXED16  ViewScale
[friend]
 

Definition at line 221 of file doccoord.cpp.

00225 {
00226 
00227     XMatrix ScaleMat(ViewScale,ViewScale);
00228 
00229 // Conversion of chapter position from DocCoords to WorkCoords
00230 //    WorkCoord WrkChapPos(MakeXLong(ChapterPos.x), MakeXLong(ChapterPos.y));
00231     WorkCoord WrkChapPos(MakeXLong(ChapterPos.x), MakeXLong(ChapterPos.y)+ChapterDepth);
00232 
00233 // DocToOS matrix is initialised as the Translate matrix: saving space and performance
00234 // by the exclusion of an extra multiplication.
00235     XMatrix DocToWork(-(WrkChapPos));
00236     
00237 // The following matrix compositions MUST be performed in this order. If you are tempted
00238 // to optimise this code MAKE SURE THAT THEY ARE STILL IN THIS ORDER WHEN YOU'VE FINISHED!
00239 //
00240 
00241 // Apply scale factors to convert from millipoint distances to pixel distances...
00242     DocToWork *= ScaleMat;
00243 
00244     return DocToWork;
00245 }

DocCoord operator+ const DocCoord One,
const DocCoord Two
[friend]
 

Adds two DocCoords together. ie One.x+Two.x, One.y+Two.y.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94
Parameters:
One - The first DocCoord [INPUTS] Two - The second DocCoord
Returns:
The result of adding the two DocCoords together.

Definition at line 645 of file doccoord.cpp.

00646 {
00647     DocCoord Result;
00648 
00649     // Add the two DocCoords together
00650     Result.x = One.x + Two.x;
00651     Result.y = One.y + Two.y;
00652 
00653     // return the result
00654     return Result;
00655 }

DocCoord operator- const DocCoord One,
const DocCoord Two
[friend]
 

Subtracts the two DocCoords. ie One.x-Two.x, One.y-Two.y.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94
Parameters:
One - The first DocCoord [INPUTS] Two - The second DocCoord
Returns:
the DocCoord that is the first DocCoord minus the second DocCoord

Definition at line 671 of file doccoord.cpp.

00672 {
00673     DocCoord Result;
00674 
00675     // Subtract the two DocCoords from each other
00676     Result.x = One.x - Two.x;
00677     Result.y = One.y - Two.y;
00678 
00679     // return the result
00680     return Result;
00681 }


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