source: git/src/model.h @ 49c58872

RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereostereo-2025walls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change on this file since 49c58872 was 49c58872, checked in by Olly Betts <olly@…>, 7 years ago

Store survey name in traverse class

This requires we split traverses where the survey name changes.

  • Property mode set to 100644
File size: 6.3 KB
Line 
1//
2//  model.h
3//
4//  Cave survey model.
5//
6//  Copyright (C) 2000-2003,2005 Mark R. Shinwell
7//  Copyright (C) 2001-2003,2004,2005,2006,2010,2011,2012,2013,2014,2015,2016 Olly Betts
8//
9//  This program is free software; you can redistribute it and/or modify
10//  it under the terms of the GNU General Public License as published by
11//  the Free Software Foundation; either version 2 of the License, or
12//  (at your option) any later version.
13//
14//  This program is distributed in the hope that it will be useful,
15//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17//  GNU General Public License for more details.
18//
19//  You should have received a copy of the GNU General Public License
20//  along with this program; if not, write to the Free Software
21//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22//
23
24#ifndef model_h
25#define model_h
26
27#include "wx.h"
28
29#include "labelinfo.h"
30#include "vector3.h"
31
32#include <ctime>
33#include <list>
34#include <vector>
35
36using namespace std;
37
38class MainFrm;
39
40class PointInfo : public Point {
41    int date;
42
43public:
44    PointInfo() : Point(), date(-1) { }
45    explicit PointInfo(const img_point & pt) : Point(pt), date(-1) { }
46    PointInfo(const img_point & pt, int date_) : Point(pt), date(date_) { }
47    PointInfo(const Point & p, int date_) : Point(p), date(date_) { }
48    int GetDate() const { return date; }
49};
50
51class XSect : public PointInfo {
52    friend class MainFrm;
53    double l, r, u, d;
54    double right_bearing;
55
56public:
57    XSect() : PointInfo(), l(0), r(0), u(0), d(0), right_bearing(0) { }
58    XSect(const Point &p, int date_,
59          double l_, double r_, double u_, double d_)
60        : PointInfo(p, date_), l(l_), r(r_), u(u_), d(d_), right_bearing(0) { }
61    double GetL() const { return l; }
62    double GetR() const { return r; }
63    double GetU() const { return u; }
64    double GetD() const { return d; }
65    double get_right_bearing() const { return right_bearing; }
66    void set_right_bearing(double right_bearing_) {
67        right_bearing = right_bearing_;
68    }
69};
70
71class traverse : public vector<PointInfo> {
72  public:
73    int n_legs;
74    // Bitmask of img_FLAG_SURFACE, img_FLAG_SPLAY and img_FLAG_DUPLICATE.
75    int flags;
76    double length;
77    double E, H, V;
78    wxString name;
79
80    explicit
81    traverse(const char* name_)
82        : n_legs(0), flags(0),
83          length(0), E(-1), H(-1), V(-1),
84          name(name_, wxConvUTF8) {
85        if (name.empty() && !name_[0]) {
86            // If name isn't valid UTF-8 then this conversion will
87            // give an empty string.  In this case, assume that the
88            // label is CP1252 (the Microsoft superset of ISO8859-1).
89            static wxCSConv ConvCP1252(wxFONTENCODING_CP1252);
90            name = wxString(name_, ConvCP1252);
91            if (name.empty()) {
92                // Or if that doesn't work (ConvCP1252 doesn't like
93                // strings with some bytes in) let's just go for
94                // ISO8859-1.
95                name = wxString(name_, wxConvISO8859_1);
96            }
97        }
98    }
99};
100
101/// Cave model.
102class Model {
103    list<traverse> traverses[8];
104    list<vector<XSect>> tubes;
105
106  public: // FIXME
107    list<LabelInfo*> m_Labels;
108
109  private:
110    Vector3 m_Ext;
111    double m_DepthMin, m_DepthExt;
112    int m_DateMin, m_DateExt;
113    bool complete_dateinfo;
114    int m_NumEntrances = 0;
115    int m_NumFixedPts = 0;
116    int m_NumExportedPts = 0;
117    bool m_HasUndergroundLegs = false;
118    bool m_HasSplays = false;
119    bool m_HasDupes = false;
120    bool m_HasSurfaceLegs = false;
121    bool m_HasErrorInformation = false;
122    bool m_IsExtendedElevation = false;
123
124    // Character separating survey levels (often '.')
125    wxChar m_separator;
126
127    wxString m_Title, m_cs_proj, m_DateStamp;
128
129    time_t m_DateStamp_numeric;
130
131    Vector3 m_Offset;
132
133  public:
134    int Load(const wxString& file, const wxString& prefix);
135
136    void CentreDataset(const Vector3& vmin);
137
138    const Vector3& GetExtent() const { return m_Ext; }
139
140    const wxString& GetSurveyTitle() const { return m_Title; }
141
142    const wxString& GetDateString() const { return m_DateStamp; }
143
144    time_t GetDateStamp() const { return m_DateStamp_numeric; }
145
146    double GetDepthExtent() const { return m_DepthExt; }
147    double GetDepthMin() const { return m_DepthMin; }
148
149    bool HasCompleteDateInfo() const { return complete_dateinfo; }
150    int GetDateExtent() const { return m_DateExt; }
151    int GetDateMin() const { return m_DateMin; }
152
153    int GetNumFixedPts() const { return m_NumFixedPts; }
154    int GetNumExportedPts() const { return m_NumExportedPts; }
155    int GetNumEntrances() const { return m_NumEntrances; }
156
157    bool HasUndergroundLegs() const { return m_HasUndergroundLegs; }
158    bool HasSplays() const { return m_HasSplays; }
159    bool HasDupes() const { return m_HasDupes; }
160    bool HasSurfaceLegs() const { return m_HasSurfaceLegs; }
161    bool HasTubes() const { return !tubes.empty(); }
162    bool HasErrorInformation() const { return m_HasErrorInformation; }
163
164    bool IsExtendedElevation() const { return m_IsExtendedElevation; }
165
166    wxChar GetSeparator() const { return m_separator; }
167
168    const wxString& GetCSProj() const { return m_cs_proj; }
169
170    const Vector3& GetOffset() const { return m_Offset; }
171
172    list<traverse>::const_iterator traverses_begin(unsigned flags) const {
173        if (flags >= sizeof(traverses)) return traverses[0].end();
174        return traverses[flags].begin();
175    }
176
177    list<traverse>::const_iterator traverses_end(unsigned flags) const {
178        if (flags >= sizeof(traverses)) flags = 0;
179        return traverses[flags].end();
180    }
181
182    list<vector<XSect> >::const_iterator tubes_begin() const {
183        return tubes.begin();
184    }
185
186    list<vector<XSect> >::const_iterator tubes_end() const {
187        return tubes.end();
188    }
189
190    list<vector<XSect> >::iterator tubes_begin() {
191        return tubes.begin();
192    }
193
194    list<vector<XSect> >::iterator tubes_end() {
195        return tubes.end();
196    }
197
198    list<LabelInfo*>::const_iterator GetLabels() const {
199        return m_Labels.begin();
200    }
201
202    list<LabelInfo*>::const_iterator GetLabelsEnd() const {
203        return m_Labels.end();
204    }
205
206    list<LabelInfo*>::const_reverse_iterator GetRevLabels() const {
207        return m_Labels.rbegin();
208    }
209
210    list<LabelInfo*>::const_reverse_iterator GetRevLabelsEnd() const {
211        return m_Labels.rend();
212    }
213
214    list<LabelInfo*>::iterator GetLabelsNC() {
215        return m_Labels.begin();
216    }
217
218    list<LabelInfo*>::iterator GetLabelsNCEnd() {
219        return m_Labels.end();
220    }
221};
222
223#endif
Note: See TracBrowser for help on using the repository browser.