fillramp.h

Go to the documentation of this file.
00001 // $Id: fillramp.h 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 #ifndef INC_FILLRAMP
00100 #define INC_FILLRAMP
00101 
00102 // This file holds classes concerned with fill ramps. 
00103 // Currently colour ramps and transparancy ramps have been implemented fully.
00104 
00105 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "doccolor.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 
00110 #define FILLRAMP_INDEXBASE 1024
00111 #define FILLRAMP_ILLEGALINDEX (FILLRAMP_INDEXBASE-1)
00112 #define ABSOLUTEINDEX(x) ((x)+FILLRAMP_INDEXBASE)
00113 #define RELATIVEINDEX(x) ((x)-FILLRAMP_INDEXBASE)
00114 #define ISA_RAMPINDEX(x) ((x)>=FILLRAMP_INDEXBASE)
00115 
00116 class FillGeometryAttribute;
00117 class RenderRegion;
00118 class BaseCamelotFilter;
00119 class CamelotFileRecord;
00120 
00121 /********************************************************************************************
00122 
00123 >   class RampItem : public ListItem
00124 
00125     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00126     Created:    05/02/97
00127     Purpose:    Defines whats common to all ramp items, i.e. their position and selection
00128                 state
00129 
00130 ********************************************************************************************/
00131 
00132 class RampItem : public ListItem
00133 {
00134     CC_DECLARE_DYNCREATE(RampItem);
00135 
00136     public:
00137         RampItem();
00138         RampItem(float pos);
00139         RampItem(const RampItem &other);
00140 
00141         void    SetPosition(float pos);
00142         void    SetSelState(BOOL selstate);
00143         
00144         float   GetPosition() const { return Position; }
00145         BOOL    GetSelState() const { return Selected; }
00146         BOOL    IsSelected()  const { return Selected; }
00147 
00148         virtual BOOL IsAColourRampItem() const { return (FALSE); }
00149         virtual BOOL IsATranspRampItem() const { return (FALSE); }
00150 
00151     private:
00152         void    ClampPosition();
00153 
00154     protected:
00155         float   Position;           // 0..1 specifies the position of this colour
00156         BOOL    Selected;           // whether this item is selected in the UI
00157 };
00158 
00159 
00160 /********************************************************************************************
00161 
00162 >   class ColRampItem : public RampItem
00163 
00164     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00165     Created:    05/02/97
00166     Purpose:    Defines a single entry in a colour ramp. 
00167                 An entry is simply made up of a single doc colour definition.
00168 
00169 ********************************************************************************************/
00170 
00171 class ColRampItem : public RampItem
00172 {
00173     CC_DECLARE_DYNCREATE(ColRampItem);
00174 
00175     public:
00176         ColRampItem();
00177         ColRampItem(float pos, DocColour *pCol);
00178         ColRampItem(const ColRampItem &other);
00179         
00180         void        SetColour(DocColour *pCol);
00181         DocColour   GetColour() const   { return Colour; }
00182         DocColour*  GetColourAddr()     { return &Colour; }
00183         
00184         INT32           operator==(const ColRampItem& other) const;
00185 
00186         virtual BOOL IsAColourRampItem() const { return (TRUE); }
00187 
00188     private:
00189         DocColour   Colour;             // the actual colour.
00190 };
00191 
00192 
00193 /********************************************************************************************
00194 
00195 >   class TranspRampItem : public RampItem
00196 
00197     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00198     Created:    05/02/97
00199     Purpose:    Defines a single entry in a transparency ramp. 
00200                 An entry is simply made up of a single long definition.
00201 
00202 ********************************************************************************************/
00203 
00204 class TranspRampItem : public RampItem
00205 {
00206     CC_DECLARE_DYNCREATE(TranspRampItem);
00207 
00208     public:
00209         TranspRampItem();
00210         TranspRampItem(float pos, UINT32 transp);
00211         TranspRampItem(const TranspRampItem &other);
00212         
00213         void    SetTransparency(UINT32 transp);
00214         UINT32  GetTransparency() const { return Transparency; }
00215         UINT32* GetTranspAddr()         { return &Transparency; }
00216         
00217         INT32       operator==(const TranspRampItem& other) const;
00218 
00219         virtual BOOL IsATranspRampItem() const { return (TRUE); }
00220 
00221     private:
00222         UINT32  Transparency;       // the actual transparency.
00223 };
00224 
00225 
00226 
00227 /********************************************************************************************
00228 
00229 >   class FillRamp : public List
00230 
00231     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00232     Created:    05/02/97
00233     Purpose:    The base class fill ramp. This class contains common functionality between
00234                 colour and transparency ramps. Each ramp entry derived from RampItem will 
00235                 contain a selection state and a (float) parameter value. The parameter value
00236                 usually ranges between 0 and 1 and hence can be used to generate a coordinate
00237                 from any given fill geometry.
00238 
00239 ********************************************************************************************/
00240 
00241 class FillRamp : public List
00242 {
00243     CC_DECLARE_DYNAMIC( FillRamp )
00244 
00245     public:
00246         void      GetSelectionState(BOOL *SelState) const;
00247                   // find the selection state for all blobs
00248                 
00249         UINT32    CountSelBlobs() const;
00250                   // just how many selected blobs are there?
00251 
00252         INT32     GetSelectedIndex() const;
00253                   // find the index of the first selected blob
00254 
00255         BOOL      GetIndexRange(UINT32 *pFirst, UINT32 *pLast) const;
00256                   // find the index of the start and end blobs (hence the range)
00257 
00258         BOOL      IsSelected(UINT32 index) const;
00259                   // is a particular blob selected?
00260 
00261         void      DeselectAll() const;
00262                   // throw away any selected bits.
00263 
00264         FillControl     RotateSelRight (BOOL StartPointSelected, BOOL EndPointSelected, FillControl& OldSelectedBlob) const;
00265                         // rotate all selection states down the list (with carry)
00266 
00267         BOOL      RotateSelLeft(BOOL StartPointSelected, BOOL EndPointSelected, FillControl& OldSelectedBlob) const;
00268                   // rotate all selection states up the list (with carry)
00269 
00270         void      SetSelState(UINT32 index, INT32 state);
00271                   // set, unset or toggle the selection state of a blob
00272 
00273         UINT32    SetPosition(UINT32 index, float pos);
00274                   // give the item at 'index' a new position.
00275 
00276         UINT32    HitBlob(FillGeometryAttribute *pGeom, DocCoord& ClickPos) const;
00277                   // is the given click position inside a blob?
00278 
00279         DocCoord  GetGeometryCoord(FillGeometryAttribute *pGeom, UINT32 index) const;
00280                   // get the actual position of a blob on a given geometry
00281 
00282         void      RenderRampBlobs(FillGeometryAttribute *pGeom, RenderRegion *pRender, BOOL *pSelState=NULL) const;
00283                   // render all the blob positions to a render region
00284 
00285         void      RenderSelectedBlob (FillGeometryAttribute *pGeom, RenderRegion *pRender);
00286                   // render just the selected blob (so that we don't get blob redraw ficker)
00287 
00288         void      SortRamp();
00289                   // ensures that all positions in the ramp are in numerical order
00290 
00291         RampItem* GetValidIndexedItem(UINT32 index) const;
00292                   // find the i'th item in our blob list, do some error checking on index
00293 
00294         void      Blend (FillGeometryAttribute* pNewAttr, BlendAttrParam* pBlendParam, FillGeometryAttribute* pOtherFill, BOOL notInvert = FALSE);
00295                   // blend those fill ramps!
00296 
00297     protected:
00298 
00299         RampItem* GetIndexedItem(INT32 index) const;
00300                   // find the i'th item in our blob list
00301         
00302         UINT32    InsertNewItem(RampItem* pItem);
00303                   // place a new item somewhere in the list.
00304 
00305     private:
00306         RampItem* FindInsertPosition(float pos, INT32* pInsert, UINT32* index) const;
00307                   // return a list insertion point for this new item (helper function)
00308 
00309         UINT32    ShuffleItem(RampItem *pItem, UINT32 index);
00310                   // shuffle pItem around in the list after a position change
00311 
00312         // private support functions for FillRamp::Blend () ....
00313         
00314         void      DoOneToOneBlend (FillGeometryAttribute* pNewAttr, BlendAttrParam* pBlendParam, FillRamp* OtherRamp, BOOL notInvert);
00315         void      DoNoneToManyBlend (FillGeometryAttribute* pNewAttr, BlendAttrParam* pBlendParam, FillRamp* OtherRamp, BOOL notInvert);
00316         void      DoManyToNoneBlend (FillGeometryAttribute* pNewAttr, BlendAttrParam* pBlendParam, FillGeometryAttribute* pOtherFill, BOOL notInvert);
00317         void      DoManyToManyBlend (FillGeometryAttribute* pNewAttr, BlendAttrParam* pBlendParam, FillRamp* OtherRamp, BOOL notInvert);
00318 };
00319 
00320 
00321 /***********************************************************************************************
00322 
00323 >   class ColourRamp : public FillRamp
00324 
00325     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00326     Created:    02/02/97
00327     Purpose:    This class holds a list of colour records, each of which describe a colour
00328                 position in a colour ramp. The list contains the usual add/delete entry members
00329                 and other suitable interfaces to allow colour ramps to be edited.
00330                 The list is used inside GradFillAttribute to describe multicoloured fills.
00331 
00332 ***********************************************************************************************/
00333 
00334 class ColourRamp : public FillRamp
00335 {
00336     CC_DECLARE_DYNAMIC( ColourRamp )
00337 
00338     public:
00339         virtual ~ColourRamp();
00340 
00341                ColRampItem* AddEntry(float pos, DocColour* pCol);
00342         inline ColRampItem* GetFirstCol() const;
00343         inline ColRampItem* GetLastCol() const;
00344         inline ColRampItem* GetNextCol(ColRampItem* pItem) const;
00345         inline ColRampItem* GetPrevCol(ColRampItem* pItem) const;
00346                ColourRamp&  operator=(const ColourRamp& other);
00347                DocColour*   GetFirstSelectedColour();
00348                DocColour*   EnumerateColourFields(UINT32 index);
00349 
00350                BOOL IsDifferentTo(ColourRamp *pRamp);
00351 
00352         INT32    operator==(const ColourRamp& other) const;
00353         void   DeleteAll();
00354 
00355         BOOL   SetItemColour(UINT32 index, DocColour* pCol);
00356         INT32   SetSelectedColours(DocColour *pCol);
00357 
00358         BOOL CopyComponentData(BaseDocument* SrcDoc, BaseDocument* NodesDoc);
00359 
00360         BOOL WriteColourDefinitions (BaseCamelotFilter* pFilter);
00361 
00362 #ifdef _DEBUG
00363         // dump all fill ramp entries
00364         void Dump();
00365 #else
00366         void Dump() { } ;
00367 #endif
00368 
00369 };
00370 
00371 
00372 // inline function to return the 'correctly typed ' first entry.
00373 ColRampItem* ColourRamp::GetFirstCol() const
00374 {
00375     return (ColRampItem*)GetHead();
00376 }
00377 
00378 // inline function to return the 'correctly typed ' last entry.
00379 ColRampItem* ColourRamp::GetLastCol() const
00380 {
00381     return (ColRampItem*)GetTail();
00382 }
00383 
00384 // inline function to return the 'correctly typed ' next entry.
00385 ColRampItem* ColourRamp::GetNextCol(ColRampItem* pItem) const
00386 {
00387     return (ColRampItem*)GetNext(pItem);
00388 }
00389 
00390 // inline function to return the 'correctly typed ' previous entry.
00391 ColRampItem* ColourRamp::GetPrevCol(ColRampItem* pItem) const
00392 {
00393     return (ColRampItem*)GetPrev(pItem);
00394 }
00395 
00396 
00397 
00398 
00399 
00400 /***********************************************************************************************
00401 
00402 >   class TransparencyRamp : public FillRamp
00403 
00404     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00405     Created:    02/02/97
00406     Purpose:    This class holds a list of transparency records, each of which describe a
00407                 specific entry in the transparency ramp
00408 
00409 ***********************************************************************************************/
00410 
00411 class TransparencyRamp : public FillRamp
00412 {
00413     CC_DECLARE_DYNAMIC( TransparencyRamp )
00414 
00415     public:
00416         virtual ~TransparencyRamp();
00417 
00418                TranspRampItem* AddEntry(float pos, UINT32 transp);
00419         inline TranspRampItem* GetFirstTransp() const;
00420         inline TranspRampItem* GetNextTransp(TranspRampItem* pItem) const;
00421                TransparencyRamp& operator=(const TransparencyRamp& other);
00422 
00423                BOOL IsDifferentTo(TransparencyRamp *pRamp);
00424                UINT32* GetFirstSelectedTransp();
00425 
00426         INT32    operator==(const TransparencyRamp& other) const;
00427         void   DeleteAll();
00428         
00429         BOOL   SetItemTransp(UINT32 index, UINT32 transp);
00430         INT32   SetSelectedTransp(UINT32 transp);
00431 };
00432 
00433 
00434 // inline function to return the 'correctly typed ' first entry
00435 TranspRampItem* TransparencyRamp::GetFirstTransp() const
00436 {
00437     return (TranspRampItem*)GetHead();
00438 }
00439 
00440 // inline function to return the 'correctly typed ' next entry
00441 TranspRampItem* TransparencyRamp::GetNextTransp(TranspRampItem* pItem) const
00442 {
00443     return (TranspRampItem*)GetNext(pItem);
00444 }
00445 
00446 
00447 
00448 #endif // INC_FILLRAMP
00449 

Generated on Sat Nov 10 03:45:14 2007 for Camelot by  doxygen 1.4.4