StatsEditor::StatsEditor(QString path, QWidget *parent) : QMainWindow(parent), ui(new Ui::StatsEditor), mPath(path) { ui->setupUi(this); connect(ui->actionQuit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); // Load bodies mBodyModel.setColumnCount(15); mBodyModel.setHeaderData(0, Qt::Horizontal, QString("Name")); mBodyModel.setHeaderData(1, Qt::Horizontal, QString("Size")); mBodyModel.setHeaderData(2, Qt::Horizontal, QString("BuildPower")); mBodyModel.setHeaderData(3, Qt::Horizontal, QString("BuildPoints")); mBodyModel.setHeaderData(4, Qt::Horizontal, QString("Weight")); mBodyModel.setHeaderData(5, Qt::Horizontal, QString("HP")); mBodyModel.setHeaderData(6, Qt::Horizontal, QString("Model")); mBodyModel.setHeaderData(7, Qt::Horizontal, QString("Weapons")); mBodyModel.setHeaderData(8, Qt::Horizontal, QString("Power")); mBodyModel.setHeaderData(9, Qt::Horizontal, QString("Armour")); mBodyModel.setHeaderData(10, Qt::Horizontal, QString("Thermal")); mBodyModel.setHeaderData(11, Qt::Horizontal, QString("FlameModel")); mBodyModel.setHeaderData(12, Qt::Horizontal, QString("Designable")); mBodyModel.setHeaderData(13, Qt::Horizontal, QString("DroidType")); mBodyModel.setHeaderData(14, Qt::Horizontal, QString("Key")); QString bodyPath(path + "/body.ini"); if (!QFile::exists(bodyPath)) { qFatal("%s not found", bodyPath.toUtf8().constData()); } loadBodies(mBodyModel, bodyPath); ui->tableViewBodies->setModel(&mBodyModel); // Load propulsions mPropModel.setColumnCount(16); mPropModel.setHeaderData(0, Qt::Horizontal, QString("Name")); mPropModel.setHeaderData(1, Qt::Horizontal, QString("BuildPower")); mPropModel.setHeaderData(2, Qt::Horizontal, QString("BuildPoints")); mPropModel.setHeaderData(3, Qt::Horizontal, QString("Weight")); mPropModel.setHeaderData(4, Qt::Horizontal, QString("Hitpoints")); mPropModel.setHeaderData(5, Qt::Horizontal, QString("Model")); mPropModel.setHeaderData(6, Qt::Horizontal, QString("Type")); mPropModel.setHeaderData(7, Qt::Horizontal, QString("Speed")); mPropModel.setHeaderData(8, Qt::Horizontal, QString("Designable")); mPropModel.setHeaderData(9, Qt::Horizontal, QString("SkidDeceleration")); mPropModel.setHeaderData(10, Qt::Horizontal, QString("SpinSpeed")); mPropModel.setHeaderData(11, Qt::Horizontal, QString("TurnSpeed")); mPropModel.setHeaderData(12, Qt::Horizontal, QString("Acceleration")); mPropModel.setHeaderData(13, Qt::Horizontal, QString("Deceleration")); mPropModel.setHeaderData(14, Qt::Horizontal, QString("SpinAngle")); mPropModel.setHeaderData(15, Qt::Horizontal, QString("Key")); QString propPath(path + "/propulsion.ini"); if (!QFile::exists(propPath)) { qFatal("%s not found", propPath.toUtf8().constData()); } loadPropulsions(mPropModel, propPath); ui->tableViewPropulsions->setModel(&mPropModel); }
PXR_NAMESPACE_USING_DIRECTIVE void TestTemplates() { // --------------------------------------------------------------------- // // This test operates on /RootPrim.foo // and /RootPrim.foo:hidden // --------------------------------------------------------------------- // SdfPath primPath("/RootPrim"); TfToken prop("foo"); TfToken metaField("hidden"); std::string propPath(primPath.GetString() + "." + prop.GetString()); // --------------------------------------------------------------------- // // Author scene and compose the Stage // --------------------------------------------------------------------- // SdfLayerRefPtr layer = SdfLayer::CreateAnonymous(); UsdStageRefPtr stage = UsdStage::Open(layer->GetIdentifier()); TF_VERIFY(stage->OverridePrim(primPath), "Failed to create prim at %s", primPath.GetText()); UsdPrim prim(stage->GetPrimAtPath(primPath)); TF_VERIFY(prim, "Failed to get Prim from %s", primPath.GetText()); // Grab the attribute we will be testing with. UsdAttribute attr = prim.CreateAttribute(prop, SdfValueTypeNames->Double3Array); TF_VERIFY(attr, "Failed to create property at %s", propPath.c_str()); // --------------------------------------------------------------------- // // Setup some test data // --------------------------------------------------------------------- // VtVec3dArray vtVecOut(1); VtVec3dArray vtVecIn; std::string tmp; VtValue value; // ===================================================================== // // TEST READING METADATA // ===================================================================== // // --------------------------------------------------------------------- // // GetMetadata & SetMetadata the value as a VtValue // --------------------------------------------------------------------- // TF_VERIFY(attr.SetMetadata(metaField, VtValue(true)), "VtValue: Failed to set hidden metadata at %s", propPath.c_str()); // Print the layer for debugging. layer->ExportToString(&tmp); std::cout << "-----------------------------------------" << std::endl; std::cout << "Metadata -- VtValue:" << std::endl; std::cout << tmp << std::endl; // Verify the result. TF_VERIFY(attr.GetMetadata(metaField, &value), "Metadata -- VtValue: Failed to get property value at %s", propPath.c_str()); TF_VERIFY(value.IsHolding<bool>(), "Metadata -- VtValue: not holding bool%s", propPath.c_str()); TF_VERIFY(value.Get<bool>(), "Metadata -- VtValue: value was not true %s", propPath.c_str()); // --------------------------------------------------------------------- // // GetMetadata & SetMetadata the value as bool // --------------------------------------------------------------------- // bool valueIn = false; TF_VERIFY(attr.SetMetadata(metaField, true), "Metadata -- bool: Failed to set property at %s", propPath.c_str()); // Print the layer for debugging. tmp = ""; layer->ExportToString(&tmp); std::cout << "-----------------------------------------" << std::endl; std::cout << "Metadata -- bool:" << std::endl; std::cout << tmp << std::endl; // Verify Result. TF_VERIFY(attr.GetMetadata(metaField, &valueIn), "Metadata -- bool: Failed to get property value at %s", propPath.c_str()); TF_VERIFY(valueIn, "Metadata -- bool: value was not true %s", propPath.c_str()); // ===================================================================== // // TEST READING VALUES // ===================================================================== // // --------------------------------------------------------------------- // // Get & Set the value as a VtValue // --------------------------------------------------------------------- // vtVecOut[0] = GfVec3d(9,8,7); TF_VERIFY(attr.Set(VtValue(vtVecOut)), "VtValue: Failed to set property at %s", propPath.c_str()); // Print the layer for debugging. layer->ExportToString(&tmp); std::cout << "-----------------------------------------" << std::endl; std::cout << "VtValue:" << std::endl; std::cout << tmp << std::endl; // Verify the result. TF_VERIFY(attr.Get(&value), "VtValue: Failed to get property value at %s", propPath.c_str()); TF_VERIFY(value.IsHolding<VtVec3dArray>(), "VtValue: not holding VtVec3dArray %s", propPath.c_str()); TF_VERIFY(value.Get<VtVec3dArray>()[0] == vtVecOut[0], "VtValue: VtVec3d[0] does not match %s", propPath.c_str()); // --------------------------------------------------------------------- // // Get & Set the value as a VtArray // --------------------------------------------------------------------- // vtVecOut[0] = GfVec3d(6,5,4); TF_VERIFY(attr.Set(vtVecOut), "Failed to set property at %s", propPath.c_str()); // Print the layer for debugging. tmp = ""; layer->ExportToString(&tmp); std::cout << "-----------------------------------------" << std::endl; std::cout << "VtArray:" << std::endl; std::cout << tmp << std::endl; // Verify Result. TF_VERIFY(attr.Get(&vtVecIn), "VtArray: Failed to get property value at %s", propPath.c_str()); TF_VERIFY(vtVecIn[0] == vtVecOut[0], "VtArray: VtVec3d[0] does not match %s", propPath.c_str()); // --------------------------------------------------------------------- // // Get & Set the value as a VtDictionary (Dictionary composition semantics // are exercised in testUsdMetadata). // --------------------------------------------------------------------- // VtDictionary inDict; inDict["$Side"] = "R"; TF_VERIFY(!prim.HasAuthoredMetadata(SdfFieldKeys->PrefixSubstitutions)); TF_VERIFY(prim.SetMetadata(SdfFieldKeys->PrefixSubstitutions, inDict)); VtDictionary outDict; TF_VERIFY(prim.HasAuthoredMetadata(SdfFieldKeys->PrefixSubstitutions)); // Verify bug 97783 - GetMetadata should return true if Usd was able to // retrieve/compose a VtDictionary. TF_VERIFY(prim.GetMetadata(SdfFieldKeys->PrefixSubstitutions,&outDict)); TF_VERIFY(inDict == outDict); std::cout << "-----------------------------------------" << std::endl; std::cout << "VtDictionary:" << std::endl; tmp = ""; layer->ExportToString(&tmp); std::cout << tmp << std::endl; }