#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Wed, 02 May 2018 21:06:31 +0200
changeset 5759 08dbdd438639
parent 5758 bff79a5aad10
child 5760 d689b29b69cc
#FEATURE by cg class: GnuplotGraphView added: #adjust: #magnificationFactor: #smoothFitBigMenuItemVisible #smoothingMenuItemVisible #updateImageAfterSizeChange changed: #generateImage #generateMagnifiedImage class: GnuplotGraphView class changed: #defaultScriptForDots #defaultScriptForHistogram #defaultScriptForLines
GnuplotGraphView.st
--- a/GnuplotGraphView.st	Wed May 02 16:24:15 2018 +0200
+++ b/GnuplotGraphView.st	Wed May 02 21:06:31 2018 +0200
@@ -75,7 +75,7 @@
     "a default initial gnuplot script to show a dots diagram"
 
     ^ '
-set term %(outputFormat)
+set term %(outputFormat) size %(width),%(height)
 set output "%(outputFile)"
 set title "%(title)"
 plot [-10:110] ''%(data)'' with dots 
@@ -86,7 +86,7 @@
     "a default initial gnuplot script to show a histogram"
 
     ^ '
-set term %(outputFormat)
+set term %(outputFormat) size %(width),%(height) 
 set output "%(outputFile)"
 set title "%(title)"
 plot [-10:110] ''%(data)'' with histogram 
@@ -97,7 +97,7 @@
     "a default initial gnuplot script to show a line diagram"
 
     ^ '
-set term %(outputFormat)
+set term %(outputFormat) size %(width),%(height) 
 set output "%(outputFile)"
 set title "%(title)"
 plot ''%(data)'' with lines 
@@ -160,6 +160,12 @@
 
 !GnuplotGraphView methodsFor:'accessing'!
 
+adjust:layoutSymbol
+    image := nil.
+    super adjust:layoutSymbol.
+    self invalidate
+!
+
 data
     ^ data
 !
@@ -168,6 +174,12 @@
     data := something.
 !
 
+magnificationFactor:aNumber
+    image := nil.
+    super magnificationFactor:aNumber.
+    self invalidate
+!
+
 script
     ^ script
 !
@@ -277,7 +289,8 @@
 !
 
 generateImage
-    "
+    "generates the magnifiedImage right away
+
      self new
         script:(GnuplotGraphView defaultScript);
         data:(RandomGenerator new next:50);
@@ -309,7 +322,14 @@
         argsDict at:'outputFile' put:(outFilename baseName).
         argsDict at:'outputFormat' put:'png'.
         argsDict at:'title' put:(title ? '').
-
+        ((adjustHolder value ? '') includesString:'fit') not
+        ifTrue:[
+            argsDict at:'width' put:(640 * (self magnificationFactor)).
+            argsDict at:'height' put:(400 * (self magnificationFactor)).
+        ] ifFalse:[
+            argsDict at:'width' put:self width.
+            argsDict at:'height' put:self height.
+        ].
         expandedScript := scriptUsed bindWithArguments:argsDict.
         scriptFilename := (Filename newTemporaryIn:tmpDir).
         scriptFilename := scriptFilename asFilename withSuffix:'gnuplot'.
@@ -355,7 +375,8 @@
     image isNil ifTrue:[
         self generateImage  
     ].
-    super generateMagnifiedImage.
+    magnifiedImage := smoothMagnifiedImage := image.
+"/    super generateMagnifiedImage.
 !
 
 redrawX:x y:y width:w height:h
@@ -378,6 +399,21 @@
 sizeChanged:how
     super sizeChanged:how.
     self invalidate.
+!
+
+updateImageAfterSizeChange
+    image := nil.
+    super updateImageAfterSizeChange
+! !
+
+!GnuplotGraphView methodsFor:'menu'!
+
+smoothFitBigMenuItemVisible
+    ^ false
+!
+
+smoothingMenuItemVisible
+    ^ false
 ! !
 
 !GnuplotGraphView methodsFor:'menu actions'!