layerdc.h

Go to the documentation of this file.
00001 /**
00002  * \file layerdc.h <gre/layerdc.h>
00003  * \brief GRE_LAYERDC class definition
00004  *
00005  * \if NODOC
00006  * $Id: layerdc.h_v 1.11 2004/03/12 16:07:19 mju Exp $
00007  *
00008  * $Log: layerdc.h_v $
00009  * Revision 1.11  2004/03/12 16:07:19  mju
00010  * Add isHidden fn.
00011  *
00012  * Revision 1.10  2004/03/05 17:01:57  mju
00013  * Make dtor virtual since has virtual fns.
00014  *
00015  * Revision 1.9  2003/10/06 20:47:23  mju
00016  * Add NotifyDrawElementBegin/End.
00017  *
00018  * Revision 1.8  2003/09/15 13:48:59  fileserver!dwilliss
00019  * Doxygen
00020  *
00021  * Revision 1.7  2003/09/10 17:03:44  scowan
00022  * Create no trans draw line clipped function.
00023  *
00024  * Revision 1.6  2003/07/31 22:09:43  mju
00025  * Ignore private section.
00026  *
00027  * Revision 1.5  2003/06/14 02:11:02  scowan
00028  * Removed dregion and changed to region2d.
00029  *
00030  * Revision 1.4  2003/06/04 23:13:54  scowan
00031  * Added methods and removed simple array.
00032  *
00033  * Revision 1.3  2003/03/20 23:14:49  vdronov
00034  * new trans
00035  *
00036  * Revision 1.2  2003/03/05 20:41:32  mju
00037  * Add GetTransLayerToDevice
00038  *
00039  * Revision 1.1  2002/09/19 17:08:41  mju
00040  * Initial revision
00041  *
00042  * \endif
00043 **/
00044 
00045 #ifndef  INC_GRE_LAYERDC_H
00046 #define  INC_GRE_LAYERDC_H
00047 
00048 #ifndef  INC_MI32_GRE_H
00049    #include <mi32/gre.h>
00050 #endif
00051 
00052 #ifndef  INC_MI32_REGION2D_H
00053    #include <mi32/region2d.h>
00054 #endif
00055 
00056 //===================================================================================================================
00057 //! Layer drawing context.
00058 //! Contains information needed to actually draw layer on a particular view.
00059 class GRE_LAYERDC : public POLYLINE::CLIP {
00060    public:
00061 
00062       GRE_LAYER *layer;                      //!< Layer being drawn
00063       GRE_VIEW *view;                        //!< View being drawn in
00064       MGD::CONTEXT* ggc;                     //!< Generic graphic context
00065       GRE_VIEWPOINT3D *ViewPoint;            //!< 3D viewpoint
00066       GRE_LAYER_SURFACE *surflayer;          //!< Surface layer in 3D
00067       const GRE_LAYER_SURFACE::DISPPARM *surfdp;   //!< Surface layer display parameters for 3D
00068       DRECT2D ObjClipRect;                   //!< Clipping rectangle in object coordinates
00069       double LayoutScale;                    //!< Map scale of layout for relative size
00070       double MapScale;                       //!< Current map scale for relative size
00071       double RotAngle;                       //!< Rotation angle
00072       double cosrot, sinrot;                 //!< sin/cos of rotation angle
00073       double xpixelsize, ypixelsize;         //!< Pixel size in millimeters
00074       double surfinc;                        //!< Increment in layer corresponding to one cell in surface raster
00075       double MapScaleZ;                      //!< Map scale factor for 3D (multiply by depth to get actual scale)
00076       COLOR BackgroundColor;                 //!< Background color for AllBackground
00077       UINT32 drawflags;                      //!< MDISPDRAW_... flags
00078       UINT32 Clip3DFlags;                    //!< 3D clipping flags
00079       bool Is3D;                             //!< Set if drawing in 3D
00080       bool UseSurface;                       //!< Use surface layer for Z value
00081       bool SurfHasNull;                      //!< Surface layer has NULL values
00082       bool NoDrawActive;                     //!< Don't draw "active" element
00083       UINT8 ViewIndex;                       //!< Stereo view index
00084       bool ScaleToMap3D;                     //!< Set if 3D scaling to map
00085 
00086       //! Constructor.
00087       explicit GRE_LAYERDC (
00088          GRE_LAYER *layer,
00089          GRE_VIEW *view = 0,
00090          MGD::CONTEXT* ggc = 0,
00091          UINT32 drawflags = 0
00092          );
00093 
00094       //! Constructor.
00095       //! Does not need a layer, but you need to calculate the transformation and pass it in.
00096       //! Do not call Setup2D() if you use this ctor.
00097       GRE_LAYERDC (
00098          GRE_VIEW *view,
00099          MGD::CONTEXT* ggc,
00100          const TRANS2D_MAPGEN& ObjectToDevice,
00101          UINT32 drawflags = 0
00102          );
00103 
00104       //! Destructor.
00105       virtual ~GRE_LAYERDC ();
00106 
00107       //! Draw line in 2D, does not translate or clip
00108       //! @return TRUE if visible, FALSE if not, < 0 if error.
00109       ERRVALUE DrawLine2D (
00110          POLYLINE& PolyLine
00111          ) { return (OnClip(PolyLine)); }
00112 
00113       //! Translate, clip and draw line in 2D
00114       //! @return TRUE if visible, FALSE if not, < 0 if error.
00115       int DrawLineClipped2D (
00116          POLYLINE& PolyLine
00117          ) const;
00118 
00119       //! Clip and draw line in 2D
00120       //! @return TRUE if visible, FALSE if not, < 0 if error.
00121       int DrawLineClipped2DNoTrans (
00122          POLYLINE& PolyLine
00123          ) const;
00124 
00125       //! Translate, clip and draw line in 3D
00126       //! @return TRUE if visible, FALSE if not, < 0 if error.
00127       int DrawLineClipped3D (
00128          POLYLINE& PolyLine
00129          ) const;
00130 
00131       //! Translate, clip and draw line in 3D
00132       //! @return TRUE if visible, FALSE if not, < 0 if error.
00133       int DrawLineClipped3D (
00134          DPOINT3D* points,                   //!< Array of points with X/Y coordinates in layer associated with context
00135          INT32 NumPoints                     //!< Number of points
00136          ) const;
00137 
00138       //! Clip and draw segment in 3D.
00139       //! @return TRUE if visible, FALSE if not, < 0 if error.
00140       int DrawSegment3D (
00141          const DPOINT3D& point1,             //!< First point in map coordinates
00142          const DPOINT3D& point2              //!< Second point in map coordinates
00143          ) const;
00144 
00145       //! Get clipping region.
00146       const REGION2D& GetClipRegion (
00147          ) const { return (m_ClipRegion); }
00148 
00149       //! Get layer.
00150       GRE_LAYER* GetLayer (
00151          ) const { return (layer); }
00152 
00153       //! Get the clip rectangle in object coordinates
00154       const DRECT2D& GetObjectClipRect (
00155          ) const { return (this->ObjClipRect); }
00156 
00157       //! Get surface Z coordinates for array of points.
00158       ERRVALUE GetSurfaceZ (
00159          DPOINT3D* points,                   //!< Array of points with X/Y coordinates in layer associated with context
00160          INT32 NumPoints                     //!< Number of points
00161          ) const;
00162 
00163       //! Get surface Z coordinates for POLYLINE.
00164       ERRVALUE GetSurfaceZ (
00165          POLYLINE& polyline                  //!< 3D polyline
00166          ) const;
00167 
00168       //! Get transformation from 'layer' to 'device' coordinates.
00169       const TRANS2D_MAPGEN& GetTransLayerDevice (
00170          ) const { return (m_Trans); }
00171 
00172       //! Get transformation from 'layer' to 'surface' coordinates.
00173       const TRANS2D_MAPGEN& GetTransLayerSurface (
00174          ) const { return (m_ObjToSurf); }
00175 
00176       //! Determine if layer is 'hidden' due to scale or other visibility setting.
00177       bool IsHidden (
00178          ) const { return (m_IsHidden); }
00179 
00180       //! Send notification before drawing element.
00181       void NotifyDrawElementBegin (
00182          const RVC::ELEMENT& element
00183          ) const { view->NotifyDrawElementBegin(layer,element); }
00184 
00185       //! Send notification before drawing element.
00186       void NotifyDrawElementBegin (
00187          ELEMTYPE ElemType,
00188          INT32 ElemNum
00189          ) const { view->NotifyDrawElementBegin(layer,RVC::ELEMENT(ElemNum,ElemType)); }
00190 
00191       //! Send notification after drawing element.
00192       void NotifyDrawElementEnd (
00193          const RVC::ELEMENT& element
00194          ) const { view->NotifyDrawElementEnd(layer,element); }
00195 
00196       //! Send notification after drawing element.
00197       void NotifyDrawElementEnd (
00198          ELEMTYPE ElemType,
00199          INT32 ElemNum
00200          ) const { view->NotifyDrawElementEnd(layer,RVC::ELEMENT(ElemNum,ElemType)); }
00201 
00202       //! Set transformation from 'layer' to 'device' coordinates.
00203       void SetTransLayerDevice (
00204          const TRANS2D_MAPGEN& tmg
00205          ) { m_Trans = tmg; }
00206 
00207       //! Setup for drawing in 2D.
00208       //! @return TRUE if visible, FALSE if not, < 0 if error.
00209       ERRVALUE Setup2D (
00210          );
00211 
00212       //! Setup for drawing in 3D.
00213       //! @return TRUE if visible, FALSE if not, < 0 if error.
00214       ERRVALUE Setup3D (
00215          const GRE_VIEWPOINT3D& ViewPoint,
00216          int ViewIndex = 0
00217          );
00218 
00219       //! Translate 3D point to display coordinates.
00220       //! @return TRUE if point visible, FALSE if not, < 0 if error.
00221       int TransPoint3D (
00222          DPOINT3D& ipoint,                   //!< Point in layer coordinates, Z value may be altered if surface reference used
00223          DPOINT3D& opoint                    //!< Point in display coordinates with canonical depth returned
00224          ) const;
00225 
00226    private:
00227       #ifndef GENERATING_DOXYGEN_OUTPUT
00228 
00229       TRANS2D_MAPGEN m_Trans;
00230       TRANS2D_MAPGEN m_ObjToSurf;                     //!< Transformation from object to surface for 3D
00231       REGION2D m_ClipRegion;
00232       bool m_CheckVisible;
00233       bool m_IsHidden;
00234 
00235       GRE_LAYERDC (const GRE_LAYERDC&);
00236       GRE_LAYERDC& operator= (const GRE_LAYERDC&);
00237       
00238       virtual ERRVALUE OnClip (const POLYLINE& PolyLine);
00239 
00240       #endif //!< GENERATING_DOXYGEN_OUTPUT
00241    };
00242 
00243 //===================================================================================================================
00244 
00245 #endif   //!< INC_GRE_LAYERDC_H

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