BRL-CAD
state.h
Go to the documentation of this file.
1/* S T A T E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2008-2023 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 ged_state
21 *
22 * Geometry EDiting Library Object Selection Functions.
23 *
24 *
25 * TODO - both the drawn state and the selection state need a rethink, particularly
26 * since they need to sync when an interface is visually indicating one or both
27 * sets of information.
28 *
29 * There are three things we may want from either:
30 *
31 * 1. "minimal" list of active entities - the shallowest paths that fully
32 * express the set of active objects
33 *
34 * 2. "input" list - what the user has actually specified to create the
35 * current state
36 *
37 * 3. "solids" list - the full paths to the solids that will be the sources of
38 * the actual geometry shown in the scene. A complication here is drawing
39 * modes that evaluate the geometry, which will not have child solids but will
40 * themselves be holding a temporary set of generated view data.
41 *
42 * 4. "active" list - the set of all paths between specified/minimal and solids
43 * that are implicit active
44 *
45 * Both #1 and #3 can be generated from #2, although how quickly this can be
46 * done is a concern as hierarchies get large. #3 is necessary for graphical
47 * interrogation of scenes to build selection sets, since it is those solid
48 * objects that the user will be interacting with. (In the case of a selection
49 * set built solely from graphical selection #2 and #3 will be the same.
50 * However, since the drawn scene will more likely have been specified with one
51 * or a small number of higher level objects, the #2 draw list needs to be used
52 * to generate a #3 list to support building up the selection list.)
53 *
54 * When a "who" command is run the user is probably looking for #1, but that is
55 * not as clear in the select case - in a tree view, selecting a comb and all
56 * of the children of that comb have different implications for editing. The
57 * former, unless the comb is a top level object, implies editing the instance of
58 * the comb in its own parent. The latter implies editing the comb definition,
59 * altering the position of its children. Unlike the former, the latter will
60 * impact ALL uses of comb, not just a single instance. That would imply select
61 * should default to #2, but that's most likely not what is desired if the user
62 * has selected large numbers of individual solids from #3 - they MAY want that,
63 * but they may also be seeking to specify groups of regions or higher level objects
64 * to manipulate. That implies the need to expose some "collapse" operations to
65 * the user so they may identify wholly selected parent objects and "promote"
66 * to them.
67 *
68 * We also need an efficient way for both drawing and selection codes to look up
69 * and manipulate the state of their corresponding information in the other container.
70 * When drawing, the interface may need to illuminate selected objects (which can
71 * be selected even if not drawn, and so will need to "appear" selected.) This requires
72 * being able to interrogate the #3 select list from the drawing code to identify if
73 * a given full path is selected. Likewise, when a selection occurs, drawn objects
74 * will need to have their illuminate state updated - the #2 select list will need
75 * to generate a #3 select list and then update (illuminate or de-illuminate, as the
76 * case may be) corresponding solids on the #3 drawn list. All this needs to also
77 * happen quickly, to handle large selections and de-selections on very large geometry
78 * hierarchies. The lists may also be invalidated by geometry editing operations,
79 * and so will need to be quickly validated against the .g state or updated in response
80 * to .g changes.
81 *
82 * A complication on the #2 lists is what happens if an erase or deselect
83 * command removes part of a previously specified object. In that case a new
84 * #2 list must be generated which captures as much of the original semantic
85 * intent of the user specification as possible - "expanding" the relevant
86 * entries from the #2 list to their solids, removing the solids from the user
87 * specified removal parents, and then collapsing the remaining solids back to
88 * a minimal set.
89 *
90 * Another #2 alteration case is when a higher level specification "subsumes" previous
91 * #2 paths into it. The existing paths must be recognized as subpaths of the
92 * specified path, and removed in favor of it.
93 *
94 * At the moment, we have explicit logic in the drawing code for handling the above
95 * cases, using db_full_path top matching. Syncing between the selection and drawing
96 * codes is imperfect - draw does not currently check for selected status when
97 * creating scene objects.
98 *
99 * Design thoughts - what if for both the ged drawn and selected lists we
100 * stash unordered sets of path hashes to indicate activity, and then add/remove
101 * those hashes based on specified paths and the related solid tree walks? To
102 * generate the #1 set from the #2 we get the parent of each #2, check if all the
103 * parent's children are in #4, and if so add it to #4 and process its parent and
104 * so on. If we find a parent without all of its children in #4, remove it from #4
105 * if present and report it as a #1. To go the other way, do a full path tree walk
106 * calculating hashes as we go and populating #4. Any solid we reach that way is
107 * part of #3. If the view containers maintain unordered maps of hashes to scene
108 * objects, the selection code can directly identify any active objects. The
109 * highlighting update pass would be one iteration to clear all flags, and then
110 * a second over the #3 hashes from the selection to set illum flags on the
111 * currently selected objects. As long as the same hashes are used for both,
112 * no further processing would be necessary to ID selection changes.
113 *
114 * Draw objects also still need to be synced with the .g state in response to
115 * update notifications from the .g I/O callbacks, which report directory
116 * pointers... we need a way to flag solids based on that info as well, which
117 * probably means we still need to keep the db_full_path associated with the
118 * scene object. May want to re-examine the current two-tier storage system
119 * and just make all solid objs top level entries. If we're willing to re-calculate
120 * the "drawn" #1 list on the fly, and not worry about #2 for the drawn objects
121 * case, that may simplify some things.
122 */
123/** @{ */
124/** @file ged/view/state.h */
125
126#ifndef GED_VIEW_STATE_H
127#define GED_VIEW_STATE_H
128
129#include "common.h"
130#include "bn/tol.h"
131#include "rt/db_fullpath.h"
132#include "rt/db_instance.h"
133#include "ged/defines.h"
134
135__BEGIN_DECLS
136
137// TODO - once this settles down, give it a magic number so we can type
138// check it after a void cast
140 struct db_i *dbip;
142 const struct bn_tol *tol;
143 const struct bg_tess_tol *ttol;
145 struct resource *res;
146};
147
148
149/* Defined in view.cpp */
150GED_EXPORT extern int ged_view_update(struct ged *gedp);
151
152/**
153 * Erase all currently displayed geometry and draw the specified object(s)
154 */
155GED_EXPORT extern int ged_blast(struct ged *gedp, int argc, const char *argv[]);
156
157/**
158 * Prepare object(s) for display
159 */
160GED_EXPORT extern int ged_draw(struct ged *gedp, int argc, const char *argv[]);
161
162/**
163 * Prepare object(s) for display
164 */
165GED_EXPORT extern int ged_E(struct ged *gedp, int argc, const char *argv[]);
166
167/**
168 * Prepare all regions with the given air code(s) for display
169 */
170GED_EXPORT extern int ged_eac(struct ged *gedp, int argc, const char *argv[]);
171
172/**
173 * Erase objects from the display.
174 */
175GED_EXPORT extern int ged_erase(struct ged *gedp, int argc, const char *argv[]);
176
177/**
178 * Returns how an object is being displayed
179 */
180GED_EXPORT extern int ged_how(struct ged *gedp, int argc, const char *argv[]);
181
182/**
183 * Illuminate/highlight database object.
184 */
185GED_EXPORT extern int ged_illum(struct ged *gedp, int argc, const char *argv[]);
186
187/**
188 * Configure Level of Detail drawing.
189 */
190GED_EXPORT extern int ged_lod(struct ged *gedp, int argc, const char *argv[]);
191
192/**
193 * Set/get the shaded mode.
194 */
195GED_EXPORT extern int ged_shaded_mode(struct ged *gedp, int argc, const char *argv[]);
196
197
198/**
199 * Recalculate plots for displayed objects.
200 */
201GED_EXPORT extern int ged_redraw(struct ged *gedp, int argc, const char *argv[]);
202
203/**
204 * List the objects currently prepped for drawing
205 */
206GED_EXPORT extern int ged_who(struct ged *gedp, int argc, const char *argv[]);
207
208/**
209 * Erase all currently displayed geometry
210 */
211GED_EXPORT extern int ged_zap(struct ged *gedp, int argc, const char *argv[]);
212
213/**
214 * Rubber band rectangle utility.
215 */
216GED_EXPORT extern int ged_rect(struct ged *gedp, int argc, const char *argv[]);
217
218/**
219 * Set/get the keypoint
220 */
221GED_EXPORT extern int ged_keypoint(struct ged *gedp, int argc, const char *argv[]);
222
223
224GED_EXPORT extern unsigned long long dl_name_hash(struct ged *gedp);
225
226
227__END_DECLS
228
229#endif /* GED_VIEW_STATE_H */
230
231/** @} */
232
233/*
234 * Local Variables:
235 * tab-width: 8
236 * mode: C
237 * indent-tabs-mode: t
238 * c-file-style: "stroustrup"
239 * End:
240 * ex: shiftwidth=4 tabstop=8
241 */
Header file for the BRL-CAD common definitions.
int ged_redraw(struct ged *gedp, int argc, const char *argv[])
int ged_shaded_mode(struct ged *gedp, int argc, const char *argv[])
int ged_keypoint(struct ged *gedp, int argc, const char *argv[])
int ged_erase(struct ged *gedp, int argc, const char *argv[])
int ged_lod(struct ged *gedp, int argc, const char *argv[])
int ged_how(struct ged *gedp, int argc, const char *argv[])
int ged_blast(struct ged *gedp, int argc, const char *argv[])
int ged_zap(struct ged *gedp, int argc, const char *argv[])
int ged_rect(struct ged *gedp, int argc, const char *argv[])
unsigned long long dl_name_hash(struct ged *gedp)
int ged_view_update(struct ged *gedp)
int ged_eac(struct ged *gedp, int argc, const char *argv[])
int ged_illum(struct ged *gedp, int argc, const char *argv[])
int ged_who(struct ged *gedp, int argc, const char *argv[])
int ged_draw(struct ged *gedp, int argc, const char *argv[])
int ged_E(struct ged *gedp, int argc, const char *argv[])
Definition: tol.h:72
const struct bg_tess_tol * ttol
Definition: state.h:143
struct resource * res
Definition: state.h:145
struct bg_mesh_lod_context * mesh_c
Definition: state.h:144
const struct bn_tol * tol
Definition: state.h:142
struct db_i * dbip
Definition: state.h:140
struct db_full_path * fp
Definition: state.h:141
Definition: defines.h:195