if isinstance(self.shape, x2a.asyArrow):
self.colorButton = Qw.QPushButton("Set Line Colour")
self.colorButton.clicked.connect(self.pickColor)
self.fillTab.layout.addWidget(self.colorButton)
self.colorButton = Qw.QPushButton("Set Fill Colour")
self.colorButton.clicked.connect(self.pickFillColor)
self.fillTab.layout.addWidget(self.colorButton)
for lineMode in self.lineList:
self.linestyleButton.addItem(lineMode)
self.linestyleButton.currentIndexChanged.connect(self.linestyleChange)
self.lineTab.layout.addWidget(self.linestyleButton)
self.linestyleButton.setCurrentIndex(self.lineList.index(self.shape.pen.style))
self.label = Qw.QLabel("Line Cap Style:")
self.lineTab.layout.addWidget(self.label)
self.lineCapStyleButton = Qw.QComboBox()
self.lineCapListStrings = ["extendcap","flatcap","roundcap"] #Is there a way to pull these directly
self.lineCapList = [Qc.Qt.PenCapStyle.SquareCap,Qc.Qt.PenCapStyle.FlatCap,Qc.Qt.PenCapStyle.RoundCap]
for lineMode in self.lineCapListStrings:
self.lineCapStyleButton.addItem(lineMode)
self.lineCapStyleButton.currentIndexChanged.connect(self.lineCapStyleChange)
self.lineTab.layout.addWidget(self.lineCapStyleButton)
self.lineCapStyleButton.setCurrentIndex(self.lineCapList.index(self.shape.pen.capStyle))
#TODO: Make this a function.
if not isinstance(self.shape, x2a.xasyShape):
self.fillButton.setCurrentIndex(int(self.shape.arrowSettings["fill"]))
if isinstance(self.shape, x2a.asyArrow):
self.arrowheadButton.setCurrentIndex(int(self.shape.arrowSettings["active"]))
else:
self.arrowheadButton.setDisabled(True)
else:
self.fillButton.setCurrentIndex(int(self.shape.path.fill))
if isinstance(self.shape, x2a.asyArrow) and self.shape.arrowSettings["active"]: #Make these all a list or something.
self.label = Qw.QLabel("Arrow Style:")
self.arrowTab.layout.addWidget(self.label)
self.arrowstyleButton = Qw.QComboBox()
for arrowStyle in self.shape.arrowStyleList:
self.arrowstyleButton.addItem(arrowStyle if arrowStyle else "(default)")
self.arrowstyleButton.currentIndexChanged.connect(self.arrowstyleChange)
self.arrowTab.layout.addWidget(self.arrowstyleButton)
def arrowheadChange(self, i):
#None, {Arrow, ArcArrow} x {(),(SimpleHead),(HookHead),(TeXHead)}
if isinstance(self.shape, x2a.xasyShape):
if i != 0:
if isinstance(self.newShape,x2a.asyArrow):
self.newShape.arrowSettings["active"] = i
else:
self.newShape = self.shape.arrowify(arrowhead=i)
else:
self.newShape.arrowSettings["active"] = i #Simplify the logic
def arrowstyleChange(self, i):
self.newShape.arrowSettings["style"] = i
def linestyleChange(self, i): #I think add an attribute to asyPen
self.shape.pen.setStyle(self.lineList[i])
def lineCapStyleChange(self, i): #I think add an attribute to asyPen
self.shape.pen.setCapStyle(self.lineCapList[i])
def fillChange(self, i):
if isinstance(self.shape, x2a.asyArrow):
self.shape.arrowSettings["fill"] = bool(i)
elif (self.shape.path.fill != bool(i)) and not isinstance(self.newShape, x2a.asyArrow):
if self.newShape:
self.newShape = self.newShape.swapFill()
if isinstance(self.newShape, x2a.asyArrow):
self.newShape.arrowSettings["fill"] = bool(i)
def angleChange(self): #Refactor this with the above.
try:
newAngle = self.arrowAngleBox.text()
self.newShape.arrowSettings["angle"] = float(newAngle)
except:
return #TODO: Show error message.
def arrowFillChange(self, i): #Can I lambda this?
self.newShape.arrowSettings["fill"] = i
def renderChanges(self): #Pull from text boxes here.
self.opacityChange()
if isinstance(self.shape, x2a.asyArrow) and self.shape.arrowSettings["active"]:
self.sizeChange()
self.angleChange()
elif (not isinstance(self.shape, x2a.asyArrow)):
self.renderLineStyle()
if self.newShape:
self.parent.replaceObject(self.parent.contextWindowObject,self.newShape)
self.parent.terminateContextWindow()
def getInfo(self,value):
""" Find out the size of an arbitrary Asymptote pen """
self.asyEngine = self.parent.asyEngine
assert isinstance(self.asyEngine, x2a.AsymptoteEngine)
assert self.asyEngine.active
fout = self.asyEngine.ostream
fin = self.asyEngine.istream
def renderLineStyle(self):
#Should only get called with asy shapes
if not self.newShape:
self.newShape=self.shape
if not isinstance(self.newShape,x2a.asyArrow):
rawPattern = self.getPattern(self.lineList[self.linestyleButton.currentIndex()],self.newShape.path.getCode())
else:
#self.newShape.updateCode() #idk if this is necessary.
rawPattern = self.getPattern(self.lineList[self.linestyleButton.currentIndex()],self.newShape.code)
pattern = []
if len(rawPattern) == 5:
pattern=[1,0]
else:
for value in rawPattern[2:-3].split(' '):
pattern.append(float(value)+1)
try:
self.newShape.pen.setDashPattern(pattern) #pen is going to be a asyPen, add as an attribute
except:
print("Pen format error")
def pickColor(self):
self.colorDialog = Qw.QColorDialog(x2a.asyPen.convertToQColor(self.shape.pen.color), self)
self.colorDialog.show()
result = self.colorDialog.exec()
if result == Qw.QDialog.Accepted:
self.shape.pen.setColorFromQColor(self.colorDialog.selectedColor())
self.parent.updateFrameDispColor()
def pickFillColor(self): #This is a copy of the above, how do you set the var as it is set?
self.colorDialog = Qw.QColorDialog(x2a.asyPen.convertToQColor(self.shape.fillPen.color), self)
self.colorDialog.show()
result = self.colorDialog.exec()
if result == Qw.QDialog.Accepted:
self.shape.fillPen.setColorFromQColor(self.colorDialog.selectedColor())
self.parent.updateFrameDispColor()
@Qc.pyqtSlot()
def on_click(self):
print("\n")
for currentQTableWidgetItem in self.tableWidget.selectedItems():
print(currentQTableWidgetItem.row(), currentQTableWidgetItem.column(), currentQTableWidgetItem.text())