FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SimpleEarth/src/LabelTool.cpp at master · MAPSWorks/SimpleEarth · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
MAPSWorks
/
SimpleEarth
Public
forked from
hmendoza2001/SimpleEarth
Notifications
You must be signed in to change notification settings
Fork
2
Star
4
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SimpleEarth
/
src
/
LabelTool.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
189 lines (171 loc) · 6.39 KB
Breadcrumbs
SimpleEarth
/
src
/
LabelTool.cpp
Copy path
File metadata and controls
189 lines (171 loc) · 6.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
* The Simple Earth Project
* Copyright (C) 2016 HueSoft LLC
* Author: Hector Mendoza, hector.mendoza@huesoftllc.com
*
* This file is part of the Simple Earth Project.
*
* The Simple Earth Project is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version
* 3 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
#
include
"
LabelTool.h
"
#
include
"
WorldObjectManager.h
"
#
include
"
Utilities.h
"
#
include
"
LabelWindow.h
"
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Constructor. Calls parent constructor with an ID of "Label" and with the
* given parameter values. Initializes attributes.
*
* @param toolButton Handle to corresponding toolbar button
* @param dialog Handle to corresponding tool dialog
*/
LabelTool::LabelTool
(QToolButton* toolButton, QDialog* dialog) : Tool(
"
Label
"
, toolButton, dialog)
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
//
Instantiate dummy label and add it to world object manager.
//
This is the label that will get rendered while the user is
//
editing the label's attributes
mDummyLabel
=
new
WorldObject
();
mDummyLabel
->
setIsVisible
(
false
);
mDummyLabel
->
setName
(
"
LabelToolDummy
"
);
mDummyLabel
->
setLabel
(
"
Label
"
);
WorldObjectManager::getInstance
()->
addWorldObject
(
mDummyLabel
);
mCalculateClickPosition
=
false
;
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Destructor.
*/
LabelTool::~LabelTool
()
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* OVERRIDE FOR Tool. Given that we need to calculate click(pick) position on
* OpenGL render thread the this mCalculateClickPosition flag is set to true on
* the onMouseReleaseEvent method. When calculation is done, this method updates
* the label tool window with the selected(picked) coordinates. After the user
* is done editting this label and hits the OK button, the system will call the
* addCurrent method.
*/
void
LabelTool::render
()
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
if
(
mCalculateClickPosition
)
{
//
convert click coordinate to world coordinate
SimpleVector worldCoordinate =
Utilities::screenToWorld
(
mClickCordinates
);
//
reset calculate flag
mCalculateClickPosition
=
false
;
//
update label position
setPosition
(worldCoordinate);
//
update label window
LabelWindow* labelWindow = (LabelWindow*)
mDialog
;
labelWindow->
setPosition
(worldCoordinate);
}
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Adds current volume to WorldObjectManager's list. Note how we copy all the
* data from our dummy label.
*
* @return True if add was a success, false if there is a naming conflict (a
* world object with that name already exists)
*/
bool
LabelTool::addCurrent
()
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
bool
returnValue =
true
;
WorldObject* worldObject =
new
WorldObject;
//
copy all attributes
worldObject->
copy
(
mDummyLabel
);
//
set object name with label's text
worldObject->
setName
(
mDummyLabel
->
getLabel
());
//
set label as a group
worldObject->
setGroup
(WorldObject::
LABEL
);
//
if addWorldObject returns false, then the add failed because
//
there was already an object with that name in the list,
//
so we need to delete the object we just created
if
(!
WorldObjectManager::getInstance
()->
addWorldObject
(worldObject))
{
//
note: the volume renderer that we associated with this world
//
object will get deleted on the world object's destructor
delete
worldObject;
returnValue =
false
;
}
return
returnValue;
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Called on a right mouse button release event when the label tools is
* selected. Saves click coordinates and sets the flag to calculate mouse click
* position on the OpenGL render cycle.
*
* @param event Qt's mouse event
*/
void
LabelTool::onMouseReleaseEvent
(QMouseEvent* event)
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
mClickCordinates
.
x
= event->
x
();
mClickCordinates
.
y
= event->
y
();
mCalculateClickPosition
=
true
;
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Sets the current label's text.
*
* @param labelText New text for current(dummy) label
*/
void
LabelTool::setLabelText
(
const
QString& labelText)
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
mDummyLabel
->
setLabel
(labelText);
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Sets the position for the current(dummy) label.
*
* @param position New position for the current label
*/
void
LabelTool::setPosition
(
const
SimpleVector& position)
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
mDummyLabel
->
setPosition
(position);
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Sets the color for the current(dummy) label.
*
* @param color New color for the current label
*/
void
LabelTool::setColor
(
const
SimpleColor& color)
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
mDummyLabel
->
setColor
(color);
}
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
*
* Sets the dummy lable's visibility so that we hide/show appropriately. Set
* value to true to make label visible. Note that "View Labels" also has to be
* enabled from the View menu in order to see any labels.
*
* @param value Set to true to make label visible
*/
void
LabelTool::setDummyLabelVisible
(
bool
value)
//
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
mDummyLabel
->
setIsVisible
(value);
}
Back
|
FazBrowse Home
|
New Git URL