Exemplo n.º 1
0
OSG_USING_NAMESPACE

// Documentation for this class is emited in the
// OSGProxyGroupBase.cpp file.
// To modify it, please change the .fcd file (OSGProxyGroup.fcd) and
// regenerate the base file.

/*-------------------------------------------------------------------------*/
/*                               Sync                                      */

void ProxyGroup::changed(ConstFieldMaskArg whichField, 
                         UInt32            origin,
                         BitVector         details)
{
    if(whichField & (UrlFieldMask))
    {
        if(getAbsoluteUrl().empty())
        {
            PathHandler *ph = SceneFileHandler::the()->getPathHandler();

            if(ph != NULL) 
            {
                setAbsoluteUrl(ph->findFile(getUrl().c_str()));
            }

            if(getAbsoluteUrl().empty())
            {
                setAbsoluteUrl(getUrl());
            }

            setState(NOT_LOADED);
        }
    }
    if(whichField & (StateFieldMask |
                     UrlFieldMask   |
                     VolumeFieldMask))
    {
        for(UInt32 i = 0; i < _mfParents.size(); i++)
        {
            _mfParents[i]->invalidateVolume();
        }
    }

    Inherited::changed(whichField, origin, details);
}
Exemplo n.º 2
0
void ProxyGroup::startLoading(void)
{
#ifdef OSG_OLD_RENDER_ACTION
    if(getConcurrentLoad() == false)
    {
        if(getMFInline()->size() == 0)
        {
            _loadedRoot = SceneFileHandler::the()->read(
                getAbsoluteUrl().c_str());
        }
        else
        {
            std::stringstream tmpStream(std::ios_base::in    |
                                        std::ios_base::out   |
                                        std::ios_base::binary);

            tmpStream.write(
                reinterpret_cast<const char*>(&getMFInline()->front()), 
                getMFInline()->size ());

            _loadedRoot = SceneFileHandler::the()->read(tmpStream, "osb");
        }

        setState(LOAD_THREAD_FINISHED);
    }
    else
    {
        if(_loadLock == NULL)
        {
            _loadLock = Lock::get("ProxyGroupLoadLock");
        }

        _loadLock->acquire();
        
        bool noThread = _loadQueue.empty();
        
        _loadQueue.push(this);

        setState(LOAD_THREAD_RUNNING);
        
        _loadLock->release();
        
        if(noThread)
        {
            if(_loadThread)
                BaseThread::join(_loadThread);

            _loadThread = dynamic_cast<Thread *>(
                ThreadManager::the()->getThread(NULL));

            _loadThread->runFunction(loadProc, 
                                     Thread::getCurrentAspect(),
                                     NULL                     );
        }
    }
#endif
}
Exemplo n.º 3
0
void HttpReqImpl::redirect(ConstStrA url, int code) {
	if (code == 0) {
		if (url.head(1) == ConstStrA('+')) code = 301;
		else code = 307;
	}


	TextParser<char> parser;
	if (parser("%[a-z]0://%",url)) {
		header(fldLocation, url);
	} else {
		StringA absurl = getAbsoluteUrl(url);
		header(fldLocation, absurl);
	}
	header(fldContentLength, "0");
	status(code);
	sendHeaders();

}
Exemplo n.º 4
0
Action::ResultE ProxyGroup::render(Action *action)
{
    DrawActionBase *da        = dynamic_cast<DrawActionBase *>(action);

    if(getEnabled() == false)
        return Action::Continue;

    if(getState() == NOT_LOADED)
        startLoading();

    if(getState() == LOAD_THREAD_FINISHED)
    {
        if(_loadedRoot != NULL)
        {
            _loadThread = NULL;

            setRoot(_loadedRoot);

            getRoot()->invalidateVolume();
            getRoot()->updateVolume();


            setState(LOADED);

            da->getActNode()->invalidateVolume();
            da->getActNode()->updateVolume    ();
        }
        else
        {
            SWARNING << "failed to load " << getAbsoluteUrl() << std::endl;

            setState(LOAD_ERROR);
        }
    }

    if(getState() == LOADED)
    {
        da->useNodeList();

        if(da->isVisible(getCPtr(getRoot())))
            da->addNode(getRoot());
    }
    else
    {
        if(da->getActNode()->getNChildren() == 0)
        {
            Color3f col;
            col.setValuesRGB(.5,.3,0);            

            dropVolume(da, da->getActNode(), col);
        }
    }

    // thread cleanup
    if(_loadThread && _loadQueue.empty())
    {
        printf("join\n");
        BaseThread::join(_loadThread);
        _loadThread = NULL;
    }

    return Action::Continue;
}