[mapguide-commits] r1243 - trunk/MgDev/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Mar 15 14:43:23 EDT 2007


Author: traianstanev
Date: 2007-03-15 14:43:22 -0400 (Thu, 15 Mar 2007)
New Revision: 1243

Modified:
   trunk/MgDev/Common/Stylization/GDRenderer.cpp
   trunk/MgDev/Common/Stylization/GDRenderer.h
   trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp
   trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
   trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp
   trunk/MgDev/Common/Stylization/SE_LineBuffer.h
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Common/Stylization/SE_Renderer.h
Log:
Further simplified SE_LineBuffer. Removed the internally managed transformed instance LineBuffer. Instead, the non-transformed instance is used for drawing and the correct transform is applied to the points at render time. 

Modified: trunk/MgDev/Common/Stylization/GDRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDRenderer.cpp	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/GDRenderer.cpp	2007-03-15 18:43:22 UTC (rev 1243)
@@ -2124,22 +2124,39 @@
 /////////////////////////////////////////////////////////////
 
 
-void GDRenderer::_TransferPoints(double* src, int numpts)
+void GDRenderer::_TransferPoints(double* src, int numpts, const SE_Matrix* xform)
 {
     EnsureBufferSize(numpts);
     int* pts = (int*)m_wtPointBuffer;
-    for (int i=0; i<numpts; i++)
+
+    if (!xform)
     {
-        *pts++ = (int)(*src);
-        src++;
-        *pts++ = (int)(*src);
-        src++;
+        for (int i=0; i<numpts; i++)
+        {
+            *pts++ = (int)(*src);
+            src++;
+            *pts++ = (int)(*src);
+            src++;
+        }
     }
+    else
+    {
+        for (int i=0; i<numpts; i++)
+        {
+            double x, y;
+            xform->transform(src[0], src[1], x, y);
+            pts[0] = (int)x;
+            pts[1] = (int)y;
+
+            src += 2;
+            pts += 2;
+        }
+    }
 }
 
 
 //copied from WritePolylines, except it doesn't do to screen trasnform -- we should refactor.
-void GDRenderer::DrawScreenPolyline(LineBuffer* srclb, unsigned int color, double weightpx)
+void GDRenderer::DrawScreenPolyline(LineBuffer* srclb, const SE_Matrix* xform, unsigned int color, double weightpx)
 {
     RS_Color c((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, (color >> 24) & 0xFF);
 
@@ -2165,7 +2182,7 @@
         int cntr_size = srclb->cntrs()[i];
 
         //convert to integer coords
-        _TransferPoints(srclb->points() + index, cntr_size);
+        _TransferPoints(srclb->points() + index, cntr_size, xform);
 
         if (cntr_size > 1)
         {
@@ -2190,7 +2207,7 @@
 }
 
 
-void GDRenderer::DrawScreenPolygon(LineBuffer* polygon, unsigned int color)
+void GDRenderer::DrawScreenPolygon(LineBuffer* polygon, const SE_Matrix* xform, unsigned int color)
 {
     RS_Color c((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, (color >> 24) & 0xFF);
 
@@ -2212,7 +2229,7 @@
         }
         */
 
-        _TransferPoints(polygon->points(), polygon->point_count());
+        _TransferPoints(polygon->points(), polygon->point_count(), xform);
 
         //call the new rasterizer
         m_polyrasterizer->FillPolygon((Point*)m_wtPointBuffer, polygon->point_count(), polygon->cntrs(), polygon->cntr_count(),

Modified: trunk/MgDev/Common/Stylization/GDRenderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/GDRenderer.h	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/GDRenderer.h	2007-03-15 18:43:22 UTC (rev 1243)
@@ -147,8 +147,8 @@
     ////////////////////////////////////////////////
     // SE_Renderer
     //
-    virtual void DrawScreenPolyline(LineBuffer* geom, unsigned int color, double weight); // px
-    virtual void DrawScreenPolygon(LineBuffer* geom, unsigned int fill);
+    virtual void DrawScreenPolyline(LineBuffer* geom, const SE_Matrix* xform, unsigned int color, double weight); // px
+    virtual void DrawScreenPolygon(LineBuffer* geom, const SE_Matrix* xform, unsigned int fill);
     virtual void DrawScreenRaster(unsigned char* data, int length, RS_ImageFormat format, int native_width, int native_height, 
         double x, double y, double w, double h, double angledeg);
     virtual void DrawScreenText(const RS_String& txt, RS_TextDef& tdef, double insx, double insy, double* path, int npts, double param_position);
@@ -206,7 +206,7 @@
     inline int _TY(double y);
 
     void _TransformPointsNoClamp(double* inpts, int numpts);
-    void _TransferPoints(double* inpts, int numpts);
+    void _TransferPoints(double* inpts, int numpts, const SE_Matrix* xform);
 
     RS_Color m_bgcolor;
     RS_Bounds m_extents;

Modified: trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp	2007-03-15 18:43:22 UTC (rev 1243)
@@ -202,7 +202,7 @@
             }
         }
 
-        rewriter->DrawScreenPolygon(&lb, color.argb());
+        rewriter->DrawScreenPolygon(&lb, NULL, color.argb());
     }
 
     return WT_Result::Success;

Modified: trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/RS_FontEngine.cpp	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/RS_FontEngine.cpp	2007-03-15 18:43:22 UTC (rev 1243)
@@ -524,7 +524,7 @@
         lb.LineTo(fpts[3].x, fpts[3].y);
         lb.Close();
 
-        m_serenderer->DrawScreenPolygon(&lb, tdef.bgcolor().argb());
+        m_serenderer->DrawScreenPolygon(&lb, NULL, tdef.bgcolor().argb());
     }
 
     for (size_t k=0; k<tm.line_pos.size(); ++k)
