void MainInterface::initFuncBar()
{
    toplevel *top ;
    seconlevel_f3 *sec_f3;
    seconlevel_f4 *sec_f4;
    seconlevel_f5 *sec_f5;
    seconlevel_f6 *sec_f6;

    top = new toplevel(this);
    top->setHidden(true);
    connect(top ,SIGNAL(menu(bool)) ,this ,SLOT(menuShow(bool)));

    sec_f3 = new seconlevel_f3(this);
    sec_f3 ->setHidden(true);

    sec_f4 = new seconlevel_f4(this);
    sec_f4 ->setHidden(true);

    sec_f5 = new seconlevel_f5(this);
    sec_f5 ->setHidden(true);

    sec_f6 = new seconlevel_f6(this);
    sec_f6 ->setHidden(true);

    barmap.clear();
    barmap.insert(23 ,sec_f3);
    barmap.insert(24 ,sec_f4);
    barmap.insert(25 ,sec_f5);
    barmap.insert(26 ,sec_f6);
    barmap.insert(28 ,top);

    barui = barmap[28];

    barui->setHidden(false);
    ui->horizontalLayout->addWidget(barui);

    connect(this ,SIGNAL(barF0()) ,barui ,SLOT(F0()));
    connect(spark_info ,SIGNAL(boolChange()) ,this ,SLOT(updateF0()));

    emit barF0();
}
void Controller::toggleExposureAutoPriority(bool value)
{
    boolChange(V4L2_CID_EXPOSURE_AUTO_PRIORITY ,value, "Exposure Auto Priority");
}
void Controller::toggleExposureAuto(bool value)
{
    boolChange(V4L2_CID_EXPOSURE_AUTO ,value, "Exposure Auto");
}
void Controller::toggleFocusAuto(bool value)
{
    boolChange(V4L2_CID_FOCUS_AUTO ,value, "Focus Auto");
}
void Controller::toggleAutoWhiteBalanceOn(bool value)
{
    boolChange(V4L2_CID_AUTO_WHITE_BALANCE ,value, "Auto White Balance");
}
MainInterface::MainInterface(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainInterface)
{
    ui->setupUi(this);

    key_pressed = false;
    start_or_end = true;

    target = 0;

    FPGA_Init();

    XYZ_Update(L_X_CURRENT);
    XYZ_Update(L_Y_CURRENT);
    XYZ_Update(L_Z_CURRENT);

    XYZ_Update(L_X_ABSOLUTE);
    XYZ_Update(L_Y_ABSOLUTE);
    XYZ_Update(L_Z_ABSOLUTE);

    XYZ_Update(L_X_REMAIN);
    XYZ_Update(L_Y_REMAIN);
    XYZ_Update(L_Z_REMAIN);

    axisIndexUpdate();

    connect(spark_info ,SIGNAL(xyzChange(int)) ,this ,SLOT(XYZ_Update(int)));
    connect(spark_info ,SIGNAL(coorIndexChange()) ,this ,SLOT(axisIndexUpdate()));

    model = new QStandardItemModel;
    /*数据表索引发生改变*/
    connect(spark_info ,SIGNAL(tableChange()) ,this ,SLOT(tableDataUpdate()));
    /*数据表的加工段和当前加工行发生改变*/
    connect(spark_info ,SIGNAL(tableRowChange()),this ,SLOT(tableRollUpdate()));

    /*初始化功能栏*/
    initFuncBar();

    /*初始化为显示态*/
    tableStateUpdate(TABLE_SHOW);

    spark = new SparkThread();
    connect(spark_info ,SIGNAL(startChange()) ,spark ,SLOT(sparkChange()));

    scan = new ScanThread();
    scan->start();
    connect(this ,SIGNAL(keyPress(int)) ,scan ,SLOT(keyPress(int)));
    connect(this ,SIGNAL(keyRelease(int)) ,scan ,SLOT(keyRelease(int)));

    mesg = new MesgBox(this);
    mesg ->setHidden(false);

    menu = new StartMenu(this);
    menu ->setHidden(true);
    connect(menu ,SIGNAL(finish(bool)) ,this ,SLOT(menuShow(bool)));

    timer = new QTimer(this);
    timer->setInterval(300);
    connect(timer ,SIGNAL(timeout()) ,this ,SLOT(menuTimeout()));

    ui->verticalLayout->addWidget(mesg);
    ui->verticalLayout->addWidget(menu);

    command = new QCommand(this);
    command->setHidden(false);
    /*命令行输入结束时的信号连接*/
    connect(command ,SIGNAL(finish()) ,this ,SLOT(commandFinish()));

    alerts = new QAlerts(this);
    alerts->setHidden(false);
    connect(spark_info ,SIGNAL(boolChange()) ,alerts ,SLOT(alertCheck()));

    clear = new ClearScreen(parent);
    clear->setHidden(true);

#ifndef Q_WS_X11
    QRect screen_size = qApp->desktop()->screenGeometry();
    clear->setGeometry(0, 0, screen_size.width(), screen_size.height());
    clear->setCursor(QCursor(Qt::BlankCursor));

    watcher = new QFileSystemWatcher(this);
    watcher->addPath(DEV_DIR);
    connect(watcher ,SIGNAL(directoryChanged(QString)) ,this ,SLOT(mouseChange(QString)));

    if(!QFile::exists(USB_MOUSE)){
        setCursor(QCursor(Qt::BlankCursor));
        is_usb = false;
    }else{
        setCursor(QCursor(Qt::ArrowCursor));
        is_usb = true;
    }
#else
    clear->setGeometry(0 ,0 ,1024 ,768);
#endif
    connect(scan ,SIGNAL(clear()) ,clear ,SLOT(show()));

    ui->horizontalLayout_3->addWidget(command);
    ui->horizontalLayout_4->addWidget(alerts);
}