BRL-CAD
util.h
Go to the documentation of this file.
1/* B V I E W _ U T I L . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2022 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 bv_util
21 *
22 */
23/** @{ */
24/** @file bv/util.h */
25
26#ifndef BV_UTIL_H
27#define BV_UTIL_H
28
29#include "common.h"
30#include "bn/tol.h"
31#include "dm/defines.h"
32#include "bv/defines.h"
33
34__BEGIN_DECLS
35
36/* Set default values for a bv. */
37BV_EXPORT extern void bv_init(struct bview *v);
38BV_EXPORT extern void bv_free(struct bview *v);
39
40/**
41 * FIXME: this routine is suspect and needs investigating. if run
42 * during view initialization, the shaders regression test fails.
43 */
44BV_EXPORT void bv_mat_aet(struct bview *v);
45
46BV_EXPORT extern void bv_settings_init(struct bview_settings *s);
47
48/* Copy the size and camera info (deliberately not a full copy of all view state) */
49BV_EXPORT extern void bv_sync(struct bview *dest, struct bview *src);
50
51/* Copy settings (potentially) common to the view and scene objects */
52BV_EXPORT extern void bv_obj_settings_sync(struct bv_obj_settings *dest, struct bv_obj_settings *src);
53
54/* Sync values within the bv, perform callbacks if any are defined */
55BV_EXPORT extern void bv_update(struct bview *gvp);
56
57/* Update objects in the selection set (if any) and their children */
58BV_EXPORT extern int bv_update_selected(struct bview *gvp);
59
60/* Return 1 if the visible contents differ
61 * Return 2 if visible content is the same but settings differ
62 * Return 3 if content is the same but user data, dmp or callbacks differ
63 * Return -1 if one or more of the views is NULL
64 * Else return 0 */
65BV_EXPORT extern int bv_differ(struct bview *v1, struct bview *v2);
66
67/* Return a hash of the contents of the bv container. Returns 0 on failure. */
68BV_EXPORT extern unsigned long long bv_hash(struct bview *v);
69
70/* Return a hash of the contents of a display list. Returns 0 on failure. */
71BV_EXPORT extern unsigned long long bv_dl_hash(struct display_list *dl);
72
73
74/* Note that some of these are mutually exclusive as far as producing any
75 * changes - a simultaneous constraint in X and Y, for example, results in a
76 * no-op. */
77#define BV_IDLE 0x0
78#define BV_ROT 0x1
79#define BV_TRANS 0x2
80#define BV_SCALE 0x4
81#define BV_CON_X 0x8
82#define BV_CON_Y 0x10
83#define BV_CON_Z 0x20
84#define BV_CON_GRID 0x40
85#define BV_CON_LINES 0x80
86
87/* Update a view in response to X,Y coordinate changes as generated
88 * by a graphical interface's mouse motion. */
89BV_EXPORT extern int bv_adjust(struct bview *v, int dx, int dy, point_t keypoint, int mode, unsigned long long flags);
90
91/* Beginning extraction of the core of libtclcad view object manipulation
92 * logic. The following functions will initially be pretty straightforward
93 * mappings from libtclcad, and will likely evolve over time.
94 */
95
96/* Return -1 if width and/or height are unset (and hence a meaningful
97 * calculation is impossible), else 0. */
98BV_EXPORT extern int bv_screen_to_view(struct bview *v, fastf_t *fx, fastf_t *fy, fastf_t x, fastf_t y);
99
100/* Initialize a scene object to standard default settings */
101BV_EXPORT extern void bv_scene_obj_init(struct bv_scene_obj *s, struct bv_scene_obj *free_scene_obj);
102
103/* Free the object contents, including all child objects */
104BV_EXPORT extern void bv_scene_obj_free(struct bv_scene_obj *s, struct bv_scene_obj *free_scene_obj);
105
106/* Compute the min, max, and center points of the scene object. */
107BV_EXPORT extern void bv_scene_obj_bound(struct bv_scene_obj *s);
108
109/* Find the nearest (mode == 0) or farthest (mode == 1) data_vZ value from
110 * the vlist points in s in the context of view v */
111BV_EXPORT extern fastf_t bv_vZ_calc(struct bv_scene_obj *s, struct bview *v, int mode);
112
113__END_DECLS
114
115/** @} */
116
117#endif /* BV_UTIL_H */
118
119/*
120 * Local Variables:
121 * mode: C
122 * tab-width: 8
123 * indent-tabs-mode: t
124 * c-file-style: "stroustrup"
125 * End:
126 * ex: shiftwidth=4 tabstop=8
127 */
Header file for the BRL-CAD common definitions.
void float float * fy
Definition: tig.h:283
void float float * y
Definition: tig.h:73
void int char * mode
Definition: tig.h:179
void float * fx
Definition: tig.h:282
void float * x
Definition: tig.h:72
void int char int int double double * dx
Definition: tig.h:183
void bv_free(struct bview *v)
unsigned long long bv_hash(struct bview *v)
int bv_update_selected(struct bview *gvp)
fastf_t bv_vZ_calc(struct bv_scene_obj *s, struct bview *v, int mode)
int bv_adjust(struct bview *v, int dx, int dy, point_t keypoint, int mode, unsigned long long flags)
void bv_init(struct bview *v)
void bv_obj_settings_sync(struct bv_obj_settings *dest, struct bv_obj_settings *src)
void bv_scene_obj_bound(struct bv_scene_obj *s)
int bv_differ(struct bview *v1, struct bview *v2)
void bv_scene_obj_free(struct bv_scene_obj *s, struct bv_scene_obj *free_scene_obj)
void bv_settings_init(struct bview_settings *s)
int bv_screen_to_view(struct bview *v, fastf_t *fx, fastf_t *fy, fastf_t x, fastf_t y)
void bv_sync(struct bview *dest, struct bview *src)
void bv_mat_aet(struct bview *v)
unsigned long long bv_dl_hash(struct display_list *dl)
void bv_update(struct bview *gvp)
void bv_scene_obj_init(struct bv_scene_obj *s, struct bv_scene_obj *free_scene_obj)
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Definition: defines.h:364