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