forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New Video
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 339
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Jun 19, 2020 11:26 am    Post subject: Reply with quote

Paul,

Thanks for this new addition to the library. I spent a few hours playing around with your examples and adding to them last night. I do like the idea of configuring a graph and seeing the changes instantly! The final version of the animation I posted a link to recently contains 38 plots in the %pl region and it took me a lot of time to get the final appearance I was trying to get to – I could almost certainly got there much quicker using this addition.

Your efforts are very much appreciated.

Ken
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



Joined: 18 May 2012
Posts: 339
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Jun 19, 2020 1:37 pm    Post subject: Reply with quote

Unfortunately, there appears to be an unwanted side effect of changing over to the new DLLs. The following code behaves differently!.

With the new DLLs, a call to SIMPLEPLOT_REDRAW@() does not trigger the %pl call back function. Consequently, the text which is drawn at 20,20 is erased when the %tt button generates a new set of data and then calls SIMPLEPLOT_REDRAW@().

Can somebody please confirm my observation.

Thanks

Ken

Code:
module test_mod
use clrwin
implicit none
integer, parameter :: dp = kind(1.d0)
integer, parameter :: n = 100
real(kind=dp) x(n), y(n)
contains

integer function run()
integer i
integer, save :: iw
i = generate_data()
call winop@('%pl[native,x_array,framed,gridlines,axes_pen=4]')
iw = winio@('%^pl&',800,600,n,x,y,pl_cb)
iw = winio@('%^tt[New data]&', new_data_cb)
iw = winio@(' ')
run = 1
end function run

integer function pl_cb()
character(len=30) cb_reason
  cb_reason = clearwin_string@('callback_reason')
  print*, cb_reason
  if (cb_reason .eq. 'PLOT_ADJUST') then
    call rotate_font@(0.d0)
    call draw_characters@('Some text',40,40,rgb@(255,0,0))
  end if
  pl_cb = 2
end function pl_cb

integer function new_data_cb()
integer i
i = generate_data()
call simpleplot_redraw@()
new_data_cb = 2
end function new_data_cb

integer function generate_data()
integer i
real(kind=dp) amp, omega
x(1) = 0.d0
do i = 2, n, 1  ; x(i) = x(i-1)+0.001d0  ; end do
omega = 2.d0*4.d0*atan(1.d0)*50.d0
amp = 10.d0*random@()
do i = 1, n, 1  ;  y(i) = amp*sin(omega*x(i))  ; end do
generate_data = 1
end function generate_data

end module test_mod

program main
use test_mod
i = run()
end program main
Back to top
View user's profile Send private message Visit poster's website
Martin_K



Joined: 09 Apr 2020
Posts: 117

PostPosted: Fri Jun 19, 2020 2:38 pm    Post subject: Reply with quote

I have similar observation, Ken.

When I zoom in/out the graphics (although I did not use the option [params] yet, I just wanted to test my original code with the new DLL´s),
a call to SIMPLEPLOT_REDRAW@() causes that (in my case) both captions on both axes dismiss.

And then, when I just move the cursor back to the graphics area, the graphics is automatically zoomed to its extents as originally displayed
without I pressed the zoom in/out buttons, what is unwanted. It needs to be investigated (the new DLL´s).

In the meantime, I had to copy back the older DLL´s to avoid these problems.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6395
Location: Salford, UK

PostPosted: Fri Jun 19, 2020 2:40 pm    Post subject: Reply with quote

Ken

This change was deliberate and in response to someone's (was it you?) code failing because of re-entry to the callback when calling simple_plot_redraw@.

So I blocked calling the callback from simple_plot_redraw. I think that this is probably best because users probably don't intend or expect this to happen.

There are various way around this.

a) I could simply remove the block and let users fend for themselves.

b) I could add code to ClearWin+ that is the equivalent of permit_another_callback@() in this context.

c) You could change your code in order to do the drawing directly after calling simpleplot_redraw@. In this program it would be this...

Code:
integer function new_data_cb()
integer i
i = generate_data()
call simpleplot_redraw@()
call rotate_font@(0.d0)
call draw_characters@('Some text',40,40,rgb@(255,0,0))
new_data_cb = 2
end function new_data_cb
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 339
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Jun 19, 2020 3:46 pm    Post subject: Reply with quote

Paul,

Yes, I think you may well have made the change in response to something else I was grumbling about a few months back (attempting to zoom into an area on the %pl using box selection – I can see that works now).

I can work around the change. It just means moving code that’s currently in the %pl call back within a “if ‘plot_adjust’ ” structure to a subroutine, and calling that subroutine instead, and also calling the same subroutine after all calls to simpleplot_redraw@().

