Procházet zdrojové kódy

Move cropmark options, Add "between" cropmarks

New cropmarks allow for cutting pages completely with bypass cutters,
instead of having to leave the page border uncut.
Weiyi Lou před 3 roky
rodič
revize
53883b018d
1 změnil soubory, kde provedl 41 přidání a 17 odebrání
  1. 41 17
      card_grid_generator/card_grid_generator_extension.py

+ 41 - 17
card_grid_generator/card_grid_generator_extension.py

@@ -46,17 +46,14 @@ class CardGridGenerator(Extension):
         row1.addWidget(self.unitInput)
         layout.addLayout(row1)
 
-        # Bleed dimension row. Also, guides or cropmarks selection.
+        # Bleed dimension row.
         self.bleedInput = QLineEdit('36')
         self.guidesCheck = QCheckBox('Guides')
         self.guidesCheck.setChecked(True)
-        self.cropmarksCheck = QCheckBox('Cropmarks')
-        self.cropmarksCheck.setChecked(True)
         row2 = QHBoxLayout()
         row2.addWidget(QLabel('Bleed size:'))
         row2.addWidget(self.bleedInput)
         row2.addWidget(self.guidesCheck)
-        row2.addWidget(self.cropmarksCheck)
         layout.addLayout(row2)
 
         # How many cards row.
@@ -72,12 +69,23 @@ class CardGridGenerator(Extension):
         row3.addWidget(self.maxCheck)
         layout.addLayout(row3)
 
+        # Cropmark options.
+        self.cropmarksCheck = QCheckBox('Cropmarks')
+        self.cropmarksCheck.setChecked(True)
+        self.cropmarkTypeInput = QComboBox()
+        self.cropmarkTypeInput.addItems( ['Around', 'Between', 'All'] )
+        row4 = QHBoxLayout()
+        row4.addWidget(self.cropmarksCheck)
+        row4.addWidget(QLabel('Cropmark Type:'))
+        row4.addWidget(self.cropmarkTypeInput)
+        layout.addLayout(row4)
+
         # Do It row.
         goButton = QPushButton("Create Card Grid")
         goButton.setIcon( Krita.instance().icon('animation_play') )
-        row4 = QHBoxLayout()
-        row4.addWidget(goButton)
-        layout.addLayout(row4)
+        row5 = QHBoxLayout()
+        row5.addWidget(goButton)
+        layout.addLayout(row5)
 
         # Hook up the actions.
         goButton.clicked.connect( self.generateCardGrid )
@@ -179,6 +187,10 @@ class CardGridGenerator(Extension):
         # Create cropmarks.
         if self.cropmarksCheck.checkState():
 
+            cropmarkType = self.cropmarkTypeInput.currentText()
+            cropAround = cropmarkType in ["Around", "All"]
+            cropBetween = cropmarkType in ["Between", "All"]
+
             # Cropmarks will be on a new layer.
             layer = doc.createNode('CardGridCropmarks', 'paintLayer')
             root = doc.rootNode()
@@ -190,22 +202,34 @@ class CardGridGenerator(Extension):
             cropMarkHeight = 48
             cropMark = QByteArray(blackPixel * cropMarkWidth * cropMarkHeight)
             for x in xSetCardsOnly:
-                # top
-                y = ySet[0] - cropMarkHeight
-                layer.setPixelData(cropMark, x - 1, y, cropMarkWidth, cropMarkHeight)
-                # bottom
-                layer.setPixelData(cropMark, x - 1, ySet[-1], cropMarkWidth, cropMarkHeight)
+                yToDo = []
+                if cropAround:
+                    yToDo.append(ySet[0] - cropMarkHeight) # top
+                    yToDo.append(ySet[-1]) # bottom
+
+                if cropBetween:
+                    for y in ySetCardsOnly:
+                        yToDo.append(y - cropMarkHeight/2)
+
+                for y in yToDo:
+                    layer.setPixelData(cropMark, x - 1, y, cropMarkWidth, cropMarkHeight)
 
             # Create horizontal cropmarks.
             cropMarkWidth = 48
             cropMarkHeight = 2
             cropMark = QByteArray(blackPixel * cropMarkWidth * cropMarkHeight)
             for y in ySetCardsOnly:
-                # left
-                x = xSet[0] - cropMarkWidth
-                layer.setPixelData(cropMark, x, y - 1, cropMarkWidth, cropMarkHeight)
-                # right
-                layer.setPixelData(cropMark, xSet[-1], y - 1, cropMarkWidth, cropMarkHeight)
+                xToDo = []
+                if cropAround:
+                    xToDo.append(xSet[0] - cropMarkWidth) # left
+                    xToDo.append(xSet[-1]) # right
+
+                if cropBetween:
+                    for x in xSetCardsOnly:
+                        xToDo.append(x - cropMarkWidth/2)
+
+                for x in xToDo:
+                    layer.setPixelData(cropMark, x, y - 1, cropMarkWidth, cropMarkHeight)
 
             # Refresh the view, or the cropmarks will not be immediately shown.
             doc.refreshProjection()