void ParserMgr::AssociateVars(mu::Parser& parser) { #ifdef DEBUG_PM_FUNC ScopeTracker st("ParserMgr::AssociateVars", std::this_thread::get_id()); #endif try { for (size_t i=0; i<ds::NUM_MODELS; ++i) { const ParamModelBase* model = _modelMgr->Model((ds::PMODEL)i); if (model->Id()==ds::INIT || model->Id()==ds::COND) continue; double* data = _modelData[i].first, * temp_data = _modelData[i].second; const size_t num_pars = model->NumPars(); for (size_t j=0; j<num_pars; ++j) { const std::string& key = model->ShortKey(j); parser.DefineVar(key, &data[j]); if (model->DoEvaluate()) parser.DefineVar(model->TempKey(j), &temp_data[j]); } } } catch (mu::ParserError& e) { _log->AddExcept("ParserMgr::AssociateVars: " + AnnotateErrMsg(e.GetMsg(), parser)); } }
VoxelOp( std::string expr ) { parser.SetExpr( expr ); parser.DefineVar( std::string( "vox" ), &voxBuff ); parser.DefineVar( std::string( "pos_x" ), &posBuff[data::rowDim] ); parser.DefineVar( std::string( "pos_y" ), &posBuff[data::columnDim] ); parser.DefineVar( std::string( "pos_z" ), &posBuff[data::sliceDim] ); parser.DefineVar( std::string( "pos_t" ), &posBuff[data::timeDim] ); }
//initialize muparser and graphics void init() { p.DefineVar("theta", &t); p.DefineConst("pi", pi); graph.create(size,size,sf::Color::Transparent); graphTx.loadFromImage(graph); graphSpr.setTexture(graphTx); //center on screen graphSpr.setOrigin(size/2,size/2); graphSpr.setPosition(windowsize.x/2, windowsize.y/2); }
//constructor Func(std::string tag, int speed_in, int line_width_in, double tmax_in, double tinc_in, double rotation_in, sf::Color color_in ) : speed( speed_in ), line_width(line_width_in), t (0), tmax ( tmax_in ), tinc ( tinc_in ), rotation( rotation_in ), color ( color_in ) { p.DefineVar("theta", &t); p.SetExpr(tag); }