Loading view/treeView.py +17 −24 Changes for view/treeView.py: 17 added lines, 24 removed lines. Original line number Diff line number Diff line Loading @@ -280,6 +280,7 @@ class TreeView(QGraphicsView): rightLine.setPen(branchPen) self.treeItemsGroup.addToGroup(leftLine) self.treeItemsGroup.addToGroup(rightLine) print("11111111111111") node = QGraphicsEllipseItem() node.setRect(tree.x * widthRatio - nodeWidth / 2, tree.y * heightRatio, nodeWidth, nodeWidth) node.setPen(nodePen) Loading @@ -288,44 +289,36 @@ class TreeView(QGraphicsView): self.drawTree2(tree.left, nodeWidth, lineWidth, heightRatio, widthRatio) self.drawTree2(tree.right, nodeWidth, lineWidth, heightRatio, widthRatio) else: if not isinstance(tree, IncompleteNode): node = QGraphicsEllipseItem() node.setRect(tree.x * widthRatio - nodeWidth / 2, tree.y * heightRatio, nodeWidth, nodeWidth) node.setPen(nodePen) node.setBrush(QColor(174, 214, 241)) self.treeItemsGroup.addToGroup(node) else: print("AAAAAAAAA") print(tree) if len(tree.children) > 0: for child in tree.children: line = QGraphicsLineItem() line.setLine(tree.x * widthRatio, tree.y * heightRatio + nodeWidth / 2, child.x * widthRatio, child.y * heightRatio) line.setPen(branchPen) self.treeItemsGroup.addToGroup(line) self.drawTree2(child, nodeWidth, lineWidth, heightRatio, widthRatio) if isinstance(tree, IncompleteNode): leaf = QGraphicsRectItem() leaf.setRect(tree.x * widthRatio, tree.y * heightRatio, nodeWidth, nodeWidth) leaf.setOpacity(0) self.treeItemsGroup.addToGroup(leaf) branchButton = BranchButton(self.controller, self.indexChildButton, 0.1 * nodeWidth, tree.x * widthRatio - nodeWidth / 2 - 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth) nodeWidth, tree.x * widthRatio + 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth) nodeButton = NodeButton(self.controller, self.indexChildButton, 0.1 * nodeWidth) self.indexChildButton += 1 nodeButton.setRect(tree.x * widthRatio + 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth, nodeWidth / 2 - 0.1 * nodeWidth) nodeButton.setRect(tree.x * widthRatio - nodeWidth / 2 - 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth, nodeWidth / 2 - 0.1 * nodeWidth) self.buttons.append(branchButton) self.buttons.append(nodeButton) self.scene().addItem(nodeButton) self.scene().addItem(branchButton) if len(tree.children) > 0: for child in tree.children: line = QGraphicsLineItem() line.setLine(tree.x * widthRatio, tree.y * heightRatio + nodeWidth / 2, child.x * widthRatio, child.y * heightRatio) line.setPen(branchPen) self.treeItemsGroup.addToGroup(line) else: node = QGraphicsEllipseItem() node.setRect(tree.x * widthRatio - nodeWidth / 2, tree.y * heightRatio, nodeWidth, nodeWidth) node.setPen(nodePen) node.setBrush(QColor(174, 214, 241)) self.treeItemsGroup.addToGroup(node) self.drawTree2(child, nodeWidth, lineWidth, heightRatio, widthRatio) class Clickable(QObject): Loading Loading @@ -397,8 +390,8 @@ class BranchButton(QGraphicsItemGroup): self.circlePen.setWidth(width) self.circle = QGraphicsEllipseItem(x, y, nodeWidth, nodeWidth) self.circle.setPen(self.circlePen) self.horizontalLine = QGraphicsLineItem() self.verticalLine = QGraphicsLineItem(x + nodeWidth / 2, y, x + nodeWidth / 2, y + nodeWidth) self.horizontalLine = QGraphicsLineItem(x + width + nodeWidth / 8, y + nodeWidth / 2, x + nodeWidth - width - nodeWidth / 8, y + nodeWidth / 2) self.verticalLine = QGraphicsLineItem(x + nodeWidth / 2, y + width + nodeWidth / 8, x + nodeWidth / 2, y + nodeWidth - width - nodeWidth / 8) self.horizontalLine.setPen(self.linePen) self.verticalLine.setPen(self.linePen) self.addToGroup(self.circle) Loading Loading
view/treeView.py +17 −24 Changes for view/treeView.py: 17 added lines, 24 removed lines. Original line number Diff line number Diff line Loading @@ -280,6 +280,7 @@ class TreeView(QGraphicsView): rightLine.setPen(branchPen) self.treeItemsGroup.addToGroup(leftLine) self.treeItemsGroup.addToGroup(rightLine) print("11111111111111") node = QGraphicsEllipseItem() node.setRect(tree.x * widthRatio - nodeWidth / 2, tree.y * heightRatio, nodeWidth, nodeWidth) node.setPen(nodePen) Loading @@ -288,44 +289,36 @@ class TreeView(QGraphicsView): self.drawTree2(tree.left, nodeWidth, lineWidth, heightRatio, widthRatio) self.drawTree2(tree.right, nodeWidth, lineWidth, heightRatio, widthRatio) else: if not isinstance(tree, IncompleteNode): node = QGraphicsEllipseItem() node.setRect(tree.x * widthRatio - nodeWidth / 2, tree.y * heightRatio, nodeWidth, nodeWidth) node.setPen(nodePen) node.setBrush(QColor(174, 214, 241)) self.treeItemsGroup.addToGroup(node) else: print("AAAAAAAAA") print(tree) if len(tree.children) > 0: for child in tree.children: line = QGraphicsLineItem() line.setLine(tree.x * widthRatio, tree.y * heightRatio + nodeWidth / 2, child.x * widthRatio, child.y * heightRatio) line.setPen(branchPen) self.treeItemsGroup.addToGroup(line) self.drawTree2(child, nodeWidth, lineWidth, heightRatio, widthRatio) if isinstance(tree, IncompleteNode): leaf = QGraphicsRectItem() leaf.setRect(tree.x * widthRatio, tree.y * heightRatio, nodeWidth, nodeWidth) leaf.setOpacity(0) self.treeItemsGroup.addToGroup(leaf) branchButton = BranchButton(self.controller, self.indexChildButton, 0.1 * nodeWidth, tree.x * widthRatio - nodeWidth / 2 - 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth) nodeWidth, tree.x * widthRatio + 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth) nodeButton = NodeButton(self.controller, self.indexChildButton, 0.1 * nodeWidth) self.indexChildButton += 1 nodeButton.setRect(tree.x * widthRatio + 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth, nodeWidth / 2 - 0.1 * nodeWidth) nodeButton.setRect(tree.x * widthRatio - nodeWidth / 2 - 0.05 * nodeWidth, tree.y * heightRatio + nodeWidth / 4, nodeWidth / 2 - 0.1 * nodeWidth, nodeWidth / 2 - 0.1 * nodeWidth) self.buttons.append(branchButton) self.buttons.append(nodeButton) self.scene().addItem(nodeButton) self.scene().addItem(branchButton) if len(tree.children) > 0: for child in tree.children: line = QGraphicsLineItem() line.setLine(tree.x * widthRatio, tree.y * heightRatio + nodeWidth / 2, child.x * widthRatio, child.y * heightRatio) line.setPen(branchPen) self.treeItemsGroup.addToGroup(line) else: node = QGraphicsEllipseItem() node.setRect(tree.x * widthRatio - nodeWidth / 2, tree.y * heightRatio, nodeWidth, nodeWidth) node.setPen(nodePen) node.setBrush(QColor(174, 214, 241)) self.treeItemsGroup.addToGroup(node) self.drawTree2(child, nodeWidth, lineWidth, heightRatio, widthRatio) class Clickable(QObject): Loading Loading @@ -397,8 +390,8 @@ class BranchButton(QGraphicsItemGroup): self.circlePen.setWidth(width) self.circle = QGraphicsEllipseItem(x, y, nodeWidth, nodeWidth) self.circle.setPen(self.circlePen) self.horizontalLine = QGraphicsLineItem() self.verticalLine = QGraphicsLineItem(x + nodeWidth / 2, y, x + nodeWidth / 2, y + nodeWidth) self.horizontalLine = QGraphicsLineItem(x + width + nodeWidth / 8, y + nodeWidth / 2, x + nodeWidth - width - nodeWidth / 8, y + nodeWidth / 2) self.verticalLine = QGraphicsLineItem(x + nodeWidth / 2, y + width + nodeWidth / 8, x + nodeWidth / 2, y + nodeWidth - width - nodeWidth / 8) self.horizontalLine.setPen(self.linePen) self.verticalLine.setPen(self.linePen) self.addToGroup(self.circle) Loading