GnuplotGraphView.st
author convert-repo
Sun, 22 Dec 2019 04:27:40 +0000
changeset 6204 f8b8bb140730
parent 6198 d5ff1b431467
child 6241 8de2ecadf40b
permissions -rw-r--r--
update tags
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6198
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     1
"{ Encoding: utf8 }"
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     2
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     3
"
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     4
 COPYRIGHT (c) 2018 by eXept Software AG
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     5
              All Rights Reserved
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     6
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     7
 This software is furnished under a license and may be used
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     8
 only in accordance with the terms of that license and with the
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    10
 be provided or otherwise made available to, or used by, any
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    11
 other person.  No title to or ownership of the software is
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    12
 hereby transferred.
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    13
"
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
"{ NameSpace: Smalltalk }"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
ImageView subclass:#GnuplotGraphView
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    19
	instanceVariableNames:'script data title formatHolder'
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Views-Misc'
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!GnuplotGraphView class methodsFor:'documentation'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
6198
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    27
copyright
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    28
"
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    29
 COPYRIGHT (c) 2018 by eXept Software AG
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    30
              All Rights Reserved
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    31
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    32
 This software is furnished under a license and may be used
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    33
 only in accordance with the terms of that license and with the
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    35
 be provided or otherwise made available to, or used by, any
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    36
 other person.  No title to or ownership of the software is
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    37
 hereby transferred.
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    38
"
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    39
!
d5ff1b431467 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6127
diff changeset
    40
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    displays the graph of the data (in model) using a gnuplot script
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    44
    Now also shown in the collection-inspector tab.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    [author:]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        cg
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [instance variables:]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    [class variables:]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    [see also:]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
examples
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
 Notice that everything between [exBegin] and [exEnd] is extracted by the html-doc generator
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
 to create nicely formatted and clickable executable examples in the generated html-doc.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
 (see the browsers class-documentation menu items for more)
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    64
 trying the widget as standAlone view (with a fix script):
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
                                                        [exBegin]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    GnuplotGraphView new 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
        script:(GnuplotGraphView defaultScript);
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
        model:(ValueHolder with:(Random new next:100));
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    69
        adjust:#smoothFit;
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    70
        extent:400@300;
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    71
        open
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    72
                                                        [exEnd]
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    73
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    74
 trying the widget as standAlone view (with no fix script):
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    75
                                                        [exBegin]
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    76
    GnuplotGraphView new 
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    77
        model:(ValueHolder with:(Random new next:100));
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    78
        adjust:#smoothFit;
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
    79
        extent:300@200;
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        open
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
                                                        [exEnd]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
 embedded in another view:
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
                                                        [exBegin]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    |top v|
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    top := StandardSystemView new.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    top extent:300@300.
5755
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    89
    v := GnuplotGraphView new.  
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    90
    v data:(Random new next:100).
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    91
    v origin:0.0@0.0 corner:1.0@1.0.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    top add:v.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    top open
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
                                                        [exEnd]
