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 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 60 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 1373 of file VP1QtInventorUtils.cxx.

1374 {
1375  buffer = (char *)realloc(bufptr, size);
1376  buffer_size = size;
1377  return buffer;
1378 }

◆ buffer_vrmlwriteaction()

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

Definition at line 1397 of file VP1QtInventorUtils.cxx.

1398 {
1399  SoToVRML2Action vwa;
1400 
1401  vwa.apply(root);
1402  SoVRMLGroup * newroot = vwa.getVRML2SceneGraph();
1403 
1404  SoOutput out;
1405  out.openFile(qPrintable(filename));
1406  out.setHeaderString("#VRML V2.0 utf8");
1407  SoWriteAction wra(&out);
1408  wra.apply(newroot);
1409  out.closeFile();
1410  newroot->unref();
1411  return;
1412 }

◆ buffer_writeaction()

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

Definition at line 1381 of file VP1QtInventorUtils.cxx.

1382 {
1383  SoOutput out;
1384  buffer = (char *)malloc(1024);
1385  buffer_size = 1024;
1386  out.setBuffer(buffer, buffer_size, buffer_realloc);
1387 
1388  SoWriteAction wa(&out);
1389  wa.apply(root);
1390 
1391  QString s(buffer);
1392  free(buffer);
1393  return s;
1394 }

◆ bwtorgba()

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

Definition at line 65 of file VP1QtInventorUtils.cxx.

66  {
67  while (n--) {
68  l[0] = *b;
69  l[1] = *b;
70  l[2] = *b;
71  l[3] = 0xff;
72  l += 4; ++b;
73  }
74  }

◆ constructImageWithTransparentBackground()

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

Definition at line 594 of file VP1QtInventorUtils.cxx.

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

◆ ConvertLong()

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

Definition at line 127 of file VP1QtInventorUtils.cxx.

128  {
129  while (length--) {
131  ++array;
132  }
133  }

◆ ImageClose()

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

Definition at line 223 of file VP1QtInventorUtils.cxx.

224  {
225  fclose(image->file);
226  free(image->tmp);
227  free(image->tmpR);
228  free(image->tmpG);
229  free(image->tmpB);
230  free(image->rowSize);
231  free(image->rowStart);
232  free(image);
233  }

◆ ImageGetRow()

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

Definition at line 235 of file VP1QtInventorUtils.cxx.

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

◆ 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 135 of file VP1QtInventorUtils.cxx.

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

◆ latorgba()

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

Definition at line 76 of file VP1QtInventorUtils.cxx.

77  {
78  while (n--) {
79  l[0] = *b;
80  l[1] = *b;
81  l[2] = *b;
82  l[3] = *a;
83  l += 4; ++b; ++a;
84  }
85  }

◆ read_texture()

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

Definition at line 285 of file VP1QtInventorUtils.cxx.

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

◆ 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 99 of file VP1QtInventorUtils.cxx.

101  {
102  while (n--) {
103  l[0] = r[0];
104  l[1] = g[0];
105  l[2] = b[0];
106  l[3] = a[0];
107  l += 4; ++r; ++g; ++b; ++a;
108  }
109  }

◆ rgbtorgba()

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

Definition at line 87 of file VP1QtInventorUtils.cxx.

89  {
90  while (n--) {
91  l[0] = r[0];
92  l[1] = g[0];
93  l[2] = b[0];
94  l[3] = 0xff;
95  l += 4; ++r; ++g; ++b;
96  }
97  }

Member Data Documentation

◆ allowedLineWidthGranularity

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

Definition at line 363 of file VP1QtInventorUtils.cxx.

◆ allowedLineWidthMax

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

Definition at line 362 of file VP1QtInventorUtils.cxx.

◆ allowedLineWidthMin

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

Definition at line 361 of file VP1QtInventorUtils.cxx.

◆ allowedPointSizeGranularity

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

Definition at line 366 of file VP1QtInventorUtils.cxx.

◆ allowedPointSizeMax

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

Definition at line 365 of file VP1QtInventorUtils.cxx.

◆ allowedPointSizeMin

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

Definition at line 364 of file VP1QtInventorUtils.cxx.

◆ buffer

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

Definition at line 354 of file VP1QtInventorUtils.cxx.

◆ buffer_size

size_t VP1QtInventorUtils::Imp::buffer_size = 0
static

Definition at line 355 of file VP1QtInventorUtils.cxx.

◆ lineWidthAndPointSizeNeedsInit

bool VP1QtInventorUtils::Imp::lineWidthAndPointSizeNeedsInit = true
static

Definition at line 360 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:674
VP1QtInventorUtils::Imp::rgbtorgba
static void rgbtorgba(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:87
VP1QtInventorUtils::Imp::bwtorgba
static void bwtorgba(unsigned char *b, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:65
add-xsec-uncert-quadrature-N.alpha
alpha
Definition: add-xsec-uncert-quadrature-N.py:110
VP1QtInventorUtils::Imp::ImageOpen
static ImageRec * ImageOpen(const char *fileName)
Definition: VP1QtInventorUtils.cxx:135
VP1QtInventorUtils::Imp::buffer_realloc
static void * buffer_realloc(void *bufptr, size_t size)
Definition: VP1QtInventorUtils.cxx:1373
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
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:157
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
x
#define x
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
VP1QtInventorUtils::Imp::buffer_size
static size_t buffer_size
Definition: VP1QtInventorUtils.cxx:355
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
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:729
VP1QtInventorUtils::Imp::buffer
static char * buffer
Definition: VP1QtInventorUtils.cxx:354
VP1QtInventorUtils::Imp::ImageClose
static void ImageClose(ImageRec *image)
Definition: VP1QtInventorUtils.cxx:223
VP1QtInventorUtils::Imp::ImageGetRow
static void ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z)
Definition: VP1QtInventorUtils.cxx:235
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:127
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:99
calibdata.exit
exit
Definition: calibdata.py:235
CxxUtils::byteswap
constexpr T byteswap(T value) noexcept
Reverse the bytes in n.
Definition: byteswap.h:42
lumiFormat.array
array
Definition: lumiFormat.py:91
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
MyPlots.image
string image
Definition: MyPlots.py:42
VP1QtInventorUtils::Imp::ConvertLong
static void ConvertLong(unsigned *array, long length)
Definition: VP1QtInventorUtils.cxx:127
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
y
#define y
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
VP1QtInventorUtils::Imp::latorgba
static void latorgba(unsigned char *b, unsigned char *a, unsigned char *l, int n)
Definition: VP1QtInventorUtils.cxx:76
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
SiliconTech::pixel
@ pixel