Forum Replies Created
-
AuthorPosts
-
DavidTrem
ParticipantI cannot restrain the urge to show you a first working version, yet quite incomplete, of my script to write polygon based text on a layer. See the pcell code in attachments… (It seems that attachments does not work on the forum so I've copied the pcell code at the end of this email.)
The pcell requires python Fonttools and TTFquery packages. It is tested on Mac OS
but should work on any other platform provided that the font path in the line:
f = describe.openFont("/Library/Fonts/Microsoft/Verdana Bold.ttf")
is set to a font which is available on your computer.I'll continue working on it as time allows.
Any suggestion is welcome, do not hesitate.Cheers,
David
# Copyright (C) 2012 Trémouilles David
#
#This pcell is free software: you can redistribute it and/or modify
#it under the terms of the GNU Lesser General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This pcell is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public License
#along with the software. If not, see <http://www.gnu.org/licenses/>.from ui import *
import sys
fonttools_path = '/Users/dtremoui/lib/python/FontTools/'
ttfquery_path = '/Users/dtremoui/lib/python/TTFQuery-1.0.5-py2.7.egg'
if not fonttools_path in sys.path:
sys.path = [fonttools_path, ] + sys.path
if not ttfquery_path in sys.path:
sys.path = [ttfquery_path, ] + sys.pathfrom ttfquery import describe, glyphquery, glyph
f = describe.openFont("/Library/Fonts/Microsoft/Verdana Bold.ttf")import numpy as np
def draw_text(cv, text="My Text", layer=10):
lib = cv.lib()
position = 0
for letter in text:
n = glyphquery.glyphName(f, letter)
g = glyph.Glyph(n)
c = g.calculateContours(f)
shapes = [glyph.decomposeOutline(elem) for elem in c]
formes = [np.array(elem) for elem in shapes]
for trace in formes:
nb_points = int(trace.shape[0])
x = intarray(nb_points)
y = intarray(nb_points)
for index, x_value in enumerate(trace.T[0].tolist()):
x[index] = int(x_value) + position
for index, y_value in enumerate(trace.T[1].tolist()):
y[index] = int(y_value)
poly = cv.dbCreatePolygon(x, y, nb_points, layer)
cv.update()
size = int(glyphquery.width(f, n))
position += sizeDavidTrem
ParticipantFine for me
Thank you very much for this nice tool Keith
David
DavidTrem
ParticipantIndeed fixed in the afternoon version
Thank you so much !
I've another related issue, if you change the properties while your
are creating the instance, then when you look at the properties afterwards
the default are displayed instead of the current one…David
DavidTrem
ParticipantFor the Pcell property You can simply create an instance of let say "nmos13_multi" in the example library, select it then 'Q' to see property, go to "Properties" tab and change let say "w" to 10.1 (default is 1.1), press OK, OK. Then reopen the property and look again at the "w" value (it is back to 1.1 here on my computer)…
David
DavidTrem
ParticipantNothing really clear yet but I also observed that Pcell parameter are not updated
to the current one in the query window (defaults are show)… Might it be related ?David
DavidTrem
ParticipantYes ! Indeed the coordinates do change in the query window. Clearly visible when
update is pressed.For example coordinates:
((69,820,207,730) (328,910,212,270) (328,910,212,270) (283,450,447,500) )
where changed to:
((69,000,820,000) (207,000,730,000) (328,000,910,000) (212,000,270,000) (328,000,910,000) (212,000,270,000) (283,000,450,000) (447,000,500,000) )DavidTrem
ParticipantNo other idea…
Might be related to MacOS X version (Lion 10.7.5 here),
or to the fact that I use python from MacPorts, even if I do
not see any evident reason it could be a problem…David
DavidTrem
ParticipantHum, again something weird…
If I launch the Glade.app double clicking the file then it works.
If, within a terminal, I "open Glade.app" then I can observe the issue.
I also tried unsetting the PYTHONPATH in the terminal before launching
Glade but the issue still remains…Any idea ? Any test I could do that might help ?
David
DavidTrem
ParticipantSimply opening the properties window (Q shortcut) of a polygon shape then pressing OK button screw it up… No issue with a rectangle.
For example: Open a new layout view, draw a triangle with the "create polygon" tool.
Select the shape an press 'Q' to see its properties, then just press OK button of the properties window -> the shape is totally screwed up.I'm using glade 4.3.12 compiled on Sep 22 2012 13:07:53 under Mac OS X.
Regards,
David
DavidTrem
ParticipantGreat !
Sorry, actually I was "thinking" layer generation and not verification
while searching the doc…Many thanks,
David
DavidTrem
ParticipantHi,
Is it possible to use boolean operations from within a python script ?
I did not find any information in Glade documentation…Regards,
David
DavidTrem
ParticipantThank you very much Keith !
DavidTrem
ParticipantOK
I was able to narrow down the issue:
Actually the script seg. fault occurs when gui.openCellView("default", "test", "layout") is executed (either in the script or by clicking "layout" to see it.
It occurs either when glade is run in the console or from double clicking glage.app
It runs smoothly when the PYTHONPATH is set and glade run from the console using "open glade.app" (as I mentioned in my previous message).
Actually the only difference I could see is that
>>>i.dbReplaceProp("w", 2.50)
return "False" when it crashes and "True" when it works…Hope this feedback could help debugging.
Glade is a great tool !
Many thanks to the author(s).DavidTrem
ParticipantHi,
After extensive tests I'm a bit puzzled… :squi: (Using Glade 4.3.12 on Mac)
1) The script works only if I run Glade from the console setting the PYTHONPATH variable in the shell. If the PYTHONPATH var is not set the script crashes…
(The PYTHONPATH being set to the main glade folder */glade4_mac64 )
And actually the seg. fault occurs when cv.update()
is called.
>>> i = cv.dbCreatePCellInst("default", "nmos13_multi", "layout", origin)>>> i.dbReplaceProp("w", 2.50)
do not crash…Well at least I managed to make it work
2) There is an issue with dbCreateInst()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/me/Desktop/Glade/glade4_mac64/ui.py", line 613, in dbCreateInst
def dbCreateInst(*args): return _ui.cellView_dbCreateInst(*args)
NotImplementedError: No matching function for overloaded 'cellView_dbCreateInst'3) Anyway dbCreateInst() does not look like a solution as I would like
to instantiate and adjust the pcell parameter from this code (actually would
like to create a pcell that instantiate other pcells).Please do not hesitate if you would like more details.
DavidTrem
ParticipantRunning the following script seg. fault while calling dbCreatePCellInst.
Any idea ?from ui import *gui = cvar.uiptr
gui.importTech("default",
"/Users/me/Desktop/Glade/glade4_mac64/example.tch")
gui.loadPCell("default", "nmos13_multi")
lib = getLibByName("default")
cv = lib.dbOpenCellView("test", "layout", 'w')
origin = Point(0,0)
i = cv.dbCreatePCellInst("default", "nmos13_multi", "layout", origin)
i.dbReplaceProp("w", 2.50)
cv.dbUpdatePCell(i);
cv.update()
gui.openCellView("default", "test", "layout")Traceback:signal 11 (Segmentation fault: 11), address is 0x0 from 0x0Stack Trace:[0]: glade 0x0000000100144e98 crit_err_hdlr(int, __siginfo*, void*) + 248[1]: libsystem_c.dylib 0x00007fff99e1fcfa _sigtramp + 26[2]: ??? 0x00000000000000ca 0x0 + 202[3]: glade 0x00000001001a915f guiGLCanvas::paintGL() + 1359[4]: QtOpenGL 0x000000010191db6f QGLWidget::glDraw() + 207[5]: QtOpenGL 0x000000010191dbdf QGLWidget::paintEvent(QPaintEvent*) + 41[6]: QtGui 0x0000000100ec5c23 QWidget::event(QEvent*) + 1389[7]: QtOpenGL 0x000000010192085a QGLWidget::event(QEvent*) + 360[8]: glade 0x000000010019e1fa guiGLCanvas::event(QEvent*) + 26[9]: QtGui 0x0000000100e77028 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 304[10]: QtGui 0x0000000100e772a6 QApplication::notify(QObject*, QEvent*) + 600[11]: glade 0x00000001001494f0 guiApplication::notify(QObject*, QEvent*) + 560[12]: QtCore 0x0000000100c1ca02 QCoreApplication::notifyInternal(QObject*, QEvent*) + 104[13]: QtGui 0x0000000100ec9151 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 2055[14]: QtGui 0x0000000100e22428 QMacInputContext::reset() + 15048[15]: AppKit 0x00007fff930ae2ce -[NSView + +[16]: AppKit 0x00007fff930db49b -[NSView + +[17]: AppKit 0x00007fff930ab8a9 -[NSView + +[18]: AppKit 0x00007fff930acb5e -[NSView + +[19]: AppKit 0x00007fff930acb5e -[NSView + +[20]: AppKit 0x00007fff930acb5e -[NSView + +[21]: AppKit 0x00007fff930acb5e -[NSView + +[22]: AppKit 0x00007fff930acb5e -[NSView + +[23]: AppKit 0x00007fff930acb5e -[NSView + +[24]: AppKit 0x00007fff930aada3 -[NSThemeFrame + +[25]: AppKit 0x00007fff930a61bb -[NSView + +[26]: AppKit 0x00007fff9309ec35 -[NSView + +[27]: AppKit 0x00007fff9309e375 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648[28]: CoreFoundation 0x00007fff95a528e7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23[29]: CoreFoundation 0x00007fff95a52846 __CFRunLoopDoObservers + 374[30]: CoreFoundation 0x00007fff95a27af9 __CFRunLoopRun + 825[31]: CoreFoundation 0x00007fff95a27486 CFRunLoopRunSpecific + 230[32]: HIToolbox 0x00007fff947fe2bf RunCurrentEventLoopInMode + 277[33]: HIToolbox 0x00007fff948054bf ReceiveNextEventCommon + 181[34]: HIToolbox 0x00007fff948053fa BlockUntilNextEventMatchingListInMode + 62[35]: AppKit 0x00007fff93062779 _DPSNextEvent + 659[36]: AppKit 0x00007fff9306207d -[NSApplication + +[37]: AppKit 0x00007fff9305e9b9 -[NSApplication + +[38]: QtGui 0x0000000100e32460 operator!=(QRectF const&, QRectF const&) + 6368[39]: QtCore 0x0000000100c19e28 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 394[40]: QtCore 0x0000000100c1d153 QCoreApplication::exec() + 175[41]: glade 0x0000000100147b02 guiMain::startApp() + 4418[42]: glade 0x000000010014908c guiMain::runWithMinimalLogging() + 12[43]: glade 0x000000010014923a guiMain::run() + 42[44]: glade 0x0000000100280837 main + 55[45]: glade 0x00000001000042bd _start + 203[46]: glade 0x00000001000041f1 start + 33[47]: ??? 0x0000000000000002 0x0 + 2# Glade release version 4.3.12 compiled on Sep 20 2012 12:44:59# Qt version 4.8.2 on 64 bit platform (little endian)# Compiled with gcc version 4.2.1# Username: Hostname:# Current time: Thu Sep 20 21:37:58 2012# Operating system: Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64# Number of CPUs: 4# OpenGL vendor: Intel Inc.# OpenGL renderer: Intel HD Graphics 3000 OpenGL Engine# OpenGL version: 2.1 APPLE-7.32.12# OpenGL FBOs will be used.# Python version 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] for darwin# Adding python module path: /Users/me/Desktop/Glade/glade4_mac64ui().execPythonFile("/Users/me/Desktop/Glade/glade4_mac64/pyscripts/create_pcell.py")ui().importTech("default", "/Users/me/Desktop/Glade/glade4_mac64/example.tch", 1000)# INFO: Reading techfile /Users/me/Desktop/Glade/glade4_mac64/example.tch# INFO: Creating layer psub purpose drawing# INFO: Creating layer nwell purpose drawing# INFO: Creating layer od purpose drawing# INFO: Creating layer polyg purpose drawing# INFO: Creating layer nimp purpose drawing# INFO: Creating layer pimp purpose drawing# INFO: Creating layer cont purpose drawing# INFO: Creating layer metal1 purpose drawing# INFO: Creating layer via12 purpose drawing# INFO: Creating layer metal2 purpose drawing# INFO: Creating layer via23 purpose drawing# INFO: Creating layer metal3 purpose drawing# INFO: Creating layer via34 purpose drawing# INFO: Creating layer metal4 purpose drawing# INFO: Creating layer via45 purpose drawing# INFO: Creating layer metal5 purpose drawing# INFO: Creating layer via56 purpose drawing# INFO: Creating layer metal6 purpose drawing# INFO: Creating layer rpo purpose drawing# INFO: Creating layer cap purpose drawing# INFO: Creating layer potxt purpose drawing# INFO: Creating layer m1txt purpose drawing# INFO: Layer nwell purpose drawing minWidth rule 1,000# INFO: Layer nwell purpose drawing minSpace rule 1,000# INFO: Layer od purpose drawing minWidth rule 0,000# INFO: Layer od purpose drawing minSpace rule 0,000# INFO: Layer polyg purpose drawing minWidth rule 0,000# INFO: Layer polyg purpose drawing minSpace rule 0,000# INFO: Layer pimp purpose drawing minWidth rule 0,000# INFO: Layer pimp purpose drawing minSpace rule 0,000# INFO: Layer nimp purpose drawing minWidth rule 0,000# INFO: Layer nimp purpose drawing minSpace rule 0,000# INFO: Layer cont purpose drawing minWidth rule 0,000# INFO: Layer cont purpose drawing minSpace rule 0,000# INFO: Layer metal1 purpose drawing minWidth rule 0,000# INFO: Layer metal1 purpose drawing minSpace rule 0,000# INFO: Layer via12 purpose drawing minWidth rule 0,000# INFO: Layer via12 purpose drawing minSpace rule 0,000# INFO: Layer metal2 purpose drawing minWidth rule 0,000# INFO: Layer metal2 purpose drawing minSpace rule 0,000# INFO: Layer via23 purpose drawing minWidth rule 0,000# INFO: Layer via23 purpose drawing minSpace rule 0,000# INFO: Layer metal3 purpose drawing minWidth rule 0,000# INFO: Layer metal3 purpose drawing minSpace rule 0,000# INFO: Layer via34 purpose drawing minWidth rule 0,000# INFO: Layer via34 purpose drawing minSpace rule 0,000# INFO: Layer metal4 purpose drawing minWidth rule 0,000# INFO: Layer metal4 purpose drawing minSpace rule 0,000# INFO: Layer via45 purpose drawing minWidth rule 0,000# INFO: Layer via45 purpose drawing minSpace rule 0,000# INFO: Layer metal5 purpose drawing minWidth rule 0,000# INFO: Layer metal5 purpose drawing minSpace rule 0,000# INFO: Layer via56 purpose drawing minWidth rule 0,000# INFO: Layer via56 purpose drawing minSpace rule 0,000# INFO: Layer metal6 purpose drawing minWidth rule 0,000# INFO: Layer metal6 purpose drawing minSpace rule 0,000# INFO: Layer rpo purpose drawing minSpace rule 0,000# INFO: Layer rpo purpose drawing minWidth rule 0,000# INFO: Creating via od_m1# INFO: Creating via polyg_m1# INFO: Creating via m1_m2# INFO: Creating via m2_m3# INFO: Creating via m3_m4# INFO: Creating via m4_m5# INFO: Creating via m5_m6# WARNING: Line 145: Line plain already defined, ignoring.# WARNING: Line 146: Line thicksolid already defined, ignoring.# WARNING: Line 147: Line thick already defined, ignoring.# WARNING: Line 148: Line dashed2 already defined, ignoring.# WARNING: Line 149: Line dotted already defined, ignoring.# WARNING: Line 150: Line dashdot already defined, ignoring.# WARNING: Line 151: Line dashdotdot already defined, ignoring.# WARNING: Line 22: Stipple zagl already defined, ignoring.# WARNING: Line 22: Stipple zagr already defined, ignoring.# WARNING: Line 22: Stipple dots1 already defined, ignoring.# WARNING: Line 22: Stipple dots2 already defined, ignoring.# WARNING: Line 22: Stipple dots3 already defined, ignoring.# WARNING: Line 22: Stipple solid already defined, ignoring.# WARNING: Line 22: Stipple empty already defined, ignoring.# WARNING: Line 22: Stipple cross already defined, ignoring.# WARNING: Line 22: Stipple brick already defined, ignoring.# WARNING: Line 22: Stipple dots4 already defined, ignoring.# INFO: Finished reading techfileui().loadPCell("default", "nmos13_multi")ui().openCellView("default", "test", "layout")# INFO: Reading preferences file /Users/me/.gladerc# INFO: Opened cell test view layout>>> -
AuthorPosts