layout.h

Go to the documentation of this file.
00001 /**
00002  * \file gre/layout.h
00003  * \brief GRE::LAYOUT definitions
00004  *
00005  * \if NODOC
00006  * $Id: layout.h_v 1.16 2004/06/28 17:53:24 mju Exp $
00007  *
00008  * $Log: layout.h_v $
00009  * Revision 1.16  2004/06/28 17:53:24  mju
00010  * Convert to spatref system.
00011  *
00012  * Revision 1.15  2004/03/26 16:47:19  mju
00013  * Add optional parm for addGroupLayer to return pointer to layer.
00014  *
00015  * Revision 1.14  2004/03/26 15:25:31  mju
00016  * Add addGroupLayer variant with no control dialog.
00017  *
00018  * Revision 1.13  2004/03/05 22:36:58  mju
00019  * Make activegroup, prevlayout, nextlayout private.
00020  *
00021  * Revision 1.12  2004/03/05 21:49:35  mju
00022  * Add getNext().
00023  *
00024  * Revision 1.11  2004/02/06 16:01:41  mju
00025  * Use GRE_FIND_FLAGS.
00026  *
00027  * Revision 1.10  2003/11/12 22:41:52  mju
00028  * Use serializer to log errors instead of group.
00029  *
00030  * Revision 1.9  2003/11/10 18:43:48  mju
00031  * REmove savefilename/inode as need in base.
00032  *
00033  * Revision 1.8  2003/11/04 18:43:28  mju
00034  * Add DlgObjMgr overrides.
00035  *
00036  * Revision 1.7  2003/10/10 13:04:02  mju
00037  * *** empty log message ***
00038  *
00039  * Revision 1.6  2003/10/01 22:21:04  dwilliss
00040  * doxygen
00041  *
00042  * Revision 1.5  2003/09/15 15:48:00  dwilliss
00043  * No!  I wanted to check out mgui\layout.h
00044  *
00045  * Revision 1.4  2003/09/15 13:48:59  fileserver!dwilliss
00046  * Doxygen
00047  *
00048  * Revision 1.3  2003/08/29 20:14:18  mju
00049  * Add v_GetExtents.
00050  *
00051  * Revision 1.2  2003/07/30 15:20:34  mju
00052  * Ignore private section.
00053  *
00054  * Revision 1.1  2003/06/16 19:39:47  mju
00055  * Initial revision
00056  * \endif
00057 **/
00058 
00059 #ifndef  INC_GRE_LAYOUT_H
00060 #define  INC_GRE_LAYOUT_H
00061 
00062 #ifndef  INC_GRE_VIEWABLE_H
00063    #include <gre/viewable.h>
00064 #endif
00065 
00066 #ifndef  INC_GRE_LAYER_H
00067    #include <gre/layer.h>
00068 #endif
00069 
00070 #ifndef INC_MI32_MPLAYOUT_H
00071    #include <mi32/mplayout.h>
00072 #endif
00073 
00074 #ifndef  INC_MI32_MATTE_H
00075    #include <mi32/matte.h>
00076 #endif
00077 
00078 
00079 #define  POSNMODE_Tiled          0
00080 #define  POSNMODE_Overlapped     1
00081 #define  POSNMODE_MapLayout      2
00082 
00083 //===================================================================================================================
00084 
00085 class GRE_LAYOUT : public GRE_VIEWABLE, public SERIALIZABLE {
00086 
00087    public:
00088 
00089       //! Flags used in creation
00090       enum CREATEFLAGS {
00091          CREATEFLAG_None =       0x00,
00092          CREATEFLAG_Hardcopy =   0x10     //!< Create layout in "hardcopy" mode
00093          };
00094 
00095       GRE_GROUP* firstgroup;              //!< First group in layout
00096       GRE_GROUP* lastgroup;               //!< Last group in layout
00097       UINT8 PosnMode;                     //!< Positioning mode, POSNMODE_...
00098       UINT8 ElemSelectMode;               //!< Element selection mode
00099       LAYOUTPARMS HardcopyLayout;         //!< Used in map/poster layout mode
00100       double PosnScale;                   //!< Scale used for attachment offsets in group positioning (eg. 24000)
00101       DRECT2D FullExtents;                //!< Extents of entire layout in layout coordinates
00102 
00103       //! Get first layout in GRE system.
00104       static GRE_LAYOUT* GetFirst (
00105          ) { return (s_FirstLayout); }
00106 
00107    #ifdef X_NATIVE
00108       //! Get layout from object attached to Widget userData
00109       static GRE_LAYOUT* GetFromWidget (
00110          Widget w
00111          );
00112    #endif
00113 
00114       //! Install SML class, called by internal SML function.
00115       static void SMLClassInstall (
00116          SMLCONTEXT *context                    //!< SML context
00117          );
00118 
00119       //! Constructor.
00120       explicit GRE_LAYOUT (
00121          CREATEFLAGS flags = CREATEFLAG_None
00122          );
00123 
00124       //! Destructor.
00125       virtual ~GRE_LAYOUT ();
00126 
00127       //! Dialog to add single-layer group and layer of specified type.
00128       //! Should only be used for single-layer-group types (eg scalebar, text, legend).
00129       ERRVALUE AddGroupLayer (
00130          MDLGPARENT dlgparent,
00131          GRE_LAYER::TYPE layertype
00132          );
00133 
00134       //! Add single-layer group and layer of specified type.
00135       //! Should only be used for single-layer-group types (eg scalebar, text, legend).
00136       ERRVALUE AddGroupLayer (
00137          GRE_LAYER::TYPE layertype,             //! Type of layer to create
00138          GRE_LAYER **player = 0                 //! Pointer to layer returned
00139          );
00140 
00141       //! Dialog to prompt user for objects and add as multiple groups.
00142       ERRVALUE AddGroupMulti (
00143          MDLGPARENT dlgparent
00144          );
00145 
00146       //! Dialog to prompt user for saved group and add to layout.
00147       int AddGroupSaved (
00148          MDLGPARENT dlgparent,
00149          bool fromtext
00150          );
00151 
00152       //! Create new group in this layout
00153       ERRVALUE CreateGroup (
00154          GRE_GROUP **retgroup,                  //!< New group returned
00155          UINT32 flags = 0,
00156          GRE_GROUP *refgroup = 0                //!< Reference group for InsertBefore/InsertAfter
00157          );
00158 
00159       //! Destroy all groups in this layout
00160       //! This method must not be used if any groups exist which have been created on the stack.
00161       void DestroyAllGroups (
00162          );
00163 
00164       //! Draw all views of this layout
00165       virtual ERRVALUE DrawAllViews (
00166          UINT32 drawflags = 0
00167          );
00168 
00169       //! Find layer using unique ID.
00170       virtual GRE_LAYER *FindLayerByID (
00171          UINT32 LayerID
00172          ) const;
00173 
00174       //! Find group containing specified point
00175       GRE_GROUP* FindPointGroup (
00176          const DPOINT2D& point,
00177          GRE_FIND_FLAGS findflags,
00178          const SPATREF::COORDREFSYS *pPointCRS = NULL
00179          ) const;
00180 
00181       //! Get active group for this layout
00182       GRE_GROUP* GetActiveGroup (
00183          ) const { return (m_ActiveGroup); }
00184 
00185       //! Get first group in layout.
00186       GRE_GROUP* GetFirstGroup (
00187          ) const { return (firstgroup); }
00188 
00189       //! Get full layout name
00190       virtual void GetFullName (
00191          MISTRING& name                         //!< Name returned
00192          ) const;
00193 
00194       //! Get "margin" rectangle in layout (page) coordinates
00195       DRECT2D GetHardcopyMarginRect (
00196          ) const {
00197          DRECT2D MarginRect;
00198          MarginRect.xinit = HardcopyLayout.LeftMargin;
00199          MarginRect.xlast = MarginRect.xinit + HardcopyLayout.FullPrintableWidth;
00200          MarginRect.ylast = HardcopyLayout.FullHeight - HardcopyLayout.TopMargin;
00201          MarginRect.yinit = MarginRect.ylast - HardcopyLayout.FullPrintableHeight;
00202          return (MarginRect);
00203          }
00204 
00205       //! Get "page" rectangle in layout (page) coordinates
00206       DRECT2D GetHardcopyPageRect (
00207          ) const {
00208          DRECT2D PageRect;
00209          PageRect.xinit = PageRect.yinit = 0.0;
00210          PageRect.xlast = HardcopyLayout.FullWidth;
00211          PageRect.ylast = HardcopyLayout.FullHeight;
00212          return (PageRect);
00213          }
00214 
00215       //! Get "printable" rectangle in layout (page) coordinates
00216       DRECT2D GetHardcopyPrintableRect (
00217          ) const {
00218          DRECT2D PrintableRect;
00219          PrintableRect.xinit = PrintableRect.yinit = 0.0;
00220          PrintableRect.xlast = HardcopyLayout.FullPrintableWidth;
00221          PrintableRect.ylast = HardcopyLayout.FullPrintableHeight;
00222          return (PrintableRect);
00223          }
00224 
00225       //! Get hardcopy layout scale.
00226       double GetHardcopyScale (
00227          ) const { return (HardcopyLayout.Scale); }
00228 
00229       //! Get hardcopy zoom factor.
00230       double GetHardcopyZoom (
00231          ) const { return (HardcopyLayout.Zoom); }
00232 
00233       //! Get last group in layout.
00234       GRE_GROUP* GetLastGroup (
00235          ) const { return (lastgroup); }
00236 
00237       //! Get matte reference for layout.
00238       MATTE& GetMatte (
00239          ) { return (m_Matte); }
00240 
00241       //! Get next layout.
00242       GRE_LAYOUT* GetNext (
00243          ) const { return (m_NextLayout); }
00244 
00245       //! Get next available unique ID.
00246       virtual UINT32 GetNextLayerID (
00247          ) const;
00248 
00249       //! Get group positioning mode.
00250       UINT8 GetPosnMode (
00251          ) const { return (PosnMode); }
00252 
00253       //! Compute dimensions of object based on scale and georeference
00254       virtual ERRVALUE GetSizeMeters (
00255          DPOINT2D& sizemeters                   //!< Size returned in meters
00256          );
00257 
00258       //! Return true if Auto-Redraw toggle is set on the Group Controls dialog.
00259       bool GroupControlsGetAutoRedraw (
00260          ) const;
00261 
00262       //! Return the units for measurements in the Layout tab of the Group Controls dialog.
00263       int GroupControlsGetLayoutUnits (
00264          ) const;
00265 
00266       //! Determine if the Group Controls dialog is open.
00267       bool GroupControlsIsOpen (
00268          ) const;
00269 
00270       //! Open the Group Controls dialog.
00271       //! If already open, it is brought to the front.
00272       //! If group passed in is NULL (default) use the Active group.
00273       void GroupControlsOpen (
00274          MDLGPARENT dlgparent = 0,     //!< Parent (0 to use default)
00275          GRE_GROUP* group = 0,         //!< Group to show initially,
00276          UINT32 flags = 0              //!<  MDISP_GCP_Xxxx
00277          );
00278 
00279       //! Set the values of the size, spacing and relative zoom prompts in the Group Controls dialog.
00280       //!
00281       //! This is used to temporarly change the values being reported in
00282       //! several of the prompts while a group is being moved or resized by
00283       //! an external tool.  It is assumed that when the user releases the mouse,
00284       //! the tool will actually modify the group and the prompts will be
00285       //! restored to new "real" values.
00286       //!
00287       //! This function should only be called by GRE_TOOL_PLACEMENT
00288       void GroupControlsSetPrompts (
00289          double hoffset,      //!< value for "Spacing" (horizontal)
00290          double hsize,        //!< value for "Width"
00291          double voffset,      //!< value for "Spacing" (vertical)
00292          double vsize,        //!< value for "Height"
00293          double relscale      //!< value for "Relative Zoom"
00294          );
00295       
00296       //! Set the group controls dialog (if open) to the "layout" tab
00297       void GroupControlsSetTabLayout (
00298          );
00299 
00300       //! Determine if layout has any layers
00301       virtual bool HasLayers (
00302          ) const;
00303 
00304       //! Determine if layout has any "temporary" layers.
00305       bool HasTempLayers (
00306          ) const;
00307 
00308       //! Determine if layout is currently being loaded.
00309       bool IsBeingLoaded (
00310          ) const { return (m_pSerializer != 0); }
00311 
00312       //! Determine if layout is in "hardcopy" mode.
00313       bool IsHardcopy (
00314          ) const { return (PosnMode == POSNMODE_MapLayout); }
00315 
00316       //! Determine if layout is an existing GRE object.
00317       bool IsValid (
00318          ) const;
00319 
00320       //! Determine if layout should be kept in TNTserver cache.
00321       bool KeepInTNTserverCache (
00322          ) const { return (m_KeepInTNTserverCache); }
00323 
00324       //! Read from serialization
00325       virtual ERRVALUE SerialRead (
00326          SERIALIZER& serializer
00327          );
00328 
00329       //! Write values to serialization
00330       virtual ERRVALUE SerialWrite (
00331          SERIALIZER& serializer,
00332          const char *tagname = 0
00333          ) const;
00334 
00335       //! Set active group for layout.
00336       void SetActiveGroup (
00337          GRE_GROUP *group
00338          );
00339 
00340       //! Set whether layout should be retained in TNTserver cache.
00341       void SetKeepInTNTserverCache (
00342          bool keepInTNTserverCache
00343          ) {
00344          if (m_KeepInTNTserverCache != keepInTNTserverCache) m_IsModified = true;
00345          m_KeepInTNTserverCache = keepInTNTserverCache;
00346          }
00347 
00348       //! Set that layout has been modified.
00349       void SetModified (
00350          bool notify = true,                 //!< Set to invoke callbacks with "Changed" message
00351          bool ViewsNeedRedraw = true         //!< Set all views of layout as needing redraw
00352          );
00353 
00354       //! Set new layout name.
00355       int SetName (
00356          const UNICODE *newname
00357          );
00358 
00359       //! Set that group positions need to be recomputed.
00360       void SetNeedUpdatePositions (
00361          ) { m_NeedUpdatePositions = 1; }
00362 
00363       //! Set group positioning mode
00364       void SetPosnMode (
00365          UINT8 posnmode
00366          );
00367 
00368       //! Set hardcopy zoom to fit to page size.
00369       int SetZoomToFitPage (
00370          );
00371 
00372       //! Read from template (serialization)
00373       ERRVALUE TemplateRead (
00374          SERIALIZER& serializer
00375          );
00376 
00377       //! Write template to serialization
00378       ERRVALUE TemplateWrite (
00379          SERIALIZER& serializer
00380          );
00381 
00382       //! Recompute group positions.
00383       int UpdatePositions (
00384          bool ForceUpdate = true
00385          );
00386 
00387       //! Validate and correct group attachments.
00388       void ValidateGroupAttachments (
00389          );
00390 
00391    protected:
00392 
00393    #ifdef X_NATIVE
00394       //! Create initial set of items in object manager.
00395       virtual void ObjMgrInitItems (
00396          );
00397    #endif
00398 
00399    private:
00400       #ifndef GENERATING_DOXYGEN_OUTPUT
00401 
00402       static GRE_LAYOUT *s_FirstLayout;
00403       static GRE_LAYOUT *s_LastLayout;
00404 
00405       static const SERIALIZER::ITEMDEF* SerialGetItemDef (
00406          SERIALIZER& serializer
00407          );
00408 
00409       static const SERIALIZER::ITEMDEF* TemplateGetItemDef (
00410          );
00411 
00412       GRE_GROUP* m_ActiveGroup;           // Currently active group for layout
00413       GRE_LAYOUT *m_PrevLayout;           // Pointer to "previous" layout if multiple layouts are in use
00414       GRE_LAYOUT *m_NextLayout;           // Pointer to "next" layout if multiple layouts are in use
00415       bool m_NeedUpdatePositions;         // Need to update positions of layout children
00416       bool m_KeepInTNTserverCache;        // Keep layout in TNTserver cache
00417       SERIALIZER *m_pSerializer;          // Serializer used while loading
00418       INT32 m_tilecols;
00419       INT32 m_tilerows;
00420       UNICODE m_name[16];                 // Layout name
00421       mutable UNICODE m_activegroupname[GRE_GROUP_NAMELEN];    // Name of active group used when saving/loading layout
00422       MATTE m_Matte;
00423    #ifdef X_NATIVE
00424       MXDHANDLE m_pDlgObjMgr;
00425    #endif
00426 
00427    #ifdef X_NATIVE
00428       virtual void OnNotifyGreObjMgr (const GRE_CALLBACK_MSG& msg);
00429    #endif
00430 
00431       //! GRE_OBJECT overrides.
00432    #ifdef X_NATIVE
00433       virtual void v_DlgObjMgrClose ();
00434       virtual ERRVALUE v_DlgObjMgrCreate (MDLGPARENT dlgparent, const MISTRING& title);
00435       virtual void v_DlgObjMgrDestroy ();
00436       virtual bool v_DlgObjMgrIsOpen () const;
00437       virtual void v_DlgObjMgrOpen ();
00438    #endif
00439       virtual bool v_Destroy (bool NotifyParent);
00440       virtual MICON v_GetIcon () const;
00441       virtual const char* v_GetTypeName () const;
00442 
00443       //! GRE_VIEWABLE overrides.
00444       virtual double v_GetDesignScale () const;
00445       virtual const DRECT2D& v_GetExtents () const;
00446       virtual void v_SetDesignScale (double DesignScale, bool notify);
00447 
00448       GRE_LAYOUT (const GRE_LAYOUT&);
00449       GRE_LAYOUT& operator= (const GRE_LAYOUT&);
00450 
00451       #endif // GENERATING_DOXYGEN_OUTPUT
00452    }; //! End of GRE_LAYOUT
00453 
00454 DEFINE_ENUM_OPERATORS(GRE_LAYOUT::CREATEFLAGS);
00455 
00456 
00457 //===================================================================================================================
00458 
00459 #ifdef WIN32_MFC
00460 
00461 class GRE_MFC_LAYOUT : public GRE_MFC_VIEWABLE {
00462    protected: //! create from serialization only
00463       GRE_MFC_LAYOUT();
00464       DECLARE_DYNCREATE(GRE_MFC_LAYOUT)
00465 
00466    public:
00467 
00468       GRE_LAYOUT* GetLayout (
00469          ) const {
00470          return (m_layout);
00471          }
00472 
00473    public:
00474       virtual ~GRE_MFC_LAYOUT();
00475 
00476    protected:
00477       GRE_LAYOUT *m_layout;
00478 
00479    protected:
00480       //! Generated message map functions
00481       //!{{AFX_MSG(GRE_MFC_LAYOUT)
00482       //!}}AFX_MSG
00483       DECLARE_MESSAGE_MAP()
00484    };
00485 
00486 #endif
00487 
00488 //===================================================================================================================
00489 
00490 #endif   // INC_GRE_LAYOUT_H

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