gre/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.33 2005/10/19 20:08:41 mju Exp $
00007  *
00008  * $Log: layerdc.h_v $
00009  * Revision 1.33  2005/10/19 20:08:41  mju
00010  * Use gre namespace instead of legacy typedefs.
00011  *
00012  * Revision 1.32  2005/10/14 17:30:30  mju
00013  * GRE namespace.
00014  *
00015  * Revision 1.31  2005/05/03 15:02:25  mju
00016  * Keep track of render target.
00017  * Add checkColorLock using elemtype/num and highlightset.
00018  *
00019  * Revision 1.30  2005/05/02 20:40:08  mju
00020  * Add checkColorOverride.
00021  *
00022  * Revision 1.29  2005/05/02 17:44:06  mju
00023  * Add checkColorLock.
00024  *
00025  * Revision 1.28  2005/03/01 14:21:15  mju
00026  * Add methods to access drawn sets.
00027  *
00028  * Revision 1.27  2005/02/25 20:31:31  mju
00029  * Include groupview hdr.
00030  *
00031  * Revision 1.26  2005/02/25 18:54:37  mju
00032  * Include layerview hdr.
00033  *
00034  * Revision 1.25  2005/02/25 17:47:27  mju
00035  * Remove setup2D/3D, add CanDrawLayer, Set3dStereoView.
00036  *
00037  * Revision 1.24  2005/02/24 20:38:57  mju
00038  * Remove commented-out method.
00039  *
00040  * Revision 1.23  2005/02/24 18:52:39  mju
00041  * Remove getBackgroundColor.
00042  * Make setDrawFlags non-inline.
00043  *
00044  * Revision 1.22  2005/02/23 18:53:08  mju
00045  * Add non-const getLayerView method.
00046  *
00047  * Revision 1.21  2005/02/23 16:56:08  mju
00048  * Add non-const variant of getLayerView.
00049  *
00050  * Revision 1.20  2005/02/14 18:53:11  mju
00051  * Use groupview.
00052  *
00053  * Revision 1.19  2005/02/04 18:57:35  mju
00054  * Add ctors using mgd device.
00055  * Add setDrawingDevice.
00056  * Deprecate ctors using mgd context.
00057  *
00058  * Revision 1.18  2005/01/27 21:42:47  mju
00059  * Undeprecate ctor.
00060  *
00061  * Revision 1.17  2005/01/24 21:37:24  mju
00062  * Add non-const get3dScene.
00063  *
00064  * Revision 1.16  2005/01/24 21:31:36  mju
00065  * Move members which can be saved between drawing to layerview.
00066  *
00067  * Revision 1.14  2005/01/21 17:30:29  mju
00068  * Make all members private.
00069  *
00070  * Revision 1.13  2005/01/20 22:47:31  mju
00071  * Add accessor methods.
00072  *
00073  * Revision 1.12  2005/01/20 16:55:43  mju
00074  * Enums for drawmode.
00075  *
00076  * Revision 1.11  2004/03/12 16:07:19  mju
00077  * Add isHidden fn.
00078  *
00079  * Revision 1.10  2004/03/05 17:01:57  mju
00080  * Make dtor virtual since has virtual fns.
00081  *
00082  * Revision 1.9  2003/10/06 20:47:23  mju
00083  * Add NotifyDrawElementBegin/End.
00084  *
00085  * Revision 1.8  2003/09/15 13:48:59  fileserver!dwilliss
00086  * Doxygen
00087  *
00088  * Revision 1.7  2003/09/10 17:03:44  scowan
00089  * Create no trans draw line clipped function.
00090  *
00091  * Revision 1.6  2003/07/31 22:09:43  mju
00092  * Ignore private section.
00093  *
00094  * Revision 1.5  2003/06/14 02:11:02  scowan
00095  * Removed dregion and changed to region2d.
00096  *
00097  * Revision 1.4  2003/06/04 23:13:54  scowan
00098  * Added methods and removed simple array.
00099  *
00100  * Revision 1.3  2003/03/20 23:14:49  vdronov
00101  * new trans
00102  *
00103  * Revision 1.2  2003/03/05 20:41:32  mju
00104  * Add GetTransLayerToDevice
00105  *
00106  * Revision 1.1  2002/09/19 17:08:41  mju
00107  * Initial revision
00108  *
00109  * \endif
00110 **/
00111 
00112 #ifndef  INC_GRE_LAYERDC_H
00113 #define  INC_GRE_LAYERDC_H
00114 
00115 #ifndef  INC_GRE_VIEW_H
00116    #include <gre/view.h>
00117 #endif
00118 
00119 #ifndef  INC_GRE_GROUP_H
00120    #include <gre/group.h>
00121 #endif
00122 
00123 #ifndef  INC_GRE_LAYERVIEW_H
00124    #include <gre/layerview.h>
00125 #endif
00126 
00127 #ifndef  INC_GRE_GROUPVIEW_H
00128    #include <gre/groupview.h>
00129 #endif
00130 
00131 #ifndef  INC_GRE_LRSURFACE_H
00132    #include <gre/lrsurface.h>
00133 #endif
00134 
00135 #ifndef  INC_MI32_REGION2D_H
00136    #include <mi32/region2d.h>
00137 #endif
00138 
00139 #ifndef  INC_MI32_SML_H
00140    #include <mi32/sml.h>
00141 #endif
00142 
00143 
00144 namespace GRE {
00145 //===================================================================================================================
00146 //! Layer drawing context.
00147 //! Contains information needed to actually draw layer on a particular view.
00148 class LAYERDC : public POLYLINE::CLIP {
00149    public:
00150 
00151       //! Construct using layer, view and drawing device.
00152       LAYERDC (
00153          LAYER *layer,                    //!< Layer, must not be NULL
00154          GRE::VIEW *view,                    //!< View, should not be NULL
00155          MGD::DEVICE* pDevice = 0,
00156          GRE::DRAWFLAGS drawflags = GRE::DRAWFLAG_None
00157          );
00158 
00159       //! Construct using view, drawing device and transformation.
00160       //! Does not need a layer, but you need to calculate the transformation and pass it in.
00161       LAYERDC (
00162          GRE::VIEW *view,                    //!< View, cannot be NULL
00163          MGD::DEVICE* pDevice,               //!< Drawing device, cannot be NULL
00164          const TRANS2D_MAPGEN& ObjectToDevice,
00165          GRE::DRAWFLAGS drawflags = GRE::DRAWFLAG_None
00166          );
00167 
00168       //! Destructor.
00169       virtual ~LAYERDC ();
00170 
00171       //! Determine if possible to draw layer.
00172       //! @return false if out of view or cannot draw based on 2D/3D view type.
00173       bool CanDrawLayer (
00174          ) const;
00175 
00176       //! Check if drawing flags require a color lock, set color and lock if so.
00177       bool CheckColorLock (
00178          MGD::COLORLOCK& colorlock           //!< Color lock passed/returned
00179          );
00180 
00181       //! Check if drawing flags require a color lock, set color and lock if so.
00182       bool CheckColorLock (
00183          MGD::COLORLOCK& colorlock,          //!< Color lock passed/returned
00184          ELEMTYPE ElemType,                  //!< Element type
00185          INT32 ElemNum,                      //!< Element number
00186          const BITSET& HighlightSet          //!< Highlight set
00187          );
00188 
00189       //! Check if drawing flags require a color override.
00190       bool CheckColorOverride (
00191          COLOR& color                        //!< Override color returned
00192          );
00193 
00194       void ClearAllDrawnSets (
00195          );
00196 
00197       //! Draw line in 2D, does not translate or clip
00198       //! @return TRUE if visible, FALSE if not, < 0 if error.
00199       ERRVALUE DrawLine2D (
00200          POLYLINE& PolyLine
00201          ) { return (OnClip(PolyLine)); }
00202 
00203       //! Translate, clip and draw line in 2D
00204       //! @return TRUE if visible, FALSE if not, < 0 if error.
00205       int DrawLineClipped2D (
00206          POLYLINE& PolyLine
00207          ) const;
00208 
00209       //! Clip and draw line in 2D
00210       //! @return TRUE if visible, FALSE if not, < 0 if error.
00211       int DrawLineClipped2DNoTrans (
00212          POLYLINE& PolyLine
00213          ) const;
00214 
00215       //! Translate, clip and draw line in 3D
00216       //! @return TRUE if visible, FALSE if not, < 0 if error.
00217       int DrawLineClipped3D (
00218          POLYLINE& PolyLine
00219          ) const;
00220 
00221       //! Translate, clip and draw line in 3D
00222       //! @return TRUE if visible, FALSE if not, < 0 if error.
00223       int DrawLineClipped3D (
00224          DPOINT3D* points,                   //!< Array of points with X/Y coordinates in layer associated with context
00225          INT32 NumPoints                     //!< Number of points
00226          ) const;
00227 
00228       //! Clip and draw segment in 3D.
00229       //! @return TRUE if visible, FALSE if not, < 0 if error.
00230       int DrawSegment3D (
00231          const DPOINT3D& point1,             //!< First point in map coordinates
00232          const DPOINT3D& point2              //!< Second point in map coordinates
00233          ) const;
00234 
00235       //! Fill 3D flat polygon.
00236       //! @return true if was visible, false if not.
00237       bool Fill3dFlatPolygon (
00238          const DPOINT3D *points,             //!< Polygon vertices
00239          INT32 numPoints                     //!< Number of vertices
00240          ) const;
00241 
00242       //! Fill 3D triangle.
00243       //! @return true if was visible, false if not.
00244       bool Fill3dTriangle (
00245          const DPOINT3D *tp[3]               //!< Pointers to triangle vertices
00246          ) const;
00247 
00248       //! Get depth scaling, multiplied by depth to get drawing scale.
00249       double Get3dDepthScale (
00250          ) const { return (m_pLayerView->Get3dDepthScale()); }
00251 
00252       //! Get 3D scene containing 3D transformations.
00253       const GRE::SCENE3D& Get3dScene (
00254          ) const { return (m_Scene3D); }
00255 
00256       //! Get 3D scene containing 3D transformations.
00257       GRE::SCENE3D& Get3dScene (
00258          ) { return (m_Scene3D); }
00259 
00260       //! Get increment in layer relative to once cell in surface layer.
00261       double Get3dSurfaceIncrement (
00262          ) const { return (m_pLayerView->Get3dSurfaceIncrement()); }
00263 
00264       //! Get 3D stereo view setting.
00265       GRE::SCENE3D::STEREOVIEW Get3dStereoView (
00266          ) const { return (m_Scene3D.GetStereoView()); }
00267 
00268       //! Get 3D Z scaling.
00269       double Get3dZScale (
00270          ) const { return (m_pLayerView->Get3dZScale()); }
00271 
00272       //! Get clipping region in device coordinates.
00273       const REGION2D& GetClipRegion (
00274          ) const { return (m_ClipRegion); }
00275 
00276       //! Get design scale.
00277       double GetDesignScale (
00278          ) const { return (m_DesignScale); }
00279 
00280       //! Get drawing flags.
00281       GRE::DRAWFLAGS GetDrawFlags (
00282          ) const { return (m_drawflags); }
00283 
00284       //! Get drawing device context.
00285       MGD::CONTEXT* GetDrawingContext (
00286          ) const { return (m_ggc); }
00287 
00288       //! Get drawing device.
00289       MGD::DEVICE* GetDrawingDevice (
00290          ) const { return (m_ggc == 0 ? 0 : &m_ggc->GetDevice()); }
00291 
00292       //! Get scale at which layer is currently being drawn.
00293       double GetDrawingScale (
00294          ) const { return (m_DrawingScale); }
00295 
00296       //! Get target based on current drawing device.
00297       GRE::RENDERTARGET GetRenderTarget (
00298          ) const { return (m_RenderTarget); }
00299 
00300       //! Get pointer to 'drawn set' based on specified element type and current target device.
00301       //! @return Pointer to BITSET, NULL if none available.
00302       BITSET* GetElemDrawnSet (
00303          ELEMTYPE ElemType = ELEMTYPE_All
00304          ) const;
00305 
00306       //! Get layer.
00307       LAYER* GetLayer (
00308          ) const { return (m_layer); }
00309 
00310       //! Get LAYERVIEW (const).
00311       const GRE::LAYERVIEW* GetLayerView (
00312          ) const { return (m_pLayerView); }
00313 
00314       //! Get LAYERVIEW (non-const).
00315       GRE::LAYERVIEW* GetLayerView (
00316          ) { return (m_pLayerView); }
00317 
00318       bool GetNoDrawActive (
00319          ) const { return (m_NoDrawActive); }
00320 
00321       //! Get the clip rectangle in object coordinates
00322       const DRECT2D& GetObjectClipRect (
00323          ) const { return (m_ObjClipRect); }
00324 
00325       //! Get pixel size in millimeters.
00326       const DPOINT2D& GetPixelSizeMM (
00327          ) const { return (m_PixelSizeMM); }
00328 
00329       //! Get rotation angle.
00330       double GetRotationAngle (
00331          ) const { return (m_RotationAngle); }
00332 
00333       //! Get rotation cosine.
00334       double GetRotationCos (
00335          ) const { return (m_pGroupView->GetRotationCos()); }
00336 
00337       //! Get rotation sine.
00338       double GetRotationSin (
00339          ) const { return (m_pGroupView->GetRotationSin()); }
00340 
00341       //! Get surface layer for 3D draping.
00342       LAYER_SURFACE* GetSurfaceLayer (
00343          ) const { return (m_pLayerView->GetSurfaceLayer()); }
00344 
00345       //! Get surface Z coordinates for array of points.
00346       ERRVALUE GetSurfaceZ (
00347          DPOINT3D* points,                   //!< Array of points with X/Y coordinates in layer associated with context
00348          INT32 NumPoints                     //!< Number of points
00349          ) const;
00350 
00351       //! Get surface Z coordinates for POLYLINE.
00352       ERRVALUE GetSurfaceZ (
00353          POLYLINE& polyline                  //!< 3D polyline
00354          ) const;
00355 
00356       //! Get transformation from 'layer' to 'device' coordinates.
00357       const TRANS2D_MAPGEN& GetTransLayerDevice (
00358          ) const { return (m_pLayerView->GetTransLayerDevice()); }
00359 
00360       //! Get transformation from 'layer' to 'surface' coordinates.
00361       const TRANS2D_MAPGEN& GetTransLayerSurface (
00362          ) const { return (m_pLayerView->GetTransLayerSurface()); }
00363 
00364       GRE::VIEW* GetView (
00365          ) const { return (m_view); }
00366 
00367       //! Determine if has surface layer.
00368       bool HasSurfaceLayer (
00369          ) const { return (m_pLayerView->GetSurfaceLayer() != 0); }
00370 
00371       //! Determine if surface has nulls.
00372       bool HasSurfaceNulls (
00373          ) const { return (m_pLayerView->HasSurfaceNulls()); }
00374 
00375       //! Determine if drawing in 2D or 3D.
00376       bool Is3D (
00377          ) const { return (m_pLayerView->Is3D()); }
00378 
00379       //! Determine if layer is 'hidden' due to scale or other visibility setting.
00380       bool IsHidden (
00381          ) const { return (m_IsHidden); }
00382 
00383       //! Determine if surface (layer or flat) is being used.
00384       bool IsSurfaceUsed (
00385          ) const { return (m_pLayerView->IsSurfaceUsed()); }
00386 
00387       //! Send notification before drawing element.
00388       void NotifyDrawElementBegin (
00389          const RVC::ELEMENT& element
00390          ) const { m_view->NotifyDrawElementBegin(m_layer,element); }
00391 
00392       //! Send notification before drawing element.
00393       void NotifyDrawElementBegin (
00394          ELEMTYPE ElemType,
00395          INT32 ElemNum
00396          ) const { m_view->NotifyDrawElementBegin(m_layer,RVC::ELEMENT(ElemNum,ElemType)); }
00397 
00398       //! Send notification after drawing element.
00399       void NotifyDrawElementEnd (
00400          const RVC::ELEMENT& element
00401          ) const { m_view->NotifyDrawElementEnd(m_layer,element); }
00402 
00403       //! Send notification after drawing element.
00404       void NotifyDrawElementEnd (
00405          ELEMTYPE ElemType,
00406          INT32 ElemNum
00407          ) const { m_view->NotifyDrawElementEnd(m_layer,RVC::ELEMENT(ElemNum,ElemType)); }
00408 
00409       //! Set whether current element is scaled when rendered in 3D.
00410       void Set3dElemScaled (
00411          bool IsScaled
00412          ) { m_ScaleToMap3D = IsScaled; }
00413 
00414       void Set3dStereoView (
00415          GRE::SCENE3D::STEREOVIEW StereoView
00416          );
00417 
00418       //! Set drawing flags.
00419       void SetDrawFlags (
00420          GRE::DRAWFLAGS drawflags
00421          );
00422 
00423       //! Set drawing device.
00424       void SetDrawingDevice (
00425          MGD::DEVICE *pDevice
00426          );
00427 
00428       //! Translate 3D point to display coordinates.
00429       //! @return TRUE if point visible, FALSE if not, < 0 if error.
00430       int TransPoint3D (
00431          DPOINT3D& ipoint,                   //!< Point in layer coordinates, Z value may be altered if surface reference used
00432          DPOINT3D& opoint                    //!< Point in display coordinates with canonical depth returned
00433          ) const;
00434 
00435    private:
00436       #ifndef GENERATING_DOXYGEN_OUTPUT
00437 
00438       static SMLAUTOCLASS_NOALLOC_T<LAYERDC> s_SML_AutoClass;
00439 
00440       static void SML_Register ();
00441 
00442       GRE::GROUPVIEW *m_pGroupView;
00443       GRE::LAYERVIEW *m_pLayerView;
00444       LAYER *m_layer;
00445       GRE::VIEW *m_view;
00446       MGD::CONTEXT* m_ggc;                      // Generic graphic context
00447       GRE::DRAWFLAGS m_drawflags;               // Drawing flags
00448       REGION2D m_ClipRegion;                    // Current clipping region in device coordinates
00449       DRECT2D m_ObjClipRect;                    // Clipping rectangle in object coordinates
00450       DPOINT2D m_PixelSizeMM;                   // Device pixel size in millimeters
00451       double m_DesignScale;                     // Mirrored from LAYERVIEW for SML access
00452       double m_DrawingScale;
00453       double m_RotationAngle;                   // Mirrored from GROUPVIEW for SML access
00454       bool m_OwnGroupView;
00455       bool m_OwnLayerView;
00456       bool m_IsHidden;
00457       bool m_NoDrawActive;                      // Don't draw "active" element
00458       bool m_ScaleToMap3D;                      // Set if 3D scaling to map
00459       GRE::SCENE3D m_Scene3D;
00460       GRE::RENDERTARGET m_RenderTarget;
00461 
00462       void SetupForDrawFlags ();
00463       void SetupForStereoView ();
00464 
00465       // Not implemented.
00466       LAYERDC (const LAYERDC&);
00467       LAYERDC& operator= (const LAYERDC&);
00468       
00469       virtual ERRVALUE OnClip (const POLYLINE& PolyLine);
00470 
00471       #endif // GENERATING_DOXYGEN_OUTPUT
00472    };
00473 
00474 //===================================================================================================================
00475 }  // End namespace GRE
00476 
00477 #endif   // INC_GRE_LAYERDC_H

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