00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 #include "camtypes.h"
00110
00111 #include "nodershp.h"
00112
00113
00114 #include "cxftags.h"
00115
00116
00117
00118 #include "rechrshp.h"
00119 #include "rechpoly.h"
00120
00121
00122 CC_IMPLEMENT_DYNAMIC(PolygonRecordHandler, RegularShapeRecordHandler);
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 UINT32* PolygonRecordHandler::GetTagList()
00139 {
00140 static UINT32 TagList[] = {TAG_POLYGON_COMPLEX,
00141 TAG_POLYGON_COMPLEX_REFORMED,
00142 TAG_POLYGON_COMPLEX_STELLATED,
00143 TAG_POLYGON_COMPLEX_STELLATED_REFORMED,
00144 TAG_POLYGON_COMPLEX_ROUNDED,
00145 TAG_POLYGON_COMPLEX_ROUNDED_REFORMED,
00146 TAG_POLYGON_COMPLEX_ROUNDED_STELLATED,
00147 TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED,
00148 CXFRH_TAG_LIST_END};
00149 return &TagList[0];
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 BOOL PolygonRecordHandler::HandleRecord(CXaraFileRecord *pCXaraFileRecord)
00165 {
00166 BOOL ok;
00167
00168 switch (pCXaraFileRecord->GetTag())
00169 {
00170 case TAG_POLYGON_COMPLEX
00171 : ok = ReadPolygonComplex(pCXaraFileRecord); break;
00172 case TAG_POLYGON_COMPLEX_REFORMED
00173 : ok = ReadPolygonComplexReformed(pCXaraFileRecord); break;
00174 case TAG_POLYGON_COMPLEX_STELLATED
00175 : ok = ReadPolygonComplexStellated(pCXaraFileRecord); break;
00176 case TAG_POLYGON_COMPLEX_STELLATED_REFORMED
00177 : ok = ReadPolygonComplexStellatedReformed(pCXaraFileRecord); break;
00178 case TAG_POLYGON_COMPLEX_ROUNDED
00179 : ok = ReadPolygonComplexRounded(pCXaraFileRecord); break;
00180 case TAG_POLYGON_COMPLEX_ROUNDED_REFORMED
00181 : ok = ReadPolygonComplexRoundedReformed(pCXaraFileRecord); break;
00182 case TAG_POLYGON_COMPLEX_ROUNDED_STELLATED
00183 : ok = ReadPolygonComplexRoundedStellated(pCXaraFileRecord); break;
00184 case TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED
00185 : ok = ReadPolygonComplexRoundedStellatedReformed(pCXaraFileRecord); break;
00186 default
00187 : ok = ReadShapeInvalid(pCXaraFileRecord); break;
00188 }
00189
00190 return ok;
00191 }
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 BOOL PolygonRecordHandler::ReadPolygonComplex(CXaraFileRecord *pCXaraFileRecord)
00213 {
00214 BOOL ok = TRUE;
00215
00216 NodeRegularShape * pPolygon;
00217 UINT16 NumberOfSides;
00218 DocCoord CentrePoint;
00219 DocCoord MajorAxis;
00220 DocCoord MinorAxis;
00221
00222 pPolygon = new NodeRegularShape;
00223
00224 if (ok) ok = SetupShape(pPolygon);
00225
00226 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00227 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00228
00229 if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00230 if (ok) ok = SetCentrePoint(pPolygon, CentrePoint);
00231
00232 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00233 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00234
00235 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00236 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00237
00238 if (ok) ok = InvalidateCache(pPolygon);
00239 if (ok) ok = InsertNode(pPolygon);
00240
00241 return ok;
00242 }
00243
00244 BOOL PolygonRecordHandler::ReadPolygonComplexReformed(CXaraFileRecord *pCXaraFileRecord)
00245 {
00246 BOOL ok = TRUE;
00247
00248 NodeRegularShape * pPolygon;
00249 UINT16 NumberOfSides;
00250 DocCoord MajorAxis;
00251 DocCoord MinorAxis;
00252 Matrix TransformMatrix;
00253
00254 pPolygon = new NodeRegularShape;
00255
00256 if (ok) ok = SetupShape(pPolygon);
00257
00258 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00259 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00260
00261 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00262 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00263
00264 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00265 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00266
00267 if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00268 if (ok) ok = SetTransformMatrix(pPolygon, TransformMatrix);
00269
00270 if (ok) ok = pCXaraFileRecord->ReadPath(&(pPolygon->EdgePath1));
00271
00272 if (ok) ok = InvalidateCache(pPolygon);
00273 if (ok) ok = InsertNode(pPolygon);
00274
00275 return ok;
00276 }
00277
00278 BOOL PolygonRecordHandler::ReadPolygonComplexStellated(CXaraFileRecord *pCXaraFileRecord)
00279 {
00280 BOOL ok = TRUE;
00281
00282 NodeRegularShape * pPolygon;
00283 UINT16 NumberOfSides;
00284 DocCoord CentrePoint;
00285 DocCoord MajorAxis;
00286 DocCoord MinorAxis;
00287 double StellationRadius;
00288 double StellationOffset;
00289
00290 pPolygon = new NodeRegularShape;
00291
00292 if (ok) ok = SetupShape(pPolygon);
00293 if (ok) ok = SetIsStellated(pPolygon, TRUE);
00294
00295 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00296 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00297
00298 if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00299 if (ok) ok = SetCentrePoint(pPolygon, CentrePoint);
00300
00301 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00302 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00303
00304 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00305 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00306
00307 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00308 if (ok) ok = SetStellationRadius(pPolygon, StellationRadius);
00309
00310 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00311 if (ok) ok = SetStellationOffset(pPolygon, StellationOffset);
00312
00313 if (ok) ok = InvalidateCache(pPolygon);
00314 if (ok) ok = InsertNode(pPolygon);
00315
00316 return ok;
00317 }
00318
00319 BOOL PolygonRecordHandler::ReadPolygonComplexStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00320 {
00321 BOOL ok = TRUE;
00322
00323 NodeRegularShape * pPolygon;
00324 UINT16 NumberOfSides;
00325 DocCoord MajorAxis;
00326 DocCoord MinorAxis;
00327 Matrix TransformMatrix;
00328 double StellationRadius;
00329 double StellationOffset;
00330
00331 pPolygon = new NodeRegularShape;
00332
00333 if (ok) ok = SetupShape(pPolygon);
00334 if (ok) ok = SetIsStellated(pPolygon, TRUE);
00335
00336 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00337 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00338
00339 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00340 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00341
00342 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00343 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00344
00345 if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00346 if (ok) ok = SetTransformMatrix(pPolygon, TransformMatrix);
00347
00348 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00349 if (ok) ok = SetStellationRadius(pPolygon, StellationRadius);
00350
00351 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00352 if (ok) ok = SetStellationOffset(pPolygon, StellationOffset);
00353
00354 if (ok) ok = pCXaraFileRecord->ReadPath(&(pPolygon->EdgePath1));
00355 if (ok) ok = pCXaraFileRecord->ReadPath(&(pPolygon->EdgePath2));
00356
00357 if (ok) ok = InvalidateCache(pPolygon);
00358 if (ok) ok = InsertNode(pPolygon);
00359
00360 return ok;
00361 }
00362
00363 BOOL PolygonRecordHandler::ReadPolygonComplexRounded(CXaraFileRecord *pCXaraFileRecord)
00364 {
00365 BOOL ok = TRUE;
00366
00367 NodeRegularShape * pPolygon;
00368 UINT16 NumberOfSides;
00369 DocCoord CentrePoint;
00370 DocCoord MajorAxis;
00371 DocCoord MinorAxis;
00372 double Curvature;
00373
00374 pPolygon = new NodeRegularShape;
00375
00376 if (ok) ok = SetupShape(pPolygon);
00377 if (ok) ok = SetIsRounded(pPolygon, TRUE);
00378
00379 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00380 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00381
00382 if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00383 if (ok) ok = SetCentrePoint(pPolygon, CentrePoint);
00384
00385 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00386 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00387
00388 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00389 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00390
00391 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Curvature);
00392 if (ok) ok = SetCurvature(pPolygon, Curvature);
00393
00394 if (ok) ok = InvalidateCache(pPolygon);
00395 if (ok) ok = InsertNode(pPolygon);
00396
00397 return ok;
00398 }
00399
00400 BOOL PolygonRecordHandler::ReadPolygonComplexRoundedReformed(CXaraFileRecord *pCXaraFileRecord)
00401 {
00402 BOOL ok = TRUE;
00403
00404 NodeRegularShape * pPolygon;
00405 UINT16 NumberOfSides;
00406 DocCoord MajorAxis;
00407 DocCoord MinorAxis;
00408 Matrix TransformMatrix;
00409 double Curvature;
00410
00411 pPolygon = new NodeRegularShape;
00412
00413 if (ok) ok = SetupShape(pPolygon);
00414 if (ok) ok = SetIsRounded(pPolygon, TRUE);
00415
00416 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00417 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00418
00419 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00420 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00421
00422 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00423 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00424
00425 if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00426 if (ok) ok = SetTransformMatrix(pPolygon, TransformMatrix);
00427
00428 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Curvature);
00429 if (ok) ok = SetCurvature(pPolygon, Curvature);
00430
00431 if (ok) ok = pCXaraFileRecord->ReadPath(&(pPolygon->EdgePath1));
00432
00433 if (ok) ok = InvalidateCache(pPolygon);
00434 if (ok) ok = InsertNode(pPolygon);
00435
00436 return ok;
00437 }
00438
00439 BOOL PolygonRecordHandler::ReadPolygonComplexRoundedStellated(CXaraFileRecord *pCXaraFileRecord)
00440 {
00441 BOOL ok = TRUE;
00442
00443 NodeRegularShape * pPolygon;
00444 UINT16 NumberOfSides;
00445 DocCoord CentrePoint;
00446 DocCoord MajorAxis;
00447 DocCoord MinorAxis;
00448 double StellationRadius;
00449 double StellationOffset;
00450 double PrimaryCurvature;
00451 double SecondaryCurvature;
00452
00453 pPolygon = new NodeRegularShape;
00454
00455 if (ok) ok = SetupShape(pPolygon);
00456 if (ok) ok = SetIsRounded(pPolygon, TRUE);
00457 if (ok) ok = SetIsStellated(pPolygon, TRUE);
00458
00459 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00460 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00461
00462 if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00463 if (ok) ok = SetCentrePoint(pPolygon, CentrePoint);
00464
00465 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00466 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00467
00468 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00469 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00470
00471 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00472 if (ok) ok = SetStellationRadius(pPolygon, StellationRadius);
00473
00474 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00475 if (ok) ok = SetStellationOffset(pPolygon, StellationOffset);
00476
00477 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00478 if (ok) ok = SetPrimaryCurvature(pPolygon, PrimaryCurvature);
00479
00480 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00481 if (ok) ok = SetSecondaryCurvature(pPolygon, SecondaryCurvature);
00482
00483 if (ok) ok = InvalidateCache(pPolygon);
00484 if (ok) ok = InsertNode(pPolygon);
00485
00486 return ok;
00487 }
00488
00489 BOOL PolygonRecordHandler::ReadPolygonComplexRoundedStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00490 {
00491 BOOL ok = TRUE;
00492
00493 NodeRegularShape * pPolygon;
00494 UINT16 NumberOfSides;
00495 DocCoord MajorAxis;
00496 DocCoord MinorAxis;
00497 Matrix TransformMatrix;
00498 double StellationRadius;
00499 double StellationOffset;
00500 double PrimaryCurvature;
00501 double SecondaryCurvature;
00502
00503 pPolygon = new NodeRegularShape;
00504
00505 if (ok) ok = SetupShape(pPolygon);
00506 if (ok) ok = SetIsRounded(pPolygon, TRUE);
00507 if (ok) ok = SetIsStellated(pPolygon, TRUE);
00508
00509 if (ok) ok = pCXaraFileRecord->ReadUINT16(&NumberOfSides);
00510 if (ok) ok = SetNumberOfSides(pPolygon, NumberOfSides);
00511
00512 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00513 if (ok) ok = SetMajorAxis(pPolygon, MajorAxis);
00514
00515 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00516 if (ok) ok = SetMinorAxis(pPolygon, MinorAxis);
00517
00518 if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00519 if (ok) ok = SetTransformMatrix(pPolygon, TransformMatrix);
00520
00521 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00522 if (ok) ok = SetStellationRadius(pPolygon, StellationRadius);
00523
00524 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00525 if (ok) ok = SetStellationOffset(pPolygon, StellationOffset);
00526
00527 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00528 if (ok) ok = SetPrimaryCurvature(pPolygon, PrimaryCurvature);
00529
00530 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00531 if (ok) ok = SetSecondaryCurvature(pPolygon, SecondaryCurvature);
00532
00533 if (ok) ok = pCXaraFileRecord->ReadPath(&(pPolygon->EdgePath1));
00534 if (ok) ok = pCXaraFileRecord->ReadPath(&(pPolygon->EdgePath2));
00535
00536 if (ok) ok = InvalidateCache(pPolygon);
00537 if (ok) ok = InsertNode(pPolygon);
00538
00539 return ok;
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 #ifdef XAR_TREE_DIALOG
00558 void PolygonRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase *pStr)
00559 {
00560 if (pRecord != NULL && pStr != NULL)
00561 {
00562
00563
00564 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
00565
00566 switch (pRecord->GetTag())
00567 {
00568 case TAG_POLYGON_COMPLEX :
00569 case TAG_POLYGON_COMPLEX_STELLATED :
00570 case TAG_POLYGON_COMPLEX_ROUNDED :
00571 case TAG_POLYGON_COMPLEX_ROUNDED_STELLATED :
00572 (*pStr) += _T("Polygon complex\r\n\r\n");
00573 DescribePolygonComplex(pRecord, pStr);
00574 break;
00575
00576 case TAG_POLYGON_COMPLEX_REFORMED :
00577 case TAG_POLYGON_COMPLEX_STELLATED_REFORMED :
00578 case TAG_POLYGON_COMPLEX_ROUNDED_REFORMED :
00579 case TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED :
00580 (*pStr) += _T("Polygon complex reformed\r\n\r\n");
00581 DescribePolygonComplexReformed(pRecord, pStr);
00582 break;
00583
00584 default : DescribeInvalid(pRecord, pStr); break;
00585 }
00586 }
00587 }
00588
00589 void PolygonRecordHandler::DescribePolygonComplex(CXaraFileRecord *pRecord, StringBase *pStr)
00590 {
00591 if (pRecord == NULL || pStr == NULL)
00592 return;
00593
00594 DocCoord CentrePoint;
00595 DocCoord MajorAxis;
00596 DocCoord MinorAxis;
00597 UINT16 NumberOfSides;
00598 TCHAR s[256];
00599
00600 BOOL ok = TRUE;
00601
00602 if (ok) ok = pRecord->ReadUINT16(&NumberOfSides);
00603 if (ok) ok = pRecord->ReadCoord(&CentrePoint);
00604 if (ok) ok = pRecord->ReadCoordTrans(&MajorAxis,0,0);
00605 if (ok) ok = pRecord->ReadCoordTrans(&MinorAxis,0,0);
00606
00607 camSprintf(s,_T("Number of sides\t= %d\r\n"),NumberOfSides);
00608 (*pStr) += s;
00609 camSprintf(s,_T("Centre point\t= %d, %d\r\n"),CentrePoint.x,CentrePoint.y);
00610 (*pStr) += s;
00611 camSprintf(s,_T("Major axis\t\t= %d, %d\r\n"),MajorAxis.x,MajorAxis.y);
00612 (*pStr) += s;
00613 camSprintf(s,_T("Minor axis\t\t= %d, %d\r\n"),MinorAxis.x,MinorAxis.y);
00614 (*pStr) += s;
00615 }
00616
00617 void PolygonRecordHandler::DescribePolygonComplexReformed(CXaraFileRecord *pRecord, StringBase *pStr)
00618 {
00619 if (pRecord == NULL || pStr == NULL)
00620 return;
00621
00622 DocCoord MajorAxis;
00623 DocCoord MinorAxis;
00624 UINT16 NumberOfSides;
00625 TCHAR s[256];
00626
00627 BOOL ok = TRUE;
00628
00629 if (ok) ok = pRecord->ReadUINT16(&NumberOfSides);
00630 if (ok) ok = pRecord->ReadCoordTrans(&MajorAxis,0,0);
00631 if (ok) ok = pRecord->ReadCoordTrans(&MinorAxis,0,0);
00632
00633 camSprintf(s,_T("Number of sides\t= %d\r\n"),NumberOfSides);
00634 (*pStr) += s;
00635 camSprintf(s,_T("Major axis\t\t= %d, %d\r\n"),MajorAxis.x,MajorAxis.y);
00636 (*pStr) += s;
00637 camSprintf(s,_T("Minor axis\t\t= %d, %d\r\n"),MinorAxis.x,MinorAxis.y);
00638 (*pStr) += s;
00639 }
00640
00641 void PolygonRecordHandler::DescribeInvalid(CXaraFileRecord *pRecord, StringBase *pStr)
00642 {
00643 if (pRecord == NULL || pStr == NULL)
00644 return;
00645
00646 (*pStr) += _T("Invalid rectangle\r\n");
00647 }
00648 #endif