Skip to content

Commit

Permalink
engine: save/load cross universe information
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 26, 2024
1 parent b00ea11 commit 483f139
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 16 deletions.
24 changes: 21 additions & 3 deletions engine/src/fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Fixture::Fixture(QObject* parent) : QObject(parent)

m_address = 0;
m_channels = 0;
m_crossUniverse = false;

m_fixtureDef = NULL;
m_fixtureMode = NULL;
Expand Down Expand Up @@ -136,6 +137,16 @@ quint32 Fixture::universe() const
return (m_address >> 9);
}

void Fixture::setCrossUniverse(bool enable)
{
m_crossUniverse = enable;
}

bool Fixture::crossUniverse() const
{
return m_crossUniverse;
}

/*****************************************************************************
* Address
*****************************************************************************/
Expand Down Expand Up @@ -979,7 +990,7 @@ bool Fixture::loader(QXmlStreamReader &root, Doc* doc)

if (fxi->loadXML(root, doc, doc->fixtureDefCache()) == true)
{
if (doc->addFixture(fxi, fxi->id()) == true)
if (doc->addFixture(fxi, fxi->id(), fxi->crossUniverse()) == true)
{
/* Success */
result = true;
Expand Down Expand Up @@ -1061,6 +1072,11 @@ bool Fixture::loadXML(QXmlStreamReader &xmlDoc, Doc *doc,
{
universe = xmlDoc.readElementText().toInt();
}
else if (xmlDoc.name() == KXMLFixtureCrossUniverse)
{
xmlDoc.readElementText();
setCrossUniverse(true);
}
else if (xmlDoc.name() == KXMLFixtureAddress)
{
address = xmlDoc.readElementText().toInt();
Expand Down Expand Up @@ -1162,14 +1178,14 @@ bool Fixture::loadXML(QXmlStreamReader &xmlDoc, Doc *doc,
/* Number of channels */
if (channels <= 0)
{
doc->appendToErrorLog(QString("%1 channels of fixture <b>%2</b> are our of bounds")
doc->appendToErrorLog(QString("%1 channels of fixture <b>%2</b> are out of bounds")
.arg(QString::number(channels))
.arg(name));
channels = 1;
}

/* Make sure that address is something sensible */
if (address > 511 || address + (channels - 1) > 511)
if (!crossUniverse() && (address > 511 || address + (channels - 1) > 511))
{
doc->appendToErrorLog(QString("Fixture address range %1-%2 is out of DMX bounds")
.arg(QString::number(address))
Expand Down Expand Up @@ -1273,6 +1289,8 @@ bool Fixture::saveXML(QXmlStreamWriter *doc) const
doc->writeTextElement(KXMLFixtureName, m_name);
/* Universe */
doc->writeTextElement(KXMLFixtureUniverse, QString::number(universe()));
if (crossUniverse())
doc->writeTextElement(KXMLFixtureCrossUniverse, KXMLQLCTrue);
/* Address */
doc->writeTextElement(KXMLFixtureAddress, QString::number(address()));
/* Channel count */
Expand Down
41 changes: 29 additions & 12 deletions engine/src/fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ class Doc;
* @{
*/

#define KXMLFixture QString("Fixture")
#define KXMLFixtureName QString("Name")
#define KXMLFixtureUniverse QString("Universe")
#define KXMLFixtureAddress QString("Address")
#define KXMLFixtureID QString("ID")
#define KXMLFixtureGeneric QString("Generic")
#define KXMLFixtureRGBPanel QString("RGBPanel")
#define KXMLFixtureChannels QString("Channels")
#define KXMLFixtureDimmer QString("Dimmer")
#define KXMLFixtureExcludeFade QString("ExcludeFade")
#define KXMLFixtureForcedHTP QString("ForcedHTP")
#define KXMLFixtureForcedLTP QString("ForcedLTP")
#define KXMLFixture QString("Fixture")
#define KXMLFixtureName QString("Name")
#define KXMLFixtureUniverse QString("Universe")
#define KXMLFixtureCrossUniverse QString("CrossUniverse")
#define KXMLFixtureAddress QString("Address")
#define KXMLFixtureID QString("ID")
#define KXMLFixtureGeneric QString("Generic")
#define KXMLFixtureRGBPanel QString("RGBPanel")
#define KXMLFixtureChannels QString("Channels")
#define KXMLFixtureDimmer QString("Dimmer")
#define KXMLFixtureExcludeFade QString("ExcludeFade")
#define KXMLFixtureForcedHTP QString("ForcedHTP")
#define KXMLFixtureForcedLTP QString("ForcedLTP")

#define KXMLFixtureChannelModifier QString("Modifier")
#define KXMLFixtureChannelIndex QString("Channel")
Expand Down Expand Up @@ -180,6 +181,19 @@ class Fixture : public QObject
*/
quint32 universe() const;

/** Set if this Fixture crosses a DMX universe
*
* @param cross-universe enable flag
*/
void setCrossUniverse(bool enable);

/**
* Get the fixture cross universe flag
*
* @return true if this Fixture crosses a universe
*/
bool crossUniverse() const;

/*********************************************************************
* Address
*********************************************************************/
Expand Down Expand Up @@ -321,6 +335,9 @@ class Fixture : public QObject
/** DMX address & universe */
quint32 m_address;

/** Flag that indicates if this fixture crosses a DMX Universe */
bool m_crossUniverse;

/** Number of channels (ONLY for dimmer fixtures!) */
quint32 m_channels;

Expand Down
3 changes: 2 additions & 1 deletion engine/src/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <math.h>

#include "qlcmacros.h"
#include "qlcfile.h"

#include "scriptwrapper.h"
#include "mastertimer.h"
Expand Down Expand Up @@ -334,7 +335,7 @@ bool Function::saveXMLCommon(QXmlStreamWriter *doc) const
doc->writeAttribute(KXMLQLCFunctionType, Function::typeToString(type()));
doc->writeAttribute(KXMLQLCFunctionName, name());
if (isVisible() == false)
doc->writeAttribute(KXMLQLCFunctionHidden, "True");
doc->writeAttribute(KXMLQLCFunctionHidden, KXMLQLCTrue);
if (path(true).isEmpty() == false)
doc->writeAttribute(KXMLQLCFunctionPath, path(true));
if (blendMode() != Universe::NormalBlend)
Expand Down
2 changes: 2 additions & 0 deletions ui/src/fixturemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,8 @@ void FixtureManager::slotAddRGBPanel()
}

fxi->setUniverse(m_doc->inputOutputMap()->getUniverseID(uniIndex));
if (address + fxi->channels() > 512)
fxi->setCrossUniverse(rgb.crossUniverse());
fxi->setAddress(address);
m_doc->addFixture(fxi, Fixture::invalidId(), rgb.crossUniverse());

Expand Down

0 comments on commit 483f139

Please sign in to comment.