BRL-CAD
view.c
Go to the documentation of this file.
1 /* V I E W . 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/view.c
21  *
22  * The view command.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <stdlib.h>
29 #include <ctype.h>
30 #include <string.h>
31 
32 #include "./ged_private.h"
33 
34 
35 int
36 ged_view_func(struct ged *gedp, int argc, const char *argv[])
37 {
38  static const char *usage = "quat|ypr|aet|center|eye|size [args]";
39 
42  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
43 
44  /* initialize result */
45  bu_vls_trunc(gedp->ged_result_str, 0);
46 
47  /* must be wanting help */
48  if (argc == 1) {
49  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
50  return GED_ERROR;
51  }
52 
53  if (6 < argc) {
54  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
55  return GED_ERROR;
56  }
57 
58  if (BU_STR_EQUAL(argv[1], "quat")) {
59  return ged_quat(gedp, argc-1, argv+1);
60  }
61 
62  if (BU_STR_EQUAL(argv[1], "ypr")) {
63  return ged_ypr(gedp, argc-1, argv+1);
64  }
65 
66  if (BU_STR_EQUAL(argv[1], "aet")) {
67  return ged_aet(gedp, argc-1, argv+1);
68  }
69 
70  if (BU_STR_EQUAL(argv[1], "center")) {
71  return ged_center(gedp, argc-1, argv+1);
72  }
73 
74  if (BU_STR_EQUAL(argv[1], "eye")) {
75  return ged_eye(gedp, argc-1, argv+1);
76  }
77 
78  if (BU_STR_EQUAL(argv[1], "size")) {
79  return ged_size(gedp, argc-1, argv+1);
80  }
81 
82  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
83  return GED_ERROR;
84 }
85 
86 
87 /*
88  * Local Variables:
89  * tab-width: 8
90  * mode: C
91  * indent-tabs-mode: t
92  * c-file-style: "stroustrup"
93  * End:
94  * ex: shiftwidth=4 tabstop=8
95  */
void usage(struct ged *gedp)
Definition: coil.c:315
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.
int ged_eye(struct ged *gedp, int argc, const char *argv[])
Definition: eye.c:36
#define GED_ERROR
Definition: ged.h:61
int ged_center(struct ged *gedp, int argc, const char *argv[])
Definition: center.c:36
#define GED_CHECK_VIEW(_gedp, _flags)
Definition: ged.h:140
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
int ged_ypr(struct ged *gedp, int argc, const char *argv[])
Definition: ypr.c:35
int ged_size(struct ged *gedp, int argc, const char *argv[])
Definition: size.c:36
int ged_aet(struct ged *gedp, int argc, const char *argv[])
Definition: aet.c:36
struct bu_vls * ged_result_str
Definition: ged.h:357
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
int ged_quat(struct ged *gedp, int argc, const char *argv[])
Definition: quat.c:36
int ged_view_func(struct ged *gedp, int argc, const char *argv[])
Definition: view.c:36
#define BU_STR_EQUAL(s1, s2)
Definition: str.h:126