GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/gui/selection-event.cc Lines: 1 19 5.3 %
Date: 2020-05-14 11:23:33 Branches: 2 10 20.0 %

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
21
#include <osgUtil/LineSegmentIntersector>
22
23
24
namespace gepetto {
25
  namespace gui {
26
    namespace {
27
      void toQVector3(const osg::Vec3f& in, QVector3D& out) {
28
        out.setX(in[0]);
29
        out.setY(in[1]);
30
        out.setZ(in[2]);
31
      }
32
      void toQVector3(const osg::Vec3d& in, QVector3D& out) {
33
        out.setX((float)in[0]);
34
        out.setY((float)in[1]);
35
        out.setZ((float)in[2]);
36
      }
37
    }
38
39
    void SelectionEvent::setupIntersection(const osgUtil::LineSegmentIntersector::Intersection& it)
40
    {
41
      hasIntersection_ = true;
42
      toQVector3(it.getLocalIntersectPoint(),  localPoint_);
43
      toQVector3(it.getWorldIntersectPoint(),  worldPoint_);
44
      toQVector3(it.getLocalIntersectNormal(), localNormal_);
45
      toQVector3(it.getWorldIntersectNormal(), worldNormal_);
46
    }
47
48
    void SelectionEvent::done()
49
    {
50
      c_.fetchAndAddAcquire(-1);
51
      if (c_.testAndSetAcquire(0,0)) {
52
        deleteLater();
53
      }
54
    }
55
  }
56

3
}