Skip to content

Commit b81c5b3

Browse files
committed
Move rt_solid_edit and edit functab to librt headers
Will need to separate out what can stay in an internal private rt_edit.h header and what needs to be visible to apps. rt_solid_edit and the functab are the most obvious, so start there.
1 parent cc9ddb0 commit b81c5b3

File tree

3 files changed

+187
-170
lines changed

3 files changed

+187
-170
lines changed

include/rt/db_internal.h

+96
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,102 @@ RT_EXPORT extern int rt_db_lookup_internal(struct db_i *dbip,
133133
struct resource *resp);
134134

135135

136+
137+
/////////////////////////////////////////////////////////////////
138+
// The following define an "editing" equivalent to rt_db_internal
139+
140+
struct rt_solid_edit_map;
141+
142+
struct rt_solid_edit {
143+
144+
struct rt_solid_edit_map *m;
145+
146+
// Optional logging of messages from editing code
147+
struct bu_vls *log_str;
148+
149+
// Container to hold the intermediate state
150+
// of the object being edited (I think?)
151+
struct rt_db_internal es_int;
152+
153+
// Tolerance for calculations
154+
const struct bn_tol *tol;
155+
struct bview *vp;
156+
157+
// Primary variable used to identify specific editing operations
158+
int edit_flag;
159+
/* item/edit_mode selected from menu. TODO - it seems like this
160+
* may be used to "specialize" edit_flag to narrow its scope to
161+
* specific operations - in which case we might be able to rename
162+
* it to something more general than "menu"... */
163+
int edit_menu;
164+
165+
// Translate values used in XY mouse vector manipulation
166+
vect_t edit_absolute_model_tran;
167+
vect_t last_edit_absolute_model_tran;
168+
vect_t edit_absolute_view_tran;
169+
vect_t last_edit_absolute_view_tran;
170+
171+
// Scale values used in XY mouse vector manipulation
172+
fastf_t edit_absolute_scale;
173+
174+
// MGED wants to know if we're in solid rotate, translate or scale mode.
175+
// (TODO - why?) Rather than keying off of primitive specific edit op
176+
// types, have the ops set flags:
177+
int solid_edit_rotate;
178+
int solid_edit_translate;
179+
int solid_edit_scale;
180+
int solid_edit_pick;
181+
182+
fastf_t es_scale; /* scale factor */
183+
mat_t incr_change; /* change(s) from last cycle */
184+
mat_t model_changes; /* full changes this edit */
185+
fastf_t acc_sc_sol; /* accumulate solid scale factor */
186+
mat_t acc_rot_sol; /* accumulate solid rotations */
187+
188+
int e_keyfixed; /* keypoint specified by user? */
189+
point_t e_keypoint; /* center of editing xforms */
190+
const char *e_keytag; /* string identifying the keypoint */
191+
192+
int e_mvalid; /* e_mparam valid. e_inpara must = 0 */
193+
vect_t e_mparam; /* mouse input param. Only when es_mvalid set */
194+
195+
int e_inpara; /* parameter input from keyboard flag. 1 == e_para valid. e_mvalid must = 0 */
196+
vect_t e_para; /* keyboard input parameter changes */
197+
198+
mat_t e_invmat; /* inverse of e_mat KAA */
199+
mat_t e_mat; /* accumulated matrix of path */
200+
201+
point_t curr_e_axes_pos; /* center of editing xforms */
202+
point_t e_axes_pos;
203+
204+
// Conversion factors
205+
double base2local;
206+
double local2base;
207+
208+
// Trigger for view updating
209+
int update_views;
210+
211+
// vlfree list
212+
struct bu_list *vlfree;
213+
214+
/* Flag to trigger some primitive edit opts to use keypoint (and maybe other behaviors?) */
215+
int mv_context;
216+
217+
/* Internal primitive editing information specific to primitive types. */
218+
void *ipe_ptr;
219+
220+
/* User pointer */
221+
void *u_ptr;
222+
};
223+
224+
struct rt_solid_edit_menu_item {
225+
char *menu_string;
226+
void (*menu_func)(struct rt_solid_edit *, int, int, int, void *);
227+
int menu_arg;
228+
};
229+
230+
231+
136232
__END_DECLS
137233

