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