hlp:荆州版本
This commit is contained in:
+125
-125
@@ -1,125 +1,125 @@
|
||||
/*
|
||||
* phaseGraphic.cpp
|
||||
*
|
||||
* Created on: Jun 29, 2013
|
||||
* Author: yiyu
|
||||
* QQ:1036184468
|
||||
* Descriptoin:
|
||||
|
||||
*/
|
||||
|
||||
#include "PhaseGraphic.h"
|
||||
#include "QPalette"
|
||||
#include <QPainter>
|
||||
PhaseGraphic::PhaseGraphic(QWidget *parent) :
|
||||
QWidget(parent){
|
||||
|
||||
pen.setStyle(Qt::SolidLine);
|
||||
pen.setWidth(2);
|
||||
pen.setBrush(Qt::red);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
pen.setJoinStyle(Qt::RoundJoin);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
setPalette(QPalette(Qt::white));
|
||||
setAutoFillBackground(true);
|
||||
setMinimumSize(626,150);
|
||||
lockPhaseFlag = false;
|
||||
lockedPhase = 0;
|
||||
phaseCount = 32;
|
||||
}
|
||||
PhaseGraphic::~PhaseGraphic(){
|
||||
|
||||
}
|
||||
|
||||
void PhaseGraphic::paintEvent(QPaintEvent *){
|
||||
if(sysPara){
|
||||
QString num;
|
||||
QRect rec = rect();
|
||||
int w = rec.width() - 30;
|
||||
int h = rec.height();
|
||||
int step = w/phaseCount;
|
||||
int high = h/3;
|
||||
int low = 2*h/3;
|
||||
int x_shift = 10;
|
||||
int current_x = x_shift;
|
||||
int phaseStep = sysPara->para.divideRatio*2/phaseCount;
|
||||
int currentPhase = 0;
|
||||
int phasePos = sysPara->para.divideRatio?w*sysPara->status.phase/(sysPara->para.divideRatio*2):0;
|
||||
int phasePosEdgePos = sysPara->status.phasePosEdge*w/phaseCount;
|
||||
int phaseNegEdgePos = sysPara->status.phaseNegEdge*w/phaseCount;
|
||||
int lockPhasePos = sysPara->para.divideRatio?w*lockedPhase/(sysPara->para.divideRatio*2):0;
|
||||
unsigned int maxPhaseDetectHighVoltageTm = 0;
|
||||
for(int i = 0;i < phaseCount; i++){
|
||||
if(sysPara->status.phaseDetectHighTm[i] > maxPhaseDetectHighVoltageTm)
|
||||
maxPhaseDetectHighVoltageTm = sysPara->status.phaseDetectHighTm[i];
|
||||
}
|
||||
QPainter p(this);
|
||||
pen.setBrush(Qt::red);
|
||||
p.setPen(pen);
|
||||
p.setBrush(brush);
|
||||
for(int i = 0; i < 8;i++){
|
||||
for(int j = 0;j < 8; j++){
|
||||
|
||||
if(sysPara->status.phaseChargeResult[i] & (1<<j)){
|
||||
p.drawLine ( current_x, high, current_x + step, high);
|
||||
}
|
||||
p.drawLine ( current_x, low, current_x + step, low);
|
||||
if(j == 0){ //标尺
|
||||
p.drawLine(current_x,low - 5,current_x,low + 5);
|
||||
num = QString::number(currentPhase);
|
||||
p.drawText(current_x - num.size()*4,low + 20,num);
|
||||
}
|
||||
int currPhaseDetectHighPos = maxPhaseDetectHighVoltageTm?sysPara->status.phaseDetectHighTm[i*8+j]*h/(3*maxPhaseDetectHighVoltageTm):0;
|
||||
int nextPhaseDetectHighPos = maxPhaseDetectHighVoltageTm?sysPara->status.phaseDetectHighTm[(i*8 + j + 1)%phaseCount]*h/(3*maxPhaseDetectHighVoltageTm):0;
|
||||
p.drawLine ( current_x, low - currPhaseDetectHighPos, current_x + step, low - nextPhaseDetectHighPos);
|
||||
current_x = (8*i + j + 1)*w/phaseCount + x_shift;
|
||||
currentPhase += phaseStep;
|
||||
}
|
||||
}
|
||||
|
||||
p.drawLine(current_x,low - 5,current_x,low + 5);
|
||||
num = QString::number(currentPhase);
|
||||
p.drawText(current_x - num.size()*4,low + 20,num); //做后的标尺
|
||||
num = QString::number(maxPhaseDetectHighVoltageTm);
|
||||
|
||||
p.drawText(x_shift + 10,high - 10,num); //给坐标画标尺
|
||||
|
||||
p.drawLine(phasePos + x_shift,low + 10,phasePos + x_shift,high - 10); //将相位尺标记一下
|
||||
pen.setBrush(Qt::blue);p.setPen(pen);
|
||||
p.drawLine(phasePosEdgePos + x_shift - 3,low + 10,phasePosEdgePos + x_shift + 3,low - 30);
|
||||
p.drawLine(phaseNegEdgePos + x_shift + 3,low + 10,phaseNegEdgePos + x_shift - 3,low - 30);
|
||||
if(lockPhaseFlag){
|
||||
pen.setBrush(Qt::green);p.setPen(pen);
|
||||
p.drawLine(lockPhasePos + x_shift,low + 5,lockPhasePos + x_shift,high - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PhaseGraphic::updateSysStatusToUI(){
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void PhaseGraphic::setLockedPhase(bool enable,int val){
|
||||
lockPhaseFlag = enable;
|
||||
lockedPhase = val;
|
||||
}
|
||||
|
||||
void PhaseGraphic::setPhaseCount(int count)
|
||||
{
|
||||
switch(count) {
|
||||
case 64:
|
||||
phaseCount = 64;
|
||||
break;
|
||||
case 32:
|
||||
phaseCount = 32;
|
||||
break;
|
||||
case 16:
|
||||
phaseCount = 16;
|
||||
break;
|
||||
default:
|
||||
phaseCount = 64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* phaseGraphic.cpp
|
||||
*
|
||||
* Created on: Jun 29, 2013
|
||||
* Author: yiyu
|
||||
* QQ:1036184468
|
||||
* Descriptoin:
|
||||
|
||||
*/
|
||||
|
||||
#include "PhaseGraphic.h"
|
||||
#include "QPalette"
|
||||
#include <QPainter>
|
||||
PhaseGraphic::PhaseGraphic(QWidget *parent) :
|
||||
QWidget(parent){
|
||||
|
||||
pen.setStyle(Qt::SolidLine);
|
||||
pen.setWidth(2);
|
||||
pen.setBrush(Qt::red);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
pen.setJoinStyle(Qt::RoundJoin);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
setPalette(QPalette(Qt::white));
|
||||
setAutoFillBackground(true);
|
||||
setMinimumSize(626,150);
|
||||
lockPhaseFlag = false;
|
||||
lockedPhase = 0;
|
||||
phaseCount = 32;
|
||||
}
|
||||
PhaseGraphic::~PhaseGraphic(){
|
||||
|
||||
}
|
||||
|
||||
void PhaseGraphic::paintEvent(QPaintEvent *){
|
||||
if(sysPara){
|
||||
QString num;
|
||||
QRect rec = rect();
|
||||
int w = rec.width() - 30;
|
||||
int h = rec.height();
|
||||
int step = w/phaseCount;
|
||||
int high = h/3;
|
||||
int low = 2*h/3;
|
||||
int x_shift = 10;
|
||||
int current_x = x_shift;
|
||||
int phaseStep = sysPara->para.divideRatio*2/phaseCount;
|
||||
int currentPhase = 0;
|
||||
int phasePos = sysPara->para.divideRatio?w*sysPara->status.phase/(sysPara->para.divideRatio*2):0;
|
||||
int phasePosEdgePos = sysPara->status.phasePosEdge*w/phaseCount;
|
||||
int phaseNegEdgePos = sysPara->status.phaseNegEdge*w/phaseCount;
|
||||
int lockPhasePos = sysPara->para.divideRatio?w*lockedPhase/(sysPara->para.divideRatio*2):0;
|
||||
unsigned int maxPhaseDetectHighVoltageTm = 0;
|
||||
for(int i = 0;i < phaseCount; i++){
|
||||
if(sysPara->status.phaseDetectHighTm[i] > maxPhaseDetectHighVoltageTm)
|
||||
maxPhaseDetectHighVoltageTm = sysPara->status.phaseDetectHighTm[i];
|
||||
}
|
||||
QPainter p(this);
|
||||
pen.setBrush(Qt::red);
|
||||
p.setPen(pen);
|
||||
p.setBrush(brush);
|
||||
for(int i = 0; i < 8;i++){
|
||||
for(int j = 0;j < 8; j++){
|
||||
|
||||
if(sysPara->status.phaseChargeResult[i] & (1<<j)){
|
||||
p.drawLine ( current_x, high, current_x + step, high);
|
||||
}
|
||||
p.drawLine ( current_x, low, current_x + step, low);
|
||||
if(j == 0){ //标尺
|
||||
p.drawLine(current_x,low - 5,current_x,low + 5);
|
||||
num = QString::number(currentPhase);
|
||||
p.drawText(current_x - num.size()*4,low + 20,num);
|
||||
}
|
||||
int currPhaseDetectHighPos = maxPhaseDetectHighVoltageTm?sysPara->status.phaseDetectHighTm[i*8+j]*h/(3*maxPhaseDetectHighVoltageTm):0;
|
||||
int nextPhaseDetectHighPos = maxPhaseDetectHighVoltageTm?sysPara->status.phaseDetectHighTm[(i*8 + j + 1)%phaseCount]*h/(3*maxPhaseDetectHighVoltageTm):0;
|
||||
p.drawLine ( current_x, low - currPhaseDetectHighPos, current_x + step, low - nextPhaseDetectHighPos);
|
||||
current_x = (8*i + j + 1)*w/phaseCount + x_shift;
|
||||
currentPhase += phaseStep;
|
||||
}
|
||||
}
|
||||
|
||||
p.drawLine(current_x,low - 5,current_x,low + 5);
|
||||
num = QString::number(currentPhase);
|
||||
p.drawText(current_x - num.size()*4,low + 20,num); //做后的标尺
|
||||
num = QString::number(maxPhaseDetectHighVoltageTm);
|
||||
|
||||
p.drawText(x_shift + 10,high - 10,num); //给坐标画标尺
|
||||
|
||||
p.drawLine(phasePos + x_shift,low + 10,phasePos + x_shift,high - 10); //将相位尺标记一下
|
||||
pen.setBrush(Qt::blue);p.setPen(pen);
|
||||
p.drawLine(phasePosEdgePos + x_shift - 3,low + 10,phasePosEdgePos + x_shift + 3,low - 30);
|
||||
p.drawLine(phaseNegEdgePos + x_shift + 3,low + 10,phaseNegEdgePos + x_shift - 3,low - 30);
|
||||
if(lockPhaseFlag){
|
||||
pen.setBrush(Qt::green);p.setPen(pen);
|
||||
p.drawLine(lockPhasePos + x_shift,low + 5,lockPhasePos + x_shift,high - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PhaseGraphic::updateSysStatusToUI(){
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void PhaseGraphic::setLockedPhase(bool enable,int val){
|
||||
lockPhaseFlag = enable;
|
||||
lockedPhase = val;
|
||||
}
|
||||
|
||||
void PhaseGraphic::setPhaseCount(int count)
|
||||
{
|
||||
switch(count) {
|
||||
case 64:
|
||||
phaseCount = 64;
|
||||
break;
|
||||
case 32:
|
||||
phaseCount = 32;
|
||||
break;
|
||||
case 16:
|
||||
phaseCount = 16;
|
||||
break;
|
||||
default:
|
||||
phaseCount = 64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user