QLCFixtureMode *Fixture::genericDimmerMode(QLCFixtureDef *def, int channels) { Q_ASSERT(def != NULL); QLCFixtureMode *mode = new QLCFixtureMode(def); mode->setName(QString("%1 Channel").arg(channels)); QList<QLCChannel *>chList = def->channels(); for (int i = 0; i < chList.count(); i++) { QLCChannel *ch = chList.at(i); mode->insertChannel(ch, i); QLCFixtureHead head; head.addChannel(i); mode->insertHead(-1, head); } QLCPhysical physical; physical.setWidth(300 * channels); physical.setHeight(300); physical.setDepth(300); mode->setPhysical(physical); def->addMode(mode); return mode; }
bool QLCFixtureMode::loadXML(const QDomElement& root) { if (root.tagName() != KXMLQLCFixtureMode) { qWarning() << Q_FUNC_INFO << "Mode tag not found"; return false; } /* Mode name */ QString str = root.attribute(KXMLQLCFixtureModeName); if (str.isEmpty() == true) { qWarning() << Q_FUNC_INFO << "Mode has no name"; return false; } else { setName(str); } /* Subtags */ QDomNode node = root.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == KXMLQLCFixtureModeChannel) { /* Channel */ Q_ASSERT(m_fixtureDef != NULL); str = tag.attribute(KXMLQLCFixtureModeChannelNumber); insertChannel(m_fixtureDef->channel(tag.text()), str.toInt()); } else if (tag.tagName() == KXMLQLCFixtureHead) { /* Head */ QLCFixtureHead head; if (head.loadXML(tag) == true) insertHead(-1, head); } else if (tag.tagName() == KXMLQLCPhysical) { /* Physical */ QLCPhysical physical; physical.loadXML(tag); setPhysical(physical); } else { qWarning() << Q_FUNC_INFO << "Unknown Fixture Mode tag:" << tag.tagName(); } node = node.nextSibling(); } // Cache all head channels cacheHeads(); return true; }
int Doc::totalPowerConsumption(int& fuzzy) const { int totalPowerConsumption = 0; // Make sure fuzzy starts from zero fuzzy = 0; QListIterator <Fixture*> fxit(fixtures()); while (fxit.hasNext() == true) { Fixture* fxi(fxit.next()); Q_ASSERT(fxi != NULL); // Generic dimmer has no mode and physical if (fxi->isDimmer() == false && fxi->fixtureMode() != NULL) { QLCPhysical phys = fxi->fixtureMode()->physical(); if (phys.powerConsumption() > 0) totalPowerConsumption += phys.powerConsumption(); else fuzzy++; } else { fuzzy++; } } return totalPowerConsumption; }
bool QLCFixtureMode::loadXML(QXmlStreamReader &doc) { if (doc.name() != KXMLQLCFixtureMode) { qWarning() << Q_FUNC_INFO << "Mode tag not found"; return false; } /* Mode name */ QString str = doc.attributes().value(KXMLQLCFixtureModeName).toString(); if (str.isEmpty() == true) { qWarning() << Q_FUNC_INFO << "Mode has no name"; return false; } else { setName(str); } /* Subtags */ while (doc.readNextStartElement()) { if (doc.name() == KXMLQLCFixtureModeChannel) { /* Channel */ Q_ASSERT(m_fixtureDef != NULL); str = doc.attributes().value(KXMLQLCFixtureModeChannelNumber).toString(); insertChannel(m_fixtureDef->channel(doc.readElementText()), str.toInt()); } else if (doc.name() == KXMLQLCFixtureHead) { /* Head */ QLCFixtureHead head; if (head.loadXML(doc) == true) insertHead(-1, head); } else if (doc.name() == KXMLQLCPhysical) { /* Physical */ QLCPhysical physical; physical.loadXML(doc); setPhysical(physical); } else { qWarning() << Q_FUNC_INFO << "Unknown Fixture Mode tag:" << doc.name(); doc.skipCurrentElement(); } } // Cache all head channels cacheHeads(); return true; }
QLCFixtureMode *Fixture::genericRGBPanelMode(QLCFixtureDef *def, Components components, quint32 width, quint32 height) { Q_ASSERT(def != NULL); QLCFixtureMode *mode = new QLCFixtureMode(def); int compNum = 3; if (components == BGR) { mode->setName("BGR"); } else if (components == RGBW) { mode->setName("RGBW"); compNum = 4; } else if (components == RGBWW) { mode->setName("RGBWW"); compNum = 5; } else mode->setName("RGB"); QList<QLCChannel *>channels = def->channels(); for (int i = 0; i < channels.count(); i++) { QLCChannel *ch = channels.at(i); mode->insertChannel(ch, i); if (i%compNum == 0) { QLCFixtureHead head; head.addChannel(i); head.addChannel(i+1); head.addChannel(i+2); if (components == RGBW) head.addChannel(i+3); else if (components == RGBWW) { head.addChannel(i+3); head.addChannel(i+4); } mode->insertHead(-1, head); } } QLCPhysical physical; physical.setWidth(width); physical.setHeight(height); physical.setDepth(height); mode->setPhysical(physical); return mode; }
void QLCFixtureMode_Test::physical() { /* Verify that a QLCPhysical can be set & get for the mode */ QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef); QVERIFY(mode->physical().bulbType().isEmpty()); QLCPhysical p; p.setBulbType("Foobar"); mode->setPhysical(p); QVERIFY(mode->physical().bulbType() == "Foobar"); delete mode; }
bool QLCFixtureMode::loadXML(const QDomElement* root) { QDomNode node; QDomElement tag; QString str; QString ch; /* Get channel name */ str = root->attribute(KXMLQLCFixtureModeName); if (str == QString::null) return false; else setName(str); /* Subtags */ node = root->firstChild(); while (node.isNull() == false) { tag = node.toElement(); if (tag.tagName() == KXMLQLCFixtureModeChannel) { str = tag.attribute(KXMLQLCFixtureModeChannelNumber); insertChannel(m_fixtureDef->channel(tag.text()), str.toInt()); } else if (tag.tagName() == KXMLQLCPhysical) { QLCPhysical physical; physical.loadXML(&tag); setPhysical(physical); } else { qDebug() << "Unknown Mode tag: " << tag.tagName(); } node = node.nextSibling(); } return true; }
void EditMode::slotLensDegreesMaxChanged(int degrees) { QLCPhysical physical = m_mode->physical(); physical.setLensDegreesMax(degrees); m_mode->setPhysical(physical); }
void EditMode::slotLensNameChanged(const QString &name) { QLCPhysical physical = m_mode->physical(); physical.setLensName(name); m_mode->setPhysical(physical); }
void EditMode::slotDepthChanged(int depth) { QLCPhysical physical = m_mode->physical(); physical.setDepth(depth); m_mode->setPhysical(physical); }
void EditMode::slotHeightChanged(int height) { QLCPhysical physical = m_mode->physical(); physical.setHeight(height); m_mode->setPhysical(physical); }
void EditMode::slotWidthChanged(int width) { QLCPhysical physical = m_mode->physical(); physical.setWidth(width); m_mode->setPhysical(physical); }
void EditMode::slotBulbColourTemperatureChanged(const QString &kelvins) { QLCPhysical physical = m_mode->physical(); physical.setBulbColourTemperature(kelvins.toInt()); m_mode->setPhysical(physical); }
void EditMode::init() { QString str; QLCPhysical physical = m_mode->physical(); /* Channels page */ connect(m_addChannelButton, SIGNAL(clicked()), this, SLOT(slotAddChannelClicked())); connect(m_removeChannelButton, SIGNAL(clicked()), this, SLOT(slotRemoveChannelClicked())); connect(m_raiseChannelButton, SIGNAL(clicked()), this, SLOT(slotRaiseChannelClicked())); connect(m_lowerChannelButton, SIGNAL(clicked()), this, SLOT(slotLowerChannelClicked())); m_modeNameEdit->setText(m_mode->name()); m_channelList->header()->setResizeMode(QHeaderView::ResizeToContents); refreshChannelList(); /* Physical page */ m_bulbTypeCombo->setEditText(physical.bulbType()); m_bulbLumensSpin->setValue(physical.bulbLumens()); m_bulbTempCombo->setEditText(str.setNum(physical.bulbColourTemperature())); m_weightSpin->setValue(physical.weight()); m_widthSpin->setValue(physical.width()); m_heightSpin->setValue(physical.height()); m_depthSpin->setValue(physical.depth()); m_lensNameCombo->setEditText(physical.lensName()); m_lensDegreesMinSpin->setValue(physical.lensDegreesMin()); m_lensDegreesMaxSpin->setValue(physical.lensDegreesMax()); m_focusTypeCombo->setEditText(physical.focusType()); m_panMaxSpin->setValue(physical.focusPanMax()); m_tiltMaxSpin->setValue(physical.focusTiltMax()); m_powerConsumptionSpin->setValue(physical.powerConsumption()); m_dmxConnectorCombo->setEditText(physical.dmxConnector()); }
void EditMode::init() { QString str; QLCPhysical physical = m_mode->physical(); /* Channel buttons */ m_addChannelButton->setIconSet(QPixmap(QString(PIXMAPS) + QString("/edit_add.png"))); m_removeChannelButton->setIconSet(QPixmap(QString(PIXMAPS) + QString("/edit_remove.png"))); m_raiseChannelButton->setIconSet(QPixmap(QString(PIXMAPS) + QString("/up.png"))); m_lowerChannelButton->setIconSet(QPixmap(QString(PIXMAPS) + QString("/down.png"))); /* Mode name */ m_modeNameEdit->setText(m_mode->name()); /* Channels */ refreshChannelList(); /* Physical properties */ m_bulbTypeCombo->setCurrentText(physical.bulbType()); m_bulbLumensSpin->setValue(physical.bulbLumens()); str.sprintf("%d", physical.bulbColourTemperature()); m_bulbTempCombo->setCurrentText(str); m_weightSpin->setValue(physical.weight()); m_widthSpin->setValue(physical.width()); m_heightSpin->setValue(physical.height()); m_depthSpin->setValue(physical.depth()); m_lensNameCombo->setCurrentText(physical.lensName()); m_lensMinDegreesSpin->setValue(physical.lensDegreesMin()); m_lensMaxDegreesSpin->setValue(physical.lensDegreesMax()); m_focusTypeCombo->setCurrentText(physical.focusType()); m_panMaxSpin->setValue(physical.focusPanMax()); m_tiltMaxSpin->setValue(physical.focusTiltMax()); }
void EditMode::slotFocusTypeChanged(const QString &type) { QLCPhysical physical = m_mode->physical(); physical.setFocusType(type); m_mode->setPhysical(physical); }
QString Fixture::status() const { QString info; QString t; QString title("<TR><TD CLASS='hilite' COLSPAN='3'>%1</TD></TR>"); QString subTitle("<TR><TD CLASS='subhi' COLSPAN='3'>%1</TD></TR>"); QString genInfo("<TR><TD CLASS='emphasis'>%1</TD><TD COLSPAN='2'>%2</TD></TR>"); /******************************************************************** * General info ********************************************************************/ info += "<TABLE COLS='3' WIDTH='100%'>"; // Fixture title info += title.arg(name()); // Manufacturer if (isDimmer() == false) { info += genInfo.arg(tr("Manufacturer")).arg(m_fixtureDef->manufacturer()); info += genInfo.arg(tr("Model")).arg(m_fixtureDef->model()); info += genInfo.arg(tr("Mode")).arg(m_fixtureMode->name()); info += genInfo.arg(tr("Type")).arg(m_fixtureDef->type()); } else { info += genInfo.arg(tr("Type")).arg(tr("Generic Dimmer")); } // Universe info += genInfo.arg(tr("Universe")).arg(universe() + 1); // Address QString range = QString("%1 - %2").arg(address() + 1).arg(address() + channels()); info += genInfo.arg(tr("Address Range")).arg(range); // Channels info += genInfo.arg(tr("Channels")).arg(channels()); // Binary address QString binaryStr = QString("%1").arg(address() + 1, 10, 2, QChar('0')); QString dipTable("<TABLE COLS='33' cellspacing='0'><TR><TD COLSPAN='33'><IMG SRC=\"" ":/ds_top.png\"></TD></TR>"); dipTable += "<TR><TD><IMG SRC=\"" ":/ds_border.png\"></TD><TD><IMG SRC=\"" ":/ds_border.png\"></TD>"; for (int i = 9; i >= 0; i--) { if (binaryStr.at(i) == '0') dipTable += "<TD COLSPAN='3'><IMG SRC=\"" ":/ds_off.png\"></TD>"; else dipTable += "<TD COLSPAN='3'><IMG SRC=\"" ":/ds_on.png\"></TD>"; } dipTable += "<TD><IMG SRC=\"" ":/ds_border.png\"></TD></TR>"; dipTable += "<TR><TD COLSPAN='33'><IMG SRC=\"" ":/ds_bottom.png\"></TD></TR>"; dipTable += "</TABLE>"; info += genInfo.arg(tr("Binary Address (DIP)")) .arg(QString("%1").arg(dipTable)); /******************************************************************** * Channels ********************************************************************/ // Title row info += QString("<TR><TD CLASS='subhi'>%1</TD>").arg(tr("Channel")); info += QString("<TD CLASS='subhi'>%1</TD>").arg(tr("DMX")); info += QString("<TD CLASS='subhi'>%1</TD></TR>").arg(tr("Name")); // Fill table with the fixture's channels for (quint32 ch = 0; ch < channels(); ch++) { QString chInfo("<TR><TD>%1</TD><TD>%2</TD><TD>%3</TD></TR>"); info += chInfo.arg(ch + 1).arg(address() + ch + 1) .arg(channel(ch)->name()); } /******************************************************************** * Extended device information for non-dimmers ********************************************************************/ if (isDimmer() == false) { QLCPhysical physical = m_fixtureMode->physical(); info += title.arg(tr("Physical")); float mmInch = 0.0393700787; float kgLbs = 2.20462262; QString mm("%1mm (%2\")"); QString kg("%1kg (%2 lbs)"); QString W("%1W"); info += genInfo.arg(tr("Width")).arg(mm.arg(physical.width())) .arg(physical.width() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Height")).arg(mm.arg(physical.height())) .arg(physical.height() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Depth")).arg(mm.arg(physical.depth())) .arg(physical.depth() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Weight")).arg(kg.arg(physical.weight())) .arg(physical.weight() * kgLbs, 0, 'g', 4); info += genInfo.arg(tr("Power consumption")).arg(W.arg(physical.powerConsumption())); info += genInfo.arg(tr("DMX Connector")).arg(physical.dmxConnector()); // Bulb QString K("%1K"); QString lm("%1lm"); info += subTitle.arg(tr("Bulb")); info += genInfo.arg(tr("Type")).arg(physical.bulbType()); info += genInfo.arg(tr("Luminous Flux")).arg(lm.arg(physical.bulbLumens())); info += genInfo.arg(tr("Colour Temperature")).arg(K.arg(physical.bulbColourTemperature())); // Lens QString angle1("%1°"); QString angle2("%1° – %2°"); info += subTitle.arg(tr("Lens")); info += genInfo.arg(tr("Name")).arg(physical.lensName()); if (physical.lensDegreesMin() == physical.lensDegreesMax()) { info += genInfo.arg(tr("Beam Angle")) .arg(angle1.arg(physical.lensDegreesMin())); } else { info += genInfo.arg(tr("Beam Angle")) .arg(angle2.arg(physical.lensDegreesMin()) .arg(physical.lensDegreesMax())); } // Focus QString range("%1°"); info += subTitle.arg(tr("Focus")); info += genInfo.arg(tr("Type")).arg(physical.focusType()); info += genInfo.arg(tr("Pan Range")).arg(range.arg(physical.focusPanMax())); info += genInfo.arg(tr("Tilt Range")).arg(range.arg(physical.focusTiltMax())); } // HTML document & table closure info += "</TABLE>"; if (isDimmer() == false) { info += "<HR>"; info += "<DIV CLASS='author' ALIGN='right'>"; info += tr("Fixture definition author: ") + fixtureDef()->author(); info += "</DIV>"; } return info; }
void MainView2D::createFixtureItem(quint32 fxID, quint16 headIndex, quint16 linkedIndex, QVector3D pos, bool mmCoords) { if (isEnabled() == false) return; if (m_gridItem == NULL) initialize2DProperties(); qDebug() << "[MainView2D] Creating fixture with ID" << fxID << headIndex << linkedIndex << "pos:" << pos; Fixture *fixture = m_doc->fixture(fxID); if (fixture == NULL) return; quint32 itemID = FixtureUtils::fixtureItemID(fxID, headIndex, linkedIndex); QLCFixtureMode *fxMode = fixture->fixtureMode(); QQuickItem *newFixtureItem = qobject_cast<QQuickItem*>(fixtureComponent->create()); quint32 itemFlags = m_monProps->fixtureFlags(fxID, headIndex, linkedIndex); newFixtureItem->setParentItem(m_gridItem); newFixtureItem->setProperty("itemID", itemID); if (itemFlags & MonitorProperties::HiddenFlag) newFixtureItem->setProperty("visible", false); if (fxMode != NULL && fixture->type() != QLCFixtureDef::Dimmer) { QLCPhysical phy = fxMode->physical(); //qDebug() << "Current mode fixture heads:" << fxMode->heads().count(); newFixtureItem->setProperty("headsNumber", fxMode->heads().count()); if (fixture->channelNumber(QLCChannel::Pan, QLCChannel::MSB) != QLCChannel::invalid()) { int panDeg = phy.focusPanMax(); if (panDeg == 0) panDeg = 360; newFixtureItem->setProperty("panMaxDegrees", panDeg); } if (fixture->channelNumber(QLCChannel::Tilt, QLCChannel::MSB) != QLCChannel::invalid()) { int tiltDeg = phy.focusTiltMax(); if (tiltDeg == 0) tiltDeg = 270; newFixtureItem->setProperty("tiltMaxDegrees", tiltDeg); } } QPointF itemPos; QSizeF size = FixtureUtils::item2DDimension(fixture->type() == QLCFixtureDef::Dimmer ? NULL : fxMode, m_monProps->pointOfView()); if (mmCoords == false && (pos.x() != 0 || pos.y() != 0)) { float gridUnits = m_monProps->gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8; itemPos.setX((pos.x() * gridUnits) / m_cellPixels); itemPos.setY((pos.y() * gridUnits) / m_cellPixels); } if (m_monProps->containsItem(fxID, headIndex, linkedIndex)) { itemPos = FixtureUtils::item2DPosition(m_monProps, m_monProps->pointOfView(), pos); newFixtureItem->setProperty("rotation", FixtureUtils::item2DRotation(m_monProps->pointOfView(), m_monProps->fixtureRotation(fxID, headIndex, linkedIndex))); } else { itemPos = FixtureUtils::available2DPosition(m_doc, m_monProps->pointOfView(), QRectF(itemPos.x(), itemPos.y(), size.width(), size.height())); // add the new fixture to the Doc monitor properties QVector3D newPos = FixtureUtils::item3DPosition(m_monProps, itemPos, 1000.0); m_monProps->setFixturePosition(fxID, headIndex, linkedIndex, newPos); m_monProps->setFixtureFlags(fxID, headIndex, linkedIndex, 0); Tardis::instance()->enqueueAction(Tardis::FixtureSetPosition, itemID, QVariant(QVector3D(0, 0, 0)), QVariant(newPos)); } newFixtureItem->setProperty("mmXPos", itemPos.x()); newFixtureItem->setProperty("mmYPos", itemPos.y()); newFixtureItem->setProperty("mmWidth", size.width()); newFixtureItem->setProperty("mmHeight", size.height()); newFixtureItem->setProperty("fixtureName", fixture->name()); // and finally add the new item to the items map m_itemsMap[itemID] = newFixtureItem; QByteArray values; updateFixture(fixture, values); }
void EditMode::slotFocusTiltMaxChanged(int degrees) { QLCPhysical physical = m_mode->physical(); physical.setFocusTiltMax(degrees); m_mode->setPhysical(physical); }
void QLCPhysical_Test::copy() { QLCPhysical c = p; QVERIFY(c.bulbType() == p.bulbType()); QVERIFY(c.bulbLumens() == p.bulbLumens()); QVERIFY(c.bulbColourTemperature() == p.bulbColourTemperature()); QVERIFY(c.weight() == p.weight()); QVERIFY(c.width() == p.width()); QVERIFY(c.height() == p.height()); QVERIFY(c.depth() == p.depth()); QVERIFY(c.lensName() == p.lensName()); QVERIFY(c.lensDegreesMin() == p.lensDegreesMin()); QVERIFY(c.lensDegreesMax() == p.lensDegreesMax()); QVERIFY(c.focusType() == p.focusType()); QVERIFY(c.focusPanMax() == p.focusPanMax()); QVERIFY(c.focusTiltMax() == p.focusTiltMax()); QVERIFY(c.powerConsumption() == p.powerConsumption()); QVERIFY(c.dmxConnector() == p.dmxConnector()); }
void EditMode::slotBulbLumensChanged(int lumens) { QLCPhysical physical = m_mode->physical(); physical.setBulbLumens(lumens); m_mode->setPhysical(physical); }
void EditMode::accept() { QLCPhysical physical = m_mode->physical(); physical.setBulbType(m_bulbTypeCombo->currentText()); physical.setBulbLumens(m_bulbLumensSpin->value()); physical.setBulbColourTemperature(m_bulbTempCombo->currentText().toInt()); physical.setWeight(m_weightSpin->value()); physical.setWidth(m_widthSpin->value()); physical.setHeight(m_heightSpin->value()); physical.setDepth(m_depthSpin->value()); physical.setLensName(m_lensNameCombo->currentText()); physical.setLensDegreesMin(m_lensDegreesMinSpin->value()); physical.setLensDegreesMax(m_lensDegreesMaxSpin->value()); physical.setFocusType(m_focusTypeCombo->currentText()); physical.setFocusPanMax(m_panMaxSpin->value()); physical.setFocusTiltMax(m_tiltMaxSpin->value()); physical.setPowerConsumption(m_powerConsumptionSpin->value()); physical.setDmxConnector(m_dmxConnectorCombo->currentText()); m_mode->setPhysical(physical); m_mode->setName(m_modeNameEdit->text()); QDialog::accept(); }