Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions GUI/UI/cv.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,27 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="2" colspan="2">
<item row="3" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGraphicsView" name="graphicsView">
<property name="minimumSize">
<size>
<width>1296</width>
<height>970</height>
<width>600</width>
<height>600</height>
</size>
</property>
<property name="cursor" stdset="0">
Expand Down Expand Up @@ -96,13 +109,13 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'SimSun'; font-size:9pt;&quot;&gt;清晰度指数:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'SimSun'; font-size:9pt;&quot;&gt;纤芯直径(um):&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'SimSun'; font-size:9pt;&quot;&gt;包层直径(um):&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'SimSun'; font-size:9pt;&quot;&gt;纤芯不圆度:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'SimSun'; font-size:9pt;&quot;&gt;包层不圆度:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'SimSun'; font-size:9pt;&quot;&gt;芯包同心度(um):&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;清晰度指数:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;纤芯直径(um):&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;包层直径(um):&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;纤芯不圆度:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;包层不圆度:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;芯包同心度(um):&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -235,19 +248,6 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
Expand All @@ -256,7 +256,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>1809</width>
<height>37</height>
<height>23</height>
</rect>
</property>
</widget>
Expand Down
24 changes: 12 additions & 12 deletions GUI/UI/cvUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def setupUi(self, MainWindow):
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem, 3, 0, 1, 1)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.graphicsView = QtGui.QGraphicsView(self.centralwidget)
self.graphicsView.setMinimumSize(QtCore.QSize(1296, 970))
self.graphicsView.setMinimumSize(QtCore.QSize(600, 400))
self.graphicsView.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CrossCursor))
self.graphicsView.setMidLineWidth(0)
self.graphicsView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
Expand Down Expand Up @@ -123,12 +125,10 @@ def setupUi(self, MainWindow):
self.extendwidget.setObjectName(_fromUtf8("extendwidget"))
self.cvOperatorLayout.addWidget(self.extendwidget)
self.horizontalLayout.addLayout(self.cvOperatorLayout)
self.gridLayout_2.addLayout(self.horizontalLayout, 0, 0, 2, 2)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem, 2, 0, 1, 1)
self.gridLayout_2.addLayout(self.horizontalLayout, 2, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1809, 37))
self.menubar.setGeometry(QtCore.QRect(0, 0, 1809, 23))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
Expand All @@ -146,13 +146,13 @@ def retranslateUi(self, MainWindow):
self.resultShowCV.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; font-size:9pt;\">清晰度指数:</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; font-size:9pt;\">纤芯直径(um):</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; font-size:9pt;\">包层直径(um):</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; font-size:9pt;\">纤芯不圆度:</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; font-size:9pt;\">包层不圆度:</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; font-size:9pt;\">芯包同心度(um):</span></p></body></html>", None))
"</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">清晰度指数:</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">纤芯直径(um):</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">包层直径(um):</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">纤芯不圆度:</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">包层不圆度:</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">芯包同心度(um):</p></body></html>", None))
self.light.setText(_translate("MainWindow", "0.0", None))
self.label.setText(_translate("MainWindow", "光强:", None))
self.label_2.setText(_translate("MainWindow", "清晰度:", None))
Expand Down
4 changes: 2 additions & 2 deletions GUI/view/mplqt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def update_figure(self, x, h,y,v):
# lastprices, yellowlines = LastPrice[::20].copy(), YellowLine[::20]
# print 'plot len', len(numbers), len(lastprices), len(yellowlines)
self.axes.cla()
self.axes.plot(x,h,'y')
self.axes_twinx.plot(y,v,'r')
self.axes.plot(x,h,'y')#yellow line
self.axes_twinx.plot(y,v,'r')#red line
self.axes.set_facecolor('none')
self.draw()

Expand Down
2 changes: 2 additions & 0 deletions GUI/view/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from datetime import datetime as dt
from PyQt4.QtGui import QWidget, QFileDialog, QMessageBox
from report.pdf import writePdfabs
from setting.config import PDF_PARAMETER


def Reporter(father):
if not isinstance(father, QWidget):
Expand Down
4 changes: 2 additions & 2 deletions GUI/view/view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding:utf-8
import threading
from functools import partial

import cv2
from PyQt4.QtCore import QObject
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtGui import QWidget
Expand All @@ -22,7 +24,6 @@
import logging
logger = logging.getLogger(__name__)


class CVViewModel(object):
"""docstring for View"""

Expand Down Expand Up @@ -134,7 +135,6 @@ def writeReporterCV(self):
def relative_index_show(self, plots):
self.relative_index_canvas.update_figure(*plots)


