本文整理汇总了C++中Quantity类的典型用法代码示例。如果您正苦于以下问题:C++ Quantity类的具体用法?C++ Quantity怎么用?C++ Quantity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Quantity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyErr_Clear
PyObject* MatrixPy::rotateZ(PyObject * args)
{
double angle = 0;
do {
PyObject *object;
if (PyArg_ParseTuple(args,"O!",&(Base::QuantityPy::Type), &object)) {
Quantity *q = static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
if (q->getUnit() == Base::Unit::Angle) {
angle = q->getValueAs(Base::Quantity::Radian);
break;
}
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "d: angle to rotate (double) needed", &angle)) {
break;
}
PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected");
return 0;
}
while (false);
PY_TRY {
getMatrixPtr()->rotZ(angle);
}
PY_CATCH;
Py_Return;
}
示例2: BitmapFactory
void InputField::newInput(const QString & text)
{
Quantity res;
try{
res = Quantity::parse(text);
}catch(Base::Exception &e){
ErrorText = e.what();
this->setToolTip(QString::fromAscii(ErrorText.c_str()));
QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height()));
iconLabel->setPixmap(pixmap);
parseError(QString::fromAscii(ErrorText.c_str()));
return;
}
QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_valid.svg", QSize(sizeHint().height(),sizeHint().height()));
iconLabel->setPixmap(pixmap);
ErrorText = "";
this->setToolTip(QString::fromAscii(ErrorText.c_str()));
actQuantity = res;
double dFactor;
res.getUserString(dFactor,actUnitStr);
// calculate the number shown
actUnitValue = res.getValue()/dFactor;
// signaling
valueChanged(res);
}
示例3: setPalette
void InputField::newInput(const QString & text)
{
Quantity res;
try{
res = Quantity::parse(text);
}catch(Base::Exception &e){
ErrorText = e.what();
this->setToolTip(QString::fromAscii(ErrorText.c_str()));
QPalette palette;
palette.setColor(QPalette::Base,QColor(255,200,200));
setPalette(palette);
parseError(QString::fromAscii(ErrorText.c_str()));
return;
}
QPalette palette;
palette.setColor(QPalette::Base,QColor(200,255,200));
setPalette(palette);
ErrorText = "";
this->setToolTip(QString::fromAscii(ErrorText.c_str()));
actQuantity = res;
double dFactor;
res.getUserString(dFactor,actUnitStr);
// calculate the number shown
actUnitValue = res.getValue()/dFactor;
// signaling
valueChanged(res);
}
示例4: strm
void QuantityManager::read(const std::string & data) {
std::stringstream strm(data);
std::string line;
while (getline(strm,line)) {
IBK::trim(line);
if (line.empty() || line[0] == '#') continue;
Quantity qd;
try {
qd.read(line);
}
catch (IBK::Exception & ex) {
throw IBK::Exception(ex, IBK::FormatString("Cannot read quantity definition from line '%1'.")
.arg(line), "[QuantityManager::read]");
}
// check if we already have such a quantity
int idx = index(qd);
if (idx != -1) {
// replace quantity
IBK::IBK_Message(IBK::FormatString("Replacing quantity '%1::%2' with new definition.\n")
.arg(Quantity::type2string(qd.m_type))
.arg(qd.m_name), IBK::MSG_PROGRESS, "QuantityManager::read" ,1);
m_quantities[idx] = qd;
}
else {
// add quantity to list
m_quantities.push_back(qd);
// add new reference to global index map
m_globalIndexMap[ std::make_pair(qd.m_type, qd.m_name)]= m_quantities.size()-1;
}
}
}
示例5: switch
Quantity UnitOfMeasureConversion::convert(const Quantity& quantity) const {
switch (data_->type) {
case Direct:
if (quantity.unitOfMeasure() == data_->source)
return Quantity(quantity.commodityType(),
data_->target,
quantity.amount()*data_->conversionFactor);
else if (quantity.unitOfMeasure() == data_->target)
return Quantity(quantity.commodityType(),
data_->source,
quantity.amount()/data_->conversionFactor);
else
QL_FAIL("direct conversion not applicable");
case Derived:
if (quantity.unitOfMeasure()
== data_->conversionFactorChain.first->source() ||
quantity.unitOfMeasure()
== data_->conversionFactorChain.first->target())
return data_->conversionFactorChain.second->convert(
data_->conversionFactorChain.first->convert(quantity));
else if (quantity.unitOfMeasure()
== data_->conversionFactorChain.second->source() ||
quantity.unitOfMeasure()
== data_->conversionFactorChain.second->target())
return data_->conversionFactorChain.first->convert(
data_->conversionFactorChain.second->convert(quantity));
else
QL_FAIL("derived conversion factor not applicable");
default:
QL_FAIL("unknown conversion-factor type");
}
}
示例6: TEST_F
TEST_F(ModelFixture,ZoneHVACFourPipeFanCoil_MediumSpeedSupplyAirFlowRatio_Quantity) {
Model model;
EXPECT_EQ(0u,model.objects().size());
EXPECT_TRUE(model.versionObject());
// need schedule
ScheduleConstant sched(model);
EXPECT_EQ(1u,model.objects().size());
sched.setValue(1.0); // Always on
// need fan
FanConstantVolume fan(model,sched);
// need cooling and heating coils
CoilCoolingWater coolingCoil(model,sched);
CoilHeatingWater heatingCoil(model,sched);
// construct object
ZoneHVACFourPipeFanCoil zoneHVACFourPipeFanCoil(model,sched,fan,coolingCoil,heatingCoil);
EXPECT_EQ(6u,model.objects().size());
Unit units = zoneHVACFourPipeFanCoil.getMediumSpeedSupplyAirFlowRatio(true).units(); // Get IP units.
double value(0.66);
Quantity testQ(value,units);
EXPECT_TRUE(zoneHVACFourPipeFanCoil.setMediumSpeedSupplyAirFlowRatio(testQ));
Quantity q = zoneHVACFourPipeFanCoil.getMediumSpeedSupplyAirFlowRatio(true);
EXPECT_NEAR(value,q.value(),1.0E-8);
EXPECT_EQ(units.standardString(),q.units().standardString());
}
示例7: wl
bool operator==(const Quantity& lQuantity,const Quantity& rQuantity) {
if ((lQuantity.system() == rQuantity.system()) && (lQuantity.units() == rQuantity.units())) {
Quantity wl(lQuantity), wr(rQuantity);
wl.setScale(0);
wr.setScale(0);
return equal(wl.value(),wr.value());
}
return false;
}
示例8: Q_D
void QuantitySpinBox::updateText(const Quantity &quant)
{
Q_D(QuantitySpinBox);
double dFactor;
QString txt = quant.getUserString(dFactor,d->unitStr);
d->unitValue = quant.getValue()/dFactor;
lineEdit()->setText(txt);
}
示例9: LOG_AND_THROW
void OSQuantityVector::push_back(Quantity q) {
if (!(q.units() == units())) {
LOG_AND_THROW("Quantity " << q << " is incompatible with this OSQuantityVector, which has "
"units " << units() << ".");
}
else if (q.scale() != scale()) {
q.setScale(scale().exponent);
}
m_values.push_back(q.value());
}
示例10: switch
Quantity Constraint::getPresentationValue() const
{
Quantity quantity;
switch (Type) {
case Distance:
case Radius:
case DistanceX:
case DistanceY:
quantity.setValue(Value);
quantity.setUnit(Unit::Length);
break;
case Angle:
quantity.setValue(toDegrees<double>(Value));
quantity.setUnit(Unit::Angle);
break;
case SnellsLaw:
quantity.setValue(Value);
break;
default:
quantity.setValue(Value);
break;
}
QuantityFormat format = quantity.getFormat();
format.option = QuantityFormat::None;
format.format = QuantityFormat::Default;
format.precision = 6; // QString's default
quantity.setFormat(format);
return quantity;
}
示例11: TEST_F
TEST_F(ModelFixture,ThermalZone_FractionofZoneControlledbySecondaryDaylightingControl_Quantity) {
Model model;
ThermalZone thermalZone(model);
Unit units = thermalZone.getFractionofZoneControlledbySecondaryDaylightingControl(true).units(); // Get IP units.
double value(0.0);
Quantity testQ(value,units);
EXPECT_TRUE(thermalZone.setFractionofZoneControlledbySecondaryDaylightingControl(testQ));
Quantity q = thermalZone.getFractionofZoneControlledbySecondaryDaylightingControl(true);
EXPECT_NEAR(value,q.value(),1.0E-8);
EXPECT_EQ(units.standardString(),q.units().standardString());
}
示例12: TEST_F
TEST_F(ModelFixture,PeopleDefinition_CarbonDioxideGenerationRate_Quantity) {
Model model;
PeopleDefinition peopleDefinition(model);
Unit units = peopleDefinition.getCarbonDioxideGenerationRate(true).units(); // Get IP units.
double value(1.0E-7);
Quantity testQ(value,units);
EXPECT_TRUE(peopleDefinition.setCarbonDioxideGenerationRate(testQ));
Quantity q = peopleDefinition.getCarbonDioxideGenerationRate(true);
EXPECT_NEAR(value,q.value(),1.0E-15);
EXPECT_EQ(units.standardString(),q.units().standardString());
}
示例13: TEST_F
TEST_F(ModelFixture,HeatExchangerAirToAirSensibleAndLatent_ThresholdTemperature_Quantity) {
Model model;
HeatExchangerAirToAirSensibleAndLatent heatExchangerAirToAirSensibleAndLatent(model);
Unit units = heatExchangerAirToAirSensibleAndLatent.getThresholdTemperature(true).units(); // Get IP units.
double value(1.0);
Quantity testQ(value,units);
EXPECT_TRUE(heatExchangerAirToAirSensibleAndLatent.setThresholdTemperature(testQ));
Quantity q = heatExchangerAirToAirSensibleAndLatent.getThresholdTemperature(true);
EXPECT_NEAR(value,q.value(),1.0E-8);
EXPECT_EQ(units.standardString(),q.units().standardString());
}
示例14: TEST_F
TEST_F(ModelFixture,ZoneCapacitanceMultiplierResearchSpecial_TemperatureCapacityMultiplier_Quantity) {
Model model;
// TODO: Check constructor.
ZoneCapacitanceMultiplierResearchSpecial zoneCapacitanceMultiplierResearchSpecial = model.getUniqueModelObject<ZoneCapacitanceMultiplierResearchSpecial>();
Unit units = zoneCapacitanceMultiplierResearchSpecial.getTemperatureCapacityMultiplier(true).units(); // Get IP units.
// TODO: Check that value is appropriate (within bounds)
double value(1.0);
Quantity testQ(value,units);
EXPECT_TRUE(zoneCapacitanceMultiplierResearchSpecial.setTemperatureCapacityMultiplier(testQ));
Quantity q = zoneCapacitanceMultiplierResearchSpecial.getTemperatureCapacityMultiplier(true);
EXPECT_NEAR(value,q.value(),1.0E-8);
EXPECT_EQ(units.standardString(),q.units().standardString());
}
示例15: TEST_F
TEST_F(ModelFixture,RoofVegetation_LeafEmissivity_Quantity) {
Model model;
// TODO: Check constructor.
RoofVegetation roofVegetation(model);
Unit units = roofVegetation.getLeafEmissivity(true).units(); // Get IP units.
// TODO: Check that value is appropriate (within bounds)
double value(1.0);
Quantity testQ(value,units);
EXPECT_TRUE(roofVegetation.setLeafEmissivity(testQ));
Quantity q = roofVegetation.getLeafEmissivity(true);
EXPECT_NEAR(value,q.value(),1.0E-8);
EXPECT_EQ(units.standardString(),q.units().standardString());
}