summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-07-16 21:36:23 +0200
committerThomas White <taw@physics.org>2019-07-16 21:36:23 +0200
commit6f0279d8dfb9db1824b2a037569e17bb0d49659a (patch)
treedcb660029d5abb0f695a3194c2b5275ecfb6bff0
parent3515a370920875883f6f388ccf29a097132ab44e (diff)
Put all attribute values in a struct
-rw-r--r--src/command.c2
-rw-r--r--src/display.c22
-rw-r--r--src/lightctx.c96
-rw-r--r--src/lightctx.h22
-rw-r--r--src/scanout.c38
5 files changed, 93 insertions, 87 deletions
diff --git a/src/command.c b/src/command.c
index f1387b8..f0b5b27 100644
--- a/src/command.c
+++ b/src/command.c
@@ -205,7 +205,7 @@ static void set_level(struct lightctx *nl, int val)
for ( i=0; i<nl->n_sel; i++ ) {
struct fixture *fix = &nl->fixtures[nl->selection[i]];
- fix->intensity = (float)val/100.0;
+ fix->v.intensity = (float)val/100.0;
}
}
diff --git a/src/display.c b/src/display.c
index becea58..122d455 100644
--- a/src/display.c
+++ b/src/display.c
@@ -77,8 +77,8 @@ static void draw_fixture(cairo_t *cr, PangoContext *pc, PangoFontDescription *fo
/* Pan/tilt (underneath rectangle) */
if ( fix->cls->attributes & PANTILT ) {
- double x = w*(1.0 + fix->pan)/2.0;
- double y = h*(1.0 - fix->tilt)/2.0;
+ double x = w*(1.0 + fix->v.pan)/2.0;
+ double y = h*(1.0 - fix->v.tilt)/2.0;
cairo_move_to(cr, x, -1.0);
cairo_line_to(cr, x, h+1.0);
@@ -117,7 +117,7 @@ static void draw_fixture(cairo_t *cr, PangoContext *pc, PangoFontDescription *fo
g_object_unref(layout);
/* Intensity */
- snprintf(tmp, 32, "%.0f %%", fix->intensity*100.0);
+ snprintf(tmp, 32, "%.0f %%", fix->v.intensity*100.0);
layout = pango_layout_new(pc);
pango_layout_set_text(layout, tmp, -1);
pango_layout_set_width(layout, (w*PANGO_SCALE)-4.0);
@@ -292,8 +292,8 @@ static void set_start_pantilt(struct lightctx *nl)
int i;
for ( i=0; i<nl->n_sel; i++ ) {
struct fixture *fix = &nl->fixtures[nl->selection[i]];
- fix->pan_start = fix->pan;
- fix->tilt_start = fix->tilt;
+ fix->pan_start = fix->v.pan;
+ fix->tilt_start = fix->v.tilt;
}
}
@@ -353,12 +353,12 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, struct lightctx
struct fixture *fix = &nl->fixtures[nl->selection[i]];
if ( !(fix->cls->attributes & PANTILT) ) continue;
- fix->pan = fix->pan_start + x_inc*speed;
- fix->tilt = fix->tilt_start + y_inc*speed;
- if ( fix->pan > 1.0 ) fix->pan = 1.0;
- if ( fix->pan < -1.0 ) fix->pan = -1.0;
- if ( fix->tilt > 1.0 ) fix->tilt = 1.0;
- if ( fix->tilt < -1.0 ) fix->tilt = -1.0;
+ fix->v.pan = fix->pan_start + x_inc*speed;
+ fix->v.tilt = fix->tilt_start + y_inc*speed;
+ if ( fix->v.pan > 1.0 ) fix->v.pan = 1.0;
+ if ( fix->v.pan < -1.0 ) fix->v.pan = -1.0;
+ if ( fix->v.tilt > 1.0 ) fix->v.tilt = 1.0;
+ if ( fix->v.tilt < -1.0 ) fix->v.tilt = -1.0;
}
diff --git a/src/lightctx.c b/src/lightctx.c
index 21c0c03..c66e4a7 100644
--- a/src/lightctx.c
+++ b/src/lightctx.c
@@ -45,24 +45,24 @@ struct fixture *create_fixture(struct lightctx *nl, struct fixture_class *cls,
fix->cls = cls;
fix->flags = flags;
- fix->intensity = 0.0;
- fix->cyan = 0.0;
- fix->magenta = 0.0;
- fix->yellow = 0.0;
- fix->red = 0.0;
- fix->green = 0.0;
- fix->blue = 0.0;
- fix->pan = 0.0;
- fix->tilt = 0.0;
- fix->gobo = 0;
- fix->gobo_rotate = 0.0;
- fix->gobo_spin = 0.0;
- fix->prism = 0;
- fix->prism_rotate = 0.0;
- fix->prism_spin = 0.0;
- fix->focus = 0.5;
- fix->zoom = 0.5;
- fix->frost = 0.0;
+ fix->v.intensity = 0.0;
+ fix->v.cyan = 0.0;
+ fix->v.magenta = 0.0;
+ fix->v.yellow = 0.0;
+ fix->v.red = 0.0;
+ fix->v.green = 0.0;
+ fix->v.blue = 0.0;
+ fix->v.pan = 0.0;
+ fix->v.tilt = 0.0;
+ fix->v.gobo = 0;
+ fix->v.gobo_rotate = 0.0;
+ fix->v.gobo_spin = 0.0;
+ fix->v.prism = 0;
+ fix->v.prism_rotate = 0.0;
+ fix->v.prism_spin = 0.0;
+ fix->v.focus = 0.5;
+ fix->v.zoom = 0.5;
+ fix->v.frost = 0.0;
return fix;
}
@@ -83,8 +83,8 @@ void attr_movex(struct lightctx *nl, signed int d, int fine)
for ( i=0; i<nl->n_sel; i++ ) {
struct fixture *fix = &nl->fixtures[nl->selection[i]];
if ( !(fix->cls->attributes & PANTILT) ) continue;
- fix->pan += chg;
- cap_value(&fix->pan, -1.0, 1.0);
+ fix->v.pan += chg;
+ cap_value(&fix->v.pan, -1.0, 1.0);
}
}
@@ -99,65 +99,65 @@ void attr_movey(struct lightctx *nl, signed int d, int fine)
switch ( nl->sel_attr ) {
case INTENSITY :
- fix->intensity += chg;
- cap_value(&fix->intensity, 0.0, 1.0);
+ fix->v.intensity += chg;
+ cap_value(&fix->v.intensity, 0.0, 1.0);
break;
case PANTILT :
- fix->tilt += chg;
- cap_value(&fix->tilt, -1.0, 1.0);
+ fix->v.tilt += chg;
+ cap_value(&fix->v.tilt, -1.0, 1.0);
break;
case FOCUS :
- fix->focus += chg;
- cap_value(&fix->focus, 0.0, 1.0);
+ fix->v.focus += chg;
+ cap_value(&fix->v.focus, 0.0, 1.0);
break;
case ZOOM :
- fix->zoom += chg;
- cap_value(&fix->zoom, 0.0, 1.0);
+ fix->v.zoom += chg;
+ cap_value(&fix->v.zoom, 0.0, 1.0);
break;
case FROST :
- fix->frost += chg;
- cap_value(&fix->frost, 0.0, 1.0);
+ fix->v.frost += chg;
+ cap_value(&fix->v.frost, 0.0, 1.0);
break;
case IRIS :
- fix->iris += chg;
- cap_value(&fix->iris, 0.0, 1.0);
+ fix->v.iris += chg;
+ cap_value(&fix->v.iris, 0.0, 1.0);
break;
case GOBO :
- if ( (fix->gobo == 0) && (d<0) ) continue;
- if ( (fix->gobo == fix->cls->n_gobos-1) && (d>0) ) continue;
- fix->gobo += d;
+ if ( (fix->v.gobo == 0) && (d<0) ) continue;
+ if ( (fix->v.gobo == fix->cls->n_gobos-1) && (d>0) ) continue;
+ fix->v.gobo += d;
break;
case GOBO_ROTATE :
- fix->gobo_rotate += chg;
- cap_value(&fix->gobo_rotate, -1.0, 1.0);
+ fix->v.gobo_rotate += chg;
+ cap_value(&fix->v.gobo_rotate, -1.0, 1.0);
break;
case GOBO_SPIN :
- fix->gobo_spin += chg;
- cap_value(&fix->gobo_spin, -1.0, 1.0);
+ fix->v.gobo_spin += chg;
+ cap_value(&fix->v.gobo_spin, -1.0, 1.0);
break;
case PRISM :
- if ( (fix->prism == 0) && (d<0) ) continue;
- if ( (fix->prism == fix->cls->n_prisms-1) && (d>0) ) continue;
- fix->prism += d;
+ if ( (fix->v.prism == 0) && (d<0) ) continue;
+ if ( (fix->v.prism == fix->cls->n_prisms-1) && (d>0) ) continue;
+ fix->v.prism += d;
break;
case PRISM_ROTATE :
- fix->prism_rotate += chg;
- cap_value(&fix->prism_rotate, -1.0, 1.0);
+ fix->v.prism_rotate += chg;
+ cap_value(&fix->v.prism_rotate, -1.0, 1.0);
break;
case PRISM_SPIN :
- fix->prism_spin += chg;
- cap_value(&fix->prism_spin, -1.0, 1.0);
+ fix->v.prism_spin += chg;
+ cap_value(&fix->v.prism_spin, -1.0, 1.0);
break;
}
@@ -173,10 +173,10 @@ int any_selected_fixture_has(struct lightctx *nl, int attr)
struct fixture *fix = &nl->fixtures[nl->selection[i]];
if ( fix->cls->attributes & attr ) return 1;
if ( fix->cls->attributes & GOBO ) {
- if ( fix->cls->gobo_flags[fix->gobo] & attr ) return 1;
+ if ( fix->cls->gobo_flags[fix->v.gobo] & attr ) return 1;
}
if ( fix->cls->attributes & PRISM ) {
- if ( fix->cls->prism_flags[fix->prism] & attr ) return 1;
+ if ( fix->cls->prism_flags[fix->v.prism] & attr ) return 1;
}
}
return 0;
diff --git a/src/lightctx.h b/src/lightctx.h
index 3084f50..ec9170a 100644
--- a/src/lightctx.h
+++ b/src/lightctx.h
@@ -97,15 +97,8 @@ struct fixture_class
};
-struct fixture
+struct attr_vals
{
- char *label;
- int universe;
- int base_addr;
- struct fixture_class *cls;
-
- int flags;
-
float intensity; /* 0 (off) to 1 (full) */
float cyan; /* 0 (no filter) to 1 (full colour) */
float magenta; /* 0 (no filter) to 1 (full colour) */
@@ -125,6 +118,19 @@ struct fixture
float zoom; /* 0 (narrowest) to 1 (widest) */
float frost; /* 0 (hardest) to 1 (softest) */
float iris; /* 0 (fully open) to 1 (fully closed) */
+};
+
+
+struct fixture
+{
+ char *label;
+ int universe;
+ int base_addr;
+ struct fixture_class *cls;
+
+ int flags;
+
+ struct attr_vals v;
/* Values at start of mouse movement */
float pan_start;
diff --git a/src/scanout.c b/src/scanout.c
index a744a34..64e5574 100644
--- a/src/scanout.c
+++ b/src/scanout.c
@@ -60,13 +60,13 @@ static void set_prism(int *dmx, struct fixture *fix, int prism)
if ( fix->cls->prism_flags[prism] & PRISM_ROTATE ) {
float rotate_val;
- rotate_val = (fix->prism_rotate + 1.0)/2.0;
+ rotate_val = (fix->v.prism_rotate + 1.0)/2.0;
set_val(dmx, fix->base_addr, fix->cls->prism_rotate_offset, rotate_val, 0);
}
if ( fix->cls->prism_flags[prism] & PRISM_SPIN ) {
float rotate_val;
- rotate_val = (fix->prism_spin + 1.0)/2.0;
+ rotate_val = (fix->v.prism_spin + 1.0)/2.0;
set_val(dmx, fix->base_addr, fix->cls->prism_spin_offset, rotate_val, 0);
}
}
@@ -86,13 +86,13 @@ static void set_gobo(int *dmx, struct fixture *fix, int gobo)
if ( fix->cls->gobo_flags[gobo] & GOBO_ROTATE ) {
float rotate_val;
- rotate_val = (fix->gobo_rotate + 1.0)/2.0;
+ rotate_val = (fix->v.gobo_rotate + 1.0)/2.0;
set_val(dmx, fix->base_addr, fix->cls->gobo_rotate_offset, rotate_val, 0);
}
if ( fix->cls->gobo_flags[gobo] & GOBO_SPIN ) {
float rotate_val;
- rotate_val = (fix->gobo_spin + 1.0)/2.0;
+ rotate_val = (fix->v.gobo_spin + 1.0)/2.0;
set_val(dmx, fix->base_addr, fix->cls->gobo_spin_offset, rotate_val, 0);
}
}
@@ -128,14 +128,14 @@ int scanout_all(struct lightctx *nl)
}
if ( cls->attributes & INTENSITY ) {
- set_val(dmx, fix->base_addr, cls->intensity_offset, fix->intensity,
+ set_val(dmx, fix->base_addr, cls->intensity_offset, fix->v.intensity,
cls->attributes16 & INTENSITY);
}
if ( cls->attributes & PANTILT ) {
float pan_val, tilt_val;
- pan_val = (fix->pan + 1.0)/2.0;
- tilt_val = (fix->tilt + 1.0)/2.0;
+ pan_val = (fix->v.pan + 1.0)/2.0;
+ tilt_val = (fix->v.tilt + 1.0)/2.0;
if ( fix->flags & REVERSE_PAN ) pan_val = 1.0 - pan_val;
if ( fix->flags & REVERSE_TILT ) tilt_val = 1.0 - tilt_val;
set_val(dmx, fix->base_addr, cls->pan_offset, pan_val,
@@ -145,49 +145,49 @@ int scanout_all(struct lightctx *nl)
}
if ( (cls->attributes & COLOUR) && (cls->properties & COL_CMY) ) {
- set_val(dmx, fix->base_addr, cls->cyan_offset, fix->cyan,
+ set_val(dmx, fix->base_addr, cls->cyan_offset, fix->v.cyan,
cls->attributes16 & COL_CMY);
- set_val(dmx, fix->base_addr, cls->magenta_offset, fix->magenta,
+ set_val(dmx, fix->base_addr, cls->magenta_offset, fix->v.magenta,
cls->attributes16 & COL_CMY);
- set_val(dmx, fix->base_addr, cls->yellow_offset, fix->yellow,
+ set_val(dmx, fix->base_addr, cls->yellow_offset, fix->v.yellow,
cls->attributes16 & COL_CMY);
}
if ( (cls->attributes & COLOUR) && (cls->properties & COL_RGB) ) {
- set_val(dmx, fix->base_addr, cls->red_offset, fix->red,
+ set_val(dmx, fix->base_addr, cls->red_offset, fix->v.red,
cls->attributes16 & COL_RGB);
- set_val(dmx, fix->base_addr, cls->green_offset, fix->green,
+ set_val(dmx, fix->base_addr, cls->green_offset, fix->v.green,
cls->attributes16 & COL_RGB);
- set_val(dmx, fix->base_addr, cls->blue_offset, fix->blue,
+ set_val(dmx, fix->base_addr, cls->blue_offset, fix->v.blue,
cls->attributes16 & COL_RGB);
}
if ( cls->attributes & FOCUS ) {
- set_val(dmx, fix->base_addr, cls->focus_offset, fix->focus,
+ set_val(dmx, fix->base_addr, cls->focus_offset, fix->v.focus,
cls->attributes16 & FOCUS);
}
if ( cls->attributes & ZOOM ) {
- set_val(dmx, fix->base_addr, cls->zoom_offset, fix->zoom,
+ set_val(dmx, fix->base_addr, cls->zoom_offset, fix->v.zoom,
cls->attributes16 & ZOOM);
}
if ( cls->attributes & FROST ) {
- set_val(dmx, fix->base_addr, cls->frost_offset, fix->frost,
+ set_val(dmx, fix->base_addr, cls->frost_offset, fix->v.frost,
cls->attributes16 & FROST);
}
if ( cls->attributes & IRIS ) {
- set_val(dmx, fix->base_addr, cls->iris_offset, fix->iris,
+ set_val(dmx, fix->base_addr, cls->iris_offset, fix->v.iris,
cls->attributes16 & IRIS);
}
if ( cls->attributes & GOBO ) {
- set_gobo(dmx, fix, fix->gobo);
+ set_gobo(dmx, fix, fix->v.gobo);
}
if ( cls->attributes & PRISM ) {
- set_prism(dmx, fix, fix->prism);
+ set_prism(dmx, fix, fix->v.prism);
}
}