Skip to content

Commit

Permalink
clone image
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhin Yao committed Aug 4, 2020
1 parent ebbae4c commit e9b821e
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 60 deletions.
145 changes: 107 additions & 38 deletions MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,14 @@ def resolveJson(self):
self.cbox_4.setChecked(False)
self.cbox_5.setChecked(False)
self.cbox_6.setChecked(False)
self.cbox_7.setChecked(False)
self.spinBox_4.setValue(0)

#value
self.dic = self.readJson()
if self.dic == 0:
self.spinBox_1.setValue(0)
self.spinBox_2.setValue(0)
self.spinBox_2.setValue(1)
self.spinBox_3.setValue(0)
if self.ignore:
self.cbox_6.setChecked(True)
Expand All @@ -214,7 +216,10 @@ def resolveJson(self):
for i in range(len(item)):
if "blur" in item[i].keys():
self.blur_list.append(item[i])
self.cbox_1.setChecked(True)
if "rotation" in item[i].keys() and self.cbox_7.isChecked() == False:
self.cbox_7.setChecked(True)
if "rotation" not in item[i].keys() and self.cbox_1.isChecked() == False:
self.cbox_1.setChecked(True)
if "mediaId" in item[i].keys():
if "ignore" not in item[i].keys():
self.cell_list.append(item[i])
Expand All @@ -237,7 +242,8 @@ def resolveJson(self):
self.spinBox_1.setValue(len(self.cell_list))
self.spinBox_2.setValue(len(self.bg_list))
self.spinBox_3.setValue(len(self.text_list))
self.spinBox_4.setValue(len(self.blur_list))
if self.cbox_7.isChecked() == True:
self.spinBox_4.setValue(len(self.blur_list))

def initData(self):
self.handleData()
Expand All @@ -247,22 +253,36 @@ def initData(self):
if self.cbox_1.isChecked() == True:
self.tableWidget_1.setRowCount(self.spinBox_4.value())
for i in range(len(self.blur_list)):
self.tableWidget_1.setItem(i,7,QTableWidgetItem(self.blur_list[i]['id']))
self.tableWidget_1.setItem(i,8,QTableWidgetItem(self.blur_list[i]['type']))
self.tableWidget_1.setItem(i,4,QTableWidgetItem(str(self.blur_list[i]['blur'])))
self.tableWidget_1.setItem(i,6,QTableWidgetItem(self.blur_list[i]['id']))
self.tableWidget_1.setItem(i,7,QTableWidgetItem(self.blur_list[i]['type']))
self.tableWidget_1.setItem(i,0,QTableWidgetItem(str(self.blur_list[i]['blur'])))
self.tableWidget_1.setItem(i,5,QTableWidgetItem(self.blur_list[i]['refId']))
if "rotation" in self.blur_list[i].keys():
self.tableWidget_1.setItem(i,6,QTableWidgetItem(str(self.blur_list[i]['rotation'])))
else:
self.tableWidget_1.setItem(i, 6, QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,0,QTableWidgetItem(str(self.blur_list[i]['constraints']['left']['percentage'])))
self.tableWidget_1.setItem(i,9,QTableWidgetItem(str(self.blur_list[i]['constraints']['left']['constant'])))
self.tableWidget_1.setItem(i,1,QTableWidgetItem(str(self.blur_list[i]['constraints']['right']['percentage'])))
self.tableWidget_1.setItem(i,10,QTableWidgetItem(str(self.blur_list[i]['constraints']['right']['constant'])))
self.tableWidget_1.setItem(i,2,QTableWidgetItem(str(self.blur_list[i]['constraints']['top']['percentage'])))
self.tableWidget_1.setItem(i,11,QTableWidgetItem(str(self.blur_list[i]['constraints']['top']['constant'])))
self.tableWidget_1.setItem(i,3,QTableWidgetItem(str(self.blur_list[i]['constraints']['bottom']['percentage'])))
self.tableWidget_1.setItem(i,12,QTableWidgetItem(str(self.blur_list[i]['constraints']['bottom']['constant'])))
self.tableWidget_1.setItem(i,1,QTableWidgetItem(str(self.blur_list[i]['constraints']['left']['percentage'])))
self.tableWidget_1.setItem(i,8,QTableWidgetItem(str(self.blur_list[i]['constraints']['left']['constant'])))
self.tableWidget_1.setItem(i,2,QTableWidgetItem(str(self.blur_list[i]['constraints']['right']['percentage'])))
self.tableWidget_1.setItem(i,9,QTableWidgetItem(str(self.blur_list[i]['constraints']['right']['constant'])))
self.tableWidget_1.setItem(i,3,QTableWidgetItem(str(self.blur_list[i]['constraints']['top']['percentage'])))
self.tableWidget_1.setItem(i,10,QTableWidgetItem(str(self.blur_list[i]['constraints']['top']['constant'])))
self.tableWidget_1.setItem(i,4,QTableWidgetItem(str(self.blur_list[i]['constraints']['bottom']['percentage'])))
self.tableWidget_1.setItem(i,11,QTableWidgetItem(str(self.blur_list[i]['constraints']['bottom']['constant'])))

