BRL-CAD
illum.c
Go to the documentation of this file.
1 /* I L L U M . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libged/illum.c
21  *
22  * The illum command.
23  *
24  */
25 
26 #include "common.h"
27 #include <string.h>
28 
29 #include "ged.h"
30 #include "./ged_private.h"
31 
32 
33 /*
34  * Illuminate/highlight database object
35  *
36  * Usage:
37  * illum [-n] obj
38  *
39  */
40 int
41 ged_illum(struct ged *gedp, int argc, const char *argv[])
42 {
43  struct display_list *gdlp;
44  struct display_list *next_gdlp;
45  int found = 0;
46  int illum = 1;
47  static const char *usage = "[-n] obj";
48 
51  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
52 
53  /* initialize result */
54  bu_vls_trunc(gedp->ged_result_str, 0);
55 
56  /* must be wanting help */
57  if (argc == 1) {
58  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
59  return GED_HELP;
60  }
61 
62  if (argc == 3) {
63  if (argv[1][0] == '-' && argv[1][1] == 'n')
64  illum = 0;
65  else
66  goto bad;
67 
68  --argc;
69  ++argv;
70  }
71 
72  if (argc != 2)
73  goto bad;
74 
76  while (BU_LIST_NOT_HEAD(gdlp, gedp->ged_gdp->gd_headDisplay)) {
77  next_gdlp = BU_LIST_PNEXT(display_list, gdlp);
78 
79  found += dl_set_illum(gdlp, argv[1], illum);
80 
81  gdlp = next_gdlp;
82  }
83 
84 
85  if (!found) {
86  bu_vls_printf(gedp->ged_result_str, "illum: %s not found", argv[1]);
87  return GED_ERROR;
88  }
89 
90  return GED_OK;
91 
92 bad:
93  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
94  return GED_ERROR;
95 }
96 
97 
98 /*
99  * Local Variables:
100  * tab-width: 8
101  * mode: C
102  * indent-tabs-mode: t
103  * c-file-style: "stroustrup"
104  * End:
105  * ex: shiftwidth=4 tabstop=8
106  */
void usage(struct ged *gedp)
Definition: coil.c:315
#define GED_OK
Definition: ged.h:55
Definition: ged.h:338
void bu_vls_trunc(struct bu_vls *vp, int len)
Definition: vls.c:198
#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _flags)
Definition: ged.h:202
Header file for the BRL-CAD common definitions.
struct bu_list * gd_headDisplay
head of display list
Definition: ged.h:307
#define GED_ERROR
Definition: ged.h:61
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
#define BU_LIST_PNEXT(structure, p)
Definition: list.h:422
#define GED_CHECK_DRAWABLE(_gedp, _flags)
Definition: ged.h:129
int ged_illum(struct ged *gedp, int argc, const char *argv[])
Definition: illum.c:41
struct bu_vls * ged_result_str
Definition: ged.h:357
struct ged_drawable * ged_gdp
Definition: ged.h:360
int dl_set_illum(struct display_list *gdlp, const char *obj, int illum)
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
#define GED_HELP
Definition: ged.h:62
#define BU_LIST_NEXT(structure, hp)
Definition: list.h:316
#define BU_LIST_NOT_HEAD(p, hp)
Definition: list.h:324