GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/gepetto/viewer/leaf-node-line.h Lines: 0 10 0.0 %
Date: 2020-05-14 11:23:33 Branches: 0 24 0.0 %

Line Branch Exec Source
1
//
2
//  leaf-node-line.h
3
//  gepetto-viewer
4
//
5
//  Created by Justin Carpentier, Mathieu Geisert in November 2014.
6
//  Copyright (c) 2014 LAAS-CNRS. All rights reserved.
7
//
8
9
#ifndef GEPETTO_VIEWER_LEAFNODELINE_HH
10
#define GEPETTO_VIEWER_LEAFNODELINE_HH
11
12
#include <gepetto/viewer/node-drawable.h>
13
14
namespace gepetto {
15
namespace viewer {
16
    DEF_CLASS_SMART_PTR(LeafNodeLine)
17
18
    class LeafNodeLine : public Node
19
    {
20
    private:
21
22
        /** Associated weak pointer */
23
        LeafNodeLineWeakPtr weak_ptr_;
24
25
        /** Geometry */
26
        ::osg::GeometryRefPtr beam_ptr_;
27
        ::osg::ref_ptr< ::osg::DrawArrays > drawArray_ptr_;
28
        ::osg::Vec3ArrayRefPtr points_ptr_;
29
        ::osg::Vec4ArrayRefPtr color_ptr_;
30
31
        void init ();
32
33
        /* Default constructor */
34
        LeafNodeLine (const std::string& name, const osgVector3& start_point, const osgVector3& end_point);
35
        LeafNodeLine (const std::string& name, const osgVector3& start_point, const osgVector3& end_point, const osgVector4& color);
36
        LeafNodeLine (const std::string& name, const ::osg::Vec3ArrayRefPtr& points, const osgVector4& color);
37
38
        /* Copy constructor */
39
        LeafNodeLine (const LeafNodeLine& other);
40
41
        /** Initialize weak_ptr */
42
        void initWeakPtr (LeafNodeLineWeakPtr other_weak_ptr);
43
44
    protected:
45
    public:
46
        /** Static method which create a new box defined by the half_axis vector
47
         */
48
        static LeafNodeLinePtr_t create (const std::string& name, const osgVector3& start_point, const osgVector3& end_point);
49
        static LeafNodeLinePtr_t create (const std::string& name, const osgVector3& start_point, const osgVector3& end_point, const osgVector4& color);
50
        static LeafNodeLinePtr_t create (const std::string& name, const ::osg::Vec3ArrayRefPtr& points, const osgVector4& color);
51
52
        /** Static method for creating a clone of box other with the copy constructor
53
         */
54
        static LeafNodeLinePtr_t createCopy (LeafNodeLinePtr_t other);
55
56
        /** Proceed to a clonage of the current object defined by the copy constructor
57
         */
58
        virtual LeafNodeLinePtr_t clone (void) const;
59
60
        /** Copy
61
         \brief Proceed to a copy of the currend object as clone
62
         */
63
        virtual NodePtr_t copy() const { return clone(); }
64
65
        /** Return a shared pointer of the current object
66
         */
67
        LeafNodeLinePtr_t self (void) const;
68
69
        /** Apply a new global configuration
70
         */
71
72
        /** Define the new start point of the line
73
         */
74
        virtual void setStartPoint (const osgVector3& start_point);
75
76
        osgVector3 getStartPoint () const;
77
78
        /** Define the new end point of the line
79
         */
80
        virtual void setEndPoint (const osgVector3& end_point);
81
82
        osgVector3 getEndPoint() const;
83
84
        /** Define the immediate mode of OpenGL used to draw the line.
85
         *  Possible values are:
86
         *  \image html opengl_primitives.png
87
         */
88
        virtual void setMode (const GLenum& mode);
89
90
        GLenum getMode () const;
91
92
        /** Define the start and end point of the line
93
         */
94
        virtual void setPoints (const osgVector3& start_point, const osgVector3& end_point);
95
96
        virtual void setPoints (const ::osg::Vec3ArrayRefPtr& points);
97
98
        /** Draw only a subset of the points
99
         */
100
        void setPointsSubset (const int first, const std::size_t count);
101
102
        ::osg::Vec3ArrayRefPtr getPoints()
103
        {
104
          return points_ptr_;
105
        }
106
107
        void setColor(const osgVector4& color);
108
        void setColors(const ::osg::Vec4ArrayRefPtr& color);
109
110
        osgVector4 getColor() const
111
        {
112
            ::osg::Vec4ArrayRefPtr color_array_ptr = dynamic_cast<osg::Vec4Array*>(beam_ptr_->getColorArray());
113
            ASSERT(color_array_ptr, "Problem of dynamic casting from VecArray to Vec4Array");
114
115
            return color_array_ptr->at(0);
116
        }
117
118
        ::osg::GeometryRefPtr geometry () const
119
        {
120
          return beam_ptr_;
121
        }
122
123
        SCENE_VIEWER_ACCEPT_VISITOR;
124
125
        /** Destructor */
126
        virtual ~LeafNodeLine();
127
128
    };
129
130
} /* namespace viewer */
131
} /* namespace gepetto */
132
133
#endif /* GEPETTO_VIEWER_LEAFNODELINE_HH */