source: git/src/labelinfo.h @ a6401ff3

RELEASE/1.2debug-cidebug-ci-sanitiserswalls-data
Last change on this file since a6401ff3 was a6401ff3, checked in by Olly Betts <olly@…>, 5 years ago

Improve handling of hidden splay ends

Previously, hidden splay ends still served as "targets" for snapping
the mouse pointer to, and still got crosses when crosses were
enabled.

We don't have a handy flag for "this is the outer end of a splay"
and computing that on demand isn't so easy to do, so for now we
use the "anonymous station" flag so at least these cases now behave
properly for splays to anonymous stations (which is likely to be
what people with huge numbers of splays from disto-x, etc are
using). This does mean that anonymous stations on continuation
passages will incorrectly also be off when splays are hidden, but
that seems an OK trade-off for now.

The snapping of the mouse pointer was reported by Frank Tully in #105.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1//
2//  labelinfo.h
3//
4//  Main frame handling for Aven.
5//
6//  Copyright (C) 2000-2003,2005 Mark R. Shinwell
7//  Copyright (C) 2001-2003,2004,2005,2006,2010,2011,2012,2013,2014 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 labelinfo_h
25#define labelinfo_h
26
27#include "aven.h"
28#include "img_hosted.h"
29#include "message.h"
30#include "vector3.h"
31#include "wx.h"
32
33// Mac OS X headers pollute the global namespace with generic names like
34// "class Point", which clashes with our "class Point".  So for __WXMAC__
35// put our class in a namespace and define Point as a macro.
36#ifdef __WXMAC__
37namespace svx {
38#endif
39
40class Point : public Vector3 {
41  public:
42    Point() {}
43    explicit Point(const Vector3 & v) : Vector3(v) { }
44    explicit Point(const img_point & pt) : Vector3(pt.x, pt.y, pt.z) { }
45    double GetX() const { return x; }
46    double GetY() const { return y; }
47    double GetZ() const { return z; }
48};
49
50#ifdef __WXMAC__
51}
52#define Point svx::Point
53#endif
54
55#define LFLAG_NOT_ANON          0x01
56#define LFLAG_NOT_WALL          0x02
57#define LFLAG_SURFACE           0x04
58#define LFLAG_UNDERGROUND       0x08
59#define LFLAG_EXPORTED          0x10
60#define LFLAG_FIXED             0x20
61#define LFLAG_ENTRANCE          0x40
62#define LFLAG_HIGHLIGHTED       0x80
63
64class LabelInfo : public Point {
65    wxString text;
66    unsigned width;
67    int flags;
68
69public:
70    wxTreeItemId tree_id;
71
72    LabelInfo() : Point(), text(), flags(0) { }
73    LabelInfo(const img_point &pt, const wxString &text_, int flags_)
74        : Point(pt), text(text_), flags(flags_) {
75        if (text.empty())
76            flags &= ~LFLAG_NOT_ANON;
77    }
78    const wxString & GetText() const { return text; }
79    wxString name_or_anon() const {
80        if (!text.empty()) return text;
81        /* TRANSLATORS: Used in place of the station name when talking about an
82         * anonymous station. */
83        return wmsg(/*anonymous station*/56);
84    }
85    int get_flags() const { return flags; }
86    void set_flags(int mask) { flags |= mask; }
87    void clear_flags(int mask) { flags &= ~mask; }
88    unsigned get_width() const { return width; }
89    void set_width(unsigned width_) { width = width_; }
90
91    bool IsEntrance() const { return (flags & LFLAG_ENTRANCE) != 0; }
92    bool IsFixedPt() const { return (flags & LFLAG_FIXED) != 0; }
93    bool IsExportedPt() const { return (flags & LFLAG_EXPORTED) != 0; }
94    bool IsUnderground() const { return (flags & LFLAG_UNDERGROUND) != 0; }
95    bool IsSurface() const { return (flags & LFLAG_SURFACE) != 0; }
96    bool IsHighLighted() const { return (flags & LFLAG_HIGHLIGHTED) != 0; }
97    bool IsAnon() const { return (flags & LFLAG_NOT_ANON) == 0; }
98    bool IsWall() const { return (flags & LFLAG_NOT_WALL) == 0; }
99    // This should really also return true for non-anonymous splay ends, and not
100    // return true for anonymous stations in other situations, but the .3d
101    // format doesn't tell us this information currently, and it's not trivial
102    // to rediscover.
103    bool IsSplayEnd() const { return IsAnon(); }
104};
105
106#endif
Note: See TracBrowser for help on using the repository browser.