ATLAS Offline Software
Loading...
Searching...
No Matches
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
26class SoQtRenderArea;
28class SoNode;
29class SoShape;
30class SoSeparator;
31class SoPath;
32class SbRotation;
33class SbColor;
34class SbVec3f;
35class QColor;
36class SoCamera;
37class SoMaterial;
38class QByteArray;
39class QSlider;
40
42public:
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
153private:
154
157
158 class Imp;
159
160};
161
162#endif
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
static bool writeGraphToVRMLFile(SoNode *root, const QString &filename)
static bool deserialiseSoMaterial(QByteArray &, SoMaterial *&)
static void ensureInitLineWidthAndPointSize(SoQtRenderArea *)
static QByteArray serialiseSoMaterial(SoMaterial *)
static double getValueLineWidthSlider(const QSlider *)
static QList< SoGLRenderAction::TransparencyType > getAllTransparencyTypes()
static QByteArray serialize(const SbRotation &)
static void setLimitsLineWidthSlider(QSlider *)
static void setMatColor(SoMaterial *, const double &r, const double &g, const double &b, const double &brightness=0.0, const double &transp=0.0)
static QImage imageFromRGBFile(const QString &filename)
static QPixmap renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
static SoGLRenderAction::TransparencyType intToTransparencyType(int)
static void getLineWidthRanges(double &min, double &max, double &granularity)
static double getValuePointSizeSlider(const QSlider *)
static QColor sbcol2qcol(const SbColor &)
static void setValuePointSizeSlider(QSlider *, const double &value)
static QByteArray serializeSoCameraParameters(const SoCamera &)
static bool writeGraphToFile(SoNode *root, const QString &filename)
static SoNode * createCircle(const double &radius)
static bool deserialize(QByteArray &, SbRotation &)
static SbColor qcol2sbcol(const QColor &)
static bool changePathTail(SoPath *path, SoNode *commonBranchPoint, SoNode *newtail)
static QString transparencyType2PrettyString(SoGLRenderAction::TransparencyType)
static void setLimitsPointSizeSlider(QSlider *)
static SoNode * createEllipse(const double &radiusX, const double &radiusY, const int &numnodes=12)
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)
static void getPointSizeRanges(double &min, double &max, double &granularity)
static void setValueLineWidthSlider(QSlider *, const double &value)
static QImage renderToImage(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
static SoSeparator * readGraphFromFile(const QString &filename)
static int transparencyTypeToInt(SoGLRenderAction::TransparencyType)
static SoGLRenderAction::TransparencyType getDefaultVP1TransparencyType()
static QPixmap pixmapFromRGBFile(const QString &filename)
int r
Definition globals.cxx:22