Skip to content

Commit

Permalink
Consolidate MENU_ and ECMD_ defines.
Browse files Browse the repository at this point in the history
If I'm following how this is used correctly, we don't really need
separate MENU and ECMD defines - they can all be ECMD, and we just
handle the flag logic setting for the various categories of command in
the menu's edit function callback.
  • Loading branch information
starseeker committed Feb 6, 2025
1 parent 1690470 commit c2ecc2a
Show file tree
Hide file tree
Showing 21 changed files with 398 additions and 486 deletions.
18 changes: 9 additions & 9 deletions src/librt/primitives/arb8/edarb.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
#define ECMD_ARB_SETUP_ROTFACE 4014
#define ECMD_ARB_ROTATE_FACE 4015

#define MENU_ARB_MV_EDGE 4036
#define MENU_ARB_MV_FACE 4037
#define MENU_ARB_ROT_FACE 4038
#define ECMD_ARB_MV_EDGE 4036
#define ECMD_ARB_MV_FACE 4037
#define ECMD_ARB_ROT_FACE 4038

struct rt_arb8_edit {
fastf_t es_peqn[7][4]; /* ARBs defining plane equations */
Expand Down Expand Up @@ -544,9 +544,9 @@ arb_control(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void
}
struct rt_solid_edit_menu_item cntrl_menu[] = {
{ "ARB MENU", NULL, 0 },
{ "Move Edges", arb_control, MENU_ARB_MV_EDGE },
{ "Move Faces", arb_control, MENU_ARB_MV_FACE },
{ "Rotate Faces", arb_control, MENU_ARB_ROT_FACE },
{ "Move Edges", arb_control, ECMD_ARB_MV_EDGE },
{ "Move Faces", arb_control, ECMD_ARB_MV_FACE },
{ "Rotate Faces", arb_control, ECMD_ARB_ROT_FACE },
{ "", NULL, 0 }
};

Expand Down Expand Up @@ -925,19 +925,19 @@ ecmd_arb_specific_menu(struct rt_solid_edit *s)

rt_solid_edit_set_edflag(s, RT_SOLID_EDIT_IDLE);
switch (s->edit_menu) {
case MENU_ARB_MV_EDGE:
case ECMD_ARB_MV_EDGE:
rt_solid_edit_map_clbk_get(&f, &d, s->m, ECMD_MENU_SET, 0, BU_CLBK_DURING);
if (!f)
return BRLCAD_ERROR;
(*f)(0, NULL, d, which_menu[arb_type-4]);
return BRLCAD_OK;
case MENU_ARB_MV_FACE:
case ECMD_ARB_MV_FACE:
rt_solid_edit_map_clbk_get(&f, &d, s->m, ECMD_MENU_SET, 0, BU_CLBK_DURING);
if (!f)
return BRLCAD_ERROR;
(*f)(0, NULL, d, which_menu[arb_type+1]);
return BRLCAD_OK;
case MENU_ARB_ROT_FACE:
case ECMD_ARB_ROT_FACE:
rt_solid_edit_map_clbk_get(&f, &d, s->m, ECMD_MENU_SET, 0, BU_CLBK_DURING);
if (!f)
return BRLCAD_ERROR;
Expand Down
13 changes: 0 additions & 13 deletions src/librt/primitives/bot/edbot.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@
#define ECMD_BOT_FDEL 30071 /* delete current face */
#define ECMD_BOT_FLAGS 30072 /* set BOT flags */

#define MENU_BOT_PICKV 30091
#define MENU_BOT_PICKE 30092
#define MENU_BOT_PICKT 30093
#define MENU_BOT_MOVEV 30094
#define MENU_BOT_MOVEE 30095
#define MENU_BOT_MOVET 30096
#define MENU_BOT_MODE 30097
#define MENU_BOT_ORIENT 30098
#define MENU_BOT_THICK 30099
#define MENU_BOT_FMODE 30100
#define MENU_BOT_DELETE_TRI 30101
#define MENU_BOT_FLAGS 30102

void *
rt_solid_edit_bot_prim_edit_create(struct rt_solid_edit *UNUSED(s))
{
Expand Down
5 changes: 0 additions & 5 deletions src/librt/primitives/cline/edcline.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
#define ECMD_CLINE_SCALE_R 29079 /* scale radius */
#define ECMD_CLINE_SCALE_T 29080 /* scale thickness */

#define MENU_CLINE_SCALE_H 29107
#define MENU_CLINE_MOVE_H 29108
#define MENU_CLINE_SCALE_R 29109
#define MENU_CLINE_SCALE_T 29110

static void
cline_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNUSED(data))
{
Expand Down
24 changes: 9 additions & 15 deletions src/librt/primitives/dsp/eddsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,28 @@
#define ECMD_DSP_SCALE_Y 25059 /* Scale DSP y size */
#define ECMD_DSP_SCALE_ALT 25060 /* Scale DSP Altitude size */

#define MENU_DSP_FNAME 25083
#define MENU_DSP_FSIZE 25084 /* Not implemented yet */
#define MENU_DSP_SCALE_X 25085
#define MENU_DSP_SCALE_Y 25086
#define MENU_DSP_SCALE_ALT 25087

static void
dsp_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNUSED(data))
{
s->edit_menu = arg;
rt_solid_edit_set_edflag(s, -1);

switch (arg) {
case MENU_DSP_FNAME:
case ECMD_DSP_FNAME:
s->edit_flag = ECMD_DSP_FNAME;
break;
case MENU_DSP_FSIZE:
case ECMD_DSP_FSIZE:
s->edit_flag = ECMD_DSP_FSIZE; // Unimplemented. Expects 2 parameters
break;
case MENU_DSP_SCALE_X:
case ECMD_DSP_SCALE_X:
s->edit_flag = ECMD_DSP_SCALE_X;
s->solid_edit_scale = 1;
break;
case MENU_DSP_SCALE_Y:
case ECMD_DSP_SCALE_Y:
s->edit_flag = ECMD_DSP_SCALE_Y;
s->solid_edit_scale = 1;
break;
case MENU_DSP_SCALE_ALT:
case ECMD_DSP_SCALE_ALT:
s->edit_flag = ECMD_DSP_SCALE_ALT;
s->solid_edit_scale = 1;
break;
Expand All @@ -85,10 +79,10 @@ dsp_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNU
}
struct rt_solid_edit_menu_item dsp_menu[] = {
{"DSP MENU", NULL, 0 },
{"Name", dsp_ed, MENU_DSP_FNAME },
{"Set X", dsp_ed, MENU_DSP_SCALE_X },
{"Set Y", dsp_ed, MENU_DSP_SCALE_Y },
{"Set ALT", dsp_ed, MENU_DSP_SCALE_ALT },
{"Name", dsp_ed, ECMD_DSP_FNAME },
{"Set X", dsp_ed, ECMD_DSP_SCALE_X },
{"Set Y", dsp_ed, ECMD_DSP_SCALE_Y },
{"Set ALT", dsp_ed, ECMD_DSP_SCALE_ALT },
{ "", NULL, 0 }
};

Expand Down
16 changes: 6 additions & 10 deletions src/librt/primitives/ebm/edebm.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,20 @@
#define ECMD_EBM_FSIZE 12054 /* set EBM file size */
#define ECMD_EBM_HEIGHT 12055 /* set EBM extrusion depth */

#define MENU_EBM_FNAME 12080
#define MENU_EBM_FSIZE 12081
#define MENU_EBM_HEIGHT 12082

static void
ebm_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNUSED(data))
{
s->edit_menu = arg;
rt_solid_edit_set_edflag(s, -1);

switch (arg) {
case MENU_EBM_FNAME:
case ECMD_EBM_FNAME:
s->edit_flag = ECMD_EBM_FNAME;
break;
case MENU_EBM_FSIZE:
case ECMD_EBM_FSIZE:
s->edit_flag = ECMD_EBM_FSIZE;
break;
case MENU_EBM_HEIGHT:
case ECMD_EBM_HEIGHT:
s->edit_flag = ECMD_EBM_HEIGHT;
s->solid_edit_scale = 1;
break;
Expand All @@ -73,9 +69,9 @@ ebm_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNU
}
struct rt_solid_edit_menu_item ebm_menu[] = {
{"EBM MENU", NULL, 0 },
{"File Name", ebm_ed, MENU_EBM_FNAME },
{"File Size (W N)", ebm_ed, MENU_EBM_FSIZE },
{"Extrude Depth", ebm_ed, MENU_EBM_HEIGHT },
{"File Name", ebm_ed, ECMD_EBM_FNAME },
{"File Size (W N)", ebm_ed, ECMD_EBM_FSIZE },
{"Extrude Depth", ebm_ed, ECMD_EBM_HEIGHT },
{ "", NULL, 0 }
};

Expand Down
40 changes: 20 additions & 20 deletions src/librt/primitives/ehy/edehy.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

#include "../edit_private.h"

#define MENU_EHY_H 20053
#define MENU_EHY_R1 20054
#define MENU_EHY_R2 20055
#define MENU_EHY_C 20056
#define ECMD_EHY_H 20053
#define ECMD_EHY_R1 20054
#define ECMD_EHY_R2 20055
#define ECMD_EHY_C 20056

static void
ehy_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNUSED(data))
Expand All @@ -54,10 +54,10 @@ ehy_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNU
}
struct rt_solid_edit_menu_item ehy_menu[] = {
{ "EHY MENU", NULL, 0 },
{ "Set H", ehy_ed, MENU_EHY_H },
{ "Set A", ehy_ed, MENU_EHY_R1 },
{ "Set B", ehy_ed, MENU_EHY_R2 },
{ "Set c", ehy_ed, MENU_EHY_C },
{ "Set H", ehy_ed, ECMD_EHY_H },
{ "Set A", ehy_ed, ECMD_EHY_R1 },
{ "Set B", ehy_ed, ECMD_EHY_R2 },
{ "Set c", ehy_ed, ECMD_EHY_C },
{ "", NULL, 0 }
};

Expand Down Expand Up @@ -178,7 +178,7 @@ rt_solid_edit_ehy_read_params(

/* scale height vector H */
void
menu_ehy_h(struct rt_solid_edit *s)
ecmd_ehy_h(struct rt_solid_edit *s)
{
struct rt_ehy_internal *ehy =
(struct rt_ehy_internal *)s->es_int.idb_ptr;
Expand All @@ -194,7 +194,7 @@ menu_ehy_h(struct rt_solid_edit *s)

/* scale semimajor axis of EHY */
void
menu_ehy_r1(struct rt_solid_edit *s)
ecmd_ehy_r1(struct rt_solid_edit *s)
{
struct rt_ehy_internal *ehy =
(struct rt_ehy_internal *)s->es_int.idb_ptr;
Expand All @@ -213,7 +213,7 @@ menu_ehy_r1(struct rt_solid_edit *s)

/* scale semiminor axis of EHY */
void
menu_ehy_r2(struct rt_solid_edit *s)
ecmd_ehy_r2(struct rt_solid_edit *s)
{
struct rt_ehy_internal *ehy =
(struct rt_ehy_internal *)s->es_int.idb_ptr;
Expand All @@ -232,7 +232,7 @@ menu_ehy_r2(struct rt_solid_edit *s)

/* scale distance between apex of EHY & asymptotic cone */
void
menu_ehy_c(struct rt_solid_edit *s)
ecmd_ehy_c(struct rt_solid_edit *s)
{
struct rt_ehy_internal *ehy =
(struct rt_ehy_internal *)s->es_int.idb_ptr;
Expand Down Expand Up @@ -267,17 +267,17 @@ rt_solid_edit_ehy_pscale(struct rt_solid_edit *s, int mode)
s->e_para[2] *= s->local2base;

switch (mode) {
case MENU_EHY_H:
menu_ehy_h(s);
case ECMD_EHY_H:
ecmd_ehy_h(s);
break;
case MENU_EHY_R1:
menu_ehy_r1(s);
case ECMD_EHY_R1:
ecmd_ehy_r1(s);
break;
case MENU_EHY_R2:
menu_ehy_r2(s);
case ECMD_EHY_R2:
ecmd_ehy_r2(s);
break;
case MENU_EHY_C:
menu_ehy_c(s);
case ECMD_EHY_C:
ecmd_ehy_c(s);
break;
};

Expand Down
40 changes: 20 additions & 20 deletions src/librt/primitives/ell/edell.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

#include "../edit_private.h"

#define MENU_ELL_SCALE_A 3039
#define MENU_ELL_SCALE_B 3040
#define MENU_ELL_SCALE_C 3041
#define MENU_ELL_SCALE_ABC 3042
#define ECMD_ELL_SCALE_A 3039
#define ECMD_ELL_SCALE_B 3040
#define ECMD_ELL_SCALE_C 3041
#define ECMD_ELL_SCALE_ABC 3042

static void
ell_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNUSED(data))
Expand All @@ -54,10 +54,10 @@ ell_ed(struct rt_solid_edit *s, int arg, int UNUSED(a), int UNUSED(b), void *UNU
}
struct rt_solid_edit_menu_item ell_menu[] = {
{ "ELLIPSOID MENU", NULL, 0 },
{ "Set A", ell_ed, MENU_ELL_SCALE_A },
{ "Set B", ell_ed, MENU_ELL_SCALE_B },
{ "Set C", ell_ed, MENU_ELL_SCALE_C },
{ "Set A,B,C", ell_ed, MENU_ELL_SCALE_ABC },
{ "Set A", ell_ed, ECMD_ELL_SCALE_A },
{ "Set B", ell_ed, ECMD_ELL_SCALE_B },
{ "Set C", ell_ed, ECMD_ELL_SCALE_C },
{ "Set A,B,C", ell_ed, ECMD_ELL_SCALE_ABC },
{ "", NULL, 0 }
};

Expand Down Expand Up @@ -165,7 +165,7 @@ rt_solid_edit_ell_read_params(

/* scale vector A */
void
menu_ell_scale_a(struct rt_solid_edit *s)
ecmd_ell_scale_a(struct rt_solid_edit *s)
{
struct rt_ell_internal *ell =
(struct rt_ell_internal *)s->es_int.idb_ptr;
Expand All @@ -180,7 +180,7 @@ menu_ell_scale_a(struct rt_solid_edit *s)

/* scale vector B */
void
menu_ell_scale_b(struct rt_solid_edit *s)
ecmd_ell_scale_b(struct rt_solid_edit *s)
{
struct rt_ell_internal *ell =
(struct rt_ell_internal *)s->es_int.idb_ptr;
Expand All @@ -195,7 +195,7 @@ menu_ell_scale_b(struct rt_solid_edit *s)

/* scale vector C */
void
menu_ell_scale_c(struct rt_solid_edit *s)
ecmd_ell_scale_c(struct rt_solid_edit *s)
{
struct rt_ell_internal *ell =
(struct rt_ell_internal *)s->es_int.idb_ptr;
Expand All @@ -210,7 +210,7 @@ menu_ell_scale_c(struct rt_solid_edit *s)

/* set A, B, and C length the same */
void
menu_ell_scale_abc(struct rt_solid_edit *s)
ecmd_ell_scale_abc(struct rt_solid_edit *s)
{
fastf_t ma, mb;
struct rt_ell_internal *ell =
Expand Down Expand Up @@ -250,17 +250,17 @@ rt_solid_edit_ell_pscale(struct rt_solid_edit *s, int mode)
s->e_para[2] *= s->local2base;

switch (mode) {
case MENU_ELL_SCALE_A:
menu_ell_scale_a(s);
case ECMD_ELL_SCALE_A:
ecmd_ell_scale_a(s);
break;
case MENU_ELL_SCALE_B:
menu_ell_scale_b(s);
case ECMD_ELL_SCALE_B:
ecmd_ell_scale_b(s);
break;
case MENU_ELL_SCALE_C:
menu_ell_scale_c(s);
case ECMD_ELL_SCALE_C:
ecmd_ell_scale_c(s);
break;
case MENU_ELL_SCALE_ABC:
menu_ell_scale_abc(s);
case ECMD_ELL_SCALE_ABC:
ecmd_ell_scale_abc(s);
break;
};

Expand Down
Loading

0 comments on commit c2ecc2a

Please sign in to comment.