gml_GRItem_Polygon.h

00001 // gml_GRItem_Polygon.h --
00002 //
00003 //    Declares the "gml_TGRItem_Polygon" class. A gml_TGRItem_Polygon is a rectangle that may
00004 //      or may not have an outline and a colored inside. And may or may not have
00005 //      a bitmap texture.
00006 //
00007 //  Copyright (c) 2003 CLIPS-IMAG
00008 //
00009 //  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00010 //  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00011 //
00012 //  March 2, 2004 (FB)
00013 //    Re-written for gml, debug (FB)
00014 //
00015 //  Created on July 2004 (Yohan Piccoli / FB).
00016 
00017 #ifndef __GML_GRITEM_POLYGON__
00018 #define __GML_GRITEM_POLYGON__
00019 
00020 #include "gml/ui/gml_GRItem.h"
00021 
00022 #include "gml/image/gml_RGBColor.h"
00023 #include "gml/gl/gml_GL_Texture.h"
00024 
00025 
00026 
00027 // Default configuration values.
00028 
00029 const gml_TBoolean          gml_cGRItem_PolygonDefaultOutline             = gml_cTrue;
00030 const gml_TGRItemParam      gml_cGRItem_PolygonDefaultOutlineWidth        = 1.0;
00031 const gml_TRGBColor         gml_cGRItem_PolygonDefaultOutlineColor        = { 0xffff, 0xffff, 0xffff };
00032 const gml_TGRItemParam      gml_cGRItem_PolygonDefaultOutlineAlpha        = 1.0;
00033 const gml_TBoolean          gml_cGRItem_PolygonDefaultOutlineAAlias       = gml_cTrue;
00034 const gml_TBoolean          gml_cGRItem_PolygonDefaultFill                = gml_cFalse;
00035 const gml_TRGBColor         gml_cGRItem_PolygonDefaultFillColor           = { 0x0, 0x0, 0x0 };
00036 const gml_TGRItemParam      gml_cGRItem_PolygonDefaultFillAlpha           = 1.0;
00037 const gml_TGRItemParam      gml_cGRItem_PolygonDefaultTexureAlpha         = 1.0;
00038 
00039 
00040 
00041 
00042 // gml_TGRItem_Polygon --
00043 
00044 class gml_TGRItem_Polygon : virtual public gml_TGRItem
00045 {
00046 public:
00047 
00048   // Init --
00049   //
00050   //  See "gml_TGRItem::Init".
00051   virtual
00052   gml_TError        Init (gml_TGRItem_Scene*  scene       = (gml_TGRItem_Scene*)NULL,
00053                           gml_TGRItem*        parentItem  = (gml_TGRItem*)NULL,
00054                           gml_TGRItemTransfo* transfo     = (gml_TGRItemTransfo*)NULL,
00055                           gml_TPointer        clientData  = (gml_TPointer)NULL);
00056   
00057   // Dispose --
00058   //
00059   //  See "gml_TGRItem::Dispose".
00060   virtual
00061   void              Dispose ();
00062 
00063   // Configure --
00064   //
00065   //  Set Polygon aspect parameters. Any parameter which value is "NULL" is not modified.
00066   //    <*shapeNpPt>      number of 2D points in the <shape> array parameter.
00067   //    <shape>           array of <*shapeNbPt> 2D points defining the shape of the polygon.
00068   //                        "Configure" will make a copy of this array, so the passed array
00069   //                        can be safely freed after the call.
00070   //    <*outline>        TRUE if the polygon has an outline.
00071   //    <*outlineWidth>   width (in pixel) of the outline stroke.
00072   //    <*outlineColor>   color of the outline. If <*outlineColor> is NULL, the
00073   //                        outline is not drawn. The given color is copied so it can be freed
00074   //                        after calling configure.
00075   //    <*outlineAlpha>   transparency value of the outline.
00076   //    <*outlineAAlias>  TRUE if the outline is to be drawn with anti-aliasing activated.
00077   //    <*fill>           TRUE if the polygon has an interior.
00078   //    <*fillColor>      color of the interior. If <*fillColor> is NULL, the
00079   //                        interior is not drawn. The given color is copied so it can be freed
00080   //                        after calling configure.
00081   //    <*fillAlpha>      transparency value of the interior.
00082   //    <*texture>        texture object for the polygon. NULL means no texture.
00083   //    <*textureAlpha>   transparency of the texture.
00084 
00085   virtual
00086   gml_TError        Configure  (int*                shapeNbPt     = (int*)NULL,
00087                                 gml_TGRItemParam*   shape         = (gml_TGRItemParam*)NULL,
00088                                 gml_TBoolean*       outline       = (gml_TBoolean*)NULL,
00089                                 gml_TGRItemParam*   outlineWidth  = (gml_TGRItemParam*)NULL,
00090                                 gml_TRGBColor*      outlineColor  = (gml_TRGBColor*)NULL,
00091                                 gml_TGRItemParam*   outlineAlpha  = (gml_TGRItemParam*)NULL,
00092                                 gml_TBoolean*       outlineAAlias = (gml_TBoolean*)NULL,
00093                                 gml_TBoolean*       fill          = (gml_TBoolean*)NULL,
00094                                 gml_TRGBColor*      fillColor     = (gml_TRGBColor*)NULL,
00095                                 gml_TGRItemParam*   fillAlpha     = (gml_TGRItemParam*)NULL,
00096                                 gmlGL_TTexture**    texture       = (gmlGL_TTexture**)NULL,
00097                                 gml_TGRItemParam*   textureAlpha  = (gml_TGRItemParam*)NULL);
00098 
00099   // GetConfiguration --
00100   //
00101   //  Get Polygon aspect parameters. Any parameter which value is "NULL" is not returned.
00102   //  See <Configure>.
00103   //
00104   //  If <shape> is not NULL, it will receive the array of 2D vertices managed by the
00105   //    polygon object: this array must not be modified or freed and the polygon
00106   //    may modify it.
00107 
00108   virtual
00109   gml_TError        GetConfiguration (int*                shapeNbPt     = (int*)NULL,
00110                                       gml_TGRItemParam**  shape         = (gml_TGRItemParam**)NULL,
00111                                       gml_TBoolean*       outline       = (gml_TBoolean*)NULL,
00112                                       gml_TGRItemParam*   outlineWidth  = (gml_TGRItemParam*)NULL,
00113                                       gml_TRGBColor*      outlineColor  = (gml_TRGBColor*)NULL,
00114                                       gml_TGRItemParam*   outlineAlpha  = (gml_TGRItemParam*)NULL,
00115                                       gml_TBoolean*       outlineAAlias = (gml_TBoolean*)NULL,
00116                                       gml_TBoolean*       fill          = (gml_TBoolean*)NULL,
00117                                       gml_TRGBColor*      fillColor     = (gml_TRGBColor*)NULL,
00118                                       gml_TGRItemParam*   fillAlpha     = (gml_TGRItemParam*)NULL,
00119                                       gmlGL_TTexture**    texture       = (gmlGL_TTexture**)NULL,
00120                                       gml_TGRItemParam*   textureAlpha  = (gml_TGRItemParam*)NULL);
00121 
00122   // Texture --
00123   
00124   gmlGL_TTexture*   Texture ()
00125                       { return fTexture; }
00126 
00127   // UpdateNonClippedBBox --
00128   //
00129   //  See "gml_TGRItem::UpdateNonClippedBBox".
00130 
00131   virtual void      UpdateNonClippedBBox ();
00132 
00133 
00134   // IsOverItem --
00135   //
00136   //  See "gml_TGRItem::IsOverItem".
00137   
00138   gml_TBoolean      IsOverItem (gml_TGRItemParam* pt);
00139 
00140 
00141 
00142   // PointToItem --
00143   //
00144   //  See "gml_TGRItem::PointToItem".
00145 
00146   gml_TGRItemParam  PointToItem (gml_TGRItemParam* pt);
00147 
00148 
00149 
00150   // RelationToRect --
00151   //
00152   //  See "gml_TGRItem::RelationToRect".
00153 
00154   int               RelationToRect (gml_TGRItemParam* rect);
00155 
00156 
00157 
00158   // LocalBBox --
00159   //
00160   //  Return the local bouding box, ie. the bouding box
00161   //    expressed in the local refernce.
00162   
00163   gml_TGRItemParam* LocalBBox ()
00164                       {
00165                         if (fLocalBBDirty)
00166                           this->ComputeLocalBBox ();
00167                         return fLocalBBox;
00168                       }
00169 
00170   // ComputeLocalBBox --
00171   
00172   void              ComputeLocalBBox ();                          
00173 
00174 
00175 protected:
00176 
00177   static void         Initialize ();
00178   static gml_TBoolean fGRItem_polygon_initialized;
00179 
00180   int                 fNbPt;            // Shape number of points.
00181   gml_TGRItemParam*   fShape;           // Array of points [x0 y0 x1 y1 ...].
00182   int                 fAutoClosed;      // 0 if the passed polygon was passed "closed", 1 otherwise
00183                                         //  (i.e. the object closed itself by allocating a last point
00184                                         //  set a the position of the first point).
00185   gml_TBoolean        fLocalBBDirty;
00186   gml_TGRItemParam    fLocalBBox[4];
00187 
00188   gml_TGRItemParam    fOutlineWidth;
00189   gml_TBoolean        fOutline;
00190   gml_TRGBColor       fOutlineColor;
00191   gml_TGRItemParam    fOutlineAlpha;
00192   gml_TBoolean        fOutlineAAlias;
00193   gml_TBoolean        fFill;
00194   gml_TRGBColor       fFillColor;
00195   gml_TGRItemParam    fFillAlpha;
00196 
00197   gmlGL_TTexture*     fTexture;
00198   gml_TGRItemParam    fTextureAlpha;
00199 
00200   gml_TGRItemParam*   fVertices;        // expressed in global coordinates, computed when the
00201                                         //  bounding box is computed. Allocated at the end
00202                                         //  of fShape.
00203 };
00204 
00205 
00206 
00207 #endif
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.