ATLAS Offline Software
Classes | Static Public Member Functions | Private Member Functions | List of all members
VP1QtInventorUtils Class Reference

#include <VP1QtInventorUtils.h>

Collaboration diagram for VP1QtInventorUtils:

Classes

class  Imp
 

Static Public Member Functions

static SbColor qcol2sbcol (const QColor &)
 
static QColor sbcol2qcol (const SbColor &)
 
static SoNode * createCircle (const double &radius)
 
static SoNode * createEllipse (const double &radiusX, const double &radiusY, const int &numnodes=12)
 
static QImage renderToImage (VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
 
static QPixmap renderToPixmap (VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
 
static QPixmap pixmapFromRGBFile (const QString &filename)
 
static QImage imageFromRGBFile (const QString &filename)
 
static SoGLRenderAction::TransparencyType getDefaultVP1TransparencyType ()
 
static QList< SoGLRenderAction::TransparencyType > getAllTransparencyTypes ()
 
static int transparencyTypeToInt (SoGLRenderAction::TransparencyType)
 
static SoGLRenderAction::TransparencyType intToTransparencyType (int)
 
static QString transparencyType2PrettyString (SoGLRenderAction::TransparencyType)
 
static QByteArray serialize (const SbRotation &)
 
static bool deserialize (QByteArray &, SbRotation &)
 
static QByteArray serialize (const SbVec3f &)
 
static bool deserialize (QByteArray &, SbVec3f &)
 
static QByteArray serializeSoCameraParameters (const SoCamera &)
 
static bool deserializeSoCameraParameters (QByteArray &, SoCamera &)
 
static QByteArray serialiseSoMaterial (SoMaterial *)
 
static bool deserialiseSoMaterial (QByteArray &, SoMaterial *&)
 
static bool changePathTail (SoPath *path, SoNode *commonBranchPoint, SoNode *newtail)
 
static bool writeGraphToFile (SoNode *root, const QString &filename)
 
static SoSeparator * readGraphFromFile (const QString &filename)
 
static bool writeGraphToVRMLFile (SoNode *root, const QString &filename)
 
static void setMatColor (SoMaterial *, const double &r, const double &g, const double &b, const double &brightness=0.0, const double &transp=0.0)
 
static void setMatColor (SoMaterial *, const QColor &, const double &brightness=0.0, const double &transp=0.0)
 
static void getLineWidthRanges (double &min, double &max, double &granularity)
 
static void getPointSizeRanges (double &min, double &max, double &granularity)
 
static void setLimitsLineWidthSlider (QSlider *)
 
static void setLimitsPointSizeSlider (QSlider *)
 
static void setValueLineWidthSlider (QSlider *, const double &value)
 
static void setValuePointSizeSlider (QSlider *, const double &value)
 
static double getValueLineWidthSlider (const QSlider *)
 
static double getValuePointSizeSlider (const QSlider *)
 
static void ensureInitLineWidthAndPointSize (SoQtRenderArea *)
 

Private Member Functions

 VP1QtInventorUtils ()
 
 ~VP1QtInventorUtils ()
 

Detailed Description

Definition at line 41 of file VP1QtInventorUtils.h.

Constructor & Destructor Documentation

◆ VP1QtInventorUtils()

VP1QtInventorUtils::VP1QtInventorUtils ( )
private

Definition at line 390 of file VP1QtInventorUtils.cxx.

391 {
392 }

◆ ~VP1QtInventorUtils()

VP1QtInventorUtils::~VP1QtInventorUtils ( )
private

Definition at line 395 of file VP1QtInventorUtils.cxx.

396 {
397 }

Member Function Documentation

◆ changePathTail()

bool VP1QtInventorUtils::changePathTail ( SoPath *  path,
SoNode *  commonBranchPoint,
SoNode *  newtail 
)
static

Definition at line 1348 of file VP1QtInventorUtils.cxx.

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 }

◆ createCircle()

SoNode * VP1QtInventorUtils::createCircle ( const double &  radius)
static

Definition at line 1282 of file VP1QtInventorUtils.cxx.

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 }

