コード例 #1
0
	void CPropBrowserCtrl::setupProperties( const std::string &type, const CInterfaceElement *element )
	{
		std::map< std::string, SWidgetInfo >::iterator itr = widgetInfo.find( type );
		if( itr == widgetInfo.end() )
			return;
		SWidgetInfo &w = itr->second;

		std::vector< SPropEntry >::const_iterator pItr;
		for( pItr = w.props.begin(); pItr != w.props.end(); ++pItr )
		{
			const SPropEntry &prop = *pItr;
			setupProperty( prop, element );
		}

		QtVariantEditorFactory *factory = new QtVariantEditorFactory;
		browser->setFactoryForManager( propertyMgr, factory );
	}
コード例 #2
0
UInt32
ColladaGeometry::setupGeometry(const domInputLocal_Array       &vertInputs,
                               const domInputLocalOffset_Array &inputs,
                               xsNCName                         matSymbol,
                               IndexStore                      &idxStore   )
{
    OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry\n"));

    typedef std::vector<UInt32>             UnhandledStore;
    typedef UnhandledStore::const_iterator  UnhandledStoreConstIt;

    Int32          vertInputIndex       = -1;  // <input> with sem "VERTEX"
    UnhandledStore unhandledVertInputs;
    UnhandledStore unhandledInputs;

    UInt32 geoIdx = _geoStore.size();
    _geoStore.push_back(GeoInfo());

    if(matSymbol != NULL)
    {
        _geoStore[geoIdx]._matSymbol = matSymbol;
    }
    else
    {
        SWARNING << "ColladaGeometry::setupGeometry: "
                 << "Found empty material symbol." << std::endl;
    }

    for(UInt32 i = 0; i < inputs.getCount(); ++i)
    {
        std::string semantic = inputs[i]->getSemantic();
        UInt32      set      = inputs[i]->getSet     ();
        UInt32      offset   = inputs[i]->getOffset  ();
        std::string sourceId = inputs[i]->getSource  ().id();

        OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry: input [%d] "
                         "semantic [%s] set [%d] offset [%d] - source [%s]\n",
                         i, semantic.c_str(), set, offset, sourceId.c_str()));

        if(semantic == "VERTEX")
        {
            // handle <input> tag with semantic "VERTEX"
            // by processing vertInputs, i.e. the <vertices> tag

            vertInputIndex = i;

            // all vertInputs use the same index - with the offset from the
            // <input> with semantic == VERTEX
            if(offset >= idxStore.size() || idxStore[offset] == NULL)
            {
                OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry: "
                                 "new index property for offset [%d]\n",
                                 offset));

                // new index
                idxStore.resize(
                    osgMax<UInt32>(offset + 1, idxStore.size()), NULL);
                idxStore[offset] = GeoUInt32Property::create();
            }

            for(UInt32 j = 0; j < vertInputs.getCount(); ++j)
            {
                semantic = vertInputs[j]->getSemantic();
                sourceId = vertInputs[j]->getSource  ().id();

                OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry: vertices [%d] "
                                 "semantic [%s] - source [%s]\n",
                                 j, semantic.c_str(), sourceId.c_str()));

                UInt32 propIdx = mapSemantic(semantic, 0, geoIdx);

                if(propIdx == Geometry::MaxAttribs)
                {
                    unhandledVertInputs.push_back(j);
                }
                else
                {
                    setupProperty(geoIdx, propIdx, semantic, set, sourceId,
                                  idxStore[offset]                         );
                }
            }
        }
        else
        {
            // handle regular <input> tags

            if(offset >= idxStore.size() || idxStore[offset] == NULL)
            {
                OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry: "
                                 "new index property for offset [%d]\n",
                                 offset));

                // new index
                idxStore.resize(osgMax<UInt32>(offset + 1, idxStore.size()), NULL);
                idxStore[offset] = GeoUInt32Property::create();
            }

            UInt32 propIdx = mapSemantic(semantic, set, geoIdx);

            if(propIdx == Geometry::MaxAttribs)
            {
                unhandledInputs.push_back(i);
            }
            else
            {
                setupProperty(geoIdx, propIdx, semantic, set, sourceId,
                              idxStore[offset]                         );
            }
        }
    }

    // some <inputs> could not be handled above because their
    // semantic was not recognized.
    // after everything else is set put them into free attribute
    // slots, starting at Geometry::TexCoordsIndex

    UnhandledStoreConstIt uhIt  = unhandledVertInputs.begin();
    UnhandledStoreConstIt uhEnd = unhandledVertInputs.end  ();

    for(; uhIt != uhEnd; ++uhIt)
    {
        std::string semantic = vertInputs[*uhIt         ]->getSemantic();
        UInt32      set      = inputs    [vertInputIndex]->getSet     ();
        UInt32      offset   = inputs    [vertInputIndex]->getOffset  ();
        std::string sourceId = vertInputs[*uhIt         ]->getSource  ().id();

        UInt32 propIdx = findFreePropertyIndex(geoIdx);

        OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry: unhandled vertex "
                         " <input> [%d] semantic [%s] set [%d] offset [%d] - "
                         "source [%s] mapped to propIdx [%d]\n",
                         *uhIt, semantic.c_str(), set, offset, sourceId.c_str(),
                         propIdx));

        setupProperty(geoIdx, propIdx, semantic, set, sourceId,
                      idxStore[offset]                         );
    }

    uhIt  = unhandledInputs.begin();
    uhEnd = unhandledInputs.end  ();

    for(; uhIt != uhEnd; ++uhIt)
    {
        std::string semantic = inputs[*uhIt]->getSemantic();
        UInt32      set      = inputs[*uhIt]->getSet     ();
        UInt32      offset   = inputs[*uhIt]->getOffset  ();
        std::string sourceId = inputs[*uhIt]->getSource  ().id();

        UInt32 propIdx = findFreePropertyIndex(geoIdx);

        OSG_COLLADA_LOG(("ColladaGeometry::setupGeometry: unhandled <input> "
                         "[%d] semantic [%s] set [%d] offset [%d] - "
                         "source [%s] mapped to propIdx [%d]\n",
                         *uhIt, semantic.c_str(), set, offset, sourceId.c_str(),
                         propIdx));

        setupProperty(geoIdx, propIdx, semantic, set, sourceId,
                      idxStore[offset]                         );
    }

#ifdef OSG_DEBUG
    // check for holes in idxStore - which is not supported
    IndexStoreConstIt idxIt  = idxStore.begin();
    IndexStoreConstIt idxEnd = idxStore.end  ();

    for(UInt32 i = 0; idxIt != idxEnd; ++idxIt, ++i)
    {
        if(*idxIt == NULL)
        {
            SWARNING << "ColladaGeometry::setupGeometry: idxStore contains "
                     << "hole at [" << i << "]" << std::endl;
        }
    }
#endif

    _geoStore[geoIdx]._lengths = GeoUInt32Property::create();
    _geoStore[geoIdx]._types   = GeoUInt8Property ::create();

    return geoIdx;
}