Revision: 52094
          http://brlcad.svn.sourceforge.net/brlcad/?rev=52094&view=rev
Author:   bob1961
Date:     2012-08-17 14:57:34 +0000 (Fri, 17 Aug 2012)
Log Message:
-----------
Added bot_face_split functionality to Archer's bot editing capability.

Modified Paths:
--------------
    brlcad/trunk/include/ged.h
    brlcad/trunk/src/libged/edbot.c
    brlcad/trunk/src/libtclcad/tclcad_obj.c
    brlcad/trunk/src/tclscripts/archer/Archer.tcl
    brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl
    brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl
    brlcad/trunk/src/tclscripts/lib/Ged.tcl

Modified: brlcad/trunk/include/ged.h
===================================================================
--- brlcad/trunk/include/ged.h  2012-08-17 14:24:39 UTC (rev 52093)
+++ brlcad/trunk/include/ged.h  2012-08-17 14:57:34 UTC (rev 52094)
@@ -811,6 +811,11 @@
 GED_EXPORT extern int ged_bot_face_sort(struct ged *gedp, int argc, const char 
*argv[]);
 
 /**
+ * Split the specified bot face into three parts (i.e. by adding a point to 
the center)
+ */
+GED_EXPORT extern int ged_bot_face_split(struct ged *gedp, int argc, const 
char *argv[]);
+
+/**
  * Flip/reverse the specified bot's orientation.
  */
 GED_EXPORT extern int ged_bot_flip(struct ged *gedp, int argc, const char 
*argv[]);

Modified: brlcad/trunk/src/libged/edbot.c
===================================================================
--- brlcad/trunk/src/libged/edbot.c     2012-08-17 14:24:39 UTC (rev 52093)
+++ brlcad/trunk/src/libged/edbot.c     2012-08-17 14:57:34 UTC (rev 52094)
@@ -38,6 +38,118 @@
 
 
 int
