#endif CLIPFORMAT cfEmbeddedObject; CLIPFORMAT cfRTF; CLIPFORMAT cfRTO; int CWordPadApp::m_nOpenMsg = RegisterWindowMessage(_T("WordPadOpenMessage")); int CWordPadApp::m_nPrinterChangedMsg = RegisterWindowMessage(_T("WordPadPrinterChanged")); const int CWordPadApp::m_nPrimaryNumUnits = 4; const int CWordPadApp::m_nNumUnits = 7; CUnit CWordPadApp::m_units[7] = { // TPU, SmallDiv, MedDiv, LargeDiv, MinMove, szAbbrev, bSpace CUnit(1440, 180, 720, 1440, 90, IDS_INCH1_ABBREV, FALSE),//inches CUnit(568, 142, 284, 568, 142, IDS_CM_ABBREV, TRUE),//centimeters CUnit(20, 120, 720, 720, 100, IDS_POINT_ABBREV, TRUE),//points CUnit(240, 240, 1440, 1440, 120, IDS_PICA_ABBREV, TRUE),//picas CUnit(1440, 180, 720, 1440, 90, IDS_INCH2_ABBREV, FALSE),//in CUnit(1440, 180, 720, 1440, 90, IDS_INCH3_ABBREV, FALSE),//inch CUnit(1440, 180, 720, 1440, 90, IDS_INCH4_ABBREV, FALSE)//inches }; static UINT DoRegistry(LPVOID lpv) { ASSERT(lpv != NULL); if (lpv != NULL) { ((CWordPadApp*)lpv)->UpdateRegistry(); }
void CUnit::SetConversionFrom (const std::string &Source) { SetConversionFrom(CUnit(Source)); }
std::set< CUnit > CUnitDefinitionDB::getAllValidUnits(const std::string & symbol, const C_FLOAT64 & exponent) const { std::set< CUnit > ValidUnits; if (getUnitDefFromSymbol(symbol) == NULL) { return ValidUnits; } CUnit Base(symbol); CUnit Power = Base.exponentiate(exponent); // dimensionless is always valid ValidUnits.insert(CUnit(CBaseUnit::dimensionless)); const_iterator it = begin(); const_iterator itEnd = end(); for (; it != itEnd; ++it) { if (it->isEquivalent(Power) || it->isEquivalent(Base)) { if ((it->getComponents().begin()->getMultiplier() == 1.0 || it->getComponents().begin()->getMultiplier() == CUnit::Avogadro || it->getSymbol() == "l") && !it->CUnit::operator==(CBaseUnit::item)) { for (C_INT32 scale = -18; scale < 18; scale += 3) { CUnit Scale; Scale.addComponent(CUnitComponent(CBaseUnit::dimensionless, 1.0, scale, 0)); CUnit ScaledUnit = (Scale * CUnit(it->getSymbol())); if (it->isEquivalent(Base)) { ScaledUnit = ScaledUnit.exponentiate(exponent); } ScaledUnit.buildExpression(); ValidUnits.insert(ScaledUnit); } } else { CUnit ScaledUnit = CUnit(it->getSymbol()); if (it->isEquivalent(Base)) { ScaledUnit = ScaledUnit.exponentiate(exponent); } ScaledUnit.buildExpression(); ValidUnits.insert(ScaledUnit); } } } return ValidUnits; }
void CUnit::SetConversionTo (const std::string &Destination) { SetConversionTo(CUnit(Destination)); }
CValidatedUnit CEvaluationNodeFunction::getUnit(const CMathContainer & /* container */, const std::vector< CValidatedUnit > & units) const { CValidatedUnit Unit(CBaseUnit::dimensionless, false); switch ((SubType)this->subType()) { case S_LOG: case S_LOG10: case S_EXP: case S_SIN: case S_COS: case S_TAN: case S_SEC: case S_CSC: case S_COT: case S_SINH: case S_COSH: case S_TANH: case S_SECH: case S_CSCH: case S_COTH: case S_ARCSIN: case S_ARCCOS: case S_ARCTAN: case S_ARCSEC: case S_ARCCSC: case S_ARCCOT: case S_ARCSINH: case S_ARCCOSH: case S_ARCTANH: case S_ARCSECH: case S_ARCCSCH: case S_ARCCOTH: case S_FACTORIAL: case S_NOT: Unit = CValidatedUnit::merge(Unit, units[0]); break; case S_MAX: case S_MIN: case S_RUNIFORM: case S_RNORMAL: Unit = CValidatedUnit::merge(units[0], units[1]); break; case S_MINUS: case S_PLUS: case S_FLOOR: case S_CEIL: case S_ABS: case S_RPOISSON: Unit = units[0]; break; case S_RGAMMA: // The unit of the gamma distribution is the inverse of the scale parameter (units[1]) Unit = units[1].exponentiate(-1); // The shape parameter must be dimensionless if (!Unit.conflict()) { Unit.setConflict(!(units[0] == CUnit(CBaseUnit::dimensionless))); } break; case S_SQRT: { // Exponentiate to 1/2. // Test if each component's exponent // is an integer. (don't want fractional exponents) by . . . // modf(exp, NULL) =< std::numeric_limits::epsilon Unit = units[0].exponentiate(1.0 / 2.0); std::set< CUnitComponent >::const_iterator it = Unit.getComponents().begin(); std::set< CUnitComponent >::const_iterator end = Unit.getComponents().end(); for (; it != end; it++) { if (!(remainder((*it).getExponent(), 1.0) <= 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon())) { Unit = CValidatedUnit(CBaseUnit::undefined, true); break; } } break; } default: Unit.setConflict(true); break; } return Unit; }