tttrlib
A library for time-tagged time resolved data
Loading...
Searching...
No Matches
CLSMLine.h
Go to the documentation of this file.
1#ifndef TTTRLIB_CLSMLINE_H
2#define TTTRLIB_CLSMLINE_H
3
4#include <vector>
5#include "TTTR.h" /* TTTRRange */
6#include "CLSMPixel.h"
7#include "TTTRSelection.h"
8
9class CLSMLine : public TTTRSelection{
10
11 friend class CLSMImage;
12 friend class CLSMFrame;
13
14private:
15
16 std::vector<CLSMPixel> pixels;
17 int pixel_duration = -1;
18
19public:
20
22 size_t size() final{
23 return pixels.size();
24 }
25
26 std::vector<CLSMPixel>& get_pixels(){
27 return pixels;
28 }
29
30 void set_pixel_duration(int v){
31 this->pixel_duration = v;
32 }
33
34 unsigned long long get_pixel_duration(){
35 if(pixel_duration < 0){
36 return (size_t) (get_duration(_tttr) / size());
37 } else{
38 return pixel_duration;
39 }
40 }
41
42 CLSMLine() = default;
43
44 CLSMLine(const CLSMLine& old_line, bool fill=true) : TTTRSelection(old_line){
45 // private attributes
46 pixels.resize(old_line.pixels.size());
47 pixels = old_line.pixels;
48 if(!fill){
49 for(auto &p: pixels) p.clear();
50 }
51 }
52
53 explicit CLSMLine(unsigned int line_start){
54 _tttr_indices.insert(line_start);
55 }
56
57 CLSMLine(int line_start, unsigned int n_pixel){
58 _tttr_indices.insert(line_start);
59 pixels.resize(n_pixel);
60 }
61
62 virtual ~CLSMLine() = default;
63
64 void append(CLSMPixel& pixel){
65 pixels.emplace_back(pixel);
66 }
67
68 CLSMPixel* operator[](unsigned int i_pixel){
69 return &pixels[i_pixel];
70 }
71
72 void crop(int pixel_start, int pixel_stop){
73 pixel_stop = std::min(pixel_stop, (int) size());
74 pixel_start = std::max(0, pixel_start);
75
76 #ifdef VERBOSE_TTTRLIB
77 std::clog << "Crop line" << std::endl;
78 std::clog << "-- Pixel range: " << pixel_start << ", " << pixel_stop << std::endl;
79 #endif
80
81 pixels.erase(pixels.begin() + pixel_stop, pixels.end());
82 pixels.erase(pixels.begin(), pixels.begin() + pixel_start);
83 }
84
86 for(size_t i = 0; i < pixels.size(); i++){
87 pixels[i] += rhs.pixels[i];
88 }
89 return *this;
90 }
91
92};
93
94#endif //TTTRLIB_CLSMLINE_H
Definition CLSMFrame.h:12
Definition CLSMImage.h:161
Definition CLSMLine.h:9
CLSMLine & operator+=(const CLSMLine &rhs)
Definition CLSMLine.h:85
void crop(int pixel_start, int pixel_stop)
Definition CLSMLine.h:72
CLSMPixel * operator[](unsigned int i_pixel)
Definition CLSMLine.h:68
size_t size() final
Get the number of pixels per line a frame of the CLSMImage.
Definition CLSMLine.h:22
CLSMLine(const CLSMLine &old_line, bool fill=true)
Definition CLSMLine.h:44
virtual ~CLSMLine()=default
std::vector< CLSMPixel > & get_pixels()
Definition CLSMLine.h:26
CLSMLine()=default
unsigned long long get_pixel_duration()
Definition CLSMLine.h:34
void set_pixel_duration(int v)
Definition CLSMLine.h:30
CLSMLine(int line_start, unsigned int n_pixel)
Definition CLSMLine.h:57
CLSMLine(unsigned int line_start)
Definition CLSMLine.h:53
void append(CLSMPixel &pixel)
Definition CLSMLine.h:64
Definition CLSMPixel.h:7
unsigned int get_duration(TTTR *tttr)
Gets the duration between the start and stop times of the TTTR range.
Definition TTTRRange.h:170
itlib::flat_set< int > _tttr_indices
Set of TTTR indices in the range.
Definition TTTRRange.h:23
Definition TTTRSelection.h:8
TTTR * _tttr
Definition TTTRSelection.h:12