34 const SbViewportRegion& viewportregion,
36 SoGLRenderAction(viewportregion),
38 selectedcolor_storage(sizeof(void*), alloc_colorpacker, free_colorpacker)
41 this->isVisible =
true;
42 this->selectedColor = SbColor(1.0f, 0.8f, 0.4f);
43 this->activeColor = SbColor(1.0f, 0.4f, 0.2f);
44 this->linepattern = 0xffff;
48 this->postprocpath =
new SoTempPath(32);
49 this->postprocpath->ref();
54 postprocpath->unref();
60 std::unique_lock lock(scene->execute_mutex);
63 SoGLRenderAction::apply(node);
67 SoSearchAction* searchAction =
new SoSearchAction;
68 searchAction->setType(SoSelection::getClassTypeId());
70 searchAction->apply(node);
72 const SoPathList& pathlist = searchAction->getPaths();
74 if (pathlist.getLength() > 0)
76 for (
int i = 0; i < pathlist.getLength(); i++)
78 SoPath* path = pathlist[i];
79 SoSelection* selection = (SoSelection*)path->getTail();
81 if (selection->getNumSelected() > 0)
84 this->drawHighlight(path, selection->getList());
92 scene3D::SoGLHighlightRenderAction::drawHighlight(SoPath* pathtothis,
const SoPathList* pathlist)
95 int oldnumpasses = this->getNumPasses();
96 this->setNumPasses(1);
99 int thispos = ((SoFullPath*)pathtothis)->getLength() - 1;
100 this->postprocpath->truncate(0);
102 for (
int i = 0; i < thispos; i++)
104 this->postprocpath->append(pathtothis->getNode(i));
108 for (
int i = 0; i < pathlist->getLength(); i++)
111 SoFullPath* path = (SoFullPath*)(*pathlist)[i];
114 for (
int j = 0; j < path->getLength(); j++)
116 this->postprocpath->append(path->getNode(j));
136 glEnable(GL_STENCIL_TEST);
137 glClearStencil(1.0f);
138 glClear(GL_STENCIL_BUFFER_BIT);
142 glStencilFunc(GL_NEVER, 0x0, 0x0);
143 glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
144 SoGLRenderAction::apply(this->postprocpath);
147 glStencilFunc(GL_NOTEQUAL, 0, 1);
149 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
152 drawWireframe(this->postprocpath, i == pathlist->getLength() - 1);
155 this->postprocpath->truncate(thispos);
157 glDisable(GL_STENCIL_TEST);
161 this->setNumPasses(oldnumpasses);
165 scene3D::SoGLHighlightRenderAction::drawWireframe(SoPath* pathtothis,
bool active)
168 SoState* state = this->getState();
174 glDisable(GL_LIGHTING);
177 SoColorPacker** selected_cptr = (SoColorPacker**)this->selectedcolor_storage.get();
181 SoGLLazyElement::setDiffuse(
182 state, pathtothis->getHead(), 1, &this->selectedColor, *selected_cptr);
187 SoGLLazyElement::setDiffuse(
188 state, pathtothis->getTail(), 1, &this->activeColor, *selected_cptr);
198 SoOverrideElement::setNormalVectorOverride(state, NULL, TRUE);
199 SoOverrideElement::setMaterialBindingOverride(state, NULL, TRUE);
200 SoOverrideElement::setLightModelOverride(state, NULL, TRUE);
201 SoOverrideElement::setDiffuseColorOverride(state, NULL, TRUE);
202 SoOverrideElement::setLineWidthOverride(state, NULL, TRUE);
203 SoOverrideElement::setLinePatternOverride(state, NULL, TRUE);
204 SoOverrideElement::setDrawStyleOverride(state, NULL, TRUE);
205 SoOverrideElement::setPolygonOffsetOverride(state, NULL, TRUE);
206 SoTextureOverrideElement::setQualityOverride(state, TRUE);
209 SoGLRenderAction::apply(this->postprocpath);
212 glEnable(GL_LIGHTING);