本文整理汇总了C++中RenderObject::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderObject::getAttribute方法的具体用法?C++ RenderObject::getAttribute怎么用?C++ RenderObject::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderObject
的用法示例。
在下文中一共展示了RenderObject::getAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ModuleName
void
ModuleFeedbackManager::updateColorBar(RenderObject *containerObject)
{
RenderObject *colorObj = NULL;
const char *colormapString = NULL;
if (containerObject)
{
colorObj = containerObject->getColors();
if (!colorObj)
colorObj = containerObject->getTexture();
if (colorObj)
{
colormapString = colorObj->getAttribute("COLORMAP");
if (colormapString == NULL && colorObj->isSet())
{
size_t noElems = colorObj->getNumElements();
for (size_t elem = 0; elem < noElems; ++elem)
{
colormapString = colorObj->getElement(elem)->getAttribute("COLORMAP");
if (colormapString)
break;
}
}
// compute colorbar
std::string tmpStr = ModuleName(geomObjectName_.c_str());
const char *modname = tmpStr.c_str();
float min = 0.0;
float max = 1.0;
int numColors;
float *r = NULL;
float *g = NULL;
float *b = NULL;
float *a = NULL;
char *species = NULL;
if (colormapString)
{
//cerr << "ModuleFeedbackManager::updateColorBar(..) COLORMAPSTRING " << colormapString << endl;
ColorBar::parseAttrib(colormapString, species, min, max, numColors, r, g, b, a);
}
else
{
species = new char[16];
strcpy(species, "NoColors");
numColors = 2;
min = 0.0;
min = 1.0;
r = new float[2];
g = new float[2];
b = new float[2];
a = new float[2];
r[0] = 0.0;
g[0] = 0.0;
b[0] = 0.0;
a[0] = 1.0;
r[1] = 1.0;
g[1] = 1.0;
b[1] = 1.0;
a[1] = 1.0;
}
// color bar
if (colorBar_)
{
colorBar_->update(species, min, max, numColors, r, g, b, a);
}
else
{
//cerr << "ModuleFeedbackManager::updateColorBar(..) MODNAME <" << modname << ">" << endl;
colorBar_ = new ColorBar(colorsButton_, menu_,
modname, species, min, max, numColors, r, g, b, a);
}
delete[] species;
delete[] r;
delete[] g;
delete[] b;
delete[] a;
}
else // container without colors
{
if (colorBar_) // the previous object had colors
delete colorBar_;
colorBar_ = NULL;
}
}
else // no container
{
if (colorBar_) //the previous object had colors
delete colorBar_;
colorBar_ = NULL;
}
}
示例2: addObject
void cuIsoSurface::addObject(RenderObject *container,
RenderObject *geometry, RenderObject *normals,
RenderObject *colorObj, RenderObject *texObj,
osg::Group * /*setName*/, int /*numCol*/,
int, int /*colorPacking*/, float *, float *,
float *, int *,
int, int, float *, float *, float *, float)
{
osg::Group *group = NULL;
std::map<std::string, osg::Group *>::iterator gi = groups.find(container->getName());
if (gi == groups.end())
{
group = new osg::Group();
group->setName(container->getName());
cover->getObjectsRoot()->addChild(group);
groups[container->getName()] = group;
}
else
group = gi->second;
if (!menu)
{
coMenu *coviseMenu = (coMenu *)(VRPinboard::instance()->namedMenu("COVISE")->getCoMenu());
coSubMenuItem *menuItem = new coSubMenuItem("cuIsoSurfaceUSG");
menu = new coRowMenu("cuIsoSurfaceUSG", coviseMenu);
menuItem->setMenu(menu);
coviseMenu->add(menuItem);
}
if (container)
{
// get min and max from COLORMAP parameter of the container object
RenderObject *tex = container->getTexture();
if (tex && tex->isSet())
{
const char *attr = tex->getAttribute("COLORMAP");
if (attr)
{
char *species;
float *r = NULL, *g = NULL, *b = NULL, *a = NULL;
int numColors;
float min, max;
ColorBar::parseAttrib(attr, species, min, max,
numColors, r, g, b, a);
struct minmax m = { min, max };
minMax[container->getName()] = m;
delete[] r;
delete[] g;
delete[] b;
delete[] a;
}
}
}
if (geometry && geometry->isUnstructuredGrid())
{
if (colorObj)
{
const float *red = colorObj->getFloat(Field::Red);
const float *green = colorObj->getFloat(Field::Green);
const float *blue = colorObj->getFloat(Field::Blue);
const int *pc = colorObj->getInt(Field::RGBA);
if (red && (!pc && !green && !blue))
{
float box[6];
geometry->getMinMax(box[0], box[1], box[2], box[3], box[4], box[5]);
float min = 0.0, max = 1.0;
float dataMin = 0.0, dataMax = 1.0;
getMinMax(red, colorObj->getNumElements(), &dataMin, &dataMax);
removeSpikesAdaptive(red, colorObj->getNumElements(), &dataMin, &dataMax);
std::map<std::string, struct minmax>::iterator mi = minMax.find(container->getName());
if (mi != minMax.end())
{
min = mi->second.min;
max = mi->second.max;
}
else
{
const char *attrMin = container->getAttribute("MIN");
const char *attrMax = container->getAttribute("MAX");
if (attrMin && attrMax)
{
min = atof(attrMin);
max = atof(attrMax);
}
}
//fprintf("stderr, Iso minmax: %f %f\n", min, max);
osg::ref_ptr<osg::StateSet> state = new osg::StateSet();
state->setGlobalDefaults();
if (texObj)
{
//.........这里部分代码省略.........