summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-05-28 23:40:58 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-05-28 23:40:58 +0000
commitcc0fcb1deab53239f13f871e1765316c737d103c (patch)
treefd1ee7254b19ceffd241251fa0c225130cd23c87
parentFixed a error that handles all kinds of pathas as bsplines (diff)
parentextensions. dxf input. create default layer 0 if it does not exist (Bug 1123907) (diff)
downloadinkscape-cc0fcb1deab53239f13f871e1765316c737d103c.tar.gz
inkscape-cc0fcb1deab53239f13f871e1765316c737d103c.zip
update to trunk
(bzr r11950.1.120)
-rwxr-xr-xshare/extensions/dxf_input.py13
-rw-r--r--src/livarot/ShapeMisc.cpp60
-rw-r--r--src/sp-shape.cpp6
3 files changed, 50 insertions, 29 deletions
diff --git a/share/extensions/dxf_input.py b/share/extensions/dxf_input.py
index 1282be880..da81ff78c 100755
--- a/share/extensions/dxf_input.py
+++ b/share/extensions/dxf_input.py
@@ -26,6 +26,8 @@ import inkex, simplestyle, math
from StringIO import StringIO
from urllib import quote
+inkex.localize()
+
def export_MTEXT():
# mandatory group codes : (1 or 3, 10, 20) (text, x, y)
if (vals[groups['1']] or vals[groups['3']]) and vals[groups['10']] and vals[groups['20']]:
@@ -365,6 +367,7 @@ stream = open(args[0], 'r')
xmax = xmin = ymin = 0.0
height = 297.0*90.0/25.4 # default A4 height in pixels
line = get_line()
+polylines = 0
flag = 0 # (0, 1, 2, 3) = (none, LAYER, LTYPE, DIMTXT)
layer_colors = {} # store colors by layer
layer_nodes = {} # store nodes by layer
@@ -411,10 +414,10 @@ else:
scale = float(options.scale) # manual scale factor
xmin = float(options.xmin)
ymin = float(options.ymin)
-desc.text = '%s - scale = %f' % (unicode(args[0], options.input_encode), scale)
+desc.text = '%s - scale = %f, origin = (%f, %f), auto = %s' % (unicode(args[0], options.input_encode), scale, xmin, ymin, options.auto)
scale *= 90.0/25.4 # convert from mm to pixels
-if not layer_nodes:
+if not layer_nodes.has_key('0'):
attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '0'}
layer_nodes['0'] = inkex.etree.SubElement(doc.getroot(), 'g', attribs)
layer_colors['0'] = 7
@@ -438,6 +441,8 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES):
line = get_line()
if line[1] == 'ENTITIES':
inENTITIES = True
+ elif line[1] == 'POLYLINE':
+ polylines += 1
if entity and groups.has_key(line[0]):
seqs.append(line[0]) # list of group codes
if line[0] == '1' or line[0] == '2' or line[0] == '3' or line[0] == '6' or line[0] == '8': # text value
@@ -467,6 +472,8 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES):
if block != defs: # in a BLOCK
layer = block
elif vals[groups['8']]: # use Common Layer Name
+ if not vals[groups['8']][0]:
+ vals[groups['8']][0] = '0' # use default name
layer = layer_nodes[vals[groups['8']][0]]
color = '#000000' # default color
if vals[groups['8']]:
@@ -493,6 +500,8 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES):
vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]
seqs = []
+if polylines:
+ inkex.errormsg(_('%d ENTITIES of type POLYLINE encountered and ignored. Please try to convert to Release 13 format using QCad.') % polylines)
doc.write(inkex.sys.stdout)
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp
index a7e5a6cdc..6fd40790f 100644
--- a/src/livarot/ShapeMisc.cpp
+++ b/src/livarot/ShapeMisc.cpp
@@ -374,6 +374,8 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
do
{
int dadContour=-1;
+ int childEdge = -1;
+ bool foundChild = false;
int startBord = -1;
{
int fi = 0;
@@ -389,6 +391,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
} else {
dadContour = GPOINTER_TO_INT(swdData[askTo].misc);
dadContour-=1; // pour compenser le decalage
+ childEdge = getPoint(fi).incidentEdge[FIRST];
}
}
lastPtUsed = fi + 1;
@@ -407,6 +410,9 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
{
// parcours en profondeur pour mettre les leF et riF a leurs valeurs
swdData[startBord].misc = (void *)(intptr_t)(1 + nbNest);
+ if (startBord == childEdge) {
+ foundChild = true;
+ }
//printf("part de %d\n",startBord);
int curBord = startBord;
bool back = false;
@@ -444,22 +450,23 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
}
else
{
- bool escapePath=false;
- int tb=curBord;
- while ( tb >= 0 && tb < numberOfEdges() ) {
- if ( ebData[tb].pathID == wildPath ) {
- escapePath=true;
- break;
- }
- tb=swdData[tb].precParc;
- }
+// bool escapePath=false;
+// int tb=curBord;
+// while ( tb >= 0 && tb < numberOfEdges() ) {
+// if ( ebData[tb].pathID == wildPath ) {
+// escapePath=true;
+// break;
+// }
+// tb=swdData[tb].precParc;
+// }
nesting=(int*)g_realloc(nesting,(nbNest+1)*sizeof(int));
contStart=(int*)g_realloc(contStart,(nbNest+1)*sizeof(int));
contStart[nbNest]=dest->descr_cmd.size();
- if ( escapePath ) {
- nesting[nbNest++]=-1; // contient des bouts de coupure -> a part
- } else {
+ if (foundChild) {
nesting[nbNest++]=dadContour;
+ foundChild = false;
+ } else {
+ nesting[nbNest++]=-1; // contient des bouts de coupure -> a part
}
swdData[curBord].suivParc = -1;
AddContour (dest, nbP, orig, startBord, curBord,splitWhenForced);
@@ -484,24 +491,24 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
if ( getEdge(curBord).en == curStartPt ) {
//printf("contour %i ",curStartPt);
- bool escapePath=false;
- int tb=curBord;
- while ( tb >= 0 && tb < numberOfEdges() ) {
- if ( ebData[tb].pathID == wildPath ) {
- escapePath=true;
- break;
- }
- tb=swdData[tb].precParc;
- }
+// bool escapePath=false;
+// int tb=curBord;
+// while ( tb >= 0 && tb < numberOfEdges() ) {
+// if ( ebData[tb].pathID == wildPath ) {
+// escapePath=true;
+// break;
+// }
+// tb=swdData[tb].precParc;
+// }
nesting=(int*)g_realloc(nesting,(nbNest+1)*sizeof(int));
contStart=(int*)g_realloc(contStart,(nbNest+1)*sizeof(int));
contStart[nbNest]=dest->descr_cmd.size();
- if ( escapePath ) {
- nesting[nbNest++]=-1; // contient des bouts de coupure -> a part
- } else {
+ if (foundChild) {
nesting[nbNest++]=dadContour;
+ foundChild = false;
+ } else {
+ nesting[nbNest++]=-1; // contient des bouts de coupure -> a part
}
-
swdData[curBord].suivParc = -1;
AddContour (dest, nbP, orig, startBord, curBord,splitWhenForced);
startBord=nb;
@@ -512,6 +519,9 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
swdData[nb].precParc = curBord;
swdData[curBord].suivParc = nb;
curBord = nb;
+ if (nb == childEdge) {
+ foundChild = true;
+ }
//printf("suite %d\n",curBord);
}
}
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 4037b302c..be9f5388c 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -889,8 +889,8 @@ int SPShape::numberOfMarkers(int type)
if (pathv.size() == 0) {
return 0;
}
-
switch(type) {
+
case SP_MARKER_LOC:
{
if ( this->_marker[SP_MARKER_LOC] ) {
@@ -914,7 +914,9 @@ int SPShape::numberOfMarkers(int type)
for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
n += path_it->size_default() + 1;
}
- return n - 2; // minus the start and end marker.
+ n = (n > 1) ? (n - 2) : 0; // Minus the start and end marker, but never negative.
+ // A path or polyline may have only one point.
+ return n;
} else {
return 0;
}