@@ -580,7 +580,7 @@
             lb.MoveTo(x0, y0);
             lb.LineTo(x1, y1);
 
-            m_serenderer->DrawScreenPolyline(&lb, tdef.color().argb(), line_width);
+            m_serenderer->DrawScreenPolyline(&lb, NULL, tdef.color().argb(), line_width);
         }
     }
 }
@@ -667,7 +667,7 @@
             lb.MoveTo(sx, sy);
             lb.LineTo(ex, ey);
 
-            m_serenderer->DrawScreenPolyline(&lb, tdef.color().argb(), line_width);
+            m_serenderer->DrawScreenPolyline(&lb, NULL, tdef.color().argb(), line_width);
 
             last_x = ex;
             last_y = ey;

Modified: trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp	2007-03-15 18:43:22 UTC (rev 1243)
@@ -357,13 +357,11 @@
     m_xf_tol(-1.0),
     m_xf_weight(-1.0),
     m_xf_bounds(NULL),
-    m_inst_bounds(NULL),
     m_compute_bounds(true)
 {
     m_pts = new double[size*2];
     m_segs = new SE_LB_SegType[size];
     m_xf_buf = new SE_LineStorage(size);
-    m_inst_buf = new SE_LineStorage(size);
 }
 
 SE_LineBuffer::~SE_LineBuffer()
@@ -371,7 +369,6 @@
     delete[] m_pts;
     delete[] m_segs;
     delete m_xf_buf;
-    delete m_inst_buf;
 }
 
 void SE_LineBuffer::MoveTo(double x, double y)
@@ -478,15 +475,9 @@
         m_xf_bounds->Free();
         m_xf_bounds = NULL;
     }
-    if (m_inst_bounds)
-    {
-        m_inst_bounds->Free();
-        m_inst_bounds = NULL;
-    }
     m_xf_tol = m_xf_weight = -1.0;
     m_xf.setIdentity();
     m_xf_buf->Reset();
-    m_inst_buf->Reset();
 }
 
 void SE_LineBuffer::ResizeBuffer(void** buffer, int unitsize, int mininc, int cur_pts, int& max_pts)
@@ -637,26 +628,6 @@
     return m_xf_buf;
 }
 
-LineBuffer* SE_LineBuffer::TransformInstance(const SE_Matrix& xform)
-{
-    m_inst_buf->SetToTransform(xform, m_xf_buf);
-
-    if (m_inst_bounds)
-    {
-        m_inst_bounds->Free();
-        m_inst_bounds = NULL;
-    }
-
-    if (m_xf_bounds && m_compute_bounds)
-    {
-        m_inst_bounds = m_pool->NewBounds(m_xf_bounds->size);
-        m_inst_bounds->Transform(xform, m_xf_bounds);
-        m_inst_buf->SetBounds(m_inst_bounds);
-    }
-
-    return m_inst_buf;
-}
-
 bool SE_LineBuffer::Empty()
 {
     return m_npts == 0;
@@ -730,10 +701,7 @@
     clone->m_xf_weight = m_xf_weight;
     if (m_xf_bounds)
         clone->m_xf_bounds = m_xf_bounds->Clone();
-    if (m_inst_bounds)
-        clone->m_inst_bounds = m_inst_bounds->Clone();
     clone->m_xf_buf->SetToCopy(m_xf_buf);
-    clone->m_inst_buf->SetToCopy(m_inst_buf);
     int grow_segs = m_nsegs - clone->m_max_segs;
     if (grow_segs > 0)
         ResizeBuffer((void**)&clone->m_segs, sizeof(double), grow_segs, clone->m_nsegs, clone->m_max_segs);

Modified: trunk/MgDev/Common/Stylization/SE_LineBuffer.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_LineBuffer.h	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/SE_LineBuffer.h	2007-03-15 18:43:22 UTC (rev 1243)
@@ -61,13 +61,10 @@
     STYLIZATION_API void Free();
 
     STYLIZATION_API LineBuffer* Transform(const SE_Matrix& xform, double weight = 0.0, double tolerance = .25);
-    STYLIZATION_API LineBuffer* TransformInstance(const SE_Matrix& xform);
-
+    
     STYLIZATION_API SE_INLINE bool& compute_bounds() { return m_compute_bounds; }
     STYLIZATION_API SE_INLINE LineBuffer* xf_buffer() { return (LineBuffer*)m_xf_buf; }
-    STYLIZATION_API SE_INLINE LineBuffer* inst_buffer() { return (LineBuffer*)m_inst_buf; }
     STYLIZATION_API SE_INLINE SE_Bounds* xf_bounds() { return m_xf_bounds; }
-    STYLIZATION_API SE_INLINE SE_Bounds* inst_bounds() { return m_inst_bounds; }
 
     STYLIZATION_API SE_LineBuffer* Clone();
 
@@ -97,9 +94,6 @@
     SE_Bounds* m_xf_bounds;
     SE_LineStorage* m_xf_buf;
 
-    SE_Bounds* m_inst_bounds;
-    SE_LineStorage* m_inst_buf;
-
     /* TODO: write a stack based allocator for this, or replace it */
     std::set<std::pair<double, double>, PointLess> m_ch_ptbuf;
 };

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-15 18:43:22 UTC (rev 1243)
@@ -235,7 +235,9 @@
             {
                 //ok, it's only a solid line, just draw it and bail out of the
                 //layout function
-                DrawScreenPolyline(geometry, rp->color, rp->weight);
+                SE_Matrix m;
+                GetWorldToScreenTransform(m);
+                DrawScreenPolyline(geometry, &m, rp->color, rp->weight);
                 return;
             }
         }
@@ -341,21 +343,21 @@
         {
             SE_RenderPolyline* pl = (SE_RenderPolyline*)primitive;
 
-            LineBuffer* geometry = pl->geometry->TransformInstance(posxform);
+            LineBuffer* geometry = pl->geometry->xf_buffer();
 
             if (m_bSelectionMode)
             {
                 if (primitive->type == SE_PolygonPrimitive)
-                    DrawScreenPolygon( geometry, m_selFill);
+                    DrawScreenPolygon( geometry, &posxform, m_selFill);
 
-                DrawScreenPolyline( geometry, m_selColor, m_selWeight );
+                DrawScreenPolyline( geometry, &posxform, m_selColor, m_selWeight );
             }
             else
             {
                 if (primitive->type == SE_PolygonPrimitive)
-                    DrawScreenPolygon( geometry, ((SE_RenderPolygon*)primitive)->fill );
+                    DrawScreenPolygon( geometry, &posxform, ((SE_RenderPolygon*)primitive)->fill );
 
-                DrawScreenPolyline( geometry, pl->color, pl->weight );
+                DrawScreenPolyline( geometry, &posxform, pl->color, pl->weight );
             }
         }
         else if (primitive->type == SE_TextPrimitive)

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.h	2007-03-15 16:46:45 UTC (rev 1242)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.h	2007-03-15 18:43:22 UTC (rev 1243)
@@ -36,8 +36,8 @@
 
     STYLIZATION_API virtual void DrawSymbol(SE_RenderPrimitiveList& symbol, const SE_Matrix& xform, double anglerad);
 
-    virtual void DrawScreenPolyline(LineBuffer* polyline, unsigned int color, double weight) = 0; // px
-    virtual void DrawScreenPolygon(LineBuffer* polygon, unsigned int fill) = 0;
+    virtual void DrawScreenPolyline(LineBuffer* polyline, const SE_Matrix* xform, unsigned int color, double weight) = 0; // px
+    virtual void DrawScreenPolygon(LineBuffer* polygon, const SE_Matrix* xform, unsigned int fill) = 0;
     virtual void DrawScreenRaster(unsigned char* data, int length, RS_ImageFormat format, int native_width, int native_height,
         double x, double y, double w, double h, double angledeg) = 0;
     virtual void DrawScreenText(const RS_String& txt, RS_TextDef& tdef, double insx, double insy, double* path, int npts, double param_position) = 0;



More information about the mapguide-commits mailing list