ATLAS Offline Software
Classes | Public Types | Static Public Member Functions | Static Public Attributes | List of all members
VP1QtInventorUtils::Imp Class Reference
Collaboration diagram for VP1QtInventorUtils::Imp:

Classes

struct  _ImageRec
 

Public Types

typedef struct VP1QtInventorUtils::Imp::_ImageRec ImageRec
 

Static Public Member Functions

static QImage constructImageWithTransparentBackground (const QImage &im_black_bgd, const QImage &image_white_bgd)
 
static void bwtorgba (unsigned char *b, unsigned char *l, int n)
 
static void latorgba (unsigned char *b, unsigned char *a, unsigned char *l, int n)
 
static void rgbtorgba (unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *l, int n)
 
static void rgbatorgba (unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a, unsigned char *l, int n)
 
static void ConvertShort (unsigned short *array, long length)
 
static void ConvertLong (unsigned *array, long length)
 
static ImageRecImageOpen (const char *fileName)
 
static void ImageClose (ImageRec *image)
 
static void ImageGetRow (ImageRec *image, unsigned char *buf, int y, int z)
 
static unsigned * read_texture (const char *name, int *width, int *height, int *components)
 
static void * buffer_realloc (void *bufptr, size_t size)
 
static QString buffer_writeaction (SoNode *root)
 
static void buffer_vrmlwriteaction (SoNode *root, const QString &filename)
 

Static Public Attributes

static char * buffer = 0
 
static size_t buffer_size = 0
 
static bool lineWidthAndPointSizeNeedsInit = true
 
static double allowedLineWidthMin = -1.0
 
static double allowedLineWidthMax = -1.0
 
static double allowedLineWidthGranularity = -1.0
 
static double allowedPointSizeMin = -1.0
 
static double allowedPointSizeMax = -1.0
 
static double allowedPointSizeGranularity = -1.0
 

Detailed Description

Definition at line 53 of file VP1QtInventorUtils.cxx.

Member Typedef Documentation

◆ ImageRec

Member Function Documentation

◆ buffer_realloc()

void * VP1QtInventorUtils::Imp::buffer_realloc ( void *  bufptr,
size_t  size 
)
static

Definition at line 1379 of file VP1QtInventorUtils.cxx.

1380 {
1381  buffer = (char *)realloc(bufptr, size);
1382  buffer_size = size;
1383  return buffer;
1384 }

◆ buffer_vrmlwriteaction()

void VP1QtInventorUtils::Imp::buffer_vrmlwriteaction ( SoNode *  root,
const QString &  filename 
)
static

Definition at line 1403 of file VP1QtInventorUtils.cxx.

1404 {
1405  SoToVRML2Action vwa;
1406 
1407  vwa.apply(root);
1408  SoVRMLGroup * newroot = vwa.getVRML2SceneGraph();
1409 
1410  SoOutput out;
1411  out.openFile(qPrintable(filename));
1412  out.setHeaderString("#VRML V2.0 utf8");
1413  SoWriteAction wra(&out);
1414  wra.apply(newroot);
1415  out.closeFile();
1416  newroot->unref();
1417  return;
1418 }

◆ buffer_writeaction()

QString VP1QtInventorUtils::Imp::buffer_writeaction ( SoNode *  root)
static

Definition at line 1387 of file VP1QtInventorUtils.cxx.

1388 {
1389  SoOutput out;
1390  buffer = (char *)malloc(1024);
1391  buffer_size = 1024;
1392  out.setBuffer(buffer, buffer_size, buffer_realloc);
1393 
1394  SoWriteAction wa(&out);
1395  wa.apply(root);
1396 
1397  QString s(buffer);
1398  free(buffer);
1399  return s;
1400 }

◆ bwtorgba()

static void VP1QtInventorUtils::Imp::bwtorgba ( unsigned char *  b,
unsigned char *  l,
int  n 
)
inlinestatic

Definition at line 58 of file VP1QtInventorUtils.cxx.

59  {
60  while (n--) {
61  l[0] = *b;
62  l[1] = *b;
63  l[2] = *b;
64  l[3] = 0xff;
65  l += 4; ++b;
66  }
67  }

◆ constructImageWithTransparentBackground()

QImage VP1QtInventorUtils::Imp::constructImageWithTransparentBackground ( const QImage &  im_black_bgd,
const QImage &  image_white_bgd 
)
static

