Skip to content

Commit 629e90b

Browse files
authored
Add support for fixture channel modes (#495)
* Add support for multiple fixture modes * Make most things work * Fix Fixture types window * Fix adding fixtures * Fix a bug in Add Fixture window * Make mode selectable * Use dmx modes in stock fixtures
1 parent 0e5fa3e commit 629e90b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1580
-1209
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ set(THEATREFILES
143143
theatre/effect.cpp
144144
theatre/fixture.cpp
145145
theatre/fixturefunction.cpp
146+
theatre/fixturemode.cpp
146147
theatre/fixturetype.cpp
147148
theatre/folder.cpp
148149
theatre/folderobject.cpp
@@ -173,7 +174,7 @@ include_directories(external/hsluv)
173174
include_directories($<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
174175

175176
add_library(glight-object OBJECT
176-
${GUIFILES} ${SYSTEMFILES} ${THEATREFILES} ${EXTERNALFILES})
177+
${THEATREFILES} ${SYSTEMFILES} ${GUIFILES} ${EXTERNALFILES})
177178

178179
add_executable(glight $<TARGET_OBJECTS:glight-object> glight.cpp)
179180

gui/components/colorselectwidget.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ void ColorSelectWidget::OpenVariableSelection() {
8282
effect->SetName(string_dialog.Value());
8383
theatre::Management &management = Instance::Management();
8484
system::ObservingPtr<theatre::Effect> added =
85-
management.AddEffect(std::move(effect), parent)
86-
.GetObserver<theatre::Effect>();
85+
management.AddEffectPtr(std::move(effect), parent);
8786
for (size_t i = 0; i != added->NInputs(); ++i)
8887
management.AddSourceValue(*added, i);
8988
Instance::Events().EmitUpdate();

gui/components/fixturelist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void FixtureList::Fill() {
4343
Gtk::TreeModel::iterator iter = model_->append();
4444
const Gtk::TreeModel::Row &row = *iter;
4545
row[columns_.title_] = fixture->Name();
46-
row[columns_.type_] = fixture->Type().Name();
46+
row[columns_.type_] = fixture->Mode().Name();
4747
row[columns_.fixture_] = fixture.GetObserver();
4848
row[columns_.group_] = nullptr;
4949
}

gui/components/powermonitor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <glibmm/main.h>
88

9+
#include "theatre/fixture.h"
10+
#include "theatre/fixturetype.h"
911
#include "theatre/management.h"
1012
#include "theatre/theatre.h"
1113

@@ -67,10 +69,10 @@ std::map<size_t, std::pair<double, double>> GetPowerPerPhase(
6769
std::map<size_t, std::pair<double, double>> phases;
6870
for (const system::TrackablePtr<theatre::Fixture>& fixture :
6971
theatre.Fixtures()) {
70-
const double fixture_power = fixture->Type().GetPower(*fixture, snapshot);
72+
const double fixture_power = fixture->Mode().GetPower(*fixture, snapshot);
7173
std::pair<double, double>& phase_power = phases[fixture->ElectricPhase()];
7274
phase_power.first += fixture_power;
73-
phase_power.second += fixture->Type().MaxPower();
75+
phase_power.second += fixture->Mode().Type().MaxPower();
7476
}
7577
if (phases.empty()) phases.emplace(0, std::make_pair(0.0, 0.0));
7678
return phases;

gui/components/reorderwidget.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "reorderwidget.h"
22

33
#include "../../theatre/fixture.h"
4+
#include "../../theatre/fixturemode.h"
45
#include "../../theatre/fixturetype.h"
56

67
#include <ranges>
@@ -37,9 +38,10 @@ void ReorderWidget::Append(system::ObservingPtr<theatre::NamedObject> object) {
3738
Gtk::TreeModel::iterator iter = model_->append();
3839
const Gtk::TreeModel::Row& row = *iter;
3940
row[columns_.title_] = object->Name();
40-
if (theatre::Fixture* fixture = dynamic_cast<theatre::Fixture*>(object.Get());
41+
if (const theatre::Fixture* fixture =
42+
dynamic_cast<const theatre::Fixture*>(object.Get());
4143
fixture) {
42-
row[columns_.type_] = fixture->Type().Name();
44+
row[columns_.type_] = fixture->Mode().Type().Name();
4345
}
4446
row[columns_.object_] = std::move(object);
4547
signal_changed_();

gui/components/visualizationwidget.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "theatre/fixture.h"
1919
#include "theatre/fixturecontrol.h"
2020
#include "theatre/fixturegroup.h"
21+
#include "theatre/fixturetype.h"
2122
#include "theatre/management.h"
2223
#include "theatre/managementtools.h"
2324
#include "theatre/theatre.h"
@@ -160,8 +161,8 @@ void VisualizationWidget::updateMidiColors() {
160161
size_t pad = 0;
161162
for (const system::TrackablePtr<theatre::Fixture> &fixture : fixtures) {
162163
if (fixture->IsVisible()) {
163-
const glight::theatre::FixtureType &type = fixture->Type();
164-
const size_t shape_count = type.ShapeCount();
164+
const glight::theatre::FixtureMode &mode = fixture->Mode();
165+
const size_t shape_count = mode.Type().ShapeCount();
165166
for (size_t shape_index = 0; shape_index != shape_count;
166167
++shape_index) {
167168
const theatre::Color color =
@@ -617,8 +618,7 @@ void VisualizationWidget::onDistributeEvenly() {
617618
}
618619

619620
void VisualizationWidget::onAddFixtures() {
620-
sub_window_ = std::make_unique<windows::AddFixtureWindow>(_eventTransmitter,
621-
*_management);
621+
sub_window_ = std::make_unique<windows::AddFixtureWindow>();
622622
sub_window_->set_transient_for(*main_window_);
623623
sub_window_->set_modal(true);
624624
sub_window_->show();
@@ -743,7 +743,7 @@ void VisualizationWidget::SetTilt(const theatre::Coordinate2D &position) {
743743
bool is_changed = false;
744744
for (const system::ObservingPtr<theatre::Fixture> &fixture :
745745
_selectedFixtures) {
746-
if (fixture->Type().CanBeamTilt()) {
746+
if (fixture->Mode().Type().CanBeamTilt()) {
747747
constexpr theatre::Coordinate2D offset(0.5, 0.5);
748748
const theatre::Coordinate2D direction =
749749
position - fixture->GetXY() - offset;
@@ -752,8 +752,8 @@ void VisualizationWidget::SetTilt(const theatre::Coordinate2D &position) {
752752
direction.Y() * direction.Y());
753753
double tilt = std::atan(z / dist) - fixture->StaticTilt();
754754
if (fixture->IsUpsideDown()) tilt = -tilt;
755-
const double begin_tilt = fixture->Type().MinTilt();
756-
const double end_tilt = fixture->Type().MaxTilt();
755+
const double begin_tilt = fixture->Mode().Type().MinTilt();
756+
const double end_tilt = fixture->Mode().Type().MaxTilt();
757757
const double min_value = std::min(begin_tilt, end_tilt);
758758
const double max_value = std::max(begin_tilt, end_tilt);
759759
tilt = system::RadialClamp(tilt, min_value, max_value);
@@ -778,15 +778,15 @@ void VisualizationWidget::SetPan(const theatre::Coordinate2D &position) {
778778
bool is_changed = false;
779779
for (const system::ObservingPtr<theatre::Fixture> &fixture :
780780
_selectedFixtures) {
781-
if (fixture->Type().CanBeamRotate()) {
781+
if (fixture->Mode().Type().CanBeamRotate()) {
782782
constexpr theatre::Coordinate2D offset(0.5, 0.5);
783783
const theatre::Coordinate2D direction =
784784
position - fixture->GetXY() - offset;
785785
const bool is_zero = direction.Y() == 0.0 && direction.X() == 0.0;
786786
const double angle =
787787
is_zero ? 0.0 : std::atan2(direction.Y(), direction.X());
788-
double begin_pan = fixture->Type().MinPan();
789-
double end_pan = fixture->Type().MaxPan();
788+
double begin_pan = fixture->Mode().Type().MinPan();
789+
double end_pan = fixture->Mode().Type().MaxPan();
790790
if (fixture->IsUpsideDown()) {
791791
std::swap(begin_pan, end_pan);
792792
}

gui/dialogs/createchasedialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void CreateChaseDialog::onCreateChaseButtonClicked() {
107107
theatre::Management &management = Instance::Management();
108108
std::unique_lock<std::mutex> lock(management.Mutex());
109109

110-
_newChase = management.AddChase().GetObserver<theatre::Chase>();
110+
_newChase = management.AddChasePtr();
111111
management.AddSourceValue(*_newChase, 0);
112112
_newChase->SetName(folder.GetAvailableName("Chase"));
113113
folder.Add(_newChase);

gui/mainwindow/actions.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void NewEmptyPreset(ObjectBrowser &browser,
7777
Management &management = Instance::Management();
7878
std::unique_lock<std::mutex> lock(management.Mutex());
7979
ObservingPtr<theatre::PresetCollection> preset_collection =
80-
management.AddPresetCollection().GetObserver<theatre::PresetCollection>();
80+
management.AddPresetCollectionPtr();
8181
preset_collection->SetName(parent_folder.GetAvailableName("Preset"));
8282
parent_folder.Add(preset_collection);
8383
management.AddSourceValue(*preset_collection, 0);
@@ -94,7 +94,7 @@ void NewPresetFromCurrent(ObjectBrowser &browser) {
9494
Management &management = Instance::Management();
9595
std::unique_lock<std::mutex> lock(management.Mutex());
9696
ObservingPtr<theatre::PresetCollection> preset_collection =
97-
management.AddPresetCollection().GetObserver<theatre::PresetCollection>();
97+
management.AddPresetCollectionPtr();
9898
preset_collection->SetName(parent.GetAvailableName("Preset"));
9999
parent.Add(preset_collection);
100100
preset_collection->SetFromCurrentSituation(management);
@@ -112,7 +112,7 @@ void NewPresetFromFixtures(
112112
Management &management = Instance::Management();
113113
std::unique_lock<std::mutex> lock(management.Mutex());
114114
ObservingPtr<theatre::PresetCollection> preset_collection =
115-
management.AddPresetCollection().GetObserver<theatre::PresetCollection>();
115+
management.AddPresetCollectionPtr();
116116
preset_collection->SetName(parent_folder.GetAvailableName("Preset"));
117117
parent_folder.Add(preset_collection);
118118
preset_collection->SetFromCurrentFixtures(management, fixtures);
@@ -142,7 +142,7 @@ void NewTimeSequence(ObjectBrowser &browser,
142142
std::unique_lock<std::mutex> lock(management.Mutex());
143143
Folder &parent_folder = browser.SelectedFolder();
144144
ObservingPtr<theatre::TimeSequence> time_sequence =
145-
management.AddTimeSequence().GetObserver<theatre::TimeSequence>();
145+
management.AddTimeSequencePtr();
146146
time_sequence->SetName(parent_folder.GetAvailableName("Seq"));
147147
parent_folder.Add(time_sequence);
148148
management.AddSourceValue(*time_sequence, 0);
@@ -164,8 +164,7 @@ void NewEffect(theatre::EffectType effect_type, ObjectBrowser &browser,
164164
effect->SetName(
165165
parent_folder.GetAvailableName(EffectTypeToName(effect_type)));
166166
ObservingPtr<Effect> added =
167-
management.AddEffect(std::move(effect), parent_folder)
168-
.GetObserver<Effect>();
167+
management.AddEffectPtr(std::move(effect), parent_folder);
169168
for (size_t i = 0; i != added->NInputs(); ++i)
170169
management.AddSourceValue(*added, i);
171170
lock.unlock();

gui/renderengine.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "renderengine.h"
22

33
#include "../theatre/fixture.h"
4+
#include "../theatre/fixturemode.h"
5+
#include "../theatre/fixturetype.h"
46
#include "../theatre/theatre.h"
57

68
#include "system/math.h"
@@ -49,14 +51,15 @@ struct DrawData {
4951

5052
void DrawFixtureProjection(const DrawData &data,
5153
const theatre::Fixture &fixture) {
52-
const theatre::FixtureType &type = fixture.Type();
54+
const theatre::FixtureMode &mode = fixture.Mode();
55+
const theatre::FixtureType &type = mode.Type();
5356
const size_t shape_count = type.ShapeCount();
5457
for (size_t shape_index = 0; shape_index != shape_count; ++shape_index) {
5558
const double tilt = fixture.GetBeamTilt(data.snapshot, shape_index);
5659
const double direction =
5760
fixture.GetBeamDirection(data.snapshot, shape_index);
5861
const double beam_angle =
59-
type.CanZoom() ? type.GetZoom(fixture, data.snapshot, shape_index) * 0.5
62+
type.CanZoom() ? mode.GetZoom(fixture, data.snapshot, shape_index) * 0.5
6063
: type.MinBeamAngle() * 0.5;
6164
const double x = fixture.GetPosition().X() + 0.5;
6265
const double y = fixture.GetPosition().Y() + 0.5;
@@ -140,7 +143,8 @@ void DrawFixtureProjection(const DrawData &data,
140143
}
141144

142145
void DrawFixtureBeam(const DrawData &data, const theatre::Fixture &fixture) {
143-
const theatre::FixtureType &type = fixture.Type();
146+
const theatre::FixtureMode &mode = fixture.Mode();
147+
const theatre::FixtureType &type = mode.Type();
144148
const size_t shape_count = type.ShapeCount();
145149
for (size_t shape_index = 0; shape_index != shape_count; ++shape_index) {
146150
const theatre::Color c = fixture.GetColor(data.snapshot, shape_index);
@@ -152,7 +156,7 @@ void DrawFixtureBeam(const DrawData &data, const theatre::Fixture &fixture) {
152156
const double z = fixture.GetPosition().Z();
153157
const double beam_angle =
154158
type.CanZoom()
155-
? type.GetZoom(fixture, data.snapshot, shape_index) * 0.5
159+
? mode.GetZoom(fixture, data.snapshot, shape_index) * 0.5
156160
: type.MinBeamAngle() * 0.5;
157161
const double tilt = fixture.GetBeamTilt(data.snapshot, shape_index);
158162
const double cos_tilt = std::cos(tilt);
@@ -214,7 +218,7 @@ void DrawFixtureBeam(const DrawData &data, const theatre::Fixture &fixture) {
214218

215219
void DrawFixture(DrawData &data, const theatre::Fixture &fixture,
216220
FixtureState &fixture_state) {
217-
size_t shapeCount = fixture.Type().ShapeCount();
221+
size_t shapeCount = fixture.Mode().Type().ShapeCount();
218222
for (size_t i = 0; i != shapeCount; ++i) {
219223
const size_t shapeIndex = shapeCount - i - 1;
220224
const theatre::Color c = fixture.GetColor(data.snapshot, shapeIndex);

0 commit comments

Comments
 (0)