My Project
Loading...
Searching...
No Matches
CHistogram.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2019, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CHistogramH
46#define CHistogramH
47//------------------------------------------------------------------------------
48#include "widgets/CPanel.h"
49//------------------------------------------------------------------------------
50
51//------------------------------------------------------------------------------
52namespace chai3d {
53//------------------------------------------------------------------------------
54
55//------------------------------------------------------------------------------
56const unsigned int C_HISTOGRAM_MAX_SAMPLES = 6000;
57//------------------------------------------------------------------------------
58
59//==============================================================================
66//==============================================================================
67
74
75//==============================================================================
86//==============================================================================
87class cHistogram : public cPanel
88{
89 //--------------------------------------------------------------------------
90 // CONSTRUCTOR & DESTRUCTOR:
91 //--------------------------------------------------------------------------
92
93public:
94
96 cHistogram();
97
99 virtual ~cHistogram() {};
100
101
102 //--------------------------------------------------------------------------
103 // PUBLIC METHODS:
104 //--------------------------------------------------------------------------
105
106public:
107
109 virtual std::string getClassName() { return ("Histogram"); }
110
112 virtual cHistogram* copy(const bool a_duplicateMaterialData = false,
113 const bool a_duplicateTextureData = false,
114 const bool a_duplicateMeshData = false,
115 const bool a_buildCollisionDetector = false);
116
118 virtual void setSize(const double& a_width, const double& a_height);
119
121 virtual bool setSampleSize(const unsigned int a_sampleSize);
122
124 virtual unsigned int getSampleSize() { return (m_sampleSize); }
125
127 inline void setLineWidth(const double a_lineWidth) { m_lineWidth = fabs(a_lineWidth); }
128
130 inline double getLineWidth() const { return (m_lineWidth); }
131
133 void setDataValue(const unsigned int a_index, const double a_dataValue);
134
136 double getDataValue(const unsigned int a_index);
137
139 void clearDataValues();
140
142 virtual void setRange(const double a_minValue,
143 const double a_maxValue);
144
146 inline double getRangeMin() const { return (m_minValue); }
147
149 inline double getRangeMax() const { return (m_maxValue); }
150
151
152 //--------------------------------------------------------------------------
153 // PUBLIC MEMBERS:
154 //--------------------------------------------------------------------------
155
156public:
157
160
161
162 //--------------------------------------------------------------------------
163 // PROTECTED MEMBERS:
164 //--------------------------------------------------------------------------
165
166protected:
167
170
172 unsigned int m_sampleSize;
173
176
179
182
185
188
191
194
197
198
199 //--------------------------------------------------------------------------
200 // PROTECTED METHODS:
201 //--------------------------------------------------------------------------
202
203protected:
204
206 virtual void render(cRenderOptions& a_options);
207
210 const bool a_duplicateMaterialData,
211 const bool a_duplicateTextureData,
212 const bool a_duplicateMeshData,
213 const bool a_buildCollisionDetector);
214};
215
216//------------------------------------------------------------------------------
217} // namespace chai3d
218//------------------------------------------------------------------------------
219
220//------------------------------------------------------------------------------
221#endif
222//------------------------------------------------------------------------------
Implements a panel widget.
This class implements a 2D histogram to display an array of data value.
Definition CHistogram.h:88
void setLineWidth(const double a_lineWidth)
This method sets the line width of the histogram in wire mode.
Definition CHistogram.h:127
double m_histogramWidth
Internal width of histogram display.
Definition CHistogram.h:190
virtual ~cHistogram()
Destructor of cHistogram.
Definition CHistogram.h:99
virtual bool setSampleSize(const unsigned int a_sampleSize)
This method sets the number of samples to be disdplayed by the histogram.
Definition CHistogram.cpp:187
cHistogramMode m_mode
Rendering mode of histogram.
Definition CHistogram.h:169
virtual void render(cRenderOptions &a_options)
This method renders the object graphically using OpenGL.
Definition CHistogram.cpp:250
double getRangeMin() const
This method returns the minimum value from the range.
Definition CHistogram.h:146
int m_dataPoints[C_HISTOGRAM_MAX_SAMPLES]
Data values.
Definition CHistogram.h:184
cHistogram()
Constructor of cHistogram.
Definition CHistogram.cpp:59
void copyScopeProperties(cHistogram *a_obj, const bool a_duplicateMaterialData, const bool a_duplicateTextureData, const bool a_duplicateMeshData, const bool a_buildCollisionDetector)
This method copies all properties of this object to another.
Definition CHistogram.cpp:412
virtual void setSize(const double &a_width, const double &a_height)
This method sets the size of this scope.
Definition CHistogram.cpp:209
unsigned int m_sampleSize
Sample size to be displayed in histogram.
Definition CHistogram.h:172
double getDataValue(const unsigned int a_index)
This method returns a data value from the histogram at a desired index location.
Definition CHistogram.cpp:122
double m_maxValue
Range - maximum value.
Definition CHistogram.h:178
virtual cHistogram * copy(const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=false)
This method creates a copy of itself.
Definition CHistogram.cpp:381
double m_lineWidth
Width used to render lines.
Definition CHistogram.h:187
double getLineWidth() const
This method returns the line width of the line.
Definition CHistogram.h:130
cVector3d m_histogramPosition
Position of scope in reference to Panel.
Definition CHistogram.h:196
cColorf m_color
Color settings for histogram.
Definition CHistogram.h:159
virtual unsigned int getSampleSize()
This method sets the number of samples to be disdplayed by the histogram.
Definition CHistogram.h:124
double m_histogramHeight
Internal height of histogram display.
Definition CHistogram.h:193
void clearDataValues()
This method clears all data values to minimum range value.
Definition CHistogram.cpp:140
virtual void setRange(const double a_minValue, const double a_maxValue)
This method sets the range of input values which can be displayed on the scope.
Definition CHistogram.cpp:157
void setDataValue(const unsigned int a_index, const double a_dataValue)
This method sets a data value in the histogram at a desired index location.
Definition CHistogram.cpp:102
double getRangeMax() const
This method returns the maximum value from the range.
Definition CHistogram.h:149
double m_minValue
Range - minimum value.
Definition CHistogram.h:175
double m_dataValues[C_HISTOGRAM_MAX_SAMPLES]
Data values.
Definition CHistogram.h:181
virtual std::string getClassName()
This method returns the name of the object class.
Definition CHistogram.h:109
This class implements a 2D panel widget.
Definition CPanel.h:81
Definition CAudioBuffer.cpp:57
const unsigned int C_HISTOGRAM_MAX_SAMPLES
Definition CHistogram.h:56
cHistogramMode
Definition CHistogram.h:69
@ C_HISTOGRAM_MODE_LINE
Definition CHistogram.h:70
@ C_HISTOGRAM_MODE_LINE_FILL
Definition CHistogram.h:71
@ C_HISTOGRAM_MODE_BAR
Definition CHistogram.h:72
This class defines a color using a GLfloat representation for each component.
Definition CColor.h:139
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83
This class implements a 3D vector.
Definition CVector3d.h:89