Drawing vector graphics
Posted: Wed Jun 24, 2015 2:40 am
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
****************************
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
****************************