Revision: 53642
          http://brlcad.svn.sourceforge.net/brlcad/?rev=53642&view=rev
Author:   bob1961
Date:     2012-11-09 20:25:44 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
Added highlighting of points, edges and faces when editing bots.

Modified Paths:
--------------
    brlcad/trunk/src/tclscripts/archer/Archer.tcl
    brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl
    brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl

Modified: brlcad/trunk/src/tclscripts/archer/Archer.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/Archer.tcl       2012-11-09 19:49:32 UTC 
(rev 53641)
+++ brlcad/trunk/src/tclscripts/archer/Archer.tcl       2012-11-09 20:25:44 UTC 
(rev 53642)
@@ -203,6 +203,7 @@
        variable mActiveEditDialogs {}
        variable wizardXmlCallbacks ""
        variable mBotFixAllFlag 0
+       variable mNumSelectedBotPts 0
 
        # plugin list
        variable mWizardClass ""
@@ -211,13 +212,18 @@
        variable mNoWizardActive 0
 
        # ArcherCore Override Section
+       method beginViewRotate {}
+       method beginViewScale {}
+       method beginViewTranslate {}
        method buildCommandView {}
        method compSelectCallback {_mstring}
        method dblClick {_tags}
        method handleTreeSelect {}
+       method initCompPick {}
        method initCompSelect {}
        method initDefaultBindings {{_comp ""}}
        method initGed {}
+       method initViewCenterMode {}
        method setActivePane {_pane}
        method updateSaveMode {}
 
@@ -1648,6 +1654,11 @@
     set mDbTitle [$itk_component(ged) title]
     set mDbUnits [$itk_component(ged) units -s]
 
+    # Reset the bot edit panel
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
     if {!$mViewOnly} {
        initDbAttrView $mTarget
        applyPreferences
@@ -1955,6 +1966,34 @@
 
 ################################### ArcherCore Override Section 
###################################
 
+
+::itcl::body Archer::beginViewRotate {} {
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
+    ArcherCore::beginViewRotate
+}
+
+
+::itcl::body Archer::beginViewScale {} {
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
+    ArcherCore::beginViewScale
+}
+
+
+::itcl::body Archer::beginViewTranslate {} {
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
+    ArcherCore::beginViewTranslate
+}
+
+
 ::itcl::body Archer::buildCommandView {} {
     set mDelayCommandViewBuild 1
 }
@@ -2018,6 +2057,8 @@
                catch {$itk_component(botView) selectBotPts $_mstring} msg
            }
        }
+
+    $itk_component(ged) rect dim 0 0
 }
 
 
@@ -2088,7 +2129,20 @@
 }
 
 
+::itcl::body Archer::initCompPick {} {
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
+    ArcherCore::initCompPick
+}
+
+
 ::itcl::body Archer::initCompSelect {} {
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState 1
+    }
+
     if {$mCompSelectMode != $COMP_SELECT_LIST_MODE &&
        $mCompSelectMode != $COMP_SELECT_LIST_PARTIAL_MODE &&
        $mCompSelectMode != $COMP_SELECT_BOT_POINTS_MODE} {
@@ -2102,10 +2156,6 @@
        $mCompSelectMode == $COMP_SELECT_GROUP_REMOVE_PARTIAL_MODE} {
        $itk_component(ged) init_view_rect 1 1
     } elseif {$mCompSelectMode == $COMP_SELECT_BOT_POINTS_MODE && 
$mSelectedObj != "" && $mSelectedObjType == "bot"} {
-       if {[info exists itk_component(botView)]} {
-           $itk_component(botView) clearEditState
-       }
-
        $itk_component(ged) init_view_rect 1 0 $mSelectedObj
     } else {
        $itk_component(ged) init_view_rect 1 0
@@ -2165,6 +2215,15 @@
 }
 
 
+::itcl::body Archer::initViewCenterMode {} {
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
+    ArcherCore::initViewCenterMode
+}
+
+
 ::itcl::body Archer::setActivePane {_pane} {
     $itk_component(rtcntrl) setActivePane $_pane
 }
@@ -6058,6 +6117,10 @@
        return
     }
 
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
     if {$GeometryEditFrame::mEditClass != $GeometryEditFrame::EDIT_CLASS_ROT} {
        initEdit
     }
@@ -6093,6 +6156,10 @@
        return
     }
 
+    if {[info exists itk_component(botView)]} {
+       $itk_component(botView) clearEditState
+    }
+
     if {$GeometryEditFrame::mEditClass != 
$GeometryEditFrame::EDIT_CLASS_SCALE} {
        initEdit
     }
