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

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