gre/viewable.h

Go to the documentation of this file.
00001 /**
00002  * \file viewable.h <gre/viewable.h>
00003  * \brief GRE::VIEWABLE class definition
00004  *
00005  * \if NODOC
00006  * $Id: viewable.h_v 1.14 2003/11/10 18:43:55 mju Exp $
00007  *
00008  * $Log: viewable.h_v $
00009  * Revision 1.14  2003/11/10 18:43:55  mju
00010  * Add SaveObjItem and methods to manage.
00011  *
00012  * Revision 1.13  2003/11/04 18:43:19  mju
00013  * Add DlgObjMgr methods.
00014  *
00015  * Revision 1.12  2003/09/19 19:45:26  mju
00016  * Add pFallbackPixel to RenderToRaster.
00017  *
00018  * Revision 1.11  2003/09/15 13:48:59  fileserver!dwilliss
00019  * Doxygen
00020  *
00021  * Revision 1.10  2003/08/29 20:13:27  mju
00022  * Add rect ptr to RenderToRaster.
00023  * Add v_GetExtents.
00024  *
00025  * Revision 1.9  2003/08/26 21:02:17  dwilliss
00026  * Added static SMLClassInstall method
00027  *
00028  * Revision 1.8  2003/07/30 15:48:28  mju
00029  * Ignore private sections.
00030  *
00031  * Revision 1.7  2003/07/29 15:45:26  mju
00032  * Don't define scriptlist prototypes unless X.
00033  *
00034  * Revision 1.6  2003/07/29 15:34:58  mju
00035  * Add UpdateViewScriptUI and Clear...ScriptList.
00036  *
00037  * Revision 1.5  2003/06/24 16:25:01  mju
00038  * Support saving macro/toolscripts with viewable.
00039  *
00040  * Revision 1.4  2003/06/18 13:56:49  mju
00041  * Include stuff for MFC.
00042  *
00043  * Revision 1.3  2003/06/17 13:40:18  mju
00044  * Fix for MFC.
00045  *
00046  * Revision 1.2  2003/06/17 13:23:56  mju
00047  * Include simplear.h.
00048  *
00049  * Revision 1.1  2003/06/16 19:40:43  mju
00050  * Initial revision
00051  * \endif
00052 **/
00053 
00054 #ifndef  INC_GRE_VIEWABLE_H
00055 #define  INC_GRE_VIEWABLE_H
00056 
00057 #if !defined(INC_MI32_STDAFX_H) && defined(WIN32_MFC)
00058 #include <mi32/stdafx.h>
00059 #endif
00060 
00061 #ifndef  INC_GRE_OBJECTBASE_H
00062    #include <gre/objectbase.h>
00063 #endif
00064 
00065 #ifndef  INC_GRE_VIEWSCRIPT_H
00066    #include <gre/viewscript.h>
00067 #endif
00068 
00069 #ifndef INC_MI32_SERIALIZ_H
00070    #include <mi32/serializ.h>
00071 #endif
00072 
00073 #ifndef  INC_MI32_MISTRING_H
00074    #include <mi32/mistring.h>
00075 #endif
00076 
00077 #ifndef  INC_MI32_SIMPLEAR_H
00078    #include <mi32/simplear.h>
00079 #endif
00080 
00081 #ifndef  INC_MI32_MGD2_H
00082    #include <mi32/mgd2.h>
00083 #endif
00084 
00085 #if defined(X_NATIVE) && !defined(INC_MI32_XDEFNS_H)
00086    #include <mi32/xdefns.h>
00087 #endif
00088 
00089 //===================================================================================================================
00090 
00091 //! Base class for objects that can have "views" (GRE_LAYOUT, GRE_GROUP).
00092 class GRE_VIEWABLE : public GRE_OBJECT {
00093    public:
00094 
00095       //! Install SML class, called by internal SML function.
00096       static void SMLClassInstall (
00097          SMLCONTEXT* context
00098          );
00099 
00100       //! Constructor.
00101       explicit GRE_VIEWABLE (
00102          GRE_OBJTYPE type                    //!< Object type
00103          );
00104 
00105       //! Destructor.
00106       virtual ~GRE_VIEWABLE (
00107          );
00108 
00109    #ifdef X_NATIVE
00110       //! Clear MacroScript list.
00111       void ClearMacroScriptList (
00112          ) { m_MacroScripts.Clear(); }
00113    #endif
00114 
00115       //! Clear save location specification.
00116       void ClearSaveLocation (
00117          ) { m_SaveObjItem.Clear(); }
00118 
00119    #ifdef X_NATIVE
00120       //! Clear ToolScript list.
00121       void ClearToolScriptList (
00122          ) { m_ToolScripts.Clear(); }
00123    #endif
00124 
00125       //! Destroy all views of this object.
00126       void DestroyAllViews (
00127          );
00128 
00129    #ifdef X_NATIVE
00130       void DlgObjMgrClose (
00131          ) { v_DlgObjMgrClose(); }
00132 
00133       ERRVALUE DlgObjMgrCreate (
00134          MDLGPARENT dlgparent
00135          ) { return (v_DlgObjMgrCreate(dlgparent,MISTRING::GetEmpty())); }
00136 
00137       ERRVALUE DlgObjMgrCreate (
00138          MDLGPARENT dlgparent,
00139          const MISTRING& title
00140          ) { return (v_DlgObjMgrCreate(dlgparent,title)); }
00141 
00142       void DlgObjMgrDestroy (
00143          ) { v_DlgObjMgrDestroy(); }
00144 
00145       bool DlgObjMgrIsOpen (
00146          ) const { return (v_DlgObjMgrIsOpen()); }
00147 
00148       void DlgObjMgrOpen (
00149          ) { v_DlgObjMgrOpen(); }
00150    #endif
00151 
00152       //! Draw all views of this object.
00153       virtual ERRVALUE DrawAllViews (
00154          UINT32 drawflags = 0
00155          ) = 0;
00156 
00157       //! Get overall viewable extents.
00158       const DRECT2D& GetExtents (
00159          ) const { return (v_GetExtents()); }
00160 
00161       //! Find layer using unique ID.
00162       virtual GRE_LAYER *FindLayerByID (
00163          UINT32 LayerID
00164          ) const = 0;
00165 
00166       //! Get 'design scale' for layout or group.
00167       double GetDesignScale (
00168          ) const { return (v_GetDesignScale()); }
00169 
00170       //! Get parent for dialogs relating to this object.
00171       MDLGPARENT GetDialogParent (
00172          ) const { return (m_DialogParent); }
00173 
00174       //! Get first view of this object.
00175       //! @return Pointer to view or NULL if no views of this object.
00176       //!
00177       //! To loop through all views for an object use this method to get the first view.
00178       //! Then use the GRE_VIEW::GetNext() to obtain the next view, checking for NULL as shown:
00179       //!
00180       //!      for (GRE_VIEW *view = object->GetFirstView(); (view != 0); view = view->GetNext()) {
00181       //!         ...
00182       //!         }
00183       GRE_VIEW* GetFirstView (
00184          ) const;
00185 
00186       //! Get full object name.
00187       virtual void GetFullName (
00188          MISTRING& name                         //!< Name returned
00189          ) const = 0;
00190 
00191       //! Get name of object to use in Ini file access.
00192       const char* GetIniName (
00193          ) const { return (m_IniName); }
00194 
00195    #ifdef X_NATIVE
00196       //! Get MacroScript list.
00197       GRE::MACROSCRIPTLIST& GetMacroScriptList (
00198          ) { return (m_MacroScripts); }
00199    #endif
00200 
00201       //! Get next available unique ID.
00202       virtual UINT32 GetNextLayerID (
00203          ) const = 0;
00204 
00205       //! Get path to file where viewable saved.
00206       const FILEPATH& GetSaveFilePath (
00207          ) const { return (m_SaveObjItem.GetFilePath()); }
00208 
00209       //! Get object item reference to save location.
00210       const RVC::OBJITEM& GetSaveObjItem (
00211          ) const { return (m_SaveObjItem); }
00212 
00213       //! Get whether to show internal tables in table lists.
00214       bool GetShowInternalTables (
00215          ) const { return (m_ShowInternalTables); }
00216 
00217       //! Get whether to show scale ranges in layer lists.
00218       bool GetShowScaleRanges (
00219          ) const { return (m_ShowScaleRanges); }
00220 
00221       //! Compute dimensions of object based on scale and georeference.
00222       virtual ERRVALUE GetSizeMeters (
00223          DPOINT2D& sizemeters                   //!< Size returned in meters
00224          ) = 0;
00225 
00226    #ifdef X_NATIVE
00227       //! Get ToolScript list.
00228       GRE::TOOLSCRIPTLIST& GetToolScriptList (
00229          ) { return (m_ToolScripts); }
00230    #endif
00231 
00232       //! Get view of this object given view number.
00233       //! @return Pointer to view or NULL if no matching view.
00234       GRE_VIEW* GetView (
00235          int ViewNum
00236          ) const;
00237 
00238       //! Determine if object has any layers.
00239       virtual bool HasLayers (
00240          ) const = 0;
00241 
00242       //! Determine if save location has been specified.
00243       bool HasSaveLocation (
00244          ) const;
00245 
00246       //! Determine if changes have been made since last save.
00247       bool IsModified (
00248          ) const { return (m_IsModified); }
00249 
00250    #ifdef X_NATIVE
00251       //! Create "object manager" container (RowColumn) widget.
00252       //! @return Frame widget surrounding container.
00253       Widget ObjMgrCreate (
00254          Widget pwidget,
00255          Arg *arglist,
00256          int argcount
00257          );
00258    #endif
00259 
00260    #ifdef X_NATIVE
00261       //! Get RowColumn widget for creating items in object manager.
00262       Widget ObjMgrGetContainer (
00263          ) const { return (m_ObjMgrRC); }
00264    #endif
00265 
00266    #ifdef X_NATIVE
00267       //! Scroll to make specified widget visible in object manager.
00268       void ObjMgrMakeVisible (
00269          Widget widget
00270          );
00271    #endif
00272 
00273    #ifdef X_NATIVE
00274       //! Set position of item in object manager.
00275       //! @return Next position after item.
00276       short ObjMgrSetPosition (
00277          Widget widget,
00278          short newindex
00279          );
00280    #endif
00281 
00282       //! Render to raster.
00283       ERRVALUE RenderToRaster (
00284          RVC::OBJITEM& objitem,
00285          COLORSPACE colorspace,
00286          INT32 rastcols,
00287          INT32 rastlins,
00288          double cellsize,
00289          const COLOR& bgcolor,
00290          int viewnum = 1,
00291          bool savegeoref = true,
00292          const SIMPLE_ARRAY<COLOR>* pColors = 0,   //!< Colormap to use for COLORSPACE_Indexed
00293          const DRECT2D *pRect = 0,                 //!< Rectangle in viewable coordinates to limit extent
00294          MGD::PIXEL *pFallbackPixel = 0            //! Pointer to fallback pixel, NULL to use 'transparent'
00295          );
00296 
00297       //! Reset "is modified" status to "false".
00298       void ResetModified (
00299          ) { m_IsModified = false; }
00300 
00301       //! Set 'design scale' for layout or group.
00302       void SetDesignScale (
00303          double DesignScale,                    //!< Design scale to set
00304          bool notify = true                     //!< Send notification if changed
00305          ) { v_SetDesignScale(DesignScale,notify); }
00306 
00307       //! Set parent for dialogs relating to this object.
00308       void SetDialogParent (
00309          MDLGPARENT DialogParent
00310          ) { m_DialogParent = DialogParent; }
00311 
00312       //! Set base name of object for use in Ini file acces.
00313       void SetIniBase (
00314          const char* name
00315          );
00316 
00317    #ifdef X_NATIVE
00318       void SetMacroScriptList (
00319          const GRE::MACROSCRIPTLIST& ScriptList
00320          ) { m_MacroScripts = ScriptList; m_IsModified = true; }
00321    #endif
00322 
00323       //! Set path to file where viewable saved.
00324       //! Also resets object such that expects to save to non-RVC file.
00325       void SetSaveFilePath (
00326          const FILEPATH& SaveFilePath
00327          );
00328 
00329       //! Set object item reference to save location.
00330       void SetSaveObjItem (
00331          const RVC::OBJITEM& SaveObjItem
00332          ) { m_SaveObjItem = SaveObjItem; }
00333 
00334       //! Set object item reference to save location from FILEPATH and RVCGENINFO.
00335       void SetSaveObjItem (
00336          const FILEPATH& SaveFilePath,
00337          const RVCGENINFO& SaveObjInfo
00338          ) { m_SaveObjItem.SetItem(SaveFilePath,SaveObjInfo); }
00339 
00340       //! Set whether to show internal tables in table lists.
00341       void SetShowInternalTables (
00342          bool ShowInternalTables
00343          );
00344 
00345       //! Set whether to show scale ranges in layer lists.
00346       void SetShowScaleRanges (
00347          bool ShowScaleRanges
00348          );
00349 
00350    #ifdef X_NATIVE
00351       void SetToolScriptList (
00352          const GRE::TOOLSCRIPTLIST& ScriptList
00353          ) { m_ToolScripts = ScriptList; m_IsModified = true; }
00354    #endif
00355 
00356    #ifdef X_NATIVE
00357       //! Update user interface for changes to view scripts.
00358       void UpdateViewScriptUI (
00359          );
00360    #endif
00361 
00362    protected:
00363 
00364       bool m_IsModified;                  //!< Changes have been made since last save
00365 
00366       //! Get unique index for building Ini name.
00367       UINT8 GetIniIndex (
00368          ) const { return (m_IniIndex); }
00369 
00370    #ifdef X_NATIVE
00371       //! Create initial set of items in object manager.
00372       virtual void ObjMgrInitItems (
00373          ) = 0;
00374    #endif
00375 
00376       //! Get serialization item definition array.
00377       static const SERIALIZER::ITEMDEF* SerialGetItemDef (
00378          SERIALIZER& serializer
00379          ) { return (TemplateGetItemDef()); }
00380 
00381       //! Set index for building Ini name.
00382       void SetIniIndex (
00383          UINT8 IniIndex
00384          );
00385 
00386       //! Get serialization item definition array.
00387       static const SERIALIZER::ITEMDEF* TemplateGetItemDef (
00388          );
00389 
00390    private:
00391       #ifndef GENERATING_DOXYGEN_OUTPUT
00392 
00393       bool m_ShowInternalTables;             // Show "internal" tables in table lists
00394       bool m_ShowScaleRanges;                // Show scale ranges in layer lists
00395       char m_IniName[20];                    // Name of object for use in Ini file access
00396       UINT8 m_IniIndex;                      // Unique index of object for use in Ini file access
00397       UINT8 m_IniBaseLen;                    // Length of base name not including appended index number
00398       MDLGPARENT m_DialogParent;             // Parent for dialogs related to this object
00399       RVC::OBJITEM m_SaveObjItem;            // Object item where saved
00400    #ifdef X_NATIVE
00401       GRE::TOOLSCRIPTLIST m_ToolScripts;     // ToolScripts saved with this object
00402       GRE::MACROSCRIPTLIST m_MacroScripts;   // MacroScripts saved with this object
00403       Widget m_ObjMgrRC;                     // RowColumn container widget for "object manager"
00404    #endif
00405 
00406    #ifdef X_NATIVE
00407       static void CB_NotifyGreObjMgr (const GRE_CALLBACK_MSG *msg, void *vviewable);
00408       virtual void OnNotifyGreObjMgr (const GRE_CALLBACK_MSG& msg) = 0;
00409       static ERRVALUE SerialCB_MacroScript (SERIALIZER&, const SERIALIZER::ITEMDEF*, GRE_VIEWABLE *viewable, SERIALIZER::ITEMDEF::ACTION);
00410       static ERRVALUE SerialCB_ToolScript (SERIALIZER&, const SERIALIZER::ITEMDEF*, GRE_VIEWABLE *viewable, SERIALIZER::ITEMDEF::ACTION);
00411    #endif
00412 
00413    #ifdef X_NATIVE
00414       virtual void v_DlgObjMgrClose () = 0;
00415       virtual ERRVALUE v_DlgObjMgrCreate (MDLGPARENT dlgparent, const MISTRING& title) = 0;
00416       virtual void v_DlgObjMgrDestroy () = 0;
00417       virtual bool v_DlgObjMgrIsOpen () const = 0;
00418       virtual void v_DlgObjMgrOpen () = 0;
00419    #endif
00420       virtual double v_GetDesignScale () const = 0;
00421       virtual const DRECT2D& v_GetExtents () const = 0;
00422       virtual void v_SetDesignScale (double DesignScale, bool notify) = 0;
00423 
00424       GRE_VIEWABLE (const GRE_VIEWABLE&);
00425       GRE_VIEWABLE& operator= (const GRE_VIEWABLE&);
00426 
00427       #endif //!< GENERATING_DOXYGEN_OUTPUT
00428    }; // End of GRE_VIEWABLE
00429 
00430 //===================================================================================================================
00431 
00432 #ifndef GENERATING_DOXYGEN_OUTPUT
00433 #ifdef WIN32_MFC
00434 
00435 class GRE_MFC_VIEWABLE : public CDocument {
00436    protected:
00437 
00438       GRE_MFC_VIEWABLE (
00439          GRE_VIEWABLE *viewable = 0
00440          );
00441 
00442       DECLARE_DYNCREATE(GRE_MFC_VIEWABLE)
00443 
00444    public:
00445       GRE_VIEWABLE *GetViewable (
00446          ) const {
00447          return (m_viewable);
00448          }
00449 
00450       virtual ~GRE_MFC_VIEWABLE();
00451 
00452    protected:
00453 
00454       GRE_VIEWABLE *m_viewable;
00455 
00456    protected:
00457       DECLARE_MESSAGE_MAP()
00458    };
00459 
00460 #endif
00461 #endif //!< GENERATING_DOXYGEN_OUTPUT
00462 
00463 
00464 //===================================================================================================================
00465 
00466 #endif   //!< INC_GRE_VIEWABLE_H

Generated on Thu Aug 12 06:18:27 2004 for TNTsdk by doxygen 1.3.4-20031026