|
Post by alexfish on Jan 2, 2023 19:19:37 GMT 1
Hi All Notice:Updated Updated bugfix HUG3 is HEREhug35 Removed hug351 Removed This version::3.5.21. fix NoteBook + New API 2. Add FlowBox 3. Add Grid :: + New API reason : TABLE = DEPRECATED in gtk3 >=3.10 4. GOO CANVAS :: DEPRECATED reason compiling original demos fail , needs to be revisited ... REFERENCE GTK2 resent versions of gtk2 supporting libs based on gtk2 are deprecated IE goo canvas , source view libosm streetmaps note the here version of osm maps and openseamaps are not dependent on libosm GTK3.2 DOCS HEREdemo files to follow after the release, there are demo's Posted for previous versions up to notebook NEW API + New INCLUDE files for SEDIT,TERMINAL & HUG WEBKIT For Original IMAGER libs & demo's of openstreetmaps and openseamaps Refer to the Original IMAGER thread HERENeed to find Your gtk versions apt-cache policy libgtk2.0-0 libgtk-3-0 OR dpkg -l libgtk2.0-0 libgtk-3-0 REFERENCE HUGOPTIONS("CANVASCAIRO")is listed as such to provide compatibility with different versions of gtk hug.bac's and must be called While there a normal pixel,circle,square etc the circle is somewhat not compliant Preferred method is to use Native CAIRO there are cairo bits in this this thread on how to get the surface + update the CANVAS CAIRO DOCS HEREFINAL INIT within user code is DEPRECATED IE INIT ,WINDOW,ENTRY will fail News ADDED Ref NOTEBOOK NEW API fixed OLD API now compatible :: Hence can use NEW & OLD code base now been tidied :: :) Of Note ' did not find a method to change the Page Text ... also ADDED new TEXTNOTE , text page IE SET (note,0) TEXTNOTE(note,"Hello World") hug352 REMOVEDRELEASEDBR Alex Attachments:hug35fix.gz (19.9 KB)
hug351fix.gz (20.68 KB)
hug353.gz (45 B)
|
|
|
Post by alexfish on Jan 2, 2023 23:10:47 GMT 1
First Steps 1. in Archive is gui_designer5 1.1 place gui_designer5 in imager5.1 folder 2. Compile with BaCon 3. Use gui_designer5 to make improved version 'gui_designer5.1' The next Archive will have gui_designer5.1 + Add svg parser svg2cairo: svg path example <svg width="4cm" height="4cm" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" version="1.1"> <title>Example triangle01- simple example of a 'path'</title> <desc>A path that draws a triangle</desc> <rect x="1" y="1" width="398" height="398" fill="none" stroke="blue" /> <path d="M 100 100 L 300 100 L 200 300 z" fill="red" stroke="blue" stroke-width="3" /> </svg> <svg width="12cm" height="5.25cm" viewBox="0 0 1200 400" xmlns="http://www.w3.org/2000/svg" version="1.1"> <title>Example arcs01 - arc commands in path data</title> <desc>Picture of a pie chart with two pie wedges and a picture of a line with arc blips</desc> <rect x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="1" />
<path d="M300,200 h-150 a150,150 0 1,0 150,-150 z" fill="red" stroke="blue" stroke-width="5" /> <path d="M275,175 v-150 a150,150 0 0,0 -150,150 z" fill="yellow" stroke="blue" stroke-width="5" />
<path d="M600,350 l 50,-25 a25,25 -30 0,1 50,-25 l 50,-25 a25,50 -30 0,1 50,-25 l 50,-25 a25,75 -30 0,1 50,-25 l 50,-25 a25,100 -30 0,1 50,-25 l 50,-25" fill="none" stroke="red" stroke-width="5" /> </svg>
Apps: typical example: see next post Alex Attachments:gui_designer5.bac.bz2 (5.11 KB)
|
|
|
Post by alexfish on Jan 3, 2023 4:50:56 GMT 1
Things To Do List 1. SolveSpace CNC See Picky : interface lib cairo:svg:eps:dfx Solved: more here later Cnc Controler Candle Picky , left some constraint info on exported svg file but it works Attachments:
|
|
|
Post by alexfish on Jan 3, 2023 19:02:40 GMT 1
Have Got half the parser working Gcode To Canvas If can see from the picky the Image is upside down , an one Circle has the control points N,S,E,W Suppose we are used to Flipping Images in a literal sense also , at this point those circles were only 10 pixels in diameter At this point Happy with the results. and will update the these bits here Proper tutorial starts the weekend Coming. BR Alex Attachments:
|
|
|
Post by alexfish on Jan 9, 2023 20:32:52 GMT 1
Hi All
Parsing svg paths
<svg width="1000" height="700" xmlns="http://www.w3.org/2000/svg">
<path d="M 10 10 C 20 20, 40 20, 50 10"/> <path d="M 70 10 C 70 20, 110 20, 110 10"/> <path d="M 130 10 C 120 20, 180 20, 170 10"/> <path d="M 10 60 C 20 80, 40 80, 50 60"/> <path d="M 70 60 C 70 5, 110 5, 110 60"/> <path d="M 130 60 C 120 80, 180 80, 170 60"/> <path d="M 10 110 C 20 140, 40 140, 50 110"/> <path d="M 70 110 C 70 140, 110 140, 110 110"/> <path d="M 130 110 C 120 140, 180 140, 170 110"/>
</svg> save in home dir /home/user as paths.svg , making your own then the path format is a must do , but can extend the data there will a update to the parser for fill, for testing as of the now can change the stroke to fill + may need add the cairo_close_path(c) at the 'z' an 'Z'
Now will need updated imager 5.2 on the main Hug Imager thread
Compile the gui designer . in the folder need to compile pathviewer.bac check out the svgparser.bac
the name of the parser will be relevant to previous post
BR Alex
|
|
|
Post by alexfish on Jan 28, 2023 21:12:47 GMT 1
updated version of BaCon openstreet map , location Whitby UK
'testmaps,bac v 5.2 INCLUDE "includegtk.bac" '=========================================================== DECLARE zoomed = 15 '===========================================================
SUB CLICK()
PRINT "Mouse xy" , MOUSE(0) , " : ",MOUSE(1)
END SUB '=========================================================== FUNCTION UPDATE() SYNC() MAPTILES(0,0)
RETURN TRUE END FUNCTION '=========================================================== SUB ZOOMOUT() DECR zoomed IF zoomed < 4 THEN zoomed = 4 TEXT(lab,STR$(zoomed)) GPS(54.48774,-0.61498,zoomed) SET_GEO(N,S,W,E) TILES_GET() MAPTILES(0,0) END SUB '=========================================================== SUB ZOOMIN()
INCR zoomed IF zoomed >18 THEN zoomed = 18 TEXT(lab,STR$(zoomed)) GPS(54.48774,-0.61498,zoomed) SET_GEO(N,S,W,E) TILES_GET() MAPTILES(0,0) END SUB '=========================================================== ts = TIMER N = 2 S = 3 W = 2 E = 5
GPS(54.48774,-0.61498,zoomed) SET_GEO(N,S,W,E) BB_MAPBOX.provider$ = "https://a.tile.openstreetmap.org" BB_MAPBOX.cache$ = "bacon-osm-maps" 'BB_MAPBOX.rem$ = "Pos: " & BB_MAPBOX.degsec$ TILES_GET()
win = WINDOW("test imager",1200,600) win2 = DESIGNER(1200,570,SCREENSIZE(0),SCREENSIZE(1))
ico1 =ICON("media-seek-backward") ATTACH(win,ico1,3,3) CALLBACK(ico1,ZOOMOUT) TOOLTIP(ico1,"Zoom out")
ico2 = ICON("media-seek-forward") ATTACH(win,ico2,30,3) CALLBACK(ico2,ZOOMIN) ATTACH(win,win2,0,30) TOOLTIP(ico2,"Zoom in") vsep = VSEPARATOR(25) ATTACH(win,vsep,54,0)
lab = MARK(STR$(zoomed),40,25) ATTACH(win,lab,55,3) TOOLTIP(lab,"Zoom Level") vsep = VSEPARATOR(25) ATTACH(win,vsep,98,0) lab2 = MARK(BB_MAPBOX.degsec$,-1,25) ATTACH(win,lab2,105,3) TOOLTIP(lab2,"Position")
canvas = CANVAS(SCREENSIZE(0),SCREENSIZE(1)) ATTACH(win2,canvas,0,0) EBOXSVISABLE(canvas,FALSE) MAPTILES(0,0) CALLBACK(canvas,CLICK)
st = TIMER PRINT "time msec : ", st - ts 'TIMEOUT(1000,UPDATE) DISPLAY
Have Fun Alex
|
|
|
Post by alexfish on Mar 23, 2023 10:54:15 GMT 1
Hi All just a update on the Gcode over last few weeks:: researched Marlin :: howto config sorted method Gcode : replicate bCNC :: sorted svg interface svg2gcode (python svgwrite svg2gcode) GcodeSender testing complete Update = can also do png to svg : install imagemagic + potrace convert *.png *.svg Viola will update the Gcode thread soon, as how to, 'Bacon Gcode Sender' using SVG Picky's of the svg2gcode interface BR Alex Attachments:
|
|
|
Post by alexfish on Mar 25, 2023 20:48:04 GMT 1
Hi All Had to do a rash decision IE gtk2 , came to the decision 'not much life left" started with gtk3 , think all Here know it's a pet hate of mine, Argh well Progress , but the ui is looking good , svg writer / gcode editor all in one so in terms of CAD/CAM 2d this = core(SVG) in basic terms Click and GO see screen shot mock ups , 1st is auto file(loaded at boot) Then the editor , click to max screen , shows all, Yes there is more to add, in terms of , flick file , click go + as can see from other demo each bit in the view can be moved so can do stack(1 item) * qty or place your bits(per file) Click go and have a cuppa thats what i gonna do now Added:: The Jogger xy are sliders call them Jerkers is wish to do so JOG has been around here longer than Jerk , here, Jerk pertains to a person well suppose Jog does , these day I prefer Jogging Back soon BR Alex Attachments:
|
|
|
Post by Pjot on Mar 26, 2023 8:29:04 GMT 1
Thanks for all your work on this Alex!
Best regards Peter
|
|
|
Post by alexfish on Mar 26, 2023 10:19:12 GMT 1
Thanks Peter here got some more progress pushing limits.. the text example takes a long time or can stall some similar aps can't mention them since overall they are good output of convertion "text.svg" converting! text.svg test90.gcode width / height 612.0 792.0 parsing gcode took 12.706945 unoptimised distance: 252704.6979311931 optimizing took 1.306094 unoptimised distance: 260099.2146037327 optimised distance 247450.9935898497 factor: 0.9513715524548859 shapes_2_gcode took 0.428597 writing file took 0.140778 done done!
about 16 seconds Thanks again + BR Alex picky Attachments:
|
|
|
Post by alexfish on Mar 26, 2023 19:41:07 GMT 1
Hi All For reference :GTK3 . base is Joes hug3 have done updates to this lib esp goocanvas , the original "hard links are outdated and now testing as a backport of the original gfx(goocanvas) + other tweaks examples astro now work see picky BR Alex Attachments:
|
|
|
Post by alexfish on Mar 27, 2023 16:31:43 GMT 1
Hi Peter
Have gone through the original hug.bac
of Note:
1. the default allocating to draw is the gtk image(this is a pixbuf) 2. the default actor (callback) is through the eventbox
all draw methods are in the imager lib
so. can update the original hug.bac can change the allocated context pixmap out to context = hug_widget_context(STR$(pixbuf))
the allocate draw becomes in short pixbuf = get pixbuf(context,x,y,with,height) IE gdk_pixbuf_new_subpixbuf
newpix = gdk_pixbuf_new_subpixbuf (context,hug_x,hug_y,hug_xsize,hug_xsize) create the bits. draw is automatic, but do have
gtk_widget_queue_draw(hug_widget_image(STR$(ebox)) )
'================================================================ the OUT needs some work , can opt cairo or the pango/cairo , from that need to get the pixbuf need to remap the pixbuf endian if not(endian) ,blagh . that routine is in the image lib
So in the main can leave the hug.bac mostly as is IE: update the lib as above then user can opt gtk3 or gtk2 switch for gtk3 =
IF NOT(INSTR(hug_lib$, "dylib")) AND NOT (INSTR(hug_lib$, "dll")) THEN hug_lib$ = CONCAT$("libgtk-3.so.", STR$(hug_sequence))
will do a mock up then its food for thought time ADDED : forgot the SCREENSIZE , hope most system still have the relics of libx11
some of the bits relative to the above
IMPORT "gtk_image_clear(long)" FROM GTK$ TYPE void IMPORT "gtk_image_set_from_pixbuf(long,long)" FROM GTK$ TYPE void IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_fill ( long , unsigned int ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_new_subpixbuf ( long , int , int , int , int ) " FROM GDK$ TYPE long
The image lib has FUNCTION GETPIX(long hug_pix,int hug_xpos,int hug_ypos,int hug_xsize,int hug_ysize) LOCAL newpix,w,h,wmax,hmax w = gdk_pixbuf_get_width(hug_pix) h = gdk_pixbuf_get_height(hug_pix) wmax = hug_xpos+ hug_xsize hmax = hug_ypos+ hug_ysize IF (wmax < w) AND (hmax < h) THEN newpix = gdk_pixbuf_new_subpixbuf (hug_pix,hug_xpos,hug_ypos,hug_xsize,hug_ysize) RETURN newpix ELSE RETURN FALSE END IF
END FUNCTION
BR Alex
|
|
|
Post by alexfish on Mar 27, 2023 22:21:16 GMT 1
Have managed to apply option gtk2 or gtk3 in the original hug
now that poses a problem in get GETCOLOR$ this bit
gdk_pixbuf_get_from_drawable where
IF HUG_CANVAS_TYPE = 0 OR HUG_CANVAS_TYPE = 2 THEN pixbuf = gdk_pixbuf_get_from_drawable(NULL, hug_gui_properties.canvas, gdk_colormap_get_system(), 0, 0, 0, 0, hug_widget_xsize(STR$(ebox)), hug_widget_ysize(STR$(ebox))) pixels = gdk_pixbuf_get_pixels(pixbuf)
should be able to do a work around:
so back to the lib
just need to use the GTK IMAGE: and change the context: then apply the draw routines : there ain't many hence should not be a problem possibles are two Raw pixbuf or cairo
Either OR the user will not be able to tell the difference : exception been once has a choice of Using ALPHA in the CANVAS , that would be a BONUS
BR Alex
|
|
|
Post by Pjot on Mar 28, 2023 15:12:44 GMT 1
Thanks Alex, The HUG library for GTK3 is a lot of work. It is always very puzzling to find the correct functions and calls. You also could peek into the latest GTK-server configuration file to see how the HUG interface for GTK3 is implemented there. HTH Peter
|
|
|
Post by alexfish on Mar 28, 2023 17:37:07 GMT 1
Hi Peter I Know , that is why = my pet hate , I am polite when I say that the combo is sorted widget wise It be a while , so very rusty How Ever , will persevere and look further If give pointer to widgets or graphic/canvas wise , and then... Now got the default CANVAS bits sorted in the original hug , can do gtk2 & gtk3 Extract of create the CANVAS , note the stored pixbuf LOCAL image, ebox,gdkpixbuf image = gtk_image_new() 'here create the pixbuf gdkpixbuf = gdk_pixbuf_new(0,TRUE,8,hug_xsize,hug_ysize) ebox = gtk_event_box_new() gtk_event_box_set_visible_window(ebox,FALSE)
gtk_container_add(ebox, image) gtk_widget_set_events(ebox, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK) g_signal_connect_data(ebox, "button-press-event", hug_mouse_event,20, 0, 0) g_signal_connect_data(ebox, "button-release-event",hug_mouse_event, 0, 0, 0)
IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(ebox) END IF
hug_widget_xsize(STR$(ebox)) = hug_xsize hug_widget_ysize(STR$(ebox)) = hug_ysize hug_widget_s_widget(STR$(ebox)) = ebox hug_widget_signal(STR$(ebox)) = 4 hug_widget_type$(STR$(ebox)) = "image" ' store the pixbuf here hug_widget_font(STR$(ebox)) = gdkpixbuf hug_widget_focus(STR$(ebox)) = image Then the HowTo note the methods to get the image & the pixbuf : + hard coded bg fill normal would be ,paint the cr(surface) LOCAL im,pixy,ebox,newpix LOCAL data TYPE unsigned char * LOCAL buf pixy=hug_widget_font(STR$(hug_widget)) im = hug_widget_focus(STR$(hug_widget))
ebox = hug_widget_s_widget(STR$(hug_widget)) gtk_image_clear(im) gdk_pixbuf_fill(pixy,0xFF00FFFF) cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,100, 50) cr = cairo_create (cs) cairo_set_source_rgb(cr,1,0,0 ) cairo_move_to (cr,0,16) cairo_set_font_size (cr, 16) cairo_show_text(cr,"Hello World") cairo_stroke(cr) cairo_destroy(cr) cairo_surface_flush(cs)
data = cairo_image_surface_get_data (cs) buf = gdk_pixbuf_new_from_data(data, 0,TRUE,8,100,50,cairo_image_surface_get_stride (cs),0,0) gdk_pixbuf_composite(buf,pixy, 0,0, 100, 50, 0,0, 1,1, 0,255)
gtk_image_set_from_pixbuf (im,pixy) g_object_unref(buf) that way only one buffer to unref , hence the stored buffer is there until done so from that buffer can extract & do save as image file , or test pixel colour & alpha more on that one later and yes the pixy fill is a different color BR Alex Picky of the day CANVAS hug-gtk2 + CANVAS hug-gtk3 Attachments:
|
|