Navigation:  Programmer's Reference >

Automatic resizing of diagrams

 

Previous pageReturn to chapter overviewNext page

The GRAPH-XT library architecture allows you to resize diagrams with a single function named FNDPlot_autosize. This function resizes all documents you have displayed before by using DPlot_show according to the current screen resolution. Once you have closed a document using FNDPlot_doc_close this document will no longer be auto-sized. The function FNDPlot_autosize takes several optional parameters in order to control the resize process.

 

Info3

Please note:
Due to technical reasons the function FNDplot_autosize does only work in 256 color mode. For high color modes you have to resize your documents by yourself (see below).

 

Here is how it works:

Show your diagram(s) using DPlot_show at least once
Call the function FNDPlot_autosize with any parameters you want

 

That's all !  The function FNDplot_autosize is capable of autosizing up to 10 documents simultaneously.

 

Example code:

CALL Dplot_show(Doc_num)         ! show DPlot diagram (100% screen size)

! now call the resize function, 0.01s timeslice, infinite wait, interruptable with the Esc key

Dummy=FNDplot_autosize(0.01,0,27)

 

lampe

Hint:

In order to reduce "black" flicker when you drag the HTBasic screen with the mouse you may want to invert black and white using the following two commands:

SET PEN 0 INTENSITY 1,1,1

SET PEN 1 INTENSITY 0,0,0

 

 

Manually un-registering documents from automatic resizing

In case you want to omit open documents from the autosize process add the following code to your program:

Dummy=FNDplot_autosize(0,0,0,0,Doc_num)  ! un-register DPlot document from autosize routine

After executing this command the document will no longer be autosized for the next call of the function FNDplot_autosize.

 

Manually re-registering documents for automatic resizing

If you want to add previously unregistered document to the autosize simply add the following code to your program:

INTEGER X,Y

REAL W,H

X=0                           ! document starts at x=0 on the screen (left)

Y=100                         ! document starts at y=100 on the screen (bottom)

W=100                         ! 100% screen height

H=100                         ! 100% screen width

! re-register DPlot document with autosize routine

Dummy=FNDplot_autosize(0,0,0,1,Doc_num,X,Y,W,H)

After executing this command the document will be autosized for the next call of the function FNDplot_autosize.

 

You can also use the function FNDplot_autosize in Interactive Mode. In this mode a button labeled "Refresh screen" will be placed at the top right of the screen which allows you to refresh the HTBasic screen when clicking on this button. See è Example program 8 for more details.

 

Automatic resizing in High color mode

Add the following code to your program and insert a GOSUB Waitloop at the end of your routine:

 

! ... end of your own DPlot drawing routines

GOSUB Waitloop                         ! call the resizing routine

!

Dummy=FNDplot_doc_close(Doc_num)  ! close DPlot document(s)

! ...

! end of the DPlot drawing routine. Jump back to your calling routine

! by using RETURN, SUBEXIT etc.

!=================================================================================

! Begin of resizing routines

Show_bitmap: !

CALL Dplot_show(Doc_num)       ! show DPlot diagram (100% screen size)

RETURN

Waitloop: !

! this routine resizes the graphic if someone has resized the HTBasic screen

INTEGER Timedue

REAL Starttime,Timeslice

Timeslice=.1                   ! time granule = 100ms

Timedue=0                       ! will be set to 1 if waiting time has elapsed

Starttime=TIMEDATE

Dhold=Dh

Dwold=Dw

Waittime=5                      ! 5s wait time until routine will be terminated

Prog_break=0

ON KBD ALL GOSUB Key_pressed

REPEAT

  WAIT Timeslice             ! wait...

  IF TIMEDATE-Starttime>=Waittime THEN Timedue=1   ! overdue?

  CALL Dplot_scr_size(Dw,Dh) ! get screen size

  IF Dw<>Dwold OR Dh<>Dhold THEN

      GOSUB Show_bitmap       ! resize the bitmap and show it again

       Dwold=Dw

       Dhold=Dh

  END IF

UNTIL Timedue OR Prog_break

RETURN

Key_pressed: Prog_break=1

RETURN

! End of resizing routines

!=================================================================================

 

Please note: It may take some time to display the new re-sized diagram, especially for complex 3D diagrams and depending on the speed of your computer !