Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function Wizard: create Effects #1649

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions ui/src/functionwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "vcsoloframe.h"
#include "vccuelist.h"
#include "rgbmatrix.h"
#include "efx.h"
#include "vcwidget.h"
#include "vcbutton.h"
#include "vcslider.h"
Expand Down Expand Up @@ -328,6 +329,15 @@ void FunctionWizard::updateAvailableFunctionsTree()
addFunctionsGroup(fxGrpItem, grpItem,
PaletteGenerator::typetoString(PaletteGenerator::Animation),
PaletteGenerator::Animation);
addFunctionsGroup(fxGrpItem, grpItem,
PaletteGenerator::typetoString(PaletteGenerator::Effect),
PaletteGenerator::Effect);
}
else if (cap == QLCChannel::groupToString(QLCChannel::Pan))
{
addFunctionsGroup(fxGrpItem, grpItem,
PaletteGenerator::typetoString(PaletteGenerator::Effect),
PaletteGenerator::Effect);
}
else if (cap == QLCChannel::groupToString(QLCChannel::Gobo))
addFunctionsGroup(fxGrpItem, grpItem,
Expand Down Expand Up @@ -427,6 +437,12 @@ void FunctionWizard::updateResultFunctionsTree()
item->setText(KFunctionName, matrix->name());
item->setIcon(KFunctionName, matrix->getIcon());
}
foreach (EFX *effect, palette->effects())
{
QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(effect));
item->setText(KFunctionName, effect->name());
item->setIcon(KFunctionName, effect->getIcon());
}
}
}
}
Expand Down Expand Up @@ -521,6 +537,20 @@ void FunctionWizard::updateWidgetsTree()
item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)matrix));
}
foreach (EFX *effect, palette->effects())
{
QTreeWidgetItem *item = NULL;
if (soloFrameItem != NULL)
item = new QTreeWidgetItem(soloFrameItem);
else
item = new QTreeWidgetItem(frame);
QString toRemove = " - " + palette->model();
item->setText(KWidgetName, effect->name().remove(toRemove));
item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
item->setCheckState(KWidgetName, Qt::Unchecked);
item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)effect));
}

if (palette->scenes().count() > 0)
{
Expand Down
80 changes: 80 additions & 0 deletions ui/src/palettegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "fixturegroup.h"
#include "chaserstep.h"
#include "rgbmatrix.h"
#include "efx.h"
#include "fixture.h"
#include "chaser.h"
#include "scene.h"
Expand Down Expand Up @@ -60,6 +61,7 @@ PaletteGenerator::~PaletteGenerator()
m_scenes.clear();
m_chasers.clear();
m_matrices.clear();
m_effects.clear();
}

void PaletteGenerator::setName(QString name)
Expand Down Expand Up @@ -102,6 +104,7 @@ QString PaletteGenerator::typetoString(PaletteGenerator::PaletteType type)
case Gobos: return tr("Gobo macros");
case ColourMacro: return tr("Colour macros");
case Animation: return tr("Animations");
case Effect: return tr("Effects");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not "EFX"? Users are used to that term

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will rename it

case Undefined:
default:
return tr("Unknown");
Expand Down Expand Up @@ -194,6 +197,11 @@ QList<RGBMatrix *> PaletteGenerator::matrices()
return m_matrices;
}

QList<EFX *> PaletteGenerator::effects()
{
return m_effects;
}

void PaletteGenerator::addToDoc()
{
foreach (Scene *scene, m_scenes)
Expand All @@ -217,6 +225,10 @@ void PaletteGenerator::addToDoc()
matrix->setFixtureGroup(m_fixtureGroup->id());
m_doc->addFunction(matrix);
}
foreach (EFX *effect, m_effects)
{
m_doc->addFunction(effect);
}
}

void PaletteGenerator::createColorScene(QList<SceneValue> chMap, QString name, PaletteSubType subType)
Expand Down Expand Up @@ -453,6 +465,65 @@ void PaletteGenerator::createRGBMatrices(QList<SceneValue> rgbMap)
}
}

