~ubuntu-branches/ubuntu/vivid/regina-normal/vivid

« back to all changes in this revision

Viewing changes to qtui/src/packettypes/nsnappeashapes.h

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2014-08-29 17:37:46 UTC
  • mfrom: (19.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140829173746-igmqc9b67y366a7u
Tags: 4.96-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/**************************************************************************
 
3
 *                                                                        *
 
4
 *  Regina - A Normal Surface Theory Calculator                           *
 
5
 *  Qt User Interface                                                     *
 
6
 *                                                                        *
 
7
 *  Copyright (c) 1999-2014, Ben Burton                                   *
 
8
 *  For further details contact Ben Burton (bab@debian.org).              *
 
9
 *                                                                        *
 
10
 *  This program is free software; you can redistribute it and/or         *
 
11
 *  modify it under the terms of the GNU General Public License as        *
 
12
 *  published by the Free Software Foundation; either version 2 of the    *
 
13
 *  License, or (at your option) any later version.                       *
 
14
 *                                                                        *
 
15
 *  As an exception, when this program is distributed through (i) the     *
 
16
 *  App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or     *
 
17
 *  (iii) Google Play by Google Inc., then that store may impose any      *
 
18
 *  digital rights management, device limits and/or redistribution        *
 
19
 *  restrictions that are required by its terms of service.               *
 
20
 *                                                                        *
 
21
 *  This program is distributed in the hope that it will be useful, but   *
 
22
 *  WITHOUT ANY WARRANTY; without even the implied warranty of            *
 
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 
24
 *  General Public License for more details.                              *
 
25
 *                                                                        *
 
26
 *  You should have received a copy of the GNU General Public             *
 
27
 *  License along with this program; if not, write to the Free            *
 
28
 *  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,       *
 
29
 *  MA 02110-1301, USA.                                                   *
 
30
 *                                                                        *
 
31
 **************************************************************************/
 
32
 
 
33
/* end stub */
 
34
 
 
35
/*! \file nsnappeashapes.h
 
36
 *  \brief Provides access to tetrahedron shapes and cusp data for
 
37
 *  SnapPea triangulations.
 
38
 */
 
39
 
 
40
#ifndef __NSNAPPEASHAPES_H
 
41
#define __NSNAPPEASHAPES_H
 
42
 
 
43
#include "../packettabui.h"
 
44
 
 
45
#include <QAbstractItemModel>
 
46
 
 
47
class EditTreeView;
 
48
class QAction;
 
49
class QToolBar;
 
50
class QTreeWidget;
 
51
class QTreeWidgetItem;
 
52
 
 
53
namespace regina {
 
54
    class NSnapPeaTriangulation;
 
55
};
 
56
 
 
57
/**
 
58
 * Note: We always allow editing the fillings in the cusp table.
 
59
 */
 
60
class CuspModel : public QAbstractItemModel {
 
61
    private:
 
62
        /**
 
63
         * Details of the cusps being displayed.
 
64
         */
 
65
        regina::NSnapPeaTriangulation* tri_;
 
66
 
 
67
    public:
 
68
        /**
 
69
         * Constructor and destructor.
 
70
         */
 
71
        CuspModel(regina::NSnapPeaTriangulation* tri);
 
72
 
 
73
        /**
 
74
         * Rebuild the model from scratch.
 
75
         */
 
76
        void rebuild();
 
77
 
 
78
        /**
 
79
         * Overrides for describing and editing data in the model.
 
80
         */
 
81
        QModelIndex index(int row, int column,
 
82
                const QModelIndex& parent) const;
 
83
        QModelIndex parent(const QModelIndex& index) const;
 
84
        int rowCount(const QModelIndex& parent) const;
 
85
        int columnCount(const QModelIndex& parent) const;
 
86
        QVariant data(const QModelIndex& index, int role) const;
 
87
        QVariant headerData(int section, Qt::Orientation orientation,
 
88
            int role) const;
 
89
        Qt::ItemFlags flags(const QModelIndex& index) const;
 
90
        bool setData(const QModelIndex& index, const QVariant& value, int role);
 
91
};
 
92
 
 
93
/**
 
94
 * A triangulation page for viewing normal surface properties.
 
95
 */
 
96
class NSnapPeaShapesUI : public QObject, public PacketEditorTab {
 
97
    Q_OBJECT
 
98
 
 
99
    private:
 
100
        /**
 
101
         * Packet details
 
102
         */
 
103
        CuspModel* model;
 
104
        regina::NSnapPeaTriangulation* tri;
 
105
 
 
106
        /**
 
107
         * Internal components
 
108
         */
 
109
        QWidget* ui;
 
110
        EditTreeView* cusps;
 
111
        QTreeWidget* shapes;
 
112
 
 
113
        /**
 
114
         * Actions
 
115
         */
 
116
        QAction* actRandomise;
 
117
        QAction* actFill;
 
118
        QAction* actToRegina;
 
119
        QLinkedList<QAction*> triActionList;
 
120
        QLinkedList<QAction*> enableWhenWritable;
 
121
        QLinkedList<QAction*> requiresNonNull;
 
122
 
 
123
    public:
 
124
        /**
 
125
         * Constructor and destructor.
 
126
         */
 
127
        NSnapPeaShapesUI(regina::NSnapPeaTriangulation* packet,
 
128
            PacketTabbedUI* useParentUI, bool readWrite);
 
129
        ~NSnapPeaShapesUI();
 
130
 
 
131
        /**
 
132
         * Fill the given toolbar with actions.
 
133
         *
 
134
         * This is necessary since the toolbar will not be a part of
 
135
         * this page, but this page (as the editor) keeps track of the
 
136
         * available actions.
 
137
         */
 
138
        void fillToolBar(QToolBar* bar);
 
139
 
 
140
        /**
 
141
         * PacketEditorTab overrides.
 
142
         */
 
143
        regina::NPacket* getPacket();
 
144
        QWidget* getInterface();
 
145
        const QLinkedList<QAction*>& getPacketTypeActions();
 
146
        void refresh();
 
147
        void endEdit();
 
148
        void setReadWrite(bool readWrite);
 
149
 
 
150
    public slots:
 
151
        /**
 
152
         * Actions.
 
153
         */
 
154
        void randomise();
 
155
        void vertexLinks();
 
156
        void canonise();
 
157
        void toRegina();
 
158
        void fill();
 
159
 
 
160
        /**
 
161
         * Update the states of internal components.
 
162
         */
 
163
        void updateNonNullActions();
 
164
};
 
165
 
 
166
inline CuspModel::CuspModel(regina::NSnapPeaTriangulation* tri) : tri_(tri) {
 
167
}
 
168
 
 
169
inline QModelIndex CuspModel::parent(const QModelIndex&) const {
 
170
    // All items are top-level.
 
171
    return QModelIndex();
 
172
}
 
173
 
 
174
#endif