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

383 {
384 }

◆ ~VP1QtInventorUtils()

VP1QtInventorUtils::~VP1QtInventorUtils ( )
private

Definition at line 387 of file VP1QtInventorUtils.cxx.

388 {
389 }

Member Function Documentation

◆ changePathTail()

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

Definition at line 1340 of file VP1QtInventorUtils.cxx.

1341 {
1342  if (!path||!commonBranchPoint||!newtail)
1343  return false;
1344 
1345  SoSearchAction sa;
1346  sa.setInterest(SoSearchAction::FIRST);
1347  sa.setNode(newtail);
1348  sa.apply(commonBranchPoint);
1349  //First truncate pickedPath at d->sceneroot, then append
1350  //newpath to pickedPath:
1351  SoPath * newpath = sa.getPath();
1352  if (!newpath)
1353  return false;
1354  bool found(false);
1355  for (int i=0;i<path->getLength();++i) {
1356  if (path->getNode(i)==commonBranchPoint) {
1357  found = true;
1358  path->truncate(i+1);
1359  break;
1360  }
1361  }
1362  if (found)
1363  path->append(newpath);
1364  return found;
1365 }

◆ createCircle()

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

Definition at line 1274 of file VP1QtInventorUtils.cxx.

1275 {
1276  SoGroup* grp = new SoGroup;
1277  grp->ref();
1278 
1279  SoCoordinate4 * coord = new SoCoordinate4;
1280  const double invsqrttwo=0.707106781186547;
1281 
1282  int icoord(0);
1283  coord->point.set1Value(icoord++,SbVec4f(1*radius,0,0,1));
1284  coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*radius,invsqrttwo*radius,0,invsqrttwo));
1285  coord->point.set1Value(icoord++,SbVec4f(0,1*radius,0,1));
1286  coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*radius,invsqrttwo*radius,0,invsqrttwo));
1287  coord->point.set1Value(icoord++,SbVec4f(-1*radius,0,0,1));
1288  coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*radius,-invsqrttwo*radius,0,invsqrttwo));
1289  coord->point.set1Value(icoord++,SbVec4f(0,-1*radius,0,1));
1290  coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*radius,-invsqrttwo*radius,0,invsqrttwo));
1291  coord->point.set1Value(icoord++,SbVec4f(1*radius,0,0,1));
1292 
1293  SoNurbsCurve * curve = new SoNurbsCurve;
1294  curve->numControlPoints = icoord;
1295 
1296  int iknot(0);
1297 
1298  curve->knotVector.set1Value(iknot++,0);
1299  curve->knotVector.set1Value(iknot++,0);
1300  curve->knotVector.set1Value(iknot++,0);
1301  curve->knotVector.set1Value(iknot++,1);
1302  curve->knotVector.set1Value(iknot++,1);
1303  curve->knotVector.set1Value(iknot++,2);
1304  curve->knotVector.set1Value(iknot++,2);
1305  curve->knotVector.set1Value(iknot++,3);
1306  curve->knotVector.set1Value(iknot++,3);
1307  curve->knotVector.set1Value(iknot++,4);
1308  curve->knotVector.set1Value(iknot++,4);
1309  curve->knotVector.set1Value(iknot++,4);
1310  grp->addChild(coord);
1311  grp->addChild(curve);
1312 
1313  grp->unrefNoDelete();
1314  return grp;
1315 }

◆ createEllipse()

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

Definition at line 1318 of file VP1QtInventorUtils.cxx.

1319 {
1320  SoVertexProperty *vertices = new SoVertexProperty();
1321 
1322  int iver(0);
1323  vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1324  for (int i = 1; i < numnodes; i++)
1325  {
1326  vertices->vertex.set1Value(iver++,
1327  cos(2.0*static_cast<double>(i)*M_PI/static_cast<double>(numnodes))*radiusX,
1328  sin(2.0*static_cast<double>(i)*M_PI/static_cast<double>(numnodes))*radiusY,0.0);
1329  }
1330  vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1331 
1332  SoLineSet * ellipse = new SoLineSet();
1333  ellipse->numVertices = iver;
1334  ellipse->vertexProperty = vertices;
1335 
1336  return ellipse;
1337 }

◆ deserialiseSoMaterial()

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

Definition at line 1180 of file VP1QtInventorUtils.cxx.

