本文整理汇总了C++中TreeViewItem::setOsgNode方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeViewItem::setOsgNode方法的具体用法?C++ TreeViewItem::setOsgNode怎么用?C++ TreeViewItem::setOsgNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeViewItem
的用法示例。
在下文中一共展示了TreeViewItem::setOsgNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TreeViewItem
BuildQtTreeView::BuildQtTreeView(osg::Node *node)
: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
, _maxTreeDepth(0)
{
TreeViewItem *item = new TreeViewItem();
item->setText(0, QObject::tr("Root"));
item->setIcon(0, QIcon(":/icons/TreeView/Group.png"));
item->setOsgNode(node);
item->setCheckState(0, Qt::Checked);
_parents.push(item);
}
示例2: apply
void BuildQtTreeView::apply(osg::Node& node)
{
osg::Geode *geode = 0L;
bool isGroup = false;
QString nodeName;
if(node.className()!="")
nodeName = "[" + QString::fromStdString(node.className()) + "]";
if(node.getName()!="")
nodeName += " " + QString::fromStdString(node.getName());
if (nodeName.isEmpty())
nodeName = QObject::tr("[<unknow_type>] <unnamed>");
TreeViewItem *item = new TreeViewItem(_parents.top());
item->setCheckState(0, Qt::Checked);
item->setOsgNode(&node);
item->setData(0, Qt::DisplayRole, nodeName);
if (dynamic_cast<osg::PagedLOD*>(&node))
{
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/LOD.png"));
_parents.push(item);
isGroup = true;
}
else if (dynamic_cast<osg::LOD*>(&node))
{
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/LOD.png"));
_parents.push(item);
isGroup = true;
}
else if (dynamic_cast<osg::Group*>(&node))
{
if (dynamic_cast<osg::MatrixTransform*>(&node))
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Matrix.png"));
else
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Group.png"));
_parents.push(item);
isGroup = true;
}
else if (dynamic_cast<osg::Billboard*>(&node))
{
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Billboard.png"));
}
else if ((geode = dynamic_cast<osg::Geode*>(&node)))
{
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Geode.png"));
for (unsigned int i=0; i<geode->getNumDrawables(); ++i)
{
osg::ref_ptr<osg::Drawable> drawable = geode->getDrawable(i);
if (drawable.valid())
{
TreeViewItem *subItem = new TreeViewItem(item);
//item->setCheckState(0, Qt::Checked);
//item->setOsgNode(&node);
subItem->setOsgObject(drawable.get());
subItem->setData(0, Qt::DisplayRole, "Drawable");
}
}
}
else
{
item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Other.png"));
}
_maxTreeDepth = std::max<int>(_maxTreeDepth, _parents.size());
traverse(node);
if (isGroup)
{
_parents.pop();
}
}