CMXReferArrow Class Reference

#include <cmxexdc.h>

Inheritance diagram for CMXReferArrow:

CMXReferListItem ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 CMXReferArrow (CMXExportDC *pDC)
void Set (ArrowRec *ptArrow)
INT32 IsInWhichDesc (void)
BOOL WriteInDesc (CMXExportDC *pDC)
 writes a arrowhead definition to the description section
BOOL AreYouThisArrow (ArrowRec *ptArrow)
INT32 IsInWhichIndex (void)
BOOL WriteInIndex (CMXExportDC *pDC)
 writes the index entry for the arrowhead
INT32 IndexEntrySize (CMXExportDC *pDC)

Protected Attributes

INT32 ArrowFilePosition
ArrowRecpArrow

Private Member Functions

 CC_DECLARE_DYNAMIC (CMXReferArrow)

Detailed Description

Definition at line 642 of file cmxexdc.h.


Constructor & Destructor Documentation

CMXReferArrow::CMXReferArrow CMXExportDC pDC  )  [inline]
 

Definition at line 647 of file cmxexdc.h.

00647 : CMXReferListItem(pDC) {pArrow = 0;};


Member Function Documentation

BOOL CMXReferArrow::AreYouThisArrow ArrowRec ptArrow  )  [inline]
 

Definition at line 654 of file cmxexdc.h.

00655         {return ((ptArrow->ArrowID == pArrow->ArrowID) || (ptArrow == pArrow))?TRUE:FALSE;};

CMXReferArrow::CC_DECLARE_DYNAMIC CMXReferArrow   )  [private]
 

INT32 CMXReferArrow::IndexEntrySize CMXExportDC pDC  )  [inline, virtual]
 

Reimplemented from CMXReferListItem.

Definition at line 659 of file cmxexdc.h.

00659 {return sizeof(cmxArrowIndexEntry);};

INT32 CMXReferArrow::IsInWhichDesc void   )  [inline, virtual]
 

Reimplemented from CMXReferListItem.

Definition at line 651 of file cmxexdc.h.

00651 {return cmxDESC_ARROW;};

INT32 CMXReferArrow::IsInWhichIndex void   )  [inline, virtual]
 

Reimplemented from CMXReferListItem.

Definition at line 657 of file cmxexdc.h.

00657 {return cmxINDEX_ARROW;};

void CMXReferArrow::Set ArrowRec ptArrow  )  [inline]
 

Definition at line 649 of file cmxexdc.h.

00649 {pArrow = ptArrow;};

BOOL CMXReferArrow::WriteInDesc CMXExportDC pDC  )  [virtual]
 

writes a arrowhead definition to the description section

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/07/96
Parameters:
none [INPUTS]
Returns:
success
See also:

Reimplemented from CMXReferListItem.

Definition at line 2920 of file cmxexdc.cpp.

