BRL-CAD
set_transparency.c
Go to the documentation of this file.
1 /* S E T _ T R A N S P A R E N C Y . 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/set_transparency.c
21  *
22  * The set_transparency command.
23  *
24  */
25 
26 #include "common.h"
27 
28 
29 
30 
31 #include "./ged_private.h"
32 
33 
34 /*
35  * Set the transparency of the specified object
36  *
37  * Usage:
38  * set_transparency obj tr
39  *
40  */
41 int
42 ged_set_transparency(struct ged *gedp, int argc, const char *argv[])
43 {
44  struct directory **dpp;
45 
46  /* intentionally double for scan */
47  double transparency;
48 
49  static const char *usage = "node tval";
50 
53  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
54 
55  /* initialize result */
56  bu_vls_trunc(gedp->ged_result_str, 0);
57 
58  /* must be wanting help */
59  if (argc == 1) {
60  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
61  return GED_ERROR;
62  }
63 
64 
65  if (argc != 3) {
66  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
67  return GED_ERROR;
68  }
69 
70  if (sscanf(argv[2], "%lf", &transparency) != 1) {
71  bu_vls_printf(gedp->ged_result_str, "dgo_set_transparency: bad transparency - %s\n", argv[2]);
72  return GED_ERROR;
73  }
74 
75  if ((dpp = _ged_build_dpp(gedp, argv[1])) == NULL) {
76  return GED_OK;
77  }
78 
79  dl_set_transparency(gedp->ged_gdp->gd_headDisplay, dpp, transparency, gedp->ged_create_vlist_callback);
80 
81  if (dpp != (struct directory **)NULL)
82  bu_free((void *)dpp, "ged_set_transparency: directory pointers");
83 
84  return GED_OK;
85 }
86 
87 
88 /*
89  * Local Variables:
90  * tab-width: 8
91  * mode: C
92  * indent-tabs-mode: t
93  * c-file-style: "stroustrup"
94  * End:
95  * ex: shiftwidth=4 tabstop=8
96  */
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.
void dl_set_transparency(struct bu_list *hdlp, struct directory **dpp, double transparency, void(*callback)(struct display_list *))
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
void(* ged_create_vlist_callback)(struct display_list *)
function to call after creating a vlist
Definition: ged.h:370
#define GED_CHECK_DRAWABLE(_gedp, _flags)
Definition: ged.h:129
struct bu_vls * ged_result_str
Definition: ged.h:357
struct directory ** _ged_build_dpp(struct ged *gedp, const char *path)
Definition: how.c:96
struct ged_drawable * ged_gdp
Definition: ged.h:360
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
int ged_set_transparency(struct ged *gedp, int argc, const char *argv[])
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328