lrlegnd2.h

Go to the documentation of this file.
00001 /**
00002  * \file lrlegnd2.h <gre/lrlegnd2.h>
00003  * \brief GRE_LAYER_LEGEND2 class definitions
00004  *
00005  * \if NODOC
00006  * $Id: lrlegnd2.h_v 1.8 2005/03/31 16:57:06 fileserver!dwilliss Exp $
00007  *
00008  * $Log: lrlegnd2.h_v $
00009  * Revision 1.8  2005/03/31 16:57:06  fileserver!dwilliss
00010  * Rename one of our types to MIUNICODE because it conflicted with a Microsoft #define
00011  *
00012  * Revision 1.7  2005/02/28 18:26:00  scowan
00013  * Support layer copy virtual method.
00014  *
00015  * Revision 1.6  2005/02/14 21:39:44  mju
00016  * Use device in usesTransparency.
00017  *
00018  * Revision 1.5  2005/01/20 16:56:45  mju
00019  * Redesign layer type registration.
00020  *
00021  * Revision 1.4  2004/03/05 18:53:49  mju
00022  * Use virtual dtor if virtual fns.
00023  *
00024  * Revision 1.3  2003/09/15 13:48:59  fileserver!dwilliss
00025  * Doxygen
00026  *
00027  * Revision 1.2  2003/07/30 15:23:21  mju
00028  * Ignore private sections.
00029  *
00030  * Revision 1.1  2002/09/20 17:37:36  mju
00031  * Initial revision
00032  *
00033  * \endif
00034 **/
00035 
00036 #ifndef  INC_GRE_LRLEGND2_H
00037 #define  INC_GRE_LRLEGND2_H
00038 
00039 #ifndef  INC_MI32_GRE_H
00040 #include <mi32/gre.h>
00041 #endif
00042 
00043 //===================================================================================================================
00044 
00045 class GRE_LAYER_LEGEND2 : public GRE_LAYER {
00046    public:
00047 
00048       //! Class used internally to keep track of which layers the legend refers to
00049       class LAYERREF  {
00050          public:
00051             MIUNICODE *m_name;   //!< Can't use MISTRING.  We MmAllocC() an array of LAYRREFs.
00052             //! Our DISPPARM's destructor worrys about freeing stuff.
00053             GRE_LAYER* m_layer;
00054             ELEMTYPE m_ElemType;
00055             UINT32 m_ID;
00056 
00057             LAYERREF (
00058                ) :
00059                m_name(0),
00060                m_layer(0),
00061                m_ID(0),
00062                m_ElemType(ELEMTYPE_Empty)
00063                {
00064                }
00065 
00066             LAYERREF (
00067                GRE_LAYER* lyr,
00068                ELEMTYPE et
00069                );
00070 
00071             LAYERREF(const LAYERREF& rhs) :
00072                m_ID(rhs.m_ID),
00073                m_layer(rhs.m_layer),
00074                m_ElemType(rhs.m_ElemType) 
00075                {
00076                   m_name = rhs.m_name ? ucstrdup(rhs.m_name) : 0;
00077                }
00078 
00079             ~LAYERREF() {
00080                MmFree(m_name);
00081                }
00082 
00083             LAYERREF& operator= (const LAYERREF& rhs) {
00084                if (this != &rhs) {
00085                   m_name = rhs.m_name ? ucstrdup(rhs.m_name) : 0;
00086                   m_ID = rhs.m_ID;
00087                   m_layer = rhs.m_layer;
00088                   m_ElemType = rhs.m_ElemType;
00089                   }
00090                return (*this);
00091                }
00092 
00093             //! Also sets m_name
00094             void SetLayer (
00095                GRE_LAYER* layer
00096                );
00097 
00098          };
00099          
00100       // GRE_LAYER_LEGEND2::DISPPARM
00101       class DISPPARM : public GRE_LAYER::DISPPARM {
00102          public:
00103 
00104             class DLG;
00105 
00106          /*=================This stuff must be saved/loaded by mdlegend.c=============*/
00107             GRAPHICLAYOUT m_grlayout;
00108             UINT32 m_NumLayers;
00109             LAYERREF* m_layers;
00110 
00111          /*=================This stuff is just internal=========================*/
00112 
00113             DISPPARM ();
00114             DISPPARM (const DISPPARM& rhs) {
00115                Copy(rhs);
00116                }
00117             virtual ~DISPPARM () {
00118                Free();
00119                }
00120 
00121             DISPPARM& operator= (const DISPPARM& rhs) {
00122                if (this != &rhs) {
00123                   Free();
00124                   Copy(rhs);
00125                   }
00126                return (*this);
00127                }
00128 
00129             static void GRECB_LayerCallback (
00130                const GRE_CALLBACK_MSG* msg,
00131                void* cbdata
00132                );
00133 
00134             static int SerializerCB_GRLayout (
00135                SERIALIZER& serializer,
00136                const SERIALIZER::ITEMDEF *itemdef,
00137                void* cbdata,
00138                SERIALIZER::ITEMDEF::ACTION action
00139                );
00140 
00141 
00142             //! Returns index into m_layers array for given layer/elemtype
00143             //! Return -1 if not found, < -1 if error.
00144             INT32 GetLayerRefNum (
00145                GRE_LAYER* layer,
00146                ELEMTYPE ElemType,
00147                bool bAllocIfNotFound = false
00148                );
00149 
00150             void OnLayerChange (
00151                INT32 LayerRefNum,
00152                bool deleting
00153                );
00154 
00155             void OnLayoutLoaded (
00156                GRE_VIEWABLE* viewable
00157                );
00158 
00159          protected:
00160             virtual const SERIALIZER::ITEMDEF* SerialGetItemDef (SERIALIZER& serializer) const;
00161 
00162          private:
00163             #ifndef GENERATING_DOXYGEN_OUTPUT
00164             GRE_LAYER_LEGEND2* m_layer;      //!< Need it in a callback that only gets the DISPPARM
00165             void Copy (const DISPPARM&);
00166             void Free ();
00167             friend class GRE_LAYER_LEGEND2;
00168             #endif //!< GENERATING_DOXYGEN_OUTPUT
00169          };
00170 
00171       //! Callback for the "Add Legend" menu of GRE_LAYER_LEGEND.
00172    #ifndef WIN32_NATIVE
00173       static void CB_NewLegend2 (
00174          Widget w,
00175          void *vsubtype,
00176          void *
00177          );
00178    #endif
00179 
00180       //! Register this layer type
00181       static void RegisterType (
00182          );
00183 
00184       //! Construct layer and insert into list
00185       explicit GRE_LAYER_LEGEND2 (
00186          GRE_GROUP *group,                            //!< Group to contain layer
00187          CREATEFLAGS createflags = CREATEFLAG_None,   //!< Creation flags
00188          GRE::LISTPOS listpos = GRE::LISTPOS_Last,    //!< Position in list
00189          GRE_LAYER *reflayer = 0                      //!< Reference layer for insertion
00190          );
00191 
00192       virtual ~GRE_LAYER_LEGEND2 ();
00193 
00194       //! Retrieve layer-specific display parameters.
00195       const DISPPARM& GetDispParm (
00196          ) const { return (m_dispparm); }
00197 
00198       //! Return scale factor between legend's layout units and output "ground meters"
00199       double GetScaleFactor (
00200          ) const;
00201 
00202       //! Set layer-specific display parameters.
00203       //! This is the recommended method for changing how an existing layer is to be
00204       //! rendered.  Validation will be performed on the specified parameters and
00205       //! adjustments made to the layer's copy if necessary.  Use of this method
00206       //! usually result in a ChangeBegin / ChangeEnd message pair, and will also
00207       //! generate a ChangeObject message if the spatial object used in the layer
00208       //! is changed.
00209       ERRVALUE SetDispParm (
00210          const DISPPARM& dispparm               //!< Parameters to set
00211          );
00212 
00213       void SetLayout (
00214          const GRAPHICLAYOUT& grlayout
00215          );
00216 
00217    #if defined(X_NATIVE) && !defined(GENERATING_DOXYGEN_OUTPUT)
00218       static void CB_CreateDialog (Widget, void*, void*);
00219    #endif
00220 
00221    protected:
00222 
00223       DISPPARM m_dispparm;                      //!< Layer-specific display parameters
00224 
00225    private:
00226       #ifndef GENERATING_DOXYGEN_OUTPUT
00227 
00228       static void GRECB_LayoutLoaded (const GRE_CALLBACK_MSG* msg, void* cbdata);
00229 
00230       //! Overrides from GRE_LAYER.
00231    #if defined(X_NATIVE) || defined(WIN32_MFC)
00232       virtual int v_ControlPanel (MDLGPARENT dlgparent,UINT32 flags = 0);
00233    #endif
00234       virtual GRE_LAYER* v_Copy (GRE_GROUP *group) const;
00235       virtual ERRVALUE v_Draw (GRE_LAYERDC& layerdc);
00236       virtual const char* v_SerialGetTagName () const;
00237       virtual void v_SetDftName (bool ReplaceExisting);
00238       virtual ERRVALUE v_TemplateRead (SERIALIZER& serializer);
00239       virtual int v_UpdateExtents (bool forceupdate);
00240       virtual bool v_UsesTransparency (const MGD::DEVICE *pDevice = 0) const;
00241 
00242       friend class GRE_LAYER_LEGEND2::DISPPARM; //!< Need access to private static GRECB_LayoutLoaded()
00243 
00244       #endif //!< GENERATING_DOXYGEN_OUTPUT
00245    };
00246 
00247 //===================================================================================================================
00248 
00249 
00250 #endif   //!< INC_GRE_LRLEGND2_H

Generated on Wed May 31 15:26:40 2006 for TNTsdk by  doxygen 1.3.8-20040913