Drawing vector graphics

This forum is for general support of Xbase++
Post Reply
Message
Author
Victorio
Posts: 620
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Drawing vector graphics

#1 Post by Victorio »

Hi,
I want create viewer for vector digital maps. I examine functions for drawing Gra... it is ok, drawing is too quick, ok for my use.
But I do not understand some things about metafile, dialogs and redrawing...
In example I have program, who open application window, and then presentation space
To it I drav several lines. After it if I move window to side (left, right, .... ) out from main app window and back, lines lost, or trim. It is no good. I want moving presentation , resizing, without lost draw.
In example metafile alaska is used metafile, but i do not know how input this to my source. In metafile.prg is I move window, draw is still in window.

Other thing : to future I want select some part of draw with mouse and zoom this to full presentation window, and other things so I need to work with maps.(zoom + -, pan, select, measure etc.

#include "Appevent.ch"
#include "Common.ch"
#include "Font.ch"
#include "Gra.CH"
#include "XBP.CH"
#include "Box.ch"

****************************
PROCEDURE AppSys
*****************************
PUBLIC oDlg, aPos[2], aSize[2],aPosu[2],aSizeu[2]

aSize := SetAppWindow():currentSize()
aPos[1] := 0.05 * aSize[1]
aPos[2] := 0.05 * aSize[2]
aSize[1] := aSize[1]*0.95
aSize[2] := aSize[2]*0.95

oDlg := XbpDialog():new( ,, aPos, aSize )
oDlg:title := "KRESLIMAPU"
oDlg:taskList := .T.
oDlg:close := {|| PostAppEvent( xbeP_Quit ) }
oDlg:create()
oDlg:drawingArea:setFontCompoundName( FONT_HELV_SMALL )

AppMenu( oDlg:menuBar() )

SetAppWindow( oDlg )

SetAppFocus( oDlg )

RETURN

**********************************************
PROCEDURE AppMenu( oMenuBar )
**********************************************
LOCAL oMenu

oMenu := XbpMenu():new( oMenuBar )
oMenu:title := "Aplikacia"
oMenu:create()
oMenu:addItem( { "Koniec", {|| PostAppEvent( xbeP_Quit ) } } )
oMenuBar:addItem( { oMenu, } )

oMenu := XbpMenu():new( oMenuBar )
oMenu:title := "Funkcie"
oMenu:create()
oMenu:addItem( { "Kresliciary ", {|| kresliciary() } } )
oMenuBar:addItem( { oMenu, } )

RETURN

*************************
PROCEDURE Main()
*************************
LOCAL i,j,k
LOCAL nEvent := NIL, mp1 := NIL, mp2 := NIL, oXbp := NIL, drawingArea
PUBLIC oDialog,oPS,oDevice
PUBLIC oMF

* rozmer okna pre vykreslenie mapy
aSizeu[1]=aSize[1]*0.8
aSizeu[2]=aSize[2]*0.8

oDialog:=XbpDialog():new( ,, aPos, aSizeu )
oDialog : create( , , {0,0},aSizeu)
oPS:= XbpPresSpace():new({1024,768})
oDevice:=oDialog:drawingArea:winDevice()
oPS:create(oDevice)


* cyklus pre čakanie na Quit, náhrada Inkey(0) ktorý tu nefunguje
DO WHILE nEvent <> xbeP_Quit
nEvent := AppEvent( @mp1, @mp2, @oXbp )
oXbp:handleEvent( nEvent, mp1, mp2 )
ENDDO
**********
RETURN
**********

****************************
FUNCTION kresliciary
****************************
GraSetColor( oPS, GRA_CLR_RED )
GraLine(oPS,{10,50},{600,50})
GraSetColor( oPS, GRA_CLR_GREEN)
GraLine(oPS,{10,100},{600,100})
GraSetColor( oPS, GRA_CLR_BLUE)
GraLine(oPS,{10,150},{600,150})
GraSetColor( oPS, GRA_CLR_BLACK)
GraLine(oPS,{10,200},{600,200})
****************************
return nil
****************************
Attachments
preForum.zip
(13.26 KiB) Downloaded 712 times

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Drawing vector graphics

#2 Post by Auge_Ohr »

Victorio wrote:Other thing : to future I want select some part of draw with mouse and zoom this to full presentation window, and other things so I need to work with maps.(zoom + -, pan, select, measure etc.
did you have played with Alaska Sample c:\ALASKA\XPPW32\Source\samples\solution\Preview\Preview.prg ?

it show how to Zoom in a Preview ... and you can "print-out" ( or Save it in a Bitmap )
remember oPS is same for Screen and Printer ... just switch Device
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Drawing vector graphics

#3 Post by rdonnay »

Try adding this:

oDialog:paint := {||kresliciary(oPS)}
The eXpress train is coming - and it has more cars.

Victorio
Posts: 620
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Drawing vector graphics

#4 Post by Victorio »

Roger: thanks, :paint work´s fine.
now I examine gra fnc, if it will be useable for my digital maps viewer.
for small maps in vector format it works fine, but maps with 200000 and more points (and 200000 lines objects) it will be slow, and map is draw without signs, texts and other objects.
also experienced with store coordinates in database and in array too, but speed drawing is little slower if coordinates is in array ?!.

I know, better for it is C,C++ language ;)

Jimmy: preview with zoom I saw, I am not sure, if it is useable for vector graphics ?

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Drawing vector graphics

#5 Post by Auge_Ohr »

Victorio wrote:Jimmy: preview with zoom I saw, I am not sure, if it is useable for vector graphics ?
you always need oPS to "paint" ... like in Preview which show how to "zoom"
greetings by OHR
Jimmy

Post Reply