예제 #1
0
  QVariant DiscreteVariable_Impl::toServerFormulationVariant() const {
    QVariantMap map;

    map["uuid"] = toQString(removeBraces(uuid()));
    map["version_uuid"] = toQString(removeBraces(uuid()));
    map["name"] = toQString(name());
    map["display_name"] = toQString(displayName());
    map["type"] = QString("Integer"); // could be Discrete instead

    // determine minimum, maximum from all values
    IntVector allValues = validValues(false);
    // right now, only have MeasureGroup, this will always be contiguous listing
    map["minimum"] = 0;
    map["maximum"] = int(allValues.size()) - 1;
    // no initial_value implemented right now

    // if selected values are subset, list them separately
    IntVector selectedValues = validValues(true);
    if (selectedValues.size() < allValues.size()) {
      QVariantList selectedList;
      for (int val : selectedValues) {
        selectedList.push_back(QVariant(val));
      }
      map["selected_values"] = selectedList;
    }

    return QVariant(map);
  }
예제 #2
0
  QVariant toVariant(const FileReference& fileReference) {
    QVariantMap fileReferenceData;

    fileReferenceData["uuid"] = toQString(removeBraces(fileReference.uuid()));
    fileReferenceData["version_uuid"] = toQString(removeBraces(fileReference.versionUUID()));
    std::string str = fileReference.name();
    if (!str.empty()) {
      fileReferenceData["name"] = toQString(str);
    }
    str = fileReference.displayName();
    if (!str.empty()) {
      fileReferenceData["display_name"] = toQString(str);
    }
    str = fileReference.description();
    if (!str.empty()) {
      fileReferenceData["description"] = toQString(str);
    }
    fileReferenceData["path"] = toQString(fileReference.path());
    fileReferenceData["file_type"] = toQString(fileReference.fileType().valueName());
    fileReferenceData["timestamp_last"] = toQString(fileReference.timestampLast().toISO8601());
    fileReferenceData["checksum_create"] = toQString(fileReference.checksumCreate());
    fileReferenceData["checksum_last"] = toQString(fileReference.checksumLast());

    return QVariant(fileReferenceData);
  }
예제 #3
0
파일: Tag.cpp 프로젝트: CUEBoxer/OpenStudio
  QVariant toVariant(const Tag& tag) {
    QVariantMap tagData;

    tagData["uuid"] = toQString(removeBraces(tag.uuid()));
    tagData["name"] = toQString(tag.name());

    return QVariant(tagData);
  }
예제 #4
0
  QVariant ContinuousVariable_Impl::toServerFormulationVariant() const {
    QVariantMap map;

    map["uuid"] = toQString(removeBraces(uuid()));
    map["version_uuid"] = toQString(removeBraces(uuid()));
    map["name"] = toQString(name());
    map["display_name"] = toQString(displayName());
    map["type"] = QString("Double"); // could be Continuous instead
    if (minimum()) {
      map["minimum"] = minimum().get();
    }
    if (maximum()) {
      map["maximum"] = maximum().get();
    }
    // there is no initial_value yet

    return QVariant(map);
  }
예제 #5
0
  QVariant AnalysisObject_Impl::toVariant() const {
    QVariantMap analysisObjectData;

    analysisObjectData["uuid"] = toQString(removeBraces(uuid()));
    analysisObjectData["version_uuid"] = toQString(removeBraces(versionUUID()));
    std::string str = name();
    if (!str.empty()) {
      analysisObjectData["name"] = toQString(str);
    }
    str = displayName();
    if (!str.empty()) {
      analysisObjectData["display_name"] = toQString(str);
    }
    str = description();
    if (!str.empty()) {
      analysisObjectData["description"] = toQString(str);
    }

    return QVariant(analysisObjectData);
  }
예제 #6
0
  QVariant toVariant(const OSArgument& argument) {
    QVariantMap argumentData;

    argumentData["uuid"] = toQString(removeBraces(argument.uuid()));
    argumentData["version_uuid"] = toQString(removeBraces(argument.versionUUID()));
    argumentData["name"] = toQString(argument.name());
    if (!argument.displayName().empty()) {
      argumentData["display_name"] = toQString(argument.displayName());
    }
    if (argument.description() && !argument.description()->empty()) {
      argumentData["description"] = toQString(argument.description().get());
    }
    OSArgumentType type = argument.type();
    if (argument.units() && !argument.units()->empty()) {
      argumentData["units"] = toQString(argument.units().get());
    }
    argumentData["type"] = toQString(type.valueName());
    argumentData["required"] = argument.required();
    argumentData["model_dependent"] = argument.modelDependent();
    if (argument.hasValue()) {
      if (type == OSArgumentType::Quantity) {
        Quantity value = argument.valueAsQuantity();
        argumentData["value"] = value.value();
        argumentData["value_units"] = toQString(value.units().standardString());
      }
      else {
        // use QVariant directly
        argumentData["value"] = argument.valueAsQVariant();
      }
    }
    if (argument.hasDefaultValue()) {
      if (type == OSArgumentType::Quantity) {
        Quantity defaultValue = argument.defaultValueAsQuantity();
        argumentData["default_value"] = defaultValue.value();
        argumentData["default_value_units"] = toQString(defaultValue.units().standardString());
      }
      else {
        // use QVariant directly
        argumentData["default_value"] = argument.defaultValueAsQVariant();
      }
    }
    argumentData["domain_type"] = toQString(argument.domainType().valueName());
    if (argument.hasDomain()) {
      QVariantList domainList;
      int index(0);
      for (const QVariant& dval : argument.domainAsQVariant()) {
        QVariantMap domainValueMap;
        domainValueMap["domain_value_index"] = index;
        if (type == OSArgumentType::Quantity) {
          Quantity q = dval.value<openstudio::Quantity>();
          domainValueMap["value"] = q.value();
          domainValueMap["units"] = toQString(q.units().standardString());
        }
        else {
          domainValueMap["value"] = dval;
        }
        domainList.push_back(domainValueMap);
        ++index;
      }
      argumentData["domain"] = domainList;
    }
    if (type == OSArgumentType::Choice) {
      QVariantList choicesList;
      StringVector displayNames = argument.choiceValueDisplayNames();
      int index(0), displayNamesN(displayNames.size());
      for (const std::string& choice : argument.choiceValues()) {
        QVariantMap choiceMap;
        choiceMap["choice_index"] = index;
        choiceMap["value"] = toQString(choice);
        if (index < displayNamesN) {
          choiceMap["display_name"] = toQString(displayNames[index]);
        }
        choicesList.push_back(choiceMap);
        ++index;
      }
      argumentData["choices"] = QVariant(choicesList);
    }
    if (type == OSArgumentType::Path) {
      argumentData["is_read"] = argument.isRead();
      argumentData["extension"] = toQString(argument.extension());
    }

    return QVariant(argumentData);
  }