ATLAS Offline Software
VP1QtInventorUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class VP1QtInventorUtils //
9 // //
10 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
11 // //
12 // Initial version: June 2007 //
13 // //
15 
18 #include "VP1Base/VP1Msg.h"
19 #include "CxxUtils/byteswap.h"
20 
21 #include "Inventor/nodes/SoMaterial.h"
22 #include <Inventor/nodes/SoPerspectiveCamera.h>
23 #include <Inventor/nodes/SoOrthographicCamera.h>
24 #include <Inventor/nodes/SoGroup.h>
25 #include <Inventor/nodes/SoNurbsCurve.h>
26 #include <Inventor/nodes/SoCoordinate4.h>
27 
28 #include <Inventor/SoPath.h>
29 #include <Inventor/SoOffscreenRenderer.h>
30 #include "Inventor/Qt/SoQtRenderArea.h"
31 #include <Inventor/actions/SoSearchAction.h>
32 #include <Inventor/SoDB.h>
33 #include <Inventor/actions/SoWriteAction.h>
34 
35 #include <Inventor/nodes/SoLineSet.h>
36 #include <Inventor/nodes/SoVertexProperty.h>
37 
38 
39 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
40 #include <Inventor/actions/SoToVRML2Action.h>
41 
42 #include <QDir>
43 #include <QTime>
44 #include <QBuffer>
45 #include <QByteArray>
46 #include <QTextStream>
47 #include <QSlider>
48 #include <QGLFormat>
49 #include <QtCoreVersion>
50 
51 #include <iostream>
52 namespace{
53  unsigned char *
54  ucharAddress(auto * pv){
55  return reinterpret_cast<unsigned char *>(pv);
56  }
57 }
58 
59 //____________________________________________________________________
61 public:
62 
63  static QImage constructImageWithTransparentBackground(const QImage& im_black_bgd, const QImage& image_white_bgd);
64 
65  static void bwtorgba(unsigned char *b,unsigned char *l,int n)
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  }
75 
76  static void latorgba(unsigned char *b, unsigned char *a,unsigned char *l,int n)
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  }
86 
87  static void rgbtorgba(unsigned char *r,unsigned char *g,
88  unsigned char *b,unsigned char *l,int n)
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  }
98 
99  static void rgbatorgba(unsigned char *r,unsigned char *g,
100  unsigned char *b,unsigned char *a,unsigned char *l,int n)
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  }
110 
111  typedef struct _ImageRec {
112  unsigned short imagic;
113  unsigned short type;
114  unsigned short dim;
115  unsigned short xsize, ysize, zsize;
116  unsigned int min, max;
117  unsigned int wasteBytes;
118  char name[80];
119  unsigned long colorMap;
120  FILE *file;
121  unsigned char *tmp, *tmpR, *tmpG, *tmpB;
122  unsigned long rleEnd;
123  unsigned int *rowStart;
124  int *rowSize;
126 
127  static void ConvertLong(unsigned *array, long length)
128  {
129  while (length--) {
131  ++array;
132  }
133  }
134 
135  static ImageRec *ImageOpen(const char *fileName)
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  }
222 
223  static void ImageClose(ImageRec *image)
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  }
234 
235  static void ImageGetRow(ImageRec *image,
236  unsigned char *buf, int y, int z)
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  }
284 
285  static unsigned *read_texture(const char *name, int *width, int *height, int *components)
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  }
352 
353  //read/write scenegraphs:
354  static char * buffer;
355  static size_t buffer_size;
356  static void * buffer_realloc(void * bufptr, size_t size);
357  static QString buffer_writeaction(SoNode * root);
358  static void buffer_vrmlwriteaction(SoNode * root, const QString& filename);
359 
361  static double allowedLineWidthMin;
362  static double allowedLineWidthMax;
364  static double allowedPointSizeMin;
365  static double allowedPointSizeMax;
367 
368  //Prerender callback:
369  // static void prerendercallback_rendertoimage( void * userdata, class SoGLRenderAction * action );
370 
371 };
372 
380 
381 //____________________________________________________________________
383 {
384 }
385 
386 //____________________________________________________________________
388 {
389 }
390 
391 //____________________________________________________________________
393 {
394  return QPixmap::fromImage(imageFromRGBFile(filename));
395 
396 }
397 
398 //____________________________________________________________________
400 {
401  int width = 0;
402  int height = 0;
403  int components = 0;
404 
405  unsigned * imagedata = Imp::read_texture(filename.toStdString().c_str(), &width, &height, &components);
406  if( width == 0 || height == 0 ) std::cout << "VP1QtInventorUtils::imageFromRGBFile - read_texture failed?" << std::endl;
407 
408  unsigned char * data = reinterpret_cast<unsigned char*>(imagedata);
409 
410 
411  QImage im(width,height, ( components <= 3 ? QImage::Format_RGB32 : QImage::Format_ARGB32 ) );
412 
413  int x, y, index = 0;
414  for (y=0; y<height; ++y) {
415  for (x=0; x<width; ++x) {
416  //Fixme: Does this also work for components=1,2 4??
417  im.setPixel ( x, height-y-1, QColor( static_cast<int>(data[index]),static_cast<int>(data[index+1]),static_cast<int>(data[index+2]),static_cast<int>(data[index+3]) ).rgb() );
418  index+=4;
419  }
420  }
421  free(imagedata);
422  return im;
423 }
424 
425 
426 //____________________________________________________________________
427 //QImage VP1QtInventorUtils::renderToImage(SoQtRenderArea *ra, int pixels_x, int pixels_y,
428 QImage VP1QtInventorUtils::renderToImage(VP1ExaminerViewer *ra, int pixels_x, int pixels_y,
429  bool transparent_background, double actualRenderedSizeFact )
430 {
431  VP1Msg::messageVerbose("VP1QtInventorUtils::renderToImage()");
432 
433  if (!ra)
434  return QImage();
435 
436 
437  // transp,anti: Render two large, figure out transp, then resize (gives best result)
438  // transp : Render two normal, then figure out transp.
439  // : Render one normal.
440  // anti : Render one large, resize.
441 
442  if (actualRenderedSizeFact!=1.0&&!transparent_background) {
443  return renderToImage(ra,
444  static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
445  static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
446  false,
447  1.0)
448  .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
449  }
450 
451  if (transparent_background) {
452  //Lets make it transparent. We do this by rendering with both
453  //white and black background, and using the two results to figure
454  //out the final result.
455 
456  SbColor save_bgd = ra->getBackgroundColor();
457  SbBool save_redraw = ra->isAutoRedraw();
458 
459  ra->setAutoRedraw(false);
460 
461 
462  QImage im_black_bgd, im_white_bgd;
463  if (actualRenderedSizeFact==1.0) {
464  ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
465  im_black_bgd = renderToImage(ra, pixels_x, pixels_y,false,1.0);
466  ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
467  im_white_bgd = renderToImage(ra, pixels_x, pixels_y,false,1.0);
468  } else {
469  ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
470  im_black_bgd = renderToImage(ra, static_cast<int>(pixels_x*actualRenderedSizeFact+0.5), static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),false,1.0);
471  ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
472  im_white_bgd = renderToImage(ra, static_cast<int>(pixels_x*actualRenderedSizeFact+0.5), static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),false,1.0);
473  }
474 
475  ra->setBackgroundColor(save_bgd);
476  ra->setAutoRedraw(save_redraw);
477 
478  if (actualRenderedSizeFact==1.0)
479  return Imp::constructImageWithTransparentBackground(im_black_bgd, im_white_bgd);
480  else
481  return Imp::constructImageWithTransparentBackground(im_black_bgd, im_white_bgd)
482  .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
483  }
484 
485  // DEFAULT CALL
486 
487  //debug
488  int off = ra->getStereoOffsetSlot();
489  int typeSt = ra->getStereoTypeSlot();
490  VP1Msg::messageVerbose("off: " + QString::number( off ) + " - type: " + QString::number( typeSt ) );
491 
492  // get the scenegraph
493  SoNode *root = ra->getSceneManager()->getSceneGraph();
494  VP1Msg::messageVerbose("got the scenegraph");
495  //std::cout << "root: " << root << std::endl;
496 
497  // get the overlay scenegraph
498 // SoNode *rootOverlay = ra->getOverlaySceneManager()->getSceneGraph();
499  SoNode *rootOverlay = ra->getOverlaySceneGraph();
500  VP1Msg::messageVerbose("got the overlay scenegraph");
501  //std::cout << "overlay root: " << rootOverlay << std::endl;
502 
503  // set a new viewport to the preferred size
504  SbViewportRegion myViewport;
505  myViewport.setWindowSize(SbVec2s(pixels_x,pixels_y));
506 
507  QString tmppath(QDir::tempPath());
508  if (!tmppath.endsWith(QDir::separator()))
509  tmppath+=QDir::separator();
510  tmppath += "vp1tmpfileXXXXXX.rgb";
511  std::string stmppath = tmppath.toStdString();
512  int tmpfd = mkstemps (stmppath.data(), 4);
513  FILE* tmpf = fdopen (tmpfd, "w");
514  QString tmpfile (stmppath.c_str());
515 
516  // declare a new renderer with the viewport created above
517  SoOffscreenRenderer *myRenderer = new SoOffscreenRenderer(myViewport);
518 
519  //Copy settings from the render area:
520  myRenderer->setBackgroundColor(ra->getBackgroundColor());
521 
522 
523  myRenderer->setComponents(SoOffscreenRenderer::RGB_TRANSPARENCY);
524  myRenderer->getGLRenderAction()->setTransparencyType(ra->getTransparencyType());
525  // myRenderer->getGLRenderAction()->addPreRenderCallback( VP1QtInventorUtils::Imp::prerendercallback_rendertoimage, 0/*userdata*/ );
526 
527  // Anti-Aliasing
528  SbBool smoothing; int numPasses;
529  ra->getAntialiasing (smoothing, numPasses);
530  myRenderer->getGLRenderAction()->setSmoothing (smoothing);
531  myRenderer->getGLRenderAction()->setNumPasses(numPasses);
532 
533  //Other things we could set:
534  // Overlay scenegraph.
535 
536  // render the scenegraph
537  // if fails, delete the renderer and return an empty image
538  if (!myRenderer->render(root)) {
539  delete myRenderer;
540  fclose (tmpf);
541  return QImage();
542  }
543  VP1Msg::messageVerbose("rendered the scenegraph");
544 
545  // render the overlay scenegraph
546  // if fails, delete the renderer and return an empty image
547  if (rootOverlay) {
548  bool okOver = myRenderer->render(rootOverlay);
549  if ( !okOver) {
550  delete myRenderer;
551  fclose (tmpf);
552  return QImage();
553  }
554  else {
555  VP1Msg::messageVerbose("rendered the overlay scenegraph");
556  }
557  }
558 
559  // write the rendered image to the temp file
560  // if fails, remove the temp file and return an empty image
561  if (!myRenderer->writeToRGB(tmpf)) {
562  fclose (tmpf);
563  if (QFile::exists(tmpfile))
564  QFile(tmpfile).remove();
565  delete myRenderer;
566  return QImage();
567  }
568 
569  fclose (tmpf);
570 
571  // delete the renderer
572  delete myRenderer;
573 
574  // get the rendered image from the temp file as a Qt QImage instance
575  QImage im(imageFromRGBFile(tmpfile));
576 
577  // delete the temp file
578  if (QFile::exists(tmpfile))
579  QFile(tmpfile).remove();
580 
581  // return the rendered image
582  return im;
583 }
584 
585 //____________________________________________________________________
586 //QPixmap VP1QtInventorUtils::renderToPixmap(SoQtRenderArea *ra, int pixels_x, int pixels_y,
587 QPixmap VP1QtInventorUtils::renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y,
588  bool transparent_background, double actualRenderedSizeFact )
589 {
590  return QPixmap::fromImage(renderToImage(ra, pixels_x, pixels_y, transparent_background, actualRenderedSizeFact));
591 }
592 
593 //____________________________________________________________________
594 QImage VP1QtInventorUtils::Imp::constructImageWithTransparentBackground(const QImage& im_black_bgd, const QImage& im_white_bgd)
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 }
630 
631 
632 //____________________________________________________________________
633 SoGLRenderAction::TransparencyType VP1QtInventorUtils::getDefaultVP1TransparencyType()
634 {
635  return SoGLRenderAction::DELAYED_BLEND;
636 }
637 
638 //____________________________________________________________________
639 QList<SoGLRenderAction::TransparencyType> VP1QtInventorUtils::getAllTransparencyTypes()
640 {
641  QList<SoGLRenderAction::TransparencyType> l;
643  << SoGLRenderAction::SCREEN_DOOR
645  << SoGLRenderAction::DELAYED_ADD
646  << SoGLRenderAction::SORTED_OBJECT_ADD
647  << SoGLRenderAction::BLEND
648  << SoGLRenderAction::DELAYED_BLEND
649  << SoGLRenderAction::SORTED_OBJECT_BLEND
650  << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD
651  << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND
652  << SoGLRenderAction::SORTED_LAYERS_BLEND;
653  return l;
654 }
655 
656 //____________________________________________________________________
657 int VP1QtInventorUtils::transparencyTypeToInt( SoGLRenderAction::TransparencyType tt )
658 {
659  switch (tt) {
660  case SoGLRenderAction::SCREEN_DOOR: return 0;
661  case SoGLRenderAction::ADD: return 1;
662  case SoGLRenderAction::DELAYED_ADD: return 2;
663  case SoGLRenderAction::SORTED_OBJECT_ADD: return 3;
664  case SoGLRenderAction::BLEND: return 4;
665  case SoGLRenderAction::DELAYED_BLEND: return 5;
666  case SoGLRenderAction::SORTED_OBJECT_BLEND: return 6;
667  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD: return 7;
668  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND: return 8;
669  case SoGLRenderAction::NONE: return 9;
670  case SoGLRenderAction::SORTED_LAYERS_BLEND: return 10;
671  default:
672  VP1Msg::messageDebug("VP1QtInventorUtils::transparencyTypeToInt ERROR: Unknown transparency type");
673  return -1;
674  }
675 }
676 //____________________________________________________________________
677 SoGLRenderAction::TransparencyType VP1QtInventorUtils::intToTransparencyType( int i )
678 {
679  switch (i) {
680  case 0: return SoGLRenderAction::SCREEN_DOOR;
681  case 1: return SoGLRenderAction::ADD;
682  case 2: return SoGLRenderAction::DELAYED_ADD;
683  case 3: return SoGLRenderAction::SORTED_OBJECT_ADD;
684  case 4: return SoGLRenderAction::BLEND;
685  case 5: return SoGLRenderAction::DELAYED_BLEND;
686  case 6: return SoGLRenderAction::SORTED_OBJECT_BLEND;
687  case 7: return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD;
688  case 8: return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND;
689  case 9: return SoGLRenderAction::NONE;
690  case 10: return SoGLRenderAction::SORTED_LAYERS_BLEND;
691  default:
692  VP1Msg::messageDebug("VP1QtInventorUtils::intToTransparencyType ERROR: int out of range "+VP1Msg::str(i));
693  return SoGLRenderAction::DELAYED_BLEND;
694  }
695 }
696 
697 
698 //____________________________________________________________________
699 QString VP1QtInventorUtils::transparencyType2PrettyString( SoGLRenderAction::TransparencyType tt )
700 {
701  switch (tt) {
702  case SoGLRenderAction::DELAYED_BLEND: return "Delayed blend"; break;
703  case SoGLRenderAction::SCREEN_DOOR: return "Screen door"; break;
704  case SoGLRenderAction::ADD: return "Add"; break;
705  case SoGLRenderAction::DELAYED_ADD: return "Delayed add"; break;
706  case SoGLRenderAction::SORTED_OBJECT_ADD: return "Sorted object add"; break;
707  case SoGLRenderAction::BLEND: return "Blend (Best for Geo volumes)"; break;
708  case SoGLRenderAction::SORTED_OBJECT_BLEND: return "Sorted object blend (Best for physics objects: jets, tracks, ...)"; break;
709  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD: return "Sorted object sorted triangle add"; break;
710  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND: return "Sorted object sorted triangle blend"; break;
711  case SoGLRenderAction::NONE: return "None"; break;
712  case SoGLRenderAction::SORTED_LAYERS_BLEND: return "Sorted layers blend"; break;
713  default: return "";
714  }
715 
716 }
717 
718 //____________________________________________________________________
719 QByteArray VP1QtInventorUtils::serialize( const SbRotation& rot )
720 {
721 
722  // ===> Setup stream writing to a byteArray:
723  QByteArray byteArray;
724  QBuffer buffer(&byteArray);
725  buffer.open(QIODevice::WriteOnly);
726  QDataStream out(&buffer);
727 
728  //Write data:
729 
730  float q0,q1,q2,q3;//quarternion components
731  rot.getValue (q0,q1,q2,q3);
732 
733  out<<(double)q0;
734  out<<(double)q1;
735  out<<(double)q2;
736  out<<(double)q3;
737 
738  if (VP1Msg::verbose()) {
739  //Fixme: check for nan's.
740  VP1Msg::messageVerbose("VP1QtInventorUtils::serialize SbRotation(q0,q1,q2,q3) = ("
741  +QString::number(q0)+", "+QString::number(q1)+", "
742  +QString::number(q2)+", "+QString::number(q3)+")");
743  }
744 
745  // ===> Finish up:
746  buffer.close();
747  return byteArray;
748 }
749 
750 //____________________________________________________________________
751 bool VP1QtInventorUtils::deserialize( QByteArray& ba, SbRotation& rot )
752 {
753  // ===> Setup stream for getting the contents of the byteArray:
754  QBuffer buffer(&ba);
755  buffer.open(QIODevice::ReadOnly);
756  QDataStream state(&buffer);
758  if(ba.size()==16) {
759  // Single precision
760  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
761  float q0,q1,q2,q3;//quarternion components
762 
763  state >> q0;
764  state >> q1;
765  state >> q2;
766  state >> q3;
767 
768  rot.setValue (q0,q1,q2,q3);
769 
770  if (VP1Msg::verbose()) {
771  //Fixme: check for nan's.
772  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbRotation(q0,q1,q2,q3) = ("
773  +QString::number(q0)+", "+QString::number(q1)+", "
774  +QString::number(q2)+", "+QString::number(q3)+")");
775  }
776  }
777  else {
778  // Double precision
779  double q0,q1,q2,q3;//quarternion components
780 
781  state >> q0;
782  state >> q1;
783  state >> q2;
784  state >> q3;
785 
786  rot.setValue (q0,q1,q2,q3);
787 
788  if (VP1Msg::verbose()) {
789  //Fixme: check for nan's.
790  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbRotation(q0,q1,q2,q3) = ("
791  +QString::number(q0)+", "+QString::number(q1)+", "
792  +QString::number(q2)+", "+QString::number(q3)+")");
793  }
794  }
795 
796  // ===> Finish up:
797  buffer.close();
798 
799  return true;//Fixme: How to check for errors? - at least check for nan's and determinant?
800 }
801 
802 //____________________________________________________________________
803 QByteArray VP1QtInventorUtils::serialize( const SbVec3f& vec )
804 {
805  // ===> Setup stream writing to a byteArray:
806  QByteArray byteArray;
807  QBuffer buffer(&byteArray);
808  buffer.open(QIODevice::WriteOnly);
809  QDataStream out(&buffer);
810 
811  //Write data:
812  float x,y,z;
813  vec.getValue(x,y,z);
814  out << (double)x;
815  out << (double)y;
816  out << (double)z;
817 
818  if (VP1Msg::verbose()) {
819  //Fixme: check for nan's.
820  VP1Msg::messageVerbose("VP1QtInventorUtils::serialize SbVec3f(x,y,z) = ("
821  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
822  }
823 
824  // ===> Finish up:
825  buffer.close();
826  return byteArray;
827 }
828 
829 //____________________________________________________________________
830 bool VP1QtInventorUtils::deserialize( QByteArray& ba, SbVec3f& vec )
831 {
832  // ===> Setup stream for getting the contents of the byteArray:
833  QBuffer buffer(&ba);
834  buffer.open(QIODevice::ReadOnly);
835  QDataStream state(&buffer);
837  if(ba.size()==12) {
838  // Single precision
839  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
840  float x,y,z;
841 
842  state >> x;
843  state >> y;
844  state >> z;
845 
846  vec.setValue (x,y,z);
847 
848  if (VP1Msg::verbose()) {
849  //Fixme: check for nan's.
850  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbVec3f(x,y,z) = ("
851  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
852  }
853  }
854  else {
855  double x,y,z;
856 
857  state >> x;
858  state >> y;
859  state >> z;
860 
861  vec.setValue (x,y,z);
862 
863  if (VP1Msg::verbose()) {
864  //Fixme: check for nan's.
865  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbVec3f(x,y,z) = ("
866  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
867  }
868  }
869 
870  // ===> Finish up:
871  buffer.close();
872 
873  return true;//Fixme: How to check for errors? - at least check for nan's
874 
875 }
876 
877 //____________________________________________________________________
878 QByteArray VP1QtInventorUtils::serializeSoCameraParameters( const SoCamera& cam ) {
879 
880  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters start");
881 
882  // ===> Setup stream writing to a byteArray:
883  QByteArray byteArray;
884  QBuffer buffer(&byteArray);
885  buffer.open(QIODevice::WriteOnly);
886  QDataStream out(&buffer);
887 
888  cam.ref();
889  //Write data:
890  SbRotation camrot = cam.orientation.getValue();
891  out << serialize(camrot);
892  SbVec3f campos = cam.position.getValue();
893  out << serialize(campos);
894  float f_aspectRatio(cam.aspectRatio.getValue());
895  float f_nearDistance(cam.nearDistance.getValue());
896  float f_farDistance(cam.farDistance.getValue());
897  float f_focalDistance(cam.focalDistance.getValue());
898  out << (double)f_aspectRatio;
899  out << (double)f_nearDistance;
900  out << (double)f_farDistance;
901  out << (double)f_focalDistance;
902 
903  int viewportmap(-1);
904  switch (cam.viewportMapping.getValue()) {
905  case SoCamera::CROP_VIEWPORT_FILL_FRAME: viewportmap = 0;break;
906  case SoCamera::CROP_VIEWPORT_LINE_FRAME: viewportmap = 1;break;
907  case SoCamera::CROP_VIEWPORT_NO_FRAME: viewportmap = 2;break;
908  case SoCamera::ADJUST_CAMERA: viewportmap = 3;break;
909  case SoCamera::LEAVE_ALONE: viewportmap = 4;break;
910  }
911  out << viewportmap;
912 
913  //Camera type and specialised info:
914  int camtype (-1);
915  if (cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()))
916  camtype = 0;
917  else if (cam.getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId()))
918  camtype = 1;
919 
920  out <<camtype;
921  if (camtype==0) {
922  out << (double)static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue();
923  } else if (camtype==1) {
924  out << (double)static_cast<const SoOrthographicCamera*>(&cam)->height.getValue();
925  }
926 
927  cam.unrefNoDelete();
928 
929  // ===> Finish up:
930  buffer.close();
931 
932  if (VP1Msg::verbose()) {
933  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
934  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
935  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
936  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
937  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
938  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters camtype = "
939  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
940  if (camtype==0)
941  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters (persp) heightAngle = "
942  +QString::number(static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue()));
943  if (camtype==1)
944  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters (ortho) height = "
945  +QString::number(static_cast<const SoOrthographicCamera*>(&cam)->height.getValue()));
946  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters end");
947  }
948 
949  return byteArray;
950 }
951 
952 //____________________________________________________________________
953 bool VP1QtInventorUtils::deserializeSoCameraParameters( QByteArray& ba, SoCamera& cam )
954 {
955  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters start");
956  if (ba==QByteArray())
957  return false;
958 
959  // ===> Setup stream for getting the contents of the byteArray:
960  QBuffer buffer(&ba);
961  buffer.open(QIODevice::ReadOnly);
962  QDataStream state(&buffer);
964  if(ba.size()==64) {
965  // Single precision
966  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
967 
968  //Orientation:
969  SbRotation rot; QByteArray ba_rot; state >> ba_rot;
970  if (!deserialize(ba_rot,rot)) return false;
971  //position:
972  SbVec3f pos; QByteArray ba_pos; state >> ba_pos;
973  if (!deserialize(ba_pos,pos)) return false;
974 
975  bool save = cam.enableNotify(false);
976  cam.ref();
977  cam.orientation.setValue(rot);
978  cam.position.setValue(pos);
979  //Misc:
980  float f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
981 
982  state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
983  state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
984  state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
985  state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
986  //viewport mapping:
987  int viewportmap;
988  state>>viewportmap;
989  switch (viewportmap) {
990  case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME); break;
991  case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);break;
992  case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);break;
993  case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);break;
994  case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);break;
995  //ERROR
996  }
997 
998  bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
999 
1000  //Camera type and specialised info:
1001  int camtype;
1002  state>>camtype;
1003  float f_orthopersp_heightpar(-999);
1004  if (camtype==0) {
1005  //perspective
1006  if (!passedcameraisperspective)
1007  return false;
1008  state >> f_orthopersp_heightpar;
1009  static_cast<SoPerspectiveCamera*>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1010  } else if (camtype==1) {
1011  //ortho
1012  if (passedcameraisperspective)
1013  return false;
1014  state >> f_orthopersp_heightpar;
1015  static_cast<SoOrthographicCamera*>(&cam)->height.setValue(f_orthopersp_heightpar);
1016  }
1017 
1018  if (save) {
1019  cam.enableNotify(true);
1020  cam.touch();
1021  }
1022 
1023  // ===> Finish up:
1024  buffer.close();
1025 
1026  if (VP1Msg::verbose()) {
1027  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
1028  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
1029  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
1030  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
1031  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
1032  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters camtype = "
1033  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
1034  if (camtype==0)
1035  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (persp) heightAngle = "
1036  +QString::number(f_orthopersp_heightpar));
1037  if (camtype==1)
1038  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (ortho) height = "
1039  +QString::number(f_orthopersp_heightpar));
1040 
1041  }
1042  }
1043  else {
1044  // Double precision
1045 
1046  //Orientation:
1047  SbRotation rot; QByteArray ba_rot; state >> ba_rot;
1048  if (!deserialize(ba_rot,rot)) return false;
1049  //position:
1050  SbVec3f pos; QByteArray ba_pos; state >> ba_pos;
1051  if (!deserialize(ba_pos,pos)) return false;
1052 
1053  bool save = cam.enableNotify(false);
1054  cam.ref();
1055  cam.orientation.setValue(rot);
1056  cam.position.setValue(pos);
1057  //Misc:
1058  double f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
1059 
1060  state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
1061  state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
1062  state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
1063  state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
1064  //viewport mapping:
1065  int viewportmap;
1066  state>>viewportmap;
1067  switch (viewportmap) {
1068  case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME); break;
1069  case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);break;
1070  case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);break;
1071  case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);break;
1072  case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);break;
1073  //ERROR
1074  }
1075 
1076  bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1077 
1078  //Camera type and specialised info:
1079  int camtype;
1080  state>>camtype;
1081  double f_orthopersp_heightpar(-999);
1082  if (camtype==0) {
1083  //perspective
1084  if (!passedcameraisperspective)
1085  return false;
1086  state >> f_orthopersp_heightpar;
1087  static_cast<SoPerspectiveCamera*>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1088  } else if (camtype==1) {
1089  //ortho
1090  if (passedcameraisperspective)
1091  return false;
1092  state >> f_orthopersp_heightpar;
1093  static_cast<SoOrthographicCamera*>(&cam)->height.setValue(f_orthopersp_heightpar);
1094  }
1095 
1096  if (save) {
1097  cam.enableNotify(true);
1098  cam.touch();
1099  }
1100 
1101  // ===> Finish up:
1102  buffer.close();
1103 
1104  if (VP1Msg::verbose()) {
1105  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
1106  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
1107  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
1108  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
1109  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
1110  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters camtype = "
1111  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
1112  if (camtype==0)
1113  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (persp) heightAngle = "
1114  +QString::number(f_orthopersp_heightpar));
1115  if (camtype==1)
1116  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (ortho) height = "
1117  +QString::number(f_orthopersp_heightpar));
1118 
1119  }
1120  }
1121 
1122  cam.unrefNoDelete();
1123  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters end");
1124  return true;
1125 }
1126 
1127 //____________________________________________________________________
1128 SbColor VP1QtInventorUtils::qcol2sbcol(const QColor& col)
1129 {
1130  return SbColor( col.red()/255.0, col.green()/255.0, col.blue()/255.0 );
1131 }
1132 
1133 //____________________________________________________________________
1134 QColor VP1QtInventorUtils::sbcol2qcol(const SbColor& col)
1135 {
1136  float r,g,b;
1137  col.getValue(r,g,b);
1138  return QColor::fromRgbF( r,g,b );
1139 }
1140 
1141 //____________________________________________________________________
1143 {
1144  if (!m||m->ambientColor.getNum()!=1
1145  ||m->diffuseColor.getNum()!=1
1146  ||m->specularColor.getNum()!=1
1147  ||m->emissiveColor.getNum()!=1
1148  ||m->transparency.getNum()!=1
1149  ||m->shininess.getNum()!=1) {
1150  VP1Msg::message("VP1QtInventorUtils::serialiseSoMaterial Error: "
1151  "Passed material must have exactly one value in each of the 6 fields!!");
1152  return QByteArray();
1153  }
1154 
1155 
1156  // ===> Setup stream writing to a byteArray:
1157  QByteArray byteArray;
1158  QBuffer buffer(&byteArray);
1159  buffer.open(QIODevice::WriteOnly);
1160  QDataStream out(&buffer);
1161 
1162  //Write data:
1163  out << QString("somat_v1_begin");
1164  out << sbcol2qcol(m->ambientColor[0]);
1165  out << sbcol2qcol(m->diffuseColor[0]);
1166  out << sbcol2qcol(m->specularColor[0]);
1167  out << sbcol2qcol(m->emissiveColor[0]);
1168  out << (double)m->shininess[0];
1169  out << (double)m->transparency[0];
1170  out << QString("somat_end");
1171 
1172  // ===> Finish up:
1173  buffer.close();
1174 
1175  return byteArray;
1176 
1177 }
1178 
1179 //____________________________________________________________________
1180 bool VP1QtInventorUtils::deserialiseSoMaterial(QByteArray&ba,SoMaterial *&m)
1181 {
1182  if (!m||m->ambientColor.getNum()!=1
1183  ||m->diffuseColor.getNum()!=1
1184  ||m->specularColor.getNum()!=1
1185  ||m->emissiveColor.getNum()!=1
1186  ||m->transparency.getNum()!=1
1187  ||m->shininess.getNum()!=1) {
1188  VP1Msg::message("VP1QtInventorUtils::deserialiseSoMaterial Error: "
1189  "Passed material must have exactly one value in each of the 6 fields!!");
1190  return false;
1191  }
1192 
1193  // ===> Setup stream for getting the contents of the byteArray:
1194  QBuffer buffer(&ba);
1195  buffer.open(QIODevice::ReadOnly);
1196  QDataStream stream(&buffer);
1197  if(ba.size()==106)
1198  stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
1199 
1200  //Read contents while checking for validity
1201  QString str; stream >> str;
1202  if (str!="somat_v1_begin")
1203  return false;
1204 
1205  QColor ambientcol; stream >> ambientcol;
1206  if (!ambientcol.isValid())
1207  return false;
1208 
1209  QColor diffusecol; stream >> diffusecol;
1210  if (!diffusecol.isValid())
1211  return false;
1212 
1213  QColor specularcol; stream >> specularcol;
1214  if (!specularcol.isValid())
1215  return false;
1216 
1217  QColor emissivecol; stream >> emissivecol;
1218  if (!emissivecol.isValid())
1219  return false;
1220 
1221  if(ba.size()==106) {
1222  // Single precision
1223  float shininess; stream >> shininess;
1224  if (shininess<0.0f||shininess>1.0f)
1225  return false;
1226 
1227  float transparency; stream >> transparency;
1228  if (transparency<0.0f||transparency>1.0f)
1229  return false;
1230 
1231  stream >> str;
1232  if (str!="somat_end")
1233  return false;
1234 
1235  buffer.close();
1236 
1237  //Apply values:
1238  m->ambientColor.setValue(qcol2sbcol(ambientcol));
1239  m->diffuseColor.setValue(qcol2sbcol(diffusecol));
1240  m->specularColor.setValue(qcol2sbcol(specularcol));
1241  m->emissiveColor.setValue(qcol2sbcol(emissivecol));
1242  m->shininess.setValue(shininess);
1243  m->transparency.setValue(transparency);
1244  }
1245  else {
1246  // Double precision
1247  double shininess; stream >> shininess;
1248  if (shininess<0.0||shininess>1.0)
1249  return false;
1250 
1251  double transparency; stream >> transparency;
1252  if (transparency<0.0||transparency>1.0)
1253  return false;
1254 
1255  stream >> str;
1256  if (str!="somat_end")
1257  return false;
1258 
1259  buffer.close();
1260 
1261  //Apply values:
1262  m->ambientColor.setValue(qcol2sbcol(ambientcol));
1263  m->diffuseColor.setValue(qcol2sbcol(diffusecol));
1264  m->specularColor.setValue(qcol2sbcol(specularcol));
1265  m->emissiveColor.setValue(qcol2sbcol(emissivecol));
1266  m->shininess.setValue(shininess);
1267  m->transparency.setValue(transparency);
1268  }
1269 
1270  return true;
1271 }
1272 
1273 //____________________________________________________________________
1274 SoNode * VP1QtInventorUtils::createCircle( const double& radius )
1275 {
1276  SoGroup* grp = new SoGroup;
1277  grp->ref();
1278 
1279  SoCoordinate4 * coord = new SoCoordinate4;
1280  const double invsqrttwo=0.707106781186547;
1281 
1282  int icoord(0);
1283  coord->point.set1Value(icoord++,SbVec4f(1*radius,0,0,1));
1284  coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*radius,invsqrttwo*radius,0,invsqrttwo));
1285  coord->point.set1Value(icoord++,SbVec4f(0,1*radius,0,1));
1286  coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*radius,invsqrttwo*radius,0,invsqrttwo));
1287  coord->point.set1Value(icoord++,SbVec4f(-1*radius,0,0,1));
1288  coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*radius,-invsqrttwo*radius,0,invsqrttwo));
1289  coord->point.set1Value(icoord++,SbVec4f(0,-1*radius,0,1));
1290  coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*radius,-invsqrttwo*radius,0,invsqrttwo));
1291  coord->point.set1Value(icoord++,SbVec4f(1*radius,0,0,1));
1292 
1293  SoNurbsCurve * curve = new SoNurbsCurve;
1294  curve->numControlPoints = icoord;
1295 
1296  int iknot(0);
1297 
1298  curve->knotVector.set1Value(iknot++,0);
1299  curve->knotVector.set1Value(iknot++,0);
1300  curve->knotVector.set1Value(iknot++,0);
1301  curve->knotVector.set1Value(iknot++,1);
1302  curve->knotVector.set1Value(iknot++,1);
1303  curve->knotVector.set1Value(iknot++,2);
1304  curve->knotVector.set1Value(iknot++,2);
1305  curve->knotVector.set1Value(iknot++,3);
1306  curve->knotVector.set1Value(iknot++,3);
1307  curve->knotVector.set1Value(iknot++,4);
1308  curve->knotVector.set1Value(iknot++,4);
1309  curve->knotVector.set1Value(iknot++,4);
1310  grp->addChild(coord);
1311  grp->addChild(curve);
1312 
1313  grp->unrefNoDelete();
1314  return grp;
1315 }
1316 
1317 //____________________________________________________________________
1318 SoNode * VP1QtInventorUtils::createEllipse( const double& radiusX, const double& radiusY, const int& numnodes )
1319 {
1320  SoVertexProperty *vertices = new SoVertexProperty();
1321 
1322  int iver(0);
1323  vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1324  for (int i = 1; i < numnodes; i++)
1325  {
1326  vertices->vertex.set1Value(iver++,
1327  cos(2.0*static_cast<double>(i)*M_PI/static_cast<double>(numnodes))*radiusX,
1328  sin(2.0*static_cast<double>(i)*M_PI/static_cast<double>(numnodes))*radiusY,0.0);
1329  }
1330  vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1331 
1332  SoLineSet * ellipse = new SoLineSet();
1333  ellipse->numVertices = iver;
1334  ellipse->vertexProperty = vertices;
1335 
1336  return ellipse;
1337 }
1338 
1339 //_____________________________________________________________________________________
1340 bool VP1QtInventorUtils::changePathTail(SoPath*path,SoNode*commonBranchPoint,SoNode*newtail)
1341 {
1342  if (!path||!commonBranchPoint||!newtail)
1343  return false;
1344 
1345  SoSearchAction sa;
1346  sa.setInterest(SoSearchAction::FIRST);
1347  sa.setNode(newtail);
1348  sa.apply(commonBranchPoint);
1349  //First truncate pickedPath at d->sceneroot, then append
1350  //newpath to pickedPath:
1351  SoPath * newpath = sa.getPath();
1352  if (!newpath)
1353  return false;
1354  bool found(false);
1355  for (int i=0;i<path->getLength();++i) {
1356  if (path->getNode(i)==commonBranchPoint) {
1357  found = true;
1358  path->truncate(i+1);
1359  break;
1360  }
1361  }
1362  if (found)
1363  path->append(newpath);
1364  return found;
1365 }
1366 
1367 
1368 //_____________________________________________________________________________________
1371 
1372 //_____________________________________________________________________________________
1373 void * VP1QtInventorUtils::Imp::buffer_realloc(void * bufptr, size_t size)
1374 {
1375  buffer = (char *)realloc(bufptr, size);
1376  buffer_size = size;
1377  return buffer;
1378 }
1379 
1380 //_____________________________________________________________________________________
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 }
1395 
1396 //_____________________________________________________________________________________
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 }
1413 
1414 //_____________________________________________________________________________________
1416 {
1417  if (!root)
1418  return false;
1419 
1420  root->ref();
1421  QString s = Imp::buffer_writeaction(root);
1422  root->unrefNoDelete();
1423 
1424  QFile data(filename);
1425  if (data.open(QFile::WriteOnly | QFile::Truncate)) {
1426  QTextStream out(&data);
1427 #if QTCORE_VERSION >= 0x050E00
1428  out << s << Qt::endl;
1429 #else
1430  out << s << endl;
1431 #endif
1432  return true;
1433  } else {
1434  return false;
1435  }
1436 }
1437 
1438 //_____________________________________________________________________________________
1440 {
1441  // SoDB::init();
1442  SoInput in;
1443  if (!in.openFile(filename.toStdString().c_str()))
1444  return 0;
1445  return SoDB::readAll(&in);
1446 }
1447 
1448 
1449 //_____________________________________________________________________________________
1451 {
1452  if (!root)
1453  return false;
1454 
1455  root->ref();
1457  root->unrefNoDelete();
1458 
1459  // QFile data(filename);
1460  // if (data.open(QFile::WriteOnly | QFile::Truncate)) {
1461  // QTextStream out(&data);
1462  // out << s << endl;
1463  // return true;
1464  // } else {
1465  // return false;
1466  // }
1467  return true;
1468 }
1469 
1470 
1472 #include "VP1Base/VP1MaterialButton.h"
1473 //_____________________________________________________________________________________
1474 void VP1QtInventorUtils::setMatColor( SoMaterial * m, const double& r, const double& g, const double& b,
1475  const double& brightness, const double& transp )
1476 {
1477  if (m)
1478  VP1MaterialButton::setMaterialParameters( m, r,g,b,brightness,transp );
1479 }
1480 
1481 //_____________________________________________________________________________________
1482 void VP1QtInventorUtils::setMatColor( SoMaterial * m, const QColor& col,
1483  const double& brightness, const double& transp )
1484 {
1485  setMatColor( m, col.redF(), col.greenF(), col.blueF(), brightness, transp);
1486 }
1488 
1489 //_____________________________________________________________________________________
1490 void VP1QtInventorUtils::getLineWidthRanges(double& min, double& max, double& granularity)
1491 {
1496  granularity = Imp::allowedLineWidthGranularity;
1497 }
1498 
1499 //_____________________________________________________________________________________
1500 void VP1QtInventorUtils::getPointSizeRanges(double& min, double& max, double& granularity)
1501 {
1506  granularity = Imp::allowedPointSizeGranularity;
1507 }
1508 
1509 //_____________________________________________________________________________________
1511 {
1513  return;
1515  QWidget * w(0);
1516  if (!ra) {
1517  VP1Msg::messageVerbose("VP1QtInventorUtils WARNING: Have to create temporary renderarea for the sole "
1518  "purpose of getting supported line widths and point sizes!");
1519  w = new QWidget(0);
1520  ra = new VP1ExaminerViewer(w);
1521  }
1522  SbVec2f range; float granularity;
1523  ra->getLineWidthLimits(range, granularity);
1524  float a,b;
1525  range.getValue(a,b);
1528  Imp::allowedLineWidthGranularity = granularity;
1529  VP1Msg::messageVerbose("VP1QtInventorUtils Determined line widths supported by hardware (min,max,granularity) = ("
1530  +VP1Msg::str(a)+", "+VP1Msg::str(b)+", "+VP1Msg::str(granularity)+")");
1531  ra->getPointSizeLimits(range, granularity);
1532  range.getValue(a,b);
1535  Imp::allowedPointSizeGranularity = granularity;
1536  VP1Msg::messageVerbose("VP1QtInventorUtils Determined point sizes supported by hardware (min,max,granularity) = ("
1537  +VP1Msg::str(a)+", "+VP1Msg::str(b)+", "+VP1Msg::str(granularity)+")");
1538  if (w) {
1539  delete ra;
1540  delete w;
1541  }
1542  //We clip to get a more consistent behaviour across hardware (and to limit ourselves to reasonable values:
1543 
1544  if (Imp::allowedLineWidthMin<0.5)
1546  if (Imp::allowedLineWidthMax>7.0)
1548  if (Imp::allowedPointSizeMin<0.5)
1550  if (Imp::allowedPointSizeMax>12.0)
1551  Imp::allowedPointSizeMax = 12.0;
1552 }
1553 
1554 //_____________________________________________________________________________________
1556 {
1557  if (!slider)
1558  return;
1561  int nsteps = std::min(1000,std::max<int>(0,static_cast<int>((Imp::allowedLineWidthMax-Imp::allowedLineWidthMin)/Imp::allowedLineWidthGranularity)));
1562  int stepsPerUnit = std::min(nsteps,std::max<int>(1,static_cast<int>(1.0/Imp::allowedLineWidthGranularity)));
1563  slider->setRange(0,nsteps);
1564  slider->setSingleStep(1);
1565  slider->setPageStep(stepsPerUnit);
1566 }
1567 
1568 //_____________________________________________________________________________________
1570 {
1571  if (!slider)
1572  return;
1575  int nsteps = std::min(1000,std::max<int>(0,
1577  int stepsPerUnit = std::min(nsteps,std::max<int>(1,
1578  static_cast<int>(0.5+1.0/Imp::allowedPointSizeGranularity)));
1579  slider->setRange(0,nsteps);
1580  slider->setSingleStep(1);
1581  slider->setPageStep(stepsPerUnit);
1582 }
1583 
1584 //_____________________________________________________________________________________
1585 void VP1QtInventorUtils::setValueLineWidthSlider(QSlider * slider, const double& value)
1586 {
1587  if (!slider)
1588  return;
1591  int itarget = std::min(slider->maximum(),std::max<int>(slider->minimum(),
1593  if (slider->value()!=itarget)
1594  slider->setValue(itarget);
1595 }
1596 
1597 //_____________________________________________________________________________________
1598 void VP1QtInventorUtils::setValuePointSizeSlider(QSlider * slider, const double& value)
1599 {
1600  if (!slider)
1601  return;
1604  int itarget = std::min(slider->maximum(),std::max<int>(slider->minimum(),
1606  if (slider->value()!=itarget)
1607  slider->setValue(itarget);
1608 }
1609 
1610 //_____________________________________________________________________________________
1611 double VP1QtInventorUtils::getValueLineWidthSlider(const QSlider * slider)
1612 {
1613  if (!slider)
1614  return 1.0;
1619 }
1620 
1621 //_____________________________________________________________________________________
1622 double VP1QtInventorUtils::getValuePointSizeSlider(const QSlider * slider)
1623 {
1624  if (!slider)
1625  return 1.0;
1630 }
NONE
@ NONE
Definition: sTGCenumeration.h:13
base
std::string base
Definition: hcg.cxx:78
beamspotman.r
def r
Definition: beamspotman.py:672
VP1QtInventorUtils::Imp::_ImageRec::rowSize
int * rowSize
Definition: VP1QtInventorUtils.cxx:124
VP1QtInventorUtils::Imp::_ImageRec::colorMap
unsigned long colorMap
Definition: VP1QtInventorUtils.cxx:119
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
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
VP1ExaminerViewer::getStereoTypeSlot
SoQtViewer::StereoType getStereoTypeSlot(void) const
Definition: VP1ExaminerViewer.cxx:584
VP1QtInventorUtils::getValueLineWidthSlider
static double getValueLineWidthSlider(const QSlider *)
Definition: VP1QtInventorUtils.cxx:1611
VP1QtInventorUtils::createEllipse
static SoNode * createEllipse(const double &radiusX, const double &radiusY, const int &numnodes=12)
Definition: VP1QtInventorUtils.cxx:1318
VP1QtInventorUtils::Imp::_ImageRec::min
unsigned int min
Definition: VP1QtInventorUtils.cxx:116
add-xsec-uncert-quadrature-N.alpha
alpha
Definition: add-xsec-uncert-quadrature-N.py:110
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
VP1QtInventorUtils::deserializeSoCameraParameters
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)
Definition: VP1QtInventorUtils.cxx:953
VP1QtInventorUtils::Imp::ImageOpen
static ImageRec * ImageOpen(const char *fileName)
Definition: VP1QtInventorUtils.cxx:135
VP1QtInventorUtils::getLineWidthRanges
static void getLineWidthRanges(double &min, double &max, double &granularity)
Definition: VP1QtInventorUtils.cxx:1490
VP1QtInventorUtils::Imp::allowedPointSizeMax
static double allowedPointSizeMax
Definition: VP1QtInventorUtils.cxx:365
VP1QtInventorUtils::Imp::buffer_realloc
static void * buffer_realloc(void *bufptr, size_t size)
Definition: VP1QtInventorUtils.cxx:1373
VP1MaterialButton.h
VP1QtInventorUtils::renderToImage
static QImage renderToImage(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
Definition: VP1QtInventorUtils.cxx:428
index
Definition: index.py:1
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
VP1Msg.h
VP1QtInventorUtils::Imp::_ImageRec::dim
unsigned short dim
Definition: VP1QtInventorUtils.cxx:114
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
VP1QtInventorUtils::Imp
Definition: VP1QtInventorUtils.cxx:60
VP1QtInventorUtils::Imp::allowedPointSizeMin
static double allowedPointSizeMin
Definition: VP1QtInventorUtils.cxx:364
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
M_PI
#define M_PI
Definition: ActiveFraction.h:11
python.atlas_oh.im
im
Definition: atlas_oh.py:167
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
athena.value
value
Definition: athena.py:124
VP1QtInventorUtils::Imp::_ImageRec::max
unsigned int max
Definition: VP1QtInventorUtils.cxx:116
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
VP1QtInventorUtils::getDefaultVP1TransparencyType
static SoGLRenderAction::TransparencyType getDefaultVP1TransparencyType()
Definition: VP1QtInventorUtils.cxx:633
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
VP1QtInventorUtils::serialize
static QByteArray serialize(const SbRotation &)
Definition: VP1QtInventorUtils.cxx:719
x
#define x
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
VP1QtInventorUtils::Imp::allowedPointSizeGranularity
static double allowedPointSizeGranularity
Definition: VP1QtInventorUtils.cxx:366
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
VP1QtInventorUtils::Imp::_ImageRec::tmp
unsigned char * tmp
Definition: VP1QtInventorUtils.cxx:121
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
VP1QtInventorUtils::deserialiseSoMaterial
static bool deserialiseSoMaterial(QByteArray &, SoMaterial *&)
Definition: VP1QtInventorUtils.cxx:1180
VP1QtInventorUtils::Imp::_ImageRec::file
FILE * file
Definition: VP1QtInventorUtils.cxx:120
VP1QtInventorUtils::createCircle
static SoNode * createCircle(const double &radius)
Definition: VP1QtInventorUtils.cxx:1274
VP1QtInventorUtils::Imp::buffer_size
static size_t buffer_size
Definition: VP1QtInventorUtils.cxx:355
VP1QtInventorUtils.h
VP1QtInventorUtils::setLimitsPointSizeSlider
static void setLimitsPointSizeSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1569
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
VP1QtInventorUtils::getPointSizeRanges
static void getPointSizeRanges(double &min, double &max, double &granularity)
Definition: VP1QtInventorUtils.cxx:1500
VP1QtInventorUtils::Imp::allowedLineWidthMax
static double allowedLineWidthMax
Definition: VP1QtInventorUtils.cxx:362
VP1QtInventorUtils::VP1QtInventorUtils
VP1QtInventorUtils()
Definition: VP1QtInventorUtils.cxx:382
VP1QtInventorUtils::getValuePointSizeSlider
static double getValuePointSizeSlider(const QSlider *)
Definition: VP1QtInventorUtils.cxx:1622
VP1QtInventorUtils::transparencyType2PrettyString
static QString transparencyType2PrettyString(SoGLRenderAction::TransparencyType)
Definition: VP1QtInventorUtils.cxx:699
VP1QtInventorUtils::Imp::_ImageRec::xsize
unsigned short xsize
Definition: VP1QtInventorUtils.cxx:115
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:176
VP1QtInventorUtils::getAllTransparencyTypes
static QList< SoGLRenderAction::TransparencyType > getAllTransparencyTypes()
Definition: VP1QtInventorUtils.cxx:639
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:11
VP1ExaminerViewer.h
VP1QtInventorUtils::Imp::_ImageRec::rowStart
unsigned int * rowStart
Definition: VP1QtInventorUtils.cxx:123
VP1QtInventorUtils::Imp::_ImageRec
Definition: VP1QtInventorUtils.cxx:111
VP1QtInventorUtils::Imp::ImageRec
struct VP1QtInventorUtils::Imp::_ImageRec ImageRec
VP1QtInventorUtils::Imp::_ImageRec::zsize
unsigned short zsize
Definition: VP1QtInventorUtils.cxx:115
VP1ExaminerViewer::getSceneGraph
virtual SoNode * getSceneGraph()
Definition: VP1ExaminerViewer.cxx:3139
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
VP1MaterialButton::setMaterialParameters
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1MaterialButton.cxx:802
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:727
VP1QtInventorUtils::Imp::_ImageRec::tmpB
unsigned char * tmpB
Definition: VP1QtInventorUtils.cxx:121
VP1QtInventorUtils::Imp::buffer
static char * buffer
Definition: VP1QtInventorUtils.cxx:354
VP1QtInventorUtils::Imp::_ImageRec::tmpG
unsigned char * tmpG
Definition: VP1QtInventorUtils.cxx:121
python.CaloAddPedShiftConfig.str
str
Definition: CaloAddPedShiftConfig.py:42
VP1QtInventorUtils::Imp::read_texture
static unsigned * read_texture(const char *name, int *width, int *height, int *components)
Definition: VP1QtInventorUtils.cxx:285
VP1QtInventorUtils::serialiseSoMaterial
static QByteArray serialiseSoMaterial(SoMaterial *)
Definition: VP1QtInventorUtils.cxx:1142
VP1QtInventorUtils::pixmapFromRGBFile
static QPixmap pixmapFromRGBFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:392
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
VP1QtInventorUtils::deserialize
static bool deserialize(QByteArray &, SbRotation &)
Definition: VP1QtInventorUtils.cxx:751
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
hist_file_dump.f
f
Definition: hist_file_dump.py:140
VP1QtInventorUtils::qcol2sbcol
static SbColor qcol2sbcol(const QColor &)
Definition: VP1QtInventorUtils.cxx:1128
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:127
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
byteswap.h
C++23-compatible byteswap()
VP1QtInventorUtils::Imp::buffer_vrmlwriteaction
static void buffer_vrmlwriteaction(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1397
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
VP1QtInventorUtils::setValueLineWidthSlider
static void setValueLineWidthSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1585
CxxUtils::byteswap
constexpr T byteswap(T value) noexcept
Reverse the bytes in n.
Definition: byteswap.h:42
VP1QtInventorUtils::imageFromRGBFile
static QImage imageFromRGBFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:399
lumiFormat.array
array
Definition: lumiFormat.py:91
VP1QtInventorUtils::sbcol2qcol
static QColor sbcol2qcol(const SbColor &)
Definition: VP1QtInventorUtils.cxx:1134
VP1QtInventorUtils::Imp::_ImageRec::type
unsigned short type
Definition: VP1QtInventorUtils.cxx:113
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
VP1QtInventorUtils::transparencyTypeToInt
static int transparencyTypeToInt(SoGLRenderAction::TransparencyType)
Definition: VP1QtInventorUtils.cxx:657
VP1QtInventorUtils::Imp::_ImageRec::wasteBytes
unsigned int wasteBytes
Definition: VP1QtInventorUtils.cxx:117
VP1QtInventorUtils::Imp::buffer_writeaction
static QString buffer_writeaction(SoNode *root)
Definition: VP1QtInventorUtils.cxx:1381
VP1QtInventorUtils::Imp::_ImageRec::name
char name[80]
Definition: VP1QtInventorUtils.cxx:118
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
MyPlots.image
string image
Definition: MyPlots.py:40
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
VP1QtInventorUtils::readGraphFromFile
static SoSeparator * readGraphFromFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:1439
VP1QtInventorUtils::writeGraphToFile
static bool writeGraphToFile(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1415
VP1QtInventorUtils::Imp::ConvertLong
static void ConvertLong(unsigned *array, long length)
Definition: VP1QtInventorUtils.cxx:127
VP1QtInventorUtils::Imp::_ImageRec::tmpR
unsigned char * tmpR
Definition: VP1QtInventorUtils.cxx:121
VP1QtInventorUtils::Imp::_ImageRec::ysize
unsigned short ysize
Definition: VP1QtInventorUtils.cxx:115
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1QtInventorUtils::Imp::_ImageRec::rleEnd
unsigned long rleEnd
Definition: VP1QtInventorUtils.cxx:122
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
VP1ExaminerViewer::getStereoOffsetSlot
float getStereoOffsetSlot()
Definition: VP1ExaminerViewer.cxx:577
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
VP1QtInventorUtils::setMatColor
static void setMatColor(SoMaterial *, const double &r, const double &g, const double &b, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1QtInventorUtils.cxx:1474
VP1QtInventorUtils::setValuePointSizeSlider
static void setValuePointSizeSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1598
VP1QtInventorUtils::setLimitsLineWidthSlider
static void setLimitsLineWidthSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1555
VP1QtInventorUtils::intToTransparencyType
static SoGLRenderAction::TransparencyType intToTransparencyType(int)
Definition: VP1QtInventorUtils.cxx:677
python.changerun.pv
pv
Definition: changerun.py:79
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
VP1QtInventorUtils::renderToPixmap
static QPixmap renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
Definition: VP1QtInventorUtils.cxx:587
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
ADD
#define ADD(NAME)
Definition: test-half-precision.cxx:19
VP1QtInventorUtils::Imp::_ImageRec::imagic
unsigned short imagic
Definition: VP1QtInventorUtils.cxx:112
str
Definition: BTagTrackIpAccessor.cxx:11
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
VP1QtInventorUtils::ensureInitLineWidthAndPointSize
static void ensureInitLineWidthAndPointSize(SoQtRenderArea *)
Definition: VP1QtInventorUtils.cxx:1510
VP1QtInventorUtils::writeGraphToVRMLFile
static bool writeGraphToVRMLFile(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1450
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:198
VP1QtInventorUtils::Imp::allowedLineWidthMin
static double allowedLineWidthMin
Definition: VP1QtInventorUtils.cxx:361
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:876
VP1QtInventorUtils::serializeSoCameraParameters
static QByteArray serializeSoCameraParameters(const SoCamera &)
Definition: VP1QtInventorUtils.cxx:878
VP1QtInventorUtils::~VP1QtInventorUtils
~VP1QtInventorUtils()
Definition: VP1QtInventorUtils.cxx:387
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
VP1QtInventorUtils::changePathTail
static bool changePathTail(SoPath *path, SoNode *commonBranchPoint, SoNode *newtail)
Definition: VP1QtInventorUtils.cxx:1340
VP1QtInventorUtils::Imp::constructImageWithTransparentBackground
static QImage constructImageWithTransparentBackground(const QImage &im_black_bgd, const QImage &image_white_bgd)
Definition: VP1QtInventorUtils.cxx:594
SiliconTech::pixel
@ pixel
VP1ExaminerViewer
Definition: VP1ExaminerViewer.h:30
VP1QtInventorUtils::Imp::lineWidthAndPointSizeNeedsInit
static bool lineWidthAndPointSizeNeedsInit
Definition: VP1QtInventorUtils.cxx:360
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
VP1QtInventorUtils::Imp::allowedLineWidthGranularity
static double allowedLineWidthGranularity
Definition: VP1QtInventorUtils.cxx:363