Пример #1
0
void CSensorView::addWidget(QString var_name, QPoint var_pos)
{

    bool isExist=false;
    int indExistant=0;
    for(int ind=0;ind<listeAddedSignals.size();ind++)
        if(listeAddedSignals.at(ind)->addedSignalName.compare(var_name)==0)
        {
            isExist=true;
            indExistant=ind;
        }


    QVariant property_value=m_application->m_data_center->getDataProperty(var_name,"Type");
    QString mime_property=property_value.toString();
    int type;

    if(mime_property.isEmpty())
        type=mime_default;
    else if(mime_property.compare("sensor_tor")==0)
        type=mime_sensor_tor;
    else if(mime_property.compare("computed_signal")==0)
        type=mime_computed_signal;
    else
        type=mime_default;

    QLed * newLed;
    QLCDNumber * newLCDNumber;

    switch(type)
    {
        case mime_default:
        case mime_computed_signal:
            newLCDNumber =new QLCDNumber(m_ihm.ui.viewWidget);
            newLCDNumber->setObjectName(var_name);
            newLCDNumber->move(var_pos);
            newLCDNumber->setVisible(true);
            if (isExist)
            {
                listeAddedSignals.at(indExistant)->addedLCDNumber=newLCDNumber;
                listeAddedSignals.at(indExistant)->addedSignalPosition.setX(var_pos.x());
                listeAddedSignals.at(indExistant)->addedSignalPosition.setY(var_pos.y());
            }
            else
                listeAddedSignals << new viewWidget(var_name,var_pos,type,newLCDNumber);
            //qDebug() << "LCDNumber" << var_name << "ajouté";
            break;
        case mime_sensor_tor:
            newLed = new QLed(m_ihm.ui.viewWidget);
            newLed->setObjectName(var_name);
            newLed->setMinimumSize(20,20);
            newLed->setMaximumSize(20,20);
            newLed->setValue(true);
            newLed->move(var_pos);
            newLed->setVisible(true);
            if (isExist)
            {
                listeAddedSignals.at(indExistant)->addedLed=newLed;
                listeAddedSignals.at(indExistant)->addedSignalPosition.setX(var_pos.x());
                listeAddedSignals.at(indExistant)->addedSignalPosition.setY(var_pos.y());
            }
            else
                listeAddedSignals << new viewWidget(var_name,var_pos,type,newLed);
            //qDebug() << "Led" << var_name << "ajouté";
            break;
        default:
            break;
    }

}
Пример #2
0
int main( int argc, char **argv )
{
    QApplication app( argc, argv );
#ifndef QSA_NO_EDITOR
    QWidget widget;
    QSProject project;
    QVBoxLayout *vboxLayout = new QVBoxLayout(&widget);

    // some help text
    QLabel *help = new QLabel("Right-click on any of the buttons to edit "
                              "its properties.");
    vboxLayout->addWidget(help);

    QWidget *hboxWidget = new QWidget;
    QHBoxLayout *hboxLayout = new QHBoxLayout(hboxWidget);
    vboxLayout->addWidget(hboxWidget);

    // create two sample widgets
    QGroupBox *lcdGroup = new QGroupBox( "lcd");
    hboxLayout->addWidget(lcdGroup);

    QVBoxLayout *lcdgroupLayout = new QVBoxLayout(lcdGroup);
    QLCDNumber *lcd = new QLCDNumber;
    lcd->setObjectName("lcd");
    lcdgroupLayout->addWidget(lcd);
    project.addObject(lcd);
    lcdgroupLayout->addWidget(new QLabel("Properties: <ul><li>value</li>"
                                         "<li>setHexMode()</li><li>...</li></ul>"));

    QGroupBox *editGroup = new QGroupBox( "edit");
    hboxLayout->addWidget(editGroup);

    QVBoxLayout *editgroupLayout = new QVBoxLayout(editGroup);
    QLineEdit *edit = new QLineEdit;
    edit->setObjectName("edit");
    edit->setText( "text" );
    editgroupLayout->addWidget(edit);
    project.addObject(edit);
    editgroupLayout->addWidget(new QLabel("Properties: <ul><li>text</li><li>maxLength</li>"
                                          "<li>clear()</li><li>...</li></ul>"));

    QWidget *buttonWidget = new QWidget;
    QVBoxLayout *buttonLayout = new QVBoxLayout(buttonWidget);
    hboxLayout->addWidget(buttonWidget);

    // add script buttons
    ScriptButton *button1 = new ScriptButton(&project, "Increase Counter", 0, "button1");
    buttonLayout->addWidget(button1);
    button1->setScriptCode( "Application.lcd.value++;" );

    ScriptButton *button2 = new ScriptButton(&project, "Reset Counter", 0, "button2");
    buttonLayout->addWidget(button2);
    button2->setScriptCode( "Application.lcd.value = 0;" );

    ScriptButton *button3 = new ScriptButton(&project, "Convert to uppercase", 0, "button3");
    buttonLayout->addWidget(button3);
    button3->setScriptCode( "Application.edit.text = Application.edit.text.upper();" );

    QPushButton *button4 = new QPushButton("&Quit");
    button4->setObjectName("button4");
    buttonLayout->addStretch(-1);
    buttonLayout->addWidget(button4);
    QObject::connect(button4, SIGNAL(clicked()), &app, SLOT(quit()));

    // teach interpreter about widgets
    project.interpreter()->addWrapperFactory( new WidgetWrapperFactory() );
    project.interpreter()->addObjectFactory( new QtNamespaceProvider() );

    widget.show();
#else
    QMessageBox::information( 0, "Disabled feature",
			      "QSA Editor has been disabled. Reconfigure to enable",
			      QMessageBox::Ok );
#endif

    return app.exec();
}
Пример #3
0
    void setupUi(QMainWindow *Detection)
    {
        if (Detection->objectName().isEmpty())
            Detection->setObjectName(QString::fromUtf8("Detection"));
        Detection->resize(729, 480);
        actionE_xit = new QAction(Detection);
        actionE_xit->setObjectName(QString::fromUtf8("actionE_xit"));
        action_Load_Map = new QAction(Detection);
        action_Load_Map->setObjectName(QString::fromUtf8("action_Load_Map"));
        action_Connect = new QAction(Detection);
        action_Connect->setObjectName(QString::fromUtf8("action_Connect"));
        action_Disconnect = new QAction(Detection);
        action_Disconnect->setObjectName(QString::fromUtf8("action_Disconnect"));
        centralWidget = new QWidget(Detection);
        centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
        gridLayoutWidget = new QWidget(centralWidget);
        gridLayoutWidget->setObjectName(QString::fromUtf8("gridLayoutWidget"));
        gridLayoutWidget->setGeometry(QRect(0, 0, 721, 421));
        gridLayout = new QGridLayout(gridLayoutWidget);
        gridLayout->setSpacing(6);
        gridLayout->setContentsMargins(11, 11, 11, 11);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        gridLayout->setSizeConstraint(QLayout::SetNoConstraint);
        gridLayout->setVerticalSpacing(5);
        gridLayout->setContentsMargins(0, 0, 0, 0);
        ugvFeedLabel = new QLabel(gridLayoutWidget);
        ugvFeedLabel->setObjectName(QString::fromUtf8("ugvFeedLabel"));
        QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(ugvFeedLabel->sizePolicy().hasHeightForWidth());
        ugvFeedLabel->setSizePolicy(sizePolicy);

        gridLayout->addWidget(ugvFeedLabel, 1, 2, 1, 1);

        connectionButton = new QCommandLinkButton(gridLayoutWidget);
        connectionButton->setObjectName(QString::fromUtf8("connectionButton"));

        gridLayout->addWidget(connectionButton, 0, 2, 1, 1);

        uavFeedLabel = new QLabel(gridLayoutWidget);
        uavFeedLabel->setObjectName(QString::fromUtf8("uavFeedLabel"));
        sizePolicy.setHeightForWidth(uavFeedLabel->sizePolicy().hasHeightForWidth());
        uavFeedLabel->setSizePolicy(sizePolicy);
        uavFeedLabel->setMaximumSize(QSize(16777215, 16777215));

        gridLayout->addWidget(uavFeedLabel, 1, 0, 1, 1);

        ugvMapLabel = new QLabel(gridLayoutWidget);
        ugvMapLabel->setObjectName(QString::fromUtf8("ugvMapLabel"));
        QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(ugvMapLabel->sizePolicy().hasHeightForWidth());
        ugvMapLabel->setSizePolicy(sizePolicy1);

        gridLayout->addWidget(ugvMapLabel, 1, 3, 1, 1);

        horizontalLayout_4 = new QHBoxLayout();
        horizontalLayout_4->setSpacing(6);
        horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
        label_2 = new QLabel(gridLayoutWidget);
        label_2->setObjectName(QString::fromUtf8("label_2"));

        horizontalLayout_4->addWidget(label_2);

        uavTakeoffLandButton = new QPushButton(gridLayoutWidget);
        uavTakeoffLandButton->setObjectName(QString::fromUtf8("uavTakeoffLandButton"));

        horizontalLayout_4->addWidget(uavTakeoffLandButton);


        gridLayout->addLayout(horizontalLayout_4, 2, 0, 1, 1);

        horizontalLayout_2 = new QHBoxLayout();
        horizontalLayout_2->setSpacing(6);
        horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
        label = new QLabel(gridLayoutWidget);
        label->setObjectName(QString::fromUtf8("label"));

        horizontalLayout_2->addWidget(label);

        ugvSpeedLCD = new QLCDNumber(gridLayoutWidget);
        ugvSpeedLCD->setObjectName(QString::fromUtf8("ugvSpeedLCD"));
        ugvSpeedLCD->setFrameShape(QFrame::Box);

        horizontalLayout_2->addWidget(ugvSpeedLCD);


        gridLayout->addLayout(horizontalLayout_2, 4, 2, 1, 1);

        horizontalLayout_6 = new QHBoxLayout();
        horizontalLayout_6->setSpacing(6);
        horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
        label_3 = new QLabel(gridLayoutWidget);
        label_3->setObjectName(QString::fromUtf8("label_3"));

        horizontalLayout_6->addWidget(label_3);

        ugvSpeakerButton = new QPushButton(gridLayoutWidget);
        ugvSpeakerButton->setObjectName(QString::fromUtf8("ugvSpeakerButton"));

        horizontalLayout_6->addWidget(ugvSpeakerButton);


        gridLayout->addLayout(horizontalLayout_6, 2, 2, 1, 1);

        verticalLayout = new QVBoxLayout();
        verticalLayout->setSpacing(6);
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
        label_4 = new QLabel(gridLayoutWidget);
        label_4->setObjectName(QString::fromUtf8("label_4"));
        label_4->setAlignment(Qt::AlignCenter);

        verticalLayout->addWidget(label_4);

        sauverStatus = new QTextBrowser(gridLayoutWidget);
        sauverStatus->setObjectName(QString::fromUtf8("sauverStatus"));
        sauverStatus->setEnabled(true);
        QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Minimum);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(sauverStatus->sizePolicy().hasHeightForWidth());
        sauverStatus->setSizePolicy(sizePolicy2);
        sauverStatus->setMaximumSize(QSize(777215, 215));

        verticalLayout->addWidget(sauverStatus);


        gridLayout->addLayout(verticalLayout, 4, 3, 1, 1);

        label_5 = new QLabel(gridLayoutWidget);
        label_5->setObjectName(QString::fromUtf8("label_5"));

        gridLayout->addWidget(label_5, 0, 0, 1, 1);

        Detection->setCentralWidget(centralWidget);
        menuBar = new QMenuBar(Detection);
        menuBar->setObjectName(QString::fromUtf8("menuBar"));
        menuBar->setGeometry(QRect(0, 0, 729, 23));
        menuFile = new QMenu(menuBar);
        menuFile->setObjectName(QString::fromUtf8("menuFile"));
        menu_Tools = new QMenu(menuBar);
        menu_Tools->setObjectName(QString::fromUtf8("menu_Tools"));
        menu_Help = new QMenu(menuBar);
        menu_Help->setObjectName(QString::fromUtf8("menu_Help"));
        Detection->setMenuBar(menuBar);
        mainToolBar = new QToolBar(Detection);
        mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
        Detection->addToolBar(Qt::TopToolBarArea, mainToolBar);
        statusBar = new QStatusBar(Detection);
        statusBar->setObjectName(QString::fromUtf8("statusBar"));
        Detection->setStatusBar(statusBar);

        menuBar->addAction(menuFile->menuAction());
        menuBar->addAction(menu_Tools->menuAction());
        menuBar->addAction(menu_Help->menuAction());
        menuFile->addAction(action_Load_Map);
        menuFile->addAction(action_Disconnect);
        menuFile->addAction(actionE_xit);
        menu_Tools->addAction(action_Connect);

        retranslateUi(Detection);
        QObject::connect(actionE_xit, SIGNAL(activated()), Detection, SLOT(close()));
        QObject::connect(action_Connect, SIGNAL(activated()), connectionButton, SLOT(click()));

        QMetaObject::connectSlotsByName(Detection);
    } // setupUi