RegularShapeRecordHandler Class Reference

Base class record handler for regular shapesBase record handler for regular shapes, used when importing regular shapes from the new file format. More...

#include <rechrshp.h>

Inheritance diagram for RegularShapeRecordHandler:

CamelotRecordHandler CXaraFileRecordHandler ListItem CCObject SimpleCCObject EllipseRecordHandler PolygonRecordHandler RectangleRecordHandler List of all members.

Public Member Functions

 RegularShapeRecordHandler ()
 ~RegularShapeRecordHandler ()
UINT32GetTagList ()
 Returns an array of records handled by this class. See Also: <???>.
BOOL HandleRecord (CXaraFileRecord *pCXaraFileRecord)
 Reads a regular shape record from a CXaraFile.

Protected Member Functions

virtual BOOL ReadShapeInvalid (CXaraFileRecord *pCXaraFileRecord)
 Called when this class is asked to read a record it doesn't know about. We raise an ERROR3 and return FALSE.
BOOL SetupShape (NodeRegularShape *pShape)
 Functions to set various pieces of information in a regular shape.
BOOL InvalidateCache (NodeRegularShape *pShape)
BOOL SetCentrePoint (NodeRegularShape *pShape, const DocCoord &CentrePoint)
BOOL SetUTCentrePoint (NodeRegularShape *pShape, const DocCoord &UTCentrePoint)
BOOL SetMajorAxis (NodeRegularShape *pShape, const DocCoord &MajorAxis)
BOOL SetMinorAxis (NodeRegularShape *pShape, const DocCoord &MinorAxis)
BOOL SetHeightAndWidth (NodeRegularShape *pShape, const INT32 &Height, const INT32 &Width)
BOOL SetNumberOfSides (NodeRegularShape *pShape, const INT32 &NumSides)
BOOL SetCurvature (NodeRegularShape *pShape, const double &Curvature)
BOOL SetPrimaryCurvature (NodeRegularShape *pShape, const double &PrimaryCurvature)
BOOL SetSecondaryCurvature (NodeRegularShape *pShape, const double &SecondaryCurvature)
BOOL SetStellationRadius (NodeRegularShape *pShape, const double &StellationRadius)
BOOL SetStellationOffset (NodeRegularShape *pShape, const double &StellationOffset)
BOOL SetTransformMatrix (NodeRegularShape *pShape, const Matrix &NewMatrix)
BOOL SetIsCircular (NodeRegularShape *pShape, const BOOL &IsCircular)
BOOL SetIsStellated (NodeRegularShape *pShape, const BOOL &IsStellated)
BOOL SetIsRounded (NodeRegularShape *pShape, const BOOL &Value)
BOOL SetFlags (NodeRegularShape *pShape, const BYTE &Value)
 Sets various flags in node regular shapes.

Private Member Functions

 CC_DECLARE_DYNAMIC (RegularShapeRecordHandler)
BOOL ReadShapeGeneralPhase1 (CXaraFileRecord *pCXaraFileRecord)
 <???>
BOOL ReadShapeGeneralPhase2 (CXaraFileRecord *pCXaraFileRecord)

Detailed Description

Base class record handler for regular shapesBase record handler for regular shapes, used when importing regular shapes from the new file format.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/06/96 Base Class: CamelotRecordHandler

Definition at line 124 of file rechrshp.h.


Constructor & Destructor Documentation

RegularShapeRecordHandler::RegularShapeRecordHandler  )  [inline]
 

Definition at line 130 of file rechrshp.h.

00130 {};

RegularShapeRecordHandler::~RegularShapeRecordHandler  )  [inline]
 

Definition at line 131 of file rechrshp.h.

00131 {};


Member Function Documentation

RegularShapeRecordHandler::CC_DECLARE_DYNAMIC RegularShapeRecordHandler   )  [private]
 

UINT32 * RegularShapeRecordHandler::GetTagList  )  [virtual]
 

Returns an array of records handled by this class. See Also: <???>.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/06/96
Parameters:
- [INPUTS]
Returns:
UINT32* to an array of records handled by this class.

Implements CXaraFileRecordHandler.

