Added support for multi edit of ints and lists.

This commit is contained in:
Leonardo Zide 2024-02-19 16:31:02 -08:00
parent 39bdb1aa0a
commit dd989bbc1d
9 changed files with 246 additions and 176 deletions

View file

@ -58,6 +58,33 @@ lcCamera::~lcCamera()
{ {
} }
QString lcCamera::GetCameraTypeString(lcCameraType CameraType)
{
switch (CameraType)
{
case lcCameraType::Perspective:
return QT_TRANSLATE_NOOP("Camera Type", "Perspective");
case lcCameraType::Orthographic:
return QT_TRANSLATE_NOOP("Camera Type", "Orthographic");
case lcCameraType::Count:
break;
}
return QString();
}
QStringList lcCamera::GetCameraTypeStrings()
{
QStringList CameraType;
for (int CameraTypeIndex = 0; CameraTypeIndex < static_cast<int>(lcCameraType::Count); CameraTypeIndex++)
CameraType.push_back(GetCameraTypeString(static_cast<lcCameraType>(CameraTypeIndex)));
return CameraType;
}
lcViewpoint lcCamera::GetViewpoint(const QString& ViewpointName) lcViewpoint lcCamera::GetViewpoint(const QString& ViewpointName)
{ {
const QLatin1String ViewpointNames[] = const QLatin1String ViewpointNames[] =
@ -132,6 +159,19 @@ void lcCamera::CreateName(const lcArray<lcCamera*>& Cameras)
mName = Prefix + QString::number(MaxCameraNumber + 1); mName = Prefix + QString::number(MaxCameraNumber + 1);
} }
bool lcCamera::SetCameraType(lcCameraType CameraType)
{
if (static_cast<int>(CameraType) < 0 || CameraType >= lcCameraType::Count)
return false;
if (GetCameraType() == CameraType)
return false;
SetOrtho(CameraType == lcCameraType::Orthographic);
return true;
}
void lcCamera::SaveLDraw(QTextStream& Stream) const void lcCamera::SaveLDraw(QTextStream& Stream) const
{ {
const QLatin1String LineEnding("\r\n"); const QLatin1String LineEnding("\r\n");
@ -575,7 +615,11 @@ QVariant lcCamera::GetPropertyValue(lcObjectPropertyId PropertyId) const
case lcObjectPropertyId::PieceStepShow: case lcObjectPropertyId::PieceStepShow:
case lcObjectPropertyId::PieceStepHide: case lcObjectPropertyId::PieceStepHide:
case lcObjectPropertyId::CameraName: case lcObjectPropertyId::CameraName:
break;
case lcObjectPropertyId::CameraType: case lcObjectPropertyId::CameraType:
return static_cast<int>(GetCameraType());
case lcObjectPropertyId::CameraFOV: case lcObjectPropertyId::CameraFOV:
case lcObjectPropertyId::CameraNear: case lcObjectPropertyId::CameraNear:
case lcObjectPropertyId::CameraFar: case lcObjectPropertyId::CameraFar:
@ -633,7 +677,11 @@ bool lcCamera::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
case lcObjectPropertyId::PieceStepShow: case lcObjectPropertyId::PieceStepShow:
case lcObjectPropertyId::PieceStepHide: case lcObjectPropertyId::PieceStepHide:
case lcObjectPropertyId::CameraName: case lcObjectPropertyId::CameraName:
break;
case lcObjectPropertyId::CameraType: case lcObjectPropertyId::CameraType:
return SetCameraType(static_cast<lcCameraType>(Value.toInt()));
case lcObjectPropertyId::CameraFOV: case lcObjectPropertyId::CameraFOV:
case lcObjectPropertyId::CameraNear: case lcObjectPropertyId::CameraNear:
case lcObjectPropertyId::CameraFar: case lcObjectPropertyId::CameraFar:

View file

@ -29,6 +29,13 @@ enum class lcViewpoint
Count Count
}; };
enum class lcCameraType
{
Perspective,
Orthographic,
Count
};
enum lcCameraSection enum lcCameraSection
{ {
LC_CAMERA_SECTION_POSITION, LC_CAMERA_SECTION_POSITION,
@ -48,6 +55,8 @@ public:
lcCamera& operator=(const lcCamera&) = delete; lcCamera& operator=(const lcCamera&) = delete;
lcCamera& operator=(lcCamera&&) = delete; lcCamera& operator=(lcCamera&&) = delete;
static QString GetCameraTypeString(lcCameraType CameraType);
static QStringList GetCameraTypeStrings();
static lcViewpoint GetViewpoint(const QString& ViewpointName); static lcViewpoint GetViewpoint(const QString& ViewpointName);
QString GetName() const override QString GetName() const override
@ -63,6 +72,13 @@ public:
return (mState & LC_CAMERA_SIMPLE) != 0; return (mState & LC_CAMERA_SIMPLE) != 0;
} }
lcCameraType GetCameraType() const
{
return ((mState & LC_CAMERA_ORTHO) == 0) ? lcCameraType::Perspective : lcCameraType::Orthographic;
}
bool SetCameraType(lcCameraType CameraType);
bool IsOrtho() const bool IsOrtho() const
{ {
return (mState & LC_CAMERA_ORTHO) != 0; return (mState & LC_CAMERA_ORTHO) != 0;

View file

@ -3172,18 +3172,6 @@ void lcModel::SetCameraName(lcCamera* Camera, const QString& Name)
gMainWindow->UpdateCameraMenu(); gMainWindow->UpdateCameraMenu();
} }
void lcModel::SetLightType(lcLight* Light, lcLightType LightType)
{
if (!Light->SetLightType(LightType))
return;
Light->UpdatePosition(mCurrentStep);
SaveCheckpoint(tr("Changing Light Type"));
gMainWindow->UpdateSelectedObjects(false);
UpdateAllViews();
}
void lcModel::SetLightAttenuationDistance(lcLight* Light, float Distance) void lcModel::SetLightAttenuationDistance(lcLight* Light, float Distance)
{ {
Light->SetAttenuationDistance(Distance, mCurrentStep, gMainWindow->GetAddKeys()); Light->SetAttenuationDistance(Distance, mCurrentStep, gMainWindow->GetAddKeys());
@ -3234,30 +3222,6 @@ void lcModel::SetSpotLightTightness(lcLight* Light, float Tightness)
UpdateAllViews(); UpdateAllViews();
} }
void lcModel::SetLightAreaShape(lcLight* Light, lcLightAreaShape LightAreaShape)
{
if (!Light->SetAreaShape(LightAreaShape))
return;
Light->UpdatePosition(mCurrentStep);
SaveCheckpoint(tr("Changing Area Light Shape"));
gMainWindow->UpdateSelectedObjects(false);
UpdateAllViews();
}
void lcModel::SetLightAreaGrid(lcLight* Light, lcVector2i AreaGrid)
{
if (!Light->SetAreaGrid(AreaGrid, mCurrentStep, gMainWindow->GetAddKeys()))
return;
Light->UpdatePosition(mCurrentStep);
SaveCheckpoint(tr("Changing Area Light Size"));
gMainWindow->UpdateSelectedObjects(false);
UpdateAllViews();
}
void lcModel::SetLightSize(lcLight* Light, lcVector2 LightAreaSize) void lcModel::SetLightSize(lcLight* Light, lcVector2 LightAreaSize)
{ {
Light->SetSize(LightAreaSize, mCurrentStep, gMainWindow->GetAddKeys()); Light->SetSize(LightAreaSize, mCurrentStep, gMainWindow->GetAddKeys());

View file

@ -373,14 +373,11 @@ public:
void SetCameraZFar(lcCamera* Camera, float ZFar); void SetCameraZFar(lcCamera* Camera, float ZFar);
void SetCameraName(lcCamera* Camera, const QString& Name); void SetCameraName(lcCamera* Camera, const QString& Name);
void SetLightType(lcLight* Light, lcLightType LightType);
void SetLightAttenuationDistance(lcLight* Light, float Distance); void SetLightAttenuationDistance(lcLight* Light, float Distance);
void SetLightAttenuationPower(lcLight* Light, float Power); void SetLightAttenuationPower(lcLight* Light, float Power);
void SetSpotLightConeAngle(lcLight* Light, float Angle); void SetSpotLightConeAngle(lcLight* Light, float Angle);
void SetSpotLightPenumbraAngle(lcLight* Light, float Angle); void SetSpotLightPenumbraAngle(lcLight* Light, float Angle);
void SetSpotLightTightness(lcLight* Light, float Tightness); void SetSpotLightTightness(lcLight* Light, float Tightness);
void SetLightAreaShape(lcLight* Light, lcLightAreaShape LightAreaShape);
void SetLightAreaGrid(lcLight* Light, lcVector2i AreaGrid);
void SetLightSize(lcLight* Light, lcVector2 LightAreaSize); void SetLightSize(lcLight* Light, lcVector2 LightAreaSize);
void SetLightPower(lcLight* Light, float Power); void SetLightPower(lcLight* Light, float Power);
void SetLightName(lcLight* Light, const QString& Name); void SetLightName(lcLight* Light, const QString& Name);

View file

@ -155,6 +155,37 @@ void lcPropertiesWidget::AddKeyFrameWidget(lcObjectPropertyId PropertyId)
mPropertyWidgets[static_cast<int>(PropertyId)].KeyFrame = Widget; mPropertyWidgets[static_cast<int>(PropertyId)].KeyFrame = Widget;
} }
std::pair<QVariant, bool> lcPropertiesWidget::GetUpdateValue(lcObjectPropertyId PropertyId, QVariant DefaultValue)
{
QVariant Value = DefaultValue;
bool Partial = false;
if (mFocusObject)
Value = mFocusObject->GetPropertyValue(PropertyId);
else
{
bool First = true;
for (const lcObject* Object : mSelection)
{
const QVariant ObjectValue = Object->GetPropertyValue(PropertyId);
if (First)
{
Value = ObjectValue;
First = false;
}
else if (Value != ObjectValue)
{
Partial = true;
break;
}
}
}
return { Value, Partial };
}
void lcPropertiesWidget::BoolChanged() void lcPropertiesWidget::BoolChanged()
{ {
QCheckBox* Widget = qobject_cast<QCheckBox*>(sender()); QCheckBox* Widget = qobject_cast<QCheckBox*>(sender());
@ -180,36 +211,15 @@ void lcPropertiesWidget::UpdateBool(lcObjectPropertyId PropertyId, bool DefaultV
return; return;
QSignalBlocker Blocker(CheckBox); QSignalBlocker Blocker(CheckBox);
bool Value = DefaultValue; QVariant Value;
bool Partial = false; bool Partial;
if (mFocusObject) std::tie(Value, Partial) = GetUpdateValue(PropertyId, DefaultValue);
Value = mFocusObject->GetPropertyValue(PropertyId).toBool();
else
{
bool First = true;
for (const lcObject* Object : mSelection)
{
const bool ObjectValue = Object->GetPropertyValue(PropertyId).toBool();
if (First)
{
Value = ObjectValue;
First = false;
}
else if (Value != ObjectValue)
{
Partial = true;
break;
}
}
}
if (Partial) if (Partial)
CheckBox->setCheckState(Qt::PartiallyChecked); CheckBox->setCheckState(Qt::PartiallyChecked);
else else
CheckBox->setCheckState(Value ? Qt::Checked : Qt::Unchecked); CheckBox->setCheckState(Value.toBool() ? Qt::Checked : Qt::Unchecked);
UpdateKeyFrameWidget(PropertyId); UpdateKeyFrameWidget(PropertyId);
} }
@ -441,8 +451,9 @@ void lcPropertiesWidget::AddFloatProperty(lcObjectPropertyId PropertyId, const Q
void lcPropertiesWidget::IntegerChanged() void lcPropertiesWidget::IntegerChanged()
{ {
QLineEdit* Widget = qobject_cast<QLineEdit*>(sender()); // todo: switch to spinner and support mouse drag
lcObjectPropertyId PropertyId = GetEditorWidgetPropertyId(Widget); QLineEdit* LineEdit = qobject_cast<QLineEdit*>(sender());
lcObjectPropertyId PropertyId = GetEditorWidgetPropertyId(LineEdit);
if (PropertyId == lcObjectPropertyId::Count) if (PropertyId == lcObjectPropertyId::Count)
return; return;
@ -452,39 +463,32 @@ void lcPropertiesWidget::IntegerChanged()
if (!Model) if (!Model)
return; return;
lcLight* Light = dynamic_cast<lcLight*>(mFocusObject); const int Value = LineEdit->text().toInt();
int Value = Widget->text().toInt(); Model->SetObjectsProperty(mFocusObject ? lcArray<lcObject*>{ mFocusObject } : mSelection, PropertyId, Value);
// todo: mouse drag
if (Light)
{
if (PropertyId == lcObjectPropertyId::LightAreaGridX)
{
lcVector2i AreaGrid = Light->GetAreaGrid();
AreaGrid.x = Value;
Model->SetLightAreaGrid(Light, AreaGrid);
}
else if (PropertyId == lcObjectPropertyId::LightAreaGridY)
{
lcVector2i AreaGrid = Light->GetAreaGrid();
AreaGrid.y = Value;
Model->SetLightAreaGrid(Light, AreaGrid);
}
}
} }
void lcPropertiesWidget::UpdateInteger(lcObjectPropertyId PropertyId, int Value) void lcPropertiesWidget::UpdateInteger(lcObjectPropertyId PropertyId, int DefaultValue)
{ {
QLineEdit* Widget = qobject_cast<QLineEdit*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor); QLineEdit* LineEdit = qobject_cast<QLineEdit*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor);
if (Widget) if (!LineEdit)
return;
QSignalBlocker Blocker(LineEdit);
QVariant Value;
bool Partial;
std::tie(Value, Partial) = GetUpdateValue(PropertyId, DefaultValue);
if (Partial)
{ {
QSignalBlocker Blocker(Widget); LineEdit->clear();
LineEdit->setPlaceholderText(tr("Multiple Values"));
Widget->setText(lcFormatValueLocalized(Value)); }
else
{
LineEdit->setText(QString::number(Value.toInt()));
LineEdit->setPlaceholderText(QString());
} }
UpdateKeyFrameWidget(PropertyId); UpdateKeyFrameWidget(PropertyId);
@ -646,8 +650,8 @@ void lcPropertiesWidget::AddStringProperty(lcObjectPropertyId PropertyId, const
void lcPropertiesWidget::StringListChanged(int Value) void lcPropertiesWidget::StringListChanged(int Value)
{ {
QComboBox* Widget = qobject_cast<QComboBox*>(sender()); QComboBox* ComboBox = qobject_cast<QComboBox*>(sender());
lcObjectPropertyId PropertyId = GetEditorWidgetPropertyId(Widget); lcObjectPropertyId PropertyId = GetEditorWidgetPropertyId(ComboBox);
if (PropertyId == lcObjectPropertyId::Count) if (PropertyId == lcObjectPropertyId::Count)
return; return;
@ -657,38 +661,36 @@ void lcPropertiesWidget::StringListChanged(int Value)
if (!Model) if (!Model)
return; return;
lcCamera* Camera = dynamic_cast<lcCamera*>(mFocusObject); Model->SetObjectsProperty(mFocusObject ? lcArray<lcObject*>{ mFocusObject } : mSelection, PropertyId, Value);
lcLight* Light = dynamic_cast<lcLight*>(mFocusObject);
if (Camera)
{
if (PropertyId == lcObjectPropertyId::CameraType)
{
Model->SetCameraOrthographic(Camera, Value == 1);
}
}
else if (Light)
{
if (PropertyId == lcObjectPropertyId::LightType)
{
Model->SetLightType(Light, static_cast<lcLightType>(Value));
}
else if (PropertyId == lcObjectPropertyId::LightAreaShape)
{
Model->SetLightAreaShape(Light, static_cast<lcLightAreaShape>(Value));
}
}
} }
void lcPropertiesWidget::UpdateStringList(lcObjectPropertyId PropertyId, int ListIndex) void lcPropertiesWidget::UpdateStringList(lcObjectPropertyId PropertyId, int DefaultValue)
{ {
QComboBox* Widget = qobject_cast<QComboBox*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor); QComboBox* ComboBox = qobject_cast<QComboBox*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor);
if (Widget) if (!ComboBox)
return;
QSignalBlocker Blocker(ComboBox);
QVariant Value;
bool Partial;
std::tie(Value, Partial) = GetUpdateValue(PropertyId, DefaultValue);
bool HasMultiple = (ComboBox->itemText(ComboBox->count() - 1) == tr("Multiple Values"));
if (Partial)
{ {
QSignalBlocker Blocker(Widget); if (!HasMultiple)
ComboBox->addItem(tr("Multiple Values"));
Widget->setCurrentIndex(ListIndex); ComboBox->setCurrentIndex(ComboBox->count() - 1);
}
else
{
if (HasMultiple)
ComboBox->removeItem(ComboBox->count() - 1);
ComboBox->setCurrentIndex(Value.toInt());
} }
UpdateKeyFrameWidget(PropertyId); UpdateKeyFrameWidget(PropertyId);
@ -751,36 +753,12 @@ void lcPropertiesWidget::UpdateColor(lcObjectPropertyId PropertyId, const lcVect
return; return;
QSignalBlocker Blocker(ColorButton); QSignalBlocker Blocker(ColorButton);
lcVector3 Value = DefaultValue; QVariant Value;
bool Partial = false; bool Partial;
if (mFocusObject) std::tie(Value, Partial) = GetUpdateValue(PropertyId, QVariant::fromValue<lcVector3>(DefaultValue));
Value = mFocusObject->GetPropertyValue(PropertyId).value<lcVector3>();
else
{
bool First = true;
for (const lcObject* Object : mSelection) QColor Color = Partial ? QColor(128, 128, 128) : lcQColorFromVector3(Value.value<lcVector3>());
{
const lcVector3 ObjectValue = Object->GetPropertyValue(PropertyId).value<lcVector3>();
if (First)
{
Value = ObjectValue;
First = false;
}
else if (Value != ObjectValue)
{
Partial = true;
break;
}
}
}
if (Partial)
Value = lcVector3(0.5f, 0.5f, 0.5f);
QColor Color = lcQColorFromVector3(Value);
QPixmap Pixmap(14, 14); QPixmap Pixmap(14, 14);
Pixmap.fill(Color); Pixmap.fill(Color);
@ -991,7 +969,7 @@ void lcPropertiesWidget::CreateWidgets()
AddCategory(CategoryIndex::Camera, tr("Camera")); AddCategory(CategoryIndex::Camera, tr("Camera"));
AddStringProperty(lcObjectPropertyId::CameraName, tr("Name"), tr("Camera name"), false); AddStringProperty(lcObjectPropertyId::CameraName, tr("Name"), tr("Camera name"), false);
AddStringListProperty(lcObjectPropertyId::CameraType, tr("Type"), tr("Camera type"), false, { tr("Perspective"), tr("Orthographic") }); AddStringListProperty(lcObjectPropertyId::CameraType, tr("Type"), tr("Camera type"), false, lcCamera::GetCameraTypeStrings());
AddSpacing(); AddSpacing();
@ -1218,7 +1196,7 @@ void lcPropertiesWidget::SetCamera(const lcArray<lcObject*>& Selection, lcObject
lcVector3 Position(0.0f, 0.0f, 0.0f); lcVector3 Position(0.0f, 0.0f, 0.0f);
lcVector3 Target(0.0f, 0.0f, 0.0f); lcVector3 Target(0.0f, 0.0f, 0.0f);
lcVector3 UpVector(0.0f, 0.0f, 0.0f); lcVector3 UpVector(0.0f, 0.0f, 0.0f);
bool Ortho = false; lcCameraType CameraType = lcCameraType::Perspective;
float FoV = 60.0f; float FoV = 60.0f;
float ZNear = 1.0f; float ZNear = 1.0f;
float ZFar = 100.0f; float ZFar = 100.0f;
@ -1230,7 +1208,7 @@ void lcPropertiesWidget::SetCamera(const lcArray<lcObject*>& Selection, lcObject
Target = Camera->mTargetPosition; Target = Camera->mTargetPosition;
UpVector = Camera->mUpVector; UpVector = Camera->mUpVector;
Ortho = Camera->IsOrtho(); CameraType = Camera->GetCameraType();
FoV = Camera->m_fovy; FoV = Camera->m_fovy;
ZNear = Camera->m_zNear; ZNear = Camera->m_zNear;
ZFar = Camera->m_zFar; ZFar = Camera->m_zFar;
@ -1238,7 +1216,7 @@ void lcPropertiesWidget::SetCamera(const lcArray<lcObject*>& Selection, lcObject
} }
UpdateString(lcObjectPropertyId::CameraName, Name); UpdateString(lcObjectPropertyId::CameraName, Name);
UpdateStringList(lcObjectPropertyId::CameraType, Ortho ? 1 : 0); UpdateStringList(lcObjectPropertyId::CameraType, static_cast<int>(CameraType));
UpdateFloat(lcObjectPropertyId::CameraFOV, FoV); UpdateFloat(lcObjectPropertyId::CameraFOV, FoV);
UpdateFloat(lcObjectPropertyId::CameraNear, ZNear); UpdateFloat(lcObjectPropertyId::CameraNear, ZNear);
@ -1266,10 +1244,9 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
mFocusObject = Light; mFocusObject = Light;
QString Name; QString Name;
lcLightType LightType = lcLightType::Point; lcLightType LightType = lcLightType::Count;
lcLightAreaShape LightAreaShape = lcLightAreaShape::Rectangle; lcLightAreaShape LightAreaShape = lcLightAreaShape::Count;
lcVector2 LightSize(0.0f, 0.0f); lcVector2 LightSize(0.0f, 0.0f);
lcVector2i AreaGrid(2, 2);
float Power = 0.0f; float Power = 0.0f;
float AttenuationDistance = 0.0f; float AttenuationDistance = 0.0f;
float AttenuationPower = 0.0f; float AttenuationPower = 0.0f;
@ -1281,6 +1258,7 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
{ {
Name = Light->GetName(); Name = Light->GetName();
LightType = Light->GetLightType(); LightType = Light->GetLightType();
LightAreaShape = Light->GetAreaShape();
Position = Light->GetPosition(); Position = Light->GetPosition();
Rotation = lcMatrix44ToEulerAngles(Light->GetWorldMatrix()) * LC_RTOD; Rotation = lcMatrix44ToEulerAngles(Light->GetWorldMatrix()) * LC_RTOD;
@ -1290,14 +1268,45 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
SpotConeAngle = Light->GetSpotConeAngle(); SpotConeAngle = Light->GetSpotConeAngle();
SpotPenumbraAngle = Light->GetSpotPenumbraAngle(); SpotPenumbraAngle = Light->GetSpotPenumbraAngle();
SpotTightness = Light->GetSpotTightness(); SpotTightness = Light->GetSpotTightness();
LightAreaShape = Light->GetAreaShape();
LightSize = Light->GetSize(); LightSize = Light->GetSize();
AreaGrid = Light->GetAreaGrid(); }
else
{
bool First = true;
bool PartialLightType = false, PartialAreaShape = false;
for (const lcObject* Object : mSelection)
{
const lcLight* CurrentLight = dynamic_cast<const lcLight*>(Object);
if (!CurrentLight)
continue;
if (First)
{
LightType = CurrentLight->GetLightType();
LightAreaShape = CurrentLight->GetAreaShape();
First = false;
}
else
{
if (LightType != CurrentLight->GetLightType())
PartialLightType = true;
if (LightAreaShape != CurrentLight->GetAreaShape())
PartialAreaShape = true;
}
}
if (PartialLightType)
LightType = lcLightType::Count;
if (PartialAreaShape)
LightAreaShape = lcLightAreaShape::Count;
} }
UpdateString(lcObjectPropertyId::LightName, Name); UpdateString(lcObjectPropertyId::LightName, Name);
UpdateStringList(lcObjectPropertyId::LightType, static_cast<int>(LightType)); UpdateStringList(lcObjectPropertyId::LightType, 0);
UpdateColor(lcObjectPropertyId::LightColor, lcVector3(1.0f, 1.0f, 1.0f)); UpdateColor(lcObjectPropertyId::LightColor, lcVector3(1.0f, 1.0f, 1.0f));
UpdateFloat(lcObjectPropertyId::LightPower, Power); UpdateFloat(lcObjectPropertyId::LightPower, Power);
@ -1306,13 +1315,13 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
UpdateFloat(lcObjectPropertyId::LightAttenuationDistance, AttenuationDistance); UpdateFloat(lcObjectPropertyId::LightAttenuationDistance, AttenuationDistance);
UpdateFloat(lcObjectPropertyId::LightAttenuationPower, AttenuationPower); UpdateFloat(lcObjectPropertyId::LightAttenuationPower, AttenuationPower);
const bool IsPointLight = Light && Light->IsPointLight(); const bool IsPointLight = (LightType == lcLightType::Point);
SetPropertyVisible(lcObjectPropertyId::LightPointSize, IsPointLight); SetPropertyVisible(lcObjectPropertyId::LightPointSize, IsPointLight);
if (IsPointLight) if (IsPointLight)
UpdateFloat(lcObjectPropertyId::LightPointSize, LightSize.x); UpdateFloat(lcObjectPropertyId::LightPointSize, LightSize.x);
const bool IsSpotLight = Light && Light->IsSpotLight(); const bool IsSpotLight = (LightType == lcLightType::Spot);
SetPropertyVisible(lcObjectPropertyId::LightSpotSize, IsSpotLight); SetPropertyVisible(lcObjectPropertyId::LightSpotSize, IsSpotLight);
SetPropertyVisible(lcObjectPropertyId::LightSpotConeAngle, IsSpotLight); SetPropertyVisible(lcObjectPropertyId::LightSpotConeAngle, IsSpotLight);
SetPropertyVisible(lcObjectPropertyId::LightSpotPenumbraAngle, IsSpotLight); SetPropertyVisible(lcObjectPropertyId::LightSpotPenumbraAngle, IsSpotLight);
@ -1326,19 +1335,19 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
UpdateFloat(lcObjectPropertyId::LightSpotTightness, SpotTightness); UpdateFloat(lcObjectPropertyId::LightSpotTightness, SpotTightness);
} }
const bool IsDirectionalLight = Light && Light->IsDirectionalLight(); const bool IsDirectionalLight = (LightType == lcLightType::Directional);
SetPropertyVisible(lcObjectPropertyId::LightDirectionalSize, IsDirectionalLight); SetPropertyVisible(lcObjectPropertyId::LightDirectionalSize, IsDirectionalLight);
if (IsDirectionalLight) if (IsDirectionalLight)
UpdateFloat(lcObjectPropertyId::LightDirectionalSize, LightSize.x); UpdateFloat(lcObjectPropertyId::LightDirectionalSize, LightSize.x);
const bool IsAreaLight = Light && Light->IsAreaLight(); const bool IsAreaLight = (LightType == lcLightType::Area);
SetPropertyVisible(lcObjectPropertyId::LightAreaShape, IsAreaLight); SetPropertyVisible(lcObjectPropertyId::LightAreaShape, IsAreaLight);
const bool IsSquare = IsAreaLight && (LightAreaShape == lcLightAreaShape::Square || LightAreaShape == lcLightAreaShape::Disk); const bool IsSquare = (LightAreaShape == lcLightAreaShape::Square || LightAreaShape == lcLightAreaShape::Disk);
SetPropertyVisible(lcObjectPropertyId::LightAreaSize, IsSquare); SetPropertyVisible(lcObjectPropertyId::LightAreaSize, IsAreaLight && IsSquare);
SetPropertyVisible(lcObjectPropertyId::LightAreaSizeX, !IsSquare); SetPropertyVisible(lcObjectPropertyId::LightAreaSizeX, IsAreaLight && !IsSquare);
SetPropertyVisible(lcObjectPropertyId::LightAreaSizeY, !IsSquare); SetPropertyVisible(lcObjectPropertyId::LightAreaSizeY, IsAreaLight && !IsSquare);
SetPropertyVisible(lcObjectPropertyId::LightAreaGridX, IsAreaLight); SetPropertyVisible(lcObjectPropertyId::LightAreaGridX, IsAreaLight);
SetPropertyVisible(lcObjectPropertyId::LightAreaGridY, IsAreaLight); SetPropertyVisible(lcObjectPropertyId::LightAreaGridY, IsAreaLight);
@ -1349,8 +1358,8 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
UpdateFloat(lcObjectPropertyId::LightAreaSize, LightSize.x); UpdateFloat(lcObjectPropertyId::LightAreaSize, LightSize.x);
UpdateFloat(lcObjectPropertyId::LightAreaSizeX, LightSize.x); UpdateFloat(lcObjectPropertyId::LightAreaSizeX, LightSize.x);
UpdateFloat(lcObjectPropertyId::LightAreaSizeY, LightSize.y); UpdateFloat(lcObjectPropertyId::LightAreaSizeY, LightSize.y);
UpdateInteger(lcObjectPropertyId::LightAreaGridX, AreaGrid.x); UpdateInteger(lcObjectPropertyId::LightAreaGridX, 0);
UpdateInteger(lcObjectPropertyId::LightAreaGridY, AreaGrid.y); UpdateInteger(lcObjectPropertyId::LightAreaGridY, 0);
} }
UpdateFloat(lcObjectPropertyId::ObjectPositionX, Position[0]); UpdateFloat(lcObjectPropertyId::ObjectPositionX, Position[0]);

View file

@ -95,13 +95,15 @@ protected:
void AddPieceColorProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames); void AddPieceColorProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
void AddPieceIdProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames); void AddPieceIdProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
std::pair<QVariant, bool> GetUpdateValue(lcObjectPropertyId PropertyId, QVariant DefaultValue);
void UpdateKeyFrameWidget(lcObjectPropertyId PropertyId); void UpdateKeyFrameWidget(lcObjectPropertyId PropertyId);
void UpdateBool(lcObjectPropertyId PropertyId, bool DefaultValue); void UpdateBool(lcObjectPropertyId PropertyId, bool DefaultValue);
void UpdateFloat(lcObjectPropertyId PropertyId, float Value); void UpdateFloat(lcObjectPropertyId PropertyId, float Value);
void UpdateInteger(lcObjectPropertyId PropertyId, int Value); void UpdateInteger(lcObjectPropertyId PropertyId, int DefaultValue);
void UpdateStepNumber(lcObjectPropertyId PropertyId, lcStep Step, lcStep Min, lcStep Max); void UpdateStepNumber(lcObjectPropertyId PropertyId, lcStep Step, lcStep Min, lcStep Max);
void UpdateString(lcObjectPropertyId PropertyId, const QString& Text); void UpdateString(lcObjectPropertyId PropertyId, const QString& Text);
void UpdateStringList(lcObjectPropertyId PropertyId, int ListIndex); void UpdateStringList(lcObjectPropertyId PropertyId, int DefaultValue);
void UpdateColor(lcObjectPropertyId PropertyId, const lcVector3& DefaultValue); void UpdateColor(lcObjectPropertyId PropertyId, const lcVector3& DefaultValue);
void UpdatePieceColor(lcObjectPropertyId PropertyId, int ColorIndex); void UpdatePieceColor(lcObjectPropertyId PropertyId, int ColorIndex);
void UpdatePieceId(lcObjectPropertyId PropertyId, const QString& Name); void UpdatePieceId(lcObjectPropertyId PropertyId, const QString& Name);

