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

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