| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421 | 
							- #include "CGH_Printer.h"
 
- #include <qdatetime.h>
 
- #include <qlabel.h>
 
- #include <thread>
 
- #include "CGH_State.h"
 
- #include <fstream>
 
- #include <map>
 
- #include <iostream>
 
- // #include "CGH_CoordinateThread.h"
 
- #include <math.h>
 
- #include <io.h>
 
- #include <set>
 
- #include <QMessageBox>
 
- #include <QFileDialog>
 
- #include <cstdio>
 
- #include <QButtonGroup>
 
- #include <stdlib.h>
 
- #include <time.h>
 
- #include <sstream>
 
- #define FREEBUF(x) {if(x!=NULL){delete [] x;x=NULL;}}
 
- CGH_Printer* gcam = NULL;// 线程函数中使用的全局变量
 
- #include <QDebug>
 
- CGH_Printer::CGH_Printer(QWidget* parent)
 
-     : QMainWindow(parent)
 
- {
 
-     ui.setupUi(this);
 
-     //----------------------------------------修改tabwidget的颜色
 
-     ////widget 背景色属性
 
-     //ui.tabWidget->setAttribute(Qt::WA_StyledBackground);
 
-     ////标题栏红色背景,tab选中蓝色,未选中灰色
 
-     //ui.tabWidget->setStyleSheet("QTabWidget#tabWidget{background-color:rgb(255,0,0);}\
 
-     //                             QTabBar::tab{background-color:rgb(220,200,180);color:rgb(0,0,0);font:10pt '新宋体'}\
 
-     //                             QTabBar::tab::selected{background-color:rgb(0,100,200);color:rgb(255,0,0);font:10pt '新宋体'}");
 
-     ////绿色背景
 
-     //ui.tab->setStyleSheet("QWidget#tab{"
 
-     //    "background-color:#00ff00;"
 
-     //    "border:1px solid #eeeeee;}");
 
-     //--------------------------------------------------------------------------------------------------------------
 
-     Desktop = new QDesktopWidget();
 
-     QRect MainWindow = Desktop->screenGeometry(0);
 
-     this->setGeometry(MainWindow);
 
-     this->move((MainWindow.width()-this->width())/2, (MainWindow.height()-this->height())/2);
 
-     initVariables();
 
-     initConfigure();
 
-     initSlots();
 
-     timer_calendar->start(500);// 定时器的刷新间隔
 
-     // CheckState->start();// 线程调用
 
-     // Coordinate->start();// 线程调用
 
-     
 
- }
 
- void CGH_Printer::initVariables()
 
- {
 
-     // 定时器对象的初始化
 
-     timer_calendar = new QTimer();
 
-     timer_WorkState = new QTimer();// 工作状态检测
 
-     timer_Expose = new QTimer();
 
-     timer_Work = new QTimer();
 
-     timer_Work->setInterval(100);
 
-     timer_WorkState->setInterval(100);
 
-     // 线程对象的初始化
 
-     // CheckState = new CGH_CheckStateThread(this);// 硬件状态检测线程的初始化
 
-     m_Printer = new PrintThread(this);
 
-     // Coordinate = new CGH_CoordinateThread(this);// 平移台坐标更新线程的初始化
 
-     // 状态检测的初始化
 
-     icon_Red = new QImage();
 
-     icon_Green = new QImage();
 
-     icon_Red->load(":/CGH_Printer/Configure/IMG/Redlight.png");
 
-     icon_Green->load(":/CGH_Printer/Configure/IMG/Greenlight.png");
 
-     curShutterState = false;
 
-     error_messages.append(SHUTTER_ERROR_MESSAGE); 
 
-     curSLMState = false;
 
-     error_messages.append(SLM_ERROR_MESSAGE);
 
-     curTransTableState = false;
 
-     error_messages.append(TRANSTABLE_ERROR_MESSAGE);
 
-     curCCDState = false;
 
-     error_messages.append(CCD_ERROR_MESSAGE);
 
-     curShutterWorkState = false;
 
-     // 快门对象的初始化
 
-     MyShutter = new CGH_Shutter();
 
-     // t1 = new QElapsedTimer();
 
-     // CCD变量的初始化
 
-     m_pCameraInfos = QCameraInfo::availableCameras();
 
-     m_pCamera = new QCamera(this);
 
-     m_pCameraCapture = new QCameraImageCapture(m_pCamera);
 
-     m_pViewfinder = new QCameraViewfinder(ui.widgetCCD);
 
-     m_pViewfinder->resize(ui.widgetCCD->size());
 
-     m_pCameraOpen = FALSE;
 
-     // 平移台变量的初始化
 
-     ControllerID = -1;// 控制器ID
 
-     DeviceNum = 0;// 设备数量
 
-     ControllerIDN = new char[BufferSize];// 接受IDN字符的缓冲区
 
-     sAxis = "1";// 轴标识符
 
-     // 工程对象的初始化
 
-     pButtonGroup = new QButtonGroup();
 
-     pButtonGroup->setExclusive(true);
 
-     // SLM显示弹窗对象的初始化
 
-     // Desktop = new QDesktopWidget();
 
-     labelPrint = new QLabel();
 
-     PRINTSTOP = FALSE;
 
- }
 
- void CGH_Printer::initConfigure()
 
