18#include <Inventor/nodes/SoLevelOfDetail.h>
19#include <Inventor/nodes/SoSeparator.h>
57 if (
m_d->attachnode) {
58 messageDebug(
"WARNING: Destructed before event data cleared!");
115 if (
m_d->detailLevel == dl )
117 m_d->detailLevel = dl;
118 m_d->updateAttachmentForDetailLevel(dl);
125 message(
"setAttachNode ERROR: Received null pointer!");
128 if (
m_d->attachnode) {
129 message(
"setAttachNode ERROR: Received new attachment group pointer while still having previous one!");
134 m_d->attachnode = an;
135 m_d->attachnode->ref();
137 m_d->attachsep_simple =
new SoSeparator;
138 m_d->attachsep_simple->ref();
139 m_d->attachsep_detailed =
new SoSeparator;
140 m_d->attachsep_detailed->ref();
141 m_d->attachnode_lod =
new SoGroup;
142 m_d->attachnode_lod->ref();
147 m_d->updateAttachmentForDetailLevel(
m_d->detailLevel);
154 if (!
m_d->attachnode) {
155 messageDebug(
"eraseEventData WARNING: - called before attachment node was set!");
158 m_d->ensureSimpleDetached();
159 m_d->ensureDetailedDetached();
160 m_d->ensureLODDetached();
163 for (it =
m_d->id_2_lodhandle.begin(); it!=itE;++it) {
166 m_d->id_2_lodhandle.clear();
168 if (
m_d->attachnode_lod) {
169 m_d->attachnode_lod->unref();
170 m_d->attachnode_lod =
nullptr;
173 if (
m_d->attachsep_simple) {
174 delete m_d->attachHelper_simple;
175 m_d->attachHelper_simple =
nullptr;
176 m_d->attachsep_simple->unref();
177 m_d->attachsep_simple =
nullptr;
180 if (
m_d->attachsep_detailed) {
181 delete m_d->attachHelper_detailed;
182 m_d->attachHelper_detailed =
nullptr;
183 m_d->attachsep_detailed->unref();
184 m_d->attachsep_detailed =
nullptr;
187 m_d->attachnode->unref();
188 m_d->attachnode =
nullptr;
196 std::map<std::pair<int,double>,
TrackLODHandle* >
::iterator it =
m_d->id_2_lodhandle.find(std::make_pair(regionindex,crossover_value));
197 if (it!=
m_d->id_2_lodhandle.end())
199 if (!
m_d->attachnode) {
200 message(
"getTrackLODHandle ERROR: Called before attachment node was set!");
204 m_d->id_2_lodhandle[std::make_pair(regionindex,crossover_value)] = lh;
220 int i,
const double& c)
250 int regionindex,
const double& crossover_value)
251 :
m_d(new
Imp(attachgroup_LOD,sephelper_simple,sephelper_detailed,regionindex,crossover_value))
256 if (!attachgroup_LOD||!sephelper_simple||!sephelper_detailed)
264 if (
m_d->attachGroup_LOD->findChild(
m_d->lod)>-1) {
265 m_d->attachGroup_LOD->removeChild(
m_d->lod);
266 m_d->attachHelper_simple->removeNode(
m_d->sep_simple);
267 m_d->attachHelper_detailed->removeNode(
m_d->sep_detailed);
270 m_d->sep_detailed->unref();
271 m_d->sep_simple->unref();
282 m_d->lod =
new SoLevelOfDetail;
283 m_d->sep_detailed =
new SoSeparator;
284 m_d->sep_simple =
new SoSeparator;
286 m_d->sep_detailed->ref();
287 m_d->sep_simple->ref();
288 m_d->lod->addChild(
m_d->sep_detailed);
289 m_d->lod->addChild(
m_d->sep_simple);
302 if (
m_d->sep_detailed->findChild(detailed)>=0) {
306 if (
m_d->sep_simple->findChild(simple)>=0) {
312 m_d->sep_detailed->addChild(detailed);
313 m_d->sep_simple->addChild(simple);
315 if (
m_d->sep_detailed->getNumChildren()==1) {
319 m_d->attachGroup_LOD->addChild(
m_d->lod);
320 m_d->attachHelper_simple->addNode(
m_d->sep_simple);
321 m_d->attachHelper_detailed->addNode(
m_d->sep_detailed);
323 m_d->updateCrossOverField();
342 if (
m_d->sep_detailed->findChild(detailed)<0) {
343 VP1Msg::messageVerbose(
"TrackLODHandle ERROR: removeNodes called for detailed node which is not already added");
346 if (
m_d->sep_simple->findChild(simple)<0) {
347 VP1Msg::messageVerbose(
"TrackLODHandle ERROR: removeNodes called for simple node which is not already added");
351 m_d->sep_detailed->removeChild(detailed);
352 m_d->sep_simple->removeChild(simple);
354 if (
m_d->sep_detailed->getNumChildren()<1) {
358 m_d->attachGroup_LOD->removeChild(
m_d->lod);
359 m_d->attachHelper_simple->removeNode(
m_d->sep_simple);
360 m_d->attachHelper_detailed->removeNode(
m_d->sep_detailed);
362 m_d->updateCrossOverField();
static QString toString(const SELECTIONMODE &)
SoGroup * attachGroup_LOD
void updateCrossOverField() const
VP1ExtraSepLayerHelper * attachHelper_simple
VP1ExtraSepLayerHelper * attachHelper_detailed
SoSeparator * sep_detailed
Imp(SoGroup *ag, VP1ExtraSepLayerHelper *shs, VP1ExtraSepLayerHelper *shd, int i, const double &c)
void removeNodes(SoGroup *simple, SoGroup *detailed)
TrackLODHandle(SoGroup *, VP1ExtraSepLayerHelper *, VP1ExtraSepLayerHelper *, int, const double &)
void addNodes(SoGroup *simple, SoGroup *detailed)
void ensureDetailedDetached() const
TrackCommonFlags::DETAILLEVEL detailLevel
SoSeparator * attachsep_simple
VP1ExtraSepLayerHelper * attachHelper_simple
std::map< std::pair< int, double >, TrackLODHandle * > id_2_lodhandle
void updateAttachmentForDetailLevel(TrackCommonFlags::DETAILLEVEL) const
VP1ExtraSepLayerHelper * attachHelper_detailed
void ensureLODDetached() const
SoSeparator * attachsep_detailed
void ensureSimpleDetached() const
friend class TrackLODHandle
TrackLODHandle * getLODHandle(int regionindex, const double &crossover_value)
void setAttachNode(SoGroup *attachnode)
virtual ~TrackLODManager()
TrackLODManager(QObject *parent=0, IVP1System *sys=0)
void setDetailLevel(TrackCommonFlags::DETAILLEVEL)
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
void messageVerbose(const QString &) const
void message(const QString &) const
void messageDebug(const QString &) const
static void messageVerbose(const QString &)
static void messageDebug(const QString &)