Open beddalumia opened 1 year ago
Have you tried using the options
feature? I have this project where I just:
call gp % options("set term dumb;")
And it changes the terminal to ASCII as expected.
BTW: honeycombs you say :) can't wait to test it
Uhm, well, apparently not for me:
[...]
case ("gnuplot")
call gnu%options("set term qt;")
call gnu%xlabel('x')
call gnu%ylabel('y')
call gnu%filename("hex_temp_script.gp")
call gnu%plot(x,y,'with points pt 6 ps 1.2 lc rgb "#000000"')
[...]
gives
Plotting neighborhood of hex a...
set term wxt size 640,480 enhanced font "verdana,10" title "ogpf libray: Rev. 0.22 of March 9th, 2018"
^
"hex_temp_script.gp" line 6: unknown or ambiguous terminal type; type just 'set terminal' for a list
(But editing manually the source code with the same option (qt
) does the trick.)
I've also tried moving around the options
command (despite I think order should not matter, as far as it comes before plot
) and nothing changed.
So here we go with the metadata:
#fpm.toml
[...]
[dependencies]
ogpf.git = "https://github.com/kookma/ogpf.git"
ogpf.branch = "master" # So I should be on master head, right?
[...]
Did maybe this use to work?
PS: I hope to roll the first minimal viable product within the weekend, keen on feedback :)
The order is important. Be sure that this is the first thing you do. Can you attatch the generated file?
Never mind, I bet the issue is that in platforms where wxt
is not available (unknown) the script will halt.
Can you please check if the command
gnuplot -e "set terminal" | grep wxt
returns anything?
PS: I have no such issue because my platform supports wxWidgets, as :
$ gnuplot -e "set terminal" | grep wxt
wxt wxWidgets cross-platform interactive terminal
$ cat ogpf_temp_script.gp | grep "set term"
set term wxt size 640,480 enhanced font "verdana,10" title "ogpf libray: Rev. 0.22 of March 9th, 2018"
set term dumb
Oh I see, the options
command does indeed insert the desired terminal specification, but it positions it after the default line, so that gnuplot parses wxt
anyway. Of course if wxt
is supported by the system inserting the custom line after the default leads to the correct behavior but when not recognized makes gnuplot halt.
So... Is there's a way to make options
override the first set term
line? It should be something like removing that line from subroutine create_outputfile
and calling internally options
if you detect the user has not (but I imagine parsing all options
calls would be just dumb. So maybe a new set_terminal
public method, allowing direct access to (a non parameter version of) gnuplot_term_type
?
Anyway the generated script has the same structure as you predicted:
And likewise the full list of available terminals does not contain wxt
:
I was about to say:
Indeed assuming a default term is a problem, a possible fix would just creating a method to handle it, let's say:
call gp % set_terminal("qt") ! I like this one the most call gp % term("qt") call gp % set_term("qt") call gp % terminal("qt")
create a character variable here
https://github.com/kookma/ogpf/blob/7b414be0d1bdeccc11bd80ed3033a0862468e630/src/ogpf.f90#L207-L209
But this requires changing it here as well (where the writing is done)
The only big problem left is figuring out all where to put all the other configs like font, size, title (I guess it's the window title) for each terminal, figuring this out is no easy task, but it may not be needed.
It can be accomplished by just checking if, let's say
this % txtterminal
, is allocated and then just outputting its contents in the writing section, or writting the default way with wxt otherwise.
This solves the issue... at least partially, can you provide a PR?
call gp % set_terminal("qt") ! I like this one the most
Yeah, I agree!
title (I guess it's the window title)
Exactly, is where the "credits" go... I think this is not intended to be customizable (but you tell me)
But, for the others, we might want to have all these new methods:
set_terminal
set_font
set_size
set_window_title
(?) which would be optional to call (if not called the script is generated with the current hardcoded values).
I believe this could be handled by just some extra character variables and the classic
if(extra_variable/=gnuplot_term_<stuff>)then
gnuplot_term_<stuff> = extra_variable
endif
Of course then, the gnuplot_term_<stuff>
variables need to give up the parameter
attribute, but I don't see big issues with this.
This solves the issue... at least partially, can you provide a PR?
Yeah if you agree with the approach described here I could give it a try, it does seem quite approachable. 🙃
Yeah if you agree with the approach described here
I mean, I agree this is an issue but the final word here is from @kookma who has the writing permissions. That's why I suggest you open a PR so I can help reviewing and digesting the changes.
Of course then, the gnuplotterm
variables need to give up the parameter attribute
Actually, it's better include/move them in the type, public :: gpf
as a member of it (since you could have multiple instances with different terminals and so on).
I suggest you focus just on the set_terminal
method as you may find that not every terminal will support all parameters ("set term png" will not support a window title because there is no such thing).
Actually, it's better include/move them in the type, public :: gpf as a member of it (since you could have multiple instances with different terminals and so on).
Yes, sure, you're right.
I suggest you focus just on the set_terminal method as you may find that not every terminal will support all parameters ("set term png" will not support a window title because there is no such thing).
Oh let me do some trials, cause I thought Gnuplot is able to deal with invalid parameter and just skip it (surely does with the window-title when I set the terminal to dumb
)
Yes, I can confirm that if you change the default terminal to qt
(in the source) and then
call gnu%options("set term png;")
you encounter no errors and get a correct png file.
I just pop up to apologize for the long wait, I've been quite busy with HoneyTools itself and the PhD work it has been developed for... As summer ends I would probably keep being busy but I intend to work on this at some point. I'll let you know when there is some progress :)
Not sure whether it will be relevant, but this is how I choose the "default terminal" for gnuplot.
Create a file called .gnuplot
under the $HOME
directory, and add
set terminal qt enhanced font "Alegreya, 14" size 1600, 960
and now for all of the 2D figure my gnuplot will use qt instead of wxt.
Do I understand correctly that the terminal option cannot be set from the Fortran client? Shouldn't
ogpf
allow the user to do that with theoptions
command?My understanding is that currently you need to directly modify the source at line:
https://github.com/kookma/ogpf/blob/7b414be0d1bdeccc11bd80ed3033a0862468e630/src/ogpf.f90#L163-L165
This, in my opinion, makes unfeasible any usage through
fpm
. If your OS does not allow the hard-codedwxt
parameter you have the only option to fork the source file and manually include it in your project, which totally defeats the purpose of afpm.toml
file.