本文整理汇总了C++中SoGroup类的典型用法代码示例。如果您正苦于以下问题:C++ SoGroup类的具体用法?C++ SoGroup怎么用?C++ SoGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void
IfReplacer::replaceMaterials(SoNode *sceneRoot, const SoType &typeToReplace)
{
// Find all nodes of the given type
SoSearchAction sa;
sa.setType(typeToReplace);
sa.setInterest(SoSearchAction::ALL);
sa.apply(sceneRoot);
// Replace the tail of each path with a material. To do this, we
// need to apply an SoCallbackAction to the path to gather the
// material components.
for (int i = 0; i < sa.getPaths().getLength(); i++) {
// Cast the path to a full path, just in case
SoFullPath *path = (SoFullPath *) sa.getPaths()[i];
ASSERT(path->getTail()->isOfType(typeToReplace));
// The path better have at least one group above the material
if (path->getLength() < 2 ||
! path->getNodeFromTail(1)->isOfType(SoGroup::getClassTypeId()))
continue;
// Create a material node that represents the material in
// effect at the tail of the path
SoMaterial *newMaterial = createMaterialForPath(path);
newMaterial->ref();
// Replace the tail node with that material
SoGroup *parent = (SoGroup *) path->getNodeFromTail(1);
parent->replaceChild(path->getTail(), newMaterial);
newMaterial->unref();
}
}
示例2: SoGroup
void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
{
ViewProviderDocumentObject::attach( pcFeat );
SoGroup* pcPointRoot = new SoGroup();
pcDrawStyle->pointSize = 3;
pcPointRoot->addChild(pcDrawStyle);
// Draw points
SoSeparator* pointsep = new SoSeparator;
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
pointsep->addChild(basecol);
pointsep->addChild(pcCoords);
pointsep->addChild(pcPoints);
pcPointRoot->addChild(pointsep);
// Draw markers
SoBaseColor * markcol = new SoBaseColor;
markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=SoMarkerSet::PLUS_7_7;
pointsep->addChild(markcol);
pointsep->addChild(marker);
addDisplayMaskMode(pcPointRoot, "Point");
}
示例3: if
void
SoUnknownNode::createFromIsA(SoMFString *isA)
//
////////////////////////////////////////////////////////////////////////
{
for (int i = 0; i < isA->getNum(); i++) {
SoType t = SoType::fromName((*isA)[i]);
if (t.canCreateInstance() &&
t.isDerivedFrom(SoNode::getClassTypeId())) {
SoNode *alternateRep = (SoNode *)t.createInstance();
alternateRep->ref();
#ifdef DEBUG
if (alternateRep == NULL) {
SoDebugError::post("SoUnknownNode::createFromIsA",
"SoType.createInstance returned "
"NULL (type %s)",
t.getName().getString());
return;
}
#endif
// Copy over all fields that are shared:
int num = instanceFieldData->getNumFields();
for (int j=0; j<num; j++) {
const SbName &fieldName = instanceFieldData->getFieldName(j);
SoField *f = instanceFieldData->getField(this, j);
// Don't copy over fields with default values:
if (f->isDefault()) continue;
SoField *nf = alternateRep->getField(fieldName);
if (nf != NULL && nf->getTypeId() == f->getTypeId()) {
nf->copyFrom(*f);
if (f->isConnectedFromField()) {
SoField *cf;
f->getConnectedField(cf);
nf->connectFrom(cf);
} else if (f->isConnectedFromEngine()) {
SoEngineOutput *eo;
f->getConnectedEngine(eo);
nf->connectFrom(eo);
}
}
}
// And if alternateRep is a group, copy over hidden
// children:
if (alternateRep->isOfType(SoGroup::getClassTypeId())) {
SoGroup *g = (SoGroup *)alternateRep;
for (int kid = 0; kid < hiddenChildren.getLength();
kid++) {
g->addChild(hiddenChildren[kid]);
}
}
addChild(alternateRep);
return;
}
}
}
示例4: getViewProvider
void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
{
//Base::Console().Log("Document::slotChangedObject() called\n");
ViewProvider* viewProvider = getViewProvider(&Obj);
if (viewProvider) {
try {
viewProvider->update(&Prop);
}
catch(const Base::MemoryException& e) {
Base::Console().Error("Memory exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
}
catch(Base::Exception& e){
e.ReportException();
}
catch(const std::exception& e){
Base::Console().Error("C++ exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
}
catch (...) {
Base::Console().Error("Cannot update representation for '%s'.\n", Obj.getNameInDocument());
}
// check for children
if(viewProvider->getChildRoot()) {
std::vector<App::DocumentObject*> children = viewProvider->claimChildren3D();
SoGroup* childGroup = viewProvider->getChildRoot();
// size not the same -> build up the list new
if(childGroup->getNumChildren() != children.size()){
childGroup->removeAllChildren();
for(std::vector<App::DocumentObject*>::iterator it=children.begin();it!=children.end();++it){
ViewProvider* ChildViewProvider = getViewProvider(*it);
if(ChildViewProvider) {
SoSeparator* childRootNode = ChildViewProvider->getRoot();
childGroup->addChild(childRootNode);
// cycling to all views of the document to remove the viewprovider from the viewer itself
for (std::list<Gui::BaseView*>::iterator vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) {
View3DInventor *activeView = dynamic_cast<View3DInventor *>(*vIt);
if (activeView && viewProvider) {
if (d->_pcInEdit == ChildViewProvider)
resetEdit();
activeView->getViewer()->removeViewProvider(ChildViewProvider);
}
}
}
}
}
}
if (viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
signalChangedObject(static_cast<ViewProviderDocumentObject&>(*viewProvider), Prop);
}
// a property of an object has changed
setModified(true);
}
示例5: SoGroup
void ViewProviderInventorObject::attach(App::DocumentObject *pcObj)
{
ViewProviderDocumentObject::attach(pcObj);
SoGroup* pcFileBuf = new SoGroup();
pcFileBuf->addChild(pcBuffer);
pcFileBuf->addChild(pcFile);
addDisplayMaskMode(pcFileBuf, "FileBuffer");
addDisplayMaskMode(pcBuffer, "Buffer");
addDisplayMaskMode(pcFile, "File");
}
示例6: COIN_UNUSED_ARG
SoCallbackAction::Response
SoToVRMLActionP::push_cb(void * closure, SoCallbackAction * COIN_UNUSED_ARG(action), const SoNode * node)
{
SoToVRMLActionP * thisp = THISP(closure);
SoSeparator * newsep = NEW_NODE(SoSeparator, node);
SoGroup * prevgroup = THISP(closure)->get_current_tail();
prevgroup->addChild(newsep);
thisp->vrmlpath->append(newsep);
return SoCallbackAction::CONTINUE;
}
示例7: getSoRenderManager
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setCameraType(SoType type)
{
if(!getSoRenderManager()->getCamera()->isOfType(SoPerspectiveCamera::getClassTypeId()) &&
!getSoRenderManager()->getCamera()->isOfType(SoOrthographicCamera::getClassTypeId())) {
Base::Console().Warning("Quarter::setCameraType",
"Only SoPerspectiveCamera and SoOrthographicCamera is supported.");
return;
}
SoType perspectivetype = SoPerspectiveCamera::getClassTypeId();
SbBool oldisperspective = getSoRenderManager()->getCamera()->getTypeId().isDerivedFrom(perspectivetype);
SbBool newisperspective = type.isDerivedFrom(perspectivetype);
if((oldisperspective && newisperspective) ||
(!oldisperspective && !newisperspective)) // Same old, same old..
return;
SoCamera* currentcam = getSoRenderManager()->getCamera();
SoCamera* newcamera = (SoCamera*)type.createInstance();
// Transfer and convert values from one camera type to the other.
if(newisperspective) {
convertOrtho2Perspective((SoOrthographicCamera*)currentcam,
(SoPerspectiveCamera*)newcamera);
}
else {
convertPerspective2Ortho((SoPerspectiveCamera*)currentcam,
(SoOrthographicCamera*)newcamera);
}
getSoRenderManager()->setCamera(newcamera);
getSoEventManager()->setCamera(newcamera);
//if the superscene has a camera we need to replace it too
SoSeparator* superscene = (SoSeparator*) getSoRenderManager()->getSceneGraph();
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setType(SoCamera::getClassTypeId());
sa.apply(superscene);
if(sa.getPath()) {
SoNode* node = sa.getPath()->getTail();
SoGroup* parent = (SoGroup*) sa.getPath()->getNodeFromTail(1);
if(node && node->isOfType(SoCamera::getClassTypeId())) {
parent->replaceChild(node, newcamera);
}
}
};
示例8: QVariant
void SceneModel::setNode(QModelIndex index, SoNode* node)
{
this->setData(index, QVariant(QString::fromAscii(node->getTypeId().getName())));
if (node->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) {
SoGroup *group = static_cast<SoGroup*>(node);
// insert SoGroup icon
this->insertColumns(0,1,index);
this->insertRows(0,group->getNumChildren(), index);
for (int i=0; i<group->getNumChildren();i++) {
SoNode* child = group->getChild(i);
setNode(this->index(i, 0, index), child);
}
}
// insert icon
}
示例9: if
void ViewProviderInventorObject::adjustSelectionNodes(SoNode* child, const char* docname,
const char* objname)
{
if (child->getTypeId().isDerivedFrom(SoFCSelection::getClassTypeId())) {
static_cast<SoFCSelection*>(child)->documentName = docname;
static_cast<SoFCSelection*>(child)->objectName = objname;
}
else if (child->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) {
SoGroup* group = static_cast<SoGroup*>(child);
for (int i=0; i<group->getNumChildren(); i++) {
SoNode* subchild = group->getChild(i);
adjustSelectionNodes(subchild, docname, objname);
}
}
}
示例10: SoCoordinate3
ViewProviderPointMarker::ViewProviderPointMarker()
{
pCoords = new SoCoordinate3();
pCoords->ref();
pCoords->point.setNum(0);
pMarker = new SoMarkerSet();
pMarker->markerIndex = SoMarkerSet::CROSS_9_9;
pMarker->numPoints=0;
pMarker->ref();
SoGroup* grp = new SoGroup();
grp->addChild(pCoords);
grp->addChild(pMarker);
addDisplayMaskMode(grp, "Base");
setDisplayMaskMode("Base");
}
示例11: main
int main(int, char **argv)
{
// Initialize Inventor. This returns a main window to use.
// If unsuccessful, exit.
HWND myWindow = SoWin::init("Water molecule"); // pass the app name
if (myWindow == NULL) exit(1);
// Make a scene containing a red cone
SoGroup *waterMolecule = new SoGroup; // water molecule
SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
SoGroup *oxygen = new SoGroup; // oxygen atom
SoMaterial *redPlastic = new SoMaterial;
SoSphere *sphere1 = new SoSphere;
SoGroup *hydrogen1 = new SoGroup; // hydrogen atoms
SoGroup *hydrogen2 = new SoGroup;
SoTransform *hydrogenXform1 = new SoTransform;
SoTransform *hydrogenXform2 = new SoTransform;
SoMaterial *whitePlastic = new SoMaterial;
SoSphere *sphere2 = new SoSphere;
SoSphere *sphere3 = new SoSphere;
// Set all field values for the oxygen atom
redPlastic->ambientColor.setValue(1.0, 0.0, 0.0);
redPlastic->diffuseColor.setValue(1.0, 0.0, 0.0);
redPlastic->specularColor.setValue(0.5, 0.5, 0.5);
redPlastic->shininess = 0.5;
// Set all field values for the hydrogen atoms
hydrogenXform1->scaleFactor.setValue(0.75, 0.75, 0.75);
hydrogenXform1->translation.setValue(0.1, 1.2, 1.0);
hydrogenXform2->translation.setValue(0.0, -3.2, 0.0);
whitePlastic->ambientColor.setValue(1.0, 1.0, 1.0);
whitePlastic->diffuseColor.setValue(1.0, 1.0, 1.0);
whitePlastic->specularColor.setValue(0.5, 0.5, 0.5);
whitePlastic->shininess = 0.5;
// Create a hierarchy
waterMolecule->ref();
waterMolecule->addChild(oxygen);
waterMolecule->addChild(hydrogen1);
waterMolecule->addChild(hydrogen2);
oxygen->addChild(redPlastic);
oxygen->addChild(sphere1);
hydrogen1->addChild(hydrogenXform1);
hydrogen1->addChild(whitePlastic);
hydrogen1->addChild(sphere2);
hydrogen2->addChild(hydrogenXform2);
hydrogen2->addChild(sphere3);
SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
// Make myCamera see everything.
myCamera->viewAll(waterMolecule, myRenderArea->getViewportRegion());
// Put our scene in myRenderArea, change the title
myRenderArea->setSceneGraph(waterMolecule);
myRenderArea->setTitle("Water molecule");
myRenderArea->show();
SoWin::show(myWindow); // Display main window
SoWin::mainLoop(); // Main Inventor event loop
delete myRenderArea;
waterMolecule->unref();
return 0;
}
示例12: getItem
void
SoXipMenu::onMenuChange()
{
mItemSeparator->removeAllChildren();
for( int i = 0; i < size(); ++ i )
{
SoTranslation* offset = new SoTranslation;
offset->translation.setValue( 0, getItem(i)->getHeight(), 0 );
SoGroup* itemGroup = new SoGroup;
itemGroup->addChild( getItem(i) );
itemGroup->addChild( offset );
mItemSeparator->addChild( itemGroup );
}
}
示例13: removeNodes
void
removeNodes(SoGroup *root, SoType type)
//
//////////////////////////////////////////////////////////////
{
SoSearchAction act;
act.setInterest(SoSearchAction::ALL);
act.setType(type);
act.apply(root);
SoPathList &paths = act.getPaths();
for (int i = 0; i < paths.getLength(); i++) {
SoNode *kid = paths[i]->getTail();
paths[i]->pop();
SoGroup *parent = (SoGroup *)paths[i]->getTail();
parent->removeChild(kid);
}
}
示例14: SoGroup
SoGroup* TDragger::buildGeometry()
{
//this builds one leg in the Y+ direction because of default done direction.
//the location anchor for shapes is the center of shape.
SoGroup *root = new SoGroup();
//cylinder
float cylinderHeight = 10.0;
float cylinderRadius = 0.2f;
SoSeparator *cylinderSeparator = new SoSeparator();
root->addChild(cylinderSeparator);
SoTranslation *cylinderTranslation = new SoTranslation();
cylinderTranslation->translation.setValue(0.0, cylinderHeight / 2.0, 0.0);
cylinderSeparator->addChild(cylinderTranslation);
SoCylinder *cylinder = new SoCylinder();
cylinder->radius.setValue(cylinderRadius);
cylinder->height.setValue(cylinderHeight);
cylinderSeparator->addChild(cylinder);
//cone
float coneBottomRadius = 1.0;
float coneHeight = 2.0;
SoSeparator *coneSeparator = new SoSeparator();
root->addChild(coneSeparator);
SoPickStyle *pickStyle = new SoPickStyle();
pickStyle->style.setValue(SoPickStyle::SHAPE);
pickStyle->setOverride(TRUE);
coneSeparator->addChild(pickStyle);
SoTranslation *coneTranslation = new SoTranslation();
coneTranslation->translation.setValue(0.0, cylinderHeight + coneHeight / 2.0, 0.0);
coneSeparator->addChild(coneTranslation);
SoCone *cone = new SoCone();
cone->bottomRadius.setValue(coneBottomRadius);
cone->height.setValue(coneHeight);
coneSeparator->addChild(cone);
return root;
}
示例15: generateSceneGraph
void Mesh2DView::
generateSceneGraph(
bool /*bForce*/)
{
m_material->diffuseColor.setValue(obj->sbColour());
updateMaterial();
root->addChild(m_material);
root->addChild(m_drawStyle);
SoGroup *cache;
if(obj->isCachedVisualisation())
{
cache = obj->cachedVisualisation();
}
else
{
cache = new SoGroup;
WlzErrorNum errNum = WLZ_ERR_NONE;
SoCoordinate3 * nodes; // nodes of the mesh
SoIndexedFaceSet * faceset; // lines of the mesh
nodes = Vertices2D(new SoCoordinate3, errNum);
if(errNum == WLZ_ERR_NONE)
{
faceset = Faces2D(new SoIndexedFaceSet, errNum);
}
if( (errNum != WLZ_ERR_NONE) || (nodes == NULL) || (faceset == NULL))
{
return ;
}
SoShapeHints *h1= new SoShapeHints;
Q_ASSERT(h1);
h1->vertexOrdering = SoShapeHints::CLOCKWISE;
h1->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
cache->addChild(h1);
cache->addChild(nodes);
cache->addChild(faceset);
obj->setVisualisation(cache);
}
root->addChild(cache);
}