EFX *PaletteGenerator::createEffect(QList<Fixture *> fixtures, bool staggered, EFXFixture::Mode mode)
{
EFX *efx = new EFX(m_doc);

QString modeString = (new QString[]{KXMLQLCEFXFixtureModePanTilt, KXMLQLCEFXFixtureModeDimmer, KXMLQLCEFXFixtureModeRGB})[mode];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that fails to build. Can you just use a QStringList?


efx->setName(tr("Effect %1 %2 - ").arg(modeString).arg(staggered ? " Staggered " : "") + m_model);

if (mode == EFXFixture::Mode::RGB)
{
efx->setAlgorithm(EFX::Algorithm::Line2);
efx->setHeight(0);
}
else if (mode == EFXFixture::Mode::PanTilt)
{
}
else if (mode == EFXFixture::Mode::Dimmer)
{
}

for (int i = 0; i < fixtures.count(); i++)
{
Fixture *fixture = fixtures[i];
for (int h = 0; h < fixture->heads(); h++)
{
qDebug() << "fx" << fixture->channelAddress(0) << " " << h;

EFXFixture *ef = new EFXFixture(efx);
ef->setHead(GroupHead(fixture->id(), h));
ef->setMode(mode);
ef->setStartOffset(staggered ? (i * (360 / fixtures.count())) : 0);
efx->addFixture(ef);
}
}

qDebug() << "efx: " << efx << efx->fixtures().count();

return efx;
}

void PaletteGenerator::createEffects(QList<Fixture *> fixtures)
{
qDebug() << "createEffects";

m_effects.append(createEffect(fixtures, false, EFXFixture::Mode::Dimmer));
m_effects.append(createEffect(fixtures, true, EFXFixture::Mode::Dimmer));

if (PaletteGenerator::getCapabilities(fixtures[0]).contains(KQLCChannelRGB))
{
m_effects.append(createEffect(fixtures, false, EFXFixture::Mode::RGB));
m_effects.append(createEffect(fixtures, true, EFXFixture::Mode::RGB));
}
if (PaletteGenerator::getCapabilities(fixtures[0]).contains(KQLCChannelMovement))
{
m_effects.append(createEffect(fixtures, false, EFXFixture::Mode::PanTilt));
m_effects.append(createEffect(fixtures, true, EFXFixture::Mode::PanTilt));
}
}

void PaletteGenerator::createChaser(QString name)
{
if (m_scenes.count() == 0)
Expand Down Expand Up @@ -561,6 +632,15 @@ void PaletteGenerator::createFunctions(PaletteGenerator::PaletteType type,
if (m_redList.size() > 1 && m_greenList.size() == m_redList.size() && m_blueList.size() == m_redList.size())
createRGBMatrices(m_redList);
}
break;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation please

case Effect:
{
if ((m_redList.size() > 1 &&
m_greenList.size() == m_redList.size() &&
m_blueList.size() == m_redList.size()) ||
m_panList.size() > 1)
createEffects(m_fixtures);
}
break;
case Gobos:
{
Expand Down
9 changes: 9 additions & 0 deletions ui/src/palettegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
#include <QHash>

#include "scenevalue.h"
#include "efx.h"

class FixtureGroup;
class RGBMatrix;
class EFX;
class EFXFixture;
class Fixture;
class Chaser;
class Scene;
Expand Down Expand Up @@ -56,6 +59,7 @@ class PaletteGenerator: public QObject
Shutter,
Gobos,
ColourMacro,
Effect,
Animation
};

Expand Down Expand Up @@ -112,6 +116,7 @@ class PaletteGenerator: public QObject
QList<Scene *> scenes();
QList<Chaser *> chasers();
QList<RGBMatrix *> matrices();
QList<EFX *> effects();

void addToDoc();

Expand All @@ -127,6 +132,9 @@ class PaletteGenerator: public QObject

void createRGBMatrices(QList<SceneValue> rgbMap);

EFX* createEffect(QList <Fixture*> fixtures, bool staggered, EFXFixture::Mode mode);
void createEffects(QList<Fixture*> fixtures);

void createChaser(QString name);

/**
Expand All @@ -152,6 +160,7 @@ class PaletteGenerator: public QObject
QList <Scene*> m_scenes;
QList <Chaser*> m_chasers;
QList <RGBMatrix*> m_matrices;
QList <EFX*> m_effects;
};

/** @} */
Expand Down
Loading