Revision: 76591
          http://sourceforge.net/p/brlcad/code/76591
Author:   starseeker
Date:     2020-07-30 12:36:58 +0000 (Thu, 30 Jul 2020)
Log Message:
-----------
Add a container/slot for libtclcad data that is ged instance associated, rather 
than view associated.

Modified Paths:
--------------
    brlcad/branches/bioh/include/tclcad.h
    brlcad/branches/bioh/src/libtclcad/tclcad_obj.c

Modified: brlcad/branches/bioh/include/tclcad.h
===================================================================
--- brlcad/branches/bioh/include/tclcad.h       2020-07-30 12:18:44 UTC (rev 
76590)
+++ brlcad/branches/bioh/include/tclcad.h       2020-07-30 12:36:58 UTC (rev 
76591)
@@ -132,11 +132,16 @@
 DM_EXPORT extern int fbs_open(struct fbserv_obj *fbsp, int port);
 DM_EXPORT extern int fbs_close(struct fbserv_obj *fbsp);
 
+struct tclcad_ged_data {
+    struct ged_obj             *gdv_gop;
+    struct bu_vls      go_rt_end_callback;
+};
+
 struct tclcad_view_data {
+    struct ged_obj             *gdv_gop;
     struct bu_vls              gdv_edit_motion_delta_callback;
     struct bu_vls              gdv_callback;
     struct fbserv_obj          gdv_fbs;
-    struct ged_obj             *gdv_gop;
 };
 
 struct ged_obj {
@@ -144,7 +149,6 @@
     struct bview       go_head_views;
     struct bu_vls      go_name;
     struct bu_vls      go_more_args_callback;
-    struct bu_vls      go_rt_end_callback;
     struct bu_vls      *go_prim_label_list;
     int                        go_prim_label_list_size;
     int                        go_refresh_on;

Modified: brlcad/branches/bioh/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/branches/bioh/src/libtclcad/tclcad_obj.c     2020-07-30 12:18:44 UTC 
(rev 76590)
+++ brlcad/branches/bioh/src/libtclcad/tclcad_obj.c     2020-07-30 12:36:58 UTC 
(rev 76591)
@@ -1101,8 +1101,15 @@
     BU_LIST_DEQUEUE(&top->l);
     bu_vls_free(&top->to_gop->go_name);
     ged_close(top->to_gop->go_gedp);
-    if (top->to_gop->go_gedp)
+    if (top->to_gop->go_gedp) {
+       if (top->to_gop->go_gedp->u_data) {
+           struct tclcad_ged_data *tgd = (struct tclcad_ged_data 
*)top->to_gop->go_gedp;
+           bu_vls_free(&tgd->go_rt_end_callback);
+           BU_PUT(tgd, struct tclcad_ged_data);
+           top->to_gop->go_gedp->u_data = NULL;
+       }
        BU_PUT(top->to_gop->go_gedp, struct ged);
+    }
 
     free_path_edit_params(top->to_gop->go_edited_paths);
     bu_hash_destroy(top->to_gop->go_edited_paths);
@@ -1290,10 +1297,16 @@
     BU_ASSERT(gedp->ged_gdp != NULL);
     top->to_gop->go_gedp->ged_gdp->gd_rtCmdNotify = 
to_rt_end_callback_internal;
 
+    // Initialize libtclcad GED data container
+    struct tclcad_ged_data *tgd;
+    BU_GET(tgd, struct tclcad_ged_data);
+    bu_vls_init(&tgd->go_rt_end_callback);
+    tgd->gdv_gop = top->to_gop;
+    gedp->u_data = (void *)tgd;
+
     bu_vls_init(&top->to_gop->go_name);
     bu_vls_strcpy(&top->to_gop->go_name, argv[1]);
     bu_vls_init(&top->to_gop->go_more_args_callback);
-    bu_vls_init(&top->to_gop->go_rt_end_callback);
     top->to_gop->go_refresh_on = 1;
     top->to_gop->go_edited_paths = bu_hash_create(0);
 
@@ -5284,6 +5297,7 @@
                   int UNUSED(maxargs))
 {
     register int i;
+    struct tclcad_ged_data *tgd = (struct tclcad_ged_data 
*)current_top->to_gop->go_gedp->u_data;
 
     /* initialize result */
     bu_vls_trunc(gedp->ged_result_str, 0);
@@ -5290,15 +5304,15 @@
 
     /* get the callback string */
     if (argc == 1) {
-       bu_vls_printf(gedp->ged_result_str, "%s", 
bu_vls_addr(&current_top->to_gop->go_rt_end_callback));
+       bu_vls_printf(gedp->ged_result_str, "%s", 
bu_vls_addr(&tgd->go_rt_end_callback));
 
        return GED_OK;
     }
 
     /* set the callback string */
-    bu_vls_trunc(&current_top->to_gop->go_rt_end_callback, 0);
+    bu_vls_trunc(&tgd->go_rt_end_callback, 0);
     for (i = 1; i < argc; ++i)
-       bu_vls_printf(&current_top->to_gop->go_rt_end_callback, "%s ", argv[i]);
+       bu_vls_printf(&tgd->go_rt_end_callback, "%s ", argv[i]);
 
     return GED_OK;
 }
@@ -6599,12 +6613,12 @@
 HIDDEN void
 to_rt_end_callback_internal(int aborted)
 {
-    if (0 < bu_vls_strlen(&current_top->to_gop->go_rt_end_callback)) {
+    struct tclcad_ged_data *tgd = (struct tclcad_ged_data 
*)current_top->to_gop->go_gedp->u_data;
+    if (0 < bu_vls_strlen(&tgd->go_rt_end_callback)) {
        struct bu_vls callback_cmd = BU_VLS_INIT_ZERO;
 
        bu_vls_printf(&callback_cmd, "%s %d",
-                     bu_vls_addr(&current_top->to_gop->go_rt_end_callback),
-                     aborted);
+                     bu_vls_addr(&tgd->go_rt_end_callback), aborted);
        Tcl_Eval(current_top->to_interp, bu_vls_addr(&callback_cmd));
     }
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to