Scope
ScopeMultiImage.cpp
1 #include "stdafx.h"
2 #include "ScopeMultiImage.h"
3 #include "ScopeImage.h"
4 
5 namespace scope {
6 
7 ScopeMultiImage::ScopeMultiImage(const uint32_t& _area, const size_t& _nochannels, const uint32_t& _lines, const uint32_t& _linewidth)
8  : area(_area)
9  , nochannels(_nochannels)
10  , lines(_lines)
11  , linewidth(_linewidth)
12  , channels(_nochannels)
13  , avg_count(0)
14  , avg_max(1)
15  , complete_avg(false)
16  , imagenumber(0)
17  , complete_frame(false)
18  , percent_complete(0.0) {
19  // Generate the (blank) images for each channel
20  std::generate(channels.begin(), channels.end(), [&]()
21  { return std::make_shared<ScopeImage<uint16_t>>(lines, linewidth, area); });
22 }
23 
24 uint16_t ScopeMultiImage::GetPixel(const size_t& _ch, const uint32_t& _x, const uint32_t& _y) const {
25  assert( _ch < nochannels );
26  return channels[_ch]->Pixel(_x, _y);
27 }
28 
29 std::vector<uint16_t> ScopeMultiImage::GetMultiPixel(const uint32_t& _x, const uint32_t& _y) const {
30  std::vector<uint16_t> multipix(0);
31  for ( auto img : channels )
32  multipix.push_back(img->Pixel(_x, _y));
33  return multipix;
34 }
35 
36 ScopeImageU16Ptr ScopeMultiImage::GetChannel(const size_t& _chan) const {
37  assert( _chan < nochannels );
38  return channels.at(_chan);
39 }
40 
41 void ScopeMultiImage::SetChannel(const size_t& _chan, ScopeImageU16Ptr const _newimg) {
42  assert( (_newimg->Lines() == lines) && (_newimg->Linewidth() == linewidth) );
43  channels.at(_chan) = _newimg;
44 }
45 
46 void ScopeMultiImage::SetAvgCount(const uint32_t& _avg_count) {
47  avg_count = _avg_count;
48 }
49 
50 void ScopeMultiImage::SetAvgMax(const uint32_t& _avg_max) {
51  assert(_avg_max!=0);
52  avg_max = _avg_max;
53 }
54 
55 void ScopeMultiImage::SetCompleteFrame(const bool& _complete) {
56  complete_frame = _complete;
57  for ( auto ch : channels )
58  ch->SetCompleteFrame(_complete);
59 }
60 
61 void ScopeMultiImage::SetPercentComplete(const double& _percent) {
62  assert(_percent>=0);
63  percent_complete = _percent;
64  for ( auto ch : channels )
65  ch->SetPercentComplete(_percent);
66 }
67 
68 void ScopeMultiImage::SetCompleteAvg(const bool& _complete) {
69  complete_avg = _complete;
70  for ( auto ch : channels )
71  ch->SetCompleteAvg(_complete);
72 }
73 
75  for ( auto ch : channels )
76  ch->FillRandom();
77 }
78 
79 }
void SetCompleteAvg(const bool &_complete)
Sets complete average.
bool complete_frame
false if frame not complete, allows for partial display during acquisition
void FillRandom()
Fills the multi image with random data.
ScopeImageU16Ptr GetChannel(const size_t &chan) const
std::vector< uint16_t > GetMultiPixel(const uint32_t &_x, const uint32_t &_y) const
const uint32_t linewidth
the linewidth (x-resolution)
void SetCompleteFrame(const bool &_complete)
Sets frame complete.
const uint32_t lines
number of lines (y-resolution)
uint32_t avg_count
this image is the xth average
ScopeMultiImage(const uint32_t &_area=0, const size_t &_nochannels=1, const uint32_t &_lines=256, const uint32_t &_linewidth=256)
Initializes and generate blank images for each channel.
void SetPercentComplete(const double &_percent)
Sets percent complete.
void SetChannel(const size_t &_chan, ScopeImageU16Ptr const _newimg)
Replaces one channel of the multiimage.
This is the include file for standard system include files, or project specific include files that ar...
bool complete_avg
false if this is a not completely averaged frame, this is then only for display purpose and will not ...
const uint32_t area
the area from which the multi image comes
const size_t nochannels
number of channels
void SetAvgMax(const uint32_t &_avg_max)
Sets the maximum average count.
std::vector< ScopeImageU16Ptr > channels
the ScopeImages that contain the data for each channel
void SetAvgCount(const uint32_t &_avg_count)
Sets the average count of this image.
double percent_complete
how many percent of the frame are already filled
uint16_t GetPixel(const size_t &_ch, const uint32_t &_x, const uint32_t &_y) const