void CHemlockLooperModel::AddDailyResult(const StringVector& header, const StringVector& data) { enum TInputAllStage{ E_NAME, E_ID, E_YEAR, E_MONTH, E_DAY, E_JDAY, E_CUMUL_L1, E_CUMUL_L2, E_CUMUL_L3, E_CUMUL_L4, E_CUMUL_PUPA, E_CUMUL_ADULT, NB_INPUT, NB_COLUMN = NB_INPUT + 7 }; enum TInputPupasion{ P_NAME, P_ID, P_YEAR, P_MONTH, P_DAY, P_NB_DAYS, P_N, NB_INPUT_PUPAISON }; CTRef TRef(ToInt(data[E_YEAR]), ToSizeT(data[E_MONTH]) - 1, ToSizeT(data[E_DAY]) - 1); if (header.size() == NB_COLUMN) { std::vector<double> obs(NB_INPUT - E_CUMUL_L1); for (size_t i = 0; i < obs.size(); i++) obs[i] = ToDouble(data[E_CUMUL_L1 + i]); m_SAResult.push_back(CSAResult(TRef, obs)); } else if (header.size() == NB_INPUT_PUPAISON) { std::vector<double> obs(2); obs[PUP_NB_DAYS] = ToDouble(data[P_NB_DAYS]); obs[PUP_N] = ToDouble(data[P_N]); m_SAResult.push_back(CSAResult(TRef, obs)); } }
void CSMMRepeater::XMLParameters(TiXmlNode *node) { if(node->FirstChild("Repeats")) SetRepetitions(ToUInt(node->FirstChild("Repeats")->FirstChild("Bagging")),ToUInt(node->FirstChild("Repeats")->FirstChild("CrossValidation"))); if(node->FirstChild("LambdaRange")) SetLambdaRange(ToDouble(node->FirstChild("LambdaRange")->FirstChild("Min")),ToDouble(node->FirstChild("LambdaRange")->FirstChild("Start")),ToDouble(node->FirstChild("LambdaRange")->FirstChild("Max"))); if(node->FirstChild("Precission")) SetPrecission(ToDouble(node->FirstChild("Precission"))); if(node->FirstChild("LogDetail")) { string detail=node->FirstChild("LogDetail")->Value(); if(detail=="None") clog_detail.push_back(NONE); else if(detail=="Minimal") clog_detail.push_back(MINIMAL); else if(detail=="Medium") clog_detail.push_back(MEDIUM); else if(detail=="Detailed") clog_detail.push_back(DETAILED); else if(detail=="All") clog_detail.push_back(ALL); } if(node->FirstChild("SeedRandomizer")) m_srand=ToUInt(node->FirstChild("SeedRandomizer")); if(node->FirstChild("MaxNormIterations")) SetMaxNormIterations(ToUInt(node->FirstChild("MaxNormIterations"))); }
/** Internal HVL calculators which use the intermediate results instead of the basic HVL parameters */ inline double HVL_t_internal(const HVL_Context *ctx, const hvl_float &a0, const hvl_float &a3, const hvl_float &gauss_base, const hvl_float &b1pb2, const hvl_float &reca3) { const hvl_float gauss = a0 * gauss_base; if (a3 == ctx->HVL_ZERO) return ToDouble(gauss); return ToDouble(reca3 * gauss / b1pb2); }
inline double HVL_da0_internal(const HVL_Context *ctx, const hvl_float &a3, const hvl_float &gauss_base, const hvl_float &b1pb2, const hvl_float &reca3) { if (a3 == ctx->HVL_ZERO) return ToDouble(gauss_base); return ToDouble(reca3 * gauss_base / b1pb2); }
inline double HVL_da3_internal(const HVL_Context *ctx, const hvl_float &a0, const hvl_float &a3, const hvl_float &gauss_base, const hvl_float &b1pb2, const hvl_float &reca3, const hvl_float &sqrtz) { if (a3 == ctx->HVL_ZERO) return ToDouble(-ctx->HVL_HALF * a0 * Erf(sqrtz) * gauss_base); const hvl_float a3e = Exp(a3); const hvl_float nmr = gauss_base * a0 * (-reca3 + (a3e / (Pow(a3e - ctx->HVL_ONE, 2) * b1pb2))); return ToDouble(reca3 * nmr / b1pb2); }
inline double HVL_da1_internal(const HVL_Context *ctx, const hvl_float &a0, const hvl_float &a2, const hvl_float &a3, const hvl_float &gauss_base, const hvl_float &b1pb2, const hvl_float &reca3, const hvl_float &nmr, const hvl_float &xmu) { const hvl_float gauss_der = a0 * xmu / (a2 * a2) * gauss_base; if (a3 == ctx->HVL_ZERO) return ToDouble(gauss_der); const hvl_float result = reca3 * ((gauss_der / b1pb2) + nmr / (b1pb2 * b1pb2)); return ToDouble(result); }
bool PlatformerObjectAutomatism::UpdateProperty(const std::string & name, const std::string & value, gd::Project & project) { if ( name == ToString(_("Default controls")) ) { ignoreDefaultControls = (value == "0"); return true; } if ( ToDouble(value) < 0 ) return false; if ( name == ToString(_("Gravity")) ) gravity = ToDouble(value); else if ( name == ToString(_("Max. falling speed")) ) maxFallingSpeed = ToDouble(value); else if ( name == ToString(_("Acceleration")) ) acceleration = ToDouble(value); else if ( name == ToString(_("Deceleration")) ) deceleration = ToDouble(value); else if ( name == ToString(_("Max. speed")) ) maxSpeed = ToDouble(value); else if ( name == ToString(_("Jump speed")) ) jumpSpeed = ToDouble(value); else if ( name == ToString(_("Slope max. angle")) ) return SetSlopeMaxAngle(ToDouble(value)); else return false; return true; }
inline double HVL_da2_internal(const HVL_Context *ctx, const hvl_float &a0, const hvl_float &a2, const hvl_float &a3, const hvl_float &gauss_base, const hvl_float &b1pb2, const hvl_float &reca3, const hvl_float &nmr, const hvl_float &xmu) { const hvl_float gauss_der = a0 * (xmu * xmu * gauss_base / Pow(a2, 3) - gauss_base / a2); if (a3 == ctx->HVL_ZERO) return ToDouble(gauss_der); const hvl_float rnmr = nmr * xmu / a2; const hvl_float result = reca3 * ((gauss_der / b1pb2) + rnmr / (b1pb2 * b1pb2)); return ToDouble(result); }
//2006-10-05 - changed to support both SafetyPackets and regular Packets -MH void CarModel::CreateMessage(Packet * msg) { switch(msg->m_ePacketType) { default: case ptGeneric: { msg->m_ID.srcID.iSeqNumber = GetNextSequenceNumber(); msg->m_ID.srcID.ipCar = m_ipCar; msg->m_ID.iRXSeqNumber = (unsigned)-1; msg->m_ptTXPosition = m_ptPosition; msg->m_ipTX = m_ipCar; msg->m_ipRX = 0; msg->m_tTX = GetCurrentTime() + MakeTime(RandDouble(0., ToDouble(m_tDelay))); msg->m_tRX = msg->m_tTX; msg->m_iRSSI = PACKET_RSSI_UNAVAILABLE; msg->m_iSNR = PACKET_SNR_UNAVAILABLE; break; } case ptSafety: { ((SafetyPacket*)msg)->m_ID.srcID.iSeqNumber = GetNextSequenceNumber(); ((SafetyPacket*)msg)->m_ID.srcID.ipCar = m_ipCar; ((SafetyPacket*)msg)->m_ID.iRXSeqNumber = (unsigned)-1; // msg.m_eType = Message::MessageTypeNormal; ((SafetyPacket*)msg)->m_tTime = m_tTimestamp; ((SafetyPacket*)msg)->m_tLifetime = m_tDelay; ((SafetyPacket*)msg)->m_ptPosition = ((SafetyPacket*)msg)->m_ptTXPosition = m_ptPosition; ((SafetyPacket*)msg)->m_iSpeed = ((SafetyPacket*)msg)->m_iTXSpeed = m_iSpeed; ((SafetyPacket*)msg)->m_iHeading = ((SafetyPacket*)msg)->m_iTXHeading = m_iHeading; ((SafetyPacket*)msg)->m_iRecord = m_iCurrentRecord; g_pMapDB->GetRelativeRecord(((SafetyPacket*)msg)->m_iRecord, ((SafetyPacket*)msg)->m_iCountyCode); ((SafetyPacket*)msg)->m_iTXRecord = ((SafetyPacket*)msg)->m_iRecord; ((SafetyPacket*)msg)->m_iTXCountyCode = ((SafetyPacket*)msg)->m_iCountyCode; ((SafetyPacket*)msg)->m_cDirection = ((SafetyPacket*)msg)->m_cTXDirection = m_bForwards ? MESSAGE_DIRECTION_FORWARDS : MESSAGE_DIRECTION_BACKWARDS; ((SafetyPacket*)msg)->m_iShapePoint = ((SafetyPacket*)msg)->m_iTXShapePoint = m_iCRShapePoint; ((SafetyPacket*)msg)->m_fProgress = ((SafetyPacket*)msg)->m_fTXProgress = m_fCRProgress; ((SafetyPacket*)msg)->m_ipTX = m_ipCar; ((SafetyPacket*)msg)->m_ipRX = 0; ((SafetyPacket*)msg)->m_tTX = GetCurrentTime() + MakeTime(RandDouble(0., ToDouble(m_tDelay))); ((SafetyPacket*)msg)->m_tRX = ((SafetyPacket*)msg)->m_tTX; ((SafetyPacket*)msg)->m_iRSSI = PACKET_RSSI_UNAVAILABLE; ((SafetyPacket*)msg)->m_iSNR = PACKET_SNR_UNAVAILABLE; break; } } }
std::pair<int, CRational> CRational::ToCompoundFraction()const { int integer = static_cast<int>(ToDouble()); int numerator = m_numerator - m_denominator * integer; return std::make_pair<int, CRational>(std::move(integer), CRational(numerator, m_denominator)); }
DriftCorrect::DriftCorrect(const HiCalConf &conf) : NonLinearLSQ(), Component("DriftCorrect") { DbProfile prof = conf.getMatrixProfile(); _history.add("Profile["+ prof.Name()+"]"); _timet.setBin(ToInteger(prof("Summing"))); _timet.setLineTime(ToDouble(prof("ScanExposureDuration"))); _skipFit = IsEqual(ConfKey(prof, "ZdSkipFit", std::string("TRUE")), "TRUE"); _useLinFit = IsTrueValue(prof, "ZdOnFailUseLinear"); _absErr = ConfKey(prof, "AbsoluteError", 1.0E-4); _relErr = ConfKey(prof, "RelativeError", 1.0E-4); _sWidth = ConfKey(prof, "GuessFilterWidth", 17); _sIters = ConfKey(prof, "GuessFilterIterations", 1); if ( prof.exists("MaximumIterations") ) { setMaxIters(ToInteger(prof("MaximumIterations"))); } _maxLog = ConfKey(prof, "MaximumLog", 709.0); _badLines = ToInteger(prof("TrimLines"))/ToInteger(prof("Summing")); _minLines = ConfKey(prof,"ZdMinimumLines", 100); string histstr = "DriftCorrect(AbsErr[" + ToString(_absErr) + "],RelErr[" + ToString(_relErr) + "],MaxIter[" + ToString(maxIters()) + "])"; _history.add(histstr); }
void CWhitePineWeevilModel::AddDailyResult(const StringVector& header, const StringVector& data) { enum TInputAllStage{ E_ID, E_YEAR, E_MONTH, E_DAY, E_DD, E_EGG, E_EGG_CUMUL, E_L1, E_CUMUL_L1, E_L2, E_CUMUL_L2, E_L3, E_CUMUL_L3, E_L4, E_CUMUL_L4, E_PUPA, E_CUMUL_PUPA, E_ADULT, E_CUMUL_ADULT, NB_INPUTS_STAGE }; enum TInputDD{ P_YEAR, P_MONTH, P_DAY, P_DD, NB_INPUTS_DD }; if (header.size() == NB_INPUTS_STAGE) { CTRef TRef(ToInt(data[E_YEAR]), ToSizeT(data[E_MONTH]) - 1, ToSizeT(data[E_DAY]) - 1); std::vector<double> obs(NB_STAGES,-999); for (size_t i = 0; i < 7 && E_EGG_CUMUL + 2 * i<data.size(); i++) obs[i] = !data[E_EGG_CUMUL + 2 * i].empty()?ToDouble(data[E_EGG_CUMUL + 2 * i]):-999; m_SAResult.push_back(CSAResult(TRef, obs)); } /*else if (header.size() == NB_INPUTS_DD) { //CTRef TRef(ToInt(data[P_YEAR]), ToSizeT(data[P_MONTH]) - 1, ToSizeT(data[P_DAY]) - 1); std::vector<double> obs(2); obs[PUP_NB_DAYS] = ToDouble(data[P_NB_DAYS]); obs[PUP_N] = ToDouble(data[P_N]); m_SAResult.push_back(CSAResult(TRef, obs)); }*/ }
bool PathfindingObstacleAutomatism::UpdateProperty(const std::string & name, const std::string & value, gd::Project & project) { if ( name == ToString(_("Impassable obstacle")) ) { impassable = (value != "0"); return true; } if ( ToDouble(value) < 0 ) return false; if ( name == ToString(_("Cost (if not impassable)")) ) cost = ToDouble(value); else return false; return true; }
wxString SPICE_VALUE::ToString() const { wxString res( wxString::Format( "%.3f", ToDouble() ) ); stripZeros( res ); return res; }
double PerformanceCounter::NextDouble() { PDH_FMT_COUNTERVALUE value; auto status = NextValue(PDH_FMT_DOUBLE, &value); if (status != ERROR_SUCCESS) return NAN; return ToDouble(value); }
/* int SimpleCommModel::Iteration(struct timeval tCurrent) { if (CarCommModel::Iteration(tCurrent)) return 1; std::map<PacketSequence, MessageHistory>::iterator iterMsgHistory; for (iterMsgHistory = m_mapMsgHistory.begin(); iterMsgHistory != m_mapMsgHistory.end(); ++iterMsgHistory) iterMsgHistory->second.tRelevant = tCurrent; while (!m_vecRebroadcast.empty() && m_vecRebroadcast.front().tNext <= tCurrent) { pop_heap(m_vecRebroadcast.begin(), m_vecRebroadcast.end()); RebroadcastMessage & msgRebroadcast = m_vecRebroadcast.back(); // setup for next rebroadcast if (msgRebroadcast.msg.m_tTime + msgRebroadcast.msg.m_tLifetime < tCurrent) { m_mapMsgHistory.erase(msgRebroadcast.msg.m_ID.srcID); m_vecRebroadcast.pop_back(); } else { msgRebroadcast.msg.m_tTX = msgRebroadcast.tNext; TransmitMessage(msgRebroadcast.msg); // only rebroadcast if there's time left msgRebroadcast.tIntervalLow = msgRebroadcast.tIntervalHigh; msgRebroadcast.tIntervalHigh = msgRebroadcast.tIntervalHigh + m_tRebroadcastInterval; msgRebroadcast.tNext = msgRebroadcast.tIntervalLow + MakeTime(RandDouble(0., ToDouble(m_tRebroadcastInterval))); push_heap(m_vecRebroadcast.begin(), m_vecRebroadcast.end()); } } return 0; } */ int SimpleCommModel::Save(std::map<QString, QString> & mapParams) { if (CarCommModel::Save(mapParams)) return 1; mapParams[SIMPLECOMMMODEL_REBROADCASTINTERVAL_PARAM] = QString("%1").arg(ToDouble(m_tRebroadcastInterval)); mapParams[SIMPLECOMMMODEL_DOREBROADCAST_PARAM] = BooleanToString(m_bRebroadcast); mapParams[SIMPLECOMMMODEL_MOBILEGATEWAY_PARAM] = BooleanToString(m_bGateway); mapParams[SIMPLECOMMMODEL_RBXJITTER_PARAM] = BooleanToString(m_bJitter); return 0; }
int CarModel::Save(std::map<QString, QString> & mapParams) { if (Model::Save(mapParams)) return 1; mapParams[CARMODEL_PARAM_DELAY] = QString("%1").arg(ToDouble(m_tDelay)); mapParams[CARMODEL_PARAM_CARIP] = IPAddressToString(m_ipCar); mapParams[CARMODEL_PARAM_LOGCAR] = BooleanToString(m_bLogThisCar); mapParams[CARMODEL_LINK_PARAM] = m_pLinkModel == NULL ? "NULL" : m_pLinkModel->GetModelName(); mapParams[CARMODEL_PHYS_PARAM] = m_pPhysModel == NULL ? "NULL" : m_pPhysModel->GetModelName(); mapParams[CARMODEL_COMM_PARAM] = m_pCommModel == NULL ? "NULL" : m_pCommModel->GetModelName(); mapParams[CARMODEL_TRACKSPEED_PARAM] = BooleanToString(m_bTrackSpeed); return 0; }
void BaseEncoder::AddFrame(std::unique_ptr<AVFrameWrapper> frame) { assert(frame->GetFrame()->pts != (int64_t) AV_NOPTS_VALUE); SharedLock lock(&m_shared_data); ++lock->m_total_frames; if(lock->m_stats_previous_pts == (int64_t) AV_NOPTS_VALUE) { lock->m_stats_previous_pts = frame->GetFrame()->pts; lock->m_stats_previous_frames = lock->m_total_frames; } double timedelta = (double) (frame->GetFrame()->pts - lock->m_stats_previous_pts) * ToDouble(m_stream->codec->time_base); if(timedelta > 0.999999) { lock->m_stats_actual_frame_rate = (double) (lock->m_total_frames - lock->m_stats_previous_frames) / timedelta; lock->m_stats_previous_pts = frame->GetFrame()->pts; lock->m_stats_previous_frames = lock->m_total_frames; } lock->m_frame_queue.push_back(std::move(frame)); }
bool PerformanceCounter::Next(std::vector<double>* values) { DWORD count = 0; auto buffer = NextArray(PDH_FMT_DOUBLE, &count); if (buffer == nullptr) return false; auto items = reinterpret_cast<PDH_FMT_COUNTERVALUE_ITEM*>(buffer.get()); values->clear(); values->reserve(count); for (DWORD i = 0; i < count; ++i) values->push_back(ToDouble(items[i].FmtValue)); return true; }
int32_t ToInteger(ejsval exp) { // XXX sorely lacking /* 1. Let number be the result of calling ToNumber on the input argument. */ ejsval number = ToNumber(exp); /* 2. If number is NaN, return +0. */ if (EJSVAL_EQ(number, _ejs_nan)) return 0; /* 3. If number is +0, 0, +, or , return number. */ double d = ToDouble(number); int classified = fpclassify(d); if (classified == FP_ZERO || classified == FP_INFINITE) return d; /* 4. Return the result of computing sign(number) floor(abs(number) */ int sign = d < 0 ? -1 : 1; return (int)(sign * floor(abs(d))); }
bool ChangeProperty(RuntimeScene & scene, unsigned int propertyNb, std::string newValue) { unsigned int i = 0; std::map < std::string, ManualTimer >::const_iterator end = TimedEventsManager::managers[&scene].timedEvents.end(); for (std::map < std::string, ManualTimer >::iterator iter = TimedEventsManager::managers[&scene].timedEvents.begin();iter != end;++iter) { if ( propertyNb == i ) { iter->second.SetTime(ToDouble(newValue)*1000000.0); return true; } ++i; } return false; }
Matrix<double> *MatrixOps<T>::Mean (const Matrix<T> *const matrix, MATRIX_DIMENSION dimension) { SSI_ASSERT (!MatrixOps<T>::IsEmpty (matrix)); Matrix<T> *summat = Sum (matrix, dimension); Matrix<double> *resmat = ToDouble (summat); delete summat; switch (dimension) { case MATRIX_DIMENSION_ROW: MatrixOps<double>::Mult (resmat, 1.0 / matrix->cols); break; case MATRIX_DIMENSION_COL: MatrixOps<double>::Mult (resmat, 1.0 / matrix->rows); break; } return resmat; }
bool CIDSLiteStation::ReadStation(const StringVector& line) { ASSERT(line.size() == NB_COLUMNS); bool bRep = false; static int nbEmptyName = 0; Reset(); if (!line[C_LAT].empty() && !line[C_LON].empty() && !line[C_ELEV].empty() && line[C_LAT] != "+00.000" && line[C_LON] != "+000.000" && line[C_ELEV] != "-0999.9" && line[C_ELEV] != "-0999.0") { ASSERT(line[C_LAT] != "-99.999" && line[C_LON] != "-999.999"); bRep = true; string name = TrimConst(line[C_STATION_NAME]); if (name.empty()) { nbEmptyName++; name = "EmptyName" + ToString(nbEmptyName); } ASSERT(!name.empty()); m_name = UppercaseFirstLetter(name); m_country = TrimConst(line[C_CTRY]); m_state = TrimConst(line[C_STATE]); if (m_country.empty()) m_country = "UN";//Unknown ASSERT(!line[C_USAF].empty()); ASSERT(!line[C_WBAN].empty()); m_USAF = "USAF" + line[C_USAF]; m_WBAN = "WBAN" + line[C_WBAN]; m_ID = line[C_USAF] + "-" + line[C_WBAN]; ASSERT(!m_ID.empty()); m_lat = ToDouble(line[C_LAT]); m_lon = ToDouble(line[C_LON]); m_elev = ToDouble(line[C_ELEV]); if (line[C_USAF] == "716920")//coordinate error over MARTICOT ISLAND m_lon = -54.583; if (line[C_WBAN] == "12848")//coordinate error over Dinner Key NAF m_lon = -80.2333; ASSERT(m_lat >= -90 && m_lat < 90); ASSERT(m_lon >= -180 && m_lon < 180); if (!line[C_BEGIN].empty() && !line[C_END].empty()) { m_period.Begin() = CTRef(ToInt(line[C_BEGIN].substr(0, 4)), ToInt(line[C_BEGIN].substr(4, 2)) - 1, ToInt(line[C_BEGIN].substr(6, 2)) - 1); m_period.End() = CTRef(ToInt(line[C_END].substr(0, 4)), ToInt(line[C_END].substr(4, 2)) - 1, ToInt(line[C_END].substr(6, 2)) - 1); } SetToSSI(); } return bRep; }
double XMLElement::GetDouble(const ea::string& name) const { return ToDouble(GetAttribute(name)); }
double ToDouble(const String& source) { return ToDouble(source.CString()); }
void Variant::FromString(VariantType type, const char* value) { switch (type) { case VAR_INT: *this = ToInt(value); break; case VAR_INT64: *this = ToInt64(value); break; case VAR_BOOL: *this = ToBool(value); break; case VAR_FLOAT: *this = ToFloat(value); break; case VAR_VECTOR2: *this = ToVector2(value); break; case VAR_VECTOR3: *this = ToVector3(value); break; case VAR_VECTOR4: *this = ToVector4(value); break; case VAR_QUATERNION: *this = ToQuaternion(value); break; case VAR_COLOR: *this = ToColor(value); break; case VAR_STRING: *this = value; break; case VAR_BUFFER: { SetType(VAR_BUFFER); PODVector<unsigned char>& buffer = *(reinterpret_cast<PODVector<unsigned char>*>(&value_)); StringToBuffer(buffer, value); } break; case VAR_VOIDPTR: // From string to void pointer not supported, set to null *this = (void*)0; break; case VAR_RESOURCEREF: { StringVector values = String::Split(value, ';'); if (values.Size() == 2) { SetType(VAR_RESOURCEREF); ResourceRef& ref = *(reinterpret_cast<ResourceRef*>(&value_)); ref.type_ = values[0]; ref.name_ = values[1]; } } break; case VAR_RESOURCEREFLIST: { StringVector values = String::Split(value, ';', true); if (values.Size() >= 1) { SetType(VAR_RESOURCEREFLIST); ResourceRefList& refList = *(reinterpret_cast<ResourceRefList*>(&value_)); refList.type_ = values[0]; refList.names_.Resize(values.Size() - 1); for (unsigned i = 1; i < values.Size(); ++i) refList.names_[i - 1] = values[i]; } } break; case VAR_INTRECT: *this = ToIntRect(value); break; case VAR_INTVECTOR2: *this = ToIntVector2(value); break; case VAR_INTVECTOR3: *this = ToIntVector3(value); break; case VAR_PTR: // From string to RefCounted pointer not supported, set to null *this = (RefCounted*)0; break; case VAR_MATRIX3: *this = ToMatrix3(value); break; case VAR_MATRIX3X4: *this = ToMatrix3x4(value); break; case VAR_MATRIX4: *this = ToMatrix4(value); break; case VAR_DOUBLE: *this = ToDouble(value); break; case VAR_RECT: *this = ToRect(value); break; default: SetType(VAR_NONE); } }
void CEMStatisticsMajorDiseasesReport::OnExportSelect(){ _debug(_T("%s"), CString(typeid(this).name())); CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CRecord rs(&pMF->m_db); CString szSQL, szTemp, tmpStr; CExcel xls; szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { ShowMessage(150, MB_ICONSTOP); return; } xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 7); xls.SetColumnWidth(1, 10); xls.SetColumnWidth(2, 78); xls.SetColumnWidth(3, 12); int nRow = 0, nCol = 0; xls.SetCellMergedColumns(nCol, nRow + 2, 4); xls.SetCellText(nCol+2, nRow, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(nCol+2, nRow + 1, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellMergedColumns(nCol, nRow + 2, 4); xls.SetCellMergedColumns(nCol, nRow + 3, 4); xls.SetCellText(nCol, nRow + 2, _T("TH\x1ED0NG K\xCA M\x1EB6T \x42\x1EC6NH \x43H\xCDNH"), FMT_TEXT | FMT_CENTER, true, 13); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x110\x1EBFn ng\xE0y %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); xls.SetCellText(nCol, nRow + 3, tmpStr, FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol, nRow + 4, _T("STT"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 1, nRow + 4, _T("M\xE3 \x62\x1EC7nh"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 2, nRow + 4, _T("T\xEAn m\x1EB7t \x62\x1EC7nh"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 3, nRow + 4, _T("S\x1ED1 l\x1B0\x1EE3ng"), FMT_TEXT | FMT_CENTER, true, 11); nRow += 5; int nIndex = 1; long double nTotal = 0.0; while (!rs.IsEOF()) { szTemp.Format(_T("%d"), nIndex); xls.SetCellText(nCol, nRow, szTemp, FMT_INTEGER); szTemp = rs.GetValue(_T("hi_icd")); xls.SetCellText(nCol + 1, nRow, szTemp, FMT_TEXT); szTemp = rs.GetValue(_T("ICDName")); xls.SetCellText(nCol + 2, nRow, szTemp, FMT_TEXT); szTemp = rs.GetValue(_T("total")); nTotal += ToDouble(szTemp); xls.SetCellText(nCol + 3, nRow, szTemp, FMT_INTEGER); nIndex++; nRow++; rs.MoveNext(); } xls.SetCellMergedColumns(nCol, nRow, 3); xls.SetCellText(nCol, nRow, _T("T\x1ED5ng \x63\x1ED9ng"), FMT_TEXT | FMT_CENTER, true, 12); xls.SetCellText(nCol + 3, nRow, double2str(nTotal), FMT_NUMBER1, true, 12 ); EndWaitCursor(); xls.Save(_T("Exports\\THONG KE MAT BENH CHINH.XLS")); }
// parse entities section: save 3DFACE and LINE entities bool DXFRenderer::ParseEntities(wxInputStream& stream) { wxTextInputStream text(stream); wxString line1, line2; int state = 0; // 0: none, 1: 3DFACE, 2: LINE DXFVector v[4]; int colour = -1; wxString layer; while (stream.CanRead()) { GetLines(text, line1, line2); if (line1 == "0" && state > 0) { // flush entity if (state == 1) // 3DFACE { DXFFace *p = new DXFFace; p->v0 = v[0]; p->v1 = v[1]; p->v2 = v[2]; p->v3 = v[3]; p->CalculateNormal(); if (colour != -1) p->colour = colour; else p->colour = GetLayerColour(layer); m_entities.Append(p); colour = -1; layer.clear(); v[0] = v[1] = v[2] = v[3] = DXFVector(); state = 0; } else if (state == 2) // LINE { DXFLine *p = new DXFLine; p->v0 = v[0]; p->v1 = v[1]; if (colour != -1) p->colour = colour; else p->colour = GetLayerColour(layer); m_entities.Append(p); colour = -1; layer.clear(); v[0] = v[1] = v[2] = v[3] = DXFVector(); state = 0; } } if (line1 == "0" && line2 == "ENDSEC") return true; else if (line1 == "0" && line2 == "3DFACE") state = 1; else if (line1 == "0" && line2 == "LINE") state = 2; else if (state > 0) { const double d=ToDouble(line2); if (line1 == "10") v[0].x = d; else if (line1 == "20") v[0].y = d; else if (line1 == "30") v[0].z = d; else if (line1 == "11") v[1].x = d; else if (line1 == "21") v[1].y = d; else if (line1 == "31") v[1].z = d; else if (line1 == "12") v[2].x = d; else if (line1 == "22") v[2].y = d; else if (line1 == "32") v[2].z = d; else if (line1 == "13") v[3].x = d; else if (line1 == "23") v[3].y = d; else if (line1 == "33") v[3].z = d; else if (line1 == "8") // layer layer = line2; else if (line1 == "62") // colour { long l; line2.ToLong(&l); colour = l; } } } return false; }
double const ToDouble(std::wstring const &content) { return ToDouble(ToUTF8(content)); }
float CJS_Value::ToFloat() const { return (float)ToDouble(); }