Not a major problem I think – after getting over the initial shock of loosing all the text on my last animation.

Martin will need to do the same with his code.

Ken

PS remember to include a call to SELECT_GRAPHICS_OBJECT@ in the new subroutine.
If there’s more than one graphics region open, the current region may not be the one you want to operate on.


PPS it works!
https://youtu.be/D3y3NjXaBbg
Back to top
View user's profile Send private message Visit poster's website
John-Silver



Joined: 30 Jul 2013
Posts: 1380
Location: Aerospace Valley

PostPosted: Fri Jun 19, 2020 7:05 pm    Post subject: Reply with quote

Well done Paul.
I see you've used your lockdown furloughing to good measure.

As I see it, after watching your (as usual) clearly presented video, what we have is a good GUI for setting up a graph interactively in the first instance, and then a way of introducing those changes via this'PARAMS' variable.

Effectively what you've done is to introduce what Dan was looking for a long time ago - a single command/line input of all paramaeters isn't it ?

So in principal couldn't we just then create a basic graph and then call the 'PARAMS' variable ?

In that case it would be very useful for many more experienced users to have a documentation of all the parameters, in order, on the 'PARAMS' list , which at the moment when you 'captcha and paste it' is just a string of numbers/character strings.

It would be so much easier, once created, to be able to simply edit a file with that parameter string rather than have to keep going into the new GUI to edit stuff.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1380
Location: Aerospace Valley

PostPosted: Fri Jun 19, 2020 7:10 pm    Post subject: Reply with quote

Apart from that, just to be the devil's avocado, what happens when you re-size the window ? any glitches ? and does it wok just for linear scales or should log scales also be compatible ?
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 339
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sat Jun 20, 2020 11:06 am    Post subject: Reply with quote

Well I opened up my main application this morning in Plato and recompiled it with the aim of identifying other places where I need to make the adjustments outlined above. I succeeded in doing this, but I had to resort to using Notepad as the editor.

Today’s problem is that the new Plato closes without warning when scrolling through a long file of code using the scroll up/down buttons– around 5000 lines in this case.

PS autocompile was off, but highlight DO/END do was on. If both are off it appears to be OK.
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6395
Location: Salford, UK

PostPosted: Sat Jun 20, 2020 12:08 pm    Post subject: Reply with quote

Ken

Is it possible to send me the code?
Back to top
View user's profile Send private message AIM Address
Martin_K



Joined: 09 Apr 2020
Posts: 117

PostPosted: Sat Jun 20, 2020 2:47 pm    Post subject: Reply with quote

I defined two additional functions as recommended by Paul/Ken to avoid direct call to SIMPLEPLOT_REDRAW@:

Code:

integer function new_data_cb()
CALL SELECT_GRAPHICS_OBJECT@(handle_pl)
call simpleplot_redraw@()
CALL select_font@('arial')
CALL bold_font@(1)
CALL size_in_points@(15,15)
CALL draw_characters@('Y_S-JTSK [m]',600,630,RGB@(255,0,255))
CALL rotate_font@(90.0d0)
CALL draw_characters@('X_S-JTSK [m]',90,400,RGB@(255,0,255))
CALL rotate_font@(0.0d0)
new_data_cb = 2
end function new_data_cb


Its contents was previously part of an integer call-back function within the %PL following the condition:

Code:

IF (cb_reason .eq. 'PLOT_ADJUST') THEN
...
i = COPY_GRAPHICS_REGION@(handle_internal_gr, 1, 1, gw, gh, handle_pl, 1, 1, gw, gh, 13369376)
END IF


Now, it looks as follows:

Code:

IF (cb_reason .eq. 'PLOT_ADJUST') THEN
i = new_data_cb()
i = COPY_GRAPHICS_REGION@(handle_internal_gr, 1, 1, gw, gh, handle_pl, 1, 1, gw, gh, 13369376)
END IF


Then, the 2nd new function to avoid direct SIMPLEPLOT_REDRAW@ call is:

Code:

integer function new_data_cb_simple_plot()

CALL SELECT_GRAPHICS_OBJECT@(handle_pl)
call simpleplot_redraw@()
new_data_cb_simple_plot = 2

end function new_data_cb_simple_plot


The above function replaces all direct SIMPLEPLOT_REDRAW@ calls (all those calls were removed) in the whole program.

When I zoom in/out the graph by pressing the corresponding buttons, it works, however as soon as I move the mouse cursor back over the graph, it automatically adjust the graph to its extents without pressing zoom in or zoom out button (what is not wanted).

Now, I do not know, whether this could be a problem with the new DLLs
or the problem is embedded in my code?

