Debian Codegraph @

vcg/wrap/gui/rubberband.h

raw symbols SCIP
1 /****************************************************************************
2 * MeshLab o o *
3 * A versatile mesh processing toolbox o o *
4 * _ O _ *
5 * Copyright(C) 2008 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 /****************************************************************************
24 History
25 $Log: rubberband.h,v $
26 Revision 1.2 2008/03/11 09:08:46 benedetti
27 Added doxygen documentation
28
29 Revision 1.1 2008/02/16 12:00:34 benedetti
30 first version, adapted from meshlab's editmeasure plugin
31
32
33 ****************************************************************************/
34 #ifndef RUBBERBAND_H
35 #define RUBBERBAND_H
36
37 #include <vcg/space/color4.h>
38 #include <QGLWidget>
39
40 namespace vcg {
41
42 /*!
43 @brief The Rubberband class.
44
45 This class is useful for interactively draw a straight line between 2 pickable points in a GL widget.
46 */
47 class Rubberband
48 {
49 public:
50 //data:
51
52 /// The color of the rubberband
53 Color4b color;
54
55 // functions:
56
57 /*!
58 @brief The constructor.
59
60 Initialize the rubberband data.
61 */
62 Rubberband(Color4b);
63
64 /*!
65 @brief The destructor.
66
67 The destructor.
68 */
69 virtual ~Rubberband() {}
70
71 /*!
72 @brief Render the rubberband and do the picking.
73
74 Is important that this function is called in order to apply the Drag and Pin commands.
75
76 @param glw the GL widget.
77 */
78 void Render(QGLWidget* glw);
79
80 /*!
81 @brief Set the current rubberband endpoint.
82
83 This function should be called after MouseMove events.
84
85 @param cursor the cursor position.
86 */
87 void Drag(QPoint cursor);
88
89 /*!
90 @brief Ask for picking.
91
92 This function should be called after MouseRelease events.
93
94 The first time is called, if the picking is successful, sets the startpoint.
95 The second time sets, if the picking is successful, the endpoint.
96 After the second time this has no effect.
97
98 @param cursor the cursor position.
99 */
100 void Pin(QPoint cursor);
101
102 /*!
103 @brief Reset the rubberband.
104 */
105 void Reset();
106
107 /*!
108 @brief Return true if the rubberband has been drawn.
109
110 @return true if the line has been drawn, false otherwise.
111 */
112 bool IsReady();
113
114 /*!
115 @brief Get the rubberband start and end points.
116
117 @param startpoint is set to the rubberband start point.
118 @param endpoint is set to the rubberband end point.
119 @warning Don't call this function until IsReady() returns true!
120 */
121 void GetPoints(Point3f &startpoint,Point3f &endpoint);
122
123 /*!
124 @brief Render a text label near the endpoint (if it exists).
125
126 @param text the text to render.
127 @param glw the GL widget.
128 */
129 void RenderLabel(QString text,QGLWidget* glw);
130
131 private:
132 // types:
133 typedef enum { RUBBER_BEGIN = 0,
134 RUBBER_DRAGGING = 1,
135 RUBBER_DRAGGED = 2,
136 } RubberPhase;
137 // data:
138 RubberPhase currentphase;
139 QPoint qt_cursor;
140 Point3f start, end;
141 bool have_to_pick;
142 QFont font;
143 // functions:
144 Point3f PixelConvert(const Point3f);
145
146 };
147
148 }//namespace
149
150 #endif /*RUBBERBAND_H*/