本文整理汇总了C++中pref函数的典型用法代码示例。如果您正苦于以下问题:C++ pref函数的具体用法?C++ pref怎么用?C++ pref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pref函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doRender
void doRender(Renderer::RenderContext& renderContext) {
const Model::BrushFace* face = m_helper.face();
const Mat4x4 fromFace = face->fromTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
const Plane3& boundary = face->boundary();
const Mat4x4 toPlane = planeProjectionMatrix(boundary.distance, boundary.normal);
const Mat4x4 fromPlane = invertedMatrix(toPlane);
const Vec2f originPosition(toPlane * fromFace * Vec3(m_helper.originInFaceCoords()));
const Vec2f faceCenterPosition(toPlane * m_helper.face()->boundsCenter());
const Color& handleColor = pref(Preferences::HandleColor);
const Color& highlightColor = pref(Preferences::SelectedHandleColor);
Renderer::ActiveShader shader(renderContext.shaderManager(), Renderer::Shaders::VaryingPUniformCShader);
const Renderer::MultiplyModelMatrix toWorldTransform(renderContext.transformation(), fromPlane);
{
const Mat4x4 translation = translationMatrix(Vec3(originPosition));
const Renderer::MultiplyModelMatrix centerTransform(renderContext.transformation(), translation);
if (m_highlight)
shader.set("Color", highlightColor);
else
shader.set("Color", handleColor);
m_outer.render();
}
{
const Mat4x4 translation = translationMatrix(Vec3(faceCenterPosition));
const Renderer::MultiplyModelMatrix centerTransform(renderContext.transformation(), translation);
shader.set("Color", highlightColor);
m_center.render();
}
}
示例2: renderService
void VertexHandleManager::renderHighlight(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch, const Vec3& position) {
Renderer::RenderService renderService(renderContext, renderBatch);
renderService.setForegroundColor(pref(Preferences::SelectedHandleColor));
renderService.renderPointHandleHighlight(position);
renderService.setForegroundColor(pref(Preferences::SelectedInfoOverlayTextColor));
renderService.setBackgroundColor(pref(Preferences::SelectedInfoOverlayBackgroundColor));
renderService.renderString(position.asString(), position);
}
示例3: main
int main() {
//tam de columnas y columnas de las matrices de hombres y mujeres
int columnas = 4;
//matriz de preferencias de hombres y mujeres
std::vector<std::vector<int>> pref(2 * columnas, std::vector<int>(columnas));
//se llena la matriz con las preferencias
pref =
{
//hombres
{ 4, 5, 6, 7 }, //hombre 0
{ 5, 6, 7, 4 }, //hombre 1
{ 6, 7, 4, 5 }, //hombre 2
{ 7, 4, 5, 6 }, //hombre 3
//mujeres
{ 0, 1, 2, 3 }, //mujer 4
{ 1, 2, 3, 0 }, //mujer 5
{ 2, 3, 0, 1 }, //mujer 6
{ 3, 0, 1, 2 }, //mujer 7
};
asignarParejas(pref, columnas);
}//cierre del main
示例4: lauchGame
//Event de double click
void GameButton::mouseDoubleClickEvent(QMouseEvent* e)
{
e->accept();
bool lauchGame(true); //Représente si le jeu peut être lancé ou non
if(pwd) //Si verif de mdp alors verif de mdp
lauchGame = SplashScreen::verifPwd();
//Si le jeu peut être lancé
if(lauchGame)
{
QLogger::QLog_Info("game", "Info : Tentative de lancement : " + path);
//Si on réussis à relacher le clavier
if(unhookKB())
{
//On update certaine stats
QSettings* pref(new QSettings("stats/" + nom + ".ini", QSettings::IniFormat));
int val(pref->value("launch", QVariant(0)).toInt());
pref->setValue("launch", QVariant(val+1));
delete pref;
//Si c'est un jeu steam, on va chercher l'exe steam qu'on lance avec certain arguments
if(steam)
proc->start(QSettings("pref.ini", QSettings::IniFormat).value("steamPath").toString(), QStringList() << "-applaunch" << gameID);
else //Sinon on lance le jeu tout simplement
proc->start(path);
}
else
QMessageBox::warning(0, "Erreur", "Le système refuse de relâcher la capture clavier");
}
}
示例5: MsgNewAtom
nsresult nsStatusBarBiffManager::Init()
{
if (mInitialized)
return NS_ERROR_ALREADY_INITIALIZED;
nsresult rv;
kBiffStateAtom = MsgNewAtom("BiffState").get();
nsCOMPtr<nsIMsgMailSession> mailSession =
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
if(NS_SUCCEEDED(rv))
mailSession->AddFolderListener(this, nsIFolderListener::intPropertyChanged);
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
bool chatEnabled = false;
if (NS_SUCCEEDED(rv))
rv = pref->GetBoolPref(PREF_CHAT_ENABLED, &chatEnabled);
if (NS_SUCCEEDED(rv) && chatEnabled) {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService)
observerService->AddObserver(this, NEW_CHAT_MESSAGE_TOPIC, false);
}
mInitialized = true;
return NS_OK;
}
示例6: pref
NS_IMETHODIMP
nsStatusBarBiffManager::OnItemIntPropertyChanged(nsIMsgFolder *item, nsIAtom *property, int32_t oldValue, int32_t newValue)
{
if (kBiffStateAtom == property && mCurrentBiffState != newValue) {
// if we got new mail, attempt to play a sound.
// if we fail along the way, don't return.
// we still need to update the UI.
if (newValue == nsIMsgFolder::nsMsgBiffState_NewMail) {
nsresult rv;
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
bool playSoundOnBiff = false;
rv = pref->GetBoolPref(PREF_PLAY_SOUND_ON_NEW_MAIL, &playSoundOnBiff);
NS_ENSURE_SUCCESS(rv, rv);
if (playSoundOnBiff) {
// if we fail to play the biff sound, keep going.
(void)PlayBiffSound();
}
}
mCurrentBiffState = newValue;
// don't care if notification fails
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService)
observerService->NotifyObservers(static_cast<nsIStatusBarBiffManager*>(this), "mail:biff-state-changed", nullptr);
}
return NS_OK;
}
示例7: pref
bool FUNCDISTANCE::execute(void)
{
bool result= false;
VMREGTYPE target= 0;
VMFLOAT distance= 0;
VMPTR<TES3REFERENCE*> pref(machine);
VMPTR<TES3REFERENCE> thisref(machine);
VMPTR<TES3REFERENCE> targetref(machine);
try
{
if(machine.pop(target))
{
pref= (TES3REFERENCE**)reltolinear(SCRIPTTARGETREF_IMAGE);
thisref= *pref;
targetref= (TES3REFERENCE*)target;
FLOAT dx= targetref->x - thisref->x;
FLOAT dy= targetref->y - thisref->y;
FLOAT dz= targetref->z - thisref->z;
distance= sqrt(dx*dx+dy*dy+dz*dz);
result= machine.push(distance);
}
}
catch(...)
{
result= false;
}
return result;
}
示例8: pref
bool FUNCREFID::execute(void)
{
bool result= false;
VMPTR<TES3REFERENCE*> pref(machine);
VMPTR<TES3REFERENCE> ref(machine);
VMPTR<TES3TEMPLATE> templ(machine);
VMPTR<TES3IDSTRING> id(machine);
const char* idstring= "null";
try
{
pref= (TES3REFERENCE**)reltolinear(SCRIPTTARGETREF_IMAGE);
ref= *pref;
templ= ref->templ;
id= (VPIDSTRING)templ->objectid;
idstring= strings.add((const char*)id->id);
result= machine.push((VMREGTYPE)idstring);
}
catch(...)
{
result= false;
}
return result;
}
示例9: output
void output()
{
ConnectionList& cl(gConnectionList);
if(!cl.empty()) {
ConnectionMap::iterator it = cl.getBeginUnlocked();
mux_t mux = it->first;
ConnectionParam& conn(it->second);
std::cout << "Client " << mux << ": " ;
if(conn.remote_end_==PacketSourceEndpoint()) {
std::cout<< "not registered";
} else {
std::cout<< conn.remote_end_;
}
std::cout << std::endl;
//std::cout << "Connection: Keyderivation-Type: " << conn.kd_.printType() << std::endl;
cl.clear();
} else {
network_address_type_t types[] = {ipv4,ipv6,ethernet};
for(int types_idx=0; types_idx<3; types_idx++) {
network_address_type_t type = types[types_idx];
if(!gRoutingTable.empty(type)) {
RoutingMap::iterator it = gRoutingTable.getBeginUnlocked(type);
NetworkPrefix pref(it->first);
std::cout << "Route: " << pref.toString() << "/" << (int)pref.getNetworkPrefixLength() << " -> ";
mux_t mux = it->second;
std::cout << mux << std::endl;
gRoutingTable.clear(type);
}
}
}
}
示例10: pref
QFont Highlighter::readFontSettings()
{
QSettings pref( "Castano Inc", "QShaderEdit" );
pref.beginGroup("CodeEditor");
QString name;
int size=0;
#if defined(Q_OS_DARWIN)
name = pref.value("font","Monaco").toString();
size = pref.value("size",11).toInt();
#elif defined(Q_OS_WIN32)
name = pref.value("font","Courier").toString();
size = pref.value("size",8).toInt();
#else
name = pref.value("font","Monospace").toString();
size = pref.value("size",8).toInt();
#endif
QFont m_font;// = QApplication::font();
m_font.setFamily(name);
m_font.setPointSize(size);
m_font.setFixedPitch(true);
pref.endGroup();
return m_font;
}
示例11: main
int main() {
#ifdef ssu1
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
scanf("%d", &n);
std::vector<int> a, x(n);
for (int i = 0; i < n; ++i) {
scanf("%d", &x[i]);
}
std::sort(x.begin(), x.end());
for (int i = 0; i + 1 < n; ++i) {
a.push_back(x[i + 1] - x[i]);
}
int cnt = (n - 2) / 2 + (n % 2);
std::vector<int> pref(a.size() + 1);
for (int i = 1; i < pref.size(); ++i) {
pref[i] = pref[i - 1] + a[i - 1];
}
int sumsuf = 0, ans = 0;
for (int cntsuf = 0; cntsuf <= cnt; ++cntsuf) {
if (cntsuf > 0) {
sumsuf += a[a.size() - cntsuf];
}
ans = std::max(ans, sumsuf + pref[cnt - cntsuf]);
}
printf("%d\n", pref.back() - ans);
return 0;
}
示例12: pref
void CodeGen::genCodeForTreeFloat(GenTreePtr tree,
regMaskTP needReg,
regMaskTP bestReg)
{
RegSet::RegisterPreference pref(needReg, bestReg);
genCodeForTreeFloat(tree, &pref);
}
示例13: AddCustomHeader
static int32_t AddCustomHeader(const char* pHeader)
{
nsresult rv;
int32_t index = -1;
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, index);
nsAutoCString headers;
pref->GetCharPref(MAILNEWS_CUSTOM_HEADERS, getter_Copies(headers));
index = 0;
if (!headers.IsEmpty())
{
char *headersString = ToNewCString(headers);
nsAutoCString hdrStr;
hdrStr.Adopt(headersString);
hdrStr.StripWhitespace(); //remove whitespace before parsing
char *newStr = headersString;
char *token = NS_strtok(":", &newStr);
while (token)
{
if (!PL_strcasecmp(token, pHeader))
return index;
token = NS_strtok(":", &newStr);
index++;
}
headers += ":";
}
headers += pHeader;
pref->SetCharPref(MAILNEWS_CUSTOM_HEADERS, headers.get());
return index;
}
示例14: pref
nsSize
nsBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
{
nsSize pref (0, 0);
AddBorderAndPadding(aBox, pref);
return pref;
}
示例15: BoyerMoore
vector<int> BoyerMoore(const string& str, istream& in) {
//----------stopTable--
int stopTable[256];
for(int i = 0; i < 256; ++i)
stopTable[i] = 0;
for(int i = 0; i < str.length(); ++i)
stopTable[unsigned char(str[i])] = i;
//-------------------
vector<int> suffTable(str.length() + 1);
PrefixFunc pref(str);
string strReverse(str.length(), 'a');
for(int i = 0; i < str.length(); ++i)
strReverse[i] = str[str.length() - i - 1];
PrefixFunc prefReverse(strReverse);
for(int i = 0; i < str.length() + 1; ++i)
suffTable[i] = str.length() - pref[str.length() - 1];
for(int i = 1; i < str.length(); ++i) {
int j = prefReverse[i];
if(j != 0)
suffTable[j] = min(suffTable[j], i - j + 1);
}
//-----------
int posEnd = str.length() - 1;
int posCompare = 0;
string text = "";
char c;
while(in >> c)
text = text + c;
//------------
vector<int> result;
while(posEnd < text.length()) {
bool flag = true;
while(posCompare < str.length()) {
if(str[str.length() - 1 - posCompare] != text[posEnd - posCompare]) {
flag = false;
break;
}
++posCompare;
}
if(flag) {
result.push_back(posEnd - str.length() + 1);
++posEnd;
posCompare = 0;
} else {
if(posCompare > 0)
posEnd += shift(text[posEnd - posCompare], str[0], str.length() - posCompare - 1,
stopTable[unsigned char(text[posEnd - posCompare])], suffTable[posCompare - 1]);
else
posEnd += shift(text[posEnd - posCompare], str[0], str.length() - posCompare - 1,
stopTable[unsigned char(text[posEnd - posCompare])], 1);
posCompare = 0;
}
}