Skip to content

Commit 8ac6b3a

Browse files
committed
Minimize use of env vars for new cmd behavior.
1 parent dc99c84 commit 8ac6b3a

Some content is hidden

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

43 files changed

+816
-832
lines changed

include/ged/defines.h

+5
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ struct ged {
332332
// bv.h gv_callback (only used by MGED?)
333333

334334
void *ged_interp; /* Temporary - do not rely on when designing new functionality */
335+
336+
// The following is used instead of environment variables to select old or new
337+
// command paths. Primarily relates to the next generation drawing setup with
338+
// view objects and the new BoT LoD logic.
339+
int new_cmd_forms;
335340
};
336341

337342
// Create and destroy a ged container. Handles all initialization - no

src/gtools/gsh/gsh.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,6 @@ Gsh_ClearScreen(int UNUSED(ac), const char **UNUSED(av), void *UNUSED(gedp), voi
331331

332332
GshState::GshState()
333333
{
334-
const char *ncmd = getenv("GED_TEST_NEW_CMD_FORMS");
335-
if (BU_STR_EQUAL(ncmd, "1"))
336-
new_cmd_forms = true;
337-
338334
BU_GET(gedp, struct ged);
339335
ged_init(gedp);
340336
BU_GET(gedp->ged_gvp, struct bview);
@@ -740,13 +736,6 @@ main(int argc, const char **argv)
740736
bu_exit(EXIT_SUCCESS, NULL);
741737
}
742738

743-
/* If we're using new (qged style) commands, set the relevant env variables.
744-
* Do this *before* we create the GshState instance. */
745-
if (new_cmd_forms) {
746-
bu_setenv("LIBGED_DBI_STATE", "1", 1);
747-
bu_setenv("GED_TEST_NEW_CMD_FORMS", "1", 1);
748-
}
749-
750739
/* If anything went wrong during LIBGED initialization, let the user know */
751740
const char *ged_init_str = ged_init_msgs();
752741
if (strlen(ged_init_str)) {
@@ -756,6 +745,16 @@ main(int argc, const char **argv)
756745
// Use a C++ class to manage info we will need
757746
std::shared_ptr<GshState> gs = std::make_shared<GshState>();
758747

748+
// If we're using the new command forms, there's a little bit
749+
// of setup to do at the moment (eventually, once this cmd
750+
// behavior is the default, ged setup will do this automatically)
751+
gs->new_cmd_forms = (new_cmd_forms) ? true : false;
752+
if (gs->new_cmd_forms) {
753+
gs->gedp->dbi_state = new DbiState(gs->gedp);
754+
gs->gedp->new_cmd_forms = 1;
755+
bu_setenv("DM_SWRAST", "1", 1);
756+
}
757+
759758
// If we're non-interactive, just evaluate and exit without getting into
760759
// linenoise and threading. First, see if we've got a viable .g file.
761760
if (argc && bu_file_exists(argv[0], NULL)) {

src/libdm/dm_plugins.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ dm_list_types(struct bu_vls *list, const char *separator)
152152
}
153153

154154
/* Report anything not included in the priority list but still available */
155-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
155+
const char *cmd2 = getenv("DM_SWRAST");
156156
int report_swrast = 0;
157157
if (BU_STR_EQUAL(cmd2, "1"))
158158
report_swrast = 1;
@@ -196,7 +196,7 @@ dm_validXType(const char *dpy_string, const char *name)
196196
return 0;
197197
}
198198

199-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
199+
const char *cmd2 = getenv("DM_SWRAST");
200200
int report_swrast = 0;
201201
if (BU_STR_EQUAL(cmd2, "1"))
202202
report_swrast = 1;

src/libged/bot/bot.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,8 @@ _bot_cmd_sync(void *bs, int argc, const char **argv)
661661
static void
662662
_bot_vlblock_plot(struct ged *gedp, struct bv_vlblock *vbp, const char *sname)
663663
{
664-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
665664
struct bview *view = gedp->ged_gvp;
666-
if (BU_STR_EQUAL(nview, "1")) {
665+
if (gedp->new_cmd_forms) {
667666
struct bu_vls nroot = BU_VLS_INIT_ZERO;
668667
bu_vls_sprintf(&nroot, "bot::%s", sname);
669668
bv_vlblock_obj(vbp, view, bu_vls_cstr(&nroot));

src/libged/bot/bot_fuse.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ show_dangling_edges(struct ged *gedp, const uint32_t *magic_p, const char *name,
127127

128128
if (out_type == 1) {
129129
/* Add overlay */
130-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
131-
if (BU_STR_EQUAL(nview, "1")) {
130+
if (gedp->new_cmd_forms) {
132131
struct bu_vls nroot = BU_VLS_INIT_ZERO;
133132
bu_vls_sprintf(&nroot, "bot_fuse::%s", name);
134133
struct bview *view = gedp->ged_gvp;

src/libged/bot/check.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ draw_edges(struct ged *gedp, struct rt_bot_internal *bot, int num_edges, int edg
278278
BV_ADD_VLIST(vbp->free_vlist_hd, vhead, b, BV_VLIST_LINE_DRAW);
279279
}
280280

281-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
282-
if (BU_STR_EQUAL(nview, "1")) {
281+
if (gedp->new_cmd_forms) {
283282
struct bu_vls nroot = BU_VLS_INIT_ZERO;
284283
bu_vls_sprintf(&nroot, "bot_check::%s", draw_name);
285284
struct bview *view = gedp->ged_gvp;

src/libged/brep/brep.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,7 @@ _brep_cmd_intersect(void *bs, int argc, const char **argv)
778778
bu_vls_printf(gedp->ged_result_str, "Invalid intersection type %s.\n", argv[6]);
779779
}
780780

781-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
782-
if (BU_STR_EQUAL(nview, "1")) {
781+
if (gedp->new_cmd_forms) {
783782
struct bview *view = gedp->ged_gvp;
784783
bv_vlblock_obj(gb->vbp, view, "brep_intersect");
785784
} else {

src/libged/brep/plot.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,8 @@ plot_nurbs_cv(struct bu_list *vlfree, struct bv_vlblock *vbp, int ucount, int vc
993993
static void
994994
_brep_vlblock_plot(struct ged *gedp, struct bv_vlblock *vbp, const char *sname)
995995
{
996-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
997996
struct bview *view = gedp->ged_gvp;
998-
if (BU_STR_EQUAL(nview, "1")) {
997+
if (gedp->new_cmd_forms) {
999998
struct bu_vls nroot = BU_VLS_INIT_ZERO;
1000999
bu_vls_sprintf(&nroot, "brep::%s", sname);
10011000
bv_vlblock_obj(vbp, view, bu_vls_cstr(&nroot));

src/libged/check/check_overlaps.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ int check_overlaps(struct ged *gedp, struct current_state *state,
341341
printOverlaps(gedp, &callbackdata, options);
342342

343343
if (options->overlaps_overlay_flag) {
344-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
345-
if (BU_STR_EQUAL(nview, "1")) {
344+
if (gedp->new_cmd_forms) {
346345
struct bview *view = gedp->ged_gvp;
347346
bv_vlblock_obj(check_plot.vbp, view, "check::overlaps");
348347
} else {

src/libged/close/close.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ ged_close_core(struct ged *gedp, int UNUSED(argc), const char **UNUSED(argv))
5757
gedp->dbip = NULL;
5858

5959
/* Clean up any old acceleration states, if present */
60-
const char *use_dbi_state = getenv("LIBGED_DBI_STATE");
61-
if (use_dbi_state && gedp->dbi_state)
60+
if (gedp->dbi_state)
6261
delete gedp->dbi_state;
6362
gedp->dbi_state = NULL;
6463
if (gedp->ged_lod)

src/libged/draw/draw.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,7 @@ extern int ged_draw2_core(struct ged *gedp, int argc, const char *argv[]);
16281628
int
16291629
ged_draw_core(struct ged *gedp, int argc, const char *argv[])
16301630
{
1631-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1632-
if (BU_STR_EQUAL(cmd2, "1"))
1631+
if (gedp->new_cmd_forms)
16331632
return ged_draw2_core(gedp, argc, argv);
16341633

16351634
return ged_draw_guts(gedp, argc, argv, _GED_DRAW_WIREFRAME);
@@ -1646,8 +1645,7 @@ extern int ged_redraw2_core(struct ged *gedp, int argc, const char *argv[]);
16461645
int
16471646
ged_redraw_core(struct ged *gedp, int argc, const char *argv[])
16481647
{
1649-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1650-
if (BU_STR_EQUAL(cmd2, "1"))
1648+
if (gedp->new_cmd_forms)
16511649
return ged_redraw2_core(gedp, argc, argv);
16521650

16531651
int ret;

src/libged/draw/preview.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ ged_preview_core(struct ged *gedp, int argc, const char *argv[])
425425
fp = NULL;
426426

427427
if (draw_eye_path) {
428-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
429-
if (BU_STR_EQUAL(nview, "1")) {
428+
if (gedp->new_cmd_forms) {
430429
struct bview *view = gedp->ged_gvp;
431430
bv_vlblock_obj(preview_vbp, view, "preview::eye_path");
432431
} else {

src/libged/edit/edit.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1972,8 +1972,7 @@ extern int ged_edit2_core(struct ged *gedp, int argc, const char *argv[]);
19721972
int
19731973
ged_edit_core(struct ged *gedp, int argc, const char *argv[])
19741974
{
1975-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1976-
if (BU_STR_EQUAL(cmd2, "1"))
1975+
if (gedp->new_cmd_forms)
19771976
return ged_edit2_core(gedp, argc, argv);
19781977

19791978
const char *const cmd_name = argv[0];

src/libged/erase/erase.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ extern int ged_erase2_core(struct ged *gedp, int argc, const char **argv);
3939
int
4040
ged_erase_core(struct ged *gedp, int argc, const char *argv[])
4141
{
42-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
43-
if (BU_STR_EQUAL(cmd2, "1"))
42+
if (gedp->new_cmd_forms)
4443
return ged_erase2_core(gedp, argc, argv);
4544

4645
size_t i;

src/libged/garbage_collect/garbage_collect.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ extern "C" int
5959
ged_garbage_collect_core(struct ged *gedp, int argc, const char *argv[])
6060
{
6161
const char *av[10] = {NULL};
62-
const char *ncmd = NULL;
6362
fastf_t fs_percent = 0.0;
6463
int confirmed = 0;
6564
int new_file_size = 0;
@@ -154,8 +153,7 @@ ged_garbage_collect_core(struct ged *gedp, int argc, const char *argv[])
154153
* views to their original state when we open the garbage collected
155154
* database. Save the who list. (TODO - do we need to save views? Or
156155
* will drawing without resize work?) */
157-
ncmd = getenv("GED_TEST_NEW_CMD_FORMS");
158-
if (BU_STR_EQUAL(ncmd, "1")) {
156+
if (gedp->new_cmd_forms) {
159157
BViewState *bvs = gedp->dbi_state->get_view_state(gedp->ged_gvp);
160158
std::vector<std::string> wpaths = bvs->list_drawn_paths(-1, false);
161159
for (size_t i = 0; i < wpaths.size(); i++) {

src/libged/gdiff/gdiff.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@ ged_gdiff_core(struct ged *gedp, int argc, const char *argv[])
414414
}
415415
}
416416

417-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
418-
if (BU_STR_EQUAL(nview, "1")) {
417+
if (gedp->new_cmd_forms) {
419418
struct bview *view = gedp->ged_gvp;
420419
bv_vlblock_obj(vbp, view, "gdiff");
421420
} else {

src/libged/ged.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ ged_init(struct ged *gedp)
165165
gedp->dbi_state = NULL;
166166

167167
gedp->ged_interp = NULL;
168+
169+
gedp->new_cmd_forms = 0;
168170
}
169171

170172
struct ged *
@@ -369,13 +371,6 @@ ged_open(const char *dbtype, const char *filename, int existing_only)
369371

370372
gedp->ged_lod = bv_mesh_lod_context_create(filename);
371373

372-
const char *use_dbi_state = getenv("LIBGED_DBI_STATE");
373-
if (use_dbi_state) {
374-
gedp->dbi_state = new DbiState(gedp);
375-
} else {
376-
gedp->dbi_state = NULL;
377-
}
378-
379374
return gedp;
380375
}
381376

src/libged/ged_util.cpp

+13-16
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,7 @@ ged_scale_args(struct ged *gedp, int argc, const char *argv[], fastf_t *sf1, fas
10641064
size_t
10651065
ged_who_argc(struct ged *gedp)
10661066
{
1067-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1068-
if (BU_STR_EQUAL(cmd2, "1")) {
1067+
if (gedp->new_cmd_forms) {
10691068
if (!gedp || !gedp->ged_gvp || !gedp->dbi_state)
10701069
return 0;
10711070
BViewState *bvs = gedp->dbi_state->get_view_state(gedp->ged_gvp);
@@ -1100,9 +1099,10 @@ int
11001099
ged_who_argv(struct ged *gedp, char **start, const char **end)
11011100
{
11021101
char **vp = start;
1103-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1104-
if (BU_STR_EQUAL(cmd2, "1")) {
1105-
if (!gedp || !gedp->ged_gvp || !gedp->dbi_state)
1102+
if (!gedp)
1103+
return 0;
1104+
if (gedp->new_cmd_forms) {
1105+
if (!gedp->ged_gvp || !gedp->dbi_state)
11061106
return 0;
11071107
BViewState *bvs = gedp->dbi_state->get_view_state(gedp->ged_gvp);
11081108
if (bvs) {
@@ -1427,8 +1427,7 @@ _ged_rt_set_eye_model(struct ged *gedp,
14271427
extremum[1][i] = -INFINITY;
14281428
}
14291429

1430-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1431-
if (BU_STR_EQUAL(cmd2, "1")) {
1430+
if (gedp->new_cmd_forms) {
14321431
VSETALL(extremum[0], INFINITY);
14331432
VSETALL(extremum[1], -INFINITY);
14341433
struct bu_ptbl *db_objs = bv_view_objs(gedp->ged_gvp, BV_DB_OBJS);
@@ -1578,16 +1577,16 @@ ged_rt_output_handler_helper(struct ged_subprocess* rrtp, bu_process_io_t type)
15781577
void
15791578
_ged_rt_output_handler(void *clientData, int mask)
15801579
{
1581-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1582-
if (BU_STR_EQUAL(cmd2, "1")) {
1583-
_ged_rt_output_handler2(clientData, mask);
1584-
return;
1585-
}
15861580
struct ged_subprocess *rrtp = (struct ged_subprocess *)clientData;
1587-
15881581
if ((rrtp == (struct ged_subprocess *)NULL) || (rrtp->gedp == (struct ged *)NULL))
15891582
return;
15901583

1584+
struct ged *gedp = rrtp->gedp;
1585+
if (gedp->new_cmd_forms) {
1586+
_ged_rt_output_handler2(clientData, mask);
1587+
return;
1588+
}
1589+
15911590
BU_CKMAG(rrtp, GED_CMD_MAGIC, "ged subprocess");
15921591

15931592
/* Get data from rt */
@@ -1597,7 +1596,6 @@ _ged_rt_output_handler(void *clientData, int mask)
15971596
return;
15981597

15991598
int retcode = 0;
1600-
struct ged *gedp = rrtp->gedp;
16011599

16021600
/* Either EOF has been sent or there was a read error.
16031601
* there is no need to block indefinitely */
@@ -1721,8 +1719,7 @@ _ged_rt_write(struct ged *gedp,
17211719
* remove the -1 case.) */
17221720
if (argc >= 0) {
17231721
if (!argc) {
1724-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
1725-
if (BU_STR_EQUAL(cmd2, "1")) {
1722+
if (gedp->new_cmd_forms) {
17261723
BViewState *bvs = gedp->dbi_state->get_view_state(gedp->ged_gvp);
17271724
if (bvs) {
17281725
std::vector<std::string> drawn_paths = bvs->list_drawn_paths(-1, true);

src/libged/gqa/gqa.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2722,8 +2722,7 @@ ged_gqa_core(struct ged *gedp, int argc, const char *argv[])
27222722
summary_reports(gedp, &state);
27232723

27242724
if (analysis_flags & ANALYSIS_PLOT_OVERLAPS) {
2725-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
2726-
if (BU_STR_EQUAL(nview, "1")) {
2725+
if (gedp->new_cmd_forms) {
27272726
struct bview *view = gedp->ged_gvp;
27282727
bv_vlblock_obj(ged_gqa_plot.vbp, view, "gqa::overlaps");
27292728
} else {

src/libged/joint/joint.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ joint_mesh(struct ged *gedp, int argc, const char *argv[])
295295
}
296296
}
297297

298-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
299-
if (BU_STR_EQUAL(nview, "1")) {
298+
if (gedp->new_cmd_forms) {
300299
struct bview *view = gedp->ged_gvp;
301300
bv_vlblock_obj(vbp, view, "joint");
302301
} else {

src/libged/lint/lint.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,8 @@ ged_lint_core(struct ged *gedp, int argc, const char *argv[])
347347
}
348348

349349
if (visualize) {
350-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
351350
struct bview *view = gedp->ged_gvp;
352-
if (BU_STR_EQUAL(nview, "1")) {
351+
if (gedp->new_cmd_forms) {
353352
bv_vlblock_obj(ldata.vbp, view, "lint_visual");
354353
} else {
355354
_ged_cvt_vlblock_to_solids(gedp, ldata.vbp, "lint_visual", 0);

src/libged/lod/lod.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ extern int ged_lod2_core(struct ged *gedp, int argc, const char *argv[]);
3737
int
3838
ged_lod_core(struct ged *gedp, int argc, const char *argv[])
3939
{
40-
const char *cmd2 = getenv("GED_TEST_NEW_CMD_FORMS");
41-
if (BU_STR_EQUAL(cmd2, "1"))
40+
if (gedp->new_cmd_forms)
4241
return ged_lod2_core(gedp, argc, argv);
4342

4443
struct bview *gvp;

src/libged/nirt/nirt.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ ged_nirt_core(struct ged *gedp, int argc, const char *argv[])
391391
qray_data_to_vlist(gedp, vbp, &HeadQRayData, dir, 0);
392392
bu_list_free(&HeadQRayData.l);
393393

394-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
395-
if (BU_STR_EQUAL(nview, "1")) {
394+
if (gedp->new_cmd_forms) {
396395
struct bview *view = gedp->ged_gvp;
397396
bv_vlblock_obj(vbp, view, "nirt");
398397
} else {

src/libged/open/open.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ ged_opendb_core(struct ged *gedp, int argc, const char *argv[])
141141
gedp->ged_lod = bv_mesh_lod_context_create(argv[0]);
142142

143143
// If enabled, set up the DbiState container for fast structure access
144-
const char *use_dbi_state = getenv("LIBGED_DBI_STATE");
145-
if (use_dbi_state)
144+
if (gedp->new_cmd_forms)
146145
gedp->dbi_state = new DbiState(gedp);
147146

148147
// Set the view units, if we have a view

src/libged/overlay/overlay.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ ged_overlay_core(struct ged *gedp, int argc, const char *argv[])
234234
}
235235
}
236236

237-
const char *nview = getenv("GED_TEST_NEW_CMD_FORMS");
238-
if (BU_STR_EQUAL(nview, "1")) {
237+
if (gedp->new_cmd_forms) {
239238
struct bview *v = gedp->ged_gvp;
240239
bv_vlblock_obj(vbp, v, bu_vls_cstr(&nroot));
241240
} else {

0 commit comments

Comments
 (0)