void RoundedRect::parseXml(QDomElement element , QPointF origin) { this->setPos(element.attribute("x").toDouble() + origin.x(),element.attribute("y").toDouble()+origin.y()); this->setSize(element.attribute("w").toDouble(),element.attribute("h").toDouble()); this->setpenWidth(element.attribute("PenWidth").toDouble()); this->setpenColor(ColorFromString(element.attribute("PenColor"))); this->setcolor1(ColorFromString(element.attribute("Color1"))); this->setcolor2(ColorFromString(element.attribute("Color2"))); this->setuseGradient( element.attribute("GradientUsed").toDouble()); this->setGradientDirection(element.attribute("GradientDirection")== "V" ? Vertical : Horizontal); this->setRadiousX(element.attribute("RadiousX").toDouble()); this->setRadiousY(element.attribute("RadiousY").toDouble()); }
void ReportLine::parseXml(QDomElement element , QPointF origin) { this->setPos(element.attribute("x").toDouble() + origin.x(),element.attribute("y").toDouble()+origin.y()); this->setSize(element.attribute("w").toDouble(),element.attribute("h").toDouble()); this->setpenWidth(element.attribute("penWidth").toDouble()); this->setpenColor(ColorFromString(element.attribute("penColor"))); this->setpenStyle(static_cast<Qt::PenStyle>(element.attribute("penStyle").toDouble())); element.attribute("Orientacion") == "V" ? setOrientacion(Vertical) : setOrientacion(Horizontal); }
void IProperty::SetValueFromString(IString value) { if (m_pVar) { switch (m_iType) { case IPT_BOOL: *((bool*)m_pVar)=BoolFromString(value); break; case IPT_INTEGER: *((int*)m_pVar)=Iatof(value); break; case IPT_FLOAT: *((float*)m_pVar)=Iatof(value); break; case IPT_VEC2: *((IVector2D*)m_pVar)=Vector2DFromString(value); break; case IPT_VEC3: *((IVector3D*)m_pVar)=Vector3DFromString(value); break; case IPT_COLOR: *((IColor*)m_pVar)=ColorFromString(value); break; case IPT_STRING: case IPT_LONG_STRING: *((IString*)m_pVar)=value; break; case IPT_CHOICE: *((int*)m_pVar)=Iatof(value); break; case IPT_RESSOURCE_ITX: // Texture //if (m_pMaterial) //m_pObject->getde //(ISmartPtr<ITexture>*)m_pVar) //(ISmartPtr<ITexture>*)m_pVar) = m_pDevice->getress //((Format::IImageITX*)m_pVar); *((IString*)m_pVar)=value; break; case IPT_RESSOURCE_IMA: // Material break; case IPT_RESSOURCE_IEM: // Animated mesh break; } } }
void RelationalField::parseXml(QDomElement element, QPointF origin) { this->setPos(element.attribute("x").toDouble() + origin.x(),element.attribute("y").toDouble()+origin.y()); this->setSize(element.attribute("w").toDouble(),element.attribute("h").toDouble()); this->setsql(element.attribute("Sql")); this->setexpandable(element.attribute("Expandable").toDouble()); element.attribute("Alineacion") == "L" ? setAlineacion(Left) : element.attribute("Alineacion") == "R" ? setAlineacion(Rigth): setAlineacion(Center); this->setfontFamily(element.attribute("fontFamily")); this->setfontSize(element.attribute("fontSize").toDouble()); this->setfontWeigth(element.attribute("fontWeigth").toDouble()); this->setitalicFont(element.attribute("italicFont").toDouble()); this->setunderlined(element.attribute("underlined").toDouble()); this->setfontColor(ColorFromString(element.attribute("color"))); this->setformato(element.attribute("formato").toDouble()); this->setName(element.attribute("name")); }
std::string EGTPEngine::parse(std::string input) { //Only returns in ifs on failure or on special responses. standard ack response returned if nothing else. LOG_VERBOSE<<"Attempting to parse EGTP input "<<input<<std::endl; std::vector<std::string> args; boost::split(args, input,boost::is_any_of( " " )); std::stringstream ss; if(args[0] == "e_request") { std::cout<<"Got req"<<std::endl; if(args[1] != "1") exit(EXIT_FAILURE); } else if(args[0] == "e_randmoves") { for(int i = 1; i<args.size(); ++i) { preselRandMoves.push_back(atoi(args[i].c_str())); } } else if(args[0] == "e_useai") //Usage: e_useai [ran|mc|ucb|uct] [ai specific args] { if(args[1] == "ucb" || args[1] == "mc" || atoi(args[1].c_str()) == UCB || atoi(args[1].c_str()) == MC ) //args: e_useai ucb [random moves] [t|s] [time in sec|num simulations] //t uses time, s uses simulations { aiType = args[1] == "ucb" ? UCB : MC; if(atoi(args[1].c_str()) == UCB) aiType = UCB; if(atoi(args[1].c_str()) == MC) aiType == MC; if(args[2] == "t") //Time alloc timeAlloc = atoi(args[3].c_str()); if(args[2] == "s") //simulations simulations = atoi(args[3].c_str()); } else if(args[1] == "rand" || atoi(args[1].c_str()) == RAN) aiType = RAN; std::cout<<"Got AI type: "<<args[1]<<std::endl; std::cout<<"Got time alloc: "<<timeAlloc<<std::endl; } else if(args[0]=="e_ping") { //Simply return ack response. No effect. Used to check alive connection } else if(args[0]=="genmove") { std::cout<<"Got genmove"<<aiType<<std::endl; std::cout<<RAN<<MC<<UCB<<std::endl; if(aiType == UCB || aiType == MC) { std::vector<UCBrow> ucbr; switch(aiType) { case(UCB): { UpperConfidence ucb(preselRandMoves,simulations); if(timeAlloc != -1) { std::cout << "Simulation uses time: "<<timeAlloc<<" seconds"<<std::endl; ucb.playUntilStopped = true; boost::thread wt(boost::bind(&EGTPEngine::genmoveTimer,this,timeAlloc,&ucb)); std::cout<< "Timer started "<<&ucb<<std::endl; } ucbr = ucb.generateUCBTable(ColorFromString(args[1]),game); break; } case(MC): { MonteCarlo mc(numRandMoves,simulations); ucbr = mc.generateMCTable(preselRandMoves,ColorFromString(args[1]),game); break; } } ss << "ucbtable:"; for(int i = 0; i<ucbr.size();++i) { ss<<ucbr[i].pos<<","<<ucbr[i].expected<<","<<ucbr[i].timesPlayed<<";"; } game->Board->reset(); preselRandMoves.clear(); ss<<"\n"; } else if(aiType == RAN) { SimpleRandomAI rand; const GoPoint p = rand.generateMove(ColorFromString(args[1]),game); std::stringstream ss1; ss1<<"rand:"<<game->Board->ReadablePosition(p)<<"\n"; std::cout<<"Rand move: "<<ss1.str()<<std::endl; ss<<ss1.str()<<"\n"; } } else { int oldLog = LogLevel; LogLevel = SILENT; std::vector<std::string> ret = GTPEngine::parse(input); LogLevel = oldLog; } return ss.str(); }