@@ -6128,6 +6195,10 @@
        initEdit
     }
 
+    if {$mSelectedObjType == "bot"} {
+       set mNumSelectedBotPts [$itk_component(botView) setMoveMode 1]
+    }
+
     $itk_component(ged) init_button_no_op 2
     set ::GeometryEditFrame::mEditLastTransMode $OBJECT_TRANSLATE_MODE
 
@@ -6136,7 +6207,11 @@
 
        if {$GeometryEditFrame::mEditCommand != ""} {
            if {$mSelectedObjType == "bot"} {
-               bind $win <1> "$itk_component(botView) 
$GeometryEditFrame::mEditCommand $dname $obj %x %y; break"
+               if {$mNumSelectedBotPts} {
+                   bind $win <1> "$itk_component(botView) 
$GeometryEditFrame::mEditCommand $dname $obj %x %y; break"
+               } else {
+                   bind $win <1> "$itk_component(ged) pane_otranslate_mode 
$dname $obj %x %y; break"
+               }
            } else {
                bind $win <1> "$itk_component(ged) 
pane_$GeometryEditFrame::mEditCommand\_mode $dname $obj 
$GeometryEditFrame::mEditParam1 %x %y; break"
            }
@@ -6160,6 +6235,14 @@
        return
     }
 
+    if {$mSelectedObjType == "bot"} {
+       set mNumSelectedBotPts [$itk_component(botView) setMoveMode]
+
+       if {$mNumSelectedBotPts != 1} {
+           $itk_component(botView) clearEditState
+       }
+    }
+
     if {$GeometryEditFrame::mEditClass != 
$GeometryEditFrame::EDIT_CLASS_TRANS} {
        initEdit
     }
