Page 2 of 3
Re: Polishing of draft wb
Posted: Fri Mar 31, 2017 5:58 pm
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
Re: Polishing of draft wb
Posted: Fri Mar 31, 2017 7:25 pm
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
Re: Polishing of draft wb
Posted: Mon Apr 10, 2017 9:16 pm
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...
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 8:36 am
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
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 9:27 am
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?
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 2:05 pm
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
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 2:59 pm
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);
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 3:51 pm
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)
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 4:53 pm
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()
Re: Polishing of draft wb
Posted: Tue Apr 11, 2017 7:38 pm
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