Definition at line 600 of file VP1QtInventorUtils.cxx.

601 {
602  if (im_black_bgd.isNull()||im_white_bgd.isNull()||im_black_bgd.size()!=im_white_bgd.size())
603  return QImage();
604 
605  QImage im(im_black_bgd.size(),QImage::Format_ARGB32);
606 
607  int width = im.width();
608  int height = im.height();
609  QRgb white = qRgba(255,255,255,255);
610  QRgb black = qRgba(0,0,0,255);
611 
612  for (int x = 0; x < width; ++x)
613  for (int y = 0; y < height; ++y) {
614  if (im_black_bgd.pixel(x,y)==im_white_bgd.pixel(x,y)) {
615  im.setPixel(x,y,im_white_bgd.pixel(x,y));
616  } else if (im_black_bgd.pixel(x,y)==black&&im_white_bgd.pixel(x,y)==white) {
617  im.setPixel(x,y,Qt::transparent);
618  } else {
619  //Calculate ...
620  QColor pix_b = QColor(im_black_bgd.pixel(x,y));
621  QColor pix_w = QColor(im_white_bgd.pixel(x,y));
622  qreal alpha = 1.0 - pix_w.redF() + pix_b.redF();
623  if (alpha==0) {
624  im.setPixel(x,y,Qt::transparent);
625  } else {
626  im.setPixel(x,y,qRgba(static_cast<int>(pix_b.redF()/alpha*255+0.5),
627  static_cast<int>(pix_b.greenF()/alpha*255+0.5),
628  static_cast<int>(pix_b.blueF()/alpha*255+0.5),
629  static_cast<int>(alpha*255+0.5)));
630  }
631  }
632  }
633 
634  return im;
635 }

◆ ConvertLong()

static void VP1QtInventorUtils::Imp::ConvertLong ( unsigned *  array,
long  length 
)
inlinestatic

Definition at line 133 of file VP1QtInventorUtils.cxx.

134  {
135  unsigned b1, b2, b3, b4;
136  unsigned char *ptr;
137 
138  ptr = (unsigned char *)array;
139  while (length--) {
140  b1 = *ptr++;
141  b2 = *ptr++;
142  b3 = *ptr++;
143  b4 = *ptr++;
144  *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4);
145  }
146  }

◆ ConvertShort()

static void VP1QtInventorUtils::Imp::ConvertShort ( unsigned short *  array,
long  length 
)
inlinestatic

Definition at line 120 of file VP1QtInventorUtils.cxx.

121  {
122  unsigned b1, b2;
123  unsigned char *ptr;
124 
125  ptr = (unsigned char *)array;
126  while (length--) {
127  b1 = *ptr++;
128  b2 = *ptr++;
129  *array++ = (b1 << 8) | (b2);
130  }
131  }

◆ ImageClose()

static void VP1QtInventorUtils::Imp::ImageClose ( ImageRec image)
inlinestatic

Definition at line 231 of file VP1QtInventorUtils.cxx.

232  {
233  fclose(image->file);
234  free(image->tmp);
235  free(image->tmpR);
236  free(image->tmpG);
237  free(image->tmpB);
238  free(image->rowSize);
239  free(image->rowStart);
240  free(image);
241  }

◆ ImageGetRow()

static void VP1QtInventorUtils::Imp::ImageGetRow ( ImageRec image,
unsigned char *  buf,
int  y,
int  z 
)
inlinestatic

Definition at line 243 of file VP1QtInventorUtils.cxx.

