layerview.h

Go to the documentation of this file.
00001 /**
00002  * \file gre/layerview.h
00003  * \brief GRE::LAYERVIEW class definition
00004  * 
00005  * \if NODOC
00006  * $Id: layerview.h_v 1.8 2005/05/24 21:29:36 mju Exp $
00007  *
00008  * $Log: layerview.h_v $
00009  * Revision 1.8  2005/05/24 21:29:36  mju
00010  * Make cliprect optional for overlayBufferIfRendered.
00011  *
00012  * Revision 1.7  2005/05/24 17:55:04  mju
00013  * Add OverlayIfRendered.
00014  *
00015  * Revision 1.6  2005/04/29 17:49:36  mju
00016  * Support rendertarget.
00017  *
00018  * Revision 1.5  2005/04/27 15:31:30  mju
00019  * Add docs for getElemDrawnSet.
00020  *
00021  * Revision 1.4  2005/04/22 17:35:44  mju
00022  * Use renderbuffer class.
00023  *
00024  * Revision 1.3  2005/03/22 21:59:50  mju
00025  * Reset overlay rendering and clear label placement in resetRendered.
00026  *
00027  * Revision 1.2  2005/03/01 14:21:31  mju
00028  * Add layerview_geometric to manage drawn sets.
00029  *
00030  * Revision 1.1  2005/02/25 18:54:42  mju
00031  * Initial revision
00032  *
00033  * \endif
00034 **/
00035 
00036 #ifndef  INC_GRE_LAYERVIEW_H
00037 #define  INC_GRE_LAYERVIEW_H
00038 
00039 #ifndef  INC_GRE_BASE_H
00040    #include <gre/base.h>
00041 #endif
00042 
00043 #ifndef  INC_GRE_LABELPLACEMENT_H
00044    #include <gre/labelplacement.h>
00045 #endif
00046 
00047 #ifndef  INC_MI32_RENDERBUFFER_H
00048    #include <mi32/renderbuffer.h>
00049 #endif
00050 
00051 #ifndef  INC_MI32_TRANS2DC_H
00052    #include <mi32/trans2dc.h>
00053 #endif
00054 
00055 
00056 namespace GRE {
00057 
00058 //===================================================================================================================
00059 
00060 //! Container for layer information retained for each view.
00061 class LAYERVIEW {
00062    public:
00063 
00064       //! Rendering buffer types.
00065       enum RENDERTYPE {
00066          RENDERTYPE_Layer =      0,
00067          RENDERTYPE_Labels =     1,
00068          RENDERTYPE_Highlight =  2
00069          };
00070 
00071       virtual ~LAYERVIEW ();
00072 
00073       //! Check if existing renderings are still valid.
00074       void CheckRendered (
00075          );
00076 
00077       //! Clear all 'drawn element' sets.
00078       //! Does not resize the sets.
00079       void ClearAllDrawnSets (
00080          bool UseHighlighted
00081          );
00082 
00083       //! Clear label placement if any.
00084       void ClearLabelPlacement (
00085          );
00086 
00087       //! Compute all transformations.
00088       ERRVALUE ComputeTrans (
00089          );
00090 
00091       //! Draw single element to specified rendering buffer.
00092       ERRVALUE DrawElementToBuffer (
00093          ELEMTYPE ElemType,
00094          INT32 ElemNum,
00095          GRE::LAYERVIEW::RENDERTYPE RenderType,
00096          GRE::DRAWFLAGS drawflags
00097          );
00098 
00099       //! Draw single element to specified rendering device.
00100       ERRVALUE DrawElementToDevice (
00101          ELEMTYPE ElemType,
00102          INT32 ElemNum,
00103          MGD::DEVICE *pDevice,
00104          GRE::DRAWFLAGS drawflags
00105          );
00106 
00107       //! Draw set of elements to specified rendering buffer.
00108       ERRVALUE DrawElementsToBuffer (
00109          ELEMTYPE ElemType,
00110          const UINT8 *ElemSet,
00111          GRE::LAYERVIEW::RENDERTYPE RenderType,
00112          GRE::DRAWFLAGS drawflags
00113          );
00114 
00115       //! Draw set of elements to specified rendering device.
00116       ERRVALUE DrawElementsToDevice (
00117          ELEMTYPE ElemType,
00118          const UINT8 *ElemSet,
00119          MGD::DEVICE *pDevice,
00120          GRE::DRAWFLAGS drawflags
00121          );
00122 
00123       //! Get depth scaling, multiplied by depth to get drawing scale.
00124       double Get3dDepthScale (
00125          ) const { return (m_3dDepthScale); }
00126 
00127       //! Get increment in layer relative to once cell in surface layer.
00128       double Get3dSurfaceIncrement (
00129          ) const { return (m_3dSurfaceIncrement); }
00130 
00131       //! Get 3D viewpoint.
00132       const GRE_VIEWPOINT3D* Get3dViewPoint (
00133          ) const { return (m_pViewPoint3D); }
00134 
00135       //! Get 3D Z scaling.
00136       double Get3dZScale (
00137          ) const { return (m_3dZScale); }
00138 
00139       //! Get design scale.
00140       double GetDesignScale (
00141          ) const { return (m_DesignScale); }
00142 
00143       //! Get device rectangle used for rendering.
00144       //! This is a nominal rectangle based on layer extents and may not account for
00145       //! symbology and marginalia.  Returned rectangle may not be suitable for clipping
00146       //! during drawing, but will be suitable for selection of source object elements.
00147       const LRECT2D& GetDeviceRectUsed (
00148          ) const { return (m_CurDevRectUsed); }
00149 
00150       //! Get set for elements drawn in view (const).
00151       //! @return NULL if no elements of specified type supported by layer.
00152       //! The set returned by this method only contains the elements which are actually visible in the view.
00153       //! Normally when checking for highlighted elements, the GRE_LAYER::GetElemHighlightSet method should be used.
00154       const BITSET* GetElemDrawnSet (
00155          ELEMTYPE ElemType,                              //! Element type
00156          bool UseHighlighted                             //! True to return set for visible elements drawn as 'highlighted'
00157          ) const { return (const_cast<LAYERVIEW*>(this)->v_GetElemDrawnSet(ElemType,UseHighlighted)); }
00158 
00159       //! Get set for elements drawn in view (non-const).
00160       //! @return NULL if no elements of specified type supported by layer.
00161       //! The set returned by this method should only contain the elements which are actually visible in the view.
00162       //! Normally when checking for highlighted elements, the GRE_LAYER::GetElemHighlightSet method should be used.
00163       BITSET* GetElemDrawnSet (
00164          ELEMTYPE ElemType,                              //! Element type
00165          bool UseHighlighted                             //! True to return set for visible elements drawn as 'highlighted'
00166          ) { return (v_GetElemDrawnSet(ElemType,UseHighlighted)); }
00167 
00168       //! Get pointer to label placement instance.
00169       //! @return LABELPLACEMENT pointer or NULL if not supported.
00170       LABELPLACEMENT* GetLabelPlacement (
00171          bool ReturnNullIfEmpty = true                   //!< Return NULL pointer if no labels
00172          );
00173 
00174       //! Get associated GRE_LAYER.
00175       GRE_LAYER* GetLayer (
00176          ) const { return (m_layer); }
00177 
00178       //! Get rendering buffer for specified rendering type (const).
00179       const RENDERBUFFER& GetRenderBuffer (
00180          RENDERTYPE RenderType                           //!< Rendering type
00181          ) const { return (m_RenderBuffer[RenderType]); }
00182 
00183       //! Get rendering buffer for specified rendering type (non-const).
00184       RENDERBUFFER& GetRenderBuffer (
00185          RENDERTYPE RenderType                           //!< Rendering type
00186          ) { return (m_RenderBuffer[RenderType]); }
00187 
00188       //! Get surface layer for 3D draping.
00189       GRE_LAYER_SURFACE* GetSurfaceLayer (
00190          ) const { return (m_pSurfaceLayer); }
00191 
00192       //! Get transformation from layer to device coordinates.
00193       const TRANS2D_MAPGEN& GetTransLayerDevice (
00194          ) const { return (m_TransLayerDevice); }
00195 
00196       //! Get transformation from 'layer' to 'surface' coordinates.
00197       const TRANS2D_MAPGEN& GetTransLayerSurface (
00198          ) const { return (m_TransLayerSurface); }
00199 
00200       //! Get transformation from layer to view coordinates.
00201       const TRANS2D_MAPGEN& GetTransLayerView (
00202          ) const { return (m_TransLayerView); }
00203 
00204       //! Get associated GRE_VIEW.
00205       GRE_VIEW* GetView (
00206          ) const { return (m_view); }
00207 
00208       //! Determine if surface has nulls.
00209       bool HasSurfaceNulls (
00210          ) const { return (m_HasSurfaceNulls); }
00211 
00212       //! Determine if drawing in 3D.
00213       bool Is3D (
00214          ) const { return (m_Is3D); }
00215 
00216       //! Determine if drawing 3D in stereo.
00217       bool Is3dStereo (
00218          ) const;
00219 
00220       //! Determine if surface (layer or flat) is being used.
00221       bool IsSurfaceUsed (
00222          ) const { return (m_IsSurfaceUsed); }
00223 
00224       //! Determine if layer overlaps view device display area.
00225       bool IsLayerOverlappedDevice (
00226          ) const { return (m_LayerOverlapsDevice); }
00227 
00228       //! Overlay rendering buffer on device if it has been rendered.
00229       //! @return true if did overlay, false if not.
00230       bool OverlayBufferIfRendered (
00231          RENDERTYPE RenderType,                          //!< Render type
00232          MGD::DEVICE *pDevTarget,                        //!< Target device
00233          const LRECT2D *pClipRect = 0                    //!< Optional clip rectangle
00234          );
00235 
00236       //! Reset all 'drawn element' sets to have no entries.
00237       void ResetAllDrawnSets (
00238          );
00239 
00240       //! Reset rendered status so redraws.
00241       void ResetRendered (
00242          GRE::RENDERTARGET target = GRE::RENDERTARGET_LayerAll
00243          );
00244 
00245    protected:
00246 
00247       //! Constructor.
00248       LAYERVIEW (
00249          GRE_LAYER *layer,
00250          GRE_VIEW *view
00251          );
00252 
00253    private:
00254       #ifndef GENERATING_DOXYGEN_OUTPUT
00255       GRE_LAYER *m_layer;
00256       GRE_VIEW *m_view;
00257       RENDERBUFFER m_RenderBuffer[3];
00258       TRANS2D_MAPGEN m_TransLayerView;
00259       TRANS2D_MAPGEN m_TransLayerDevice;
00260       TRANS2D_MAPGEN m_TransLayerSurface;
00261       GRE_VIEWPOINT3D *m_pViewPoint3D;          // 3D viewpoint
00262       GRE_LAYER_SURFACE *m_pSurfaceLayer;       // Surface layer in 3D
00263       DRECT2D m_NewTgtRectFull;                 // New full rectangle in target device coordinates, based on transformation
00264       DRECT2D m_CurTgtRectFull;                 // Current full rectangle in target device coordinates used by layer
00265       LRECT2D m_NewDevRectUsed;                 // New clipped rectangle on device used, based on transformation
00266       LRECT2D m_CurDevRectUsed;                 // Current clipped rectangle on device used
00267       double m_DesignScale;                     // Design scale of layout/group for relative size
00268       double m_3dSurfaceIncrement;              // Increment in layer corresponding to one cell in surface raster
00269       double m_3dDepthScale;                    // Map scale factor for 3D (multiply by depth to get actual scale)
00270       double m_3dZScale;
00271       bool m_Is3D;                              // Set if drawing in 3D
00272       bool m_IsSurfaceUsed;                     // Use surface layer for Z value
00273       bool m_HasSurfaceNulls;                   // Surface layer has null cells
00274       bool m_LayerOverlapsDevice;
00275 
00276       void DestroyRenderDevices (
00277          );
00278 
00279       void SetTransLayerDevice (
00280          const TRANS2D_MAPGEN& TransLayerDevice
00281          ) { m_TransLayerDevice = TransLayerDevice; }
00282 
00283       LAYERVIEW (const LAYERVIEW&);
00284       LAYERVIEW& operator= (const LAYERVIEW&);
00285 
00286       friend class GRE_LAYER;
00287       friend class GRE_LAYERDC;
00288       #endif // GENERATING_DOXYGEN_OUTPUT
00289 
00290       // LAYERVIEW Overridables.
00291 
00292       //! Get set for elements drawn in view.
00293       //! @return NULL if no elements of specified type supported by layer.
00294       virtual BITSET* v_GetElemDrawnSet (
00295          ELEMTYPE ElemType,
00296          bool UseHighlighted
00297          );
00298 
00299       //! Get pointer label placement manager.
00300       //! @return NULL if labels not supported.
00301       virtual LABELPLACEMENT* v_GetLabelPlacement (
00302          );
00303 
00304    };
00305 
00306 
00307 //! Derived class supporting geometric element drawn sets.
00308 class LAYERVIEW_GEOMETRIC : public LAYERVIEW {
00309    public:
00310 
00311       //! Constructor.
00312       LAYERVIEW_GEOMETRIC (
00313          GRE_LAYER *layer,
00314          GRE_VIEW *view
00315          );
00316 
00317       virtual ~LAYERVIEW_GEOMETRIC ();
00318 
00319    private:
00320       #ifndef GENERATING_DOXYGEN_OUTPUT
00321 
00322       unsigned m_NumComponents;
00323       BITSET *m_ElemDrawnSetsNormal;
00324       BITSET *m_ElemDrawnSetsHighlighted;
00325 
00326       virtual BITSET* v_GetElemDrawnSet (
00327          ELEMTYPE ElemType,
00328          bool UseHighlighted
00329          );
00330 
00331       LAYERVIEW_GEOMETRIC (const LAYERVIEW_GEOMETRIC&);
00332       LAYERVIEW_GEOMETRIC& operator= (const LAYERVIEW_GEOMETRIC&);
00333 
00334       #endif // GENERATING_DOXYGEN_OUTPUT
00335    };
00336 
00337 
00338 
00339 //! Derived class supporting label placement.
00340 class LAYERVIEW_LABELED : public LAYERVIEW_GEOMETRIC {
00341    public:
00342 
00343       //! Constructor.
00344       LAYERVIEW_LABELED (
00345          GRE_LAYER *layer,
00346          GRE_VIEW *view
00347          );
00348 
00349       virtual ~LAYERVIEW_LABELED ();
00350 
00351    private:
00352       #ifndef GENERATING_DOXYGEN_OUTPUT
00353       LABELPLACEMENT m_LabelPlacement;
00354 
00355       virtual LABELPLACEMENT* v_GetLabelPlacement (
00356          );
00357 
00358       LAYERVIEW_LABELED (const LAYERVIEW_LABELED&);
00359       LAYERVIEW_LABELED& operator= (const LAYERVIEW_LABELED&);
00360 
00361       #endif // GENERATING_DOXYGEN_OUTPUT
00362    };
00363 
00364 //===================================================================================================================
00365 }  // End namespace GRE
00366 
00367 #endif   // INC_GRE_LAYERVIEW_H

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