@@ -6255,8 +6338,12 @@
        } else {
            if {$GeometryEditFrame::mEditCommand != ""} {
                if {$mSelectedObjType == "bot"} {
-                   set sl [gedCmd pane_view2screen $_dm [list $vx $vy]]
-                   $itk_component(botView) moveBotElement $_dm $_obj [lindex 
$sl 0] [lindex $sl 1]
+                   if {$mNumSelectedBotPts == 1} {
+                       set sl [gedCmd pane_view2screen $_dm [list $vx $vy]]
+                       $itk_component(botView) moveBotElement $_dm $_obj 
[lindex $sl 0] [lindex $sl 1]
+                   } else {
+                       eval gedCmd ocenter $_obj $new_ocenter
+                   }
                } else {
                    $itk_component(ged) $GeometryEditFrame::mEditCommand $_obj 
$GeometryEditFrame::mEditParam1 $new_ocenter
                }
@@ -8108,6 +8195,11 @@
 
     if {$mPrimitiveLabelColor != $mPrimitiveLabelColorPref} {
        set mPrimitiveLabelColor $mPrimitiveLabelColorPref
+
+       if {$mSelectedObjType == "bot"} {
+           eval gedCmd data_axes color [getRgbColor $mPrimitiveLabelColor]
+           eval gedCmd data_lines color [getRgbColor $mPrimitiveLabelColor]
+       }
     }
 
     if {$mViewingParamsColor != $mViewingParamsColorPref} {

Modified: brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl 2012-11-09 19:49:32 UTC 
(rev 53641)
+++ brlcad/trunk/src/tclscripts/archer/BotEditFrame.tcl 2012-11-09 20:25:44 UTC 
(rev 53642)
@@ -9,7 +9,7 @@
 # version 2.1 as published by the Free Software Foundation.
 #
 # This library is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of   common 
mEditLastTransMode $::ArcherCore::OBJECT_CENTER_MODE
+# 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.
@@ -30,7 +30,7 @@
 ##
 # TODO
 #
-# -) Highlight selected points
+# -) Add constrained translation of bot elements (i.e. points, edges, faces). 
Generalize for use with other primitives.
 # -) Delete points, faces and edges
 # -) Operations to create/extend surface mode bots
 #    - Three pts are specified to create a face.
@@ -75,8 +75,10 @@
            {Split Face}
        }
 
-       method clearEditState {}
+       method clearEditState {{_clearModeOnly 0}}
+       method clearAllTables {}
        method selectBotPts {_plist}
+       method setMoveMode {{_tflag 0}}
 
        # Override what's in GeometryEditFrame
        method initGeometry {_gdata}
@@ -103,6 +105,9 @@
        variable mCurrentBotEdges ""
        variable mCurrentBotFaces ""
        variable mFrontPointsOnly 1
+       variable mHighlightPoints 1
+       variable mHighlightPointSize 1.0
+       variable mHighlightPointColor {255 255 255}
 
        # Methods used by the constructor
        # override methods in GeometryEditFrame
@@ -123,6 +128,8 @@
        method detailBrowseCommand {_row _col}
        method handleDetailPopup {_index _X _Y}
        method handleEnter {_row _col}
+       method highlightCurrentBotElements {}
+       method initPointHighlight {}
        method loadTables {_gdata}
        method multiEdgeSelectCallback {}
        method multiFaceSelectCallback {}
@@ -132,6 +139,7 @@
        method syncTablesWrtEdges {}
        method syncTablesWrtFaces {}
        method validateDetailEntry {_row _col _newval _clientdata}
+       method validatePointSize {_size}
     }
 
     private {}
@@ -157,11 +165,31 @@
 
 
 
-::itcl::body BotEditFrame::clearEditState {} {
+::itcl::body BotEditFrame::clearEditState {{_clearModeOnly 0}} {
     set mEditMode 0
+
+    if {$_clearModeOnly} {
+       return
+    }
+
+    clearAllTables
+    set itk_option(-prevGeometryObject) ""
 }
 
 
+::itcl::body BotEditFrame::clearAllTables {} {
+    $itk_option(-mged) data_axes points {}
+    $itk_option(-mged) data_lines points {}
+
+    set mCurrentBotPoints ""
+    set mCurrentBotEdges ""
+    set mCurrentBotFaces ""
+    $itk_component(vertTab) unselectAllRows
+    $itk_component(edgeTab) unselectAllRows
+    $itk_component(faceTab) unselectAllRows
+}
+
+
 ::itcl::body BotEditFrame::selectBotPts {_plist} {
     foreach item $_plist {
        incr item
@@ -175,6 +203,30 @@
 }
 
 
+## - setMoveMode
+#
+#
+::itcl::body BotEditFrame::setMoveMode {{_tflag 0}} {
+    set len [llength $mCurrentBotPoints]
+
+    if {$len} {
+       set mEditPCommand [::itcl::code $this p]
+       set mEditParam1 ""
+       set mEditClass $EDIT_CLASS_TRANS
+       set mEditLastTransMode $::ArcherCore::OBJECT_TRANSLATE_MODE
+
+       if {$mEditMode != $movePoints && $mEditMode != $moveEdge && $mEditMode 
!= $moveFace} {
+           set mEditMode $movePoints
+           set mEditCommand moveBotPtsMode
+       }
+    } elseif {$_tflag && ($mEditMode == $movePoints || $mEditMode == $moveEdge 
|| $mEditMode == $moveFace)} {
+       set len 1
+    }
+
+    return $len
+}
+
+
 ## - initGeometry
 #
 # Initialize the variables containing the object's specification.
@@ -189,11 +241,11 @@
 
     GeometryEditFrame::initGeometry $_gdata
 
-    if {$itk_option(-geometryObject) != $mPrevGeometryObject} {
+    if {$itk_option(-geometryObject) != $itk_option(-prevGeometryObject)} {
        set mCurrentBotPoints ""
        set mCurrentBotEdges ""
        set mCurrentBotFaces ""
-       set mPrevGeometryObject $itk_option(-geometryObject)
+       set itk_option(-prevGeometryObject) $itk_option(-geometryObject)
 
        $itk_component(edgeTab) unselectAllRows
        $itk_component(faceTab) unselectAllRows
@@ -357,8 +409,9 @@
        return
     }
 
-    set mCurrentBotPoints {}
-    $itk_component(vertTab) unselectAllRows
+#    set mCurrentBotPoints {}
+#    $itk_component(vertTab) unselectAllRows
+    set mCurrentBotFaces {}
     botFacesSelectCallback $face
 
     set plist [$itk_component(vertTab) getSelectedRows]
@@ -538,15 +591,40 @@
     }
 
     itk_component add frontPointOnlyCB {
-       ::ttk::checkbutton $parent.dlistModeCB \
+       ::ttk::checkbutton $parent.frontPointOnlyCB \
            -text "Front Points Only" \
            -command [::itcl::code $this initEditState] \
            -variable [::itcl::scope mFrontPointsOnly]
     } {}
+    itk_component add hlPointsCB {
+       ::ttk::checkbutton $parent.hlPointsCB \
+           -text "Highlight Points" \
+           -command [::itcl::code $this highlightCurrentBotElements] \
+           -variable [::itcl::scope mHighlightPoints]
+    } {}
+
+    itk_component add pointSizeL {
+       ::ttk::label $parent.pointSizeL \
+           -anchor e \
+           -text "Highlight Point Size"
+    } {}
+    itk_component add pointSizeE {
+       ::ttk::entry $parent.pointSizeE \
+           -width 12 \
+           -textvariable [::itcl::scope mHighlightPointSize] \
+           -validate key \
+           -validatecommand [::itcl::code $this validatePointSize %P]
+    } {}
+
     incr row
     grid rowconfigure $parent $row -weight 1
     incr row
     grid $itk_component(frontPointOnlyCB) -row $row -column 0 -sticky w
+    incr row
+    grid $itk_component(hlPointsCB) -row $row -column 0 -sticky w
+    incr row
+    grid $itk_component(pointSizeL) -column 0 -row $row -sticky e
+    grid $itk_component(pointSizeE) -column 1 -row $row -sticky ew
     grid columnconfigure $parent 1 -weight 1
 }
 
@@ -617,7 +695,7 @@
 
     set mEditPCommand [::itcl::code $this p]
     set mEditParam1 ""
-    $itk_option(-mged) rect lwidth 0
+    highlightCurrentBotElements
 
     switch -- $mEditMode \
        $movePoints {
@@ -726,17 +804,21 @@
     loadTables $gdata
 
     # Select one of the newly created edges (i.e. one with the largest vertex 
index)
-    set selist [lsort -index 1 $mEdgeList]
+    set selist [lsort -integer -index 1 $mEdgeList]
     set edge [lindex $selist end]
     set ei [lsearch $mEdgeList $edge]
 
-    incr ei
-    set mCurrentBotEdges $ei
-    $itk_component(edgeTab) unselectAllRows
-    $itk_component(edgeTab) selectRow $ei
-    $itk_component(edgeTab) see "$ei,0"
+    if {1} {
+       clearAllTables
+    } else {
+       incr ei
+       set mCurrentBotEdges $ei
+       $itk_component(edgeTab) unselectAllRows
+       $itk_component(edgeTab) selectRow $ei
+       $itk_component(edgeTab) see "$ei,0"
 
-    syncTablesWrtEdges
+       syncTablesWrtEdges
+    }
 }
 
 
@@ -767,15 +849,17 @@
     set gdata [lrange [$itk_option(-mged) get $itk_option(-geometryObject)] 1 
end]
     loadTables $gdata
 
-    incr _face
-    set findex [lsearch $mCurrentBotFaces $_face]
-    if {$findex < 0} {
-       lappend mCurrentBotFaces $_face
+    if {1} {
+       clearAllTables
+    } else {
+       incr _face
+       set mCurrentBotFaces $_face
+       $itk_component(faceTab) unselectAllRows
+       $itk_component(faceTab) selectRow $_face
+       $itk_component(faceTab) see "$_face,0"
+
+       syncTablesWrtFaces
     }
-
-    $itk_component(faceTab) selectRow $_face
-    $itk_component(faceTab) see "$_face,0"
-    syncTablesWrtFaces
 }
 
 
@@ -831,6 +915,52 @@
 }
 
 
