rechpoly.cpp

Go to the documentation of this file.
00001 // $Id: rechpoly.cpp 1688 2006-08-10 12:05:20Z gerry $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 /********************************************************************************************
00099 
00100 >   rechpoly.cpp
00101 
00102     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00103     Created:    11/06/96
00104     Purpose:    Implementation of class to handle loading of polygon records from the new
00105                 file format.
00106 
00107 ********************************************************************************************/
00108 
00109 #include "camtypes.h"
00110 
00111 #include "nodershp.h"
00112 
00113 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 #include "cxftags.h"
00115 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 
00118 #include "rechrshp.h"
00119 #include "rechpoly.h"
00120 
00121 // to match the declare in the header file
00122 CC_IMPLEMENT_DYNAMIC(PolygonRecordHandler, RegularShapeRecordHandler);
00123 
00124 /********************************************************************************************
00125 
00126 >   UINT32* PolygonRecordHandler::GetTagList()
00127 
00128     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00129     Created:    06/06/96
00130     Inputs:     -
00131     Returns:    UINT32* to an array of records handled by this class. The last entry in the
00132                 array is CXFRH_TAG_LIST_END
00133     Purpose:    Returns an array of records handled by this class.
00134     See Also:   EllispeRecordHandler::HandleRecord
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 >   BOOL PolygonRecordHandler::HandleRecord(CXaraFileRecord * pCXaraFileRecord)
00155 
00156     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00157     Created:    06/06/96
00158     Inputs:     pCXaraFileRecord - CXaraFileRecord object to read
00159     Returns:    TRUE if successful, FALSE otherwise
00160     Purpose:    Handles ellipse type records for the new file format
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     BOOL PolygonRecordHandler::ReadPolygonComplex(CXaraFileRecord *pCXaraFileRecord)
00196     BOOL PolygonRecordHandler::ReadPolygonComplexReformed(CXaraFileRecord *pCXaraFileRecord)
00197     BOOL PolygonRecordHandler::ReadPolygonComplexStellated(CXaraFileRecord *pCXaraFileRecord)
00198     BOOL PolygonRecordHandler::ReadPolygonComplexStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00199     BOOL PolygonRecordHandler::ReadPolygonComplexRounded(CXaraFileRecord *pCXaraFileRecord)
00200     BOOL PolygonRecordHandler::ReadPolygonComplexRoundedReformed(CXaraFileRecord *pCXaraFileRecord)
00201     BOOL PolygonRecordHandler::ReadPolygonComplexRoundedStellated(CXaraFileRecord *pCXaraFileRecord)
00202     BOOL PolygonRecordHandler::ReadPolygonComplexRoundedStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00203 
00204     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00205     Created:    06/06/96
00206     Inputs:     pCXaraFileRecord - pointer to the record to read
00207     Returns:    TRUE if successfull, false otherwise
00208     Purpose:    Reads in an polygon record
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 >   void GetRecordDescriptionText(CXaraFileRecord* pCXaraFileRecord,StringBase* Str);
00546 
00547 
00548     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00549     Created:    20/08/96
00550     Inputs:     pCXaraFileRecord - CXaraFileRecord holding the record in question
00551                 Str - StringBase to add our information to
00552     Returns:    -
00553     Purpose:    Returns textual information on this record
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         // Call base class first
00563         // This outputs the tag and size
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

Generated on Sat Nov 10 03:46:42 2007 for Camelot by  doxygen 1.4.4