Polishing of draft wb

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Polishing of draft wb

Post by HoWil »

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
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: Polishing of draft wb

Post by kkremitzki »

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
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Polishing of draft wb

Post by yorik »

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
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Polishing of draft wb

Post by wmayer »

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
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo »

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?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo »

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
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Polishing of draft wb

Post by wmayer »

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);
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo »

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)
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Polishing of draft wb

Post by wmayer »

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()
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Polishing of draft wb

Post by looo »

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
Post Reply