Vector Curve Designer (RAD Tool)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Vector Curve Designer (RAD Tool)

Post by Olliv »

You can note this code line :

Code: Select all

SetClipboardText("%FILE %CURSOR")
This is specific tl this subject. There are more options available, and I did not make a request to include them...

Note too that my grammar is ever so surprising...
And I did not work a lot for the design...

Apologize ! :D
User avatar
HeX0R
Addict
Addict
Posts: 973
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Vector Curve Designer (RAD Tool)

Post by HeX0R »

Olliv wrote:Here is the all-in-one 'HowTo' procedure to compile and install a new tool...
You could also use this and let the tool install itself.
With the help of this, you don't even need to add the source to it ;)
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Vector Curve Designer (RAD Tool)

Post by Olliv »

@HeXor

Excellent way I understand. It's different when we are beginners...

This does not remove permanent problems, that the installing of a new tool can reserve : in example, there is no map about the shortcuts already used.
User avatar
HeX0R
Addict
Addict
Posts: 973
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Vector Curve Designer (RAD Tool)

Post by HeX0R »

The include checks the existing shortcuts, and in case the wished shortcut is already in use, it will open a requester and let the user decide.

But that's enough about it, back to topic
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8422
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Vector Curve Designer (RAD Tool)

Post by netmaestro »

IDE tool functionality added today. Working on zoom now. (wishing I had srod's head for math)
BERESHEIT
User avatar
Michael Vogel
Addict
Addict
Posts: 2663
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Vector Curve Designer (RAD Tool)

Post by Michael Vogel »

netmaestro wrote:IDE tool functionality added today. Working on zoom now. (wishing I had srod's head for math)
Would use translate coordinates, then you won't have to change a lot of things...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8422
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Vector Curve Designer (RAD Tool)

Post by netmaestro »

Would use translate coordinates, then you won't have to change a lot of things...
I don't know that one, could you post a short sample snippet?
BERESHEIT
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Vector Curve Designer (RAD Tool)

Post by Olliv »

NetMaestro wrote:I don't know that one, could you post a short sample snippet?
Maybe a good way consists to you in building the zoom tool, and add a temporary zoom button. I say this because I can imagine three ways to execute a positive zoom (equ to go to front) :

1) classical : all the points go away from the central point of the draw. Coefficient is fixed.

2) from a point : all the points go away from the a specific point choosen in the draw. Coefficient is fixed

3) from a rectangular form : all the points go away from the central point of a rectangular selection. Coefficient is depending the size of the rectangle.

I do not imagine other zoom types, but I think it exists others types.

Code: Select all

Procedure ZoomNewX(*X.Double, ZoomCenterX.D, ZoomCoefficient.D)

*X\D - ZoomCenterX
*X\D * ZoomCoefficient
*X\D + ZoomCenterX

EndProcedure
User avatar
Michael Vogel
Addict
Addict
Posts: 2663
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Vector Curve Designer (RAD Tool)

Post by Michael Vogel »

Here are some lines for demonstrating a simple zoom function (mouse wheel only, no problem to add shortcuts and buttons...)

Code: Select all

