-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcenterlineview.h
227 lines (185 loc) · 7.14 KB
/
centerlineview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/* -*- c++ -*-
* centerlineview.h
*
* Header for the Centerline View classes
* Copyright (C) 2002 lignum Computing, Inc. <[email protected]>
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef CENTERLINEVIEW_H
#define CENTERLINEVIEW_H
#include <qdom.h>
#include "vectoralgebra.h"
#include "figureview.h"
#include <memory>
#include "centerlineinfodialog.h"
namespace Space2D {
class Page;
class Centerline;
class CenterlineView;
class DimensionView;
class CenterlineCreateInput : public InputObject {
Q_OBJECT
QMenu* context_menu_;
QAction* separator_id_;
Centerline* centerline_;
CenterlineView* centerline_view_;
Point start_;
static QChar centerline_symbol_;
public:
CenterlineCreateInput ( Centerline* centerline,
CenterlineView* centerline_view );
// Implemention of InputObject interface
SelectionType selectionType ( void ) const
{
return SelectionType( TRANSIENT, EDGE );
}
bool needsPrepressMouseCoordinates ( void ) const { return true; }
void startDisplay ( QMenu* context_menu );
void stopDisplay ( QMenu* /*context_menu*/ ) {}
void mousePrepress ( QMouseEvent* me, const SelectedNames& selected );
void mousePress ( QMouseEvent* me, const SelectedNames& selected );
void mouseDrag ( QMouseEvent* me, const SelectedNames& selected );
bool mouseRelease ( QMouseEvent* me, const SelectedNames& selected );
void mouseDoubleClick ( QMouseEvent* /*me*/ ) {}
void keyPress ( QKeyEvent* ke );
public slots:
void cancelOperation ( void );
};
class CenterlineModifyInput : public InputObject {
Q_OBJECT
SelectionType selection_type_;
Centerline* centerline_;
CenterlineView* centerline_view_;
GLuint drag_handle_;
double old_offset_;
Point start_pnt_;
Point last_pnt_;
Point current_pnt_;
QDomDocument* xml_rep_;
QDomElement from_ref_xml_;
public:
CenterlineModifyInput ( Centerline* centerline,
CenterlineView* centerline_view );
// Implemention of InputObject interface
SelectionType selectionType ( void ) const { return selection_type_; }
bool needsPrepressMouseCoordinates ( void ) const { return true; }
void startDisplay ( QMenu* /*context_menu*/ ) {}
void stopDisplay ( QMenu* /*context_menu*/ ) {}
void mousePrepress ( QMouseEvent* me, const SelectedNames& selected );
void mousePress ( QMouseEvent* me, const SelectedNames& selected );
void mouseDrag ( QMouseEvent* me, const SelectedNames& selected );
bool mouseRelease ( QMouseEvent* me, const SelectedNames& selected );
void mouseDoubleClick ( QMouseEvent* me );
void keyPress ( QKeyEvent* /*me*/ ) {}
// Other methods
void setCenterline ( Centerline* centerline );
public slots:
void cancelOperation ( void ) {}
};
class CenterlineView : public FigureView {
Q_OBJECT
Centerline* centerline_;
ListViewItem* list_view_item_;
ListViewItem* line_list_view_;
DimensionView* dimension_view_;
GraphicsView line_;
GraphicsView handle0_;
GraphicsView handle1_;
CenterlineCreateInput create_input_;
CenterlineModifyInput modify_input_;
QHash< int,GraphicsView > centerline_objects_;
QHash< int,std::shared_ptr<DimensionView> > dimensionview_objects_;
public:
CenterlineView ( Centerline* centerline, PageView* parent );
CenterlineView ( const QDomElement& xml_rep, PageView* parent );
CenterlineView ( const QString& name, const QDomElement& xml_rep,
Page* page, PageView* parent );
~CenterlineView ( void );
Centerline* centerline ( void ) const { return centerline_; }
// Implementation of GraphicsObject interface
void draw ( void ) const;
void select ( SelectionType select_type ) const;
// Implementation of FigureView interface
//! \return the list view item for this page view.
ListViewItem* listViewItem ( void ) const { return list_view_item_; }
uint id ( void ) const;
QString name ( void ) const;
QString type ( void ) const;
DBURL dbURL ( void ) const;
QString selectionText ( const std::vector<GLuint>& selection_name,
SelectionEntity entity ) const;
View* lookup ( QStringList& path_components ) const;
void setHighlighted ( bool highlight, SelectionEntity entity,
const std::vector<GLuint>& items );
void setActivated( bool activate, SelectionEntity entity,
const std::vector<GLuint>& items );
InputObject* createInput ( void ) { return &create_input_; }
InputObject* modifyInput ( void );
CreateObject* memento ( void );
uint dimensionPickCount ( void ) const { return 3; }
void setDimensionView ( const QDomElement& xml_rep );
void viewAttributeChanged ( void );
bool isGeometry ( GLuint selection_name ) const;
Curve* geometry ( GLuint selection_name ) const;
FigureBase* figure ( void ) const;
/*!
* Create an XML representation of this view (only) suitable for
* saving in a file with the rest of the model information.
* \param xml_rep the XML representation of the model to append
* this representation to.
*/
void write ( QDomElement& xml_rep ) const;
/*!
* Create an XML representation for this view *AND* its object suitable
* for use as a clipboard selection.
* \param xml_rep the XML representation of the selection to append
* this representation to.
*/
void copyWrite ( QDomElement& xml_rep ) const;
public:
// Other methods
void editInformation ( void );
void setCursor ( GLuint selection_name );
void setCursor ( const QCursor* cursor );
void unsetCursor ( void );
private:
static CenterlineInfoDialog* centerline_info_dialog_;
void init ( void );
void editCenterlineInformation ( void );
private slots:
/*!
* Set the centerline to the given name. Assumes this is an interactive
* modification and records an undo/redo command.
* \param name new name.
*/
void setName ( const QString& );
/*!
* The name in the list view has changed. This has to be checked for
* redundancy before it can be allowed.
* \param name new name for list view edit.
*/
void listNameChanged ( const QString& name );
void updateName ( const QString& name );
void modifiedConstraint ( void );
void modifiedPosition ( void );
void dmvRefModified ( void );
void destroyedDmVRef ( void );
void updateDimensionViews ( void );
};
} // End of Space2D namespace
#endif // CENTERLINEVIEW_H