source: git/src/model.h @ 672459c

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

Hook up multi-select in survey tree

Filtering works for everthing except exporting.

  • Property mode set to 100644
File size: 6.7 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 {
52    friend class MainFrm;
53    const LabelInfo* stn;
54    int date;
55    double l, r, u, d;
56    double right_bearing;
57
58public:
59    XSect(const LabelInfo* stn_, int date_,
60          double l_, double r_, double u_, double d_)
61        : stn(stn_), date(date_), l(l_), r(r_), u(u_), d(d_), right_bearing(0) { }
62    double GetL() const { return l; }
63    double GetR() const { return r; }
64    double GetU() const { return u; }
65    double GetD() const { return d; }
66    double get_right_bearing() const { return right_bearing; }
67    void set_right_bearing(double right_bearing_) {
68        right_bearing = right_bearing_;
69    }
70    int GetDate() const { return date; }
71    wxString GetLabel() const { return stn->GetText(); }
72    const Point& GetPoint() const { return *stn; }
73    double GetX() const { return stn->GetX(); }
74    double GetY() const { return stn->GetY(); }
75    double GetZ() const { return stn->GetZ(); }
76    friend Vector3 operator-(const XSect& a, const XSect& b);
77};
78
79inline Vector3 operator-(const XSect& a, const XSect& b) {
80    return *(a.stn) - *(b.stn);
81}
82
83class traverse : public vector<PointInfo> {
84  public:
85    int n_legs;
86    // Bitmask of img_FLAG_SURFACE, img_FLAG_SPLAY and img_FLAG_DUPLICATE.
87    int flags;
88    double length;
89    double E, H, V;
90    wxString name;
91
92    explicit
93    traverse(const char* name_)
94        : n_legs(0), flags(0),
95          length(0), E(-1), H(-1), V(-1),
96          name(name_, wxConvUTF8) {
97        if (name.empty() && !name_[0]) {
98            // If name isn't valid UTF-8 then this conversion will
99            // give an empty string.  In this case, assume that the
100            // label is CP1252 (the Microsoft superset of ISO8859-1).
101            static wxCSConv ConvCP1252(wxFONTENCODING_CP1252);
102            name = wxString(name_, ConvCP1252);
103            if (name.empty()) {
104                // Or if that doesn't work (ConvCP1252 doesn't like
105                // strings with some bytes in) let's just go for
106                // ISO8859-1.
107                name = wxString(name_, wxConvISO8859_1);
108            }
109        }
110    }
111};
112
113/// Cave model.
114class Model {
115    list<traverse> traverses[8];
116    list<vector<XSect>> tubes;
117
118  public: // FIXME
119    list<LabelInfo*> m_Labels;
120
121  private:
122    Vector3 m_Ext;
123    double m_DepthMin, m_DepthExt;
124    int m_DateMin, m_DateExt;
125    bool complete_dateinfo;
126    int m_NumEntrances = 0;
127    int m_NumFixedPts = 0;
128    int m_NumExportedPts = 0;
129    bool m_HasUndergroundLegs = false;
130    bool m_HasSplays = false;
131    bool m_HasDupes = false;
132    bool m_HasSurfaceLegs = false;
133    bool m_HasErrorInformation = false;
134    bool m_IsExtendedElevation = false;
135
136    // Character separating survey levels (often '.')
137    wxChar m_separator;
138
139    wxString m_Title, m_cs_proj, m_DateStamp;
140
141    time_t m_DateStamp_numeric;
142
143    Vector3 m_Offset;
144
145  public:
146    int Load(const wxString& file, const wxString& prefix);
147
148    void CentreDataset(const Vector3& vmin);
149
150    const Vector3& GetExtent() const { return m_Ext; }
151
152    const wxString& GetSurveyTitle() const { return m_Title; }
153
154    const wxString& GetDateString() const { return m_DateStamp; }
155
156    time_t GetDateStamp() const { return m_DateStamp_numeric; }
157
158    double GetDepthExtent() const { return m_DepthExt; }
159    double GetDepthMin() const { return m_DepthMin; }
160
161    bool HasCompleteDateInfo() const { return complete_dateinfo; }
162    int GetDateExtent() const { return m_DateExt; }
163    int GetDateMin() const { return m_DateMin; }
164
165    int GetNumFixedPts() const { return m_NumFixedPts; }
166    int GetNumExportedPts() const { return m_NumExportedPts; }
167    int GetNumEntrances() const { return m_NumEntrances; }
168
169    bool HasUndergroundLegs() const { return m_HasUndergroundLegs; }
170    bool HasSplays() const { return m_HasSplays; }
171    bool HasDupes() const { return m_HasDupes; }
172    bool HasSurfaceLegs() const { return m_HasSurfaceLegs; }
173    bool HasTubes() const { return !tubes.empty(); }
174    bool HasErrorInformation() const { return m_HasErrorInformation; }
175
176    bool IsExtendedElevation() const { return m_IsExtendedElevation; }
177
178    wxChar GetSeparator() const { return m_separator; }
179
180    const wxString& GetCSProj() const { return m_cs_proj; }
181
182    const Vector3& GetOffset() const { return m_Offset; }
183
184    list<traverse>::const_iterator traverses_begin(unsigned flags) const {
185        if (flags >= sizeof(traverses)) return traverses[0].end();
186        return traverses[flags].begin();
187    }
188
189    list<traverse>::const_iterator traverses_end(unsigned flags) const {
190        if (flags >= sizeof(traverses)) flags = 0;
191        return traverses[flags].end();
192    }
193
194    list<vector<XSect> >::const_iterator tubes_begin() const {
195        return tubes.begin();
196    }
197
198    list<vector<XSect> >::const_iterator tubes_end() const {
199        return tubes.end();
200    }
201
202    list<vector<XSect> >::iterator tubes_begin() {
203        return tubes.begin();
204    }
205
206    list<vector<XSect> >::iterator tubes_end() {
207        return tubes.end();
208    }
209
210    list<LabelInfo*>::const_iterator GetLabels() const {
211        return m_Labels.begin();
212    }
213
214    list<LabelInfo*>::const_iterator GetLabelsEnd() const {
215        return m_Labels.end();
216    }
217
218    list<LabelInfo*>::const_reverse_iterator GetRevLabels() const {
219        return m_Labels.rbegin();
220    }
221
222    list<LabelInfo*>::const_reverse_iterator GetRevLabelsEnd() const {
223        return m_Labels.rend();
224    }
225
226    list<LabelInfo*>::iterator GetLabelsNC() {
227        return m_Labels.begin();
228    }
229
230    list<LabelInfo*>::iterator GetLabelsNCEnd() {
231        return m_Labels.end();
232    }
233};
234
235#endif
Note: See TracBrowser for help on using the repository browser.