Пример #1
0
bool awari::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: reset(); break;
    case 1: takeopp((QValueList<int>::iterator)(*((QValueList<int>::iterator*)static_QUType_ptr.get(_o+1))),(int)static_QUType_int.get(_o+2)); break;
    case 2: display(); break;
    case 3: p1_clicked(); break;
    case 4: p2_clicked(); break;
    case 5: p3_clicked(); break;
    case 6: p4_clicked(); break;
    case 7: p5_clicked(); break;
    case 8: movec5(); break;
    case 9: movec4(); break;
    case 10: movec3(); break;
    case 11: movec2(); break;
    case 12: movec1(); break;
    case 13: movecomp(); break;
    case 14: movecomp((QValueList<int>::iterator)(*((QValueList<int>::iterator*)static_QUType_ptr.get(_o+1)))); break;
    case 15: checkwin(); break;
    case 16: comp1st_clicked(); break;
    case 17: spinBox_valueChanged((int)static_QUType_int.get(_o+1)); break;
    case 18: ok_clicked(); break;
    case 19: languageChange(); break;
    default:
	return QWizard::qt_invoke( _id, _o );
    }
    return TRUE;
}
void MainWindow::MakeTabUI(QGroupBox *joint_widget, QGroupBox *torque_widget, QButtonGroup *button_group,
                           std::map<int, std::string> &offset_group)
{
  QSignalMapper *torque_checkbox_signalMapper = new QSignalMapper(this);

  QGridLayout *grid_layout = (QGridLayout *) joint_widget->layout();
  QGridLayout *torque_layout = (QGridLayout *) torque_widget->layout();

  button_group = new QButtonGroup();
  button_group->setExclusive(false);

  int row = 3;
  int torque_checkbox_index = 0;
  int torque_row = 1;
  int torque_col = 0;
  for (std::map<int, std::string>::iterator map_iter = offset_group.begin(); map_iter != offset_group.end(); ++map_iter)
  {
    QSignalMapper *spingox_signalMapper = new QSignalMapper(this);
    QList<QAbstractSpinBox *> spinbox_list;

    // spin_box
    int col = 0;
    int size = 1;
    std::string joint_name = map_iter->second;
    QString q_joint_name = QString::fromStdString(joint_name);

    // label
    QLabel *joint_label = new QLabel(q_joint_name);
    grid_layout->addWidget(joint_label, row, col++, 1, size);

    // double spin box
    for (int ix = 0; ix < 4; ix++)
    {
      QDoubleSpinBox *spin_box = new QDoubleSpinBox();
      spin_box->setWhatsThis(tr(spinBox_list_[ix].c_str()));
      spin_box->setMinimum(-360);
      spin_box->setMaximum(360);
      spin_box->setSingleStep(0.05);

      switch (ix)
      {
        case 2:
        case 3:
          spin_box->setReadOnly(true);
          break;

        default:
          spingox_signalMapper->setMapping(spin_box, q_joint_name);
          QObject::connect(spin_box, SIGNAL(valueChanged(QString)), spingox_signalMapper, SLOT(map()));
          break;
      }

      grid_layout->addWidget(spin_box, row, col++, 1, size);

      spinbox_list.append(spin_box);
    }

    // spin box
    for (int ix = 0; ix < 3; ix++)
    {
      QSpinBox *spin_box = new QSpinBox();
      spin_box->setWhatsThis(tr(spinBox_list_[ix + 4].c_str()));
      spin_box->setMinimum(0);
      spin_box->setMaximum(1000);
      spin_box->setSingleStep(1);

      switch (ix)
      {
        case 0:
          spin_box->setValue(32);

          spingox_signalMapper->setMapping(spin_box, q_joint_name);
          QObject::connect(spin_box, SIGNAL(valueChanged(QString)), spingox_signalMapper, SLOT(map()));
          break;

        default:
          spin_box->setReadOnly(true);
          break;
      }

      grid_layout->addWidget(spin_box, row, col++, 1, size);

      spinbox_list.append(spin_box);
    }

    // spinbox
    joint_spinbox_map_[joint_name] = spinbox_list;
    QObject::connect(spingox_signalMapper, SIGNAL(mapped(QString)), this, SLOT(spinBox_valueChanged(QString)));

    row += 1;

    // torque checkbox
    torque_row = torque_checkbox_index / 6;
    torque_col = torque_checkbox_index % 6;

    QCheckBox *check_box = new QCheckBox(q_joint_name);
    check_box->setChecked(true);
    torque_layout->addWidget(check_box, torque_row, torque_col, 1, size);
    button_group->addButton(check_box);

    torque_checkbox_signalMapper->setMapping(check_box, check_box);
    QObject::connect(check_box, SIGNAL(clicked()), torque_checkbox_signalMapper, SLOT(map()));

    torque_checkbox_index += 1;
  }

  // all torque on
  QSignalMapper *torque_on_signalMapper = new QSignalMapper(this);
  QPushButton *on_button = new QPushButton(tr("All torque ON"));
  torque_layout->addWidget(on_button, torque_row + 1, 4, 1, 1);
  torque_on_signalMapper->setMapping(on_button, button_group);
  QObject::connect(on_button, SIGNAL(clicked()), torque_on_signalMapper, SLOT(map()));
  QObject::connect(torque_on_signalMapper, SIGNAL(mapped(QObject*)), this,
                   SLOT(all_torque_on_button_clicked(QObject*)));

  // all torque off
  QSignalMapper *torque_off_signalMapper = new QSignalMapper(this);
  QPushButton *off_button = new QPushButton(tr("All torque OFF"));
  torque_layout->addWidget(off_button, torque_row + 1, 5, 1, 1);
  torque_off_signalMapper->setMapping(off_button, button_group);
  QObject::connect(off_button, SIGNAL(clicked()), torque_off_signalMapper, SLOT(map()));
  QObject::connect(torque_off_signalMapper, SIGNAL(mapped(QObject*)), this,
                   SLOT(all_torque_off_button_clicked(QObject*)));

  QObject::connect(torque_checkbox_signalMapper, SIGNAL(mapped(QWidget*)), this,
                   SLOT(torque_checkbox_clicked(QWidget*)));
}