+::itcl::body BotEditFrame::highlightCurrentBotElements {} {
+    if {$itk_option(-mged) == ""} {
+       return
+    }
+    
+
+    set hpoints {}
+    foreach index $mCurrentBotPoints {
+       incr index -1
+       lappend hpoints [lindex $mPointList $index]
+    }
+
+    set lsegPoints {}
+    foreach edge $mCurrentBotEdges {
+       set indexA $mEdgeDetail($edge,$A_COL)
+       set indexB $mEdgeDetail($edge,$B_COL)
+       lappend lsegPoints [lindex $mPointList $indexA]
+       lappend lsegPoints [lindex $mPointList $indexB]
+    }
+
+    $itk_option(-mged) refresh_off
+    set hlcolor [$::ArcherCore::application getRgbColor [$itk_option(-mged) 
cget -primitiveLabelColor]]
+
+    $itk_option(-mged) data_axes draw $mHighlightPoints
+    $itk_option(-mged) data_axes size $mHighlightPointSize
+    eval $itk_option(-mged) data_axes color $hlcolor
+
+    $itk_option(-mged) data_lines draw $mHighlightPoints
+    eval $itk_option(-mged) data_lines color $hlcolor
+    $itk_option(-mged) data_lines points $lsegPoints
+
+    $itk_option(-mged) refresh_on
+
+    $itk_option(-mged) data_axes points $hpoints
+}
+
+
+::itcl::body BotEditFrame::initPointHighlight {} {
+    if {$itk_option(-mged) == ""} {
+       return
+    }
+
+    $itk_option(-mged) data_axes draw $mHighlightPoints
+}
+
+
 ::itcl::body BotEditFrame::loadTables {_gdata} {
     unset mVertDetail
     unset mEdgeDetail
@@ -892,7 +1022,7 @@
                    set mFaceDetail($index,$C_COL) [lindex $item 2]
                    incr index
 
-                   lappend mFaceList [lsort $item]
+                   lappend mFaceList [lsort -integer $item]
                }
            }
            default {
@@ -969,13 +1099,14 @@
     set plist {}
     set len [llength $mCurrentBotPoints]
     if {$len < 2} {
+       highlightCurrentBotElements
        return
     }
 
     # Sorting the points insures the correct point order
     # within an edge for searching the edge list below.
     set sortedPoints {}
-    foreach item [lsort $mCurrentBotPoints] {
+    foreach item [lsort -integer $mCurrentBotPoints] {
        incr item -1
        lappend sortedPoints $item
     }
@@ -1003,6 +1134,7 @@
 
     set len [llength $mCurrentBotEdges]
     if {$len < 2} {
+       highlightCurrentBotElements
        return
     }
 
@@ -1015,7 +1147,7 @@
                lappend flist $mEdgeDetail($edgeB,$A_COL) 
$mEdgeDetail($edgeB,$B_COL)
                lappend flist $mEdgeDetail($edgeC,$A_COL) 
$mEdgeDetail($edgeC,$B_COL)
 
-               set flist [lsort -unique $flist]
+               set flist [lsort -integer -unique $flist]
                if {[llength $flist] != 3} {
                    continue
                }
@@ -1036,6 +1168,8 @@
 
        incr i
     }
+
+    highlightCurrentBotElements
 }
 
 
