[brlcad-commits] SF.net SVN: brlcad:[40007] brlcad/trunk/src/tclscripts/boteditor
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <n_...@us...> - 2010-08-04 20:36:13
|
Revision: 40007 http://brlcad.svn.sourceforge.net/brlcad/?rev=40007&view=rev Author: n_reed Date: 2010-08-04 20:36:06 +0000 (Wed, 04 Aug 2010) Log Message: ----------- changed layout and reorganized code for bot editor Modified Paths: -------------- brlcad/trunk/src/tclscripts/boteditor/botEditor.tcl brlcad/trunk/src/tclscripts/boteditor/botPropertyBox.tcl brlcad/trunk/src/tclscripts/boteditor/botTools.tcl Modified: brlcad/trunk/src/tclscripts/boteditor/botEditor.tcl =================================================================== --- brlcad/trunk/src/tclscripts/boteditor/botEditor.tcl 2010-08-04 16:32:25 UTC (rev 40006) +++ brlcad/trunk/src/tclscripts/boteditor/botEditor.tcl 2010-08-04 20:36:06 UTC (rev 40007) @@ -1,6 +1,10 @@ +# BotEditor class for editing a BoT primitive +# +package require Tk package require Itcl package require Itk +# manually sourcing dependencies for now if {[catch { set script [file join [bu_brlcad_data "tclscripts"] boteditor botPropertyBox.tcl] source $script @@ -9,6 +13,7 @@ source $script } errMsg] > 0} { puts "Couldn't load \"$script\"\n$errMsg" + exit } ::itcl::class BotEditor { @@ -20,121 +25,189 @@ method load {bot} method onChange {} method apply {} + method revert {} method accept {} method reject {} } + + private { + method showUnsaved {show} + } } +# basic initialization - nothing can really be done until load +# ::itcl::body BotEditor::constructor {args} { eval itk_initialize $args - grid rowconfigure $itk_interior 0 -weight 1 - grid columnconfigure $itk_interior 0 -weight 1 - $this configure -title "BoT Editor" } +# open editor for bot named 'bot' +# this bot is assumed to exist in the current database +# ::itcl::body BotEditor::load {bot} { # show name of bot being edited $this configure -title "[eval $this cget -title] - $bot" - # make edit widgets frame - itk_component add eframe { - ttk::frame $itk_interior.editFrame \ + # create frames for organization + itk_component add histFrame { + ttk::frame $itk_interior.historyFrame \ -padding 7 } {} - - # make close buttons frame - itk_component add bframe { - ttk::frame $itk_interior.buttonsFrame \ + itk_component add eframe { + EditPane $itk_interior.editPane + } {} + itk_component add closeframe { + ttk::frame $itk_interior.closeFrame \ -padding 7 } {} - # make tool tabs - itk_component add tools { - BotTools $itk_component(eframe).tools - } {} - - # make property box - itk_component add propBox { - BotPropertyBox $itk_component(eframe).propBox \ - -command "$this onChange" - } {} - - # make apply button + # add widgets to history frame itk_component add apply { - ttk::button $itk_component(eframe).apply \ + ttk::button $itk_component(histFrame).apply \ -text Apply \ -command "$this apply" } {} + itk_component add revert { + ttk::button $itk_component(histFrame).revert \ + -text Revert \ + -command "$this revert" + } {} - # make accept/reject buttons + # add widgets to close frame itk_component add accept { - ttk::button $itk_component(bframe).accept \ + ttk::button $itk_component(closeframe).accept \ -text Accept \ -command "$this accept" } {} - itk_component add reject { - ttk::button $itk_component(bframe).reject \ + ttk::button $itk_component(closeframe).reject \ -text Reject \ -command "$this reject" } {} -# itk_component add disp { -# Display $itk_component(eframe).display -# } + # display main frames + grid $itk_component(histFrame) -row 0 -column 0 -sticky news + grid $itk_component(eframe) -row 1 -column 0 -sticky news + grid $itk_component(closeframe) -row 2 -column 0 -sticky news + grid rowconfigure $itk_interior 1 -weight 1 + grid columnconfigure $itk_interior 0 -weight 1 - # display frames - grid $itk_component(eframe) -row 0 -column 0 -sticky news - grid $itk_component(bframe) -row 1 -column 0 -sticky news + # display history frame components + pack $itk_component(apply) -side left + pack $itk_component(revert) -side left -padx 5 - # allow contents to expand - grid rowconfigure $itk_component(eframe) 2 -weight 1 - grid columnconfigure $itk_component(eframe) 0 -weight 1 + # display close frame components + pack $itk_component(reject) -side right + pack $itk_component(accept) -side right -padx 5 +} - # display components - set row 0; set col 0 - grid $itk_component(apply) -row $row -column [expr "$col + 1"] -sticky se -pady {5 0} +# give feedback on unsaved change +::itcl::body BotEditor::showUnsaved {show} { - incr row - grid $itk_component(tools) -row $row -column $col -sticky news -padx {0 10} - grid $itk_component(propBox) -row $row -column [expr $col + 1] -sticky nes + if {$show} { -# incr row -# grid $itk_component(disp) -row $row -column $col -columnspan 2 -sticky nesw + # append '*' to title to indicate unapplyed change + set title [eval $this cget -title] + + if {[regexp ^.*\\*$ $title] == 0} { + $this configure -title $title* + } + } else { - pack $itk_component(reject) -side right - pack $itk_component(accept) -side right -padx 5 + # remove '*' from title to indicate application + set match ""; set title [eval $this cget -title] + regexp ^(.*)\\*$ $title match title + $this configure -title $title + } } +# called whenever an edit is made ::itcl::body BotEditor::onChange {} { - - # append '*' to title to indicate unapplyed change - set title [eval $this cget -title] - - if {[regexp ^.*\\*$ $title] == 0} { - $this configure -title $title* - } + showUnsaved yes } +# save current edit ::itcl::body BotEditor::apply {} { + showUnsaved no +} - # remove '*' from title to indicate application - set match ""; set title [eval $this cget -title] - regexp ^(.*)\\*$ $title match title - $this configure -title $title +# return to last saved edit +::itcl::body BotEditor::revert {} { + showUnsaved no } +# apply changes to original ::itcl::body BotEditor::accept {} { # close window delete object $this } +# discard all changes ::itcl::body BotEditor::reject {} { # close window delete object $this # TODO - modal confirmation dialog } + +::itcl::class EditPane { + inherit itk::Widget + + constructor {args} { + eval itk_initialize $args + + # make container frame + itk_component add main { + ttk::frame $itk_interior.editPaneFrame \ + -padding 7 + } {} + + # add layout frames to main frame + itk_component add tframe { + ttk::frame $itk_component(main).topFrame + } {} + itk_component add bframe { + ttk::frame $itk_component(main).bottomFrame + } {} + + # add layout frames to top frame + itk_component add lframe { + ttk::frame $itk_component(tframe).leftFrame \ + -padding 5 + } {} + itk_component add rframe { + ttk::frame $itk_component(tframe).rightFrame \ + -padding 5 + } {} + + # add components + itk_component add tools { + BotTools $itk_component(lframe).tools + } {} + itk_component add props { + BotPropertyBox $itk_component(rframe).properties + } {} + + # display main frame + pack $itk_component(main) -expand yes -fill both + + # display main layout frames + grid $itk_component(tframe) -row 0 -column 0 -sticky news + grid $itk_component(bframe) -row 1 -column 0 -sticky news + grid rowconfigure $itk_component(main) 1 -weight 1 + grid columnconfigure $itk_component(main) 0 -weight 1 + + # display top subframes + grid $itk_component(lframe) -row 0 -column 0 -sticky news + grid $itk_component(rframe) -row 0 -column 1 -sticky news + grid rowconfigure $itk_component(tframe) 0 -weight 1 + grid columnconfigure $itk_component(tframe) 0 -weight 1 + + # display components + pack $itk_component(tools) -expand yes -fill both + pack $itk_component(props) -expand yes -fill both + } +} Modified: brlcad/trunk/src/tclscripts/boteditor/botPropertyBox.tcl =================================================================== --- brlcad/trunk/src/tclscripts/boteditor/botPropertyBox.tcl 2010-08-04 16:32:25 UTC (rev 40006) +++ brlcad/trunk/src/tclscripts/boteditor/botPropertyBox.tcl 2010-08-04 20:36:06 UTC (rev 40007) @@ -1,3 +1,5 @@ +# BotPropertyBox class for viewing/manipulating BoT properties +# ::itcl::class BotPropertyBox { inherit ::itk::Widget @@ -10,112 +12,131 @@ eval itk_initialize $args - # create main box - itk_component add box { - ttk::labelframe $itk_interior.box \ - -text {BoT Properties} \ - -padding 5 + # make container frame + itk_component add main { + ttk::frame $itk_interior.propertyFrame } {} - # create type selection widgets - itk_component add typeLabel { - ttk::label $itk_component(box).typeLbl \ - -text {Type} + # add notebook to container frame + itk_component add nb { + ttk::notebook $itk_component(main).notebook } {} - - itk_component add typeLine { - ttk::separator $itk_component(box).typeSep \ - -orient horizontal + + # add tab panes to container frame + itk_component add tpane { + TypePane $itk_component(main).typePane } {} - - itk_component add surfRadio { - ttk::radiobutton $itk_component(box).surfRadio \ - -text Surface \ - -command $itk_option(-command) + itk_component add gpane { + GeometryPane $itk_component(main).geometryPane } {} - itk_component add volRadio { - ttk::radiobutton $itk_component(box).volRadio \ - -text Volume - } {} + # display main frame + pack $itk_component(main) -expand yes -fill both - itk_component add plateRadio { - ttk::radiobutton $itk_component(box).plateRadio \ - -text Plate - } {} + # display notebook in main frame + pack $itk_component(nb) -expand yes -fill both - # create geometry info widgets - itk_component add infoLabel { - ttk::label $itk_component(box).infoLbl \ - -text {Geometry} - } {} + # display tab panes in notebook + $itk_component(nb) add $itk_component(gpane) \ + -text Geometry \ + -sticky nw + $itk_component(nb) add $itk_component(tpane) \ + -text Type \ + -sticky nw +} - itk_component add infoLine { - ttk::separator $itk_component(box).infoSep \ - -orient horizontal - } {} +::itcl::class TypePane { + inherit itk::Widget - itk_component add faces { - ttk::label $itk_component(box).faces \ - -text {Faces: } - } {} + constructor {args} { + eval itk_initialize $args - itk_component add vertices { - ttk::label $itk_component(box).vertices \ - -text {Vertices: } - } {} + # make container frame + itk_component add main { + ttk::frame $itk_interior.typePaneFrame + } {} - # display main box - grid $itk_component(box) -row 0 -column 0 -sticky news - grid rowconfigure $itk_component(box) {0 1 3 4} -weight 1 - grid rowconfigure $itk_interior 0 -weight 1 - grid columnconfigure $itk_interior 0 -weight 1 + # add layout frames to container frame + itk_component add cframe { + ttk::frame $itk_component(main).contentFrame \ + -padding 5 + } {} + itk_component add sframe { + ttk::frame $itk_component(main).springFrame + } {} - # display bot type selection widgets - set r 0; set c 0 - grid $itk_component(typeLabel) \ - -row $r -column $c \ - -sticky nw \ - -padx 2 - incr r - grid $itk_component(typeLine) \ - -row $r -column $c \ - -columnspan 4 \ - -sticky ew \ - -padx {2 10} -pady {0 5} - incr r; set c 0 - grid $itk_component(surfRadio) \ - -row $r -column $c \ - -padx 5 - incr c - grid $itk_component(volRadio) \ - -row $r -column $c \ - -padx 5 - incr c - grid $itk_component(plateRadio) \ - -row $r -column $c \ - -padx 5 + # add widgets to content frame + itk_component add surfRadio { + ttk::radiobutton $itk_component(cframe).surfaceRadio \ + -text Surface + } {} + itk_component add volRadio { + ttk::radiobutton $itk_component(cframe).volumeRadio \ + -text Volume + } {} + itk_component add plateRadio { + ttk::radiobutton $itk_component(cframe).plateRadio \ + -text Plate + } {} - # display geometry info widgets - incr r; set c 0 - grid $itk_component(infoLabel) \ - -row $r -column $c \ - -sticky nw \ - -padx 2 -pady {20 0} - incr r - grid $itk_component(infoLine) \ - -row $r -column $c \ - -columnspan 3 \ - -sticky ew \ - -padx {2 10} -pady {0 5} - incr r - grid $itk_component(faces) \ - -row $r -column $c \ - -sticky w \ - -padx 5 - incr r - grid $itk_component(vertices) \ - -row $r -column $c \ - -sticky w \ - -padx 5 + # display container frame + pack $itk_component(main) -expand yes -fill both + + # display layout frames in container frame + grid $itk_component(cframe) -row 0 -column 0 + grid $itk_component(sframe) -row 1 -column 0 -sticky news + grid rowconfigure $itk_component(main) 1 -weight 1 + grid columnconfigure $itk_component(main) 0 -weight 1 + + # display widgets in content frame - no expansion + grid $itk_component(surfRadio) -row 0 -column 0 -sticky nw + grid $itk_component(volRadio) -row 1 -column 0 -sticky nw + grid $itk_component(plateRadio) -row 2 -column 0 -sticky nw + } } + +::itcl::class GeometryPane { + inherit itk::Widget + + constructor {args} { + eval itk_initialize $args + + # make container frame + itk_component add main { + ttk::frame $itk_interior.geometryPaneFrame + } {} + + # add layout frames to container frame + itk_component add cframe { + ttk::frame $itk_component(main).contentFrame \ + -padding 5 + } {} + itk_component add sframe { + ttk::frame $itk_component(main).springFrame + } {} + + # add widgets to content frame + itk_component add faces { + ttk::label $itk_component(cframe).faces \ + -text {Faces: } + } {} + + itk_component add vertices { + ttk::label $itk_component(cframe).vertices \ + -text {Vertices: } + } {} + + # display container frame + pack $itk_component(main) -expand yes -fill both + + # display layout frames in container frame + grid $itk_component(cframe) -row 0 -column 0 + grid $itk_component(sframe) -row 1 -column 0 -sticky news + grid rowconfigure $itk_component(main) 1 -weight 1 + grid columnconfigure $itk_component(main) 0 -weight 1 + + # display widgets in content frame - no expansion + grid $itk_component(faces) -row 0 -column 0 -sticky nw + grid $itk_component(vertices) -row 1 -column 0 -sticky nw + } +} Modified: brlcad/trunk/src/tclscripts/boteditor/botTools.tcl =================================================================== --- brlcad/trunk/src/tclscripts/boteditor/botTools.tcl 2010-08-04 16:32:25 UTC (rev 40006) +++ brlcad/trunk/src/tclscripts/boteditor/botTools.tcl 2010-08-04 20:36:06 UTC (rev 40007) @@ -35,7 +35,8 @@ incr panes itk_component add $name { - ttk::frame $itk_interior.$name + ttk::frame $itk_interior.$name \ + -padding 5 } {} return $itk_component($name) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |