ATLAS Offline Software
VP1QtInventorUtils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class VP1QtInventorUtils //
9 // //
10 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
11 // //
12 // Initial version: June 2007 //
13 // //
15 
16 #ifndef VP1QTINVENTORUTILS_H
17 #define VP1QTINVENTORUTILS_H
18 
19 #include <Inventor/C/errors/debugerror.h>
20 #include <Inventor/actions/SoGLRenderAction.h>
21 #include <QString>
22 #include <QByteArray>
23 #include <QPixmap>
24 #include <QImage>
25 
26 class SoQtRenderArea;
27 class VP1ExaminerViewer;
28 class SoNode;
29 class SoShape;
30 class SoSeparator;
31 class SoPath;
32 class SbRotation;
33 class SbColor;
34 class SbVec3f;
35 class QColor;
36 class SoCamera;
37 class SoMaterial;
38 class QByteArray;
39 class QSlider;
40 
42 public:
43 
45  // Conversion of colour classes //
47 
48  static SbColor qcol2sbcol(const QColor&);//Ignores alpha channel of QColor
49  static QColor sbcol2qcol(const SbColor&);
50 
52  // How to create a circle //
54 
55  static SoNode * createCircle( const double& radius );//Creates circle (with ref-count 0) of given
56  //radius in xy plane, centered at the origo.
57 
59  // How to create an ellipse //
61 
62  static SoNode * createEllipse( const double& radiusX, const double& radiusY, const int& numnodes = 12 );
63  //Creates ellipse (with ref-count 0) of given
64  //radii in xy plane, centered at the origo.
65 
67  // Off-screen rendering //
69 
70  //Check .isNull() of returned images to check success/failure.
71 
72  //Useful stuff:
73 // static QImage renderToImage(SoQtRenderArea *ra, int pixels_x, int pixels_y,
74  static QImage renderToImage(VP1ExaminerViewer *ra, int pixels_x, int pixels_y,
75  bool transparent_background = false, double actualRenderedSizeFact = 1.0 );
76 
77 // static QPixmap renderToPixmap(SoQtRenderArea *ra, int pixels_x, int pixels_y,
78  static QPixmap renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y,
79  bool transparent_background = false, double actualRenderedSizeFact = 1.0 );
80 
81  //Esoteric usage:
82  static QPixmap pixmapFromRGBFile(const QString& filename);
83  static QImage imageFromRGBFile(const QString& filename);
84 
86  // For persistification, etc. of transparency types //
88 
89  static SoGLRenderAction::TransparencyType getDefaultVP1TransparencyType();
90  static QList<SoGLRenderAction::TransparencyType> getAllTransparencyTypes();
91  static int transparencyTypeToInt( SoGLRenderAction::TransparencyType );//Returns -1 if unknown.
92  static SoGLRenderAction::TransparencyType intToTransparencyType( int );//Return DELAYED_BLEND if unknown;
93  static QString transparencyType2PrettyString( SoGLRenderAction::TransparencyType );//Returns "" if unknown.
94 
96  // For persistification of various Inventor types //
98 
99  static QByteArray serialize( const SbRotation& );
100  static bool deserialize( QByteArray&, SbRotation& );
101 
102  static QByteArray serialize( const SbVec3f& );
103  static bool deserialize( QByteArray&, SbVec3f& );
104 
105  static QByteArray serializeSoCameraParameters( const SoCamera& );
106  static bool deserializeSoCameraParameters( QByteArray&, SoCamera& );//Does nothing and returns false in case of errors.
107 
108  static QByteArray serialiseSoMaterial(SoMaterial *);
109  static bool deserialiseSoMaterial(QByteArray&,SoMaterial *&);//Does nothing and returns false in case of errors.
110 
112  // Changing path trailing part (to fix selections) //
114 
115  static bool changePathTail(SoPath*path,SoNode*commonBranchPoint,SoNode*newtail);
116 
118  // Read/write scenegraphs to file //
120 
121  static bool writeGraphToFile(SoNode*root, const QString& filename);//returns false in case of errors
122  static SoSeparator* readGraphFromFile(const QString& filename);//returns 0 in case of errors
123 
124  static bool writeGraphToVRMLFile(SoNode*root, const QString& filename);//returns false in case of errors
125 
127  // Simple materials (color/brightness/transparency) //
129 
130  //THESE ARE OBSOLETE. USE STATIC METHODS IN VP1MaterialButton instead!!
131 
132  static void setMatColor( SoMaterial *, const double& r, const double& g, const double& b,
133  const double& brightness = 0.0, const double& transp = 0.0 );//OBSOLETE
134  static void setMatColor( SoMaterial *, const QColor&,
135  const double& brightness = 0.0, const double& transp = 0.0 );//OBSOLETE
136 
138  // Get allowed ranges for point size/line widths (depends on hardware) //
140 
141  static void getLineWidthRanges(double& min, double& max, double& granularity);
142  static void getPointSizeRanges(double& min, double& max, double& granularity);
143  static void setLimitsLineWidthSlider(QSlider *);
144  static void setLimitsPointSizeSlider(QSlider *);
145  static void setValueLineWidthSlider(QSlider *, const double& value);
146  static void setValuePointSizeSlider(QSlider *, const double& value);
147  static double getValueLineWidthSlider(const QSlider *);
148  static double getValuePointSizeSlider(const QSlider *);
149 
150  //Call whenever making a renderarea (so we don't need to create extra instances just for this info):
151  static void ensureInitLineWidthAndPointSize(SoQtRenderArea*);
152 
153 private:
154 
157 
158  class Imp;
159 
160 };
161 
162 #endif
beamspotman.r
def r
Definition: beamspotman.py:676
VP1QtInventorUtils::getValueLineWidthSlider
static double getValueLineWidthSlider(const QSlider *)
Definition: VP1QtInventorUtils.cxx:1619
VP1QtInventorUtils::createEllipse
static SoNode * createEllipse(const double &radiusX, const double &radiusY, const int &numnodes=12)
Definition: VP1QtInventorUtils.cxx:1326
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
max
#define max(a, b)
Definition: cfImp.cxx:41
VP1QtInventorUtils::deserializeSoCameraParameters
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)
Definition: VP1QtInventorUtils.cxx:961
VP1QtInventorUtils::getLineWidthRanges
static void getLineWidthRanges(double &min, double &max, double &granularity)
Definition: VP1QtInventorUtils.cxx:1498
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
VP1QtInventorUtils::Imp
Definition: VP1QtInventorUtils.cxx:53
athena.value
value
Definition: athena.py:124
VP1QtInventorUtils::getDefaultVP1TransparencyType
static SoGLRenderAction::TransparencyType getDefaultVP1TransparencyType()
Definition: VP1QtInventorUtils.cxx:641
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
VP1QtInventorUtils::serialize
static QByteArray serialize(const SbRotation &)
Definition: VP1QtInventorUtils.cxx:727
VP1QtInventorUtils::deserialiseSoMaterial
static bool deserialiseSoMaterial(QByteArray &, SoMaterial *&)
Definition: VP1QtInventorUtils.cxx:1188
VP1QtInventorUtils::createCircle
static SoNode * createCircle(const double &radius)
Definition: VP1QtInventorUtils.cxx:1282
VP1QtInventorUtils::setLimitsPointSizeSlider
static void setLimitsPointSizeSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1577
VP1QtInventorUtils::getPointSizeRanges
static void getPointSizeRanges(double &min, double &max, double &granularity)
Definition: VP1QtInventorUtils.cxx:1508
VP1QtInventorUtils::VP1QtInventorUtils
VP1QtInventorUtils()
Definition: VP1QtInventorUtils.cxx:390
VP1QtInventorUtils::getValuePointSizeSlider
static double getValuePointSizeSlider(const QSlider *)
Definition: VP1QtInventorUtils.cxx:1630
VP1QtInventorUtils::transparencyType2PrettyString
static QString transparencyType2PrettyString(SoGLRenderAction::TransparencyType)
Definition: VP1QtInventorUtils.cxx:707
VP1QtInventorUtils::getAllTransparencyTypes
static QList< SoGLRenderAction::TransparencyType > getAllTransparencyTypes()
Definition: VP1QtInventorUtils.cxx:647
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
VP1QtInventorUtils::serialiseSoMaterial
static QByteArray serialiseSoMaterial(SoMaterial *)
Definition: VP1QtInventorUtils.cxx:1150
VP1QtInventorUtils::pixmapFromRGBFile
static QPixmap pixmapFromRGBFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:400
VP1QtInventorUtils::deserialize
static bool deserialize(QByteArray &, SbRotation &)
Definition: VP1QtInventorUtils.cxx:759
VP1QtInventorUtils::qcol2sbcol
static SbColor qcol2sbcol(const QColor &)
Definition: VP1QtInventorUtils.cxx:1136
VP1QtInventorUtils::setValueLineWidthSlider
static void setValueLineWidthSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1593
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
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1QtInventorUtils::transparencyTypeToInt
static int transparencyTypeToInt(SoGLRenderAction::TransparencyType)
Definition: VP1QtInventorUtils.cxx:665
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
VP1QtInventorUtils::readGraphFromFile
static SoSeparator * readGraphFromFile(const QString &filename)
Definition: VP1QtInventorUtils.cxx:1447
VP1QtInventorUtils::writeGraphToFile
static bool writeGraphToFile(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1423
VP1QtInventorUtils::setMatColor
static void setMatColor(SoMaterial *, const double &r, const double &g, const double &b, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1QtInventorUtils.cxx:1482
VP1QtInventorUtils::setValuePointSizeSlider
static void setValuePointSizeSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1606
VP1QtInventorUtils::setLimitsLineWidthSlider
static void setLimitsLineWidthSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1563
VP1QtInventorUtils
Definition: VP1QtInventorUtils.h:41
VP1QtInventorUtils::intToTransparencyType
static SoGLRenderAction::TransparencyType intToTransparencyType(int)
Definition: VP1QtInventorUtils.cxx:685
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
VP1QtInventorUtils::renderToPixmap
static QPixmap renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
Definition: VP1QtInventorUtils.cxx:595
VP1QtInventorUtils::ensureInitLineWidthAndPointSize
static void ensureInitLineWidthAndPointSize(SoQtRenderArea *)
Definition: VP1QtInventorUtils.cxx:1518
VP1QtInventorUtils::writeGraphToVRMLFile
static bool writeGraphToVRMLFile(SoNode *root, const QString &filename)
Definition: VP1QtInventorUtils.cxx:1458
VP1QtInventorUtils::serializeSoCameraParameters
static QByteArray serializeSoCameraParameters(const SoCamera &)
Definition: VP1QtInventorUtils.cxx:886
VP1QtInventorUtils::~VP1QtInventorUtils
~VP1QtInventorUtils()
Definition: VP1QtInventorUtils.cxx:395
VP1QtInventorUtils::changePathTail
static bool changePathTail(SoPath *path, SoNode *commonBranchPoint, SoNode *newtail)
Definition: VP1QtInventorUtils.cxx:1348
VP1ExaminerViewer
Definition: VP1ExaminerViewer.h:30