[Solved] Mimic FPS info on FullScreen
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[Solved] Mimic FPS info on FullScreen
Hello,
Nice to meet you
First post here.
I want to display some info on FullScreen, via Python, just like the FPS does,
info which will stay and will not rotate with camera.
I didn't had success so far, but most likely I don't know where to look for examples.
I'll appreciate any help.
So far I used Annotation, which is great and I like it, except it rotates with camera
so at each new view I had to re-position it.
cheers,
Dorin
Nice to meet you
First post here.
I want to display some info on FullScreen, via Python, just like the FPS does,
info which will stay and will not rotate with camera.
I didn't had success so far, but most likely I don't know where to look for examples.
I'll appreciate any help.
So far I used Annotation, which is great and I like it, except it rotates with camera
so at each new view I had to re-position it.
cheers,
Dorin
Last edited by DorinDXN on Sun Nov 01, 2020 9:39 am, edited 2 times in total.
Re: Mimic FPS info on FullScreen
Hi and welcome to the forum!
Please explain what FPS is. I know it as FramesPerSecond, which makes no sense here.
Please explain what FPS is. I know it as FramesPerSecond, which makes no sense here.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Mimic FPS info on FullScreen
Hi, thanks for quick reply
In FreeCAD, when at Preferences/3D View
[x] Show counter of frames per second
is enabled
In the bottom/left corner of Full Screen the FramesPerSecond info is shown
In the same way I want to show other properties, not FPS, say, the object rotation instead of FPS
I guess, must be a way, to display some info in Full Screen, info which will stay in that position regardless of camera rotation.
cheers,
Dorin
In FreeCAD, when at Preferences/3D View
[x] Show counter of frames per second
is enabled
In the bottom/left corner of Full Screen the FramesPerSecond info is shown
In the same way I want to show other properties, not FPS, say, the object rotation instead of FPS
I guess, must be a way, to display some info in Full Screen, info which will stay in that position regardless of camera rotation.
cheers,
Dorin
Re: Mimic FPS info on FullScreen
Maybe if I'll add a video for better understanding.
In this one I used annotation to display the rotation of the cylinder.
The annotation is fine except when I rotate the camera, the annotation is moving along,
I need for that info to stay in that place of the Full Screen regardless of camera position.
I used this code for this video.
So what to use instead of annotation, I tried without success to have the annotation fixed, I guess I need a different approach.
cheers,
Dorin
In this one I used annotation to display the rotation of the cylinder.
The annotation is fine except when I rotate the camera, the annotation is moving along,
I need for that info to stay in that place of the Full Screen regardless of camera position.
I used this code for this video.
Code: Select all
from PySide import QtCore
import FreeCADGui as Gui
i=0
def update():
global i
FreeCAD.ActiveDocument.getObject("Cylinder").Placement = App.Placement(App.Vector(0,-10,-10),App.Rotation(App.Vector(0,1,0),-i), App.Vector(0,0,10))
App.ActiveDocument.getObject("Annotation").LabelText=[str(i)+"°"]
Gui.updateGui()
i+=0.1
if i>360:
i=0
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(1)
cheers,
Dorin
Re: Mimic FPS info on FullScreen
Here is a possible solution, using SuperImposition of coin3d :
Here is the coin3d doc : https://coin3d.github.io/Coin/html/annotated.html
Code: Select all
from pivy import coin
textSep = coin.SoSeparator()
cam = coin.SoOrthographicCamera()
cam.aspectRatio = 1
cam.viewportMapping = coin.SoCamera.LEAVE_ALONE
trans = coin.SoTranslation()
trans.translation = (-0.98, 0.90, 0)
myFont = coin.SoFont()
myFont.name = "FreeMono,FreeSans,sans"
size = 24
myFont.size.setValue(size)
SoText2 = coin.SoText2()
SoText2.string = "Hello World"
color = coin.SoBaseColor()
color.rgb = (0, 0, 0)
textSep.addChild(cam)
textSep.addChild(trans)
textSep.addChild(color)
textSep.addChild(myFont)
textSep.addChild(SoText2)
activeDoc = FreeCADGui.ActiveDocument
view = activeDoc.ActiveView
sg = view.getSceneGraph()
viewer = view.getViewer()
render = viewer.getSoRenderManager()
sup = render.addSuperimposition(textSep)
# remove the Superimposition layer with :
# render.removeSuperimposition(sup)
Re: Mimic FPS info on FullScreen
Thank you very much!
Solved
cheers,
Dorin
Solved
Code: Select all
from pivy import coin
from PySide import QtCore
import FreeCADGui as Gui
textSep = coin.SoSeparator()
cam = coin.SoOrthographicCamera()
cam.aspectRatio = 1
cam.viewportMapping = coin.SoCamera.LEAVE_ALONE
trans = coin.SoTranslation()
trans.translation = (-0.98, -0.35, 0)
myFont = coin.SoFont()
myFont.name = "Arial"
size = 135
myFont.size.setValue(size)
SoText2 = coin.SoText2()
SoText2.string = "0°"
color = coin.SoBaseColor()
color.rgb = (0, 0, 0)
textSep.addChild(cam)
textSep.addChild(trans)
textSep.addChild(color)
textSep.addChild(myFont)
textSep.addChild(SoText2)
activeDoc = FreeCADGui.ActiveDocument
view = activeDoc.ActiveView
sg = view.getSceneGraph()
viewer = view.getViewer()
render = viewer.getSoRenderManager()
sup = render.addSuperimposition(textSep)
i=0
def update():
global i
FreeCAD.ActiveDocument.getObject("Cylinder").Placement = App.Placement(App.Vector(0,-10,-10),App.Rotation(App.Vector(0,1,0),-i), App.Vector(0,0,10))
SoText2.string=str(i)+"°"
Gui.updateGui()
i+=0.1
if i>360:
i=0
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(1)
# remove the Superimposition layer with :
# render.removeSuperimposition(sup)
Dorin
Re: [Solved] Mimic FPS info on FullScreen
One more thing
I thought it will be easy..
how to have a multi-line string
tried
but it doesn't work
From Coin3D docu
---8<------------------
SoMFString SoText2::string
The set of strings to render. Each string in the multiple value field will be rendered on its own line.
---8<------------------
It looks like a multi-line text needs to be given as a set of strings, but how?
Appreciate any help.
cheers,
Dorin
I thought it will be easy..
how to have a multi-line string
tried
Code: Select all
SoText2.string = "line1\r\nline2"
From Coin3D docu
---8<------------------
SoMFString SoText2::string
The set of strings to render. Each string in the multiple value field will be rendered on its own line.
---8<------------------
It looks like a multi-line text needs to be given as a set of strings, but how?
Appreciate any help.
cheers,
Dorin
Re: [Solved] Mimic FPS info on FullScreen
Code: Select all
SoText2.string.setValues(0,3,["Hello", "World", "!!!!"])
If you want to reduce the number of items of a multifield node, you may need to reset the field beforehand:
Code: Select all
SoText2.string.setValues(0,0,0)
Re: [Solved] Mimic FPS info on FullScreen
Again thank you very much!
Makes perfect sense, tested, worked!
BTW, I noticed that after
it doesn't disappear automatically all the times,
and
seems to help but still are cases when the text stay, though it disappear at mouse click or hover (sometimes).
Tested on single line text only
This is not so important, I'm, maybe, yet to find how to force a redraw after render.remove.
thanks again,
Dorin
L.E.
Just thought, maybe I need to have a delay before render.render(), could be windows message queue issue.
Makes perfect sense, tested, worked!
BTW, I noticed that after
Code: Select all
render.removeSuperimposition(sup)
Code: Select all
render.render()
Code: Select all
SoText2.string=""
render.render()
Tested on single line text only
This is not so important, I'm, maybe, yet to find how to force a redraw after render.remove.
thanks again,
Dorin
L.E.
Just thought, maybe I need to have a delay before render.render(), could be windows message queue issue.
Last edited by DorinDXN on Mon Nov 02, 2020 11:28 am, edited 2 times in total.
Re: [Solved] Mimic FPS info on FullScreen
Maybe the touch() function of the scenegraph will work better ?
Code: Select all
sg.touch()