[mapguide-commits] r7936 - in trunk/MgDev/Desktop: MgDesktop/Services/Rendering UnitTest
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Nov 27 05:01:45 PST 2013
Author: jng
Date: 2013-11-27 05:01:44 -0800 (Wed, 27 Nov 2013)
New Revision: 7936
Modified:
trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.cpp
trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.h
trunk/MgDev/Desktop/MgDesktop/Services/Rendering/icons.h
trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp
Log:
#2334: Port fixes to mg-desktop
Modified: trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.cpp
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.cpp 2013-11-27 12:35:03 UTC (rev 7935)
+++ trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.cpp 2013-11-27 13:01:44 UTC (rev 7936)
@@ -80,6 +80,9 @@
RS_LineStroke lineStroke;
dr.ProcessPolyline(&lb, lineStroke);
+ //Pad left at the top-level
+ legendOffsetX += (defaultLegendMargin * convertUnits);
+
//And then do the content.
BuildLegendContent(map, dMapScale, legendSpec, legendOffsetX, legendOffsetY, dr, convertUnits);
}
@@ -173,6 +176,29 @@
//bottom of the legend -- where we stop drawing
double bottomLimit = legendOffsetY + legendSpec->GetMarginBottom();
+ if (NULL != mggroup)
+ {
+ x = startX - initialMarginX;
+ // use group icon
+ RS_Bounds b2(x, y, x + dIconWidth, y + dIconHeight);
+ DrawPNG(&dr, (unsigned char*)LAYER_GROUP_ICON, sizeof(LAYER_GROUP_ICON), bitmapPixelWidth, bitmapPixelHeight, b2);
+
+ // Add the group legend label.
+ RS_LabelInfo info(x + dIconWidth + (defaultLegendMargin * convertUnits), y + legendTextVertAdjust*convertUnits, textDef);
+ dr.ProcessLabelGroup(&info, 1, mggroup->GetLegendLabel(), RS_OverpostType_All, false, NULL, 0.0);
+
+ // Indent for children
+ x += initialMarginX;
+
+ //move y cursor down one line
+ y -= verticalDelta;
+
+ if (y < bottomLimit)
+ {
+ return;
+ }
+ }
+
// build the list of layers that need to be processed
Ptr<MgLayerCollection> layers = map->GetLayers();
Ptr<MgStringCollection> layerIds = new MgStringCollection();
@@ -441,6 +467,29 @@
break;
}
}
+
+ //Process child groups of this legend
+ Ptr<MgLayerGroupCollection> groups = map->GetLayerGroups();
+ for (int i = 0; i < groups->GetCount(); i++)
+ {
+ Ptr<MgLayerGroup> group = groups->GetItem(i);
+ if (!group->GetDisplayInLegend())
+ continue;
+
+ Ptr<MgLayerGroup> groupParent = group->GetGroup();
+ if (groupParent.p == mggroup)
+ {
+ //If this group has no visible layers, skip it
+ if (!HasVisibleLayers(group->GetName(), visibleLayers, groupChildren))
+ continue;
+
+ ProcessLayersForLegend(map, mapScale, group, startX + initialMarginX, y, textDef, dr, legendSpec, legendOffsetY, convertUnits, visibleLayers, groupChildren);
+ if (y < bottomLimit)
+ {
+ break;
+ }
+ }
+ }
}
Modified: trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.h
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.h 2013-11-27 12:35:03 UTC (rev 7935)
+++ trunk/MgDev/Desktop/MgDesktop/Services/Rendering/LegendPlotUtil.h 2013-11-27 13:01:44 UTC (rev 7936)
@@ -96,8 +96,8 @@
const double legendSpacing = bitmapPixelHeight / bitmapDpi + 0.005;
const double defaultLegendMargin = 0.1; // inch
-const double legendFontHeightMeters = 0.002;
-const double legendTextVertAdjust = 0.07; // inch
+const double legendFontHeightMeters = 0.003;
+const double legendTextVertAdjust = 0.06; // inch
const double PrintLegendWidth = 2.0;
const double PrintLegendPadding = 0.1;
Modified: trunk/MgDev/Desktop/MgDesktop/Services/Rendering/icons.h
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/Rendering/icons.h 2013-11-27 12:35:03 UTC (rev 7935)
+++ trunk/MgDev/Desktop/MgDesktop/Services/Rendering/icons.h 2013-11-27 13:01:44 UTC (rev 7936)
@@ -125,4 +125,26 @@
0x82
};
+//lc_group.png
+const unsigned char LAYER_GROUP_ICON[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff,
+0x61, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
+0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00,
+0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0e, 0xc3, 0x00, 0x00, 0x0e, 0xc3, 0x01, 0xc7,
+0x6f, 0xa8, 0x64, 0x00, 0x00, 0x00, 0x1a, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77,
+0x61, 0x72, 0x65, 0x00, 0x50, 0x61, 0x69, 0x6e, 0x74, 0x2e, 0x4e, 0x45, 0x54, 0x20, 0x76, 0x33,
+0x2e, 0x35, 0x2e, 0x31, 0x30, 0x30, 0xf4, 0x72, 0xa1, 0x00, 0x00, 0x00, 0x84, 0x49, 0x44, 0x41,
+0x54, 0x38, 0x4f, 0x63, 0xf8, 0xff, 0xff, 0x3f, 0x45, 0x18, 0xab, 0x20, 0x29, 0x18, 0x4c, 0x1c,
+0x5c, 0xd3, 0xf2, 0xbf, 0x39, 0x92, 0x13, 0x03, 0x83, 0xc4, 0x91, 0x15, 0x63, 0xc3, 0x60, 0x02,
+0xa4, 0xf8, 0xff, 0xdb, 0x5e, 0x0c, 0x8c, 0x6e, 0x20, 0x32, 0x86, 0x19, 0x8e, 0x6a, 0xc0, 0x75,
+0x4b, 0x54, 0xfc, 0xa6, 0x03, 0xc3, 0x50, 0x10, 0xbe, 0xb4, 0x25, 0xe2, 0x7f, 0xa2, 0x21, 0x0b,
+0x61, 0x03, 0x90, 0x6d, 0xc4, 0x86, 0x31, 0x0c, 0xc0, 0x50, 0x80, 0x66, 0x20, 0x0c, 0x5f, 0xde,
+0x62, 0x89, 0xdd, 0x05, 0xe8, 0x9a, 0x40, 0x0a, 0xb1, 0xe1, 0x1d, 0xb3, 0x35, 0xf0, 0x1b, 0x80,
+0x4d, 0x13, 0x32, 0x1e, 0xee, 0x06, 0xc0, 0x14, 0x10, 0xc2, 0x28, 0x06, 0x80, 0x52, 0x15, 0x48,
+0x80, 0x14, 0xbc, 0x61, 0x46, 0x23, 0xc2, 0x00, 0x4a, 0x30, 0x56, 0x41, 0xe2, 0xf1, 0x7f, 0x06,
+0x00, 0x36, 0x20, 0xae, 0xaf, 0x57, 0x56, 0xf5, 0x08, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
+0x44, 0xae, 0x42, 0x60, 0x82
+};
+
#endif
Modified: trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp
===================================================================
--- trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp 2013-11-27 12:35:03 UTC (rev 7935)
+++ trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp 2013-11-27 13:01:44 UTC (rev 7936)
@@ -691,34 +691,58 @@
Ptr<MgLayerGroupCollection> layerGroups = map->GetLayerGroups();
Ptr<MgLayerCollection> layers = map->GetLayers();
- Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
+ Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
+ Ptr<MgResourceIdentifier> ldfRail = new MgResourceIdentifier(L"Library://UnitTests/Layers/Rail.LayerDefinition");
- Ptr<MgLayerGroup> group = new MgLayerGroup(L"Can't see me");
- group->SetLegendLabel(L"Can't see me");
+ Ptr<MgLayerGroup> group = new MgLayerGroup(L"Test Group");
+ group->SetLegendLabel(L"Test Group");
group->SetDisplayInLegend(true);
layerGroups->Add(group);
+ Ptr<MgLayerGroup> group1 = new MgLayerGroup(L"Nest top level");
+ group1->SetLegendLabel(L"Nest top level");
+ group1->SetDisplayInLegend(true);
+ layerGroups->Add(group1);
+
+ Ptr<MgLayerGroup> group2 = new MgLayerGroup(L"Nest child");
+ group2->SetLegendLabel(L"Nest child (Nest top level)");
+ group2->SetDisplayInLegend(true);
+ group2->SetGroup(group1);
+ layerGroups->Add(group2);
+
+ Ptr<MgLayerGroup> group3 = new MgLayerGroup(L"Not visible in legend");
+ group3->SetLegendLabel(L"Not visible in legend");
+ group3->SetDisplayInLegend(false);
+ layerGroups->Add(group3);
+
Ptr<MgdLayer> layer = new MgdLayer(resId, m_svcResource);
- layer->SetName(L"MyParcels");
- layer->SetLegendLabel(L"Parcels");
+ layer->SetName(L"HydroPolygons");
+ layer->SetLegendLabel(L"HydroPolygons (Test Group)");
layer->SetGroup(group);
layer->SetDisplayInLegend(true);
+ Ptr<MgdLayer> layer2 = new MgdLayer(ldfRail, m_svcResource);
+ layer2->SetName(L"RailUnderNestedGroup");
+ layer2->SetLegendLabel(L"Rail (Nest Child)");
+ layer2->SetGroup(group2);
+ layer2->SetDisplayInLegend(true);
+
layers->Add(layer);
+ layers->Add(layer2);
//Re-draw at 75k. Layer group should not be there because it has no visible layers
map->SetViewScale(75000.0);
- Ptr<MgByteReader> rdr3 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
- rdr3->ToFile(GetPath(L"../UnitTestFiles/RenderLegend75kWithEmptyLayerGroup", imageFormat, extension));
+ Ptr<MgByteReader> rdr3 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ rdr3->ToFile(GetPath(L"../UnitTestFiles/RenderLegend75kWithEmptyLayerGroup", imageFormat, extension));
//Re-draw at 14000. Layer group should still not be there because it has no visible layers
map->SetViewScale(14000.0);
- Ptr<MgByteReader> rdr4 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ Ptr<MgByteReader> rdr4 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
rdr4->ToFile(GetPath(L"../UnitTestFiles/RenderLegend14kWithEmptyLayerGroup", imageFormat, extension));
//Re-draw at 12000. Layer group should now be there because its child layer (Parcels) should be visible
map->SetViewScale(12000.0);
- Ptr<MgByteReader> rdr5 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ Ptr<MgByteReader> rdr5 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
rdr5->ToFile(GetPath(L"../UnitTestFiles/RenderLegend12kWithLayerGroup", imageFormat, extension));
}
catch (MgException* e)
More information about the mapguide-commits
mailing list