+ged_bot_face_split(struct ged *gedp, int argc, const char *argv[])
+{
+    static const char *usage = "bot face";
+    struct directory *dp;
+    static fastf_t sf = 1.0 / 3.0;
+    struct rt_db_internal intern;
+    struct rt_bot_internal *botip;
+    mat_t mat;
+    char *last;
+    size_t face_i;
+    size_t last_vi;
+    size_t save_vi;
+    point_t new_pt;
+
+    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+    /* initialize result */
+    bu_vls_trunc(gedp->ged_result_str, 0);
+
+    /* must be wanting help */
+    if (argc == 1) {
+       bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+       return GED_HELP;
+    }
+
+    if (argc != 3) {
+       bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+       return GED_ERROR;
+    }
+
+    if ((last = strrchr(argv[1], '/')) == NULL)
+       last = (char *)argv[1];
+    else
+       ++last;
+
+    if (last[0] == '\0') {
+       bu_vls_printf(gedp->ged_result_str, "%s: illegal input - %s", argv[0], 
argv[1]);
+       return GED_ERROR;
+    }
+
+    dp = db_lookup(gedp->ged_wdbp->dbip, last, LOOKUP_QUIET);
+    if (dp == RT_DIR_NULL) {
+       bu_vls_printf(gedp->ged_result_str, "%s: failed to find %s", argv[0], 
argv[1]);
+       return GED_ERROR;
+    }
+
+    if (sscanf(argv[2], "%zu", &face_i) != 1) {
+       bu_vls_printf(gedp->ged_result_str, "%s: bad bot vertex index - %s", 
argv[0], argv[2]);
+       return GED_ERROR;
+    }
+
+    if (wdb_import_from_path2(gedp->ged_result_str, &intern, argv[1], 
gedp->ged_wdbp, mat) == GED_ERROR) {
+       bu_vls_printf(gedp->ged_result_str, "%s: failed to find %s", argv[0], 
argv[1]);
+       return GED_ERROR;
+    }
+
+    if (intern.idb_major_type != DB5_MAJORTYPE_BRLCAD ||
+       intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) {
+       bu_vls_printf(gedp->ged_result_str, "Object is not a BOT");
+       rt_db_free_internal(&intern);
+
+       return GED_ERROR;
+    }
+
+    botip = (struct rt_bot_internal *)intern.idb_ptr;
+    last_vi = botip->num_vertices;
+
+    if (face_i >= botip->num_faces) {
+       bu_vls_printf(gedp->ged_result_str, "%s: bad bot face index - %s", 
argv[0], argv[2]);
+       rt_db_free_internal(&intern);
+       return GED_ERROR;
+    }
+
+    /* Create the new point, modify face_i and hook in the two extra faces */
+    /* First, create some space */
+    botip->num_vertices++;
+    botip->num_faces += 2;
+    botip->vertices = bu_realloc((genptr_t)botip->vertices, 
botip->num_vertices*3*sizeof(fastf_t), "realloc bot vertices");
+    botip->faces = bu_realloc((genptr_t)botip->faces, 
botip->num_faces*3*sizeof(int), "realloc bot faces");
+
+    /* Create the new point. For the moment, we're using the average of the 
face_i's points */
+    VADD3(new_pt,
+         &botip->vertices[botip->faces[face_i*3]*3],
+         &botip->vertices[botip->faces[face_i*3+1]*3],
+         &botip->vertices[botip->faces[face_i*3+2]*3]);
+    VSCALE(new_pt, new_pt, sf);
+    
+    /* Add the new point to the last position in the list of vertices. */
+    VMOVE(&botip->vertices[last_vi*3], new_pt);
+
+    /* Update face_i */
+    save_vi = botip->faces[face_i*3+2];
+    botip->faces[face_i*3+2] = last_vi;
+
+    /* Initialize the two new faces */
+    botip->faces[(botip->num_faces-2)*3] = botip->faces[face_i*3+1];
+    botip->faces[(botip->num_faces-2)*3+1] = save_vi;
+    botip->faces[(botip->num_faces-2)*3+2] = last_vi;
+    botip->faces[(botip->num_faces-1)*3] = save_vi;
+    botip->faces[(botip->num_faces-1)*3+1] = botip->faces[face_i*3];
+    botip->faces[(botip->num_faces-1)*3+2] = last_vi;
+
+    bu_vls_printf(gedp->ged_result_str, "%zu", last_vi);
+
+    GED_DB_PUT_INTERNAL(gedp, dp, &intern, &rt_uniresource, GED_ERROR);
+    rt_db_free_internal(&intern);
+    return GED_OK;
+}
+
+
+int
 ged_find_botpt_nearest_pt(struct ged *gedp, int argc, const char *argv[])
 {
     static const char *usage = "bot view_xyz";
@@ -106,8 +218,8 @@
 int
 ged_move_botpt(struct ged *gedp, int argc, const char *argv[])
 {
+    static const char *usage = "[-r] bot vertex_i pt";
     struct directory *dp;
-    static const char *usage = "[-r] bot vertex_i pt";
     struct rt_db_internal intern;
     struct rt_bot_internal *botip;
     mat_t mat;

Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c     2012-08-17 14:24:39 UTC (rev 
52093)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c     2012-08-17 14:57:34 UTC (rev 
52094)
@@ -131,6 +131,12 @@
                    ged_func_ptr func,
                    const char *usage,
                    int maxargs);
+HIDDEN int to_bot_face_split(struct ged *gedp,
+                            int argc,
+                            const char *argv[],
+                            ged_func_ptr func,
+                            const char *usage,
+                            int maxargs);
 HIDDEN int to_bounds(struct ged *gedp,
                     int argc,
                     const char *argv[],
@@ -871,6 +877,7 @@
     {"bot_dump",       (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_bot_dump},
     {"bot_face_fuse",  (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_bot_face_fuse},
     {"bot_face_sort",  (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_bot_face_sort},
+    {"bot_face_split", "bot face", TO_UNLIMITED, to_bot_face_split, 
GED_FUNC_PTR_NULL},
     {"bot_flip",       (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_bot_flip},
     {"bot_fuse",       (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_bot_fuse},
     {"bot_merge",      (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_bot_merge},
@@ -1458,6 +1465,7 @@
 
 
 /*************************** Local Command Functions 
***************************/
+
 HIDDEN int
 to_autoview(struct ged *gedp,
            int argc,
@@ -10893,7 +10901,40 @@
     return GED_OK;
 }
 
+
 HIDDEN int
+to_bot_face_split(struct ged *gedp,
+                 int argc,
+                 const char *argv[],
+                 ged_func_ptr UNUSED(func),
+                 const char *UNUSED(usage),
+                 int UNUSED(maxargs))
+{
+    int ret;
+
+    if ((ret = ged_bot_face_split(gedp, argc, argv)) == GED_OK) {
+       char *av[3];
+       struct bu_vls save_result;
+
+       bu_vls_init(&save_result);
+
+       av[0] = "draw";
+       av[1] = (char *)argv[1];
+       av[2] = (char *)0;
+       to_edit_redraw(gedp, 2, (const char **)av);
+
+       bu_vls_trunc(gedp->ged_result_str, 0);
+       bu_vls_printf(gedp->ged_result_str, "%V", &save_result);
+       bu_vls_free(&save_result);
+
+       return GED_OK;
+    }
+
+    return ret;
+}
+
+
+HIDDEN int
 to_translate_mode(struct ged *gedp,
                  int argc,
                  const char *argv[],

Modified: brlcad/trunk/src/tclscripts/archer/Archer.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/Archer.tcl       2012-08-17 14:24:39 UTC 
(rev 52093)
+++ brlcad/trunk/src/tclscripts/archer/Archer.tcl       2012-08-17 14:57:34 UTC 
(rev 52094)
@@ -153,12 +153,14 @@
 
        method importFg4Sections   {_slist _wlist _delta}
        method initAppendPipePoint {_obj _button _callback}
+       method initFindBotFace {_obj _button _callback}
        method initFindBotPoint {_obj _button _callback}
        method initFindPipePoint {_obj _button _callback}
        method initPrependPipePoint {_obj _button _callback}
 
        # General
        method askToRevert {}
+       method bot_find_face {_bot _mx _my}
        method bot_fix_all {}
        method bot_fix_all_wrapper {}
        method bot_flip_check      {args}
@@ -748,6 +750,18 @@
 }
 
 
+::itcl::body Archer::initFindBotFace {_obj _button _callback} {
+    if {![info exists itk_component(ged)]} {
+       return
+    }
+
+    # This deselects the selected mouse mode in the primary toolbar
+    set mDefaultBindingMode FIRST_FREE_BINDING_MODE
+
+    $itk_component(ged) init_find_bot_face $_obj $_button [expr 
{$mZClipFrontMax * $mZClipFront}] $_callback
+}
+
+
 ::itcl::body Archer::initFindBotPoint {_obj _button _callback} {
     if {![info exists itk_component(ged)]} {
        return
@@ -1067,6 +1081,11 @@
 }
 
 
+::itcl::body Archer::bot_find_face {_bot _mx _my} {
+#    set view [lreplace $view 2 2 [expr {$mZClipFrontMax * $mZClipFront}]]
+}
+
+
 ::itcl::body Archer::bot_fix_all {} {
     set mBotFixAllFlag 1
 

Modified: brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl   2012-08-17 14:24:39 UTC 
(rev 52093)
+++ brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl   2012-08-17 14:57:34 UTC 
(rev 52094)
@@ -5364,12 +5364,7 @@
 }
 
 ::itcl::body ArcherCore::shootRay_doit {_start _op _target _prep _no_bool 
_onehit _bot_dflag _objects} {
-    eval $itk_component(ged) rt_gettrees ray -i -u $_objects
-    ray prep $_prep
-    ray set no_bool $_no_bool
-    ray set onehit $_onehit
-    ray set bot_reverse_normal_disabled $_bot_dflag
-
+    init_shoot_ray ray $_prep $_no_bool $_onehit $_bot_dflag $_objects
     return [ray shootray $_start $_op $_target]
 }
 

Modified: brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl 2012-08-17 14:24:39 UTC 
(rev 52093)
+++ brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl 2012-08-17 14:57:34 UTC 
(rev 52094)
@@ -34,17 +34,25 @@
 
     public {
        common SELECT_COL 0
+       common A_COL 1
+       common B_COL 2
+       common C_COL 3
        common X_COL 1
        common Y_COL 2
        common Z_COL 3
 
-       common selectPoint 1
-       common movePoint 2
+       common movePoint 1
+       common selectFace 2
+       common selectPoint 3
+       common splitFace 4
 
-       common mDetailHeadings {{} X Y Z}
+       common mVertDetailHeadings {{} X Y Z}
+       common mFaceDetailHeadings {{} A B C}
        common mEditLabels {
+           {Move Point}
+           {Select Face}
            {Select Point}
-           {Move Point}
+           {Split Face}
        }
 
        # Override what's in GeometryEditFrame
@@ -57,8 +65,10 @@
     }
 
     protected {
-       variable mDetail
+       variable mVertDetail
+       variable mFaceDetail
        variable mCurrentBotPoint 1
+       variable mCurrentBotFace 1
 
        # Methods used by the constructor
        # override methods in GeometryEditFrame
@@ -70,11 +80,14 @@
        method initEditState {}
 
        method applyData {}
+       method botFaceSelectCallback {_pindex}
+       method botFaceSplitCallback {_pindex}
+       method botPointSelectCallback {_pindex}
        method detailBrowseCommand {_row _col}
        method handleDetailPopup {_index _X _Y}
        method handleEnter {_row _col}
-       method botPointSelectCallback {_pindex}
-       method singleSelectCallback {_pindex}
+       method singleFaceSelectCallback {_pindex}
+       method singlePointSelectCallback {_pindex}
        method validateDetailEntry {_row _col _newval _clientdata}
     }
 
@@ -104,15 +117,24 @@
 # Initialize the variables containing the object's specification.
 #
 ::itcl::body BotEditFrame::initGeometry {gdata} {
-    unset mDetail
-    set mDetail(active) ""
+    unset mVertDetail
+    unset mFaceDetail
 
+    set mVertDetail(active) ""
+    set mFaceDetail(active) ""
+
     set col 0
-    foreach heading $mDetailHeadings {
-       set mDetail(0,$col) $heading
+    foreach heading $mVertDetailHeadings {
+       set mVertDetail(0,$col) $heading
        incr col
     }
 
+    set col 0
+    foreach heading $mFaceDetailHeadings {
+       set mFaceDetail(0,$col) $heading
+       incr col
+    }
+
     foreach {attr val} $gdata {
        switch -- $attr {
            "mode" {
@@ -124,14 +146,22 @@
            "V" {
                set index 1
                foreach item $val {
-                   set mDetail($index,$SELECT_COL) ""
-                   set mDetail($index,$X_COL) [lindex $item 0]
-                   set mDetail($index,$Y_COL) [lindex $item 1]
-                   set mDetail($index,$Z_COL) [lindex $item 2]
+                   set mVertDetail($index,$SELECT_COL) ""
+                   set mVertDetail($index,$X_COL) [lindex $item 0]
+                   set mVertDetail($index,$Y_COL) [lindex $item 1]
+                   set mVertDetail($index,$Z_COL) [lindex $item 2]
                    incr index
                }
            }
            "F" {
+               set index 1
+               foreach item $val {
+                   set mFaceDetail($index,$SELECT_COL) ""
+                   set mFaceDetail($index,$A_COL) [lindex $item 0]
+                   set mFaceDetail($index,$B_COL) [lindex $item 1]
+                   set mFaceDetail($index,$C_COL) [lindex $item 2]
+                   incr index
+               }
            }
            default {
                # Shouldn't get here
@@ -161,7 +191,7 @@
     set pipe_spec {}
     set pt {}
 
-    foreach aname [lsort [array names mDetail]] {
+    foreach aname [lsort [array names mVertDetail]] {
        set alist [split $aname ","]
        if {[llength $alist] != 2} {
            continue
@@ -180,25 +210,25 @@
 
        switch -- $col \
            $OD_COL {
-               lappend pipe_spec O$index $mDetail($row,$col)
+               lappend pipe_spec O$index $mVertDetail($row,$col)
            } \
            $ID_COL {
-               lappend pipe_spec I$index $mDetail($row,$col)
+               lappend pipe_spec I$index $mVertDetail($row,$col)
            } \
            $RADIUS_COL {
-               lappend pipe_spec R$index $mDetail($row,$col)
+               lappend pipe_spec R$index $mVertDetail($row,$col)
            } \
            $PX_COL - \
            $PY_COL {
-               lappend pt $mDetail($row,$col)
+               lappend pt $mVertDetail($row,$col)
            } \
            $PZ_COL {
-               lappend pt $mDetail($row,$col)
+               lappend pt $mVertDetail($row,$col)
                lappend pipe_spec V$index $pt
                set pt {}
            } \
            default {
-               puts "Encountered bad one - $mDetail($row,$col)"
+               puts "Encountered bad one - $mVertDetail($row,$col)"
            }
     }
 
@@ -272,10 +302,16 @@
 ::itcl::body BotEditFrame::buildUpperPanel {} {
     set parent [$this childsite]
 
-    itk_component add detailTab {
-       ::cadwidgets::TkTable $parent.detailTab \
-           [::itcl::scope mDetail] \
-           $mDetailHeadings \
+    itk_component add vertTabLF {
+       ::ttk::labelframe $parent.vertTabLF \
+           -text "Bot Vertices" \
+           -labelanchor n
+    } {}
+
+    itk_component add vertTab {
+       ::cadwidgets::TkTable $itk_component(vertTabLF).vertTab \
+           [::itcl::scope mVertDetail] \
+           $mVertDetailHeadings \
            -cursor arrow \
            -height 0 \
            -maxheight 2000 \
@@ -285,17 +321,50 @@
            -validate 1 \
            -validatecommand [::itcl::code $this validateDetailEntry] \
            -tablePopupHandler [::itcl::code $this handleDetailPopup] \
-           -entercommand [::itcl::code $this handleEnter] \
-           -singleSelectCallback [::itcl::code $this singleSelectCallback]
+           -singleSelectCallback [::itcl::code $this singlePointSelectCallback]
     } {}
+#          -entercommand [::itcl::code $this handleEnter]
 #          -browsecommand [::itcl::code $this detailBrowseCommand %r %c]
 #          -dataCallback [::itcl::code $this applyData]
 
+
+    itk_component add faceTabLF {
+       ::ttk::labelframe $parent.faceTabLF \
+           -text "Bot Faces" \
+           -labelanchor n
+    } {}
+
+    itk_component add faceTab {
+       ::cadwidgets::TkTable $itk_component(faceTabLF).faceTab \
+           [::itcl::scope mFaceDetail] \
+           $mFaceDetailHeadings \
+           -cursor arrow \
+           -height 0 \
+           -maxheight 2000 \
+           -width 0 \
+           -rows 100000 \
+           -colstretchmode unset \
+           -validate 1 \
+           -validatecommand [::itcl::code $this validateDetailEntry] \
+           -tablePopupHandler [::itcl::code $this handleDetailPopup] \
+           -singleSelectCallback [::itcl::code $this singleFaceSelectCallback]
+    } {}
+
     # Set width of column 0
-    $itk_component(detailTab) width 0 3
+    $itk_component(vertTab) width 0 3
+    $itk_component(faceTab) width 0 3
 
-    pack $itk_component(detailTab) -expand yes -fill both
-    pack $parent -expand yes -fill both
+    pack $itk_component(vertTab) -expand yes -fill both
+    pack $itk_component(faceTab) -expand yes -fill both
+
+    set row 0
+    grid $itk_component(vertTabLF) -row $row -sticky nsew
+    grid rowconfigure $parent $row -weight 1
+    incr row
+    grid $itk_component(faceTabLF) -row $row -sticky nsew
+    grid rowconfigure $parent $row -weight 1
+
+    grid columnconfigure $parent 0 -weight 1
 }
 
 ::itcl::body BotEditFrame::buildLowerPanel {} {
@@ -338,24 +407,24 @@
 
        switch -regexp -- $attr {
            {[Vv][0-9]+} {
-               if {$mDetail($index,$PX_COL) != [lindex $val 0] ||
-                   $mDetail($index,$PY_COL) != [lindex $val 1] ||
-                   $mDetail($index,$PZ_COL) != [lindex $val 2]} {
+               if {$mVertDetail($index,$PX_COL) != [lindex $val 0] ||
+                   $mVertDetail($index,$PY_COL) != [lindex $val 1] ||
+                   $mVertDetail($index,$PZ_COL) != [lindex $val 2]} {
                    set doUpdate 1
                }
            }
            {[Oo][0-9]+} {
-               if {$mDetail($index,$OD_COL) != $val} {
+               if {$mVertDetail($index,$OD_COL) != $val} {
                    set doUpdate 1
                }
            }
            {[Ii][0-9]+} {
-               if {$mDetail($index,$ID_COL) != $val} {
+               if {$mVertDetail($index,$ID_COL) != $val} {
                    set doUpdate 1
                }
            }
            {[Rr][0-9]+} {
-               if {$mDetail($index,$RADIUS_COL) != $val} {
+               if {$mVertDetail($index,$RADIUS_COL) != $val} {
                    set doUpdate 1
                }
            }
@@ -378,17 +447,30 @@
 #    configure -valueUnits "mm"
 
     set mEditPCommand [::itcl::code $this p]
-    set mEditParam1 [expr {$mCurrentBotPoint - 1}]
 
     switch -- $mEditMode \
+       $movePoint {
+           set mEditCommand move_botpt
+           set mEditClass $EDIT_CLASS_TRANS
+           set mEditParam1 [expr {$mCurrentBotPoint - 1}]
+       } \
+       $selectFace {
+           set mEditCommand ""
+           set mEditClass ""
+           set mEditParam1 [expr {$mCurrentBotFace - 1}]
+           $::ArcherCore::application initFindBotFace 
$itk_option(-geometryObjectPath) 1 [::itcl::code $this botFaceSelectCallback]
+       } \
        $selectPoint {
            set mEditCommand ""
            set mEditClass ""
+           set mEditParam1 [expr {$mCurrentBotPoint - 1}]
            $::ArcherCore::application initFindBotPoint 
$itk_option(-geometryObjectPath) 1 [::itcl::code $this botPointSelectCallback]
        } \
-       $movePoint {
-           set mEditCommand move_botpt
-           set mEditClass $EDIT_CLASS_TRANS
+       $splitFace {
+           set mEditCommand ""
+           set mEditClass ""
+           set mEditParam1 [expr {$mCurrentBotFace - 1}]
+           $::ArcherCore::application initFindBotFace 
$itk_option(-geometryObjectPath) 1 [::itcl::code $this botFaceSplitCallback]
        }
 
     GeometryEditFrame::initEditState
@@ -397,12 +479,34 @@
 ::itcl::body BotEditFrame::applyData {} {
 }
 
+::itcl::body BotEditFrame::botFaceSelectCallback {_pindex} {
+    set mEditParam1 $_pindex
+    incr _pindex
+    set mCurrentBotFace $_pindex
+    $itk_component(faceTab) selectSingleRow $_pindex
+}
+
+::itcl::body BotEditFrame::botFaceSplitCallback {_pindex} {
+    set mEditParam1 $_pindex
+    incr _pindex
+    set mCurrentBotFace $_pindex
+    $itk_component(faceTab) selectSingleRow $_pindex
+    $itk_option(-mged) bot_face_split $itk_option(-geometryObjectPath) 
$mEditParam1
+}
+
+::itcl::body BotEditFrame::botPointSelectCallback {_pindex} {
+    set mEditParam1 $_pindex
+    incr _pindex
+    set mCurrentBotPoint $_pindex
+    $itk_component(vertTab) selectSingleRow $_pindex
+}
+
 ::itcl::body BotEditFrame::detailBrowseCommand {_row _col} {
-    if {![info exists mDetail($_row,0)]} {
+    if {![info exists mVertDetail($_row,0)]} {
        return 0
     }
 
-    $itk_component(detailTab) see $_row,$_col
+    $itk_component(vertTab) see $_row,$_col
 }
 
 ::itcl::body BotEditFrame::handleDetailPopup {_index _X _Y} {
@@ -420,21 +524,22 @@
     updateGeometryIfMod
 }
 
-::itcl::body BotEditFrame::botPointSelectCallback {_pindex} {
-    set mEditParam1 $_pindex
-    incr _pindex
-    set mCurrentBotPoint $_pindex
-    $itk_component(detailTab) selectSingleRow $_pindex
+::itcl::body BotEditFrame::singleFaceSelectCallback {_pindex} {
+    set mCurrentBotFace $_pindex
+    set mEditParam1 [expr {$mCurrentBotFace - 1}]
+    initEditState
 }
 
-::itcl::body BotEditFrame::singleSelectCallback {_pindex} {
+::itcl::body BotEditFrame::singlePointSelectCallback {_pindex} {
     set mCurrentBotPoint $_pindex
     set mEditParam1 [expr {$mCurrentBotPoint - 1}]
     initEditState
 }
 
 ::itcl::body BotEditFrame::validateDetailEntry {_row _col _newval _clientdata} 
{
-    if {![info exists mDetail($_row,0)]} {
+    return 0
+
+    if {![info exists mVertDetail($_row,0)]} {
        return 0
     }
 

Modified: brlcad/trunk/src/tclscripts/lib/Ged.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/lib/Ged.tcl     2012-08-17 14:24:39 UTC (rev 
52093)
+++ brlcad/trunk/src/tclscripts/lib/Ged.tcl     2012-08-17 14:57:34 UTC (rev 
52094)
@@ -128,6 +128,7 @@
        method bot_dump {args}
        method bot_face_fuse {args}
        method bot_face_sort {args}
+       method bot_face_split {args}
        method bot_flip {args}
        method bot_merge {args}
        method bot_smooth {args}
@@ -334,6 +335,7 @@
        method pane_mouse_append_pipept {_pane args}
        method pane_mouse_constrain_rot {_pane args}
        method pane_mouse_constrain_trans {_pane args}
+       method pane_mouse_find_bot_face {_pane _bot _viewz _mx _my}
        method pane_mouse_find_botpt {_pane args}
        method pane_mouse_find_pipept {_pane args}
        method pane_mouse_move_arb_edge {_pane args}
@@ -609,6 +611,7 @@
        method init_data_poly_cont {{_button 1}}
        method init_data_poly_ell {{_button 1}}
        method init_data_poly_rect {{_button 1} {_sflag 0}}
+       method init_find_bot_face {_obj {_button 1} {_viewz 1.0} {_callback {}}}
        method init_find_botpt {_obj {_button 1} {_callback {}}}
        method init_find_pipept {_obj {_button 1} {_callback {}}}
        method init_prepend_pipept {_obj {_button 1} {_callback {}}}
@@ -627,7 +630,9 @@
        method pane_mouse_data_pick {_pane _x _y}
        method pane_mouse_ray {_pane _x _y {_pflag 0}}
        method pane {args}
-       method shoot_ray {_start _op _target _prep _no_bool _onehit}
+       method init_shoot_ray {_rayname _prep _no_bool _onehit _bot_dflag 
_objects}
+       method shoot_ray_who {_start _op _target _prep _no_bool _onehit 
_bot_dflag}
+       method shoot_ray {_rayname _start _op _target _prep _no_bool _onehit 
_bot_dflag _objects}
 
        method add_begin_data_arrow_callback {_callback}
        method clear_begin_data_arrow_callback_list {}
@@ -702,6 +707,7 @@
        variable mGed ""
        variable mSharedGed 0
        variable mHistoryCallback ""
+       variable mBotFaceCallback ""
        variable mBotPointCallback ""
        variable mPipePointCallback ""
        variable mMeasuringStickColorVDraw2D ff00ff
@@ -740,7 +746,7 @@
        variable mPolyEllCallbacks ""
        variable mPolyRectCallbacks ""
 
-       variable mRay "ray"
+       variable mRay "ged_ray"
        variable mRayCurrWho ""
        variable mRayLastWho ""
        variable mRayNeedGettrees 1
@@ -1108,6 +1114,10 @@
     eval $mGed bot_face_sort $args
 }
 
+::itcl::body cadwidgets::Ged::bot_face_split {args} {
+    eval $mGed bot_face_split $args
+}
+
 ::itcl::body cadwidgets::Ged::bot_flip {args} {
     eval $mGed bot_flip $args
 }
@@ -1770,11 +1780,7 @@
 }
 
 ::itcl::body cadwidgets::Ged::mouse_find_pipept {args} {
-    set i [eval $mGed mouse_find_pipept $itk_component($itk_option(-pane)) 
$args]
-
-    if {$mPipePointCallback != ""} {
-       catch {$mPipePointCallback $i}
-    }
+    eval $mGed mouse_find_pipept $itk_component($itk_option(-pane)) $args
 }
 
 ::itcl::body cadwidgets::Ged::mouse_move_arb_edge {args} {
@@ -2090,10 +2096,38 @@
     eval $mGed mouse_constrain_rot $itk_component($_pane) $args
 }
 
+
 ::itcl::body cadwidgets::Ged::pane_mouse_constrain_trans {_pane args} {
     eval $mGed mouse_constrain_trans $itk_component($_pane) $args
 }
 
+
+::itcl::body cadwidgets::Ged::pane_mouse_find_bot_face {_pane _bot _viewz _mx 
_my} {
+    if {[get_type $_bot] != "bot"} {
+       return ""
+    }
+
+    set view [pane_screen2view $_pane $_mx $_my]
+    set target [eval pane_v2m_point $_pane $view]
+
+    set view [lreplace $view 2 2 $_viewz]
+    set start [eval pane_v2m_point $_pane $view]
+
+    set partitions [shoot_ray bot_ray $start "at" $target 1 1 1 1 $_bot]
+    set partition [lindex $partitions 0]
+    if {[catch {bu_get_value_by_keyword in $partition} in] ||
+       [catch {bu_get_value_by_keyword surfno $in} surfno]} {
+       return ""
+    }
+
+    if {$mBotFaceCallback != ""} {
+       catch {$mBotFaceCallback $surfno}
+    }
+
+    return $surfno
+}
+
+
 ::itcl::body cadwidgets::Ged::pane_mouse_find_botpt {_pane args} {
     set i [eval $mGed mouse_find_botpt $itk_component($_pane) $args]
 
@@ -2104,6 +2138,7 @@
     return $i
 }
 
+
 ::itcl::body cadwidgets::Ged::pane_mouse_find_pipept {_pane args} {
     set i [eval $mGed mouse_find_pipept $itk_component($_pane) $args]
 
@@ -2114,6 +2149,7 @@
     return $i
 }
 
+
 ::itcl::body cadwidgets::Ged::pane_mouse_move_arb_edge {_pane args} {
     eval $mGed mouse_move_arb_edge $itk_component($_pane) $args
 }
@@ -3873,6 +3909,18 @@
 }
 
 
+::itcl::body cadwidgets::Ged::init_find_bot_face {_obj {_button 1} {_viewz 
1.0} {_callback {}}} {
+    measure_line_erase
+
+    set mBotFaceCallback $_callback
+
+    foreach dm {ur ul ll lr} {
+       bind $itk_component($dm) <$_button> "[::itcl::code $this 
pane_mouse_find_bot_face $dm $_obj $_viewz %x %y]; focus %W; break"
+       bind $itk_component($dm) <ButtonRelease-$_button> ""
+    }
+}
+
+
 ::itcl::body cadwidgets::Ged::init_find_botpt {_obj {_button 1} {_callback 
{}}} {
     measure_line_erase
 
@@ -4119,7 +4167,7 @@
     set mLastMouseRayStart [$mGed v2m_point $itk_component($_pane) [lindex 
$view 0] [lindex $view 1] $vZ]
     set mLastMouseRayTarget [$mGed v2m_point $itk_component($_pane) [lindex 
$view 0] [lindex $view 1] 0]
 
-    if {[catch {shoot_ray $mLastMouseRayStart "at" $mLastMouseRayTarget 1 1 0} 
partitions]} {
+    if {[catch {shoot_ray_who $mLastMouseRayStart "at" $mLastMouseRayTarget 1 
1 0 1} partitions]} {
        return $partitions
     }
 
@@ -4272,26 +4320,43 @@
     }
 }
 
-::itcl::body cadwidgets::Ged::shoot_ray {_start _op _target _prep _no_bool 
_onehit} {
+
+::itcl::body cadwidgets::Ged::init_shoot_ray {_rayname _prep _no_bool _onehit 
_bot_dflag _objects} {
+    eval rt_gettrees $_rayname -i -u $_objects
+    $_rayname prep $_prep
+    $_rayname set no_bool $_no_bool
+    $_rayname set onehit $_onehit
+    $_rayname set bot_reverse_normal_disabled $_bot_dflag
+}
+
+
+::itcl::body cadwidgets::Ged::shoot_ray {_rayname _start _op _target _prep 
_no_bool _onehit _bot_dflag _objects} {
     SetWaitCursor $this
 
+    init_shoot_ray $_rayname $_prep $_no_bool $_onehit $_bot_dflag $_objects
+    set result [$_rayname shootray $_start $_op $_target]
+
+    SetNormalCursor $this
+    return $result
+}
+
+
+::itcl::body cadwidgets::Ged::shoot_ray_who {_start _op _target _prep _no_bool 
_onehit _bot_dflag} {
+    SetWaitCursor $this
+
     set result ""
     catch {
        if {$mRayCurrWho != $mRayLastWho || $mRayNeedGettrees} {
            set mRayCurrWho [$mGed who]
-           eval $mGed rt_gettrees $mRay -i -u $mRayCurrWho
-           $mRay prep $_prep
-           $mRay no_bool $_no_bool
-           $mRay onehit $_onehit
            set mRayLastWho $mRayCurrWho
            set mRayNeedGettrees 0
+           init_shoot_ray $mRay $_prep $_no_bool $_onehit $_bot_dflag 
$mRayCurrWho
        }
 
        set result [$mRay shootray $_start $_op $_target]
     }
 
     SetNormalCursor $this
-
     return $result
 }
 

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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to