void Camera::Init() { if( pPlayerState != GameProcess ) { return; } // ---- SetFloat((LPVOID)oCam_Zoom, this->Default.Zoom); SetFloat((LPVOID)oCam_RotY, this->Default.RotationY); SetFloat((LPVOID)oCam_RotZ, this->Default.RotationZ); SetDouble((LPVOID)oCam_PosZ, this->Default.PositionZ); #if defined __BEREZNUK__ || __ALIEN__ SetDouble((LPVOID)oCam_ClipX, this->Default.ClipX + 500); SetFloat((LPVOID)oCam_ClipGL, this->Default.ClipGL + 200); #else SetDouble((LPVOID)oCam_ClipX, this->Default.ClipX); SetFloat((LPVOID)oCam_ClipGL, this->Default.ClipGL); #endif SetFloat((LPVOID)oCam_ClipY, this->Default.ClipY); SetDouble((LPVOID)oCam_ClipZ, this->Default.ClipZ); SetDouble((LPVOID)oCam_ClipX2, this->Default.ClipX2); SetFloat((LPVOID)oCam_ClipY2, this->Default.ClipY2); SetFloat((LPVOID)oCam_ClipZ2, this->Default.ClipZ2); // ---- _beginthread(Return, 0, NULL); _beginthread(FreeMemory, 0, NULL); this->ZoomPercent = *(float*)oCam_Zoom / ((float)ZOOM_MAX / 100.0f); }
// ---------------------------------------------------------------------------------------------- void Camera::Position() { if (!this->IsActive) { return; } // ---- if (this->InMove) { if (this->TempCursorY < gObjUser.m_CursorY) { if (*(float*)oCam_RotY < -45) { SetDouble((LPVOID)oCam_PosZ, *(double*)oCam_PosZ - 44); SetFloat((LPVOID)oCam_RotY, *(float*)oCam_RotY + (double)2.42); } } else if (this->TempCursorY > gObjUser.m_CursorY) { if (*(float*)oCam_RotY > -90) { SetDouble((LPVOID)oCam_PosZ, *(double*)oCam_PosZ + 44); SetFloat((LPVOID)oCam_RotY, *(float*)oCam_RotY - (double)2.42); } } // ---- this->TempCursorY = gObjUser.m_CursorY; } }
void CXTPPropertyGridItemDouble::OnBeforeInsert() { if (m_pBindDouble && *m_pBindDouble != m_fValue) { SetDouble(*m_pBindDouble); } }
/************************************* * operator = *************************************/ SHVDataVariant& SHVDataVariantImpl::operator=(const SHVDataVariant& val) { switch (val.GetDataType()) { case SHVDataVariant::TypeInt: SetInt(val.AsInt()); break; case SHVDataVariant::TypeInt64: SetInt64(val.AsInt64()); break; case SHVDataVariant::TypeBool: SetBool(val.AsBool()); break; case SHVDataVariant::TypeDouble: SetDouble(val.AsDouble()); break; case SHVDataVariant::TypeString: SetString(val.AsString()); break; case SHVDataVariant::TypeTime: SetTime(val.AsTime()); break; } return *this; }
CXTPPropertyGridItemDouble::CXTPPropertyGridItemDouble(UINT nID, double fValue, LPCTSTR strFormat, double* pBindDouble) : CXTPPropertyGridItem(nID) { m_pBindDouble = pBindDouble; m_strFormat = strFormat; m_bUseSystemDecimalSymbol = m_strFormat.IsEmpty(); SetDouble(fValue); m_strDefaultValue = m_strValue; EnableAutomation(); }
bool NFCProperty::FromString( const std::string& strData ) { const TDATA_TYPE eType = GetType(); bool bRet = false; switch (eType) { case TDATA_INT: { NFINT64 nValue = 0; bRet = NF_StrTo(strData, nValue); SetInt(nValue); } break; case TDATA_FLOAT: { float fValue = 0; bRet = NF_StrTo(strData, fValue); SetFloat(fValue); } break; case TDATA_DOUBLE: { double dValue = 0; bRet = NF_StrTo(strData, dValue); SetDouble(dValue); } break; case TDATA_STRING: { SetString(strData); bRet = true; } break; case TDATA_OBJECT: { NFIDENTID xID; bRet = xID.FromString(strData); SetObject(xID); } break; default: break; } return bRet; }
void feature_extraction::map(int argc, const t_atom *argv) { GRT::VectorDouble input(argc); GRT::FeatureExtraction &feature_extractor = get_FeatureExtraction_instance(); if (argc <= 0 || (GRT::UINT)argc != feature_extractor.getNumInputDimensions()) { std::stringstream ss; ss << "invalid input length: " << argc << ", expected: " << feature_extractor.getNumInputDimensions(); error(ss.str()); return; } for (uint32_t index = 0; index < (uint32_t)argc; ++index) { double value = GetAFloat(argv[index]); input[index] = value; } bool success = feature_extractor.computeFeatures(input); if (success == false) { error("unable to map input"); return; } GRT::VectorDouble features = feature_extractor.getFeatureVector(); if (features.size() == 0 || features.size() != feature_extractor.getNumOutputDimensions()) { std::stringstream ss; ss << "unexpected output length: " << features.size() << ", expected: " << feature_extractor.getNumOutputDimensions(); error(ss.str()); return; } AtomList features_l; GRT::VectorDouble::iterator iterator; for (iterator = features.begin(); iterator != features.end(); iterator++) { t_atom feature_a; SetDouble(&feature_a, *iterator); features_l.Append(feature_a); } ToOutList(0, features_l); }
SmallConf &SmallConf::Assign(const SmallConf &o, SmallConf *root, SmallConf *local, SmallConf *artif, SmallConf *param) { if (&o == this) return (*this); switch (o.last_type) { case INTEGER: { int tmp; o.GetInt(&tmp, root, local, artif, param); SetInt(tmp); break ; } case DOUBLE: { double tmp; o.GetDouble(&tmp, root, local, artif, param); SetDouble(tmp); break ; } case STRING: { const char *tmp; o.GetString(&tmp, root, local, artif, param); SetString(tmp, false); break ; } case RAWSTRING: { const char *tmp; o.GetString(&tmp, root, local, artif, param); SetString(tmp, true); break ; } case NOTYPE: break ; } return (*this); }
void CMdbPara::SetNumber(register uint32 nFieldNo, register void* pVal, register uint32 nOperator) { switch(GetType(nFieldNo)) { case MDB_INT8_FIELD: SetInt8(nFieldNo, *(int8*)pVal, nOperator); break; case MDB_INT16_FIELD: SetInt16(nFieldNo, *(int16*)pVal, nOperator); break; case MDB_INT32_FIELD: SetInt32(nFieldNo, *(int32*)pVal, nOperator); break; case MDB_INT64_FIELD: SetInt64(nFieldNo, *(int64*)pVal, nOperator); break; case MDB_UINT8_FIELD: SetUInt8(nFieldNo, *(uint8*)pVal, nOperator); break; case MDB_UINT16_FIELD: SetUInt16(nFieldNo, *(uint16*)pVal, nOperator); break; case MDB_UINT32_FIELD: SetUInt32(nFieldNo, *(uint32*)pVal, nOperator); break; case MDB_UINT64_FIELD: SetUInt64(nFieldNo, *(uint64*)pVal, nOperator); break; case MDB_FLOAT_FIELD: SetFloat(nFieldNo, *(float*)pVal, nOperator); break; case MDB_DOUBLE_FIELD: SetDouble(nFieldNo, *(double*)pVal, nOperator); break; case MDB_DATE_FIELD: SetDate(nFieldNo, *(CDate*)pVal, nOperator); break; case MDB_TIME_FIELD: SetTime(nFieldNo, *(CTime*)pVal, nOperator); break; case MDB_DATETIME_FIELD: SetDateTime(nFieldNo, *(CDateTime*)pVal, nOperator); break; } }
void GroupElemJac::SetAdd(const GroupElemJac &p, const GroupElem &q) { if (p.fInfinity) { x = q.x; y = q.y; fInfinity = q.fInfinity; z = FieldElem(1); return; } if (q.fInfinity) { *this = p; return; } fInfinity = false; const FieldElem &x1 = p.x, &y1 = p.y, &z1 = p.z, &x2 = q.x, &y2 = q.y; FieldElem z12; z12.SetSquare(z1); FieldElem u1 = x1; u1.Normalize(); FieldElem u2; u2.SetMult(x2, z12); FieldElem s1 = y1; s1.Normalize(); FieldElem s2; s2.SetMult(y2, z12); s2.SetMult(s2, z1); u1.Normalize(); u2.Normalize(); if (u1 == u2) { s1.Normalize(); s2.Normalize(); if (s1 == s2) { SetDouble(p); } else { fInfinity = true; } return; } FieldElem h; h.SetNeg(u1,1); h += u2; FieldElem r; r.SetNeg(s1,1); r += s2; FieldElem r2; r2.SetSquare(r); FieldElem h2; h2.SetSquare(h); FieldElem h3; h3.SetMult(h,h2); z = p.z; z.SetMult(z, h); FieldElem t; t.SetMult(u1,h2); x = t; x *= 2; x += h3; x.SetNeg(x,3); x += r2; y.SetNeg(x,5); y += t; y.SetMult(y,r); h3.SetMult(h3,s1); h3.SetNeg(h3,1); y += h3; }
SmallConf &SmallConf::operator=(const SmallConf &o) { if (&o == this) return (*this); switch (o.last_type) { case INTEGER: { int tmp; o.GetInt(&tmp); SetInt(tmp); break ; } case DOUBLE: { double tmp; o.GetDouble(&tmp); SetDouble(tmp); break ; } case STRING: { const char *tmp; o.GetString(&tmp); SetString(tmp, false); break ; } case RAWSTRING: { const char *tmp; o.GetString(&tmp); SetString(tmp, true); break ; } case NOTYPE: break ; } return (*this); }
void ParamWidget::LoadState(const QVariant& variant) { QMap<QString, QVariant> data = variant.toMap(); for (auto& item : widgets_) { const QString& name = item.first; const QString qname = name; QWidget* widget = item.second; QVariant param_type = widget->property("param_widget_type"); QVariant value = data[qname]; assert(param_type.isValid()); switch (param_type.toInt()) { case kParamEnum: if (value.canConvert<int>()) { SetEnum(name, value.toInt()); } break; case kParamBool: if (value.canConvert<bool>()) { SetBool(name, value.toBool()); } break; case kParamInt: if (value.canConvert<int>()) { SetInt(name, value.toInt()); } break; case kParamDouble: if (value.canConvert<double>()) { SetDouble(name, value.toDouble()); } break; case kParamButton: default: assert(false); break; } } }
bool Pb2Json::Json2Message(const Json& json, ProtobufMsg& message, bool str2enum) { auto descriptor = message.GetDescriptor(); auto reflection = message.GetReflection(); if (nullptr == descriptor || nullptr == reflection) return false; auto count = descriptor->field_count(); for (auto i = 0; i < count; ++i) { const auto field = descriptor->field(i); if (nullptr == field) continue; auto& value = json[field->name()]; if (value.is_null()) continue; if (field->is_repeated()) { if (!value.is_array()) { return false; } else { Json2RepeatedMessage(value, message, field, reflection, str2enum); continue; } } switch (field->type()) { case ProtobufFieldDescriptor::TYPE_BOOL: { if (value.is_boolean()) reflection->SetBool(&message, field, value.get<bool>()); else if (value.is_number_integer()) reflection->SetBool(&message, field, value.get<uint32_t>() != 0); else if (value.is_string()) { if (value.get<std::string>() == "true") reflection->SetBool(&message, field, true); else if (value.get<std::string>() == "false") reflection->SetBool(&message, field, false); } } break; case ProtobufFieldDescriptor::TYPE_ENUM: { auto const* pedesc = field->enum_type(); const ::google::protobuf::EnumValueDescriptor* pevdesc = nullptr; if (str2enum) { pevdesc = pedesc->FindValueByName(value.get<std::string>()); } else { pevdesc = pedesc->FindValueByNumber(value.get<int>()); } if (nullptr != pevdesc) { reflection->SetEnum(&message, field, pevdesc); } } break; case ProtobufFieldDescriptor::TYPE_INT32: case ProtobufFieldDescriptor::TYPE_SINT32: case ProtobufFieldDescriptor::TYPE_SFIXED32: { if (value.is_number()) reflection->SetInt32(&message, field, value.get<int32_t>()); } break; case ProtobufFieldDescriptor::TYPE_UINT32: case ProtobufFieldDescriptor::TYPE_FIXED32: { if (value.is_number()) reflection->SetUInt32(&message, field, value.get<uint32_t>()); } break; case ProtobufFieldDescriptor::TYPE_INT64: case ProtobufFieldDescriptor::TYPE_SINT64: case ProtobufFieldDescriptor::TYPE_SFIXED64: { if (value.is_number()) reflection->SetInt64(&message, field, value.get<int64_t>()); } break; case ProtobufFieldDescriptor::TYPE_UINT64: case ProtobufFieldDescriptor::TYPE_FIXED64: { if (value.is_number()) reflection->SetUInt64(&message, field, value.get<uint64_t>()); } break; case ProtobufFieldDescriptor::TYPE_FLOAT: { if (value.is_number()) reflection->SetFloat(&message, field, value.get<float>()); } break; case ProtobufFieldDescriptor::TYPE_DOUBLE: { if (value.is_number()) reflection->SetDouble(&message, field, value.get<double>()); } break; case ProtobufFieldDescriptor::TYPE_STRING: case ProtobufFieldDescriptor::TYPE_BYTES: { if (value.is_string()) reflection->SetString(&message, field, value.get<std::string>()); } break; case ProtobufFieldDescriptor::TYPE_MESSAGE: { if (value.is_object()) Json2Message(value, *reflection->MutableMessage(&message, field)); } break; default: break; } } return true; }
bool Cx_XmlSection::SetFloat(const wchar_t* name, float value) { return SetDouble(name, value); }
void Camera::Run(MOUSEHOOKSTRUCTEX * Mouse, WPARAM wParam) { if( pMapNumber == 30 || pMapNumber == 31 ) { this->IsActive = false; this->Init(); } // ---- switch(wParam) { case WM_MOUSEWHEEL: { if( !this->IsActive || gInterface.CheckWindow(MoveList) ) { return; } // ---- if( (int)Mouse->mouseData > 0 ) { if( *(float*)oCam_Zoom < ZOOM_MAX ) { SetFloat((LPVOID)oCam_Zoom, *(float*)oCam_Zoom + ZOOM_INTER); } else { SetFloat((LPVOID)oCam_Zoom, (float)ZOOM_MAX); } } else if( (int)Mouse->mouseData < 0 ) { if( *(float*)oCam_Zoom > ZOOM_MIN ) { SetFloat((LPVOID)oCam_Zoom, *(float*)oCam_Zoom - ZOOM_INTER); } else { SetFloat((LPVOID)oCam_Zoom, (float)ZOOM_MIN); } } // ---- this->ZoomPercent = *(float*)oCam_Zoom / ((float)ZOOM_MAX / 100.0f); // ---- SetDouble((LPVOID)oCam_ClipX, PERCF(PERCF(this->Default.ClipX, 500), this->ZoomPercent)); SetFloat((LPVOID)oCam_ClipY, PERCF(PERCF(this->Default.ClipY, 285), this->ZoomPercent)); SetDouble((LPVOID)oCam_ClipZ, PERCF(PERCF(this->Default.ClipZ, -395), this->ZoomPercent)); SetDouble((LPVOID)oCam_ClipX2, PERCF(PERCF(this->Default.ClipX2, 235), this->ZoomPercent)); SetFloat((LPVOID)oCam_ClipY2, PERCF(PERCF(this->Default.ClipY2, 195), this->ZoomPercent)); SetFloat((LPVOID)oCam_ClipZ2, PERCF(PERCF(this->Default.ClipZ2, -4000), this->ZoomPercent)); SetFloat((LPVOID)oCam_ClipGL, PERCF(PERCF(this->Default.ClipGL, 250), this->ZoomPercent)); } break; // -- case WM_MBUTTONDOWN: { this->InMove = true; } break; // -- case WM_MBUTTONUP: { this->InMove = false; } break; } }
inline CField& CField::operator=(double dValue) { SetDouble(dValue); return *this; }
void CXTPPropertyGridItemDouble::SetValue(CString strValue) { SetDouble(StringToDouble(strValue)); }
void Value::SetCurrency(const double d) { SetDouble(d); type_ = ods::Type::Currency; }
void Value::SetPercentage(const double d) { SetDouble(d); type_ = ods::Type::Percentage; }
void mlp::map(int argc, const t_atom *argv) { const data_type data_type = get_data_type(); GRT::UINT numSamples = data_type == LABELLED_CLASSIFICATION ? classification_data.getNumSamples() : regression_data.getNumSamples(); if (numSamples == 0) { flext::error("no observations added, use 'add' to add training data"); return; } if (grt_mlp.getTrained() == false) { flext::error("model has not been trained, use 'train' to train the model"); return; } GRT::UINT numInputNeurons = grt_mlp.getNumInputNeurons(); GRT::VectorDouble query(numInputNeurons); if (argc < 0 || (unsigned)argc != numInputNeurons) { flext::error("invalid input length, expected %d, got %d", numInputNeurons, argc); } for (uint32_t index = 0; index < (uint32_t)argc; ++index) { double value = GetAFloat(argv[index]); query[index] = value; } bool success = grt_mlp.predict(query); if (success == false) { flext::error("unable to map input"); return; } // TODO: add probs to attributes if (grt_mlp.getClassificationModeActive()) { GRT::VectorDouble likelihoods = grt_mlp.getClassLikelihoods(); GRT::vector<GRT::UINT> labels = classification_data.getClassLabels(); GRT::UINT classification = grt_mlp.getPredictedClassLabel(); if (likelihoods.size() != labels.size()) { flext::error("labels / likelihoods size mismatch"); } else { AtomList probs; for (uid_t count = 0; count < labels.size(); ++count) { t_atom label_a; t_atom likelihood_a; // Need to call SetDouble() first or label_a gets corrupted. Bug in Flext? SetDouble(&likelihood_a, likelihoods[count]); SetInt(label_a, labels[count]); probs.Append(label_a); probs.Append(likelihood_a); } ToOutAnything(1, s_probs, probs); } ToOutInt(0, classification); } else if (grt_mlp.getRegressionModeActive()) { GRT::VectorDouble regression_data = grt_mlp.getRegressionData(); GRT::VectorDouble::size_type numOutputDimensions = regression_data.size(); if (numOutputDimensions != grt_mlp.getNumOutputNeurons()) { flext::error("invalid output dimensions: %d", numOutputDimensions); return; } AtomList result; for (uint32_t index = 0; index < numOutputDimensions; ++index) { t_atom value_a; double value = regression_data[index]; SetFloat(value_a, value); result.Append(value_a); } ToOutList(0, result); } }
wxMysqlPreparedStatementParameter::wxMysqlPreparedStatementParameter(MYSQL_BIND* pBind, double dblValue) : wxDatabaseErrorReporter() { m_pBind = pBind; SetDouble(dblValue); }