Example #1
0
ConnectionWidget::ConnectionWidget(QWidget *parent): QDockWidget(parent)
{
    robotName = QString("");
    setWindowTitle(tr("Conection"));
    setObjectName(tr("Conection"));
    nameLabel = new QLabel("Robot name: ");
    nameLineEdit = new QLineEdit();
    nameLineEdit->setText("IP ADDRESS");
    connectButton = new QPushButton("Connect");
    disconnectButton = new QPushButton("Disconnect");
    layout = new QVBoxLayout;
    selectLayout1 = new QHBoxLayout;
    selectLayout1->setAlignment(Qt::AlignTop);
    selectLayout1->addWidget(nameLabel);
    selectLayout1->addWidget(nameLineEdit,2);
    selectLayout1->addWidget(connectButton,1);

    selectLayout2 = new QHBoxLayout;;
    statusLabel = new QLabel("Status: ");
    statusNetworkLabel = new QLabel("Not connected");
    selectLayout2->setAlignment(Qt::AlignTop);
    selectLayout2->addWidget(statusLabel);
    selectLayout2->addWidget(statusNetworkLabel,2);
    selectLayout2->addWidget(disconnectButton,1);
    layout->addLayout(selectLayout1);
    layout->addLayout(selectLayout2);
    layout->setAlignment(Qt::AlignLeft);
    window = new QWidget;
    window->setLayout(layout);

    setWidget(window);
    disconnectButton->setEnabled(false);
    connectButton->setEnabled(false);

    udpSocket = new QUdpSocket(this);
    udpSocket->setReadBufferSize(12000);
    connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));

    connect(connectButton,SIGNAL(pressed()), this, SLOT(connectToRobot()));
    connect(disconnectButton, SIGNAL(pressed()), this, SLOT(disconnectFromRobot()));
    connect(nameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateRobotName(QString)));
}
void cameraSettingsWidget::createConnections()                    //!< Connect all of the child widgets.
{
    // Setup Shift Gain signals
    connect(shiftGainSlider,SIGNAL(valueChanged(int)),shiftGainSpinBox,SLOT(setValue(int)));
    connect(shiftGainSpinBox,SIGNAL(valueChanged(int)),shiftGainSlider,SLOT(setValue(int)));
    connect(shiftGainSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift Exposure signals
    connect(shiftExposureSlider,SIGNAL(valueChanged(int)),shiftExposureSpinBox,SLOT(setValue(int)));
    connect(shiftExposureSpinBox,SIGNAL(valueChanged(int)),shiftExposureSlider,SLOT(setValue(int)));
    connect(shiftExposureSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift BlueChroma signals
    connect(shiftBlueChromaSlider,SIGNAL(valueChanged(int)),shiftBlueChromaSpinBox,SLOT(setValue(int)));
    connect(shiftBlueChromaSpinBox,SIGNAL(valueChanged(int)),shiftBlueChromaSlider,SLOT(setValue(int)));
    connect(shiftBlueChromaSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift RedChroma signals
    connect(shiftRedChromaSlider,SIGNAL(valueChanged(int)),shiftRedChromaSpinBox,SLOT(setValue(int)));
    connect(shiftRedChromaSpinBox,SIGNAL(valueChanged(int)),shiftRedChromaSlider,SLOT(setValue(int)));
    connect(shiftRedChromaSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift Brightness signals
    connect(shiftBrightnessSlider,SIGNAL(valueChanged(int)),shiftBrightnessSpinBox,SLOT(setValue(int)));
    connect(shiftBrightnessSpinBox,SIGNAL(valueChanged(int)),shiftBrightnessSlider,SLOT(setValue(int)));
    connect(shiftBrightnessSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift Saturation signals
    connect(shiftSaturationSlider,SIGNAL(valueChanged(int)),shiftSaturationSpinBox,SLOT(setValue(int)));
    connect(shiftSaturationSpinBox,SIGNAL(valueChanged(int)),shiftSaturationSlider,SLOT(setValue(int)));
    connect(shiftSaturationSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift Contrast signals.
    connect(shiftContrastSlider,SIGNAL(valueChanged(int)),shiftContrastSpinBox,SLOT(setValue(int)));
    connect(shiftContrastSpinBox,SIGNAL(valueChanged(int)),shiftContrastSlider,SLOT(setValue(int)));
    connect(shiftContrastSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Shift Hue signals
    connect(shiftHueSlider,SIGNAL(valueChanged(int)),shiftHueSpinBox,SLOT(setValue(int)));
    connect(shiftHueSpinBox,SIGNAL(valueChanged(int)),shiftHueSlider,SLOT(setValue(int)));
    connect(shiftHueSlider,SIGNAL(valueChanged(int)),this,SLOT(cameraSettingsChanged()));

    // Setup Auto:
    //QCheckBox* TopCameraSelected;
    //QCheckBox* BottomCameraSelected;
    connect(AutoGainSelected,SIGNAL(clicked()),this,SLOT(cameraSettingsChanged()));
    connect(AutoWhiteBalanceSelected,SIGNAL(clicked()),this,SLOT(cameraSettingsChanged()));
    connect(AutoExposureSelected,SIGNAL(clicked()),this,SLOT(cameraSettingsChanged()));

    connect(TopCameraSelected,SIGNAL(clicked()),BottomCameraSelected,SLOT(toggle()));
    connect(BottomCameraSelected,SIGNAL(clicked()),TopCameraSelected,SLOT(toggle()));
    connect(TopCameraSelected,SIGNAL(clicked()),this,SLOT(cameraSettingsChanged()));
    connect(BottomCameraSelected,SIGNAL(clicked()),this,SLOT(cameraSettingsChanged()));


    connect(nameLineEdit, SIGNAL(textChanged(QString)),this,SLOT(updateRobotName(QString)));
    connect(getCameraSettingsButton,SIGNAL(pressed()),this,SLOT(getCameraSetting()));
    connect(streamCameraSettingsButton,SIGNAL(pressed()),this,SLOT(streamCameraSetting()));
    connect(stopStreamCameraSettingsButton,SIGNAL(pressed()),this,SLOT(stopStreamCameraSetting()));

    connect(&readPacketTimer,SIGNAL(timeout()),this,SLOT(readPendingData()));
    connect(&timer,SIGNAL(timeout()),this,SLOT(sendSettingsToRobot()));
    connect(StartSavingImagesButton, SIGNAL(pressed()),this,SLOT(sendStartSavingImagesJob()));
    connect(StopSavingImagesButton, SIGNAL(pressed()),this,SLOT(sendStopSavingImagesJob()));
}