def __init__(self): super(mixerHead, self).__init__() self.edt_glyphName = QtGui.QLineEdit() self.edt_stemV0 = QtGui.QLineEdit('1') self.edt_stemV1 = QtGui.QLineEdit('1') self.edt_stemH0 = QtGui.QLineEdit('1') self.edt_stemH1 = QtGui.QLineEdit('1') self.btn_refresh = QtGui.QPushButton('&Refresh') self.btn_set_axis = QtGui.QPushButton('Set &Axis') self.btn_getVstem = QtGui.QPushButton('Get &V Stems') self.btn_getHstem = QtGui.QPushButton('Get &H Stems') self.spb_compV = QtGui.QDoubleSpinBox() self.spb_compH = QtGui.QDoubleSpinBox() self.spb_compV.setValue(0.) self.spb_compH.setValue(0.) self.spb_compV.setSingleStep(.01) self.spb_compH.setSingleStep(.01) self.cmb_0 = QtGui.QComboBox() self.cmb_1 = QtGui.QComboBox() self.chk_italic = QtGui.QPushButton('Italic') self.chk_single = QtGui.QPushButton('Anisotropic') self.chk_preview = QtGui.QPushButton('Live Preview') self.chk_single.setToolTip( 'Active: Use X and Y sliders to control interpolation.') self.chk_single.setCheckable(True) self.chk_italic.setCheckable(True) self.chk_preview.setCheckable(True) self.chk_single.setChecked(False) self.chk_italic.setChecked(False) self.chk_preview.setChecked(False) self.addWidget(QtGui.QLabel('Glyph:'), 0, 0, 1, 1) self.addWidget(self.edt_glyphName, 0, 1, 1, 6) self.addWidget(self.btn_refresh, 0, 7, 1, 1) self.addWidget(QtGui.QLabel('Axis:'), 1, 0, 1, 1) self.addWidget(self.cmb_0, 1, 1, 1, 3) self.addWidget(self.cmb_1, 1, 4, 1, 3) self.addWidget(self.btn_set_axis, 1, 7, 1, 1) self.addWidget(QtGui.QLabel('V Stems:'), 2, 0, 1, 1) self.addWidget(self.edt_stemV0, 2, 1, 1, 3) self.addWidget(self.edt_stemV1, 2, 4, 1, 3) self.addWidget(self.btn_getVstem, 2, 7, 1, 1) self.addWidget(QtGui.QLabel('H Stems:'), 3, 0, 1, 1) self.addWidget(self.edt_stemH0, 3, 1, 1, 3) self.addWidget(self.edt_stemH1, 3, 4, 1, 3) self.addWidget(self.btn_getHstem, 3, 7, 1, 1) self.addWidget(QtGui.QLabel('Adj.V/H:'), 4, 0, 1, 1) self.addWidget(self.spb_compV, 4, 1, 1, 3) self.addWidget(self.spb_compH, 4, 4, 1, 3) self.addWidget(self.chk_italic, 4, 7, 1, 1) self.addWidget(QtGui.QLabel('Control:'), 5, 0, 1, 1) self.addWidget(self.chk_single, 5, 1, 1, 4) self.addWidget(self.chk_preview, 5, 5, 1, 3)
def __init__(self): super(curveEq, self).__init__() # - Basic operations self.btn_tunni = QtGui.QPushButton('&Tunni (Auto)') self.btn_hobby = QtGui.QPushButton('Set &Curvature') self.btn_hobby_get = QtGui.QPushButton('Get') self.btn_hobby_swap = QtGui.QPushButton('Swap') self.btn_prop = QtGui.QPushButton('Set &Handles') self.btn_tunni.setToolTip('Apply Tunni curve optimization') self.btn_hobby.setToolTip('Set Hobby spline curvature') self.btn_hobby_swap.setToolTip('Swap C0, C1 curvatures') self.btn_hobby_get.setToolTip( 'Get curvature for current selected\nsegment at active layer.') self.btn_prop.setToolTip( 'Set handle length in proportion to bezier node distance') self.spn_hobby0 = QtGui.QDoubleSpinBox() self.spn_hobby1 = QtGui.QDoubleSpinBox() self.spn_hobby0.setValue(0.95) self.spn_hobby1.setValue(0.95) self.spn_hobby0.setSingleStep(0.05) self.spn_hobby1.setSingleStep(0.05) self.spn_prop = QtGui.QDoubleSpinBox() self.spn_prop.setValue(0.30) self.spn_prop.setSingleStep(0.1) self.btn_tunni.clicked.connect(lambda: self.eqContour('tunni')) self.btn_hobby_swap.clicked.connect(self.hobby_swap) self.btn_hobby_get.clicked.connect(self.hobby_get) self.btn_hobby.clicked.connect(lambda: self.eqContour('hobby')) self.btn_prop.clicked.connect(lambda: self.eqContour('prop')) # -- Build: Curve optimization self.addWidget(self.btn_tunni, 0, 0, 1, 5) self.addWidget(QtGui.QLabel('Proportional handles'), 1, 0, 1, 5) self.addWidget(self.btn_prop, 2, 0, 1, 3) self.addWidget(QtGui.QLabel('P:'), 2, 3, 1, 1) self.addWidget(self.spn_prop, 2, 4, 1, 1) self.addWidget(QtGui.QLabel('Hobby curvature'), 3, 0, 1, 5) self.addWidget(self.btn_hobby_swap, 4, 0, 1, 1) self.addWidget(QtGui.QLabel('C0'), 4, 1, 1, 1) self.addWidget(self.spn_hobby0, 4, 2, 1, 1) self.addWidget(QtGui.QLabel('C1'), 4, 3, 1, 1) self.addWidget(self.spn_hobby1, 4, 4, 1, 1) self.addWidget(self.btn_hobby_get, 5, 0, 1, 1) self.addWidget(self.btn_hobby, 5, 1, 1, 4) self.setColumnStretch(0, 1) self.setColumnStretch(4, 0) self.setColumnStretch(5, 0) self.setColumnStretch(6, 0) self.setColumnStretch(7, 0)
def setTable(self, data, reset=False): name_row, name_column = [], [] self.blockSignals(True) self.setColumnCount(max(map(len, data.values()))) self.setRowCount(len(data.keys())) # - Populate for n, layer in enumerate(sorted(data.keys())): name_row.append(layer) for m, key in enumerate(data[layer].keys()): # -- Build name column name_column.append(key) # -- Selectively add data if m == 0: newitem = QtGui.QTableWidgetItem(str(data[layer][key])) newitem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable) newitem.setCheckState(QtCore.Qt.Unchecked) self.setItem(n, m, newitem) if 0 < m < 3: combo = QtGui.QComboBox() if m % 2: combo.setStyleSheet( 'QComboBox { background-color: rgba(255, 0, 0, 15); }' ) else: combo.setStyleSheet( 'QComboBox { background-color: rgba(0, 255, 0, 15); }' ) combo.addItems(data[layer][key]) self.setCellWidget(n, m, combo) if 2 < m < len(data[layer].keys()): spin = QtGui.QDoubleSpinBox() if m <= 6: spin.setSuffix(' u') if m % 2: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(255, 0, 0, 15); }' ) else: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(0, 255, 0, 15); }' ) spin.setMinimum(0.) spin.setMaximum(1000.) if 7 <= m <= 8: spin.setSuffix(' u') if m % 2: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(255, 200, 0, 25); }' ) else: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(255, 200, 0, 25); }' ) spin.setMinimum(0.) spin.setMaximum(1000.) if 9 <= m <= 10: spin.setSuffix(' %') spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(0, 0, 255, 15); }' ) spin.setMinimum(0.) spin.setMaximum(500.) if 10 < m: spin.setMinimum(0) spin.setMaximum(1) spin.setSingleStep(0.01) spin.setValue(data[layer][key]) self.setCellWidget(n, m, spin) self.setHorizontalHeaderLabels(name_column) self.setVerticalHeaderLabels(name_row) self.blockSignals(False)