Drawing: SVG and Browser Views

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Drawing: SVG and Browser Views

Post by wandererfan »

In the current Drawing module, what are
- Open SVG
- Open Page in Browser View

used for? Are they worth moving to the new (mrlukeparry) Drawing module? Or do they just duplicate function that is available in other apps?

wf

OS: Ubuntu 12.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4263 (Git)
Branch: master
Hash: 7801fbef3a4442915c1897f9e8c3b9430373d0a0
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
OCC version: 6.7.0
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Drawing: SVG and Browser Views

Post by microelly2 »

Open Page in Browser View
is needed to display hatch pattern
viewtopic.php?f=9&t=4264&p=64366&hilit=hatch#p64366
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Drawing: SVG and Browser Views

Post by NormandC »

Didn't Luke use a new Qt viewer? If so, the "Open page in browser view" may not be necessary anymore.

As for Open SVG, it may be useful to be able to open an SVG in the Drawing module. After all, you can export a Drawing page as SVG, it seems logical you should be able to open it back as a drawing, not in the 3D space.
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Drawing: SVG and Browser Views

Post by wandererfan »

normandc wrote:After all, you can export a Drawing page as SVG, it seems logical you should be able to open it back as a drawing, not in the 3D space.
Don't think you can import the svg as a "drawing" now. It is display only as far as I can tell.

I'll look into the hatch pattern thing.

wf
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Drawing: SVG and Browser Views

Post by NormandC »

IIRC hatch pattern is only one example where the Qt viewer is lacking. It cannot display stacked text either, and possibly other stuff.
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Drawing: SVG and Browser Views

Post by yorik »

Actually the "Open SVG" button dates from when the Drawing WB only had that button :) Indeed it could be removed now, I don't think anyone uses that... Or maybe go to the image WB? It makes more sense there...

The "open in Browser" is indeed there because of the limitations of the QtSVG library, that is currently used in the Drawing WB. It supports only a small subset of the SVG specs (called "tinySVG"). The Webkit browser, however, that is used in the Web WB, has one of the best supports to SVG available. As a result, many interesting features (multiline texts, hatches, gradients, etc...) won't render correctly in the Drawing WB, but perfectly in the web WB, that's why I added that button.

Of course, at some point, we should make the transition of the DrawingWB to webkit. But it's not that simple. Luke's work doesn't use webkit either, for that reason: The problem is that the QtSVG stuff is deeply integrated in Qt. The display and even the elements inside the SVG image can be hooked to the whole Qt structure, so you can manage them, link them to Qt events, etc. The Qt implementation of webkit, however (QWebkit) is very simple, it only gives a few tools to display web content (including SVG) inside a Qt window. There are only very minimalist controls on the contents of that window from Qt. So basically for all the cool stuff that luke and hamish have done (moving things graphically, etc) to work in QWebkit, we would need to code a lot of base funcionality ourselves, which is no small work.

So yeah, no easy way out of this...
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Drawing: SVG and Browser Views

Post by shoogen »

If the QtSVG only renders a well-defined subset, then we probably need some kind of translator.
Like something that can convert hatches to basic paths.
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Drawing: SVG and Browser Views

Post by yorik »

shoogen wrote:If the QtSVG only renders a well-defined subset, then we probably need some kind of translator.
Like something that can convert hatches to basic paths.
That's not a bad idea actually... The same can be made for ex. for multiline texts. It'll fall short for some things (gradients, etc) but most of the useful stuff could be converted.
mrlukeparry
Posts: 655
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Drawing: SVG and Browser Views

Post by mrlukeparry »

My implementation used QGraphicsView which allows interactivity at a c++ level.

I wouldn't advise using QtSVG because it's an extra 'addon' module in Qt and I don't think it's being update / maintained in the long term, especially when it comes to Qt5.

Qt5.3 brings a new Qt Webkit engine that will be far more up to date but it apparently supports hooking in into c++.

It would actually be useful to add the Open SVG in my branch because it should natively export to SVG and also PDF.
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Drawing: SVG and Browser Views

Post by yorik »

mrlukeparry wrote:My implementation used QGraphicsView
Interesting, I wasn't aware that in your branch you were not using QtSVG anymore...
Post Reply