Revision: 32571
          http://brlcad.svn.sourceforge.net/brlcad/?rev=32571&view=rev
Author:   bob1961
Date:     2008-09-03 14:35:36 +0000 (Wed, 03 Sep 2008)

Log Message:
-----------
Added ADC (angle distance cursor) functions to libged. Added ADC drawing to 
libdm. Added ADC command to libtclcad.

Modified Paths:
--------------
    brlcad/trunk/include/dm.h
    brlcad/trunk/include/ged.h
    brlcad/trunk/include/tclcad.h
    brlcad/trunk/misc/win32-msvc8/libdm/libdm.vcproj
    brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj
    brlcad/trunk/src/libdm/Makefile.am
    brlcad/trunk/src/libdm/axes.c
    brlcad/trunk/src/libdm/clip.c
    brlcad/trunk/src/libdm/dm-Null.c
    brlcad/trunk/src/libdm/dm-generic.c
    brlcad/trunk/src/libdm/dm-plot.c
    brlcad/trunk/src/libdm/dm-ps.c
    brlcad/trunk/src/libdm/knob.c
    brlcad/trunk/src/libdm/options.c
    brlcad/trunk/src/libdm/query.c
    brlcad/trunk/src/libdm/vers.c
    brlcad/trunk/src/libged/Makefile.am
    brlcad/trunk/src/libtclcad/ged_obj.c

Added Paths:
-----------
    brlcad/trunk/src/libdm/adc.c
    brlcad/trunk/src/libged/adc.c

Modified: brlcad/trunk/include/dm.h
===================================================================
--- brlcad/trunk/include/dm.h   2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/include/dm.h   2008-09-03 14:35:36 UTC (rev 32571)
@@ -30,6 +30,7 @@
 
 #include "bu.h"
 #include "vmath.h"
+#include "ged.h"
 
 #define USE_FBSERV 1
 
@@ -76,6 +77,9 @@
 #define Xx_TO_GED(_dmp, x) ((int)(((x)/(double)_dmp->dm_width - 0.5) * 
GED_RANGE))
 #define Xy_TO_GED(_dmp, x) ((int)((0.5 - (x)/(double)_dmp->dm_height) * 
GED_RANGE))
 
+/* +-2048 to +-1 */
+#define GED_TO_PM1(x) (((fastf_t)(x))*INV_GED)
+
 #if IR_KNOBS
 #define NOISE 16               /* Size of dead spot on knob */
 #endif
@@ -345,6 +349,12 @@
                     register fastf_t *,
                     register fastf_t *));
 