138234
#endif /* RT_DB_INTERNAL_H */

include/rt/functab.h

+89
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,95 @@ RT_EXPORT extern const struct rt_functab OBJ[];
309309

310310
RT_EXPORT extern const struct rt_functab *rt_get_functab_by_label(const char *label);
311311

312+
313+
314+
////////////////////////////////////////////////////////////////////////////////////
315+
/* Second table specific to editing functionality. Eventually this may simply fold
316+
* into the main librt table, but currently (in 2025) we're in early testing so
317+
* keeping things separate for now. */
318+
struct rt_solid_edit_functab {
319+
uint32_t magic;
320+
char ft_name[17]; /* current longest name is 16 chars, need one element for terminating NULL */
321+
char ft_label[9]; /* current longest label is 8 chars, need one element for terminating NULL */
322+
323+
void (*ft_labels)(int *num_lines,
324+
point_t *lines,
325+
struct rt_point_labels *pl,
326+
int max_pl,
327+
const mat_t xform,
328+
struct rt_solid_edit *s,
329+
struct bn_tol *tol);
330+
#define EDFUNCTAB_FUNC_LABELS_CAST(_func) ((void (*)(int *, point_t *, struct rt_point_labels *, int, const mat_t, struct rt_solid_edit *, struct bn_tol *))((void (*)(void))_func))
331+
332+
const char *(*ft_keypoint)(point_t *pt,
333+
const char *keystr,
334+
const mat_t mat,
335+
struct rt_solid_edit *s,
336+
const struct bn_tol *tol);
337+
#define EDFUNCTAB_FUNC_KEYPOINT_CAST(_func) ((const char *(*)(point_t *, const char *, const mat_t, struct rt_solid_edit *, const struct bn_tol *))((void (*)(void))_func))
338+
339+
void(*ft_e_axes_pos)(
340+
struct rt_solid_edit *s,
341+
const struct rt_db_internal *ip,
342+
const struct bn_tol *tol);
343+
#define EDFUNCTAB_FUNC_E_AXES_POS_CAST(_func) ((void(*)(struct rt_solid_edit *s, const struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
344+
345+
// Written format is intended to be human editable text that will be parsed
346+
// by ft_read_params. There are no guarantees of formatting consistency by
347+
// this API, so external apps should not rely on this format being
348+
// consistent release-to-release. The only API guarantee is that
349+
// ft_write_params output for a given BRL-CAD version is readable by
350+
// ft_read_params.
351+
void(*ft_write_params)(
352+
struct bu_vls *p,
353+
const struct rt_db_internal *ip,
354+
const struct bn_tol *tol,
355+
fastf_t base2local);
356+
#define EDFUNCTAB_FUNC_WRITE_PARAMS_CAST(_func) ((void(*)(struct bu_vls *, const struct rt_db_internal *, const struct bn_tol *, fastf_t))((void (*)(void))_func))
357+
358+
// Parse ft_write_params output and assign numerical values to ip.
359+
int(*ft_read_params)(
360+
struct rt_db_internal *ip,
361+
const char *fc,
362+
const struct bn_tol *tol,
363+
fastf_t local2base);
364+
#define EDFUNCTAB_FUNC_READ_PARAMS_CAST(_func) ((int(*)(struct rt_db_internal *, const char *, const struct bn_tol *, fastf_t))((void (*)(void))_func))
365+
366+
int(*ft_edit)(struct rt_solid_edit *s, int edflag);
367+
#define EDFUNCTAB_FUNC_EDIT_CAST(_func) ((int(*)(struct rt_solid_edit *, int))((void (*)(void))_func))
368+
369+
/* Translate mouse info into edit ready info. mousevec [X] and [Y] are in
370+
* the range -1.0...+1.0, corresponding to viewspace.
371+
*
372+
* In order to allow command line commands to do the same things that a
373+
* mouse movements can, the preferred strategy is to store values and allow
374+
* ft_edit to actually do the work. */
375+
int(*ft_edit_xy)(struct rt_solid_edit *s, int edflag, const vect_t mousevec);
376+
#define EDFUNCTAB_FUNC_EDITXY_CAST(_func) ((int(*)(struct rt_solid_edit *, int, const vect_t))((void (*)(void))_func))
377+
378+
/* Create primitive specific editing struct */
379+
void *(*ft_prim_edit_create)(struct rt_solid_edit *s);
380+
#define EDFUNCTAB_FUNC_PRIMEDIT_CREATE_CAST(_func) ((void *(*)(struct rt_solid_edit *))((void (*)(void))_func))
381+
382+
/* Destroy primitive specific editing struct */
383+
void (*ft_prim_edit_destroy)(void *);
384+
#define EDFUNCTAB_FUNC_PRIMEDIT_DESTROY_CAST(_func) ((void(*)(void *))((void (*)(void))_func))
385+
386+
/* Create primitive specific editing struct */
387+
void (*ft_prim_edit_reset)(struct rt_solid_edit *s);
388+
#define EDFUNCTAB_FUNC_PRIMEDIT_RESET_CAST(_func) ((void(*)(struct rt_solid_edit *))((void (*)(void))_func))
389+
390+
int (*ft_menu_str)(struct bu_vls *m, const struct rt_db_internal *ip, const struct bn_tol *tol);
391+
#define EDFUNCTAB_FUNC_MENU_STR_CAST(_func) ((int(*)(struct bu_vls *, const struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
392+
393+
struct rt_solid_edit_menu_item *(*ft_menu_item)(const struct bn_tol *tol);
394+
#define EDFUNCTAB_FUNC_MENU_ITEM_CAST(_func) ((struct rt_solid_edit_menu_item *(*)(const struct bn_tol *))((void (*)(void))_func))
395+
396+
};
397+
398+
extern const struct rt_solid_edit_functab EDOBJ[];
399+
400+
312401
__END_DECLS
313402

