[mapguide-commits] r4249 -
sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Sep 22 18:53:51 EDT 2009
Author: uvlite
Date: 2009-09-22 18:53:50 -0400 (Tue, 22 Sep 2009)
New Revision: 4249
Modified:
sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.h
Log:
rfc60 add a new string based color table to the runtime map
Modified: sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp 2009-09-22 06:48:50 UTC (rev 4248)
+++ sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp 2009-09-22 22:53:50 UTC (rev 4249)
@@ -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);
@@ -293,7 +303,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, false);
@@ -399,6 +409,7 @@
// attach the layer to its group
rtLayer->SetGroup(rtGroup);
+
}
}
}
@@ -438,6 +449,7 @@
// there's nothing to unpack anymore in this case
m_unpackedLayersGroups = true;
+
MG_CATCH_AND_THROW(L"MgMap.Create")
}
@@ -459,6 +471,7 @@
m_name = mapName;
MgMapBase::Create(mapSRS, mapExtent, mapName);
m_unpackedLayersGroups = true;
+ m_colorPalette = NULL;
}
@@ -635,12 +648,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;
}
@@ -1101,3 +1117,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: sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.h
===================================================================
--- sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.h 2009-09-22 06:48:50 UTC (rev 4248)
+++ sandbox/rfc60/MgDev/Common/MapGuideCommon/MapLayer/Map.h 2009-09-22 22:53:50 UTC (rev 4249)
@@ -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