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

Generated on Thu Apr 26 04:44:41 2007 for TNTsdk by  doxygen 1.5.2