Reimplemented in EllipseRecordHandler, PolygonRecordHandler, and RectangleRecordHandler.

Definition at line 135 of file rechrshp.cpp.

00136 {
00137     static UINT32 TagList[] = {TAG_REGULAR_SHAPE_PHASE_1,
00138                               TAG_REGULAR_SHAPE_PHASE_2,
00139                               CXFRH_TAG_LIST_END};
00140     return &TagList[0];
00141 }

BOOL RegularShapeRecordHandler::HandleRecord CXaraFileRecord pCXaraFileRecord  )  [virtual]
 

Reads a regular shape record from a CXaraFile.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/06/96
Parameters:
pCXaraFileRecord - pointer to a CXaraFileRecord to read [INPUTS]
Returns:
TRUE if successful, FALSE otherwise

Implements CXaraFileRecordHandler.

Reimplemented in EllipseRecordHandler, PolygonRecordHandler, and RectangleRecordHandler.

Definition at line 155 of file rechrshp.cpp.

00156 {
00157     BOOL ok;
00158 
00159     // see kernel/cxftags.h for a description of the differences between these two tags - ach
00160     switch (pCXaraFileRecord->GetTag())
00161     {
00162         case TAG_REGULAR_SHAPE_PHASE_1  : ok = ReadShapeGeneralPhase1(pCXaraFileRecord);
00163                                                   break;
00164         case TAG_REGULAR_SHAPE_PHASE_2  : ok = ReadShapeGeneralPhase2(pCXaraFileRecord);
00165                                                   break;
00166         default                                 : ok = ReadShapeInvalid(pCXaraFileRecord);
00167                                                   break;
00168     }
00169 
00170     return ok;
00171 }

BOOL RegularShapeRecordHandler::InvalidateCache NodeRegularShape pShape  )  [protected]
 

Definition at line 366 of file rechrshp.cpp.

00367 {
00368     pShape->InvalidateCache();
00369     return TRUE;
00370 }

BOOL RegularShapeRecordHandler::ReadShapeGeneralPhase1 CXaraFileRecord pCXaraFileRecord  )  [private]
 

<???>

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/06/96
Parameters:
pCXaraFileRecord - pointer to a CXaraFileRecord to read [INPUTS]
Returns:
TRUE if successful, FALSE otherwise

Definition at line 186 of file rechrshp.cpp.

00187 {
00188     BOOL ok = TRUE;
00189 
00190     NodeRegularShape * pShape;
00191     BYTE Flags;
00192     UINT16 NumberOfSides;
00193     DocCoord UTCentrePoint;
00194     DocCoord MajorAxis;
00195     DocCoord MinorAxis;
00196     Matrix TransformMatrix;
00197     double StellationRadius;
00198     double StellationOffset;
00199     double PrimaryCurvature;
00200     double SecondaryCurvature;
00201     
00202     pShape = new NodeRegularShape;
00203 
00204     if (ok) ok = SetupShape(pShape);
00205 
00206     if (ok) ok = pCXaraFileRecord->ReadBYTE(&Flags);
00207     if (ok) ok = SetFlags(pShape, Flags);
00208     
00209     if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00210     if (ok) ok = SetNumberOfSides(pShape, NumberOfSides);
00211 
00212     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&UTCentrePoint,0,0);
00213     if (ok) ok = SetUTCentrePoint(pShape, UTCentrePoint);
00214 
00215     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00216     if (ok) ok = SetMajorAxis(pShape, MajorAxis);
00217 
00218     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00219     if (ok) ok = SetMinorAxis(pShape, MinorAxis);
00220 
00221     if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00222     if (ok) ok = SetTransformMatrix(pShape, TransformMatrix);
00223 
00224     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00225     if (ok) ok = SetStellationRadius(pShape, StellationRadius);
00226 
00227     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00228     if (ok) ok = SetStellationOffset(pShape, StellationOffset);
00229 
00230     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00231     if (ok) ok = SetPrimaryCurvature(pShape, PrimaryCurvature);
00232 
00233     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00234     if (ok) ok = SetSecondaryCurvature(pShape, SecondaryCurvature);
00235 
00236     if (ok) ok = pCXaraFileRecord->ReadPath(&(pShape->EdgePath1));
00237     if (ok) ok = pCXaraFileRecord->ReadPath(&(pShape->EdgePath2));
00238     
00239     if (ok) ok = InvalidateCache(pShape);
00240     if (ok) ok = InsertNode(pShape);
00241 
00242     return ok;
00243 }

