Beispiel #1
0
void EventManager::drawButtonList(ButtonList *buttonList) {
	for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
		toggleButton((*button), 1, true);

		if (!(*button)->_isEnabled)
			toggleButton((*button), 1, false);
	}
}
Beispiel #2
0
void TaskHeader::paintEvent(QPaintEvent *ev) {
    QFrame::paintEvent(ev);
    QPainter p(this);
    m_icon.paint(&p, QRect(2, 1, 32, 32), Qt::AlignCenter,
                 isEnabled() ? QIcon::Normal : QIcon::Disabled,
                 toggleButton()->isChecked() ? QIcon::On : QIcon::Off);
}
Beispiel #3
0
void buttonBoard::mousePressed(int x, int y, int button)
{
    int col=(x-mx)/cw;
    int row=(y-my)/rh;
    if (col<BB_COLS && row < BB_ROWS)
    {
      toggleButton(row,col);
    }

}
Beispiel #4
0
void CrewUI::onGui()
{
    if (mySpaceship)
    {
        switch(showPosition)
        {
        case helmsOfficer:
            helmsUI();
            break;
        case weaponsOfficer:
            weaponsUI();
            break;
        case engineering:
            engineeringUI();
            break;
        case scienceOfficer:
            scienceUI();
            break;
        case commsOfficer:
            commsUI();
            break;
        default:
            drawStatic();
            text(sf::FloatRect(0, 500, 1600, 100), "???", AlignCenter, 100);
            break;
        }
        if (myPlayerInfo->main_screen_control)
            mainScreenSelectGUI();
    }else{
        drawStatic();
    }

    int offset = 0;
    for(int n=0; n<maxCrewPositions; n++)
    {
        if (myPlayerInfo->crew_position[n])
        {
            if (toggleButton(sf::FloatRect(200 * offset, 0, 200, 25), showPosition == ECrewPosition(n), getCrewPositionName(ECrewPosition(n)), 20))
            {
                showPosition = ECrewPosition(n);
            }
            offset++;
        }
    }
    
    MainUI::onGui();
}
//--------------------------------------------------------------
void arduinoGrapher::mousePressed(int x, int y, int button){
    
    cout << "pressed at "<<x<<", "<<y<<""<<endl;
    
    if (drawBaudPane){ //overrides all other commands
        
        if (insideCentreRect(mouseX, mouseY, baudPaneX, baudPaneY, baudButtonW, baudPaneH)){
            
            for(int i=0; i<11; i++){
                
                if (insideCentreRect(mouseX, mouseY, baudPaneX, i*28+baudPaneY-(baudPaneH/2)+38, 150, 25)){
                    serial.setBaud(serial.baudRates[i]);
                    serial.serialConnection.flush(true, true);
                    
                    serial.println("{print:begin}");
                    recievingData = true;
                    
                    drawBaudPane = false;
                }
            }
            
        }else{
            drawBaudPane = false;
        }
        
    }else{
        
        
        if (mouseY>graphY&&mouseY<(graphY+graphH)){
            if (mouseX>graphX&&mouseX<(graphX+graphW)) { //inside graph
                
                if (cursorActive){
                    
                    cout << "adding probe"<<endl;
                    if(serial.messages.size()>0){
                        addProbe(x);
                    }
                    
                }
                
            }
        }else if (insideStartButton(mouseX, mouseY)){
            if(recievingData){
                serial.println("{print:end}");
                recievingData = false;
            }else{
                serial.println("{print:begin}");
                recievingData = true;
            }
        }else if(insideResetButton(mouseX, mouseY)){
            
            serial.messages.clear();
            probes.clear();
            
            
        }else if(insideBaudButton(mouseX, mouseY)){
            
            if(!drawBaudPane){
                
                serial.println("{print:end}");
                recievingData = false;
                
                drawBaudPane = true;
                
            }
            
            
        }else{
            for (int i=0; i<buttons.size(); i++){
                
                if(mouseX>=buttons[i].x&&mouseX<=buttons[i].x+buttons[i].w){
                    if(mouseY>=buttons[i].y&&mouseY<=buttons[i].y+buttons[i].h){
                        
                        toggleButton(i);
                        
                    }
                    
                }
            }
        }
        
    }
    
    
    
    
    

}
Beispiel #6
0
MainWindow::MainWindow(int width, int height) : m_buffer(0xffff - 28) {
    setMinimumSize(width, height);

    centralWidget = new QWidget(this);
    setCentralWidget(centralWidget);

    m_settings = std::make_unique<Settings>("IPSettings.txt");

    m_client = new MjpegClient(m_settings->getString("streamHost"),
                               m_settings->getInt("mjpegPort"),
                               m_settings->getString("mjpegRequestPath"));

    m_stream =
        new VideoStream(m_client, this, 640, 480, &m_streamCallback, [this] {},
                        [this] { m_button->setText("Stop Stream"); },
                        [this] { m_button->setText("Start Stream"); });
    m_stream->setMaximumSize(640, 480);

    m_button = new QPushButton("Start Stream");
    connect(m_button, SIGNAL(released()), this, SLOT(toggleButton()));

    m_leftLayout = new QVBoxLayout;

    m_centerLayout = new QVBoxLayout;

    m_centerLayout->addWidget(m_stream, 0, Qt::AlignTop);

    QHBoxLayout* buttonLayout = new QHBoxLayout;
    buttonLayout->addWidget(m_button, 0, Qt::AlignTop);
    buttonLayout->insertStretch(1);
    m_centerLayout->addLayout(buttonLayout);

    m_rightLayout = new QVBoxLayout;

    m_optionLayout = new QVBoxLayout;

    m_autoSelect = new QComboBox;
    connect(m_autoSelect,
            static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
            [this](int index) {
                char data[16] = "autonSelect\r\n";
                data[13] = index;

                m_dataSocket->writeDatagram(data, sizeof(data), m_remoteIP,
                                            m_dataPort);
            });
    m_optionLayout->addWidget(m_autoSelect);
    m_optionLayout->setAlignment(m_autoSelect, Qt::AlignTop);

    QGridLayout* mainLayout = new QGridLayout;
    mainLayout->setColumnMinimumWidth(0, width / 4);
    mainLayout->setColumnMinimumWidth(1, width / 4);
    mainLayout->setColumnMinimumWidth(2, width / 4);
    mainLayout->setColumnMinimumWidth(3, width / 4);

    mainLayout->addLayout(m_leftLayout, 0, 0);
    mainLayout->addLayout(m_centerLayout, 0, 1);
    mainLayout->addLayout(m_rightLayout, 0, 2);
    mainLayout->addLayout(m_optionLayout, 0, 3);

    centralWidget->setLayout(mainLayout);

    createActions();
    createMenus();

    setUnifiedTitleAndToolBarOnMac(true);

    m_dataSocket = std::make_unique<QUdpSocket>(this);
    m_dataSocket->bind(m_settings->getInt("dsDataPort"));
    connect(m_dataSocket.get(), SIGNAL(readyRead()), this,
            SLOT(handleSocketData()));

    m_remoteIP = QString::fromUtf8(m_settings->getString("robotIP").c_str());
    m_dataPort = m_settings->getInt("robotDataPort");

    m_connectTimer = std::make_unique<QTimer>();
    connect(m_connectTimer.get(), &QTimer::timeout, [this] {
        if (!m_connectDlgOpen) {
            char data[16] = "connect\r\n";
            m_dataSocket->writeDatagram(data, sizeof(data), m_remoteIP,
                                        m_dataPort);
        }

        m_connectTimer->start(2000);
    });
    m_connectTimer->start(2000);
}