void CKnownFileList::Process() { if (::GetTickCount() - m_nLastSaved > MIN2MS(11)) Save(); }
bool Section::Save(std::string strFilePath) { FILE* pFile = fopen(strFilePath.c_str(), "w+"); return Save(pFile); }
// close without header update bool Close(bool fHeaderUpdate) { if (fHeaderUpdate) return C4Group::Close(); else { bool fSuccess = Save(false); Clear(); return fSuccess; } }
int scaleSmearTemplateFit_Muon(TString RDFile, TString MCFile, char BaseName[30]) { cout<<"Processing "<<BaseName<<endl; gStyle->SetPalette(1); //Output file TString ResultDir = "MCRDfitMu_Plot"; ofstream Fout; TString FoutName=ResultDir+"/"+BaseName+"_SummaryFinal.txt"; Fout.open(FoutName); //Variables char histName[50]; //Data and histograms TFile *f_RD = new TFile(RDFile); TFile *f_MC = new TFile(MCFile); TH1D *h1_ZmassDaughEtaRD[ScMuCombiBins]; TH1D *h1_ZmassDaughEtaMC[ScMuCombiBins]; //Plots RooPlot *zmassFrameRD; RooPlot *zmassFrameMC; CPlot *plotFitRD; CPlot *plotFitMC; RooFitResult* fitResTotalMC; RooFitResult* fitResTotalRD; //RooFitResult* fitResRD; RooFitResult* fitResMCbw[ScMuCombiBins]; RooFitResult* fitResMC[ScMuCombiBins]; RooFitResult* fitResRD[ScMuCombiBins]; TCanvas *myCan = MakeCanvas("myCan","myCan",800,600); //Fitting stuff RooRealVar *scaleMC[ScaleBins-1]; RooRealVar *scaleRD[ScaleBins-1]; RooRealVar *smearRD[ScaleBins-1]; RooRealVar *smearMC[ScaleBins-1]; RooRealVar *nSRD[ScMuCombiBins]; RooRealVar *nBRD[ScMuCombiBins]; RooRealVar *CBalpha[ScMuCombiBins]; RooRealVar *CBn[ScMuCombiBins]; RooFormulaVar *scaleScaleMC[ScMuCombiBins]; RooFormulaVar *scaleScaleRD[ScMuCombiBins]; RooFormulaVar *smearSmearMC[ScMuCombiBins]; RooFormulaVar *smearSmearRD[ScMuCombiBins]; RooRealVar zMass("zMass","zMass",60,120); RooCategory rooCat("rooCat","rooCat"); RooDataHist *ZmassRD[ScMuCombiBins]; // RooDataHist *ZmassMC; RooDataHist *ZmassMC[ScMuCombiBins]; // CBreitWigner *BW[ScMuCombiBins]; CBreitWignerConvCrystalBall *BWCB[ScMuCombiBins]; CBreitWignerConvCrystalBallScale *BWCBsCale[ScMuCombiBins]; CBreitWignerMC *BWMC[ScMuCombiBins]; CBreitWignerRD *BWRD[ScMuCombiBins]; RooGaussian *gaus[ScMuCombiBins]; RooCBShape *cbMC[ScMuCombiBins]; RooCBShape *cbRD[ScMuCombiBins]; CErfExpo *ZbgRD[ScMuCombiBins]; CExponential *ZbgExpRD[ScMuCombiBins]; RooAbsPdf *pdfRDsig[ScMuCombiBins]; RooAbsPdf *pdfMCsig[ScMuCombiBins]; //RooAddPdf *pdfRDsig[ScMuCombiBins]; RooAbsPdf *histPdf[ScMuCombiBins]; RooAddPdf *pdfRD[ScMuCombiBins]; //Initialization for(int i(0);i<ScaleBins-1;i++) { sprintf(histName,"scaleMC_%d",i); scaleMC[i] = new RooRealVar(histName, histName,1.01,0.001,3); sprintf(histName,"scaleRD_%d",i); scaleRD[i] = new RooRealVar(histName, histName,1.01,0.001,3); sprintf(histName,"smearMC_%d",i); smearMC[i] = new RooRealVar(histName,histName,0.5,0.01,3); sprintf(histName,"smearRD_%d",i); smearRD[i] = new RooRealVar(histName,histName,0.5,0.01,3); } for(int i(0);i<ScMuCombiBins;i++) { sprintf(histName,"nBRD_%d",i); nBRD[i] = new RooRealVar(histName, histName,0.1,0.01,1); sprintf(histName,"nSRD_%d",i); nSRD[i]= new RooRealVar(histName,histName,1,0,2); sprintf(histName,"CBalpha_%d",i); CBalpha[i]= new RooRealVar(histName,histName,5,0,20); sprintf(histName,"CBn_%d",i); CBn[i] = new RooRealVar(histName,histName,1,0,10); sprintf(histName,"cat_%d",i); rooCat.defineType(histName); } RooSimultaneous pdfTotalMC("pdfTotalMC","pdfTotalMC",rooCat); map<string,TH1*>hmapMC; RooSimultaneous pdfTotalRD("pdfTotalRD","pdfTotalRD",rooCat); map<string,TH1*>hmapRD; //* ///scaleScale sprintf(histName,"scaleScaleMC_0"); scaleScaleMC[0] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleMC[0],*scaleMC[0])); sprintf(histName,"scaleScaleMC_1"); scaleScaleMC[1] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[0],*scaleMC[1])); sprintf(histName,"scaleScaleMC_2"); scaleScaleMC[2] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[0],*scaleMC[2])); sprintf(histName,"scaleScaleMC_3"); scaleScaleMC[3] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[0],*scaleMC[3])); sprintf(histName,"scaleScaleMC_4"); scaleScaleMC[4] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[0],*scaleMC[4])); sprintf(histName,"scaleScaleMC_5"); scaleScaleMC[5] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleMC[1],*scaleMC[1])); sprintf(histName,"scaleScaleMC_6"); scaleScaleMC[6] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[1],*scaleMC[2])); sprintf(histName,"scaleScaleMC_7"); scaleScaleMC[7] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[1],*scaleMC[3])); sprintf(histName,"scaleScaleMC_8"); scaleScaleMC[8] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[1],*scaleMC[4])); sprintf(histName,"scaleScaleMC_9"); scaleScaleMC[9] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleMC[2],*scaleMC[2])); sprintf(histName,"scaleScaleMC_10"); scaleScaleMC[10] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[2],*scaleMC[3])); sprintf(histName,"scaleScaleMC_11"); scaleScaleMC[11] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[2],*scaleMC[4])); sprintf(histName,"scaleScaleMC_12"); scaleScaleMC[12] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleMC[3],*scaleMC[3])); sprintf(histName,"scaleScaleMC_13"); scaleScaleMC[13] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleMC[3],*scaleMC[4])); sprintf(histName,"scaleScaleMC_14"); scaleScaleMC[14] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleMC[4],*scaleMC[4])); //*/ //* ///scaleScale sprintf(histName,"scaleScaleRD_0"); scaleScaleRD[0] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleRD[0],*scaleRD[0])); sprintf(histName,"scaleScaleRD_1"); scaleScaleRD[1] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[0],*scaleRD[1])); sprintf(histName,"scaleScaleRD_2"); scaleScaleRD[2] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[0],*scaleRD[2])); sprintf(histName,"scaleScaleRD_3"); scaleScaleRD[3] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[0],*scaleRD[3])); sprintf(histName,"scaleScaleRD_4"); scaleScaleRD[4] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[0],*scaleRD[4])); sprintf(histName,"scaleScaleRD_5"); scaleScaleRD[5] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleRD[1],*scaleRD[1])); sprintf(histName,"scaleScaleRD_6"); scaleScaleRD[6] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[1],*scaleRD[2])); sprintf(histName,"scaleScaleRD_7"); scaleScaleRD[7] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[1],*scaleRD[3])); sprintf(histName,"scaleScaleRD_8"); scaleScaleRD[8] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[1],*scaleRD[4])); sprintf(histName,"scaleScaleRD_9"); scaleScaleRD[9] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleRD[2],*scaleRD[2])); sprintf(histName,"scaleScaleRD_10"); scaleScaleRD[10] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[2],*scaleRD[3])); sprintf(histName,"scaleScaleRD_11"); scaleScaleRD[11] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[2],*scaleRD[4])); sprintf(histName,"scaleScaleRD_12"); scaleScaleRD[12] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleRD[3],*scaleRD[3])); sprintf(histName,"scaleScaleRD_13"); scaleScaleRD[13] = new RooFormulaVar(histName,"1/sqrt(@0*@1)",RooArgSet(*scaleRD[3],*scaleRD[4])); sprintf(histName,"scaleScaleRD_14"); scaleScaleRD[14] = new RooFormulaVar(histName,"1/sqrt(@0*@0)",RooArgSet(*scaleRD[4],*scaleRD[4])); //*/ //* ///smearSmear sprintf(histName,"smearSmearMC_0"); smearSmearMC[0] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearMC[0],*smearMC[0])); sprintf(histName,"smearSmearMC_1"); smearSmearMC[1] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[0],*smearMC[1])); sprintf(histName,"smearSmearMC_2"); smearSmearMC[2] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[0],*smearMC[2])); sprintf(histName,"smearSmearMC_3"); smearSmearMC[3] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[0],*smearMC[3])); sprintf(histName,"smearSmearMC_4"); smearSmearMC[4] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[0],*smearMC[4])); sprintf(histName,"smearSmearMC_5"); smearSmearMC[5] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearMC[1],*smearMC[1])); sprintf(histName,"smearSmearMC_6"); smearSmearMC[6] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[1],*smearMC[2])); sprintf(histName,"smearSmearMC_7"); smearSmearMC[7] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[1],*smearMC[3])); sprintf(histName,"smearSmearMC_8"); smearSmearMC[8] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[1],*smearMC[4])); sprintf(histName,"smearSmearMC_9"); smearSmearMC[9] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearMC[2],*smearMC[2])); sprintf(histName,"smearSmearMC_10"); smearSmearMC[10] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[2],*smearMC[3])); sprintf(histName,"smearSmearMC_11"); smearSmearMC[11] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[2],*smearMC[4])); sprintf(histName,"smearSmearMC_12"); smearSmearMC[12] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearMC[3],*smearMC[3])); sprintf(histName,"smearSmearMC_13"); smearSmearMC[13] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearMC[3],*smearMC[4])); sprintf(histName,"smearSmearMC_14"); smearSmearMC[14] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearMC[4],*smearMC[4])); //*/ //* ///smearSmear sprintf(histName,"smearSmearRD_0"); smearSmearRD[0] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearRD[0],*smearRD[0])); sprintf(histName,"smearSmearRD_1"); smearSmearRD[1] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[0],*smearRD[1])); sprintf(histName,"smearSmearRD_2"); smearSmearRD[2] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[0],*smearRD[2])); sprintf(histName,"smearSmearRD_3"); smearSmearRD[3] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[0],*smearRD[3])); sprintf(histName,"smearSmearRD_4"); smearSmearRD[4] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[0],*smearRD[4])); sprintf(histName,"smearSmearRD_5"); smearSmearRD[5] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearRD[1],*smearRD[1])); sprintf(histName,"smearSmearRD_6"); smearSmearRD[6] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[1],*smearRD[2])); sprintf(histName,"smearSmearRD_7"); smearSmearRD[7] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[1],*smearRD[3])); sprintf(histName,"smearSmearRD_8"); smearSmearRD[8] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[1],*smearRD[4])); sprintf(histName,"smearSmearRD_9"); smearSmearRD[9] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearRD[2],*smearRD[2])); sprintf(histName,"smearSmearRD_10"); smearSmearRD[10] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[2],*smearRD[3])); sprintf(histName,"smearSmearRD_11"); smearSmearRD[11] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[2],*smearRD[4])); sprintf(histName,"smearSmearRD_12"); smearSmearRD[12] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearRD[3],*smearRD[3])); sprintf(histName,"smearSmearRD_13"); smearSmearRD[13] = new RooFormulaVar(histName,"sqrt(@0*@0+@1*@1)",RooArgSet(*smearRD[3],*smearRD[4])); sprintf(histName,"smearSmearRD_14"); smearSmearRD[14] = new RooFormulaVar(histName,"sqrt(@0*@0+@0*@0)",RooArgSet(*smearRD[4],*smearRD[4])); //*/ RooRealVar gaussMean("gaussMean","gaussMean",0); gaussMean.setConstant(kTRUE); RooRealVar CBMean("CBMean","CBMean",0); CBMean.setConstant(kTRUE); for(int i(0);i<ScMuCombiBins;i++) { //Getting histogram from RD & MC sprintf(histName,"h1_ZmassDaughEtaMu_%d",i); h1_ZmassDaughEtaMC[i] = (TH1D*)f_MC->Get(histName)->Clone(histName); h1_ZmassDaughEtaRD[i] = (TH1D*)f_RD->Get(histName)->Clone(histName); sprintf(histName,"ZmassRD_%d",i); ZmassRD[i] = new RooDataHist(histName,histName,RooArgSet(zMass),h1_ZmassDaughEtaRD[i]); sprintf(histName,"cat_%d",i); hmapMC[histName] = h1_ZmassDaughEtaMC[i]; sprintf(histName,"cat_%d",i); hmapRD[histName] = h1_ZmassDaughEtaRD[i]; // Making template from MC sprintf(histName,"ZmassMC_%d",i); ZmassMC[i] = new RooDataHist(histName,histName,RooArgSet(zMass),h1_ZmassDaughEtaMC[i]); sprintf(histName,"cbMC_%d",i); cbMC[i] = new RooCBShape(histName,histName,zMass,CBMean,*smearSmearMC[i],*CBalpha[i],*CBn[i]); sprintf(histName,"BWMC_%d",i); BWMC[i] = new CBreitWignerMC(histName,zMass, scaleScaleMC[i]); sprintf(histName,"pdfMCsig_%d",i); pdfMCsig[i] = new RooFFTConvPdf(histName,histName,zMass,*(BWMC[i]->model),*cbMC[i]); //Making RD pdf // sprintf(histName,"gaus_%d",i); // gaus[i] = new RooGaussian(histName,histName,zMass,gaussMean,*smearSmearRD[i]); // sprintf(histName,"BWCBsCale_%d",i); // BWCBsCale[i] = new CBreitWignerConvCrystalBallScale // (histName,zMass, scaleScaleRD[i], // BWCB[i]->mean->getVal(),BWCB[i]->sigma->getVal(),BWCB[i]->alpha->getVal(),BWCB[i]->n->getVal()); //* sprintf(histName,"cbRD_%d",i); cbRD[i] = new RooCBShape(histName,histName,zMass,CBMean,*smearSmearRD[i],*CBalpha[i],*CBn[i]); sprintf(histName,"BWRD_%d",i); BWRD[i] = new CBreitWignerRD(histName,zMass, scaleScaleRD[i]); sprintf(histName,"pdfRDsig_%d",i); // pdfRDsig[i] = new RooFFTConvPdf(histName,histName,zMass,*(BWCBsCale[i]->model),*gaus[i]); pdfRDsig[i] = new RooFFTConvPdf(histName,histName,zMass,*(BWRD[i]->model),*cbRD[i]); sprintf(histName,"cat_%d",i); pdfTotalMC.addPdf(*pdfMCsig[i],histName); sprintf(histName,"cat_%d",i); pdfTotalRD.addPdf(*pdfRDsig[i],histName); } RooDataHist MCTotal("MCTotal","MCTotal",zMass,rooCat,hmapMC); fitResTotalMC = pdfTotalMC.fitTo(MCTotal,Minos(kTRUE),Save(kTRUE),SumW2Error(kTRUE)); RooDataHist dataTotal("dataTotal","dataTotal",zMass,rooCat,hmapRD); fitResTotalRD = pdfTotalRD.fitTo(dataTotal,Minos(kTRUE),Save(kTRUE),SumW2Error(kTRUE)); Fout<<"bin range \t scale \t smear "<<endl; for(int i(0);i<ScaleBins-1;i++) { // cout<<" "<<i<<"\t"<<scaleMC[i]->getVal()<<"+"<<scaleMC[i]->getError()<<"\t"<<smearMC[i]->getVal()<<"+"<<smearMC[i]->getError()<<endl; // Fout<<" "<<i<<"\t"<<scaleMC[i]->getVal()<<"+"<<scaleMC[i]->getError()<<"\t"<<smearMC[i]->getVal()<<"+"<<smearMC[i]->getError()<<endl; // cout<<" "<<i<<"\t"<<scaleRD[i]->getVal()<<"+"<<scaleRD[i]->getError()<<"\t"<<smearRD[i]->getVal()<<"+"<<smearRD[i]->getError()<<endl; // Fout<<" "<<i<<"\t"<<scaleRD[i]->getVal()<<"+"<<scaleRD[i]->getError()<<"\t"<<smearRD[i]->getVal()<<"+"<<smearRD[i]->getError()<<endl; cout<<" "<<i<<"\t"<<scaleRD[i]->getVal()/scaleMC[i]->getVal()<<"+-"<<(scaleRD[i]->getVal()/scaleMC[i]->getVal())*sqrt((scaleRD[i]->getError()*scaleRD[i]->getError())/scaleRD[i]->getVal()/scaleRD[i]->getVal()+(scaleMC[i]->getError()*scaleMC[i]->getError())/scaleMC[i]->getVal()/scaleMC[i]->getVal())<<"\t"<<smearRD[i]->getVal()- smearMC[i]->getVal()<<"+"<<sqrt(smearRD[i]->getError()*smearRD[i]->getError()+ smearMC[i]->getError()*smearMC[i]->getError())<<endl; Fout<<" "<<i<<"\t"<<scaleRD[i]->getVal()/scaleMC[i]->getVal()<<"+-"<<(scaleRD[i]->getVal()/scaleMC[i]->getVal())*sqrt((scaleRD[i]->getError()*scaleRD[i]->getError())/scaleRD[i]->getVal()/scaleRD[i]->getVal()+(scaleMC[i]->getError()*scaleMC[i]->getError())/scaleMC[i]->getVal()/scaleMC[i]->getVal())<<"\t"<<smearRD[i]->getVal()- smearMC[i]->getVal()<<"+"<<sqrt(smearRD[i]->getError()*smearRD[i]->getError()+ smearMC[i]->getError()*smearMC[i]->getError())<<endl; } //* for(int i(0);i<ScMuCombiBins;i++) { //* zmassFrameMC = zMass.frame(); ZmassMC[i]->plotOn(zmassFrameMC,DrawOption("p")); pdfMCsig[i]->plotOn(zmassFrameMC,DrawOption("l")); sprintf(histName,"ZmassMC_%s_%d",BaseName,i); plotFitMC = new CPlot(histName,zmassFrameMC,"","Di-Lepton M",""); plotFitMC->setOutDir(ResultDir); plotFitMC->Draw(myCan,kTRUE,"png"); //*/ zmassFrameRD = zMass.frame(); ZmassRD[i]->plotOn(zmassFrameRD,DrawOption("p")); pdfRDsig[i]->plotOn(zmassFrameRD,DrawOption("l")); sprintf(histName,"ZmassRD_%s_%d",BaseName,i); plotFitRD = new CPlot(histName,zmassFrameRD,"","Di-Lepton M",""); plotFitRD->setOutDir(ResultDir); plotFitRD->Draw(myCan,kTRUE,"png"); } //*/ Fout.close(); return 0; }
bool wxXmlDocument::Save(const wxString& filename) const { wxFileOutputStream stream(filename); return Save(stream); }
void Map::UpdateRaknet() { switch (mRaknet.mPacket->data[0]) { case ID_ITEM_TAKEN: { int itemIndex = 0; RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(itemIndex); mMapData.mLayer1[itemIndex].SetActive(false); break; } case ID_DROP_ITEM: { int imageNumber = 0; int index = 0; RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(imageNumber); bsIn.Read(index); AddItem(imageNumber, index); break; } case ID_MAP_DATA: { int map = 0; int width = 0; int height = 0; int tiles = 0; RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(map); bsIn.Read(width); bsIn.Read(height); bsIn.Read(tiles); mMapData.SetWidth(width); mMapData.SetHeight(height); mMapData.SetNumberOfTiles(tiles); mMapData.CreateTiles(); for (int a = 0; a < tiles; ++a) { bsIn.Read(mMapData.mLayer1[a]); bsIn.Read(mMapData.mLayer2[a]); bsIn.Read(mMapData.mLayer3[a]); bsIn.Read(mMapData.mLayer4[a]); } bsIn.Read(mNumberOfNPCS); for (int a = 0; a < mNumberOfNPCS; ++a) { NPC* temp = new NPC(mRaknet, a); bsIn.Read(temp->GetData()); mNPCS.push_back(temp); } // Save map so we dont need to retrieve it every time Save(); // Create are tiles for the map mNumberOfItems = IniFile_GetInt("Number_Of_items", 5); LoadTiles(); LoadItems(); mPathFinding.Init(GetWidth(), GetHeight(), &mMapData.mLayer1[0]); // Load npcs for (int a = 0; a < mNumberOfNPCS; ++a) { NPC* temp = mNPCS[a]; NPCData& tempData = temp->GetData(); temp->Init(width, height, mPathFinding.GetGraph()); temp->ReloadGraphic(); if (!tempData.mHost) { temp->CreatePath(); } } int north = 0; int east = 0; int south = 0; int west = 0; bsIn.Read(north); bsIn.Read(east); bsIn.Read(south); bsIn.Read(west); mMapData.SetNorth(north); mMapData.SetEast(east); mMapData.SetSouth(south); mMapData.SetWest(west); break; } case ID_NPC_NEW_PATH: { int npcSlot = 0; int endIndex = 0; SVector2 position(0.0f, 0.0f); RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(npcSlot); bsIn.Read(endIndex); bsIn.Read(position); NPC* tempNPC = mNPCS[npcSlot]; tempNPC->SetEndPath(endIndex); tempNPC->CreatePath(); tempNPC->GetData().SetPosition(position); break; } case ID_NPC_HOST: { for (int a = 0; a < mNumberOfNPCS; ++a) { mNPCS[a]->GetData().SetHost(true); } break; } case ID_NPC_STOP: { if (!mMemoryCreated) break; int npcSlot = 0; bool stop = false; RakNet::BitStream bsIn(mRaknet.mPacket->data, mRaknet.mPacket->length, false); bsIn.IgnoreBytes(sizeof(RakNet::MessageID)); bsIn.Read(npcSlot); bsIn.Read(stop); if (stop) { int test = 0; } mNPCS[npcSlot]->SetStop(stop); break; } } }
int main(void) { // Initialize I/O DDRB = 0x3e; // 00111110 PORTB = 0x01; // 00000001 DDRC = 0x20; // 00100000 PORTC = 0x03; // 00000011 DDRD = 0xff; // 11111111 PORTD = 0xff; // 11111111 // Load saved state, if any Load(); // Setup the display timer... // prescaler 1/8; at 1MHz system clock, this gives us an overflow // at 488 Hz, providing a per-digit refresh rate of 97.6 Hz. TCCR0A = 0; TCCR0B = (1<<CS01); // Output compare value B - controls blanking. // In full brightness mode, we'll make this happen immediately before the refresh, // In lower brightness modes, we'll make it happen sooner. OCR0A = pgm_read_byte(&brighttable[bright]); // Enable overflow and compare match interrupts TIMSK0 = (1<<TOIE0) | (1<<OCIE0A); // Setup the RTC... gMin = 0; gSec = 0; // select asynchronous operation of Timer2 ASSR = (1<<AS2); // select prescaler: 32.768 kHz / 128 = 1 sec between each overflow TCCR2A = 0; TCCR2B = (1<<CS22) | (1<<CS20); // wait for TCN2UB and TCR2UB to be cleared while((ASSR & 0x01) | (ASSR & 0x04)); // clear interrupt-flags TIFR2 = 0xFF; // init the state machine enum State state = ST_TIME; enum State prevstate = ST_TIME; uint8_t remaining = 0; uint8_t cmode = 0; // Enable interrupts sei(); // Do some stuff for(;;) { uint8_t buttons = GetButtons(); if ((buttons & BUTTON_RIGHT) && (state < ST_BRIGHT)) { prevstate = state; remaining = count; cmode = 0; buttons = 0; state = ST_RUN_PRIME; } newstate: switch(state) { case ST_TIME: DisplayNum(stime[0], HIGH_POS, 0, 3); display[COLON_POS] = COLON; DisplayNum(stime[1], LOW_POS, 0, 0); if (buttons & BUTTON_LEFT) { state = ST_DELAY; } else if (buttons & BUTTON_UP) { state = ST_TIME_SET_MINS; } break; case ST_DELAY: DisplayNum(delay[0], HIGH_POS, 0, 3); display[COLON_POS] = LOWDOT; DisplayNum(delay[1], LOW_POS, 0, 0); if (buttons & BUTTON_LEFT) { state = ST_COUNT; } else if (buttons & BUTTON_UP) { state = ST_DELAY_SET_MINS; } break; case ST_COUNT: DisplayAlnum('\xC6', count, 0); if (buttons & BUTTON_LEFT) { state = ST_MLU; } else if (buttons & BUTTON_UP) { state = ST_COUNT_SET; } break; case ST_MLU: DisplayAlnum('\xC7', mlu, 0); if (buttons & BUTTON_LEFT) { state = ST_BRIGHT; } else if (buttons & BUTTON_UP) { state = ST_MLU_SET; } break; /* I'll put this in once there's more than one option ;) case ST_OPTIONS: display[0] = '\xC0'; // 00111111 = 'O' display[1] = '\x8C'; // 01110011 = 'P' display[2] = EMPTY; display[3] = '0x87'; // 01111000 = 't' display[4] = '0x92'; // 01101101 = 'S' if (buttons & BUTTON_LEFT) { state = ST_TIME; } else if (buttons & BUTTON_UP) { state = ST_BRIGHT; } break; */ case ST_BRIGHT: DisplayAlnum('\x83', 4 - bright, 0); // 10000011 = 'b' if (buttons & BUTTON_LEFT) { state = ST_TIME; } else if (buttons & BUTTON_UP) { bright = (bright - 1) & 3; OCR0A = pgm_read_byte(&brighttable[bright]); } else if (buttons & BUTTON_RIGHT) { Save(); state = ST_SAVED; remaining = 15; } break; case ST_SAVED: display[0] = '\x92'; // 01101101 = 'S' display[1] = '\x88'; // 01110111 = 'A' display[2] = EMPTY; display[3] = '\xc1'; // 00111110 = 'V' display[4] = '\x86'; // 01111001 = 'E' if (--remaining == 0) state = ST_BRIGHT; break; case ST_TIME_SET_MINS: DisplayNum(stime[0], HIGH_POS, 0x40, 0); display[COLON_POS] = COLON; DisplayNum(stime[1], LOW_POS, 0, 0); if (EditNum(&stime[0], buttons, 100)) { state = ST_TIME_SET_SECS; } break; case ST_TIME_SET_SECS: DisplayNum(stime[0], HIGH_POS, 0, 0); display[COLON_POS] = COLON; DisplayNum(stime[1], LOW_POS, 0x40, 0); if (EditNum(&stime[1], buttons, 60)) { state = ST_TIME; } break; case ST_DELAY_SET_MINS: DisplayNum(delay[0], HIGH_POS, 0x40, 0); display[COLON_POS] = LOWDOT; DisplayNum(delay[1], LOW_POS, 0, 0); if (EditNum(&delay[0], buttons, 100)) { state = ST_DELAY_SET_SECS; } break; case ST_DELAY_SET_SECS: DisplayNum(delay[0], HIGH_POS, 0, 0); display[COLON_POS] = LOWDOT; DisplayNum(delay[1], LOW_POS, 0x40, 0); if (EditNum(&delay[1], buttons, 60)) { state = ST_DELAY; } break; case ST_COUNT_SET: DisplayAlnum('\xC6', count, 0x40); if (EditNum(&count, buttons, 100)) { state = ST_COUNT; } break; case ST_MLU_SET: DisplayAlnum('\xC7', mlu, 0x40); if (EditNum(&mlu, buttons, 60)) { state = ST_MLU; } break; case ST_RUN_PRIME: if (mlu > 0) { state = ST_MLU_PRIME; SHUTTER_ON(); DisplayAlnum('\xC7', mlu, 0); } else { InitRun(&state); goto newstate; } break; case ST_RUN_AUTO: if (gDirection == 0) { // time has elapsed. close the shutter and stop the timer. SHUTTER_OFF(); clock_stop(); if (remaining > 0) { if (--remaining == 0) { // we're done. state = prevstate; break; } } gMin = delay[0]; gSec = delay[1]; gDirection = -1; state = ST_WAIT; clock_start(); goto newstate; } // fall through case ST_RUN_MANUAL: if (cmode == 0) { // time left in this exposure DisplayNum(gMin, HIGH_POS, 0, 3); DisplayNum(gSec, LOW_POS, 0, 0); } else { // remaining exposures DisplayAlnum('\xC6', remaining, 0); } display[COLON_POS] = (TCNT2 & 0x80) ? EMPTY : COLON; break; case ST_MLU_PRIME: SHUTTER_OFF(); gMin = 0; gSec = mlu; gDirection = -1; state = ST_MLU_WAIT; clock_start(); // fall-through case ST_MLU_WAIT: DisplayAlnum('\xC7', gSec, 0); if (gDirection == 0) { // MLU wait period has elapsed clock_stop(); InitRun(&state); goto newstate; } break; case ST_WAIT: if (cmode == 0) { // wait time DisplayNum(gMin, HIGH_POS, 0, 3); DisplayNum(gSec, LOW_POS, 0, 0); } else { // remaining exposures DisplayAlnum('\xC6', remaining, 0); } display[COLON_POS] = (TCNT2 & 0x80) ? EMPTY : LOWDOT; if (gDirection == 0) { // wait period has timed out; // stop the timer and start a new cycle clock_stop(); state = ST_RUN_PRIME; goto newstate; } break; } if (state >= ST_RUN_PRIME) { // check keys if (buttons & BUTTON_RIGHT) { // canceled. clock_stop(); SHUTTER_OFF(); // if counting up, freeze the count here if (state == ST_RUN_MANUAL) { stime[0] = gMin; stime[1] = gSec; } state = prevstate; } else if ((buttons & BUTTON_LEFT) && (count > 1)) { // toggle display, time left vs. count left cmode = (cmode + 1) & 1; } else if (buttons & BUTTON_UP) { // adjust brightness bright = (bright - 1) & 3; OCR0A = pgm_read_byte(&brighttable[bright]); } } Sleep(48); // approx 50ms at 1MHz } }
Error Win32Prefs:: Initialize() { LONG result; uint32 length; char path[MAX_PATH] = {0x00}; char cwd[MAX_PATH]= {0x00}; Error error = kError_UnknownErr; // Where are we starting the program from? GetCurrentDirectory(sizeof(cwd), cwd); if(m_prefsKey) { // people DO move their apps around on windows length = sizeof(path); error = GetPrefString(kInstallDirPref, path, &length); char foo[MAX_PATH] = {0x00}; sprintf(foo,"%s\\freeamp.exe",cwd); WIN32_FIND_DATA win32fd; // check for freeamp exe in cwd HANDLE h = FindFirstFile(foo, &win32fd); if (h != INVALID_HANDLE_VALUE) { //if (win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if(IsError(error) || strcmp(cwd, path)) { result = RegSetValueEx( m_prefsKey, kInstallDirPref, NULL, REG_SZ, (LPBYTE)cwd, strlen(cwd) + 1); strcat(cwd, "\\db"); result = RegSetValueEx( m_prefsKey, kDatabaseDirPref, NULL, REG_SZ, (LPBYTE)cwd, strlen(cwd) + 1); } } FindClose(h); } error = kError_NoErr; } else // keys need to be created for the first time { DWORD disposition; HKEY freeampKey; HKEY versionKey; // create the main key in the windows registry result = RegCreateKeyEx(kMainKey, kFreeAmpKey, NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &freeampKey, &disposition); if(result == ERROR_SUCCESS) { // create the version key under the freeamp key result = RegCreateKeyEx(freeampKey, kFreeAmpVersionKey, NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &versionKey, &disposition); } if(result == ERROR_SUCCESS) { // create the version key under the freeamp key result = RegCreateKeyEx(versionKey, kMainComponentKey, NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &m_prefsKey, &disposition); } if(result != ERROR_SUCCESS) error = kError_NoPrefs; RegCloseKey(freeampKey); RegCloseKey(versionKey); } SetDefaults(); Save(); return error; }
void SetData(uint32 uiType, uint32 uiData) { switch(uiType) { case TYPE_JARAXXUS: if (uiData == DONE) m_uiEvent = 2000; break; case TYPE_CRUSADERS: switch (uiData) { case IN_PROGRESS: m_uiResilienceWillFixItTimer = 0; break; case SPECIAL: //Means the first blood m_uiResilienceWillFixItTimer = 60*IN_MILLISECONDS; uiData = IN_PROGRESS; break; case DONE: DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DEFEAT_FACTION_CHAMPIONS); if (m_uiResilienceWillFixItTimer > 0) DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_CHAMPIONS_KILLED_IN_MINUTE); if (GameObject* pChest = instance->GetGameObject(m_uiCrusadersCacheGUID)) if (pChest && !pChest->isSpawned()) pChest->SetRespawnTime(7*DAY); m_uiEvent = 3100; break; } break; case TYPE_VALKIRIES: switch (uiData) { case FAIL: if (m_auiEncounter[TYPE_VALKIRIES] == NOT_STARTED) uiData = NOT_STARTED; break; case SPECIAL: if (m_auiEncounter[TYPE_VALKIRIES] == SPECIAL) uiData = DONE; break; case DONE: if (instance->GetPlayers().getFirst()->getSource()->GetTeam() == ALLIANCE) m_uiEvent = 4020; else m_uiEvent = 4030; break; } break; case TYPE_ANUBARAK: switch (uiData) { case DONE: m_uiEvent = 6000; break; case SPECIAL: uint32 tributeChest = 0; if (instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC) { if (m_uiTrialCounter >= 50) tributeChest = GO_TRIBUTE_CHEST_10H_99; else if (m_uiTrialCounter >= 45) tributeChest = GO_TRIBUTE_CHEST_10H_50; else if (m_uiTrialCounter >= 25) tributeChest = GO_TRIBUTE_CHEST_10H_45; else tributeChest = GO_TRIBUTE_CHEST_10H_25; } else if (instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC) { if (m_uiTrialCounter >= 50) tributeChest = GO_TRIBUTE_CHEST_25H_99; else if (m_uiTrialCounter >= 45) tributeChest = GO_TRIBUTE_CHEST_25H_50; else if (m_uiTrialCounter >= 25) tributeChest = GO_TRIBUTE_CHEST_25H_45; else tributeChest = GO_TRIBUTE_CHEST_25H_25; } if (tributeChest) if (Creature* pTirion = instance->GetCreature(m_uiTirionGUID)) if (GameObject* pChest = pTirion->SummonGameObject(tributeChest, 805.62f, 134.87f, 142.16f, 3.27f, 0, 0, 0, 0, 90000000)) pChest->SetRespawnTime(pChest->GetRespawnDelay()); break; } break; case TYPE_COUNTER: m_uiTrialCounter = uiData; uiData = DONE; break; case TYPE_EVENT: m_uiEvent = uiData; uiData = NOT_STARTED; break; case TYPE_EVENT_TIMER: m_uiEventTimer = uiData; uiData = NOT_STARTED; break; case TYPE_NORTHREND_BEASTS: m_uiNorthrendBeasts = uiData; switch (uiData) { case GORMOK_DONE: m_uiEvent = 200; SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS); SetData(TYPE_BEASTS, IN_PROGRESS); break; case SNAKES_IN_PROGRESS: m_uiNotOneButTwoJormungarsTimer = 0; break; case SNAKES_SPECIAL: m_uiNotOneButTwoJormungarsTimer = 10*IN_MILLISECONDS; break; case SNAKES_DONE: if (m_uiNotOneButTwoJormungarsTimer > 0) DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_WORMS_KILLED_IN_10_SECONDS); m_uiEvent = 300; SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS); SetData(TYPE_BEASTS, IN_PROGRESS); break; case ICEHOWL_DONE: m_uiEvent = 400; SetData(TYPE_NORTHREND_BEASTS, DONE); SetData(TYPE_BEASTS, DONE); break; case FAIL: SetData(TYPE_BEASTS, FAIL); break; } break; case DATA_HEALTH_TWIN_SHARED: m_uiDataDamageTwin = uiData; uiData = NOT_STARTED; break; //Achievements case DATA_SNOBOLD_COUNT: if (uiData == INCREASE) ++m_uiSnoboldCount; else if (uiData == DECREASE) --m_uiSnoboldCount; break; case DATA_MISTRESS_OF_PAIN_COUNT: if (uiData == INCREASE) ++m_uiMistressOfPainCount; else if (uiData == DECREASE) --m_uiMistressOfPainCount; break; case DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE: m_bTributeToImmortalityElegible = false; break; } if (IsEncounterInProgress()) { CloseDoor(GetData64(GO_EAST_PORTCULLIS)); CloseDoor(GetData64(GO_WEB_DOOR)); } else { OpenDoor(GetData64(GO_EAST_PORTCULLIS)); OpenDoor(GetData64(GO_WEB_DOOR)); } if (uiType < MAX_ENCOUNTERS) { sLog->outBasic("[ToCr] m_auiEncounter[uiType %u] %u = uiData %u;", uiType, m_auiEncounter[uiType], uiData); if (uiData == FAIL) { if (IsRaidWiped()) { --m_uiTrialCounter; m_bNeedSave = true; m_uiEvent = (uiType == TYPE_BEASTS? 666 : 0); } uiData = NOT_STARTED; } m_auiEncounter[uiType] = uiData; if (uiData == DONE || m_bNeedSave == true) { if (Unit* pAnnouncer = instance->GetCreature(GetData64(NPC_BARRENT))) pAnnouncer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); Save(); } } }
int ExplicitShapeRegression::LearnRegression(const std::vector<std::string>& imgFiles, const std::vector<double>& initTheta, const std::vector<double>& finalTheta, int dataPerImgCount, int keyPointCount, int outerCount, int innerCount, int fernSize, int featureSizePerKey) { if (imgFiles.size() == 0 || initTheta.size() == 0 || finalTheta.size() == 0) { return MAGIC_INVALID_INPUT; } if (imgFiles.size() * dataPerImgCount != finalTheta.size() / (keyPointCount * 2)) { return MAGIC_INVALID_INPUT; } Reset(); mInnerFernCount = innerCount; //ImageLoader imageLoader; DebugLog << "Load Image......"; mImageLoader.LoadImages(imgFiles, ImageLoader::IT_Gray); DebugLog << "done" << std::endl; srand(time(NULL)); int thetaDim = keyPointCount * 2; int fernCount = outerCount * innerCount; mRandomFerns.reserve(fernCount); int dataCount = initTheta.size() / thetaDim; std::vector<bool> dataX(featureSizePerKey * keyPointCount * dataCount); std::vector<double> theta(thetaDim); //one theta std::vector<double> curTheta = initTheta; std::vector<double> interTheta; std::vector<double> deltaTheta(curTheta.size()); bool earlyStop = false; for (int outerId = 0; outerId < outerCount; outerId++) { if (earlyStop) { break; } double timeStart = MagicTool::Profiler::GetTime(); DebugLog << "Out stage: " << outerId << std::endl; interTheta = curTheta; for (int thetaId = 0; thetaId < interTheta.size(); thetaId++) { deltaTheta.at(thetaId) = finalTheta.at(thetaId) - interTheta.at(thetaId); } FeaturePatternGeneration(interTheta, deltaTheta, dataPerImgCount, dataCount, featureSizePerKey, keyPointCount, dataX); int fernBaseId = outerId * mInnerFernCount; for (int innerId = 0; innerId < mInnerFernCount; innerId++) { DebugLog << " Inner stage: " << innerId << " fernId: " << fernBaseId + innerId << std::endl; int fernId = fernBaseId + innerId; double avgDelta = 0; for (int thetaId = 0; thetaId < curTheta.size(); thetaId++) { deltaTheta.at(thetaId) = finalTheta.at(thetaId) - curTheta.at(thetaId); avgDelta += fabs(deltaTheta.at(thetaId)); } avgDelta /= curTheta.size(); DebugLog << " AvgDelta: " << avgDelta << std::endl; if (avgDelta < 0.5) //modify_flag { earlyStop = true; } MagicML::RandomFern* pFern = new MagicML::RandomFern; pFern->Learn(dataX, featureSizePerKey * keyPointCount, deltaTheta, thetaDim, fernSize); mRandomFerns.push_back(pFern); //Update Valid Features std::vector<int> validFeatureIds = pFern->GetFeatureIds(); /*DebugLog << " ValidFeatureIds: "; for (std::vector<int>::iterator itr = validFeatureIds.begin(); itr != validFeatureIds.end(); itr++) { DebugLog << *itr << " "; } DebugLog << std::endl;*/ UpdateValidFeaturePosPair(validFeatureIds); //Update curTheta for (int dataId = 0; dataId < dataCount; dataId++) { //Generate feature from theta int baseIndex = dataId * thetaDim; for (int thetaId = 0; thetaId < thetaDim; thetaId++) { //theta.at(thetaId) = curTheta.at(baseIndex + thetaId); theta.at(thetaId) = interTheta.at(baseIndex + thetaId); } std::vector<bool> features; int imgId = dataId / dataPerImgCount; ValidFeatureGenerationByImageLoader(imgId, theta, fernId, features); //Predict delta theta std::vector<double> predictDelta = pFern->PredictWithValidFeature(features); //Update curTheta baseIndex = dataId * thetaDim; for (int thetaId = 0; thetaId < thetaDim; thetaId++) { curTheta.at(baseIndex + thetaId) += predictDelta.at(thetaId); } } } DebugLog << "time: " << MagicTool::Profiler::GetTime() - timeStart << std::endl; Save("./temp.shape"); } return MAGIC_NO_ERROR; }
Settings::~Settings() { QVariant v; v.setValue(textFormulaNodeFonts); Save("Formulas", "textFormulaNodeFonts", v); }
bool JSONFile::Save(Serializer& dest) const { return Save(dest, "\t"); }
void SettingsDialog::DialogButtonClicked(QAbstractButton* button) { // While we only connect Apply at the moment, this might change in the future if (ui_->buttonBox->button(QDialogButtonBox::Apply) == button) { Save(); } }
void SettingsDialog::accept() { Save(); QDialog::accept(); }
Contact::~Contact() { if (save_on_destructor_) { Save(); } }
void CCrossDlg::OnSaveA() { Save(SEL_A); }
bool CGUIDialogCMSSettings::OnBack(int actionID) { Save(); return CGUIDialogSettingsBase::OnBack(actionID); }
void CCrossDlg::OnSaveB() { Save(SEL_B); }
uint32 TransitionArea::EngineMessageFn( uint32 messageID, void *pData, float fData ) { switch( messageID ) { case MID_PRECREATE : { // Let the GameBase handle the message first uint32 dwRet = GameBase::EngineMessageFn( messageID, pData, fData ); ObjectCreateStruct *pOCS = (ObjectCreateStruct*)pData; if( pOCS ) { if( PRECREATE_WORLDFILE == fData ) { // [RP] HACK - Deal with the double rotation problem m_tfWorld.m_rRot = pOCS->m_Rotation; m_tfWorld.m_vPos = pOCS->m_Pos; pOCS->m_Rotation.Identity(); ReadProps( &pOCS->m_cProperties ); } PostReadProps( pOCS ); } // Important!! - We already sent the message to the GameBase so DONT do it again. return dwRet; } break; case MID_INITIALUPDATE : { // Don't eat ticks please... SetNextUpdate(UPDATE_NEVER); } break; case MID_SAVEOBJECT : { Save( (ILTMessage_Write*)pData, (uint32)fData ); } break; case MID_LOADOBJECT : { Load( (ILTMessage_Read*)pData, (uint32)fData ); } break; case MID_UPDATE: { Update( ); } break; default : break; } return GameBase::EngineMessageFn( messageID, pData, fData ); }
void CCrossDlg::OnMixSave() { Save(SEL_MIX); }
void PreferencesDialog::on_okButton_clicked() { if (Save()) accept(); }
// // GPWindow::MessageReceived // // Called when a message is received by our // application. // void GPWindow::MessageReceived(BMessage *message) { switch(message->what) { case WINDOW_REGISTRY_ADDED: { char s[22]; BRect rect; if (message->FindInt32("new_window_number", &window_id) == B_OK) { if (!savemessage) { // if it's untitled sprintf(s, "File%ld.html", window_id); SetTitle(s); } } if (message->FindRect("rect", &rect) == B_OK) { MoveTo(rect.LeftTop()); ResizeTo(rect.Width(), rect.Height()); } Minimize(false); } break; case MENU_FILE_NEW: { BRect r; r = Frame(); new GPWindow(r); } break; case MENU_FILE_CLOSE: Quit(); break; case MENU_FILE_QUIT: be_app->PostMessage(B_QUIT_REQUESTED); break; case MENU_FILE_SAVEAS: savePanel->Show(); break; case MENU_FILE_SAVE: Save(NULL); break; case B_SAVE_REQUESTED: Save(message); break; case MENU_HELP_REQUESTED:{ int arg_c; char **_arg; arg_c=1; _arg = (char **)malloc(sizeof(char *) * (arg_c+ 1)); _arg[0]="/boot/home/peojects/WebEditor/help.html"; _arg[1]=NULL; be_roster->Launch("application/x-vnd.Be-NPOS",arg_c,_arg,NULL); free(_arg); } break; case MENU_HELP_ABOUT:{ BAlert *alert; alert= new BAlert("About ", "WebEditor for BeOS™\n©François Jouen 1999.\ne-mail:[email protected]", "OK"); alert->Go(); } break; // case B_MOUSE_UP: // printf("gor something\n"); // break; case bmsgNewCmd: case bmsgClrCmd: case bmsgBitmapDirty: case bmsgBitmapResize: // printf("gor something\n"); plotview->MessageReceived(message); break; default: BWindow::MessageReceived(message); break; } }
Config::~Config() { Save(); delete qt_config; }
COptions::~COptions() { Save(); delete m_ExporterList; }
bool SetBossState(uint32 type, EncounterState state) { if (!InstanceScript::SetBossState(type, state)) return false; switch (type) { case BOSS_BEASTS: break; case BOSS_JARAXXUS: // Cleanup Icehowl if (Creature* icehowl = instance->GetCreature(IcehowlGUID)) icehowl->DespawnOrUnsummon(); if (state == DONE) EventStage = 2000; break; case BOSS_CRUSADERS: // Cleanup Jaraxxus if (Creature* jaraxxus = instance->GetCreature(JaraxxusGUID)) jaraxxus->DespawnOrUnsummon(); if (Creature* fizzlebang = instance->GetCreature(FizzlebangGUID)) fizzlebang->DespawnOrUnsummon(); switch (state) { case IN_PROGRESS: ResilienceWillFixItTimer = 0; break; case SPECIAL: //Means the first blood ResilienceWillFixItTimer = 60*IN_MILLISECONDS; state = IN_PROGRESS; break; case DONE: DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DEFEAT_FACTION_CHAMPIONS); if (ResilienceWillFixItTimer > 0) DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_CHAMPIONS_KILLED_IN_MINUTE); DoRespawnGameObject(CrusadersCacheGUID, 7*DAY); EventStage = 3100; break; default: break; } break; case BOSS_VALKIRIES: // Cleanup chest if (GameObject* cache = instance->GetGameObject(CrusadersCacheGUID)) cache->Delete(); switch (state) { case FAIL: if (GetBossState(BOSS_VALKIRIES) == NOT_STARTED) state = NOT_STARTED; break; case SPECIAL: if (GetBossState(BOSS_VALKIRIES) == SPECIAL) state = DONE; break; case DONE: if (instance->GetPlayers().getFirst()->getSource()->GetTeam() == ALLIANCE) EventStage = 4020; else EventStage = 4030; break; default: break; } break; case BOSS_LICH_KING: break; case BOSS_ANUBARAK: switch (state) { case DONE: { EventStage = 6000; uint32 tributeChest = 0; if (instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC) { if (TrialCounter >= 50) tributeChest = GO_TRIBUTE_CHEST_10H_99; else { if (TrialCounter >= 45) tributeChest = GO_TRIBUTE_CHEST_10H_50; else { if (TrialCounter >= 25) tributeChest = GO_TRIBUTE_CHEST_10H_45; else tributeChest = GO_TRIBUTE_CHEST_10H_25; } } } else if (instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC) { if (TrialCounter >= 50) tributeChest = GO_TRIBUTE_CHEST_25H_99; else { if (TrialCounter >= 45) tributeChest = GO_TRIBUTE_CHEST_25H_50; else { if (TrialCounter >= 25) tributeChest = GO_TRIBUTE_CHEST_25H_45; else tributeChest = GO_TRIBUTE_CHEST_25H_25; } } } if (tributeChest) if (Creature* tirion = instance->GetCreature(TirionGUID)) if (GameObject* chest = tirion->SummonGameObject(tributeChest, 805.62f, 134.87f, 142.16f, 3.27f, 0, 0, 0, 0, WEEK)) chest->SetRespawnTime(chest->GetRespawnDelay()); break; } default: break; } break; default: break; } if (IsEncounterInProgress()) { CloseDoor(GetData64(GO_EAST_PORTCULLIS)); CloseDoor(GetData64(GO_WEB_DOOR)); } else { OpenDoor(GetData64(GO_EAST_PORTCULLIS)); OpenDoor(GetData64(GO_WEB_DOOR)); } if (type < MAX_ENCOUNTERS) { sLog->outInfo(LOG_FILTER_TSCR, "[ToCr] BossState(type %u) %u = state %u;", type, GetBossState(type), state); if (state == FAIL) { if (instance->IsHeroic()) { --TrialCounter; // decrease attempt counter at wipe Map::PlayerList const &PlayerList = instance->GetPlayers(); for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) if (Player* player = itr->getSource()) player->SendUpdateWorldState(UPDATE_STATE_UI_COUNT, TrialCounter); // if theres no more attemps allowed if (!TrialCounter) { if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT))) announcer->ToCreature()->DespawnOrUnsummon(); if (Creature* anubArak = instance->GetCreature(GetData64(NPC_ANUBARAK))) anubArak->DespawnOrUnsummon(); } } NeedSave = true; EventStage = (type == BOSS_BEASTS ? 666 : 0); state = NOT_STARTED; } if (state == DONE || NeedSave) { if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT))) announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); Save(); } } return true; }
//--------------------------------------------------------------------------- // Backup void ZtringListListF::Backup_Set (bool NewSave) { Sauvegarde=NewSave; Save(); }
usbMsgLen_t usbFunctionSetup(uchar data[8]) { usbRequest_t *rq = (void *)data; static uchar dataBuffer[4]; currentRequest = rq->bRequest; currentValue = rq->wValue.word; currentIndex = rq->wIndex.word; usbMsgPtr = (int)dataBuffer; switch (rq->bRequest) { case WL_REQUEST_ECHO: dataBuffer[0] = rq->wValue.bytes[0]; dataBuffer[1] = rq->wValue.bytes[1]; dataBuffer[2] = rq->wIndex.bytes[0]; dataBuffer[3] = rq->wIndex.bytes[1]; return 4; case WL_REQUEST_COLOR: case WL_REQUEST_TRANSITION: case WL_REQUEST_PAUSE: currentPosition = 0; bytesRemaining = rq->wLength.word; if (bytesRemaining > sizeof(buffer)) { bytesRemaining = sizeof(buffer); } return USB_NO_MSG; case WL_REQUEST_SET_WEBUSB_URLS: currentPosition = 0; bytesRemaining = rq->wLength.word; return USB_NO_MSG; case WL_REQUEST_HALT: HandleHALT(); break; case WL_REQUEST_RECORD: Record(); break; case WL_REQUEST_PLAY: Play(); break; case WL_REQUEST_STOP: Stop(); break; case WL_REQUEST_SAVE: Save(); break; case WL_REQUEST_LOAD: Load(); break; case WL_REQUEST_EFFECT: HandleEffect(rq->wValue.word); break; case WL_REQUEST_RESET_WATCHDOG: ResetAppWatchdog(rq->wValue.word * 1000); break; case WL_REQUEST_WEBUSB: { switch (rq->wIndex.word) { case WEBUSB_REQUEST_GET_ALLOWED_ORIGINS: pmResponsePtr = WEBUSB_ALLOWED_ORIGINS; pmResponseBytesRemaining = sizeof(WEBUSB_ALLOWED_ORIGINS); return USB_NO_MSG; case WEBUSB_REQUEST_GET_URL: switch (rq->wValue.word) { case 1: pmResponsePtr = WEBUSB_ORIGIN_1; pmResponseBytesRemaining = sizeof(WEBUSB_ORIGIN_1); return USB_NO_MSG; case 2: pmResponsePtr = WEBUSB_ORIGIN_2; pmResponseBytesRemaining = sizeof(WEBUSB_ORIGIN_2); return USB_NO_MSG; } } break; } case WL_REQUEST_WINUSB: { switch (rq->wIndex.word) { case WINUSB_REQUEST_DESCRIPTOR: pmResponsePtr = MS_OS_20_DESCRIPTOR_SET; pmResponseBytesRemaining = sizeof(MS_OS_20_DESCRIPTOR_SET); return USB_NO_MSG; } break; } case WL_REQUEST_RESET_DEVICE: forceReset(); break; } return 0; }
void FolderShaperWindow::MessageReceived(BMessage * a_message) { switch(a_message->what) { case 'move': // Move m_do_move = true; m_moveitem->SetMarked(true); m_deleitem->SetMarked(false); Save(); break; case 'dele': // Delete m_do_move = false; m_moveitem->SetMarked(false); m_deleitem->SetMarked(true); Save(); break; case 'alwa': // Do open m_do_open = FS_ALWAYS_OPEN; m_alwaysitem->SetMarked(true); m_neveritem->SetMarked(false); m_keepitem->SetMarked(false); Save(); break; case 'neve': // Don't open m_do_open = FS_NEVER_OPEN; m_alwaysitem->SetMarked(false); m_neveritem->SetMarked(true); m_keepitem->SetMarked(false); Save(); break; case 'keep': // Open if Original was open m_do_open = FS_IF_ORIGINAL_OPEN; m_alwaysitem->SetMarked(false); m_neveritem->SetMarked(false); m_keepitem->SetMarked(true); Save(); break; case 'kpos': // Use the X/Y position of the original m_do_keep_position = true; m_keep_pos_item->SetMarked(true); m_remove_pos_item->SetMarked(false); Save(); break; case 'rpos': // Remove X/Y position from template folder m_do_keep_position = false; m_keep_pos_item->SetMarked(false); m_remove_pos_item->SetMarked(true); Save(); break; case 'clob': // Template contents takes precedence if (m_do_clobber == false) { m_do_clobber = true; m_clobber_item->SetMarked(true); } else { m_do_clobber = false; m_clobber_item->SetMarked(false); } Save(); break; case 'clup': // Remove all X/Y pos. info of New folder contents if (m_do_clean_up == false) { m_do_clean_up = true; m_clean_up_item->SetMarked(true); } else { m_do_clean_up = false; m_clean_up_item->SetMarked(false); } Save(); break; case 'help': // Help -- documentation, settings be_app->PostMessage('help'); break; case 'tmpl': // Open Templates Folder -button be_app->PostMessage('tmpl'); break; case 'abou': // About -button be_app->PostMessage(B_ABOUT_REQUESTED); break; case 'quit': // Quit, Alt-Q, whatever Quit(); break; case 'drpt': // Template drop be_app->PostMessage(a_message); break; case 'drpf': // Folder drop be_app->PostMessage(a_message); break; default: BWindow::MessageReceived(a_message); break; } }
void GoAutoBook::Flush() { Save(m_filename); }
DDWORD UndeadGideon::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData) { switch(messageID) { case MID_PRECREATE: { // Need to call base class to have the object name read in before // we call PostPropRead() DDWORD dwRet = AI_Mgr::EngineMessageFn(messageID, pData, fData); PostPropRead((ObjectCreateStruct*)pData); return dwRet; } break; case MID_INITIALUPDATE: { InitialUpdate((DVector *)pData); CacheFiles(); break; } case MID_UPDATE: { if (m_bCreateHealth) { if (!m_fFullHealth) { m_fFullHealth = m_damage.GetHitPoints(); HMESSAGEWRITE hWrite = m_pServerDE->StartMessage(NULL, SMSG_BOSSHEALTH); m_pServerDE->WriteToMessageFloat(hWrite,1.0f); m_pServerDE->EndMessage(hWrite); m_bCreateHealth = DFALSE; } else { DFLOAT fTemp = m_damage.GetHitPoints() / m_fFullHealth; HMESSAGEWRITE hWrite = m_pServerDE->StartMessage(NULL, SMSG_BOSSHEALTH); m_pServerDE->WriteToMessageFloat(hWrite,fTemp); m_pServerDE->EndMessage(hWrite); } } } break; case MID_SAVEOBJECT: Save((HMESSAGEWRITE)pData, (DDWORD)fData); break; case MID_LOADOBJECT: Load((HMESSAGEREAD)pData, (DDWORD)fData); break; default : break; } return AI_Mgr::EngineMessageFn(messageID, pData, fData); }