BOOL RegularShapeRecordHandler::ReadShapeGeneralPhase2 CXaraFileRecord pCXaraFileRecord  )  [private]
 

Definition at line 245 of file rechrshp.cpp.

00246 {
00247     BOOL ok = TRUE;
00248 
00249     NodeRegularShape * pShape;
00250     BYTE Flags;
00251     UINT16 NumberOfSides;
00252     DocCoord MajorAxis;
00253     DocCoord MinorAxis;
00254     Matrix TransformMatrix;
00255     double StellationRadius;
00256     double StellationOffset;
00257     double PrimaryCurvature;
00258     double SecondaryCurvature;
00259     
00260     pShape = new NodeRegularShape;
00261 
00262     if (ok) ok = SetupShape(pShape);
00263 
00264     if (ok) ok = pCXaraFileRecord->ReadBYTE(&Flags);
00265     if (ok) ok = SetFlags(pShape, Flags);
00266     
00267     if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00268     if (ok) ok = SetNumberOfSides(pShape, NumberOfSides);
00269 
00270     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00271     if (ok) ok = SetMajorAxis(pShape, MajorAxis);
00272 
00273     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00274     if (ok) ok = SetMinorAxis(pShape, MinorAxis);
00275 
00276     if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00277     if (ok) ok = SetTransformMatrix(pShape, TransformMatrix);
00278 
00279     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00280     if (ok) ok = SetStellationRadius(pShape, StellationRadius);
00281 
00282     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00283     if (ok) ok = SetStellationOffset(pShape, StellationOffset);
00284 
00285     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00286     if (ok) ok = SetPrimaryCurvature(pShape, PrimaryCurvature);
00287 
00288     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00289     if (ok) ok = SetSecondaryCurvature(pShape, SecondaryCurvature);
00290 
00291     if (ok) ok = pCXaraFileRecord->ReadPath(&(pShape->EdgePath1));
00292     if (ok) ok = pCXaraFileRecord->ReadPath(&(pShape->EdgePath2));
00293     
00294     if (ok) ok = InvalidateCache(pShape);
00295     if (ok) ok = InsertNode(pShape);
00296 
00297     return ok;
00298 }

BOOL RegularShapeRecordHandler::ReadShapeInvalid CXaraFileRecord pCXaraFileRecord  )  [protected, virtual]
 

Called when this class is asked to read a record it doesn't know about. We raise an ERROR3 and return FALSE.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/06/96
Parameters:
pCXaraFileRecord - points to a CXaraFileRecord to read [INPUTS]
Returns:
FALSE

Definition at line 313 of file rechrshp.cpp.

00314 {
00315     ERROR3("Attempt to read an invalid shape.");
00316     return FALSE;
00317 }

BOOL RegularShapeRecordHandler::SetCentrePoint NodeRegularShape pShape,
const DocCoord CentrePoint
[protected]
 

Definition at line 376 of file rechrshp.cpp.

00377 {
00378     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00379 
00380     Matrix m = Matrix(CentrePoint);
00381     pShape->SetTransformMatrix(&m);
00382 
00383     return TRUE;
00384 }

BOOL RegularShapeRecordHandler::SetCurvature NodeRegularShape pShape,
const double &  Curvature
[protected]
 

Definition at line 431 of file rechrshp.cpp.

00432 {
00433     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00434 
00435     pShape->SetPrimaryCurveToPrimary(Curvature);
00436     return TRUE;
00437 }

BOOL RegularShapeRecordHandler::SetFlags NodeRegularShape pShape,
const BYTE &  Value
[protected]
 

Sets various flags in node regular shapes.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/06/96
Parameters:
pShape - node regular shape to write to [INPUTS] BYTE x - flags information to write
Returns:
TRUE if successful, FALSE otherwise

Definition at line 515 of file rechrshp.cpp.