if self.cbox_7.isChecked() == True:
self.tableWidget_7.setRowCount(self.spinBox_4.value())
for i in range(len(self.blur_list)):
self.tableWidget_7.setItem(i,7,QTableWidgetItem(self.blur_list[i]['id']))
self.tableWidget_7.setItem(i,8,QTableWidgetItem(self.blur_list[i]['type']))
self.tableWidget_7.setItem(i,4,QTableWidgetItem(str(self.blur_list[i]['blur'])))
self.tableWidget_7.setItem(i,5,QTableWidgetItem(self.blur_list[i]['refId']))
self.tableWidget_7.setItem(i,6,QTableWidgetItem(str(self.blur_list[i]['rotation'])))
self.tableWidget_7.setItem(i,0,QTableWidgetItem(str(self.blur_list[i]['constraints']['left']['percentage'])))
self.tableWidget_7.setItem(i,9,QTableWidgetItem(str(self.blur_list[i]['constraints']['left']['constant'])))
self.tableWidget_7.setItem(i,1,QTableWidgetItem(str(self.blur_list[i]['constraints']['right']['percentage'])))
self.tableWidget_7.setItem(i,10,QTableWidgetItem(str(self.blur_list[i]['constraints']['right']['constant'])))
self.tableWidget_7.setItem(i,2,QTableWidgetItem(str(self.blur_list[i]['constraints']['top']['percentage'])))
self.tableWidget_7.setItem(i,11,QTableWidgetItem(str(self.blur_list[i]['constraints']['top']['constant'])))
self.tableWidget_7.setItem(i,3,QTableWidgetItem(str(self.blur_list[i]['constraints']['bottom']['percentage'])))
self.tableWidget_7.setItem(i,12,QTableWidgetItem(str(self.blur_list[i]['constraints']['bottom']['constant'])))

#赋值cell表
if self.spinBox_1.value() != 0:
if self.cbox_3.isChecked() == False:
Expand Down Expand Up @@ -500,17 +520,33 @@ def createTable(self):
self.initComBox()
name = self.comBox_2.currentText()
#初始化blur表
if self.cbox_1.isChecked() == True:
self.tableWidget_1.setRowCount(count_1)
for i in range(count_1):
self.tableWidget_1.setItem(i,7,QTableWidgetItem(str(i)))
self.tableWidget_1.setItem(i,8,QTableWidgetItem("image"))
# self.tableWidget_1.setItem(i,5,QTableWidgetItem(str(count_1)))
if self.cbox_1.isChecked() == True:
for i in range(1):
self.tableWidget_1.setItem(i,1,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,2,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,3,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,4,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,7,QTableWidgetItem("image"))
self.tableWidget_1.setItem(i,8,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,5,QTableWidgetItem(str("1")))
self.tableWidget_1.setItem(i,6,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,9,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,10,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,11,QTableWidgetItem("0"))
self.tableWidget_1.setItem(i,12,QTableWidgetItem("0"))
count_1 = 0