View file

@ -1061,9 +1061,11 @@ QVariant lcLight::GetPropertyValue(lcObjectPropertyId PropertyId) const
case lcObjectPropertyId::CameraUpY: case lcObjectPropertyId::CameraUpY:
case lcObjectPropertyId::CameraUpZ: case lcObjectPropertyId::CameraUpZ:
case lcObjectPropertyId::LightName: case lcObjectPropertyId::LightName:
case lcObjectPropertyId::LightType:
break; break;
case lcObjectPropertyId::LightType:
return static_cast<int>(GetLightType());
case lcObjectPropertyId::LightColor: case lcObjectPropertyId::LightColor:
return QVariant::fromValue<lcVector3>(GetColor()); return QVariant::fromValue<lcVector3>(GetColor());
@ -1084,9 +1086,17 @@ QVariant lcLight::GetPropertyValue(lcObjectPropertyId PropertyId) const
case lcObjectPropertyId::LightSpotConeAngle: case lcObjectPropertyId::LightSpotConeAngle:
case lcObjectPropertyId::LightSpotPenumbraAngle: case lcObjectPropertyId::LightSpotPenumbraAngle:
case lcObjectPropertyId::LightSpotTightness: case lcObjectPropertyId::LightSpotTightness:
break;
case lcObjectPropertyId::LightAreaShape: case lcObjectPropertyId::LightAreaShape:
return static_cast<int>(GetAreaShape());
case lcObjectPropertyId::LightAreaGridX: case lcObjectPropertyId::LightAreaGridX:
return GetAreaGrid().x;
case lcObjectPropertyId::LightAreaGridY: case lcObjectPropertyId::LightAreaGridY:
return GetAreaGrid().y;
case lcObjectPropertyId::ObjectPositionX: case lcObjectPropertyId::ObjectPositionX:
case lcObjectPropertyId::ObjectPositionY: case lcObjectPropertyId::ObjectPositionY:
case lcObjectPropertyId::ObjectPositionZ: case lcObjectPropertyId::ObjectPositionZ:
@ -1123,9 +1133,11 @@ bool lcLight::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
case lcObjectPropertyId::CameraUpY: case lcObjectPropertyId::CameraUpY:
case lcObjectPropertyId::CameraUpZ: case lcObjectPropertyId::CameraUpZ:
case lcObjectPropertyId::LightName: case lcObjectPropertyId::LightName:
case lcObjectPropertyId::LightType:
break; break;
case lcObjectPropertyId::LightType:
return SetLightType(static_cast<lcLightType>(Value.toInt()));
case lcObjectPropertyId::LightColor: case lcObjectPropertyId::LightColor:
return SetColor(Value.value<lcVector3>(), Step, AddKey); return SetColor(Value.value<lcVector3>(), Step, AddKey);
@ -1146,9 +1158,17 @@ bool lcLight::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
case lcObjectPropertyId::LightSpotConeAngle: case lcObjectPropertyId::LightSpotConeAngle:
case lcObjectPropertyId::LightSpotPenumbraAngle: case lcObjectPropertyId::LightSpotPenumbraAngle:
case lcObjectPropertyId::LightSpotTightness: case lcObjectPropertyId::LightSpotTightness:
break;
case lcObjectPropertyId::LightAreaShape: case lcObjectPropertyId::LightAreaShape:
return SetAreaShape(static_cast<lcLightAreaShape>(Value.toInt()));
case lcObjectPropertyId::LightAreaGridX: case lcObjectPropertyId::LightAreaGridX:
return SetAreaGrid(lcVector2i(Value.toInt(), GetAreaGrid().y), Step, AddKey);
case lcObjectPropertyId::LightAreaGridY: case lcObjectPropertyId::LightAreaGridY:
return SetAreaGrid(lcVector2i(GetAreaGrid().x, Value.toInt()), Step, AddKey);
case lcObjectPropertyId::ObjectPositionX: case lcObjectPropertyId::ObjectPositionX:
case lcObjectPropertyId::ObjectPositionY: case lcObjectPropertyId::ObjectPositionY:
case lcObjectPropertyId::ObjectPositionZ: case lcObjectPropertyId::ObjectPositionZ:

View file

@ -19,7 +19,11 @@ QString lcObject::GetCheckpointString(lcObjectPropertyId PropertyId)
case lcObjectPropertyId::PieceStepShow: case lcObjectPropertyId::PieceStepShow:
case lcObjectPropertyId::PieceStepHide: case lcObjectPropertyId::PieceStepHide:
case lcObjectPropertyId::CameraName: case lcObjectPropertyId::CameraName:
break;
case lcObjectPropertyId::CameraType: case lcObjectPropertyId::CameraType:
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Camera Type");
case lcObjectPropertyId::CameraFOV: case lcObjectPropertyId::CameraFOV:
case lcObjectPropertyId::CameraNear: case lcObjectPropertyId::CameraNear:
case lcObjectPropertyId::CameraFar: case lcObjectPropertyId::CameraFar:
@ -33,9 +37,11 @@ QString lcObject::GetCheckpointString(lcObjectPropertyId PropertyId)
case lcObjectPropertyId::CameraUpY: case lcObjectPropertyId::CameraUpY:
case lcObjectPropertyId::CameraUpZ: case lcObjectPropertyId::CameraUpZ:
case lcObjectPropertyId::LightName: case lcObjectPropertyId::LightName:
case lcObjectPropertyId::LightType:
break; break;
case lcObjectPropertyId::LightType:
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Light Type");
case lcObjectPropertyId::LightColor: case lcObjectPropertyId::LightColor:
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Light Color"); return QT_TRANSLATE_NOOP("Checkpoint", "Changing Light Color");
@ -56,9 +62,15 @@ QString lcObject::GetCheckpointString(lcObjectPropertyId PropertyId)
case lcObjectPropertyId::LightSpotConeAngle: case lcObjectPropertyId::LightSpotConeAngle:
case lcObjectPropertyId::LightSpotPenumbraAngle: case lcObjectPropertyId::LightSpotPenumbraAngle:
case lcObjectPropertyId::LightSpotTightness: case lcObjectPropertyId::LightSpotTightness:
break;
case lcObjectPropertyId::LightAreaShape: case lcObjectPropertyId::LightAreaShape:
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Area Light Shape");
case lcObjectPropertyId::LightAreaGridX: case lcObjectPropertyId::LightAreaGridX:
case lcObjectPropertyId::LightAreaGridY: case lcObjectPropertyId::LightAreaGridY:
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Area Light Grid");
case lcObjectPropertyId::ObjectPositionX: case lcObjectPropertyId::ObjectPositionX:
case lcObjectPropertyId::ObjectPositionY: case lcObjectPropertyId::ObjectPositionY:
case lcObjectPropertyId::ObjectPositionZ: case lcObjectPropertyId::ObjectPositionZ:

View file

@ -179,6 +179,8 @@ int main(int argc, char *argv[])
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>"); qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
#endif #endif
qRegisterMetaType<lcVector3>("lcVector3");
QMetaType::registerComparators<lcVector3>();
QList<QPair<QString, bool>> LibraryPaths; QList<QPair<QString, bool>> LibraryPaths;