00516 {
00517     // !!HACK!! constants embedded in code
00518     // !!HACK!! see CXaraFileRegularShape::GetFlags for the other code which needs to
00519     // !!HACK!! understand how the flags are packed into the byte.
00520     if ((Value & 0x1) == 0x1) pShape->SetCircular(TRUE);
00521     if ((Value & 0x2) == 0x2) pShape->SetStellated(TRUE);
00522     if ((Value & 0x4) == 0x4) pShape->SetPrimaryCurvature(TRUE);
00523     if ((Value & 0x8) == 0x8) pShape->SetStellationCurvature(TRUE);
00524 
00525     return TRUE;
00526 }

BOOL RegularShapeRecordHandler::SetHeightAndWidth NodeRegularShape pShape,
const INT32 &  Height,
const INT32 &  Width
[protected]
 

Definition at line 414 of file rechrshp.cpp.

00415 {
00416     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00417 
00418     SetMajorAxis(pShape, DocCoord(0, Height/2));
00419     SetMinorAxis(pShape, DocCoord(Width/2, 0));
00420     return TRUE;
00421 }

BOOL RegularShapeRecordHandler::SetIsCircular NodeRegularShape pShape,
const BOOL &  IsCircular
[protected]
 

Definition at line 477 of file rechrshp.cpp.

00478 {
00479     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00480 
00481     pShape->SetCircular(IsCircular);
00482     return TRUE;
00483 }

BOOL RegularShapeRecordHandler::SetIsRounded NodeRegularShape pShape,
const BOOL &  Value
[protected]
 

Definition at line 493 of file rechrshp.cpp.

00494 {
00495     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00496 
00497     pShape->SetPrimaryCurvature(IsRounded);
00498     pShape->SetStellationCurvature(IsRounded);
00499     return TRUE;
00500 }

BOOL RegularShapeRecordHandler::SetIsStellated NodeRegularShape pShape,
const BOOL &  IsStellated
[protected]
 

Definition at line 485 of file rechrshp.cpp.

00486 {
00487     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00488 
00489     pShape->SetStellated(IsStellated);
00490     return TRUE;
00491 }

BOOL RegularShapeRecordHandler::SetMajorAxis NodeRegularShape pShape,
const DocCoord MajorAxis
[protected]
 

Definition at line 395 of file rechrshp.cpp.

00396 {
00397     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00398 
00399     pShape->SetMajorAxes(MajorAxis);
00400     return TRUE;
00401 }

BOOL RegularShapeRecordHandler::SetMinorAxis NodeRegularShape pShape,
const DocCoord MinorAxis
[protected]
 

Definition at line 404 of file rechrshp.cpp.

00405 {
00406     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00407 
00408     pShape->SetMinorAxes(MinorAxis);
00409     return TRUE;
00410 }

BOOL RegularShapeRecordHandler::SetNumberOfSides NodeRegularShape pShape,
const INT32 &  NumSides
[protected]
 

Definition at line 423 of file rechrshp.cpp.

00424 {
00425     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00426 
00427     pShape->SetNumSides(NumberOfSides);
00428     return TRUE;
00429 }

BOOL RegularShapeRecordHandler::SetPrimaryCurvature NodeRegularShape pShape,
const double &  PrimaryCurvature
[protected]
 

Definition at line 439 of file rechrshp.cpp.

00440 {
00441     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00442 
00443     pShape->SetPrimaryCurveToPrimary(PrimaryCurvature);
00444     return TRUE;
00445 }

BOOL RegularShapeRecordHandler::SetSecondaryCurvature NodeRegularShape pShape,
const double &  SecondaryCurvature
[protected]
 

Definition at line 447 of file rechrshp.cpp.

00448 {
00449     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00450 
00451     pShape->SetStellCurveToStell(SecondaryCurvature);
00452     return TRUE;
00453 }

BOOL RegularShapeRecordHandler::SetStellationOffset NodeRegularShape pShape,
const double &  StellationOffset
[protected]
 

Definition at line 463 of file rechrshp.cpp.

00464 {
00465     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00466 
00467     pShape->SetStellationRatio(StellationOffset);
00468     return TRUE;
00469 }