#初始化cloneimage表
if self.cbox_7.isChecked() == True:
self.tableWidget_7.setRowCount(count_1)
for i in range(count_1):
self.tableWidget_7.setItem(i,7,QTableWidgetItem(str(i)))
self.tableWidget_7.setItem(i,8,QTableWidgetItem("clone_image"))
self.tableWidget_7.setItem(i,6,QTableWidgetItem("0"))
self.tableWidget_7.setItem(i,9,QTableWidgetItem("0"))
self.tableWidget_7.setItem(i,10,QTableWidgetItem("0"))
self.tableWidget_7.setItem(i,11,QTableWidgetItem("0"))
self.tableWidget_7.setItem(i,12,QTableWidgetItem("0"))

#初始化cell表
if self.cbox_3.isChecked() == False:
self.tableWidget_2.setRowCount(count_2)
Expand Down Expand Up @@ -743,20 +779,53 @@ def tableValues(self):
if self.cbox_1.isChecked() == True:
for i in range(self.spinBox_4.value()):
blur_dic = {}
blur_dic["id"] = self.tableWidget_1.item(i, 7).text()
blur_dic["type"] = self.tableWidget_1.item(i, 8).text()
blur_dic["blur"] = int(self.tableWidget_1.item(i, 4).text())
blur_dic["id"] = self.tableWidget_1.item(i, 6).text()
blur_dic["type"] = self.tableWidget_1.item(i, 7).text()
blur_dic["blur"] = int(self.tableWidget_1.item(i, 0).text())
blur_dic["refId"] = self.tableWidget_1.item(i,5).text()
if self.tableWidget_1.item(i, 8).text() != "clone_image":
blur_dic["rotation"] = float(self.tableWidget_1.item(i, 6).text())
item_1 = self.tableWidget_1.item(i,0).text()
item_2 = self.tableWidget_1.item(i,9).text()
item_3 = self.tableWidget_1.item(i,1).text()
item_4 = self.tableWidget_1.item(i,10).text()
item_5 = self.tableWidget_1.item(i,2).text()
item_6 = self.tableWidget_1.item(i,11).text()
item_7 = self.tableWidget_1.item(i,3).text()
item_8 = self.tableWidget_1.item(i,12).text()
item_1 = self.tableWidget_1.item(i,1).text()
item_2 = self.tableWidget_1.item(i,8).text()
item_3 = self.tableWidget_1.item(i,2).text()
item_4 = self.tableWidget_1.item(i,9).text()
item_5 = self.tableWidget_1.item(i,3).text()
item_6 = self.tableWidget_1.item(i,10).text()
item_7 = self.tableWidget_1.item(i,4).text()
item_8 = self.tableWidget_1.item(i,11).text()
blur_dic["constraints"] = {"left":{
"percentage": float(item_1),
"constant": float(item_2)
},
"right":{
"percentage": float(item_3),
"constant": float(item_4)
},
"top":{
"percentage": float(item_5),
"constant": float(item_6)
},
"bottom":{
"percentage": float(item_7),
"constant": float(item_8)
}
}
self.item.append(blur_dic)