1181 {
1182  if (!m||m->ambientColor.getNum()!=1
1183  ||m->diffuseColor.getNum()!=1
1184  ||m->specularColor.getNum()!=1
1185  ||m->emissiveColor.getNum()!=1
1186  ||m->transparency.getNum()!=1
1187  ||m->shininess.getNum()!=1) {
1188  VP1Msg::message("VP1QtInventorUtils::deserialiseSoMaterial Error: "
1189  "Passed material must have exactly one value in each of the 6 fields!!");
1190  return false;
1191  }
1192 
1193  // ===> Setup stream for getting the contents of the byteArray:
1194  QBuffer buffer(&ba);
1195  buffer.open(QIODevice::ReadOnly);
1196  QDataStream stream(&buffer);
1197  if(ba.size()==106)
1198  stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
1199 
1200  //Read contents while checking for validity
1201  QString str; stream >> str;
1202  if (str!="somat_v1_begin")
1203  return false;
1204 
1205  QColor ambientcol; stream >> ambientcol;
1206  if (!ambientcol.isValid())
1207  return false;
1208 
1209  QColor diffusecol; stream >> diffusecol;
1210  if (!diffusecol.isValid())
1211  return false;
1212 
1213  QColor specularcol; stream >> specularcol;
1214  if (!specularcol.isValid())
1215  return false;
1216 
1217  QColor emissivecol; stream >> emissivecol;
1218  if (!emissivecol.isValid())
1219  return false;
1220 
1221  if(ba.size()==106) {
1222  // Single precision
1223  float shininess; stream >> shininess;
1224  if (shininess<0.0f||shininess>1.0f)
1225  return false;
1226 
1227  float transparency; stream >> transparency;
1228  if (transparency<0.0f||transparency>1.0f)
1229  return false;
1230 
1231  stream >> str;
1232  if (str!="somat_end")
1233  return false;
1234 
1235  buffer.close();
1236 
1237  //Apply values:
1238  m->ambientColor.setValue(qcol2sbcol(ambientcol));
1239  m->diffuseColor.setValue(qcol2sbcol(diffusecol));
1240  m->specularColor.setValue(qcol2sbcol(specularcol));
1241  m->emissiveColor.setValue(qcol2sbcol(emissivecol));
1242  m->shininess.setValue(shininess);
1243  m->transparency.setValue(transparency);
1244  }
1245  else {
1246  // Double precision
1247  double shininess; stream >> shininess;
1248  if (shininess<0.0||shininess>1.0)
1249  return false;
1250 
1251  double transparency; stream >> transparency;
1252  if (transparency<0.0||transparency>1.0)
1253  return false;
1254 
1255  stream >> str;
1256  if (str!="somat_end")
1257  return false;
1258 
1259  buffer.close();
1260 
1261  //Apply values:
1262  m->ambientColor.setValue(qcol2sbcol(ambientcol));
1263  m->diffuseColor.setValue(qcol2sbcol(diffusecol));
1264  m->specularColor.setValue(qcol2sbcol(specularcol));
1265  m->emissiveColor.setValue(qcol2sbcol(emissivecol));
1266  m->shininess.setValue(shininess);
1267  m->transparency.setValue(transparency);
1268  }
1269 
1270  return true;
1271 }

◆ deserialize() [1/2]

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

Definition at line 751 of file VP1QtInventorUtils.cxx.

752 {
753  // ===> Setup stream for getting the contents of the byteArray:
754  QBuffer buffer(&ba);
755  buffer.open(QIODevice::ReadOnly);
756  QDataStream state(&buffer);
758  if(ba.size()==16) {
759  // Single precision
760  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
761  float q0,q1,q2,q3;//quarternion components
762 
763  state >> q0;
764  state >> q1;
765  state >> q2;
766  state >> q3;
767 
768  rot.setValue (q0,q1,q2,q3);
769 
770  if (VP1Msg::verbose()) {
771  //Fixme: check for nan's.
772  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbRotation(q0,q1,q2,q3) = ("
773  +QString::number(q0)+", "+QString::number(q1)+", "
774  +QString::number(q2)+", "+QString::number(q3)+")");
775  }
776  }
777  else {
778  // Double precision
779  double q0,q1,q2,q3;//quarternion components
780 
781  state >> q0;
782  state >> q1;
783  state >> q2;
784  state >> q3;
785 
786  rot.setValue (q0,q1,q2,q3);
787 
788  if (VP1Msg::verbose()) {
789  //Fixme: check for nan's.
790  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbRotation(q0,q1,q2,q3) = ("
791  +QString::number(q0)+", "+QString::number(q1)+", "
792  +QString::number(q2)+", "+QString::number(q3)+")");
793  }
794  }
795 
796  // ===> Finish up:
797  buffer.close();
798 
799  return true;//Fixme: How to check for errors? - at least check for nan's and determinant?
800 }

◆ deserialize() [2/2]

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

Definition at line 830 of file VP1QtInventorUtils.cxx.

