当前位置: 首页>>代码示例>>C++>>正文


C++ Quantity类代码示例

本文整理汇总了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;
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:30,代码来源:MatrixPyImp.cpp

示例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);

}
开发者ID:MarcusWolschon,项目名称:FreeCAD_sf_master,代码行数:28,代码来源:InputField.cpp

示例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);

}
开发者ID:asosarma,项目名称:FreeCAD_sf_master,代码行数:28,代码来源:InputField.cpp

示例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;
		}
	}
}
开发者ID:ghorwin,项目名称:OpenHAM,代码行数:31,代码来源:IBK_QuantityManager.cpp

示例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");
     }
 }
开发者ID:21hub,项目名称:QuantLib,代码行数:32,代码来源:unitofmeasureconversion.cpp

示例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());
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:25,代码来源:ZoneHVACFourPipeFanCoil_GTest.cpp

示例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;
}
开发者ID:urbanengr,项目名称:OpenStudio,代码行数:9,代码来源:Quantity.cpp

示例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);
}
开发者ID:needtogettomit,项目名称:FreeCAD,代码行数:9,代码来源:QuantitySpinBox.cpp

示例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());
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:10,代码来源:OSQuantityVector.cpp

示例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;
}
开发者ID:lanigb,项目名称:FreeCAD,代码行数:30,代码来源:Constraint.cpp

示例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());
}
开发者ID:urbanengr,项目名称:OpenStudio,代码行数:12,代码来源:ThermalZone_GTest.cpp

示例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());
}
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:12,代码来源:People_GTest.cpp

示例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());
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:12,代码来源:HeatExchangerAirToAirSensibleAndLatent_GTest.cpp

示例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());
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:13,代码来源:ZoneCapacitanceMultiplierResearchSpecial_GTest.cpp

示例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());
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:14,代码来源:RoofVegetation_GTest.cpp


注:本文中的Quantity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。