00001 // $Id: cxfrgshp.cpp 1282 2006-06-09 09:46:49Z alex $ 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 > cxfrgshp.cpp 00101 00102 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00103 Created: 04/06/96 00104 Purpose: Base class holding code for exporting regular shapes to the new file format 00105 SeeAlso: Class NodeRegularShape 00106 00107 ********************************************************************************************/ 00108 00109 #include "camtypes.h" 00110 00111 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00112 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00113 #include "nodershp.h" 00114 #include "cxftags.h" 00115 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00116 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00117 #include "cxfile.h" 00118 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00119 #include "cxfrgshp.h" 00120 #include "cxfellp.h" 00121 #include "cxfrect.h" 00122 #include "cxfpoly.h" 00123 00124 /******************************************************************************************** 00125 00126 > BOOL CXaraFileRegularShape::WritePreChildrenNative(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00127 BOOL CXaraFileRegularShape::WritePreChildrenWeb(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00128 00129 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00130 Created: 04/06/96 00131 Inputs: pFilter - filter to save this shape to 00132 pShape - regular shape to save 00133 Returns: boolean value indicating success of writing record 00134 Purpose: Writes a regular shape to the filter in native or web format 00135 00136 ********************************************************************************************/ 00137 00138 BOOL CXaraFileRegularShape::WritePreChildrenNative(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 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 } 00151 00152 BOOL CXaraFileRegularShape::WritePreChildrenWeb(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00153 { 00154 ERROR2IF(pFilter == NULL, FALSE, "Argument pFilter == NULL."); 00155 ERROR2IF(pShape == NULL, FALSE, "Argument pShape == NULL."); 00156 00157 return WriteShapeWeb(pFilter, pShape); 00158 } 00159 00160 /******************************************************************************************** 00161 00162 > BOOL CXaraFileRegularShape::WriteShapeNative(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00163 BOOL CXaraFileRegularShape::WriteShapeWeb(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00164 00165 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00166 Created: 04/06/96 00167 Inputs: pFilter - filter to use 00168 pShape - regular shape to save out 00169 Returns: boolean value indicating success of writing record 00170 Purpose: Writes a regular shape record to the filter 00171 00172 ********************************************************************************************/ 00173 00174 BOOL CXaraFileRegularShape::WriteShapeNative(BaseCamelotFilter *pFilter, NodeRegularShape *pShape) 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 } 00196 00197 BOOL CXaraFileRegularShape::WriteShapeWeb(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 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 } 00229 00230 /******************************************************************************************** 00231 00232 > BOOL CXaraFileRegularShape::FixOldShape(NodeRegularShape *pShape) 00233 00234 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00235 Created: 02/07/96 00236 Inputs: pShape - NodeRegularShape to fix 00237 Returns: TRUE if successful, FALSE otherwise 00238 Purpose: Fixes old regular shapes, i.e. those which have UTCentrePoint != DocCoord(0,0) 00239 by adjusting the UTCentrePoint, UTMajorAxis, UTMinorAxis, TransformMatrix. 00240 00241 ********************************************************************************************/ 00242 00243 BOOL CXaraFileRegularShape::FixOldShape(NodeRegularShape *pShape) 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 } 00324 00325 /******************************************************************************************** 00326 00327 > BOOL CXaraFileRegularShape::WriteShapeGeneral(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00328 00329 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00330 Created: 04/06/96 00331 Inputs: pFilter - filter to use 00332 pShape - regular shape to save out 00333 Returns: boolean value indicating sucess of writing record to filter 00334 Purpose: Writes a generic regular shape record to the filter 00335 00336 ********************************************************************************************/ 00337 00338 BOOL CXaraFileRegularShape::WriteShapeGeneral(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 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 } 00360 00361 /******************************************************************************************** 00362 00363 > BOOL CXaraFileRegularShape::WriteShapeInvalid(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00364 00365 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00366 Created: 04/06/96 00367 Inputs: pFilter - filter to use 00368 pShape - regular shape to save out 00369 Returns: FALSE 00370 Purpose: Called when earlier functions are asked to write an invalid shape to the file. 00371 We raise an ERROR3, then return FALSE. 00372 00373 ********************************************************************************************/ 00374 00375 BOOL CXaraFileRegularShape::WriteShapeInvalid(BaseCamelotFilter * pFilter, NodeRegularShape *pShape) 00376 { 00377 ERROR3("Invalid shape being written to file."); 00378 00379 return FALSE; 00380 } 00381 00382 /******************************************************************************************** 00383 00384 > BOOL CXaraFileRegularShape::IsEllipse(NodeRegularShape *pShape) 00385 BOOL CXaraFileRegularShape::IsRectangle(NodeRegularShape *pShape) 00386 BOOL CXaraFileRegularShape::IsSimple(NodeRegularShape *pShape) 00387 BOOL CXaraFileRegularShape::IsComplex(NodeRegularShape *pShape) 00388 BOOL CXaraFileRegularShape::IsRounded(NodeRegularShape *pShape) 00389 BOOL CXaraFileRegularShape::IsStellated(NodeRegularShape *pShape) 00390 BOOL CXaraFileRegularShape::IsReformed(NodeRegularShape *pShape) 00391 00392 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00393 Created: 04/06/96 00394 Inputs: pShape - regular shape to test for a particular attribute 00395 Returns: boolean value, true if the regular shape has the particular attribute, false otherwise 00396 Purpose: Tests the regular shape for particular attributes. 00397 See Also: <???> 00398 00399 ********************************************************************************************/ 00400 00401 BOOL CXaraFileRegularShape::IsEllipse(NodeRegularShape *pShape) 00402 { 00403 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00404 00405 return pShape->IsCircular(); 00406 } 00407 00408 BOOL CXaraFileRegularShape::IsRectangle(NodeRegularShape *pShape) 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 } 00418 00419 BOOL CXaraFileRegularShape::IsSimple(NodeRegularShape *pShape) 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 } 00440 00441 BOOL CXaraFileRegularShape::IsComplex(NodeRegularShape *pShape) 00442 { 00443 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00444 00445 return !(IsSimple(pShape)); 00446 } 00447 00448 BOOL CXaraFileRegularShape::IsRounded(NodeRegularShape *pShape) 00449 { 00450 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00451 00452 return pShape->IsPrimaryCurvature(); 00453 } 00454 00455 BOOL CXaraFileRegularShape::IsStellated(NodeRegularShape *pShape) 00456 { 00457 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00458 00459 return pShape->IsStellated(); 00460 } 00461 00462 BOOL CXaraFileRegularShape::IsReformed(NodeRegularShape *pShape) 00463 { 00464 ERROR2IF(pShape==NULL, FALSE, "parameter pShape == NULL"); 00465 00466 return pShape->IsReformed(); 00467 } 00468 00469 /******************************************************************************************** 00470 00471 > BYTE CXaraFileRegularShape::GetFlags(NodeRegularShape *pShape); 00472 00473 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00474 Created: 13/06/96 00475 Inputs: pShape - Node regular shape to retrieve flag information from 00476 Returns: BYTE of information 00477 Purpose: Retrieves flag information from node regular shapes 00478 00479 ********************************************************************************************/ 00480 00481 BYTE CXaraFileRegularShape::GetFlags(NodeRegularShape *pShape) 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 } 00497 00498 /******************************************************************************************** 00499 00500 > DocCoord CXaraFileRegularShape::GetCentrePoint(NodeRegularShape *pShape) 00501 DocCoord CXaraFileRegularShape::GetMajorAxis(NodeRegularShape *pShape) 00502 DocCoord CXaraFileRegularShape::GetMinorAxis(NodeRegularShape *pShape) 00503 DocCoord CXaraFileRegularShape::GetUTCentrePoint(NodeRegularShape *pShape) 00504 DocCoord CXaraFileRegularShape::GetUTMajorAxis(NodeRegularShape *pShape) 00505 DocCoord CXaraFileRegularShape::GetUTMinorAxis(NodeRegularShape *pShape) 00506 INT32 CXaraFileRegularShape::GetHeight(NodeRegularShape *pShape) 00507 INT32 CXaraFileRegularShape::GetWidth(NodeRegularShape *pShape) 00508 UINT16 CXaraFileRegularShape::GetNumberOfSides(NodeRegularShape *pShape) 00509 double CXaraFileRegularShape::GetCurvature(NodeRegularShape *pShape) 00510 double CXaraFileRegularShape::GetPrimaryCurvature(NodeRegularShape *pShape) 00511 double CXaraFileRegularShape::GetSecondaryCurvature(NodeRegularShape *pShape) 00512 double CXaraFileRegularShape::GetStellationRadius(NodeRegularShape *pShape) 00513 double CXaraFileRegularShape::GetStellationOffset(NodeRegularShape *pShape) 00514 Matrix * CXaraFileRegularShape::GetTransformMatrix(NodeRegularShape *pShape); 00515 PATH * CXaraFileRegularShape::GetEdgePath(NodeRegularShape *pShape) 00516 PATH * CXaraFileRegularShape::GetPrimaryEdgePath(NodeRegularShape *pShape) 00517 PATH * CXaraFileRegularShape::GetSecondaryEdgePath(NodeRegularShape *pShape) 00518 00519 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00520 Created: 04/06/96 00521 Inputs: pShape - regular shape to retrive information from 00522 Returns: information from the regular shape 00523 Purpose: Functions to retrieve information from regular shapes 00524 00525 ********************************************************************************************/ 00526 00527 DocCoord CXaraFileRegularShape::GetCentrePoint(NodeRegularShape *pShape) 00528 { 00529 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00530 00531 return (pShape->GetCentrePoint()); 00532 } 00533 00534 // returns the transformed major axis relative to the origin 00535 DocCoord CXaraFileRegularShape::GetMajorAxis(NodeRegularShape *pShape) 00536 { 00537 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00538 00539 return (pShape->GetMajorAxes() - pShape->GetCentrePoint()); 00540 } 00541 00542 // returns the transformed minor axis relative to the origin 00543 DocCoord CXaraFileRegularShape::GetMinorAxis(NodeRegularShape *pShape) 00544 { 00545 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00546 00547 return (pShape->GetMinorAxes() - pShape->GetCentrePoint()); 00548 } 00549 00550 DocCoord CXaraFileRegularShape::GetUTCentrePoint(NodeRegularShape *pShape) 00551 { 00552 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00553 00554 return (pShape->GetUTCentrePoint()); 00555 } 00556 00557 // returns the untransformed major axis 00558 DocCoord CXaraFileRegularShape::GetUTMajorAxis(NodeRegularShape *pShape) 00559 { 00560 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00561 00562 return pShape->GetUTMajorAxes(); 00563 } 00564 00565 // returns the untransformed minor axis 00566 DocCoord CXaraFileRegularShape::GetUTMinorAxis(NodeRegularShape *pShape) 00567 { 00568 ERROR2IF(pShape==NULL, DocCoord(0,0), "parameter pShape == NULL"); 00569 00570 return pShape->GetUTMinorAxes(); 00571 } 00572 00573 // uses the GetMajorAxis and GetMinorAxis functions in this class to get the 00574 // transformed major and minor axes for this regular shape. calculating the width 00575 // and height of the shape is then trivial. 00576 INT32 CXaraFileRegularShape::GetHeight(NodeRegularShape *pShape) 00577 { 00578 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00579 00580 return 2*abs(GetMajorAxis(pShape).y + GetMinorAxis(pShape).y); 00581 } 00582 00583 INT32 CXaraFileRegularShape::GetWidth(NodeRegularShape *pShape) 00584 { 00585 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00586 00587 return 2*abs(GetMajorAxis(pShape).x + GetMinorAxis(pShape).x); 00588 } 00589 00590 UINT16 CXaraFileRegularShape::GetNumberOfSides(NodeRegularShape *pShape) 00591 { 00592 ERROR2IF(pShape==NULL, 0, "parameter pShape == NULL"); 00593 00594 return pShape->GetNumSides(); 00595 } 00596 00597 double CXaraFileRegularShape::GetCurvature(NodeRegularShape *pShape) 00598 { 00599 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00600 00601 return pShape->GetPrimaryCurveToPrimary(); 00602 } 00603 00604 double CXaraFileRegularShape::GetPrimaryCurvature(NodeRegularShape *pShape) 00605 { 00606 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00607 00608 return pShape->GetPrimaryCurveToPrimary(); 00609 } 00610 00611 double CXaraFileRegularShape::GetSecondaryCurvature(NodeRegularShape *pShape) 00612 { 00613 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00614 00615 return pShape->GetStellCurveToStell(); 00616 } 00617 00618 double CXaraFileRegularShape::GetStellationRadius(NodeRegularShape *pShape) 00619 { 00620 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00621 00622 return pShape->GetStellRadiusToPrimary(); 00623 } 00624 00625 double CXaraFileRegularShape::GetStellationOffset(NodeRegularShape *pShape) 00626 { 00627 ERROR2IF(pShape==NULL, .0, "parameter pShape == NULL"); 00628 00629 return pShape->GetStellationRatio(); 00630 } 00631 00632 Matrix CXaraFileRegularShape::GetTransformMatrix(NodeRegularShape *pShape) 00633 { 00634 // ERROR2IF(pShape==NULL, Matrix(), "parameter pShape == NULL"); 00635 Matrix m; 00636 00637 pShape->GetTransformMatrix(&m); 00638 00639 return m; 00640 } 00641 00642 Path * CXaraFileRegularShape::GetEdgePath(NodeRegularShape *pShape) 00643 { 00644 ERROR2IF(pShape==NULL, NULL, "parameter pShape == NULL"); 00645 00646 return &(pShape->EdgePath1); 00647 } 00648 00649 Path * CXaraFileRegularShape::GetPrimaryEdgePath(NodeRegularShape *pShape) 00650 { 00651 ERROR2IF(pShape==NULL, NULL, "parameter pShape == NULL"); 00652 00653 return &(pShape->EdgePath1); 00654 } 00655 00656 Path * CXaraFileRegularShape::GetSecondaryEdgePath(NodeRegularShape *pShape) 00657 { 00658 ERROR2IF(pShape==NULL, NULL, "parameter pShape == NULL"); 00659 00660 return &(pShape->EdgePath2); 00661 } 00662 00663 /******************************************************************************************** 00664 00665 > const double CXaraFileRegularShape::mEpsilon 00666 00667 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00668 Created: 04/06/96 00669 Purpose: Epsilon value used for checking matrix type 00670 See Also: CXaraFileRegularShape::IsIdentity 00671 00672 ********************************************************************************************/ 00673 00674 const double CXaraFileRegularShape::mEpsilon = 0.000016; 00675