source: git/src/model.h @ c63f69e

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

Move Model class to its own file

  • Property mode set to 100644
File size: 5.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 : 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
79    traverse()
80        : n_legs(0), flags(0),
81          length(0), E(-1), H(-1), V(-1) { }
82};
83
84/// Cave model.
85class Model {
86    list<traverse> traverses[8];
87    list<vector<XSect>> tubes;
88
89  public: // FIXME
90    list<LabelInfo*> m_Labels;
91
92  private:
93    Vector3 m_Ext;
94    double m_DepthMin, m_DepthExt;
95    int m_DateMin, m_DateExt;
96    bool complete_dateinfo;
97    int m_NumEntrances = 0;
98    int m_NumFixedPts = 0;
99    int m_NumExportedPts = 0;
100    bool m_HasUndergroundLegs = false;
101    bool m_HasSplays = false;
102    bool m_HasDupes = false;
103    bool m_HasSurfaceLegs = false;
104    bool m_HasErrorInformation = false;
105    bool m_IsExtendedElevation = false;
106
107    // Character separating survey levels (often '.')
108    wxChar m_separator;
109
110    wxString m_Title, m_cs_proj, m_DateStamp;
111
112    time_t m_DateStamp_numeric;
113
114    Vector3 m_Offset;
115
116  public:
117    int Load(const wxString& file, const wxString& prefix);
118
119    void CentreDataset(const Vector3& vmin);
120
121    const Vector3& GetExtent() const { return m_Ext; }
122
123    const wxString& GetSurveyTitle() const { return m_Title; }
124
125    const wxString& GetDateString() const { return m_DateStamp; }
126
127    time_t GetDateStamp() const { return m_DateStamp_numeric; }
128
129    double GetDepthExtent() const { return m_DepthExt; }
130    double GetDepthMin() const { return m_DepthMin; }
131
132    bool HasCompleteDateInfo() const { return complete_dateinfo; }
133    int GetDateExtent() const { return m_DateExt; }
134    int GetDateMin() const { return m_DateMin; }
135
136    int GetNumFixedPts() const { return m_NumFixedPts; }
137    int GetNumExportedPts() const { return m_NumExportedPts; }
138    int GetNumEntrances() const { return m_NumEntrances; }
139
140    bool HasUndergroundLegs() const { return m_HasUndergroundLegs; }
141    bool HasSplays() const { return m_HasSplays; }
142    bool HasDupes() const { return m_HasDupes; }
143    bool HasSurfaceLegs() const { return m_HasSurfaceLegs; }
144    bool HasTubes() const { return !tubes.empty(); }
145    bool HasErrorInformation() const { return m_HasErrorInformation; }
146
147    bool IsExtendedElevation() const { return m_IsExtendedElevation; }
148
149    wxChar GetSeparator() const { return m_separator; }
150
151    const wxString& GetCSProj() const { return m_cs_proj; }
152
153    const Vector3& GetOffset() const { return m_Offset; }
154
155    list<traverse>::const_iterator traverses_begin(unsigned flags) const {
156        if (flags >= sizeof(traverses)) return traverses[0].end();
157        return traverses[flags].begin();
158    }
159
160    list<traverse>::const_iterator traverses_end(unsigned flags) const {
161        if (flags >= sizeof(traverses)) flags = 0;
162        return traverses[flags].end();
163    }
164
165    list<vector<XSect> >::const_iterator tubes_begin() const {
166        return tubes.begin();
167    }
168
169    list<vector<XSect> >::const_iterator tubes_end() const {
170        return tubes.end();
171    }
172
173    list<vector<XSect> >::iterator tubes_begin() {
174        return tubes.begin();
175    }
176
177    list<vector<XSect> >::iterator tubes_end() {
178        return tubes.end();
179    }
180
181    list<LabelInfo*>::const_iterator GetLabels() const {
182        return m_Labels.begin();
183    }
184
185    list<LabelInfo*>::const_iterator GetLabelsEnd() const {
186        return m_Labels.end();
187    }
188
189    list<LabelInfo*>::const_reverse_iterator GetRevLabels() const {
190        return m_Labels.rbegin();
191    }
192
193    list<LabelInfo*>::const_reverse_iterator GetRevLabelsEnd() const {
194        return m_Labels.rend();
195    }
196
197    list<LabelInfo*>::iterator GetLabelsNC() {
198        return m_Labels.begin();
199    }
200
201    list<LabelInfo*>::iterator GetLabelsNCEnd() {
202        return m_Labels.end();
203    }
204};
205
206#endif
Note: See TracBrowser for help on using the repository browser.