VR-Forces 4.1 Class Documentation
baseSymbolMapper.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2001 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: baseSymbolMapper.h,v $ $Revision: 1.55 $ $State: Exp $
7 *********************************************************************/
8 
11 
12 #ifndef BASESYMBOLMAPPER_H
13 #define BASESYMBOLMAPPER_H
14 
16 #include "symbolMapper/mapReader.h"
17 #include "symbology/symbol.h"
19 #include "symbolDrawer/ttsDrawer.h"
21 #include "ngutil/orderedKeyList.h"
22 #include "geometry/point.h"
23 
24 #include <QtCore/QObject>
25 #include <QtCore/QHash>
26 #include <QtGui/QColor>
27 #include <QtGui/QPixmap>
28 
29 class DtSymbol;
30 class DtObjectType;
31 class DtSymbolDrawer;
32 class DtDrawerColl;
33 class DtModelData;
34 class DtBaseSymbolMapper;
35 class DtCompassModelData;
36 class DtDrawerKey;
37 class DtEntityMapperKey;
38 class DtCompositeSymbol;
39 class DtTTSSymbol;
40 class DtTerrainModelData;
41 class DtNameLabelSymbol;
43 
45 typedef DtSymbol* (*DtSymbolCreatorCallback)(const DtBaseSymbolMapper* mapper, const DtModelData& data, void* usr);
46 typedef void (*DtPostSymbolCreateCallbackFcn)(DtSymbol*, const DtModelData&, const DtBaseSymbolMapper*, void* usr);
47 
49 
50 const int DtCacheMainSymbolAsBitmap = 0x00000001;
51 const int DtCacheNameLabelAsBitmap = 0x00000002;
52 const int DtCacheLabelLabelAsBitmap = 0x00000004;
53 
55 {
56 public:
59  myCallback(orig.myCallback),
60  myUserData(orig.myUserData)
61  {
62  }
63 
64  virtual ~DtCreateCallbackInfo();
65 
66  virtual DtSymbolCreatorCallback callback();
67  virtual void* usertoLatin1();
68 
69 protected:
71  void* myUserData;
72 };
73 
74 typedef QHash<int, DtCreateCallbackInfo> DtSymbolCreators;
75 
77 {
78 public:
81  myCallback(orig.myCallback),
82  myUserData(orig.myUserData),
83  myType(orig.myType)
84  {
85  }
86 
87  virtual ~DtPostCreateCallbackInfo();
88 
89  virtual DtPostSymbolCreateCallbackFcn callback();
90  virtual void* usertoLatin1();
91  virtual int type();
92 
93 protected:
95  void* myUserData;
96  int myType;
97 };
98 
100 {
101 public:
104  myCallback(orig.myCallback) {};
105 
106  virtual ~DtMapReaderCallbackInfo();
107 
108  virtual DtMapReaderCreatorFcn callback();
109  virtual void setCallback(DtMapReaderCreatorFcn fcn);
110 
111 protected:
113 };
114 
115 typedef QHash<QString, DtMapReaderCallbackInfo> DtMapReaders;
116 
118 {
119 public:
120  DtObjectColor() : myColor(255, 0, 0) {};
121  DtObjectColor(const DtEntityMapperKey& key) : DtEntityMapperKey(key), myColor(255, 0, 0) {};
122  DtObjectColor(const DtObjectColor& c) : DtEntityMapperKey(c), myColor(c.myColor) {};
123 
124  QColor myColor;
125 };
126 
146 {
147  Q_OBJECT
148 
149 public:
151 
156 
157  virtual ~DtBaseSymbolMapper();
158 
161  virtual DtSymbol* createSymbol(const DtModelData& d);
162 
163  virtual void setDrawerColl(DtDrawerColl* dc);
164  virtual DtDrawerColl* drawerColl() const;
165 
167  virtual bool init();
168 
178  virtual bool load(const char* filename, bool replace = false);
179 
183  virtual bool save(const char* filename);
184 
185  virtual bool addSymbolToList(DtDescriptor* sd, bool replace = false);
186  virtual bool addSymbolToList(DtSymbolDescriptor* sd, bool replace = false);
187 
189  virtual DtSymbolDescriptor* getStringKeyedSymbolDesc(const QString& key) const;
190  virtual void addStringKeyedSymbolToList(DtSymbolDescriptor* desc);
191 
195  virtual void getSymbolDescriptors(DtSDList* list) const;
196 
199  virtual DtSymbolDescriptor* fullLookup(const QString& key) const;
200 
201  virtual DtSymbolDrawer* lookupDrawer(const DtDrawerKey& key, DtSymbolDescriptor* symDesc);
202  virtual DtSymbolDrawer* lookupDrawer(DtSymbolDescriptor* symDesc);
203 
204  virtual DtTTSDrawer& labelDrawer();
205  virtual QColor labelColor() const;
206 
208  virtual void removeEntries(const DtBaseSymbolMapper& mapper);
209  virtual void removeAllEntries(const DtSDList& mapper);
210 
212  virtual void removeEntry(DtSymbolDescriptor* sd);
213 
214  virtual const DtSDList& entities() const;
215 
216  virtual int defaultTransparencyFor(const DtEntityMapperKey& key) const;
217 
219  virtual void postLoadCleanup();
220 
222  virtual QPixmap getIcon(const DtModelData* d);
223  virtual void setIconSize(const QSize size);
224  virtual QSize iconSize() const;
225 
226  virtual QPixmap finalizeSymbolPixmap(const DtSymbol*) const;
227 
228  const QString& filename() const;
229 
230  virtual void clear();
231 
232 public:
234  virtual void addSymbolCreateCallback(int type, DtSymbolCreatorCallback fcn, void* usr = NULL);
235  virtual void removeSymbolCreateCallback(int type);
236 
237  virtual DtSymbolDescriptor* getSymbolDesc(const DtEntityMapperKey& key) const;
238  virtual DtSymbolDescriptor* getSymbolDesc(const DtModelData& data) const;
239 
240  virtual DtCompositeSymbol* createSymbolOfType(const DtEntityMapperKey& type,
241  int force, DtSymbolCreatorFcn fcn);
242 
245  virtual void addPostCreateCallback(int iType, DtPostSymbolCreateCallbackFcn fcn, void* usr);
246 
248  virtual void removePostCreateCallback(int iType, DtPostSymbolCreateCallbackFcn fcn, void* usr);
249 
252  virtual void removeAllPostCreateCallbacks();
253 
255  virtual DtSymbol* createMainSymbol(const DtEntityMapperKey& emk, int force);
256 
257 public:
258 
260  static DtBaseSymbolMapper* create();
261 
263  static void addReader(QString extension, DtMapReaderCreatorFcn fcn);
264 
267  static void cleanupReaders();
268 
269 public:
270  virtual DtMapReader* createReader(QString extension);
271 
273  virtual QColor defaultColorFor(const DtEntityMapperKey& key) const;
274  virtual QColor defaultColorFor(const DtModelData& data) const;
275 
276  virtual DtTTSSymbol* createLabelSymbol();
277 
278  //Since the base mapper loads the map readers, it also needs
279  //the media mappers so that it can pass it to it.
280  //Ideally however, I would not have the symbol mapper create the map
281  //reader. They should be separate.
282  virtual void setMediaMapper(DtBaseMapper* map);
283 
285  virtual void addColor(const DtEntityMapperKey&, const QColor&);
286 
287  virtual void addNameLabel(DtNameLabelSymbol* symbol);
288  virtual void addLabelLabel(DtNameLabelSymbol* symbol);
289 
290  virtual void chainSymbolMapper(DtBaseSymbolMapper*);
291 
292  virtual void clearCache();
293 
295  virtual void setDeleteChainedMappers(bool);
296  virtual bool deleteChainedMappers() const;
297 
300  virtual void setCacheSymbolOptions(int);
301  int cacheSymbolOptions() const;
302  virtual DtSymbol* createSymbolFromDescription(DtSymbolDescriptor* symDesc, const DtEntityMapperKey& key);
303 
304 public:
307  virtual DtEnvironmentalModelData* createObject(const QString& object, QVector<DtPoint>& points,
308  const QString& name = QString::null);
309 
310 public slots:
311  virtual void setLabelColor(const QColor& color);
312  virtual void setUsingAnimation(bool b);
313  virtual void removeChainedMapper(QObject*);
314 
315 signals:
316  void labelColorChanged(const QColor& color);
317 
318 protected:
319 
321  virtual void modifySymbol(DtSymbol* symbol, DtSymbolDescriptor* symDesc, int force, const DtEntityMapperKey& emk);
322 
323  virtual void removeEntry(DtSymbolDescriptor* sd, DtSDList& list);
324 
325  virtual void invokePostCreateCallbacks(DtSymbol*, const DtModelData&);
326 
327  virtual bool addEntry(DtSymbolDescriptor* sd, DtSDList& list, bool replace);
328 
329 private:
331  DtBaseSymbolMapper& operator=(const DtBaseSymbolMapper orig);
332 
333 protected:
338  QHash<QString, DtSymbolDescriptor*> myStringKeyedSDList;
339 
342 
345 
346  QColor myLabelColor;
347 
349 
351 
352  QSize myIconSize;
353  QHash<QString, QPixmap*> myIconCache;
354 
356 
357  static const QSize theDefaultIconSize;
358 
359  QString myFilename;
360 
362 
364  QString myComment;
365 
367 
371 };
372 
373 inline const QString& DtBaseSymbolMapper::filename() const
374 {
375  return myFilename;
376 }
377 
379 {
380  return myCacheSymbolOptions;
381 }
382 
383 #endif

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)