diff options
author | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
commit | 47aa8b00b2b11df13a100489e0f904a4947177ef (patch) | |
tree | b35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/bottompanel/graph_wdg.tcl | |
parent | 5b8466f7fae0e071c0f4eda13051c93313910028 (diff) |
Import Upstream version 1.4.7
Diffstat (limited to 'lib/bottompanel/graph_wdg.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/bottompanel/graph_wdg.tcl | 97 |
1 files changed, 60 insertions, 37 deletions
diff --git a/lib/bottompanel/graph_wdg.tcl b/lib/bottompanel/graph_wdg.tcl index bcb2d62..a528bc5 100755..100644 --- a/lib/bottompanel/graph_wdg.tcl +++ b/lib/bottompanel/graph_wdg.tcl @@ -2,7 +2,7 @@ # Part of MCU 8051 IDE ( http://mcu8051ide.sf.net ) ############################################################################ -# Copyright (C) 2007-2008 by Martin Ošmera # +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # This program is free software; you can redistribute it and#or modify # @@ -21,6 +21,11 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ +# >>> File inclusion guard +if { ! [ info exists _GRAPH_WDG_TCL ] } { +set _GRAPH_WDG_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Graph widget for showing port states @@ -35,17 +40,20 @@ class GraphWidget { # Big font (vertical header) common big_font [font create \ -family $::DEFAULT_FIXED_FONT \ - -size -14 -weight bold \ + -size -14 \ + -weight bold \ ] # Small font (horizontal header) common small_font [font create \ -family $::DEFAULT_FIXED_FONT \ - -size -14 -weight bold \ + -size -14 \ + -weight bold \ ] # Font for booleans values for each port common bool_font [font create \ -family $::DEFAULT_FIXED_FONT \ - -size -12 -weight bold \ + -size -12 \ + -weight bold \ ] # Definition of graph popup menu common GRAPHMENU { @@ -53,7 +61,7 @@ class GraphWidget { {} "Enable/Disable graph"} {separator} {command {Change grid} {} 1 "graph_switch_grid_mode 1" - {} "Change grid morfology"} + {} "Change grid morphology"} {separator} {command {Zoom in} {} 1 "graph_zoom_in" {viewmag_in} "Change bit length on X axis to a lower value"} @@ -65,13 +73,13 @@ class GraphWidget { } # Variables related to object initialization - private variable gui_initialized 0 ;# Bool: GUI created + private variable graph_w_gui_initialized 0 ;# Bool: GUI created private variable _parent ;# Parent widget private variable parent ;# Innert parent widget private variable canvasWidget ;# ID of the canvas widget private variable grid_mode {b} ;# Current grid mode (one of {b n x y}) - private variable drawing_on 1 ;# Bool: Graph enabled + private variable drawing_on 0 ;# Bool: Graph enabled private variable magnification 0 ;# Magnification level (0..3) private variable graph_elements ;# Array: IDs of graph elements (green and red lines) private variable intr_lines {} ;# List of IDs of interrupt lines @@ -100,12 +108,12 @@ class GraphWidget { constructor {Parent super} { set _parent $Parent set Super $super - set gui_initialized 0 + set graph_w_gui_initialized 0 } ## Object destructor destructor { - if {$gui_initialized} { + if {$graph_w_gui_initialized} { menu_Sbar_remove $menu } } @@ -113,20 +121,20 @@ class GraphWidget { ## React to MCU change # @return void public method change_mcu {} { - if {!$gui_initialized} {return} + if {!$graph_w_gui_initialized} {return} foreach wdg [winfo children $_parent] { destroy $wdg } - set gui_initialized 0 + set graph_w_gui_initialized 0 CreateGraphGUI } ## Initialize graph # @return void public method CreateGraphGUI {} { - if {$gui_initialized} {return} - set gui_initialized 1 + if {$graph_w_gui_initialized} {return} + set graph_w_gui_initialized 1 # Determinate number of ports and port indexes set number_of_ports [$Super get_ports_info] @@ -181,7 +189,7 @@ class GraphWidget { # Create canvas popup menu set menu $canvasWidget.menu - menuFactory $GRAPHMENU $menu 0 "$Super " 0 {} + menuFactory $GRAPHMENU $menu 0 "$Super " 0 {} [namespace current] # Set event bindings for the canvas widget @@ -205,19 +213,19 @@ class GraphWidget { } ## Draw interrupt line - # @parm String = {} - If "nohistory" the history of interrupt lines will not be modified + # @parm String nh={} - If "nohistory" the history of interrupt lines will not be modified # @return void - public method graph_draw_interrupt_line args { - if {!$gui_initialized} {CreateGraphGUI} + public method graph_draw_interrupt_line {{nh {}}} { + if {!$graph_w_gui_initialized} {CreateGraphGUI} # Check if graph is enabled if {!$drawing_on} {return} # Adjust history - if {$args != {nohistory}} { + if {$nh != {nohistory}} { if {[llength $intr_history]} { lset intr_history end 1 - } { + } else { lappend intr_history 1 } } @@ -231,10 +239,10 @@ class GraphWidget { } # Adjust list of canvas elements related to this line - if {$args != {nohistory}} { + if {$nh != {nohistory}} { if {[llength $intr_lines]} { lset intr_lines end $lines - } { + } else { lappend intr_lines $lines } } @@ -251,7 +259,7 @@ class GraphWidget { # @parm List - {# {P0_hex P1_hex P2_hex P3_hex P4_hex}} # @return void public method graph_new_output_state args { - if {!$gui_initialized} {CreateGraphGUI} + if {!$graph_w_gui_initialized} {CreateGraphGUI} # Check if graph is enabled if {!$drawing_on} {return} @@ -290,7 +298,7 @@ class GraphWidget { if {[lindex $args 0] != {#}} { lappend state_history [list {#} $args] lappend intr_history 0 - } { + } else { set args [lindex $args 1] } lappend intr_lines {} @@ -359,6 +367,10 @@ class GraphWidget { set txt {L} set clr {#FF00AA} } + default { + set txt {?} + set clr {#888888} + } } $canvasWidget create text $x $y \ @@ -385,7 +397,7 @@ class GraphWidget { ($idx / 8) * $port_length_in_px + ($pos * $step_x) + 20 }] - # Determinate length of line elements acording to the current magnification level + # Determinate length of line elements according to the current magnification level switch -- $magnification { {0} { set line_len 3 @@ -417,7 +429,7 @@ class GraphWidget { if {$bool == {=}} { set bool 0 set zero_color {#FF00AA} - } { + } else { set zero_color {#FF0000} } @@ -445,7 +457,7 @@ class GraphWidget { $offset_x [expr {$offset_y + 0}] \ -fill $zero_color -tags graph] } - {-} { ;# From undeterminable state + {-} { ;# From indeterminable state lappend lines [$canvasWidget create line \ $offset_x [expr {$offset_y + $half_edge}] \ $offset_x [expr {$offset_y + 0}] \ @@ -588,7 +600,7 @@ class GraphWidget { [expr {$offset_x + 2*$line_len + $enge_inc0 + $enge_inc1}] $offset_y \ -fill {#FF8800} -tags graph] - # "Undeterminable state" -> "Zero" + # "Indeterminable state" -> "Zero" } elseif {$prev == {-} && $bool == 0} { lappend lines [$canvasWidget create line \ $offset_x [expr {$offset_y + $half_edge}] \ @@ -596,7 +608,7 @@ class GraphWidget { [expr {$offset_x + $step_x}] [expr {$offset_y + $full_edge}] \ -fill {#00FF00} -tags graph] - # "Undeterminable state" -> "One" + # "Indeterminable state" -> "One" } elseif {$prev == {-} && $bool == 1} { lappend lines [$canvasWidget create line \ $offset_x [expr {$offset_y + $half_edge}] \ @@ -735,7 +747,7 @@ class GraphWidget { set previous_state($idx) $bool } - ## Iterate over avaliable grid modes + ## Iterate over available grid modes # @parm Int by - Iterate by # @return void public method graph_switch_grid_mode {_grid_mode} { @@ -753,7 +765,7 @@ class GraphWidget { adjust_grid } - ## Adjust grid morfology to the current grid mode + ## Adjust grid morphology to the current grid mode # @return void private method adjust_grid {} { # Remove the current grid @@ -796,7 +808,7 @@ class GraphWidget { } ## Set graph configuration variables - # @parm Char _grid_mode - Grid morfology (one of {'n' 'x' 'y' 'b'}) + # @parm Char _grid_mode - Grid morphology (one of {'n' 'x' 'y' 'b'}) # @parm Int _magnification - Magnification mode (one of {0 1 2 3}) # @parm Bool _drawing_on - Widget enabled # @parm List _mark_flags - List of mark flags (e.g {0 0 0 1 1 0}) @@ -811,10 +823,17 @@ class GraphWidget { ## Get mark flags # @return String - String of boolean flags public method graph_get_marks {} { - return [join $mark_flags {}] + set result [::NumSystem::bin2hex [join $mark_flags {}]] + set len [string length $result] + if {$len < 43} { + set result "[string repeat {0} [expr {43 - $len}]]$result" + } + + return "X$result" } ## Adjust graph to the current magnification level + # @parm Int _magnification - Maginification level (0..3) # @return void public method commit_magnification {_magnification} { set magnification $_magnification @@ -864,7 +883,7 @@ class GraphWidget { # @parm String - If "keephistory" then do not clear history # @return void public method clear_graph args { - if {!$gui_initialized} {CreateGraphGUI} + if {!$graph_w_gui_initialized} {CreateGraphGUI} catch { $canvasWidget delete graph @@ -898,7 +917,7 @@ class GraphWidget { ## Adjust object to the current value of flag 'drawing_on' # @return void public method commit_state_on_off {_drawing_on} { - if {!$gui_initialized} {CreateGraphGUI} + if {!$graph_w_gui_initialized} {CreateGraphGUI} set drawing_on $_drawing_on # Enable widgets @@ -1018,7 +1037,7 @@ class GraphWidget { lset mark_flags $idx 1 # Remove mark - } { + } else { catch { foreach elm [lindex $marks $idx] { $canvasWidget delete $elm @@ -1051,7 +1070,7 @@ class GraphWidget { update } # Show scrollbar - } { + } else { if {![winfo ismapped $horizontal_scrollbar]} { pack $horizontal_scrollbar -fill x -side top -before $scrollable_frame } @@ -1064,7 +1083,7 @@ class GraphWidget { # @parm Int bits - Number of steps to take back # @return void public method graph_stepback {bits} { - if {!$gui_initialized} {CreateGraphGUI} + if {!$graph_w_gui_initialized} {CreateGraphGUI} if {!$drawing_on} {return} # Remove elemets @@ -1113,3 +1132,7 @@ class GraphWidget { } } } + +# >>> File inclusion guard +} +# <<< File inclusion guard |