+/* adc.c */
+DM_EXPORT BU_EXTERN(void dm_draw_adc,
+                   (struct dm *dmp,
+                    struct ged_adc_state *gasp,
+                    struct ged_view *gvp));
+
 /* axes.c */
 DM_EXPORT BU_EXTERN(void dmo_drawDataAxes_cmd,
                    (struct dm *dmp,

Modified: brlcad/trunk/include/ged.h
===================================================================
--- brlcad/trunk/include/ged.h  2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/include/ged.h  2008-09-03 14:35:36 UTC (rev 32571)
@@ -164,6 +164,30 @@
        return (_ret); \
     }
 
+struct ged_adc_state {
+    int                gas_draw;
+    int                gas_dv_x;
+    int                gas_dv_y;
+    int                gas_dv_a1;
+    int                gas_dv_a2;
+    int                gas_dv_dist;
+    fastf_t    gas_pos_model[3];
+    fastf_t    gas_pos_view[3];
+    fastf_t    gas_pos_grid[3];
+    fastf_t    gas_a1;
+    fastf_t    gas_a2;
+    fastf_t    gas_dst;
+    int                gas_anchor_pos;
+    int                gas_anchor_a1;
+    int                gas_anchor_a2;
+    int                gas_anchor_dst;
+    fastf_t    gas_anchor_pt_a1[3];
+    fastf_t    gas_anchor_pt_a2[3];
+    fastf_t    gas_anchor_pt_dst[3];
+    int                gas_line_color[3];
+    int                gas_tick_color[3];
+    int                gas_linewidth;
+};
 
 struct ged_run_rt {
     struct bu_list l;
@@ -319,6 +343,50 @@
 };
 
 
+/* defined in adc.c */
+GED_EXPORT BU_EXTERN(void ged_adc_model_To_adc_view,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_adc_grid_To_adc_view,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_adc_view_To_adc_grid,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_calc_adc_pos,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_calc_adc_a1,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_calc_adc_a2,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_calc_adc_dst,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_adc_reset,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp));
+GED_EXPORT BU_EXTERN(void ged_adc_vls_print,
+                    (struct ged_adc_state *gasp,
+                     struct ged_view *gvp,
+                     fastf_t base2local,
+                     struct bu_vls *out_vp));
+
+/* defined in clip.c */
+GED_EXPORT BU_EXTERN(int ged_clip,
+                    (fastf_t *xp1,
+                     fastf_t *yp1,
+                     fastf_t *xp2,
+                     fastf_t *yp2));
+GED_EXPORT BU_EXTERN(int ged_vclip,
+                    (vect_t a,
+                     vect_t b,
+                     register fastf_t *min,
+                     register fastf_t *max));
+
+
 /* defined in ged.c */
 GED_EXPORT BU_EXTERN(struct ged *ged_open,
                     (const char *dbtype,

Modified: brlcad/trunk/include/tclcad.h
===================================================================
--- brlcad/trunk/include/tclcad.h       2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/include/tclcad.h       2008-09-03 14:35:36 UTC (rev 32571)
@@ -78,18 +78,14 @@
     struct ged_view    *gdv_view;
     struct dm          *gdv_dmp;
     struct fbserv_obj  gdv_fbs;
+    struct ged_adc_state gdv_gas;
     struct ged_obj     *gdv_gop; /* Pointer back to its ged object */
 };
 
 struct ged_obj {
     struct bu_list     l;
     struct ged         *go_gedp;
-#if 1
     struct ged_dm_view go_head_views;
-#else
-    struct ged_view    *go_views[GED_OBJ_NUM_VIEWS];
-    struct dm          *go_dmp;
-#endif
     struct bu_vls      go_name;
     struct bu_observer go_observers;
     Tcl_Interp         *go_interp;

Modified: brlcad/trunk/misc/win32-msvc8/libdm/libdm.vcproj
===================================================================
--- brlcad/trunk/misc/win32-msvc8/libdm/libdm.vcproj    2008-09-03 03:26:32 UTC 
(rev 32570)
+++ brlcad/trunk/misc/win32-msvc8/libdm/libdm.vcproj    2008-09-03 14:35:36 UTC 
(rev 32571)
@@ -229,6 +229,10 @@
                        Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
                        >
                        <File
+                               RelativePath="..\..\..\src\libdm\adc.c"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\..\src\libdm\axes.c"
                                >
                                <FileConfiguration

Modified: brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj
===================================================================
--- brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj  2008-09-03 03:26:32 UTC 
(rev 32570)
+++ brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj  2008-09-03 14:35:36 UTC 
(rev 32571)
@@ -230,6 +230,10 @@
                                >
                        </File>
                        <File
+                               RelativePath="..\..\..\src\libged\adc.c"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\..\src\libged\adjust.c"
                                >
                        </File>

Modified: brlcad/trunk/src/libdm/Makefile.am
===================================================================
--- brlcad/trunk/src/libdm/Makefile.am  2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/Makefile.am  2008-09-03 14:35:36 UTC (rev 32571)
@@ -30,6 +30,7 @@
 endif
 
 libdm_la_SOURCES = \
+       adc.c \
        axes.c \
        clip.c \
        color.c \

Added: brlcad/trunk/src/libdm/adc.c
===================================================================
--- brlcad/trunk/src/libdm/adc.c                                (rev 0)
+++ brlcad/trunk/src/libdm/adc.c        2008-09-03 14:35:36 UTC (rev 32571)
@@ -0,0 +1,201 @@
+/*                           A D C . C
+ * BRL-CAD
+ *
+ * Copyright (c) 1985-2008 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file adc.c
+ *
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#include "bio.h"
+#include "bu.h"
+#include "vmath.h"
+#include "ged.h"
+#include "dm.h"
+
+
+static void
+dm_draw_ticks(struct dm *dmp, struct ged_adc_state *gasp, struct ged_view 
*gvp, fastf_t angle)
+{
+    fastf_t c_tdist;
+    fastf_t d1, d2;
+    fastf_t t1, t2;
+    fastf_t x1, Y1;       /* not "y1", due to conflict with math lib */
+    fastf_t x2, y2;
+
+    /*
+     * Position tic marks from dial 9.
+     */
+    /* map -2048 - 2047 into 0 - 2048 * sqrt (2) */
+    /* Tick distance */
+    c_tdist = ((fastf_t)(gasp->gas_dv_dist) + GED_MAX) * M_SQRT1_2;
+
+    d1 = c_tdist * cos (angle);
+    d2 = c_tdist * sin (angle);
+    t1 = 20.0 * sin (angle);
+    t2 = 20.0 * cos (angle);
+
+    /* Quadrant 1 */
+    x1 = gasp->gas_dv_x + d1 + t1;
+    Y1 = gasp->gas_dv_y + d2 - t2;
+    x2 = gasp->gas_dv_x + d1 -t1;
+    y2 = gasp->gas_dv_y + d2 + t2;
+    if (ged_clip(&x1, &Y1, &x2, &y2) == 0) {
+       DM_DRAW_LINE_2D(dmp,
+                       GED_TO_PM1(x1), GED_TO_PM1(Y1) * dmp->dm_aspect,
+                       GED_TO_PM1(x2), GED_TO_PM1(y2) * dmp->dm_aspect);
+    }
+
+    /* Quadrant 2 */
+    x1 = gasp->gas_dv_x - d2 + t2;
+    Y1 = gasp->gas_dv_y + d1 + t1;
+    x2 = gasp->gas_dv_x - d2 - t2;
+    y2 = gasp->gas_dv_y + d1 - t1;
+    if (ged_clip(&x1, &Y1, &x2, &y2) == 0) {
+       DM_DRAW_LINE_2D(dmp,
+                       GED_TO_PM1(x1), GED_TO_PM1(Y1) * dmp->dm_aspect,
+                       GED_TO_PM1(x2), GED_TO_PM1(y2) * dmp->dm_aspect);
+    }
+
+    /* Quadrant 3 */
+    x1 = gasp->gas_dv_x - d1 - t1;
+    Y1 = gasp->gas_dv_y - d2 + t2;
+    x2 = gasp->gas_dv_x - d1 + t1;
+    y2 = gasp->gas_dv_y - d2 - t2;
+    if (ged_clip(&x1, &Y1, &x2, &y2) == 0) {
+       DM_DRAW_LINE_2D(dmp,
+                       GED_TO_PM1(x1), GED_TO_PM1(Y1) * dmp->dm_aspect,
+                       GED_TO_PM1(x2), GED_TO_PM1(y2) * dmp->dm_aspect);
+    }
+
+    /* Quadrant 4 */
+    x1 = gasp->gas_dv_x + d2 - t2;
+    Y1 = gasp->gas_dv_y - d1 - t1;
+    x2 = gasp->gas_dv_x + d2 + t2;
+    y2 = gasp->gas_dv_y - d1 + t1;
+    if (ged_clip(&x1, &Y1, &x2, &y2) == 0) {
+       DM_DRAW_LINE_2D(dmp,
+                       GED_TO_PM1(x1), GED_TO_PM1(Y1) * dmp->dm_aspect,
+                       GED_TO_PM1(x2), GED_TO_PM1(y2) * dmp->dm_aspect);
+    }
+}
+
+
+/**
+ * Compute and display the angle/distance cursor.
+ */
+void
+dm_draw_adc(struct dm *dmp, struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    fastf_t x1, Y1;    /* not "y1", due to conflict with math lib */
+    fastf_t x2, y2;
+    fastf_t x3, y3;
+    fastf_t x4, y4;
+    fastf_t d1, d2;
+    fastf_t angle1, angle2;
+
+    ged_calc_adc_pos(gasp, gvp);
+    ged_calc_adc_a1(gasp, gvp);
+    ged_calc_adc_a2(gasp, gvp);
+    ged_calc_adc_dst(gasp, gvp);
+
+    DM_SET_FGCOLOR(dmp,
+                  gasp->gas_line_color[0],
+                  gasp->gas_line_color[1],
+                  gasp->gas_line_color[2], 1, 1.0);
+    DM_SET_LINE_ATTR(dmp, gasp->gas_linewidth, 0);
+
+    /* Horizontal */
+    DM_DRAW_LINE_2D(dmp,
+                   GED_TO_PM1(GED_MIN), GED_TO_PM1(gasp->gas_dv_y) * 
dmp->dm_aspect,
+                   GED_TO_PM1(GED_MAX), GED_TO_PM1(gasp->gas_dv_y) * 
dmp->dm_aspect);
+
+    /* Vertical */
+    DM_DRAW_LINE_2D(dmp,
+                   GED_TO_PM1(gasp->gas_dv_x), GED_TO_PM1(GED_MAX),
+                   GED_TO_PM1(gasp->gas_dv_x), GED_TO_PM1(GED_MIN));
+
+    angle1 = gasp->gas_a1 * DEG2RAD;
+    angle2 = gasp->gas_a2 * DEG2RAD;
+
+    /* sin for X and cos for Y to reverse sense of knob */
+    d1 = cos (angle1) * 8000.0;
+    d2 = sin (angle1) * 8000.0;
+    x1 = gasp->gas_dv_x + d1;
+    Y1 = gasp->gas_dv_y + d2;
+    x2 = gasp->gas_dv_x - d1;
+    y2 = gasp->gas_dv_y - d2;
+
+    x3 = gasp->gas_dv_x + d2;
+    y3 = gasp->gas_dv_y - d1;
+    x4 = gasp->gas_dv_x - d2;
+    y4 = gasp->gas_dv_y + d1;
+
+    DM_DRAW_LINE_2D(dmp,
+                   GED_TO_PM1(x1), GED_TO_PM1(Y1) * dmp->dm_aspect,
+                   GED_TO_PM1(x2), GED_TO_PM1(y2) * dmp->dm_aspect);
+    DM_DRAW_LINE_2D(dmp,
+                   GED_TO_PM1(x3), GED_TO_PM1(y3) * dmp->dm_aspect,
+                   GED_TO_PM1(x4), GED_TO_PM1(y4) * dmp->dm_aspect);
+
+    d1 = cos(angle2) * 8000.0;
+    d2 = sin(angle2) * 8000.0;
+    x1 = gasp->gas_dv_x + d1;
+    Y1 = gasp->gas_dv_y + d2;
+    x2 = gasp->gas_dv_x - d1;
+    y2 = gasp->gas_dv_y - d2;
+
+    x3 = gasp->gas_dv_x + d2;
+    y3 = gasp->gas_dv_y - d1;
+    x4 = gasp->gas_dv_x - d2;
+    y4 = gasp->gas_dv_y + d1;
+
+    DM_SET_LINE_ATTR(dmp, gasp->gas_linewidth, 1);
+    DM_DRAW_LINE_2D(dmp,
+                   GED_TO_PM1(x1), GED_TO_PM1(Y1) * dmp->dm_aspect,
+                   GED_TO_PM1(x2), GED_TO_PM1(y2) * dmp->dm_aspect);
+    DM_DRAW_LINE_2D(dmp,
+                   GED_TO_PM1(x3), GED_TO_PM1(y3) * dmp->dm_aspect,
+                   GED_TO_PM1(x4), GED_TO_PM1(y4) * dmp->dm_aspect);
+    DM_SET_LINE_ATTR(dmp, gasp->gas_linewidth, 0);
+
+    DM_SET_FGCOLOR(dmp,
+                  gasp->gas_tick_color[0],
+                  gasp->gas_tick_color[1],
+                  gasp->gas_tick_color[2], 1, 1.0);
+    dm_draw_ticks(dmp, gasp, gvp, 0.0);
+    dm_draw_ticks(dmp, gasp, gvp, angle1);
+    dm_draw_ticks(dmp, gasp, gvp, angle2);
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/libdm/adc.c
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: brlcad/trunk/src/libdm/axes.c
===================================================================
--- brlcad/trunk/src/libdm/axes.c       2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/axes.c       2008-09-03 14:35:36 UTC (rev 32571)
@@ -26,6 +26,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <stdio.h>
 #include <math.h>

Modified: brlcad/trunk/src/libdm/clip.c
===================================================================
--- brlcad/trunk/src/libdm/clip.c       2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/clip.c       2008-09-03 14:35:36 UTC (rev 32571)
@@ -33,6 +33,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <stdio.h>
 

Modified: brlcad/trunk/src/libdm/dm-Null.c
===================================================================
--- brlcad/trunk/src/libdm/dm-Null.c    2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/dm-Null.c    2008-09-03 14:35:36 UTC (rev 32571)
@@ -22,6 +22,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #define PLOTBOUND       1000.0  /* Max magnification in Rot matrix */
 #include <stdio.h>

Modified: brlcad/trunk/src/libdm/dm-generic.c
===================================================================
--- brlcad/trunk/src/libdm/dm-generic.c 2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/dm-generic.c 2008-09-03 14:35:36 UTC (rev 32571)
@@ -24,6 +24,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <string.h>
 

Modified: brlcad/trunk/src/libdm/dm-plot.c
===================================================================
--- brlcad/trunk/src/libdm/dm-plot.c    2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/dm-plot.c    2008-09-03 14:35:36 UTC (rev 32571)
@@ -30,6 +30,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <stdio.h>
 #include <string.h>

Modified: brlcad/trunk/src/libdm/dm-ps.c
===================================================================
--- brlcad/trunk/src/libdm/dm-ps.c      2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/dm-ps.c      2008-09-03 14:35:36 UTC (rev 32571)
@@ -28,6 +28,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <stdio.h>
 #include <string.h>

Modified: brlcad/trunk/src/libdm/knob.c
===================================================================
--- brlcad/trunk/src/libdm/knob.c       2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/knob.c       2008-09-03 14:35:36 UTC (rev 32571)
@@ -24,6 +24,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include "tcl.h"
 #include "bu.h"

Modified: brlcad/trunk/src/libdm/options.c
===================================================================
--- brlcad/trunk/src/libdm/options.c    2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/options.c    2008-09-03 14:35:36 UTC (rev 32571)
@@ -24,6 +24,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <stdlib.h>
 

Modified: brlcad/trunk/src/libdm/query.c
===================================================================
--- brlcad/trunk/src/libdm/query.c      2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/query.c      2008-09-03 14:35:36 UTC (rev 32571)
@@ -22,6 +22,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include <string.h>
 

Modified: brlcad/trunk/src/libdm/vers.c
===================================================================
--- brlcad/trunk/src/libdm/vers.c       2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libdm/vers.c       2008-09-03 14:35:36 UTC (rev 32571)
@@ -26,6 +26,7 @@
  */
 
 #include "common.h"
+#include "bio.h"
 
 #include "dm.h"
 #include "brlcad_version.h"

Modified: brlcad/trunk/src/libged/Makefile.am
===================================================================
--- brlcad/trunk/src/libged/Makefile.am 2008-09-03 03:26:32 UTC (rev 32570)
+++ brlcad/trunk/src/libged/Makefile.am 2008-09-03 14:35:36 UTC (rev 32571)
@@ -4,6 +4,7 @@
 
 libged_nil_la_SOURCES = \
        3ptarb.c \
+       adc.c \
        adjust.c \
        ae2dir.c \
        aet.c \

Added: brlcad/trunk/src/libged/adc.c
===================================================================
--- brlcad/trunk/src/libged/adc.c                               (rev 0)
+++ brlcad/trunk/src/libged/adc.c       2008-09-03 14:35:36 UTC (rev 32571)
@@ -0,0 +1,207 @@
+/*                           A D C . C
+ * BRL-CAD
+ *
+ * Copyright (c) 1985-2008 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file adc.c
+ *
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#include "bio.h"
+#include "bu.h"
+#include "vmath.h"
+#include "ged.h"
+#include "dm.h"
+
+
+void
+ged_adc_model_To_adc_view(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    MAT4X3PNT(gasp->gas_pos_view, gvp->gv_model2view, gasp->gas_pos_model);
+    gasp->gas_dv_x = gasp->gas_pos_view[X] * GED_MAX;
+    gasp->gas_dv_y = gasp->gas_pos_view[Y] * GED_MAX;
+}
+
+void
+ged_adc_grid_To_adc_view(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    point_t model_pt;
+    point_t view_pt;
+
+    VSETALL(model_pt, 0.0);
+    MAT4X3PNT(view_pt, gvp->gv_model2view, model_pt);
+    VADD2(gasp->gas_pos_view, view_pt, gasp->gas_pos_grid);
+    gasp->gas_dv_x = gasp->gas_pos_view[X] * GED_MAX;
+    gasp->gas_dv_y = gasp->gas_pos_view[Y] * GED_MAX;
+}
+
+void
+ged_adc_view_To_adc_grid(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    point_t model_pt;
+    point_t view_pt;
+
+    VSETALL(model_pt, 0.0);
+    MAT4X3PNT(view_pt, gvp->gv_model2view, model_pt);
+    VSUB2(gasp->gas_pos_grid, gasp->gas_pos_view, view_pt);
+}
+
+void
+ged_calc_adc_pos(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    if (gasp->gas_anchor_pos == 1) {
+       ged_adc_model_To_adc_view(gasp, gvp);
+       ged_adc_view_To_adc_grid(gasp, gvp);
+    } else if (gasp->gas_anchor_pos == 2) {
+       ged_adc_grid_To_adc_view(gasp, gvp);
+       MAT4X3PNT(gasp->gas_pos_model, gvp->gv_view2model, gasp->gas_pos_view);
+    } else {
+       ged_adc_view_To_adc_grid(gasp, gvp);
+       MAT4X3PNT(gasp->gas_pos_model, gvp->gv_view2model, gasp->gas_pos_view);
+    }
+}
+
+void
+ged_calc_adc_a1(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    if (gasp->gas_anchor_a1) {
+       fastf_t dx, dy;
+       point_t view_pt;
+
+       MAT4X3PNT(view_pt, gvp->gv_model2view, gasp->gas_anchor_pt_a1);
+       dx = view_pt[X] * GED_MAX - gasp->gas_dv_x;
+       dy = view_pt[Y] * GED_MAX - gasp->gas_dv_y;
+
+       if (dx != 0.0 || dy != 0.0) {
+           gasp->gas_a1 = RAD2DEG*atan2(dy, dx);
+           gasp->gas_dv_a1 = (1.0 - (gasp->gas_a1 / 45.0)) * GED_MAX;
+       }
+    }
+}
+
+void
+ged_calc_adc_a2(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    if (gasp->gas_anchor_a2) {
+       fastf_t dx, dy;
+       point_t view_pt;
+
+       MAT4X3PNT(view_pt, gvp->gv_model2view, gasp->gas_anchor_pt_a2);
+       dx = view_pt[X] * GED_MAX - gasp->gas_dv_x;
+       dy = view_pt[Y] * GED_MAX - gasp->gas_dv_y;
+
+       if (dx != 0.0 || dy != 0.0) {
+           gasp->gas_a2 = RAD2DEG*atan2(dy, dx);
+           gasp->gas_dv_a2 = (1.0 - (gasp->gas_a2 / 45.0)) * GED_MAX;
+       }
+    }
+}
+
+void
+ged_calc_adc_dst(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    if (gasp->gas_anchor_dst) {
+       fastf_t dist;
+       fastf_t dx, dy;
+       point_t view_pt;
+
+       MAT4X3PNT(view_pt, gvp->gv_model2view, gasp->gas_anchor_pt_dst);
+
+       dx = view_pt[X] * GED_MAX - gasp->gas_dv_x;
+       dy = view_pt[Y] * GED_MAX - gasp->gas_dv_y;
+       dist = sqrt(dx * dx + dy * dy);
+       gasp->gas_dst = dist * INV_GED;
+       gasp->gas_dv_dist = (dist / M_SQRT1_2) - GED_MAX;
+    } else
+       gasp->gas_dst = (gasp->gas_dv_dist * INV_GED + 1.0) * M_SQRT1_2;
+}
+
+void
+ged_adc_reset(struct ged_adc_state *gasp, struct ged_view *gvp)
+{
+    gasp->gas_dv_x = gasp->gas_dv_y = 0;
+    gasp->gas_dv_a1 = gasp->gas_dv_a2 = 0;
+    gasp->gas_dv_dist = 0;
+
+    VSETALL(gasp->gas_pos_view, 0.0);
+    MAT4X3PNT(gasp->gas_pos_model, gvp->gv_view2model, gasp->gas_pos_view);
+    gasp->gas_dst = (gasp->gas_dv_dist * INV_GED + 1.0) * M_SQRT1_2;
+    gasp->gas_a1 = gasp->gas_a2 = 45.0;
+    ged_adc_view_To_adc_grid(gasp, gvp);
+
+    VSETALL(gasp->gas_anchor_pt_a1, 0.0);
+    VSETALL(gasp->gas_anchor_pt_a2, 0.0);
+    VSETALL(gasp->gas_anchor_pt_dst, 0.0);
+
+    gasp->gas_anchor_pos = 0;
+    gasp->gas_anchor_a1 = 0;
+    gasp->gas_anchor_a2 = 0;
+    gasp->gas_anchor_dst = 0;
+}
+
+void
+ged_adc_vls_print(struct ged_adc_state *gasp, struct ged_view *gvp, fastf_t 
base2local, struct bu_vls *out_vp)
+{
+    bu_vls_printf(out_vp, "draw = %d\n", gasp->gas_draw);
+    bu_vls_printf(out_vp, "a1 = %.15e\n", gasp->gas_a1);
+    bu_vls_printf(out_vp, "a2 = %.15e\n", gasp->gas_a2);
+    bu_vls_printf(out_vp, "dst = %.15e\n", gasp->gas_dst * gvp->gv_scale * 
base2local);
+    bu_vls_printf(out_vp, "odst = %d\n", gasp->gas_dv_dist);
+    bu_vls_printf(out_vp, "hv = %.15e %.15e\n",
+                 gasp->gas_pos_grid[X] * gvp->gv_scale * base2local,
+                 gasp->gas_pos_grid[Y] * gvp->gv_scale * base2local);
+    bu_vls_printf(out_vp, "xyz = %.15e %.15e %.15e\n",
+                 gasp->gas_pos_model[X] * base2local,
+                 gasp->gas_pos_model[Y] * base2local,
+                 gasp->gas_pos_model[Z] * base2local);
+    bu_vls_printf(out_vp, "x = %d\n", gasp->gas_dv_x);
+    bu_vls_printf(out_vp, "y = %d\n", gasp->gas_dv_y);
+    bu_vls_printf(out_vp, "anchor_pos = %d\n", gasp->gas_anchor_pos);
+    bu_vls_printf(out_vp, "anchor_a1 = %d\n", gasp->gas_anchor_a1);
+    bu_vls_printf(out_vp, "anchor_a2 = %d\n", gasp->gas_anchor_a2);
+    bu_vls_printf(out_vp, "anchor_dst = %d\n", gasp->gas_anchor_dst);
+    bu_vls_printf(out_vp, "anchorpoint_a1 = %.15e %.15e %.15e\n",
+                 gasp->gas_anchor_pt_a1[X] * base2local,
+                 gasp->gas_anchor_pt_a1[Y] * base2local,
+                 gasp->gas_anchor_pt_a1[Z] * base2local);
+    bu_vls_printf(out_vp, "anchorpoint_a2 = %.15e %.15e %.15e\n",
+                 gasp->gas_anchor_pt_a2[X] * base2local,
+                 gasp->gas_anchor_pt_a2[Y] * base2local,
+                 gasp->gas_anchor_pt_a2[Z] * base2local);
+    bu_vls_printf(out_vp, "anchorpoint_dst = %.15e %.15e %.15e\n",
+                 gasp->gas_anchor_pt_dst[X] * base2local,
+                 gasp->gas_anchor_pt_dst[Y] * base2local,
+                 gasp->gas_anchor_pt_dst[Z] * base2local);
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/libged/adc.c
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: brlcad/trunk/src/libtclcad/ged_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/ged_obj.c        2008-09-03 03:26:32 UTC (rev 
32570)
+++ brlcad/trunk/src/libtclcad/ged_obj.c        2008-09-03 14:35:36 UTC (rev 
32571)
@@ -82,12 +82,45 @@
 #include "dg.h"
 #endif
 
+static char go_adc_syntax[] = "\
+ adc vname                     toggle display of angle/distance cursor\n\
+ adc vname vars                        print a list of all variables (i.e. var 
= val)\n\
+ adc vname draw [0|1]          set or get the draw parameter\n\
+ adc vname a1 [#]              set or get angle1\n\
+ adc vname a2 [#]              set or get angle2\n\
+ adc vname dst [#]             set or get radius (distance) of tick\n\
+ adc vname odst [#]            set or get radius (distance) of tick (+-2047)\n\
+ adc vname hv [# #]            set or get position (grid coordinates)\n\
+ adc vname xyz [# # #]         set or get position (model coordinates)\n\
+ adc vname x [#]               set or get horizontal position (+-2047)\n\
+ adc vname y [#]               set or get vertical position (+-2047)\n\
+ adc vname dh #                        add to horizontal position (grid 
coordinates)\n\
+ adc vname dv #                        add to vertical position (grid 
coordinates)\n\
+ adc vname dx #                        add to X position (model coordinates)\n\
+ adc vname dy #                        add to Y position (model coordinates)\n\
+ adc vname dz #                        add to Z position (model coordinates)\n\
+ adc vname anchor_pos          [0|1]   anchor ADC to current position in model 
coordinates\n\
+ adc vname anchor_a1           [0|1]   anchor angle1 to go through 
anchorpoint_a1\n\
+ adc vname anchor_a2           [0|1]   anchor angle2 to go through 
anchorpoint_a2\n\
+ adc vname anchor_dst          [0|1]   anchor tick distance to go through 
anchorpoint_dst\n\
+ adc vname anchorpoint_a1      [# # #] set or get anchor point for angle1\n\
+ adc vname anchorpoint_a2      [# # #] set or get anchor point for angle2\n\
+ adc vname anchorpoint_dst     [# # #] set or get anchor point for tick 
distance\n\
+ adc vname -i                  any of the above appropriate commands will 
interpret parameters as increments\n\
+ adc vname reset               reset angles, location, and tick distance\n\
+ adc vname help                        prints this help message\n\
+";
+
 static int go_open_tcl(ClientData clientData,
                       Tcl_Interp *interp,
                       int argc,
                       const char **argv);
-
-
+static int go_adc(struct ged   *gedp,
+                 int           argc,
+                 const char    *argv[],
+                 ged_func_ptr  func,
+                 const char    *usage,
+                 int           maxargs);
 static int go_autoview(struct ged      *gedp,
                       int              argc,
                       const char       *argv[],
@@ -332,6 +365,7 @@
 
 static struct go_cmdtab go_cmds[] = {
     {"3ptarb", (char *)0, MAXARGS, go_pass_through_func, ged_3ptarb},
+    {"adc",    go_adc_syntax, MAXARGS, go_adc, GED_FUNC_PTR_NULL},
     {"adjust", (char *)0, MAXARGS, go_pass_through_func, ged_adjust},
     {"ae2dir", (char *)0, MAXARGS, go_pass_through_func, ged_ae2dir},
     {"aet",    "vname [[-i] az el [tw]]", 6, go_view_func, ged_aet},
@@ -833,6 +867,562 @@
 
 /*************************** Local Command Functions 
***************************/
 static int
+go_adc(struct ged      *gedp,
+       int             argc,
+       const char      *argv[],
+       ged_func_ptr    func,
+       const char      *usage,
+       int             maxargs)
+{
+    char *command;
+    char *parameter;
+    char **argp = (char **)argv;
+    point_t user_pt;           /* Value(s) provided by user */
+    point_t scaled_pos;
+    int incr_flag;
+    int i;
+    struct ged_dm_view *gdvp;
+
+    /* initialize result */
+    bu_vls_trunc(&gedp->ged_result_str, 0);
+    gedp->ged_result = GED_RESULT_NULL;
+
+    if (argc < 2 || 7 < argc) {
+       bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+       return BRLCAD_ERROR;
+    }
+
+    for (BU_LIST_FOR(gdvp, ged_dm_view, &go_current_gop->go_head_views.l)) {
+       if (!strcmp(bu_vls_addr(&gdvp->gdv_name), argv[1]))
+           break;
+    }
+
+    if (BU_LIST_IS_HEAD(&gdvp->l, &go_current_gop->go_head_views.l)) {
+       bu_vls_printf(&gedp->ged_result_str, "View not found - %s", argv[1]);
+       return BRLCAD_ERROR;
+    }
+
+    if (argc == 2) {
+       if (gdvp->gdv_gas.gas_draw)
+           gdvp->gdv_gas.gas_draw = 0;
+       else
+           gdvp->gdv_gas.gas_draw = 1;
+
+       go_refresh_view(gdvp);
+       return BRLCAD_OK;
+    }
+
+    command = (char *)argv[0];
+
+    if (strcmp(argv[2], "-i") == 0) {
+       if (argc < 5) {
+           bu_vls_printf(&gedp->ged_result_str, "%s: -i option specified 
without an op-val pair", command);
+           return BRLCAD_ERROR;
+       }
+
+       incr_flag = 1;
+       parameter = (char *)argv[3];
+       argc -= 4;
+       argp += 4;
+    } else {
+       incr_flag = 0;
+       parameter = (char *)argv[2];
+       argc -= 3;
+       argp += 3;
+    }
+
+    for (i = 0; i < argc; ++i)
+       user_pt[i] = atof(argp[i]);
+
+    if (strcmp(parameter, "draw") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", gdvp->gdv_gas.gas_draw);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           i = (int)user_pt[X];
+
+           if (i)
+               gdvp->gdv_gas.gas_draw = 1;
+           else
+               gdvp->gdv_gas.gas_draw = 0;
+
+           go_refresh_view(gdvp);
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s draw' command accepts 0 
or 1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "a1") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%.15e", gdvp->gdv_gas.gas_a1);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_a1) {
+               if (incr_flag)
+                   gdvp->gdv_gas.gas_a1 += user_pt[0];
+               else
+                   gdvp->gdv_gas.gas_a1 = user_pt[0];
+
+               gdvp->gdv_gas.gas_dv_a1 = (1.0 - (gdvp->gdv_gas.gas_a1 / 45.0)) 
* GED_MAX;
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s a1' command accepts only 
1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "a2") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%.15e", gdvp->gdv_gas.gas_a2);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_a2) {
+               if (incr_flag)
+                   gdvp->gdv_gas.gas_a2 += user_pt[0];
+               else
+                   gdvp->gdv_gas.gas_a2 = user_pt[0];
+
+               gdvp->gdv_gas.gas_dv_a2 = (1.0 - (gdvp->gdv_gas.gas_a2 / 45.0)) 
* GED_MAX;
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s a2' command accepts only 
1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "dst") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%.15e", gdvp->gdv_gas.gas_dst 
* gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_dst) {
+               if (incr_flag)
+                   gdvp->gdv_gas.gas_dst += user_pt[0] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+               else
+                   gdvp->gdv_gas.gas_dst = user_pt[0] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+
+               gdvp->gdv_gas.gas_dv_dist = (gdvp->gdv_gas.gas_dst / M_SQRT1_2 
- 1.0) * GED_MAX;
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s dst' command accepts 0 or 
1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "odst") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", 
gdvp->gdv_gas.gas_dv_dist);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_dst) {
+               if (incr_flag)
+                   gdvp->gdv_gas.gas_dv_dist += user_pt[0];
+               else
+                   gdvp->gdv_gas.gas_dv_dist = user_pt[0];
+
+               gdvp->gdv_gas.gas_dst = (gdvp->gdv_gas.gas_dv_dist * INV_GED + 
1.0) * M_SQRT1_2;
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s odst' command accepts 0 
or 1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "dh") == 0) {
+       if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               gdvp->gdv_gas.gas_pos_grid[X] += user_pt[0] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+               ged_adc_grid_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+               MAT4X3PNT(gdvp->gdv_gas.gas_pos_model, 
gdvp->gdv_view->gv_view2model, gdvp->gdv_gas.gas_pos_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s dh' command requires 1 
argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "dv") == 0) {
+       if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               gdvp->gdv_gas.gas_pos_grid[Y] += user_pt[0] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+               ged_adc_grid_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+               MAT4X3PNT(gdvp->gdv_gas.gas_pos_model, 
gdvp->gdv_view->gv_view2model, gdvp->gdv_gas.gas_pos_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s dv' command requires 1 
argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "hv") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e",
+                         gdvp->gdv_gas.gas_pos_grid[X] * 
gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local,
+                         gdvp->gdv_gas.gas_pos_grid[Y] * 
gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+           return BRLCAD_OK;
+       } else if (argc == 2) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               if (incr_flag) {
+                   gdvp->gdv_gas.gas_pos_grid[X] += user_pt[X] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+                   gdvp->gdv_gas.gas_pos_grid[Y] += user_pt[Y] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+               } else {
+                   gdvp->gdv_gas.gas_pos_grid[X] = user_pt[X] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+                   gdvp->gdv_gas.gas_pos_grid[Y] = user_pt[Y] / 
(gdvp->gdv_view->gv_scale * gedp->ged_wdbp->dbip->dbi_base2local);
+               }
+
+               gdvp->gdv_gas.gas_pos_grid[Z] = 0.0;
+               ged_adc_grid_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+               MAT4X3PNT(gdvp->gdv_gas.gas_pos_model, 
gdvp->gdv_view->gv_view2model, gdvp->gdv_gas.gas_pos_model);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s hv' command requires 0 or 
2 arguments\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "dx") == 0) {
+       if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               gdvp->gdv_gas.gas_pos_model[X] += user_pt[0] * 
gedp->ged_wdbp->dbip->dbi_local2base;
+               ged_adc_model_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+               ged_adc_view_To_adc_grid(&gdvp->gdv_gas, gdvp->gdv_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s dx' command requires 1 
argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "dy") == 0) {
+       if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               gdvp->gdv_gas.gas_pos_model[Y] += user_pt[0] * 
gedp->ged_wdbp->dbip->dbi_local2base;
+               ged_adc_model_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+               ged_adc_view_To_adc_grid(&gdvp->gdv_gas, gdvp->gdv_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s dy' command requires 1 
argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "dz") == 0) {
+       if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               gdvp->gdv_gas.gas_pos_model[Z] += user_pt[0] * 
gedp->ged_wdbp->dbip->dbi_local2base;
+               ged_adc_model_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+               ged_adc_view_To_adc_grid(&gdvp->gdv_gas, gdvp->gdv_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s dz' command requires 1 
argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "xyz") == 0) {
+       if (argc == 0) {
+           VSCALE(scaled_pos, gdvp->gdv_gas.gas_pos_model, 
gedp->ged_wdbp->dbip->dbi_base2local);
+           bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e %.15e", 
V3ARGS(scaled_pos));
+           return BRLCAD_OK;
+       } else if (argc == 3) {
+           VSCALE(user_pt, user_pt, gedp->ged_wdbp->dbip->dbi_local2base);
+
+           if (incr_flag) {
+               VADD2(gdvp->gdv_gas.gas_pos_model, gdvp->gdv_gas.gas_pos_model, 
user_pt);
+           } else {
+               VMOVE(gdvp->gdv_gas.gas_pos_model, user_pt);
+           }
+
+           ged_adc_model_To_adc_view(&gdvp->gdv_gas, gdvp->gdv_view);
+           ged_adc_view_To_adc_grid(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s xyz' command requires 0 
or 3 arguments\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "x") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", gdvp->gdv_gas.gas_dv_x);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               if (incr_flag) {
+                   gdvp->gdv_gas.gas_dv_x += user_pt[0];
+               } else {
+                   gdvp->gdv_gas.gas_dv_x = user_pt[0];
+               }
+
+               gdvp->gdv_gas.gas_pos_view[X] = gdvp->gdv_gas.gas_dv_x * 
INV_GED;
+               gdvp->gdv_gas.gas_pos_view[Y] = gdvp->gdv_gas.gas_dv_y * 
INV_GED;
+               ged_adc_view_To_adc_grid(&gdvp->gdv_gas, gdvp->gdv_view);
+               MAT4X3PNT(gdvp->gdv_gas.gas_pos_model, 
gdvp->gdv_view->gv_view2model, gdvp->gdv_gas.gas_pos_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s x' command requires 0 or 
1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "y") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", gdvp->gdv_gas.gas_dv_y);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           if (!gdvp->gdv_gas.gas_anchor_pos) {
+               if (incr_flag) {
+                   gdvp->gdv_gas.gas_dv_y += user_pt[0];
+               } else {
+                   gdvp->gdv_gas.gas_dv_y = user_pt[0];
+               }
+
+               gdvp->gdv_gas.gas_pos_view[X] = gdvp->gdv_gas.gas_dv_x * 
INV_GED;
+               gdvp->gdv_gas.gas_pos_view[Y] = gdvp->gdv_gas.gas_dv_y * 
INV_GED;
+               ged_adc_view_To_adc_grid(&gdvp->gdv_gas, gdvp->gdv_view);
+               MAT4X3PNT(gdvp->gdv_gas.gas_pos_model, 
gdvp->gdv_view->gv_view2model, gdvp->gdv_gas.gas_pos_view);
+               go_refresh_view(gdvp);
+           }
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s y' command requires 0 or 
1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchor_pos") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", 
gdvp->gdv_gas.gas_anchor_pos);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           i = (int)user_pt[X];
+
+           if (i < 0 || 2 < i) {
+               bu_vls_printf(&gedp->ged_result_str, "The '%s anchor_pos' 
parameter accepts values of 0, 1, or 2.");
+               return BRLCAD_ERROR;
+           }
+
+           gdvp->gdv_gas.gas_anchor_pos = i;
+           ged_calc_adc_pos(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchor_pos' command 
accepts 0 or 1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchor_a1") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", 
gdvp->gdv_gas.gas_anchor_a1);
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           i = (int)user_pt[X];
+
+           if (i)
+               gdvp->gdv_gas.gas_anchor_a1 = 1;
+           else
+               gdvp->gdv_gas.gas_anchor_a1 = 0;
+
+           ged_calc_adc_a1(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchor_a1' command 
accepts 0 or 1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchorpoint_a1") == 0) {
+       if (argc == 0) {
+           VSCALE(scaled_pos, gdvp->gdv_gas.gas_anchor_pt_a1, 
gedp->ged_wdbp->dbip->dbi_base2local);
+           bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e %.15e", 
V3ARGS(scaled_pos));
+
+           return BRLCAD_OK;
+       } else if (argc == 3) {
+           VSCALE(user_pt, user_pt, gedp->ged_wdbp->dbip->dbi_local2base);
+
+           if (incr_flag) {
+               VADD2(gdvp->gdv_gas.gas_anchor_pt_a1, 
gdvp->gdv_gas.gas_anchor_pt_a1, user_pt);
+           } else {
+               VMOVE(gdvp->gdv_gas.gas_anchor_pt_a1, user_pt);
+           }
+
+           ged_calc_adc_a1(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchorpoint_a1' command 
accepts 0 or 3 arguments\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchor_a2") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", 
gdvp->gdv_gas.gas_anchor_a2);
+
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           i = (int)user_pt[X];
+
+           if (i)
+               gdvp->gdv_gas.gas_anchor_a2 = 1;
+           else
+               gdvp->gdv_gas.gas_anchor_a2 = 0;
+
+           ged_calc_adc_a2(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchor_a2' command 
accepts 0 or 1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchorpoint_a2") == 0) {
+       if (argc == 0) {
+           VSCALE(scaled_pos, gdvp->gdv_gas.gas_anchor_pt_a2, 
gedp->ged_wdbp->dbip->dbi_base2local);
+
+           bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e %.15e", 
V3ARGS(scaled_pos));
+
+           return BRLCAD_OK;
+       } else if (argc == 3) {
+           VSCALE(user_pt, user_pt, gedp->ged_wdbp->dbip->dbi_local2base);
+
+           if (incr_flag) {
+               VADD2(gdvp->gdv_gas.gas_anchor_pt_a2, 
gdvp->gdv_gas.gas_anchor_pt_a2, user_pt);
+           } else {
+               VMOVE(gdvp->gdv_gas.gas_anchor_pt_a2, user_pt);
+           }
+
+           ged_calc_adc_a2(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchorpoint_a2' command 
accepts 0 or 3 arguments\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchor_dst") == 0) {
+       if (argc == 0) {
+           bu_vls_printf(&gedp->ged_result_str, "%d", 
gdvp->gdv_gas.gas_anchor_dst);
+
+           return BRLCAD_OK;
+       } else if (argc == 1) {
+           i = (int)user_pt[X];
+
+           if (i) {
+               gdvp->gdv_gas.gas_anchor_dst = 1;
+           } else
+               gdvp->gdv_gas.gas_anchor_dst = 0;
+
+           ged_calc_adc_dst(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchor_dst' command 
accepts 0 or 1 argument\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "anchorpoint_dst") == 0) {
+       if (argc == 0) {
+           VSCALE(scaled_pos, gdvp->gdv_gas.gas_anchor_pt_dst, 
gedp->ged_wdbp->dbip->dbi_base2local);
+           bu_vls_printf(&gedp->ged_result_str, "%.15e %.15e %.15e", 
V3ARGS(scaled_pos));
+
+           return BRLCAD_OK;
+       } else if (argc == 3) {
+           VSCALE(user_pt, user_pt, gedp->ged_wdbp->dbip->dbi_local2base);
+
+           if (incr_flag) {
+               VADD2(gdvp->gdv_gas.gas_anchor_pt_dst, 
gdvp->gdv_gas.gas_anchor_pt_dst, user_pt);
+           } else {
+               VMOVE(gdvp->gdv_gas.gas_anchor_pt_dst, user_pt);
+           }
+
+           ged_calc_adc_dst(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s anchorpoint_dst' command 
accepts 0 or 3 arguments\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "reset") == 0) {
+       if (argc == 0) {
+           ged_adc_reset(&gdvp->gdv_gas, gdvp->gdv_view);
+           go_refresh_view(gdvp);
+
+           return BRLCAD_OK;
+       }
+
+       bu_vls_printf(&gedp->ged_result_str, "The '%s reset' command accepts no 
arguments\n", command);
+       return BRLCAD_ERROR;
+    }
+
+    if (strcmp(parameter, "vars") == 0) {
+       ged_adc_vls_print(&gdvp->gdv_gas, gdvp->gdv_view, 
gedp->ged_wdbp->dbip->dbi_base2local, &gedp->ged_result_str);
+       return BRLCAD_OK;
+    }
+
+    if (strcmp(parameter, "help") == 0) {
+       bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", command, usage);
+       return BRLCAD_HELP;
+    }
+
+    bu_vls_printf(&gedp->ged_result_str, "%s: unrecognized command 
'%s'\nUsage: %s %s\n",
+                 command, parameter, command, usage);
+    return BRLCAD_ERROR;
+}
+
+static int
 go_autoview(struct ged         *gedp,
            int                 argc,
            const char          *argv[],
@@ -1928,6 +2518,15 @@
     new_gdvp->gdv_fbs.fbs_clientData = new_gdvp;
     new_gdvp->gdv_fbs.fbs_interp = go_current_gop->go_interp;
 
+    new_gdvp->gdv_gas.gas_a1 = 45.0;
+    new_gdvp->gdv_gas.gas_a2 = 45.0;
+    new_gdvp->gdv_gas.gas_line_color[0] = 255;
+    new_gdvp->gdv_gas.gas_line_color[1] = 255;
+    new_gdvp->gdv_gas.gas_line_color[2] = 0;
+    new_gdvp->gdv_gas.gas_tick_color[0] = 255;
+    new_gdvp->gdv_gas.gas_tick_color[1] = 255;
+    new_gdvp->gdv_gas.gas_tick_color[2] = 255;
+
     /* open the framebuffer */
     go_open_fbs(new_gdvp, go_current_gop->go_interp);
 
@@ -3297,7 +3896,7 @@
     /*XXX Whether or not and how things are drawn needs to be application 
settable.
      *    For the moment, things are hardwired.
      */
-    /*Draw view axes */
+    /* Draw view axes */
     {
        point_t origin = {0.0, 0.0, 0.0};
        int axes_color[3] = {100, 100, 255};
@@ -3323,6 +3922,10 @@
                         0 /* tick threshold */);
     }
 
+    /* Draw the angle distance cursor */
+    if (gdvp->gdv_gas.gas_draw)
+       dm_draw_adc(gdvp->gdv_dmp, &gdvp->gdv_gas, gdvp->gdv_view);
+
     DM_DRAW_END(gdvp->gdv_dmp);
 }
 


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to