/** * Draw the image onto the renderer. * @param renderer */ void ImageView::draw(SDL_Renderer* renderer) { RectangleView::draw(renderer); auto x = static_cast<uint16_t>(getX() + getHorizontalOffset()); auto y = static_cast<uint16_t>(getY() + getVerticalOffset()); animation->move(x, y); animation->draw(renderer); }
QWidget * DataRecorderChannelBoolean::getPropertyWidget(QWidget * parent, const char * name) { if (!m_propertyWidget) { // Setup widget QVBox * widget = new QVBox(parent,name); Q_CHECK_PTR(widget); widget->setMargin(KDialog::marginHint()); widget->setSpacing(KDialog::spacingHint()); QLabel * lab; lab = new QLabel(i18n("DataRecorder", "Channel:"), widget); Q_CHECK_PTR(lab); KSimLineEdit * conName; conName = new KSimLineEdit(widget); Q_CHECK_PTR(conName); conName->setText(getConnector()->getName()); connect(getConnector(), SIGNAL(signalSetName(const QString &)), conName, SLOT(setText(const QString &))); connect(conName, SIGNAL(changed(const QString &)), SLOT(setChannelName(const QString &))); lab->setBuddy(conName); // TODO add ToolTip ChannelPositionWidget * pos; pos = new ChannelPositionWidget(this, widget); Q_CHECK_PTR(pos); pos->setGainValue(getVerticalGain()); pos->setOffsetValue(getVerticalOffset()); connect(pos, SIGNAL(gainChanged(double)), SLOT(setVerticalGain(double))); connect(pos, SIGNAL(offsetChanged(double)), SLOT(setVerticalOffset(double))); KColorButton * color = new KColorButton(widget); Q_CHECK_PTR(color); color->setColor(getLineColor()); connect(color, SIGNAL(changed(const QColor &)), SLOT(setLineColor(const QColor &))); m_propertyWidget = widget; } else { if (parent) { KSIMDEBUG("Only one widget allowed"); } } return m_propertyWidget; }
int DataRecorderChannelFloat::drawData(QPaintDevice * paintDev, int startSample, int stopSample, int horizontalOffset, int height, double samplePerPixel, int verticalDivs) { #define LIMIT 32767 #define LIMITER(a) (QMIN(QMAX(a,-LIMIT),LIMIT)) int index = startSample; int counter = 0; int horiPos = horizontalOffset; int lastHoriPos = horizontalOffset; int lastVertPos, vertPos; QPainter painter(paintDev); painter.setPen(getLineColor()); double verticalOffset = (getVerticalOffset() * height) / verticalDivs; double verticalGain = (getVerticalGain() * height) / verticalDivs; if (index >= m_data->count()) return m_data->count(); // Nothing to draw if (stopSample >= m_data->count()) stopSample = m_data->count()-1; // Limit samples vertPos = lastVertPos = LIMITER(height - qRound(verticalGain * getData(index) + verticalOffset)); while(index < stopSample) { index++; counter++; vertPos = LIMITER(height - qRound(verticalGain * getData(index) + verticalOffset)); horiPos = horizontalOffset + qRound(counter / samplePerPixel); // if(lastVertPos != vertPos) // Speed up static signals { painter.drawLine(lastHoriPos, lastVertPos, horiPos, vertPos); lastVertPos = vertPos; lastHoriPos = horiPos; } } // Draw final line // painter.drawLine(lastHoriPos, lastVertPos, horiPos, vertPos); return index-1; }
int DataRecorderChannelBoolean::drawData(QPaintDevice * paintDev, int startSample, int stopSample, int horizontalOffset, int height, double samplePerPixel, int verticalDivs) { int index = startSample; int counter = 0; int horiPos = horizontalOffset; int lastHoriPos = horizontalOffset; int lastVertPos, vertPos; QPainter painter(paintDev); painter.setPen(getLineColor()); int verticalOffset = qRound((getVerticalOffset() * height) / verticalDivs); int verticalGain = qRound((getVerticalGain() * height) / verticalDivs); if (index >= m_data->count()) return m_data->count(); // Nothing to draw if (stopSample >= m_data->count()) stopSample = m_data->count()-1; // Limit samples lastVertPos = height - (verticalGain * getData(index) + verticalOffset); while(index <= stopSample) { vertPos = height - (verticalGain * getData(index) + verticalOffset); if(lastVertPos != vertPos) { painter.drawLine(lastHoriPos, lastVertPos, horiPos, lastVertPos); painter.drawLine(horiPos, lastVertPos, horiPos, vertPos); lastVertPos = vertPos; lastHoriPos = horiPos; } horiPos = horizontalOffset + qRound(counter / samplePerPixel); index++; counter++; } // Draw final line painter.drawLine(lastHoriPos, lastVertPos, horiPos, lastVertPos); return index-1; }
void ListBox::paintComponent( const agui::PaintEvent &paintEvent ) { int itemsSkipped = getVisibleItemStart(); int hScrollHeight = 0; if(m_hScroll->isVisible()) { hScrollHeight = m_hScroll->getHeight(); } int maxitems = getVisibleItemCount(); int h = getItemHeight() * itemsSkipped; int rcount = 0; int diff = getItemHeight() - getFont()->getLineHeight(); agui::Color inverseFont = agui::Color(255,255,255); agui::Color* color; agui::Point absPos = getAbsolutePosition(); agui::Rectangle parentRect = m_visbilityWidget ? m_visbilityWidget->getAbsoluteRectangle() : getParent()->getAbsoluteRectangle(); int posX = absPos.getX() + (getInnerWidth() / 2); for(agui::ListItem::const_iterator it = getItemsBegin() + itemsSkipped ; it != getItemsEnd(); ++it) { if(rcount == maxitems) { break; } //if the item cannot be seen in the parent do not render it if(parentRect.pointInside(agui::Point(posX, absPos.getY() + h + getVerticalOffset())) || getSizeRectangle().pointInside(agui::Point(posX ,absPos.getY() + getItemHeight() + h + getVerticalOffset()) )) { if(it->second) { int vOffset = m_vScroll->isVisible() ? m_vScroll->getWidth() + 1 : 0; paintEvent.graphics()->drawNinePatchImage(m_selImage, agui::Point(0,h + getVerticalOffset()), agui::Dimension(getInnerSize().getWidth() - vOffset,getItemHeight())); color = &inverseFont; } else if(itemsSkipped + rcount == getHoverIndex()) { agui::Color highlight = agui::Color( getFontColor().getR() + 0.12f, getFontColor().getG() + 0.12f, getFontColor().getB() + 0.12f); color = (agui::Color*)&highlight; } else { color = (agui::Color*)&getFontColor(); } paintEvent.graphics()->drawText(agui::Point(getHorizontalOffset() + 4 , h + getVerticalOffset() + (diff / 2)),it->first.text.c_str(),*color, getFont()); } h += getItemHeight(); rcount++; } }