#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Sat, 21 Mar 2020 11:42:53 +0100
changeset 6241 8de2ecadf40b
parent 6240 b7d61c1bfe9e
child 6242 c145a08717ee
#FEATURE by cg class: GnuplotGraphView class definition added: #gnuplotCommand #gnuplotCommand: changed: #generateImage #redrawX:y:width:height:
GnuplotGraphView.st
--- a/GnuplotGraphView.st	Tue Mar 10 15:26:11 2020 +0100
+++ b/GnuplotGraphView.st	Sat Mar 21 11:42:53 2020 +0100
@@ -16,7 +16,7 @@
 "{ NameSpace: Smalltalk }"
 
 ImageView subclass:#GnuplotGraphView
-	instanceVariableNames:'script data title formatHolder'
+	instanceVariableNames:'script data title formatHolder gnuplotCommand'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Misc'
@@ -215,6 +215,10 @@
     data := something.
 !
 
+gnuplotCommand:something
+    gnuplotCommand := something.
+!
+
 hasNoScript
     ^ [ script isEmptyOrNil ]
 !
@@ -353,7 +357,7 @@
         scriptUsed := self defaultScript.
     ].
 
-    command := 'gnuplot "%1"'.
+    command := self gnuplotCommand,' "%1"'.
     argsDict := Dictionary new.
 
     tmpDir := Filename tempDirectory.
@@ -428,8 +432,29 @@
 "/    super generateMagnifiedImage.
 !
 
+gnuplotCommand
+    gnuplotCommand isNil ifTrue:[
+        gnuplotCommand := OperatingSystem getEnvironment:'GNUPLOT'.
+        gnuplotCommand isEmptyOrNil ifTrue:[
+            gnuplotCommand := 'gnuplot'
+        ].
+        (OperatingSystem canExecuteCommand:gnuplotCommand) ifFalse:[
+            OperatingSystem isMSWINDOWSlike ifTrue:[
+                (OperatingSystem canExecuteCommand:'%PROGRAMFILES%\gnuplot\bin\gnuplot.exe') ifTrue:[
+                    gnuplotCommand := '%PROGRAMFILES%\gnuplot\bin\gnuplot.exe'
+                ].
+            ].
+        ].
+    ].
+    ^ gnuplotCommand
+
+    "
+     self basicNew gnuplotCommand
+    "
+!
+
 redrawX:x y:y width:w height:h
-    (OperatingSystem canExecuteCommand:'gnuplot') ifFalse:[
+    (OperatingSystem canExecuteCommand:(self gnuplotCommand)) ifFalse:[
         self clearRectangleX:x y:y width:w height:h.
         self showWarning.
         ^ self.