Skip to content

Commit

Permalink
Stub in callback management functions
Browse files Browse the repository at this point in the history
To get Tcl out of the editing logic we'll need this almost immediately,
and removing the "basic" Tcl use cases will help make the outliers
easier to spot.
  • Loading branch information
starseeker committed Jan 24, 2025
1 parent 9a2a8db commit 7b322cb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/mged/edsol.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,6 @@ sedit(struct mged_state *s)
sedraw = 0;
++update_views;

// Handle any primitive specific flags TODO - will have to reserve integer
// values for the generic operations so primitive specific methods don't
// conflict with them. Maybe something simple like all primitive specific
// edflag vals need to be >RT_EDIT_OP_GENERIC_MAX? Primitives could then
// define with:
// #define PRIM_OP_1 RT_EDIT_OP_GENERIC_MAX+1,
// #define PRIM_OP_2 PRIM_OP_1+1
// ...
int had_method = 0;
const struct rt_db_internal *ip = &s->s_edit->es_int;
if (MGED_OBJ[ip->idb_type].ft_edit) {
Expand Down
18 changes: 18 additions & 0 deletions src/mged/mged.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,24 @@ struct mged_solid_edit {

};

// TODO - need callback registration mechanism. If sedit() is going to become
// something like rt_solid_edit_process() then looking at the code we'll need
// callbacks for at least:
//
// mged_print_results
// set_e_axes_pos
// replot_editing_solid
// view_update
//
// in addition to allowing ECMD specific callback registrations. Simplest thing
// to do is probably assign the "generic" operations above some specific numbers
// and supply a 0 obj type so we can just use the same mechanism for everything.
//
extern int mged_edit_clbk_set(struct mged_solid_edit *s, int obj_type, int ed_cmd, int mode, bu_clbk_t f, void *d);
extern int mged_edit_clbk_get(bu_clbk_t *f, void **d, struct mged_solid_edit *s, int obj_type, int ed_cmd, int mode);



/* global application state */
struct mged_state_impl;
struct mged_state {
Expand Down
40 changes: 40 additions & 0 deletions src/mged/mged_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,46 @@ mged_solid_edit_destroy(struct mged_solid_edit *s)
BU_PUT(s, struct mged_solid_edit);
}

int mged_edit_clbk_set(struct mged_solid_edit *s, int obj_type, int ed_cmd, int mode, bu_clbk_t f, void *d)
{
// Check for no-op case
if (!s || mode < 0)
return BRLCAD_OK;

if (!f) {
if (d)
bu_log("data but no callback?\n");
bu_log("null f means clear callback\n");
}

if (!obj_type) {
bu_log("generic callback functionality");
}

bu_log("ed_cmd: %d, mode: %d\n", ed_cmd, mode);

// TODO - should we define functab callback to validate ed_cmd against the
// known primitive editing operations? Thinking that might be preferable
// otherwise a mistake in the cmd will result in the callback not running
// as expected, which may or may not be an immediately apparent failure.

return BRLCAD_OK;
}
int mged_edit_clbk_get(bu_clbk_t *f, void **d, struct mged_solid_edit *s, int obj_type, int ed_cmd, int mode)
{
// Check for no-op case
if (!f || !d || !s || mode < 0)
return BRLCAD_OK;

if (!obj_type) {
bu_log("generic callback functionality");
}

bu_log("ed_cmd: %d, mode: %d\n", ed_cmd, mode);

return BRLCAD_OK;
}

// Local Variables:
// tab-width: 8
// mode: C++
Expand Down

0 comments on commit 7b322cb

Please sign in to comment.