245  {
246  unsigned char *iPtr, *oPtr, pixel;
247  int count;
248 
249  if (image) {
250  if ((image->type & 0xFF00) == 0x0100) {
251 
252  int okseek = fseek(image->file, (long)image->rowStart[y+z*image->ysize], SEEK_SET);
253  int okread = fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
254  image->file);
255 
256  if( !okseek || !okread ) VP1Msg::messageDebug("fseek or fread failed!!");
257 
258  iPtr = image->tmp;
259  oPtr = buf;
260  for (;;) {
261  pixel = *iPtr++;
262  count = (int)(pixel & 0x7F);
263  if (!count) {
264  return;
265  }
266  if (pixel & 0x80) {
267  while (count--) {
268  *oPtr++ = *iPtr++;
269  }
270  } else {
271  pixel = *iPtr++;
272  while (count--) {
273  *oPtr++ = pixel;
274  }
275  }
276  }
277  } else {
278  const unsigned int yDim(y*image->xsize), zDim(z*image->xsize*image->ysize);
279  int okstatus = fseek(image->file, 512u+yDim+zDim, SEEK_SET);
280  if (okstatus) { VP1Msg::messageDebug("fseek failed!!"); }
281 
282  size_t bytesRead = 0;
283  bytesRead = fread(buf, 1, image->xsize, image->file);
284  VP1Msg::messageDebug("bytesRead(buf): " + QString::number(bytesRead));
285 
286  }
287  }
288  else {
289  std::cout << "Warning! ImageGetRow() - no 'image'..." << std::endl;
290  }
291  }

◆ ImageOpen()

static ImageRec* VP1QtInventorUtils::Imp::ImageOpen ( const char *  fileName)
inlinestatic