◆ createEllipse()

SoNode * VP1QtInventorUtils::createEllipse ( const double &  radiusX,
const double &  radiusY,
const int &  numnodes = 12 
)
static

Definition at line 1326 of file VP1QtInventorUtils.cxx.

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 }

◆ deserialiseSoMaterial()

bool VP1QtInventorUtils::deserialiseSoMaterial ( QByteArray &  ba,
SoMaterial *&  m 
)
static

Definition at line 1188 of file VP1QtInventorUtils.cxx.

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 }

◆ deserialize() [1/2]

bool VP1QtInventorUtils::deserialize ( QByteArray &  ba,
SbRotation &  rot 
)
static

Definition at line 759 of file VP1QtInventorUtils.cxx.

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 }

◆ deserialize() [2/2]

bool VP1QtInventorUtils::deserialize ( QByteArray &  ba,
SbVec3f &  vec 
)
static

Definition at line 838 of file VP1QtInventorUtils.cxx.

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 }

◆ deserializeSoCameraParameters()

bool VP1QtInventorUtils::deserializeSoCameraParameters ( QByteArray &  ba,
SoCamera &  cam 
)
static

Definition at line 961 of file VP1QtInventorUtils.cxx.

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 }

◆ ensureInitLineWidthAndPointSize()

void VP1QtInventorUtils::ensureInitLineWidthAndPointSize ( SoQtRenderArea *  ra)
static

Definition at line 1518 of file VP1QtInventorUtils.cxx.

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 }

◆ getAllTransparencyTypes()

QList< SoGLRenderAction::TransparencyType > VP1QtInventorUtils::getAllTransparencyTypes ( )
static

Definition at line 647 of file VP1QtInventorUtils.cxx.

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 }

◆ getDefaultVP1TransparencyType()

SoGLRenderAction::TransparencyType VP1QtInventorUtils::getDefaultVP1TransparencyType ( )
static

Definition at line 641 of file VP1QtInventorUtils.cxx.

642 {
643  return SoGLRenderAction::DELAYED_BLEND;
644 }

◆ getLineWidthRanges()

void VP1QtInventorUtils::getLineWidthRanges ( double &  min,
double &  max,
double &  granularity 
)
static

Definition at line 1498 of file VP1QtInventorUtils.cxx.

◆ getPointSizeRanges()

void VP1QtInventorUtils::getPointSizeRanges ( double &  min,
double &  max,
double &  granularity 
)
static

Definition at line 1508 of file VP1QtInventorUtils.cxx.

◆ getValueLineWidthSlider()

double VP1QtInventorUtils::getValueLineWidthSlider ( const QSlider *  slider)
static

Definition at line 1619 of file VP1QtInventorUtils.cxx.

1620 {
1621  if (!slider)
1622  return 1.0;
1627 }

◆ getValuePointSizeSlider()

double VP1QtInventorUtils::getValuePointSizeSlider ( const QSlider *  slider)
static

Definition at line 1630 of file VP1QtInventorUtils.cxx.

1631 {
1632  if (!slider)
1633  return 1.0;
1638 }

◆ imageFromRGBFile()

QImage VP1QtInventorUtils::imageFromRGBFile ( const QString &  filename)
static

Definition at line 407 of file VP1QtInventorUtils.cxx.

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 }

◆ intToTransparencyType()

SoGLRenderAction::TransparencyType VP1QtInventorUtils::intToTransparencyType ( int  i)
static

Definition at line 685 of file VP1QtInventorUtils.cxx.

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 }

◆ pixmapFromRGBFile()

QPixmap VP1QtInventorUtils::pixmapFromRGBFile ( const QString &  filename)
static

Definition at line 400 of file VP1QtInventorUtils.cxx.

401 {
402  return QPixmap::fromImage(imageFromRGBFile(filename));
403 
404 }

◆ qcol2sbcol()