- {
 
-     // 路径的初始化
 
-     ProjectType = ".pro";
 
-     ConfigureName = "Configure.txt";
 
-     absPath = (QCoreApplication::applicationDirPath()).toStdString();
 
-     relConfigurePath = "../Configure";
 
-     relProjectPath = "../Project";
 
-     relCapturePath = "../Capture";
 
-     relResourcesPath = "../Resources";
 
-     absConfigurePath = absPath + "/" + relConfigurePath;
 
-     absProjectPath = absPath + "/" + relProjectPath;
 
-     absCapturePath = absPath + "/" + relCapturePath;
 
-     absResourcesPath = absPath + "/" + relResourcesPath;
 
-     // 工作状态的初始化
 
-     ui.labelWorkState->setText("就绪");
 
-     // 打印进度条的初始化
 
-     ui.progressBarPrint->setMinimum(0);
 
-     ui.progressBarPrint->setMaximum(100);
 
-     ui.progressBarPrint->setValue(0);
 
-     //double dProgress = (ui.progressBarPrint->value() - ui.progressBarPrint->minimum()) * 100.0
 
-        // / (ui.progressBarPrint->maximum() - ui.progressBarPrint->minimum());
 
-     //ui.progressBarPrint->setFormat(QString::fromLocal8Bit("当前进度为:%1%").arg(QString::number(dProgress, 'f', 50)));
 
-     //ui.progressBarPrint->setAlignment(Qt::AlignRight | Qt::AlignVCenter);  // 对齐方式
 
-     // Shutter状态的初始化
 
-     // MyShutter->connect();
 
-     curShutterState = MyShutter->isconnected();
 
-     if (curShutterState)
 
-     {
 
-         error_messages.removeOne(SHUTTER_ERROR_MESSAGE);
 
-         ui.labelShutter->clear();
 
-         ui.labelShutter->setPixmap(QPixmap::fromImage(*icon_Green));
 
-     }
 
-     // SLM状态的初始化
 
-     //int SLM_Num = Desktop->numScreens();//获取当前环境屏幕个数
 
-     if (Desktop->numScreens() == 2)
 
-     {
 
-         curSLMState = true;
 
-         error_messages.removeOne(SLM_ERROR_MESSAGE);
 
-         ui.labelSLM->clear();
 
-         ui.labelSLM->setPixmap(QPixmap::fromImage(*icon_Green));
 
-         SLMDisplay();
 
-     }
 
-     // CCD设备的初始化
 
-     if (m_pCameraInfos.size() > 0)
 
-     {
 
-         curCCDState = true;
 
-         error_messages.removeOne(CCD_ERROR_MESSAGE);
 
-         ui.labelCCD->clear();
 
-         ui.labelCCD->setPixmap(QPixmap::fromImage(*icon_Green));
 
-         ComboDevice();
 
-     }
 
-     // 平移台控制的初始化
 
-     // 通讯连接
 
-     ControllerID = PI_OpenRS232DaisyChain(8, 115200, &DeviceNum, ControllerIDN, BufferSize);
 
-     // 如果成功打开菊花链,则开始进行通讯连接
 
-     if (ControllerID != -1)
 
-     {
 
-         curTransTableState = true;
 
-         error_messages.removeOne(TRANSTABLE_ERROR_MESSAGE);
 
-         ui.labelStages->clear();
 
-         ui.labelStages->setPixmap(QPixmap::fromImage(*icon_Green));
 
-         PITransTableInit();
 
-     }
 
-     for (const QString msg : error_messages) {
 
-         ui.textEditWarning->insertPlainText(msg + '\n');
 
-     }
 
-     ReadConfigure();
 
-     // 以下的语句出错,我暂时屏蔽了
 
-   //  loadHistory(); 
 
- }
 
- void CGH_Printer::initSlots()
 
- {
 
-     connect(timer_calendar, SIGNAL(timeout()), this, SLOT(timerUpdate()));
 
-     connect(timer_WorkState, SIGNAL(timeout()), this, SLOT(WorkStateUpdate()));
 
-     connect(timer_Expose, SIGNAL(timeout()), this, SLOT(ExposeUpdate()));
 
-     connect(timer_Work, SIGNAL(timeout()), this, SLOT(WorkTimeUpdate()));
 
-     // 作业页面
 
-     connect(ui.pushButtonNew, SIGNAL(clicked()), this, SLOT(NewProject()));
 
-     connect(ui.pushButtonModify, SIGNAL(clicked()), this, SLOT(ModifyProject()));
 
-     connect(ui.pushButtonDelete, SIGNAL(clicked()), this, SLOT(DeleteProject()));
 
-     connect(ui.pushButtonFeed, SIGNAL(clicked()), this, SLOT(Feed()));
 
-     connect(ui.pushButtonUnderfeed, SIGNAL(clicked()), this, SLOT(Underfeed()));
 
-     connect(ui.pushButtonPrint, SIGNAL(clicked()), this, SLOT(PrintTemp()));
 
-     connect(ui.pushButtonPrintOK, SIGNAL(clicked()), this, SLOT(PrintProgress()));
 
-     connect(ui.pushButtonPrintCancel, SIGNAL(clicked()), this, SLOT(PrintStop()));
 
-     connect(ui.pushButtonPreview, SIGNAL(clicked()), this, SLOT(Preview()));
 
-     //connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(Preview()));//添加一个槽函数,页面切换打开相机
 
-     connect(ui.pushButtonSnapshot, SIGNAL(clicked()), this, SLOT(Snapshot()));
 
-     connect(ui.comboBoxDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeDevice()));
 
-     connect(ui.comboBoxFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeFormat()));
 
-     connect(ui.pushButtonLoad, SIGNAL(clicked()), this, SLOT(CGHLoad()));
 
-     // *** 电控平移台 *** //
 
-     connect(ui.pushButtonUp, SIGNAL(clicked()), this, SLOT(MoveUp()));
 
-     connect(ui.pushButtonDown, SIGNAL(clicked()), this, SLOT(MoveDown()));
 
-     connect(ui.pushButtonLeft, SIGNAL(clicked()), this, SLOT(MoveLeft()));
 
-     connect(ui.pushButtonRight, SIGNAL(clicked()), this, SLOT(MoveRight()));
 
-     connect(ui.pushButtonTranstableStop, SIGNAL(clicked()), this, SLOT(TranstableStop()));
 
-     connect(ui.pushButtonBlank, SIGNAL(clicked()), this, SLOT(MoveZero()));
 
-     // *** 电子快门 *** //
 
-     connect(ui.pushButtonShutterExpose, SIGNAL(clicked()), this, SLOT(Expose()));
 
-     connect(ui.pushButtonShutterStop, SIGNAL(clicked()), this, SLOT(ShutterStop()));
 
-     // *** 配置保存 *** //
 
-     connect(ui.pushButtonTempSaved, SIGNAL(clicked()), this, SLOT(TempSaved()));
 
-     connect(ui.pushButtonPermSaved, SIGNAL(clicked()), this, SLOT(PermSaved()));
 
-     
 
- }
 
- void CGH_Printer::ReadConfigure()
 
- {
 
-     // 配置文件加载
 
-     ifstream infile;
 
-     map<string, string> maps_Configure;
 
-     string name_temp, value_temp;
 
-     infile.open(absConfigurePath + "/" + ConfigureName);
 
-     if (infile)
 
-     {
 
-         while (!infile.eof())
 
-         {
 
-             infile >> name_temp >> value_temp;
 
-             maps_Configure[name_temp] = value_temp;
 
-         }
 
-     }
 
-     infile.close();
 
-     // 参数设置
 
-     ui.lineEditMoveUp->setText(QString::fromStdString(maps_Configure["前"]));
 
-     ui.lineEditMoveDown->setText(QString::fromStdString(maps_Configure["后"]));
 
-     ui.lineEditMoveLeft->setText(QString::fromStdString(maps_Configure["左"]));
 
-     ui.lineEditMoveRight->setText(QString::fromStdString(maps_Configure["右"]));
 
-     ui.lineEditShutter->setText(QString::fromStdString(maps_Configure["时间"]));
 
-     ReadTransTableConfigue();
 
-     // 设置曝光时间输入为整数
 
-     QIntValidator* aIntValidator;
 
-     aIntValidator = new QIntValidator(this);
 
-     ui.lineEditShutter->setValidator(aIntValidator);
 
- 	ui.lineEditPrinted->setText("00:00:00");
 
- 	ui.lineEditStart->setText("00:00:00");
 
- }
 
