def __init__(self): QDialog.__init__(self) self.setWindowIcon(QIcon(QPixmap(":/eagleimages/eaglepy.png"))) self.setWindowTitle("Alignment Tool") self.setGeometry(0, 0, 500, 300) self.setMaximumHeight(300) self.centerToWidget() self.setLayout(QHBoxLayout()) self.buttonLayout = QHBoxLayout() def setupButton(button, tooltip, width=50, height=50): button.setMaximumWidth(width) button.setMinimumWidth(width) button.setMaximumHeight(height) button.setMinimumHeight(height) button.setToolTip(tooltip) return button self.alignmentButtonFrame = QFrame() self.alignmentButtonFrame.setMaximumHeight(280) self.alignmentButtonFrame.setMaximumWidth(170) self.alignmentButtonFrame.setLayout(QGridLayout()) self.nudgeUpButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_move_u.png")), ""), "Nudge Up") self.nudgeDownButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_move_d.png")), ""), "Nudge Down") self.nudgeLeftButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_move_l.png")), ""), "Nudge Left") self.nudgeRightButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_move_r.png")), ""), "Nudge Right") self.alignLeftButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_align_l.png")), ""), "Align Left") self.alignRightButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_align_r.png")), ""), "Align Right") self.alignCenterVButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_align_v_c.png")), ""), "Align Vertical Center") self.alignCenterHButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_align_h_c.png")), ""), "Align Horizontal Center") self.alignTopButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_align_t.png")), ""), "Align Top") self.alignBottomButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_align_b.png")), ""), "Align Bottom") self.distributeHButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_distrib_h.png")), ""), "Distrubute Horiztontal") self.distributeVButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_distrib_v.png")), ""), "Distrubute Vertical") self.distributeGButton = setupButton( QPushButton(QIcon(QPixmap(":/alignmenttool/button_distrib_g.png")), ""), "Distrubute Grid") # Nudge Buttons self.nudgeSignalMapper = QSignalMapper() self.nudgeSignalMapper.setMapping(self.nudgeUpButton, self.DIRECTION_UP) self.nudgeSignalMapper.setMapping(self.nudgeDownButton, self.DIRECTION_DOWN) self.nudgeSignalMapper.setMapping(self.nudgeLeftButton, self.DIRECTION_LEFT) self.nudgeSignalMapper.setMapping(self.nudgeRightButton, self.DIRECTION_RIGHT) self.nudgeUpButton.clicked.connect(self.nudgeSignalMapper.map) self.nudgeDownButton.clicked.connect(self.nudgeSignalMapper.map) self.nudgeLeftButton.clicked.connect(self.nudgeSignalMapper.map) self.nudgeRightButton.clicked.connect(self.nudgeSignalMapper.map) self.nudgeSignalMapper.mapped.connect(self.nudgePressed) # Align Buttons self.alignSignalMapper = QSignalMapper() self.alignSignalMapper.setMapping(self.alignLeftButton, self.DIRECTION_LEFT) self.alignSignalMapper.setMapping(self.alignRightButton, self.DIRECTION_RIGHT) self.alignSignalMapper.setMapping(self.alignTopButton, self.DIRECTION_TOP) self.alignSignalMapper.setMapping(self.alignBottomButton, self.DIRECTION_BOTTOM) self.alignSignalMapper.setMapping(self.alignCenterHButton, self.DIRECTION_CENTER_H) self.alignSignalMapper.setMapping(self.alignCenterVButton, self.DIRECTION_CENTER_V) self.alignLeftButton.clicked.connect(self.alignSignalMapper.map) self.alignRightButton.clicked.connect(self.alignSignalMapper.map) self.alignCenterHButton.clicked.connect(self.alignSignalMapper.map) self.alignCenterVButton.clicked.connect(self.alignSignalMapper.map) self.alignTopButton.clicked.connect(self.alignSignalMapper.map) self.alignBottomButton.clicked.connect(self.alignSignalMapper.map) self.alignSignalMapper.mapped.connect(self.alignPressed) # Distribute Buttons self.distributeSignalMapper = QSignalMapper() self.distributeSignalMapper.setMapping(self.distributeHButton, self.DIRECTION_HORIZONTAL) self.distributeSignalMapper.setMapping(self.distributeVButton, self.DIRECTION_VERTICAL) self.distributeSignalMapper.setMapping(self.distributeGButton, self.DIRECTION_GRID) self.distributeHButton.clicked.connect(self.distributeSignalMapper.map) self.distributeVButton.clicked.connect(self.distributeSignalMapper.map) self.distributeGButton.clicked.connect(self.distributeSignalMapper.map) self.distributeSignalMapper.mapped.connect(self.distributePressed) self.alignmentButtonFrame.layout().addWidget(self.distributeHButton, 0, 0) self.alignmentButtonFrame.layout().addWidget(self.distributeGButton, 0, 1) self.alignmentButtonFrame.layout().addWidget(self.distributeVButton, 0, 2) self.alignmentButtonFrame.layout().addWidget(self.alignLeftButton, 1, 0) self.alignmentButtonFrame.layout().addWidget(self.alignCenterVButton, 1, 1) self.alignmentButtonFrame.layout().addWidget(self.alignRightButton, 1, 2) self.alignmentButtonFrame.layout().addWidget(self.alignTopButton, 2, 0) self.alignmentButtonFrame.layout().addWidget(self.alignCenterHButton, 2, 1) self.alignmentButtonFrame.layout().addWidget(self.alignBottomButton, 2, 2) self.alignmentButtonFrame.layout().addWidget(self.nudgeUpButton, 3, 1) self.alignmentButtonFrame.layout().addWidget(self.nudgeLeftButton, 4, 0) self.alignmentButtonFrame.layout().addWidget(self.nudgeDownButton, 4, 1) self.alignmentButtonFrame.layout().addWidget(self.nudgeRightButton, 4, 2) self.fileInfoName = QLabel("File Name : ") self.fileInfoName.setAlignment(Qt.AlignTop | Qt.AlignRight) self.fileInfoName.setMaximumWidth(self.LABEL_WIDTH) self.fileInfoName.setMinimumWidth(self.LABEL_WIDTH) self.activateMarkerLayout = QHBoxLayout() self.activateMarkerName = QLabel("Activate Marker : ") self.activateMarkerName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.activateMarkerName.setMaximumWidth(self.LABEL_WIDTH) self.activateMarkerName.setMinimumWidth(self.LABEL_WIDTH) self.activateMarkerCheckBox = QCheckBox() self.activateMarkerLayout.addWidget(self.activateMarkerName) self.activateMarkerLayout.addWidget(self.activateMarkerCheckBox) self.activateMarkerCheckBox.toggled.connect(self.markerActivated) self.currentGridUnitLayout = QHBoxLayout() self.currentGridUnitName = QLabel("Current Unit : ") self.currentGridUnitName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.currentGridUnitName.setMaximumWidth(self.LABEL_WIDTH) self.currentGridUnitName.setMinimumWidth(self.LABEL_WIDTH) self.currentGridUnitCombo = QComboBox() for item in (("mic", Eaglepy.GRID_UNIT_MIC), ("mm", Eaglepy.GRID_UNIT_MM), ("mil", Eaglepy.GRID_UNIT_MIL), ("inch", Eaglepy.GRID_UNIT_INCH)): self.currentGridUnitCombo.addItem(item[0], item[1]) self.currentGridUnitLayout.addWidget(self.currentGridUnitName) self.currentGridUnitLayout.addWidget(self.currentGridUnitCombo) self.currentGridValueLayout = QHBoxLayout() self.currentGridValueName = QLabel("Current Unit : ") self.currentGridValueName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.currentGridValueName.setMaximumWidth(self.LABEL_WIDTH) self.currentGridValueName.setMinimumWidth(self.LABEL_WIDTH) self.currentGridValueSpinBox = QDoubleSpinBox() self.currentGridValueSpinBox.setDecimals(6) self.currentGridValueSpinBox.setMinimum(0.000001) self.currentGridValueSpinBox.setMaximum(1000) self.currentGridValueSpinBox.setSingleStep(0.000001) self.currentGridValueLayout.addWidget(self.currentGridValueName) self.currentGridValueLayout.addWidget(self.currentGridValueSpinBox) self.distributeModeLayout = QHBoxLayout() self.distributeModeName = QLabel("Distribute Mode : ") self.distributeModeName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.distributeModeName.setMaximumWidth(self.LABEL_WIDTH) self.distributeModeName.setMinimumWidth(self.LABEL_WIDTH) self.distributeModeMinMax = QRadioButton("Min/Max") self.distributeModeMinMax.setChecked(True) self.distributeModeValues = QRadioButton("Values") self.distributeModeMinMax.toggled.connect(self.distributeModeChanged) self.distributeModeLayout.addWidget(self.distributeModeName) self.distributeModeLayout.addWidget(self.distributeModeMinMax) self.distributeModeLayout.addWidget(self.distributeModeValues) self.distributeValuesHorizontalLayout = QHBoxLayout() self.distributeValuesHorizontalName = QLabel("Distribute X Values : ") self.distributeValuesHorizontalName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.distributeValuesHorizontalName.setMaximumWidth(self.LABEL_WIDTH) self.distributeValuesHorizontalName.setMinimumWidth(self.LABEL_WIDTH) self.distributeValuesHorizontalMinSpinBox = QDoubleSpinBox() self.distributeValuesHorizontalMinSpinBox.setDecimals(6) self.distributeValuesHorizontalMinSpinBox.setMinimum(-1000) self.distributeValuesHorizontalMinSpinBox.setMaximum(1000) self.distributeValuesHorizontalMinSpinBox.setSingleStep(0.1) self.distributeValuesHorizontalMinSpinBox.setValue(0) self.distributeValuesHorizontalMaxSpinBox = QDoubleSpinBox() self.distributeValuesHorizontalMaxSpinBox.setDecimals(6) self.distributeValuesHorizontalMaxSpinBox.setMinimum(-1000) self.distributeValuesHorizontalMaxSpinBox.setMaximum(1000) self.distributeValuesHorizontalMaxSpinBox.setSingleStep(0.1) self.distributeValuesHorizontalMaxSpinBox.setValue(5) self.distributeValuesHorizontalMinSpinBox.valueChanged.connect( self.distributeValueChanged) self.distributeValuesHorizontalMaxSpinBox.valueChanged.connect( self.distributeValueChanged) self.distributeValuesHorizontalLayout.addWidget( self.distributeValuesHorizontalName) self.distributeValuesHorizontalLayout.addWidget( self.distributeValuesHorizontalMinSpinBox) self.distributeValuesHorizontalLayout.addWidget( self.distributeValuesHorizontalMaxSpinBox) self.distributeValuesVerticalLayout = QHBoxLayout() self.distributeValuesVerticalName = QLabel("Distribute Y Values : ") self.distributeValuesVerticalName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.distributeValuesVerticalName.setMaximumWidth(self.LABEL_WIDTH) self.distributeValuesVerticalName.setMinimumWidth(self.LABEL_WIDTH) self.distributeValuesVerticalMinSpinBox = QDoubleSpinBox() self.distributeValuesVerticalMinSpinBox.setDecimals(6) self.distributeValuesVerticalMinSpinBox.setMinimum(-1000) self.distributeValuesVerticalMinSpinBox.setMaximum(1000) self.distributeValuesVerticalMinSpinBox.setSingleStep(0.1) self.distributeValuesVerticalMinSpinBox.setValue(0) self.distributeValuesVerticalMaxSpinBox = QDoubleSpinBox() self.distributeValuesVerticalMaxSpinBox.setDecimals(6) self.distributeValuesVerticalMaxSpinBox.setMinimum(-1000) self.distributeValuesVerticalMaxSpinBox.setMaximum(1000) self.distributeValuesVerticalMaxSpinBox.setSingleStep(0.1) self.distributeValuesVerticalMaxSpinBox.setValue(5) self.distributeValuesVerticalMinSpinBox.valueChanged.connect( self.distributeValueChanged) self.distributeValuesVerticalMaxSpinBox.valueChanged.connect( self.distributeValueChanged) self.distributeValuesVerticalLayout.addWidget( self.distributeValuesVerticalName) self.distributeValuesVerticalLayout.addWidget( self.distributeValuesVerticalMinSpinBox) self.distributeValuesVerticalLayout.addWidget( self.distributeValuesVerticalMaxSpinBox) self.distributeGridLayout = QHBoxLayout() self.distributeGridName = QLabel("Grid Rows/Columns : ") self.distributeGridName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.distributeGridName.setMaximumWidth(self.LABEL_WIDTH) self.distributeGridName.setMinimumWidth(self.LABEL_WIDTH) self.distributeGridRowsSpinBox = QSpinBox() self.distributeGridRowsSpinBox.setMinimum(2) self.distributeGridRowsSpinBox.setMaximum(50) self.distributeGridColsSpinBox = QSpinBox() self.distributeGridColsSpinBox.setMinimum(2) self.distributeGridColsSpinBox.setMaximum(50) self.distributeGridLayout.addWidget(self.distributeGridName) self.distributeGridLayout.addWidget(self.distributeGridColsSpinBox) self.distributeGridLayout.addWidget(self.distributeGridRowsSpinBox) self.currentNudgeValueLayout = QHBoxLayout() self.currentNudgeValueName = QLabel("Nudge Value : ") self.currentNudgeValueName.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.currentNudgeValueName.setMaximumWidth(self.LABEL_WIDTH) self.currentNudgeValueName.setMinimumWidth(self.LABEL_WIDTH) self.currentNudgeValueSpinBox = QDoubleSpinBox() self.currentNudgeValueSpinBox.setDecimals(6) self.currentNudgeValueSpinBox.setMinimum(0.000001) self.currentNudgeValueSpinBox.setMaximum(10000) self.currentNudgeValueSpinBox.setSingleStep(0.000001) self.currentNudgeValueLayout.addWidget(self.currentNudgeValueName) self.currentNudgeValueLayout.addWidget(self.currentNudgeValueSpinBox) self.currentNudgeValueSpinBox.setValue(0.1) self.valuesLayout = QVBoxLayout() self.valuesLayout.addSpacerItem( QSpacerItem(50, 10, QSizePolicy.Fixed, QSizePolicy.Fixed)) self.valuesLayout.addLayout(self.activateMarkerLayout) self.valuesLayout.addLayout(self.currentGridUnitLayout) self.valuesLayout.addLayout(self.currentGridValueLayout) self.valuesLayout.addLayout(self.currentNudgeValueLayout) self.valuesLayout.addLayout(self.distributeModeLayout) self.valuesLayout.addLayout(self.distributeValuesHorizontalLayout) self.valuesLayout.addLayout(self.distributeValuesVerticalLayout) self.valuesLayout.addLayout(self.distributeGridLayout) self.valuesLayout.addSpacerItem( QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.outlinerTree = OutlinerTree() self.outlinerTree.setMinimumWidth(250) self.outlinerTree.setColumnWidth(0, 120) self.outlinerTree.setVisible(False) self.buttonLayout.addWidget(self.alignmentButtonFrame) self.buttonLayout.addSpacerItem( QSpacerItem(0, 100, QSizePolicy.Expanding, QSizePolicy.Maximum)) self.extrasButtonLayout = QVBoxLayout() self.extraOutlinerButton = setupButton(QPushButton("+"), "Show Outliner", 18, 18) self.extraOutlinerButton.clicked.connect(self.toggleOutliner) self.extrasButtonLayout.setAlignment(Qt.AlignHCenter) self.extrasButtonLayout.setSpacing(0) self.extrasButtonLayout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Fixed, QSizePolicy.Fixed)) self.extrasButtonLayout.addWidget(self.extraOutlinerButton) self.extrasButtonLayout.addSpacerItem( QSpacerItem(0, 500, QSizePolicy.Fixed, QSizePolicy.Expanding)) self.outlinerLayout = QVBoxLayout() self.outlinerLayout.setSpacing(0) self.outlinerLayout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Fixed, QSizePolicy.Fixed)) self.outlinerLayout.addWidget(self.outlinerTree) self.layout().addLayout(self.outlinerLayout) self.layout().addLayout(self.extrasButtonLayout) self.layout().addLayout(self.buttonLayout) self.layout().addLayout(self.valuesLayout) self.markerLast = (0, 0) self.layout().setSpacing(5) self.layout().setStretch(0, 0) self.layout().setStretch(1, 0) self.layout().setStretch(2, 0) self.layout().setStretch(3, 100) print "L" self.eaglegrid = Eaglepy.ULContext().grid() print "L2" currentUnit = self.eaglegrid.unit(Eaglepy.REFRESH_VALUE) currentValue = self.eaglegrid.distance(Eaglepy.REFRESH_VALUE) self.currentGridUnitCombo.setCurrentIndex(currentUnit) self.currentGridValueSpinBox.setValue(currentValue) self.updateSelection() self.outlinerTree.itemSelectionChanged.connect(self.updateSelection) self.currentGridUnitCombo.currentIndexChanged.connect( self.currentGridUnitChanged) self.currentGridValueSpinBox.valueChanged.connect( self.currentGridValueChanged) self.distributeModeChanged()