Insert one .svg image into the scene aligned with the scene axes and not always facing the camera.

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
juanvanyo
Posts: 16
Joined: Sat Dec 10, 2016 12:14 am
Location: Spain

Insert one .svg image into the scene aligned with the scene axes and not always facing the camera.

Post by juanvanyo »

Hi, I would to insert one .svg image into the scene aligned with the scene axes and not always facing the camera.

I have tried using coin3d and I found coin.SoImage() method. But with this I obtain the image aligned always facing the camera and I would to obtain the image aligned to the scene axis. I tried using coin.SoTransform() but had no effect.

Any way to insert an image through the file path and be able to move it to the position I want with coin.SoTransform ()?

A little example that I had tried is:

Code: Select all

from pivy import coin
sg = Gui.ActiveDocument.ActiveView.getSceneGraph()
svg = coin.SoImage()
svg.filename = 'routeFilename.svg'
imagePos = coin.SoTransform()
imagePos.translation.setValue([10,0,0])
imagePos.rotation = coin.SbRotation(0,0,0,0)
image = coin.SoSeparator()
image.addChild(svg)
image.addChild(imagePos)
sg.addChild(image)
---
OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6706 (Git)
Build type: Release
Branch: tag: 0.16.6706
Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.8.0.oce-0.17
juanvanyo
Posts: 16
Joined: Sat Dec 10, 2016 12:14 am
Location: Spain

Re: Insert one .svg image into the scene aligned with the scene axes and not always facing the camera.

Post by juanvanyo »

Now I tried adding a texture in a box with profundity 0. But with this I obtain mirror effect. Any suggestion?
[img]
icons.jpg
icons.jpg (100.15 KiB) Viewed 1123 times
[/img]

Code: Select all

from pivy import coin
sg = Gui.ActiveDocument.ActiveView.getSceneGraph()
svg = coin.SoTexture2()
svg.filename = '/Users/juanvanyo/Desktop/FreeCAD/FreeCAD-GDT/Gui/Resources/icons/Characteristic/perpendicularity.svg'
box = coin.SoVRMLBox()
box.size = (2,2,0)
imagePos = coin.SoTransform()
imagePos.translation.setValue([10,0,0])
imagePos.rotation = coin.SbRotation(0,0,0,0)
image = coin.SoSeparator()
image.addChild(imagePos)
image.addChild(svg)
image.addChild(box)
sg.addChild(image)
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Insert one .svg image into the scene aligned with the scene axes and not always facing the camera.

Post by HoWil »

Dear juanvanyo ,
How is your image imported?
Is it a 'pixel'-graphic or is it inserted as 'vector'-graphics?

I tried to import a matplotlib-plot but the imported .svg looks blured and additionally it is mirrored as you also mentioned.

BR
HoWil
Attachments
export.png
export.png (117.83 KiB) Viewed 1103 times
Post Reply