831 {
832  // ===> Setup stream for getting the contents of the byteArray:
833  QBuffer buffer(&ba);
834  buffer.open(QIODevice::ReadOnly);
835  QDataStream state(&buffer);
837  if(ba.size()==12) {
838  // Single precision
839  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
840  float x,y,z;
841 
842  state >> x;
843  state >> y;
844  state >> z;
845 
846  vec.setValue (x,y,z);
847 
848  if (VP1Msg::verbose()) {
849  //Fixme: check for nan's.
850  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbVec3f(x,y,z) = ("
851  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
852  }
853  }
854  else {
855  double x,y,z;
856 
857  state >> x;
858  state >> y;
859  state >> z;
860 
861  vec.setValue (x,y,z);
862 
863  if (VP1Msg::verbose()) {
864  //Fixme: check for nan's.
865  VP1Msg::messageVerbose("VP1QtInventorUtils::deserialize SbVec3f(x,y,z) = ("
866  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
867  }
868  }
869 
870  // ===> Finish up:
871  buffer.close();
872 
873  return true;//Fixme: How to check for errors? - at least check for nan's
874 
875 }

◆ deserializeSoCameraParameters()

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

Definition at line 953 of file VP1QtInventorUtils.cxx.

954 {
955  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters start");
956  if (ba==QByteArray())
957  return false;
958 
959  // ===> Setup stream for getting the contents of the byteArray:
960  QBuffer buffer(&ba);
961  buffer.open(QIODevice::ReadOnly);
962  QDataStream state(&buffer);
964  if(ba.size()==64) {
965  // Single precision
966  state.setFloatingPointPrecision(QDataStream::SinglePrecision);
967 
968  //Orientation:
969  SbRotation rot; QByteArray ba_rot; state >> ba_rot;
970  if (!deserialize(ba_rot,rot)) return false;
971  //position:
972  SbVec3f pos; QByteArray ba_pos; state >> ba_pos;
973  if (!deserialize(ba_pos,pos)) return false;
974 
975  bool save = cam.enableNotify(false);
976  cam.ref();
977  cam.orientation.setValue(rot);
978  cam.position.setValue(pos);
979  //Misc:
980  float f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
981 
982  state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
983  state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
984  state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
985  state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
986  //viewport mapping:
987  int viewportmap;
988  state>>viewportmap;
989  switch (viewportmap) {
990  case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME); break;
991  case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);break;
992  case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);break;
993  case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);break;
994  case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);break;
995  //ERROR
996  }
997 
998  bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
999 
1000  //Camera type and specialised info:
1001  int camtype;
1002  state>>camtype;
1003  float f_orthopersp_heightpar(-999);
1004  if (camtype==0) {
1005  //perspective
1006  if (!passedcameraisperspective)
1007  return false;
1008  state >> f_orthopersp_heightpar;
1009  static_cast<SoPerspectiveCamera*>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1010  } else if (camtype==1) {
1011  //ortho
1012  if (passedcameraisperspective)
1013  return false;
1014  state >> f_orthopersp_heightpar;
1015  static_cast<SoOrthographicCamera*>(&cam)->height.setValue(f_orthopersp_heightpar);
1016  }
1017 
1018  if (save) {
1019  cam.enableNotify(true);
1020  cam.touch();
1021  }
1022 
1023  // ===> Finish up:
1024  buffer.close();
1025 
1026  if (VP1Msg::verbose()) {
1027  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
1028  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
1029  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
1030  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
1031  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
1032  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters camtype = "
1033  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
1034  if (camtype==0)
1035  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (persp) heightAngle = "
1036  +QString::number(f_orthopersp_heightpar));
1037  if (camtype==1)
1038  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (ortho) height = "
1039  +QString::number(f_orthopersp_heightpar));
1040 
1041  }
1042  }
1043  else {
1044  // Double precision
1045 
1046  //Orientation:
1047  SbRotation rot; QByteArray ba_rot; state >> ba_rot;
1048  if (!deserialize(ba_rot,rot)) return false;
1049  //position:
1050  SbVec3f pos; QByteArray ba_pos; state >> ba_pos;
1051  if (!deserialize(ba_pos,pos)) return false;
1052 
1053  bool save = cam.enableNotify(false);
1054  cam.ref();
1055  cam.orientation.setValue(rot);
1056  cam.position.setValue(pos);
1057  //Misc:
1058  double f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
1059 
1060  state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
1061  state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
1062  state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
1063  state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
1064  //viewport mapping:
1065  int viewportmap;
1066  state>>viewportmap;
1067  switch (viewportmap) {
1068  case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME); break;
1069  case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);break;
1070  case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);break;
1071  case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);break;
1072  case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);break;
1073  //ERROR
1074  }
1075 
1076  bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1077 
1078  //Camera type and specialised info:
1079  int camtype;
1080  state>>camtype;
1081  double f_orthopersp_heightpar(-999);
1082  if (camtype==0) {
1083  //perspective
1084  if (!passedcameraisperspective)
1085  return false;
1086  state >> f_orthopersp_heightpar;
1087  static_cast<SoPerspectiveCamera*>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1088  } else if (camtype==1) {
1089  //ortho
1090  if (passedcameraisperspective)
1091  return false;
1092  state >> f_orthopersp_heightpar;
1093  static_cast<SoOrthographicCamera*>(&cam)->height.setValue(f_orthopersp_heightpar);
1094  }
1095 
1096  if (save) {
1097  cam.enableNotify(true);
1098  cam.touch();
1099  }
1100 
1101  // ===> Finish up:
1102  buffer.close();
1103 
1104  if (VP1Msg::verbose()) {
1105  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
1106  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
1107  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
1108  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
1109  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
1110  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters camtype = "
1111  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
1112  if (camtype==0)
1113  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (persp) heightAngle = "
1114  +QString::number(f_orthopersp_heightpar));
1115  if (camtype==1)
1116  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters (ortho) height = "
1117  +QString::number(f_orthopersp_heightpar));
1118 
1119  }
1120  }
1121 
1122  cam.unrefNoDelete();
1123  VP1Msg::messageVerbose("VP1QtInventorUtils::deserializeSoCameraParameters end");
1124  return true;
1125 }

◆ ensureInitLineWidthAndPointSize()

void VP1QtInventorUtils::ensureInitLineWidthAndPointSize ( SoQtRenderArea *  ra)
static

Definition at line 1510 of file VP1QtInventorUtils.cxx.

1511 {
1513  return;
1515  QWidget * w(0);
1516  if (!ra) {
1517  VP1Msg::messageVerbose("VP1QtInventorUtils WARNING: Have to create temporary renderarea for the sole "
1518  "purpose of getting supported line widths and point sizes!");
1519  w = new QWidget(0);
1520  ra = new VP1ExaminerViewer(w);
1521  }
1522  SbVec2f range; float granularity;
1523  ra->getLineWidthLimits(range, granularity);
1524  float a,b;
1525  range.getValue(a,b);
1528  Imp::allowedLineWidthGranularity = granularity;
1529  VP1Msg::messageVerbose("VP1QtInventorUtils Determined line widths supported by hardware (min,max,granularity) = ("
1530  +VP1Msg::str(a)+", "+VP1Msg::str(b)+", "+VP1Msg::str(granularity)+")");
1531  ra->getPointSizeLimits(range, granularity);
1532  range.getValue(a,b);
1535  Imp::allowedPointSizeGranularity = granularity;
1536  VP1Msg::messageVerbose("VP1QtInventorUtils Determined point sizes supported by hardware (min,max,granularity) = ("
1537  +VP1Msg::str(a)+", "+VP1Msg::str(b)+", "+VP1Msg::str(granularity)+")");
1538  if (w) {
1539  delete ra;
1540  delete w;
1541  }
1542  //We clip to get a more consistent behaviour across hardware (and to limit ourselves to reasonable values:
1543 
1544  if (Imp::allowedLineWidthMin<0.5)
1546  if (Imp::allowedLineWidthMax>7.0)
1548  if (Imp::allowedPointSizeMin<0.5)
1550  if (Imp::allowedPointSizeMax>12.0)
1551  Imp::allowedPointSizeMax = 12.0;
1552 }

