本文整理汇总了C++中ModelObject::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelObject::getAttribute方法的具体用法?C++ ModelObject::getAttribute怎么用?C++ ModelObject::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelObject
的用法示例。
在下文中一共展示了ModelObject::getAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refreshTextAndLabel
void OSIntegerEdit::refreshTextAndLabel() {
if (m_modelObject) {
QString textValue;
ModelObject modelObject = m_modelObject.get();
std::stringstream ss;
if (m_isAutosizedProperty) {
Attribute autosized = modelObject.getAttribute(*m_isAutosizedProperty).get();
if (autosized.valueAsBoolean()) {
textValue = QString("autosize");
}
}
if (m_isAutocalculatedProperty) {
Attribute autocalculated = modelObject.getAttribute(*m_isAutocalculatedProperty).get();
if (autocalculated.valueAsBoolean()) {
textValue = QString("autocalculate");
}
}
OptionalAttribute attribute = modelObject.getAttribute(m_property);
if (attribute) {
int value = attribute->valueAsInteger();
if (m_isScientific) {
ss << std::scientific;
}
else {
ss << std::fixed;
}
if (m_precision) {
ss << std::setprecision(*m_precision);
}
ss << value;
textValue = toQString(ss.str());
ss.str("");
}
this->setText(textValue);
if (m_isDefaultedProperty) {
Attribute defaulted = modelObject.getAttribute(*m_isDefaultedProperty).get();
if (defaulted.valueAsBoolean()) {
this->setStyleSheet("color:green");
}
else {
this->setStyleSheet("color:black");
}
}
}
}
示例2:
TEST_F(ModelFixture, ModelObject_Attributes)
{
Model model;
OptionalWorkspaceObject oObject = model.addObject(IdfObject(IddObjectType::OS_Version));
ASSERT_TRUE(oObject);
ModelObject version = oObject->cast<ModelObject>();
StringVector versionAttributeNames = version.attributeNames();
ASSERT_EQ(static_cast<unsigned>(3),versionAttributeNames.size());
EXPECT_EQ("iddObjectType",versionAttributeNames[0]);
EXPECT_EQ("handle",versionAttributeNames[1]);
EXPECT_EQ("name",versionAttributeNames[2]);
EXPECT_FALSE(version.getAttribute("N a m e"));
}