Example #1
0
void
Profile::SetAirspaceFillMode(unsigned i, uint8_t mode)
{
  TCHAR name[64];
  MakeAirspaceSettingName(name, _T("AirspaceFillMode"), i);
  SetEnum(name, (AirspaceClassRendererSettings::FillMode)mode);
}
Example #2
0
void UK2Node_Select::AllocateDefaultPins()
{
	const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();

	// To refresh, just in case it changed
	SetEnum(Enum, true);

	if (Enum)
	{
		NumOptionPins = EnumEntries.Num();
	}

	// Create the option pins
	for (int32 Idx = 0; Idx < NumOptionPins; Idx++)
	{
		UEdGraphPin* NewPin = NULL;

		if (Enum)
		{
			const FString PinName = EnumEntries[Idx].ToString();
			UEdGraphPin* TempPin = FindPin(PinName);
			if (!TempPin)
			{
				NewPin = CreatePin(EGPD_Input, Schema->PC_Wildcard, TEXT(""), NULL, false, false, PinName);
			}
		}
		else
		{
			const FString PinName = FString::Printf(TEXT("Option %d"), Idx);
			NewPin = CreatePin(EGPD_Input, Schema->PC_Wildcard, TEXT(""), NULL, false, false, PinName);
		}

		if (NewPin)
		{
			if (IndexPinType.PinCategory == UEdGraphSchema_K2::PC_Boolean)
			{
				NewPin->PinFriendlyName = (Idx == 0 ? GFalse : GTrue);
			}
			else if (Idx < EnumEntryFriendlyNames.Num())
			{
				if (EnumEntryFriendlyNames[Idx] != NAME_None)
				{
					NewPin->PinFriendlyName = FText::FromName(EnumEntryFriendlyNames[Idx]);
				}
				else
				{
					NewPin->PinFriendlyName = FText::GetEmpty();
				}
			}
		}
	}

	// Create the index wildcard pin
	CreatePin(EGPD_Input, IndexPinType.PinCategory, IndexPinType.PinSubCategory, IndexPinType.PinSubCategoryObject.Get(), false, false, "Index");

	// Create the return value
	CreatePin(EGPD_Output, Schema->PC_Wildcard, TEXT(""), NULL, false, false, Schema->PN_ReturnValue);

	Super::AllocateDefaultPins();
}
void UK2Node_SwitchEnum::CreateCasePins()
{
	if(NULL != Enum)
	{
		SetEnum(Enum);
	}

	const bool bShouldUseAdvancedView = (EnumEntries.Num() > 5);
	if(bShouldUseAdvancedView && (ENodeAdvancedPins::NoPins == AdvancedPinDisplay))
	{
		AdvancedPinDisplay = ENodeAdvancedPins::Hidden;
	}

	const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
	for (auto EnumIt = EnumEntries.CreateConstIterator(); EnumIt; ++EnumIt)
	{
		FName EnumEntry = *EnumIt;
		UEdGraphPin * NewPin = CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, EnumEntry.ToString());
		int32 Index = EnumIt.GetIndex();
		if (EnumFriendlyNames.IsValidIndex(Index))
		{
			NewPin->PinFriendlyName = FText::FromString(EnumFriendlyNames[Index]);
		}
		
		if(bShouldUseAdvancedView && (EnumIt.GetIndex() > 2))
		{
			NewPin->bAdvancedView = true;
		}
	}
}
void CXTPPropertyGridItemEnum::OnBeforeInsert()
{
	if (m_pBindEnum && *m_pBindEnum != m_nValue)
	{
		SetEnum(*m_pBindEnum);
	}
}
void CXTPPropertyGridItemEnum::_Init(int nValue)
{
	SetEnum(nValue);
	m_nFlags = xtpGridItemHasComboButton | xtpGridItemHasEdit;

	SetConstraintEdit(TRUE);
	m_strDefaultValue = m_strValue;
}
void CXTPPropertyGridItemEnum::SetValue(CString strValue)
{
	int nIndex = m_pConstraints->FindConstraint(strValue);
	ASSERT(nIndex >= 0);
	if (nIndex >= 0)
	{
		SetEnum(m_pConstraints->GetConstraintAt(nIndex));
	}
}
Example #7
0
void ParamWidget::LoadState(const QVariant& variant) {
  QMap<QString, QVariant> data = variant.toMap();

  for (auto& item : widgets_) {
    const QString& name = item.first;
    const QString qname = name;
    QWidget* widget = item.second;
    QVariant param_type = widget->property("param_widget_type");
    QVariant value = data[qname];
    assert(param_type.isValid());
    switch (param_type.toInt()) {
      case kParamEnum:
        if (value.canConvert<int>()) {
          SetEnum(name, value.toInt());
        }
        break;
      case kParamBool:
        if (value.canConvert<bool>()) {
          SetBool(name, value.toBool());
        }
        break;
      case kParamInt:
        if (value.canConvert<int>()) {
          SetInt(name, value.toInt());
        }
        break;
      case kParamDouble:
        if (value.canConvert<double>()) {
          SetDouble(name, value.toDouble());
        }
        break;
      case kParamButton:
      default:
        assert(false);
        break;
    }
  }
}
Example #8
0
bool Pb2Json::Json2Message(const Json& json, ProtobufMsg& message, bool str2enum) {
    auto descriptor = message.GetDescriptor();
    auto reflection = message.GetReflection();
    if (nullptr == descriptor || nullptr == reflection) return false;

    auto count = descriptor->field_count();
    for (auto i = 0; i < count; ++i) {
        const auto field = descriptor->field(i);
        if (nullptr == field) continue;

        auto& value = json[field->name()];
        if (value.is_null()) continue;

        if (field->is_repeated()) {
            if (!value.is_array()) {
                return false;
            } else {
                Json2RepeatedMessage(value, message, field, reflection, str2enum);
                continue;
            }
        }

        switch (field->type()) {
            case ProtobufFieldDescriptor::TYPE_BOOL: {
                if (value.is_boolean())
                    reflection->SetBool(&message, field, value.get<bool>());
                else if (value.is_number_integer())
                    reflection->SetBool(&message, field, value.get<uint32_t>() != 0);
                else if (value.is_string()) {
                    if (value.get<std::string>() == "true")
                        reflection->SetBool(&message, field, true);
                    else if (value.get<std::string>() == "false")
                        reflection->SetBool(&message, field, false);
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_ENUM: {
                auto const* pedesc = field->enum_type();
                const ::google::protobuf::EnumValueDescriptor* pevdesc = nullptr;

                if (str2enum) {
                    pevdesc = pedesc->FindValueByName(value.get<std::string>());
                } else {
                    pevdesc = pedesc->FindValueByNumber(value.get<int>());
                }

                if (nullptr != pevdesc) {
                    reflection->SetEnum(&message, field, pevdesc);
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_INT32:
            case ProtobufFieldDescriptor::TYPE_SINT32:
            case ProtobufFieldDescriptor::TYPE_SFIXED32: {
                if (value.is_number()) reflection->SetInt32(&message, field, value.get<int32_t>());
            } break;

            case ProtobufFieldDescriptor::TYPE_UINT32:
            case ProtobufFieldDescriptor::TYPE_FIXED32: {
                if (value.is_number()) reflection->SetUInt32(&message, field, value.get<uint32_t>());
            } break;

            case ProtobufFieldDescriptor::TYPE_INT64:
            case ProtobufFieldDescriptor::TYPE_SINT64:
            case ProtobufFieldDescriptor::TYPE_SFIXED64: {
                if (value.is_number()) reflection->SetInt64(&message, field, value.get<int64_t>());
            } break;
            case ProtobufFieldDescriptor::TYPE_UINT64:
            case ProtobufFieldDescriptor::TYPE_FIXED64: {
                if (value.is_number()) reflection->SetUInt64(&message, field, value.get<uint64_t>());
            } break;

            case ProtobufFieldDescriptor::TYPE_FLOAT: {
                if (value.is_number()) reflection->SetFloat(&message, field, value.get<float>());
            } break;

            case ProtobufFieldDescriptor::TYPE_DOUBLE: {
                if (value.is_number()) reflection->SetDouble(&message, field, value.get<double>());
            } break;

            case ProtobufFieldDescriptor::TYPE_STRING:
            case ProtobufFieldDescriptor::TYPE_BYTES: {
                if (value.is_string()) reflection->SetString(&message, field, value.get<std::string>());
            } break;

            case ProtobufFieldDescriptor::TYPE_MESSAGE: {
                if (value.is_object()) Json2Message(value, *reflection->MutableMessage(&message, field));
            } break;

            default:
                break;
        }
    }
    return true;
}
Example #9
0
void UK2Node_Select::PinTypeChanged(UEdGraphPin* Pin)
{
	const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();

	if (Pin == GetIndexPin())
	{
		if (IndexPinType != Pin->PinType)
		{
			IndexPinType = Pin->PinType;

			if (IndexPinType.PinSubCategoryObject.IsValid())
			{
				SetEnum(Cast<UEnum>(IndexPinType.PinSubCategoryObject.Get()));
			}
			else if (Enum)
			{
				SetEnum(NULL);
			}

			// Remove all but two options if we switched to a bool index
			if (IndexPinType.PinCategory == Schema->PC_Boolean)
			{
				if (NumOptionPins > 2)
				{
					NumOptionPins = 2;
					bReconstructNode = true;
				}
			}

			// Reset the default value
			Schema->SetPinDefaultValueBasedOnType(Pin);
		}
	}
	else
	{
		// Set the return value
		UEdGraphPin* ReturnPin = GetReturnValuePin();
		if (ReturnPin->PinType != Pin->PinType)
		{
			ReturnPin->PinType = Pin->PinType;
			Schema->SetPinDefaultValueBasedOnType(ReturnPin);
		}

		// Set the options
		TArray<UEdGraphPin*> OptionPins;
		GetOptionPins(OptionPins);
		for (auto It = OptionPins.CreateConstIterator(); It; It++)
		{
			UEdGraphPin* OptionPin = (*It);
			if (OptionPin->PinType != Pin->PinType ||
				OptionPin == Pin)
			{
				OptionPin->PinType = Pin->PinType;
				Schema->SetPinDefaultValueBasedOnType(OptionPin);
			}
		}
	}


	// Reconstruct the node since the options could change
	if (bReconstructNode)
	{
		ReconstructNode();
	}

	// Let the graph know to refresh
	GetGraph()->NotifyGraphChanged();

	UBlueprint* Blueprint = GetBlueprint();
	if(!Blueprint->bBeingCompiled)
	{
		FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
		Blueprint->BroadcastChanged();
	}
}
Example #10
0
/** Determine if any pins are connected, if so make all the other pins the same type, if not, make sure pins are switched back to wildcards */
void UK2Node_Select::NotifyPinConnectionListChanged(UEdGraphPin* Pin)
{
	Super::NotifyPinConnectionListChanged(Pin);

	const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();

	// If this is the Enum pin we need to set the enum and reconstruct the node
	if (Pin == GetIndexPin())
	{
		// If the index pin was just linked to another pin
		if (Pin->LinkedTo.Num() > 0)
		{
			UEdGraphPin* LinkPin = Pin->LinkedTo[0];
			IndexPinType = LinkPin->PinType;
			Pin->PinType = IndexPinType;

			// See if it was an enum pin
			if (LinkPin->PinType.PinCategory == Schema->PC_Byte &&
				LinkPin->PinType.PinSubCategoryObject != NULL &&
				LinkPin->PinType.PinSubCategoryObject->IsA(UEnum::StaticClass()))
			{
				UEnum* EnumPtr = Cast<UEnum>(LinkPin->PinType.PinSubCategoryObject.Get());
				SetEnum(EnumPtr);
			}
			else
			{
				SetEnum(NULL);
			}

			Schema->SetPinDefaultValueBasedOnType(Pin);

			GetGraph()->NotifyGraphChanged();
			UBlueprint* Blueprint = GetBlueprint();
			if(!Blueprint->bBeingCompiled)
			{
				FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
				Blueprint->BroadcastChanged();
			}

			// If the index pin is a boolean, we need to remove all but 2 options
			if (IndexPinType.PinCategory == Schema->PC_Boolean &&
				NumOptionPins != 2)
			{
				NumOptionPins = 2;
				bReconstructNode = true;
			}
		}
	}
	else
	{
		// Grab references to all option pins and the return pin
		TArray<UEdGraphPin*> OptionPins;
		GetOptionPins(OptionPins);
		UEdGraphPin* ReturnPin = FindPin(Schema->PN_ReturnValue);

		// See if this pin is one of the wildcard pins
		bool bIsWildcardPin = (Pin == ReturnPin || OptionPins.Find(Pin) != INDEX_NONE) && Pin->PinType.PinCategory == Schema->PC_Wildcard;

		// If the pin was one of the wildcards we have to handle it specially
		if (bIsWildcardPin)
		{
			// If the pin is linked, make sure the other wildcard pins match
			if (Pin->LinkedTo.Num() > 0)
			{
				// Set pin type on the pin
				Pin->PinType = Pin->LinkedTo[0]->PinType;

				// Make sure the return pin is the same pin type
				if (ReturnPin != Pin)
				{
					ReturnPin->Modify();

					ReturnPin->PinType = Pin->PinType;
					UEdGraphSchema_K2::ValidateExistingConnections(ReturnPin);
				}

				// Make sure all options are of the same pin type
				for (auto It = OptionPins.CreateConstIterator(); It; It++)
				{
					UEdGraphPin* OptionPin = (*It);
					if (*It && *It != Pin)
					{
						(*It)->Modify();

						(*It)->PinType = Pin->PinType;
						UEdGraphSchema_K2::ValidateExistingConnections(*It);
					}
				}

				bReconstructNode = true;
			}
		}
	}
}
Example #11
0
void
Profile::SetDeviceConfig(unsigned n, const DeviceConfig &config)
{
  char buffer[64];

  WritePortType(n, config.port_type);

  MakeDeviceSettingName(buffer, "Port", n, "BluetoothMAC");
  Set(buffer, config.bluetooth_mac);

  MakeDeviceSettingName(buffer, "Port", n, "IOIOUartID");
  Set(buffer, config.ioio_uart_id);

  MakeDeviceSettingName(buffer, "Port", n, "Path");
  Set(buffer, config.path);

  MakeDeviceSettingName(buffer, "Port", n, "BaudRate");
  Set(buffer, config.baud_rate);

  MakeDeviceSettingName(buffer, "Port", n, "BulkBaudRate");
  Set(buffer, config.bulk_baud_rate);

  MakeDeviceSettingName(buffer, "Port", n, "IPAddress");
  Set(buffer, config.ip_address);

  MakeDeviceSettingName(buffer, "Port", n, "TCPPort");
  Set(buffer, config.tcp_port);

  strcpy(buffer, "DeviceA");
  buffer[strlen(buffer) - 1] += n;
  Set(buffer, config.driver_name);

  MakeDeviceSettingName(buffer, "Port", n, "Enabled");
  Set(buffer, config.enabled);

  MakeDeviceSettingName(buffer, "Port", n, "SyncFromDevice");
  Set(buffer, config.sync_from_device);

  MakeDeviceSettingName(buffer, "Port", n, "SyncToDevice");
  Set(buffer, config.sync_to_device);

  MakeDeviceSettingName(buffer, "Port", n, "K6Bt");
  Set(buffer, config.k6bt);

  MakeDeviceSettingName(buffer, "Port", n, "I2C_Bus");
  Set(buffer, config.i2c_bus);

  MakeDeviceSettingName(buffer, "Port", n, "I2C_Addr");
  Set(buffer, config.i2c_addr);

  MakeDeviceSettingName(buffer, "Port", n, "PressureUse");
  SetEnum(buffer, config.press_use);

  MakeDeviceSettingName(buffer, "Port", n, "SensorOffset");
  fixed offset = DeviceConfig::UsesCalibration(config.port_type) ? config.sensor_offset : fixed(0);
  // Has new calibration data been delivered ?
  if (CommonInterface::Basic().sensor_calibration_available)
    offset = CommonInterface::Basic().sensor_calibration_offset;
  Set(buffer, offset);

  MakeDeviceSettingName(buffer, "Port", n, "SensorFactor");
  fixed factor = DeviceConfig::UsesCalibration(config.port_type) ? config.sensor_factor : fixed(0);
  // Has new calibration data been delivered ?
  if (CommonInterface::Basic().sensor_calibration_available)
    factor = CommonInterface::Basic().sensor_calibration_factor;
  Set(buffer, factor);
}