cxftrans.cpp

Go to the documentation of this file.
00001 // $Id: cxftrans.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 >   cxftrans.cpp
00101 
00102     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00103     Created:    03/06/96
00104     Purpose:    Code for importing and exporting transformation attributes to and
00105             from the new native file format.
00106 
00107 ********************************************************************************************/
00108 
00109 #include "camtypes.h"
00110 /*
00111 //#include "matrix.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "cxftags.h"
00113 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "cxftrans.h"
00117 */
00118 /********************************************************************************************
00119 
00120 >   BOOL CXaraFileTransforms::Write(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00121 
00122     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00123     Created:    03/06/96
00124     Inputs:     pFilter - Filter to save the record to
00125                 pMatrix - Matrix to save
00126     Returns:    BOOL indicating success or not.
00127     Purpose:    Writes a transformation attribute to the filter
00128 
00129 ********************************************************************************************/
00130 /*
00131 
00132 BOOL CXaraFileTransforms::Write(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00133 {
00134     // check the arguments
00135     ERROR2IF(pFilter == NULL, FALSE, "NULL filter pointer passed as argument.");
00136     ERROR2IF(pMatrix == NULL, FALSE, "NULL matrix pointer passed as argument.");
00137     
00138     BOOL Result;
00139 
00140     // !!ACH!!
00141     // here we just switch on the transform type of the matrix, and assume it gets set
00142     // properly by whoever created it. What we ought to do is decompose the matrix and
00143     // decide whcih of the many transform attribute records we ought to output.
00144     // This works for the moment, but needs changing.
00145     
00146     switch (pMatrix->Type)
00147     {
00148         case TRANS_IDENTITY     :   Result = WriteIdentity(pFilter, pMatrix);
00149                                     break;
00150         case TRANS_TRANSLATION  :   Result = WriteTranslation(pFilter, pMatrix);
00151                                     break;
00152         case TRANS_ROTATION     :   Result = WriteRotation(pFilter, pMatrix);
00153                                     break;
00154         case TRANS_SCALE        :   Result = WriteScale(pFilter, pMatrix);
00155                                     break;
00156         case TRANS_SHEAR        :   Result = WriteShearX(pFilter, pMatrix);
00157                                     break;
00158         case TRANS_COMPLEX      :   Result = WriteGeneral(pFilter, pMatrix);
00159                                     break;
00160         default                 :   Result = WriteGeneral(pFilter, pMatrix);
00161                                     break;
00162     }
00163 
00164     return Result;
00165 }
00166 */
00167 /********************************************************************************************
00168 
00169 >   BOOL CXaraFileTransforms::WriteIdentity(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00170 
00171     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00172     Created:    03/06/96
00173     Inputs:     pFilter - filter to use
00174                 pMatrix - matrix to save
00175     Returns:    Bool indicating success
00176     Purpose:    Writes an identity transform attribute record to the filter
00177 
00178 ********************************************************************************************/
00179 /*
00180 
00181 BOOL CXaraFileTransforms::WriteIdentity(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00182 {
00183     BOOL ok;
00184 
00185     CXaraFileRecord Rec(TAG_TRANSFORM_IDENTITY, TAG_TRANSFORM_IDENTITY_SIZE);
00186 
00187     ok = Rec.Init();
00188     
00189     if (ok) ok = pFilter->Write(&Rec);
00190     
00191     return ok;
00192 }
00193 */
00194 /********************************************************************************************
00195 
00196 >   BOOL CXaraFileTransforms::WriteTranslation(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00197 
00198     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00199     Created:    03/06/96
00200     Inputs:     pFilter - filter to use
00201                 pMatrix - matrix to save
00202     Returns:    boolean value indicating success
00203     Purpose:    Writes a translation transform attribute to the filter
00204 
00205 ********************************************************************************************/
00206 /*
00207 
00208 BOOL CXaraFileTransforms::WriteTranslation(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00209 {
00210     BOOL ok;
00211     INT32 XTrans, YTrans;
00212 
00213     CXaraFileRecord Rec(TAG_TRANSFORM_TRANSLATION, TAG_TRANSFORM_TRANSLATION_SIZE);
00214 
00215     ok = Rec.Init();
00216 
00217     pMatrix->GetTranslation(XTrans, YTrans);
00218 
00219     if (ok) ok = Rec.Write(XTrans);
00220     if (ok) ok = Rec.Write(YTrans);
00221     if (ok) ok = pFilter->Write(&Rec);
00222 
00223     return ok;
00224 }
00225 */
00226 /********************************************************************************************
00227 
00228 >   BOOL CXaraFileTransforms::WriteRotation(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00229 
00230     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00231     Created:    03/06/96
00232     Inputs:     pFilter - filter to use
00233                 pMatrix - matrix to save
00234     Returns:    boolean value indicating success
00235     Purpose:    Writes a rotation transform attribute to the filter
00236 
00237 ********************************************************************************************/
00238 /*
00239 
00240 BOOL CXaraFileTransforms::WriteRotation(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00241 {
00242     BOOL ok;
00243 
00244     ANGLE Rotation;
00245 
00246     CXaraFileRecord Rec(TAG_TRANSFORM_ROTATION, TAG_TRANSFORM_ROTATION_SIZE);
00247 
00248     ok = Rec.Init();
00249 
00250     if (ok) ok = pMatrix->Decompose(NULL, NULL, &Rotation, NULL, NULL);
00251     if (ok) ok = Rec.Write( (FLOAT) Rotation.MakeDouble() );
00252     if (ok) ok = pFilter->Write(&Rec);
00253 
00254     return ok;
00255 }
00256 */
00257 /********************************************************************************************
00258 
00259 >   BOOL CXaraFileTransforms::WriteScale(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00260 
00261     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00262     Created:    03/06/96
00263     Inputs:     pFilter - filter to use
00264                 pMatrix - matrix to save
00265     Returns:    boolean value indicating success
00266     Purpose:    Writes a scaling transform attribute to the filter
00267 
00268 ********************************************************************************************/
00269 /*
00270 
00271 BOOL CXaraFileTransforms::WriteScale(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00272 {
00273     BOOL ok;
00274 
00275     FIXED16 Scale;
00276 
00277     CXaraFileRecord Rec(TAG_TRANSFORM_SCALE, TAG_TRANSFORM_SCALE_SIZE);
00278 
00279     ok = Rec.Init();
00280 
00281     if (ok) ok = pMatrix->Decompose(&Scale, NULL, NULL, NULL, NULL);
00282     if (ok) ok = Rec.Write( (FLOAT) Scale.MakeDouble() );
00283     if (ok) ok = pFilter->Write(&Rec);
00284 
00285     return ok;
00286 }
00287 */
00288 /********************************************************************************************
00289 
00290 >   BOOL CXaraFileTransforms::WriteShearX(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00291 
00292     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00293     Created:    03/06/96
00294     Inputs:     pFilter - filter to use
00295                 pMatrix - matrix to save
00296     Returns:    boolean indicating success
00297     Purpose:    Writes a shear parallel to the X axis to the filter
00298 
00299 ********************************************************************************************/
00300 /*
00301 
00302 BOOL CXaraFileTransforms::WriteShearX(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00303 {
00304     BOOL ok;
00305     
00306     ANGLE Shear;
00307 
00308     CXaraFileRecord Rec(TAG_TRANSFORM_SHEAR_X, TAG_TRANSFORM_SHEAR_X_SIZE);
00309 
00310     ok = Rec.Init();
00311 
00312     if (ok) ok = pMatrix->Decompose(NULL, NULL, NULL, &Shear, NULL);
00313     if (ok) ok = Rec.Write( (FLOAT) Shear.MakeDouble() );
00314     if (ok) ok = pFilter->Write(&Rec);
00315 
00316     return ok;
00317 }
00318 */
00319 /********************************************************************************************
00320 
00321 >   BOOL CXaraFileTransforms::WriteGeneral(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00322 
00323     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00324     Created:    03/06/96
00325     Inputs:     pFilter - filter to use
00326                 pMatrix - matrix to save out
00327     Returns:    boolean value indicating success
00328     Purpose:    writes a general transformation matrix to the filter
00329 
00330 ********************************************************************************************/
00331 /*
00332 
00333 BOOL CXaraFileTransforms::WriteGeneral(BaseCamelotFilter * pFilter, Matrix * pMatrix)
00334 {
00335     BOOL ok;
00336 
00337     FIXED16 abcd[4];
00338     INT32 ef[2];
00339 
00340     pMatrix->GetComponents(&abcd[0], &ef[0]);
00341 
00342     CXaraFileRecord Rec(TAG_TRANSFORM_GENERAL, TAG_TRANSFORM_GENERAL_SIZE);
00343 
00344     ok = Rec.Init();
00345 
00346     if (ok) ok = Rec.Write( (FLOAT) abcd[0].MakeDouble() );
00347     if (ok) ok = Rec.Write( (FLOAT) abcd[1].MakeDouble() );
00348     if (ok) ok = Rec.Write( (FLOAT) abcd[2].MakeDouble() );
00349     if (ok) ok = Rec.Write( (FLOAT) abcd[3].MakeDouble() );
00350     if (ok) ok = Rec.Write( ef[0] );
00351     if (ok) ok = Rec.Write( ef[1] );
00352     if (ok) ok = pFilter->Write(&Rec);
00353 
00354     return ok;
00355 }
00356 
00357 */

Generated on Sat Nov 10 03:44:59 2007 for Camelot by  doxygen 1.4.4