Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
VP1QtInventorUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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  fclose (tmpf);
549  return QImage();
550  }
551  VP1Msg::messageVerbose("rendered the scenegraph");
552 
553  // render the overlay scenegraph
554  // if fails, delete the renderer and return an empty image
555  if (rootOverlay) {
556  bool okOver = myRenderer->render(rootOverlay);
557  if ( !okOver) {
558  delete myRenderer;
559  fclose (tmpf);
560  return QImage();
561  }
562  else {
563  VP1Msg::messageVerbose("rendered the overlay scenegraph");
564  }
565  }
566 
567  // write the rendered image to the temp file
568  // if fails, remove the temp file and return an empty image
569  if (!myRenderer->writeToRGB(tmpf)) {
570  fclose (tmpf);
571  if (QFile::exists(tmpfile))
572  QFile(tmpfile).remove();
573  delete myRenderer;
574  return QImage();
575  }
576 
577  fclose (tmpf);
578 
579  // delete the renderer
580  delete myRenderer;
581 
582  // get the rendered image from the temp file as a Qt QImage instance
583  QImage im(imageFromRGBFile(tmpfile));
584 
585  // delete the temp file
586  if (QFile::exists(tmpfile))
587  QFile(tmpfile).remove();
588 
589  // return the rendered image
590  return im;
591 }
592 
593 //____________________________________________________________________
594 //QPixmap VP1QtInventorUtils::renderToPixmap(SoQtRenderArea *ra, int pixels_x, int pixels_y,
595 QPixmap VP1QtInventorUtils::renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y,
596  bool transparent_background, double actualRenderedSizeFact )
597 {
598  return QPixmap::fromImage(renderToImage(ra, pixels_x, pixels_y, transparent_background, actualRenderedSizeFact));
599 }
600 
601 //____________________________________________________________________
602 QImage VP1QtInventorUtils::Imp::constructImageWithTransparentBackground(const QImage& im_black_bgd, const QImage& im_white_bgd)
603 {
604  if (im_black_bgd.isNull()||im_white_bgd.isNull()||im_black_bgd.size()!=im_white_bgd.size())
605  return QImage();
606 
607  QImage im(im_black_bgd.size(),QImage::Format_ARGB32);
608 
609  int width = im.width();
610  int height = im.height();
611  QRgb white = qRgba(255,255,255,255);
612  QRgb black = qRgba(0,0,0,255);
613 
614  for (int x = 0; x < width; ++x)
615  for (int y = 0; y < height; ++y) {
616  if (im_black_bgd.pixel(x,y)==im_white_bgd.pixel(x,y)) {
617  im.setPixel(x,y,im_white_bgd.pixel(x,y));
618  } else if (im_black_bgd.pixel(x,y)==black&&im_white_bgd.pixel(x,y)==white) {
619  im.setPixel(x,y,Qt::transparent);
620  } else {
621  //Calculate ...
622  QColor pix_b = QColor(im_black_bgd.pixel(x,y));
623  QColor pix_w = QColor(im_white_bgd.pixel(x,y));
624  qreal alpha = 1.0 - pix_w.redF() + pix_b.redF();
625  if (alpha==0) {
626  im.setPixel(x,y,Qt::transparent);
627  } else {
628  im.setPixel(x,y,qRgba(static_cast<int>(pix_b.redF()/alpha*255+0.5),
629  static_cast<int>(pix_b.greenF()/alpha*255+0.5),
630  static_cast<int>(pix_b.blueF()/alpha*255+0.5),
631  static_cast<int>(alpha*255+0.5)));
632  }
633  }
634  }
635 
636  return im;
637 }
638 
639 
640 //____________________________________________________________________
641 SoGLRenderAction::TransparencyType VP1QtInventorUtils::getDefaultVP1TransparencyType()
642 {
643  return SoGLRenderAction::DELAYED_BLEND;
644 }
645 
646 //____________________________________________________________________
647 QList<SoGLRenderAction::TransparencyType> VP1QtInventorUtils::getAllTransparencyTypes()
648 {
649  QList<SoGLRenderAction::TransparencyType> l;
651  << SoGLRenderAction::SCREEN_DOOR
653  << SoGLRenderAction::DELAYED_ADD
654  << SoGLRenderAction::SORTED_OBJECT_ADD
655  << SoGLRenderAction::BLEND
656  << SoGLRenderAction::DELAYED_BLEND
657  << SoGLRenderAction::SORTED_OBJECT_BLEND
658  << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD
659  << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND
660  << SoGLRenderAction::SORTED_LAYERS_BLEND;
661  return l;
662 }
663 
664 //____________________________________________________________________
665 int VP1QtInventorUtils::transparencyTypeToInt( SoGLRenderAction::TransparencyType tt )
666 {
667  switch (tt) {
668  case SoGLRenderAction::SCREEN_DOOR: return 0;
669  case SoGLRenderAction::ADD: return 1;
670  case SoGLRenderAction::DELAYED_ADD: return 2;
671  case SoGLRenderAction::SORTED_OBJECT_ADD: return 3;
672  case SoGLRenderAction::BLEND: return 4;
673  case SoGLRenderAction::DELAYED_BLEND: return 5;
674  case SoGLRenderAction::SORTED_OBJECT_BLEND: return 6;
675  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD: return 7;
676  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND: return 8;
677  case SoGLRenderAction::NONE: return 9;
678  case SoGLRenderAction::SORTED_LAYERS_BLEND: return 10;
679  default:
680  VP1Msg::messageDebug("VP1QtInventorUtils::transparencyTypeToInt ERROR: Unknown transparency type");
681  return -1;
682  }
683 }
684 //____________________________________________________________________
685 SoGLRenderAction::TransparencyType VP1QtInventorUtils::intToTransparencyType( int i )
686 {
687  switch (i) {
688  case 0: return SoGLRenderAction::SCREEN_DOOR;
689  case 1: return SoGLRenderAction::ADD;
690  case 2: return SoGLRenderAction::DELAYED_ADD;
691  case 3: return SoGLRenderAction::SORTED_OBJECT_ADD;
692  case 4: return SoGLRenderAction::BLEND;
693  case 5: return SoGLRenderAction::DELAYED_BLEND;
694  case 6: return SoGLRenderAction::SORTED_OBJECT_BLEND;
695  case 7: return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD;
696  case 8: return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND;
697  case 9: return SoGLRenderAction::NONE;
698  case 10: return SoGLRenderAction::SORTED_LAYERS_BLEND;
699  default:
700  VP1Msg::messageDebug("VP1QtInventorUtils::intToTransparencyType ERROR: int out of range "+VP1Msg::str(i));
701  return SoGLRenderAction::DELAYED_BLEND;
702  }
703 }
704 
705 
706 //____________________________________________________________________
707 QString VP1QtInventorUtils::transparencyType2PrettyString( SoGLRenderAction::TransparencyType tt )
708 {
709  switch (tt) {
710  case SoGLRenderAction::DELAYED_BLEND: return "Delayed blend"; break;
711  case SoGLRenderAction::SCREEN_DOOR: return "Screen door"; break;
712  case SoGLRenderAction::ADD: return "Add"; break;
713  case SoGLRenderAction::DELAYED_ADD: return "Delayed add"; break;
714  case SoGLRenderAction::SORTED_OBJECT_ADD: return "Sorted object add"; break;
715  case SoGLRenderAction::BLEND: return "Blend (Best for Geo volumes)"; break;
716  case SoGLRenderAction::SORTED_OBJECT_BLEND: return "Sorted object blend (Best for physics objects: jets, tracks, ...)"; break;
717  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD: return "Sorted object sorted triangle add"; break;
718  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND: return "Sorted object sorted triangle blend"; break;
719  case SoGLRenderAction::NONE: return "None"; break;
720  case SoGLRenderAction::SORTED_LAYERS_BLEND: return "Sorted layers blend"; break;
721  default: return "";
722  }
723 
724 }
725 
726 //____________________________________________________________________
727 QByteArray VP1QtInventorUtils::serialize( const SbRotation& rot )
728 {
729 
730  // ===> Setup stream writing to a byteArray:
731  QByteArray byteArray;
732  QBuffer buffer(&byteArray);
733  buffer.open(QIODevice::WriteOnly);
734  QDataStream out(&buffer);
735 
736  //Write data:
737 
738  float q0,q1,q2,q3;//quarternion components
739  rot.getValue (q0,q1,q2,q3);
740 
741  out<<(double)q0;
742  out<<(double)q1;
743  out<<(double)q2;
744  out<<(double)q3;
745 
746  if (VP1Msg::verbose()) {
747  //Fixme: check for nan's.
748  VP1Msg::messageVerbose("VP1QtInventorUtils::serialize SbRotation(q0,q1,q2,q3) = ("
749  +QString::number(q0)+", "+QString::number(q1)+", "
750  +QString::number(q2)+", "+QString::number(q3)+")");
751  }
752 
753  // ===> Finish up:
754  buffer.close();
755  return byteArray;
756 }
757 
758 //____________________________________________________________________
759 bool VP1QtInventorUtils::deserialize( QByteArray& ba, SbRotation& rot )
760 {
761  // ===> Setup stream for getting the contents of the byteArray:
762  QBuffer buffer(&ba);
763  buffer.open(QIODevice::ReadOnly);
764  QDataStream state(&buffer);
766  if(ba.size()==16) {
767  // Single precision
768  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
769  float q0,q1,q2,q3;//quarternion components
770 
771  state >> q0;
772  state >> q1;
773  state >> q2;
774  state >> q3;
775 
776  rot.setValue (q0,q1,q2,q3);
777 
778  if (VP1Msg::verbose()) {
779  //Fixme: check for nan's.
780  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbRotation(q0,q1,q2,q3) = ("
781  +QString::number(q0)+", "+QString::number(q1)+", "
782  +QString::number(q2)+", "+QString::number(q3)+")");
783  }
784  }
785  else {
786  // Double precision
787  double q0,q1,q2,q3;//quarternion components
788 
789  state >> q0;
790  state >> q1;
791  state >> q2;
792  state >> q3;
793 
794  rot.setValue (q0,q1,q2,q3);
795 
796  if (VP1Msg::verbose()) {
797  //Fixme: check for nan's.
798  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbRotation(q0,q1,q2,q3) = ("
799  +QString::number(q0)+", "+QString::number(q1)+", "
800  +QString::number(q2)+", "+QString::number(q3)+")");
801  }
802  }
803 
804  // ===> Finish up:
805  buffer.close();
806 
807  return true;//Fixme: How to check for errors? - at least check for nan's and determinant?
808 }
809 
810 //____________________________________________________________________
811 QByteArray VP1QtInventorUtils::serialize( const SbVec3f& vec )
812 {
813  // ===> Setup stream writing to a byteArray:
814  QByteArray byteArray;
815  QBuffer buffer(&byteArray);
816  buffer.open(QIODevice::WriteOnly);
817  QDataStream out(&buffer);
818 
819  //Write data:
820  float x,y,z;
821  vec.getValue(x,y,z);
822  out << (double)x;
823  out << (double)y;
824  out << (double)z;
825 
826  if (VP1Msg::verbose()) {
827  //Fixme: check for nan's.
828  VP1Msg::messageVerbose("VP1QtInventorUtils::serialize SbVec3f(x,y,z) = ("
829  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
830  }
831 
832  // ===> Finish up:
833  buffer.close();
834  return byteArray;
835 }
836 
837 //____________________________________________________________________
838 bool VP1QtInventorUtils::deserialize( QByteArray& ba, SbVec3f& vec )
839 {
840  // ===> Setup stream for getting the contents of the byteArray:
841  QBuffer buffer(&ba);
842  buffer.open(QIODevice::ReadOnly);
843  QDataStream state(&buffer);
845  if(ba.size()==12) {
846  // Single precision
847  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
848  float x,y,z;
849 
850  state >> x;
851  state >> y;
852  state >> z;
853 
854  vec.setValue (x,y,z);
855 
856  if (VP1Msg::verbose()) {
857  //Fixme: check for nan's.
858  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbVec3f(x,y,z) = ("
859  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
860  }
861  }
862  else {
863  double x,y,z;
864 
865  state >> x;
866  state >> y;
867  state >> z;
868 
869  vec.setValue (x,y,z);
870 
871  if (VP1Msg::verbose()) {
872  //Fixme: check for nan's.
873  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbVec3f(x,y,z) = ("
874  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
875  }
876  }
877 
878  // ===> Finish up:
879  buffer.close();
880 
881  return true;//Fixme: How to check for errors? - at least check for nan's
882 
883 }
884 
885 //____________________________________________________________________
886 QByteArray VP1QtInventorUtils::serializeSoCameraParameters( const SoCamera& cam ) {
887 
888  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters start");
889 
890  // ===> Setup stream writing to a byteArray:
891  QByteArray byteArray;
892  QBuffer buffer(&byteArray);
893  buffer.open(QIODevice::WriteOnly);
894  QDataStream out(&buffer);
895 
896  cam.ref();
897  //Write data:
898  SbRotation camrot = cam.orientation.getValue();
899  out << serialize(camrot);
900  SbVec3f campos = cam.position.getValue();
901  out << serialize(campos);
902  float f_aspectRatio(cam.aspectRatio.getValue());
903  float f_nearDistance(cam.nearDistance.getValue());
904  float f_farDistance(cam.farDistance.getValue());
905  float f_focalDistance(cam.focalDistance.getValue());
906  out << (double)f_aspectRatio;
907  out << (double)f_nearDistance;
908  out << (double)f_farDistance;
909  out << (double)f_focalDistance;
910 
911  int viewportmap(-1);
912  switch (cam.viewportMapping.getValue()) {
913  case SoCamera::CROP_VIEWPORT_FILL_FRAME: viewportmap = 0;break;
914  case SoCamera::CROP_VIEWPORT_LINE_FRAME: viewportmap = 1;break;
915  case SoCamera::CROP_VIEWPORT_NO_FRAME: viewportmap = 2;break;
916  case SoCamera::ADJUST_CAMERA: viewportmap = 3;break;
917  case SoCamera::LEAVE_ALONE: viewportmap = 4;break;
918  }
919  out << viewportmap;
920 
921  //Camera type and specialised info:
922  int camtype (-1);
923  if (cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()))
924  camtype = 0;
925  else if (cam.getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId()))
926  camtype = 1;
927 
928  out <<camtype;
929  if (camtype==0) {
930  out << (double)static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue();
931  } else if (camtype==1) {
932  out << (double)static_cast<const SoOrthographicCamera*>(&cam)->height.getValue();
933  }
934 
935  cam.unrefNoDelete();
936 
937  // ===> Finish up:
938  buffer.close();
939 
940  if (VP1Msg::verbose()) {
941  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
942  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
943  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
944  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
945  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
946  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters camtype = "
947  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
948  if (camtype==0)
949  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters (persp) heightAngle = "
950  +QString::number(static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue()));
951  if (camtype==1)
952  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters (ortho) height = "
953  +QString::number(static_cast<const SoOrthographicCamera*>(&cam)->height.getValue()));
954  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters end");
955  }
956 
957  return byteArray;
958 }
959 
960 //____________________________________________________________________
961 bool VP1QtInventorUtils::deserializeSoCameraParameters( QByteArray& ba, SoCamera& cam )
962 {
963  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters start");
964  if (ba==QByteArray())
965  return false;
966 
967  // ===> Setup stream for getting the contents of the byteArray:
968  QBuffer buffer(&ba);
969  buffer.open(QIODevice::ReadOnly);
970  QDataStream state(&buffer);
972  if(ba.size()==64) {
973  // Single precision
974  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
975 
976  //Orientation:
977  SbRotation rot; QByteArray ba_rot; state >> ba_rot;
978  if (!deserialize(ba_rot,rot)) return false;
979  //position:
980  SbVec3f pos; QByteArray ba_pos; state >> ba_pos;
981  if (!deserialize(ba_pos,pos)) return false;
982 
983  bool save = cam.enableNotify(false);
984  cam.ref();
985  cam.orientation.setValue(rot);
986  cam.position.setValue(pos);
987  //Misc:
988  float f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
989 
990  state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
991  state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
992  state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
993  state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
994  //viewport mapping:
995  int viewportmap;
996  state>>viewportmap;
997  switch (viewportmap) {
998  case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME); break;
999  case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);break;
1000  case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);break;
1001  case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);break;
1002  case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);break;
1003  //ERROR
1004  }
1005 
1006  bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1007 
1008  //Camera type and specialised info:
1009  int camtype;
1010  state>>camtype;
1011  float f_orthopersp_heightpar(-999);
1012  if (camtype==0) {
1013  //perspective
1014  if (!passedcameraisperspective)
1015  return false;
1016  state >> f_orthopersp_heightpar;
1017  static_cast<SoPerspectiveCamera*>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1018  } else if (camtype==1) {
1019  //ortho
1020  if (passedcameraisperspective)
1021  return false;
1022  state >> f_orthopersp_heightpar;
1023  static_cast<SoOrthographicCamera*>(&cam)->height.setValue(f_orthopersp_heightpar);
1024  }
1025 
1026  if (save) {
1027  cam.enableNotify(true);
1028  cam.touch();
1029  }
1030 
1031  // ===> Finish up:
1032  buffer.close();
1033 
1034  if (VP1Msg::verbose()) {
1035  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
1036  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
1037  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
1038  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
1039  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
1040  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters camtype = "
1041  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
1042  if (camtype==0)
1043  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (persp) heightAngle = "
1044  +QString::number(f_orthopersp_heightpar));
1045  if (camtype==1)
1046  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (ortho) height = "
1047  +QString::number(f_orthopersp_heightpar));
1048 
1049  }
1050  }
1051  else {
1052  // Double precision
1053 
1054  //Orientation:
1055  SbRotation rot; QByteArray ba_rot; state >> ba_rot;
1056  if (!deserialize(ba_rot,rot)) return false;
1057  //position:
1058  SbVec3f pos; QByteArray ba_pos; state >> ba_pos;
1059  if (!deserialize(ba_pos,pos)) return false;
1060 
1061  bool save = cam.enableNotify(false);
1062  cam.ref();
1063  cam.orientation.setValue(rot);
1064  cam.position.setValue(pos);
1065  //Misc:
1066  double f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
1067 
1068  state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
1069  state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
1070  state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
1071  state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
1072  //viewport mapping:
1073  int viewportmap;
1074  state>>viewportmap;
1075  switch (viewportmap) {
1076  case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME); break;
1077  case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);break;
1078  case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);break;
1079  case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);break;
1080  case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);break;
1081  //ERROR
1082  }
1083 
1084  bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1085 
1086  //Camera type and specialised info:
1087  int camtype;
1088  state>>camtype;
1089  double f_orthopersp_heightpar(-999);
1090  if (camtype==0) {
1091  //perspective
1092  if (!passedcameraisperspective)
1093  return false;
1094  state >> f_orthopersp_heightpar;
1095  static_cast<SoPerspectiveCamera*>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1096  } else if (camtype==1) {
1097  //ortho
1098  if (passedcameraisperspective)
1099  return false;
1100  state >> f_orthopersp_heightpar;
1101  static_cast<SoOrthographicCamera*>(&cam)->height.setValue(f_orthopersp_heightpar);
1102  }
1103 
1104  if (save) {
1105  cam.enableNotify(true);
1106  cam.touch();
1107  }
1108 
1109  // ===> Finish up:
1110  buffer.close();
1111 
1112  if (VP1Msg::verbose()) {
1113  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
1114  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
1115  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
1116  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
1117  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
1118  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters camtype = "
1119  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
1120  if (camtype==0)
1121  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (persp) heightAngle = "
1122  +QString::number(f_orthopersp_heightpar));
1123  if (camtype==1)
1124  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (ortho) height = "
1125  +QString::number(f_orthopersp_heightpar));
1126 
1127  }
1128  }
1129 
1130  cam.unrefNoDelete();
1131  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters end");
1132  return true;
1133 }
1134 
1135 //____________________________________________________________________
1136 SbColor VP1QtInventorUtils::qcol2sbcol(const QColor& col)
1137 {
1138  return SbColor( col.red()/255.0, col.green()/255.0, col.blue()/255.0 );
1139 }
1140 
1141 //____________________________________________________________________
1142 QColor VP1QtInventorUtils::sbcol2qcol(const SbColor& col)
1143 {
1144  float r,g,b;
1145  col.getValue(r,g,b);
1146  return QColor::fromRgbF( r,g,b );
1147 }
1148 
1149 //____________________________________________________________________
1151 {
1152  if (!m||m->ambientColor.getNum()!=1
1153  ||m->diffuseColor.getNum()!=1
1154  ||m->specularColor.getNum()!=1
1155  ||m->emissiveColor.getNum()!=1
1156  ||m->transparency.getNum()!=1
1157  ||m->shininess.getNum()!=1) {
1158  VP1Msg::message("VP1QtInventorUtils::serialiseSoMaterial Error: "
1159  "Passed material must have exactly one value in each of the 6 fields!!");
1160  return QByteArray();
1161  }
1162 
1163 
1164  // ===> Setup stream writing to a byteArray:
1165  QByteArray byteArray;
1166  QBuffer buffer(&byteArray);
1167  buffer.open(QIODevice::WriteOnly);
1168  QDataStream out(&buffer);
1169 
1170  //Write data:
1171  out << QString("somat_v1_begin");
1172  out << sbcol2qcol(m->ambientColor[0]);
1173  out << sbcol2qcol(m->diffuseColor[0]);
1174  out << sbcol2qcol(m->specularColor[0]);
1175  out << sbcol2qcol(m->emissiveColor[0]);
1176  out << (double)m->shininess[0];
1177  out << (double)m->transparency[0];
1178  out << QString("somat_end");
1179 
1180  // ===> Finish up:
1181  buffer.close();
1182 
1183  return byteArray;
1184 
1185 }
1186 
1187 //____________________________________________________________________
1188 bool VP1QtInventorUtils::deserialiseSoMaterial(QByteArray&ba,SoMaterial *&m)
1189 {
1190  if (!m||m->ambientColor.getNum()!=1
1191  ||m->diffuseColor.getNum()!=1
1192  ||m->specularColor.getNum()!=1
1193  ||m->emissiveColor.getNum()!=1
1194  ||m->transparency.getNum()!=1
1195  ||m->shininess.getNum()!=1) {
1196  VP1Msg::message("VP1QtInventorUtils::deserialiseSoMaterial Error: "
1197  "Passed material must have exactly one value in each of the 6 fields!!");
1198  return false;
1199  }
1200 
1201  // ===> Setup stream for getting the contents of the byteArray:
1202  QBuffer buffer(&ba);
1203  buffer.open(QIODevice::ReadOnly);
1204  QDataStream stream(&buffer);
1205  if(ba.size()==106)
1206  stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
1207 
1208  //Read contents while checking for validity
1209  QString str; stream >> str;
1210  if (str!="somat_v1_begin")
1211  return false;
1212 
1213  QColor ambientcol; stream >> ambientcol;
1214  if (!ambientcol.isValid())
1215  return false;
1216 
1217  QColor diffusecol; stream >> diffusecol;
1218  if (!diffusecol.isValid())
1219  return false;
1220 
1221  QColor specularcol; stream >> specularcol;
1222  if (!specularcol.isValid())
1223  return false;
1224 
1225  QColor emissivecol; stream >> emissivecol;
1226  if (!emissivecol.isValid())
1227  return false;
1228 
1229  if(ba.size()==106) {
1230  // Single precision
1231  float shininess; stream >> shininess;
1232  if (shininess<0.0f||shininess>1.0f)
1233  return false;
1234 
1235  float transparency; stream >> transparency;
1236  if (transparency<0.0f||transparency>1.0f)
1237  return false;
1238 
1239  stream >> str;
1240  if (str!="somat_end")
1241  return false;
1242 
1243  buffer.close();
1244 
1245  //Apply values:
1246  m->ambientColor.setValue(qcol2sbcol(ambientcol));
1247  m->diffuseColor.setValue(qcol2sbcol(diffusecol));
1248  m->specularColor.setValue(qcol2sbcol(specularcol));
1249  m->emissiveColor.setValue(qcol2sbcol(emissivecol));
1250  m->shininess.setValue(shininess);
1251  m->transparency.setValue(transparency);
1252  }
1253  else {
1254  // Double precision
1255  double shininess; stream >> shininess;
1256  if (shininess<0.0||shininess>1.0)
1257  return false;
1258 
1259  double transparency; stream >> transparency;
1260  if (transparency<0.0||transparency>1.0)
1261  return false;
1262 
1263  stream >> str;
1264  if (str!="somat_end")
1265  return false;
1266 
1267  buffer.close();
1268 
1269  //Apply values:
1270  m->ambientColor.setValue(qcol2sbcol(ambientcol));
1271  m->diffuseColor.setValue(qcol2sbcol(diffusecol));
1272  m->specularColor.setValue(qcol2sbcol(specularcol));
1273  m->emissiveColor.setValue(qcol2sbcol(emissivecol));
1274  m->shininess.setValue(shininess);
1275  m->transparency.setValue(transparency);
1276  }
1277 
1278  return true;
1279 }
1280 
1281 //____________________________________________________________________
1282 SoNode * VP1QtInventorUtils::createCircle( const double& radius )
1283 {
1284  SoGroup* grp = new SoGroup;
1285  grp->ref();
1286 
1287  SoCoordinate4 * coord = new SoCoordinate4;
1288  const double invsqrttwo=0.707106781186547;
1289 
1290  int icoord(0);
1291  coord->point.set1Value(icoord++,SbVec4f(1*radius,0,0,1));
1292  coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*radius,invsqrttwo*radius,0,invsqrttwo));
1293  coord->point.set1Value(icoord++,SbVec4f(0,1*radius,0,1));
1294  coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*radius,invsqrttwo*radius,0,invsqrttwo));
1295  coord->point.set1Value(icoord++,SbVec4f(-1*radius,0,0,1));
1296  coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*radius,-invsqrttwo*radius,0,invsqrttwo));
1297  coord->point.set1Value(icoord++,SbVec4f(0,-1*radius,0,1));
1298  coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*radius,-invsqrttwo*radius,0,invsqrttwo));
1299  coord->point.set1Value(icoord++,SbVec4f(1*radius,0,0,1));
1300 
1301  SoNurbsCurve * curve = new SoNurbsCurve;
1302  curve->numControlPoints = icoord;
1303 
1304  int iknot(0);
1305 
1306  curve->knotVector.set1Value(iknot++,0);
1307  curve->knotVector.set1Value(iknot++,0);
1308  curve->knotVector.set1Value(iknot++,0);
1309  curve->knotVector.set1Value(iknot++,1);
1310  curve->knotVector.set1Value(iknot++,1);
1311  curve->knotVector.set1Value(iknot++,2);
1312  curve->knotVector.set1Value(iknot++,2);
1313  curve->knotVector.set1Value(iknot++,3);
1314  curve->knotVector.set1Value(iknot++,3);
1315  curve->knotVector.set1Value(iknot++,4);
1316  curve->knotVector.set1Value(iknot++,4);
1317  curve->knotVector.set1Value(iknot++,4);
1318  grp->addChild(coord);
1319  grp->addChild(curve);
1320 
1321  grp->unrefNoDelete();
1322  return grp;
1323 }
1324 
1325 //____________________________________________________________________
1326 SoNode * VP1QtInventorUtils::createEllipse( const double& radiusX, const double& radiusY, const int& numnodes )
1327 {
1328  SoVertexProperty *vertices = new SoVertexProperty();
1329 
1330  int iver(0);
1331  vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1332  for (int i = 1; i < numnodes; i++)
1333  {
1334  vertices->vertex.set1Value(iver++,
1335  cos(2.0*static_cast<double>(i)*M_PI/static_cast<double>(numnodes))*radiusX,
1336  sin(2.0*static_cast<double>(i)*M_PI/static_cast<double>(numnodes))*radiusY,0.0);
1337  }
1338  vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1339 
1340  SoLineSet * ellipse = new SoLineSet();
1341  ellipse->numVertices = iver;
1342  ellipse->vertexProperty = vertices;
1343 
1344  return ellipse;
1345 }
1346 
1347 //_____________________________________________________________________________________
1348 bool VP1QtInventorUtils::changePathTail(SoPath*path,SoNode*commonBranchPoint,SoNode*newtail)
1349 {
1350  if (!path||!commonBranchPoint||!newtail)
1351  return false;
1352 
1353  SoSearchAction sa;
1354  sa.setInterest(SoSearchAction::FIRST);
1355  sa.setNode(newtail);
1356  sa.apply(commonBranchPoint);
1357  //First truncate pickedPath at d->sceneroot, then append
1358  //newpath to pickedPath:
1359  SoPath * newpath = sa.getPath();
1360  if (!newpath)
1361  return false;
1362  bool found(false);
1363  for (int i=0;i<path->getLength();++i) {
1364  if (path->getNode(i)==commonBranchPoint) {
1365  found = true;
1366  path->truncate(i+1);
1367  break;
1368  }
1369  }
1370  if (found)
1371  path->append(newpath);
1372  return found;
1373 }
1374 
1375 
1376 //_____________________________________________________________________________________
1379 
1380 //_____________________________________________________________________________________
1381 void * VP1QtInventorUtils::Imp::buffer_realloc(void * bufptr, size_t size)
1382 {
1383  buffer = (char *)realloc(bufptr, size);
1384  buffer_size = size;
1385  return buffer;
1386 }
1387 
1388 //_____________________________________________________________________________________
1390 {
1391  SoOutput out;
1392  buffer = (char *)malloc(1024);
1393  buffer_size = 1024;
1394  out.setBuffer(buffer, buffer_size, buffer_realloc);
1395 
1396  SoWriteAction wa(&out);
1397  wa.apply(root);
1398 
1399  QString s(buffer);
1400  free(buffer);
1401  return s;
1402 }
1403 
1404 //_____________________________________________________________________________________
1406 {
1407  SoToVRML2Action vwa;
1408 
1409  vwa.apply(root);
1410  SoVRMLGroup * newroot = vwa.getVRML2SceneGraph();
1411 
1412  SoOutput out;
1413  out.openFile(qPrintable(filename));
1414  out.setHeaderString("#VRML V2.0 utf8");
1415  SoWriteAction wra(&out);
1416  wra.apply(newroot);
1417  out.closeFile();
1418  newroot->unref();
1419  return;
1420 }
1421 
1422 //_____________________________________________________________________________________
1424 {
1425  if (!root)
1426  return false;
1427 
1428  root->ref();
1429  QString s = Imp::buffer_writeaction(root);
1430  root->unrefNoDelete();
1431 
1432  QFile data(filename);
1433  if (data.open(QFile::WriteOnly | QFile::Truncate)) {
1434  QTextStream out(&data);
1435 #if QTCORE_VERSION >= 0x050E00
1436  out << s << Qt::endl;
1437 #else
1438  out << s << endl;
1439 #endif
1440  return true;
1441  } else {
1442  return false;
1443  }
1444 }
1445 
1446 //_____________________________________________________________________________________
1448 {
1449  // SoDB::init();
1450  SoInput in;
1451  if (!in.openFile(filename.toStdString().c_str()))
1452  return 0;
1453  return SoDB::readAll(&in);
1454 }
1455 
1456 
1457 //_____________________________________________________________________________________
1459 {
1460  if (!root)
1461  return false;
1462 
1463  root->ref();
1465  root->unrefNoDelete();
1466 
1467  // QFile data(filename);
1468  // if (data.open(QFile::WriteOnly | QFile::Truncate)) {
1469  // QTextStream out(&data);
1470  // out << s << endl;
1471  // return true;
1472  // } else {
1473  // return false;
1474  // }
1475  return true;
1476 }
1477 
1478 
1480 #include "VP1Base/VP1MaterialButton.h"
1481 //_____________________________________________________________________________________
1482 void VP1QtInventorUtils::setMatColor( SoMaterial * m, const double& r, const double& g, const double& b,
1483  const double& brightness, const double& transp )
1484 {
1485  if (m)
1486  VP1MaterialButton::setMaterialParameters( m, r,g,b,brightness,transp );
1487 }
1488 
1489 //_____________________________________________________________________________________
1490 void VP1QtInventorUtils::setMatColor( SoMaterial * m, const QColor& col,
1491  const double& brightness, const double& transp )
1492 {
1493  setMatColor( m, col.redF(), col.greenF(), col.blueF(), brightness, transp);
1494 }
1496 
1497 //_____________________________________________________________________________________
1498 void VP1QtInventorUtils::getLineWidthRanges(double& min, double& max, double& granularity)
1499 {
1504  granularity = Imp::allowedLineWidthGranularity;
1505 }
1506 
1507 //_____________________________________________________________________________________
1508 void VP1QtInventorUtils::getPointSizeRanges(double& min, double& max, double& granularity)
1509 {
1514  granularity = Imp::allowedPointSizeGranularity;
1515 }
1516 
1517 //_____________________________________________________________________________________
1519 {
1521  return;
1523  QWidget * w(0);
1524  if (!ra) {
1525  VP1Msg::messageVerbose("VP1QtInventorUtils WARNING: Have to create temporary renderarea for the sole "
1526  "purpose of getting supported line widths and point sizes!");
1527  w = new QWidget(0);
1528  ra = new VP1ExaminerViewer(w);
1529  }
1530  SbVec2f range; float granularity;
1531  ra->getLineWidthLimits(range, granularity);
1532  float a,b;
1533  range.getValue(a,b);
1536  Imp::allowedLineWidthGranularity = granularity;
1537  VP1Msg::messageVerbose("VP1QtInventorUtils Determined line widths supported by hardware (min,max,granularity) = ("
1538  +VP1Msg::str(a)+", "+VP1Msg::str(b)+", "+VP1Msg::str(granularity)+")");
1539  ra->getPointSizeLimits(range, granularity);
1540  range.getValue(a,b);
1543  Imp::allowedPointSizeGranularity = granularity;
1544  VP1Msg::messageVerbose("VP1QtInventorUtils Determined point sizes supported by hardware (min,max,granularity) = ("
1545  +VP1Msg::str(a)+", "+VP1Msg::str(b)+", "+VP1Msg::str(granularity)+")");
1546  if (w) {
1547  delete ra;
1548  delete w;
1549  }
1550  //We clip to get a more consistent behaviour across hardware (and to limit ourselves to reasonable values:
1551 
1552  if (Imp::allowedLineWidthMin<0.5)
1554  if (Imp::allowedLineWidthMax>7.0)
1556  if (Imp::allowedPointSizeMin<0.5)
1558  if (Imp::allowedPointSizeMax>12.0)
1559  Imp::allowedPointSizeMax = 12.0;
1560 }
1561 
1562 //_____________________________________________________________________________________
1564 {
1565  if (!slider)
1566  return;
1569  int nsteps = std::min(1000,std::max<int>(0,static_cast<int>((Imp::allowedLineWidthMax-Imp::allowedLineWidthMin)/Imp::allowedLineWidthGranularity)));
1570  int stepsPerUnit = std::min(nsteps,std::max<int>(1,static_cast<int>(1.0/Imp::allowedLineWidthGranularity)));
1571  slider->setRange(0,nsteps);
1572  slider->setSingleStep(1);
1573  slider->setPageStep(stepsPerUnit);
1574 }
1575 
1576 //_____________________________________________________________________________________
1578 {
1579  if (!slider)
1580  return;
1583  int nsteps = std::min(1000,std::max<int>(0,
1585  int stepsPerUnit = std::min(nsteps,std::max<int>(1,
1586  static_cast<int>(0.5+1.0/Imp::allowedPointSizeGranularity)));
1587  slider->setRange(0,nsteps);
1588  slider->setSingleStep(1);
1589  slider->setPageStep(stepsPerUnit);
1590 }
1591 
1592 //_____________________________________________________________________________________
1593 void VP1QtInventorUtils::setValueLineWidthSlider(QSlider * slider, const double& value)
1594 {
1595  if (!slider)
1596  return;
1599  int itarget = std::min(slider->maximum(),std::max<int>(slider->minimum(),
1601  if (slider->value()!=itarget)
1602  slider->setValue(itarget);
1603 }
1604 
1605 //_____________________________________________________________________________________
1606 void VP1QtInventorUtils::setValuePointSizeSlider(QSlider * slider, const double& value)
1607 {
1608  if (!slider)
1609  return;
1612  int itarget = std::min(slider->maximum(),std::max<int>(slider->minimum(),
1614  if (slider->value()!=itarget)
1615  slider->setValue(itarget);
1616 }
1617 
1618 //_____________________________________________________________________________________
1619 double VP1QtInventorUtils::getValueLineWidthSlider(const QSlider * slider)
1620 {
1621  if (!slider)
1622  return 1.0;
1627 }
1628 
1629 //_____________________________________________________________________________________
1630 double VP1QtInventorUtils::getValuePointSizeSlider(const QSlider * slider)
1631 {
1632  if (!slider)
1633  return 1.0;
1638 }
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
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:1619
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:1326
VP1QtInventorUtils::Imp::_ImageRec::min
unsigned int min
Definition: VP1QtInventorUtils.cxx:109
add-xsec-uncert-quadrature-N.alpha
alpha
Definition: add-xsec-uncert-quadrature-N.py:110
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
VP1QtInventorUtils::deserializeSoCameraParameters
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)
Definition: VP1QtInventorUtils.cxx:961
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:1498
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:1381
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
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
VP1Msg.h
VP1QtInventorUtils::Imp::_ImageRec::dim
unsigned short dim
Definition: VP1QtInventorUtils.cxx:107
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
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:124
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:641
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
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
VP1QtInventorUtils::serialize
static QByteArray serialize(const SbRotation &)
Definition: VP1QtInventorUtils.cxx:727
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:77
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:1188
VP1QtInventorUtils::Imp::_ImageRec::file
FILE * file
Definition: VP1QtInventorUtils.cxx:113
VP1QtInventorUtils::createCircle
static SoNode * createCircle(const double &radius)
Definition: VP1QtInventorUtils.cxx:1282
VP1QtInventorUtils::Imp::buffer_size
static size_t buffer_size
Definition: VP1QtInventorUtils.cxx:363
VP1QtInventorUtils.h
VP1QtInventorUtils::setLimitsPointSizeSlider
static void setLimitsPointSizeSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1577
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
VP1QtInventorUtils::getPointSizeRanges
static void getPointSizeRanges(double &min, double &max, double &granularity)
Definition: VP1QtInventorUtils.cxx:1508
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:1630
VP1QtInventorUtils::transparencyType2PrettyString
static QString transparencyType2PrettyString(SoGLRenderAction::TransparencyType)
Definition: VP1QtInventorUtils.cxx:707
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:647
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: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: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:1150
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:759
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
hist_file_dump.f
f
Definition: hist_file_dump.py:135
VP1QtInventorUtils::qcol2sbcol
static SbColor qcol2sbcol(const QColor &)
Definition: VP1QtInventorUtils.cxx:1136
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:132
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
VP1QtInventorUtils::Imp::buffer_vrmlwriteaction
static void buffer_vrmlwriteaction(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1405
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:1593
VP1QtInventorUtils::imageFromRGBFile
static QImage imageFromRGBFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:407
lumiFormat.array
array
Definition: lumiFormat.py:91
VP1QtInventorUtils::sbcol2qcol
static QColor sbcol2qcol(const SbColor &)
Definition: VP1QtInventorUtils.cxx:1142
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:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1QtInventorUtils::transparencyTypeToInt
static int transparencyTypeToInt(SoGLRenderAction::TransparencyType)
Definition: VP1QtInventorUtils.cxx:665
VP1QtInventorUtils::Imp::_ImageRec::wasteBytes
unsigned int wasteBytes
Definition: VP1QtInventorUtils.cxx:110
VP1QtInventorUtils::Imp::buffer_writeaction
static QString buffer_writeaction(SoNode *root)
Definition: VP1QtInventorUtils.cxx:1389
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:1447
VP1QtInventorUtils::writeGraphToFile
static bool writeGraphToFile(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1423
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:1482
VP1QtInventorUtils::setValuePointSizeSlider
static void setValuePointSizeSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1606
VP1QtInventorUtils::setLimitsLineWidthSlider
static void setLimitsLineWidthSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1563
VP1QtInventorUtils::intToTransparencyType
static SoGLRenderAction::TransparencyType intToTransparencyType(int)
Definition: VP1QtInventorUtils.cxx:685
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:595
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:1518
VP1QtInventorUtils::writeGraphToVRMLFile
static bool writeGraphToVRMLFile(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1458
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:886
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:1348
VP1QtInventorUtils::Imp::constructImageWithTransparentBackground
static QImage constructImageWithTransparentBackground(const QImage &im_black_bgd, const QImage &image_white_bgd)
Definition: VP1QtInventorUtils.cxx:602
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