Skip to content

Commit 6cfba6d

Browse files
committed
Set a variable up front to improve readability
1 parent 4b0ebde commit 6cfba6d

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

src/mged/doevent.c

+13-24
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
158158
fastf_t f;
159159
fastf_t fx, fy;
160160
fastf_t td;
161+
int edit_mode = ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) && mged_variables->mv_transform == 'e') ? 1 : 0;
161162

162163
if (s->dbip == DBI_NULL)
163164
return;
@@ -219,8 +220,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
219220
save_coords = mged_variables->mv_coords;
220221
mged_variables->mv_coords = 'v';
221222

222-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
223-
mged_variables->mv_transform == 'e') {
223+
if (edit_mode) {
224224

225225
if (GEOM_EDIT_STATE == ST_S_EDIT) {
226226
save_edflag = es_edflag;
@@ -263,8 +263,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
263263
fx = dx / (fastf_t)width * 2.0;
264264
fy = -dy / (fastf_t)height / dm_get_aspect(DMP) * 2.0;
265265

266-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
267-
mged_variables->mv_transform == 'e') {
266+
if (edit_mode) {
268267

269268
if (GEOM_EDIT_STATE == ST_S_EDIT) {
270269
save_edflag = es_edflag;
@@ -329,8 +328,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
329328
goto reset_edflag;
330329
}
331330
case AMM_SCALE:
332-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
333-
mged_variables->mv_transform == 'e') {
331+
if (edit_mode) {
334332
if (GEOM_EDIT_STATE == ST_S_EDIT && !SEDIT_SCALE) {
335333
save_edflag = es_edflag;
336334
es_edflag = SSCALE;
@@ -387,8 +385,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
387385

388386
break;
389387
case AMM_CON_ROT_X:
390-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
391-
mged_variables->mv_transform == 'e') {
388+
if (edit_mode) {
392389
if (GEOM_EDIT_STATE == ST_S_EDIT) {
393390
save_edflag = es_edflag;
394391
if (!SEDIT_ROTATE)
@@ -412,8 +409,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
412409

413410
break;
414411
case AMM_CON_ROT_Y:
415-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
416-
mged_variables->mv_transform == 'e') {
412+
if (edit_mode) {
417413
if (GEOM_EDIT_STATE == ST_S_EDIT) {
418414
save_edflag = es_edflag;
419415
if (!SEDIT_ROTATE)
@@ -437,8 +433,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
437433

438434
break;
439435
case AMM_CON_ROT_Z:
440-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
441-
mged_variables->mv_transform == 'e') {
436+
if (edit_mode) {
442437
if (GEOM_EDIT_STATE == ST_S_EDIT) {
443438
save_edflag = es_edflag;
444439
if (!SEDIT_ROTATE)
@@ -462,8 +457,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
462457

463458
break;
464459
case AMM_CON_TRAN_X:
465-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
466-
mged_variables->mv_transform == 'e') {
460+
if (edit_mode) {
467461
if (GEOM_EDIT_STATE == ST_S_EDIT) {
468462
save_edflag = es_edflag;
469463
if (!SEDIT_TRAN)
@@ -486,8 +480,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
486480

487481
break;
488482
case AMM_CON_TRAN_Y:
489-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
490-
mged_variables->mv_transform == 'e') {
483+
if (edit_mode) {
491484
if (GEOM_EDIT_STATE == ST_S_EDIT) {
492485
save_edflag = es_edflag;
493486
if (!SEDIT_TRAN)
@@ -510,8 +503,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
510503

511504
break;
512505
case AMM_CON_TRAN_Z:
513-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
514-
mged_variables->mv_transform == 'e') {
506+
if (edit_mode) {
515507
if (GEOM_EDIT_STATE == ST_S_EDIT) {
516508
save_edflag = es_edflag;
517509
if (!SEDIT_TRAN)
@@ -534,8 +526,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
534526

535527
break;
536528
case AMM_CON_SCALE_X:
537-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
538-
mged_variables->mv_transform == 'e') {
529+
if (edit_mode) {
539530
if (GEOM_EDIT_STATE == ST_S_EDIT) {
540531
save_edflag = es_edflag;
541532
if (!SEDIT_SCALE)
@@ -558,8 +549,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
558549

559550
break;
560551
case AMM_CON_SCALE_Y:
561-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
562-
mged_variables->mv_transform == 'e') {
552+
if (edit_mode) {
563553
if (GEOM_EDIT_STATE == ST_S_EDIT) {
564554
save_edflag = es_edflag;
565555
if (!SEDIT_SCALE)
@@ -582,8 +572,7 @@ motion_event_handler(struct mged_state *s, XMotionEvent *xmotion)
582572

583573
break;
584574
case AMM_CON_SCALE_Z:
585-
if ((GEOM_EDIT_STATE == ST_S_EDIT || GEOM_EDIT_STATE == ST_O_EDIT) &&
586-
mged_variables->mv_transform == 'e') {
575+
if (edit_mode) {
587576
if (GEOM_EDIT_STATE == ST_S_EDIT) {
588577
save_edflag = es_edflag;
589578
if (!SEDIT_SCALE)

0 commit comments

Comments
 (0)