BOOL RegularShapeRecordHandler::SetStellationRadius NodeRegularShape pShape,
const double &  StellationRadius
[protected]
 

Definition at line 455 of file rechrshp.cpp.

00456 {
00457     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00458 
00459     pShape->SetStellRadiusToPrimary(StellationRadius);
00460     return TRUE;
00461 }

BOOL RegularShapeRecordHandler::SetTransformMatrix NodeRegularShape pShape,
const Matrix NewMatrix
[protected]
 

Definition at line 471 of file rechrshp.cpp.

00472 {
00473     pShape->SetTransformMatrix(&NewMatrix);
00474     return TRUE;
00475 }

BOOL RegularShapeRecordHandler::SetupShape NodeRegularShape pShape  )  [protected]
 

Functions to set various pieces of information in a regular shape.

BOOL RegularShapeRecordHandler::SetCentrePoint(NodeRegularShape *pShape, const DocCoord & CentrePoint); BOOL RegularShapeRecordHandler::SetMajorAxis(NodeRegularShape *pShape, const DocCoord & MajorAxis); BOOL RegularShapeRecordHandler::SetMinorAxis(NodeRegularShape *pShape, const DocCoord & MinorAxis); BOOL RegularShapeRecordHandler::SetHeightAndWidth(NodeRegularShape *pShape, const INT32 & Height, const INT32 & Width); BOOL RegularShapeRecordHandler::SetNumberOfSides(NodeRegularShape *pShape, const INT32 & NumSides); BOOL RegularShapeRecordHandler::SetCurvature(NodeRegularShape *pShape, const double & Curvature); BOOL RegularShapeRecordHandler::SetPrimaryCurvature(NodeRegularShape *pShape, const double & PrimaryCurvature); BOOL RegularShapeRecordHandler::SetSecondaryCurvature(NodeRegularShape *pShape, const double & SecondaryCurvature); BOOL RegularShapeRecordHandler::SetStellationRadius(NodeRegularShape *pShape, const double & StellationRadius); BOOL RegularShapeRecordHandler::SetStellationOffset(NodeRegularShape *pShape, const double & StellationOffset); BOOL RegularShapeRecordHandler::SetEdgePath(NodeRegularShape *pShape, const Path & NewPath); BOOL RegularShapeRecordHandler::SetPrimaryEdgePath(NodeRegularShape *pShape, const Path & NewPrimaryPath); BOOL RegularShapeRecordHandler::SetSecondaryEdgePath(NodeRegularShape *pShape, const Path & NewSecondaryPath); BOOL RegularShapeRecordHandler::SetTransformMatrix(NodeRegularShape *pShape, const Matrix & NewMatrix); BOOL RegularShapeRecordHandler::SetCircular(NodeRegularShape *pShape, const BOOL & IsCircular); BOOL RegularShapeRecordHandler::SetStellated(NodeRegularShape *pShape, const BOOL & IsStellated); BOOL RegularShapeRecordHandler::SetPrimaryCurvature(NodeRegularShape *pShape, const BOOL & Value); BOOL RegularShapeRecordHandler::SetStellationCurvature(NodeRegularShape *pShape, const BOOL & Value);

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/06/96
Parameters:
xxx - information to set [INPUTS] pShape - regular shape to alter
Returns:
-

Definition at line 352 of file rechrshp.cpp.

00353 {
00354     DocCoord Origin = DocCoord(0,0);
00355 
00356     pShape->SetCentrePoint(Origin);
00357     pShape->SetMinorAxes(Origin);
00358     pShape->SetMajorAxes(Origin);
00359 
00360     Matrix m = Matrix();    // Identity transform
00361     pShape->SetTransformMatrix(&m);
00362 
00363     return pShape->SetUpShape();
00364 }

BOOL RegularShapeRecordHandler::SetUTCentrePoint NodeRegularShape pShape,
const DocCoord UTCentrePoint
[protected]
 

Definition at line 386 of file rechrshp.cpp.

00387 {
00388     ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL");
00389     
00390     pShape->SetCentrePoint(CentrePoint);
00391     return TRUE;
00392 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:00:25 2007 for Camelot by  doxygen 1.4.4