BRL-CAD
rect.c
Go to the documentation of this file.
1 /* R E C T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1998-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This program 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 program 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 libdm/rect.c
21  *
22  * Rubber band rectangle.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <math.h>
29 
30 #include "vmath.h"
31 #include "dm.h"
32 #include "dm_private.h"
33 
34 void
36 {
37  if (ZERO(grsp->width) &&
38  ZERO(grsp->height))
39  return;
40 
41  /* draw rectangle */
42  dm_set_fg(dmp,
43  (unsigned char)grsp->color[0],
44  (unsigned char)grsp->color[1],
45  (unsigned char)grsp->color[2], 1, 1.0);
46  dm_set_line_attr(dmp, grsp->line_width, grsp->line_style);
47 
48  dm_draw_line_2d(dmp,
49  grsp->x,
50  grsp->y * dmp->dm_aspect,
51  grsp->x,
52  (grsp->y + grsp->height) * dmp->dm_aspect);
53  dm_draw_line_2d(dmp,
54  grsp->x,
55  (grsp->y + grsp->height) * dmp->dm_aspect,
56  grsp->x + grsp->width,
57  (grsp->y + grsp->height) * dmp->dm_aspect);
58  dm_draw_line_2d(dmp,
59  grsp->x + grsp->width,
60  (grsp->y + grsp->height) * dmp->dm_aspect,
61  grsp->x + grsp->width,
62  grsp->y * dmp->dm_aspect);
63  dm_draw_line_2d(dmp,
64  grsp->x + grsp->width,
65  grsp->y * dmp->dm_aspect,
66  grsp->x,
67  grsp->y * dmp->dm_aspect);
68 }
69 
70 
71 /*
72  * Local Variables:
73  * mode: C
74  * tab-width: 8
75  * indent-tabs-mode: t
76  * c-file-style: "stroustrup"
77  * End:
78  * ex: shiftwidth=4 tabstop=8
79  */
Header file for the BRL-CAD common definitions.
fastf_t dm_aspect
Definition: dm_private.h:97
int dm_set_fg(dm *dmp, unsigned char r, unsigned char g, unsigned char b, int strict, fastf_t transparency)
Definition: dm-generic.c:441
#define ZERO(val)
Definition: units.c:38
void dm_draw_rect(dm *dmp, struct bview_interactive_rect_state *grsp)
Definition: rect.c:35
int dm_set_line_attr(dm *dmp, int width, int style)
Definition: dm-generic.c:617
int dm_draw_line_2d(dm *dmp, fastf_t x1, fastf_t y1_2d, fastf_t x2, fastf_t y2)
Definition: dm-generic.c:741