OpenWalnut  1.5.0dev
WConnectorData.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WCONNECTORDATA_H
26 #define WCONNECTORDATA_H
27 
28 #include <memory>
29 #include <vector>
30 
31 #include <osg/Geode>
32 
33 
34 /**
35  * Holds the data of the WMPointConnector.
36  */
38 {
39 public:
40  /**
41  * A shared_ptr to this class.
42  */
43  typedef std::shared_ptr< WConnectorData > SPtr;
44 
45  /**
46  * Creates the internal vector arrays.
47  */
49 
50  /**
51  * Clears the internal vector arrays.
52  */
53  void clear();
54 
55  /**
56  * \return osg::ref_ptr< osg::Vec3Array > The vertices in this data.
57  */
58  osg::ref_ptr< osg::Vec3Array > getVertices();
59 
60  /**
61  * \return osg::ref_ptr< osg::Vec4Array > The colors in this data.
62  */
63  osg::ref_ptr< osg::Vec4Array > getColors();
64 
65  /**
66  * \return std::shared_ptr< std::vector< float > > The energy deposition in this data.
67  */
68  std::shared_ptr< std::vector< float > > getEdeps();
69 
70  /**
71  * \return std::shared_ptr< std::vector< float > > The cluster size in this data.
72  */
73  std::shared_ptr< std::vector< float > > getClusterSizes();
74 
75  /**
76  * Adds a vertex with its color to the currently selected fiber.
77  * \param vertex The vertex to add.
78  * \param color The color of the vertex.
79  * \param edep The energy deposition of the vertex.
80  * \param clusterSize The cluster size of the vertex.
81  */
82  void addVertex( osg::Vec3 vertex, osg::Vec4 color, float edep = 0.0, float clusterSize = 0.0 );
83 
84  /**
85  * Selects a point by its index in m_vertices.
86  * \param idx The index of the point.
87  */
88  void selectPoint( size_t idx );
89 
90  /**
91  * Selects a poit by its coordinates.
92  * \param vertex The coordinates of the point.
93  */
94  void selectPoint( osg::Vec3 vertex );
95 
96  /**
97  * Deselects the currently selected point.
98  */
99  void deselectPoint();
100 
101  /**
102  *
103  * \param idx Where to write the index of the selected point
104  * \return true A point is selected
105  * \return false A point is not selected
106  */
107  bool getSelectedPoint( size_t* idx );
108 
109  /**
110  * \return true Cluster size should be used.
111  * \return false Cluster size should not be used.
112  */
113  bool hasClusterSize();
114 
115  /**
116  * Sets whether the cluster size should be used.
117  * \param clusterSize
118  */
119  void setHasClusterSize( bool clusterSize = true );
120 
121 private:
122  /**
123  * The vertices that are drawn.
124  */
125  osg::ref_ptr< osg::Vec3Array > m_vertices;
126 
127  /**
128  * The color of the vertices that are drawn.
129  */
130  osg::ref_ptr< osg::Vec4Array > m_colors;
131 
132  /**
133  * The energy deposition of the vertices.
134  */
135  std::shared_ptr< std::vector< float > > m_edeps;
136 
137  /**
138  * The cluster size of the vertices.
139  */
140  std::shared_ptr< std::vector< float > > m_clusterSizes;
141 
142  /**
143  * The index of the selected vertex.
144  */
146 
147  /**
148  * Whether a selection has been done or not.
149  */
150  bool m_hasSelected = false;
151 
152  /**
153  * Whether cluster size should be used.
154  */
155  bool m_hasClusterSize = false;
156 };
157 
158 #endif // WCONNECTORDATA_H
Holds the data of the WMPointConnector.
bool getSelectedPoint(size_t *idx)
void deselectPoint()
Deselects the currently selected point.
void addVertex(osg::Vec3 vertex, osg::Vec4 color, float edep=0.0, float clusterSize=0.0)
Adds a vertex with its color to the currently selected fiber.
void selectPoint(size_t idx)
Selects a point by its index in m_vertices.
WConnectorData()
Creates the internal vector arrays.
std::shared_ptr< std::vector< float > > m_clusterSizes
The cluster size of the vertices.
bool m_hasClusterSize
Whether cluster size should be used.
void setHasClusterSize(bool clusterSize=true)
Sets whether the cluster size should be used.
std::shared_ptr< std::vector< float > > getEdeps()
void clear()
Clears the internal vector arrays.
bool m_hasSelected
Whether a selection has been done or not.
std::shared_ptr< std::vector< float > > m_edeps
The energy deposition of the vertices.
osg::ref_ptr< osg::Vec3Array > m_vertices
The vertices that are drawn.
std::shared_ptr< std::vector< float > > getClusterSizes()
size_t m_selectedIndex
The index of the selected vertex.
osg::ref_ptr< osg::Vec4Array > getColors()
std::shared_ptr< WConnectorData > SPtr
A shared_ptr to this class.
osg::ref_ptr< osg::Vec3Array > getVertices()
osg::ref_ptr< osg::Vec4Array > m_colors
The color of the vertices that are drawn.