当前位置: 首页>>代码示例>>C++>>正文


C++ SoGroup::addChild方法代码示例

本文整理汇总了C++中SoGroup::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SoGroup::addChild方法的具体用法?C++ SoGroup::addChild怎么用?C++ SoGroup::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SoGroup的用法示例。


在下文中一共展示了SoGroup::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: attach

void ViewProviderPartReference::attach(App::DocumentObject *pcFeat)
{
    // call parent attach method
    ViewProviderGeometryObject::attach(pcFeat);

    SoGroup* pcNormalRoot = new SoGroup();
    SoGroup* pcFlatRoot = new SoGroup();
    SoGroup* pcWireframeRoot = new SoGroup();
    SoGroup* pcPointsRoot = new SoGroup();

    // enable two-side rendering
    pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
    pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;

    // normal viewing with edges and points
    pcNormalRoot->addChild(pShapeHints);
    pcNormalRoot->addChild(FaceRoot);
    pcNormalRoot->addChild(EdgeRoot);
    pcNormalRoot->addChild(VertexRoot);

    // just faces with no edges or points
    pcFlatRoot->addChild(pShapeHints);
    pcFlatRoot->addChild(FaceRoot);

    // only edges
    pcWireframeRoot->addChild(EdgeRoot);
    pcWireframeRoot->addChild(VertexRoot);

    // normal viewing with edges and points
    pcPointsRoot->addChild(VertexRoot);

    // putting all together with the switch
    addDisplayMaskMode(pcNormalRoot, "Reference");
}
开发者ID:DeepSOIC,项目名称:FreeCAD-ellipse,代码行数:34,代码来源:ViewProviderReference.cpp

示例2: THISP

SoCallbackAction::Response
SoToVRMLActionP::vrmlelevation_cb(void * closure, SoCallbackAction * COIN_UNUSED_ARG(action), const SoNode * node)
{
  SoToVRMLActionP * thisp = THISP(closure);

  SoGroup * tail = thisp->get_current_tail();

  const SoVRMLElevationGrid * grid = coin_assert_cast<const SoVRMLElevationGrid*>(node);
  SoShapeHints * sh = new SoShapeHints;
  sh->creaseAngle = grid->creaseAngle.getValue();
  sh->vertexOrdering = grid->ccw.getValue() ?
    SoShapeHints::COUNTERCLOCKWISE : SoShapeHints::CLOCKWISE;
  sh->shapeType = grid->solid.getValue() ?
    SoShapeHints::SOLID : SoShapeHints::UNKNOWN_SHAPE_TYPE;
  sh->faceType = SoShapeHints::CONVEX;
  tail->addChild(sh);

  SoVRMLColor * color = coin_assert_cast<SoVRMLColor *>(grid->color.getValue());

  if (color) {
    SoMaterial * mat = thisp->find_or_create_material();
    mat->diffuseColor.setValues(0, color->color.getNum(),
                                color->color.getValues(0));
  }

  thisp->init_gen(color != NULL);
  return SoCallbackAction::CONTINUE;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:28,代码来源:SoToVRMLAction.cpp

示例3: replaceSeparators

SoNode *
replaceSeparators(SoNode *root)
//
//////////////////////////////////////////////////////////////
{
    //
    // if it's a group, make a new group and copy its
    //  children over
    //
    if (root->isOfType(SoGroup::getClassTypeId())) {
	SoGroup *group = (SoGroup *) root;
        SoGroup *newGroup = (SoGroup *) group->getTypeId().createInstance();
        newGroup->SoNode::copyContents(group, FALSE);

	int	i;
	for (i=0; i<group->getNumChildren(); i++) {
	    SoNode *child = replaceSeparators(group->getChild(i));
	    newGroup->addChild(child);
	}
	return newGroup;
    }
    //
    // if not a group, return the node
    //
    else 
	return root;
}
开发者ID:Alexpux,项目名称:IvTools,代码行数:27,代码来源:ivperf.cpp

示例4: attach

void ViewProviderFace::attach(App::DocumentObject* obj)
{
    ViewProviderDocumentObject::attach(obj);

    pcMeshPick->mesh.setValue(static_cast<Mesh::Feature*>(obj)->Mesh.getValuePtr());

    // Draw markers
    SoGroup* markers = new SoGroup();
    SoDrawStyle* pointStyle = new SoDrawStyle();
    pointStyle->style = SoDrawStyle::POINTS;
    pointStyle->pointSize = 8.0f;
    markers->addChild(pointStyle);

    SoBaseColor * markcol = new SoBaseColor;
    markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
    SoPointSet* marker = new SoPointSet();
    markers->addChild(markcol);
    markers->addChild(pcCoords);
    markers->addChild(marker);

    // Draw face
    SoGroup* faces = new SoGroup();
    SoDrawStyle* faceStyle = new SoDrawStyle();
    faceStyle->style = SoDrawStyle::FILLED;
    faces->addChild(faceStyle);

    SoShapeHints * flathints = new SoShapeHints;
    //flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
    //flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
    faces->addChild(flathints);

    SoBaseColor* basecol = new SoBaseColor;
    if (mesh) {
        App::Color col = mesh->ShapeColor.getValue();
        basecol->rgb.setValue(col.r, col.g, col.b);
    }
    else {
        basecol->rgb.setValue(1.0f, 0.0f, 0.0f);
    }

    faces->addChild(basecol);
    faces->addChild(pcCoords);
    faces->addChild(pcFaces);

    SoGroup* face_marker = new SoGroup();
    face_marker->addChild(faces);
    face_marker->addChild(markers);

    addDisplayMaskMode(markers, "Marker");
    addDisplayMaskMode(face_marker, "Face");
    setDisplayMode("Marker");
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:52,代码来源:MeshEditor.cpp

示例5: 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 );
	}
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:17,代码来源:SoXipMenu.cpp

