예제 #1
0
void DropDownList::onLeftUp(wxMouseEvent&) {
    if (mouse_down) {
        if (selected_item != NO_SELECTION && !itemEnabled(selected_item)) return; // disabled item
        // don't hide if there is a child menu
        if (selected_item != NO_SELECTION && submenu(selected_item)) return;
        hide(true);
    }
}
예제 #2
0
void DropDownList::drawItem(DC& dc, int y, size_t item) {
    if (y + item_size.height <= 0 || y >= dc.GetSize().y) return; // not visible
    // draw background
    dc.SetPen(*wxTRANSPARENT_PEN);
    if (item == selected_item) {
        if (itemEnabled(item)) {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        } else {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        }
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else if (!itemEnabled(item)) {
        // mix between foreground and background
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    } else if (highlightItem(item)) {
        // mix a color between selection and window
        dc.SetBrush         (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
                                  wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else {
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
    }
    // draw text and icon
    drawIcon(dc, marginW, y, item, item == selected_item);
    dc.DrawText(capitalize(itemText(item)), marginW + (int)icon_size.width + 1, y + text_offset);
    // draw popup icon
    if (submenu(item)) {
        draw_menu_arrow(this, dc, RealRect(marginW, y, item_size.width, item_size.height), item == selected_item);
    }
    // draw line below
    if (lineBelow(item) && item != itemCount()) {
        dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawLine(marginW, y + (int)item_size.height, marginW + (int)item_size.width, y + (int)item_size.height);
    }
}
예제 #3
0
void AP2DataPlot2D::addGraphLeft()
{
    if (ui.tableWidget->selectedItems().size() == 0)
    {
        return;
    }
    if (ui.tableWidget->horizontalHeaderItem(ui.tableWidget->selectedItems()[0]->column()))
    {
        QString headertext = ui.tableWidget->horizontalHeaderItem(ui.tableWidget->selectedItems()[0]->column())->text();
        QString itemtext = ui.tableWidget->item(ui.tableWidget->selectedItems()[0]->row(),0)->text();
        itemEnabled(itemtext + "." + headertext);
        m_dataSelectionScreen->enableItem(itemtext + "." + headertext);
    }
}
예제 #4
0
void DataSelectionScreen::checkBoxClicked(bool checked)
{
	QCheckBox *check = qobject_cast<QCheckBox*>(sender());
	if (!check)
	{
		return;
	}
	if (checked)
	{
		emit itemEnabled(check->text());
	}
	else
	{
		emit itemDisabled(check->text());
	}
}
예제 #5
0
void DropDownList::hide(bool event, bool allow_veto) {
    // hide?
    bool keep_open = event && allow_veto && stayOpen(selected_item);
    if (keep_open) {
        close_on_mouse_out = true;
    } else {
        // hide root
        DropDownList* root = this;
        while (root->parent_menu) {
            root = root->parent_menu;
        }
        root->realHide();
    }
    // send event
    if (event && selected_item != NO_SELECTION && itemEnabled(selected_item)) {
        select(selected_item);
        if (IsShown()) Refresh(false);
    }
}
void DataSelectionScreen::onItemChanged(QTreeWidgetItem* item,int column)
{
    if (!item->parent())
    {
        return;
    }
    QString name = item->parent()->text(0) + "." + item->text(0);
    if (item->checkState(0) == Qt::Checked)
    {
        if (!m_enabledList.contains(name))
        {
            m_enabledList.append(name);
            emit itemEnabled(name);
        }
    }
    else
    {
        if (m_enabledList.contains(name))
        {
            m_enabledList.removeOne(name);
            emit itemDisabled(name);
        }
    }
}
예제 #7
0
void DropDownList::onMotion(wxMouseEvent& ev) {
    // size
    wxSize cs = GetClientSize();
    // inside?
    if (ev.GetX() < marginW || ev.GetX() + marginW >= cs.GetWidth() || ev.GetY() < marginH || ev.GetY() + marginH >= cs.GetHeight()) {
        ev.Skip();
        return;
    }
    // find selected item
    int startY = marginH - visible_start;
    size_t count = itemCount();
    for (size_t i = 0 ; i < count ; ++i) {
        int endY = startY + (int)item_size.height;
        if (ev.GetY() >= startY && ev.GetY() < endY) {
            if (itemEnabled(i)) {
                showSubMenu(i, startY);
            }
            selectItem(i);
            return;
        }
        startY = endY + lineBelow(i);
    }
    hideSubMenu();
}
예제 #8
0
AP2DataPlot2D::AP2DataPlot2D(QWidget *parent) : QWidget(parent),
    m_uas(NULL),
    m_logDownloadDialog(NULL),
    m_updateTimer(NULL),
    m_tlogReplayEnabled(false)
{
    m_startIndex = 0;
    m_axisGroupingDialog = 0;
    m_logLoaderThread= 0;
    m_logLoaded = false;
    m_progressDialog=0;
    m_currentIndex=0;
    m_graphCount=0;
    m_showOnlyActive = false;

    ui.setupUi(this);

    QDateTime utc = QDateTime::currentDateTimeUtc();
    utc.setTimeSpec(Qt::LocalTime);
    m_timeDiff = QDateTime::currentDateTime().msecsTo(utc);
    m_plot = new QCustomPlot(ui.widget);
    m_plot->setInteraction(QCP::iRangeDrag, true);
    m_plot->setInteraction(QCP::iRangeZoom, true);

    connect(m_plot,SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)),this,SLOT(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)));

    connect(m_plot,SIGNAL(mouseMove(QMouseEvent*)),this,SLOT(plotMouseMove(QMouseEvent*)));

    //ui.horizontalLayout_3->addWidget(m_plot);
    ui.verticalLayout_5->insertWidget(0,m_plot);

    m_plot->show();
    m_plot->plotLayout()->clear();

    m_wideAxisRect = new QCPAxisRect(m_plot);
    m_wideAxisRect->setupFullAxesBox(true);
    m_wideAxisRect->axis(QCPAxis::atRight, 0)->setTickLabels(false);
    m_wideAxisRect->removeAxis(m_wideAxisRect->axis(QCPAxis::atLeft,0));

    m_wideAxisRect->axis(QCPAxis::atBottom, 0)->setTickLabelType(QCPAxis::ltDateTime);
    m_wideAxisRect->axis(QCPAxis::atBottom, 0)->setDateTimeFormat("hh:mm:ss");
    m_wideAxisRect->axis(QCPAxis::atBottom, 0)->setRange(m_timeDiff / 1000,(m_timeDiff / 1000) + 100); //Default range of 0-100 milliseconds?


    m_plot->plotLayout()->addElement(0, 0, m_wideAxisRect);

    QCPMarginGroup *marginGroup = new QCPMarginGroup(m_plot);
    m_wideAxisRect->setMarginGroup(QCP::msLeft | QCP::msRight, marginGroup);

    m_dataSelectionScreen = new DataSelectionScreen(this);
    connect( m_dataSelectionScreen,SIGNAL(itemEnabled(QString)),this,SLOT(itemEnabled(QString)));
    connect( m_dataSelectionScreen,SIGNAL(itemDisabled(QString)),this,SLOT(itemDisabled(QString)));
    ui.horizontalLayout_3->addWidget(m_dataSelectionScreen);

    ui.horizontalLayout_3->setStretch(0,5);
    ui.horizontalLayout_3->setStretch(1,1);

    connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*)));
    activeUASSet(UASManager::instance()->getActiveUAS());

    ui.tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu);

    m_addGraphAction = new QAction("Add To Graph",0);
    ui.tableWidget->addAction(m_addGraphAction);
    connect(m_addGraphAction,SIGNAL(triggered()),this,SLOT(addGraphLeft()));

    ui.tableWidget->setVisible(false);
    ui.hideExcelView->setVisible(false);

    connect(ui.loadOfflineLogButton,SIGNAL(clicked()),this,SLOT(loadButtonClicked()));
    connect(ui.autoScrollCheckBox,SIGNAL(clicked(bool)),this,SLOT(autoScrollClicked(bool)));
    connect(ui.hideExcelView,SIGNAL(clicked(bool)),ui.tableWidget,SLOT(setHidden(bool)));
    connect(ui.tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(tableCellClicked(int,int)));

    ui.logTypeLabel->setText("<p align=\"center\"><span style=\" font-size:24pt; color:#0000ff;\">Live Data</span></p>");


    connect(ui.graphControlsPushButton,SIGNAL(clicked()),this,SLOT(graphControlsButtonClicked()));
    model = new QStandardItemModel();
    connect(ui.toKMLPushButton, SIGNAL(clicked()), this, SIGNAL(toKMLClicked()));
    connect(ui.horizontalScrollBar,SIGNAL(sliderMoved(int)),this,SLOT(horizontalScrollMoved(int)));
    connect(ui.verticalScrollBar,SIGNAL(sliderMoved(int)),this,SLOT(verticalScrollMoved(int)));

    connect(ui.horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horizontalScrollMoved(int)));
    connect(ui.verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(verticalScrollMoved(int)));
    connect(m_wideAxisRect->axis(QCPAxis::atBottom), SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    m_plot->setPlottingHint(QCP::phFastPolylines,true);

    connect(ui.downloadPushButton, SIGNAL(clicked()), this, SLOT(showLogDownloadDialog()));
    ui.downloadPushButton->setEnabled(false);
    connect(ui.loadTLogButton,SIGNAL(clicked()),this,SLOT(replyTLogButtonClicked()));
}
예제 #9
0
bool DropDownList::onCharInParent(wxKeyEvent& ev) {
    // keyboard codes
    int k = ev.GetKeyCode();
    if (IsShown()) {
        if (open_sub_menu) {
            // sub menu always takes keys
            return open_sub_menu->onCharInParent(ev);
        } else {
            switch (k) {
            case WXK_UP:
                return selectItem(selected_item - 1);
            case WXK_DOWN:
                return selectItem(selected_item + 1);
            case WXK_RETURN:
                if (!showSubMenu() && (selected_item == NO_SELECTION || itemEnabled(selected_item))) {
                    hide(true, false); // don't veto; always close
                }
                break;
            case WXK_SPACE:
                if (!showSubMenu() && (selected_item == NO_SELECTION || itemEnabled(selected_item))) {
                    hide(true);
                }
                break;
            case WXK_ESCAPE:
                hide(false);
                break;
            case WXK_LEFT:
                if (parent_menu) hide(false);
                break;
            case WXK_RIGHT:
                return showSubMenu();
            default:
                // match first character of an item, start searching just after the current selection
                size_t si = selected_item != NO_SELECTION ? selected_item + 1 : 0;
                size_t count = itemCount();
                for (size_t i = 0 ; i < count ; ++i) {
                    size_t index = (si + i) % count;
                    if (!itemEnabled(index)) continue;
                    String c = itemText(index);
#ifdef UNICODE
                    if (!c.empty() && toUpper(c.GetChar(0)) == toUpper(ev.GetUnicodeKey())) {
#else
                    if (!c.empty() && toUpper(c.GetChar(0)) == toUpper(ev.GetKeyCode())) {
#endif
                        // first character matches
                        selected_item = index;
                        showSubMenu();
                        selectItem(index);
                        return true;
                    }
                }
            }
        }
        return true;
    }
    else if (k==WXK_SPACE || k==WXK_RETURN || k==WXK_DOWN) {
        // drop down list is not shown yet, show it now
        show(false, wxPoint(0,0));
        return true;
    }
    return false;
}