5755
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    95
 use as inspect tab:
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    96
                                                        [exBegin]
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    97
    (Random new next:100) inspect.
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
    98
                                                        [exEnd]
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!GnuplotGraphView class methodsFor:'defaults'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
defaultScript
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    "return a default initial gnuplot script"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    ^ self defaultScriptForHistogram
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   110
defaultScriptForDots
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   111
    "a default initial gnuplot script to show a dots diagram"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   112
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   113
    ^ '
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   114
set term %(outputFormat) size %(width),%(height)
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   115
set output "%(outputFile)"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   116
set title "%(title)"
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   117
set nokey
5762
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   118
plot [-10:110] ''%(data)''
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   119
'
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   120
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   121
    "Modified: / 31-05-2018 / 11:54:43 / Claus Gittinger"
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   122
!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   123
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
defaultScriptForHistogram
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "a default initial gnuplot script to show a histogram"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ^ '
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   128
set term %(outputFormat) size %(width),%(height) 
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
set output "%(outputFile)"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
set title "%(title)"
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   131
set nokey
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
plot [-10:110] ''%(data)'' with histogram 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
'
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   134
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   135
    "Modified: / 31-05-2018 / 11:54:47 / Claus Gittinger"
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   136
!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   137
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   138
defaultScriptForLines
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   139
    "a default initial gnuplot script to show a line diagram"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   140
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   141
    ^ '
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   142
set term %(outputFormat) size %(width),%(height) 
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   143
set output "%(outputFile)"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   144
set title "%(title)"
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   145
set nokey
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   146
plot ''%(data)'' with lines 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   147
'
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   148
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   149
    "Modified: / 31-05-2018 / 11:54:52 / Claus Gittinger"
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   150
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   151
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   152
!GnuplotGraphView class methodsFor:'menu specs'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   153
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   154
middleButtonMenuExtraSlice
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   155
    "This resource specification was automatically generated
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   156
     by the MenuEditor of ST/X."
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   157
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   158
    "Do not manually edit this!! If it is corrupted,
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   159
     the MenuEditor may not be able to read the specification."
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   160
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   161
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   162
    "
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   163
     MenuEditor new openOnClass:GnuplotGraphView andSelector:#middleButtonMenuExtraSlice
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   164
     (Menu new fromLiteralArrayEncoding:(GnuplotGraphView middleButtonMenuExtraSlice)) startUp
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   165
    "
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   166
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   167
    <resource: #menu>
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   168
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   169
    ^ 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   170
     #(Menu
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   171
        (
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   172
         (MenuItem
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   173
            label: '-'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   174
          )
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   175
         (MenuItem
5781
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   176
            enabled: hasNoScript
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   177
            label: 'Histogram'
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   178
            hideMenuOnActivated: false
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   179
            choice: formatHolder
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   180
            choiceValue: histogram
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   181
          )
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   182
         (MenuItem
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   183
            enabled: hasNoScript
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   184
            label: 'Line Graph'
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   185
            hideMenuOnActivated: false
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   186
            choice: formatHolder
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   187
            choiceValue: lines
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   188
          )
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   189
         (MenuItem
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   190
            enabled: hasNoScript
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   191
            label: 'Dots'
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   192
            hideMenuOnActivated: false
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   193
            choice: formatHolder
38948bac30f3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5765
diff changeset
   194
            choiceValue: dots
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   195
          )
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   196
         )
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   197
        nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   198
        nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   199
      )
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
!GnuplotGraphView methodsFor:'accessing'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   204
adjust:layoutSymbol
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   205
    image := nil.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   206
    super adjust:layoutSymbol.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   207
    self invalidate
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   208
!
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   209
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
data
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    ^ data
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
data:something
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    data := something.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
5762
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   218
hasNoScript
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   219
    ^ [ script isEmptyOrNil ]
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   220
!
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   221
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   222
hasScript
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   223
    ^ [ script notEmptyOrNil ]
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   224
!
13f699b3e47c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5759
diff changeset
   225
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   226
magnificationFactor:aNumber
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   227
    image := nil.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   228
    super magnificationFactor:aNumber.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   229
    self invalidate
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   230
!
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   231
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
script
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    ^ script
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
script:something
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    script := something.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
title
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    ^ title
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
title:something
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    title := something.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   248
!GnuplotGraphView methodsFor:'aspects'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   249
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   250
formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   251
    formatHolder isNil ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   252
        formatHolder := #histogram asValue.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   253
        formatHolder onChangeSend:#formatChanged to:self.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   254
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   255
    ^ formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   256
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   257
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   258
!GnuplotGraphView methodsFor:'defaults'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   259
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   260
defaultScript
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   261
    |format|
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   262
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   263
    format := self formatHolder value.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   264
    format == #histogram ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   265
        ^ self class defaultScriptForHistogram
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   266
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   267
    format == #lines ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   268
        ^ self class defaultScriptForLines
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   269
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   270
    format == #dots ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   271
        ^ self class defaultScriptForDots
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   272
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   273
    ^ self class defaultScript
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   274
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   275
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
!GnuplotGraphView methodsFor:'drawing'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
generateDataFileIn:aDirectory
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    "the format of data expected by gnuplot depends on the type of plot:
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
        regular plot: a number of values (each in a separate line)
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
        multiCol plots: a number of lines, each containing a row
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
     here, handle common situations;
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
     however, if the data does not match, the program should have prepared the 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
     data into a string and present it as such.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
     Strings will be sent as-is to the file"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    |dataFilename printRow|
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    dataFilename := (Filename newTemporaryIn:aDirectory) pathName.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    dataFilename := dataFilename asFilename withSuffix:'dat'.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    (data isString or:[data isByteArray]) ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
        dataFilename contents:data.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
        ^ dataFilename.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    data isCollection ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
        dataFilename contents:data printString.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
        ^ dataFilename.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    printRow := 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
        [:s :eachValueOrRow |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
            eachValueOrRow isString ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
                s nextPutAll:eachValueOrRow
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
            ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
                eachValueOrRow isAssociation ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
                    eachValueOrRow key printOn:s.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
                    s space.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
                    eachValueOrRow value printOn:s.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
                ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
                    eachValueOrRow isCollection ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
                        eachValueOrRow 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
                            do:[:element | element printOn:s]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
                            separatedBy:[ s space]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
                    ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
                        eachValueOrRow printOn:s
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
                    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
                ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
            ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
            s cr.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    dataFilename writingFileDo:[:s |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
        data isSequenceable ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
            data do:[:eachValueOrRow |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
                printRow value:s value:eachValueOrRow.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
            ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
        ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
            data keysAndValuesDo:[:eachKey :eachValueOrRow |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
                eachKey printOn:s.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
                s space.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
                printRow value:s value:eachValueOrRow.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
            ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
        ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
    ^ dataFilename
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
generateImage
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   341
    "generates the magnifiedImage right away
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   342
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
     self new
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
        script:(GnuplotGraphView defaultScript);
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
        data:(RandomGenerator new next:50);
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
        open
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
    "
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   348
    |scriptUsed command tmpDir outStream errorStream statusCode ok
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
     dataFilename scriptFilename outFilename argsDict expandedScript
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
     stdout stderr|
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   352
    (scriptUsed := script) isNil ifTrue:[
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   353
        scriptUsed := self defaultScript.
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   354
    ].
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    command := 'gnuplot "%1"'.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
    argsDict := Dictionary new.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    tmpDir := Filename tempDirectory.
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   360
    [
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   361
        data notEmptyOrNil ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   362
            dataFilename := self generateDataFileIn:tmpDir.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   363
        ] ifFalse:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   364
            dataFilename := nil.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
        ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   367
        outFilename := (Filename newTemporaryIn:tmpDir) withSuffix:'png'.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   368
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   369
        argsDict at:'data' put:(dataFilename isNil ifTrue:[''] ifFalse:[dataFilename baseName]).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   370
        argsDict at:'dataSize' put:(data size).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   371
        argsDict at:'outputFile' put:(outFilename baseName).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   372
        argsDict at:'outputFormat' put:'png'.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   373
        argsDict at:'title' put:(title ? '').
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   374
        ((adjustHolder value ? '') includesString:'fit') not
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   375
        ifTrue:[
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   376
            argsDict at:'width' put:(640 * (self magnificationFactor)).
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   377
            argsDict at:'height' put:(400 * (self magnificationFactor)).
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   378
        ] ifFalse:[
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   379
            argsDict at:'width' put:self width.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   380
            argsDict at:'height' put:self height.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   381
        ].
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   382
        expandedScript := scriptUsed bindWithArguments:argsDict.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   383
        scriptFilename := (Filename newTemporaryIn:tmpDir).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   384
        scriptFilename := scriptFilename asFilename withSuffix:'gnuplot'.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   385
        scriptFilename contents:expandedScript.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   386
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   387
        command := command bindWith:(scriptFilename baseName).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   388
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   389
        outStream := '' writeStream.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   390
        errorStream := '' writeStream.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   391
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   392
        ok := OperatingSystem 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   393
            executeCommand:command
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   394
            inputFrom:Stdin
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   395
            outputTo:outStream
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   396
            errorTo:errorStream
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   397
            environment:nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   398
            inDirectory:tmpDir
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   399
            lineWise:true
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   400
            showWindow:false
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   401
            onError:[:status | 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   402
                statusCode := status code.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   403
                ok := false.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   404
            ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   405
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   406
        ok ifFalse:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   407
            (stderr := errorStream contents) notEmptyOrNil ifTrue:[
6127
051421a27b60 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 5781
diff changeset
   408
                Transcript showCR:(stderr allRed).
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   409
            ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   410
        ] ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   411
            (stdout := outStream contents) notEmpty ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   412
                Transcript showCR:stdout.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   413
            ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   414
            image := Image fromFile:outFilename.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
        ].
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   416
    ] ensure:[
5765
57796607f252 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5762
diff changeset
   417
        dataFilename notNil ifTrue:[ dataFilename remove ]. 
57796607f252 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5762
diff changeset
   418
        outFilename notNil ifTrue:[ outFilename remove ]. 
57796607f252 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5762
diff changeset
   419
        scriptFilename notNil ifTrue:[ scriptFilename remove ]. 
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
generateMagnifiedImage
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
    image isNil ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
        self generateImage  
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
    ].
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   427
    magnifiedImage := smoothMagnifiedImage := image.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   428
"/    super generateMagnifiedImage.
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   429
!
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   430
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   431
redrawX:x y:y width:w height:h
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   432
    (OperatingSystem canExecuteCommand:'gnuplot') ifFalse:[
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   433
        self clearRectangleX:x y:y width:w height:h.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   434
        self showWarning.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   435
        ^ self.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   436
    ].
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   437
    super redrawX:x y:y width:w height:h.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   438
!
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   439
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   440
showWarning
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   441
    |infoMsg wString|
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   442
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   443
    infoMsg := resources string:'No gnuplot command found'.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   444
    wString := gc font widthOf:infoMsg.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   445
    gc displayString:infoMsg x:(self width - wString) // 2 y:(self height // 2).
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   446
!
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   447
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   448
sizeChanged:how
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   449
    super sizeChanged:how.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   450
    self invalidate.
5759
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   451
!
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   452
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   453
updateImageAfterSizeChange
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   454
    image := nil.
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   455
    super updateImageAfterSizeChange
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   456
! !
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   457
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   458
!GnuplotGraphView methodsFor:'menu'!
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   459
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   460
smoothFitBigMenuItemVisible
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   461
    ^ false
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   462
!
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   463
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   464
smoothingMenuItemVisible
08dbdd438639 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5755
diff changeset
   465
    ^ false
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   468
!GnuplotGraphView methodsFor:'menu actions'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   469
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   470
formatChanged
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   471
    image := magnifiedImage := smoothMagnifiedImage := nil.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   472
    self invalidate
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   473
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   474
5755
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   475
!GnuplotGraphView methodsFor:'mvc'!
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   476
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   477
updateFromModel
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   478
    "the model changes, set my image"
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   479
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   480
    self data:model value.
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   481
! !
ab974e8d9ee5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5754
diff changeset
   482
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
!GnuplotGraphView class methodsFor:'documentation'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
version
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
    ^ '$Header$'
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
version_CVS
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    ^ '$Header$'
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492