Revision: 76380
          http://sourceforge.net/p/brlcad/code/76380
Author:   starseeker
Date:     2020-07-20 23:34:23 +0000 (Mon, 20 Jul 2020)
Log Message:
-----------
Looking at libtclcad, there are a number of possible desired cmd behaviors (not 
counting option parsing changing them, which futher increases complexity.)  See 
if we can use bit flags to make this more managable.

Modified Paths:
--------------
    brlcad/branches/bioh/src/libged/exec.cpp
    brlcad/branches/bioh/src/libged/include/plugin.h
    brlcad/branches/bioh/src/libged/zoom/zoom.c

Modified: brlcad/branches/bioh/src/libged/exec.cpp
===================================================================
--- brlcad/branches/bioh/src/libged/exec.cpp    2020-07-20 22:55:58 UTC (rev 
76379)
+++ brlcad/branches/bioh/src/libged/exec.cpp    2020-07-20 23:34:23 UTC (rev 
76380)
@@ -51,7 +51,7 @@
 
     int cret = (*cmd->i->cmd)(gedp, argc, argv);
 
-    if (cmd->i->update_view) {
+    if (cmd->i->opts & GED_CMD_UPDATE_VIEW) {
        // Do update view callback
     }
 

Modified: brlcad/branches/bioh/src/libged/include/plugin.h
===================================================================
--- brlcad/branches/bioh/src/libged/include/plugin.h    2020-07-20 22:55:58 UTC 
(rev 76379)
+++ brlcad/branches/bioh/src/libged/include/plugin.h    2020-07-20 23:34:23 UTC 
(rev 76380)
@@ -2,14 +2,39 @@
 
 extern void *ged_cmds;
 
+/* Default command behaviors when it comes to impacts on calling applications.
+ * Need callback hooks in gedp so the application can tell the command what it
+ * needs in these scenarios.  For some it might be possible to have default
+ * libdm based callbacks if none are supplied... */
+
+/* Flags are set and checked with bitwise operations:
+ * (see, for example, 
https://www.learncpp.com/cpp-tutorial/bit-manipulation-with-bitwise-operators-and-bit-masks/)
+ *
+ * int flags = 0;
+ *
+ * // Enable one flag:
+ * flags |= flag1
+ * // Enable multiple flags at once:
+ * flags |= ( flag2 | flag3 );
+ * // Disable one flag:
+ * flags &= ~flag1
+ * // Disable multiple flags at once:
+ * flags &= &( flag2 | flag3 );
+ */
+
+#define GED_CMD_INTERACTIVE   1 << 0
+#define GED_CMD_UPDATE_SCENE  1 << 1
+#define GED_CMD_UPDATE_VIEW   1 << 2
+#define GED_CMD_AUTOVIEW      1 << 3
+#define GED_CMD_ALL_VIEWS     1 << 4
+#define GED_CMD_VIEW_CALLBACK 1 << 5
+
 struct ged_cmd_impl {
     const char *cname;
     ged_func_ptr cmd;
-    int update_view;
-    int interactive;
+    int64_t opts;
 };
 
-#define GED_CMD_IMPL_NULL {NULL, 0}
 
 /*
  * Local Variables:

Modified: brlcad/branches/bioh/src/libged/zoom/zoom.c
===================================================================
--- brlcad/branches/bioh/src/libged/zoom/zoom.c 2020-07-20 22:55:58 UTC (rev 
76379)
+++ brlcad/branches/bioh/src/libged/zoom/zoom.c 2020-07-20 23:34:23 UTC (rev 
76380)
@@ -67,12 +67,13 @@
 
 #ifdef GED_PLUGIN
 #include "../include/plugin.h"
+//struct ged_cmd_impl zoom_cmd_impl = {"zoom", ged_zoom, GED_CMD_UPDATE_VIEW};
 struct ged_cmd_impl zoom_cmd_impl = {
     "zoom",
     ged_zoom,
-    1,
-    0
+    GED_CMD_UPDATE_VIEW | GED_CMD_ALL_VIEWS
 };
+
 struct ged_cmd zoom_cmd = { &zoom_cmd_impl };
 
 static const struct ged_plugin pinfo = { &zoom_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