@@ -1048,7 +1182,7 @@
        incr indexB
        lappend mCurrentBotPoints $indexA $indexB
     }
-    set mCurrentBotPoints [lsort -unique $mCurrentBotPoints]
+    set mCurrentBotPoints [lsort -integer -unique $mCurrentBotPoints]
 
     selectCurrentBotPoints 0
 }
@@ -1112,8 +1246,10 @@
        $itk_component(vertTab) selectRow $indexA
        $itk_component(vertTab) see "$indexA,0"
     }
-    set mCurrentBotEdges [lsort -unique $mCurrentBotEdges]
-    set mCurrentBotPoints [lsort -unique $mCurrentBotPoints]
+    set mCurrentBotEdges [lsort -integer -unique $mCurrentBotEdges]
+    set mCurrentBotPoints [lsort -integer -unique $mCurrentBotPoints]
+
+    highlightCurrentBotElements
 }
 
 
@@ -1128,6 +1264,30 @@
 }
 
 
+::itcl::body BotEditFrame::validatePointSize {_size} {
+    if {$_size == "."} {
+       $itk_option(-mged) data_axes size 0
+
+       return 1
+    }
+
+    if {[string is double $_size]} {
+       if {$_size == "" || $_size < 0} {
+           set sz 0
+       } else {
+           set sz $_size
+       }
+
+       $itk_option(-mged) data_axes size $sz
+
+       return 1
+    }
+
+    return 0
+}
+
+
+
 # Local Variables:
 # mode: Tcl
 # tab-width: 8

Modified: brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl    2012-11-09 
19:49:32 UTC (rev 53641)
+++ brlcad/trunk/src/tclscripts/archer/GeometryEditFrame.tcl    2012-11-09 
20:25:44 UTC (rev 53642)
@@ -34,6 +34,7 @@
     itk_option define -geometryObject geometryObject GeometryObject ""
     itk_option define -geometryObjectPath geometryObjectPath 
GeometryObjectPath ""
     itk_option define -geometryChangedCallback geometryChangedCallback 
GeometryChangedCallback ""
+    itk_option define -prevGeometryObject prevGeometryObject 
PrevGeometryObject ""
 
     itk_option define -labelFont labelFont Font [list 
$::ArcherCore::SystemWindowFont 12]
     itk_option define -boldLabelFont boldLabelFont Font [list 
$::ArcherCore::SystemWindowFont 12 bold]
@@ -83,7 +84,6 @@
        variable mYmax 0
        variable mZmin 0
        variable mZmax 0
-       variable mPrevGeometryObject ""
 
        method buildUpperPanel {}
        method buildLowerPanel {}

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


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to