LVRHistogram.cpp
Go to the documentation of this file.
1 
28 #include "LVRHistogram.hpp"
29 
30 namespace lvr2
31 {
32 
34  : QDialog(parent)
35 {
36  m_histogram.setupUi(this);
37  //Set Plotmode to create a bar chart
38  m_histogram.plotter->setPlotMode(PlotMode::BAR);
39  m_histogram.plotter->setXRange(*points->getIntAtomic("spectral_wavelength_min"), *points->getIntAtomic("spectral_wavelength_max"));
40 
41  size_t n;
42  size_t n_spec;
43 
44  //Get Array with Spectraldata
45  //floatArr spec = points->getPointSpectralChannelsArray(n_spec, m_numChannels);
46  UCharChannelOptional spec = points->getUCharChannel("spectral_channels");
47  m_numChannels = spec->width();
48  n_spec = spec->numElements();
49 
50  //New Array for Average channelintensity
51  m_data = floatArr(new float[m_numChannels]);
52 
53  #pragma omp parallel for
54  //calculate average intensity of all Points for all channels
55  for (size_t channel = 0; channel < m_numChannels; channel++)
56  {
57  m_data[channel] = 0;
58 
59  for (size_t i = 0; i < n_spec; i++)
60  {
61  m_data[channel] += (*spec)[i][channel];
62  }
63  m_data[channel] /= n_spec;
64  }
65 
66  refresh();
67 
68  //Connect scale checkbox
69  QObject::connect(m_histogram.shouldScale, SIGNAL(stateChanged(int)), this, SLOT(refresh()));
70 }
71 
73 {
74 }
75 
77 {
78  if (m_histogram.shouldScale->isChecked())
79  {
80  m_histogram.plotter->setPoints(m_data, m_numChannels);
81  }
82  else
83  {
84  m_histogram.plotter->setPoints(m_data, m_numChannels, 0, 1);
85  }
86  //show Dialog
87  show();
88  raise();
89  activateWindow();
90 }
91 
92 } // namespace lvr2
lvr2::floatArr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
lvr2::LVRHistogram::~LVRHistogram
virtual ~LVRHistogram()
Definition: LVRHistogram.cpp:72
lvr2::UCharChannelOptional
UCharChannel::Optional UCharChannelOptional
Definition: Channel.hpp:96
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
lvr2::PlotMode::BAR
@ BAR
lvr2::LVRHistogram::LVRHistogram
LVRHistogram(QWidget *parent, PointBufferPtr points)
Definition: LVRHistogram.cpp:33
LVRHistogram.hpp
lvr2::LVRHistogram::m_histogram
Histogram m_histogram
Definition: LVRHistogram.hpp:54
lvr2::LVRHistogram::m_data
floatArr m_data
Definition: LVRHistogram.hpp:55
lvr2::LVRHistogram::m_numChannels
size_t m_numChannels
Definition: LVRHistogram.hpp:56
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::LVRHistogram::refresh
void refresh()
Definition: LVRHistogram.cpp:76


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24