Beispiel #1
0
void FilterThread::run()
{
    try
    {
        Env env;
        QScriptValue val = env.loadMLScriptEnv(_md,_pm);
        if (val.isError())
            throw JavaScriptException("A Plugin-bridge-code generated a JavaScript Error: " + val.toString() + "\n");

        QMap<QString,MeshLabXMLFilterContainer>::iterator it =_pm.stringXMLFilterMap.find(_fname);
        if ((it == _pm.stringXMLFilterMap.end()) || (it->xmlInfo == NULL))
            throw MeshLabException("Filter " + _fname + " has not been found.\n");
        if (it->filterInterface != NULL)
        {

            it->filterInterface->glContext = new QGLContext(QGLFormat::defaultFormat(),_glwid->context()->device());
            it->filterInterface->glContext->create(_glwid->context());
            for (QMap<QString,QString>::const_iterator itp = _parexpval.constBegin();itp != _parexpval.constEnd();++itp)
                env.insertExpressionBinding(itp.key(),itp.value());
            EnvWrap envwrap(env);
            _cur = this;
            _success = it->filterInterface->applyFilter(_fname, _md, envwrap, &localCallBack);
            _cur = NULL;

            delete it->filterInterface->glContext;
        }
        else
            throw MeshLabException("There is not yet support for not-C++ filters.");
    }
    catch (MeshLabException& e)
    {
        _md.Log.Log(GLLogStream::SYSTEM,e.what());
    }
}
void MLSceneGLSharedDataContext::initializeGL()
{
    glewExperimental=GL_TRUE;
    makeCurrent();
    GLenum err = glewInit();
    doneCurrent();
    if (err != GLEW_OK ) {
        throw MeshLabException("MLSceneGLSharedDataContext: GLEW initialization failed\n");
    }
    
}
void PluginGeneratorGUI::executeCurrentCode()
{
	Env env;
	if (doc != NULL)
	{
		QScriptValue res = env.loadMLScriptEnv(*doc,PM);
		if (res.isError())
			throw JavaScriptException("A Plugin-bridge-code generated a JavaScript Error: " + res.toString() + "\n");
		FilterGeneratorTab* ftab = tab(tabs->currentIndex());
		if (ftab != NULL)
		{
			QTime t;
			t.start();
			QScriptValue result = env.evaluate(ftab->getCode());
			int time = t.elapsed();
			emit scriptCodeExecuted(result,time,env.output());
		}
		else
			throw MeshLabException("System Error: A FilterGeneratorTab object has been expected.");
	}
	else
		throw MeshLabException("System Error: A valid MeshLabDocument has not correctly been associated with PluginGeneratorGUI. Code cannot be executed.");
}
Beispiel #4
0
void XMLStdParFrame::loadFrameContent(const MLXMLPluginInfo::XMLMapList& parMap,EnvWrap& envir)
{
	MeshLabXMLStdDialog* dialog = qobject_cast<MeshLabXMLStdDialog*>(parent());
	if (dialog == NULL)
		throw MeshLabException("An XMLStdParFrame has not a MeshLabXMLStdDialog's parent");
	QGridLayout* glay = new QGridLayout();
	int ii = 0;
	for(MLXMLPluginInfo::XMLMapList::const_iterator it = parMap.constBegin();it != parMap.constEnd();++it)
	{
		XMLMeshLabWidget* widg = XMLMeshLabWidgetFactory::create(*it,envir,dialog->curMeshDoc,this);
		if (widg == NULL)
			return;
		xmlfieldwidgets.push_back(widg); 
		helpList.push_back(widg->helpLabel());
		widg->addWidgetToGridLayout(glay,ii);
		++ii;
	}
	setLayout(glay);
	//showNormal();
	updateGeometry();
	adjustSize();
}
MLSceneGLSharedDataContext::MLSceneGLSharedDataContext(MeshDocument& md,vcg::QtThreadSafeMemoryInfo& gpumeminfo,bool highprecision,size_t perbatchtriangles) 
    :QGLWidget(),_md(md),_gpumeminfo(gpumeminfo),_perbatchtriangles(perbatchtriangles),_highprecision(highprecision)
{
    if (md.size() != 0)
        throw MeshLabException(QString("MLSceneGLSharedDataContext: MeshDocument is not empty when MLSceneGLSharedDataContext is constructed."));
}