#include <VisAttributes.h>
|
| void | add (const std::string &name, SoMaterial *) |
| void | setColorFromRGB (SoMaterial *mat, const std::string &type, const int r, const int g, const int b) |
Definition at line 14 of file VisAttributes.h.
◆ VisAttributes() [1/2]
| VisAttributes::VisAttributes |
( |
| ) |
|
◆ VisAttributes() [2/2]
◆ ~VisAttributes()
| VisAttributes::~VisAttributes |
( |
| ) |
|
|
virtual |
Definition at line 104 of file VisAttributes.cxx.
104 {
105
106 std::map<std::string, SoMaterial *>::iterator
m,
e=
m_d->_map.end();
107 for (m=
m_d->_map.begin();m!=e;++m)
108 (*m).second->unref();
109
111}
◆ add()
| void VisAttributes::add |
( |
const std::string & | name, |
|
|
SoMaterial * | material ) |
|
protected |
Definition at line 122 of file VisAttributes.cxx.
122 {
123 if (
m_d->_map.find(name)!=
m_d->_map.end()) {
124 std::cout<<
"VisAttributes::add ERROR: Material " <<
name<<
" already added!"<<std::endl;
125 return;
126 }
127 material->ref();
129 if (material->transparency.getNum()!=1)
130 std::cout<<
"VisAttributes::add Warning: Found #transparency values different from 1 in material "<<
name<<std::endl;
131
132
133
134
135}
◆ applyState()
| void VisAttributes::applyState |
( |
QByteArray | ba | ) |
|
Definition at line 61 of file VisAttributes.cxx.
62{
63
64 QMap<QString,QByteArray> storedstates;
66 buffer.open(QIODevice::ReadOnly);
67 QDataStream state(&buffer);
70 if (version!=0)
71 return;
72 state >> storedstates;
74
75 std::map< std::string, SoMaterial *>::iterator itMat,itMatE(
m_d->_map.end());
76
77
78 QMap<QString,QByteArray>::const_iterator
it,
itE(storedstates.constEnd());
79 for (it = storedstates.constBegin(); it!=itE; ++it) {
80 itMat =
m_d->_map.find(
it.key().toStdString());
81 if (itMat!=itMatE) {
82 QByteArray
b(
it.value());
84 }
85 }
86
87}
static bool deserialiseSoMaterial(QByteArray &, SoMaterial *&)
◆ get()
| SoMaterial * VisAttributes::get |
( |
const std::string & | name | ) |
const |
Definition at line 113 of file VisAttributes.cxx.
113 {
114 std::map <std::string, SoMaterial *>::const_iterator
m =
m_d->_map.find(name);
115 if (m!=
m_d->_map.end()) {
116 return (*m).second;
117 } else {
118 return NULL;
119 }
120}
◆ getState()
| QByteArray VisAttributes::getState |
( |
bool | onlyChangedMaterials = true | ) |
|
Definition at line 32 of file VisAttributes.cxx.
33{
34
35 QMap<QString,QByteArray> storedstates, statesnow =
m_d->currentState();
36 if (onlyChangedMaterials) {
37 QMap<QString,QByteArray>::const_iterator
it,
itE(statesnow.constEnd());
38 QMap<QString,QByteArray>::const_iterator itOrig, itOrigE(
m_d->initialState.constEnd());
39 for (it = statesnow.constBegin(); it!=itE; ++it) {
40 itOrig =
m_d->initialState.constFind(
it.key());
41 if (itOrig==itOrigE||
it.value()!=itOrig.value())
42 storedstates.insert(
it.key(),
it.value());
43 }
44 } else {
45 storedstates = statesnow;
46 }
47
48
49 QByteArray byteArray;
50 QBuffer
buffer(&byteArray);
51 buffer.open(QIODevice::WriteOnly);
52 QDataStream
out(&buffer);
56 return byteArray;
57
58}
◆ getValFromRGB()
| float VisAttributes::getValFromRGB |
( |
const int | rgb | ) |
|
|
private |
◆ init()
| void VisAttributes::init |
( |
| ) |
|
◆ operator=()
◆ overrideTransparencies()
| void VisAttributes::overrideTransparencies |
( |
float | transpfact | ) |
|
Definition at line 137 of file VisAttributes.cxx.
138{
139 std::map< std::string, SoMaterial *>::iterator
it,
itE =
m_d->_map.end();
140 for (it=
m_d->_map.begin();it!=itE;++it)
141 it->second->transparency.set1Value( 0, transpfact );
142}
◆ setColorFromRGB()
| void VisAttributes::setColorFromRGB |
( |
SoMaterial * | mat, |
|
|
const std::string & | type, |
|
|
const int | r, |
|
|
const int | g, |
|
|
const int | b ) |
|
protected |
Definition at line 149 of file VisAttributes.cxx.
150{
154 if (type == "ambient")
155 mat->ambientColor.setValue(fr, fg, fb);
156 else if (type == "diffuse")
157 mat->diffuseColor.setValue(fr, fg, fb);
158 else if (type == "specular")
159 mat->specularColor.setValue(fr, fg, fb);
160 else if (type == "emissive")
161 mat->emissiveColor.setValue(fr, fg, fb);
162 else
163 std::cout <<
"ERROR! Color type not supported ==> " <<
type << std::endl;
164
165
166
167 return;
168}
float getValFromRGB(const int rgb)
◆ m_d
The documentation for this class was generated from the following files: