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

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Mar 21 16:22:21 EDT 2007


Author: traianstanev
Date: 2007-03-21 16:22:21 -0400 (Wed, 21 Mar 2007)
New Revision: 1320

Modified:
   trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
   trunk/MgDev/Common/Stylization/SE_StyleVisitor.h
   trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp
   trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h
Log:
Part 2 of fix for image resources. Also added support for image name being an expression and also fixed problems with fetching images when they are attached to the symbol definition resources.

Modified: trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp	2007-03-21 20:21:10 UTC (rev 1319)
+++ trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp	2007-03-21 20:22:21 UTC (rev 1320)
@@ -454,6 +454,10 @@
     SE_Raster* primitive = new SE_Raster();
     m_primitive = primitive;
 
+    //remember the parent symbol's res ID so that we can use it later for getting the raster data
+    //in case the image name is an expression
+    primitive->resId = m_resIdStack.back();
+
     if (image.GetContent().size())
     {
         /* Handle this; Base64 as MdfString is not a particularly inspired plan */
@@ -461,13 +465,10 @@
     }
     else
     {
-        //TODO: Disallow expressions for now since
-        //ParseStringExpression(image.GetReference(), primitive->pngPath);
-        primitive->pngPath = image.GetReference().c_str();
-        primitive->pngPath.expression = NULL;
+        ParseStringExpression(image.GetReference(), primitive->pngPath);
 
         if (primitive->pngPath.expression == NULL) // constant path
-            primitive->pngPtr = m_resources? m_resources->GetImageData(image.GetReference().c_str(), primitive->pngSize) : NULL;
+            primitive->pngPtr = m_resources? m_resources->GetImageData(primitive->resId, primitive->pngPath.value, primitive->pngSize) : NULL;
         else
             primitive->pngPtr = NULL;
     }
@@ -594,6 +595,8 @@
     {
         SimpleSymbol* sym = symbols->GetAt(i);
 
+        bool isRef = false;
+
         // get the symbol definition, either inlined or by reference
         SimpleSymbolDefinition* def = sym->GetSymbolDefinition();
         if (def == NULL)
@@ -605,12 +608,20 @@
             def = dynamic_cast<SimpleSymbolDefinition*>(m_resources->GetSymbolDefinition(ref.c_str()));
             if (def == NULL)
                 return;
+
+            //remember the current symbol resource id, in case it references an 
+            //attached png image resource
+            isRef = true;
+            m_resIdStack.push_back(ref.c_str());
         }
 
         VisitSimpleSymbolDefinition(*def);
 
         if (m_style)
             ParseIntegerExpression(sym->GetRenderingPass(), m_style->renderPass);
+
+        if (isRef)
+            m_resIdStack.pop_back();
     }
 }
 
@@ -619,6 +630,8 @@
     if (symbolization == NULL)
         return;
 
+    m_resIdStack.clear();
+
     SymbolInstanceCollection* symbols = symbolization->GetSymbolCollection();
     int nSymbols = symbols->GetCount();
 
@@ -628,6 +641,8 @@
 
         SetParameterValues(instance->GetParameterOverrides());
 
+        bool isRef = false;
+
         // get the symbol definition, either inlined or by reference
         SymbolDefinition* def = instance->GetSymbolDefinition();
         if (def == NULL)
@@ -639,6 +654,11 @@
             def = m_resources->GetSymbolDefinition(ref.c_str());
             if (def == NULL)
                 continue;
+
+            //remember the current symbol resource id, in case it references an 
+            //attached png image resource
+            isRef = true;
+            m_resIdStack.push_back(ref.c_str());
         }
 
         m_symbolization = new SE_Symbolization();
@@ -658,7 +678,10 @@
         ParseDoubleExpression(instance->GetInsertionOffsetY(), m_symbolization->absOffset[1]);
 
         def->AcceptVisitor(*this);
+        
+        result.push_back(m_symbolization);
 
-        result.push_back(m_symbolization);
+        if (isRef)
+            m_resIdStack.pop_back();
     }
 }

Modified: trunk/MgDev/Common/Stylization/SE_StyleVisitor.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_StyleVisitor.h	2007-03-21 20:21:10 UTC (rev 1319)
+++ trunk/MgDev/Common/Stylization/SE_StyleVisitor.h	2007-03-21 20:22:21 UTC (rev 1320)
@@ -64,6 +64,7 @@
     SE_Symbolization* m_symbolization;
     SE_Style* m_style;
     SE_Primitive* m_primitive;
+    std::vector<const wchar_t*> m_resIdStack;
 };
 
 #endif // SE_STYLEVISITOR_H

Modified: trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp	2007-03-21 20:21:10 UTC (rev 1319)
+++ trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp	2007-03-21 20:22:21 UTC (rev 1320)
@@ -257,7 +257,7 @@
 
     if (!pngPtr)
     {
-        ret->pngPtr = cxt->resources->GetImageData(pngPath.evaluate(cxt->exec), ret->pngSize);
+        ret->pngPtr = cxt->resources->GetImageData(resId, pngPath.evaluate(cxt->exec), ret->pngSize);
     }
     else
     {

Modified: trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h	2007-03-21 20:21:10 UTC (rev 1319)
+++ trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h	2007-03-21 20:22:21 UTC (rev 1320)
@@ -110,6 +110,7 @@
 struct SE_Raster : public SE_Primitive
 {
     SE_String pngPath;
+    const wchar_t* resId;
     const unsigned char* pngPtr;
     int pngSize;
     SE_Double position[2];



More information about the mapguide-commits mailing list