|
|
@@ -85,20 +85,26 @@ class BoxGenerator(Extension):
|
|
|
|
|
|
# Actually generates the box!
|
|
|
def generateBox(self, e):
|
|
|
- layer = self.doc.createVectorLayer("Box")
|
|
|
+ length_text = self.lengthInput.text()
|
|
|
+ width_text = self.widthInput.text()
|
|
|
+ height_text = self.heightInput.text()
|
|
|
+
|
|
|
+ # Box dimensions in pixels.
|
|
|
+ doc_ppi = self.doc.resolution()
|
|
|
+ mm = doc_ppi/25.4
|
|
|
+ multiplier = 1
|
|
|
+ if self.unitInput.currentText() == "inch":
|
|
|
+ multiplier = doc_ppi
|
|
|
+ if self.unitInput.currentText() == "mm":
|
|
|
+ multiplier = mm
|
|
|
+ length = float(length_text) * multiplier
|
|
|
+ height = float(height_text) * multiplier
|
|
|
+ width = float(width_text) * multiplier
|
|
|
+
|
|
|
+ layer = self.doc.createVectorLayer(f"""Box {length_text}x{width_text}x{height_text}""")
|
|
|
root = self.doc.rootNode()
|
|
|
root.addChildNode(layer, None)
|
|
|
|
|
|
- # Get dimensions in points. Points to mm conversion depends on document DPI.
|
|
|
- length_mm = float(self.lengthInput.text())
|
|
|
- width_mm = float(self.widthInput.text())
|
|
|
- height_mm = float(self.heightInput.text())
|
|
|
- # Assume input is in mm.
|
|
|
- mm = 300 / 25.4
|
|
|
- length = length_mm * mm
|
|
|
- height = height_mm * mm
|
|
|
- width = width_mm * mm
|
|
|
-
|
|
|
# Create outline using SVG (starts from top left corner).
|
|
|
if self.boxTypeInput.currentIndex() == 0: # Tuckbox
|
|
|
|
|
|
@@ -114,9 +120,12 @@ class BoxGenerator(Extension):
|
|
|
l {height*0.1} -{height}
|
|
|
h {height*0.4}
|
|
|
a {height*0.5} {height} 0 0 1 {height*0.5-0.25*mm} {height-3.5*mm}
|
|
|
- h {0.5*mm}
|
|
|
+ h {0.6*mm}
|
|
|
v {3.5*mm}
|
|
|
- h {length+height-0.5*mm}
|
|
|
+ h {length*0.5-0.35*mm - 7*mm}
|
|
|
+ a {7.3*mm} {7.3*mm} 0 0 0 {14*mm} 0
|
|
|
+ h {length*0.5 - 7*mm}
|
|
|
+ h {height-0.25*mm}
|
|
|
v {width-0.25*mm}
|
|
|
h -{height-0.25*mm}
|
|
|
v {height-0.25*mm}
|
|
|
@@ -163,8 +172,11 @@ class BoxGenerator(Extension):
|
|
|
M {1*mm+height*2+length} {height*1.66 - 3.5*mm}
|
|
|
v -{1*mm}
|
|
|
M {1*mm+height*2+length} {height*1.66}
|
|
|
- h {0.25*mm}
|
|
|
+ h {0.35*mm}
|
|
|
"></path>
|
|
|
+ <rect x="{1*mm+height*2+length+2.5*mm}"
|
|
|
+ y="{height*1.66+width+2.5*mm}" width="{length-5*mm}" height="{height-0.5*mm - 3*mm}"></rect>
|
|
|
+ <rect x="{1*mm+height*2+length*2+2.5*mm}" y="{height*1.66+2.5*mm}" width="{height-0.25*mm - 3*mm}" height="{width-5*mm}"></rect>
|
|
|
</svg>"""
|
|
|
|
|
|
else: # Telescopic
|