legend.h

Go to the documentation of this file.
00001 /**
00002  * \file gre/legend.h
00003  * \brief GRE LEGEND base class definitions
00004  *
00005  * \if NODOC
00006  * $Id: legend.h_v 1.1 2004/03/04 19:00:34 mju Exp $
00007  *
00008  * $Log: legend.h_v $
00009  * Revision 1.1  2004/03/04 19:00:34  mju
00010  * Initial revision
00011  *
00012  * \endif
00013 **/
00014 
00015 #ifndef  INC_GRE_LEGEND_H
00016 #define  INC_GRE_LEGEND_H
00017 
00018 #ifndef  INC_RVC_DBELEM_H
00019    #include <rvc/dbelem.h>
00020 #endif
00021 
00022 #ifndef  INC_GRE_ELEMSAMPLEDC_H
00023    #include <gre/elemsampledc.h>
00024 #endif
00025 
00026 //===================================================================================================================
00027 
00028 #define  GRE_LEGENDVIEW_LabelSpace  4
00029 #define  GRE_LEGENDVIEW_ItemSpace   2
00030 
00031 //! Legend base class.
00032 class GRE_LEGEND {
00033    public:
00034 
00035       class DRAWCONTEXT;
00036       class ITEMBASE;
00037       typedef MILIST<ITEMBASE*> ITEMLIST;
00038 
00039       //! Constructor
00040       explicit GRE_LEGEND (
00041          GRE_LAYER *layer,
00042          ELEMTYPE ElemType
00043          );
00044 
00045       //! Destructor.
00046       virtual ~GRE_LEGEND (
00047          );
00048 
00049    #if defined(X_NATIVE) || defined(WIN32_MFC)
00050       //! Add element to legend 'element table' with prompt for label(s).
00051       virtual ERRVALUE AddElemPrompted (
00052          MDLGPARENT dlgparent,               //!< Parent for dialog
00053          const RVC::ELEMENT& element         //!< Element to add
00054          );
00055    #endif
00056 
00057       //! Determine if legend 'element table' contains specified element.
00058       bool ContainsElem (
00059          const RVC::ELEMENT& element         //!< Element
00060          ) const;
00061 
00062       //! Create 'element table' if don't already have one attached.
00063       ERRVALUE CreateElemTable (
00064          const RVC::OBJECTNAME& TableName,   //!< Name of table to create
00065          const RVC::OBJECTDESC& TableDesc    //!< Description of table to create
00066          );
00067 
00068       //! Delete all items from the legend.
00069       void DeleteAllItems (
00070          );
00071 
00072       //! Delete element from legend 'element table'.
00073       ERRVALUE DeleteElem (
00074          const RVC::ELEMENT& element         //!< Element
00075          );
00076 
00077       //! Draw entire legend.
00078       void Draw (
00079          const DRAWCONTEXT& dc,              //!< Legend drawing context
00080          LPOINT2D& origin                    //!< Origin passed / returned
00081          ) const;
00082 
00083       //! Return element type legend is for.
00084       ELEMTYPE GetElemType (
00085          ) const { return (m_ElemType); }
00086 
00087       //! Get legend item list.
00088       const ITEMLIST& GetItemList (
00089          ) const { return (m_ItemList); }
00090 
00091       //! Get "preferred" item size in millimeters.
00092       virtual void GetItemSizeMM (
00093          DPOINT2D& size                      //!< Size in millimeters returned, not including labels
00094          ) const;
00095 
00096       //! Get "preferred" item size in pixels.
00097       //! This is used for rendering legend in user interface (ie. LegendView).
00098       virtual void GetItemSizePixels (
00099          LPOINT2D& size                      //!< Size in pixels returned, not including labels
00100          ) const;
00101 
00102       //! Return layer legend is associated with.
00103       GRE_LAYER* GetLayer (
00104          ) const { return (m_layer); }
00105 
00106       //! Return flags for sample style rendering.
00107       //! @return Flags for sample style rendering.
00108       MGD::STYLESAMPLEFLAGS GetSampleFlags (
00109          ) const { return (m_SampleFlags); }
00110 
00111       //! Get size of legend given sample item height and width.
00112       //! @return Size of legend given sample item height and width.
00113       LPOINT2D GetSize (
00114          const DRAWCONTEXT& dc               //!< Legend drawing context
00115          ) const;
00116 
00117       //! Get reference to style object item used by legend.
00118       const RVC::OBJITEM& GetStyleObjItem (
00119          ) { return (m_StyleObjItem); }
00120 
00121       //! Determine if legend has associated 'element table'.
00122       bool HasElemTable (
00123          ) const { return (m_ElemTable.IsAttached()); }
00124 
00125       //! Determine if legend has any items.
00126       bool HasItems (
00127          ) const { return (!m_ItemList.IsEmpty()); }
00128 
00129       //! Determine if duplicate styles are being merged as items are added.
00130       bool IsMergingDuplicateStyles (
00131          ) const { return (m_MergeDupStyles); }
00132 
00133       //! Determine if legend is sorted by label strings.
00134       bool IsSorted (
00135          ) const { return (m_Sorted); }
00136 
00137       //! Set whether to merge duplicate styles. 
00138       void SetMergeDuplicateStyles (
00139          bool MergeDupStyles = true
00140          ) { m_MergeDupStyles = MergeDupStyles; }
00141 
00142       //! Set whether a style object is needed.
00143       void SetNeedStyleObject (
00144          bool NeedStyleObj = true
00145          ) { m_NeedStyleObj = NeedStyleObj; }
00146 
00147       //! Set sample flags.
00148       void SetSampleFlags (
00149          MGD::STYLESAMPLEFLAGS newflags
00150          ) { m_SampleFlags = newflags | MGD::STYLESAMPLE_ShrinkToFit; }
00151 
00152       //! Set whether should be sorted by labels.
00153       //! Must be done before adding items.
00154       void SetSorted (                 
00155          bool sorted = true
00156          ) { m_Sorted = sorted; }
00157 
00158       //! Set style object to use for legend using RVC::OBJITEM reference.
00159       void SetStyleObject (
00160          const RVC::OBJITEM& StyleObj
00161          );
00162 
00163    protected:
00164 
00165       ITEMLIST m_ItemList;                //!< List of legend items
00166       RVC::OBJITEM m_GeoObjItem;
00167       RVC::DBASE_ELEMENT m_DbObject;
00168       RVC::DBTABLE m_ElemTable;
00169 
00170       ERRVALUE AddElemRecord (
00171          const RVC::ELEMENT& element,
00172          const MISTRING& prilabel,
00173          const MISTRING& seclabel
00174          );
00175 
00176       void InsertItem (
00177          ITEMBASE *item                         //!< Item to insert
00178          );
00179 
00180       ERRVALUE OpenElemTable (
00181          const RVC::OBJECTNAME& ElemTableName
00182          );
00183 
00184       ERRVALUE OpenStyle (
00185          RVC::DBTABLE_STYLE& StyleTable,
00186          const RVC::OBJITEM& StyleObjItem,
00187          const RVC::OBJITEM& GeoObjItem,
00188          RVC::STYLE& StyleObj
00189          );
00190 
00191       void SetHasMergedStyles (
00192          ) { m_HasMergedStyles = true; }
00193 
00194    private:
00195       #ifndef GENERATING_DOXYGEN_OUTPUT
00196       GRE_LAYER *m_layer;              //!< Layer legend is associated with
00197       ELEMTYPE m_ElemType;             //!< Element type legend is for
00198       bool m_Sorted;                   //!< Set if sorted
00199       bool m_NeedStyleObj;             //!< Set if need style object for patterns
00200       bool m_MergeDupStyles;           //!< Merge duplicate styles when adding
00201       bool m_HasMergedStyles;          //!< Duplicate styles have been merged
00202       MGD::STYLESAMPLEFLAGS m_SampleFlags;      //!< Flags for sample style drawing
00203       RVC::OBJITEM m_StyleObjItem;
00204 
00205       GRE_LEGEND (const GRE_LEGEND&);
00206       GRE_LEGEND& operator= (const GRE_LEGEND&);
00207 
00208       friend class DRAWCONTEXT;
00209       #endif // GENERATING_DOXYGEN_OUTPUT
00210    };
00211 
00212 
00213 //! Context for legend item drawing.
00214 class GRE_LEGEND::DRAWCONTEXT : public GRE_ELEMSAMPLE_DC {
00215    public:
00216 
00217       //! Orientation for drawing if supported by legend type.
00218       //! This is used by "color scale" legend.
00219       enum ORIENTATION {
00220          ORIENTATION_Vertical =     0,    //!< Draw items in "vertical" orientation (default)
00221          ORIENTATION_Horizonatal =  1     //!< Draw items in "horizontal" orientation
00222          };
00223 
00224       GRE_LAYER *m_layer;
00225       ELEMTYPE m_ElemType;
00226       INT32 m_itemheight;
00227       INT32 m_samplewidth;
00228       INT32 m_labelspace;
00229       INT32 m_itemspace;
00230       LRECT2D m_cliprect;
00231       bool m_DrawLabels;
00232       bool m_DrawLabelsOnColorScales;     //!< Special case override for above flag.
00233       bool m_HasTextStyle;
00234       TEXTSTYLE m_TextStyle;
00235       ORIENTATION m_Orientation;
00236 
00237       //! Constructor for use in user interface
00238       DRAWCONTEXT (
00239          const GRE_LEGEND& legend,
00240          MGD::CONTEXT *gc,
00241          INT32 labelspace,                //!< Spacing between sample and label in pixels
00242          INT32 itemspace,                 //!< Spacing between items in pixels
00243          const LRECT2D& cliprect          //!< Clipping rectangle
00244          );
00245 
00246       virtual ~DRAWCONTEXT (
00247          );
00248 
00249       //! Determine if legend has vertical orientation.
00250       bool IsVertical (
00251          ) const { return (m_Orientation == ORIENTATION_Vertical); }
00252 
00253       //! Set whether or not to draw labels for legend items.
00254       void SetDrawLabels (
00255          bool DrawLabels
00256          ) { m_DrawLabels = DrawLabels; }
00257 
00258    }; //! End of GRE_LEGEND::DRAWCONTEXT class.
00259 
00260 
00261 //! Base class for legend item defining virtual methods for drawing
00262 class GRE_LEGEND::ITEMBASE {
00263    public:
00264 
00265       //! Default constructor.
00266       ITEMBASE (
00267          );
00268 
00269       //! Construct with no specified element
00270       explicit ITEMBASE (
00271          const MISTRING& label            //!< Label
00272          );
00273 
00274       //! Construct with element and label.
00275       ITEMBASE (
00276          const RVC::ELEMENT& element,     //!< Element from associated object
00277          const MISTRING& label            //!< Label
00278          );
00279 
00280       //! Destructor.
00281       virtual ~ITEMBASE (
00282          );
00283 
00284       //! Draw item.
00285       virtual void Draw (
00286          const DRAWCONTEXT& dc,           //!< Legend drawing context
00287          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00288          ) const = 0;
00289 
00290       //! Draw label.
00291       void DrawLabel (
00292          const DRAWCONTEXT& dc,           //!< Legend drawing context
00293          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00294          ) const;
00295 
00296    #ifdef WIN32_MFC
00297       //! Draw item with label in MFC TreeView (MFC only).
00298       //! Must implement in derived class when compiling for WIN32_MFC.
00299       virtual void DrawTreeView (
00300          void *hdc,                       //!< Windows device context
00301          const GRE_ELEMSAMPLE_DC& dc,     //!< Legend drawing context
00302          const CRect& rect,               //!< Bounding rectangle including label
00303          bool HasFocus                    //!< 'true' if item has "focus"
00304          ) = 0;
00305    #endif
00306 
00307       //! Get element used by item.
00308       const RVC::ELEMENT& GetElement (
00309          ) const { return (m_element); }
00310 
00311       //! Get element number.
00312       INT32 GetElemNum (
00313          ) const { return (m_element.GetNumber()); }
00314 
00315       //! Get the label.
00316       const MISTRING& GetLabel (
00317          ) const { return (m_label); }
00318 
00319       //! Get size of label.
00320       void GetLabelSize (
00321          const DRAWCONTEXT& dc,           //!< Legend drawing context
00322          LPOINT2D& size                   //!< Size in "display pixels" returned
00323          ) const;
00324 
00325       //! Determine if item requires transparency support.
00326       virtual bool HasTransparency (
00327          ) const;
00328 
00329       //! Merge label with current label.
00330       void MergeLabel (
00331          const MISTRING& label
00332          );
00333 
00334    private:
00335       #ifndef GENERATING_DOXYGEN_OUTPUT
00336       RVC::ELEMENT m_element;
00337       MISTRING m_label;
00338 
00339       ITEMBASE (const ITEMBASE&);
00340       ITEMBASE& operator= (const ITEMBASE&);
00341       #endif // GENERATING_DOXYGEN_OUTPUT
00342    }; //! End of GRE_LEGEND::ITEMBASE class.
00343 
00344 
00345 //===================================================================================================================
00346 
00347 //! Point Feature legend subclass.
00348 class GRE_LEGEND_POINT : public GRE_LEGEND {
00349    public:
00350 
00351       class ITEM;
00352 
00353       //! Construct legend for layer and element type.
00354       GRE_LEGEND_POINT (
00355          GRE_LAYER *layer,                   //!< Layer legend is for
00356          ELEMTYPE ElemType                   //!< Element type
00357          );
00358 
00359    #if defined(X_NATIVE) || defined(WIN32_MFC)
00360       //! Add element to legend 'element table' with prompt for label(s).
00361       virtual ERRVALUE AddElemPrompted (
00362          MDLGPARENT dlgparent,               //!< Parent for dialog
00363          const RVC::ELEMENT& element         //!< Element to add
00364          );
00365    #endif
00366 
00367       //! Add item to legend.
00368       void AddItem (
00369          const POINTSTYLE& style,
00370          const MISTRING& label
00371          );
00372 
00373       //! Add item to legend.
00374       void AddItem (
00375          const RVC::ELEMENT& element,           //!< Element to add
00376          const MISTRING& label
00377          );
00378 
00379       ERRVALUE Setup (
00380          const POINTPARMS& parms,
00381          const RVC::OBJITEM& GeoObjItem,
00382          const RVC::OBJITEM& StyleObjItem
00383          );
00384 
00385    private:
00386       #ifndef GENERATING_DOXYGEN_OUTPUT
00387       GRE_LEGEND_POINT (const GRE_LEGEND_POINT&);
00388       GRE_LEGEND_POINT& operator= (const GRE_LEGEND_POINT&);
00389       #endif // GENERATING_DOXYGEN_OUTPUT
00390    };
00391 
00392 
00393 //! Individual item in point legend.
00394 class GRE_LEGEND_POINT::ITEM : public GRE_LEGEND::ITEMBASE {
00395    public:
00396 
00397       //! Constructor using POINTSTYLE and label.
00398       ITEM (
00399          const POINTSTYLE& style,
00400          const MISTRING& label
00401          );
00402 
00403       //! Constructor using element number and label.
00404       ITEM (
00405          const RVC::ELEMENT& element,     //!< Element
00406          const MISTRING& label            //!< Label
00407          );
00408 
00409       //! Destructor.
00410       virtual ~ITEM (
00411          );
00412 
00413       //! Draw item.
00414       virtual void Draw (
00415          const DRAWCONTEXT& dc,           //!< Legend drawing context
00416          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00417          ) const;
00418 
00419    #ifdef WIN32_MFC
00420       //! Draw item with label in TreeView (WIN32_MFC).
00421       virtual void DrawTreeView (
00422          void *hdc,                       //!< Windows device context
00423          const GRE_ELEMSAMPLE_DC& dc,     //!< Legend drawing context
00424          const CRect& rect,               //!< Bounding rectangle including label
00425          bool HasFocus                    //!< 'true' if item has "focus"
00426          );
00427    #endif
00428 
00429       //! Get style for item.
00430       const POINTSTYLE& GetStyle (
00431          ) const { return (m_style); }
00432 
00433       //! Determine if this item has same style.
00434       bool HasSameStyle (
00435          const POINTSTYLE& style          //!< Style to compare
00436          ) const;
00437 
00438       //! Determine if item requires transparency support.
00439       virtual bool HasTransparency (
00440          ) const;
00441 
00442    private:
00443       #ifndef GENERATING_DOXYGEN_OUTPUT
00444       POINTSTYLE m_style;
00445       ITEM (const ITEM&);
00446       ITEM& operator= (const ITEM&);
00447       #endif // GENERATING_DOXYGEN_OUTPUT
00448    };
00449 
00450 
00451 //===================================================================================================================
00452 
00453 //! Line Feature legend subclass.
00454 class GRE_LEGEND_LINE : public GRE_LEGEND {
00455    public:
00456 
00457       class ITEM;
00458 
00459       //! Construct legend for layer and element type.
00460       GRE_LEGEND_LINE (
00461          GRE_LAYER *layer,                   //!< Layer legend is for
00462          ELEMTYPE ElemType                   //!< Element type
00463          );
00464 
00465    #if defined(X_NATIVE) || defined(WIN32_MFC)
00466       //! Add element to legend 'element table' with prompt for label(s).
00467       virtual ERRVALUE AddElemPrompted (
00468          MDLGPARENT dlgparent,               //!< Parent for dialog
00469          const RVC::ELEMENT& element         //!< Element to add
00470          );
00471    #endif
00472 
00473       //! Add item to legend.
00474       void AddItem (
00475          const LINESTYLE& style,
00476          const MISTRING& label
00477          );                               
00478 
00479       //! Add item to legend.
00480       void AddItem (
00481          const RVC::ELEMENT& element,           //!< Element to add
00482          const MISTRING& label
00483          );
00484 
00485       ERRVALUE Setup (
00486          const LINEPARMS& parm,
00487          const RVC::OBJITEM& GeoObjItem,
00488          const RVC::OBJITEM& StyleObjItem
00489          );
00490 
00491    private:
00492       #ifndef GENERATING_DOXYGEN_OUTPUT
00493       GRE_LEGEND_LINE (const GRE_LEGEND_LINE&);
00494       GRE_LEGEND_LINE& operator= (const GRE_LEGEND_LINE&);
00495       #endif // GENERATING_DOXYGEN_OUTPUT
00496    };
00497 
00498 //! Individual item in line legend.
00499 class GRE_LEGEND_LINE::ITEM : public GRE_LEGEND::ITEMBASE {
00500    public:
00501 
00502       //! Constructor.
00503       ITEM (
00504          const LINESTYLE& style,
00505          const MISTRING& label
00506          );
00507 
00508       //! Constructor using element number and label.
00509       ITEM (
00510          const RVC::ELEMENT& element,     //!< Element
00511          const MISTRING& label            //!< Label
00512          );
00513 
00514       //! Destructor.
00515       virtual ~ITEM (
00516          );
00517 
00518       //! Draw item.
00519       virtual void Draw (
00520          const DRAWCONTEXT& dc,           //!< Legend drawing context
00521          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00522          ) const;
00523 
00524    #ifdef WIN32_MFC
00525       //! Draw item with label in TreeView (WIN32_MFC).
00526       virtual void DrawTreeView (
00527          void *hdc,                       //!< Windows device context
00528          const GRE_ELEMSAMPLE_DC& dc,     //!< Legend drawing context
00529          const CRect& rect,               //!< Bounding rectangle including label
00530          bool HasFocus                    //!< 'true' if item has "focus"
00531          );
00532    #endif
00533 
00534       //! Get style for item.
00535       const LINESTYLE& GetStyle (
00536          ) const { return (m_style); };
00537 
00538       //! Determine if this item has same style.
00539       bool HasSameStyle (
00540          const LINESTYLE& style           //!< Style to compare
00541          ) const;
00542 
00543       //! Determine if item requires transparency support.
00544       virtual bool HasTransparency (
00545          ) const;
00546 
00547    private:
00548       #ifndef GENERATING_DOXYGEN_OUTPUT
00549       LINESTYLE m_style;
00550       ITEM (const ITEM&);
00551       ITEM& operator= (const ITEM&);
00552       #endif // GENERATING_DOXYGEN_OUTPUT
00553    };
00554 
00555 //===================================================================================================================
00556 
00557 //! Polygon/Area Feature legend subclass.
00558 class GRE_LEGEND_POLY : public GRE_LEGEND {
00559    public:
00560 
00561       class ITEM;
00562 
00563       //! Construct legend for layer and element type.
00564       GRE_LEGEND_POLY (
00565          GRE_LAYER *layer,                      //!< Layer legend is for
00566          ELEMTYPE ElemType                      //!< Element type
00567          );
00568 
00569    #if defined(X_NATIVE) || defined(WIN32_MFC)
00570       //! Add element to legend 'element table' with prompt for label(s).
00571       virtual ERRVALUE AddElemPrompted (
00572          MDLGPARENT dlgparent,                  //!< Parent for dialog
00573          const RVC::ELEMENT& element            //!< Element to add
00574          );
00575    #endif
00576 
00577       //! Add item to legend.
00578       void AddItem (
00579          const POLYSTYLE& style,
00580          const MISTRING& label,                 //!< Label to place to right of sample
00581          const MISTRING& intlabel               //!< Label to place INSIDE sample (blank for none)
00582          );                                        
00583 
00584       //! Add item to legend.
00585       void AddItem (
00586          const RVC::ELEMENT& element,           //!< Element to add
00587          const MISTRING& label,                 //!< Label to place to right of sample
00588          const MISTRING& intlabel               //!< Label to place INSIDE sample (blank for none)
00589          );                               
00590 
00591       ERRVALUE Setup (
00592          const POLYPARMS& parm,
00593          const RVC::OBJITEM& GeoObjItem,
00594          const RVC::OBJITEM& StyleObjItem
00595          );
00596 
00597    private:
00598       #ifndef GENERATING_DOXYGEN_OUTPUT
00599       GRE_LEGEND_POLY (const GRE_LEGEND_POLY&);
00600       GRE_LEGEND_POLY& operator= (const GRE_LEGEND_POLY&);
00601       #endif // GENERATING_DOXYGEN_OUTPUT
00602    };
00603 
00604 //! Individual item in polygon legend.
00605 class GRE_LEGEND_POLY::ITEM : public GRE_LEGEND::ITEMBASE {
00606    public:
00607 
00608       //! Constructor.
00609       ITEM (
00610          const POLYSTYLE& style,          //!< Item style
00611          const MISTRING& label,           //!< Label to place to right of sample
00612          const MISTRING& intlabel         //!< Label to place INSIDE sample (blank string for none)
00613          );
00614 
00615       //! Constructor using element number and label.
00616       ITEM (
00617          const RVC::ELEMENT& element,     //!< Element
00618          const MISTRING& label,           //!< Label to place to right of sample
00619          const MISTRING& intlabel         //!< Label to place INSIDE sample (blank string for none)
00620          );
00621 
00622       //! Destructor.
00623       virtual ~ITEM (
00624          );
00625 
00626       //! Draw item.
00627       virtual void Draw (
00628          const DRAWCONTEXT& dc,           //!< Legend drawing context
00629          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00630          ) const;
00631 
00632    #ifdef WIN32_MFC
00633       //! Draw item with label in TreeView (WIN32_MFC).
00634       virtual void DrawTreeView (
00635          void *hdc,                       //!< Windows device context
00636          const GRE_ELEMSAMPLE_DC& dc,     //!< Legend drawing context
00637          const CRect& rect,               //!< Bounding rectangle including label
00638          bool HasFocus                    //!< 'true' if item has "focus"
00639          );
00640    #endif
00641 
00642       //! Get style for item.
00643       const POLYSTYLE& GetStyle (
00644          ) const { return (m_style); }
00645 
00646       //! Determine if this item has same style.
00647       bool HasSameStyle (
00648          const POLYSTYLE& style           //!< Style to compare
00649          ) const;
00650 
00651       //! Determine if item requires transparency support.
00652       virtual bool HasTransparency (
00653          ) const;
00654 
00655    private:
00656       #ifndef GENERATING_DOXYGEN_OUTPUT
00657       POLYSTYLE m_style;
00658       MISTRING m_intlabel;    //!< Label to place INSIDE sample
00659 
00660       //! Draw the Interior label (m_intlabel) label
00661       void DrawInteriorLabel (
00662          const DRAWCONTEXT& cd,           //!< Legend drawing context
00663          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00664          ) const;
00665 
00666       ITEM (const ITEM&);
00667       ITEM& operator= (const ITEM&);
00668       #endif // GENERATING_DOXYGEN_OUTPUT
00669    };
00670 
00671 //===================================================================================================================
00672 
00673 //! Color-Sample legend subclass.
00674 class GRE_LEGEND_COLORSAMPLE : public GRE_LEGEND {
00675    public:
00676 
00677       class ITEM;
00678 
00679       //! Construct legend for layer and element type.
00680       GRE_LEGEND_COLORSAMPLE (
00681          GRE_LAYER *layer                    //!< Layer legend is for
00682          );
00683 
00684       //! Add item to legend.
00685       void AddItem (
00686          const COLOR& color,
00687          const MISTRING& label
00688          );                               
00689 
00690    private:
00691       #ifndef GENERATING_DOXYGEN_OUTPUT
00692       GRE_LEGEND_COLORSAMPLE (const GRE_LEGEND_COLORSAMPLE&);
00693       GRE_LEGEND_COLORSAMPLE& operator= (const GRE_LEGEND_COLORSAMPLE&);
00694       #endif // GENERATING_DOXYGEN_OUTPUT
00695    };
00696 
00697 class GRE_LEGEND_COLORSAMPLE::ITEM : public GRE_LEGEND::ITEMBASE {
00698    public:
00699 
00700       //! Constructor.
00701       ITEM (
00702          const COLOR& color,
00703          const MISTRING& label
00704          );
00705 
00706       //! Destructor.
00707       virtual ~ITEM (
00708          );
00709 
00710       //! Draw item.
00711       virtual void Draw (
00712          const DRAWCONTEXT& dc,           //!< Legend drawing context
00713          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including label
00714          ) const;
00715 
00716    #ifdef WIN32_MFC
00717       //! Draw item with label in TreeView (WIN32_MFC).
00718       virtual void DrawTreeView (
00719          void *hdc,                       //!< Windows device context
00720          const GRE_ELEMSAMPLE_DC& dc,     //!< Legend drawing context
00721          const CRect& rect,               //!< Bounding rectangle including label
00722          bool HasFocus                    //!< 'true' if item has "focus"
00723          );
00724    #endif
00725 
00726       //! Get color associated with item.
00727       const COLOR& GetColor (
00728          ) const { return (m_color); }
00729 
00730       //! Determine if this item has same style.
00731       bool HasSameStyle (
00732          const COLOR& color
00733          ) const;
00734 
00735    private:
00736       #ifndef GENERATING_DOXYGEN_OUTPUT
00737       COLOR m_color;
00738       ITEM (const ITEM&);
00739       ITEM& operator= (const ITEM&);
00740       #endif // GENERATING_DOXYGEN_OUTPUT
00741    };
00742 
00743 //===================================================================================================================
00744 
00745 //! Color-Scale legend subclass.
00746 class GRE_LEGEND_COLORSCALE : public GRE_LEGEND {
00747    public:
00748 
00749       class ITEM;
00750 
00751       //! Construct legend for layer.
00752       GRE_LEGEND_COLORSCALE (
00753          GRE_LAYER *layer                    //!< Layer legend is for
00754          );
00755 
00756       //! Get "preferred" item size in pixels.
00757       virtual void GetItemSizePixels (
00758          LPOINT2D& size                      //!< Size in pixels returned, not including labels
00759          ) const;
00760 
00761       //! Set legend values.
00762       //! This will create or update the single legend "item".
00763       void SetValues (
00764          const SIMPLE_ARRAY<COLOR>& palette,
00765          const CBPARMS& ColorBalance,           //!< For adjusting color
00766          double MinValue,
00767          double MaxValue,
00768          bool VerticalMinAtTop
00769          );
00770 
00771    private:
00772       #ifndef GENERATING_DOXYGEN_OUTPUT
00773       GRE_LEGEND_COLORSCALE (const GRE_LEGEND_COLORSCALE&);
00774       GRE_LEGEND_COLORSCALE& operator= (const GRE_LEGEND_COLORSCALE&);
00775       #endif // GENERATING_DOXYGEN_OUTPUT
00776    };
00777 
00778 class GRE_LEGEND_COLORSCALE::ITEM : public GRE_LEGEND::ITEMBASE {
00779    public:
00780 
00781       //! Constructor.
00782       ITEM (
00783          GRE_LEGEND_COLORSCALE& legend,   //!< Legend containing item
00784          const SIMPLE_ARRAY<COLOR>& palette,
00785          const CBPARMS& ColorBalance,     //!< For adjusting color
00786          double MinValue,
00787          double MaxValue,
00788          bool VerticalMinAtTop
00789          );
00790 
00791       //! Destructor.
00792       virtual ~ITEM (
00793          );
00794 
00795       //! Draw item.
00796       virtual void Draw (
00797          const DRAWCONTEXT& dc,           //!< Legend drawing context
00798          const LRECT2D& samplerect        //!< Rectangle for sample symbol, not including labels
00799          ) const;
00800 
00801    #ifdef WIN32_MFC
00802       //! Draw item with label in TreeView (WIN32_MFC).
00803       virtual void DrawTreeView (
00804          void *hdc,                       //!< Windows device context
00805          const GRE_ELEMSAMPLE_DC& dc,     //!< Legend drawing context
00806          const CRect& rect,               //!< Bounding rectangle including label
00807          bool HasFocus                    //!< 'true' if item has "focus"
00808          );
00809    #endif
00810 
00811       //! Convert "value" to position in legend coordinates.
00812       //! This accounts for whether minimum is at bottom/left or top/right.
00813       INT32 ValueToPosition (
00814          const GRE_LAYER_RASTER *layer,   //!< Raster layer
00815          double value,                    //!< Value to obtain position for
00816          INT32 size                       //!< Size of legend in pixels
00817          ) const;
00818 
00819    private:
00820       #ifndef GENERATING_DOXYGEN_OUTPUT
00821       GRE_LEGEND_COLORSCALE& m_legend;
00822       SIMPLE_ARRAY<COLOR> m_palette;
00823       double m_MinValue;
00824       double m_MaxValue;
00825       bool m_MinAtTop;
00826 
00827       ITEM (const ITEM&);
00828       ITEM& operator= (const ITEM&);
00829 
00830       friend class GRE_LEGEND_COLORSCALE;
00831       #endif // GENERATING_DOXYGEN_OUTPUT
00832    };
00833 
00834 //===================================================================================================================
00835 
00836 #endif   // INC_GRE_LEGEND_H

Generated on Tue Dec 14 13:18:13 2004 for TNTsdk by  doxygen 1.3.8-20040913