◆ getAllTransparencyTypes()

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

Definition at line 639 of file VP1QtInventorUtils.cxx.

640 {
641  QList<SoGLRenderAction::TransparencyType> l;
643  << SoGLRenderAction::SCREEN_DOOR
645  << SoGLRenderAction::DELAYED_ADD
646  << SoGLRenderAction::SORTED_OBJECT_ADD
647  << SoGLRenderAction::BLEND
648  << SoGLRenderAction::DELAYED_BLEND
649  << SoGLRenderAction::SORTED_OBJECT_BLEND
650  << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD
651  << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND
652  << SoGLRenderAction::SORTED_LAYERS_BLEND;
653  return l;
654 }

◆ getDefaultVP1TransparencyType()

SoGLRenderAction::TransparencyType VP1QtInventorUtils::getDefaultVP1TransparencyType ( )
static

Definition at line 633 of file VP1QtInventorUtils.cxx.

634 {
635  return SoGLRenderAction::DELAYED_BLEND;
636 }

◆ getLineWidthRanges()

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

Definition at line 1490 of file VP1QtInventorUtils.cxx.

◆ getPointSizeRanges()

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

Definition at line 1500 of file VP1QtInventorUtils.cxx.

◆ getValueLineWidthSlider()

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

Definition at line 1611 of file VP1QtInventorUtils.cxx.

1612 {
1613  if (!slider)
1614  return 1.0;
1619 }

◆ getValuePointSizeSlider()

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

Definition at line 1622 of file VP1QtInventorUtils.cxx.

1623 {
1624  if (!slider)
1625  return 1.0;
1630 }

◆ imageFromRGBFile()

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

Definition at line 399 of file VP1QtInventorUtils.cxx.

400 {
401  int width = 0;
402  int height = 0;
403  int components = 0;
404 
405  unsigned * imagedata = Imp::read_texture(filename.toStdString().c_str(), &width, &height, &components);
406  if( width == 0 || height == 0 ) std::cout << "VP1QtInventorUtils::imageFromRGBFile - read_texture failed?" << std::endl;
407 
408  unsigned char * data = reinterpret_cast<unsigned char*>(imagedata);
409 
410 
411  QImage im(width,height, ( components <= 3 ? QImage::Format_RGB32 : QImage::Format_ARGB32 ) );
412 
413  int x, y, index = 0;
414  for (y=0; y<height; ++y) {
415  for (x=0; x<width; ++x) {
416  //Fixme: Does this also work for components=1,2 4??
417  im.setPixel ( x, height-y-1, QColor( static_cast<int>(data[index]),static_cast<int>(data[index+1]),static_cast<int>(data[index+2]),static_cast<int>(data[index+3]) ).rgb() );
418  index+=4;
419  }
420  }
421  free(imagedata);
422  return im;
423 }

◆ intToTransparencyType()

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

Definition at line 677 of file VP1QtInventorUtils.cxx.

678 {
679  switch (i) {
680  case 0: return SoGLRenderAction::SCREEN_DOOR;
681  case 1: return SoGLRenderAction::ADD;
682  case 2: return SoGLRenderAction::DELAYED_ADD;
683  case 3: return SoGLRenderAction::SORTED_OBJECT_ADD;
684  case 4: return SoGLRenderAction::BLEND;
685  case 5: return SoGLRenderAction::DELAYED_BLEND;
686  case 6: return SoGLRenderAction::SORTED_OBJECT_BLEND;
687  case 7: return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD;
688  case 8: return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND;
689  case 9: return SoGLRenderAction::NONE;
690  case 10: return SoGLRenderAction::SORTED_LAYERS_BLEND;
691  default:
692  VP1Msg::messageDebug("VP1QtInventorUtils::intToTransparencyType ERROR: int out of range "+VP1Msg::str(i));
693  return SoGLRenderAction::DELAYED_BLEND;
694  }
695 }

◆ pixmapFromRGBFile()

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

Definition at line 392 of file VP1QtInventorUtils.cxx.

393 {
394  return QPixmap::fromImage(imageFromRGBFile(filename));
395 
396 }

◆ qcol2sbcol()

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

Definition at line 1128 of file VP1QtInventorUtils.cxx.

1129 {
1130  return SbColor( col.red()/255.0, col.green()/255.0, col.blue()/255.0 );
1131 }

◆ readGraphFromFile()

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

Definition at line 1439 of file VP1QtInventorUtils.cxx.

1440 {
1441  // SoDB::init();
1442  SoInput in;
1443  if (!in.openFile(filename.toStdString().c_str()))
1444  return 0;
1445  return SoDB::readAll(&in);
1446 }

◆ renderToImage()

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

Definition at line 428 of file VP1QtInventorUtils.cxx.