; Define

	Enumeration
		#Win
		#WinCanvas
		#WinScrollarea
		#KeyZoomIn
		#KeyZoomOut
		#KeyScrollUp
		#KeyScrollDown
		#KeyScrollLeft
		#KeyScrollRight
	EndEnumeration

	#WinMinX=320
	#WinMinY=200
	#WinMaxX=1600
	#WinMaxY=1000

	#PB_EventType_MouseWheel_Up=		1
	#PB_EventType_MouseWheel_Down=	-1

	Enumeration
		#NoShiftAndControl
		#ShiftOnly
		#ControlOnly
		#ShiftAndControl
	EndEnumeration

	Structure WinType
		X.i;					Bildgröße
		Y.i
		SX.i;				Canvasgröße
		SY.i
		ZX.i;				Zoomgröße
		ZY.i;
		Zoom.i;
	EndStructure

	Global Win.WinType


	Macro ShiftKey()
		((GetKeyState_(#VK_SHIFT)&128)>>7)
	EndMacro
	Macro ControlKey()
		((GetKeyState_(#VK_CONTROL)&128)>>7)
	EndMacro

; EndDefine
Procedure WinTrack()
	
	Debug "-"
	With Win

		\SY=WindowHeight(#Win)
		\SX=WindowWidth(#Win)
		\ZX=\SX*\Zoom
		\ZY=\SY*\Zoom
		
		ResizeGadget(#WinScrollarea,#PB_Ignore,#PB_Ignore,\SX,\SY)
		ResizeGadget(#WinCanvas,#PB_Ignore,#PB_Ignore,\ZX,\ZY)
		SetGadgetAttribute(#WinScrollarea,#PB_ScrollArea_InnerWidth,\ZX)
		SetGadgetAttribute(#WinScrollarea,#PB_ScrollArea_InnerHeight,\ZY)

	EndWith

EndProcedure
Procedure WinDraw()

	With Win

		StartVectorDrawing(CanvasVectorOutput(#WinCanvas))
		VectorSourceColor($ffffffff)
		FillVectorOutput()
		
		ScaleCoordinates(\Zoom,\Zoom)

		MovePathCursor(50,50)
		AddPathLine(350,50)
		AddPathLine(250,175)
		ClosePath()
		VectorSourceColor($ffc0F0F0)
		FillPath(#PB_Path_Preserve)
		VectorSourceColor($ff802020)
		StrokePath(3)

		StopVectorDrawing()

	EndWith

EndProcedure

With Win
	\SX=400
	\SY=200
	\Zoom=1
	\ZX=400
	\ZY=200

	OpenWindow(#Win,16,10,\SX,\SY,"",#PB_Window_SizeGadget|#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
	ScrollAreaGadget(#WinScrollarea,0,0,\SX,\SY,\SX,\SY,1,#PB_ScrollArea_Flat)
	CanvasGadget(#WinCanvas,0,0,\SX,\SY,#PB_Canvas_Keyboard)
	WindowBounds(#Win,#WinMinX,#WinMinY,#WinMaxX,#WinMaxY)

	BindEvent(#PB_Event_SizeWindow,@WinTrack())

	WinDraw()

	SetActiveGadget(#WinCanvas)
	Repeat

		Select WaitWindowEvent()

		Case #PB_Event_Gadget,#PB_Event_Menu
			Select EventGadget()
			Case #WinCanvas
				Select EventType()
				Case #PB_EventType_MouseMove

				Case #PB_EventType_MouseEnter
					;
				Case #PB_EventType_MouseLeave
					;
				Case #PB_EventType_LeftClick
					;
				Case #PB_EventType_RightClick
					;
				Case #PB_EventType_MouseWheel
					Select GetGadgetAttribute(#WinCanvas,#PB_Canvas_WheelDelta)
					Case #PB_EventType_MouseWheel_Down
						Select ShiftKey()+ControlKey()<<1
						Case #NoShiftAndControl
							PostEvent(#PB_Event_Gadget,#Win,#KeyZoomOut)
						Case #ShiftOnly
							PostEvent(#PB_Event_Gadget,#Win,#KeyScrollLeft)
						Case #ControlOnly
							PostEvent(#PB_Event_Gadget,#Win,#KeyScrollDown)
						Case #ShiftAndControl
							;
						EndSelect
						;
					Case #PB_EventType_MouseWheel_Up
						Select ShiftKey()+ControlKey()<<1
						Case #NoShiftAndControl
							PostEvent(#PB_Event_Gadget,#Win,#KeyZoomIn)
						Case #ShiftOnly
							PostEvent(#PB_Event_Gadget,#Win,#KeyScrollRight)
						Case #ControlOnly
							PostEvent(#PB_Event_Gadget,#Win,#KeyScrollUp)
						Case #ShiftAndControl
							;
						EndSelect
					EndSelect
				EndSelect


			Case #KeyZoomIn
				If Win\Zoom<10
					Win\Zoom+1
					WinTrack()
					WinDraw()
				EndIf
			Case #KeyZoomOut
				If Win\Zoom>1
					Win\Zoom-1
					WinTrack()
					WinDraw()
				EndIf

			EndSelect

		Case #PB_Event_CloseWindow
			End


		EndSelect

	ForEver

EndWith
User avatar
kernadec
Enthusiast
Enthusiast
Posts: 146
Joined: Tue Jan 05, 2010 10:35 am

Re: Vector Curve Designer (RAD Tool)

Post by kernadec »

Hello netmaestro & Michael Vogel

Thank you for sharing

to zoom any 4 point figure can be this idea
as a solution with this geometric method.

Cordialement
https://jmp.sh/URILrLk
Last edited by kernadec on Mon Jun 08, 2020 8:49 am, edited 1 time in total.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Vector Curve Designer (RAD Tool)

Post by Olliv »

Small remark : I completely forgot this documentation page.

I apologize their author which made a good help.
Karellen
User
User
Posts: 82
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Post by Karellen »

netmaestro wrote:Vector Curve Designer (RAD Tool)
Thank you so much for this awesome tool - comes in handy! :)
Stanley decided to go to the meeting room...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8422
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Vector Curve Designer (RAD Tool)

Post by netmaestro »

Zoom feature is implemented today for doing tiny work, this is enough features for now so if no serious bugs are reported in a few days the project will be at beta 1.0. Code in first post is updated to most recent.

For those interested in this project, if you find any bugs please report them so we can have a solid tool when it's done.
BERESHEIT
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Vector Curve Designer (RAD Tool)

Post by davido »

@netmaestro,
I note that you designed this tool for PCs.
It has now stopped working on Macs due to the code appended below.

If I remove this code it appears to work for me.

I find this incredible program so useful that I am happy to loose some functionality to be able to use it.
I have always found creating curves, except circles and eclipses, in Vector Graphics to be nigh on impossible.
Your code makes it so simple! Thank you. :D

Code: Select all

Procedure InsertHandler()
  scintilla.i = Val(GetEnvironmentVariable("PB_Tool_Scintilla"))
  If scintilla
    *textBuffer = MakeScintillaText(#CRLF$+"; Code inserted by Vector Curve Designer" +
                                    #CRLF$+GetGadgetText(gadget_output)+#CRLF$ +
                                    "; End of Curve Designer Code"+#CRLF$)
    SendMessage_(scintilla, #EM_REPLACESEL, 0, *textBuffer)
  Else
    MessageRequester("Notice:","Scintilla editor not found!"+#CRLF$+#CRLF$ +
                               "Invoke Curve Designer tool from the PureBasic IDE for this feature.")
  EndIf
EndProcedure
DE AA EB
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8422
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Vector Curve Designer (RAD Tool)

Post by netmaestro »

I didn't even notice I was breaking cross-platform with that, but there it is right there, an API call. I've surrounded all relevant code parts with CompilerIf directives so the button and procedure only show on Windows for now but I'll ask if anyone can show how to do it on Mac and Linux so all can have the functionality. Thanks for the heads-up!
BERESHEIT
Post Reply