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
LVRHistogram(QWidget *parent, PointBufferPtr points)
UCharChannel::Optional UCharChannelOptional
Definition: Channel.hpp:96
std::shared_ptr< PointBuffer > PointBufferPtr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
virtual ~LVRHistogram()


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 Mon Feb 28 2022 22:46:08