Pie Menu

Need help, or want to share a macro? Post here!
ilyxa
Posts: 7
Joined: Mon Mar 23, 2015 12:28 pm

Re: Pie Menu

Postby ilyxa » Tue May 12, 2015 6:16 am

looo wrote:The frame-builder stuff is a macro I've done some time ago. ...
if you want you can try: https://bitbucket.org/looooo/beam
Tnx! I'll try :)
User avatar
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Pie Menu

Postby microelly2 » Wed May 20, 2015 12:00 pm

I have startet to work with your beams model.
very fast access - faster than toolbars

your examples work with start key "a" and TAB
is there a reason why you use these?
TAB is good for right hand mouse holders
what about COMMA for left handers

I want to use your idea inside my plugin manager to generate context sensitive toolsets.
are there known problems?

The only task I see is to create a new pie menu whenever the next 3d window is opend.
User avatar
looo
Posts: 3482
Joined: Mon Nov 11, 2013 5:29 pm

Re: Pie Menu

Postby looo » Wed May 20, 2015 5:32 pm

your examples work with start key "a" and TAB
is there a reason why you use these?
TAB is good for right hand mouse holders
what about COMMA for left handers
There was no reason for these keys. Tab is used in blender for switching between different editing modes, but I don't know if it is a good idea to use this key in qt.
I want to use your idea inside my plugin manager to generate context sensitive toolsets.
are there known problems?
There is still this random interruption. I've tried a workaround with a QTimer but still sometimes the menue dissapears without releasing the pressed key. Maybe it's not the best idea to use it in this state.
rentlau_64
Posts: 181
Joined: Tue Oct 21, 2014 9:47 am
Location: Pau (France)

Re: Pie Menu

Postby rentlau_64 » Wed May 20, 2015 6:05 pm

looo,

Very good idea and nice tool to speed up work.
The first idea of the Work Feature was also a "one click" function access but also give users simple "quick" tools independantly of the WBs

Do you think we can merge the 2 tools to give contextual tools depending on :
- where is the pointer on the view and
- what are the selected objects
??

Again very nice tool

Rentlau_64
User avatar
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Pie Menu

Postby microelly2 » Wed May 20, 2015 8:34 pm

+looo
I began to study the possibilities of the Qt QEvents
viewtopic.php?f=22&t=11022

I think I can control the switch of windows and workbenches

Can you describe the "random interuption"
How I can reproduce its?

+rentlau_64
I think we only need to know when Gui.Selection.getSelection() changes
This is possible with an eventfilter
we watch the MousePress Events ...

Code: Select all

from PySide import QtCore
from PySide import QtGui
mw=Gui.getMainWindow()
views=mw.findChildren(QtGui.QMainWindow)
views[0].metaObject().className()
view=views[0]

class EventFilter(QtCore.QObject):
  def eventFilter(self, o, e):
	# http://doc.qt.io/qt-5/qevent.html
	z=str(e.type())
	if z == 'PySide.QtCore.QEvent.Type.ChildAdded' or z == 'PySide.QtCore.QEvent.Type.ChildRemoved':
		return False
	FreeCAD.Console.PrintMessage("\n")
	FreeCAD.Console.PrintMessage(e.type())

	if z == 'PySide.QtCore.QEvent.Type.HoverMove' :
		# http://doc.qt.io/qt-5/qhoverevent.html
		FreeCAD.Console.PrintMessage("\n")
		FreeCAD.Console.PrintMessage(e.oldPos())
		FreeCAD.Console.PrintMessage(e.pos())
		FreeCAD.Console.PrintMessage("\n")
	# selection activities
	if z=="PySide.QtCore.QEvent.Type.MouseButtonPress":
		FreeCAD.Console.PrintMessage("pressed \n")
	if z=="PySide.QtCore.QEvent.Type.MouseButtonRelease":
		FreeCAD.Console.PrintMessage("released \n")
	return False

ef=EventFilter()
view.installEventFilter(ef)


# To check if a new mdi view was created you have to get access to QMdiArea and set an even filter for QEvent.Type.ChildAdded.

mw=Gui.getMainWindow()
mdi=mw.findChild(QtGui.QMdiArea)
mdi.installEventFilter(ef)
User avatar
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Pie Menu

Postby microelly2 » Thu May 21, 2015 8:37 am