示例6: 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;
	}
    }
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:58,代码来源:SoUnknownNode.cpp

示例7: slotChangedObject

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);
}
开发者ID:RipCurrent,项目名称:FreeCAD_sf_master,代码行数:58,代码来源:Document.cpp

示例8: buildGeometry

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;
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:44,代码来源:SoFCCSysDragger.cpp

示例9: go

void SetupResultBoundingBox::go(ResultEntry *entry)
{
    entry->boxSep = new SoSeparator();
    entry->viewProvider->getRoot()->addChild(entry->boxSep);
    entry->boxSwitch = new SoSwitch();
    entry->boxSep->addChild(entry->boxSwitch);
    SoGroup *group = new SoGroup();
    entry->boxSwitch->addChild(group);
    entry->boxSwitch->whichChild.setValue(SO_SWITCH_NONE);
    SoDrawStyle *dStyle = new SoDrawStyle();
    dStyle->style.setValue(SoDrawStyle::LINES);
    dStyle->linePattern.setValue(0xc0c0);
    group->addChild(dStyle);
    SoMaterial *material = new SoMaterial();
    material->diffuseColor.setValue(255.0, 255.0, 255.0);
    material->ambientColor.setValue(255.0, 255.0, 255.0);
    group->addChild(material);

    Bnd_Box boundingBox;
    BRepBndLib::Add(entry->shape, boundingBox);
    Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
    boundingBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);

    double xCenter, yCenter, zCenter;
    xCenter = (xmax - xmin)/2 + xmin;
    yCenter = (ymax - ymin)/2 + ymin;
    zCenter = (zmax - zmin)/2 + zmin;

    SbVec3f boundCenter(xCenter, yCenter, zCenter);
    Standard_Real x, y, z;
    entry->shape.Location().Transformation().TranslationPart().Coord(x, y, z);
    boundCenter -= SbVec3f(x, y, z);

    SoTransform *position = new SoTransform();
    position->translation.setValue(boundCenter);
    group->addChild(position);

    SoCube *cube = new SoCube();
    cube->width.setValue(xmax - xmin);
    cube->height.setValue(ymax - ymin);
    cube->depth.setValue(zmax - zmin);
    group->addChild(cube);
}
开发者ID:MarcusWolschon,项目名称:FreeCAD_sf_master,代码行数:43,代码来源:TaskCheckGeometry.cpp

示例10: updateMaterial

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);
}
开发者ID:ma-tech,项目名称:WlzQtApps,代码行数:43,代码来源:Mesh2DView.cpp

示例11: goSetupResultBoundingBox

