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

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