SbColor VP1QtInventorUtils::qcol2sbcol ( const QColor &  col)
static

Definition at line 1136 of file VP1QtInventorUtils.cxx.

1137 {
1138  return SbColor( col.red()/255.0, col.green()/255.0, col.blue()/255.0 );
1139 }

◆ readGraphFromFile()

SoSeparator * VP1QtInventorUtils::readGraphFromFile ( const QString &  filename)
static

Definition at line 1447 of file VP1QtInventorUtils.cxx.

1448 {
1449  // SoDB::init();
1450  SoInput in;
1451  if (!in.openFile(filename.toStdString().c_str()))
1452  return 0;
1453  return SoDB::readAll(&in);
1454 }

◆ renderToImage()

QImage VP1QtInventorUtils::renderToImage ( VP1ExaminerViewer ra,
int  pixels_x,
int  pixels_y,
bool  transparent_background = false,
double  actualRenderedSizeFact = 1.0 
)
static

Definition at line 436 of file VP1QtInventorUtils.cxx.

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 }

◆ renderToPixmap()

QPixmap VP1QtInventorUtils::renderToPixmap ( VP1ExaminerViewer ra,
int  pixels_x,
int  pixels_y,
bool  transparent_background = false,
double  actualRenderedSizeFact = 1.0 
)
static

Definition at line 595 of file VP1QtInventorUtils.cxx.

597 {
598  return QPixmap::fromImage(renderToImage(ra, pixels_x, pixels_y, transparent_background, actualRenderedSizeFact));
599 }

◆ sbcol2qcol()

QColor VP1QtInventorUtils::sbcol2qcol ( const SbColor &  col)
static

Definition at line 1142 of file VP1QtInventorUtils.cxx.

1143 {
1144  float r,g,b;
1145  col.getValue(r,g,b);
1146  return QColor::fromRgbF( r,g,b );
1147 }

◆ serialiseSoMaterial()

QByteArray VP1QtInventorUtils::serialiseSoMaterial ( SoMaterial *  m)
static

Definition at line 1150 of file VP1QtInventorUtils.cxx.

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 }

◆ serialize() [1/2]

QByteArray VP1QtInventorUtils::serialize ( const SbRotation &  rot)
static

Definition at line 727 of file VP1QtInventorUtils.cxx.

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 }

◆ serialize() [2/2]

QByteArray VP1QtInventorUtils::serialize ( const SbVec3f &  vec)
static

Definition at line 811 of file VP1QtInventorUtils.cxx.

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 }

◆ serializeSoCameraParameters()

QByteArray VP1QtInventorUtils::serializeSoCameraParameters ( const SoCamera &  cam)
static

Definition at line 886 of file VP1QtInventorUtils.cxx.

886  {
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 }

◆ setLimitsLineWidthSlider()

void VP1QtInventorUtils::setLimitsLineWidthSlider ( QSlider *  slider)
static

Definition at line 1563 of file VP1QtInventorUtils.cxx.

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 }

◆ setLimitsPointSizeSlider()

void VP1QtInventorUtils::setLimitsPointSizeSlider ( QSlider *  slider)
static

Definition at line 1577 of file VP1QtInventorUtils.cxx.

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 }

◆ setMatColor() [1/2]

void VP1QtInventorUtils::setMatColor ( SoMaterial *  m,
const double &  r,
const double &  g,
const double &  b,
const double &  brightness = 0.0,
const double &  transp = 0.0 
)
static

Definition at line 1482 of file VP1QtInventorUtils.cxx.

1484 {
1485  if (m)
1486  VP1MaterialButton::setMaterialParameters( m, r,g,b,brightness,transp );
1487 }

◆ setMatColor() [2/2]

void VP1QtInventorUtils::setMatColor ( SoMaterial *  m,
const QColor &  col,
const double &  brightness = 0.0,
const double &  transp = 0.0 
)
static

Definition at line 1490 of file VP1QtInventorUtils.cxx.

1492 {
1493  setMatColor( m, col.redF(), col.greenF(), col.blueF(), brightness, transp);
1494 }

