Skip to content

Commit

Permalink
Add an option to allow fixture crossing a universe
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 17, 2024
1 parent 87572c9 commit b00ea11
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 29 deletions.
19 changes: 13 additions & 6 deletions engine/src/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ quint32 Doc::createFixtureId()
return m_latestFixtureId;
}

bool Doc::addFixture(Fixture* fixture, quint32 id)
bool Doc::addFixture(Fixture* fixture, quint32 id, bool crossUniverse)
{
Q_ASSERT(fixture != NULL);

Expand Down Expand Up @@ -461,21 +461,28 @@ bool Doc::addFixture(Fixture* fixture, quint32 id)
for (i = 0; i < fixture->channels(); i++)
{
const QLCChannel *channel(fixture->channel(i));
quint32 addr = fxAddress + i;

if (crossUniverse)
{
uni = floor((fixture->universeAddress() + i) / 512);
addr = (fixture->universeAddress() + i) - (uni * 512);
}

// Inform Universe of any HTP/LTP forcing
if (forcedHTP.contains(int(i)))
universes.at(uni)->setChannelCapability(fxAddress + i, channel->group(), Universe::HTP);
universes.at(uni)->setChannelCapability(addr, channel->group(), Universe::HTP);
else if (forcedLTP.contains(int(i)))
universes.at(uni)->setChannelCapability(fxAddress + i, channel->group(), Universe::LTP);
universes.at(uni)->setChannelCapability(addr, channel->group(), Universe::LTP);
else
universes.at(uni)->setChannelCapability(fxAddress + i, channel->group());
universes.at(uni)->setChannelCapability(addr, channel->group());

// Apply the default value BEFORE modifiers
universes.at(uni)->setChannelDefaultValue(fxAddress + i, channel->defaultValue());
universes.at(uni)->setChannelDefaultValue(addr, channel->defaultValue());

// Apply a channel modifier, if defined
ChannelModifier *mod = fixture->channelModifier(i);
universes.at(uni)->setChannelModifier(fxAddress + i, mod);
universes.at(uni)->setChannelModifier(addr, mod);
}
inputOutputMap()->releaseUniverses(true);

Expand Down
2 changes: 1 addition & 1 deletion engine/src/doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class Doc : public QObject
* @return true if the fixture was successfully added to doc,
* otherwise false.
*/
bool addFixture(Fixture* fixture, quint32 id = Fixture::invalidId());
bool addFixture(Fixture* fixture, quint32 id = Fixture::invalidId(), bool crossUniverse = false);

/**
* Delete the given fixture instance from Doc
Expand Down
5 changes: 5 additions & 0 deletions ui/src/addrgbpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ Fixture::Components AddRGBPanel::components()
return Fixture::RGB;
}

bool AddRGBPanel::crossUniverse()
{
return m_crossUniverseCheck->isChecked();
}

void AddRGBPanel::slotSizeChanged(int)
{
checkAddressAvailability();
Expand Down
1 change: 1 addition & 0 deletions ui/src/addrgbpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class AddRGBPanel : public QDialog, public Ui_AddRGBPanel
Type type();
Direction direction();
Fixture::Components components();
bool crossUniverse();

private:
/** Check if an address is available for contiguous channels.
Expand Down
45 changes: 26 additions & 19 deletions ui/src/addrgbpanel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<x>0</x>
<y>0</y>
<width>477</width>
<height>452</height>
<height>482</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -58,10 +58,10 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="m_nameEdit">
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>RGB Panel</string>
<string>Address</string>
</property>
</widget>
</item>
Expand All @@ -72,16 +72,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_uniCombo"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="m_addressSpin">
<property name="minimum">
Expand All @@ -92,23 +82,40 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="5" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Components</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_uniCombo"/>
</item>
<item row="4" column="1">
<widget class="QLabel" name="m_addrErrorLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;ERROR: Address already used!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_11">
<item row="0" column="1">
<widget class="QLineEdit" name="m_nameEdit">
<property name="text">
<string>Components</string>
<string>RGB Panel</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="m_compCombo"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="m_crossUniverseCheck">
<property name="text">
<string>Allow cross-universe addressing</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
15 changes: 12 additions & 3 deletions ui/src/fixturemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,19 +1201,28 @@ void FixtureManager::slotAddRGBPanel()
// Check universe span
if (address + fxi->channels() > 512)
{
uniIndex++;
if (!rgb.crossUniverse())
uniIndex++;

if (m_doc->inputOutputMap()->getUniverseID(uniIndex) == m_doc->inputOutputMap()->invalidUniverse())
{
m_doc->inputOutputMap()->addUniverse();
m_doc->inputOutputMap()->startUniverses();
}
address = 0;
if (!rgb.crossUniverse())
address = 0;
}

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

address += fxi->channels();
m_doc->addFixture(fxi);
if (address > 512 && rgb.crossUniverse())
{
address -= 512;
uniIndex++;
}

if (rgb.type() == AddRGBPanel::ZigZag)
{
Expand Down

0 comments on commit b00ea11

Please sign in to comment.