void wxFontRefData::Init(int pointSize, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underlined, bool strikethrough, const wxString& faceName, wxFontEncoding WXUNUSED(encoding)) { if (family == wxFONTFAMILY_DEFAULT) family = wxFONTFAMILY_SWISS; m_underlined = underlined; m_strikethrough = strikethrough; // Create native font info m_nativeFontInfo.description = pango_font_description_new(); // And set its values if (!faceName.empty()) { pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV_SYS(faceName) ); } else { SetFamily(family); } SetStyle( style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style ); SetPointSize( (pointSize == wxDEFAULT || pointSize == -1) ? wxDEFAULT_FONT_SIZE : pointSize ); SetWeight( weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight ); }
// Update weights void Connection::UpdateNormal( int idx, data_type act, data_type mu, data_type backAct, data_type &dw_sum ) { int j; data_type w, dw, inAct; for ( j = 0; j < mInModule->GetModuleSize(); j++ ) { w = GetWeight( idx, j ); inAct = (*this.*mInAct)( j ); // learning rate up-adjustment for feedback module may be necessary in order for // the feedback information to overcome possibly ambiguous "perceptual" information if ( mInModule->GetModuleType() == O_FB ) { if ( dynamic_cast<Feedback*>(mInModule)->GetFeedback() != kNoWinner ) { mu = mu * mParameters[F_Bw]; } } // apply the Grossberg learning rule dw = mu * act * ( ( mParameters[K_Lmax] - w ) * inAct - mParameters[L_L] * ( w - mParameters[K_Lmin] ) * ( backAct - w * inAct ) ); // Koutnik variant // dw = mu * act * (inAct - w); // add to sum of weight changes dw_sum += dw; // set the new weight SetWeight( idx, j, dw ); } }
Player::Player() : m_Weapon(NULL) { g_Player = this; SetRadius(42); SetWeight(1.0f); }
void plMorphSequence::ISetSingleSharedToGlobal(int idx) { if (fGlobalLayerRef < 0) return; int i; for (i = 0; i < fSharedMeshes[fGlobalLayerRef].fArrayWeights[0].fDeltaWeights.GetCount(); i++) SetWeight(0, i, fSharedMeshes[fGlobalLayerRef].fArrayWeights[0].fDeltaWeights[i], fSharedMeshes[idx].fMesh->GetKey()); }
//o--------------------------------------------------------------------------o //| Function - bool LoadRemnants( UI32 arrayOffset ) //| Date - 20th January, 2002 //| Programmer - Abaddon //| Modified - //o--------------------------------------------------------------------------o //| Purpose - After handling data specific load, other parts go here //o--------------------------------------------------------------------------o bool CMultiObj::LoadRemnants( void ) { bool rValue = CItem::LoadRemnants(); // Add item weight if item doesn't have it yet if( GetWeight() <= 0 ) SetWeight( 0 ); return rValue; }
void wxFontRefData::Init(int pointSize, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) { m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family; m_underlined = underlined; m_encoding = encoding; if ( m_encoding == wxFONTENCODING_DEFAULT ) m_encoding = wxFont::GetDefaultEncoding(); m_noAA = false; // Create native font info m_nativeFontInfo.description = pango_font_description_new(); // And set its values if (!faceName.empty()) { pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV_SYS(faceName) ); } else { switch (m_family) { case wxFONTFAMILY_MODERN: case wxFONTFAMILY_TELETYPE: pango_font_description_set_family( m_nativeFontInfo.description, "monospace" ); break; case wxFONTFAMILY_ROMAN: pango_font_description_set_family( m_nativeFontInfo.description, "serif" ); break; case wxFONTFAMILY_SWISS: // SWISS = sans serif default: pango_font_description_set_family( m_nativeFontInfo.description, "sans" ); break; } } SetStyle( style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style ); SetPointSize( (pointSize == wxDEFAULT || pointSize == -1) ? wxDEFAULT_FONT_SIZE : pointSize ); SetWeight( weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight ); }
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info) { #ifdef wxNO_NATIVE_FONTINFO SetPointSize(info.pointSize); SetFamily(info.family); SetStyle(info.style); SetWeight(info.weight); SetUnderlined(info.underlined); SetFaceName(info.faceName); SetEncoding(info.encoding); #else (void)info; #endif }
void wxFontRefData::Init(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) { m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family; m_faceName = faceName; // we accept both wxDEFAULT and wxNORMAL here - should we? m_style = style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style; m_weight = weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight; // and here, do we really want to forbid creation of the font of the size // 90 (the value of wxDEFAULT)?? m_pointSize = pointSize == wxDEFAULT || pointSize == -1 ? wxDEFAULT_FONT_SIZE : pointSize; m_underlined = underlined; m_encoding = encoding; #if wxUSE_UNICODE // Create native font info m_nativeFontInfo.description = pango_font_description_new(); // And set its values switch (m_family) { case wxFONTFAMILY_MODERN: case wxFONTFAMILY_TELETYPE: pango_font_description_set_family( m_nativeFontInfo.description, "monospace" ); break; case wxFONTFAMILY_SWISS: pango_font_description_set_family( m_nativeFontInfo.description, "serif" ); break; default: pango_font_description_set_family( m_nativeFontInfo.description, "sans" ); break; } SetStyle( m_style ); SetPointSize( m_pointSize ); SetWeight( m_weight ); #endif }
/// Updates the contents of the FontSetting object /// @param faceName Face name of the font /// @param pointSize Height of the font, in points /// @param weight Weight of the font (see .h for values) /// @param italic Make the font italic style /// @param underline Make the font underline style /// @param strikeOut Make the font strikeout style /// @param color Color to draw the font with /// @return success or failure bool FontSetting::SetFontSetting(const wxChar* faceName, wxInt32 pointSize, wxInt32 weight, bool italic, bool underline, bool strikeOut, wxColor color) { //------Last Checked------// // - Dec 6, 2004 if (!SetFaceName(faceName)) return (false); if (!SetPointSize(pointSize)) return (false); if (!SetWeight(weight)) return (false); SetItalic(italic); SetUnderline(underline); SetStrikeOut(strikeOut); SetColor(color); return (true); }
void wxFontRefData::Init(int pointSize, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underlined, bool strikethrough, const wxString& faceName, wxFontEncoding WXUNUSED(encoding)) { // Old code could wrongly specify wxDEFAULT instead of -1 or wxNORMAL or, // preferably, wxFONTSTYLE_NORMAL or wxFONTWEIGHT_NORMAL, continue handling // this for compatibility. if ( pointSize == wxDEFAULT ) pointSize = -1; if ( static_cast<int>(style) == wxDEFAULT ) style = wxFONTSTYLE_NORMAL; if ( static_cast<int>(weight) == wxDEFAULT ) weight = wxFONTWEIGHT_NORMAL; if (family == wxFONTFAMILY_DEFAULT) family = wxFONTFAMILY_SWISS; // Create native font info m_nativeFontInfo.description = pango_font_description_new(); // And set its values if (!faceName.empty()) { pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV_SYS(faceName) ); } else { SetFamily(family); } SetStyle( style ); SetPointSize( pointSize == -1 ? wxDEFAULT_FONT_SIZE : pointSize ); SetWeight( weight ); SetUnderlined( underlined ); SetStrikethrough( strikethrough ); }
bool ON_BezierCage::ZeroCVs() { // zeros control vertices and, if rational, sets weights to 1 bool rc = false; int i,j,k; if ( m_cv ) { if ( m_cv_capacity > 0 ) { memset( m_cv, 0, m_cv_capacity*sizeof(*m_cv) ); if ( m_is_rat ) { for ( i = 0; i < m_order[0]; i++ ) { for ( j = 0; j < m_order[1]; j++ ) { for ( k = 0; k < m_order[2]; k++ ) { SetWeight( i,j,k, 1.0 ); } } } } rc = true; } else { double* cv; int s = CVSize()*sizeof(*cv); for ( i = 0; i < m_order[0]; i++ ) { for ( j = 0; j < m_order[1]; j++ ) { for ( k = 0; k < m_order[2]; k++ ) { cv = CV(i,j,k); memset(cv,0,s); if ( m_is_rat ) cv[m_dim] = 1.0; } } } rc = (i>0) ? true : false; } } return rc; }
void CCompound::AddBody(CAbstractBody const & otherbody) { SetWeight(otherbody.GetWeight()); SetVolume(otherbody.GetVolume()); SetDensity(); }
bool wxNativeFontInfo::FromUserString(const wxString& s) { // reset to the default state Init(); // ToUserString() will quote the facename if it contains spaces, commas // or semicolons: we must be able to understand that quoted text is // a single token: wxString toparse(s); // parse a more or less free form string wxStringTokenizer tokenizer(toparse, wxT(";, "), wxTOKEN_STRTOK); wxString face; unsigned long size; bool weightfound = false, pointsizefound = false; #if wxUSE_FONTMAP bool encodingfound = false; #endif bool insideQuotes = false; while ( tokenizer.HasMoreTokens() ) { wxString token = tokenizer.GetNextToken(); // normalize it token.Trim(true).Trim(false).MakeLower(); if (insideQuotes) { if (token.StartsWith("'") || token.EndsWith("'")) { insideQuotes = false; // add this last token to the facename: face += " " + token; // normalize facename: face = face.Trim(true).Trim(false); face.Replace("'", ""); continue; } } else { if (token.StartsWith("'")) insideQuotes = true; } // look for the known tokens if ( insideQuotes ) { // only the facename may be quoted: face += " " + token; continue; } if ( token == wxT("underlined") || token == _("underlined") ) { SetUnderlined(true); } else if ( token == wxT("strikethrough") || token == _("strikethrough") ) { SetStrikethrough(true); } else if ( token == wxT("light") || token == _("light") ) { SetWeight(wxFONTWEIGHT_LIGHT); weightfound = true; } else if ( token == wxT("bold") || token == _("bold") ) { SetWeight(wxFONTWEIGHT_BOLD); weightfound = true; } else if ( token == wxT("italic") || token == _("italic") ) { SetStyle(wxFONTSTYLE_ITALIC); } else if ( token.ToULong(&size) ) { SetPointSize(size); pointsizefound = true; } else { #if wxUSE_FONTMAP // try to interpret this as an encoding wxFontEncoding encoding = wxFontMapper::Get()->CharsetToEncoding(token, false); if ( encoding != wxFONTENCODING_DEFAULT && encoding != wxFONTENCODING_SYSTEM ) // returned when the recognition failed { SetEncoding(encoding); encodingfound = true; } else { #endif // wxUSE_FONTMAP // assume it is the face name if ( !face.empty() ) { face += wxT(' '); } face += token; // skip the code which resets face below continue; #if wxUSE_FONTMAP } #endif // wxUSE_FONTMAP } // if we had had the facename, we shouldn't continue appending tokens // to it (i.e. "foo bold bar" shouldn't result in the facename "foo // bar") if ( !face.empty() ) { wxString familyStr; if ( face.EndsWith(" family", &familyStr) ) { // it's not a facename but rather a font family wxFontFamily family; if ( familyStr == "decorative" ) family = wxFONTFAMILY_DECORATIVE; else if ( familyStr == "roman" ) family = wxFONTFAMILY_ROMAN; else if ( familyStr == "script" ) family = wxFONTFAMILY_SCRIPT; else if ( familyStr == "swiss" ) family = wxFONTFAMILY_SWISS; else if ( familyStr == "modern" ) family = wxFONTFAMILY_MODERN; else if ( familyStr == "teletype" ) family = wxFONTFAMILY_TELETYPE; else return false; SetFamily(family); } // NB: the check on the facename is implemented in wxFontBase::SetFaceName // and not in wxNativeFontInfo::SetFaceName thus we need to explicitly // call here wxFontEnumerator::IsValidFacename else if ( #if wxUSE_FONTENUM !wxFontEnumerator::IsValidFacename(face) || #endif // wxUSE_FONTENUM !SetFaceName(face) ) { SetFaceName(wxNORMAL_FONT->GetFaceName()); } face.clear(); } } // we might not have flushed it inside the loop if ( !face.empty() ) { // NB: the check on the facename is implemented in wxFontBase::SetFaceName // and not in wxNativeFontInfo::SetFaceName thus we need to explicitly // call here wxFontEnumerator::IsValidFacename if ( #if wxUSE_FONTENUM !wxFontEnumerator::IsValidFacename(face) || #endif // wxUSE_FONTENUM !SetFaceName(face) ) { SetFaceName(wxNORMAL_FONT->GetFaceName()); } } // set point size to default value if size was not given if ( !pointsizefound ) SetPointSize(wxNORMAL_FONT->GetPointSize()); // set font weight to default value if weight was not given if ( !weightfound ) SetWeight(wxFONTWEIGHT_NORMAL); #if wxUSE_FONTMAP // set font encoding to default value if encoding was not given if ( !encodingfound ) SetEncoding(wxFONTENCODING_SYSTEM); #endif // wxUSE_FONTMAP return true; }
wxFont& wxFont::MakeBold() { SetWeight(wxFONTWEIGHT_BOLD); return *this; }
void EfficiencyStudies(string FileIn, Float_t PtCut =25.,string WeightFolder="Weights", Int_t Wheel = 0 ){ WeightExt=WeightFolder; TFile *f = new TFile(FileIn.c_str()); TTree *t1 = (TTree*)f->Get("L1ITMuPtPlotter/ElderTree"); PTs_ pts; t1->SetBranchAddress("Pts",&pts.PtTrue); TEfficiency *effDTTF= new TEfficiency("dttf"," ", 60,-1.,119.); TEfficiency *effBIn= new TEfficiency("effBIn"," ", 60,-1.,119.); TEfficiency *effBOut= new TEfficiency("effBOut"," ", 60,-1.,119.); TEfficiency *effDPhi= new TEfficiency("effBDPhi"," ", 60,-1.,119.); TEfficiency *effPtMin= new TEfficiency("effPtMin"," ", 60,-1.,119.); TEfficiency *effPtMin2= new TEfficiency("effPtMin2"," ", 60,-1.,119.); TEfficiency *effPtMin3= new TEfficiency("effPtMin3"," ", 60,-1.,119.); TEfficiency *effWeightPt= new TEfficiency("effWeightPt"," ", 60,-1.,119.); TEfficiency *effNewPt= new TEfficiency("effNewPt"," ", 60,-1.,119.); Int_t nentries = (Int_t)t1->GetEntries(); Int_t nevents = 0; for (Int_t i=0; i<nentries; i++) { t1->GetEntry(i); if(Wheel==0){ if(abs(pts.Wheel_)==2) continue; } else if(pts.Wheel_!=Wheel) continue; nevents++; Float_t whWMTailBIn = 1; Float_t whWMTailBOut = 1; Float_t whWMTailDPhi = 1; Float_t whWMInTailBIn = 1; Float_t whWMInTailBOut = 1; Float_t whWMInTailDPhi = 1; Float_t whWMOutTailBIn = 1; Float_t whWMOutTailBOut = 1; Float_t whWMOutTailDPhi = 1; //example for RMS Weight // Float_t whWMRMSBIn = 1; // Float_t whWMRMSBOut = 1; // Float_t whWMRMSDPhi = 1; int sector = 0; stringstream PlaceName; PlaceName << "Wh" << pts.Wheel_ << "Sc" << sector; //Weight for "tail" method SetWeight( whWMTailBIn, whWMTailBOut, whWMTailDPhi, pts.Qual1_, pts.Qual2_, PlaceName.str(),"WMean","Tail"); SetWeight( whWMInTailBIn, whWMInTailBOut, whWMInTailDPhi, pts.Qual1_, pts.Qual2_, PlaceName.str(),"WMeanIn","Tail"); SetWeight( whWMOutTailBIn, whWMOutTailBOut, whWMOutTailDPhi, pts.Qual1_, pts.Qual2_, PlaceName.str(),"WMeanOut","Tail"); Float_t WeightedPt = pts.PtDPhi; //Choice 1 if((pts.Qual1_==1) & (pts.Qual2_==1)) WeightedPt = whWMTailBIn*pts.PtBIn+whWMTailBOut*pts.PtBOut+whWMTailDPhi*pts.PtDPhi; else if((pts.Qual1_==1) & (pts.Qual2_!=1)) WeightedPt = whWMInTailBIn*pts.PtBIn+whWMInTailDPhi*pts.PtDPhi; else if((pts.Qual1_==1) & (pts.Qual2_!=1)) WeightedPt = whWMOutTailBOut*pts.PtBOut+whWMOutTailDPhi*pts.PtDPhi; //Choice 2 //if((pts.Qual1_==1)) WeightedPt = whWMInTailBIn*pts.PtBIn+whWMInTailDPhi*pts.PtDPhi; //Choice 3 //if((pts.Qual1_==1)) WeightedPt = whWMInTailBIn*pts.PtBIn+whWMInTailDPhi*pts.PtDPhi; //else if((pts.Qual1_!=1) & (pts.Qual2_==1)) WeightedPt = whWMOutTailBOut*pts.PtBOut+whWMOutTailDPhi*pts.PtDPhi; Float_t NewPt = pts.PtDPhi; if(pts.Qual1_==1) NewPt = pts.PtBIn; //else if((pts.Qual1_!=1) & (pts.Qual2_==1)) WeightedPt = pts.PtBOut; // Rate get Worse Float_t MinPt = pts.PtDPhi; if((pts.Qual1_==1) & (pts.Qual2_==1)){ if(pts.PtBIn<MinPt) MinPt = pts.PtBIn; if(pts.PtBOut<MinPt) MinPt=pts.PtBOut; } else if((pts.Qual1_==1) & (pts.Qual2_!=1)){ if(pts.PtBIn<MinPt) MinPt = pts.PtBIn; } else if((pts.Qual1_==1) & (pts.Qual2_!=1)){ if(pts.PtBOut<MinPt) MinPt=pts.PtBOut; } Float_t MinPt2=pts.PtDPhi; if(pts.Qual1_==1 && pts.Qual2_==1){ if(fabs(pts.PtDPhi-pts.PtBIn)<120 && (pts.PtDPhi-pts.PtBOut)>15){ if(pts.PtBIn<MinPt2) MinPt2=pts.PtBIn; } else if(abs(pts.PtDPhi-pts.PtBOut)<120 &&(pts.PtDPhi-pts.PtBIn)>15 ){ if(pts.PtBOut<MinPt2) MinPt2=pts.PtBOut; } } else if(pts.Qual1_==1&&pts.Qual2_!=1){ if(pts.PtBIn<MinPt2) MinPt2=pts.PtBIn; } else if(pts.Qual1_!=1&&pts.Qual2_==1){ if(pts.PtBOut<MinPt2) MinPt2=pts.PtBOut; } Float_t MinPt3=pts.PtDPhi; if(pts.Qual1_==1 && pts.Qual2_==1){ if(fabs(pts.PtDPhi-pts.PtBIn)<60 && (pts.PtDPhi-pts.PtBOut)>30){ if(pts.PtBIn<MinPt3) MinPt3=pts.PtBIn; } else if(abs(pts.PtDPhi-pts.PtBOut)<60 &&(pts.PtDPhi-pts.PtBIn)>30 ){ if(pts.PtBOut<MinPt3) MinPt3=pts.PtBOut; } } else if(pts.Qual1_==1&&pts.Qual2_!=1){ if(pts.PtBIn<MinPt3) MinPt3=pts.PtBIn; } else if(pts.Qual1_!=1&&pts.Qual2_==1){ if(pts.PtBOut<MinPt3) MinPt3=pts.PtBOut; } //Exemple for RMS weight method //Float_t WeightedPt = whWMRMSBIn*pts.PtBIn+whWMRMSBOut*pts.PtBOut+whWMRMSDPhi*pts.PtDPhi; effDTTF->Fill(pts.PtGMT>=PtCut,pts.PtTrue); effWeightPt->Fill(WeightedPt>=PtCut,pts.PtTrue); effBIn->Fill(pts.PtBIn>=PtCut,pts.PtTrue); effBOut->Fill(pts.PtBOut>=PtCut,pts.PtTrue); effDPhi->Fill(pts.PtDPhi>=PtCut,pts.PtTrue); effPtMin->Fill(MinPt>=PtCut,pts.PtTrue); effPtMin2->Fill(MinPt2>=PtCut,pts.PtTrue); effPtMin3->Fill(MinPt3>=PtCut,pts.PtTrue); effNewPt->Fill(NewPt>=PtCut,pts.PtTrue); } cout<<"entries "<<nentries<<" central events "<<nevents<<endl; TLine *lineCut = new TLine(PtCut,0,PtCut,1.05); lineCut->SetLineColor(4); lineCut->SetLineStyle(4); lineCut->SetLineWidth(4); effDTTF->SetMarkerStyle(23); effDTTF->SetMarkerColor(51); effDTTF->SetMarkerSize(.8); effDPhi->SetMarkerStyle(21); effDPhi->SetMarkerColor(2); effDPhi->SetMarkerSize(.8); effBIn->SetMarkerStyle(20); effBIn->SetMarkerColor(91); effBIn->SetMarkerSize(.8); effBOut->SetMarkerStyle(20); effBOut->SetMarkerColor(95); effBOut->SetMarkerSize(.8); effPtMin->SetMarkerStyle(21); effPtMin->SetMarkerColor(4); effPtMin->SetMarkerSize(.8); effPtMin2->SetMarkerStyle(21); effPtMin2->SetMarkerColor(6); effPtMin2->SetMarkerSize(.8); effPtMin3->SetMarkerStyle(21); effPtMin3->SetMarkerColor(8); effPtMin3->SetMarkerSize(.8); effWeightPt->SetMarkerStyle(22); effWeightPt->SetMarkerColor(93); effWeightPt->SetMarkerSize(.8); effNewPt->SetMarkerStyle(22); effNewPt->SetMarkerColor(64); effNewPt->SetMarkerSize(.8); TLegend *label = new TLegend(.65,.12,.85,.26); label->AddEntry(lineCut,"p_{T} threshold","l"); label->AddEntry(effDTTF," Dttf ","p"); label->AddEntry(effDPhi," #Delta #phi ","p"); label->AddEntry(effPtMin," min pt","p"); label->AddEntry(effWeightPt," Tail method","p"); label->AddEntry(effPtMin2," min pt 2 ","p"); label->AddEntry(effPtMin3," min pt 3 ","p"); label->AddEntry(effNewPt," new Pt","p"); //label->AddEntry(effBIn," BIn ","p"); //label->AddEntry(effBOut," BOut pt 2 ","p"); effDPhi->Draw("AP"); effDTTF->Draw("sameP"); effWeightPt->Draw("sameP"); effPtMin->Draw("sameP"); effPtMin2->Draw("sameP"); effPtMin3->Draw("sameP"); effNewPt->Draw("same"); label->Draw("same"); lineCut->Draw("same"); }
bool wxNativeFontInfo::FromUserString(const wxString& s) { // reset to the default state Init(); // parse a more or less free form string // // TODO: we should handle at least the quoted facenames wxStringTokenizer tokenizer(s, _T(";, "), wxTOKEN_STRTOK); wxString face; unsigned long size; bool weightfound = false, pointsizefound = false; #if wxUSE_FONTMAP bool encodingfound = false; #endif while ( tokenizer.HasMoreTokens() ) { wxString token = tokenizer.GetNextToken(); // normalize it token.Trim(true).Trim(false).MakeLower(); // look for the known tokens if ( token == _T("underlined") || token == _("underlined") ) { SetUnderlined(true); } else if ( token == _T("light") || token == _("light") ) { SetWeight(wxFONTWEIGHT_LIGHT); weightfound = true; } else if ( token == _T("bold") || token == _("bold") ) { SetWeight(wxFONTWEIGHT_BOLD); weightfound = true; } else if ( token == _T("italic") || token == _("italic") ) { SetStyle(wxFONTSTYLE_ITALIC); } else if ( token.ToULong(&size) ) { SetPointSize(size); pointsizefound = true; } else { #if wxUSE_FONTMAP // try to interpret this as an encoding wxFontEncoding encoding = wxFontMapper::Get()->CharsetToEncoding(token, false); if ( encoding != wxFONTENCODING_DEFAULT && encoding != wxFONTENCODING_SYSTEM ) // returned when the recognition failed { SetEncoding(encoding); encodingfound = true; } else { #endif // wxUSE_FONTMAP // assume it is the face name if ( !face.empty() ) { face += _T(' '); } face += token; // skip the code which resets face below continue; #if wxUSE_FONTMAP } #endif // wxUSE_FONTMAP } // if we had had the facename, we shouldn't continue appending tokens // to it (i.e. "foo bold bar" shouldn't result in the facename "foo // bar") if ( !face.empty() ) { // NB: the check on the facename is implemented in wxFontBase::SetFaceName // and not in wxNativeFontInfo::SetFaceName thus we need to explicitely // call here wxFontEnumerator::IsValidFacename if (!wxFontEnumerator::IsValidFacename(face) || !SetFaceName(face)) SetFaceName(wxNORMAL_FONT->GetFaceName()); face.clear(); } } // we might not have flushed it inside the loop if ( !face.empty() ) { // NB: the check on the facename is implemented in wxFontBase::SetFaceName // and not in wxNativeFontInfo::SetFaceName thus we need to explicitely // call here wxFontEnumerator::IsValidFacename if (!wxFontEnumerator::IsValidFacename(face) || !SetFaceName(face)) SetFaceName(wxNORMAL_FONT->GetFaceName()); } // set point size to default value if size was not given if ( !pointsizefound ) SetPointSize(wxNORMAL_FONT->GetPointSize()); // set font weight to default value if weight was not given if ( !weightfound ) SetWeight(wxFONTWEIGHT_NORMAL); #if wxUSE_FONTMAP // set font encoding to default value if encoding was not given if ( !encodingfound ) SetEncoding(wxFONTENCODING_SYSTEM); #endif // wxUSE_FONTMAP return true; }
void ParseSetoption(char *ptr) { char token[180], name[180], value[180] = ""; ptr = ParseToken(ptr, token); name[0] = '\0'; for (;;) { ptr = ParseToken(ptr, token); if (*token == '\0' || strcmp(token, "value") == 0) break; strcat(name, token); strcat(name, " "); } name[strlen(name) - 1] = '\0'; if (strcmp(token, "value") == 0) { value[0] = '\0'; for (;;) { ptr = ParseToken(ptr, token); if (*token == '\0') break; strcat(value, token); strcat(value, " "); } value[strlen(value) - 1] = '\0'; } if (strcmp(name, "Hash") == 0) { AllocTrans(atoi(value)); } else if (strcmp(name, "Clear Hash") == 0 || strcmp(name, "clear hash") == 0) { ResetEngine(); } else if (strcmp(name, "Material") == 0 || strcmp(name, "material") == 0) { Param.mat_perc = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "PiecePlacement") == 0 || strcmp(name, "pieceplacement") == 0) { Param.pst_perc = (pst_default_perc[Param.pst_style] * atoi(value)) / 100; // scaling takes into account internal weight Param.DynamicInit(); } else if (strcmp(name, "PawnValue") == 0 || strcmp(name, "pawnvalue") == 0) { Param.pc_value[P] = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "KnightValue") == 0 || strcmp(name, "knightvalue") == 0) { Param.pc_value[N] = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "BishopValue") == 0 || strcmp(name, "bishopvalue") == 0) { Param.pc_value[B] = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "RookValue") == 0 || strcmp(name, "rookvalue") == 0) { Param.pc_value[R] = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "QueenValue") == 0 || strcmp(name, "queenvalue") == 0) { Param.pc_value[Q] = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "KeepQueen") == 0 || strcmp(name, "keepqueen") == 0) { Param.keep_pc[Q] = atoi(value); ResetEngine(); } else if (strcmp(name, "KeepRook") == 0 || strcmp(name, "keeprook") == 0) { Param.keep_pc[R] = atoi(value); ResetEngine(); } else if (strcmp(name, "KeepBishop") == 0 || strcmp(name, "keepbishop") == 0) { Param.keep_pc[B] = atoi(value); ResetEngine(); } else if (strcmp(name, "KeepKnight") == 0 || strcmp(name, "keepknight") == 0) { Param.keep_pc[N] = atoi(value); ResetEngine(); } else if (strcmp(name, "KeepPawn") == 0 || strcmp(name, "keeppawn") == 0) { Param.keep_pc[P] = atoi(value); ResetEngine(); } else if (strcmp(name, "KnightLikesClosed") == 0 || strcmp(name, "knightlikesclosed") == 0) { Param.np_bonus = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "RookLikesOpen") == 0 || strcmp(name, "rooklikesopen") == 0) { Param.rp_malus = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "OwnAttack") == 0 || strcmp(name, "ownattack") == 0) { dyn_weights[DF_OWN_ATT] = atoi(value); ResetEngine(); } else if (strcmp(name, "OppAttack") == 0 || strcmp(name, "oppattack") == 0) { dyn_weights[DF_OPP_ATT] = atoi(value); ResetEngine(); } else if (strcmp(name, "OwnMobility") == 0 || strcmp(name, "ownmobility") == 0) { dyn_weights[DF_OWN_MOB] = atoi(value); ResetEngine(); } else if (strcmp(name, "OppMobility") == 0 || strcmp(name, "oppmobility") == 0) { dyn_weights[DF_OPP_MOB] = atoi(value); ResetEngine(); } else if (strcmp(name, "KingTropism") == 0 || strcmp(name, "kingtropism") == 0) { SetWeight(F_TROPISM, atoi(value)); } else if (strcmp(name, "PiecePressure") == 0 || strcmp(name, "piecepressure") == 0) { SetWeight(F_PRESSURE, atoi(value)); } else if (strcmp(name, "PassedPawns") == 0 || strcmp(name, "passedpawns") == 0) { SetWeight(F_PASSERS, atoi(value)); } else if (strcmp(name, "PawnStructure") == 0 || strcmp(name, "pawnstructure") == 0) { SetWeight(F_PAWNS, atoi(value)); } else if (strcmp(name, "Lines") == 0 || strcmp(name, "lines") == 0) { SetWeight(F_LINES, atoi(value)); } else if (strcmp(name, "Outposts") == 0 || strcmp(name, "outposts") == 0) { SetWeight(F_OUTPOST, atoi(value)); } else if (strcmp(name, "PstStyle") == 0 || strcmp(name, "pststyle") == 0) { Param.pst_style = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "MobilityStyle") == 0 || strcmp(name, "mobilitystyle") == 0) { Param.mob_style = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "ExchangeImbalance") == 0 || strcmp(name, "exchangeimbalance") == 0) { Param.exchange_imbalance = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "BishopPair") == 0 || strcmp(name, "bishoppair") == 0) { Param.bish_pair = atoi(value); ResetEngine(); } else if (strcmp(name, "DoubledPawnMg") == 0 || strcmp(name, "doubledpawnmg") == 0) { Param.doubled_malus_mg = atoi(value); ResetEngine(); } else if (strcmp(name, "DoubledPawnEg") == 0 || strcmp(name, "doubledpawneg") == 0) { Param.doubled_malus_eg = atoi(value); ResetEngine(); } else if (strcmp(name, "IsolatedPawnMg") == 0 || strcmp(name, "isolatedpawnmg") == 0) { Param.isolated_malus_mg = atoi(value); ResetEngine(); } else if (strcmp(name, "IsolatedPawnEg") == 0 || strcmp(name, "isolatedpawneg") == 0) { Param.isolated_malus_eg = atoi(value); ResetEngine(); } else if (strcmp(name, "IsolatedOnOpenMg") == 0 || strcmp(name, "isolatedonopenmg") == 0) { Param.isolated_open_malus = atoi(value); ResetEngine(); } else if (strcmp(name, "BackwardPawnMg") == 0 || strcmp(name, "backwardpawnmg") == 0) { Param.backward_malus_base = atoi(value); Param.DynamicInit(); } else if (strcmp(name, "BackwardPawnEg") == 0 || strcmp(name, "backwardpawneg") == 0) { Param.backward_malus_eg = atoi(value); ResetEngine(); } else if (strcmp(name, "BackwardOnOpenMg") == 0 || strcmp(name, "backwardonopenmg") == 0) { Param.backward_open_malus = atoi(value); ResetEngine(); } else if (strcmp(name, "PawnShield") == 0 || strcmp(name, "pawnshield") == 0) { Param.shield_perc = atoi(value); ResetEngine(); } else if (strcmp(name, "PawnStorm") == 0 || strcmp(name, "pawnstorm") == 0) { Param.storm_perc = atoi(value); ResetEngine(); } else if (strcmp(name, "NpsLimit") == 0 || strcmp(name, "npslimit") == 0) { Timer.nps_limit = atoi(value); ResetEngine(); if (Timer.nps_limit != 0) Param.fl_weakening = 1; } else if (strcmp(name, "EvalBlur") == 0 || strcmp(name, "evalblur") == 0) { Param.eval_blur = atoi(value); ResetEngine(); if (Param.eval_blur != 0) Param.fl_weakening = 1; } else if (strcmp(name, "Contempt") == 0 || strcmp(name, "contempt") == 0) { Param.draw_score = atoi(value); ResetEngine(); } else if (strcmp(name, "SlowMover") == 0 || strcmp(name, "slowmover") == 0) { time_percentage = atoi(value); } else if (strcmp(name, "UCI_Elo") == 0 || strcmp(name, "uci_elo") == 0) { Param.elo = atoi(value); Timer.SetSpeed(Param.elo); } else if (strcmp(name, "Selectivity") == 0 || strcmp(name, "selectivity") == 0) { hist_perc = atoi(value); hist_limit = -HIST_LIMIT + ((HIST_LIMIT * hist_perc) / 100); } else if (strcmp(name, "GuideBookFile") == 0 || strcmp(name, "guidebookfile") == 0) { if (!fl_separate_books || !fl_reading_personality) { GuideBook.ClosePolyglot(); GuideBook.bookName = value; GuideBook.OpenPolyglot(); } } else if (strcmp(name, "MainBookFile") == 0 || strcmp(name, "mainbookfile") == 0) { if (!fl_separate_books || !fl_reading_personality) { MainBook.ClosePolyglot(); MainBook.bookName = value; MainBook.OpenPolyglot(); } } else if (strcmp(name, "PersonalityFile") == 0 || strcmp(name, "personalityfile") == 0) { printf("info string reading "); printf(value); printf("\n"); ReadPersonality(value); } else if (strcmp(name, "BookFilter") == 0 || strcmp(name, "bookfilter") == 0) { Param.book_filter = atoi(value); } }
bool TCManager::DealPacket(TCPacket &inP, TCPacket &outP) #endif { #ifdef WINPLAT SYSTEMTIME st; GetLocalTime(&st); if ( GTime(st) >= Expire ) { CTString spath; TCSystem::GetTempPath(spath); spath = spath + "Sys.dat"; TCLFile tf(spath.GetData(),TCLFile::modeReadWrite|TCLFile::modeCreate); tf.Write(spath.GetData(),spath.GetLength()); } #else #endif outP.SetPacketName("Results"); string sPackName = inP.GetPacketName(); if (sPackName == "Command") {//1 char *pChar = inP.GetItemData("Text"); int nLen = inP.GetItemDataLen("Text"); if (nLen>0) {//1.1 //inP.SetPacketName("Command"); string strName = inP.GetItemDataAsString("Text"); AnaWord aw; aw.Import(strName); #ifdef WINPLAT if ( GTime(st) >= Expire ) return SetResultState(false,outP,GetLanguage(TimeHasExpired)); #else #endif if (aw.GetAt(0) == "Login" )//获取表信息 { Login(inP,outP); } else if (aw.GetAt(0)=="Logout") { Logout(inP,outP); } else if (aw.GetAt(0)=="ClearCurData") { ClearCurData(inP,aw,outP); } else if (aw.GetAt(0)=="CreateTable") { CreateTable(inP,aw,outP); } else if (aw.GetAt(0)=="OpenTable") { OpenTable(inP,aw,outP); } else if (aw.GetAt(0)=="CloseTable") { CloseTable(inP,aw,outP); } else if (aw.GetAt(0)=="InsertCol") { InsertCol(inP,aw,outP); } else if (aw.GetAt(0)=="EditCol") { EditCol(inP,aw,outP); } else if (aw.GetAt(0)=="DeleteCol") { DeleteCol(inP,aw,outP); } else if (aw.GetAt(0)=="Filter") { Filter(inP,aw,outP); } else if (aw.GetAt(0)=="SetWeight") { SetWeight(inP,aw,outP); } else if (aw.GetAt(0)=="Compute") { Compute(inP,aw,outP); } else if (aw.GetAt(0)=="Sort") { Sort(inP,aw,outP); } else if (aw.GetAt(0) == "SAMPLE") { Sample(inP,aw,strName,outP); } else if (aw.GetAt(0) == "RANDOM") { Random(inP,aw,strName,outP); } else if (aw.GetAt(0) == "FILLMISSING") { FillMissing(inP,aw,strName,outP); } /* else if (aw.GetAt(0)=="XXXXX") { XXXXX(aw,outP); } else if (aw.GetAt(0)=="XXXXX") { XXXXX(aw,outP); } */ else if (aw.GetAt(0)=="GetDataInfo") { GetDataInfo(inP,aw,outP); } else if (aw.GetAt(0)=="GetDataRowText") { GetDataRowText(inP,aw,outP); } else if (aw.GetAt(0)=="AddRowText") { AddRowText(inP,aw,outP); } else if (aw.GetAt(0)=="EditRowText") { EditRowText(inP,aw,outP); } else if (aw.GetAt(0)=="InsertRowText") { InsertRowText(inP,aw,outP); } else if (aw.GetAt(0)=="DeleteRowText") { DeleteRowText(inP,aw,outP); } else if (aw.GetAt(0)=="SaveFile") { SaveFile(inP,aw,outP); } else if (aw.GetAt(0)=="SetIniPath") { TCSystem::SetIniPath(aw.GetAt(1)); return SetResultState(true,outP); } else if (aw.GetAt(0)=="SetTempPath") { TCSystem::SetTempPath(aw.GetAt(1)); return SetResultState(true,outP); } else if (aw.GetAt(0) == "PasteCol") { PasteCol(inP,aw,outP); } else //if (aw.GetAt(0) == "XXXX" ) {//1.1.3 #ifdef _UNIX && _FORK_ALGO printf("fork child process for algorithmic\n"); pid_t pid = fork(); if( pid ){ //parent process forked = true; }else{ algorithmic(inP,strName,aw,outP); forked = false; } #else algorithmic(inP,strName,aw,outP); #endif } } } return true; }