- void CGH_Printer::loadHistory()
 
- {
 
-     _finddata_t data;
 
-     auto handle = _findfirst((absProjectPath + "/*.*").c_str(), &data);// 读取第一文件或文件夹
 
-     do
 
-     {
 
-         string fullname = data.name;// 文件名
 
-         // 去掉文件名后缀
 
-         int length = strlen(fullname.c_str()) - strlen(ProjectType.c_str());
 
-         string name = fullname.substr(0, length);
 
-         if (fullname.rfind(ProjectType) == fullname.size() - ProjectType.size())// 判断后缀是否为.type
 
-         {
 
-             addProject(name);
 
-         }
 
-     } while (_findnext(handle, &data) == 0);
 
-     _findclose(handle);
 
- }
 
- // 时间更新
 
- void CGH_Printer::timerUpdate()
 
- {
 
-     QDateTime time = QDateTime::currentDateTime();
 
-     QString str = time.toString("yyyy-MM-dd \nhh:mm:ss");
 
-     ui.labelDatetime->setText(str);
 
- }
 
- //// 硬件工作状态检测
 
- //void CGH_Printer::StateUpdate(int statetype)
 
- //{
 
- //    // SLM工作状态检测
 
- //    if (statetype == SLM_ERROR)
 
- //    {
 
- //        curSLMState = false;
 
- //        delete Desktop;
 
- //        delete labelPrint;
 
- //
 
- //        ui.labelSLM->clear();
 
- //        ui.labelSLM->setPixmap(QPixmap::fromImage(*icon_Red));
 
- //        error_messages.append(SLM_ERROR_MESSAGE);
 
- //    }
 
- //    else if (statetype == SLM_OK)
 
- //    {
 
- //        curSLMState = true;
 
- //        Desktop = new QDesktopWidget();
 
- //        labelPrint = new QLabel();
 
- //        SLMDisplay();
 
- //
 
- //        ui.labelSLM->clear();
 
- //        ui.labelSLM->setPixmap(QPixmap::fromImage(*icon_Green));
 
- //        error_messages.removeOne(SLM_ERROR_MESSAGE);
 
- //    }
 
- //
 
- //    // 电子快门工作状态检测
 
- //    if (statetype == SHUTTER_ERROR)
 
- //    {
 
- //        curShutterState = false;
 
- //        delete MyShutter;
 
- //
 
- //        ui.labelShutter->clear();
 
- //        ui.labelShutter->setPixmap(QPixmap::fromImage(*icon_Red));
 
- //        error_messages.append(SHUTTER_ERROR_MESSAGE);
 
- //    }
 
- //    else if (statetype == SHUTTER_OK)
 
- //    {
 
- //        MyShutter = new CGH_Shutter();
 
- //        MyShutter->connect();
 
- //        curShutterState = MyShutter->isconnected();
 
- //
 
- //        ui.labelShutter->clear();
 
- //        ui.labelShutter->setPixmap(QPixmap::fromImage(*icon_Green));
 
- //        error_messages.removeOne(SHUTTER_ERROR_MESSAGE);
 
- //    }
 
- //
 
- //    // 平移台工作状态检测
 
- //    if (statetype == TRANSTABLE_ERROR)
 
- //    {
 
- //        curTransTableState = false;
 
- //        ControllerID = -1;
 
- //        DeviceNum = 0;
 
- //        delete ControllerIDN;
 
- //
 
- //        ui.labelStages->clear();
 
- //        ui.labelStages->setPixmap(QPixmap::fromImage(*icon_Red));
 
- //        error_messages.append(TRANSTABLE_ERROR_MESSAGE);
 
- //    }
 
- //    else if (statetype == TRANSTABLE_OK)
 
- //    {
 
- //        ControllerID = PI_OpenRS232DaisyChain(8, 115200, &DeviceNum, ControllerIDN, BufferSize);
 
- //        if (ControllerID != -1)
 
- //        {
 
- //            curTransTableState = true;
 
- //            PITransTableInit();
 
- //
 
- //            ui.labelStages->clear();
 
- //            ui.labelStages->setPixmap(QPixmap::fromImage(*icon_Green));
 
- //            error_messages.removeOne(TRANSTABLE_ERROR_MESSAGE);
 
- //        }
 
- //    }
 
- //
 
- //    // CCD工作状态检测
 
- //	if (statetype == CCD_ERROR)
 
- //	{
 
- //        curCCDState = false;
 
- //        ComboDevice();
 
- //
 
- //        ui.labelCCD->clear();
 
- //		ui.labelCCD->setPixmap(QPixmap::fromImage(*icon_Red));
 
- //		error_messages.append(CCD_ERROR_MESSAGE);
 
- //	}
 
- //	else if (statetype == CCD_OK)
 
- //	{
 
- //        curCCDState = true;
 
- //        ComboDevice();
 
- //
 
- //        ui.labelCCD->clear();
 
- //		ui.labelCCD->setPixmap(QPixmap::fromImage(*icon_Green));
 
- //		error_messages.removeOne(CCD_ERROR_MESSAGE);
 
- //	}
 
- //
 
- //    ui.textEditWarning->clear();
 
- //    for (const QString msg : error_messages) {
 
- //        ui.textEditWarning->insertPlainText(msg + '\n');
 
- //    }
 
- //}
 
- void CGH_Printer::BusyState()
 
- {
 
-     ui.labelStateMarking->setPixmap(QPixmap(":/CGH_Printer/Configure/IMG/Parallelogram_Red.png"));
 
-     ui.labelWorkState->setText("正忙");
 
- }
 
- void CGH_Printer::ReadyState()
 
- {
 
-     ui.labelStateMarking->setPixmap(QPixmap(":/CGH_Printer/Configure/IMG/Parallelogram_Green.png"));
 
-     ui.labelWorkState->setText("就绪");
 
- }
 
- void CGH_Printer::ReadTransTableConfigue()
 
