Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2017, Joseph Mirabel |
2 |
|
|
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) |
3 |
|
|
// |
4 |
|
|
// This file is part of gepetto-viewer. |
5 |
|
|
// gepetto-viewer is free software: you can redistribute it |
6 |
|
|
// and/or modify it under the terms of the GNU Lesser General Public |
7 |
|
|
// License as published by the Free Software Foundation, either version |
8 |
|
|
// 3 of the License, or (at your option) any later version. |
9 |
|
|
// |
10 |
|
|
// gepetto-viewer is distributed in the hope that it will be |
11 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
12 |
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 |
|
|
// General Lesser Public License for more details. You should have |
14 |
|
|
// received a copy of the GNU Lesser General Public License along with |
15 |
|
|
// gepetto-viewer. If not, see <http://www.gnu.org/licenses/>. |
16 |
|
|
|
17 |
|
|
#include "gepetto/gui/selection-event.hh" |
18 |
|
|
|
19 |
|
|
#include <QDebug> |
20 |
|
|
#include <osgUtil/LineSegmentIntersector> |
21 |
|
|
|
22 |
|
|
namespace gepetto { |
23 |
|
|
namespace gui { |
24 |
|
|
namespace { |
25 |
|
✗ |
void toQVector3(const osg::Vec3f& in, QVector3D& out) { |
26 |
|
✗ |
out.setX(in[0]); |
27 |
|
✗ |
out.setY(in[1]); |
28 |
|
✗ |
out.setZ(in[2]); |
29 |
|
|
} |
30 |
|
✗ |
void toQVector3(const osg::Vec3d& in, QVector3D& out) { |
31 |
|
✗ |
out.setX((float)in[0]); |
32 |
|
✗ |
out.setY((float)in[1]); |
33 |
|
✗ |
out.setZ((float)in[2]); |
34 |
|
|
} |
35 |
|
|
} // namespace |
36 |
|
|
|
37 |
|
✗ |
void SelectionEvent::setupIntersection( |
38 |
|
|
const osgUtil::LineSegmentIntersector::Intersection& it) { |
39 |
|
✗ |
hasIntersection_ = true; |
40 |
|
✗ |
primitiveIndex_ = it.primitiveIndex; |
41 |
|
✗ |
toQVector3(it.getLocalIntersectPoint(), localPoint_); |
42 |
|
✗ |
toQVector3(it.getWorldIntersectPoint(), worldPoint_); |
43 |
|
✗ |
toQVector3(it.getLocalIntersectNormal(), localNormal_); |
44 |
|
✗ |
toQVector3(it.getWorldIntersectNormal(), worldNormal_); |
45 |
|
|
} |
46 |
|
|
|
47 |
|
✗ |
void SelectionEvent::done() { |
48 |
|
✗ |
c_.fetchAndAddAcquire(-1); |
49 |
|
✗ |
if (c_.testAndSetAcquire(0, 0)) { |
50 |
|
✗ |
deleteLater(); |
51 |
|
|
} |
52 |
|
|
} |
53 |
|
|
} // namespace gui |
54 |
|
|
} // namespace gepetto |
55 |
|
|
|