Polishing of draft wb

A forum for research and development of the user interface of FreeCAD

Moderator: agryson

HoWil
Posts: 840
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Polishing of draft wb

Post by HoWil » Fri Mar 31, 2017 5:58 pm

yorik wrote: But if more people want the draft default color to be white, of course, I have nothing against changing.
I my opinion it is not only switching to white. It is almost more on emphasizing hints in color like the points or the snapping suggestions. Additionally, it would be great if they could be drawn larger as in my suggestion above.
BR
Howil

User avatar
kkremitzki
Posts: 1756
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: Polishing of draft wb

Post by kkremitzki » Fri Mar 31, 2017 7:25 pm

HoWil wrote:
yorik wrote: But if more people want the draft default color to be white, of course, I have nothing against changing.
I my opinion it is not only switching to white. It is almost more on emphasizing hints in color like the points or the snapping suggestions. Additionally, it would be great if they could be drawn larger as in my suggestion above.
BR
Howil
+1
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.

User avatar
yorik
Site Admin
Posts: 11547
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Polishing of draft wb

Post by yorik » Mon Apr 10, 2017 9:16 pm

kkremitzki wrote:Additionally, it would be great if they could be drawn larger as in my suggestion above.
Unfortunately they are drawn with SoMarkerSet nodes and they are already at maximum size (9). This would require to make custom coin nodes, that's much more work. But I'll keep it in a corner of my mind...

wmayer
Site Admin
Posts: 14869
Joined: Thu Feb 19, 2009 10:32 am

Re: Polishing of draft wb

Post by wmayer » Tue Apr 11, 2017 8:36 am

SoMarkerSet can be extended with custom bitmaps:
https://grey.colorado.edu/coin3d/classS ... 08d6c233a4

However, I have no clue if you get it working via its Python interface using pivy. At least it works using C++ which we also did to get bigger circles in the sketcher module

looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo » Tue Apr 11, 2017 9:27 am

wmayer wrote:However, I have no clue if you get it working via its Python interface using pivy. At least it works using C++ which we also did to get bigger circles in the sketcher module
I don't think it's working right now, but it shouldn't be much work:

Code: Select all

NotImplementedError: Wrong number or type of arguments for overloaded function 'SoMarkerSet_addMarker'.
  Possible C/C++ prototypes are:
    SoMarkerSet::addMarker(int,SbVec2s const &,unsigned char const *,SbBool,SbBool)
    SoMarkerSet::addMarker(int,SbVec2s const &,unsigned char const *,SbBool)
    SoMarkerSet::addMarker(int,SbVec2s const &,unsigned char const *)
maybe direct conversation from svg to unsigned char is possible?
please help with my conda-packaging efforts: https://liberapay.com/looooo/

looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo » Tue Apr 11, 2017 2:05 pm

I have tried to implement the addMarker function in pivy:
implementation, example
There seems to be some problems with the boarders of the bitmap. Some empty columns are necessary to get a good visualization of the bitmap.This is also true for the c++ implementation http://github.com/FreeCAD/FreeCAD/blob/ ... cpp#L64L75
please help with my conda-packaging efforts: https://liberapay.com/looooo/

wmayer
Site Admin
Posts: 14869
Joined: Thu Feb 19, 2009 10:32 am

Re: Polishing of draft wb

Post by wmayer » Tue Apr 11, 2017 2:59 pm

Code: Select all

    SoMarkerSet.CUSTOM_BIT_MAP_1 = 99
    SoMarkerSet.CUSTOM_BIT_MAP_2 = 98
You don't have to deal with hard-coded numbers. With

Code: Select all

idx = SoMarkerSet.getNumDefinedMarkers()
you get the next index for a new bitmap which you then can add with

Code: Select all

SoMarkerSet.addMarker(idx, SbVec2s(width, height), bitmap);

looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo » Tue Apr 11, 2017 3:51 pm

thanks for the hint.

Automatic rendering of a svg-file seems to be a bit more complecated with python. (at least I didn't succeed with PySide) Maybe this could be done in FreeCADGui? Something like this:

FreeCADGui.svg2string(file-path, scale) -> returns char * / bytes.

This way all markers could have the same source (svg) but have different scale (regarding screen size, or user preference)
please help with my conda-packaging efforts: https://liberapay.com/looooo/

wmayer
Site Admin
Posts: 14869
Joined: Thu Feb 19, 2009 10:32 am

Re: Polishing of draft wb

Post by wmayer » Tue Apr 11, 2017 4:53 pm

To convert a svg icon into a format Coin3d will understand you can try this:

Code: Select all

from PySide import QtCore
from PySide import QtGui

icon=QtGui.QBitmap(QtGui.QPixmap(":/icons/delete.svg"))

buffer=QtCore.QBuffer()
buffer.open(buffer.WriteOnly)
icon.save(buffer,"XPM")
buffer.close()

ary=buffer.buffer()
lines=ary.split(",")
ba=QtCore.QByteArray()
for i in lines[3:]:
   ba = ba.append(i)

ba=ba.replace("#","x")
ba=ba.replace("."," ")
ba.data()

looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo » Tue Apr 11, 2017 7:38 pm

thanks, added: https://github.com/looooo/pivy/blob/mas ... y/utils.py
with the last two arguments of SoMarkerSet::addMarker(..., isLSBFirst, isUpToDown) both set to false the full bitmap is shown without the need of an additional empty first column...
example how to use this feature: https://github.com/looooo/pivy/blob/mas ... svg.py#L36
please help with my conda-packaging efforts: https://liberapay.com/looooo/

Post Reply