Files
scheincommander/lightproject.h

157 lines
3.4 KiB
C
Raw Permalink Normal View History

2023-02-15 01:12:19 +01:00
#pragma once
#include <vector>
#include <algorithm>
2023-02-15 01:12:19 +01:00
#include <QString>
#include <QVector3D>
#include <QMetaEnum>
#include <QMetaType>
namespace scheincommander {
Q_NAMESPACE
2023-02-15 22:45:18 +01:00
enum class DeviceTypeRegisterType
{
Dummy,
Dimmer,
Red,
Green,
Blue,
White,
Shutter,
Pan,
PanFine,
Tilt,
TiltFine,
Color,
Cyan,
Magenta,
Yellow,
Gobo,
Rotation,
Prism,
Frost,
Focus,
Speed,
Iris,
Zoom,
Extra1,
Extra2
};
2023-02-15 22:45:18 +01:00
Q_ENUM_NS(DeviceTypeRegisterType)
} // namespace scheincommander
Q_DECLARE_METATYPE(scheincommander::DeviceTypeRegisterType)
using DeviceTypeRegisterType = scheincommander::DeviceTypeRegisterType;
2023-02-15 22:45:18 +01:00
struct DeviceTypeRegisterConfig
{
2023-02-15 22:45:18 +01:00
DeviceTypeRegisterType type;
};
2023-02-15 01:12:19 +01:00
2023-02-15 22:45:18 +01:00
struct DeviceTypeConfig
2023-02-15 01:12:19 +01:00
{
int id;
QString name;
2023-02-18 23:48:28 +01:00
QString iconName;
2023-02-15 22:45:18 +01:00
std::vector<DeviceTypeRegisterConfig> registers;
};
2023-02-15 22:45:18 +01:00
class DeviceTypesContainer : public std::vector<DeviceTypeConfig>
{
2023-02-15 22:45:18 +01:00
using base_t = std::vector<DeviceTypeConfig>;
public:
using base_t::base_t;
2023-02-15 22:45:18 +01:00
DeviceTypeConfig *findById(int id)
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
2023-02-15 22:45:18 +01:00
[&id](const DeviceTypeConfig &deviceType){ return deviceType.id == id; });
return iter != std::end(*this) ? &*iter : nullptr;
}
2023-02-15 22:45:18 +01:00
const DeviceTypeConfig *findById(int id) const
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
2023-02-15 22:45:18 +01:00
[&id](const DeviceTypeConfig &deviceType){ return deviceType.id == id; });
return iter != std::end(*this) ? &*iter : nullptr;
}
2023-02-15 01:12:19 +01:00
};
2023-02-20 00:36:55 +01:00
struct DeviceConfig
2023-02-15 01:12:19 +01:00
{
int id;
QString name;
2023-02-15 22:45:18 +01:00
int deviceTypeId;
2023-02-15 01:12:19 +01:00
int address;
QVector3D position;
};
2023-02-20 00:36:55 +01:00
class DevicesContainer : public std::vector<DeviceConfig>
{
using base_t = std::vector<DeviceConfig>;
public:
using base_t::base_t;
DeviceConfig *findById(int id)
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
[&id](const DeviceConfig &device){ return device.id == id; });
return iter != std::end(*this) ? &*iter : nullptr;
}
const DeviceConfig *findById(int id) const
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
[&id](const DeviceConfig &device){ return device.id == id; });
return iter != std::end(*this) ? &*iter : nullptr;
}
};
using sliders_state_t = std::vector<std::vector<quint8>>;
2023-02-20 00:36:55 +01:00
struct PresetStepConfig
{
sliders_state_t sliders;
};
2023-02-22 23:18:09 +01:00
struct PresetConfig
2023-02-19 20:14:36 +01:00
{
int id;
QString name;
2023-03-04 23:37:45 +01:00
int msecsPerStep;
std::vector<PresetStepConfig> steps;
2023-02-20 00:36:55 +01:00
};
2023-02-22 23:18:09 +01:00
class PresetsContainer : public std::vector<PresetConfig>
2023-02-20 00:36:55 +01:00
{
2023-02-22 23:18:09 +01:00
using base_t = std::vector<PresetConfig>;
2023-02-20 00:36:55 +01:00
public:
using base_t::base_t;
2023-02-22 23:18:09 +01:00
PresetConfig *findById(int id)
2023-02-20 00:36:55 +01:00
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
2023-02-22 23:18:09 +01:00
[&id](const PresetConfig &preset){ return preset.id == id; });
2023-02-20 00:36:55 +01:00
return iter != std::end(*this) ? &*iter : nullptr;
}
2023-02-22 23:18:09 +01:00
const PresetConfig *findById(int id) const
2023-02-20 00:36:55 +01:00
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
2023-02-22 23:18:09 +01:00
[&id](const PresetConfig &preset){ return preset.id == id; });
2023-02-20 00:36:55 +01:00
return iter != std::end(*this) ? &*iter : nullptr;
}
2023-02-19 20:14:36 +01:00
};
2023-02-15 01:12:19 +01:00
struct LightProject
{
2023-02-15 22:45:18 +01:00
DeviceTypesContainer deviceTypes;
2023-02-20 00:36:55 +01:00
DevicesContainer devices;
2023-02-22 23:18:09 +01:00
PresetsContainer presets;
2023-02-15 01:12:19 +01:00
};