21#include <Inventor/C/errors/debugerror.h>
22#include <Inventor/nodes/SoSwitch.h>
23#include <Inventor/nodes/SoMaterial.h>
24#include <Inventor/nodes/SoSeparator.h>
76 QString safetext(
text());
77 safetext.replace(
' ',
'_');
78 safetext.replace(
'[',
'_');
79 safetext.replace(
']',
'_');
80 safetext.replace(
'/',
'_');
81 safetext.replace(
'.',
'_');
82 safetext.replace(
',',
'_');
83 safetext.replace(
'<',
'_');
84 safetext.replace(
'>',
'_');
85 safetext.replace(
'&',
'_');
87 m_d->theswitch =
new SoSwitch;
88 m_d->theswitch->ref();
89 m_d->theswitch->setName((
"StdCollSwitch"+safetext).toStdString().c_str());
92 m_d->material =
new SoMaterial;
93 m_d->material->setName((
"StdCollMat"+safetext).toStdString().c_str());
99 m_d->matButton->setObjectName(
"matButtonColl_"+safetext);
101 m_d->matButton->setMaterial(
m_d->material);
105 m_d->checkBox =
new QCheckBox();
106 m_d->checkBox->setText(
m_d->checkBox->fontMetrics().elidedText(
text(), Qt::ElideRight, 140 ));
107 m_d->checkBox->setObjectName(
"checkBoxColl_"+safetext);
109 connect(
m_d->checkBox,SIGNAL(toggled(
bool)),
this,SLOT(
setVisible(
bool)));
111 m_d->collsep =
new SoSeparator;
113 m_d->collsep->setName((
"StdCollSep"+safetext).toStdString().c_str());
121 delete m_d->checkBox;
122 delete m_d->matButton;
123 for (QWidget*w :
m_d->extraWidgets)
125 m_d->material->unref();
126 m_d->collsep->unref();
127 m_d->theswitch->unref();
134 if (!
m_d->textProvided) {
135 m_d->textProvided =
true;
156 return m_d->problemsloading;
168 if (
m_d->visible&&!
m_d->loaded) {
170 m_d->theswitch->whichChild = SO_SWITCH_NONE;
173 m_d->problemsloading =
true;
174 m_d->visible =
false;
175 m_d->checkBox->blockSignals(
true);
176 m_d->checkBox->setChecked(
false);
177 m_d->checkBox->setToolTip(
"Problems encountered during attempt to load this collection");
179 w->setEnabled(
false);
183 m_d->theswitch->addChild(
m_d->material);
184 m_d->theswitch->addChild(
m_d->collsep);
190 if (
m_d->checkBox->isChecked()!=
m_d->visible) {
191 bool save =
m_d->checkBox->blockSignals(
true);
192 m_d->checkBox->setChecked(
m_d->visible);
194 m_d->checkBox->blockSignals(
false);
196 if ((
m_d->theswitch->whichChild.getValue()==SO_SWITCH_ALL) !=
m_d->visible)
197 m_d->theswitch->whichChild = (
m_d->visible ? SO_SWITCH_ALL : SO_SWITCH_NONE );
207 message(
"ERROR: collSwitch() called before init()");
208 return m_d->theswitch;
215 message(
"ERROR: collSep() called before init()");
223 message(
"ERROR: material() called before init()");
224 return m_d->material;
231 message(
"ERROR: largeChangesBegin() called before init()");
232 m_d->collsep->enableNotify(
false);
233 ++(
m_d->largechangescount_sep);
234 m_d->theswitch->enableNotify(
false);
235 ++(
m_d->largechangescount_switch);
242 message(
"ERROR: largeChangesEnd() called before init()");
243 if (
m_d->largechangescount_sep>0) {
244 if (--(
m_d->largechangescount_sep)==0) {
245 m_d->collsep->enableNotify(
true);
246 m_d->collsep->touch();
249 if (
m_d->largechangescount_switch>0) {
250 if (--(
m_d->largechangescount_switch)==0) {
251 m_d->theswitch->enableNotify(
true);
252 m_d->theswitch->touch();
265 l <<
m_d->extraWidgets;
272 messageDebug(
"VP1StdCollection::persistifiableState()");
274 if (!
m_d->material) {
275 message(
"ERROR: persistifiableState() called before init()");
279 serialise.disableUnsavedChecks();
280 serialise.save(
m_d->visible);
281 Q_ASSERT(
m_d->material&&
"Did you forget to call init() on this VP1StdCollection?");
282 serialise.save(
m_d->material);
284 return serialise.result();
290 if (!
m_d->material) {
291 message(
"ERROR: setState(..) called before init()");
297 messageDebug(
"Warning: Ignoring state with wrong version");
306 m_d->matButton->copyValuesFromMaterial(
m_d->material);
310 if (extraWidgetState!=QByteArray())
317 if (!
m_d->idProvided) {
318 m_d->idProvided =
true;
329 serialise.disableUnsavedChecks();
331 serialise.save(
text());
332 return serialise.result();
338 return m_d->lastMatTransparency;
344 return m_d->lastMatBrightness;
350 double t =
m_d->matButton->lastAppliedTransparency();
351 double b =
m_d->matButton->lastAppliedBrightness();
352 if (
m_d->lastMatTransparency == t &&
m_d->lastMatBrightness == b )
354 m_d->lastMatTransparency = t;
355 m_d->lastMatBrightness = b;
VP1Collection(IVP1System *sys=0, const QString &helperClassName="VP1Collection")
virtual QList< QWidget * > widgetsForGuiRow() const
QByteArray restoreByteArray()
void disableUnrestoredChecks()
void messageVerbose(const QString &) const
const QString & helperClassName() const
void message(const QString &) const
void messageDebug(const QString &) const
static bool deserialiseSoMaterial(QByteArray &, SoMaterial *&)
int largechangescount_sep
int largechangescount_switch
QList< QWidget * > extraWidgets
double lastMatTransparency
VP1MaterialButtonBase * matButton
virtual QString matButtonToolTip() const
virtual void setExtraWidgetsState(const QByteArray &)
virtual ~VP1StdCollection()
QList< QWidget * > provideWidgetsForGuiRow() const
double collMaterialTransparency() const
virtual qint32 provideCollTypeID() const
virtual void collMaterialTransparencyAndBrightnessChanged()
bool problemsLoading() const
virtual void assignDefaultMaterial(SoMaterial *) const =0
SoMaterial * material() const
virtual void largeChangesEnd()
virtual void init(VP1MaterialButtonBase *button=0)
SoSeparator * collSep() const
All 3D objects from this coll.
SoSwitch * collSwitch() const
Add this somewhere in your scenegraph (do not add any children here!)
virtual void largeChangesBegin()
virtual QString checkBoxToolTip() const
qint32 collTypeID() const
virtual QByteArray providePersistifiableID() const
double collMaterialBrightness() const
void possibleChangeMatTranspOrBrightness()
virtual QByteArray persistifiableState() const
Provide default implementation based on widget list + version.
void visibilityChanged(bool)
virtual QByteArray extraWidgetsState() const
virtual void setState(const QByteArray &)
Provide default implementation based on widget list + version.
virtual QList< QWidget * > provideExtraWidgetsForGuiRow() const
virtual QString provideText() const =0
VP1StdCollection(IVP1System *, const QString &helperClassName)