void rkBtnSw::paintEvent(QPaintEvent *) { QPainter painter(this); painter.drawPixmap(QPoint(0,0), pixmapBackground); /* Background */ QPoint ptFore; /* Set Font */ QFont font = painter.font(); font.setPointSize(12); painter.setFont(font); if (buttonOn) { ptFore = rect().topLeft(); } else { ptFore = QPoint(this->width() - pixmapForeground.width(),this->rect().top()); } QRect rcOn; rcOn.setTopLeft(rect().topLeft()); rcOn.setBottomRight(QPoint(pixmapForeground.width(), pixmapForeground.height())); painter.drawText(rcOn, Qt::AlignCenter, "OFF"); /* Text "OFF" */ QRect rcOff; rcOff.setTopLeft(QPoint(rect().width() - pixmapForeground.width(), rect().top())); rcOff.setBottomRight(rect().bottomRight()); painter.drawText(rcOff, Qt::AlignCenter, "ON"); /* Text "ON" */ painter.drawPixmap(ptFore, pixmapForeground); /* Foreground */ }
/** * @brief 마우스 커서가 MainWindow의 탭영역(1,2,3)에 올라가있는지 확인한다. * * +-------------------------------+-+-+-+ * | TITLE BAR |_|O|X| * +----------+----------+---------+-+-+-+ * |##1(Tab)##|##2(Tab)##|###3(Empty)####| * +----------+----------+---------------+ * | | * | 4 | * | | * +-------------------------------------+ * * TabBar::geometry()는 1,2영역을 나타내고, TabWidget::geometry()는 1,2,3,4영역을 나타낸다. * 이 두 geometry()를 연산해서 1,2,3 영역을 찾는다. * * @param mainWindow 대상 메인 윈도 * @return bool * */ bool CWindowManager::isCursorOnTabWithEmptyArea(MainWindow *mainWindow) { QRect barRect; QRect barRectG; QRect widgetRect; QRect widgetRectG; QTabBar* tabBar = 0; QTabWidget* tabWidget = 0; if(!mainWindow) return false; tabBar = mainWindow->getTabBar(); tabWidget = mainWindow->getTabWidget(); barRect = tabBar->geometry(); widgetRect = tabWidget->geometry(); barRectG.setTopLeft(tabBar->mapToGlobal(barRect.topLeft())); barRectG.setBottomRight(tabBar->mapToGlobal(barRect.bottomRight())); widgetRectG.setTopLeft(tabWidget->mapToGlobal(widgetRect.topLeft())); widgetRectG.setBottomRight(tabWidget->mapToGlobal(widgetRect.bottomRight())); widgetRectG.setTopLeft(QPoint(widgetRectG.topLeft().x(), barRectG.topLeft().y())); widgetRectG.setBottomRight(QPoint(widgetRectG.bottomRight().x(), barRectG.bottomRight().y())); return widgetRectG.contains(QCursor::pos()); }
void TimeLineCells::paintOnionSkin( QPainter& painter ) { Layer* layer = mEditor->layers()->currentLayer(); if (layer == nullptr) { return; } int frameNumber = mEditor->currentFrame(); int prevOnionSkinCount = mEditor->preference()->getInt(SETTING::ONION_PREV_FRAMES_NUM); int nextOnionSkinCount = mEditor->preference()->getInt(SETTING::ONION_NEXT_FRAMES_NUM); bool isAbsolute = (mEditor->preference()->getString(SETTING::ONION_TYPE) == "absolute"); if (mEditor->preference()->isOn(SETTING::PREV_ONION) && prevOnionSkinCount > 0) { int onionFrameNumber = layer->getPreviousFrameNumber(frameNumber, isAbsolute); int onionPosition = 0; while (onionPosition < prevOnionSkinCount && onionFrameNumber > 0) { painter.setBrush( QColor( 128, 128, 128, 128 ) ); painter.setPen( Qt::NoPen ); QRect onionRect; onionRect.setTopLeft( QPoint( getFrameX( onionFrameNumber - 1 ), 0 ) ); onionRect.setBottomRight( QPoint( getFrameX( onionFrameNumber ), height() ) ); onionRect.setBottomRight( QPoint( getFrameX( onionFrameNumber ), 19 ) ); painter.drawRect( onionRect ); onionFrameNumber = layer->getPreviousFrameNumber(onionFrameNumber, isAbsolute); onionPosition++; } } if (mEditor->preference()->isOn(SETTING::NEXT_ONION) && nextOnionSkinCount > 0) { int onionFrameNumber = layer->getNextFrameNumber(frameNumber, isAbsolute); int onionPosition = 0; while (onionPosition < nextOnionSkinCount && onionFrameNumber > 0) { painter.setBrush( QColor( 128, 128, 128, 128 ) ); painter.setPen( Qt::NoPen ); QRect onionRect; onionRect.setTopLeft( QPoint( getFrameX( onionFrameNumber - 1 ), 0 ) ); onionRect.setBottomRight( QPoint( getFrameX( onionFrameNumber ), height() ) ); onionRect.setBottomRight( QPoint( getFrameX( onionFrameNumber ), 19 ) ); painter.drawRect( onionRect ); onionFrameNumber = layer->getNextFrameNumber(onionFrameNumber, isAbsolute); onionPosition++; } } }
void TimeLineCells::paintEvent( QPaintEvent* event ) { Q_UNUSED( event ); Object* object = mEditor->object(); Layer* layer = mEditor->layers()->currentLayer(); Q_ASSUME( object != nullptr && layer != nullptr ); QPainter painter( this ); bool isPlaying = mEditor->playback()->isPlaying(); if ( ( !isPlaying && !timeLine->scrubbing ) || m_pCache == NULL ) { drawContent(); } if ( m_pCache ) { painter.drawPixmap( QPoint( 0, 0 ), *m_pCache ); } if ( m_eType == TIMELINE_CELL_TYPE::Tracks ) { if (!isPlaying) { paintOnionSkin(painter); } // --- draw the position of the current frame if ( mEditor->currentFrame() > frameOffset ) { painter.setBrush( QColor( 255, 0, 0, 128 ) ); painter.setPen( Qt::NoPen ); painter.setFont( QFont( "helvetica", 10 ) ); //painter.setCompositionMode(QPainter::CompositionMode_Source); // this causes the message: QPainter::setCompositionMode: PorterDuff modes not supported on device QRect scrubRect; scrubRect.setTopLeft( QPoint( getFrameX( mEditor->currentFrame() - 1 ), 0 ) ); scrubRect.setBottomRight( QPoint( getFrameX( mEditor->currentFrame() ), height() ) ); if ( shortScrub ) { scrubRect.setBottomRight( QPoint( getFrameX( mEditor->currentFrame() ), 19 ) ); } painter.drawRect( scrubRect ); painter.setPen( QColor( 70, 70, 70, 255 ) ); int incr = 0; if ( mEditor->currentFrame() < 10 ) { incr = 4; } else { incr = 0; } painter.drawText( QPoint( getFrameX( mEditor->currentFrame() - 1 ) + incr, 15 ), QString::number( mEditor->currentFrame() ) ); } } }
/*! * \param[in] aPos point to insert into the polygon * \param[in] aPoly polygon */ int ImageHolder::posInPolygon(QPoint *aPos, QPolygon *aPoly) const { if (!aPos || !aPoly || aPoly->count() < 2 || aPos->isNull()) { return -1; /* NOTREACHED */ } int x = aPos->x(); int y = aPos->y(); int index = 0; int dist = 100000; int temp = 0; int count = aPoly->count(); QRect rect; for (int i = 0; i < count - 1; i++) { temp = pointToLineDistance( QLine(aPoly->at(i), aPoly->at(i + 1)), *aPos ); rect.setTopLeft(aPoly->at(i)); rect.setBottomRight(aPoly->at(i + 1)); rect = rect.normalized(); if (temp < dist && ((x < rect.right() && rect.left() < x) || (y < rect.bottom() && rect.top() < y))) { dist = temp; index = i + 1; } } /* first and last points */ temp = pointToLineDistance( QLine(aPoly->at(0), aPoly->at(count - 1)), *aPos ); rect.setTopLeft(aPoly->at(0)); rect.setBottomRight(aPoly->at(count - 1)); rect = rect.normalized(); if (temp < dist && ((x < rect.right() && rect.left() < x) || (y < rect.bottom() && rect.top() < y))) { index = 0; } return index; }
void UIGraphicsZoomButton::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget*) { /* Save painter: */ pPainter->save(); /* Prepare variables: */ int iMargin = data(GraphicsButton_Margin).toInt(); QRect paintRect = pOption->rect; paintRect.setTopLeft(paintRect.topLeft() + QPoint(iMargin, iMargin)); paintRect.setBottomRight(paintRect.bottomRight() - QPoint(iMargin, iMargin)); QIcon icon = data(GraphicsButton_Icon).value<QIcon>(); QSize iconSize = data(GraphicsButton_IconSize).toSize(); /* Make painter beauty: */ pPainter->setRenderHint(QPainter::SmoothPixmapTransform); /* Draw pixmap: */ pPainter->drawPixmap(/* Pixmap rectangle: */ paintRect, /* Pixmap size: */ icon.pixmap(iconSize)); /* Restore painter: */ pPainter->restore(); }
void ShockSectorLabel::update() { QRect boundary; boundary.setTopLeft(QPoint(10, 10)); boundary.setBottomRight(QPoint(SIZE - 10, SIZE - 10)); QPixmap pixmap(SIZE, SIZE); pixmap.fill(Qt::white); QPainter painter(&pixmap); // Arena painter.setPen(Qt::black); painter.drawEllipse(boundary); // Shock sector int a = angle - (range / 2); int alen = range; painter.setBrush(QBrush(Qt::yellow, Qt::FDiagPattern)); painter.drawPie(boundary, a, alen); setPixmap(pixmap); }
void WidgetItem::resizeEvent(QResizeEvent *e) { QSize newSize = e->size(); QRect rect = ui->text->geometry(); rect.setBottomRight(QPoint(newSize.width()-50, rect.bottom())); ui->text->setGeometry(rect); ui->background->resize(newSize); }
QRect ControlRuler::mapItemToWidget(QRectF *rect) { QRect newrect; newrect.setTopLeft(QPoint(mapXToWidget(rect->left()),mapYToWidget(rect->top()))); newrect.setBottomRight(QPoint(mapXToWidget(rect->right()),mapYToWidget(rect->bottom()))); return newrect; }
void OneToOneRoom::stackedWidgetCurrentChanged(int index) { auto widget = stackedWidget->currentWidget(); QRect rc; rc.setBottomRight(stackedWidget->geometry().bottomRight()); rc.setTopLeft(QPoint(rc.bottom() - widget->height(), rc.right() - widget->width())); stackedWidget->setGeometry(rc); updateGeometry(); }
void MapWidget::clipCellRect(QRect & r) const { QPoint topLeft = r.topLeft(); QPoint bottomRight = r.bottomRight(); clipCellCoord(topLeft); clipCellCoord(bottomRight); r.setTopLeft(topLeft); r.setBottomRight(bottomRight); }
QRect CWndControl::GetClientRect(bool parent) const { QRect rect = m_clientRect; if (!parent) { rect.setTopLeft(rect.topLeft() - m_windowRect.topLeft()); rect.setBottomRight(rect.bottomRight() - m_windowRect.topLeft()); } return rect; }
QRect CWndControl::GetWindowRect(bool parent) const { QRect rect = m_windowRect; if (!parent) { const QPoint topLeft = rect.topLeft(); rect.setTopLeft(QPoint(0, 0)); rect.setBottomRight(rect.bottomRight() - topLeft); } return rect; }
void RegionGrabber::resizeEvent( QResizeEvent* e ) { Q_UNUSED( e ); if ( selection.isNull() ) return; QRect r = selection; r.setTopLeft( limitPointToRect( r.topLeft(), rect() ) ); r.setBottomRight( limitPointToRect( r.bottomRight(), rect() ) ); if ( r.width() <= 1 || r.height() <= 1 ) //this just results in ugly drawing... r = QRect(); selection = r; }
/** * @brief Draw the world. * @param painter */ void RenderArea::drawField(QPainter &painter) { painter.save(); painter.setRenderHint(QPainter::Antialiasing); QRect field; field.setTopLeft(QPoint(this->x(), this->y())); field.setBottomRight(QPoint(this->width()-1, this->height()-1)); painter.setPen(Qt::black); painter.setBrush(QBrush(Qt::green)); painter.drawRect(field); painter.restore(); }
static QPixmap pixmapWithText(const QString &text, const QColor color) { QFont font; QFontMetrics metric(font); QRect rectangle = metric.boundingRect(text); rectangle.setBottomRight(rectangle.bottomRight() + QPoint(20, 20)); QImage image(rectangle.size(), QImage::Format_RGB32); image.fill(color); QPainter painter(&image); painter.setFont(font); painter.drawText(rectangle, Qt::AlignHCenter | Qt::AlignVCenter, text); return QPixmap::fromImage(image); }
static QRect getBoundingRect(const GH_List &list){ GH_List::const_iterator n = list.begin(); if (n != list.end()){ QRect rect = (*n)->box; for (++n; n!=list.end(); ++n){ rect = rect.united((*n)->box); } rect.setTopLeft(rect.topLeft() - QPoint(g_border, g_border)); rect.setBottomRight(rect.topLeft() + QPoint(rect.width() + 2 * g_border, rect.height() + 2 * g_border)); return rect; } return QRect(); }
void Receiver::drawBorderRect() { if(isDrawBorder){ QPainter painter(this); QRect rect; QPen pen; pen.setColor(QColor(211, 211, 211)); rect.setTopLeft(QPoint(10, 20)); rect.setBottomRight(QPoint(this->width() - 15, this->height() - 20)); painter.setPen(pen); painter.drawRect(rect); } }
QRect KstGfxMouseHandlerUtils::resizeRectFromCorner(const QPoint& anchorPoint, const QPoint& movePoint, const QPoint& pos, const QRect& bounds, bool maintainAspect) { QRect newSize; QPoint npos = pos; if (maintainAspect) { QPoint fakeMovePoint = anchorPoint + QPoint(quadrantSign(pos,anchorPoint)*abs((movePoint - anchorPoint).x()),abs((movePoint - anchorPoint).y())); // allow the rectangle to flip. npos = findNearestPtOnLine(anchorPoint, fakeMovePoint, pos, bounds); } newSize.setTopLeft(anchorPoint); newSize.setBottomRight(npos); return bounds.intersect(newSize.normalize()); }
void RectMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); QPen pn; pn.setColor(color); pn.setWidth(width/currentScale); painter->setPen(pn); QRect rect; rect.setTopLeft(firstPoint); rect.setBottomRight(secondPoint); painter->drawRect(rect); }
void RegionGrab::resizeEvent(QResizeEvent *event) { Q_UNUSED( event ); if (m_selection.isNull()) return; QRect r = m_selection; r.setTopLeft(limitPointToRect(r.topLeft(), rect())); r.setBottomRight(limitPointToRect(r.bottomRight(), rect())); if (r.width() <= 1 || r.height() <= 1) //this just results in ugly drawing... m_selection = QRect(); else m_selection = normalizeSelection(r); }
void SpectralMeterView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); // re-draw the background pixmap if (bgPixmap.width() != int(m_boundingRect.width()) || bgPixmap.height() != int(m_boundingRect.height())) { update_background(); } painter->drawPixmap(0, 0, bgPixmap); // draw the bars if (m_spectrum.size()) { QRect rect; painter->setClipRegion(m_rect); painter->setBrush(m_brushFg); painter->setPen(Qt::NoPen); int spc = 0; if (num_bands < 64) spc = 1; // draw the freq bands for (uint i = 0; i < (uint)m_spectrum.size(); ++i) { if (m_bands.at(i+1) < lower_db) { continue; } rect.setTopLeft(QPoint((int)freq2xpos(m_bands.at(i)) + spc, (int)db2ypos(m_spectrum.at(i)))); rect.setBottomRight(QPoint((int)freq2xpos(m_bands.at(i+1)) - spc, (int)db2ypos(DB_FLOOR))); painter->drawRect(rect); } // draw the average line if requested if (show_average) { painter->setPen(m_penAvgCurve); QPoint pt; QPoint po((int)m_map_idx2xpos.at(0), (int)db2ypos(m_avg_db.at(0))); for (uint i = 0; i < (uint)m_avg_db.size(); ++i) { pt.setX((int)m_map_idx2xpos.at(i)); pt.setY((int)db2ypos(m_avg_db.at(i))); painter->drawLine(po, pt); po = pt; } } } }
/*! * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen) * \see drawPolygons(QPainter *aPainter, QPen *aPen) * * It contains drawing of the confirmed and not confirmed selections either. */ void ImageHolder::paintEvent(QPaintEvent *anEvent) { QLabel::paintEvent(anEvent); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); //painter.setRenderHint(QPainter::SmoothPixmapTransform); QPen pen; if (NoTool != tool_) { pen.setWidth(1); pen.setColor(QColor(Qt::black)); pen.setStyle(Qt::DashLine); painter.setPen(pen); if (BoundingBoxTool == tool_) { /* scaling */ QRect bbox = bounding_box_.rect; QPoint bboxTopLeft = bbox.topLeft() * scale_; QPoint bboxBottomRight = bbox.bottomRight() * scale_; bbox.setTopLeft(bboxTopLeft); bbox.setBottomRight(bboxBottomRight); painter.drawRect(bbox); } else if (PolygonTool == tool_) { /* scaling */ QPoint point; QPolygon poly = polygon_.poly; for (int i = 0; i < poly.size(); i++) { point.setX(poly.at(i).x()); point.setY(poly.at(i).y()); point *= scale_; poly.remove(i); poly.insert(i, point); } painter.drawPolygon(poly); } } /* drawing bounding boxes */ drawBoundingBoxes(&painter, &pen); drawPolygons(&painter, &pen); }
void KstTopLevelView::pressMoveLayoutModeSelect(const QPoint& pos, bool shift) { Q_UNUSED(shift) const QRect old(_prevBand); QRect r; r.setTopLeft(_moveOffset); r.setBottomRight(pos); _prevBand = r.normalize().intersect(_geom); if (old != _prevBand) { KstPainter p; p.begin(_w); p.setRasterOp(Qt::NotROP); p.drawWinFocusRect(old); p.drawWinFocusRect(_prevBand); p.end(); } KstApp::inst()->slotUpdateDataMsg(QString::null); }
void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) { QTextEdit *edit = textEdit(); QTextCursor cursor = textCursor(); cursor.setPosition(startIndex); QRect r = edit->cursorRect(cursor); cursor.setPosition(endIndex); r.setBottomRight(edit->cursorRect(cursor).bottomRight()); r.moveTo(r.x() + edit->horizontalScrollBar()->value(), r.y() + edit->verticalScrollBar()->value()); // E V I L, but ensureVisible is not public if (!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r))) qWarning("AccessibleTextEdit::scrollToSubstring failed!"); }
void KisCurveMagnetic::reduceMatrix(QRect& rc, GrayMatrix& m, int top, int right, int bottom, int left) { QPoint topleft(top, left); QPoint bottomright(bottom, right); rc.setTopLeft(rc.topLeft() + topleft); rc.setBottomRight(rc.bottomRight() - bottomright); if (left) m.erase(m.begin(), m.begin() + left); if (right) m.erase(m.end() - right, m.end()); if (top) { for (uint i = 0; i < m.count(); i++) m[i].erase(m[i].begin(), m[i].begin() + top); } if (bottom) { for (uint i = 0; i < m.count(); i++) m[i].erase(m[i].end() - bottom, m[i].end()); } }
void CQTOpenGLMainWindow::POVRaySceneXMLPopUp() { /* Set the text window up */ QTextEdit* pcPOVRayOutput = new QTextEdit(); /* Calculate the geometry of the window so that it's 1/4 of the main window and placed in the exact center of it */ QRect cGeom = geometry(); cGeom.setBottomRight(geometry().center()); cGeom.moveCenter(geometry().center()); pcPOVRayOutput->setGeometry(cGeom); /* This window steals all input */ pcPOVRayOutput->setWindowModality(Qt::ApplicationModal); /* You can't modify its contents (but can copy-paste them) */ pcPOVRayOutput->setReadOnly(true); /* Set nice document name and window title */ pcPOVRayOutput->setDocumentTitle("ARGoS-POVRay XML camera config"); pcPOVRayOutput->setWindowTitle("ARGoS-POVRay XML camera config"); /* Set the actual text to visualize */ pcPOVRayOutput->setPlainText(GetPOVRaySceneXMLData()); /* Finally, show the resulting window */ pcPOVRayOutput->show(); }
//----------------------------------------------------------------------------- void qtSqueezedLabelPrivate::invalidate(QWidget* self) { this->offset = -1; this->length = -1; this->elided = true; if (self) { // Prepare to repaint our underlay background this->background = QImage(self->size(), QImage::Format_ARGB32_Premultiplied); qtScopedValueChange<bool> cb(this->cacheBackground, true); // Calculate our rect relative to our top level widget QWidget* tlw = self->topLevelWidget(); QRect rect = self->rect(); rect.setTopLeft(self->mapTo(tlw, rect.topLeft())); rect.setBottomRight(self->mapTo(tlw, rect.bottomRight())); // Render underlay background tlw->render(&this->background, QPoint(), rect); } }
void CropWidget::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); QRect rubberRect = rubberBand->geometry(); QRect useRect; if(rubberRect.width() < 0 && rubberRect.height() < 0) { useRect.setTopLeft(rubberRect.bottomRight()); useRect.setBottomRight(rubberRect.topLeft()); } else if(rubberRect.width() < 0) { useRect.setTopRight(rubberRect.topLeft()); useRect.setBottomLeft(rubberRect.bottomRight()); } else if(rubberRect.height() < 0) { useRect.setTopRight(rubberRect.bottomRight()); useRect.setBottomLeft(rubberRect.topLeft()); } else useRect = rubberRect; QRect rect1(0,0,useRect.x(),this->height()); QRect rect2(useRect.x()+useRect.width(),0,this->width()-useRect.x()-useRect.width(),this->height()); QRect rect3(useRect.x(),0,useRect.width(), useRect.y()); QRect rect4(useRect.x(),useRect.y()+useRect.height(), useRect.width(), this->height()-useRect.y()-useRect.height()); QPainter painter(this); painter.setPen(QPen(QBrush(QColor(0,0,0,180)),1,Qt::NoPen)); painter.setBrush(QBrush(QColor(0,0,0,220))); painter.drawRect(rect1); painter.drawRect(rect2); painter.drawRect(rect3); painter.drawRect(rect4); painter.end(); }
void GUI::paintEvent(QPaintEvent *event) { event->accept(); //rysowanie pojazdu if(this->vehicles.size() == 0 || currentVehicle < 0 || currentVehicle >= vehicles.size()) return; QPainter painter(this); Vehicle v = this->vehicles[currentVehicle]; double length = v.getLength(); unsigned axles = v.getAxlesNumber(); double positions[axles]; for(unsigned i = 0; i < axles; i++) { positions[i] = v.getAxlePosition(i); } const double scale = 1000 / this->scale_length; //1000pix = 24m; QPoint vehicleStart, vehicleEnd; vehicleStart.setX(this->startx); vehicleEnd.setX(this->startx + length * scale); vehicleStart.setY(this->starty); vehicleEnd.setY(this->starty + this->v_height); QRect vehicle; vehicle.setTopLeft(vehicleStart); vehicle.setBottomRight(vehicleEnd); painter.drawRoundedRect(vehicle, 40, 10); painter.fillRect(vehicle, QColor(0, 0, 0, 70)); for(unsigned i = 0; i < axles; i++) { //sprawdz warunek na podniesioną oś unsigned axle_offset_y = 0; if(axles == 5 && v.is5up() && i == 2) axle_offset_y = -5;// 3 os auta 5 os. z podniesioną osią QPoint center; center.setX(this->startx + scale * positions[i]); center.setY(this->starty + this->v_height + axle_offset_y); painter.setBrush(QWidget::palette().color(QWidget::backgroundRole())); painter.setPen(QWidget::palette().color(QWidget::backgroundRole())); painter.drawEllipse(center, this->wheel_size + 5, this->wheel_size + 5); painter.setPen(Qt::black); painter.setBrush(Qt::black); painter.drawEllipse(center, this->wheel_size, this->wheel_size); painter.setBrush(Qt::white); painter.drawEllipse(center, this->wheel_size - 5, this->wheel_size - 5); } const unsigned scale_offset = 100; QPoint scaleStart, scaleEnd; scaleStart.setX(this->startx); scaleStart.setY(this->starty + this->v_height + scale_offset); scaleEnd.setX(this->startx + scale * this->scale_length); scaleEnd.setY(this->starty + this->v_height + scale_offset); painter.drawLine(scaleStart, scaleEnd); //rysuj skale co 4m for(int pos = 0; pos <= this->scale_length; pos += 4) { QPoint scaleTop, scaleBottom, scaleCenter; scaleTop.setX(this->startx + pos * scale); scaleTop.setY(this->starty + this->v_height + scale_offset - 10); scaleBottom.setX(this->startx + pos * scale); scaleBottom.setY(this->starty + this->v_height + scale_offset + 10); scaleCenter.setX(this->startx + pos * scale); scaleCenter.setY(this->starty + this->v_height + scale_offset); painter.drawLine(scaleTop, scaleBottom); painter.drawText(scaleCenter, QString::number(pos) + QString("m")); } //rysuj wartości położenia dla osi //długość pojazdu QPoint vehicleLengthStart, vehicleLengthEnd; QPoint scaleTop, scaleBottom, scaleCenter; vehicleLengthStart.setX(this->startx); vehicleLengthEnd.setX(this->startx + length * scale); vehicleLengthStart.setY(this->starty + this->v_height + 70); vehicleLengthEnd.setY(this->starty + this->v_height + 70); painter.drawLine(vehicleLengthStart, vehicleLengthEnd); scaleCenter.setX((this->startx + length * scale + this->startx) / 2); scaleCenter.setY(this->starty + this->v_height + 70); painter.drawText(scaleCenter, QString().sprintf("%.2f", length) + QString("m")); //podzialka na początku i końcu scaleTop.setX(this->startx); scaleTop.setY(this->starty + this->v_height + 70 - 10); scaleBottom.setX(this->startx); scaleBottom.setY(this->starty + this->v_height + 70 + 10); painter.drawLine(scaleTop, scaleBottom); scaleTop.setX(this->startx + length * scale); scaleTop.setY(this->starty + this->v_height + 70 - 10); scaleBottom.setX(this->startx + length * scale); scaleBottom.setY(this->starty + this->v_height + 70 + 10); painter.drawLine(scaleTop, scaleBottom); //odległości między osiami double start = 0; double end = 0; //początek do osi 1 start = 0; end = positions[0]; scaleStart.setX(this->startx); scaleEnd.setX(this->startx + end * scale); scaleStart.setY(this->starty + this->v_height + 40); scaleEnd.setY(this->starty + this->v_height + 40); painter.drawLine(scaleStart, scaleEnd); scaleCenter.setX((this->startx + end * scale + this->startx) / 2); scaleCenter.setY(this->starty + this->v_height + 40); painter.drawText(scaleCenter, QString().sprintf("%.2f", end) + QString("m")); //podzialka na początku i końcu scaleTop.setX(this->startx); scaleTop.setY(this->starty + this->v_height + 40 - 10); scaleBottom.setX(this->startx); scaleBottom.setY(this->starty + this->v_height + 40 + 10); painter.drawLine(scaleTop, scaleBottom); scaleTop.setX(this->startx + end * scale); scaleTop.setY(this->starty + this->v_height + 40 - 10); scaleBottom.setX(this->startx + end * scale); scaleBottom.setY(this->starty + this->v_height + 40 + 10); painter.drawLine(scaleTop, scaleBottom); for(unsigned axle = 0; axle < axles - 1; axle++) { start = end; end = positions[axle + 1]; scaleStart.setX(this->startx + start * scale); scaleEnd.setX(this->startx + end * scale); scaleStart.setY(starty + this->v_height + 40); scaleEnd.setY(starty + this->v_height + 40); painter.drawLine(scaleStart, scaleEnd); scaleCenter.setX((this->startx + end * scale + this->startx + start * scale) / 2); scaleCenter.setY(this->starty + this->v_height + 40); painter.drawText(scaleCenter, QString().sprintf("%.2f", end - start) + QString("m")); //podzialka na początku i końcu scaleTop.setX(this->startx + start * scale); scaleTop.setY(this->starty + this->v_height + 40 - 10); scaleBottom.setX(this->startx + start * scale); scaleBottom.setY(this->starty + this->v_height + 40 + 10); painter.drawLine(scaleTop, scaleBottom); scaleTop.setX(this->startx + end * scale); scaleTop.setY(this->starty + this->v_height + 40 - 10); scaleBottom.setX(this->startx + end * scale); scaleBottom.setY(this->starty + this->v_height + 40 + 10); painter.drawLine(scaleTop, scaleBottom); } //koniec pojazdu start = end; end = length; scaleStart.setX(this->startx + start * scale); scaleEnd.setX(this->startx + end * scale); scaleStart.setY(this->starty + this->v_height + 40); scaleEnd.setY(this->starty + this->v_height + 40); painter.drawLine(scaleStart, scaleEnd); scaleCenter.setX((this->startx + end * scale + this->startx + start * scale) / 2); scaleCenter.setY(this->starty + this->v_height + 40); painter.drawText(scaleCenter, QString().sprintf("%.2f", end - start) + QString("m")); //podzialka na początku i końcu scaleTop.setX(this->startx + start * scale); scaleTop.setY(this->starty + this->v_height + 40 - 10); scaleBottom.setX(this->startx + start * scale); scaleBottom.setY(this->starty + this->v_height + 40 + 10); painter.drawLine(scaleTop, scaleBottom); scaleTop.setX(this->startx + end * scale); scaleTop.setY(this->starty + this->v_height + 40 - 10); scaleBottom.setX(this->startx + end * scale); scaleBottom.setY(this->starty + this->v_height + 40 + 10); painter.drawLine(scaleTop, scaleBottom); }