314403
#endif /* RT_FUNCTAB_H */

src/mged/primitives/edfunctab.h

+2-170
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
#include "vmath.h"
2929
#include "bn.h"
30-
#include "raytrace.h"
30+
#include "rt/functab.h"
31+
#include "rt/db_internal.h"
3132
#include "rt_ecmds.h"
3233

3334
#ifdef __cplusplus
@@ -76,88 +77,6 @@ __BEGIN_DECLS
7677
#define CMD_BAD 920
7778
#define CMD_MORE 921
7879

79-
struct rt_solid_edit {
80-
81-
struct rt_solid_edit_map *m;
82-
83-
// Optional logging of messages from editing code
84-
struct bu_vls *log_str;
85-
86-
// Container to hold the intermediate state
87-
// of the object being edited (I think?)
88-
struct rt_db_internal es_int;
89-
90-
// Tolerance for calculations
91-
const struct bn_tol *tol;
92-
struct bview *vp;
93-
94-
// Primary variable used to identify specific editing operations
95-
int edit_flag;
96-
/* item/edit_mode selected from menu. TODO - it seems like this
97-
* may be used to "specialize" edit_flag to narrow its scope to
98-
* specific operations - in which case we might be able to rename
99-
* it to something more general than "menu"... */
100-
int edit_menu;
101-
102-
// Translate values used in XY mouse vector manipulation
103-
vect_t edit_absolute_model_tran;
104-
vect_t last_edit_absolute_model_tran;
105-
vect_t edit_absolute_view_tran;
106-
vect_t last_edit_absolute_view_tran;
107-
108-
// Scale values used in XY mouse vector manipulation
109-
fastf_t edit_absolute_scale;
110-
111-
// MGED wants to know if we're in solid rotate, translate or scale mode.
112-
// (TODO - why?) Rather than keying off of primitive specific edit op
113-
// types, have the ops set flags:
114-
int solid_edit_rotate;
115-
int solid_edit_translate;
116-
int solid_edit_scale;
117-
int solid_edit_pick;
118-
119-
fastf_t es_scale; /* scale factor */
120-
mat_t incr_change; /* change(s) from last cycle */
121-
mat_t model_changes; /* full changes this edit */
122-
fastf_t acc_sc_sol; /* accumulate solid scale factor */
123-
mat_t acc_rot_sol; /* accumulate solid rotations */
124-
125-
int e_keyfixed; /* keypoint specified by user? */
126-
point_t e_keypoint; /* center of editing xforms */
127-
const char *e_keytag; /* string identifying the keypoint */
128-
129-
int e_mvalid; /* e_mparam valid. e_inpara must = 0 */
130-
vect_t e_mparam; /* mouse input param. Only when es_mvalid set */
131-
132-
int e_inpara; /* parameter input from keyboard flag. 1 == e_para valid. e_mvalid must = 0 */
133-
vect_t e_para; /* keyboard input parameter changes */
134-
135-
mat_t e_invmat; /* inverse of e_mat KAA */
136-
mat_t e_mat; /* accumulated matrix of path */
137-
138-
point_t curr_e_axes_pos; /* center of editing xforms */
139-
point_t e_axes_pos;
140-
141-
// Conversion factors
142-
double base2local;
143-
double local2base;
144-
145-
// Trigger for view updating
146-
int update_views;
147-
148-
// vlfree list
149-
struct bu_list *vlfree;
150-
151-
/* Flag to trigger some primitive edit opts to use keypoint (and maybe other behaviors?) */
152-
int mv_context;
153-
154-
/* Internal primitive editing information specific to primitive types. */
155-
void *ipe_ptr;
156-
157-
/* User pointer */
158-
void *u_ptr;
159-
};
160-
16180
struct rt_solid_edit_map *rt_solid_edit_map_create(void);
16281
void rt_solid_edit_map_destroy(struct rt_solid_edit_map *);
16382
int rt_solid_edit_map_clbk_set(struct rt_solid_edit_map *em, int ed_cmd, int menu_cmd, int mode, bu_clbk_t f, void *d);
@@ -166,12 +85,6 @@ int rt_solid_edit_map_sync(struct rt_solid_edit_map *om, struct rt_solid_edit_ma
16685
int rt_solid_edit_clbk_get(bu_clbk_t *f, void **d, struct rt_solid_edit *s, int ed_cmd, int menu_cmd, int mode);
16786

16887

169-
struct rt_solid_edit_menu_item {
170-
char *menu_string;
171-
void (*menu_func)(struct rt_solid_edit *, int, int, int, void *);
172-
int menu_arg;
173-
};
174-
17588
void rt_solid_edit_process(struct rt_solid_edit *s);
17689

17790

@@ -243,87 +156,6 @@ int
243156
rt_solid_edit_generic_menu_str(struct bu_vls *mstr, const struct rt_db_internal *ip, const struct bn_tol *tol);
244157

245158

246-
struct rt_solid_edit_functab {
247-
uint32_t magic;
248-
char ft_name[17]; /* current longest name is 16 chars, need one element for terminating NULL */
249-
char ft_label[9]; /* current longest label is 8 chars, need one element for terminating NULL */
250-
251-
void (*ft_labels)(int *num_lines,
252-
point_t *lines,
253-
struct rt_point_labels *pl,
254-
int max_pl,
255-
const mat_t xform,
256-
struct rt_solid_edit *s,
257-
struct bn_tol *tol);
258-
#define EDFUNCTAB_FUNC_LABELS_CAST(_func) ((void (*)(int *, point_t *, struct rt_point_labels *, int, const mat_t, struct rt_solid_edit *, struct bn_tol *))((void (*)(void))_func))
259-
260-
const char *(*ft_keypoint)(point_t *pt,
261-
const char *keystr,
262-
const mat_t mat,
263-
struct rt_solid_edit *s,
264-
const struct bn_tol *tol);
265-
#define EDFUNCTAB_FUNC_KEYPOINT_CAST(_func) ((const char *(*)(point_t *, const char *, const mat_t, struct rt_solid_edit *, const struct bn_tol *))((void (*)(void))_func))
266-
267-
void(*ft_e_axes_pos)(
268-
struct rt_solid_edit *s,
269-
const struct rt_db_internal *ip,
270-
const struct bn_tol *tol);
271-
#define EDFUNCTAB_FUNC_E_AXES_POS_CAST(_func) ((void(*)(struct rt_solid_edit *s, const struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
272-
273-
// Written format is intended to be human editable text that will be parsed
274-
// by ft_read_params. There are no guarantees of formatting consistency by
275-
// this API, so external apps should not rely on this format being
276-
// consistent release-to-release. The only API guarantee is that
277-
// ft_write_params output for a given BRL-CAD version is readable by
278-
// ft_read_params.
279-
void(*ft_write_params)(
280-
struct bu_vls *p,
281-
const struct rt_db_internal *ip,
282-
const struct bn_tol *tol,
283-
fastf_t base2local);
284-
#define EDFUNCTAB_FUNC_WRITE_PARAMS_CAST(_func) ((void(*)(struct bu_vls *, const struct rt_db_internal *, const struct bn_tol *, fastf_t))((void (*)(void))_func))
285-
286-
// Parse ft_write_params output and assign numerical values to ip.
287-
int(*ft_read_params)(
288-
struct rt_db_internal *ip,
289-
const char *fc,
290-
const struct bn_tol *tol,
291-
fastf_t local2base);
292-
#define EDFUNCTAB_FUNC_READ_PARAMS_CAST(_func) ((int(*)(struct rt_db_internal *, const char *, const struct bn_tol *, fastf_t))((void (*)(void))_func))
293-
294-
int(*ft_edit)(struct rt_solid_edit *s, int edflag);
295-
#define EDFUNCTAB_FUNC_EDIT_CAST(_func) ((int(*)(struct rt_solid_edit *, int))((void (*)(void))_func))
296-
297-
/* Translate mouse info into edit ready info. mousevec [X] and [Y] are in
298-
* the range -1.0...+1.0, corresponding to viewspace.
299-
*
300-
* In order to allow command line commands to do the same things that a
301-
* mouse movements can, the preferred strategy is to store values and allow
302-
* ft_edit to actually do the work. */
303-
int(*ft_edit_xy)(struct rt_solid_edit *s, int edflag, const vect_t mousevec);
304-
#define EDFUNCTAB_FUNC_EDITXY_CAST(_func) ((int(*)(struct rt_solid_edit *, int, const vect_t))((void (*)(void))_func))
305-
306-
/* Create primitive specific editing struct */
307-
void *(*ft_prim_edit_create)(struct rt_solid_edit *s);
308-
#define EDFUNCTAB_FUNC_PRIMEDIT_CREATE_CAST(_func) ((void *(*)(struct rt_solid_edit *))((void (*)(void))_func))
309-
310-
/* Destroy primitive specific editing struct */
311-
void (*ft_prim_edit_destroy)(void *);
312-
#define EDFUNCTAB_FUNC_PRIMEDIT_DESTROY_CAST(_func) ((void(*)(void *))((void (*)(void))_func))
313-
314-
/* Create primitive specific editing struct */
315-
void (*ft_prim_edit_reset)(struct rt_solid_edit *s);
316-
#define EDFUNCTAB_FUNC_PRIMEDIT_RESET_CAST(_func) ((void(*)(struct rt_solid_edit *))((void (*)(void))_func))
317-
318-
int (*ft_menu_str)(struct bu_vls *m, const struct rt_db_internal *ip, const struct bn_tol *tol);
319-
#define EDFUNCTAB_FUNC_MENU_STR_CAST(_func) ((int(*)(struct bu_vls *, const struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
320-
321-
struct rt_solid_edit_menu_item *(*ft_menu_item)(const struct bn_tol *tol);
322-
#define EDFUNCTAB_FUNC_MENU_ITEM_CAST(_func) ((struct rt_solid_edit_menu_item *(*)(const struct bn_tol *))((void (*)(void))_func))
323-
324-
};
325-
extern const struct rt_solid_edit_functab EDOBJ[];
326-
327159
__END_DECLS
328160

329161
#endif /* EDFUNCTAB_H */

0 commit comments

Comments
 (0)