GnuplotGraphView.st
author Claus Gittinger <cg@exept.de>
Tue, 01 May 2018 10:48:57 +0200
changeset 5754 e2ff55aff529
parent 5750 78ef41988e39
child 5755 ab974e8d9ee5
permissions -rw-r--r--
#FEATURE by cg class: GnuplotGraphView class definition added: #defaultScript #formatChanged #formatHolder changed: #generateImage class: GnuplotGraphView class added: #defaultScriptForDots #defaultScriptForLines #middleButtonMenuExtraSlice comment/format in: #documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
     1
"{ Encoding: utf8 }"
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
     2
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:libwidg2' }"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: Smalltalk }"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
ImageView subclass:#GnuplotGraphView
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
     8
	instanceVariableNames:'script data title formatHolder'
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	category:'Views-Misc'
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!GnuplotGraphView class methodsFor:'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
documentation
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    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
    19
    Now also shown in the collection-inspector tab.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    [author:]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
        cg
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
    [instance 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
    [class variables:]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
    [see also:]
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
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
examples
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 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
    36
 to create nicely formatted and clickable executable examples in the generated html-doc.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 (see the browsers class-documentation menu items for more)
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 trying the widget as standAlone view:
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
                                                        [exBegin]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    GnuplotGraphView new 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
        script:(GnuplotGraphView defaultScript);
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
        model:(ValueHolder with:(Random new next:100));
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
        open
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
                                                        [exEnd]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
 embedded in another view:
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
                                                        [exBegin]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    |top v|
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    top := StandardSystemView new.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    top extent:300@300.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    v := GnuplotGraphView new.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    v origin:10@10 corner:150@150.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    top add:v.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    top open
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
                                                        [exEnd]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!GnuplotGraphView class methodsFor:'defaults'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
defaultScript
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    "return a default initial gnuplot script"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    ^ self defaultScriptForHistogram
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    69
defaultScriptForDots
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    70
    "a default initial gnuplot script to show a dots diagram"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    71
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    72
    ^ '
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    73
set term %(outputFormat)
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    74
set output "%(outputFile)"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    75
set title "%(title)"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    76
plot [-10:110] ''%(data)'' with dots 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    77
'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    78
!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    79
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
defaultScriptForHistogram
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "a default initial gnuplot script to show a histogram"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    ^ '
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
set term %(outputFormat)
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
set output "%(outputFile)"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
set title "%(title)"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
plot [-10:110] ''%(data)'' with histogram 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
'
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    89
!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    90
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    91
defaultScriptForLines
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    92
    "a default initial gnuplot script to show a line diagram"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    93
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    94
    ^ '
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    95
set term %(outputFormat)
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    96
set output "%(outputFile)"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    97
set title "%(title)"
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    98
plot ''%(data)'' with lines 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    99
'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   100
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   101
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   102
!GnuplotGraphView class methodsFor:'menu specs'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   103
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   104
middleButtonMenuExtraSlice
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   105
    "This resource specification was automatically generated
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   106
     by the MenuEditor of ST/X."
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   107
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   108
    "Do not manually edit this!! If it is corrupted,
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   109
     the MenuEditor may not be able to read the specification."
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
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
     MenuEditor new openOnClass:GnuplotGraphView andSelector:#middleButtonMenuExtraSlice
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   114
     (Menu new fromLiteralArrayEncoding:(GnuplotGraphView middleButtonMenuExtraSlice)) startUp
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   115
    "
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   116
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   117
    <resource: #menu>
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   118
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   119
    ^ 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   120
     #(Menu
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   121
        (
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   122
         (MenuItem
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   123
            label: '-'
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
         (MenuItem
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   126
            label: 'Format'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   127
            submenu: 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   128
           (Menu
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   129
              (
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   130
               (MenuItem
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   131
                  label: 'Histogram'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   132
                  choice: formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   133
                  choiceValue: histogram
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
               (MenuItem
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   136
                  label: 'Lines'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   137
                  choice: formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   138
                  choiceValue: lines
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
               (MenuItem
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   141
                  label: 'Dots'
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   142
                  choice: formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   143
                  choiceValue: dots
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
               )
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   146
              nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   147
              nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   148
            )
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   149
          )
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
        nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   152
        nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   153
      )
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
!GnuplotGraphView methodsFor:'accessing'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
data
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    ^ data
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
data:something
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    data := something.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
script
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    ^ script
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
script:something
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    script := something.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
title
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    ^ title
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
title:something
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    title := something.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   182
!GnuplotGraphView methodsFor:'aspects'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   183
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   184
formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   185
    formatHolder isNil ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   186
        formatHolder := #histogram asValue.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   187
        formatHolder onChangeSend:#formatChanged to:self.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   188
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   189
    ^ formatHolder
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   190
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   191
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   192
!GnuplotGraphView methodsFor:'defaults'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   193
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   194
defaultScript
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   195
    |format|
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
    format := self formatHolder value.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   198
    format == #histogram ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   199
        ^ self class defaultScriptForHistogram
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   200
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   201
    format == #lines ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   202
        ^ self class defaultScriptForLines
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   203
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   204
    format == #dots ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   205
        ^ self class defaultScriptForDots
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   206
    ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   207
    ^ self class defaultScript
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   208
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   209
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
!GnuplotGraphView methodsFor:'drawing'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
generateDataFileIn:aDirectory
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    "the format of data expected by gnuplot depends on the type of plot:
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
        regular plot: a number of values (each in a separate line)
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        multiCol plots: a number of lines, each containing a row
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
     here, handle common situations;
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
     however, if the data does not match, the program should have prepared the 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
     data into a string and present it as such.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
     Strings will be sent as-is to the file"
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    |dataFilename printRow|
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    dataFilename := (Filename newTemporaryIn:aDirectory) pathName.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    dataFilename := dataFilename asFilename withSuffix:'dat'.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    (data isString or:[data isByteArray]) ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        dataFilename contents:data.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
        ^ dataFilename.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    data isCollection ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
        dataFilename contents:data printString.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
        ^ dataFilename.
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
    printRow := 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
        [:s :eachValueOrRow |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
            eachValueOrRow isString ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
                s nextPutAll:eachValueOrRow
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
            ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
                eachValueOrRow isAssociation ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
                    eachValueOrRow key printOn:s.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
                    s space.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
                    eachValueOrRow value printOn:s.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
                ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
                    eachValueOrRow isCollection ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
                        eachValueOrRow 
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
                            do:[:element | element printOn:s]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
                            separatedBy:[ s space]
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
                    ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
                        eachValueOrRow printOn:s
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
                    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
                ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
            ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
            s cr.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    dataFilename writingFileDo:[:s |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
        data isSequenceable ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
            data do:[:eachValueOrRow |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
                printRow value:s value:eachValueOrRow.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
            ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
        ] ifFalse:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
            data keysAndValuesDo:[:eachKey :eachValueOrRow |
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
                eachKey printOn:s.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
                s space.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
                printRow value:s value:eachValueOrRow.
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
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    ^ dataFilename
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
generateImage
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    "
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
     self new
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
        script:(GnuplotGraphView defaultScript);
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
        data:(RandomGenerator new next:50);
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
        open
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    "
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   281
    |scriptUsed command tmpDir outStream errorStream statusCode ok
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
     dataFilename scriptFilename outFilename argsDict expandedScript
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
     stdout stderr|
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   285
    (scriptUsed := script) isNil ifTrue:[
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   286
        scriptUsed := self defaultScript.
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   287
    ].
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    command := 'gnuplot "%1"'.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    argsDict := Dictionary new.
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    tmpDir := Filename tempDirectory.
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   293
    [
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   294
        data notEmptyOrNil ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   295
            dataFilename := self generateDataFileIn:tmpDir.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   296
        ] ifFalse:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   297
            dataFilename := nil.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
        ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   300
        outFilename := (Filename newTemporaryIn:tmpDir) withSuffix:'png'.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   301
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   302
        argsDict at:'data' put:(dataFilename isNil ifTrue:[''] ifFalse:[dataFilename baseName]).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   303
        argsDict at:'dataSize' put:(data size).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   304
        argsDict at:'outputFile' put:(outFilename baseName).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   305
        argsDict at:'outputFormat' put:'png'.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   306
        argsDict at:'title' put:(title ? '').
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   307
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   308
        expandedScript := scriptUsed bindWithArguments:argsDict.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   309
        scriptFilename := (Filename newTemporaryIn:tmpDir).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   310
        scriptFilename := scriptFilename asFilename withSuffix:'gnuplot'.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   311
        scriptFilename contents:expandedScript.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   312
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   313
        command := command bindWith:(scriptFilename baseName).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   314
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   315
        outStream := '' writeStream.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   316
        errorStream := '' writeStream.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   317
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   318
        ok := OperatingSystem 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   319
            executeCommand:command
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   320
            inputFrom:Stdin
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   321
            outputTo:outStream
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   322
            errorTo:errorStream
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   323
            environment:nil
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   324
            inDirectory:tmpDir
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   325
            lineWise:true
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   326
            showWindow:false
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   327
            onError:[:status | 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   328
                statusCode := status code.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   329
                ok := false.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   330
            ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   331
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   332
        ok ifFalse:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   333
            (stderr := errorStream contents) notEmptyOrNil ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   334
                Transcript showCR:(stderr withColor:Color red).
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   335
            ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   336
        ] ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   337
            (stdout := outStream contents) notEmpty ifTrue:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   338
                Transcript showCR:stdout.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   339
            ].
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   340
            image := Image fromFile:outFilename.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
        ].
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   342
    ] ensure:[
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   343
        dataFilename notNil ifTrue:[ dataFilename delete ]. 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   344
        outFilename notNil ifTrue:[ outFilename delete ]. 
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   345
        scriptFilename notNil ifTrue:[ scriptFilename delete ]. 
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
generateMagnifiedImage
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    image isNil ifTrue:[
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
        self generateImage  
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    ].
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
    super generateMagnifiedImage.
5750
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   354
!
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   355
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   356
redrawX:x y:y width:w height:h
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   357
    (OperatingSystem canExecuteCommand:'gnuplot') ifFalse:[
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   358
        self clearRectangleX:x y:y width:w height:h.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   359
        self showWarning.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   360
        ^ self.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   361
    ].
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   362
    super redrawX:x y:y width:w height:h.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   363
!
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   364
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   365
showWarning
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   366
    |infoMsg wString|
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   367
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   368
    infoMsg := resources string:'No gnuplot command found'.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   369
    wString := gc font widthOf:infoMsg.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   370
    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
   371
!
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   372
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   373
sizeChanged:how
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   374
    super sizeChanged:how.
78ef41988e39 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
   375
    self invalidate.
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
5754
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   378
!GnuplotGraphView methodsFor:'menu actions'!
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   379
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   380
formatChanged
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   381
    image := magnifiedImage := smoothMagnifiedImage := nil.
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   382
    self invalidate
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   383
! !
e2ff55aff529 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
   384
5742
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
!GnuplotGraphView class methodsFor:'documentation'!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
version
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    ^ '$Header$'
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
!
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
version_CVS
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    ^ '$Header$'
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
! !
5a4a11ee0b1f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394