430 {
431  VP1Msg::messageVerbose("VP1QtInventorUtils::renderToImage()");
432 
433  if (!ra)
434  return QImage();
435 
436 
437  // transp,anti: Render two large, figure out transp, then resize (gives best result)
438  // transp : Render two normal, then figure out transp.
439  // : Render one normal.
440  // anti : Render one large, resize.
441 
442  if (actualRenderedSizeFact!=1.0&&!transparent_background) {
443  return renderToImage(ra,
444  static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
445  static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
446  false,
447  1.0)
448  .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
449  }
450 
451  if (transparent_background) {
452  //Lets make it transparent. We do this by rendering with both
453  //white and black background, and using the two results to figure
454  //out the final result.
455 
456  SbColor save_bgd = ra->getBackgroundColor();
457  SbBool save_redraw = ra->isAutoRedraw();
458 
459  ra->setAutoRedraw(false);
460 
461 
462  QImage im_black_bgd, im_white_bgd;
463  if (actualRenderedSizeFact==1.0) {
464  ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
465  im_black_bgd = renderToImage(ra, pixels_x, pixels_y,false,1.0);
466  ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
467  im_white_bgd = renderToImage(ra, pixels_x, pixels_y,false,1.0);
468  } else {
469  ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
470  im_black_bgd = renderToImage(ra, static_cast<int>(pixels_x*actualRenderedSizeFact+0.5), static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),false,1.0);
471  ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
472  im_white_bgd = renderToImage(ra, static_cast<int>(pixels_x*actualRenderedSizeFact+0.5), static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),false,1.0);
473  }
474 
475  ra->setBackgroundColor(save_bgd);
476  ra->setAutoRedraw(save_redraw);
477 
478  if (actualRenderedSizeFact==1.0)
479  return Imp::constructImageWithTransparentBackground(im_black_bgd, im_white_bgd);
480  else
481  return Imp::constructImageWithTransparentBackground(im_black_bgd, im_white_bgd)
482  .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
483  }
484 
485  // DEFAULT CALL
486 
487  //debug
488  int off = ra->getStereoOffsetSlot();
489  int typeSt = ra->getStereoTypeSlot();
490  VP1Msg::messageVerbose("off: " + QString::number( off ) + " - type: " + QString::number( typeSt ) );
491 
492  // get the scenegraph
493  SoNode *root = ra->getSceneManager()->getSceneGraph();
494  VP1Msg::messageVerbose("got the scenegraph");
495  //std::cout << "root: " << root << std::endl;
496 
497  // get the overlay scenegraph
498 // SoNode *rootOverlay = ra->getOverlaySceneManager()->getSceneGraph();
499  SoNode *rootOverlay = ra->getOverlaySceneGraph();
500  VP1Msg::messageVerbose("got the overlay scenegraph");
501  //std::cout << "overlay root: " << rootOverlay << std::endl;
502 
503  // set a new viewport to the preferred size
504  SbViewportRegion myViewport;
505  myViewport.setWindowSize(SbVec2s(pixels_x,pixels_y));
506 
507  QString tmppath(QDir::tempPath());
508  if (!tmppath.endsWith(QDir::separator()))
509  tmppath+=QDir::separator();
510  tmppath += "vp1tmpfileXXXXXX.rgb";
511  std::string stmppath = tmppath.toStdString();
512  int tmpfd = mkstemps (stmppath.data(), 4);
513  FILE* tmpf = fdopen (tmpfd, "w");
514  QString tmpfile (stmppath.c_str());
515 
516  // declare a new renderer with the viewport created above
517  SoOffscreenRenderer *myRenderer = new SoOffscreenRenderer(myViewport);
518 
519  //Copy settings from the render area:
520  myRenderer->setBackgroundColor(ra->getBackgroundColor());
521 
522 
523  myRenderer->setComponents(SoOffscreenRenderer::RGB_TRANSPARENCY);
524  myRenderer->getGLRenderAction()->setTransparencyType(ra->getTransparencyType());
525  // myRenderer->getGLRenderAction()->addPreRenderCallback( VP1QtInventorUtils::Imp::prerendercallback_rendertoimage, 0/*userdata*/ );
526 
527  // Anti-Aliasing
528  SbBool smoothing; int numPasses;
529  ra->getAntialiasing (smoothing, numPasses);
530  myRenderer->getGLRenderAction()->setSmoothing (smoothing);
531  myRenderer->getGLRenderAction()->setNumPasses(numPasses);
532 
533  //Other things we could set:
534  // Overlay scenegraph.
535 
536  // render the scenegraph
537  // if fails, delete the renderer and return an empty image
538  if (!myRenderer->render(root)) {
539  delete myRenderer;
540  fclose (tmpf);
541  return QImage();
542  }
543  VP1Msg::messageVerbose("rendered the scenegraph");
544 
545  // render the overlay scenegraph
546  // if fails, delete the renderer and return an empty image
547  if (rootOverlay) {
548  bool okOver = myRenderer->render(rootOverlay);
549  if ( !okOver) {
550  delete myRenderer;
551  fclose (tmpf);
552  return QImage();
553  }
554  else {
555  VP1Msg::messageVerbose("rendered the overlay scenegraph");
556  }
557  }
558 
559  // write the rendered image to the temp file
560  // if fails, remove the temp file and return an empty image
561  if (!myRenderer->writeToRGB(tmpf)) {
562  fclose (tmpf);
563  if (QFile::exists(tmpfile))
564  QFile(tmpfile).remove();
565  delete myRenderer;
566  return QImage();
567  }
568 
569  fclose (tmpf);
570 
571  // delete the renderer
572  delete myRenderer;
573 
574  // get the rendered image from the temp file as a Qt QImage instance
575  QImage im(imageFromRGBFile(tmpfile));
576 
577  // delete the temp file
578  if (QFile::exists(tmpfile))
579  QFile(tmpfile).remove();
580 
581  // return the rendered image
582  return im;
583 }

◆ renderToPixmap()

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

Definition at line 587 of file VP1QtInventorUtils.cxx.

589 {
590  return QPixmap::fromImage(renderToImage(ra, pixels_x, pixels_y, transparent_background, actualRenderedSizeFact));
591 }

◆ sbcol2qcol()

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

Definition at line 1134 of file VP1QtInventorUtils.cxx.

1135 {
1136  float r,g,b;
1137  col.getValue(r,g,b);
1138  return QColor::fromRgbF( r,g,b );
1139 }

