[mapguide-commits] r4241 -
branches/2.1/MgDev/Common/MapGuideCommon/MapLayer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Sep 21 11:26:01 EDT 2009
Author: uvlite
Date: 2009-09-21 11:26:01 -0400 (Mon, 21 Sep 2009)
New Revision: 4241
Modified:
branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.h
Log:
rfc60 add a new string based color table to the runtime map
Modified: branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp 2009-09-21 15:20:46 UTC (rev 4240)
+++ branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp 2009-09-21 15:26:01 UTC (rev 4241)
@@ -35,7 +35,8 @@
MgMap::MgMap()
: MgMapBase(),
m_inSave(false),
- m_unpackedLayersGroups(false)
+ m_unpackedLayersGroups(false),
+ m_colorPalette(new STRCOLORLIST())
{
}
@@ -46,7 +47,8 @@
MgMap::MgMap(MgSiteConnection* siteConnection)
: MgMapBase(),
m_inSave(false),
- m_unpackedLayersGroups(false)
+ m_unpackedLayersGroups(false),
+ m_colorPalette(new STRCOLORLIST())
{
if (NULL == siteConnection)
{
@@ -118,6 +120,14 @@
m_mapDefinitionId = SAFE_ADDREF(mapDefinition);
m_name = mapName;
+ // dont forget to reset the colorlist from our layers if there are any left - you never know
+ if (m_colorPalette && !m_colorPalette->empty())
+ {
+ m_colorPalette->clear();
+ delete m_colorPalette;
+ }
+ m_colorPalette = new STRCOLORLIST();
+
// generate a unique id for this map
MgUtil::GenerateUuid(m_objectId);
@@ -257,7 +267,7 @@
for(int i = 0; i < layers->GetCount(); i++, displayOrder += LAYER_ZORDER_INCR)
{
MapLayer* layer = (MapLayer*)layers->GetAt(i);
- //create a runtime layer from this layer and add it to the layer collection
+ //create a runtime layer from this layerDefinition and add it to the layer collection
//pull identity properties as a batch process after the layers are created
Ptr<MgResourceIdentifier> layerDefId = new MgResourceIdentifier(layer->GetLayerResourceID());
Ptr<MgLayerBase> rtLayer = new MgLayer(layerDefId, m_resourceService, false);
@@ -361,6 +371,7 @@
// attach the layer to its group
rtLayer->SetGroup(rtGroup);
+
}
}
}
@@ -400,6 +411,7 @@
// there's nothing to unpack anymore in this case
m_unpackedLayersGroups = true;
+
MG_CATCH_AND_THROW(L"MgMap.Create")
}
@@ -421,6 +433,7 @@
m_name = mapName;
MgMapBase::Create(mapSRS, mapExtent, mapName);
m_unpackedLayersGroups = true;
+ m_colorPalette = NULL;
}
@@ -597,12 +610,15 @@
//
MgMap::~MgMap()
{
+ if (m_colorPalette != NULL) m_colorPalette->clear(); // clear the STL container
+ delete m_colorPalette; // destroy the container
}
//////////////////////////////////////////////////////////////
void MgMap::Dispose()
{
+ if (m_colorPalette != NULL) m_colorPalette->clear(); // is this enough cleanup?
delete this;
}
@@ -1063,3 +1079,26 @@
}
}
}
+
+//////////////////////////////////////////////////////////////
+// ColorPalette Accessors
+// used for the map colors collected from the stylization of the visible layers
+PSTRCOLORLIST MgMap::GetColorPalette(CREFSTRING baseMapLayerGroupName)
+{
+ if (m_colorPalette == NULL)
+ m_colorPalette = new STRCOLORLIST();
+ return m_colorPalette;
+}
+/// setter does sort and prune the list also
+void MgMap::SetColorPalette(PSTRCOLORLIST newColorPalette, CREFSTRING baseMapLayerGroupName)
+{
+ // sort and delete duplicates if any coming in
+ if (newColorPalette != NULL && !newColorPalette->empty())
+ {
+ newColorPalette->sort();
+ newColorPalette->unique();
+ }
+ assert (m_colorPalette == newColorPalette); //make sure this is the same!
+ m_colorPalette = newColorPalette;
+}
+
Modified: branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.h
===================================================================
--- branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.h 2009-09-21 15:20:46 UTC (rev 4240)
+++ branches/2.1/MgDev/Common/MapGuideCommon/MapLayer/Map.h 2009-09-21 15:26:01 UTC (rev 4241)
@@ -22,21 +22,19 @@
/// \ingroup Maps_and_Layers_Module
/// \{
-/*TSW remove
#include "Foundation.h"
#include <vector>
#include <list>
#include <map>
-#include "LayerBase.h"
-#include "LayerGroup.h"
-#include "LayerCollection.h"
-#include "LayerGroupCollection.h"
-#include "MapCollection.h"
-#include "ObjectChange.h"
-#include "ChangeList.h"
-#include "ReadOnlyLayerCollection.h"
-#include "SelectionBase.h"
-*/
+//#include "LayerBase.h"
+//#include "LayerGroup.h"
+//#include "LayerCollection.h"
+//#include "LayerGroupCollection.h"
+//#include "MapCollection.h"
+//#include "ObjectChange.h"
+//#include "ChangeList.h"
+//#include "ReadOnlyLayerCollection.h"
+//#include "SelectionBase.h"
class MgMap;
class MgSiteConnection;
@@ -46,6 +44,8 @@
#undef CreateService
#endif
+// workaround for preprocessor include problems
+#include "../MdfModel/VectorLayerDefinition.h"
/////////////////////////////////////////////////////////////////
/// \brief
@@ -578,6 +578,10 @@
///
virtual void OnLayerParentChanged(MgLayerBase* layer, CREFSTRING parentId);
+ /// accessor for the colors as defined in the baseMap with given name
+ PSTRCOLORLIST GetColorPalette(CREFSTRING baseMapLayerGroupName=L"");
+ void SetColorPalette(PSTRCOLORLIST newColorPalette, CREFSTRING baseMapLayerGroupName=L"" );
+
//////////////////////////////////////////////////////////////////
/// Bulk load identity properties
///
@@ -636,6 +640,7 @@
Ptr<MgResourceService> m_resourceService;
bool m_inSave;
bool m_unpackedLayersGroups;
+ PSTRCOLORLIST m_colorPalette;
};
/// \}
More information about the mapguide-commits
mailing list