bool FixtureGroup::assignFixture(quint32 id, const QLCPoint& pt) { Fixture* fxi = doc()->fixture(id); Q_ASSERT(fxi != NULL); QLCPoint tmp = pt; int headAddedcount = 0; for (int i = 0; i < fxi->heads(); i++) { if (pt.isNull()) { if (assignHead(pt, GroupHead(fxi->id(), i)) == true) headAddedcount++; } else { if (assignHead(tmp, GroupHead(fxi->id(), i)) == true) headAddedcount++; tmp.setX(tmp.x() + 1); if (tmp.x() >= size().width()) { tmp.setX(0); tmp.setY(tmp.y() + 1); } } } return headAddedcount ? true : false; }
void FixtureGroup::assignHead(const QLCPoint& pt, const GroupHead& head) { if (m_heads.values().contains(head) == true) return; if (size().isValid() == false) setSize(QSize(1, 1)); if (pt.isNull() == false) { m_heads[pt] = head; } else { bool assigned = false; int y = 0; int x = 0; int xmax = size().width(); int ymax = size().height(); while (assigned == false) { for (; y < ymax; y++) { for (x = 0; x < xmax; x++) { QLCPoint tmp(x, y); if (m_heads.contains(tmp) == false) { m_heads[tmp] = head; assigned = true; break; } } if (assigned == true) break; } ymax++; } } emit changed(this->id()); }
void FixtureGroup::assignFixture(quint32 id, const QLCPoint& pt) { Fixture* fxi = doc()->fixture(id); Q_ASSERT(fxi != NULL); QLCPoint tmp = pt; for (int i = 0; i < fxi->heads(); i++) { if (pt.isNull()) { assignHead(pt, GroupHead(fxi->id(), i)); } else { assignHead(tmp, GroupHead(fxi->id(), i)); tmp.setX(tmp.x() + 1); if (tmp.x() >= size().width()) { tmp.setX(0); tmp.setY(tmp.y() + 1); } } } }