void drawInterface::showPolygon3D(QPainter& painter, SceneModel *i_pSmNode, QSharedPointer < polygon3D<double> > poly, const QColor& color) { unsigned int i; point3D<double> *begin, *end; point2D<double> pointBegin, pointEnd; if(poly == NULL) return; for(i=0; i < POLYGON_N_POINTS(poly)-1; i++) { begin = POLYGON_NTH_POINT(poly,i); end = POLYGON_NTH_POINT(poly, i+1); //Get 2D coordinate from 3D coordinate get2Dfrom3D(i_pSmNode, begin, &pointBegin); get2Dfrom3D(i_pSmNode, end, &pointEnd); painter.setPen(color); paintLine(painter, &pointBegin, &pointEnd); } // the last line begin = POLYGON_NTH_POINT(poly,POLYGON_N_POINTS(poly)-1); end = POLYGON_NTH_POINT(poly,0); //Get 2D coordinate from 3D coordinate get2Dfrom3D(i_pSmNode, begin, &pointBegin); get2Dfrom3D(i_pSmNode, end, &pointEnd); painter.setPen(color); paintLine(painter, &pointBegin, &pointEnd); }
/** Paints an integral and an outline of that integral for each data set (rsdht * and/or alldht) that is to be displayed. The integrals will be drawn first, * followed by the outlines, since we want the area of overlapping integrals * to blend, but not the outlines of those integrals. */ void RSGraphWidget::paintData() { /* Convert the bandwidth data points to graph points */ if(_source == NULL) return ; const RSGraphSource& source(*_source) ; _maxValue = 0.0f ; for(int i=0;i<source.n_values();++i) if( _masked_entries.find(source.displayName(i).toStdString()) == _masked_entries.end() ) { std::vector<QPointF> values ; source.getDataPoints(i,values) ; QVector<QPointF> points ; pointsFromData(values,points) ; /* Plot the bandwidth data as area graphs */ if (_flags & RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) paintIntegral(points, getColor(i), _opacity); /* Plot the bandwidth as solid lines. If the graph style is currently an * area graph, we end up outlining the integrals. */ paintLine(points, getColor(i)); } if(_maxValue > 0.0f) if(_flags & RSGRAPH_FLAGS_LOG_SCALE_Y) _y_scale = _rec.height()*0.8 / log(_maxValue) ; else _y_scale = _rec.height()*0.8/_maxValue ; }
void NMGChartSeries::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { if(!vertexList.isEmpty()) { if(spaceAvailableIntoSceneChanged || rebuildScaleFactors) { calculateScaleFactors(); if(spaceAvailableIntoSceneChanged) spaceAvailableIntoSceneChanged = FALSE; if(rebuildScaleFactors) rebuildScaleFactors = FALSE; } QPen pen; pen.setColor(baseColor); pen.setWidth(1); painter->setPen(pen); if(isClipped) { painter->setClipRect(0, 0, currentWidthIntoScene + pen.width(), currentHeightIntoScene); } painter->save(); painter->translate(0,currentHeightIntoScene); if(representation == LINE_TYPE) paintLine(painter, option, widget); else if(representation == AREA_TYPE) paintArea(painter, option, widget); else if(representation == POINTS_TYPE) paintPoints(painter, option, widget); else if(representation == BARS_TYPE) paintBars(painter, option, widget); painter->restore(); } }
KisToolFreehandHelper::KisToolFreehandHelper(KisPaintingInformationBuilder *infoBuilder, const KUndo2MagicString &transactionText, KisRecordingAdapter *recordingAdapter, KisSmoothingOptions *smoothingOptions) : m_d(new Private()) { m_d->infoBuilder = infoBuilder; m_d->recordingAdapter = recordingAdapter; m_d->transactionText = transactionText; m_d->smoothingOptions = KisSmoothingOptionsSP( smoothingOptions ? smoothingOptions : new KisSmoothingOptions()); m_d->canvasRotation = 0; m_d->strokeTimeoutTimer.setSingleShot(true); connect(&m_d->strokeTimeoutTimer, SIGNAL(timeout()), SLOT(finishStroke())); connect(&m_d->airbrushingTimer, SIGNAL(timeout()), SLOT(doAirbrushing())); connect(&m_d->stabilizerPollTimer, SIGNAL(timeout()), SLOT(stabilizerPollAndPaint())); m_d->stabilizerDelayedPaintHelper.setPaintLineCallback( [this](const KisPaintInformation &pi1, const KisPaintInformation &pi2) { paintLine(pi1, pi2); }); m_d->stabilizerDelayedPaintHelper.setUpdateOutlineCallback( [this]() { emit requestExplicitUpdateOutline(); }); }
void QProg::paintEvent(QPaintEvent *) { paintBorder(); paintBar(); paintLine(); paintValue(); }
void KisToolFreehandHelper::stabilizerPollAndPaint() { KisStabilizedEventsSampler::iterator it; KisStabilizedEventsSampler::iterator end; std::tie(it, end) = m_d->stabilizedSampler.range(); QVector<KisPaintInformation> delayedPaintTodoItems; for (; it != end; ++it) { KisPaintInformation sampledInfo = *it; bool canPaint = true; if (m_d->smoothingOptions->useDelayDistance()) { const qreal R = m_d->smoothingOptions->delayDistance() / m_d->resources->effectiveZoom(); QPointF diff = sampledInfo.pos() - m_d->previousPaintInformation.pos(); qreal dx = sqrt(pow2(diff.x()) + pow2(diff.y())); canPaint = dx > R; } if (canPaint) { KisPaintInformation newInfo = m_d->getStabilizedPaintInfo(m_d->stabilizerDeque, sampledInfo); if (m_d->stabilizerDelayedPaintHelper.running()) { delayedPaintTodoItems.append(newInfo); } else { paintLine(m_d->previousPaintInformation, newInfo); } m_d->previousPaintInformation = newInfo; // Push the new entry through the queue m_d->stabilizerDeque.dequeue(); m_d->stabilizerDeque.enqueue(sampledInfo); } else if (m_d->stabilizerDeque.head().pos() != m_d->previousPaintInformation.pos()) { QQueue<KisPaintInformation>::iterator it = m_d->stabilizerDeque.begin(); QQueue<KisPaintInformation>::iterator end = m_d->stabilizerDeque.end(); while (it != end) { *it = m_d->previousPaintInformation; ++it; } } } m_d->stabilizedSampler.clear(); if (m_d->stabilizerDelayedPaintHelper.running()) { m_d->stabilizerDelayedPaintHelper.update(delayedPaintTodoItems); } else { emit requestExplicitUpdateOutline(); } }
void PaintMethods::paintDebugDrawing(QPainter& painter, const DebugDrawing& debugDrawing, const QTransform& baseTrans) { for(const DebugDrawing::Element* e = debugDrawing.getFirst(); e; e = debugDrawing.getNext(e)) switch(e->type) { case DebugDrawing::Element::POLYGON: { paintPolygon(*static_cast<const DebugDrawing::Polygon*>(e), painter); break; } case DebugDrawing::Element::GRID_RGBA: { paintGridRGBA(*static_cast<const DebugDrawing::GridRGBA*>(e), painter); break; } case DebugDrawing::Element::GRID_MONO: { paintGridMono(*static_cast<const DebugDrawing::GridMono*>(e), painter); break; } case DebugDrawing::Element::ELLIPSE: { paintEllipse(*static_cast<const DebugDrawing::Ellipse*>(e), painter); break; } case DebugDrawing::Element::ARC: { paintArc(*static_cast<const DebugDrawing::Arc*>(e), painter); break; } case DebugDrawing::Element::RECTANGLE: { paintRectangle(*static_cast<const DebugDrawing::Rectangle*>(e), painter); break; } case DebugDrawing::Element::LINE: { paintLine(*static_cast<const DebugDrawing::Line*>(e), painter); break; } case DebugDrawing::Element::ORIGIN: { paintOrigin(*static_cast<const DebugDrawing::Origin*>(e), painter, baseTrans); break; } case DebugDrawing::Element::TEXT: { paintText(*static_cast<const DebugDrawing::Text*>(e), painter); break; } default: break; } }
void KisToolFreehandHelper::paintBezierCurve(int painterInfoId, const KisPaintInformation &pi1, const QPointF &control1, const QPointF &control2, const KisPaintInformation &pi2) { #ifdef DEBUG_BEZIER_CURVES KisPaintInformation tpi1; KisPaintInformation tpi2; tpi1 = pi1; tpi2 = pi2; tpi1.setPressure(0.3); tpi2.setPressure(0.3); paintLine(tpi1, tpi2); tpi1.setPressure(0.6); tpi2.setPressure(0.3); tpi1.setPos(pi1.pos()); tpi2.setPos(control1); paintLine(tpi1, tpi2); tpi1.setPos(pi2.pos()); tpi2.setPos(control2); paintLine(tpi1, tpi2); #endif m_d->hasPaintAtLeastOnce = true; m_d->strokesFacade->addJob(m_d->strokeId, new FreehandStrokeStrategy::Data(m_d->resources->currentNode(), painterInfoId, pi1, control1, control2, pi2)); if(m_d->recordingAdapter) { m_d->recordingAdapter->addCurve(pi1, control1, control2, pi2); } }
void CFbAccel::paintPixel(const int x, const int y, const fb_pixel_t col) { #if HAVE_TRIPLEDRAGON setColor(col); dfbdest->DrawLine(dfbdest, x, y, x, y); #elif defined (USE_NEVIS_GXA) paintLine(x, y, x + 1, y, col); #else fb_pixel_t *pos = fb->getFrameBufferPointer(); pos += (fb->stride / sizeof(fb_pixel_t)) * y; pos += x; *pos = col; #endif }
void PSV_TreeItem::afterUpdateItem() { // m_dh = 50; double depth = m_itemData->depth(); PSV_Public::printMes(depth,"depth"); PSV_Public::printMes(m_max_y_left,"m_max_y_left"); PSV_Public::printMes(m_dhRatio,"m_dhRatio"); QPointF point(m_chartRect.center().x(),m_chartRect.top() + (m_max_y_left - depth) * m_dhRatio); PSV_Public::printMes(point,"point"); PSV_Public::printMes(m_chartRect,"m_chartRect"); paintLine(QLineF(point,point),m_itemData); }
/** Paints an integral and an outline of that integral for each data set (send * and/or receive) that is to be displayed. The integrals will be drawn first, * followed by the outlines, since we want the area of overlapping integrals * to blend, but not the outlines of those integrals. */ void GraphFrame::paintData() { QVector<QPointF> recvPoints, sendPoints; /* Convert the bandwidth data points to graph points */ recvPoints = pointsFromData(_recvData); sendPoints = pointsFromData(_sendData); if (_graphStyle == AreaGraph) { /* Plot the bandwidth data as area graphs */ if (_showRecv) paintIntegral(recvPoints, RECV_COLOR, 0.6); if (_showSend) paintIntegral(sendPoints, SEND_COLOR, 0.4); } /* Plot the bandwidth as solid lines. If the graph style is currently an * area graph, we end up outlining the integrals. */ if (_showRecv) paintLine(recvPoints, RECV_COLOR); if (_showSend) paintLine(sendPoints, SEND_COLOR); }
static inline void reprintText(uint16* curX, uint16* curY, uint32* index, strbuilder_t data) { *curX = 1; *curY = 5; uint16 oldX = 1, oldY = 5, indexClone = *index; paintLine(blue, 1, *curY, sw); for(uint16 loopi = 0; loopi < data.ilist.size; loopi++) { printChar(strbuilder_charAt(data, loopi), curX, curY); if(*curY > oldY) { indexClone -= oldX; } oldY = *curY; oldX = *curX; } *curX = indexClone + 1; }
/** * @brief Adds the path of the given way to current path, if path is not set it creates it form the data * @param cr the cairo contetx to add the path to * */ void WayRenderer::addWayPath(cairo_t* cr) { cairo_new_path(cr); if (path != NULL) { cairo_append_path(cr, path); return; } const std::vector<NodeId>& children = way->getNodeIDs(); paintLine(cr, children); path = cairo_copy_path(cr); double x0, y0, x1, y1; cairo_path_extents(cr, &x0, &y0, &x1, &y1); bounds = FloatRect(x0, y0, x1, y1); }
void KisToolLineHelper::repaintLine(KoCanvasResourceManager *resourceManager, KisImageWSP image, KisNodeSP node, KisStrokesFacade *strokesFacade) { if (!m_d->enabled) return; cancelPaint(); if (m_d->linePoints.isEmpty()) return; QVector<KisPaintInformation>::const_iterator it = m_d->linePoints.constBegin(); QVector<KisPaintInformation>::const_iterator end = m_d->linePoints.constEnd(); initPaintImpl(*it, resourceManager, image, node, strokesFacade); ++it; while (it != end) { paintLine(*(it - 1), *it); ++it; } }
void KPrTimeLineView::paintRow(QPainter *painter, int row, int y, const int RowHeight) { int start = 0; //Column 0 int column = KPrShapeAnimations::ShapeThumbnail; paintIconRow(painter, start, y, row, column, RowHeight - 2, RowHeight); //Column 1 column = KPrShapeAnimations::AnimationIcon; start = start + m_mainView->widthOfColumn(column - 1); paintIconRow(painter, start, y, row, column, RowHeight / 2, RowHeight); //Column 2 (6 y 7) column = KPrShapeAnimations::StartTime; start = start + m_mainView->widthOfColumn(column - 1); QRect rect(start, y, m_mainView->widthOfColumn(column), RowHeight); paintItemBackground(painter, rect, row == m_mainView->selectedRow()); paintLine(painter, row, rect, row == m_mainView->selectedRow()); }
void KisCurvePaintOp::paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) { Q_UNUSED(currentDistance); if (!painter()) return; if (!m_dab) { m_dab = source()->createCompositionSourceDevice(); } else { m_dab->clear(); } paintLine(m_dab, pi1, pi2); QRect rc = m_dab->extent(); quint8 origOpacity = m_opacityOption.apply(painter(), pi2); painter()->bitBlt(rc.topLeft(), m_dab, rc); painter()->renderMirrorMask(rc, m_dab); painter()->setOpacity(origOpacity); }
void Painter::paintBezierCourve(BezierCurve *bc) { for (unsigned int i = 0; i < bc->getLines().size(); i++) { paintLine(bc->getLines()[i]); } #if BEZ_DEBUG SDL_Rect r; r = (SDL_Rect ) { bc->getPointA().x - 4, bc->getPointA().y - 4, 8, 8 }; SDL_RenderFillRect(renderer, &r); r = (SDL_Rect ) { bc->getPointB().x - 4, bc->getPointB().y - 4, 8, 8 }; SDL_RenderFillRect(renderer, &r); r = (SDL_Rect ) { bc->getControlPointA().x - 4, bc->getControlPointA().y - 4, 8, 8 }; SDL_RenderFillRect(renderer, &r); r = (SDL_Rect ) { bc->getControlPointB().x - 4, bc->getControlPointB().y - 4, 8, 8 }; SDL_RenderFillRect(renderer, &r); SDL_RenderDrawLine(renderer, bc->getPointA().x, bc->getPointA().y, bc->getControlPointA().x, bc->getControlPointA().y); SDL_RenderDrawLine(renderer, bc->getPointB().x, bc->getPointB().y, bc->getControlPointB().x, bc->getControlPointB().y); #endif }
void Painter::paintLine(int x1, int y1, int x2, int y2) { paintLine(Line(x1, y1, x2, y2)); }
void CImageInfo::paint() { const char * head_string; char imagedate[18] = ""; int xpos = x+10; ypos = y+5; head_string = g_Locale->getText(LOCALE_IMAGEINFO_HEAD); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, head_string); //frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_MENUHEAD_PLUS_0); frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_INFOBAR_PLUS_0); g_Font[font_head]->RenderString(xpos, ypos+ hheight+1, width, head_string, COL_MENUHEAD, 0, true); ypos += hheight; ypos += (iheight >>1); CConfigFile config('\t'); config.loadConfig("/.version"); const char * imagename = config.getString("imagename", "Neutrino-HD").c_str(); const char * homepage = config.getString("homepage", "n/a").c_str(); const char * creator = config.getString("creator", "n/a").c_str(); const char * version = config.getString("version", "no version").c_str(); const char * docs = config.getString("docs", "man neutrino").c_str(); const char * forum = config.getString("forum", "http://forum.tuxbox.org").c_str(); static CFlashVersionInfo versionInfo(version); const char * releaseCycle = versionInfo.getReleaseCycle(); sprintf((char*) imagedate, "%s %s", versionInfo.getDate(), versionInfo.getTime()); ypos += iheight; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_IMAGE)); paintLine(xpos+offset, font_info, imagename); ypos += iheight; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_DATE)); paintLine(xpos+offset, font_info, imagedate); ypos += iheight; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_VERSION)); paintLine(xpos+offset, font_info, releaseCycle); ypos += iheight; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_CREATOR)); paintLine(xpos+offset, font_info, creator); ypos += iheight+15; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_HOMEPAGE)); paintLine(xpos+offset, font_info, homepage); ypos += iheight; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_DOKUMENTATION)); paintLine(xpos+offset, font_info, docs); ypos += iheight; paintLine(xpos , font_info, g_Locale->getText(LOCALE_IMAGEINFO_FORUM)); paintLine(xpos+offset, font_info, forum); ypos += iheight+15; paintLine(xpos, font_info,g_Locale->getText(LOCALE_IMAGEINFO_LICENSE)); paintLine(xpos+offset, font_small, "This program is free software; you can redistribute it and/or modify"); ypos+= sheight; paintLine(xpos+offset, font_small, "it under the terms of the GNU General Public License as published by"); ypos+= sheight; paintLine(xpos+offset, font_small, "the Free Software Foundation; either version 2 of the License, or"); ypos+= sheight; paintLine(xpos+offset, font_small, "(at your option) any later version."); ypos+= sheight+10; paintLine(xpos+offset, font_small, "This program is distributed in the hope that it will be useful,"); ypos+= sheight; paintLine(xpos+offset, font_small, "but WITHOUT ANY WARRANTY; without even the implied warranty of"); ypos+= sheight; paintLine(xpos+offset, font_small, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); ypos+= sheight; paintLine(xpos+offset, font_small, "See the GNU General Public License for more details."); ypos+= sheight+10; paintLine(xpos+offset, font_small, "You should have received a copy of the GNU General Public License"); ypos+= sheight; paintLine(xpos+offset, font_small, "along with this program; if not, write to the Free Software"); ypos+= sheight; paintLine(xpos+offset, font_small, "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."); }
void CImageInfo::paint() { const char * head_string; char imagedate[18] = ""; int xpos = x + BORDER_LEFT; int x_offset = g_Font[font_info]->getRenderWidth(g_Locale->getText(LOCALE_IMAGEINFO_HOMEPAGE)) + 10; ypos = y + 5; head_string = g_Locale->getText(LOCALE_IMAGEINFO_HEAD); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, head_string); // frameBuffer->paintBoxRel(0, 0, max_width, max_height, COL_INFOBAR_PLUS_0); // title g_Font[font_head]->RenderString(xpos, ypos + hheight + 1, width, head_string, COL_MENUHEAD, 0, true); ypos += hheight; ypos += (iheight >>1); //CConfigFile config('\t'); //config.loadConfig("/etc/.version"); const char * imagename = "neutrinoHD2"; /*config.getString("imagename", "NeutrinoHD2").c_str();*/ //const char * homepage = config.getString("homepage", "http://www.dgstation-forum.org").c_str(); //const char * creator = config.getString("creator", "mohousch").c_str(); const char * version = "2.1"; /*config.getString("version", "1201201602031021").c_str();*/ const char * docs = "http://wiki.neutrino-hd.de"; /*config.getString("docs", "http://wiki.neutrino-hd.de").c_str();*/ //const char * forum = config.getString("forum", "http://www.dgstation-forum.org").c_str(); #ifdef SVNVERSION const char * builddate = SVNVERSION; /*config.getString("builddate", SVNVERSION).c_str();*/ #else const char * builddate = BUILT_DATE; /*config.getString("builddate", BUILT_DATE).c_str();*/ #endif //static CFlashVersionInfo versionInfo(version); const char * releaseCycle = "2.1"; /*versionInfo.getReleaseCycle();*/ const char * imageType = "Snapshot"; /*versionInfo.getType();*/ sprintf((char*) imagedate, "%s %s", __DATE__ /*versionInfo.getDate()*/, __TIME__ /*versionInfo.getTime()*/); // image name ypos += iheight; paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_IMAGE)); paintLine(xpos + x_offset, font_info, imagename); // image date ypos += iheight; paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_DATE)); paintLine(xpos + x_offset, font_info, imagedate); // release cycle ypos += iheight; paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_VERSION)); paintLine(xpos + x_offset, font_info, releaseCycle); // svn/git built date ypos += iheight; #ifdef SVNVERSION paintLine(xpos, font_info, SVN_REV); #else paintLine(xpos, font_info, GIT_REV); #endif paintLine(xpos + x_offset, font_info, builddate ); // image type ypos += iheight; paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_TYPE)); paintLine(xpos + x_offset, font_info, imageType); // image creator //ypos += iheight; //paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_CREATOR)); //paintLine(xpos + x_offset, font_info, creator); // homepage //ypos += iheight; //paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_HOMEPAGE)); //paintLine(xpos + x_offset, font_info, homepage); /* doko */ ypos += iheight; paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_DOKUMENTATION)); paintLine(xpos + x_offset, font_info, docs); // forum //ypos += iheight; //paintLine(xpos, font_info, g_Locale->getText(LOCALE_IMAGEINFO_FORUM)); //paintLine(xpos + x_offset, font_info, forum); // license ypos += 5*iheight; paintLine(xpos, font_info,g_Locale->getText(LOCALE_IMAGEINFO_LICENSE)); paintLine(xpos + x_offset, font_small, "This program is free software; you can redistribute it and/or modify"); ypos += sheight; paintLine(xpos + x_offset, font_small, "it under the terms of the GNU General Public License as published by"); ypos += sheight; paintLine(xpos + x_offset, font_small, "the Free Software Foundation; either version 2 of the License, or"); ypos += sheight; paintLine(xpos + x_offset, font_small, "(at your option) any later version."); ypos += sheight; paintLine(xpos + x_offset, font_small, "This program is distributed in the hope that it will be useful,"); ypos += sheight; paintLine(xpos + x_offset, font_small, "but WITHOUT ANY WARRANTY; without even the implied warranty of"); ypos += sheight; paintLine(xpos + x_offset, font_small, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); ypos += sheight; paintLine(xpos + x_offset, font_small, "See the GNU General Public License for more details."); ypos += sheight; paintLine(xpos + x_offset, font_small, "You should have received a copy of the GNU General Public License"); ypos += sheight; paintLine(xpos + x_offset, font_small, "along with this program; if not, write to the Free Software"); ypos += sheight; paintLine(xpos + x_offset, font_small, "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."); }
void CrossFadeAnimation::paintFrame(Painter &p, float64 positionReady, float64 alphaWas, float64 alphaNow) { if (_lines.isEmpty()) return; for_const (auto &line, _lines) { paintLine(p, line, positionReady, alphaWas, alphaNow); }
void KisToolFreehandHelper::paint(KoPointerEvent *event) { KisPaintInformation info = m_d->infoBuilder->continueStroke(event, elapsedStrokeTime()); info.setCanvasRotation( m_d->canvasRotation ); info.setCanvasHorizontalMirrorState( m_d->canvasMirroredH ); KisUpdateTimeMonitor::instance()->reportMouseMove(info.pos()); /** * Smooth the coordinates out using the history and the * distance. This is a heavily modified version of an algo used in * Gimp and described in https://bugs.kde.org/show_bug.cgi?id=281267 and * http://www24.atwiki.jp/sigetch_2007/pages/17.html. The main * differences are: * * 1) It uses 'distance' instead of 'velocity', since time * measurements are too unstable in realworld environment * * 2) There is no 'Quality' parameter, since the number of samples * is calculated automatically * * 3) 'Tail Aggressiveness' is used for controling the end of the * stroke * * 4) The formila is a little bit different: 'Distance' parameter * stands for $3 \Sigma$ */ if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::WEIGHTED_SMOOTHING && m_d->smoothingOptions->smoothnessDistance() > 0.0) { { // initialize current distance QPointF prevPos; if (!m_d->history.isEmpty()) { const KisPaintInformation &prevPi = m_d->history.last(); prevPos = prevPi.pos(); } else { prevPos = m_d->previousPaintInformation.pos(); } qreal currentDistance = QVector2D(info.pos() - prevPos).length(); m_d->distanceHistory.append(currentDistance); } m_d->history.append(info); qreal x = 0.0; qreal y = 0.0; if (m_d->history.size() > 3) { const qreal sigma = m_d->effectiveSmoothnessDistance() / 3.0; // '3.0' for (3 * sigma) range qreal gaussianWeight = 1 / (sqrt(2 * M_PI) * sigma); qreal gaussianWeight2 = sigma * sigma; qreal distanceSum = 0.0; qreal scaleSum = 0.0; qreal pressure = 0.0; qreal baseRate = 0.0; Q_ASSERT(m_d->history.size() == m_d->distanceHistory.size()); for (int i = m_d->history.size() - 1; i >= 0; i--) { qreal rate = 0.0; const KisPaintInformation nextInfo = m_d->history.at(i); double distance = m_d->distanceHistory.at(i); Q_ASSERT(distance >= 0.0); qreal pressureGrad = 0.0; if (i < m_d->history.size() - 1) { pressureGrad = nextInfo.pressure() - m_d->history.at(i + 1).pressure(); const qreal tailAgressiveness = 40.0 * m_d->smoothingOptions->tailAggressiveness(); if (pressureGrad > 0.0 ) { pressureGrad *= tailAgressiveness * (1.0 - nextInfo.pressure()); distance += pressureGrad * 3.0 * sigma; // (3 * sigma) --- holds > 90% of the region } } if (gaussianWeight2 != 0.0) { distanceSum += distance; rate = gaussianWeight * exp(-distanceSum * distanceSum / (2 * gaussianWeight2)); } if (m_d->history.size() - i == 1) { baseRate = rate; } else if (baseRate / rate > 100) { break; } scaleSum += rate; x += rate * nextInfo.pos().x(); y += rate * nextInfo.pos().y(); if (m_d->smoothingOptions->smoothPressure()) { pressure += rate * nextInfo.pressure(); } } if (scaleSum != 0.0) { x /= scaleSum; y /= scaleSum; if (m_d->smoothingOptions->smoothPressure()) { pressure /= scaleSum; } } if ((x != 0.0 && y != 0.0) || (x == info.pos().x() && y == info.pos().y())) { info.setPos(QPointF(x, y)); if (m_d->smoothingOptions->smoothPressure()) { info.setPressure(pressure); } m_d->history.last() = info; } } } if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::SIMPLE_SMOOTHING || m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::WEIGHTED_SMOOTHING) { // Now paint between the coordinates, using the bezier curve interpolation if (!m_d->haveTangent) { m_d->haveTangent = true; m_d->previousTangent = (info.pos() - m_d->previousPaintInformation.pos()) / qMax(qreal(1.0), info.currentTime() - m_d->previousPaintInformation.currentTime()); } else { QPointF newTangent = (info.pos() - m_d->olderPaintInformation.pos()) / qMax(qreal(1.0), info.currentTime() - m_d->olderPaintInformation.currentTime()); paintBezierSegment(m_d->olderPaintInformation, m_d->previousPaintInformation, m_d->previousTangent, newTangent); m_d->previousTangent = newTangent; } m_d->olderPaintInformation = m_d->previousPaintInformation; m_d->strokeTimeoutTimer.start(100); } else if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::NO_SMOOTHING) { paintLine(m_d->previousPaintInformation, info); } if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::STABILIZER) { m_d->stabilizedSampler.addEvent(info); } else { m_d->previousPaintInformation = info; } if(m_d->airbrushingTimer.isActive()) { m_d->airbrushingTimer.start(); } }
void PSV_TreeItem::paintLine(const QLineF &parentVLine, PSV_TreeItemData *itemData) { if(itemData == NULL) { return; } QPointF point2 = parentVLine.p2(); QList<PSV_TreeItemData*> children = itemData->children(); int leafCount = itemData->leafCount(); int count = children.count(); QPen pen; pen.setColor(QColor(Qt::red)); QPen pen_vLine; pen_vLine.setColor(QColor(Qt::blue)); QPen pen_hLine; QString tempText = itemData->text().trimmed(); QString text; for(int i = 0; i < tempText.length(); ++i) { text.append(tempText.at(i)); if(i != tempText.length() - 1) { text.append("\n"); } } QGraphicsItem* nodeItem = new QGraphicsEllipseItem(QRectF(0,0,1,1),this); nodeItem->setToolTip(tempText); QSizeF size = nodeItem->boundingRect().size(); nodeItem->setPos(point2.x() - size.width() * 0.5,point2.y() - size.height() * 0.5); QRectF rect = QRectF(nodeItem->pos().x(),nodeItem->pos().y(),size.width(),size.height()); // QGraphicsRectItem* rectItem = new QGraphicsRectItem(rect,this); // rectItem->setPen(pen); if(parentVLine.length() > PSV_ZEOR) { QLineF line = parentVLine; line.setP2(QPointF(line.x2(),rect.top())); QGraphicsLineItem* item = new QGraphicsLineItem(line,this); PSV_NOUSED(item); } if(count > 0) { QLineF leftHLine(point2.x() - leafCount * 0.5 * m_dw ,point2.y() ,rect.left() ,point2.y()); QLineF rightHLine(rect.right() ,point2.y() ,point2.x() + leafCount * 0.5 * m_dw ,point2.y()); double curX1 = leftHLine.x1(); for(int i = 0; i < count; ++i) { PSV_TreeItemData* tempItemData = children.at(i); int tempLeafCount = tempItemData->leafCount(); curX1 += tempLeafCount * 0.5 * m_dw; if(i == 0) { leftHLine.setP1(QPointF(curX1,leftHLine.y1())); } if(i == count - 1) { rightHLine.setP2(QPointF(curX1,leftHLine.y2())); } double y1 = point2.y(); double y2 = point2.y() + tempItemData->distance() * m_dhRatio; if(curX1 > rect.left() && curX1 < rect.right()) { y1 = rect.bottom(); } QLineF lineV(curX1,y1,curX1,y2); curX1 += tempLeafCount * 0.5 * m_dw; paintLine(lineV,tempItemData); } if(count > 1) { QGraphicsLineItem* leftHLineItem = new QGraphicsLineItem(leftHLine,this); leftHLineItem->setPen(pen_hLine); QGraphicsLineItem* rightHLineItem = new QGraphicsLineItem(rightHLine,this); rightHLineItem->setPen(pen_hLine); } } }
/*! Draw the shape in response to an update event. */ void QgsHighlight::paint( QPainter* p ) { if ( !mGeometry ) { return; } p->setPen( mPen ); p->setBrush( mBrush ); switch ( mGeometry->wkbType() ) { case QGis::WKBPoint: case QGis::WKBPoint25D: { paintPoint( p, mGeometry->asPoint() ); } break; case QGis::WKBMultiPoint: case QGis::WKBMultiPoint25D: { QgsMultiPoint m = mGeometry->asMultiPoint(); for ( int i = 0; i < m.size(); i++ ) { paintPoint( p, m[i] ); } } break; case QGis::WKBLineString: case QGis::WKBLineString25D: { paintLine( p, mGeometry->asPolyline() ); } break; case QGis::WKBMultiLineString: case QGis::WKBMultiLineString25D: { QgsMultiPolyline m = mGeometry->asMultiPolyline(); for ( int i = 0; i < m.size(); i++ ) { paintLine( p, m[i] ); } } break; case QGis::WKBPolygon: case QGis::WKBPolygon25D: { paintPolygon( p, mGeometry->asPolygon() ); } break; case QGis::WKBMultiPolygon: case QGis::WKBMultiPolygon25D: { QgsMultiPolygon m = mGeometry->asMultiPolygon(); for ( int i = 0; i < m.size(); i++ ) { paintPolygon( p, m[i] ); } } break; case QGis::WKBUnknown: default: return; } }
KisSpacingInformation KisParticlePaintOp::paintAt(const KisPaintInformation& info) { KisDistanceInformation di; paintLine(info, info, &di); return di.currentSpacing(); }
void Painter::paintPolygon(Polygon pol) { if (status.fill.alpha() > 0) { Polygon * s = pol.transformPolygon(*status.transformation); std::vector<Line> lines = s->lines(); SDL_Point p; Line l(0, 0, 0, 0); int x0 = s->getBoundingBox().x; int y0 = s->getBoundingBox().y; int h0 = s->getBoundingBox().h; int w0 = s->getBoundingBox().w; std::vector<int> inters; SDL_SetRenderDrawColor(renderer, status.fill.red(), status.fill.green(), status.fill.blue(), status.fill.alpha()); if (w0 > h0) { for (int y = y0; y < y0 + h0; y++) { inters.clear(); l = Line(x0, y, x0 + w0, y); if (s->contains(x0, y)) { inters.push_back(x0); } for (unsigned int i = 0; i < lines.size(); i++) { if (lines[i].intersectLine(l, p)) { if (std::find(inters.begin(), inters.end(), p.x) == inters.end()) { inters.push_back(p.x); } } } if (inters.size() > 0) { std::sort(inters.begin(), inters.end()); for (unsigned int i = 0; i < inters.size() - 1; i += 2) { SDL_RenderDrawLine(renderer, inters[i], y, inters[i + 1], y); } if (inters.size() % 2 != 0) { SDL_RenderDrawPoint(renderer, inters.back(), y); } } } } else { for (int x = x0; x < x0 + w0; x++) { inters.clear(); l = Line(x, y0, x, y0 + h0); if (s->contains(x, y0)) { inters.push_back(y0); } for (unsigned int i = 0; i < lines.size(); i++) { if (lines[i].intersectLine(l, p)) { if (std::find(inters.begin(), inters.end(), p.y) == inters.end()) { inters.push_back(p.y); } } } if (inters.size() > 0) { std::sort(inters.begin(), inters.end()); for (unsigned int i = 0; i < inters.size() - 1; i += 2) { SDL_RenderDrawLine(renderer, x, inters[i], x, inters[i + 1]); } if (inters.size() % 2 != 0) { SDL_RenderDrawPoint(renderer, x, inters.back()); } } } } } for (unsigned int i = 0; i < pol.lines().size(); i++) { paintLine(pol.lines()[i]); } }
void NMGChartSeries::paintArea(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { int maxValuesInPartialPath = 1000; QColor hsv = baseColor.toHsv(); hsv.setHsv(hsv.hue(), (int)(hsv.saturation()*0.25), hsv.value()); if(isAveraged || isAccumulated) { painter->setBrush(hsv); paintLine(painter, option, widget); } else { // not average nor accumulated /* NOTE A specific implementation is needed in this case because Graphics View doesn't * support correctly huge amount of points (X11 crashes). The design has been based in * partial paths that are painted with brush (to paint the area), and later they are * added to the complete path (to paint the boundary line).*/ painter->setPen(Qt::NoPen); painter->setBrush(hsv); QPainterPath completedPath; double closingYpixel = ((minValues.y < 0.0 && 0.0 < maxValues.y) ? yWindowToViewport(0.0) : ((minValues.y >= 0.0) ? yWindowToViewport(minValues.y) : yWindowToViewport(maxValues.y))); QList<Vertex>::const_iterator it = vertexList.constBegin(); do { QPainterPath partialPath; QPainterPath partialPathModif; partialPath.moveTo(xWindowToViewport(it->x), -yWindowToViewport(it->y)); for(int i = 1; i <= maxValuesInPartialPath && it != vertexList.constEnd(); i++, it++) { partialPath.lineTo(xWindowToViewport(it->x),-yWindowToViewport(it->y)); } if(completedPath.isEmpty()) { partialPathModif = partialPath; partialPathModif.lineTo(partialPathModif.currentPosition().rx(), -closingYpixel); partialPathModif.lineTo(xWindowToViewport(vertexList.first().x), -closingYpixel); completedPath = partialPath; } else { partialPathModif = partialPath; partialPathModif.lineTo(partialPath.currentPosition().rx(), -closingYpixel); partialPathModif.lineTo(completedPath.currentPosition().rx(), -closingYpixel); partialPathModif.lineTo(completedPath.currentPosition().rx(), completedPath.currentPosition().ry()); completedPath.connectPath(partialPath); } partialPathModif.closeSubpath(); painter->drawPath(partialPathModif); } while(it != vertexList.constEnd()); painter->setPen(Qt::SolidLine); painter->setPen(baseColor); painter->setBrush(Qt::NoBrush); completedPath.lineTo(xWindowToViewport(vertexList.last().x), -closingYpixel); completedPath.lineTo(xWindowToViewport(vertexList.first().x), -closingYpixel); completedPath.closeSubpath(); painter->drawPath(completedPath); } }
void KisToolFreehandHelper::paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2) { paintLine(0, pi1, pi2); }