EmbHMI/sharedviews/colorordersetwidget.cpp
huahaiyan c6c9ede54d 20240301
1、整合合并任晴代码,修改设置色序是后需要刷新图形功能,及删除边框刺绣文件功能;
2024-03-01 15:57:37 +08:00

2947 lines
100 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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_mousePressX = 0;
m_mousePressY = 0;
m_mouseReleaseX = 0;
m_mouseReleaseY = 0;
m_greyBeginStep = 0;//灰色起始
m_greyEndStep = 0; //灰色结束
initWidget();
initControl();
initNeedleBar();
refreshLockBtn();
initArabControlPos();
}
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());
int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
if(coil == 1)
{
ui->buttonExplanation->setVisible(true);//缠绕的解释说明
}
else
{
ui->buttonExplanation->setVisible(false);
}
int laser = g_pSettings->readFromInHMIiFile("HMI/laser").toInt();//是否有激光功能
if(laser == 1)
{
ui->buttonColorLaser->setVisible(true);//设置激光的快捷色序
}
else
{
ui->buttonColorLaser->setVisible(false);
}
int combineEmb = g_pSettings->readFromInHMIiFile("HMI/combineEmb").toInt();//是否有双头组合绣功能
//是否显示双头组合按钮
if(combineEmb == 1)
{
ui->buttonCombineEmb->setVisible(true);
}
else
{
ui->buttonCombineEmb->setVisible(false);
}
int threeCombineEmb = g_pSettings->readFromInHMIiFile("HMI/threeCombineEmb").toInt();//是否有三头组合绣功能
//是否显示双头组合按钮
if(threeCombineEmb == 1)
{
ui->buttonThreeCombineEmb->setVisible(true);
}
else
{
ui->buttonThreeCombineEmb->setVisible(false);
}
int headEmb = g_pSettings->readFromInHMIiFile("HMI/headEmb").toInt();//是否有隔头绣功能
//是否显示隔头绣按钮
if(headEmb == 1)
{
ui->buttonHeadEmb->setVisible(true);
}
else
{
ui->buttonHeadEmb->setVisible(false);
}
m_colorBeginStepCtrl = 0;
m_colorEndStepCtrl = 0;
m_curSelectColor = -1;
m_curPages = 1;
m_pageNums = 1;
m_combineEmb = 1;//双头组合绣
m_threeCombineEmb = 1;//三头组合绣
m_combineEmbFirst = 1;
m_threeCombineEmbFirst = 1;
m_colorOrderLimitFlag = 0;
m_refreshColorOrder = 1;//是否刷新花版色序的标志
memset(m_headBuf, 0, sizeof(m_headBuf));
m_colorSetBtnLockFlag = 1;//锁住
m_setType = TYPE_COLORSET;
m_fileType = FILE_TYPE_DST;
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()));
}
}
void ColorOrderSetWidget::initControl()
{
//根据不同分辨率设置控件的位置和尺寸
switch (g_emResolut)
{
case resolution1910:
initResolution1910();
break;
case resolution1006:
initResolution1006();
break;
default:
this->resize(1920,1080);
break;
}
int towel = g_pSettings->readFromInHMIiFile("HMI/towel").toInt();//是否有毛巾功能
int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
int laser = g_pSettings->readFromInHMIiFile("HMI/laser").toInt();//是否有激光功能
//右上方色序锁住按钮是否可见
if((g_emMacType == MACHINE_EMB && towel ==1)|| //绣花机带毛巾
(g_emMacType == MACHINE_EMB && coil ==1)|| //绣花机带缠绕
(g_emMacType == MACHINE_EMB && laser ==1) //绣花机带激光
)
{
ui->buttonColorSetLock->setVisible(true);
}
else
{
ui->buttonColorSetLock->setVisible(false);
}
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->buttonHeadEmb->setGeometry(428,0,66,66);
ui->buttonCombineEmb->setGeometry(340,0,66,66);
ui->buttonThreeCombineEmb->setGeometry(252,0,66,66);
ui->buttonExplanation->setGeometry(164,0,66,66);
ui->buttonColorLaser->setGeometry(76,0,66,66);
ui ->buttonRefreshColorOrder->setGeometry(0,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(38,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 < 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));
}
}
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(500,40,857,61);
ui->buttonColorOrderClear->setGeometry(456,0,50,50);
ui->buttonColorOrderCycle->setGeometry(399,0,50,50);
ui->buttonColorSetLock->setGeometry(342,0,50,50);
ui->buttonHeadEmb->setGeometry(285,0,50,50);
ui->buttonCombineEmb->setGeometry(228,0,50,50);
ui->buttonThreeCombineEmb->setGeometry(171,0,50,50);
ui->buttonExplanation->setGeometry(114,0,50,50);
ui->buttonColorLaser->setGeometry(57,0,50,50);
ui ->buttonRefreshColorOrder->setGeometry(0,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(22,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 < 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));
}
}
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);
//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->buttonHeadEmb->setGreenGradientBottomStyle(BORDER_RADIUS1);
ui->buttonHeadEmb->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonHeadEmb->objectName()));
ui->buttonCombineEmb->setGreenGradientBottomStyle(BORDER_RADIUS1);
ui->buttonCombineEmb->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonCombineEmb->objectName()));
ui->buttonThreeCombineEmb->setGreenGradientBottomStyle(BORDER_RADIUS1);
ui->buttonThreeCombineEmb->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonThreeCombineEmb->objectName()));
ui->buttonExplanation->setGreenGradientBottomStyle(BORDER_RADIUS1);
ui->buttonExplanation->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonExplanation->objectName()));
ui->buttonColorLaser->setGreenGradientBottomStyle(BORDER_RADIUS1);
ui->buttonColorLaser->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonColorLaser->objectName()));
ui->buttonRefreshColorOrder->setGreenGradientBottomStyle(BORDER_RADIUS1);
// ui->buttonRefreshColorOrder->setVisible(false);
ui->buttonRefreshColorOrder->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRefreshColorOrder->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::initArabControlPos()
{
int language = g_pSettings->readFromInHMIiFile("HMI/language").toInt();
if(language != arabic)
{
return;
}
ui->labelMainTitle->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
ui->labelSubTitle->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
//ui->labelNameValue->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
ui->labelTotalNeedle->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// ui->labelTotalNeedleValue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->labelTotalColor->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
//ui->labelTotalColorValue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->labelCurColorNum->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// ui->labelCurColorNumValue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->labelBeginIdx->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// ui->labelBeginIdxValue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->labelEndIdx->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
//ui->labelEndIdxValue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->labelNeedleSelect->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
//ui->labelNeedleSelectValue->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
}
void ColorOrderSetWidget::initNeedleBar()
{
//读入配置
QDir apppath(qApp->applicationDirPath());
//配置文件路径
QString configFile = apppath.path() + apppath.separator() + "config.ini";
QFile iniFile(configFile);
int num,idx;
if(!iniFile.exists())
{
if(m_combineEmb == -1)//组合绣模式
{
num = 2;
}
else if(m_threeCombineEmb == -1)//三头组合绣模式
{
num = 3;
}
else
{
num = 1;
}
idx = 0;
QRgb rgb = m_pColorBuf[(idx % EMB_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)
{
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)//i<1
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/2)//i>=1
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/2)+1));
}
}
else if(m_threeCombineEmb == -1)//三头组合绣
{
if(i < num/3)//9*3 = 27
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/3 && i < (num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/3)+1));
}
else if(i >=(num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("EX"+QString::number((i-(num/3*2))+1));
}
}
else
{
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);//显示当前色序所选的针杆
if(m_combineEmb == -1)//组合绣模式
{
num = num * 2;//
}
else if(m_threeCombineEmb == -1)
{
num = num * 3;//9个针杆 *3
}
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
{
QString idxStr;
idxStr = getNeedleColorStr(i+1);
#if(0)
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)
{
idxStr = "EmbNeedle/"+QString::number(i+1)+"_coloridx";
}
else if(i >= num/2)
{
idxStr = "EmbNeedle/"+QString::number((i-num/2)+1)+"_coloridx";
}
}
else
{
idxStr = "EmbNeedle/"+QString::number(i+1)+"_coloridx";
}
#endif
if(g_pSettings->ifKeyExists(idxStr) == true)
{
idx = g_pSettings->readFromIniFile(idxStr).toInt();
rgb = m_pColorBuf[(idx % EMB_BF_SW_ND)];
m_pCurEmbData->setNeedleColorTable(i,idx);
}
else
{
rgb = m_pColorBuf[(i % EMB_MC_SW_ND)];
m_pCurEmbData->setNeedleColorTable(i,i);
#if(0)
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)
{
rgb = m_pColorBuf[(i % EMB_MC_SW_ND)];
}
else if(i >= num/2)
{
rgb = m_pColorBuf[((i-num/2) % EMB_MC_SW_ND)];
}
}
else
{
rgb = m_pColorBuf[(i % EMB_MC_SW_ND)];
}
#endif
}
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)
{
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/2)
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/2)+1));
}
}
else if(m_threeCombineEmb == -1)
{
if(i < num/3)//9*3 = 27
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/3 && i < (num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/3)+1));
}
else if(i >=(num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("EX"+QString::number((i-(num/3*2))+1));
}
}
else
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
//属于冲缝绣,毛巾针步才显示针杆设置按钮,因为有的色序里只有偏移针步
if(m_colorBeginStepCtrl == DATA_SEWING ||
m_colorBeginStepCtrl == DATA_EMB ||
m_colorBeginStepCtrl == DATA_PUNCH ||
m_colorBeginStepCtrl == DATA_CHENILLE ||
m_colorBeginStepCtrl == DATA_CHAIN ||
m_colorBeginStepCtrl == DATA_COIL ||
m_colorBeginStepCtrl == DATA_SAWTOOTH ||
m_colorBeginStepCtrl == DATA_RIBBON ||
m_colorBeginStepCtrl == DATA_LASER ||
m_colorBeginStepCtrl == 0)
{
m_buttonEmbNeedleList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
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);
}
if(m_threeCombineEmb != 1 || m_combineEmb !=1)
{
m_colorSetBtnLockFlag = 1;
refreshLockBtn();
ui->buttonColorSetLock->setVisible(false);
m_colorBeginStepCtrl = DATA_EMB;
switchNeedleBar();
}
if(m_threeCombineEmb == 1 && m_combineEmb ==1)
{
ui->buttonColorSetLock->setVisible(true);
}
}
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())
{
if(m_combineEmb == -1)//组合绣模式
{
num = 2;
}
else if(m_threeCombineEmb == -1)//三头组合绣模式
{
num = 3;
}
else
{
num = 1;
}
idx = 0;
QRgb rgb = m_pColorBuf[(idx % EMB_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)
{
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)//i<1
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/2)//i>=1
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/2)+1));
}
}
else if(m_threeCombineEmb == -1)//三头组合绣
{
if(i < num/3)//9*3 = 27
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/3 && i < (num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/3)+1));
}
else if(i >=(num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("EX"+QString::number((i-(num/3*2))+1));
}
}
else
{
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);
if(m_colorBeginStepCtrl == DATA_CHENILLE)//毛巾针杆
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Chenille (T):"));//毛巾针杆 //显示毛巾针杆
}
else if(m_colorBeginStepCtrl == DATA_CHAIN)//链式针杆
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Chain (C):"));//链式针杆
}
else if(m_colorBeginStepCtrl == DATA_COIL)//缠绕针杆
{
num = COILNEEDLE;
ui->buttonNeedle->setText(tr("Coil (W):"));//缠绕针杆
ui->buttonExplanation->setEnabled(true);
}
else if(m_colorBeginStepCtrl == DATA_SAWTOOTH)//锯齿针杆
{
num = SAWTOOTHNEEDLE;
ui->buttonNeedle->setText(tr("Sawtooth (Z):"));//锯齿针杆
ui->buttonExplanation->setEnabled(true);
}
else if(m_colorBeginStepCtrl == DATA_RIBBON)//盘带针杆
{
num = RIBBONNEEDLE;
ui->buttonNeedle->setText(tr("Ribbon (R):"));//盘带针杆
ui->buttonExplanation->setEnabled(true);
}
else if(m_colorBeginStepCtrl == DATA_LASER)//激光针杆
{
num = LASERNEEDLE;
ui->buttonNeedle->setText(tr("Laser (L):"));//激光针杆
ui->buttonExplanation->setEnabled(false);
}
else if(m_colorBeginStepCtrl == DATA_EMB)//绣花针杆 //第一次选完花版进来是绣花数据,然后根据selIdx切换相应的针杆
{
ui->buttonExplanation->setEnabled(false);
//针杆按钮切换,切换到绣花的时候,针杆显示不对
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Emb (F):"));//绣花针杆
}
if(m_combineEmb == -1)//组合绣模式
{
num = num * 2;//
}
else if(m_threeCombineEmb == -1)
{
num = num * 3;//9个针杆 *3
}
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
{
QString idxStr;
idxStr = getNeedleColorStr(i+1);
#if(0)
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)
{
idxStr = "EmbNeedle/"+QString::number(i+1)+"_coloridx";
}
else if(i >= num/2)
{
idxStr = "EmbNeedle/"+QString::number((i-num/2)+1)+"_coloridx";
}
}
else
{
idxStr = "EmbNeedle/"+QString::number(i+1)+"_coloridx";
}
#endif
if(g_pSettings->ifKeyExists(idxStr) == true)
{
idx = g_pSettings->readFromIniFile(idxStr).toInt();
rgb = m_pColorBuf[(idx % EMB_BF_SW_ND)];
m_pCurEmbData->setNeedleColorTable(i,idx);
}
else
{
rgb = m_pColorBuf[(i % EMB_MC_SW_ND)];
m_pCurEmbData->setNeedleColorTable(i,i);
#if(0)
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)
{
rgb = m_pColorBuf[(i % EMB_MC_SW_ND)];
}
else if(i >= num/2)
{
rgb = m_pColorBuf[((i-num/2) % EMB_MC_SW_ND)];
}
}
else
{
rgb = m_pColorBuf[(i % EMB_MC_SW_ND)];
}
#endif
}
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)
{
if(m_combineEmb == -1)//组合绣模式
{
if(i < num/2)
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/2)
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/2)+1));
}
}
else if(m_threeCombineEmb == -1)
{
if(i < num/3)//9*3 = 27
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
else if(i >= num/3 && i < (num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("E"+QString::number((i-num/3)+1));
}
else if(i >=(num/3)*2)
{
m_buttonEmbNeedleList[i]->setText("EX"+QString::number((i-(num/3*2))+1));
}
}
else
{
m_buttonEmbNeedleList[i]->setText(QString::number(i+1));
}
//属于冲缝绣,毛巾针步才显示针杆设置按钮,因为有的色序里只有偏移针步
if(m_colorBeginStepCtrl == DATA_SEWING ||
m_colorBeginStepCtrl == DATA_EMB ||
m_colorBeginStepCtrl == DATA_PUNCH ||
m_colorBeginStepCtrl == DATA_CHENILLE ||
m_colorBeginStepCtrl == DATA_CHAIN ||
m_colorBeginStepCtrl == DATA_COIL ||
m_colorBeginStepCtrl == DATA_SAWTOOTH ||
m_colorBeginStepCtrl == DATA_RIBBON ||
m_colorBeginStepCtrl == DATA_LASER ||
m_colorBeginStepCtrl == 0)
{
m_buttonEmbNeedleList.at(i)->setStyleSheet(m_buttonStyle1 + cstyle + "}" + m_buttonStyle2);
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(int colorInPage)
{
QString str;
QString strNeedle;
m_colorOrderLimitFlag = 0;
int num = 0;
getNeedleNum(num);//获取配置文件针杆数量
int colorNum = m_colorTable.size();
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;
}
s16 embHeadnum = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
for (int i = 0; i < m_itemPerPage; i++)
{
// 颜色显示
if (colorIdx < colorNum)
{
s16 needleIdx = m_colorTable.at(colorIdx);//花版里的第一个色序设置成了毛巾1
int colorIdxCp = needleIdx;
//大于平绣机头数
if(needleIdx > embHeadnum && needleIdx <= EMB_NEEDLE_NUM)
{
//等于绣花机时有双头组合功能才有色序设置不合理的判断
if(m_combineEmb == 1 && m_threeCombineEmb == 1)//rq 没有判断有没有组合功能
{
m_colorOrderLimitFlag = -1;
}
}
if(m_combineEmb == 1&& m_threeCombineEmb == 1)//非组合绣模式
{
strNeedle = getCurColorTabStr(needleIdx);
getCurColorTabValue(needleIdx);
}
QString idxStr;
if(colorInPage == -1)
{
idxStr = getNeedleColorStr(needleIdx);//needleIdx 针杆索引
}
else
{
if(colorIdxCp >= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM)
{
m_colorBeginStepCtrl = DATA_LASER;//激光针杆
idxStr = "LaserNeedle/"+QString::number(needleIdx)+"_coloridx";
}
else if(colorIdxCp >= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM)
{
m_colorBeginStepCtrl = DATA_SAWTOOTH;//锯齿针杆
idxStr = "SawtoothNeedle/"+QString::number(needleIdx)+"_coloridx";
}
else if(colorIdxCp >= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM)
{
m_colorBeginStepCtrl = DATA_COIL;//缠绕针杆
idxStr = "ColiNeedle/"+QString::number(needleIdx)+"_coloridx";
}
else if(colorIdxCp >= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM+SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM)
{
m_colorBeginStepCtrl = DATA_CHAIN;//链式针杆
idxStr = "TowelNeedle/"+QString::number(needleIdx)+"_coloridx";
}
else if(colorIdxCp >= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM)
{
m_colorBeginStepCtrl = DATA_CHENILLE;//毛巾针杆
idxStr = "TowelNeedle/"+QString::number(needleIdx)+"_coloridx";
}
else if(colorIdxCp >= EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM+SEW_NEEDLE_NUM)
{
m_colorBeginStepCtrl = DATA_RIBBON;//盘带针杆
idxStr = "RibbonNeedle/"+QString::number(needleIdx)+"_coloridx";
}
else
{
m_colorBeginStepCtrl = DATA_EMB;
idxStr = "EmbNeedle/"+QString::number(needleIdx)+"_coloridx";
}
}
s16 colorInTab;
if(g_pSettings->ifKeyExists(idxStr) == true)
{
colorInTab = g_pSettings->readFromIniFile(idxStr).toInt();
}
else
{
colorInTab = m_colorTable.at(colorIdx);
if(m_combineEmb == 1&& m_threeCombineEmb == 1)//非组合绣模式
{
getCurColorTabValue(colorInTab);
}
colorInTab -= 1;
if(colorInTab < 0){colorInTab = 0;}
}
// 文件中的色序
QRgb rgb = m_pColorBuf[(colorInTab % EMB_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
{
if(m_combineEmb == -1)
{
if(needleIdx > num)
{
int idx = needleIdx-num;
if(idx > EMB_NEEDLE_NUM)
{
s16 cidx = needleIdx;
QString str = getCurColorTabStr(cidx);
getCurColorTabValue(cidx);
m_buttonColorOrderList.at(i)->setLabelValue(str+QString::number(cidx));
}
else
{
m_buttonColorOrderList.at(i)->setLabelValue("E"+QString::number(idx));
}
}
else
{
m_buttonColorOrderList.at(i)->setLabelValue(QString::number(needleIdx));
}
}
else if(m_threeCombineEmb == -1)
{
if(needleIdx <= num)
{
m_buttonColorOrderList.at(i)->setLabelValue(QString::number(needleIdx));
}
else if(needleIdx>num && needleIdx <= num*2)
{
m_buttonColorOrderList.at(i)->setLabelValue("E"+QString::number(needleIdx-num));
}
else if(needleIdx>num*2 && needleIdx <= num*3)
{
m_buttonColorOrderList.at(i)->setLabelValue("EX"+QString::number(needleIdx-num*2));
}
else
{
s16 cidx = needleIdx;
QString str = getCurColorTabStr(cidx);
getCurColorTabValue(cidx);
m_buttonColorOrderList.at(i)->setLabelValue(str+QString::number(cidx));
}
}
else
{
m_buttonColorOrderList.at(i)->setLabelValue(strNeedle+QString::number(needleIdx));
}
}
str.sprintf("%d", colorIdx+1);
//下方的色序按钮
//设置数字 花版里的色序个数
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;
beginIdx = endIdx = 0;
if(m_colorTable.size() == 1)//只有一个换色
{
endIdx = m_pCurEmbData->getStitchNums();
m_pCurEmbData->getNeedleIdxFromColorIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
beginIdx = 1;
}
else
{
//获取起始针步和换色后第一个针步的针步属性(非跳针跨步等)
m_pCurEmbData->getNeedleIdxFromColorIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
if(m_curSelectColor+1 == m_colorTable.size())//当前选择颜色数等于总的颜色数
{
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);
if (m_refreshColorOrder != -1)
{
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1, 1); // 重新画灰图
}
ui->labelBeginIdxValue->setText(QString::number(beginIdx));
ui->labelEndIdxValue->setText(QString::number(endIdx));
ui->labelCurColorNumValue->setText(QString::number(m_curSelectColor+1));
m_greyBeginStep = beginIdx;//灰色起始
m_greyEndStep = endIdx; //灰色结束
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
ui->labelPatternView->setPixmap(patternPix);
//根据 beginStepCtrl 切换到相应针杆设置
int num = 0;
getNeedleNum(num);
s16 selIdx = m_colorTable[m_curSelectColor];
int idx = selIdx;
if(m_combineEmb == 1&& m_threeCombineEmb == 1)//非组合绣模式
{
getCurColorTabValue(selIdx);
}
QString str;
if(selIdx <= 0)
{
str = tr("Not set");//未设置
}
else
{
if(m_combineEmb == -1)
{
if(selIdx <= num)//selIdx 总针杆的索引 num 针杆个数
{
str = tr("Head 1 Needle ") + QString::number(selIdx);//针杆
}
else
{
str = tr("Head 2 Needle ") + QString::number(selIdx-num);//针杆
}
}
else if (m_threeCombineEmb == -1)//三头组合绣
{
if(selIdx <= num)
{
str = tr("Head 1 Needle ") + QString::number(selIdx);//针杆
}
else if(selIdx>num && selIdx <= num*2)
{
str = tr("Head 2 Needle ") + QString::number(selIdx-num);//针杆
}
else
{
str = tr("Head 3 Needle ") + QString::number(selIdx-num*2);//针杆
}
}
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("EmbNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Emb (F):"));//绣花针杆
return;
}
if(m_colorBeginStepCtrl == DATA_CHENILLE)//毛巾针杆
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Chenille (T):"));//毛巾针杆 //显示毛巾针杆
}
else if(m_colorBeginStepCtrl == DATA_CHAIN)//链式针杆
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Chain (C):"));//链式针杆
}
else if(m_colorBeginStepCtrl == DATA_COIL)//缠绕针杆
{
num = COILNEEDLE;
ui->buttonNeedle->setText(tr("Coil (W):"));//缠绕针杆
ui->buttonExplanation->setEnabled(true);
}
else if(m_colorBeginStepCtrl == DATA_SAWTOOTH)//锯齿针杆
{
num = SAWTOOTHNEEDLE;
ui->buttonNeedle->setText(tr("Sawtooth (Z):"));//锯齿针杆
ui->buttonExplanation->setEnabled(true);
}
else if(m_colorBeginStepCtrl == DATA_RIBBON)//盘带针杆
{
num = RIBBONNEEDLE;
ui->buttonNeedle->setText(tr("Ribbon (R):"));//盘带针杆
ui->buttonExplanation->setEnabled(true);
}
else if(m_colorBeginStepCtrl == DATA_LASER)//激光针杆
{
num = LASERNEEDLE;
ui->buttonNeedle->setText(tr("Laser (L):"));//激光针杆
ui->buttonExplanation->setEnabled(false);
}
else if(m_colorBeginStepCtrl == DATA_EMB)//绣花针杆 //第一次选完花版进来是绣花数据,然后根据selIdx切换相应的针杆
{
ui->buttonExplanation->setEnabled(false);
//针杆按钮切换,切换到绣花的时候,针杆显示不对
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Emb (F):"));//绣花针杆
}
else
{
ui->buttonExplanation->setEnabled(false);
num = 0;
//非冲缝绣针步
ui->buttonNeedle->setText(tr("Non needle step"));//非下针针步
}
}
void ColorOrderSetWidget::switchNeedleNum(int &num)
{
//m_curSelectColor 花版中的第几个色序
//m_colorTable 色序表
//selIdx 色序表里的色序 0就是没有色序
if(m_colorTable.size() <= 0)
{
return;
}
int selIdx = m_colorTable[m_curSelectColor];
if(m_combineEmb == 1&& m_threeCombineEmb == 1)//非组合绣模式
{
/*如果是dsr文件有多种属性的针步时(或者dst文件),绣花针步可能会设置为其他色序,
* 此时点击色序设定按钮时需要切换为相应设置的针杆*/
if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM)//激光针杆
{
num=LASERNEEDLE;
ui->buttonNeedle->setText(tr("Laser (L):"));//激光针杆
m_colorBeginStepCtrl = DATA_LASER;
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM)//锯齿针杆
{
num = SAWTOOTHNEEDLE;
ui->buttonNeedle->setText(tr("Sawtooth (Z):"));//锯齿针杆
m_colorBeginStepCtrl = DATA_SAWTOOTH;
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM)//缠绕针杆
{
num = COILNEEDLE;
ui->buttonNeedle->setText(tr("Coil (W):"));//缠绕针杆
m_colorBeginStepCtrl = DATA_COIL;
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM)//链式针杆
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();//链式针杆和毛巾针杆是相同的
ui->buttonNeedle->setText(tr("Chain (C):"));//链式针杆
m_colorBeginStepCtrl = DATA_CHAIN;
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM)//毛巾针杆
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Chenille (T):"));//毛巾针杆 //显示的毛巾针杆
m_colorBeginStepCtrl = DATA_CHENILLE;
}
//selIdx =51 当前选择的是盘带针杆
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM)//盘带针杆 盘带 缠绕 平绣
{
num = RIBBONNEEDLE;
ui->buttonNeedle->setText(tr("Ribbon (R):"));//盘带针杆
m_colorBeginStepCtrl = DATA_RIBBON;
}
else
{
if(g_emMacType == MACHINE_EMB && g_emProductType == PRODUCT_CHEN)//绣花机且为纯毛巾
{
num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Chenille (T):"));//毛巾针杆 //显示的毛巾针杆
m_colorBeginStepCtrl = DATA_CHENILLE;
}
else
{
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Emb (F):"));//绣花针杆
m_colorBeginStepCtrl = DATA_EMB;
}
}
}
else
{
num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
ui->buttonNeedle->setText(tr("Emb (F):"));//绣花针杆
}
}
//获取配置文件针杆颜色索引字符
QString ColorOrderSetWidget::getNeedleColorStr(s16 idx)
{
QString idxStr;
idxStr.clear();
if(m_colorBeginStepCtrl == DATA_CHENILLE)//毛巾针杆
{
idxStr = "TowelNeedle/"+QString::number(idx)+"_coloridx";
}
else if(m_colorBeginStepCtrl == DATA_CHAIN)//链式针杆
{
idxStr = "TowelNeedle/"+QString::number(idx)+"_coloridx";
}
else if(m_colorBeginStepCtrl == DATA_COIL)//缠绕针杆
{
idxStr = "ColiNeedle/"+QString::number(idx)+"_coloridx";
}
else if(m_colorBeginStepCtrl == DATA_SAWTOOTH)//锯齿针杆
{
idxStr = "SawtoothNeedle/"+QString::number(idx)+"_coloridx";
}
else if(m_colorBeginStepCtrl == DATA_RIBBON)//盘带针杆
{
idxStr = "RibbonNeedle/"+QString::number(idx)+"_coloridx";
}
else if(m_colorBeginStepCtrl == DATA_LASER)//激光针杆
{
idxStr = "LaserNeedle/"+QString::number(idx)+"_coloridx";
}
else if(m_colorBeginStepCtrl == DATA_EMB)//绣花针杆
{
idxStr = "EmbNeedle/"+QString::number(idx)+"_coloridx";//绣花针杆
if(m_curSelectColor < 0){return idxStr;}
int selIdx = m_colorTable[m_curSelectColor];
if(m_combineEmb == 1&& m_threeCombineEmb == 1)//非组合绣模式
{
/*如果是dsr文件有多种属性的针步时(或者dst文件),绣花针步可能会设置为其他色序
* 此时点击色序设定按钮时需要切换为相应设置的针杆*/
if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM)//激光针杆
{
idxStr = "LaserNeedle/"+QString::number(idx)+"_coloridx";
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM)//锯齿针杆
{
idxStr = "SawtoothNeedle/"+QString::number(idx)+"_coloridx";
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM)//缠绕针杆
{
idxStr = "CoilNeedle/"+QString::number(idx)+"_coloridx";
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM)//链式针杆
{
idxStr = "TowelNeedle/"+QString::number(idx)+"_coloridx";
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM)//毛巾针杆
{
idxStr = "TowelNeedle/"+QString::number(idx)+"_coloridx";
}
else if(selIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM+ SEW_NEEDLE_NUM)//盘带
{
idxStr = "RibbonNeedle/"+QString::number(idx)+"_coloridx";
}
else
{
idxStr = "EmbNeedle/"+QString::number(idx)+"_coloridx";//绣花针杆
}
}
else
{
idxStr = "EmbNeedle/"+QString::number(idx)+"_coloridx";//绣花针杆
}
}
else
{
idxStr = "EmbNeedle/"+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);//针杆按钮可按
}
}
void ColorOrderSetWidget::initTowelHeightValue()
{
int num = TOWELHIGHRANGE;
QString cstyle = "background-color: rgba(245, 245, 245);color: rgba(0, 0, 0);";
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();
}
}
for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
{
m_buttonEmbNeedleList.at(i)->setChecked(false);
m_buttonEmbNeedleList.at(i)->setCheckable(false);
}
}
void ColorOrderSetWidget::refreshTowelHeightShow()
{
QString str;
int colorNum = m_colorTable.size();
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)
{
int needleIdx = m_colorTable.at(colorIdx);
if(needleIdx <= 0)
{
m_buttonColorOrderList.at(i)->setLabelValue("");//数字是空
}
else
{
m_buttonColorOrderList.at(i)->setLabelValue(QString::number(needleIdx));
}
str.sprintf("%d", colorIdx+1);
//下方的按钮
//设置数字
m_buttonColorOrderList.at(i)->setLabelName(str);
QString cstyle = "outline: none;background-color:rgba(245, 245, 245);color: rgba(0, 0, 0);";
QString cstyle1 = "outline: none;background-color:rgba(255, 255, 255, 0);color: rgba(0, 0, 0);";
m_buttonColorOrderList.at(i)->setImageBackColor(cstyle);
m_buttonColorOrderList.at(i)->setLabelValueStyle(cstyle1);
//选择显示
if (colorIdx == m_curSelectColor)
{
m_buttonColorOrderList.at(i)->setLabelImageChecked(cstyle);
}
m_buttonColorOrderList.at(i)->show();
}
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::refreshPatternCurTowelHeightShow()
{
if(m_curSelectColor < 0)
{
return;
}
int beginIdx, endIdx;
if(m_colorTable.size() == 1)//只有一个毛巾高度
{
endIdx = m_pCurEmbData->getStitchNums();
if(m_fileType == FILE_TYPE_DSR)
{
m_pCurEmbData->getNeedleIdxFromTowelHighIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
}
else if(m_fileType == FILE_TYPE_DST)
{
m_pCurEmbData->getNeedleIdxFromColorIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
}
beginIdx = 1;
}
else
{
//获取起始针步和换毛巾高度后第一个针步的针步属性(非跳针跨步等)
if(m_fileType == FILE_TYPE_DSR)
{
m_pCurEmbData->getNeedleIdxFromTowelHighIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
}
else if(m_fileType == FILE_TYPE_DST)
{
m_pCurEmbData->getNeedleIdxFromColorIdx(beginIdx, m_curSelectColor+1, m_colorBeginStepCtrl);
}
if(m_curSelectColor+1 == m_colorTable.size())//当前选择数等于总数
{
endIdx = m_pCurEmbData->getStitchNums();
}
else
{
if(m_fileType == FILE_TYPE_DSR)
{
m_pCurEmbData->getNeedleIdxFromTowelHighIdx(endIdx, m_curSelectColor+2, m_colorEndStepCtrl);
}
else if(m_fileType == FILE_TYPE_DST)
{
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, 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));
int selIdx = m_colorTable[m_curSelectColor];
QString str;
if(selIdx <= 0)
{
str = tr("Not set");//未设置
}
else
{
str = QString::number(selIdx);//针杆
}
ui->labelNeedleSelectValue->setText(str);// 右下角显示当前索引
}
QString ColorOrderSetWidget::getCurColorTabStr(s16 needleIdx)
{
QString strNeedle;
strNeedle.clear();
if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM +CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM)//激光针杆
{
strNeedle = tr("L");
}
else if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM +CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM)//锯齿针杆
{
strNeedle = tr("Z");
}
else if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM +CHAIN_NEEDLE_NUM)//缠绕针杆
{
strNeedle = tr("W");
}
else if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM)//链式针杆
{
strNeedle = tr("C");
}
else if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM)//毛巾针杆
{
strNeedle = tr("T");
}
else if(needleIdx > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM)//盘带针杆
{
strNeedle = tr("R");
}
else
{
strNeedle = tr("F");
}
return strNeedle;
}
void ColorOrderSetWidget::getCurColorTabValue(s16 &colorInTab)
{
if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM)//激光针杆
{
colorInTab -= (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM);
}
else if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM)//锯齿针杆
{
colorInTab -= (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM);
}
else if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM)//缠绕针杆
{
colorInTab -= (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM);
}
else if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM)//链式针杆
{
colorInTab -= (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+ TOWEL_NEEDLE_NUM);
}
else if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM)//毛巾针杆
{
colorInTab -= (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM);
}
else if(colorInTab > EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM)//缠绕针杆
{
colorInTab -= (EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM + SEW_NEEDLE_NUM);
}
}
//设置类型图标
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)
{
ui->buttonColorSetLock->setVisible(true);//右上方解锁按钮
m_colorSetBtnLockFlag = 1;//锁住
refreshLockBtn();
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->appendAEmbAbsFile(filePath,dst.getEmbAbsData());//生成文件信息
m_colorTable.resize(dst.getColorNums());
}
else if(ext == "DSR")//dsr文件
{
DataFileDsr dsr;
dsr.initFile(filePath);
dsr.convertDataToEmbAbs();
m_pCurEmbData->appendAEmbAbsFile(filePath,dsr.getEmbAbsData());//生成文件信息
m_colorTable.resize(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(1);
initNeedleBar();
#if(0)
ui->labelCurColorNumValue->setText("");
ui->labelBeginIdxValue->setText("");
ui->labelEndIdxValue->setText("");
ui->labelNeedleSelectValue->setText("");
#endif
QWidget::show();
}
void ColorOrderSetWidget::showTowelHeight(QString filePath)
{
m_colorSetBtnLockFlag = 1;//锁住
ui->buttonNeedle->setStyleSheet(LABELWHITESTYLE);
ui->buttonNeedle->setEnabled(false);//针杆按钮不可按
initTowelHeightValue();
QFileInfo file(filePath);
QString ext = file.suffix().toUpper();
m_pCurEmbData->setViewInfo(ui->labelPatternView->width(),ui->labelPatternView->height());
m_pCurEmbData->clear();
if(ext == "DST")//dst文件
{
m_fileType = FILE_TYPE_DST;
DataFileDst dst;
dst.initFile(filePath);
dst.convertDataToAbs();
m_pCurEmbData->appendAEmbAbsFile(filePath,dst.getEmbAbsData());//生成文件信息
m_colorTable.resize(dst.getColorNums());
}
else if(ext == "DSR")//dsr文件
{
m_fileType = FILE_TYPE_DSR;
DataFileDsr dsr;
dsr.initFile(filePath);
dsr.convertDataToEmbAbs();
m_pCurEmbData->appendAEmbAbsFile(filePath,dsr.getEmbAbsData());//生成文件信息
m_colorTable.resize(dsr.getTowelHighNums());
}
m_pCurEmbData->getDsDat();
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 high Num:"));//总高度数:
ui->labelTotalColorValue->setText(QString::number(m_pCurEmbData->getTowelHighNums()));
}
m_curSelectColor = 0;
if(m_buttonColorOrderList.size() > 0)
{
m_pColorBtn = m_buttonColorOrderList.at(0);//默认选中(等于)第一个按钮
}
refreshPatternCurTowelHeightShow();
refreshTowelHeightShow();
#if(0)
ui->labelCurColorNumValue->setText("");
ui->labelBeginIdxValue->setText("");
ui->labelEndIdxValue->setText("");
ui->labelNeedleSelectValue->setText("");
#endif
QWidget::show();
}
void ColorOrderSetWidget::setColorTable(QByteArray table,s16 combineMode)
{
ui->labelCurColorNum->setText(tr("Color num:"));//当前色序:
ui->labelNeedleSelect->setText(tr("Needle:"));//针杆选择:
m_setType = TYPE_COLORSET;
int towel = g_pSettings->readFromInHMIiFile("HMI/towel").toInt();//是否有毛巾功能
//这里用是否有毛巾功能做判断,是因为有毛巾功能时会有毛巾高度设置功能,毛巾高度设置会把以下按钮全部隐藏
//这里需要根据配置再显示出来
if((towel == 1)||
(g_emProductType == PRODUCT_CHEN)
)
{
int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
if(coil == 1)
{
ui->buttonExplanation->setVisible(true);//缠绕的解释说明
}
else
{
ui->buttonExplanation->setVisible(false);
}
int laser = g_pSettings->readFromInHMIiFile("HMI/laser").toInt();//是否有激光功能
if(laser == 1)
{
ui->buttonColorLaser->setVisible(true);//设置激光的快捷色序
}
else
{
ui->buttonColorLaser->setVisible(false);
}
int combineEmb = g_pSettings->readFromInHMIiFile("HMI/combineEmb").toInt();//是否有双头组合绣功能
//是否显示双头组合按钮
if(combineEmb == 1)
{
ui->buttonCombineEmb->setVisible(true);
}
else
{
ui->buttonCombineEmb->setVisible(false);
}
int threeCombineEmb = g_pSettings->readFromInHMIiFile("HMI/threeCombineEmb").toInt();//是否有三头组合绣功能
//是否显示双头组合按钮
if(threeCombineEmb == 1)
{
ui->buttonThreeCombineEmb->setVisible(true);
}
else
{
ui->buttonThreeCombineEmb->setVisible(false);
}
int headEmb = g_pSettings->readFromInHMIiFile("HMI/headEmb").toInt();//是否有隔头绣功能
//是否显示隔头绣按钮
if(headEmb == 1)
{
ui->buttonHeadEmb->setVisible(true);
}
else
{
ui->buttonHeadEmb->setVisible(false);
}
//右上方色序锁住按钮是否可见
if((g_emMacType == MACHINE_EMB && towel ==1)|| //绣花机带毛巾
(g_emMacType == MACHINE_EMB && coil ==1)|| //绣花机带缠绕
(g_emMacType == MACHINE_EMB && laser ==1) //绣花机带激光
)
{
ui->buttonColorSetLock->setVisible(true);
}
else
{
ui->buttonColorSetLock->setVisible(false);
}
}
if(combineMode != 0)
{
m_combineEmbFirst = combineMode;
}
m_combineEmb = combineMode;
if(m_combineEmb == 0)
{
m_combineEmb = 1;
}
if(combineMode == -1)//双头组合模式清空工作机头缓存
{
//memset(m_headBuf, 0, sizeof(m_headBuf));
ui->buttonHeadEmb->setEnabled(false);//隔头不可用
ui->buttonCombineEmb->setCheckable(true);
ui->buttonCombineEmb->setChecked(true);
}
else
{
ui->buttonHeadEmb->setEnabled(true);//隔头可用
ui->buttonCombineEmb->setCheckable(true);
ui->buttonCombineEmb->setChecked(false);
}
m_beforeColorTable.clear();
m_beforeColorTable.append(table);
m_colorTable.clear();
m_colorTable.append(table);
}
void ColorOrderSetWidget::setTowelHighTable(QByteArray table)
{
m_setType = TYPE_TOWELHIGHSET;
ui->buttonHeadEmb->setVisible(false);//隔头不可用
ui->buttonColorLaser->setVisible(false);
ui->buttonCombineEmb->setVisible(false);
ui->buttonThreeCombineEmb->setVisible(false);
ui->buttonColorSetLock->setVisible(false);
ui->buttonExplanation->setVisible(false);
ui->buttonNeedle->setText(tr("Towel high:"));//毛巾高度:
ui->labelCurColorNum->setText(tr("High index:"));//高度索引:
ui->labelNeedleSelect->setText(tr("High value:"));//高度值:
m_beforeColorTable.clear();
m_beforeColorTable.append(table);
m_colorTable.clear();
m_colorTable.append(table);
}
void ColorOrderSetWidget::setThreeColorTable(QByteArray table,s16 threeCombineMode)
{
if(threeCombineMode != 0)
{
m_threeCombineEmbFirst = threeCombineMode;
}
m_threeCombineEmb = threeCombineMode;
if(m_threeCombineEmb == 0)
{
m_threeCombineEmb = 1;
}
if(m_threeCombineEmb == -1)//双头组合模式清空工作机头缓存
{
//memset(m_headBuf, 0, sizeof(m_headBuf));
ui->buttonHeadEmb->setEnabled(false);//隔头不可用
ui->buttonThreeCombineEmb->setCheckable(true);
ui->buttonThreeCombineEmb->setChecked(true);
}
else
{
ui->buttonHeadEmb->setEnabled(true);//隔头可用
ui->buttonThreeCombineEmb->setCheckable(true);
ui->buttonThreeCombineEmb->setChecked(false);
}
m_beforeColorTable.clear();
m_beforeColorTable.append(table);
m_colorTable.clear();
m_colorTable.append(table);
}
//初始化隔头绣数据
void ColorOrderSetWidget::initHeadBuf(QString filePath)
{
QFile file(filePath + ".fcg");
if(file.exists())//存在fcg文件
{
if(file.open(QIODevice::ReadOnly))
{
QByteArray ary = file.readAll();
if((u32)ary.size() >= sizeof(DataFileHead)+HEADBUF)
{
memcpy(m_headBuf,ary.data()+sizeof(DataFileHead),sizeof(m_headBuf));
}
}
file.close();
}
}
void ColorOrderSetWidget::slotResetHeadBuf(u8 *buf)
{
if(buf != NULL)
{
memcpy(m_headBuf,buf,sizeof(m_headBuf));
}
}
void ColorOrderSetWidget::slotSetEmbDatNeedleTable()
{
int idx = 0;
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();
m_pCurEmbData->setNeedleColorTable(i,idx);
}
else
{
m_pCurEmbData->setNeedleColorTable(i,i);
}
}
}
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;
}
}
// int beforeColor = m_curSelectColor;//上一次选择的色序
m_curSelectColor = (m_curPages - 1) * m_itemPerPage + idx;
//针杆按钮不选中
if(m_pEmbNeedleBtn != NULL)
{
m_pEmbNeedleBtn->setChecked(false);
m_pEmbNeedleBtn->setCheckable(false);
}
if(m_setType == TYPE_COLORSET)//色序设定
{
refreshColorShow(1);
refreshPatternCurColorShow();//右下角花样数据
initNeedleBar();
}
else if(m_setType == TYPE_TOWELHIGHSET)
{
refreshTowelHeightShow();
refreshPatternCurTowelHeightShow();
}
}
//针杆按钮被按下
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);
}
if(m_setType == TYPE_TOWELHIGHSET)//毛巾高度设置
{
if(m_curSelectColor >= 0)
{
if(m_curSelectColor >= m_colorTable.size())
{
return;
}
//int colorInTab = m_colorTable.at(m_curSelectColor);
//if (colorInTab != btnIdx)
{
// 设置数据中的色序
m_colorTable[m_curSelectColor] = btnIdx;
emit siChangeTowelHighTable(m_curSelectColor,btnIdx);
QString str = tr("High ") + QString::number(btnIdx);//高度
ui->labelNeedleSelectValue->setText(str);
//当前色序设定完成后自动跳到下一色序
if(m_curSelectColor < m_colorTable.size() - 1)
{
m_curSelectColor += 1;//花版中的第几个色序
}
refreshTowelHeightShow();
refreshPatternCurTowelHeightShow();
}
}
return;
}
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_LASER)//激光针杆
{
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM;
}
else if(m_colorBeginStepCtrl == DATA_SAWTOOTH)//锯齿针杆
{
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM;
}
else if(m_colorBeginStepCtrl == DATA_COIL)//缠绕针杆
{
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM;
}
else if(m_colorBeginStepCtrl == DATA_CHAIN)//链式针杆
{
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM+SEW_NEEDLE_NUM +RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM;
}
else if(m_colorBeginStepCtrl == DATA_CHENILLE)//毛巾针杆
{
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM;
}
else if(m_colorBeginStepCtrl == DATA_RIBBON)//盘带针杆
{
colorInPage += EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM+SEW_NEEDLE_NUM;
}
if(m_curSelectColor >= 0)
{
int colorInTab = m_colorTable.at(m_curSelectColor); // 文件中的色序
if (colorInTab != colorInPage)
{
m_colorTable[m_curSelectColor] = colorInPage;
emit siChangeColorTable(m_curSelectColor,colorInPage);//针杆写入色序表
}
s16 selIdx = m_colorTable[m_curSelectColor];
if(m_combineEmb == 1&& m_threeCombineEmb == 1)//非组合绣模式
{
getCurColorTabValue(selIdx);
}
QString str;
if(selIdx <= 0)
{
str = tr("Not set");//未设置
}
else
{
if(m_combineEmb == -1)
{
if(selIdx <= num)
{
str = tr("Head 1 Needle ") + QString::number(selIdx);//针杆
}
else
{
str = tr("Head 2 Needle ") + QString::number(selIdx-num);//针杆
}
}
else if (m_threeCombineEmb == -1)//三头组合绣
{
if(selIdx <= num)
{
str = tr("Head 1 Needle ") + QString::number(selIdx);//针杆
}
else if(selIdx>num && selIdx <= num*2)
{
str = tr("Head 2 Needle ") + QString::number(selIdx-num);//针杆
}
else
{
str = tr("Head 3 Needle ") + QString::number(selIdx-num*2);//针杆
}
}
else
{
str = tr("Needle ") + QString::number(selIdx);//针杆
}
}
ui->labelNeedleSelectValue->setText(str);
//当前色序设定完成后自动跳到下一色序
if(m_curSelectColor < m_colorTable.size() - 1)
{
m_curSelectColor += 1;//花版中的第几个色序
}
refreshColorShow(colorInPage);
refreshPatternCurColorShow();
initNeedleBar();//下一个色序针杆变,在这个函数里
}
}
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)//色序设定
{
//非组合模式且针位设置超限
if(m_combineEmb == 1 && m_threeCombineEmb == 1 && m_colorOrderLimitFlag == -1)
{
PromptDialog dlg(this);
dlg.initDialog(PromptDialog::BTN_OK);
dlg.setTitleStr(tr("Prompt"));
dlg.setContentStr(tr("Color order setting is unreasonable, please reset!"));//色序设定不合理,请重新设置!
dlg.exec();
return;
}
if(m_combineEmb == -1)//组合模式设置机头工作缓存区(绣花机才有)
{
int num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
int size = 16;//16个字节
s8 evenVal = 85;//偶 0101 0101
s8 oddVal = -86;//奇 1010 1010
s8 allVal = 0;//全部工作 0000 0000
int colorNum = m_colorTable.size();
for(int i = 0 ; i < colorNum; i++)
{
int needleIdx = m_colorTable.at(i);
for(int j = 0; j < size; j++)
{
if(needleIdx > num)
{
m_headBuf[i*size+j] = evenVal;
}
else if(needleIdx <= 0)
{
m_headBuf[i*size+j] = allVal;
}
else
{
m_headBuf[i*size+j] = oddVal;
}
}
}
}
else if(m_threeCombineEmb ==-1)//三头组合绣
{
int num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
int size = 16;//16个字节
s8 Val1 = 182;// 1011 0110
s8 Val2 = 109;// 0110 1101
s8 Val3 = 219;// 1101 1011
s8 Val4 = 109;// 0110 1101
s8 Val5 = 219;// 1101 1011
s8 Val6 = 182;// 1011 0110
s8 Val7 = 219;// 1101 1011
s8 Val8 = 182;// 1011 0110
s8 Val9 = 109;// 0110 1101
int colorNum = m_colorTable.size();
for(int i = 0 ; i < colorNum; i++)
{
int needleIdx = m_colorTable.at(i);
for(int j = 0; j < size; j++)
{
if(needleIdx <= num)
{
int k= j%3;
if(k == 0)
{
m_headBuf[i*size+j] = Val1;
}
else if(k == 1)
{
m_headBuf[i*size+j] = Val2;
}
else if(k == 2)
{
m_headBuf[i*size+j] = Val3;
}
}
else if(needleIdx <= num*2 && needleIdx > num)
{
int k= j%3;
if(k == 0)
{
m_headBuf[i*size+j] = Val4;
}
else if(k == 1)
{
m_headBuf[i*size+j] = Val5;
}
else if(k == 2)
{
m_headBuf[i*size+j] = Val6;
}
}
else
{
int k= j%3;
if(k == 0)
{
m_headBuf[i*size+j] = Val7;
}
else if(k == 1)
{
m_headBuf[i*size+j] = Val8;
}
else if(k == 2)
{
m_headBuf[i*size+j] = Val9;
}
}
}
}
}
emit siBackHome(m_combineEmb,m_threeCombineEmb);
}
else if(m_setType == TYPE_TOWELHIGHSET)
{
emit siTowelHighBackHome();
}
this->hide();
}
void ColorOrderSetWidget::on_buttonCancel_clicked()
{
if(m_combineEmbFirst == 1 || m_threeCombineEmbFirst == 1)//非组合绣模式 或者三头组合绣模式
{
ui->buttonCombineEmb->setCheckable(true);
ui->buttonCombineEmb->setChecked(false);
ui->buttonHeadEmb->setEnabled(true);
siSetHeadEmbBtnEnable(true);
}
else//组合绣模式
{
ui->buttonCombineEmb->setCheckable(true);
ui->buttonCombineEmb->setChecked(true);
ui->buttonHeadEmb->setEnabled(false);
siSetHeadEmbBtnEnable(false);
}
//恢复之前的色序表
if(m_setType == TYPE_COLORSET)
{
emit siCancelChangeColor(m_beforeColorTable);
}
else if(m_setType == TYPE_TOWELHIGHSET)
{
emit siCancelChangeTowelHigh(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_TOWELHIGHSET)
{
emit siChangeTowelHighTable(i,colorInTab);
}
}
if(m_setType == TYPE_COLORSET)
{
m_pCurEmbData->setGreyAreaRange(0,m_pCurEmbData->getStitchNums());
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1, 1); // 重绘
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
ui->labelPatternView->setPixmap(patternPix);
m_curSelectColor = -1;
refreshColorShow(1);
}
else if(m_setType == TYPE_TOWELHIGHSET)
{
m_curSelectColor = -1;
refreshTowelHeightShow();
}
}
//色序清空
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_TOWELHIGHSET)
{
emit siChangeTowelHighTable(i,colorInTab);
}
}
if(m_setType == TYPE_COLORSET)
{
m_pCurEmbData->setGreyAreaRange(0,m_pCurEmbData->getStitchNums());
m_pCurEmbData->setDispAreaRange(0,0);
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1, 1); // 重绘
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
ui->labelPatternView->setPixmap(patternPix);
m_curSelectColor = -1;
refreshColorShow();
}
else if(m_setType == TYPE_TOWELHIGHSET)
{
m_curSelectColor = -1;
refreshTowelHeightShow();
}
}
void ColorOrderSetWidget::on_buttonHeadEmb_clicked()
{
emit siHeadEmb();//发送隔头绣设置的信号
}
void ColorOrderSetWidget::on_buttonCombineEmb_clicked()
{
m_combineEmb *= -1;
if(m_combineEmb == 1)//非双头组合绣模式
{
ui->buttonCombineEmb->setCheckable(true);//setCheckable(true)为属性,表示可以选中
ui->buttonCombineEmb->setChecked(false);
ui->buttonHeadEmb->setEnabled(true);//false 按钮就不可点击设置成true按钮就可以点击。
emit siSetHeadEmbBtnEnable(true);
}
else//双头组合绣模式
{
m_threeCombineEmb = 1;
ui->buttonThreeCombineEmb->setCheckable(true);//setCheckable(true)为属性,表示可以选中
ui->buttonThreeCombineEmb->setChecked(false);
ui->buttonCombineEmb->setCheckable(true);
ui->buttonCombineEmb->setChecked(true);//setCheckedtrue为属性的值表示已经选中
ui->buttonHeadEmb->setEnabled(false);
emit siSetHeadEmbBtnEnable(false);
}
initNeedleBar();
refreshColorShow();
}
void ColorOrderSetWidget::on_buttonThreeCombineEmb_clicked()
{
m_threeCombineEmb *= -1;
if(m_threeCombineEmb == 1)//非三头组合绣模式
{
ui->buttonThreeCombineEmb->setCheckable(true);//setCheckable(true)为属性,表示可以选中
ui->buttonThreeCombineEmb->setChecked(false);
ui->buttonHeadEmb->setEnabled(true);//false 按钮就不可点击设置成true按钮就可以点击。
emit siSetHeadEmbBtnEnable(true);
}
else//三头组合绣模式
{
m_combineEmb = 1;
ui->buttonCombineEmb->setCheckable(true);//setCheckable(true)为属性,表示可以选中
ui->buttonCombineEmb->setChecked(false);
ui->buttonThreeCombineEmb->setCheckable(true);
ui->buttonThreeCombineEmb->setChecked(true);//setCheckedtrue为属性的值表示已经选中
ui->buttonHeadEmb->setEnabled(false);
emit siSetHeadEmbBtnEnable(false);
}
initNeedleBar();
refreshColorShow();
}
void ColorOrderSetWidget::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
{
m_mousePressX = e->x();
m_mousePressY = e->y();
m_mouseReleaseX = 0;
m_mouseReleaseY = 0;
}
}
void ColorOrderSetWidget::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
{
m_mouseReleaseX = e->x();
m_mouseReleaseY = e->y();
}
int width = this->width();
int height = this->height();
if ((m_mousePressX >= 0 && m_mousePressX <= 100) &&
((m_mousePressY >= (height - 100)) && m_mousePressY <= height) &&
((m_mouseReleaseX >= (width - 100)) && m_mouseReleaseX <= width) &&
((m_mouseReleaseY >= (height - 100)) && m_mouseReleaseY <= height))
{
MainWidgetFunction mainFunction;
QString usbPath;//优盘路径
usbPath = mainFunction.detectUsb();//优盘检测
if(usbPath.length() <= 0)
{
//优盘不存在
return;
}
else
{
QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap
QString name_pc = usbPath + "EMB" + //
QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间
+"_"+
QDateTime::currentDateTime().toString("hhmmss") + ".png";
pixmap.save(name_pc,"png"); // 路径
}
}
m_mousePressX = 0;
m_mousePressY = 0;
m_mouseReleaseX = 0;
m_mouseReleaseY = 0;
}
//色序设定是否解锁,锁住时针杆不可切换,未锁住时针杆可切换
void ColorOrderSetWidget::on_buttonColorSetLock_clicked()
{
m_colorSetBtnLockFlag *= -1;
refreshLockBtn();
}
//切换成不同的针杆显示
void ColorOrderSetWidget::on_buttonNeedle_clicked()
{
int towel = g_pSettings->readFromInHMIiFile("HMI/towel").toInt();//是否有毛巾功能
int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
int laser = g_pSettings->readFromInHMIiFile("HMI/laser").toInt();//是否有激光功能
ui->buttonExplanation->setEnabled(false);
switch (m_colorBeginStepCtrl)
{
case DATA_CHAIN:
{
if(coil == 1)
{
m_colorBeginStepCtrl = DATA_SAWTOOTH;
ui->buttonExplanation->setEnabled(true);
}
else
{
//纯毛巾时不会带激光
if(laser == 1)
{
m_colorBeginStepCtrl = DATA_LASER;//缠绕变激光
}
else if(g_emProductType == PRODUCT_CHEN)//纯毛巾
{
m_colorBeginStepCtrl = DATA_CHENILLE;
}
else
{
m_colorBeginStepCtrl = DATA_EMB;
}
}
break;
}
case DATA_LASER:
{
m_colorBeginStepCtrl = DATA_EMB;
break;
}
case DATA_EMB://第一次进来是平绣
{
if((towel == 1 && coil != 1) ||
(coil == 1 && towel == 1)||
(g_emProductType == PRODUCT_CHEN)
)
{
m_colorBeginStepCtrl = DATA_CHENILLE;
}
if(coil == 1 && towel != 1)
{
m_colorBeginStepCtrl = DATA_SAWTOOTH;
ui->buttonExplanation->setEnabled(true);
}
if(coil != 1 && towel != 1)
{
if(laser == 1)
{
m_colorBeginStepCtrl = DATA_LASER;
}
}
break;
}
case DATA_CHENILLE:
{
m_colorBeginStepCtrl = DATA_CHAIN;
break;
}
case DATA_SAWTOOTH:
{
m_colorBeginStepCtrl = DATA_RIBBON;
ui->buttonExplanation->setEnabled(true);
break;
}
case DATA_RIBBON:
{
m_colorBeginStepCtrl = DATA_COIL;
ui->buttonExplanation->setEnabled(true);
break;
}
case DATA_COIL:
{
if(laser == 1)
{
m_colorBeginStepCtrl = DATA_LASER;//缠绕变激光
}
else
{
m_colorBeginStepCtrl = DATA_EMB;
}
break;
}
default:
m_colorBeginStepCtrl = DATA_EMB;
break;
}
switchNeedleBar();
}
//缠绕绣的说明按钮
void ColorOrderSetWidget::on_buttonExplanation_clicked()
{
if(m_colorBeginStepCtrl == DATA_COIL)
{
PromptDialog dlg(this);
dlg.initDialog(PromptDialog::BTN_OK);
dlg.setTitleStr(tr("Coil function description"));//缠绕功能说明
dlg.setContentStr(tr("W1: Left-handed 1; W2: Left-handed 2; W3: Left-handed 3; W4:Left-handed 4;W5:Right-handed 1;W6:Right-handed 2;W7:Right-handed 3;W8:Right-handed 4;W9:Winding plain embroidery"));//W1:左旋1;W2:左旋2;W3:左旋3;W4:左旋4;
dlg.exec();
}
else if (m_colorBeginStepCtrl == DATA_RIBBON)
{
PromptDialog dlg(this);
dlg.initDialog(PromptDialog::BTN_OK);
dlg.setTitleStr(tr("Ribbon function description"));//盘带功能说明
dlg.setContentStr(tr("R1: Normal 1; R2: Pleated embroidery"));//盘带1是正常,2是褶绣
dlg.exec();
}
else if (m_colorBeginStepCtrl == DATA_SAWTOOTH)
{
PromptDialog dlg(this);
dlg.initDialog(PromptDialog::BTN_OK);
dlg.setTitleStr(tr("Sawtooh function description")); //锯齿功能说明
dlg.setContentStr(tr("Z1: Each needle swings once; Z2: The same as Z1, with additional embroidery frame compensation;Z3: The needle will swing when it is dropped in place, and the needle will not swing when it is inserted; Z4: One swing per needle and one swing per three needles alternately; Z5: The needle will swing when it is dropped in place, and the needle will not swing when it is inserted; Z6: Swing once every two stitches"));//Z1:每针摆动一次;Z2:同Z1,附加绣框补偿;
//Z3:原地落两针摆动,进针不摆;Z4:每针摆动一次和每三针摆动一次交替进行;Z5:原地落一针摆动,进针不摆;Z6:每两针摆动一次
dlg.exec();
}
}
//激光色序快捷按钮
void ColorOrderSetWidget::on_buttonColorLaser_clicked()
{
//快捷设置色序按钮是激光色序5
int colorInPage = EMB_NEEDLE_NUM + PUNCH_NEEDLE_NUM +SEW_NEEDLE_NUM+RIBBON_NEEDLE_NUM+TOWEL_NEEDLE_NUM+CHAIN_NEEDLE_NUM+COIL_NEEDLE_NUM+REV2_NEEDLE_NUM+SAWTOOTH_NEEDLE_NUM+REV3_NEEDLE_NUM+LASER_NEEDLE_NUM-5;
if(m_curSelectColor >= 0)
{
int colorInTab = m_colorTable.at(m_curSelectColor); // 文件中的色序
if (colorInTab != colorInPage)
{
m_colorTable[m_curSelectColor] = colorInPage;
emit siChangeColorTable(m_curSelectColor,colorInPage);//针杆写入色序表
}
//当前色序设定完成后自动跳到下一色序
if(m_curSelectColor < m_colorTable.size() - 1)
{
m_curSelectColor += 1;//花版中的第几个色序
}
refreshColorShow(colorInPage);
refreshPatternCurColorShow();
initNeedleBar();//下一个色序针杆变,在这个函数里
}
}
//是否刷新色序颜色显示
void ColorOrderSetWidget::on_buttonRefreshColorOrder_clicked()
{
PromptDialog dlg(this);
dlg.initDialog(PromptDialog::BTN_OK);
dlg.setTitleStr(tr("Description"));//说明
m_refreshColorOrder *=-1;
if(m_refreshColorOrder == -1)
{
dlg.setContentStr(tr("Turn off color sequence refresh function"));//关闭色序刷新功能
dlg.exec();
ui->buttonRefreshColorOrder->setCheckable(true);
ui->buttonRefreshColorOrder->setChecked(true); // 设置按钮的初始状态为未选中
}
else
{
dlg.setContentStr(tr("Enable color sequence refresh function"));//打开色序刷新功能
dlg.exec();
ui->buttonRefreshColorOrder->setCheckable(false);
ui->buttonRefreshColorOrder->setChecked(false); // 设置按钮的初始状态为未选中
m_greyBeginStep = 0;//灰色起始
m_greyEndStep = m_pCurEmbData->getStitchNums(); //灰色结束
m_pCurEmbData->setGreyAreaRange(m_greyBeginStep,m_greyEndStep);
m_pCurEmbData->setDispMode(EmbData::DISP_ALL_AREA, 1, 1); // 重新画灰图
QPixmap patternPix = m_pCurEmbData->getPreviewImage();
ui->labelPatternView->setPixmap(patternPix);
}
}