void PartGui::goSetupResultBoundingBox(ResultEntry *entry)
{
    //empty compound throws bounding box error. Mantis #0001426
    try
    {
      Bnd_Box boundingBox;
      BRepBndLib::Add(entry->shape, boundingBox);
      Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
      boundingBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
      SbVec3f boundCenter((xmax - xmin)/2 + xmin, (ymax - ymin)/2 + ymin, (zmax - zmin)/2 + zmin);
  
      entry->boxSep = new SoSeparator();
      entry->viewProviderRoot->addChild(entry->boxSep);
      entry->boxSwitch = new SoSwitch();
      entry->boxSep->addChild(entry->boxSwitch);
      SoGroup *group = new SoGroup();
      entry->boxSwitch->addChild(group);
      entry->boxSwitch->whichChild.setValue(SO_SWITCH_NONE);
      SoDrawStyle *dStyle = new SoDrawStyle();
      dStyle->style.setValue(SoDrawStyle::LINES);
      dStyle->linePattern.setValue(0xc0c0);
      group->addChild(dStyle);
      SoMaterial *material = new SoMaterial();
      material->diffuseColor.setValue(255.0, 255.0, 255.0);
      material->ambientColor.setValue(255.0, 255.0, 255.0);
      group->addChild(material);

      SoResetTransform *reset = new SoResetTransform();
      group->addChild(reset);
      
      SoTransform *position = new SoTransform();
      position->translation.setValue(boundCenter);
      group->addChild(position);

      SoCube *cube = new SoCube();
      cube->width.setValue(xmax - xmin);
      cube->height.setValue(ymax - ymin);
      cube->depth.setValue(zmax - zmin);
      group->addChild(cube);
    }
    catch (const Standard_Failure &){}
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:42,代码来源:TaskCheckGeometry.cpp

示例12: attach

void ViewProviderInspection::attach(App::DocumentObject *pcFeat)
{
    // creats the standard viewing modes
    inherited::attach(pcFeat);

    SoShapeHints * flathints = new SoShapeHints;
    flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
    flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;

    SoGroup* pcColorShadedRoot = new SoGroup();
    pcColorShadedRoot->addChild(flathints);

    // color shaded  ------------------------------------------
    SoDrawStyle *pcFlatStyle = new SoDrawStyle();
    pcFlatStyle->style = SoDrawStyle::FILLED;
    pcColorShadedRoot->addChild(pcFlatStyle);

    pcColorShadedRoot->addChild(pcColorMat);
    pcColorShadedRoot->addChild(pcMatBinding);
    pcColorShadedRoot->addChild(pcLinkRoot);

    addDisplayMaskMode(pcColorShadedRoot, "ColorShaded");

    // Check for an already existing color bar
    Gui::SoFCColorBar* pcBar = ((Gui::SoFCColorBar*)findFrontRootOfType(Gui::SoFCColorBar::getClassTypeId()));
    if (pcBar) {
        float fMin = pcColorBar->getMinValue();
        float fMax = pcColorBar->getMaxValue();
    
        // Attach to the foreign color bar and delete our own bar
        pcBar->Attach(this);
        pcBar->ref();
        pcBar->setRange(fMin, fMax, 3);
        pcBar->Notify(0);
        pcColorBar->Detach(this);
        pcColorBar->unref();
        pcColorBar = pcBar;
    }

    pcColorRoot->addChild(pcColorBar);
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:41,代码来源:ViewProviderInspection.cpp

示例13: Draw

void MyExaminerViewer::Draw()
{
    sp = new SoSeparator;
    sp->ref();
    SoSphere *headSphere = new SoSphere;
    SoMaterial *bronze = new SoMaterial;
    bronze->ambientColor.setValue(0.33,0.22,0.27);
    bronze->diffuseColor.setValue(0.78,0.57,0.11);
    bronze->specularColor.setValue(0.99,0.94,0.81);
    bronze->shininess = 0.28;

    SoTransform *myTransform = new SoTransform;
    myTransform->translation.setValue(0.0,-1.0,0.0);

    SoGroup *head = new SoGroup;
    head->addChild(myTransform);
    head->addChild(bronze);
    head->addChild(headSphere);

    sp->addChild(head);
}
开发者ID:tangming10000,项目名称:Tang,代码行数:21,代码来源:myexaminerviewer.cpp

示例14:

// creates a part of a scene-graph which is a plane suitable for the decoration
// of our SoJackDragger
SoGroup *InvPlaneMover::makePlane()
{

    static float vertexPos[4][3] = {
        { 0, 0.5, -0.5 },
        { 0, 0.5, 0.5 },
        { 0, -0.5, 0.5 },
        { 0, -0.5, -0.5 }
    };

    static int indices[4] = { 3, 2, 1, 0 };

    SoGroup *plane = new SoGroup;
    plane->ref();

    SoMaterial *mat = new SoMaterial;

    mat->ambientColor.setValue(0.3f, 0.1f, 0.1f);
    mat->diffuseColor.setValue(0.8f, 0.7f, 0.2f);
    mat->specularColor.setValue(0.4f, 0.3f, 0.1f);
    mat->transparency = 0.3f;
    plane->addChild(mat);

    SoMaterialBinding *bndng = new SoMaterialBinding;
    bndng->value = SoMaterialBinding::DEFAULT;
    plane->addChild(bndng);

    SoCoordinate3 *coords = new SoCoordinate3;
    coords->point.setValues(0, 4, vertexPos);

    plane->addChild(coords);

    SoIndexedFaceSet *faceSet = new SoIndexedFaceSet;
    faceSet->coordIndex.setValues(0, 4, indices);

    plane->addChild(faceSet);

    return plane;
}
开发者ID:nixz,项目名称:covise,代码行数:41,代码来源:InvPlaneMover.cpp

示例15: SoMarkerSet

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");
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:16,代码来源:ViewProviderMeasureDistance.cpp


注:本文中的SoGroup::addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。