#include <cxfrgshp.h>
Inheritance diagram for CXaraFileRegularShape:
Static Public Member Functions | |
static BOOL | WritePreChildrenNative (BaseCamelotFilter *pFilter, NodeRegularShape *pShape) |
Base class holding code for exporting regular shapes to the new file format Writes a regular shape to the filter in native or web format. | |
static BOOL | WritePreChildrenWeb (BaseCamelotFilter *pFilter, NodeRegularShape *pShape) |
static BOOL | IsEllipse (NodeRegularShape *pShape) |
Tests the regular shape for particular attributes. See Also: <???>. | |
static BOOL | IsRectangle (NodeRegularShape *pShape) |
static BOOL | IsSimple (NodeRegularShape *pShape) |
static BOOL | IsComplex (NodeRegularShape *pShape) |
static BOOL | IsRounded (NodeRegularShape *pShape) |
static BOOL | IsStellated (NodeRegularShape *pShape) |
static BOOL | IsReformed (NodeRegularShape *pShape) |
Static Protected Member Functions | |
static BOOL | WriteShapeNative (BaseCamelotFilter *pFilter, NodeRegularShape *pShape) |
Writes a regular shape record to the filter. | |
static BOOL | WriteShapeWeb (BaseCamelotFilter *pFilter, NodeRegularShape *pShape) |
static BOOL | FixOldShape (NodeRegularShape *pShape) |
Fixes old regular shapes, i.e. those which have UTCentrePoint != DocCoord(0,0) by adjusting the UTCentrePoint, UTMajorAxis, UTMinorAxis, TransformMatrix. | |
static BOOL | WriteShapeGeneral (BaseCamelotFilter *pFilter, NodeRegularShape *pShape) |
Writes a generic regular shape record to the filter. | |
static BOOL | WriteShapeInvalid (BaseCamelotFilter *pFilter, NodeRegularShape *pShape) |
Called when earlier functions are asked to write an invalid shape to the file. We raise an ERROR3, then return FALSE. | |
static BYTE | GetFlags (NodeRegularShape *pShape) |
Retrieves flag information from node regular shapes. | |
static DocCoord | GetCentrePoint (NodeRegularShape *pShape) |
Functions to retrieve information from regular shapes. | |
static DocCoord | GetMajorAxis (NodeRegularShape *pShape) |
static DocCoord | GetMinorAxis (NodeRegularShape *pShape) |
static DocCoord | GetUTCentrePoint (NodeRegularShape *pShape) |
static DocCoord | GetUTMajorAxis (NodeRegularShape *pShape) |
static DocCoord | GetUTMinorAxis (NodeRegularShape *pShape) |
static INT32 | GetHeight (NodeRegularShape *pShape) |
static INT32 | GetWidth (NodeRegularShape *pShape) |
static UINT16 | GetNumberOfSides (NodeRegularShape *pShape) |
static double | GetCurvature (NodeRegularShape *pShape) |
static double | GetPrimaryCurvature (NodeRegularShape *pShape) |
static double | GetSecondaryCurvature (NodeRegularShape *pShape) |
static double | GetStellationRadius (NodeRegularShape *pShape) |
static double | GetStellationOffset (NodeRegularShape *pShape) |
static Matrix | GetTransformMatrix (NodeRegularShape *pShape) |
static Path * | GetEdgePath (NodeRegularShape *pShape) |
static Path * | GetPrimaryEdgePath (NodeRegularShape *pShape) |
static Path * | GetSecondaryEdgePath (NodeRegularShape *pShape) |
Static Protected Attributes | |
static const double | mEpsilon = 0.000016 |
Epsilon value used for checking matrix type See Also: CXaraFileRegularShape::IsIdentity. |
Definition at line 125 of file cxfrgshp.h.
|
Fixes old regular shapes, i.e. those which have UTCentrePoint != DocCoord(0,0) by adjusting the UTCentrePoint, UTMajorAxis, UTMinorAxis, TransformMatrix.
Definition at line 243 of file cxfrgshp.cpp. 00244 { 00245 // since the UTCentrePoint is != DocCoord(0,0), we need to fix the major axis, minor 00246 // axis and the transform before we can save them. The idea is to get the 00247 // UTCentrePoint = DocCoord(0,0), and alter the other variables so that the transformed 00248 // remains the same. 00249 00250 DocCoord MyUTCentrePointOld; 00251 DocCoord MyUTCentrePointNew; 00252 00253 Matrix MyTransformOld; 00254 Matrix MyTransformNew; 00255 Matrix MyTransformNewInverse; 00256 00257 DocCoord MyUTMajorAxisOld; 00258 DocCoord MyUTMajorAxisNew; 00259 DocCoord MyUTMinorAxisOld; 00260 DocCoord MyUTMinorAxisNew; 00261 00262 { 00263 // retrieve the all values 00264 MyUTCentrePointOld = pShape->GetUTCentrePoint(); 00265 pShape->GetTransformMatrix(&MyTransformOld); 00266 MyUTMajorAxisOld = pShape->GetUTMajorAxes(); 00267 MyUTMinorAxisOld = pShape->GetUTMinorAxes(); 00268 } 00269 00270 { 00271 // set the new UTCentrePoint. Simple really, and the compiler should constant-fold 00272 // this variable away. 00273 MyUTCentrePointNew = DocCoord(0,0); 00274 } 00275 00276 { 00277 // calculate the new transform matrix. We know that 00278 // 00279 // UTCentrePointOld * TransformOld = UTCentrePointNew * TransformNew 00280 // 00281 // and that UTCentrePointNew = DocCoord(0,0). Hence (you can probably guess what I 00282 // mean by this) TransformNew.matrix = TransformOld.matrix and 00283 // TransformNew.translation = TransformedCentrePoint. 00284 00285 DocCoord MyCentrePoint; 00286 00287 MyCentrePoint = pShape->GetUTCentrePoint(); 00288 MyTransformOld.transform(&MyCentrePoint); 00289 MyTransformNew = MyTransformOld; 00290 MyTransformNew.SetTranslation(MyCentrePoint); 00291 00292 MyTransformNewInverse = MyTransformNew.Inverse(); 00293 } 00294 00295 { 00296 // calculate the new major and minor axes. Since: 00297 // 00298 // UTMajorAxisOld * TransformOld = UTMajorAxisNew * TransformNew 00299 // 00300 // then 00301 // 00302 // UTMajorAxisNew = (UTMajorAxisOld * TransformOld) * TransformNew' 00303 00304 MyUTMajorAxisNew = MyUTMajorAxisOld; 00305 MyTransformOld.transform(&MyUTMajorAxisNew); 00306 MyTransformNewInverse.transform(&MyUTMajorAxisNew); 00307 00308 MyUTMinorAxisNew = MyUTMinorAxisOld; 00309 MyTransformOld.transform(&MyUTMinorAxisNew); 00310 MyTransformNewInverse.transform(&MyUTMinorAxisNew); 00311 } 00312 00313 { 00314 // now set the variables to their new values. 00315 00316 pShape->SetCentrePoint(MyUTCentrePointNew); 00317 pShape->SetTransformMatrix(&MyTransformNew); 00318 pShape->SetMajorAxes(MyUTMajorAxisNew); 00319 pShape->SetMinorAxes(MyUTMinorAxisNew); 00320 } 00321 00322 return TRUE; 00323 }
|
|
Functions to retrieve information from regular shapes.
Definition at line 527 of file cxfrgshp.cpp. 00528 { 00529 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00530 00531 return (pShape->GetCentrePoint()); 00532 }
|
|
Definition at line 597 of file cxfrgshp.cpp. 00598 { 00599 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00600 00601 return pShape->GetPrimaryCurveToPrimary(); 00602 }
|
|
Definition at line 642 of file cxfrgshp.cpp. 00643 { 00644 ERROR2IF(pShape==NULL, NULL, "parameter pShape == NULL"); 00645 00646 return &(pShape->EdgePath1); 00647 }
|
|
Retrieves flag information from node regular shapes.
Definition at line 481 of file cxfrgshp.cpp. 00482 { 00483 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00484 00485 BYTE result = 0; 00486 00487 // !!HACK!! constants in code. 00488 // !!HACK!! see RegularShapeRecordHandler::SetFlags for the other bit of code which 00489 // !!HACK!! needs these constants. 00490 if (pShape->IsCircular()) result |= 0x1; 00491 if (pShape->IsStellated()) result |= 0x2; 00492 if (pShape->IsPrimaryCurvature()) result |= 0x4; 00493 if (pShape->IsStellationCurvature()) result |= 0x8; 00494 00495 return result; 00496 }
|
|
Definition at line 576 of file cxfrgshp.cpp. 00577 { 00578 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00579 00580 return 2*abs(GetMajorAxis(pShape).y + GetMinorAxis(pShape).y); 00581 }
|
|
Definition at line 535 of file cxfrgshp.cpp. 00536 { 00537 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00538 00539 return (pShape->GetMajorAxes() - pShape->GetCentrePoint()); 00540 }
|
|
Definition at line 543 of file cxfrgshp.cpp. 00544 { 00545 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00546 00547 return (pShape->GetMinorAxes() - pShape->GetCentrePoint()); 00548 }
|
|
Definition at line 590 of file cxfrgshp.cpp. 00591 { 00592 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00593 00594 return pShape->GetNumSides(); 00595 }
|
|
Definition at line 604 of file cxfrgshp.cpp. 00605 { 00606 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00607 00608 return pShape->GetPrimaryCurveToPrimary(); 00609 }
|
|
Definition at line 649 of file cxfrgshp.cpp. 00650 { 00651 ERROR2IF(pShape==NULL, NULL, "parameter pShape == NULL"); 00652 00653 return &(pShape->EdgePath1); 00654 }
|
|
Definition at line 611 of file cxfrgshp.cpp. 00612 { 00613 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00614 00615 return pShape->GetStellCurveToStell(); 00616 }
|
|
Definition at line 656 of file cxfrgshp.cpp. 00657 { 00658 ERROR2IF(pShape==NULL, NULL, "parameter pShape == NULL"); 00659 00660 return &(pShape->EdgePath2); 00661 }
|
|
Definition at line 625 of file cxfrgshp.cpp. 00626 { 00627 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00628 00629 return pShape->GetStellationRatio(); 00630 }
|
|
Definition at line 618 of file cxfrgshp.cpp. 00619 { 00620 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00621 00622 return pShape->GetStellRadiusToPrimary(); 00623 }
|
|
Definition at line 632 of file cxfrgshp.cpp. 00633 { 00634 // ERROR2IF(pShape==NULL, Matrix(), "parameter pShape == NULL"); 00635 Matrix m; 00636 00637 pShape->GetTransformMatrix(&m); 00638 00639 return m; 00640 }
|
|
Definition at line 550 of file cxfrgshp.cpp. 00551 { 00552 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00553 00554 return (pShape->GetUTCentrePoint()); 00555 }
|
|
Definition at line 558 of file cxfrgshp.cpp. 00559 { 00560 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00561 00562 return pShape->GetUTMajorAxes(); 00563 }
|
|
Definition at line 566 of file cxfrgshp.cpp. 00567 { 00568 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00569 00570 return pShape->GetUTMinorAxes(); 00571 }
|
|
Definition at line 583 of file cxfrgshp.cpp. 00584 { 00585 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00586 00587 return 2*abs(GetMajorAxis(pShape).x + GetMinorAxis(pShape).x); 00588 }
|
|
Definition at line 441 of file cxfrgshp.cpp. 00442 { 00443 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00444 00445 return !(IsSimple(pShape)); 00446 }
|
|
Tests the regular shape for particular attributes. See Also: <???>.
Definition at line 401 of file cxfrgshp.cpp. 00402 { 00403 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00404 00405 return pShape->IsCircular(); 00406 }
|
|
Definition at line 408 of file cxfrgshp.cpp. 00409 { 00410 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00411 00412 // by rectangular, we mean it's not circular, and has four sides. A 'four-sided 00413 // polygon' would be a better name, but we stick with rectangle for legacy reasons. 00414 // i.e. I can't be bothered to change everything now. 00415 00416 return (!IsEllipse(pShape)) && (GetNumberOfSides(pShape) == 4); 00417 }
|
|
Definition at line 462 of file cxfrgshp.cpp. 00463 { 00464 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00465 00466 return pShape->IsReformed(); 00467 }
|
|
Definition at line 448 of file cxfrgshp.cpp. 00449 { 00450 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00451 00452 return pShape->IsPrimaryCurvature(); 00453 }
|
|
Definition at line 419 of file cxfrgshp.cpp. 00420 { 00421 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00422 00423 // check to see if the transformation is just a translation, and that the major and 00424 // minor axes are perpendicular and parallel to the y and x axes respectively 00425 Matrix MyMatrix; 00426 BOOL FlagIsTranslation; 00427 DocCoord MajorAxis; 00428 DocCoord MinorAxis; 00429 00430 pShape->GetTransformMatrix(&MyMatrix); 00431 FlagIsTranslation = MyMatrix.IsTranslation(mEpsilon); 00432 MajorAxis = pShape->GetUTMajorAxes(); 00433 MinorAxis = pShape->GetUTMinorAxes(); 00434 00435 return ((FlagIsTranslation && MajorAxis.x == 0 && MinorAxis.y == 0) || 00436 (FlagIsTranslation && MajorAxis.y == 0 && MinorAxis.x == 0)); 00437 00438 // return MyMatrix.IsTranslation(mEpsilon) && MajorAxis.x == 0 && MinorAxis.y == 0; 00439 }
|
|
Definition at line 455 of file cxfrgshp.cpp. 00456 { 00457 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00458 00459 return pShape->IsStellated(); 00460 }
|
|
Base class holding code for exporting regular shapes to the new file format Writes a regular shape to the filter in native or web format.
Definition at line 138 of file cxfrgshp.cpp. 00139 { 00140 ERROR2IF(pFilter == NULL, FALSE, "Argument pFilter == NULL."); 00141 ERROR2IF(pShape == NULL, FALSE, "Argument pShape == NULL."); 00142 00143 // Due to last minute changes, of course after the spec was approved, we now use this for native 00144 // and the pants web files. There is a new flag to say if we are doing a compact native AKA the web file 00145 // half way between the true web file and the full native file. 00146 if (pFilter->IsCompactNativeFilter() || pFilter->WriteSpecificRegularShapes()) 00147 return WriteShapeWeb(pFilter, pShape); 00148 00149 return WriteShapeNative(pFilter, pShape); 00150 }
|
|
Definition at line 152 of file cxfrgshp.cpp. 00153 { 00154 ERROR2IF(pFilter == NULL, FALSE, "Argument pFilter == NULL."); 00155 ERROR2IF(pShape == NULL, FALSE, "Argument pShape == NULL."); 00156 00157 return WriteShapeWeb(pFilter, pShape); 00158 }
|
|
Writes a generic regular shape record to the filter.
Definition at line 338 of file cxfrgshp.cpp. 00339 { 00340 BOOL ok; 00341 00342 CamelotFileRecord Rec(pFilter, TAG_REGULAR_SHAPE_PHASE_2, TAG_REGULAR_SHAPE_PHASE_2_SIZE); 00343 00344 ok = Rec.Init(); 00345 if (ok) ok = Rec.WriteBYTE(GetFlags(pShape)); 00346 if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape)); 00347 if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0); 00348 if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0); 00349 if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape)); 00350 if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape)); 00351 if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape)); 00352 if (ok) ok = Rec.WriteDOUBLE(GetPrimaryCurvature(pShape)); 00353 if (ok) ok = Rec.WriteDOUBLE(GetSecondaryCurvature(pShape)); 00354 if (ok) ok = Rec.WritePath(GetPrimaryEdgePath(pShape)); 00355 if (ok) ok = Rec.WritePath(GetSecondaryEdgePath(pShape)); 00356 if (ok) ok = pFilter->Write(&Rec); 00357 00358 return ok; 00359 }
|
|
Called when earlier functions are asked to write an invalid shape to the file. We raise an ERROR3, then return FALSE.
Definition at line 375 of file cxfrgshp.cpp.
|
|
Writes a regular shape record to the filter.
Definition at line 174 of file cxfrgshp.cpp. 00175 { 00176 ERROR2IF(pFilter == NULL, FALSE, "Argument pFilter == NULL."); 00177 ERROR2IF(pShape == NULL, FALSE, "Argument pShape == NULL."); 00178 00179 NodeRegularShape MyRegularShape; 00180 BOOL ok = TRUE; 00181 00182 if (GetUTCentrePoint(pShape) != DocCoord(0,0)) 00183 { 00184 // sigh, we've got a very old regular shape, where the UT Centre Point isn't the 00185 // origin (it is for all v1.0 and later versions of Camelot). Instead we make a copy 00186 // of the shape, fix the coordinates and then save it. 00187 pShape->CopyNodeContents(&MyRegularShape); 00188 if (ok) ok = FixOldShape(&MyRegularShape); 00189 pShape = &MyRegularShape; 00190 } 00191 00192 if (ok) ok = CXaraFileRegularShape::WriteShapeGeneral(pFilter, pShape); 00193 00194 return ok; 00195 }
|
|
Definition at line 197 of file cxfrgshp.cpp. 00198 { 00199 ERROR2IF(pFilter == NULL, FALSE, "Argument pFilter == NULL."); 00200 ERROR2IF(pShape == NULL, FALSE, "Argument pShape == NULL."); 00201 00202 NodeRegularShape MyRegularShape; 00203 BOOL ok = TRUE; 00204 00205 if (GetUTCentrePoint(pShape) != DocCoord(0,0)) 00206 { 00207 // sigh, we've got a very old regular shape, where the UT Centre Point isn't the 00208 // origin (it is for all v1.0 and later versions of Camelot). Instead we make a copy 00209 // of the shape, fix the coordinates and then save it. 00210 pShape->CopyNodeContents(&MyRegularShape); 00211 if (ok) ok = FixOldShape(&MyRegularShape); 00212 pShape = &MyRegularShape; 00213 } 00214 00215 if (IsEllipse(pShape)) 00216 { 00217 ok = CXaraFileEllipse::WriteEllipse(pFilter, pShape); 00218 } 00219 else if (IsRectangle(pShape)) 00220 { 00221 ok = CXaraFileRectangle::WriteRectangle(pFilter, pShape); 00222 } 00223 else // it's a polygon 00224 { 00225 ok = CXaraFilePolygon::WritePolygon(pFilter, pShape); 00226 } 00227 return ok; 00228 }
|
|
Epsilon value used for checking matrix type See Also: CXaraFileRegularShape::IsIdentity.
Definition at line 182 of file cxfrgshp.h. |