- {
 
- 	if (ControllerID != -1)
 
- 	{
 
- 		PI_qACC(Devices[0], sAxis.c_str(), &AccX);
 
- 		PI_qACC(Devices[1], sAxis.c_str(), &AccY);
 
- 		PI_qDEC(Devices[0], sAxis.c_str(), &DecX);
 
- 		PI_qDEC(Devices[1], sAxis.c_str(), &DecY);
 
- 		PI_qVEL(Devices[0], sAxis.c_str(), &MaxvX);
 
- 		PI_qVEL(Devices[1], sAxis.c_str(), &MaxvY);
 
- 		ui.lineEditAccX->setText(QString::number(AccX, 'f', 3));
 
- 		ui.lineEditAccY->setText(QString::number(AccY, 'f', 3));
 
- 		ui.lineEditDecX->setText(QString::number(DecX, 'f', 3));
 
- 		ui.lineEditDecY->setText(QString::number(DecY, 'f', 3));
 
- 		ui.lineEditMaxvX->setText(QString::number(MaxvX, 'f', 3));
 
- 		ui.lineEditMaxvY->setText(QString::number(MaxvY, 'f', 3));
 
- 	}
 
- }
 
- void CGH_Printer::WorkStateUpdate()
 
- {
 
-     BOOL isMoving_sAxisX = FALSE;
 
-     BOOL isMoving_sAxisY = FALSE;
 
-     if (curTransTableState)
 
-     {
 
- 		PI_IsMoving(Devices[0], sAxis.c_str(), &isMoving_sAxisX);
 
- 		PI_IsMoving(Devices[1], sAxis.c_str(), &isMoving_sAxisY);
 
-     }
 
-     if (isMoving_sAxisX || isMoving_sAxisY)
 
-     {
 
-         CoordinateUpdate();
 
-     }
 
-     else if (!isMoving_sAxisX && !isMoving_sAxisY && !curShutterWorkState)
 
-     {
 
-         ReadyState();
 
-         timer_WorkState->stop();
 
-     }
 
- }
 
- void CGH_Printer::MoveUp()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         double offset = ui.lineEditMoveUp->text().toDouble();
 
-         offset = -1 * offset;
 
-         if (!PI_MVR(Devices[1], sAxis.c_str(), &offset))
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能移动到目标!"));
 
-         }
 
-         else
 
-         {
 
-             BusyState();
 
-             timer_WorkState->start();
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::MoveDown()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         double offset = ui.lineEditMoveDown->text().toDouble();
 
-         if (!PI_MVR(Devices[1], sAxis.c_str(), &offset))
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能移动到目标!"));
 
-         }
 
-         else
 
-         {
 
-             BusyState();
 
-             timer_WorkState->start();
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- // 平移台左移
 
- void CGH_Printer::MoveLeft()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         double offset = ui.lineEditMoveLeft->text().toDouble();
 
-         if (!PI_MVR(Devices[0], sAxis.c_str(), &offset))
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能移动到目标!"));
 
-         }
 
-         else
 
-         {
 
-             BusyState();
 
-             timer_WorkState->start();
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- // 平移台右移
 
- void CGH_Printer::MoveRight()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         double offset = ui.lineEditMoveRight->text().toDouble();
 
-         offset = -1 * offset;
 
-         if (!PI_MVR(Devices[0], sAxis.c_str(), &offset))
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能移动到目标!"));
 
-         }
 
-         else
 
