-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplottk_lineseries.tcl
More file actions
104 lines (84 loc) · 3.97 KB
/
implottk_lineseries.tcl
File metadata and controls
104 lines (84 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright (c) 2022 Nicolas ROBERT.
# Distributed under MIT license. Please see LICENSE for details.
namespace eval ::implottk {
oo::class create lineSeries {
variable _series ; # list num series
variable _cmdplot ; # list commands plot
method series {num args} {
# Configure line serie
#
# num - num serie
# args - options described below.
#
# -data - list x y data (not supported yet).
# -dataX - list values x.
# -dataY - list values y.
# -name - name serie.
# -lineStyle - options described below.
# color - list 3 RGB values for line style
# weight - size point line
#
# Returns nothing
foreach {key value} $args {
if {$value eq ""} {
error "No value specified for key '$key'"
}
switch -exact -- $key {
-data {dict set dataseries -data $value}
-dataX {dict set dataseries -dataX $value}
-dataY {dict set dataseries -dataY $value}
-name {dict set dataseries -name $value}
-lineStyle {
set colorline ""
set weightline ""
foreach {keystyle valuestyle} $value {
if {$valuestyle eq ""} {
error "No value specified for subkey '$keystyle'"
}
switch -exact -- $keystyle {
color {
if {[llength $valuestyle] != 3} {
error "list color should be equal to 3..."
}
set colorline [implottk::rgbaToVec4 $valuestyle]
}
weight {
if {![string is integer $valuestyle] || $valuestyle <= 0} {
error "Size font should be greater than 0"
}
set weightline $valuestyle
}
default {error "Unknown key '$keystyle' specified"}
}
}
if {$colorline ne "" && $weightline ne ""} {
lappend _cmdplot [list implot::SetNextLineStyle $colorline $weightline]
}
if {$colorline ne "" && $weightline eq ""} {
lappend _cmdplot [list implot::SetNextLineStyle $colorline]
}
if {$colorline eq "" && $weightline ne ""} {
lappend _cmdplot [list implot::SetNextLineStyle [implottk::rgbaToVec4 {0 0 0 -255}] $weightline]
}
}
default {error "Unknown key '$key' specified"}
}
}
if {$num in $_series} {
error "This series is already configured..."
}
lappend _cmdplot [implottk::dataLine $num $dataseries]
lappend _series $num
return {}
}
method addLinePlotCmds {args} {
# Add command on the fly
#
# args - command line plot
#
# Returns nothing
lappend _cmdplot [lindex $args 0]
return {}
}
}
}