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

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Mar 12 13:53:22 EDT 2007


Author: waltweltonlair
Date: 2007-03-12 13:53:22 -0400 (Mon, 12 Mar 2007)
New Revision: 1201

Modified:
   trunk/MgDev/Common/Stylization/GDRenderer.cpp
   trunk/MgDev/Common/Stylization/GDRenderer.h
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Common/Stylization/SE_Renderer.h
Log:
Add selection support for the new symbolization.  Selected features
using the new symbolization now draw highlighted.


Modified: trunk/MgDev/Common/Stylization/GDRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDRenderer.cpp	2007-03-12 17:12:43 UTC (rev 1200)
+++ trunk/MgDev/Common/Stylization/GDRenderer.cpp	2007-03-12 17:53:22 UTC (rev 1201)
@@ -128,7 +128,6 @@
 m_fcInfo(NULL),
 m_bRequiresClipping(requiresClipping),
 m_bLocalOverposting(localOverposting),
-m_bSelectionMode(false),
 m_bIsSymbolW2D(false),
 m_bHaveViewport(false),
 m_imsym(NULL),
@@ -367,6 +366,9 @@
 
 void GDRenderer::EndMap()
 {
+    // turn off selection mode so the labels draw normal
+    SetRenderSelectionMode(false);
+
     //finally draw all the labels
     m_labeler->BlastLabels();
 
@@ -1491,7 +1493,7 @@
 
 void GDRenderer::SetRenderSelectionMode(bool mode)
 {
-    m_bSelectionMode = mode;
+    SE_Renderer::SetRenderSelectionMode(mode);
 
     //initialize the selection styles if needed
     if (mode)

Modified: trunk/MgDev/Common/Stylization/GDRenderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/GDRenderer.h	2007-03-12 17:12:43 UTC (rev 1200)
+++ trunk/MgDev/Common/Stylization/GDRenderer.h	2007-03-12 17:53:22 UTC (rev 1201)
@@ -237,7 +237,6 @@
     void* m_imsym;
     int m_lineColor;
 
-    bool m_bSelectionMode;
     RS_FillStyle m_selFill;
 
     LabelRendererBase* m_labeler;

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-12 17:12:43 UTC (rev 1200)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-12 17:53:22 UTC (rev 1201)
@@ -23,11 +23,40 @@
 
 using namespace MDFMODEL_NAMESPACE;
 
+SE_Renderer::SE_Renderer()
+: m_bSelectionMode(false)
+, m_selWeight(0.0)
+, m_selColor(0)
+, m_selFill(0)
+, m_textForeColor(0)
+, m_textBackColor(0)
+{
+}
+
+SE_Renderer::~SE_Renderer()
+{
+}
+
 void SE_Renderer::SetLineBufferPool(SE_LineBufferPool* pool)
 {
     m_lbp = pool;
 }
 
+void SE_Renderer::SetRenderSelectionMode(bool mode)
+{
+    m_bSelectionMode = mode;
+
+    if (mode)
+    {
+        // set the default selection style - 1mm line weight, partially transparent blue
+        m_selWeight = 3.0;  // should be 1 to give 1mm, but the renderer is way off
+        m_selColor = RS_Color(0, 0, 255, 200).argb();
+        m_selFill = RS_Color(0, 0, 255, 160).argb();
+        m_textForeColor = RS_Color(0, 0, 255, 200);
+        m_textBackColor = RS_Color(0, 0, 255, 255);
+    }
+}
+
 void SE_Renderer::ProcessPoint(LineBuffer* geometry, SE_RenderPointStyle* style)
 {
     SE_Matrix xform;
@@ -150,10 +179,20 @@
 
             LineBuffer* geometry = pl->geometry->TransformInstance(posxform);
 
-            if (primitive->type == SE_PolygonPrimitive)
-                DrawScreenPolygon( geometry, ((SE_RenderPolygon*)primitive)->fill );
+            if (m_bSelectionMode)
+            {
+                if (primitive->type == SE_PolygonPrimitive)
+                    DrawScreenPolygon( geometry, m_selFill);
 
+                DrawScreenPolyline( geometry, m_selColor, m_selWeight );
+            }
+            else
+            {
+                if (primitive->type == SE_PolygonPrimitive)
+                    DrawScreenPolygon( geometry, ((SE_RenderPolygon*)primitive)->fill );
+
                 DrawScreenPolyline( geometry, pl->color, pl->weight );
+            }
         }
         else if (primitive->type == SE_TextPrimitive)
         {
@@ -164,12 +203,21 @@
             double x, y;
             posxform.transform(tp->position[0], tp->position[1], x, y);
 
-            if (anglerad != 0)
+            if (m_bSelectionMode)
             {
-                RS_TextDef tdef2 = tp->tdef;
-                tdef2.rotation() = anglerad * (180 / M_PI);
-                DrawScreenText(tp->text, tdef2, x, y, NULL, 0, 0.0);
+                RS_TextDef tdef = tp->tdef;
+                tdef.color() = m_textForeColor;
+                tdef.bgcolor() = m_textBackColor;
+                if (anglerad != 0)
+                    tdef.rotation() = anglerad * (180 / M_PI);
+                DrawScreenText(tp->text, tdef, x, y, NULL, 0, 0.0);
             }
+            else if (anglerad != 0.0)
+            {
+                RS_TextDef tdef = tp->tdef;
+                tdef.rotation() = anglerad * (180.0 / M_PI);
+                DrawScreenText(tp->text, tdef, x, y, NULL, 0, 0.0);
+            }
             else
             {
                 DrawScreenText(tp->text, tp->tdef, x, y, NULL, 0, 0.0);

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.h	2007-03-12 17:12:43 UTC (rev 1200)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.h	2007-03-12 17:53:22 UTC (rev 1201)
@@ -25,6 +25,9 @@
 class SE_Renderer
 {
 public:
+    STYLIZATION_API SE_Renderer();
+    STYLIZATION_API ~SE_Renderer();
+
     void SetLineBufferPool(SE_LineBufferPool* pool);
     /* SE_RenderSymbol, under associated xform, is in screen space, and geometry is in screen space */
     STYLIZATION_API virtual void ProcessPoint(LineBuffer* geometry, SE_RenderPointStyle* style);
@@ -35,7 +38,7 @@
 
     virtual void DrawScreenPolyline(LineBuffer* polyline, unsigned int color, double weight) = 0; // px
     virtual void DrawScreenPolygon(LineBuffer* polygon, unsigned int fill) = 0;
-    virtual void DrawScreenRaster(unsigned char* data, int length, RS_ImageFormat format, int native_width, int native_height, 
+    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;
 
@@ -61,16 +64,25 @@
     //sigh
     const RS_F_Point* GetLastExclusionRegion() { return m_lastExclusionRegion; }
 
+protected:
+    void SetRenderSelectionMode(bool mode);
+
 private:
     void AddLabel(LineBuffer* geom, SE_RenderStyle* style, SE_Matrix& xform, double angle);
-    
+
     void AddExclusionRegion(SE_RenderStyle* rstyle, SE_Matrix& xform, double angle);
 
     RS_F_Point m_lastExclusionRegion[4];
-    
+
 protected:
     SE_LineBufferPool* m_lbp;
-    
+    bool m_bSelectionMode;
+
+    double m_selWeight;
+    unsigned int m_selColor;
+    unsigned int m_selFill;
+    RS_Color m_textForeColor;
+    RS_Color m_textBackColor;
 };
 
 #endif // SE_RENDERER_H



More information about the mapguide-commits mailing list