Пример #1
0
SoMField * QCtkXipSGWidget::getMField(const char * fieldContainerName, const char * fieldName)
{
  SoField * field = getSoField(fieldContainerName, fieldName);
  if(field->isOfType(SoMField::getClassTypeId()))
    return (SoMField *) field;
  return 0;
}
Пример #2
0
SbBool
SoUnknownNode::readInstance(SoInput *in, unsigned short flags)

//
////////////////////////////////////////////////////////////////////////
{
    int i;

    // This is mostly the normal SoGroup reading code, but we look for
    // an alternateRep field after reading and move our public
    // children onto the hidden children list:

    hasChildren = (!in->isBinary() || (flags & IS_GROUP));
    SbBool result;
    if (hasChildren) {
	result = SoGroup::readInstance(in, flags);

	// If read ASCII AND didn't read any children, set hasChildren
	// to FALSE:
	if (!in->isBinary() && getNumChildren() == 0) hasChildren = FALSE;

	// Add all kids to hiddenChildren, then remove them all from the
	// regular (SoGroup) list
	for (i = 0; i < getNumChildren(); i++) {
	    hiddenChildren.append(getChild(i));
	}
	removeAllChildren();
    }
    else {
	result = SoNode::readInstance(in, flags);
    }

    // Check to see if an alternate representation was read and
    // store a pointer to it if one is found.
    int num = instanceFieldData->getNumFields();
    SbBool haveAlternateRep = FALSE;
    for (i=0; i<num; i++) {
        if (instanceFieldData->getFieldName(i) == SbName("alternateRep")) {
	    SoField *f = instanceFieldData->getField(this, i);
	    if (f->isOfType(SoSFNode::getClassTypeId())) {
		haveAlternateRep = TRUE;
		SoSFNode *alternateRepField = (SoSFNode *)f;
		SoNode *n = alternateRepField->getValue();
		if (n != NULL)
		    addChild(n);
	    }
            break;
        }
    }

    // If no alternateRep was specified, look for a field named "isA"
    // of type MFString and try to automatically create an
    // alternateRep:
    if (!haveAlternateRep) for (i=0; i<num; i++) {
        if (instanceFieldData->getFieldName(i) == SbName("isA")) {
	    SoField *f = instanceFieldData->getField(this, i);
	    if (f->isOfType(SoMFString::getClassTypeId())) {
		createFromIsA((SoMFString *)f);
	    }
	}
    }

    return result;
}