02921 {
02922     // store the position of this thingy
02923     ArrowFilePosition = pDC->GetFilePosition();
02924 
02925     // start a tag
02926     if(!pDC->StartTag(cmxTAG_DescrSection_Arrow))
02927         return FALSE;
02928 
02929     // get some details about the path of the arrowhead
02930     Path *pPath = pArrow->GetArrowPath();
02931     ERROR2IF(pPath == NULL, FALSE, "no arrow path");
02932     INT32 NumCoords = pPath->GetNumCoords();
02933     DocCoord *Coords = pPath->GetCoordArray();
02934     PathVerb *Verbs = pPath->GetVerbArray();
02935     DocRect ArrowBBox;
02936     pDC->CalcCorelBBox(Coords, NumCoords, &ArrowBBox);
02937 
02938     // work out a matrix for transforming the arrowhead path
02939     DocCoord ArrowCentre = pArrow->GetArrowCentre();
02940     // this bounding box needs to be scaled so that it's in the required range
02941     INT32 dl = abs(ArrowCentre.x - ArrowBBox.lo.x);
02942     INT32 dr = abs(ArrowBBox.hi.x - ArrowCentre.x);
02943     INT32 db = abs(ArrowCentre.y - ArrowBBox.lo.y);
02944     INT32 dt = abs(ArrowBBox.hi.y - ArrowCentre.y);
02945     INT32 maxdist = (dl > dr)?dl:dr;
02946     maxdist = (maxdist > db)?maxdist:db;
02947     maxdist = (maxdist > dt)?maxdist:dt;
02948     // maxdist is the greatest distance from the centre point -- this is
02949     // the distance which determines the scaling factor
02950     double ScaleFactor =
02951         ((double)(pDC->IsThirtyTwoBit()?cmxARROWDEF_MAXCOORD32:cmxARROWDEF_MAXCOORD16))
02952         / ((double)maxdist);
02953     Matrix Mat((FIXED16)ScaleFactor, 0, 0, (FIXED16)ScaleFactor, - ArrowCentre.x, - ArrowCentre.y);
02954 
02955     // export the path, transforming each coordinate as we go along
02956 
02957     // do we need to add an extra point?
02958     BOOL BungInExtraPoint = FALSE;
02959     if(Coords[0] != Coords[NumCoords - 1])
02960         BungInExtraPoint = TRUE;
02961 
02962     // write the point count
02963     WORD Count = (WORD)NumCoords + (BungInExtraPoint?1:0);
02964     pDC->WriteData(&Count, sizeof(Count));
02965 
02966     // run through the coords writing and transforming
02967     INT32 l;
02968     for(l = 0; l < NumCoords; l++)
02969     {
02970         DocCoord Coord = Coords[l];
02971         Mat.transform(&Coord);
02972 
02973         // write it...
02974         if(pDC->IsThirtyTwoBit())
02975         {
02976             cmxPoint32 p = {Coord.x, Coord.y};
02977             pDC->WriteData(&p, sizeof(p));
02978         }
02979         else
02980         {
02981             cmxPoint16 p = {(SWORD)Coord.x, (SWORD)Coord.y};
02982             pDC->WriteData(&p, sizeof(p));
02983         }
02984     }
02985 
02986     if(BungInExtraPoint)
02987     {
02988         DocCoord Coord = Coords[0];
02989         Mat.transform(&Coord);
02990 
02991         // write it...
02992         if(pDC->IsThirtyTwoBit())
02993         {
02994             cmxPoint32 p = {Coord.x, Coord.y};
02995             pDC->WriteData(&p, sizeof(p));
02996         }
02997         else
02998         {
02999             cmxPoint16 p = {(SWORD)Coord.x, (SWORD)Coord.y};
03000             pDC->WriteData(&p, sizeof(p));
03001         }
03002     }
03003 
03004     // run through the verbs writing point types
03005     INT32 BezCount = 0;     // for counting Bez
03006     for(l = 0; l < NumCoords; l++)
03007     {
03008         BYTE Type;
03009 
03010         switch(Verbs[l] & (PT_LINETO | PT_MOVETO | PT_BEZIERTO))
03011         {
03012         case PT_MOVETO:
03013             {
03014                 Type = CMXNODETYPE_TYPE_MOVE | CMXNODETYPE_USER;
03015             
03016                 // wibble forwards through the verbs to see if the correspondingness is closed
03017                 for(INT32 lp = l + 1; lp < NumCoords; lp++)
03018                 {
03019                     // OK, is this a move?
03020                     if((Verbs[lp] & (PT_LINETO | PT_MOVETO | PT_BEZIERTO)) == PT_MOVETO)
03021                         break;
03022 
03023                     // is closefigure set?
03024                     if((Verbs[lp] & PT_CLOSEFIGURE) != 0)
03025                     {
03026                         Type |= CMXNODETYPE_CLOSED;
03027                         break;
03028                     }
03029                 }
03030             }
03031             BezCount = 0;
03032             break;
03033 
03034         case PT_LINETO:
03035             Type = CMXNODETYPE_TYPE_LINE | CMXNODETYPE_USER;
03036             BezCount = 0;
03037             break;
03038 
03039         case PT_BEZIERTO:
03040             // in CMX, the control points have type ARC, and the end points
03041             // have type CURVE. This code does the trickery.
03042             if(BezCount == 2)
03043             {
03044                 Type = CMXNODETYPE_TYPE_CURVE | CMXNODETYPE_USER;
03045             }
03046             else
03047             {
03048                 Type = CMXNODETYPE_TYPE_ARC;
03049             }
03050             BezCount++;
03051             if(BezCount > 2)
03052                 BezCount = 0;       // so that only the end points of beziers get user flag
03053             break;
03054 
03055         default:
03056             ERROR3("Unknown node type");
03057             break;
03058         }
03059 
03060         if((Verbs[l] & PT_CLOSEFIGURE) != 0)
03061         {
03062             if(!BungInExtraPoint || l != (NumCoords - 1))
03063                 Type |= CMXNODETYPE_CLOSED;
03064         }
03065 
03066         if(l == (NumCoords - 1) && !BungInExtraPoint)
03067             Type |= CMXNODETYPE_CLOSED;
03068 
03069         pDC->WriteData(&Type, sizeof(Type));
03070     }
03071 
03072     if(BungInExtraPoint)
03073     {
03074         BYTE Type = CMXNODETYPE_TYPE_LINE | CMXNODETYPE_USER | CMXNODETYPE_CLOSED;
03075         pDC->WriteData(&Type, sizeof(Type));
03076     }
03077 
03078     // write the line offset
03079     DWORD LineOffset = 0;
03080     if(!pDC->WriteData(&LineOffset, sizeof(LineOffset)))
03081         return FALSE;
03082 
03083     // end the tag
03084     if(!pDC->EndTag() || !pDC->WriteMinEndTag())
03085         return FALSE;
03086 
03087     return TRUE;
03088 }

BOOL CMXReferArrow::WriteInIndex CMXExportDC pDC  )  [virtual]
 

writes the index entry for the arrowhead

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/07/96
Parameters:
none [INPUTS]
Returns:
success
See also:

Reimplemented from CMXReferListItem.

Definition at line 3104 of file cmxexdc.cpp.

03105 {
03106     // make the entry
03107     cmxArrowIndexEntry En;
03108     En.FilePosition = ArrowFilePosition;
03109 
03110     // write it...
03111     return pDC->WriteData(&En, sizeof(En));
03112 }


Member Data Documentation

INT32 CMXReferArrow::ArrowFilePosition [protected]
 

Definition at line 659 of file cmxexdc.h.

ArrowRec* CMXReferArrow::pArrow [protected]
 

Definition at line 663 of file cmxexdc.h.


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