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