本文整理汇总了C++中SoSeparator::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SoSeparator::addChild方法的具体用法?C++ SoSeparator::addChild怎么用?C++ SoSeparator::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoSeparator
的用法示例。
在下文中一共展示了SoSeparator::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SoSeparator
static SoSeparator *arrowGeom(ScaleAxisArrow::AxisEnum axis, SoScale *antiScale, bool mirrored)
{
SoSeparator *root = new SoSeparator();
SoText2 *label = new SoText2();
label->justification = SoText2::CENTER;
if (axis == ScaleAxisArrow::AXIS_X) {
label->string.setValue(mirrored ? "-X" : "+X");
} else if (axis == ScaleAxisArrow::AXIS_Y) {
label->string.setValue(mirrored ? "-Y" : "+Y");
} else if (axis == ScaleAxisArrow::AXIS_Z) {
label->string.setValue(mirrored ? "-Z" : "+Z");
}
float mul = mirrored ? -1.0f : 1.0f;
// lines
float verts[][3] = {
// from origin to bottom of cone
{0, 0, 0},
{0, mul * CUBE_OFFS, 0},
};
SoCoordinate3 *coords = new SoCoordinate3();
coords->point.setValues(0, 2, verts);
root->addChild(coords);
int indices[] = {
0, 1, SO_END_LINE_INDEX,
};
SoIndexedLineSet *lines = new SoIndexedLineSet();
lines->coordIndex.setValues(0, 3, indices);
root->addChild(lines);
// cube translation
SoTranslation *xlat = new SoTranslation();
xlat->translation.setValue(0, mul * CUBE_OFFS, 0);
root->addChild(xlat);
// to keep the cubes from scaling (ultimately handled/set by parent ScaleWidget)
root->addChild(antiScale);
SoCube *cube = new SoCube();
cube->width = cube->height = cube->depth = 0.35;
root->addChild(cube);
// axis label translation
SoTranslation *xlat2 = new SoTranslation();
xlat2->translation.setValue(0, mul * (CUBE_HEIGHT/2+0.2), 0);
root->addChild(xlat2);
root->addChild(label);
return root;
}
示例2: SoQtExaminerViewer
int
main(int argc, char ** argv)
{
QWidget * w = SoQt::init(argc, argv, "SoQtColorEditor");
SoQtExaminerViewer * viewer = new SoQtExaminerViewer(w);
SoSeparator * root;
viewer->setSceneGraph(root = makescene());
viewer->show();
// we want ColorEditor in scene
SoSeparator * editorscene = new SoSeparator;
SoTranslation * trans = new SoTranslation;
trans->translation.setValue(SbVec3f(2.0f, 0.0f, 0.0f));
SoRotationXYZ * rot = new SoRotationXYZ;
SoMaterial * mat = new SoMaterial;
mat->diffuseColor.setValue(0.8, 0.8, 0.8);
rot->axis = SoRotationXYZ::Y;
rot->angle = 0.5;
editorscene->addChild(trans);
editorscene->addChild(rot);
editorscene->addChild(mat);
SoGuiColorEditor * inscene = new SoGuiColorEditor;
inscene->wysiwyg.setValue(TRUE);
inscene->color.connectFrom(&(material->diffuseColor));
inscene->color.getValue(); // update field
material->diffuseColor.connectFrom(&(inscene->color));
editorscene->addChild(inscene);
root->insertChild(editorscene, 0);
#if 0
SoQtColorEditor * editor = new SoQtColorEditor;
editor->attach(&(material->diffuseColor));
editor->show();
#endif
SoQt::show(w);
SoQt::mainLoop();
return 0;
}
示例3: app
int
main(int argc, char ** argv)
{
QApplication app(argc, argv);
// Initializes Quarter library (and implicitly also the Coin and Qt
// libraries).
Quarter::init();
// Make a dead simple scene graph by using the Coin library, only
// containing a single yellow cone under the scenegraph root.
SoSeparator * root = new SoSeparator;
root->ref();
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(1, 1, 0);
root->addChild(col);
root->addChild(new SoCone);
// Create a QuarterWidget for displaying a Coin scene graph
QuarterWidget * viewer = new QuarterWidget;
viewer->setSceneGraph(root);
// make the viewer react to input events similar to the good old
// ExaminerViewer
viewer->setNavigationModeFile(QUrl("coin:///scxml/navigation/examiner.xml"));
// Pop up the QuarterWidget
viewer->show();
// Loop until exit.
app.exec();
// Clean up resources.
root->unref();
delete viewer;
Quarter::clean();
return 0;
}
示例4: clone
VirtualRobot::VisualizationNodePtr CoinVisualizationNode::clone(bool deepCopy, float scaling)
{
THROW_VR_EXCEPTION_IF(scaling<=0,"Scaling must be >0");
SoSeparator* newModel = NULL;
if (visualization)
{
newModel = new SoSeparator;
newModel->ref();
if (scaling!=1.0)
{
SoScale *s = new SoScale;
s->scaleFactor.setValue(scaling,scaling,scaling);
newModel->addChild(s);
}
if (deepCopy)
{
newModel->addChild(visualization->copy(FALSE));
} else
newModel->addChild(visualization);
}
VisualizationNodePtr p(new CoinVisualizationNode(newModel));
if (newModel)
newModel->unrefNoDelete();
p->setUpdateVisualization(updateVisualization);
p->setGlobalPose(getGlobalPose());
p->setFilename(filename,boundingBox);
// clone attached visualizations
std::map< std::string, VisualizationNodePtr >::const_iterator i = attachedVisualizations.begin();
while (i!=attachedVisualizations.end())
{
VisualizationNodePtr attachedClone = i->second->clone(deepCopy,scaling);
p->attachVisualization(i->first, attachedClone);
i++;
}
return p;
}
示例5: SbColor
SoSeparator*
VirtualContact::getVisualIndicator()
{
SoTransform *tran;
//this one is a member variable so we can change color if we want to "mark" the contact
if (!mZaxisMat) {
mZaxisMat = new SoMaterial;
mZaxisMat->ref();
}
mZaxisMat->diffuseColor = SbColor(0.8f,0,0);
mZaxisMat->ambientColor = SbColor(0.8f,0,0);
tran = new SoTransform;
getContactFrame().toSoTransform(tran);
SoCylinder *zaxisCyl = new SoCylinder;
zaxisCyl->radius = 0.2f;
zaxisCyl->height = Body::CONE_HEIGHT;
SoSphere *zaxisSphere = new SoSphere;
zaxisSphere->radius = 3.0f;
SoTransform *zaxisTran = new SoTransform;
zaxisTran->translation.setValue(0,0,Body::CONE_HEIGHT/2.0);
// zaxisTran->translation.setValue(0,0,2.0);
zaxisTran->rotation.setValue(SbVec3f(1,0,0),(float)M_PI/2.0f);
SoSeparator *zaxisSep = new SoSeparator;
zaxisSep->addChild(zaxisTran);
zaxisSep->addChild(mZaxisMat);
zaxisSep->addChild(zaxisCyl);
// zaxisSep->addChild(zaxisSphere);
SoSeparator* cne = new SoSeparator;
cne->addChild(tran);
cne->addChild(zaxisSep);
return cne;
}
示例6:
void
SoXipOverlayTransformBoxManip::create()
{
mControlPointsCoords = new SoCoordinate3;
mControlPointsCoords->point.setNum(8);
mControlPointsCoords->point.set1Value( 0, SbVec3f( -0.5, 0.5, 0 ) );
mControlPointsCoords->point.set1Value( 1, SbVec3f( 0, 0.5, 0 ) );
mControlPointsCoords->point.set1Value( 2, SbVec3f( 0.5, 0.5, 0 ) );
mControlPointsCoords->point.set1Value( 3, SbVec3f( 0.5, 0, 0 ) );
mControlPointsCoords->point.set1Value( 4, SbVec3f( 0.5, -0.5, 0 ) );
mControlPointsCoords->point.set1Value( 5, SbVec3f( 0, -0.5, 0 ) );
mControlPointsCoords->point.set1Value( 6, SbVec3f( -0.5, -0.5, 0 ) );
mControlPointsCoords->point.set1Value( 7, SbVec3f( -0.5, 0, 0 ) );
mControlPointsStyle = new SoDrawStyle;
mControlPointsStyle->pointSize.setValue(5);
mControlPointsStyle->lineWidth.setValue(1);
SoBaseColor* pColor = new SoBaseColor;
pColor->rgb.setValue( 1, 1, 1 );
mBBoxTransform = new SoMatrixTransform;
mBBoxTransform->matrix.setValue( SbMatrix::identity() );
SoBaseColor* secondColor = new SoBaseColor;
secondColor->rgb.setValue( 0.5, 0.5, 0.5 );
SoDrawStyle* secondStyle = new SoDrawStyle;
secondStyle->pointSize.setValue(3);
if( mControlPointsSwitch )
mControlPointsSwitch->unref();
SoSeparator* controlPointsSeparator = new SoSeparator;
controlPointsSeparator->addChild( mBBoxTransform );
controlPointsSeparator->addChild( mControlPointsCoords );
controlPointsSeparator->addChild( mControlPointsStyle );
controlPointsSeparator->addChild( pColor );
controlPointsSeparator->addChild( new SoPointSet );
controlPointsSeparator->addChild( mControlPointsCoords );
controlPointsSeparator->addChild( secondStyle );
controlPointsSeparator->addChild( secondColor );
controlPointsSeparator->addChild( new SoPointSet );
mControlPointsSwitch = new SoSwitch;
mControlPointsSwitch->addChild( controlPointsSeparator );
mControlPointsSwitch->ref();
}
示例7: showPoints
void SketcherValidation::showPoints(const std::vector<Base::Vector3d>& pts)
{
SoCoordinate3 * coords = new SoCoordinate3();
SoDrawStyle * drawStyle = new SoDrawStyle();
drawStyle->pointSize = 6;
SoPointSet* pcPoints = new SoPointSet();
coincidenceRoot = new SoGroup();
coincidenceRoot->addChild(drawStyle);
SoSeparator* pointsep = new SoSeparator();
SoBaseColor * basecol = new SoBaseColor();
basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
pointsep->addChild(basecol);
pointsep->addChild(coords);
pointsep->addChild(pcPoints);
coincidenceRoot->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_9_9;
pointsep->addChild(markcol);
pointsep->addChild(marker);
int pts_size = (int)pts.size();
coords->point.setNum(pts_size);
SbVec3f* c = coords->point.startEditing();
for (int i = 0; i < pts_size; i++) {
const Base::Vector3d& v = pts[i];
c[i].setValue((float)v.x,(float)v.y,(float)v.z);
}
coords->point.finishEditing();
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(sketch);
vp->getRoot()->addChild(coincidenceRoot);
}
示例8: getPointOnRay
SoPickedPoint* ViewProvider::getPointOnRay(const SbVec3f& pos,const SbVec3f& dir, const View3DInventorViewer* viewer) const
{
// Note: There seems to be a bug with setRay() which causes SoRayPickAction
// to fail to get intersections between the ray and a line
//first get the path to this node and calculate the current setTransformation
SoSearchAction sa;
sa.setNode(pcRoot);
sa.setSearchingAll(true);
sa.apply(viewer->getSoRenderManager()->getSceneGraph());
SoGetMatrixAction gm(viewer->getSoRenderManager()->getViewportRegion());
gm.apply(sa.getPath());
// build a temporary scenegraph only keeping this viewproviders nodes and the accumulated
// transformation
SoTransform* trans = new SoTransform;
trans->ref();
trans->setMatrix(gm.getMatrix());
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getSoRenderManager()->getCamera());
root->addChild(trans);
root->addChild(pcRoot);
//get the picked point
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
rp.setRay(pos,dir);
rp.setRadius(viewer->getPickRadius());
rp.apply(root);
root->unref();
trans->unref();
// returns a copy of the point
SoPickedPoint* pick = rp.getPickedPoint();
//return (pick ? pick->copy() : 0); // needs the same instance of CRT under MS Windows
return (pick ? new SoPickedPoint(*pick) : 0);
}
示例9: interactiveFilletArc
Py::Object interactiveFilletArc(const Py::Tuple& args)
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
SoSeparator* scene = static_cast<SoSeparator*>(viewer->getSceneGraph());
SoSeparator* node = new SoSeparator();
SoBaseColor* rgb = new SoBaseColor();
rgb->rgb.setValue(1,1,0);
node->addChild(rgb);
SoCoordinate3* coords = new SoCoordinate3();
node->addChild(coords);
node->addChild(new SoLineSet());
scene->addChild(node);
ObjectObserver* obs = new ObjectObserver(doc->getDocument()->getActiveObject(), coords);
obs->attachDocument(doc->getDocument());
}
}
return Py::None();
}
示例10: SoSeparator
static SoSeparator *arrowGeom(AxisArrow::AxisEnum axis, bool mirrored)
{
SoSeparator *root = new SoSeparator();
SoText2 *label = new SoText2();
label->justification = SoText2::CENTER;
if (axis == AxisArrow::AXIS_X) {
label->string.setValue(mirrored ? "-X" : "+X");
} else if (axis == AxisArrow::AXIS_Y) {
label->string.setValue(mirrored ? "-Y" : "+Y");
} else if (axis == AxisArrow::AXIS_Z) {
label->string.setValue(mirrored ? "-Z" : "+Z");
}
float mul = mirrored ? -1.0f : 1.0f;
// lines
float verts[][3] = {
// from origin to bottom of cone
{0, mul * CONE_OFFS/4, 0},
{0, mul * CONE_OFFS, 0},
};
SoCoordinate3 *coords = new SoCoordinate3();
coords->point.setValues(0, 2, verts);
root->addChild(coords);
int indices[] = {
0, 1, SO_END_LINE_INDEX,
};
SoIndexedLineSet *lines = new SoIndexedLineSet();
lines->coordIndex.setValues(0, 3, indices);
root->addChild(lines);
if (mirrored) {
// easiest way to mirror the cone, I guess
SoRotationXYZ *rot = new SoRotationXYZ();
rot->axis = SoRotationXYZ::X;
rot->angle = M_PI;
root->addChild(rot);
}
SoTranslation *xlat = new SoTranslation();
xlat->translation.setValue(0, CONE_OFFS, 0);
root->addChild(xlat);
SoCone *cone = new SoCone();
cone->bottomRadius = 0.35;
cone->height = CONE_HEIGHT;
root->addChild(cone);
SoTranslation *xlat2 = new SoTranslation();
xlat2->translation.setValue(0, CONE_HEIGHT/2+0.2, 0);
root->addChild(xlat2);
root->addChild(label);
return root;
}
示例11: attach
void ViewProviderDatum::attach(App::DocumentObject *obj)
{
ViewProviderGeometryObject::attach ( obj );
// TODO remove this field (2015-09-08, Fat-Zer)
App::DocumentObject* o = getObject();
if (o->getTypeId() == PartDesign::Plane::getClassTypeId())
datumType = QObject::tr("Plane");
else if (o->getTypeId() == PartDesign::Line::getClassTypeId())
datumType = QObject::tr("Line");
else if (o->getTypeId() == PartDesign::Point::getClassTypeId())
datumType = QObject::tr("Point");
else if (o->getTypeId() == PartDesign::CoordinateSystem::getClassTypeId())
datumType = QObject::tr("CoordinateSystem");
SoShapeHints* hints = new SoShapeHints();
hints->shapeType.setValue(SoShapeHints::UNKNOWN_SHAPE_TYPE);
hints->vertexOrdering.setValue(SoShapeHints::COUNTERCLOCKWISE);
SoDrawStyle* fstyle = new SoDrawStyle();
fstyle->style = SoDrawStyle::FILLED;
fstyle->lineWidth = 3;
fstyle->pointSize = 5;
pPickStyle->style = SoPickStyle::SHAPE;
SoMaterialBinding* matBinding = new SoMaterialBinding;
matBinding->value = SoMaterialBinding::OVERALL;
SoSeparator* sep = new SoSeparator();
sep->addChild(hints);
sep->addChild(fstyle);
sep->addChild(pPickStyle);
sep->addChild(matBinding);
sep->addChild(pcShapeMaterial);
sep->addChild(pShapeSep);
addDisplayMaskMode(sep, "Base");
}
示例12: computeVertices
Standard_Boolean ViewProviderCurveNet::computeVertices(SoSeparator* root, const TopoDS_Shape &myShape)
{
TopExp_Explorer ex;
SoSeparator *VertexRoot = new SoSeparator();
root->addChild(VertexRoot);
VertexRoot->addChild(pcPointMaterial);
SoComplexity *copl = new SoComplexity();
copl->value = (float)0.2;
VertexRoot->addChild(copl);
for (ex.Init(myShape, TopAbs_VERTEX); ex.More(); ex.Next())
{
// get the shape
const TopoDS_Vertex& aVertex = TopoDS::Vertex(ex.Current());
gp_Pnt gpPt = BRep_Tool::Pnt (aVertex);
SoSeparator *TransRoot = new SoSeparator();
SoTransform *Trans = new SoTransform();
TransRoot->addChild(Trans);
Trans->translation.setValue((float)(gpPt.X()),(float)(gpPt.Y()),(float)(gpPt.Z()));
SoLocateHighlight* h = new SoLocateHighlight();
h->color.setValue((float)0.2,(float)0.5,(float)0.2);
SoSphere * sphere = new SoSphere;
sphere->radius = (float)pcPointStyle->pointSize.getValue();
h->addChild(sphere);
TransRoot->addChild(h);
VertexRoot->addChild(TransRoot);
}
return true;
}
示例13: showPlane
bool SimoxRobotViewer::showPlane( const std::string &planeName, const Eigen::Vector3f &pos, const Eigen::Vector3f &n )
{
removePlane(planeName);
lock();
SoSeparator* sep = new SoSeparator();
sep->addChild(CoinVisualizationFactory::CreatePlaneVisualization(pos,n,4000.0f,0.5f));
planes[planeName] = sep;
// add visu
sceneSep->addChild(sep);
unlock();
return true;
}
示例14: setEEFVisu
bool SimoxRobotViewer::setEEFVisu( const std::string &eefVisuName, SoSeparator *vis )
{
removeEEFVisu(eefVisuName);
if (!vis)
return false;
lock();
SoSeparator *v = new SoSeparator;
SoMatrixTransform *mat = new SoMatrixTransform;
mat->matrix.setValue(SbMatrix::identity());
v->addChild(mat);
v->addChild(vis);
eefVisu[eefVisuName] = v;
eefVisu[eefVisuName]->ref();
unlock();
showEEFVisu(eefVisuName,true);
return true;
}
示例15:
SoSeparator *
createCameraObject (const float zoomFactor = 1.0)
{
vpDEBUG_TRACE (15, "# Entree.");
SoSeparator * cam = new SoSeparator;
cam->ref ();
SoMaterial *myMaterial = new SoMaterial;
myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);
myMaterial->emissiveColor.setValue(0.5, 0.0, 0.0);
SoScale *taille = new SoScale;
{
float zoom = 0.1f * zoomFactor;
taille->scaleFactor.setValue (zoom, zoom, zoom);
}
SoMaterial *couleurBlanc = new SoMaterial;
couleurBlanc->diffuseColor.setValue(1.0, 1.0, 1.0);
couleurBlanc->emissiveColor.setValue(1.0, 1.0, 1.0);
SoDrawStyle * filDeFer = new SoDrawStyle;
filDeFer->style.setValue (SoDrawStyle::LINES);
filDeFer->lineWidth.setValue (1);
SoSeparator * cone = new SoSeparator;
cone->ref();
cone->addChild (makePyramide());
cone->addChild (couleurBlanc);
cone->addChild (filDeFer);
cone->addChild (makePyramide());
cone->unrefNoDelete();
cam->addChild(myMaterial);
cam->addChild(taille);
cam->addChild(cone);
cam->addChild(createFrame(2.0f,0.1f,0.01f));
// cam->unref() ;
vpDEBUG_TRACE (15, "# Sortie.");
return cam;
}