|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Mar 16, 2021 11:52 am Post subject: |
|
|
Martin,
I can see in some of the snippets of code that you have shared that you don't have call backs on the %vx, %hx, or %sl, but you do have a %dl. So all processing of new slider values is **possibly** carried out asynchronously by the %dl ?
Having said that, when the x or y siders are moved the %pl callback is called, I've just discovered that.
There may be a lot of unnecessary processing within the %pl callback at this time. Try to inhibit this by adding the following code at the very beginning of the call back.
Code: | if ( clearwin_string@('callback_reason') .eq. 'VSCROLL' .or. &
clearwin_string@('callback_reason') .eq. 'HSCROLL' ) then
pl_cb = 2
return
end if |
Don't do this if you are currently using the call back reason VSCROLL or HSCROLL for other purposes - I am second guessing other parts of your code.
As a further safeguard Paul's suggested approach could also be applied to the %pl call back.
See http://forums.silverfrost.com/viewtopic.php?t=3992&highlight=reentry
Also check that there are no unnecessary calls to simpleplot_redraw@ in the code. |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Tue Mar 16, 2021 8:30 pm Post subject: |
|
|
Thanks Paul!
you are right, I did it and after some experiments
with really very rapid slider movements back and forth, program did not crash!
Maybe some interesting info for you as FTN95 developer:
During development of the program, I always created the DEBUG/x64
version of the executable using also the option /UNDEF (in Plato environment)
and tested the program. Program worked fine in last stages of its development.
Then I created the executable as RELEASE/x64 also with /UNDEF and got
some error regarding an undefined variable.
Then, I created again the RELEASE/x64 executable, this time by deactivating /UNDEF
and program works fine and after implementing your suggestion
regarding slider - no crash occured at all. |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Tue Mar 16, 2021 9:23 pm Post subject: |
|
|
Ken,
Thanks for your - as always - very useful tips/observations.
I will have a look at this!
A question:
Somehow, I was unable to understand how could I write a short code
for selecting an object in a graphic area by mouse click on it, which could
be used universally (for any graphic) and that it would be optically visible
in the graphic area, which object (point or line or area) was selected
and then - say - deselecting it by additional mouse click (left or right).
Is there a free code which would do it? |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Wed Mar 17, 2021 9:25 am Post subject: |
|
|
Martin,
See the following: https://www.silverfrost.com/ftn95-help/clearwinp/gdialog/graphicsicons.aspx
Using the basic ideas described there I was able to develop a graphics interface which allowed me to draw interactively an electrical network and extract its parameters and connectivity to a file for input to another program. |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed Mar 17, 2021 7:08 pm Post subject: |
|
|
I had a look there some time ago, but was unsure whether it can be applied
also with %PL, since there is explicitly stated the %GR only.
So, can I use these features also with %PL or there is necessary to rewrite the code with %PL to %GR?
Now - an additional remark for Paul regarding my previous
suggestion for enhancing %PL capabilities.:
I still mulled how to simplify my second suggestion for the %PL enhancement (georeferencing of images in the graph) mentioned
earlier in this string of conversations and have the following
- I think, essentially simplified - idea:
Would it be realizable (with no huge effort and amount of time) to add a new option for the %PL like this:
%PL [image=filename.jpg]?
The purpose of this option would be to overlay current vector graphics
in the graph (like red lines and blue points in my case) with a pure jpg
image/picture (like in the case of %IM), with NO georeferencing,
hence no association with real geodetic coordinates which have the points/lines/areas in the graph.
I suppose, it would mean no complicated mathematics behind this.
The only requirement for such option would be that it
would have to stretch the image between X,Y axes in the graph.
Namely, I would be able to prepare a georeferenced orthophotomosaic
images in another software used for mobile mapping, which would at least roughly fit the area where
objects with real geodetic coordinates are located in the graph.
It would mean - at least - a roughly fit/coincide between the
image with no coordinate association a and objects in the graph with real geodetic coordinates.
Such option would just serve as a background source for the vector graphics in the graph. I think this would be very interesting enhancement.
Thanks for your evaluation of this idea and answer. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Mar 17, 2021 11:03 pm Post subject: |
|
|
Paul (Laidler), is this documentation section 'Graphics icons' referenced by Ken a relatively recent addition or a longstanding capability?
I don't remember seeing it before myself and as I know there's been a documentation update being continuously ongoing for a while now I just wandered. _________________ ''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 ... " |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Thu Mar 18, 2021 8:10 am Post subject: |
|
|
Very long standing. |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Thu Mar 18, 2021 9:37 pm Post subject: |
|
|
I had a look at your code and this fulfills the basic idea - thanks, Ken!
But as always - it is rarely the case, when something works
with me on the first time and this is no exception.
So, I have a problem and a question.
PROBLEM:
I have the following plot function(using %PL) calling a callback (PL_CB) called by %PL (an extract of my code):
Code: |
INTEGER FUNCTION plot_OK_MM ()
IMPLICIT NONE
iw = CREATE_GRAPHICS_REGION@(handle_internal_gr,gw,gh)
...
iw=winio@('%`^pl[vscroll,hscroll,full_mouse_input]&',gw,gh,n_pl,Y_OK_U,X_OK_U,handle_pl_ok,pl_cb)
...
iw=DELETE_GRAPHICS_REGION@(handle_internal_gr)
plot_OK_MM = 1
END FUNCTION plot_OK_MM
|
The callback PL_CB:
Code: |
...
IF (cb_reason .eq. 'PLOT_ADJUST') THEN
...
i = COPY_GRAPHICS_REGION@(handle_internal_gr, 1, 1, gw, gh, handle_pl_OK, 1, 1, gw, gh, 13369376)
END IF
IF (cb_reason .eq. 'MOUSE_MOVE' ) THEN
i = COPY_GRAPHICS_REGION@(handle_pl_OK,1,1,gw,gh,handle_internal_gr,1,1,gw,gh,13369376)
ENDIF
...
|
Now, I use your code to display an image in the graph (I modified your code slightly):
Code: |
INTEGER FUNCTION pridaj_raster ()
IMPLICIT NONE
INTEGER width_raster, height_raster, nbbp, ercode
INTEGER i
CALL GET_DIB_SIZE@( 'orthophoto_and_geo_surveying.jpg', WIDTH_RASTER, HEIGHT_RASTER, NBBP,ERCODE )
! i = NEW_GRAPHICS_REGION@( 1001, WIDTH_RASTER, HEIGHT_RASTER, rgb@(0,0,0))
i = IMPORT_FILE_IMAGE@( 'orthophoto_and_geo_surveying.jpg' , 0, 0 )
! i = COPY_GRAPHICS_REGION@(handle_pl_OK, 100, 100, gw, gh, &
! 1001, 0, 0, WIDTH_RASTER, HEIGHT_RASTER, 13369376)
! i = DELETE_GRAPHICS_REGION@(1001)
pridaj_raster = 2
END FUNCTION pridaj_raster
|
The result is that the image (file orthophoto_and_geo_surveying.jpg is loaded onto the graph BUT
it hides the vector graphic (lines and points are not visible, only the image) AND when I move with mouse over the graph area, the image automatically disappears.
QUESTION:
When the problem above will be solved, I thing that when I use the buttons zoom in/out/to extents and slider, all will be related to vector graphic only and the image will not be zoomed out/in.
How could it be resolved that also image file will be zoomed in/out/to extents along with vector graphic?
I could prevent the zooming in/out/to extents when image is displayed,
but if possible, it would be better to zoom in/out/to extents also the image. |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Thu Mar 18, 2021 11:08 pm Post subject: |
|
|
Additional info to my previous post:
I already partially found why the raster JPG image automatically disappears when
I moved with mouse over the graph.
In the callback PL_CB called within %PL I originally used the code:
Code: |
...
IF (cb_reason .eq. 'MOUSE_MOVE' ) THEN
i = COPY_GRAPHICS_REGION@(handle_pl_OK,1,1,gw,gh,handle_internal_gr,1,1,gw,gh,8913094) !!!13369376)
...
|
Now, instead 13369376 I used 8913094 and the image does NOT automatically disappear when moving with the mouse over the graph,
although after its initial loading the lines and points are still not automatically visible over the image. I have to move with the mouse over it
and then the lines and points are visible. The same is valid when I switch off the image and subsequently switch on it (first, I have to move
over graph to see the lines and points). However, when I make some zooming in/out/to extents (or any other actions relating to graph like switching off/on lines and points), the image displayed in the graph automatically disappears and must be reloaded again.
So, what is the real meaning of numbers 13369376 and 8913094 in this context and where I could find more details (all numbers and their meaning) for COPY_MODE? |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Thu Mar 18, 2021 11:21 pm Post subject: |
|
|
And still: the use of 8913094 instead of 13369376 is no win-win situation:
when I use it (8913094) and I move over the graph with mouse the yellow rectangle, where the relevant data from surveyed points are extracted displayed is always present. It means when I point over a point, then on next and so on,
every yellow box remains permanently visible in the graph. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Fri Mar 19, 2021 9:43 am Post subject: |
|
|
Martin,
Any call to simpleplot_redraw@ will remove the imported image as the %pl region is reformed. At this point you have to use COPY_GRAPHICS_REGION@ to repaste the image into the %pl graphics, before you call COPY_GRAPHICS_REGION@ to create a "back up" copy of the now modified %pl display which is used to let you display your moving yellow box.
To avoid continually calling IMPORT_IMAGE@, it would make sense to create a new permanent internal graphics region into which you import the image just once (permanent for the duration of the winio@ sequence that is associated with the %pl). Also, remember that IMPORT_IMAGE@ imports to the currently selected graphics region.
COPY_GRAPHICS_REGION@ will automatically rescale if the destination and source x/y ranges are different and since you can specify an x/y offset as well as width/height for both destination and source; this gives you a means of pasting a smaller region of the image when you have for example zoomed into an area of the graph - you know the %pl xmin/xmax/ymin/ymax values and you know the pixel width/height dimensions of the image as well as the physical origin and x/y extent coordinates the image refers to.
If your yellow box is permanently displayed you are creating the back up copy at the wrong point in the code. You just need to ensure that the copy operations are in the correct sequence. |
|
Back to top |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Sat Mar 20, 2021 10:54 pm Post subject: |
|
|
Thanks Ken for your important remarks!
However, at this moment I have something wrong somewhere in the code
of one (or more?) of the three callbacks dealing with the graphics.
Their full code can be seen/downloaded here:
https://www.dropbox.com/s/ben76ov4n02ivs0/PL%2BCB.f95?dl=0
What I am getting now is this:
A short 10s video can be seen here:
https://www.dropbox.com/s/k12axnjebx21bzf/jpg_problem.mp4?dl=0
So, the facts are as follows:
1. I need the JPG to be displayed (stretched) ONLY between X,Y axes, not over the whole graph.
I have differences between source and destination widths and heights.
I tried it to adjust tentatively in a few iteration by specifying the offset
of the image - but I achieve practically nothing, moreover - I do not want to do it manually (to find the values of offset by manually and iteratively trying by typing in their estimated values, since this will always be different from one jpg to the another one).
So, in this particular case I would need to shorten (to squeeze) the image
both in north-south and east-west direction to get it between X,Y axes and I was unable to find how
(I would also need to specify an offset from right bottom corner).
2. As can be seen in the short video, when I load in the raster onto the graph and when I move with mouse (placed outside graph) back over the
graph, the image automatically disappears although I used the COPY_GRAPHICS_REGION@ from the buffer on the graph (the ID of the graph is variable handle_pl_OK and equals 0) also in the condition:
IF (cb_reason .eq. 'MOUSE_MOVE' ) THEN
which is in the PL_CB function called within %PL. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Sun Mar 21, 2021 12:18 am Post subject: |
|
|
Looking only at your graphic above, I suspect that in your call to COPY_GRAPHICS_REGION@
Syntax
Quote: | INTEGER FUNCTION COPY_GRAPHICS_REGION@(
+ DEST_GR, DX, DY, DWIDTH, DHEIGHT,
+ SRC_GR, SX, SY, SWIDTH, SHEIGHT, COPY_MODE )
INTEGER DEST_GR, DX, DY, DWIDTH, DHEIGHT,
+ SRC_GR, SX, SY, SWIDTH, SHEIGHT, COPY_MODE |
you need to subtract the width of the right %pl margin from the present value of DWIDTH, and the height of the bottom %pl margin from the present value of DHEIGHT.
DWIDTH should equal the width X of the %pl graphics region minus the sum of the widths of the left and right margins.
DHEIGHT should equal the depth Y of the %pl graphics region minus the sum of the heights of the top and bottom margins.
X,Y are defined in the %pl call
Code: | i= winio@('%pl&',Npoints,X,Y) |
DX should equal the width of the left margin.
DY should equal the height of the top margin.
If you have not explicitly specified the margins, use the %pl[margin] option.
[margin=d] Specifies the margin value in pixels for all margins.
[margin=(d,d,d,d)] Specifies values in pixels for the left, top, right and bottom margins.
Code: | module demo_margin
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0)
integer, parameter :: mtop = 20, mbottom=300, mleft=300, mright=30
integer, parameter :: npoints = 20
real(kind=dp) :: x(1:npoints),y(1:npoints)
contains
integer function draw_pl()
integer i, iw
character(len=126) pl_str
do i = 1, npoints,1
x(i) = i-1
y(i) = (i-1)*(i-1)
end do
iw = winio@('%mn[Exit]&','exit')
call winop@('%pl[native,x_array,independent,frame,gridlines]')
write(pl_str,'("%pl[margin=(",I3,",",I3,",",I3,",",I3,")]")') mleft, mtop, mright, mbottom
call winop@(pl_str)
iw = winio@('%pl&',1000,800,npoints,x,y)
iw = winio@(' ')
draw_pl =1
end function draw_pl
end module demo_margin
program main
use demo_margin
implicit none
integer i
i = draw_pl()
end program main |
|
|
Back to top |
|
|
|
|
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
|