1690 lines
51 KiB
C++
1690 lines
51 KiB
C++
#include "colorordersetwidget.h"
|
||
#include "ui_colorordersetwidget.h"
|
||
|
||
ColorOrderSetWidget::ColorOrderSetWidget(QWidget *parent) :
|
||
QWidget(parent),
|
||
ui(new Ui::ColorOrderSetWidget),
|
||
m_itemPerPage(72),
|
||
m_pEmbNeedleBtn(NULL),
|
||
m_pColorBtn(NULL)
|
||
{
|
||
ui->setupUi(this);
|
||
setWindowFlags (Qt::Window | Qt::FramelessWindowHint);
|
||
setWindowModality(Qt::ApplicationModal);
|
||
|
||
m_greyBeginStep = 0;//灰色起始
|
||
m_greyEndStep = 0; //灰色结束
|
||
|
||
ui->buttonColorSetLock->setVisible(false);
|
||
|
||
initWidget();
|
||
initPatternColorTable();
|
||
initControl();
|
||
refreshLockBtn();
|
||
}
|
||
|
||
ColorOrderSetWidget::~ColorOrderSetWidget()
|
||
{
|
||
if(m_pCurEmbData != NULL)
|
||
{
|
||
delete m_pCurEmbData;
|
||
}
|
||
delete ui;
|
||
}
|
||
|
||
void ColorOrderSetWidget::initWidget()
|
||
{
|
||
m_pCurEmbData = new EmbData();
|
||
m_pCurEmbData->initColor(g_pSettings->getColorRgbArray().size(),(QRgb*)g_pSettings->getColorRgbArray().data());
|
||
|
||
m_colorBeginStepCtrl = 0;
|
||
m_colorEndStepCtrl = 0;
|
||
m_curSelectColor = -1;
|
||
m_curPages = 1;
|
||
m_pageNums = 1;
|
||
m_colorNums = 0;
|
||
m_colorSetBtnLockFlag = 1;//锁住
|
||
m_setType = TYPE_COLORSET;
|
||
m_fileType = FILE_TYPE_DST;
|
||
ui->frameGear->setVisible(false);
|
||
ui->buttonValue->setEnabled(false);
|
||
m_singleMulMode = 0;
|
||
|
||
m_pColorBuf = (QRgb *)(g_pSettings->getColorRgbArray().data());
|
||
m_buttonStyle1 = "QPushButton{outline: none;border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;";
|
||
m_buttonStyle2 = "QPushButton:checked{outline: none;border:3px groove rgb(80,80,80);}";
|
||
|
||
m_buttonColorOrderList.clear();//色序按钮
|
||
for(int i = 0; i < m_itemPerPage; i++)
|
||
{
|
||
MyButton *buttonColorOrder = new MyButton(ui->frameColorOrder);
|
||
m_buttonColorOrderList.append(buttonColorOrder);
|
||
connect(buttonColorOrder,
|
||
SIGNAL(clicked()),
|
||
this,
|
||
SLOT(colorOrderBtnClick())
|
||
);
|
||
}
|
||
|
||
m_buttonEmbNeedleList.clear();//针杆按钮
|
||
for(int i = 0; i < 32; i++)
|
||
{
|
||
QPushButton *buttonEmbNeedle = new QPushButton(ui->frameColorOrder);
|
||
m_buttonEmbNeedleList.append(buttonEmbNeedle);
|
||
connect(buttonEmbNeedle,
|
||
SIGNAL(pressed()),
|
||
this,
|
||
SLOT(embNeedleBtnPressed()));
|
||
|
||
connect(buttonEmbNeedle,
|
||
SIGNAL(released()),
|
||
this,
|
||
SLOT(embNeedleBtnReleased()));
|
||
}
|
||
|
||
//定制冲孔机有6个冲刀深度显示
|
||
m_buttonPunchDepthList.clear();
|
||
for(int i = 0; i < 6; i++)
|
||
{
|
||
QPushButton *buttonEmbNeedle = new QPushButton(ui->frameColorOrder);
|
||
m_buttonPunchDepthList.append(buttonEmbNeedle);
|
||
connect(buttonEmbNeedle,
|
||
SIGNAL(clicked()),
|
||
this,
|
||
SLOT(punchDepthBtnClick())
|
||
);
|
||
m_buttonPunchDepthList[i]->hide();
|
||
double value = g_pSettings->readFromIniFile("AUFUS/punchDepth"+QString::number(i)).toDouble();
|
||
m_buttonPunchDepthList[i]->setText(QString::number(value,'f',2));
|
||
m_buttonPunchDepthList[i]->setFont(fontNormal_1);
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::initControl()
|
||
{
|
||
//根据不同分辨率设置控件的位置和尺寸
|
||
switch (g_emResolut)
|
||
{
|
||
case resolution1910:
|
||
initResolution1910();
|
||
break;
|
||
case resolution1006:
|
||
initResolution1006();
|
||
break;
|
||
default:
|
||
this->resize(1920,1080);
|
||
break;
|
||
}
|
||
|
||
initControlStyle();//初始化窗体控件样式
|
||
}
|
||
|
||
void ColorOrderSetWidget::initResolution1910()
|
||
{
|
||
this->resize(1920,1080);
|
||
ui->frameBack->setGeometry(0,0,1920,1080);
|
||
|
||
ui->buttonTypeLogo->setGeometry(128,66,78,78);
|
||
ui->labelMainTitle->setGeometry(226,60,400,44);
|
||
ui->labelSubTitle->setGeometry(302,112,1000,36);
|
||
|
||
ui->frameRightUp->setGeometry(1130,92,768,72);
|
||
ui->buttonColorOrderClear->setGeometry(692,0,66,66);
|
||
ui->buttonColorOrderCycle->setGeometry(604,0,66,66);
|
||
ui->buttonColorSetLock->setGeometry(516,0,66,66);
|
||
|
||
ui->frameColorOrder->setGeometry(84,220,1344,704);
|
||
ui->buttonNeedle->setGeometry(0,0,200,52);
|
||
|
||
QRect rectImage(0,0,88,52);
|
||
QRect rectName(28,47,44,28);
|
||
QRect rectValue(0,0,88,52);
|
||
for(int i = 0; i < 6; i++)
|
||
{
|
||
int num = m_buttonColorOrderList.size()/6;
|
||
for(int j = 0; j < num; j++)
|
||
{
|
||
m_buttonColorOrderList[i*num+j]->setGeometry(j*114,220+i*82,88,80);
|
||
m_buttonColorOrderList[i*num+j]->initUpImageDownName(rectImage,rectName);
|
||
m_buttonColorOrderList[i*num+j]->initLabelValue(rectValue);
|
||
m_buttonColorOrderList[i*num+j]->setLabelNameFont(fontNormal_3);
|
||
m_buttonColorOrderList[i*num+j]->setLabelValueFont(fontNormal_1);
|
||
m_buttonColorOrderList[i*num+j]->setStyleSheet("border:0px;outline:none;");//无边框、无焦点
|
||
}
|
||
}
|
||
|
||
for(int i = 0; i < 6; i++)
|
||
{
|
||
m_buttonPunchDepthList[i]->setGeometry(i*114+228,220-156,88,52);//下边控件的大小
|
||
}
|
||
|
||
for(int i = 0; i < 3; i++)
|
||
{
|
||
int num,xSp,idx;
|
||
if(i == 0)
|
||
{
|
||
num = 10;//第一行10个
|
||
xSp = 228;
|
||
idx = 0;
|
||
}
|
||
else if(i == 1)
|
||
{
|
||
num = 12;//第二行12个
|
||
xSp = 0;
|
||
idx = 10;
|
||
}
|
||
else if(i == 2)
|
||
{
|
||
num = 10;//第三行10个
|
||
xSp = 0;
|
||
idx = 22;
|
||
}
|
||
for(int j = 0; j < num; j++)
|
||
{
|
||
m_buttonEmbNeedleList[idx+j]->setGeometry(xSp+j*114,i*70,88,52);
|
||
m_buttonEmbNeedleList[idx+j]->setFont(fontNormal_1);
|
||
m_buttonEmbNeedleList[idx+j]->setText(QString::number(idx+j+1));
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
m_buttonEmbNeedleList[idx+j]->hide();
|
||
}
|
||
}
|
||
}
|
||
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
ui->frameGear->setVisible(true);
|
||
ui->frameGear->setGeometry(300,0,600,80);
|
||
|
||
ui->buttonSingle->setGeometry(4,0,88,76);
|
||
ui->buttonSingle->setFont(fontNormal_1);
|
||
|
||
ui->buttonMul->setGeometry(120,0,88,76);
|
||
ui->buttonMul->setFont(fontNormal_1);
|
||
|
||
ui->buttonValue->setGeometry(220,0,88,76);
|
||
ui->buttonValue->setFont(fontNormal_1);
|
||
}
|
||
|
||
ui->labelPatternView->setGeometry(1536,220,302,302);
|
||
ui->labelNameValue->setGeometry(1538,564,400,36);
|
||
ui->labelTotalNeedle->setGeometry(1538,604,200,36);
|
||
ui->labelTotalNeedleValue->setGeometry(1760,604,94,36);
|
||
ui->labelTotalColor->setGeometry(1538,644,200,36);
|
||
ui->labelTotalColorValue->setGeometry(1760,644,94,36);
|
||
ui->labelCurColorNum->setGeometry(1538,684,200,36);
|
||
ui->labelCurColorNumValue->setGeometry(1760,684,94,36);
|
||
ui->labelBeginIdx->setGeometry(1538,724,200,36);
|
||
ui->labelBeginIdxValue->setGeometry(1760,724,94,36);
|
||
ui->labelEndIdx->setGeometry(1538,764,200,36);
|
||
ui->labelEndIdxValue->setGeometry(1760,764,94,36);
|
||
ui->labelNeedleSelect->setGeometry(1538,804,180,36);
|
||
ui->labelNeedleSelectValue->setGeometry(1655,804,200,36);
|
||
|
||
ui->framePageBtn->setGeometry(1120,990,800,70);
|
||
ui->labelPage->setGeometry(32,1008,400,40);
|
||
ui->buttonPgUp->setGeometry(0,0,168,70);
|
||
ui->buttonPgDn->setGeometry(200,0,168,70);
|
||
ui->buttonOk->setGeometry(400,0,168,70);
|
||
ui->buttonCancel->setGeometry(600,0,168,70);
|
||
}
|
||
|
||
void ColorOrderSetWidget::initResolution1006()
|
||
{
|
||
this->resize(1024,600);
|
||
ui->frameBack->setGeometry(0,0,1024,600);
|
||
|
||
ui->buttonTypeLogo->setGeometry(25,30,60,60);
|
||
ui->labelMainTitle->setGeometry(100,30,200,24);
|
||
ui->labelSubTitle->setGeometry(130,64,240,21);
|
||
|
||
ui->frameRightUp->setGeometry(560,40,857,61);
|
||
ui->buttonColorOrderClear->setGeometry(399,0,50,50);
|
||
ui->buttonColorOrderCycle->setGeometry(342,0,50,50);
|
||
ui->buttonColorSetLock->setGeometry(285,0,50,50);
|
||
|
||
ui->frameColorOrder->setGeometry(20,120,740,420);
|
||
ui->buttonNeedle->setGeometry(24,0,110,32);
|
||
QRect rectImage(0,0,56,32);//下边颜色图片的大小和位置
|
||
QRect rectName(18,30,28,16);//数字
|
||
QRect rectValue(0,0,56,32);//下边颜色图片里的文字
|
||
for(int i = 0; i < 6; i++)
|
||
{
|
||
int num = m_buttonColorOrderList.size()/6;
|
||
for(int j = 0; j < num; j++)
|
||
{
|
||
m_buttonColorOrderList[i*num+j]->setGeometry(25+j*60,124+i*50,56,46);//下边控件的大小
|
||
m_buttonColorOrderList[i*num+j]->initUpImageDownName(rectImage,rectName);
|
||
m_buttonColorOrderList[i*num+j]->initLabelValue(rectValue);
|
||
m_buttonColorOrderList[i*num+j]->setLabelNameFont(fontNormal_1);
|
||
m_buttonColorOrderList[i*num+j]->setLabelValueFont(fontNormal_1);
|
||
m_buttonColorOrderList[i*num+j]->setStyleSheet("border:0px;outline:none;");//无边框、无焦点
|
||
}
|
||
}
|
||
|
||
for(int i = 0; i < 6; i++)
|
||
{
|
||
m_buttonPunchDepthList[i]->setGeometry(25+i*60+120,124-90,56,32);//下边控件的大小
|
||
}
|
||
|
||
for(int i = 0; i < 3; i++)
|
||
{
|
||
int num,xSp,idx;
|
||
if(i == 0)
|
||
{
|
||
num = 10;//第一行10个
|
||
xSp = 145;
|
||
idx = 0;
|
||
}
|
||
else if(i == 1)
|
||
{
|
||
num = 12;//第二行12个
|
||
xSp = 25;
|
||
idx = 10;
|
||
}
|
||
else if(i == 2)
|
||
{
|
||
num = 10;//第三行10个
|
||
xSp = 25;
|
||
idx = 22;
|
||
}
|
||
for(int j = 0; j < num; j++)
|
||
{
|
||
m_buttonEmbNeedleList[idx+j]->setGeometry(xSp+j*60,i*38,56,32);//上边颜色的大小
|
||
m_buttonEmbNeedleList[idx+j]->setFont(fontNormal_1);
|
||
m_buttonEmbNeedleList[idx+j]->setText(QString::number(idx+j+1));
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
m_buttonEmbNeedleList[idx+j]->hide();
|
||
}
|
||
}
|
||
}
|
||
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
ui->frameGear->setVisible(true);
|
||
ui->frameGear->setGeometry(120,0,400,80);
|
||
|
||
ui->buttonSingle->setGeometry(4,0,56,40);
|
||
ui->buttonSingle->setFont(fontNormal_1);
|
||
|
||
ui->buttonMul->setGeometry(96,0,56,40);
|
||
ui->buttonMul->setFont(fontNormal_1);
|
||
|
||
ui->buttonValue->setGeometry(160,0,56,40);
|
||
ui->buttonValue->setFont(fontNormal_1);
|
||
}
|
||
|
||
ui->labelPatternView->setGeometry(790,98,220,220);
|
||
ui->labelNameValue->setGeometry(816,320,141,20);
|
||
ui->labelTotalNeedle->setGeometry(816,350,141,20);
|
||
ui->labelTotalNeedleValue->setGeometry(895,350,91,20);
|
||
ui->labelTotalColor->setGeometry(816,375,91,20);
|
||
ui->labelTotalColorValue->setGeometry(895,375,91,20);
|
||
ui->labelCurColorNum->setGeometry(816,400,91,20);
|
||
ui->labelCurColorNumValue->setGeometry(895,400,91,20);
|
||
ui->labelBeginIdx->setGeometry(816,425,91,20);
|
||
ui->labelBeginIdxValue->setGeometry(895,425,91,20);
|
||
ui->labelEndIdx->setGeometry(816,450,91,20);
|
||
ui->labelEndIdxValue->setGeometry(895,450,91,20);
|
||
ui->labelNeedleSelect->setGeometry(816,475,91,20);
|
||
ui->labelNeedleSelectValue->setGeometry(895,475,91,20);
|
||
|
||
ui->framePageBtn->setGeometry(595,545,600,40);
|
||
ui->labelPage->setGeometry(20,550,102,45);
|
||
ui->buttonPgUp->setGeometry(0,0,96,40);
|
||
ui->buttonPgDn->setGeometry(106,0,96,40);
|
||
ui->buttonOk->setGeometry(212,0,96,40);
|
||
ui->buttonCancel->setGeometry(318,0,96,40);
|
||
}
|
||
|
||
void ColorOrderSetWidget::initControlStyle()
|
||
{
|
||
SetControlStyle setControlStyle;
|
||
setControlStyle.setUiName(this->objectName());
|
||
|
||
//背景图
|
||
QString frameBackImgPath = setControlStyle.getStyleSheet(this->objectName());
|
||
ui->frameBack->setStyleSheet(frameBackImgPath);
|
||
ui->frameColorOrder->setStyleSheet(TRANSPARENTSTYLE);
|
||
ui->frameGear->setStyleSheet(TRANSPARENTSTYLE);
|
||
|
||
//label样式
|
||
ui->labelMainTitle->setFont(fontBold_1);
|
||
ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelSubTitle->setFont(fontNormal_1);
|
||
ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelPage->setFont(fontNormal_1);
|
||
ui->labelPage->setStyleSheet(LABELWHITESTYLE);
|
||
ui->buttonNeedle->setFont(fontNormal_6);
|
||
ui->labelPatternView->setStyleSheet(TRANSPARENTSTYLE);
|
||
ui->labelNameValue->setFont(fontNormal_6);
|
||
ui->labelNameValue->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelTotalNeedle->setFont(fontNormal_6);
|
||
ui->labelTotalNeedle->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelTotalNeedleValue->setFont(fontNormal_6);
|
||
ui->labelTotalNeedleValue->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelTotalColor->setFont(fontNormal_6);
|
||
ui->labelTotalColor->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelTotalColorValue->setFont(fontNormal_6);
|
||
ui->labelTotalColorValue->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelCurColorNum->setFont(fontNormal_6);
|
||
ui->labelCurColorNum->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelCurColorNumValue->setFont(fontNormal_6);
|
||
ui->labelCurColorNumValue->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelBeginIdx->setFont(fontNormal_6);
|
||
ui->labelBeginIdx->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelBeginIdxValue->setFont(fontNormal_6);
|
||
ui->labelBeginIdxValue->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelEndIdx->setFont(fontNormal_6);
|
||
ui->labelEndIdx->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelEndIdxValue->setFont(fontNormal_6);
|
||
ui->labelEndIdxValue->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelNeedleSelect->setFont(fontNormal_6);
|
||
ui->labelNeedleSelect->setStyleSheet(LABELWHITESTYLE);
|
||
ui->labelNeedleSelectValue->setFont(fontNormal_6);
|
||
ui->labelNeedleSelectValue->setStyleSheet(LABELWHITESTYLE);
|
||
|
||
ui->framePageBtn->setStyleSheet(TRANSPARENTSTYLE);
|
||
|
||
//右上方
|
||
ui->frameRightUp->setStyleSheet(TRANSPARENTSTYLE);
|
||
ui->buttonColorOrderClear->setGreenGradientBottomStyle(BORDER_RADIUS1);
|
||
ui->buttonColorOrderClear->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonColorOrderClear->objectName()));
|
||
ui->buttonColorOrderCycle->setGreenGradientBottomStyle(BORDER_RADIUS1);
|
||
ui->buttonColorOrderCycle->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonColorOrderCycle->objectName()));
|
||
ui->buttonColorSetLock->setGreenGradientBottomStyle(BORDER_RADIUS1);
|
||
|
||
//四个按钮样式表一样
|
||
ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2);
|
||
ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12);
|
||
|
||
ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2);
|
||
ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12);
|
||
|
||
ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2);
|
||
ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12);
|
||
|
||
ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2);
|
||
ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12);
|
||
}
|
||
|
||
void ColorOrderSetWidget::initPatternColorTable()
|
||
{
|
||
//设置颜色列表(针杆色序表)
|
||
for(int i = 0; i < TOTAL_NEEDLE_NUM; i++)
|
||
{
|
||
QString idxStr;
|
||
idxStr.clear();
|
||
//绣花针杆
|
||
if(i >= 0 && i <= EMB_NEEDLE_NUM - 1)
|
||
{
|
||
idxStr = "EmbNeedle/"+QString::number(i+1)+"_coloridx";
|
||
}
|
||
//冲孔针杆
|
||
else if(i >= (EMB_NEEDLE_NUM - 1) && i < (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM))
|
||
{
|
||
int punchIdx = i + 1 - EMB_NEEDLE_NUM;
|
||
idxStr = "PunchNeedle/"+QString::number(punchIdx)+"_coloridx";
|
||
}
|
||
//缝纫针杆
|
||
else if(i == EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM)
|
||
{
|
||
int sewIdx = i + 1 - EMB_NEEDLE_NUM - PUNCH_NEEDLE_NUM;
|
||
idxStr = "SewNeedle/"+QString::number(sewIdx)+"_coloridx";
|
||
}
|
||
if(g_pSettings->ifKeyExists(idxStr) == true)
|
||
{
|
||
int idx = g_pSettings->readFromIniFile(idxStr).toInt();
|
||
m_pCurEmbData->setNeedleColorTable(i,idx);
|
||
}
|
||
else
|
||
{
|
||
m_pCurEmbData->setNeedleColorTable(i,i);
|
||
}
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::initNeedleBar()
|
||
{
|
||
//读入配置
|
||
QDir apppath(qApp->applicationDirPath());
|
||
|
||
//配置文件路径
|
||
QString configFile = apppath.path() + apppath.separator() + "config.ini";
|
||
QFile iniFile(configFile);
|
||
|
||
int highFlag = g_pSettings->readFromIniFile("AUFUS/highSpeed").toInt();
|
||
|
||
int num,idx;
|
||
if(!iniFile.exists())
|
||
{
|
||
num = 1;
|
||
idx = 0;
|
||
|
||
QRgb rgb = m_pColorBuf[(idx % BF_SW_ND)];
|
||
rgb |= 0xff000000;
|
||
QColor bkcolor(rgb);
|
||
QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
|
||
QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
|
||
+ " color:" + tcolor.name() + ";";
|
||
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
if(i < num)
|
||
{
|
||
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
|
||
|
||
m_buttonEmbNeedleList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
|
||
m_buttonEmbNeedleList.at(i)->show();
|
||
}
|
||
else
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->hide();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
QRgb rgb = qRgb(0,255,0);
|
||
switchNeedleNum(num);//显示当前色序所选的针杆
|
||
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
QString idxStr;
|
||
idxStr = getNeedleColorStr(i+1);
|
||
|
||
if(g_pSettings->ifKeyExists(idxStr) == true)
|
||
{
|
||
idx = g_pSettings->readFromIniFile(idxStr).toInt();
|
||
rgb = m_pColorBuf[(idx % BF_SW_ND)];
|
||
}
|
||
else
|
||
{
|
||
rgb = m_pColorBuf[(i % MC_SW_ND)];
|
||
}
|
||
rgb |= 0xff000000;
|
||
QColor bkcolor(rgb);
|
||
QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
|
||
QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
|
||
+ " color:" + tcolor.name() + ";";
|
||
if(i < num)
|
||
{
|
||
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
|
||
|
||
//属于冲缝绣才显示针杆设置按钮,因为有的色序里只有偏移针步
|
||
if(m_colorBeginStepCtrl == DATA_SEWING ||
|
||
m_colorBeginStepCtrl == DATA_EMB ||
|
||
m_colorBeginStepCtrl == DATA_PUNCH ||
|
||
m_colorBeginStepCtrl == 0)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
|
||
m_buttonEmbNeedleList.at(i)->show();
|
||
|
||
if(highFlag == 1)
|
||
{
|
||
if(i < m_buttonPunchDepthList.size())
|
||
{
|
||
m_buttonPunchDepthList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
|
||
m_buttonPunchDepthList.at(i)->show();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->hide();
|
||
|
||
if(highFlag == 1)
|
||
{
|
||
if(i < m_buttonPunchDepthList.size())
|
||
{
|
||
m_buttonPunchDepthList.at(i)->hide();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->hide();
|
||
|
||
if(highFlag == 1)
|
||
{
|
||
if(i < m_buttonPunchDepthList.size())
|
||
{
|
||
m_buttonPunchDepthList.at(i)->hide();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->setChecked(false);
|
||
m_buttonEmbNeedleList.at(i)->setCheckable(false);
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::switchNeedleBar()
|
||
{
|
||
//读入配置
|
||
QDir apppath(qApp->applicationDirPath());
|
||
|
||
//配置文件路径
|
||
QString configFile = apppath.path() + apppath.separator() + "config.ini";
|
||
QFile iniFile(configFile);
|
||
|
||
int num,idx;
|
||
num = 0;
|
||
if(!iniFile.exists())
|
||
{
|
||
num = 1;
|
||
idx = 0;
|
||
|
||
QRgb rgb = m_pColorBuf[(idx % BF_SW_ND)];
|
||
rgb |= 0xff000000;
|
||
QColor bkcolor(rgb);
|
||
QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
|
||
QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
|
||
+ " color:" + tcolor.name() + ";";
|
||
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
if(i < num)
|
||
{
|
||
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
|
||
m_buttonEmbNeedleList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
|
||
//压胶机时隐藏,不显示
|
||
if(g_emMacType != MACHINE_ADHESIVE)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->show();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->hide();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
QRgb rgb = qRgb(0,255,0);
|
||
|
||
if(m_colorBeginStepCtrl == DATA_PUNCH)//冲孔
|
||
{
|
||
num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Punch (P):"));//冲孔(P):
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_EMB)//绣花
|
||
{
|
||
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Emb (P):"));//绣花(E):
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_SEWING)//缝纫
|
||
{
|
||
num = g_pSettings->readFromIniFile("SewNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Sew (S):"));//缝纫(S):
|
||
}
|
||
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
ui->buttonNeedle->setText(tr("Gear:"));//档位:
|
||
}
|
||
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
QString idxStr;
|
||
idxStr = getNeedleColorStr(i+1);
|
||
|
||
if(g_pSettings->ifKeyExists(idxStr) == true)
|
||
{
|
||
idx = g_pSettings->readFromIniFile(idxStr).toInt();
|
||
rgb = m_pColorBuf[(idx % BF_SW_ND)];
|
||
}
|
||
else
|
||
{
|
||
rgb = m_pColorBuf[(i % MC_SW_ND)];
|
||
}
|
||
rgb |= 0xff000000;
|
||
QColor bkcolor(rgb);
|
||
QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
|
||
QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
|
||
+ " color:" + tcolor.name() + ";";
|
||
if(i < num)
|
||
{
|
||
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
|
||
//属于冲缝绣,毛巾针步才显示针杆设置按钮,因为有的色序里只有偏移针步
|
||
if(m_colorBeginStepCtrl == DATA_SEWING ||
|
||
m_colorBeginStepCtrl == DATA_EMB ||
|
||
m_colorBeginStepCtrl == DATA_PUNCH ||
|
||
m_colorBeginStepCtrl == 0)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
|
||
//压胶机时隐藏,不显示
|
||
if(g_emMacType != MACHINE_ADHESIVE)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->show();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->hide();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->hide();
|
||
}
|
||
}
|
||
}
|
||
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->setChecked(false);
|
||
m_buttonEmbNeedleList.at(i)->setCheckable(false);
|
||
}
|
||
}
|
||
|
||
//刷新色序显示
|
||
void ColorOrderSetWidget::refreshColorShow()
|
||
{
|
||
QString str;
|
||
QString strNeedle;
|
||
|
||
int num = 0;
|
||
getNeedleNum(num);//获取配置文件针杆数量
|
||
|
||
int colorNum = m_colorNums;
|
||
m_pageNums = (colorNum + m_itemPerPage - 1)/m_itemPerPage;// 计算页数
|
||
if (m_curPages > m_pageNums)// 当前页
|
||
{
|
||
m_curPages = m_pageNums;
|
||
}
|
||
if (m_curPages <= 1 && colorNum != 0)
|
||
{
|
||
m_curPages = 1;
|
||
}
|
||
|
||
int colorIdx = (m_curPages-1) * m_itemPerPage;
|
||
if(colorIdx < 0)
|
||
{
|
||
colorIdx = 0;
|
||
}
|
||
|
||
for (int i = 0; i < m_itemPerPage; i++)
|
||
{
|
||
// 颜色显示
|
||
if (colorIdx < colorNum)
|
||
{
|
||
s16 needleIdx = m_colorTable.at(colorIdx);//花版里的第一个色序
|
||
strNeedle = getCurColorTabStr(needleIdx);
|
||
s16 needleIdxCp = needleIdx;
|
||
|
||
//不等于压胶机时
|
||
if(g_emMacType != MACHINE_ADHESIVE)
|
||
{
|
||
getCurColorTabValue(needleIdx);
|
||
}
|
||
|
||
QString idxStr;
|
||
idxStr = getNeedleColorStr(needleIdxCp,needleIdx);//needleIdx 针杆索引
|
||
|
||
s16 colorInTab;
|
||
if(g_pSettings->ifKeyExists(idxStr) == true)
|
||
{
|
||
colorInTab = g_pSettings->readFromIniFile(idxStr).toInt();
|
||
}
|
||
else
|
||
{
|
||
colorInTab = m_colorTable.at(colorIdx);
|
||
getCurColorTabValue(colorInTab);
|
||
colorInTab -= 1;
|
||
if(colorInTab < 0){colorInTab = 0;}
|
||
}
|
||
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
colorInTab = m_colorTable.at(colorIdx);
|
||
}
|
||
|
||
// 文件中的色序
|
||
QRgb rgb = m_pColorBuf[(colorInTab % BF_SW_ND)];
|
||
rgb |= 0xff000000;
|
||
QColor bkcolor(rgb);
|
||
QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
|
||
QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
|
||
+ " color:" + tcolor.name() + ";";
|
||
|
||
m_buttonColorOrderList.at(i)->setImageBackColor(cstyle);
|
||
|
||
QString cstyle1 = "outline: none;background-color:rgba(255, 255, 255, 0);color:" + tcolor.name() + ";";
|
||
m_buttonColorOrderList.at(i)->setLabelValueStyle(cstyle1);
|
||
if(needleIdx <= 0)
|
||
{
|
||
m_buttonColorOrderList.at(i)->setLabelValue("");//色序里的数字是空
|
||
}
|
||
else
|
||
{
|
||
m_buttonColorOrderList.at(i)->setLabelValue(strNeedle+QString::number(needleIdx));
|
||
}
|
||
|
||
str.sprintf("%d", colorIdx+1);
|
||
|
||
if(g_emMacType == MACHINE_PUNCH_AUTOPOS)
|
||
{
|
||
if( i < 256)
|
||
{
|
||
//int size = m_colorTable.length();
|
||
int val = m_colorTable.at(TABLE_HEIGHT_IDX+i)-EMB_NEEDLE_NUM-1;
|
||
for(int m = 0; m < 10; m++)
|
||
{
|
||
if(m <= val && val <= (m*10 + 9))
|
||
{
|
||
str = QString::number(m)+"." + QString::number(val-m*10);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//下方的色序按钮
|
||
//设置数字 花版里的色序个数
|
||
m_buttonColorOrderList.at(i)->setLabelName(str);
|
||
m_buttonColorOrderList.at(i)->show();
|
||
|
||
//选择显示
|
||
if (colorIdx == m_curSelectColor)
|
||
{
|
||
m_buttonColorOrderList.at(i)->setLabelImageChecked(cstyle);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_buttonColorOrderList.at(i)->setLabelName("");
|
||
m_buttonColorOrderList.at(i)->hide();
|
||
}
|
||
colorIdx++;
|
||
}
|
||
|
||
// 翻页按钮
|
||
if (m_curPages <= 1)
|
||
{
|
||
ui->buttonPgUp->setEnabled(false);
|
||
}
|
||
else
|
||
{
|
||
ui->buttonPgUp->setEnabled(true);
|
||
}
|
||
if (m_curPages >= m_pageNums)
|
||
{
|
||
ui->buttonPgDn->setEnabled(false);
|
||
}
|
||
else
|
||
{
|
||
ui->buttonPgDn->setEnabled(true);
|
||
}
|
||
|
||
// 页信息
|
||
if(m_pageNums == 0)
|
||
{
|
||
m_curPages = 0;
|
||
}
|
||
|
||
QString pStr = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数:
|
||
ui->labelPage->setText(pStr);
|
||
}
|
||
|
||
//刷新花样选中的色序显示(刷新花样部分线迹)
|
||
void ColorOrderSetWidget::refreshPatternCurColorShow()
|
||
{
|
||
if(m_curSelectColor < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
int beginIdx, endIdx;
|
||
|
||
if(m_colorTable.size() == 1)//只有一个换色
|
||
{
|
||
endIdx = m_pCurEmbData->getStitchNums();
|
||
m_pCurEmbData->getNeedleIdxFromColorIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
|
||
beginIdx = 1;
|
||
}
|
||
else
|
||
{
|
||
if(m_curSelectColor+1 <= m_colorNums)//当前选择颜色数等于总的颜色数
|
||
{
|
||
//获取起始针步和换色后第一个针步的针步属性(非跳针跨步等)
|
||
m_pCurEmbData->getNeedleIdxFromColorIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
|
||
}
|
||
|
||
if(m_curSelectColor+1 >= m_colorNums)//当前选择颜色数等于总的颜色数
|
||
{
|
||
endIdx = m_pCurEmbData->getStitchNums();
|
||
}
|
||
else
|
||
{
|
||
m_pCurEmbData->getNeedleIdxFromColorIdx(endIdx, m_curSelectColor+2, m_colorEndStepCtrl);
|
||
}
|
||
}
|
||
|
||
m_pCurEmbData->setGreyAreaRange(m_greyBeginStep,m_greyEndStep);
|
||
m_pCurEmbData->setDispAreaRange(beginIdx,endIdx,0);
|
||
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1); // 重新画灰图
|
||
|
||
m_greyBeginStep = beginIdx;//灰色起始
|
||
m_greyEndStep = endIdx; //灰色结束
|
||
|
||
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
|
||
ui->labelPatternView->setPixmap(patternPix);
|
||
|
||
ui->labelCurColorNumValue->setText(QString::number(m_curSelectColor+1));
|
||
ui->labelBeginIdxValue->setText(QString::number(beginIdx));
|
||
ui->labelEndIdxValue->setText(QString::number(endIdx));
|
||
|
||
//根据 beginStepCtrl 切换到相应针杆设置
|
||
int num = 0;
|
||
getNeedleNum(num);
|
||
|
||
s16 selIdx = m_colorTable[m_curSelectColor];
|
||
int idx = selIdx;
|
||
getCurColorTabValue(selIdx);
|
||
|
||
QString str;
|
||
if(selIdx <= 0)
|
||
{
|
||
str = tr("Not set");//未设置
|
||
}
|
||
else
|
||
{
|
||
QString typeStr;
|
||
typeStr = getCurColorTabStr(idx);
|
||
str = typeStr + QString::number(selIdx);//针杆
|
||
}
|
||
ui->labelNeedleSelectValue->setText(str);// 右下角显示当前色序的针杆
|
||
ui->buttonColorSetLock->setEnabled(true);//右上方色序设定解锁按钮可按
|
||
}
|
||
|
||
//获取配置文件针杆数量
|
||
void ColorOrderSetWidget::getNeedleNum(int &num)
|
||
{
|
||
if(m_colorBeginStepCtrl == 0)//界面没打开的时候,进来这个里边
|
||
{
|
||
num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Punch (P):"));//冲孔
|
||
return;
|
||
}
|
||
|
||
if(m_colorBeginStepCtrl == DATA_SEWING)//缝纫
|
||
{
|
||
num = g_pSettings->readFromIniFile("SewNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Sew (S):"));//缝纫
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_PUNCH)//冲孔
|
||
{
|
||
num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Punch (P):"));//冲孔
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_EMB)//绣花
|
||
{
|
||
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Emb (E):"));//绣花
|
||
}
|
||
else if(m_colorBeginStepCtrl == 0)
|
||
{
|
||
num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Punch (P):"));//冲孔
|
||
}
|
||
else
|
||
{
|
||
//非冲缝绣针步
|
||
ui->buttonNeedle->setText(tr("Non needle step"));//非下针针步
|
||
}
|
||
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
ui->buttonNeedle->setText(tr("Gear:"));//档位
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::switchNeedleNum(int &num)
|
||
{
|
||
//m_curSelectColor 花版中的第几个色序
|
||
//m_colorTable 色序表
|
||
//selIdx 色序表里的色序 0就是没有色序
|
||
if(m_colorTable.size() <= 0)
|
||
{
|
||
return;
|
||
}
|
||
int selIdx = m_colorTable[m_curSelectColor];
|
||
|
||
if(selIdx > EMB_NEEDLE_NUM+PUNCH_NEEDLE_NUM)//缝纫
|
||
{
|
||
num = g_pSettings->readFromIniFile("SewNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Sew (S):"));//缝纫
|
||
m_colorBeginStepCtrl = DATA_SEWING;
|
||
}
|
||
else if(selIdx > EMB_NEEDLE_NUM)//冲孔
|
||
{
|
||
num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Punch (P):"));//冲孔
|
||
m_colorBeginStepCtrl = DATA_PUNCH;
|
||
}
|
||
else
|
||
{
|
||
if(selIdx > 0)
|
||
{
|
||
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
|
||
ui->buttonNeedle->setText(tr("Emb (E):"));//绣花
|
||
m_colorBeginStepCtrl = DATA_EMB;
|
||
}
|
||
else
|
||
{
|
||
if(m_colorBeginStepCtrl == DATA_PUNCH)
|
||
{
|
||
num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_SEWING)
|
||
{
|
||
num = g_pSettings->readFromIniFile("SewNeedle/number").toInt();
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_EMB)
|
||
{
|
||
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
|
||
}
|
||
else
|
||
{
|
||
num = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
ui->buttonNeedle->setText(tr("Gear:"));//档位:
|
||
}
|
||
}
|
||
|
||
//获取配置文件针杆颜色索引字符
|
||
QString ColorOrderSetWidget::getNeedleColorStr(s16 idx)
|
||
{
|
||
QString idxStr;
|
||
idxStr.clear();
|
||
|
||
if(m_colorBeginStepCtrl == DATA_EMB)//绣花
|
||
{
|
||
idxStr = "EmbNeedle/"+QString::number(idx)+"_coloridx";//绣花
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_PUNCH)//冲孔
|
||
{
|
||
idxStr = "PunchNeedle/"+QString::number(idx)+"_coloridx";//冲孔
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_SEWING)//缝纫
|
||
{
|
||
idxStr = "SewNeedle/"+QString::number(idx)+"_coloridx";//缝纫
|
||
}
|
||
else
|
||
{
|
||
idxStr = "PunchNeedle/"+QString::number(idx)+"_coloridx";//冲孔
|
||
}
|
||
|
||
return idxStr;
|
||
}
|
||
|
||
QString ColorOrderSetWidget::getNeedleColorStr(s16 colorIdx, s16 idx)
|
||
{
|
||
QString idxStr;
|
||
idxStr.clear();
|
||
|
||
if(colorIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM)//缝纫
|
||
{
|
||
idxStr = "SewNeedle/";
|
||
}
|
||
else if(colorIdx > EMB_NEEDLE_NUM)//冲孔
|
||
{
|
||
idxStr = "PunchNeedle/";
|
||
}
|
||
else
|
||
{
|
||
idxStr = "EmbNeedle/";
|
||
}
|
||
|
||
idxStr += QString::number(idx)+"_coloridx";
|
||
|
||
return idxStr;
|
||
}
|
||
|
||
//刷新色序锁定按钮
|
||
void ColorOrderSetWidget::refreshLockBtn()
|
||
{
|
||
SetControlStyle setControlStyle;
|
||
setControlStyle.setUiName(this->objectName());
|
||
if(m_colorSetBtnLockFlag == 1)//锁住
|
||
{
|
||
ui->buttonColorSetLock->setCheckable(true);
|
||
ui->buttonColorSetLock->setChecked(true);
|
||
ui->buttonColorSetLock->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonColorSetLock->objectName()));
|
||
ui->buttonNeedle->setStyleSheet(LABELWHITESTYLE);
|
||
ui->buttonNeedle->setEnabled(false);//针杆按钮不可按
|
||
}
|
||
else//解锁
|
||
{
|
||
ui->buttonColorSetLock->setChecked(false);
|
||
ui->buttonColorSetLock->setCheckable(false);
|
||
ui->buttonColorSetLock->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonColorSetLock->objectName()+"_unlock"));
|
||
ui->buttonNeedle->setStyleSheet(BUTTONWHITESTYLE);
|
||
ui->buttonNeedle->setEnabled(true);//针杆按钮可按
|
||
}
|
||
}
|
||
|
||
QString ColorOrderSetWidget::getCurColorTabStr(s16 needleIdx)
|
||
{
|
||
QString strNeedle;
|
||
strNeedle.clear();
|
||
|
||
if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM)//缝纫
|
||
{
|
||
strNeedle = tr("S");
|
||
}
|
||
else if(needleIdx > EMB_NEEDLE_NUM)//冲孔
|
||
{
|
||
strNeedle = tr("P");
|
||
}
|
||
else
|
||
{
|
||
strNeedle = tr("E");
|
||
}
|
||
|
||
//等于压胶机
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
strNeedle = tr("G");
|
||
}
|
||
|
||
return strNeedle;
|
||
}
|
||
|
||
void ColorOrderSetWidget::getCurColorTabValue(s16 &colorInTab)
|
||
{
|
||
if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM)//缝纫
|
||
{
|
||
colorInTab -= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM;
|
||
}
|
||
else if(colorInTab > EMB_NEEDLE_NUM)//冲孔
|
||
{
|
||
colorInTab -= EMB_NEEDLE_NUM;
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::showPunchShape(QString filePath)
|
||
{
|
||
DataFileDsr dsr;
|
||
int ret = dsr.createPunchShapeData(filePath);
|
||
|
||
if(ret < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
int num = g_pSettings->readFromIniFile("PunchNeedle/number").toInt();
|
||
|
||
for(int i = 0; i < num; i++)
|
||
{
|
||
QLabel *pcLabel=new QLabel(ui->frameColorOrder);
|
||
|
||
int widthImg,heightImg;
|
||
if(i >= 0 && i <= 9)//仅一排
|
||
{
|
||
if(g_emResolut == resolution1910)
|
||
{
|
||
pcLabel->setGeometry(250+i*42+i*72,120,68,68);
|
||
widthImg = pcLabel->width()-5;
|
||
heightImg = pcLabel->height()-5;
|
||
}
|
||
else if(g_emResolut == resolution1006)
|
||
{
|
||
pcLabel->setGeometry(150+i*42+i*18,70,42,42);//42是单个控件高度,18是控件间距
|
||
widthImg = pcLabel->width()-5;
|
||
heightImg = pcLabel->height()-5;
|
||
}
|
||
}
|
||
|
||
QImage Image(widthImg,heightImg, QImage::Format_ARGB32);
|
||
dsr.createPunchShapeImage(&Image,i);
|
||
pcLabel->setPixmap(QPixmap::fromImage(Image));
|
||
pcLabel->show();
|
||
}
|
||
}
|
||
|
||
//设置类型图标
|
||
void ColorOrderSetWidget::setTypeLogo(QString tStyle)
|
||
{
|
||
ui->buttonTypeLogo->setUnPreBtnLogo(tStyle);
|
||
}
|
||
|
||
//设置主title
|
||
void ColorOrderSetWidget::setMainTitle(QString str)
|
||
{
|
||
ui->labelMainTitle->setText(str);
|
||
}
|
||
|
||
void ColorOrderSetWidget::setSubTitle(QString str)
|
||
{
|
||
ui->labelSubTitle->setText(str);
|
||
}
|
||
|
||
void ColorOrderSetWidget::show(QString filePath)
|
||
{
|
||
m_colorSetBtnLockFlag = 1;//锁住
|
||
refreshLockBtn();
|
||
|
||
m_singleMulMode = 0;
|
||
ui->buttonSingle->setCheckable(true);
|
||
ui->buttonSingle->setChecked(true);
|
||
ui->buttonMul->setChecked(false);
|
||
ui->buttonMul->setCheckable(false);
|
||
|
||
QFileInfo file(filePath);
|
||
QString ext = file.suffix().toUpper();
|
||
|
||
m_pCurEmbData->setViewInfo(ui->labelPatternView->width(),ui->labelPatternView->height());
|
||
m_pCurEmbData->clear();
|
||
|
||
if(ext == "DST")//dst文件
|
||
{
|
||
DataFileDst dst;
|
||
dst.initFile(filePath);
|
||
dst.convertDataToAbs();
|
||
m_pCurEmbData->appendAbsFile(filePath,dst.getEmbAbsData());//生成文件信息
|
||
//m_colorTable.resize(dst.getColorNums());
|
||
m_colorNums = dst.getColorNums();
|
||
}
|
||
else if(ext == "DSR")//dsr文件
|
||
{
|
||
DataFileDsr dsr;
|
||
dsr.initFile(filePath);
|
||
dsr.convertDataToEmbAbs();
|
||
m_pCurEmbData->appendAbsFile(filePath,dsr.getEmbAbsData());//生成文件信息
|
||
//m_colorTable.resize(dsr.getColorNums());
|
||
m_colorNums = dsr.getColorNums();
|
||
}
|
||
|
||
m_pCurEmbData->getDsDat();
|
||
//转换为ds16数据后设置色序表
|
||
m_pCurEmbData->setDs16ColorOfTable((u8*)m_colorTable.data());
|
||
m_pCurEmbData->setEmbData();
|
||
m_greyBeginStep = 0;//灰色起始
|
||
m_greyEndStep = m_pCurEmbData->getStitchNums(); //灰色结束
|
||
|
||
QFileInfo info(filePath);
|
||
QString fileName = info.fileName();
|
||
int size = fileName.length();
|
||
if(size > NAMEMAXLENGTH+12)//花样名称过长时截取
|
||
{
|
||
fileName = fileName.mid(0,NAMEMAXLENGTH+12) + "~";
|
||
}
|
||
ui->labelNameValue->setText(fileName);
|
||
if(size <= 0)//未选择文件时
|
||
{
|
||
ui->labelTotalNeedleValue->setText("");
|
||
ui->labelTotalColorValue->setText("");
|
||
}
|
||
else
|
||
{
|
||
ui->labelTotalNeedleValue->setText(QString::number(m_pCurEmbData->getStitchNums()));
|
||
ui->labelTotalColor->setText(tr("Total color:"));//总颜色数:
|
||
ui->labelTotalColorValue->setText(QString::number(m_pCurEmbData->getColorNums()));
|
||
}
|
||
|
||
m_curSelectColor = 0;
|
||
if(m_buttonColorOrderList.size() > 0)
|
||
{
|
||
m_pColorBtn = m_buttonColorOrderList.at(0);//默认选中(等于)第一个色序按钮
|
||
}
|
||
refreshPatternCurColorShow();
|
||
refreshColorShow();
|
||
//不等于压胶机时
|
||
if(g_emMacType != MACHINE_ADHESIVE)
|
||
{
|
||
initNeedleBar();
|
||
}
|
||
|
||
if(g_emMacType == MACHINE_PUNCH_AUTOPOS)
|
||
{
|
||
showPunchShape(filePath);
|
||
}
|
||
|
||
#if(0)
|
||
ui->labelCurColorNumValue->setText("");
|
||
ui->labelBeginIdxValue->setText("");
|
||
ui->labelEndIdxValue->setText("");
|
||
ui->labelNeedleSelectValue->setText("");
|
||
#endif
|
||
|
||
QWidget::show();
|
||
}
|
||
|
||
void ColorOrderSetWidget::setColorTable(QByteArray table, int type)
|
||
{
|
||
ui->labelCurColorNum->setText(tr("Color num:"));//当前色序:
|
||
ui->labelNeedleSelect->setText(tr("Punch:"));//冲孔:
|
||
m_setType = type;
|
||
|
||
m_beforeColorTable.clear();
|
||
m_colorTable.clear();
|
||
|
||
if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
m_beforeColorTable.append(table.data()+TABLE_HEIGHT_IDX,table.length()-TABLE_HEIGHT_IDX);
|
||
m_colorTable.append(table.data()+TABLE_HEIGHT_IDX,table.length()-TABLE_HEIGHT_IDX);
|
||
}
|
||
else
|
||
{
|
||
m_beforeColorTable.append(table);
|
||
m_colorTable.append(table);
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::colorOrderBtnClick()
|
||
{
|
||
int idx = 0;
|
||
m_pColorBtn = (MyButton*) this->sender();
|
||
|
||
if(m_pColorBtn == NULL)
|
||
{
|
||
return;
|
||
}
|
||
for(int i = 0; i < m_buttonColorOrderList.size(); i++)
|
||
{
|
||
if(m_pColorBtn == m_buttonColorOrderList.at(i))
|
||
{
|
||
idx = i;
|
||
}
|
||
}
|
||
|
||
m_curSelectColor = (m_curPages - 1) * m_itemPerPage + idx;
|
||
|
||
//针杆按钮不选中
|
||
if(m_pEmbNeedleBtn != NULL)
|
||
{
|
||
m_pEmbNeedleBtn->setChecked(false);
|
||
m_pEmbNeedleBtn->setCheckable(false);
|
||
}
|
||
|
||
int minVal = 0;
|
||
int maxVal = 0;
|
||
int defVal = 0;
|
||
|
||
if(m_setType == TYPE_COLORSET)//色序设定
|
||
{
|
||
minVal = 1;
|
||
maxVal = 255;
|
||
defVal = 10;
|
||
}
|
||
else if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
minVal = -127;
|
||
maxVal = 127;
|
||
defVal = 0;
|
||
}
|
||
|
||
//等于压胶机时
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
int idx = 0;
|
||
if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
idx = TABLE_HEIGHT_IDX;
|
||
}
|
||
if(m_singleMulMode == 0)//单选
|
||
{
|
||
NumerInputDialog numberInputDlg;
|
||
numberInputDlg.setTitleStr(tr("Gear set"));//档位设置
|
||
numberInputDlg.setUnitStr("");
|
||
|
||
numberInputDlg.setValueAndRange(defVal, minVal, maxVal, 0);//默认10
|
||
|
||
if(numberInputDlg.exec() == 1)
|
||
{
|
||
s32 val = numberInputDlg.getValue();
|
||
m_colorTable[m_curSelectColor] = val;
|
||
emit siChangeColorTable(m_curSelectColor+idx,val);
|
||
}
|
||
}
|
||
else//多选
|
||
{
|
||
int val = ui->buttonValue->text().toInt();
|
||
m_colorTable[m_curSelectColor] = val;
|
||
emit siChangeColorTable(m_curSelectColor+idx,val);
|
||
}
|
||
}
|
||
|
||
refreshColorShow();
|
||
refreshPatternCurColorShow();//右下角花样数据
|
||
//不等于压胶机时
|
||
if(g_emMacType != MACHINE_ADHESIVE)
|
||
{
|
||
initNeedleBar();
|
||
}
|
||
}
|
||
|
||
//针杆按钮被按下
|
||
void ColorOrderSetWidget::embNeedleBtnPressed()
|
||
{
|
||
m_pEmbNeedleBtn = (QPushButton*) this->sender();
|
||
m_pEmbNeedleBtn->setCheckable(true);
|
||
m_pEmbNeedleBtn->setChecked(true);
|
||
}
|
||
|
||
//针杆按钮抬起
|
||
void ColorOrderSetWidget::embNeedleBtnReleased()
|
||
{
|
||
if(m_pColorBtn == NULL || m_pEmbNeedleBtn == NULL || m_curSelectColor == -1)
|
||
{
|
||
//按钮都不选中
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
m_buttonEmbNeedleList.at(i)->setChecked(false);
|
||
m_buttonEmbNeedleList.at(i)->setCheckable(false);
|
||
}
|
||
return;
|
||
}
|
||
int btnIdx = 0;
|
||
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
|
||
{
|
||
if(m_pEmbNeedleBtn == m_buttonEmbNeedleList.at(i))
|
||
{
|
||
btnIdx = i+1;
|
||
}
|
||
m_buttonEmbNeedleList.at(i)->setChecked(false);
|
||
m_buttonEmbNeedleList.at(i)->setCheckable(false);
|
||
}
|
||
|
||
int num = 0;
|
||
getNeedleNum(num);//显示当前的色序的针杆
|
||
|
||
#if(0)
|
||
if(m_combineEmb == -1)//组合模式
|
||
{
|
||
if(btnIdx > num)
|
||
{
|
||
btnIdx = btnIdx-num;
|
||
}
|
||
}
|
||
#endif
|
||
|
||
int colorInPage = btnIdx;
|
||
if(m_colorBeginStepCtrl == DATA_SEWING)//缝纫
|
||
{
|
||
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM;
|
||
}
|
||
else if(m_colorBeginStepCtrl == DATA_PUNCH)//冲孔
|
||
{
|
||
colorInPage += EMB_NEEDLE_NUM;
|
||
}
|
||
|
||
if(m_curSelectColor >= 0)
|
||
{
|
||
int colorInTab = m_colorTable.at(m_curSelectColor); // 文件中的色序
|
||
|
||
if (colorInTab != colorInPage || colorInTab == TOTAL_NEEDLE_NUM)
|
||
{
|
||
m_colorTable[m_curSelectColor] = colorInPage;
|
||
emit siChangeColorTable(m_curSelectColor,colorInPage);//针杆写入色序表
|
||
}
|
||
|
||
s16 selIdx = m_colorTable[m_curSelectColor];
|
||
getCurColorTabValue(selIdx);
|
||
|
||
QString str;
|
||
if(selIdx <= 0)
|
||
{
|
||
str = tr("Not set");//未设置
|
||
}
|
||
else
|
||
{
|
||
str = tr("Needle ") + QString::number(selIdx);//针杆
|
||
}
|
||
ui->labelNeedleSelectValue->setText(str);
|
||
|
||
//当前色序设定完成后自动跳到下一色序
|
||
if(m_curSelectColor < m_colorNums-1)
|
||
{
|
||
m_curSelectColor += 1;//花版中的第几个色序
|
||
}
|
||
|
||
refreshColorShow();
|
||
refreshPatternCurColorShow();
|
||
initNeedleBar();//下一个色序针杆变,在这个函数里
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::punchDepthBtnClick()
|
||
{
|
||
int idx = 0;
|
||
m_pColorBtn = (MyButton*) this->sender();
|
||
|
||
if(m_pColorBtn == NULL)
|
||
{
|
||
return;
|
||
}
|
||
for(int i = 0; i < m_buttonPunchDepthList.size(); i++)
|
||
{
|
||
if(m_pColorBtn == m_buttonPunchDepthList[i])
|
||
{
|
||
idx = i;
|
||
}
|
||
}
|
||
|
||
NumerInputDialog numberInputDlg;
|
||
numberInputDlg.setTitleStr(tr("Punch depth"));//冲刀深度
|
||
numberInputDlg.setUnitStr("");
|
||
numberInputDlg.setValueAndRange(0, 0, 200, 2);//默认0,0~2
|
||
if(numberInputDlg.exec() == 1)
|
||
{
|
||
double val = (double)numberInputDlg.getValue() / 100;
|
||
|
||
g_pSettings->writeToIniFile("AUFUS/punchDepth"+QString::number(idx),QString::number(val,'f',2));
|
||
m_buttonPunchDepthList[idx]->setText(QString::number(val,'f',2));
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::on_buttonPgUp_clicked()
|
||
{
|
||
m_curPages--;
|
||
refreshColorShow();
|
||
}
|
||
|
||
void ColorOrderSetWidget::on_buttonPgDn_clicked()
|
||
{
|
||
m_curPages++;
|
||
refreshColorShow();
|
||
}
|
||
|
||
void ColorOrderSetWidget::on_buttonOk_clicked()
|
||
{
|
||
if(m_setType == TYPE_COLORSET)//色序设定
|
||
{
|
||
emit siBackHome();
|
||
}
|
||
else if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
emit siHighBackHome();
|
||
}
|
||
this->hide();
|
||
}
|
||
|
||
void ColorOrderSetWidget::on_buttonCancel_clicked()
|
||
{
|
||
//恢复之前的色序表
|
||
if(m_setType == TYPE_COLORSET)
|
||
{
|
||
emit siCancelChangeColor(m_beforeColorTable);
|
||
}
|
||
else if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
emit siCancelChangeHigh(m_beforeColorTable);
|
||
}
|
||
this->hide();
|
||
}
|
||
|
||
//色序循环
|
||
void ColorOrderSetWidget::on_buttonColorOrderCycle_clicked()
|
||
{
|
||
QByteArray cycleTable;
|
||
cycleTable.clear();
|
||
|
||
//拷贝循环列表
|
||
for(int i = 0; i < m_colorTable.length(); i++)
|
||
{
|
||
int colorInTab = m_colorTable.at(i); // 色序
|
||
|
||
if(colorInTab != 0)
|
||
{
|
||
cycleTable.append(m_colorTable[i]);
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
|
||
if(cycleTable.length() <= 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
//将循环列表循环复制到m_colorTable中
|
||
for(int i = 0; i < m_colorTable.length();)
|
||
{
|
||
memcpy((char*)m_colorTable.data() + i,(char*)cycleTable.data(),cycleTable.length());
|
||
i += cycleTable.length();
|
||
}
|
||
|
||
for(int i = 0; i < m_colorTable.length(); i++)
|
||
{
|
||
int colorInTab = m_colorTable.at(i); // 色序
|
||
|
||
if(m_setType == TYPE_COLORSET)
|
||
{
|
||
emit siChangeColorTable(i,colorInTab);
|
||
}
|
||
else if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
emit siChangeColorTable(i+TABLE_HEIGHT_IDX,colorInTab);
|
||
}
|
||
}
|
||
|
||
m_pCurEmbData->setGreyAreaRange(0,m_pCurEmbData->getStitchNums());
|
||
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1); // 重绘
|
||
|
||
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
|
||
ui->labelPatternView->setPixmap(patternPix);
|
||
|
||
m_curSelectColor = -1;
|
||
refreshColorShow();
|
||
}
|
||
|
||
//色序清空
|
||
void ColorOrderSetWidget::on_buttonColorOrderClear_clicked()
|
||
{
|
||
for(int i = 0; i < m_colorTable.length(); i++)
|
||
{
|
||
m_colorTable[i] = 0;//清空
|
||
int colorInTab = m_colorTable.at(i); // 色序
|
||
if(m_setType == TYPE_COLORSET)
|
||
{
|
||
emit siChangeColorTable(i,colorInTab);
|
||
}
|
||
else if(m_setType == TYPE_HIGHSET)
|
||
{
|
||
emit siChangeColorTable(i+TABLE_HEIGHT_IDX,colorInTab);
|
||
}
|
||
}
|
||
|
||
m_pCurEmbData->setGreyAreaRange(0,m_pCurEmbData->getStitchNums());
|
||
m_pCurEmbData->setDispAreaRange(0,0);
|
||
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1); // 重绘
|
||
|
||
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
|
||
ui->labelPatternView->setPixmap(patternPix);
|
||
|
||
m_curSelectColor = -1;
|
||
refreshColorShow();
|
||
}
|
||
|
||
//色序设定是否解锁,锁住时针杆不可切换,未锁住时针杆可切换
|
||
void ColorOrderSetWidget::on_buttonColorSetLock_clicked()
|
||
{
|
||
m_colorSetBtnLockFlag *= -1;
|
||
refreshLockBtn();
|
||
}
|
||
|
||
//切换成不同的针杆显示
|
||
void ColorOrderSetWidget::on_buttonNeedle_clicked()
|
||
{
|
||
switch (m_colorBeginStepCtrl)
|
||
{
|
||
case DATA_EMB://第一次进来是平绣
|
||
{
|
||
|
||
break;
|
||
}
|
||
}
|
||
|
||
switchNeedleBar();
|
||
}
|
||
|
||
|
||
|
||
void ColorOrderSetWidget::on_buttonSingle_clicked()
|
||
{
|
||
m_singleMulMode = 0;
|
||
ui->buttonSingle->setCheckable(true);
|
||
ui->buttonSingle->setChecked(true);
|
||
|
||
ui->buttonMul->setChecked(false);
|
||
ui->buttonMul->setCheckable(false);
|
||
}
|
||
|
||
void ColorOrderSetWidget::on_buttonMul_clicked()
|
||
{
|
||
m_singleMulMode = 1;
|
||
ui->buttonMul->setCheckable(true);
|
||
ui->buttonMul->setChecked(true);
|
||
|
||
ui->buttonSingle->setChecked(false);
|
||
ui->buttonSingle->setCheckable(false);
|
||
|
||
//等于压胶机时
|
||
if(g_emMacType == MACHINE_ADHESIVE)
|
||
{
|
||
NumerInputDialog numberInputDlg;
|
||
numberInputDlg.setTitleStr(tr("Gear set"));//档位设置
|
||
numberInputDlg.setUnitStr("");
|
||
|
||
numberInputDlg.setValueAndRange(10, 1, 255, 0);//默认10
|
||
|
||
if(numberInputDlg.exec() == 1)
|
||
{
|
||
s32 val = numberInputDlg.getValue();
|
||
ui->buttonValue->setText(QString::number(val));
|
||
}
|
||
}
|
||
}
|
||
|
||
void ColorOrderSetWidget::slotChangeNeedleColor(int idx, int colorIdx)
|
||
{
|
||
if(m_pCurEmbData != NULL)
|
||
{
|
||
m_pCurEmbData->setNeedleColorTable(idx,colorIdx);
|
||
}
|
||
}
|