I will start to create a dynamic switching menu depending on the selected objects. It will be maintained by a Gui.Selection Observer.
The idea is to have a configuration file like this

Code: Select all

workfeature:
	shortkeys:
		lineCutsPlane:
			selection: .edge .face
			exec: Msg("Create a point at the intersection of the Line and Plane selected.")
		projectPointToLine:
			selection: .edge .vertex
			exec: Msg("Create a projection Point of a Point onto a Line and symmetric point")
		name of the action:
			selection:	[objectType].subObjectType ...
			exec: yourCommand()
# objectType can be optional - no means all types
# but so I can restrict some commands to special objects (example DWire Sketch )
EDIT
I have used this afternoon
https://www.youtube.com/watch?v=uWD6nTWwCJs
https://github.com/microelly2/freecad-dynamictools

what is open:
switch from Qt Toolbar to pie menu
add the observer to automated refresh
EDIT 2
observer added - the video seems to be slow but the function call time is 0.01 sec: http://youtu.be/-V6sSCeS5vU
User avatar
looo
Posts: 3482
Joined: Mon Nov 11, 2013 5:29 pm

Re: Pie Menu

Postby looo » Fri May 22, 2015 11:52 am

Do you think we can merge the 2 tools to give contextual tools depending on :
- where is the pointer on the view and
- what are the selected objects
??
Sounds interesting. And I think microelly2 has already shown how to do it.
Can you describe the "random interruption"
How I can reproduce its?
press the key for the pie-menu and move the mouse for some time. The problem occurs only on my old laptop. So maybe this isn't an issue for you.

I've played a bit with pixmap brushes for the pie-menu and it should be possible to add a svg icon. see herehttps://bitbucket.org/looooo/beam/src/d ... ?at=master
confrey
Posts: 15
Joined: Mon Feb 17, 2014 7:56 pm

Re: Pie Menu

Postby confrey » Thu Nov 19, 2015 8:03 am

looo wrote:That is the plan. One global menu for wb.switch and one locale menu for every workbench. The problem is, that it is too heavy and buggy in this state and I don't know how to improve that. One thing is that background events sometimes close the window, or maybe that is a problem with the autorepeat option of the keyevent. The other thing is the key down suppress of the draft wb...
Here is a short demo of the menu connected with some framebuild functionality in action.
https://vimeo.com/127369120

Hi loo,
I saw in th vimeo video you can easy make pipe from two sketch; I'm not interestiing in pie menu yet, but I'd like to know how to make that pipes with two mouse click, may you explain that?

that

confrey
User avatar
looo
Posts: 3482
Joined: Mon Nov 11, 2013 5:29 pm

Re: Pie Menu

Postby looo » Thu Nov 19, 2015 3:51 pm

The script I have used for this, rotate and translate a 1. sketch (profile) to the endpoint of a line of a 2. sketch and extrude it. It's really simple. The trickier part was the selection of the inner and outer wire in a profile. I had a look in part design, and as I remember there it is done with the bounding-boxes.
You can have a look into this repository. Not all file are relevant for the beam creation. Look into beam.py which does the selection thing, obj.py defining the beam-object and c-beam-obj (cutted beam). The cut_....py files define the commands for cut beams. I have no time at the moment to develop this further, but if I had I would change a few things to make the tool also usable for arcs. So basically changing the extrusion to a sweep.
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Pie Menu

Postby triplus » Thu May 05, 2016 4:07 pm

Hi @looo and @microelly2.

Following the idea from:

viewtopic.php?f=8&t=13429&start=50#p123819

I evaluated this a bit and indeed currently we don't have much context sensitive interaction available in FreeCAD. I tested the Pie Menu macro and i watched video from @microelly2 on context sensitivity detection on YouTube. The idea is to take this to the next level. Therefore make Pie Menu do something useful and provide minimal support for context sensitive interaction. Are you two OK with me doing that on my GitHub account and where it make sense to reuse the code from this thread? I would put LGPL licence header on top and add attribution to all 3 of us. If that is OK should i post updates in this thread or create separate one? I haven’t actually look into the code yet as i plan to do this over the weekend. And it will probably take some time for me to create some prototypes and to go over the existing code and understand what it does and where it needs additional work. But i guess it would be nice to gather all that was already done and try to make something that works good out of it. Opinions and alternative suggestions?