◆ serialiseSoMaterial()

QByteArray VP1QtInventorUtils::serialiseSoMaterial ( SoMaterial *  m)
static

Definition at line 1142 of file VP1QtInventorUtils.cxx.

1143 {
1144  if (!m||m->ambientColor.getNum()!=1
1145  ||m->diffuseColor.getNum()!=1
1146  ||m->specularColor.getNum()!=1
1147  ||m->emissiveColor.getNum()!=1
1148  ||m->transparency.getNum()!=1
1149  ||m->shininess.getNum()!=1) {
1150  VP1Msg::message("VP1QtInventorUtils::serialiseSoMaterial Error: "
1151  "Passed material must have exactly one value in each of the 6 fields!!");
1152  return QByteArray();
1153  }
1154 
1155 
1156  // ===> Setup stream writing to a byteArray:
1157  QByteArray byteArray;
1158  QBuffer buffer(&byteArray);
1159  buffer.open(QIODevice::WriteOnly);
1160  QDataStream out(&buffer);
1161 
1162  //Write data:
1163  out << QString("somat_v1_begin");
1164  out << sbcol2qcol(m->ambientColor[0]);
1165  out << sbcol2qcol(m->diffuseColor[0]);
1166  out << sbcol2qcol(m->specularColor[0]);
1167  out << sbcol2qcol(m->emissiveColor[0]);
1168  out << (double)m->shininess[0];
1169  out << (double)m->transparency[0];
1170  out << QString("somat_end");
1171 
1172  // ===> Finish up:
1173  buffer.close();
1174 
1175  return byteArray;
1176 
1177 }

◆ serialize() [1/2]

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

Definition at line 719 of file VP1QtInventorUtils.cxx.

720 {
721 
722  // ===> Setup stream writing to a byteArray:
723  QByteArray byteArray;
724  QBuffer buffer(&byteArray);
725  buffer.open(QIODevice::WriteOnly);
726  QDataStream out(&buffer);
727 
728  //Write data:
729 
730  float q0,q1,q2,q3;//quarternion components
731  rot.getValue (q0,q1,q2,q3);
732 
733  out<<(double)q0;
734  out<<(double)q1;
735  out<<(double)q2;
736  out<<(double)q3;
737 
738  if (VP1Msg::verbose()) {
739  //Fixme: check for nan's.
740  VP1Msg::messageVerbose("VP1QtInventorUtils::serialize SbRotation(q0,q1,q2,q3) = ("
741  +QString::number(q0)+", "+QString::number(q1)+", "
742  +QString::number(q2)+", "+QString::number(q3)+")");
743  }
744 
745  // ===> Finish up:
746  buffer.close();
747  return byteArray;
748 }

◆ serialize() [2/2]

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

Definition at line 803 of file VP1QtInventorUtils.cxx.

804 {
805  // ===> Setup stream writing to a byteArray:
806  QByteArray byteArray;
807  QBuffer buffer(&byteArray);
808  buffer.open(QIODevice::WriteOnly);
809  QDataStream out(&buffer);
810 
811  //Write data:
812  float x,y,z;
813  vec.getValue(x,y,z);
814  out << (double)x;
815  out << (double)y;
816  out << (double)z;
817 
818  if (VP1Msg::verbose()) {
819  //Fixme: check for nan's.
820  VP1Msg::messageVerbose("VP1QtInventorUtils::serialize SbVec3f(x,y,z) = ("
821  +QString::number(x)+", "+QString::number(y)+", "+QString::number(z)+")");
822  }
823 
824  // ===> Finish up:
825  buffer.close();
826  return byteArray;
827 }

◆ serializeSoCameraParameters()

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

Definition at line 878 of file VP1QtInventorUtils.cxx.

878  {
879 
880  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters start");
881 
882  // ===> Setup stream writing to a byteArray:
883  QByteArray byteArray;
884  QBuffer buffer(&byteArray);
885  buffer.open(QIODevice::WriteOnly);
886  QDataStream out(&buffer);
887 
888  cam.ref();
889  //Write data:
890  SbRotation camrot = cam.orientation.getValue();
891  out << serialize(camrot);
892  SbVec3f campos = cam.position.getValue();
893  out << serialize(campos);
894  float f_aspectRatio(cam.aspectRatio.getValue());
895  float f_nearDistance(cam.nearDistance.getValue());
896  float f_farDistance(cam.farDistance.getValue());
897  float f_focalDistance(cam.focalDistance.getValue());
898  out << (double)f_aspectRatio;
899  out << (double)f_nearDistance;
900  out << (double)f_farDistance;
901  out << (double)f_focalDistance;
902 
903  int viewportmap(-1);
904  switch (cam.viewportMapping.getValue()) {
905  case SoCamera::CROP_VIEWPORT_FILL_FRAME: viewportmap = 0;break;
906  case SoCamera::CROP_VIEWPORT_LINE_FRAME: viewportmap = 1;break;
907  case SoCamera::CROP_VIEWPORT_NO_FRAME: viewportmap = 2;break;
908  case SoCamera::ADJUST_CAMERA: viewportmap = 3;break;
909  case SoCamera::LEAVE_ALONE: viewportmap = 4;break;
910  }
911  out << viewportmap;
912 
913  //Camera type and specialised info:
914  int camtype (-1);
915  if (cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()))
916  camtype = 0;
917  else if (cam.getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId()))
918  camtype = 1;
919 
920  out <<camtype;
921  if (camtype==0) {
922  out << (double)static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue();
923  } else if (camtype==1) {
924  out << (double)static_cast<const SoOrthographicCamera*>(&cam)->height.getValue();
925  }
926 
927  cam.unrefNoDelete();
928 
929  // ===> Finish up:
930  buffer.close();
931 
932  if (VP1Msg::verbose()) {
933  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters aspectRatio = "+QString::number(f_aspectRatio));
934  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters nearDistance = "+QString::number(f_nearDistance));
935  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters farDistance = "+QString::number(f_farDistance));
936  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters focalDistance = "+QString::number(f_focalDistance));
937  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters viewportmap = "+QString::number(viewportmap));
938  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters camtype = "
939  +QString(camtype==0?"perspective":(camtype==1?"orthographic":"unknown")));
940  if (camtype==0)
941  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters (persp) heightAngle = "
942  +QString::number(static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue()));
943  if (camtype==1)
944  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters (ortho) height = "
945  +QString::number(static_cast<const SoOrthographicCamera*>(&cam)->height.getValue()));
946  VP1Msg::messageVerbose("VP1QtInventorUtils::serializeSoCameraParameters end");
947  }
948 
949  return byteArray;
950 }