if self.cbox_7.isChecked() == True:
for i in range(self.spinBox_4.value()):
blur_dic = {}
blur_dic["id"] = self.tableWidget_7.item(i, 7).text()
blur_dic["type"] = self.tableWidget_7.item(i, 8).text()
blur_dic["blur"] = int(self.tableWidget_7.item(i, 4).text())
blur_dic["refId"] = self.tableWidget_7.item(i,5).text()
blur_dic["rotation"] = float(self.tableWidget_7.item(i, 6).text())
item_1 = self.tableWidget_7.item(i,0).text()
item_2 = self.tableWidget_7.item(i,9).text()
item_3 = self.tableWidget_7.item(i,1).text()
item_4 = self.tableWidget_7.item(i,10).text()
item_5 = self.tableWidget_7.item(i,2).text()
item_6 = self.tableWidget_7.item(i,11).text()
item_7 = self.tableWidget_7.item(i,3).text()
item_8 = self.tableWidget_7.item(i,12).text()
blur_dic["constraints"] = {"left":{
"percentage": float(item_1),
"constant": float(item_2)
Expand Down
102 changes: 81 additions & 21 deletions MainWindowUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def setupUi(self, MainWindow):
self.label_4.setObjectName("label_4")
self.spinBox_2 = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox_2.setGeometry(QtCore.QRect(485, 50, 100, 30))
self.spinBox_2.setValue(1)
# self.spinBox_2.setValue(1)

self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(685, 50, 60, 30))
Expand All @@ -107,15 +107,15 @@ def setupUi(self, MainWindow):
self.label_6.setAlignment(QtCore.Qt.AlignCenter)
self.label_6.setObjectName("label_6")
self.cbox_1 = QtWidgets.QCheckBox(self.centralwidget)
self.cbox_1.setGeometry(QtCore.QRect(155,110,100,30))
self.cbox_1.setGeometry(QtCore.QRect(155,150,100,30))
self.cbox_1.setText("背景虚化")
self.cbox_1.setObjectName("cbox_1")
self.spinBox_4 = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox_4.setGeometry(QtCore.QRect(265, 110, 50, 30))
self.spinBox_4.setValue(1)
# self.spinBox_4.setValue(1)

self.cbox_2 = QtWidgets.QCheckBox(self.centralwidget)
self.cbox_2.setGeometry(QtCore.QRect(155,150,100,30))
self.cbox_2.setGeometry(QtCore.QRect(265,150,100,30))
self.cbox_2.setText("图片重叠")
self.cbox_2.setObjectName("cbox_2")

Expand All @@ -129,6 +129,11 @@ def setupUi(self, MainWindow):
self.lineEdit_1.setObjectName("lineEdit_1")
self.lineEdit_1.setText("FFFFFF")

self.cbox_7 = QtWidgets.QCheckBox(self.centralwidget)
self.cbox_7.setGeometry(QtCore.QRect(155,110,100,30))
self.cbox_7.setText("图片复制")
self.cbox_7.setObjectName("cbox_7")

#第二行
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(545,150,100,30))
Expand Down Expand Up @@ -392,45 +397,43 @@ def initBlurTable(self):
self.tab_1 = QtWidgets.QWidget()
self.tab_1.setObjectName("tab_1")
self.tableWidget_1 = QtWidgets.QTableWidget(self.tab_1)
self.tableWidget_1.setColumnCount(13)
self.tableWidget_1.setColumnCount(12)
self.tableWidget_1.setGeometry(QtCore.QRect(0, 0, 1000, 450))
self.tableWidget_1.setObjectName("tableWidget_1")

for i in range(13):
for i in range(12):
item = QtWidgets.QTableWidgetItem()
self.tableWidget_1.setHorizontalHeaderItem(i, item)
self.tabWidget.addTab(self.tab_1, "")
#设置列宽
self.tableWidget_1.setColumnWidth(9,120)
self.tableWidget_1.setColumnWidth(10,120)
self.tableWidget_1.setColumnWidth(11,120)
#虚化背景表格的顶栏字段
_translate = QtCore.QCoreApplication.translate

item = self.tableWidget_1.horizontalHeaderItem(7)
item = self.tableWidget_1.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "总编号"))
item = self.tableWidget_1.horizontalHeaderItem(8)
item = self.tableWidget_1.horizontalHeaderItem(7)
item.setText(_translate("MainWindow", "类型"))
item = self.tableWidget_1.horizontalHeaderItem(4)
item = self.tableWidget_1.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "虚化")) #1,10
item = self.tableWidget_1.horizontalHeaderItem(5)
item.setText(_translate("MainWindow", "关联编号"))
item = self.tableWidget_1.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "旋转角度"))
item = self.tableWidget_1.horizontalHeaderItem(0)
item = self.tableWidget_1.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "左边距离"))
item = self.tableWidget_1.horizontalHeaderItem(9)
item = self.tableWidget_1.horizontalHeaderItem(8)
item.setText(_translate("MainWindow", "left_constant"))
item = self.tableWidget_1.horizontalHeaderItem(1)
item = self.tableWidget_1.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "右边距离"))
item = self.tableWidget_1.horizontalHeaderItem(10)
item = self.tableWidget_1.horizontalHeaderItem(9)
item.setText(_translate("MainWindow", "right_constant"))
item = self.tableWidget_1.horizontalHeaderItem(2)
item = self.tableWidget_1.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "顶部距离"))
item = self.tableWidget_1.horizontalHeaderItem(11)
item = self.tableWidget_1.horizontalHeaderItem(10)
item.setText(_translate("MainWindow", "top_constant"))
item = self.tableWidget_1.horizontalHeaderItem(3)
item = self.tableWidget_1.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "底部距离"))
item = self.tableWidget_1.horizontalHeaderItem(12)
item = self.tableWidget_1.horizontalHeaderItem(11)
item.setText(_translate("MainWindow", "bottom_constant"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_1), _translate("MainWindow", "背景虚化"))