class MyQGraphicsScene(QGraphicsScene):
def __init__(self):
QGraphicsScene.__init__(self)
Expand Down
Empty file added onefile/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions onefile/base_css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
table {
border-collapse: collapse;
width:70%;
border:1;
cellspacing:1;
cellpadding:0;
bgcolor: #000000;
border-color: #999999;
}
table, td, th {
border: 1px solid black;
}
td{
width:15%;
font-size:15px;
}
49 changes: 49 additions & 0 deletions onefile/convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import sys
from PyQt4.QtGui import QPrinter, QTextDocument, QApplication
from jinja2 import Environment, PackageLoader, select_autoescape
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

def to_html():
# print 'Base', BASE_DIR

env = Environment(
loader=PackageLoader('onefile', 'template'),
autoescape=select_autoescape(['html', 'xml'])
)

template = env.get_template('tabel.html')
# d = {"title":unicode("ssx", "utf-8")}
para={'title':"xxx",
'worker':"a",
'fibertype':"b",
'producer':"c",
'fiberNo':"d",
'corediameter':"e",
'claddiameter':"f",
'coreroundness':"g",
'cladroundness':"h",
'concentricity':"i",
'sharpindex':"j",
# lightindex=PDF_PARAMETER['lightindex'],
'date':"k",
'fiberLength':"1",
"src":"E:\Python\\fiberwmx\\fiberGeometry\onefile\img.jpg"
}
myhtml = template.render(**para)

return myhtml

def to_pdf(dir_,myhtml):
# try:
# app = QApplication(sys.argv)
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(dir_)
printer.setPageSize(QPrinter.A4)
text = QTextDocument()
text.setHtml(myhtml)
text.print_(printer)
# sys.exit(app.exec_())


71 changes: 71 additions & 0 deletions onefile/template/tabel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tabel</title>
<!--<style>-->
<!--table{-->
<!--border-collapse: collapse;-->
<!--}-->
<!--</style>-->

</head>
<body>

<h1 align="center">{{title}}</h1>
<div align="center">
<table width="100%"border="1"cellspacing="1"cellpadding="0">
<tr>
<th width="5%"rowspan="6"height="900"bgcolor="#e9faff"><h2>测试人员</h2></th>
<td width="20%">操作人员</td>
<td width="75%">{{worker}}</td>
</tr>
<tr>
<td width="20%">日期</td>
<td width="75%">{{date}}</td>
</tr>
<tr>
<td width="20%">光纤型号</td>
<td width="75%">{{fibertype}}</td>
</tr>
<tr>
<td width="20%">生产厂家</td>
<td width="75%">{{producer}}</td>
</tr>
<tr>
<td width="20%">光线编号</td>
<td width="75%">{{fiberNo}}</td>
</tr>
<tr>
<td width="20%">光纤长度</td>
<td width="75%">{{fiberLength}}</td>
</tr>
<tr >
<th width="5%"rowspan="5"height="900"bgcolor="#e9faff"><h2>测试结果</h2></th>
<td width="20%">纤芯直径</td>
<td width="75%">{{corediameter}}</td>
</tr>
<tr>
<td width="20%">包层直径</td>
<td width="75%">{{claddiameter}}</td>
</tr>
<tr >
<td width="20%">纤芯不圆度</td>
<td width="75%">{{coreroundness}}</td>
</tr>
<tr>
<td width="20%">包层不圆度</td>
<td width="75%">{{cladroundness}}</td>
</tr>
<tr >
<td width="20%">芯包同心度</td>
<td width="75%">{{concentricity}}</td>
</tr>
<tr>
<th width="5%"height="900"bgcolor="#e9faff"><h2>测试图片</h2></th>
<td align="center"colspan="2"><img src="{{src}}" alt="image"width="300"height="200"></td>
</tr>
</table>
</div>
</body>
</html>
16 changes: 16 additions & 0 deletions onefile/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys

import os
from PyQt4.QtGui import QApplication

from onefile.convert import to_html, to_pdf

if __name__ == '__main__':
os.system('del test_pdf\\test.pdf')
app = QApplication(sys.argv)
dir_ = "test_pdf\\test.pdf"
# myhtml = to_html()
with open("test_pdf\\test.html", 'r') as f:
myhtml = "".join(f.readlines())
to_pdf(dir_, myhtml)
sys.exit(app.exec_())
35 changes: 35 additions & 0 deletions report/first.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#coding=utf-8
from jinja2 import Environment, PackageLoader, select_autoescape

env = Environment(
loader=PackageLoader('report', 'template'),
autoescape=select_autoescape(['html', 'xml'])
)


template = env.get_template('template.html')

x= template.render(
title=u'测试',
worker= '1',
fibertype= '2',
producer= '3',
fiberNo='4',
corediameter= '5',
claddiameter= '6',
coreroundness= '7',
cladroundness= '8',
concentricity= '9',
sharpindex='10',
lightindex= '11',
date='12',
fiberLength= '13',
src="img\img.jpg"
)

print x
print type(x)
# x=str(x)
# y=x.decode("utf-8")
# print y
# print type(y)
Empty file added report/mypdf.py
Empty file.
Loading