◆ setLimitsLineWidthSlider()

void VP1QtInventorUtils::setLimitsLineWidthSlider ( QSlider *  slider)
static

Definition at line 1555 of file VP1QtInventorUtils.cxx.

1556 {
1557  if (!slider)
1558  return;
1561  int nsteps = std::min(1000,std::max<int>(0,static_cast<int>((Imp::allowedLineWidthMax-Imp::allowedLineWidthMin)/Imp::allowedLineWidthGranularity)));
1562  int stepsPerUnit = std::min(nsteps,std::max<int>(1,static_cast<int>(1.0/Imp::allowedLineWidthGranularity)));
1563  slider->setRange(0,nsteps);
1564  slider->setSingleStep(1);
1565  slider->setPageStep(stepsPerUnit);
1566 }

◆ setLimitsPointSizeSlider()

void VP1QtInventorUtils::setLimitsPointSizeSlider ( QSlider *  slider)
static

Definition at line 1569 of file VP1QtInventorUtils.cxx.

1570 {
1571  if (!slider)
1572  return;
1575  int nsteps = std::min(1000,std::max<int>(0,
1577  int stepsPerUnit = std::min(nsteps,std::max<int>(1,
1578  static_cast<int>(0.5+1.0/Imp::allowedPointSizeGranularity)));
1579  slider->setRange(0,nsteps);
1580  slider->setSingleStep(1);
1581  slider->setPageStep(stepsPerUnit);
1582 }

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

1476 {
1477  if (m)
1478  VP1MaterialButton::setMaterialParameters( m, r,g,b,brightness,transp );
1479 }

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

1484 {
1485  setMatColor( m, col.redF(), col.greenF(), col.blueF(), brightness, transp);
1486 }

◆ setValueLineWidthSlider()

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

Definition at line 1585 of file VP1QtInventorUtils.cxx.

1586 {
1587  if (!slider)
1588  return;
1591  int itarget = std::min(slider->maximum(),std::max<int>(slider->minimum(),
1593  if (slider->value()!=itarget)
1594  slider->setValue(itarget);
1595 }

◆ setValuePointSizeSlider()

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

Definition at line 1598 of file VP1QtInventorUtils.cxx.

1599 {
1600  if (!slider)
1601  return;
1604  int itarget = std::min(slider->maximum(),std::max<int>(slider->minimum(),
1606  if (slider->value()!=itarget)
1607  slider->setValue(itarget);
1608 }

◆ transparencyType2PrettyString()

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

Definition at line 699 of file VP1QtInventorUtils.cxx.

700 {
701  switch (tt) {
702  case SoGLRenderAction::DELAYED_BLEND: return "Delayed blend"; break;
703  case SoGLRenderAction::SCREEN_DOOR: return "Screen door"; break;
704  case SoGLRenderAction::ADD: return "Add"; break;
705  case SoGLRenderAction::DELAYED_ADD: return "Delayed add"; break;
706  case SoGLRenderAction::SORTED_OBJECT_ADD: return "Sorted object add"; break;
707  case SoGLRenderAction::BLEND: return "Blend (Best for Geo volumes)"; break;
708  case SoGLRenderAction::SORTED_OBJECT_BLEND: return "Sorted object blend (Best for physics objects: jets, tracks, ...)"; break;
709  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD: return "Sorted object sorted triangle add"; break;
710  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND: return "Sorted object sorted triangle blend"; break;
711  case SoGLRenderAction::NONE: return "None"; break;
712  case SoGLRenderAction::SORTED_LAYERS_BLEND: return "Sorted layers blend"; break;
713  default: return "";
714  }
715 
716 }

◆ transparencyTypeToInt()

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

Definition at line 657 of file VP1QtInventorUtils.cxx.

658 {
659  switch (tt) {
660  case SoGLRenderAction::SCREEN_DOOR: return 0;
661  case SoGLRenderAction::ADD: return 1;
662  case SoGLRenderAction::DELAYED_ADD: return 2;
663  case SoGLRenderAction::SORTED_OBJECT_ADD: return 3;
664  case SoGLRenderAction::BLEND: return 4;
665  case SoGLRenderAction::DELAYED_BLEND: return 5;
666  case SoGLRenderAction::SORTED_OBJECT_BLEND: return 6;
667  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD: return 7;
668  case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND: return 8;
669  case SoGLRenderAction::NONE: return 9;
670  case SoGLRenderAction::SORTED_LAYERS_BLEND: return 10;
671  default:
672  VP1Msg::messageDebug("VP1QtInventorUtils::transparencyTypeToInt ERROR: Unknown transparency type");
673  return -1;
674  }
675 }

◆ writeGraphToFile()

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

Definition at line 1415 of file VP1QtInventorUtils.cxx.

1416 {
1417  if (!root)
1418  return false;
1419 
1420  root->ref();
1421  QString s = Imp::buffer_writeaction(root);
1422  root->unrefNoDelete();
1423 
1424  QFile data(filename);
1425  if (data.open(QFile::WriteOnly | QFile::Truncate)) {
1426  QTextStream out(&data);
1427 #if QTCORE_VERSION >= 0x050E00
1428  out << s << Qt::endl;
1429 #else
1430  out << s << endl;
1431 #endif
1432  return true;
1433  } else {
1434  return false;
1435  }
1436 }

◆ writeGraphToVRMLFile()

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

Definition at line 1450 of file VP1QtInventorUtils.cxx.

1451 {
1452  if (!root)
1453  return false;
1454 
1455  root->ref();
1457  root->unrefNoDelete();
1458 
1459  // QFile data(filename);
1460  // if (data.open(QFile::WriteOnly | QFile::Truncate)) {
1461  // QTextStream out(&data);
1462  // out << s << endl;
1463  // return true;
1464  // } else {
1465  // return false;
1466  // }
1467  return true;
1468 }

The documentation for this class was generated from the following files:
NONE
@ NONE
Definition: sTGCenumeration.h:13
beamspotman.r
def r
Definition: beamspotman.py:674
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
VP1ExaminerViewer::getStereoTypeSlot
SoQtViewer::StereoType getStereoTypeSlot(void) const
Definition: VP1ExaminerViewer.cxx:584
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
VP1QtInventorUtils::Imp::allowedPointSizeMax
static double allowedPointSizeMax
Definition: VP1QtInventorUtils.cxx:365
VP1QtInventorUtils::renderToImage
static QImage renderToImage(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
Definition: VP1QtInventorUtils.cxx:428
index
Definition: index.py:1
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
VP1QtInventorUtils::Imp::allowedPointSizeMin
static double allowedPointSizeMin
Definition: VP1QtInventorUtils.cxx:364
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
M_PI
#define M_PI
Definition: ActiveFraction.h:11
python.atlas_oh.im
im
Definition: atlas_oh.py:167
athena.value
value
Definition: athena.py:124
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
VP1QtInventorUtils::serialize
static QByteArray serialize(const SbRotation &)
Definition: VP1QtInventorUtils.cxx:719
x
#define x
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
VP1QtInventorUtils::Imp::allowedPointSizeGranularity
static double allowedPointSizeGranularity
Definition: VP1QtInventorUtils.cxx:366
VP1QtInventorUtils::Imp::allowedLineWidthMax
static double allowedLineWidthMax
Definition: VP1QtInventorUtils.cxx:362
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:176
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:11
VP1ExaminerViewer::getSceneGraph
virtual SoNode * getSceneGraph()
Definition: VP1ExaminerViewer.cxx:3139
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
VP1MaterialButton::setMaterialParameters
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1MaterialButton.cxx:802
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
python.CaloAddPedShiftConfig.str
str
Definition: CaloAddPedShiftConfig.py:42
VP1QtInventorUtils::Imp::read_texture
static unsigned * read_texture(const char *name, int *width, int *height, int *components)
Definition: VP1QtInventorUtils.cxx:285
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
VP1QtInventorUtils::deserialize
static bool deserialize(QByteArray &, SbRotation &)
Definition: VP1QtInventorUtils.cxx:751
hist_file_dump.f
f
Definition: hist_file_dump.py:140
VP1QtInventorUtils::qcol2sbcol
static SbColor qcol2sbcol(const QColor &)
Definition: VP1QtInventorUtils.cxx:1128
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
VP1QtInventorUtils::Imp::buffer_vrmlwriteaction
static void buffer_vrmlwriteaction(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1397
VP1QtInventorUtils::imageFromRGBFile
static QImage imageFromRGBFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:399
VP1QtInventorUtils::sbcol2qcol
static QColor sbcol2qcol(const SbColor &)
Definition: VP1QtInventorUtils.cxx:1134
python.selection.number
number
Definition: selection.py:20
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
VP1QtInventorUtils::Imp::buffer_writeaction
static QString buffer_writeaction(SoNode *root)
Definition: VP1QtInventorUtils.cxx:1381
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
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
VP1ExaminerViewer::getStereoOffsetSlot
float getStereoOffsetSlot()
Definition: VP1ExaminerViewer.cxx:577
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
VP1QtInventorUtils::setMatColor
static void setMatColor(SoMaterial *, const double &r, const double &g, const double &b, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1QtInventorUtils.cxx:1474
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
ADD
#define ADD(NAME)
Definition: test-half-precision.cxx:19
str
Definition: BTagTrackIpAccessor.cxx:11
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
VP1QtInventorUtils::ensureInitLineWidthAndPointSize
static void ensureInitLineWidthAndPointSize(SoQtRenderArea *)
Definition: VP1QtInventorUtils.cxx:1510
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:198
VP1QtInventorUtils::Imp::allowedLineWidthMin
static double allowedLineWidthMin
Definition: VP1QtInventorUtils.cxx:361
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:876
VP1QtInventorUtils::Imp::constructImageWithTransparentBackground
static QImage constructImageWithTransparentBackground(const QImage &im_black_bgd, const QImage &image_white_bgd)
Definition: VP1QtInventorUtils.cxx:594
VP1ExaminerViewer
Definition: VP1ExaminerViewer.h:30
VP1QtInventorUtils::Imp::lineWidthAndPointSizeNeedsInit
static bool lineWidthAndPointSizeNeedsInit
Definition: VP1QtInventorUtils.cxx:360
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
VP1QtInventorUtils::Imp::allowedLineWidthGranularity
static double allowedLineWidthGranularity
Definition: VP1QtInventorUtils.cxx:363