Expand Down Expand Up @@ -899,6 +902,54 @@ def initDynamicTable(self):

self.tableWidget_6.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)

def initCloneImageTable(self):
self.tab_7 = QtWidgets.QWidget()
self.tab_7.setObjectName("tab_7")
self.tableWidget_7 = QtWidgets.QTableWidget(self.tab_7)
self.tableWidget_7.setColumnCount(13)
self.tableWidget_7.setGeometry(QtCore.QRect(0, 0, 1000, 450))
self.tableWidget_7.setObjectName("tableWidget_7")

for i in range(13):
item = QtWidgets.QTableWidgetItem()
self.tableWidget_7.setHorizontalHeaderItem(i, item)
self.tabWidget.addTab(self.tab_7, "")
#设置列宽
self.tableWidget_7.setColumnWidth(10,120)
self.tableWidget_7.setColumnWidth(11,120)
#虚化背景表格的顶栏字段
_translate = QtCore.QCoreApplication.translate

item = self.tableWidget_7.horizontalHeaderItem(7)
item.setText(_translate("MainWindow", "总编号"))
item = self.tableWidget_7.horizontalHeaderItem(8)
item.setText(_translate("MainWindow", "类型"))
item = self.tableWidget_7.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "虚化")) #1,10
item = self.tableWidget_7.horizontalHeaderItem(5)
item.setText(_translate("MainWindow", "关联编号"))
item = self.tableWidget_7.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "旋转角度"))
item = self.tableWidget_7.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "左边距离"))
item = self.tableWidget_7.horizontalHeaderItem(9)
item.setText(_translate("MainWindow", "left_constant"))
item = self.tableWidget_7.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "右边距离"))
item = self.tableWidget_7.horizontalHeaderItem(10)
item.setText(_translate("MainWindow", "right_constant"))
item = self.tableWidget_7.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "顶部距离"))
item = self.tableWidget_7.horizontalHeaderItem(11)
item.setText(_translate("MainWindow", "top_constant"))
item = self.tableWidget_7.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "底部距离"))
item = self.tableWidget_7.horizontalHeaderItem(12)
item.setText(_translate("MainWindow", "bottom_constant"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_7), _translate("MainWindow", "图片复制"))

self.tableWidget_7.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)

def initTable(self):
if self.index > 0:
self.tabWidget.close()
Expand All @@ -907,7 +958,7 @@ def initTable(self):
self.tabWidget.setObjectName("tabWidget")
#静态模版
#初始化普通模版的table
if self.cbox_1.isChecked() == False and self.cbox_2.isChecked() == False and self.cbox_3.isChecked() == False:
if self.cbox_1.isChecked() == False and self.cbox_2.isChecked() == False and self.cbox_7.isChecked() == False and self.cbox_3.isChecked() == False:
if self.spinBox_1.value() != 0:
self.initNormalCellTable()
if self.spinBox_3.value() != 0:
Expand All @@ -931,6 +982,15 @@ def initTable(self):
self.initNormalTextTable()
self.initLevelTable()
self.initNormalBgTable()

#初始化图片复制模版的table
if self.cbox_1.isChecked() ==False and self.cbox_2.isChecked() == False and self.cbox_7.isChecked() == True and self.cbox_3.isChecked() == False:
if self.spinBox_1.value() != 0:
self.initNormalCellTable()
if self.spinBox_3.value() != 0:
self.initNormalTextTable()
self.initCloneImageTable()
self.initNormalBgTable()


#动态模版
Expand Down
2 changes: 1 addition & 1 deletion resources/json/setting.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "/Volumes/Hello/workspace2"
"directory": "/Volumes/Hello/workspace_chic_static"
}

0 comments on commit e9b821e

Please sign in to comment.