-         {
 
-             BusyState();
 
-             timer_WorkState->start();
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::MoveZero()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         bool isMoving_sAxisX = TRUE;
 
-         bool isMoving_sAxisY = TRUE;
 
-         isMoving_sAxisX = PI_GOH(Devices[0], sAxis.c_str());
 
-         isMoving_sAxisY = PI_GOH(Devices[1], sAxis.c_str());
 
-         if (isMoving_sAxisX || isMoving_sAxisY)
 
-         {
 
- 			BusyState();
 
- 			timer_WorkState->start();
 
-         }
 
-         else
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能移动到零点!"));
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::TranstableStop()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         PI_HLT(Devices[0], sAxis.c_str());
 
-         PI_HLT(Devices[1], sAxis.c_str());
 
-         timer_WorkState->start();
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::Expose()
 
- {
 
-     if (curShutterState)
 
-     {
 
-         BusyState();
 
-         int Ext = ui.lineEditShutter->text().toInt();// 快门曝光时间
 
-         timer_Expose->setInterval(Ext);
 
-         MyShutter->open();
 
-         curShutterWorkState = true;
 
-         timer_Expose->start();
 
-         timer_WorkState->start();
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("电子快门未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::ShutterStop()
 
- {
 
-     if (curShutterState)
 
-     {
 
-         MyShutter->close();
 
-         curShutterWorkState = false;
 
-         timer_Expose->stop();
 
-         timer_WorkState->start();
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("电子快门未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::ExposeUpdate()
 
- {
 
-     timer_Expose->stop();
 
-     MyShutter->close();
 
-     curShutterWorkState = false;
 
- }
 
- void CGH_Printer::WorkTimeUpdate()
 
- {
 
-     timePrintCur = clock();
 
-     Printtimed = (timePrintCur - timePrintStart) / CLOCKS_PER_SEC;
 
-     string Worktimed;
 
-     Worktimed = formatTime(Printtimed);
 
-     ui.lineEditPrinted->setText(QString::fromStdString(Worktimed));
 
- }
 
- void CGH_Printer::PrintOKUpdate()
 
- {
 
-     ReadyState();
 
-     // UI控件设置
 
-     ui.pushButtonPrintOK->setChecked(false);
 
-     labelPrint->clear();
 
-     ui.labelSLMCopy->clear();
 
-     timer_Work->stop();
 
-     ui.lineEditPrintName->setText(QString::fromStdString(PrintName));
 
-     QMessageBox::about(this, tr("提示"), tr("打印已完成!"));
 
- }
 
- void CGH_Printer::PrintCancelUpdate()
 
- {
 
-     ReadyState();
 
-     // UI控件设置
 
-     ui.pushButtonPrintOK->setChecked(false);
 
-     ui.progressBarPrint->setValue(0);
 
-     ui.lineEditPrinted->setText("00:00:00");
 
-     ui.lineEditStart->setText("00:00:00");
 
-     labelPrint->clear();
 
-     ui.labelSLMCopy->clear();
 
-     ui.lineEditPrintName->setText(QString::fromStdString(PrintName));
 
-     timer_Work->stop();
 
-     QMessageBox::about(this, tr("提示"), tr("打印已停止!"));
 
- }
 
- // 平移台轴坐标实时更新
 
- void CGH_Printer::CoordinateUpdate()
 
- {
 
-     PI_qPOS(Devices[0], sAxis.c_str(), &CoordinateX);
 
-     PI_qPOS(Devices[1], sAxis.c_str(), &CoordinateY);
 
-     ui.labelXPosition->setText(QString::number(CoordinateX, 'f', 3));
 
-     ui.labelYPosition->setText(QString::number(CoordinateY, 'f', 3));
 
- }
 
- // 新建工程
 
- void CGH_Printer::NewProject()
 
- {
 
-     CGH_ProjectView* myNewProjectView = new CGH_ProjectView(this);
 
-     CGH_Project* myNewProject = new CGH_Project();
 
-     myNewProjectView->initWindow();
 
-     if (myNewProjectView->exec() == QDialog::Accepted) {
 
-     //保存参数
 
- 		myNewProject->setWorkName(myNewProjectView->getViewName());
 
- 		myNewProject->setWorkLSpacing(myNewProjectView->getViewLSpacing());
 
- 		myNewProject->setWorkCSpacing(myNewProjectView->getViewCSpacing());
 
- 		myNewProject->setWorkLine(myNewProjectView->getViewLine());
 
- 		myNewProject->setWorkColumn(myNewProjectView->getViewColumn());
 
- 		myNewProject->setWorkPrefix(myNewProjectView->getViewPrefix());
 
- 		myNewProject->setWorkExpose(myNewProjectView->getViewExpose());
 
- 		myNewProject->setWorkQuiet(myNewProjectView->getViewQuiet());
 
- 		myNewProject->setWorkResource(myNewProjectView->getViewResource());
 
- 		myNewProject->saveToLocal();
 
-         addProject(myNewProject);
 
-     }
 
- }
 
- // 修改工程
 
- void CGH_Printer::ModifyProject() {
 
-     if (pButtonGroup->checkedButton())
 
-     {
 
-         CGH_ProjectView* myModifyProjectView = new CGH_ProjectView(this);
 
-         string ModifyProjectName = (pButtonGroup->checkedButton())->text().toStdString();
 
-         CGH_Project* myModifyProject = new CGH_Project(ModifyProjectName);
 
-         myModifyProjectView->initWindow();
 
-         myModifyProjectView->setViewName(myModifyProject->getWorkName());
 
-         myModifyProjectView->setViewLSpacing(myModifyProject->getWorkLSpacing());
 
-         myModifyProjectView->setViewCSpacing(myModifyProject->getWorkCSpacing());
 
-         myModifyProjectView->setViewLine(myModifyProject->getWorkLine());
 
-         myModifyProjectView->setViewColumn(myModifyProject->getWorkColumn());
 
-         myModifyProjectView->setViewPrefix(myModifyProject->getWorkPrefix());
 
-         myModifyProjectView->setViewExpose(myModifyProject->getWorkExpose());
 
-         myModifyProjectView->setViewQuiet(myModifyProject->getWorkQuiet());
 
-         myModifyProjectView->setViewResource(myModifyProject->getWorkResource());
 
- 		if (myModifyProjectView->exec() == QDialog::Accepted) {
 
- 			string fullProjectName;
 
- 			fullProjectName = absProjectPath + "/" + (myModifyProject->getWorkName()) + ProjectType;
 
- 			remove(fullProjectName.c_str());
 
- 			ui.verticalLayoutWork->removeWidget(pButtonGroup->checkedButton());
 
- 			delete pButtonGroup->checkedButton();
 
- 			myModifyProject->setWorkName(myModifyProjectView->getViewName());
 
- 			myModifyProject->setWorkLSpacing(myModifyProjectView->getViewLSpacing());
 
- 			myModifyProject->setWorkCSpacing(myModifyProjectView->getViewCSpacing());
 
- 			myModifyProject->setWorkLine(myModifyProjectView->getViewLine());
 
- 			myModifyProject->setWorkColumn(myModifyProjectView->getViewColumn());
 
- 			myModifyProject->setWorkPrefix(myModifyProjectView->getViewPrefix());
 
- 			myModifyProject->setWorkExpose(myModifyProjectView->getViewExpose());
 
- 			myModifyProject->setWorkQuiet(myModifyProjectView->getViewQuiet());
 
- 			myModifyProject->setWorkResource(myModifyProjectView->getViewResource());
 
- 			myModifyProject->saveToLocal();
 
- 			addProject(myModifyProject);
 
-         }
 
- 	}
 
-     else
 
-     {
 
-         QMessageBox::about(this, tr("提示"), tr("未选中工程!"));
 
-     }
 
- }
 
- // 添加工程文件
 
- void CGH_Printer::addProject(CGH_Project* pj)
 
- {
 
- 	string WorkName = pj->getWorkName();
 
- 	addProject(WorkName);
 
- }
 
- void CGH_Printer::addProject(const string& name)
 
- {
 
- 	QPushButton* Button = new QPushButton;
 
-     string fullprojectName = name + ProjectType;
 
- 	Button->setText(QString::fromLocal8Bit(fullprojectName.c_str()));
 
- 	Button->setCheckable(true);
 
- 	//Button->setAutoExclusive(true);
 
-     pButtonGroup->addButton(Button);
 
- 	ui.verticalLayoutWork->addWidget(Button);
 
- }
 
- // 删除工程文件
 
- void CGH_Printer::DeleteProject()
 
- {
 
-     string fileName;
 
-     QString ButtonName;
 
-     fileName = (pButtonGroup->checkedButton())->text().toStdString();
 
-     ButtonName = (pButtonGroup->checkedButton())->objectName();
 
-     QPushButton* tempButton = this->findChild<QPushButton *>(ButtonName);
 
-     string fullProjectName;
 
-     fullProjectName = absProjectPath + "/" + fileName;
 
- 	if (QMessageBox::warning(this, tr("提示"), tr("确定删除工程?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
- 	{
 
- 		remove(fullProjectName.c_str());
 
- 		ui.verticalLayoutWork->removeWidget(pButtonGroup->checkedButton());
 
- 		delete pButtonGroup->checkedButton();
 
- 	}
 
- 	return;
 
- }
 
- void CGH_Printer::Underfeed()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         if (!PI_GOH(Devices[0], sAxis.c_str()) && !PI_FNL(Devices[1], sAxis.c_str()))
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能完成下料!"));
 
-         }
 
-         else
 
-         {
 
-             BusyState();
 
-             timer_WorkState->start();
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::TempSaved()
 
- {
 
-     if (curTransTableState)
 
-     {
 
- 		if (QMessageBox::information(this, tr("提示"), tr("是否暂时保存配置?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
- 		{
 
- 			AccX = ui.lineEditAccX->text().toDouble();
 
- 			AccY = ui.lineEditAccY->text().toDouble();
 
- 			DecX = ui.lineEditDecX->text().toDouble();
 
- 			DecY = ui.lineEditDecY->text().toDouble();
 
- 			MaxvX = ui.lineEditMaxvX->text().toDouble();
 
- 			MaxvY = ui.lineEditMaxvY->text().toDouble();
 
- 			PI_SPA(Devices[0], sAxis.c_str(), &Acc, &AccX, NULL);
 
- 			PI_SPA(Devices[1], sAxis.c_str(), &Acc, &AccY, NULL);
 
- 			PI_SPA(Devices[0], sAxis.c_str(), &Dec, &DecX, NULL);
 
- 			PI_SPA(Devices[1], sAxis.c_str(), &Dec, &DecY, NULL);
 
- 			PI_SPA(Devices[0], sAxis.c_str(), &Maxv, &MaxvX, NULL);
 
- 			PI_SPA(Devices[1], sAxis.c_str(), &Maxv, &MaxvY, NULL);
 
- 		}
 
- 		else
 
- 		{
 
- 			ReadTransTableConfigue();
 
- 		}
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::PermSaved()
 
- {
 
-     if (curTransTableState)
 
-     {
 
- 		if (QMessageBox::information(this, tr("提示"), tr("是否永久保存配置?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
- 		{
 
- 			AccX = ui.lineEditAccX->text().toDouble();
 
- 			AccY = ui.lineEditAccY->text().toDouble();
 
- 			DecX = ui.lineEditDecX->text().toDouble();
 
- 			DecY = ui.lineEditDecY->text().toDouble();
 
- 			MaxvX = ui.lineEditMaxvX->text().toDouble();
 
- 			MaxvY = ui.lineEditMaxvY->text().toDouble();
 
- 			PI_SPA(Devices[0], sAxis.c_str(), &Acc, &AccX, NULL);
 
- 			PI_SPA(Devices[1], sAxis.c_str(), &Acc, &AccY, NULL);
 
- 			PI_SPA(Devices[0], sAxis.c_str(), &Dec, &DecX, NULL);
 
- 			PI_SPA(Devices[1], sAxis.c_str(), &Dec, &DecY, NULL);
 
- 			PI_SPA(Devices[0], sAxis.c_str(), &Maxv, &MaxvX, NULL);
 
- 			PI_SPA(Devices[1], sAxis.c_str(), &Maxv, &MaxvY, NULL);
 
- 			PI_RPA(Devices[0], sAxis.c_str(), &Acc);
 
- 			PI_RPA(Devices[1], sAxis.c_str(), &Acc);
 
- 			PI_RPA(Devices[0], sAxis.c_str(), &Dec);
 
- 			PI_RPA(Devices[1], sAxis.c_str(), &Dec);
 
- 			PI_RPA(Devices[0], sAxis.c_str(), &Maxv);
 
- 			PI_RPA(Devices[1], sAxis.c_str(), &Maxv);
 
- 		}
 
- 		else
 
- 		{
 
- 			ReadTransTableConfigue();
 
- 		}
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- void CGH_Printer::Feed()
 
- {
 
-     if (curTransTableState)
 
-     {
 
-         if (!PI_GOH(Devices[1], sAxis.c_str()) && !PI_GOH(Devices[0], sAxis.c_str()))
 
-         {
 
-             QMessageBox::critical(this, tr("错误"), tr("不能完成上料!"));
 
-         }
 
-         else
 
-         {
 
-             BusyState();
 
-             timer_WorkState->start();
 
-         }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::critical(this, tr("错误"), tr("平移台未连接!"));
 
-     }
 
- }
 
- // 打印选中的工程
 
- void CGH_Printer::PrintTemp()
 
- {
 
-     if (pButtonGroup->checkedButton())
 
-     {
 
-         Print();
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::about(this, tr("提示"), tr("未选中工程!"));
 
-     }
 
- }
 
- void CGH_Printer::Print()
 
- {
 
-     if (QMessageBox::information(this, tr("提示"), tr("是否加载工程?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
-     {
 
-         string PrintProjectName = (pButtonGroup->checkedButton())->text().toStdString();
 
-         CGH_Project* PrintProject = new CGH_Project(PrintProjectName);
 
-         PrintName = PrintProject->getWorkName();
 
-         PrintLSpacing = stod(PrintProject->getWorkLSpacing());
 
- 		PrintCSpacing = stod(PrintProject->getWorkCSpacing());
 
- 		PrintLine = stoi(PrintProject->getWorkLine());
 
- 		PrintColumn = stoi(PrintProject->getWorkColumn());
 
- 		PrintPrefix = PrintProject->getWorkPrefix();
 
- 		PrintExpose = stoi(PrintProject->getWorkExpose());
 
- 		PrintQuiet = stoi(PrintProject->getWorkQuiet());
 
- 		PrintResource = PrintProject->getWorkResource();
 
-         ui.tabWidget->setCurrentIndex(3);
 
-         ui.lineEditPrintName->setText(QString::fromStdString(PrintName));
 
-         ui.progressBarPrint->setValue(0);
 
-         labelPrint->clear();
 
- 		// 加载实物图
 
- 		string sep = "/";
 
- 		string Format = ".bmp";
 
- 		string Phyfilename;// 实物图路径
 
- 		Phyfilename = PrintResource + sep + PrintPrefix + Format;
 
- 		ui.labelPhy->setPixmap(QPixmap(QString::fromStdString(Phyfilename)));
 
-     }
 
- }
 
- void CGH_Printer::SLMUpdate(const QString& tempCGH)
 
- {
 
- 	labelPrint->clear();
 
- 	labelPrint->setPixmap(QPixmap(tempCGH));
 
-     ui.labelSLMCopy->setPixmap(QPixmap(tempCGH));
 
-     QString CurPrintName;
 
-     CurPrintName = QString::fromStdString(PrintName) + "(" + tempCGH + ")";
 
- 	ui.lineEditPrintName->setText(tempCGH);
 
- }
 
- void CGH_Printer::PrintUpdate(int tempLL, int tempCC)
 
- {
 
- 	PrintLL = tempLL;
 
- 	PrintCC = tempCC;
 
- 	CurProgress = (PrintLL - 1) * PrintColumn + PrintCC;
 
- 	FulProgress = PrintLine * PrintColumn;
 
- 	ui.progressBarPrint->setMaximum(FulProgress);
 
- 	ui.progressBarPrint->setValue(CurProgress);
 
- }
 
- void CGH_Printer::PrintStop()
 
- {
 
-     if (QMessageBox::warning(this, tr("提示"), tr("是否停止打印?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
-     {
 
-         PRINTSTOP = TRUE;
 
-     }
 
- }
 
- // 打印工作进程
 
- void CGH_Printer::PrintProgress()
 
- {
 
- 	if (!ui.lineEditPrintName->text().isEmpty() && curTransTableState && curShutterState && curSLMState)
 
- 	{
 
- 		if (QMessageBox::warning(this, tr("提示"), tr("是否开始打印?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
- 		{
 
-             PRINTSTOP = FALSE;
 
- 			BusyState();
 
- 			// 开始工作时间
 
- 			QDateTime timeStart = QDateTime::currentDateTime();
 
- 			QString str = timeStart.toString("hh:mm:ss");
 
- 			ui.lineEditStart->setText(str);
 
- 			// 已打印
 
- 			timePrintStart = clock();
 
- 			timer_Work->start();
 
- 			m_Printer->start();
 
- 		}
 
-         else
 
-         {
 
-             ui.pushButtonPrintOK->setChecked(false);
 
-         }
 
- 	}
 
- 	else if (ui.lineEditPrintName->text().isEmpty())
 
- 	{
 
- 		ui.pushButtonPrintOK->setChecked(false);
 
- 		QMessageBox::about(this, tr("提示"), tr("未加载工程!"));
 
- 	}
 
- 	else
 
- 	{
 
- 		ui.pushButtonPrintOK->setChecked(false);
 
- 		QMessageBox::about(this, tr("提示"), tr("请检查电子快门、空间光调制器和电控平移台的状态!"));
 
- 	}
 
- }
 
- void CGH_Printer::ComboDevice()
 
- {
 
-     ui.comboBoxDevice->clear();
 
-     m_pCameraInfos = QCameraInfo::availableCameras();   
 
-     for (int i = 0; i < m_pCameraInfos.size(); i++)
 
-     {
 
-         ui.comboBoxDevice->addItem(m_pCameraInfos[i].description());
 
-     }
 
-     m_pCameraIndex = ui.comboBoxDevice->currentIndex();
 
- }
 
- // 切换设备
 
- void CGH_Printer::ChangeDevice()
 
- {
 
-     if (m_pCameraOpen)
 
-     {
 
- 		CloseCamera();
 
- 		m_pCameraIndex = ui.comboBoxDevice->currentIndex();
 
- 		OpenCamera();
 
- 		ComboFormatandFramerate();
 
-     }
 
- }
 
- // 切换分辨率
 
- void CGH_Printer::ChangeFormat()
 
- {
 
-     if (m_pCameraOpen)
 
-     {
 
- 		QString strFormat = ui.comboBoxFormat->currentText();
 
- 		QStringList ListFormat = strFormat.split('x');
 
- 		CloseCamera();
 
- 		m_pCamera = new QCamera(m_pCameraInfos[m_pCameraIndex]);
 
- 		QCameraViewfinderSettings* m_pCameraSet = new QCameraViewfinderSettings();
 
- 		m_pCameraSet->setResolution(ListFormat[0].toInt(), ListFormat[1].toInt());
 
-         m_pCamera->setViewfinderSettings(*m_pCameraSet);
 
- 		m_pCamera->setViewfinder(m_pViewfinder);
 
- 		m_pCamera->start();
 
-     }
 
- }
 
- void CGH_Printer::CGHLoad()
 
- {
 
-     QFileDialog* CGH_dialog = new QFileDialog(this);
 
-     QString filefull;
 
-     QString Fullfilename;
 
-     QFileInfo fileinfo;
 
-     QString curPath = QString::fromStdString(absResourcesPath);// 默认路径
 
-     // 路径不存在则创建路径
 
-     QDir dir(curPath);
 
-     if (!dir.exists(curPath))
 
-     {
 
-         dir.mkdir(curPath);
 
-     }
 
-     QString dlgTitle = "选择文件";// 对话框标题
 
-     QString filter = "Bmp Files(*.bmp)";// 文件过滤器
 
-     filefull = CGH_dialog->getOpenFileName(this, dlgTitle, curPath, filter);
 
-     QFileInfo file(filefull);
 
-     //点击确定按钮
 
-     if (file.isFile() && file.exists())
 
-     {
 
-         //获取新建项目路径
 
-         fileinfo = QFileInfo(filefull);
 
-         Fullfilename = fileinfo.absolutePath() + "/" + fileinfo.fileName();
 
-         ui.lineEditCGHName->setText(Fullfilename);//设置路径栏
 
-         ui.labelCGHDisplay->clear();
 
-         ui.labelCGHDisplay->setPixmap(QPixmap(Fullfilename));
 
-         // labelPrint->setPixmap(QPixmap(Fullfilename));
 
-         if (Desktop->numScreens() == 2)
 
-         {
 
-             labelPrint->clear();
 
-             labelPrint->setPixmap(QPixmap(Fullfilename));
 
-         }
 
-     }
 
-     //点取消则返回
 
-     else
 
-     {
 
-         return;
 
-     }
 
-     delete CGH_dialog;
 
-     CGH_dialog = NULL;
 
- }
 
- // 视频预览
 
- void CGH_Printer::Preview()
 
- {
 
-         if (m_pCameraInfos.size() > 0)
 
-         {
 
-             if (!m_pCameraOpen)
 
-             {
 
-                 ui.pushButtonPreview->setText("停止");
 
-                 OpenCamera();
 
-                 ComboFormatandFramerate();
 
-                 m_pCameraOpen = TRUE;
 
-             }
 
-             else
 
-             {
 
-                 ui.pushButtonPreview->setText("预览");
 
-                 CloseCamera();
 
-                 m_pCameraOpen = FALSE;
 
-                 ui.comboBoxFormat->clear();
 
-                 ui.comboBoxFramerate->clear();
 
-                 delete m_pCamera;
 
-             }
 
-         }
 
-         else
 
-         {
 
-             QMessageBox::about(this, tr("提示"), tr("打开相机失败!"));
 
-         }
 
- }
 
- // 视频截图
 
- void CGH_Printer::Snapshot()
 
- {
 
-     if (m_pCameraOpen)
 
-     {
 
-         string filename;
 
-         m_pCameraCapture = new QCameraImageCapture(m_pCamera);
 
-         m_pCameraCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile);
 
-         QString curPath = QString::fromStdString(absCapturePath);// 默认路径
 
-         // 路径不存在则创建路径
 
-         QDir dir(curPath);
 
-         if (!dir.exists(curPath))
 
-         {
 
-             dir.mkdir(curPath);
 
-         }
 
-         QString dlgTitle = "保存文件";// 对话框标题
 
-         QString filter = "Jpep Files(*.jpg)";// 文件过滤器
 
-         QString aFileName = QFileDialog::getSaveFileName(this, dlgTitle, curPath, filter);
 
-         if (!aFileName.isEmpty())
 
-             m_pCameraCapture->capture(aFileName);
 
-   //      默认输出到Capture文件夹
 
-   //	  QDir dir(QString::fromStdString(absCapturePath));
 
-   //      dir.setFilter(QDir::Files | QDir::NoSymLinks);
 
-   //      QFileInfoList list = dir.entryInfoList();
 
-   //      int file_count = list.count();
 
-   //      if (!dir.exists() || file_count <= 0)
 
-   //      {
 
-   //          filename = absCapturePath + "/Cap_0";
 
-   //      }
 
-   //      else
 
-   //      {
 
-   //          QStringList string_list;
 
-   //          int maxindex = 0;
 
-   //          for (int i = 0; i < file_count; i++)
 
-   //          {
 
-   //              QFileInfo file_info = list.at(i);
 
-   //              QString curfilename = file_info.fileName();
 
-   //              int start = curfilename.lastIndexOf("_");
 
-   //              int end = curfilename.lastIndexOf(".");
 
-   //              QString temp = curfilename.mid(start+1, end - start-1);
 
-   //              int curindex = temp.toInt();
 
-   //              maxindex = qMax(maxindex, curindex);
 
-   //          }
 
-   //          filename = absCapturePath + "/Cap_" + to_string(maxindex + 1);
 
-   //      }
 
-     }
 
-     else
 
-     {
 
-         QMessageBox::about(this, tr("提示"), tr("相机未开启!"));
 
-     }
 
- }
 
- void CGH_Printer::ComboFormatandFramerate()
 
- {
 
- 	QList<QSize> m_pCameraFormats = m_pCamera->supportedViewfinderResolutions();
 
- 	QString strFormat;
 
- 	foreach(QSize m_pCameraFormat, m_pCameraFormats)
 
- 	{
 
- 		strFormat = QString("%1x%2").arg(m_pCameraFormat.width()).arg(m_pCameraFormat.height());
 
- 		ui.comboBoxFormat->addItem(strFormat);
 
- 	}
 
- 	QList<QCamera::FrameRateRange> m_pCameraFramerates = m_pCamera->supportedViewfinderFrameRateRanges();
 
- 	foreach(QCamera::FrameRateRange m_pCameraFramerate, m_pCameraFramerates)
 
- 	{
 
-         ui.comboBoxFramerate->addItem(QString::number(m_pCameraFramerate.maximumFrameRate, 'f', 0));
 
- 	}
 
- }
 
- void CGH_Printer::OpenCamera()
 
- {
 
- 	m_pCamera = new QCamera(m_pCameraInfos[m_pCameraIndex]);
 
-     m_pCamera->setViewfinder(m_pViewfinder);
 
-     m_pCamera->setCaptureMode(QCamera::CaptureStillImage);
 
- 	m_pCamera->start();
 
-     QList<QSize> ViewFormats = m_pCamera->supportedViewfinderResolutions();
 
-     QCameraViewfinderSettings* initm_pCameraSet = new QCameraViewfinderSettings();
 
-     initm_pCameraSet->setResolution(ViewFormats[0].width(), ViewFormats[0].height());
 
-     QList<QCamera::FrameRateRange> ViewFramerates = m_pCamera->supportedViewfinderFrameRateRanges();
 
-     initm_pCameraSet->setMaximumFrameRate(ViewFramerates[0].maximumFrameRate);
 
-     initm_pCameraSet->setMinimumFrameRate(ViewFramerates[0].minimumFrameRate);
 
-     m_pCamera->setViewfinderSettings(*initm_pCameraSet);
 
- }
 
- void CGH_Printer::CloseCamera()
 
- {
 
-     m_pCamera->stop();
 
- }
 
- void CGH_Printer::SLMDisplay()
 
- {
 
-     QRect winMain = Desktop->screenGeometry(1);
 
-     labelPrint->setGeometry(winMain);
 
-     labelPrint->setWindowFlags(Qt::FramelessWindowHint |
 
-         Qt::WindowStaysOnTopHint |
 
-         Qt::Popup | Qt::Tool);//设置窗口弹出、无边框、窗口置顶
 
-     //labelPrint->setWindowFlags(Qt::FramelessWindowHint |
 
-     //    Qt::WindowStaysOnTopHint |
 
-     //    Qt::Popup | Qt::Tool);//设置窗口弹出、无边框、窗口置顶
 
-     labelPrint->setCursor(Qt::BlankCursor);
 
-     //labelPrint->move(winMain.width(), 0);
 
-     labelPrint->showFullScreen();
 
-     labelPrint->setAlignment(Qt::AlignCenter);
 
-     labelPrint->setScaledContents(true);
 
- }
 
- void CGH_Printer::PITransTableInit()
 
- {
 
-         for (int num = 1; num <= DeviceNum; num++)
 
-         {
 
-             int Device = PI_ConnectDaisyChainDevice(ControllerID, num);
 
-             if (Device >= 0)
 
- 			{
 
- 				Devices.push_back(Device);
 
-             }
 
-         }
 
- 		// 轴开启伺服控制
 
- 		for (const auto& Device : Devices)
 
- 		{
 
- 			PI_SVO(Device, sAxis.c_str(), &SERVO_ON);
 
- 		}
 
-         BusyState();
 
-         timer_WorkState->start();
 
-         // 轴参考移动
 
-         for (const auto& Device : Devices)
 
-         {
 
-             PI_FRF(Device, sAxis.c_str());
 
-         }
 
- }
 
- void CGH_Printer::closeEvent(QCloseEvent* event)
 
- {
 
- 	if (QMessageBox::information(this, tr("提示"), tr("是否关闭程序?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
 
- 	{
 
- 		event->accept();
 
- 	}
 
- 	else
 
- 	{
 
- 		event->ignore();
 
- 	}
 
- }
 
- string CGH_Printer::numberToString(int n,int l)
 
- {
 
-     string res = to_string(n);
 
-     int length = res.size();
 
-     while (length++ < l) {
 
-         res = "0" + res;
 
-     }
 
-     return res;
 
- }
 
- std::string CGH_Printer::formatTime(long ss)
 
- {
 
-     int mi = 60;
 
-     int hh = mi * 60;
 
-     long hour = ss / hh;
 
-     long minute = (ss - hour * hh) / mi;
 
-     long second = ss - hour * hh - minute * mi;
 
-     string shour, sminute, ssecond;
 
-     shour = numberToString(hour, 2);
 
-     sminute = numberToString(minute, 2);
 
-     ssecond = numberToString(second, 2);
 
-     string format;
 
-     format = shour + ":" + sminute + ":" + ssecond;
 
-     return format;
 
- }
 
-     
 
 
  |