Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Layer.h
1 //
2 // Layer.h
3 //
4 // Copyright (c) 2001-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef LAYER_H
9 #define LAYER_H
10 
11 #include "vtdata/MathTypes.h"
12 #include "vtdata/vtString.h"
13 
14 enum LayerType
15 {
16  LT_UNKNOWN = -1,
17  LT_RAW,
18  LT_ELEVATION,
19  LT_IMAGE,
20  LT_ROAD,
21  LT_STRUCTURE,
22  LT_WATER,
23  LT_VEG,
24  LT_UTILITY,
25 #if SUPPORT_TRANSIT
26  LT_TRANSIT,
27 #endif
28  LAYER_TYPES
29 };
30 
31 class BuilderView;
32 class vtScaledView;
33 class vtProjection;
34 struct UIContext;
35 
42 class vtLayer
43 {
44 public:
45  vtLayer(LayerType type);
46  virtual ~vtLayer();
47 
48  // attributes
49  LayerType GetType() { return m_type; }
50  bool SetVisible(bool bVisible);
51  bool GetVisible() { return m_bVisible; }
52  void SetModified(bool bModified);
53  bool GetModified() { return m_bModified; }
54  void SetSticky(bool bSticky) { m_bSticky = bSticky; }
55  bool GetSticky() { return m_bSticky; }
56  bool IsNative() { return m_bNative; }
57 
58  wxString GetImportedFrom() { return m_wsImportedFrom; }
59  void SetImportedFrom(const wxString &fname) { m_wsImportedFrom = fname; }
60 
61  // operations
62  static vtLayer *CreateNewLayer(LayerType ltype);
63  bool Save(bool progress_callback(int) = NULL);
64  bool SaveAs(const wxString &filename = _T(""), bool progress_callback(int) = NULL);
65  bool Load(const wxString &filename = _T(""));
66 
67  // these must be implemented:
69  virtual bool GetExtent(DRECT &rect) = 0;
70  virtual void DrawLayer(wxDC *pDC, vtScaledView *pView) = 0;
72  virtual bool TransformCoords(vtProjection &proj) = 0;
73  virtual bool OnSave(bool progress_callback(int) = NULL) = 0;
74  virtual bool OnLoad() = 0;
76  virtual bool AppendDataFrom(vtLayer *pL) = 0;
78  virtual void GetProjection(vtProjection &proj) = 0;
80  virtual void SetProjection(const vtProjection &proj) = 0;
82  virtual void Offset(const DPoint2 &p);
83 
84  // these may be optionally implemented:
85  virtual bool SetExtent(const DRECT &rect) { return false; }
86  virtual void GetPropertyText(wxString &str) {}
87  virtual wxString GetFileExtension();
88  virtual bool CanBeSaved() { return true; }
89  virtual wxString GetLayerFilename() { return m_wsFilename; }
90  virtual void SetLayerFilename(const wxString &fname);
91  virtual bool AskForSaveFilename();
92  vtString GetExportFilename(const wxString &format_filter);
93  bool GetAreaExtent(DRECT &rect) { return GetExtent(rect); }
94 
95  // UI event handlers which can be implemented if desired
96  virtual void OnLeftDown(BuilderView *pView, UIContext &ui) {}
97  virtual void OnLeftUp(BuilderView *pView, UIContext &ui) {}
98  virtual void OnRightDown(BuilderView *pView, UIContext &ui) {}
99  virtual void OnRightUp(BuilderView *pView, UIContext &ui) {}
100  virtual void OnLeftDoubleClick(BuilderView *pView, UIContext &ui) {}
101  virtual void OnMouseMove(BuilderView *pView, UIContext &ui) {}
102 
103  static wxArrayString LayerTypeNames;
104  static const wxChar *LayerFileExtension[];
105 
106 protected:
107  wxString GetSaveFileDialogFilter();
108  void SetMessageText(const wxString &msg);
109 
110  // this filename is only used if the layer subclass doesn't have its own
111  wxString m_wsFilename;
112 
113  // remember what file this layer was imported from
114  wxString m_wsImportedFrom;
115 
116  LayerType m_type;
117  bool m_bVisible;
118  bool m_bModified;
119  bool m_bNative;
120  bool m_bSticky; // If sticky, don't page out the layer
121 };
122 
123 typedef vtLayer *vtLayerPtr;
124 
125 
126 //
127 // Name: LayerArray
128 // An array of layer objects.
129 //
130 class LayerArray : public vtArray<vtLayerPtr>
131 {
132 public:
133  // don't need explicit destructor here because Empty() is always called
134  virtual void DestructItems(uint first, uint last);
135  vtLayer *FindByFilename(const wxString &name);
136 };
137 
139 {
140 public:
141  DrawStyle();
142 
143  RGBi m_LineColor;
144  RGBi m_FillColor;
145  bool m_bFill;
146  int m_MarkerShape; // 0 = circle, 1 = crosshair, this should be an enum
147  int m_MarkerSize; // in pixels
148 };
149 
151 // Helpers
152 
153 wxString GetLayerTypeName(const LayerType &lype);
154 
155 #endif
156