tdaq-develop-2025-02-12
PixelHistoPicGen.h
1 #ifndef _PixelHistoPicGen_h_
2 #define _PixelHistoPicGen_h_
3 
4 #include <stdlib.h>
5 #include <string>
6 //#include "PixelHistoFPix.h"
7 
9 {
10  public:
13 
14  void readBmpToReadImg(const std::string& filename);
15  void convertBmp(const std::string& fileBMP, const std::string& convertFile);
16 
17  void initImgBuffer(int sourceKey);
18  void initImgBuffer(int r, int g, int b);
19  void writeImgToBmp(std::string filename);
20  void transferReadImgToImg(void);
21  void drawDiscToImg(int disc, bool isClicked = false);
22  void drawPanelToImg(int disc, int panel, int x, int y, bool isClicked = false);
23  void drawBladeToImg(int disc,
24  int panel,
25  int halfDisc,
26  int blade,
27  int x,
28  int y,
29  float deg,
30  int& roci,
31  int& clicki,
32  bool isClicked = false);
33  void drawFillRectAng(int x, int y, int w, int h, int r, int g, int b, float deg);
34  void drawFillRect(int x,
35  int y,
36  int w,
37  int h,
38  int r,
39  int g,
40  int b,
41  float m1 = 1.0f,
42  float m2 = 0.0f,
43  float m3 = 0.0f,
44  float m4 = 1.0f);
45  void setImgPixel(int x, int y, int r, int g, int b);
46  void fillFPixColors(void);
47  std::string getFPixStandardName(
48  int disc, int panel, int halfDisc, int blade, int roc);
49  void getFPixIndices(
50  std::string stdName, int& disc, int& panel, int& halfDisc, int& blade, int& roc);
51 
52  void initBImgBuffer(int sourceKey);
53  void initBImgBuffer(int r, int g, int b);
54  void writeBImgToBmp(std::string filename);
55  void transferReadImgToBImg(void);
56  void fillBPixColors(void);
57  void drawLayerToBImg(int layer, bool isClicked = false);
58  void drawBPixRoc(int x, int y, int r, int g, int b);
59  std::string getBPixStandardName(int layer, int pm, int row, int col);
60  void getBPixIndices(std::string stdName, int& layer, int& pm, int& row, int& col);
61 
63  void setRocColor(std::string stdName, int r, int g, int b);
64  void setRocColor(std::string stdName, bool isGood);
65 
67  void clearAuxBuffer(int r, int g, int b, int a);
68  void drawFillRectAux(int x,
69  int y,
70  int w,
71  int h,
72  int r,
73  int g,
74  int b,
75  float m1 = 1.0f,
76  float m2 = 0.0f,
77  float m3 = 0.0f,
78  float m4 = 1.0f);
79  void drawFillRectAngAux(int x, int y, int w, int h, int r, int g, int b, float deg);
80  void setAuxPixel(int x, int y, int r, int g, int b);
81  void writeAuxToBmp(char* fn);
82  void createRocAlphaMasks(void);
83 
85  void PrepareDetectorNavigatorJava(void);
86 
87  void createClickMask(std::string maskString, int size);
88  void createAuxImages(void);
89 
90  void clearTurtleBuffer(int r, int g, int b, int a);
91  void writeTurtleToBmp(const char* fn);
92  void generateTurtle(const std::string& filepath);
93  void resetFPixGood(int disk);
94  int getFPixGood(int disk);
95  void resetBPixGood(int part);
96  int getBPixGood(int part);
97 
98  enum
99  { //public for user enums here
100 
101  IMG_INIT_BLACK = 0,
102  IMG_INIT_BGIMG = 1,
103 
104  COLOR_HI_R = 255,
105  COLOR_HI_G = 255,
106  COLOR_HI_B = 255,
107  COLOR_LO_R = 150,
108  COLOR_LO_G = 150,
109  COLOR_LO_B = 150,
110  };
111 
112  bool imageMagickInstallChecked = false;
113  bool imageMagickInstalled = false;
114 
115  private:
116  enum
117  {
118  //fpix enums
119  IMG_DIM_MULT = 1,
120  IMG_WIDTH = 600 * IMG_DIM_MULT,
121  IMG_HEIGHT = 600 * IMG_DIM_MULT,
122  IMG_HEADER_SIZE = 54,
123  IMG_RAW_SIZE = IMG_WIDTH * IMG_HEIGHT * 3,
124  IMG_FILE_SIZE = IMG_RAW_SIZE + IMG_HEADER_SIZE,
125 
126  DET_DISCL_X = 300 * IMG_DIM_MULT,
127  DET_DISCL_Y = 300 * IMG_DIM_MULT,
128  DET_DISCR_X = 900 * IMG_DIM_MULT,
129  DET_DISCR_Y = 300 * IMG_DIM_MULT,
130  DET_DISC_RADIUS = 295 * IMG_DIM_MULT,
131  DET_ROC_SIZE = 9 * IMG_DIM_MULT,
132  DET_ROC_OFFSET = 3 * IMG_DIM_MULT,
133  DET_PLAQ_OFFSET = 4 * IMG_DIM_MULT,
134 
135  //bpix enums
136  BIMG_DIM_MULT = 1,
137  BIMG_WIDTH = 300 * BIMG_DIM_MULT,
138  BIMG_HEIGHT = 600 * BIMG_DIM_MULT,
139  BIMG_HEADER_SIZE = 54,
140  BIMG_RAW_SIZE = BIMG_WIDTH * BIMG_HEIGHT * 3,
141  BIMG_FILE_SIZE = BIMG_RAW_SIZE + BIMG_HEADER_SIZE,
142 
143  BPIX_LYRM_XOFF = 7,
144  BPIX_LYRM_YOFF = 5,
145  BPIX_LYRP_XOFF = 307,
146  BPIX_LYRP_YOFF = 5,
147  BPIX_ROC_WIDTH = 7,
148  BPIX_ROC_HEIGHT = 5,
149  BPIX_COL_OFFSET = 2,
150  BPIX_ROW_OFFSET = 2,
151  BPIX_LYR1_ROWS = 36,
152  BPIX_LYR2_ROWS = 60,
153  BPIX_LYR3_ROWS = 84,
154  BPIX_LYR_COLS = 32,
155 
156  //web enums
157  WEB_LARGE_WIDTH = IMG_WIDTH / IMG_DIM_MULT,
158  WEB_LARGE_HEIGHT = IMG_HEIGHT / IMG_DIM_MULT,
159  WEB_MINI_WIDTH = WEB_LARGE_WIDTH / 4,
160  WEB_MINI_HEIGHT = WEB_LARGE_HEIGHT / 4,
161  WEB_BLARGE_WIDTH = WEB_LARGE_WIDTH,
162  WEB_BLARGE_HEIGHT = WEB_LARGE_HEIGHT,
163  WEB_BMINI_WIDTH = WEB_BLARGE_WIDTH / 6,
164  WEB_BMINI_HEIGHT = WEB_BLARGE_HEIGHT / 3,
165  WEB_XOFFSET = 0,
166  WEB_YOFFSET = 2,
167  WEB_DISC_X = DET_DISCL_X / IMG_DIM_MULT,
168  WEB_DISC_Y = DET_DISCL_Y / IMG_DIM_MULT,
169  WEB_DISC_RADIUS = DET_DISC_RADIUS / IMG_DIM_MULT,
170  WEB_ROC_SIZE = DET_ROC_SIZE / IMG_DIM_MULT,
171  WEB_ROC_OFFSET = DET_ROC_OFFSET / IMG_DIM_MULT,
172  WEB_PLAQ_OFFSET = DET_PLAQ_OFFSET / IMG_DIM_MULT,
173  WEB_BLYR_XOFF = BPIX_LYRM_XOFF * WEB_BLARGE_WIDTH / BIMG_WIDTH,
174  WEB_BLYR_YOFF = BPIX_LYRM_YOFF * WEB_BLARGE_HEIGHT / BIMG_HEIGHT,
175  WEB_BROC_WIDTH = BPIX_ROC_WIDTH * WEB_BLARGE_WIDTH / BIMG_WIDTH,
176  WEB_BROC_HEIGHT = BPIX_ROC_HEIGHT * WEB_BLARGE_HEIGHT / BIMG_HEIGHT,
177  WEB_BCOL_OFFSET = BPIX_COL_OFFSET * WEB_BLARGE_WIDTH / BIMG_WIDTH,
178  WEB_BROW_OFFSET = BPIX_ROW_OFFSET * WEB_BLARGE_HEIGHT / BIMG_HEIGHT,
179 
180  //colors
181  COLOR_GOOD_R = 0,
182  COLOR_GOOD_G = 255,
183  COLOR_GOOD_B = 0,
184  COLOR_BAD_R = 255,
185  COLOR_BAD_G = 0,
186  COLOR_BAD_B = 0,
187  COLOR_INIT_R = 50,
188  COLOR_INIT_G = 50,
189  COLOR_INIT_B = 50,
190  COLOR_HIGHLIGHT_R = 255,
191  COLOR_HIGHLIGHT_G = 255,
192  COLOR_HIGHLIGHT_B = 100,
193  CLICK_MASK_R = 30,
194  CLICK_MASK_G = 30,
195  CLICK_MASK_B = 30,
196 
197  //highlight enums
198  AUX_IMG_WIDTH = WEB_ROC_SIZE * 4 + 1,
199  AUX_IMG_HEIGHT = AUX_IMG_WIDTH,
200  AUX_IMG_HEADER_SIZE = 108,
201  AUX_IMG_RAW_SIZE = AUX_IMG_WIDTH * AUX_IMG_HEIGHT * 4,
202  AUX_IMG_FILE_SIZE = AUX_IMG_RAW_SIZE + AUX_IMG_HEADER_SIZE + 14,
203 
204  //turtle
205  TUR_IMG_WIDTH = 256,
206  TUR_IMG_HEIGHT = 256,
207  TUR_IMG_HEADER_SIZE = 108,
208  TUR_IMG_RAW_SIZE = TUR_IMG_WIDTH * TUR_IMG_HEIGHT * 4,
209  TUR_IMG_FILE_SIZE = TUR_IMG_RAW_SIZE + TUR_IMG_HEADER_SIZE + 14,
210  };
211 
212  //int *getIndices(string name);
213  unsigned char& bpix_(int layer, int pm, int row, int col, int rgb)
214  {
215  switch(layer)
216  {
217  case 0:
218  return bpixLyr1_[pm][row][col][rgb];
219  case 1:
220  return bpixLyr2_[pm][row][col][rgb];
221  case 2:
222  return bpixLyr3_[pm][row][col][rgb];
223  default:
224  exit(0);
225  }
226  }
227 
228  //fpix_ [disc] [panel] [halfDisc] [blade] [roc] [rgb];
229  unsigned char fpix_[4][2][2][12][24][3];
230  int fpixGood_[8];
231  int fpixOn_[8];
232  int bpixGood_[6];
233  int bpixOn_[6];
234 
235  //bpix_ [shells] [sectors] [layers] [ladders] [modules] [rocs];
236  //layer [p/m] [rows] [cols] [rgb];
237  unsigned char bpixLyr1_[2][BPIX_LYR1_ROWS][BPIX_LYR_COLS][3];
238  unsigned char bpixLyr2_[2][BPIX_LYR2_ROWS][BPIX_LYR_COLS][3];
239  unsigned char bpixLyr3_[2][BPIX_LYR3_ROWS][BPIX_LYR_COLS][3];
240 
241  int* clickMask_;
242 
243  unsigned char img_[IMG_WIDTH][IMG_HEIGHT][3];
244  unsigned char bimg_[BIMG_WIDTH][BIMG_HEIGHT]
245  [3];
246  unsigned char auxImg_[AUX_IMG_WIDTH][AUX_IMG_HEIGHT]
247  [4];
248  unsigned char*** readImg_;
249  int readImgW_, readImgH_;
250 
251  unsigned char turtleImg_[TUR_IMG_WIDTH][TUR_IMG_HEIGHT]
252  [4];
253  bool firstTurtle;
254 };
255 
256 #endif
void createAuxImages(void)
generates pre-made images for web-client
void drawFillRect(int x, int y, int w, int h, int r, int g, int b, float m1=1.0f, float m2=0.0f, float m3=0.0f, float m4=1.0f)
draws rect to img buffer. {x,y} is lower left corner. d is degrees of rotation around z-axis.
void writeImgToBmp(std::string filename)
write img buffer to bmp file
void readBmpToReadImg(const std::string &filename)
read bmp file to readImg_ buffer
void createRocAlphaMasks(void)
added 2nd trip
void initImgBuffer(int sourceKey)
fpix buffer
void clearTurtleBuffer(int r, int g, int b, int a)
initializes aux buffer to all invisible black pixels
void initBImgBuffer(int sourceKey)
bpix buffer
void PrepareDetectorNavigatorHtml(void)
web page essentials
void clearAuxBuffer(int r, int g, int b, int a)
auxiliary buffer
void drawFillRectAngAux(int x, int y, int w, int h, int r, int g, int b, float deg)
void drawFillRectAux(int x, int y, int w, int h, int r, int g, int b, float m1=1.0f, float m2=0.0f, float m3=0.0f, float m4=1.0f)
void setRocColor(std::string stdName, int r, int g, int b)
common