BRL-CAD
fb_util.c
Go to the documentation of this file.
1 /* F B _ U T I L . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1990-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 /** @addtogroup fb */
21 /** @{ */
22 /** @file fb_util.c
23  *
24  * Subroutines to simulate device specific functions for simple
25  * device interfaces to use, and backward compatibility routines.
26  *
27  */
28 /** @} */
29 
30 #include "common.h"
31 
32 #include <stdio.h>
33 
34 #include "fb_private.h"
35 #include "fb.h"
36 
37 
38 /*
39  * A routine to simulate the effect of fb_view() by simply
40  * storing this information into the fb structure.
41  */
42 int
43 fb_sim_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
44 {
45  FB_CK_FB(ifp);
46 
47  ifp->if_xcenter = xcenter;
48  ifp->if_ycenter = ycenter;
49  ifp->if_xzoom = xzoom;
50  ifp->if_yzoom = yzoom;
51 
52  return 0;
53 }
54 
55 
56 /*
57  * A routine to simulate the effect of fb_getview() by simply
58  * reading this information from the fb structure.
59  */
60 int
61 fb_sim_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
62 {
63  FB_CK_FB(ifp);
64 
65  *xcenter = ifp->if_xcenter;
66  *ycenter = ifp->if_ycenter;
67  *xzoom = ifp->if_xzoom;
68  *yzoom = ifp->if_yzoom;
69 
70  return 0;
71 }
72 
73 
74 /*
75  * A routine to simulate the effect of fb_cursor() by simply
76  * storing this information into the fb structure.
77  */
78 int
79 fb_sim_cursor(fb *ifp, int mode, int x, int y)
80 {
81  FB_CK_FB(ifp);
82 
83  ifp->if_cursmode = mode;
84  ifp->if_xcurs = x;
85  ifp->if_ycurs = y;
86 
87  return 0;
88 }
89 
90 
91 /*
92  * A routine to simulate the effect of fb_getcursor() by simply
93  * reading this information from the fb structure.
94  */
95 int
96 fb_sim_getcursor(fb *ifp, int *mode, int *x, int *y)
97 {
98  FB_CK_FB(ifp);
99 
100  *mode = ifp->if_cursmode;
101  *x = ifp->if_xcurs;
102  *y = ifp->if_ycurs;
103 
104  return 0;
105 }
106 
107 
108 /* Backward Compatibility Routines */
109 
110 int
112 {
113  if (ifp) {
114  FB_CK_FB(ifp);
115  }
116 
117  return 0;
118 }
119 
120 
121 int
122 fb_viewport(fb *ifp, int UNUSED(left), int UNUSED(top), int UNUSED(right), int UNUSED(bottom))
123 {
124  if (ifp) {
125  FB_CK_FB(ifp);
126  }
127 
128  return 0;
129 }
130 
131 
132 int
133 fb_window(fb *ifp, int x, int y)
134 {
135  int xcenter, ycenter;
136  int xzoom, yzoom;
137 
138  if (ifp) {
139  FB_CK_FB(ifp);
140  fb_getview(ifp, &xcenter, &ycenter, &xzoom, &yzoom);
141  xcenter = x;
142  ycenter = y;
143  return fb_view(ifp, xcenter, ycenter, xzoom, yzoom);
144  } else {
145  return 0;
146  }
147 }
148 
149 
150 int
151 fb_zoom(fb *ifp, int x, int y)
152 {
153  int xcenter, ycenter;
154  int xzoom, yzoom;
155 
156  if (ifp) {
157  FB_CK_FB(ifp);
158 
159  fb_getview(ifp, &xcenter, &ycenter, &xzoom, &yzoom);
160  xzoom = x;
161  yzoom = y;
162  return fb_view(ifp, xcenter, ycenter, xzoom, yzoom);
163  } else {
164  return 0;
165  }
166 }
167 
168 
169 int
170 fb_scursor(fb *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
171 {
172  if (ifp) {
173  FB_CK_FB(ifp);
174  }
175 
176  /* We could actually implement this but it
177  * is probably of no value.
178  */
179  return 0;
180 }
181 
182 
183 /*
184  * Local Variables:
185  * mode: C
186  * tab-width: 8
187  * indent-tabs-mode: t
188  * c-file-style: "stroustrup"
189  * End:
190  * ex: shiftwidth=4 tabstop=8
191  */
int fb_sim_getcursor(fb *ifp, int *mode, int *x, int *y)
Definition: fb_util.c:96
int fb_sim_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
Definition: fb_util.c:61
int if_xzoom
zoom factors
Definition: fb_private.h:120
Header file for the BRL-CAD common definitions.
int fb_zoom(fb *ifp, int x, int y)
Definition: fb_util.c:151
int fb_window(fb *ifp, int x, int y)
Definition: fb_util.c:133
int if_ycenter
Definition: fb_private.h:123
#define FB_CK_FB(_p)
Definition: fb.h:100
int fb_scursor(fb *ifp, int mode, int x, int y)
Definition: fb_util.c:170
int fb_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
Definition: fb_generic.c:288
static void top()
#define UNUSED(parameter)
Definition: common.h:239
int fb_viewport(fb *ifp, int left, int top, int right, int bottom)
Definition: fb_util.c:122
int fb_sim_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
Definition: fb_util.c:43
int fb_sim_cursor(fb *ifp, int mode, int x, int y)
Definition: fb_util.c:79
int fb_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
Definition: fb_generic.c:292
int if_cursmode
cursor on/off
Definition: fb_private.h:124
int if_xcurs
cursor position
Definition: fb_private.h:125
int fb_reset(fb *ifp)
Definition: fb_util.c:111
A frame-buffer IO structure.
Definition: fb_private.h:80
int if_xcenter
pan position
Definition: fb_private.h:122