◆ setValueLineWidthSlider()

void VP1QtInventorUtils::setValueLineWidthSlider ( QSlider *  slider,
const double &  value 
)
static

Definition at line 1593 of file VP1QtInventorUtils.cxx.

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 }

◆ setValuePointSizeSlider()

void VP1QtInventorUtils::setValuePointSizeSlider ( QSlider *  slider,
const double &  value 
)
static

Definition at line 1606 of file VP1QtInventorUtils.cxx.

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 }

◆ transparencyType2PrettyString()

QString VP1QtInventorUtils::transparencyType2PrettyString ( SoGLRenderAction::TransparencyType  tt)
static

Definition at line 707 of file VP1QtInventorUtils.cxx.

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 }

◆ transparencyTypeToInt()

int VP1QtInventorUtils::transparencyTypeToInt ( SoGLRenderAction::TransparencyType  tt)
static

Definition at line 665 of file VP1QtInventorUtils.cxx.

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 }

◆ writeGraphToFile()

bool VP1QtInventorUtils::writeGraphToFile ( SoNode *  root,
const QString &  filename 
)
static

Definition at line 1423 of file VP1QtInventorUtils.cxx.

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 }

◆ writeGraphToVRMLFile()

bool VP1QtInventorUtils::writeGraphToVRMLFile ( SoNode *  root,
const QString &  filename 
)
static

Definition at line 1458 of file VP1QtInventorUtils.cxx.

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 }

The documentation for this class was generated from the following files:
NONE
@ NONE
Definition: sTGCenumeration.h:13
beamspotman.r
def r
Definition: beamspotman.py:676
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
VP1ExaminerViewer::getStereoTypeSlot
SoQtViewer::StereoType getStereoTypeSlot(void) const
Definition: VP1ExaminerViewer.cxx:584
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
max
#define max(a, b)
Definition: cfImp.cxx:41
VP1QtInventorUtils::Imp::allowedPointSizeMax
static double allowedPointSizeMax
Definition: VP1QtInventorUtils.cxx:373
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
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
athena.value
value
Definition: athena.py:124
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
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: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
VP1QtInventorUtils::Imp::allowedLineWidthMax
static double allowedLineWidthMax
Definition: VP1QtInventorUtils.cxx:370
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
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
VP1QtInventorUtils::Imp::read_texture
static unsigned * read_texture(const char *name, int *width, int *height, int *components)
Definition: VP1QtInventorUtils.cxx:293
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
VP1QtInventorUtils::deserialize
static bool deserialize(QByteArray &, SbRotation &)
Definition: VP1QtInventorUtils.cxx:759
hist_file_dump.f
f
Definition: hist_file_dump.py:135
VP1QtInventorUtils::qcol2sbcol
static SbColor qcol2sbcol(const QColor &)
Definition: VP1QtInventorUtils.cxx:1136
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
min
#define min(a, b)
Definition: cfImp.cxx:40
VP1QtInventorUtils::imageFromRGBFile
static QImage imageFromRGBFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:407
VP1QtInventorUtils::sbcol2qcol
static QColor sbcol2qcol(const SbColor &)
Definition: VP1QtInventorUtils.cxx:1142
python.selection.number
number
Definition: selection.py:20
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1QtInventorUtils::Imp::buffer_writeaction
static QString buffer_writeaction(SoNode *root)
Definition: VP1QtInventorUtils.cxx:1389
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
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
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
y
#define y
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
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
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
str
Definition: BTagTrackIpAccessor.cxx:11
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
VP1QtInventorUtils::ensureInitLineWidthAndPointSize
static void ensureInitLineWidthAndPointSize(SoQtRenderArea *)
Definition: VP1QtInventorUtils.cxx:1518
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::Imp::constructImageWithTransparentBackground
static QImage constructImageWithTransparentBackground(const QImage &im_black_bgd, const QImage &image_white_bgd)
Definition: VP1QtInventorUtils.cxx:602
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