And to be honest, I do not quite understand, what it is advantage of blocking direct calls to SIMPLEPLOT_REDRAW@ function (which worked problem free) and using an user defined function instead? At present, I have some problems with this approach.

Martin
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6395
Location: Salford, UK

PostPosted: Sat Jun 20, 2020 3:13 pm    Post subject: Reply with quote

Ken

There is an alternative way for ClearWin+ to avoid re-entry and that is for it to block calls to simpleplot_redraw@ from the "PLOT_ADJUST" callback.

We can try that if you wish.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 339
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sat Jun 20, 2020 6:20 pm    Post subject: Reply with quote

Martin,

If you look carefully at the examples I provided you with in the other thread, there are no calls to SIMPLEPLOT_REDRAW@ within the “PLOT_ADJUST” section, or any other section of the %pl call back.

If you did have call to SIMPLEPLOT_REDRAW@ in the %pl call back, then you will get into a recursive loop and it’s by sheer luck rather than design that your code was previously running.

The zoom/pan example I posted on Thu May 14, 2020 7:39 pm works without any modification with the new DLLs. As does the example from Fri May 29, 2020. Neither of these have calls to SIMPLEPLOT_REDRAW@() within the %pl callback.

The issue I raised above was that using the %gr drawing routines on the %pl region was only occurring on the first time the call back was called. Subsequent calls to SIMPLEPLOT_REDRAW@ do not now call the callback, and so I was missing some graphics information which is added to the %pl graphics region.

Based on the discussion in the other thread, you do not appear to be trying to do this – since your %gr calls are to a different graphics region.

Without seeing a simple example which demonstrates how you have adapted the samples I have provided you with and the nature of the problem there’s not much more I can say.

For example, in you first code fragment above why do you need to call simpleplot_redraw@ before labelling your axis? Is that really necessary?

Paul,

I was OK with the previous DLLs – what I was trying to do with box selection in a %pl to create a zoom function was pushing the library to its limits – so happy to back off on that one. In any case, the modifications I made yesterday to my code, will not cause the code to fail if the block in the new DLLs is removed – which would address Martin’s issue – for the time being anyway.

Having said that, I think the block is the best way forward for all users – but you are in a far better position to make the final call on this than I am.

Ken
Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2196
Location: South Pole, Antarctica

PostPosted: Sat Jun 20, 2020 7:49 pm    Post subject: Reply with quote

Paul,
Great overall improvement of %PL!

Looked at video, though had no chance to play with it yet, too many other programs are still loaded. But from just the video was surprised that 256 bytes buffer was enough to keep all the settings. Is it formally infinite to accommodate future additions?

Also as just the potential option to discuss, do you think it is doable to implement also what John Silver mentioned, i.e. additional option for saving settings into the file ? If this will be done in the form easily included after that into the Fortran source text without editing (i.e. complete lines of text like iz=winop@('link=lines') ) that probably would be great as the current settings character line looks totally cryptic. May be on this early stage at least adding short keywords in this settings line would make it human readable and editable

And the option (button or keyboard combination) for saving image into png/jpg?

As a matter of beautification of settings probably great would be to use property sheet %ps where related settings can be systematized under the specific tabs and also 'spiced' by small images clarifying what means link=lines or frame, or etched


This was real breakthrough for %PL !


Last edited by DanRRight on Sat Jun 20, 2020 9:46 pm; edited 7 times in total
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 117

PostPosted: Sat Jun 20, 2020 8:08 pm    Post subject: Reply with quote

Ken,

sorry, this was copied by mistake (the call to SIMPLEPLOT_REDRAW@ within the function I provided above)! I never used there the call to SIMPLEPLOT_REDRAW@. Nevertheless, the issue I described I still have, simply when I zoom in/out by pressing the corresponding buttons and then when I move with the cursor over the graph, it automatically adjust to its extents.

Now, I am investigating where could be the problem hidden.
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 339
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sat Jun 20, 2020 8:45 pm    Post subject: Reply with quote

Martin,

OK, understood, but you can see how a single line of code can be misleading.

Using the terminology/definition of variables in of my post on Thu May 14, 2020 7:39 pm, maybe adding the following will fix the problem – before your call(s) to simpleplot_redraw@()

Code:
k = CHANGE_PLOT_DBL@(0, 'x_min', 0, x_min_now)
k = CHANGE_PLOT_DBL@(0, 'x_max', 0, x_max_now)
k = CHANGE_PLOT_DBL@(0, 'y_min', 0, y_min_now)
k = CHANGE_PLOT_DBL@(0, 'y_max', 0, y_max_now)


Ken
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 2 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group