if (image == NULL) { //image cannot be null here, it has been used! fprintf(stderr, "image == NULL!\n"); return (ImageRec *)malloc(sizeof(ImageRec)); }

Definition at line 148 of file VP1QtInventorUtils.cxx.

149  {
150  union {
151  int testWord;
152  char testByte[4];
153  } endianTest;
154  ImageRec *image;
155  int swapFlag;
156 
157  endianTest.testWord = 1;
158  if (endianTest.testByte[0] == 1) {
159  swapFlag = 1;
160  } else {
161  swapFlag = 0;
162  }
163 
164  image = (ImageRec *)malloc(sizeof(ImageRec));
165  if (image == NULL) {
166  fprintf(stderr, "Out of memory!\n");
167  exit(1);
168  }
169  if ((image->file = fopen(fileName, "rb")) == NULL) {
170  perror(fileName);
171  exit(1);
172  }
173 
174  int bytesRead = fread(image, 1, 12, image->file);
175 
176  if (!bytesRead) {
177  fprintf(stderr, "fread failed!\n");
178  }
184  if (swapFlag) {
185  ConvertShort(&image->imagic, 6);
186  }
187 
188 
189  const unsigned int colourBuffSize=image->xsize*256u;
190  image->tmp = (unsigned char *)malloc(colourBuffSize);
191  image->tmpR = (unsigned char *)malloc(colourBuffSize);
192  image->tmpG = (unsigned char *)malloc(colourBuffSize);
193  image->tmpB = (unsigned char *)malloc(colourBuffSize);
194  if (image->tmp == NULL || image->tmpR == NULL || image->tmpG == NULL ||
195  image->tmpB == NULL) {
196  fprintf(stderr, "Out of memory!\n");
197  exit(1);
198  }
199 
200  //should test upper limits on x here...but what is sensible? 1Mb? 100Mb?
201  if ((image->type & 0xFF00) == 0x0100) {
202  size_t x = ((size_t)image->ysize * (size_t)image->zsize) * sizeof(unsigned);
203  image->rowStart = (unsigned *)malloc(x);
204  image->rowSize = (int *)malloc(x);
205  if (image->rowStart == NULL || image->rowSize == NULL) {
206  fprintf(stderr, "Out of memory!\n");
207  exit(1);
208  }
209  image->rleEnd = 512 + (2 * x);
210  const int fseekRetVal= fseek(image->file, 512, SEEK_SET);
211  if (fseekRetVal !=0){
212  fprintf(stderr, "Something very wrong with fseek near line 205 of VP1QtInventorUtils.cxx");
213  }
214  size_t bytesRead = 0;
215  bytesRead = fread(image->rowStart, 1, x, image->file);
216  VP1Msg::messageDebug("bytesRead(rowStart): " + QString::number(bytesRead));
217  bytesRead = fread(image->rowSize, 1, x, image->file);
218  VP1Msg::messageDebug("bytesRead(rowSize): " + QString::number(bytesRead));
219 
220  if (swapFlag) {
221  ConvertLong(image->rowStart, x/(int)sizeof(unsigned));
222  ConvertLong((unsigned *)image->rowSize, x/(int)sizeof(int));
223  }
224  } else {
225  image->rowStart = NULL;
226  image->rowSize = NULL;
227  }
228  return image;
229  }

◆ latorgba()

static void VP1QtInventorUtils::Imp::latorgba ( unsigned char *  b,
unsigned char *  a,
unsigned char *  l,
int  n 
)
inlinestatic

Definition at line 69 of file VP1QtInventorUtils.cxx.

70  {
71  while (n--) {
72  l[0] = *b;
73  l[1] = *b;
74  l[2] = *b;
75  l[3] = *a;
76  l += 4; ++b; ++a;
77  }
78  }

◆ read_texture()

static unsigned* VP1QtInventorUtils::Imp::read_texture ( const char *  name,
int *  width,
int *  height,
int *  components 
)
inlinestatic

Definition at line 293 of file VP1QtInventorUtils.cxx.

294  {
295  unsigned *base, *lptr;
296  unsigned char *rbuf, *gbuf, *bbuf, *abuf;
297  ImageRec *image;
298  int y;
299 
300  image = ImageOpen(name);
301 
302  if(!image)
303  return NULL;
304 
305  (*width)=image->xsize;
306  (*height)=image->ysize;
307  (*components)=image->zsize;
308  const unsigned int imageWidth = image->xsize;
309  const unsigned int imageHeight = image->ysize;
310  const unsigned int uintSize(sizeof(unsigned)), ucharSize(sizeof(unsigned char));
311  const unsigned int colourBufSize=imageWidth*ucharSize;
312  base = (unsigned *)malloc(imageWidth*imageHeight*uintSize);
313  rbuf = (unsigned char *)malloc(colourBufSize);
314  gbuf = (unsigned char *)malloc(colourBufSize);
315  bbuf = (unsigned char *)malloc(colourBufSize);
316  abuf = (unsigned char *)malloc(colourBufSize);
317  if(!base || !rbuf || !gbuf || !bbuf) {
318  ImageClose(image);
319  if (base) free(base);
320  if (rbuf) free(rbuf);
321  if (gbuf) free(gbuf);
322  if (bbuf) free(bbuf);
323  if (abuf) free(abuf);
324  return NULL;
325  }
326  lptr = base;
327  for (y=0; y<image->ysize; ++y) {
328  if (image->zsize>=4) {
329  ImageGetRow(image,rbuf,y,0);
330  ImageGetRow(image,gbuf,y,1);
331  ImageGetRow(image,bbuf,y,2);
332  ImageGetRow(image,abuf,y,3);
333  rgbatorgba(rbuf,gbuf,bbuf,abuf,(unsigned char *)lptr,image->xsize);
334  lptr += image->xsize;
335  } else if(image->zsize==3) {
336  ImageGetRow(image,rbuf,y,0);
337  ImageGetRow(image,gbuf,y,1);
338  ImageGetRow(image,bbuf,y,2);
339  rgbtorgba(rbuf,gbuf,bbuf,(unsigned char *)lptr,image->xsize);
340  lptr += image->xsize;
341  } else if(image->zsize==2) {
342  ImageGetRow(image,rbuf,y,0);
343  ImageGetRow(image,abuf,y,1);
344  latorgba(rbuf,abuf,(unsigned char *)lptr,image->xsize);
345  lptr += image->xsize;
346  } else {
347  ImageGetRow(image,rbuf,y,0);
348  bwtorgba(rbuf,(unsigned char *)lptr,image->xsize);
349  lptr += image->xsize;
350  }
351  }
352  ImageClose(image);
353  free(rbuf);
354  free(gbuf);
355  free(bbuf);
356  free(abuf);
357 
358  return (unsigned *) base;
359  }

◆ rgbatorgba()

static void VP1QtInventorUtils::Imp::rgbatorgba ( unsigned char *  r,
unsigned char *  g,
unsigned char *  b,
unsigned char *  a,
unsigned char *  l,
int  n 
)
inlinestatic

Definition at line 92 of file VP1QtInventorUtils.cxx.

94  {
95  while (n--) {
96  l[0] = r[0];
97  l[1] = g[0];
98  l[2] = b[0];
99  l[3] = a[0];
100  l += 4; ++r; ++g; ++b; ++a;
101  }
102  }

◆ rgbtorgba()

static void VP1QtInventorUtils::Imp::rgbtorgba ( unsigned char *  r,
unsigned char *  g,
unsigned char *  b,
unsigned char *  l,
int  n 
)
inlinestatic

Definition at line 80 of file VP1QtInventorUtils.cxx.

82  {
83  while (n--) {
84  l[0] = r[0];
85  l[1] = g[0];
86  l[2] = b[0];
87  l[3] = 0xff;
88  l += 4; ++r; ++g; ++b;
89  }
90  }

Member Data Documentation

◆ allowedLineWidthGranularity

double VP1QtInventorUtils::Imp::allowedLineWidthGranularity = -1.0
static

Definition at line 371 of file VP1QtInventorUtils.cxx.

◆ allowedLineWidthMax

double VP1QtInventorUtils::Imp::allowedLineWidthMax = -1.0
static

Definition at line 370 of file VP1QtInventorUtils.cxx.

◆ allowedLineWidthMin

double VP1QtInventorUtils::Imp::allowedLineWidthMin = -1.0
static

Definition at line 369 of file VP1QtInventorUtils.cxx.

◆ allowedPointSizeGranularity

double VP1QtInventorUtils::Imp::allowedPointSizeGranularity = -1.0
static

Definition at line 374 of file VP1QtInventorUtils.cxx.

◆ allowedPointSizeMax

double VP1QtInventorUtils::Imp::allowedPointSizeMax = -1.0
static

Definition at line 373 of file VP1QtInventorUtils.cxx.

◆ allowedPointSizeMin

double VP1QtInventorUtils::Imp::allowedPointSizeMin = -1.0
static

Definition at line 372 of file VP1QtInventorUtils.cxx.

◆ buffer

char * VP1QtInventorUtils::Imp::buffer = 0
static

Definition at line 362 of file VP1QtInventorUtils.cxx.

◆ buffer_size

size_t VP1QtInventorUtils::Imp::buffer_size = 0
static

Definition at line 363 of file VP1QtInventorUtils.cxx.

◆ lineWidthAndPointSizeNeedsInit

bool VP1QtInventorUtils::Imp::lineWidthAndPointSizeNeedsInit = true
static

Definition at line 368 of file VP1QtInventorUtils.cxx.


The documentation for this class was generated from the following file:
base
std::string base
Definition: hcg.cxx:78
beamspotman.r
def r
Definition: beamspotman.py:676
VP1QtInventorUtils::Imp::rgbtorgba
static void rgbtorgba(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:80
VP1QtInventorUtils::Imp::bwtorgba
static void bwtorgba(unsigned char *b, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:58
VP1QtInventorUtils::Imp::ConvertShort
static void ConvertShort(unsigned short *array, long length)
Definition: VP1QtInventorUtils.cxx:120
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1QtInventorUtils::Imp::ImageOpen
static ImageRec * ImageOpen(const char *fileName)
Definition: VP1QtInventorUtils.cxx:148
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
VP1QtInventorUtils::Imp::buffer_realloc
static void * buffer_realloc(void *bufptr, size_t size)
Definition: VP1QtInventorUtils.cxx:1379
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
python.atlas_oh.im
im
Definition: atlas_oh.py:167
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
x
#define x
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
VP1QtInventorUtils::Imp::buffer_size
static size_t buffer_size
Definition: VP1QtInventorUtils.cxx:363
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
VP1QtInventorUtils::Imp::ImageRec
struct VP1QtInventorUtils::Imp::_ImageRec ImageRec
z
#define z
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:731
VP1QtInventorUtils::Imp::buffer
static char * buffer
Definition: VP1QtInventorUtils.cxx:362
VP1QtInventorUtils::Imp::ImageClose
static void ImageClose(ImageRec *image)
Definition: VP1QtInventorUtils.cxx:231
VP1QtInventorUtils::Imp::ImageGetRow
static void ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z)
Definition: VP1QtInventorUtils.cxx:243
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:129
VP1QtInventorUtils::Imp::rgbatorgba
static void rgbatorgba(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:92
calibdata.exit
exit
Definition: calibdata.py:236
lumiFormat.array
array
Definition: lumiFormat.py:98
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MyPlots.image
string image
Definition: MyPlots.py:43
VP1QtInventorUtils::Imp::ConvertLong
static void ConvertLong(unsigned *array, long length)
Definition: VP1QtInventorUtils.cxx:133
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
y
#define y
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
VP1QtInventorUtils::Imp::latorgba
static void latorgba(unsigned char *b, unsigned char *a, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:69
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
SiliconTech::pixel
@ pixel