char		*get_home(t_vars *v)
{
  char		*home;
  char		*tmp;

  home = get_env_var(v, "HOME");
  if (!home)
    {
      if ((home = get_home_via_username(v)))
	{
	  tmp = my_strcat("HOME=", home);
	  v->env = add_elem_to_tab(v->env, tmp);
	  tmp = my_xxfree(tmp);
	  return (home);
	}
      else
	home = ask_home(v);
    }
  return (home);
}
Exemplo n.º 2
0
WatchDiamondWidget::WatchDiamondWidget(int argc, char **argv, QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);
    setFocusPolicy(Qt::StrongFocus);
    markWidget = new MarkWidget(argc,argv,wg_mark);
    coordinate = new Coordinate(lb_x,lb_y,lb_z,lb_a,lb_b);
    setupDialog= new AlgorithmDialog(this);

    for(int i=0; i<5; i++)
        axisPos[i] = 0;

    doubleValidator = new QDoubleValidator(this);
    le_setDiamondT->setValidator(doubleValidator);
    le_getDiamondT->setValidator(doubleValidator);
    le_glueT->setValidator(doubleValidator);
    le_afterGlueT->setValidator(doubleValidator);

    slowVel = markWidget->get_slow_velocity();
    fastVel = markWidget->get_fast_velocity();
    currentVel = fastVel;
    //QString vel = double_to_qstring(currentVel);
    //le_setVelocity->setText(vel);
    autoRun = false;

    QAction* clear = new QAction(QString::fromUtf8("清除所有"),this);
    te_sysMessage->addAction(clear);
    te_sysMessage->setContextMenuPolicy(Qt::ActionsContextMenu);
    te_sysMessage->setTextColor(QColor(Qt::red));
    te_sysMessage->setReadOnly(true);
    te_sysMessage->setText(QString("system Message:\n"));

    jogButtons[0] = bt_xPlus; jogButtons[1] = bt_xReduce; jogButtons[2] = bt_yPlus; jogButtons[3] = bt_yReduce;
    jogButtons[4] = bt_zPlus; jogButtons[5] = bt_zReduce; jogButtons[6] = bt_aPlus; jogButtons[7] = bt_aReduce;
    jogButtons[8] = bt_bPlus; jogButtons[9] = bt_bReduce;

    ioButtons[0] = tb_1; ioButtons[1] = tb_2; ioButtons[2] = tb_3;
    ioButtons[3] = tb_4; ioButtons[4] = tb_5; ioButtons[5] = tb_6;

    connect(markWidget,SIGNAL(update_emc_status(MarkEmcStatus)),this,SLOT(update_emc_slot(MarkEmcStatus)));    
    connect(markWidget,SIGNAL(update_infor(Information&)),this,SLOT(update_infor_slot(Information&)));
    connect(bt_machineRun,SIGNAL(toggled(bool)),this,SLOT(machine_open_toggled(bool)));
    connect(bt_home,SIGNAL(clicked()),this,SLOT(home()));
    connect(bt_zero,SIGNAL(clicked()),this,SLOT(zero()));
    connect(bt_changeVelocity,SIGNAL(toggled(bool)),this,SLOT(change_vel_toggled(bool)));
    //connect(le_setVelocity,SIGNAL(editingFinished()),this,SLOT(finish_set_velocity()));
    connect(bt_scanDiamond,SIGNAL(clicked()),this,SLOT(scan_diamond()));
    connect(bt_scanWatch,SIGNAL(toggled(bool)),this,SLOT(scan_watch(bool)));
    connect(bt_setGlue,SIGNAL(toggled(bool)),this,SLOT(set_glue(bool)));
    connect(bt_setDiamond,SIGNAL(toggled(bool)),this,SLOT(set_diamond(bool)));
    connect(action_open,SIGNAL(triggered()),this,SLOT(open_project()));
    connect(action_new,SIGNAL(triggered()),this,SLOT(new_project()));
    connect(action_halConfig,SIGNAL(triggered()),this,SLOT(hal_config()));
    connect(action_halMeter,SIGNAL(triggered()),this,SLOT(hal_meter()));
    connect(action_halScope,SIGNAL(triggered()),this,SLOT(hal_scope()));
    connect(action_algorithm,SIGNAL(triggered()),this,SLOT(setup_algorithm()));
    connect(bt_autoRun,SIGNAL(toggled(bool)),this,SLOT(auto_run(bool)));
    connect(bt_pause,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
    connect(bt_stop,SIGNAL(clicked()),this,SLOT(stop()));
    connect(clear,SIGNAL(triggered()),this,SLOT(clear_error_message()));

    connect(bt_getDiamondZ,SIGNAL(clicked()),this,SLOT(set_height()));
    connect(bt_setGlueZ,SIGNAL(clicked()),this,SLOT(set_height()));
    connect(bt_setDiamondZ,SIGNAL(clicked()),this,SLOT(set_height()));
    connect(sp_getDiamondZ,SIGNAL(editingFinished()),this,SLOT(set_height()));
    connect(sp_setDiamondZ,SIGNAL(editingFinished()),this,SLOT(set_height()));
    connect(sp_setGlueZ,SIGNAL(editingFinished()),this,SLOT(set_height()));

    connect(le_setDiamondT,SIGNAL(editingFinished()),this,SLOT(set_time()));
    connect(le_getDiamondT,SIGNAL(editingFinished()),this,SLOT(set_time()));
    connect(le_glueT,SIGNAL(editingFinished()),this,SLOT(set_time()));
    connect(le_afterGlueT,SIGNAL(editingFinished()),this,SLOT(set_time()));

    connect(hs_slowVel,SIGNAL(valueChanged(int)),this,SLOT(set_velocity(int)));
    connect(hs_fastVel,SIGNAL(valueChanged(int)),this,SLOT(set_velocity(int)));

    connect(sp_pickupOffsetX,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));
    connect(sp_pickupOffsetY,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));
    connect(sp_glueOffsetX,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));
    connect(sp_glueOffsetY,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));

    for(int i=0; i<10; i++){
        connect(jogButtons[i],SIGNAL(pressed()),this,SLOT(jog()));
        connect(jogButtons[i],SIGNAL(released()),this,SLOT(end_jog()));
    }

    for(int i=0; i<6; i++){
        connect(ioButtons[i],SIGNAL(toggled(bool)),this,SLOT(io_button_toggled(bool)));
    }

    connect(sp_distance,SIGNAL(valueChanged(double)),this,SLOT(set_diamond_distance(double)));
    sp_distance->setValue(0.080);
    bt_machineRun->setChecked(true);
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(ask_home()));
    timer->start(500);

    //bt_home->setChecked(true);
}