| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include "lc_printviewportrenderer.h" |
| |
|
| | #include "lc_graphicviewport.h" |
| | #include "rs_entitycontainer.h" |
| | #include "rs_math.h" |
| | #include "rs_painter.h" |
| |
|
| | class RS_EntityContainer; |
| |
|
| | LC_PrintViewportRenderer::LC_PrintViewportRenderer(LC_GraphicViewport *viewport, RS_Painter* p) |
| | :LC_GraphicViewportRenderer(viewport, nullptr) |
| | ,painter{p} |
| | { |
| | setBackground({255,255,255}); |
| | } |
| |
|
| |
|
| | void LC_PrintViewportRenderer::doRender() { |
| | setupPainter(painter); |
| | RS_EntityContainer *container = viewport->getContainer(); |
| | container->draw(painter); |
| | } |
| |
|
| |
|
| | void LC_PrintViewportRenderer::renderEntity(RS_Painter *painter, RS_Entity *e) { |
| | #ifdef DEBUG_RENDERING |
| | isVisibleTimer.start(); |
| | #endif |
| | |
| | bool visible = e->isVisible(); |
| | #ifdef DEBUG_RENDERING |
| | isVisibleTime += isVisibleTimer.nsecsElapsed(); |
| | #endif |
| | if (!visible) { |
| | return; |
| | } |
| |
|
| | #ifdef DEBUG_RENDERING |
| | isConstructionTimer.start(); |
| | #endif |
| | bool constructionEntity = e->isConstruction(); |
| | #ifdef DEBUG_RENDERING |
| | isConstructionTime += isConstructionTimer.nsecsElapsed(); |
| | #endif |
| | |
| | if (!e->isPrint() || constructionEntity) |
| | return; |
| |
|
| | if (isOutsideOfBoundingClipRect(e, constructionEntity)) { |
| | return; |
| | } |
| | setPenForPrintingEntity(painter, e); |
| | justDrawEntity(painter, e); |
| | } |
| |
|
| | void LC_PrintViewportRenderer::setPenForPrintingEntity(RS_Painter *painter, RS_Entity *e) { |
| | #ifdef DEBUG_RENDERING |
| | setPenTimer.start(); |
| | #endif |
| | |
| | RS_Pen pen = e->getPenResolved(); |
| | RS_Pen originalPen = pen; |
| |
|
| | double patternOffset = painter->currentDashOffset(); |
| | if (lastPaintEntityPen.isSameAs(pen, patternOffset)) { |
| | return; |
| | } |
| | |
| | double width = pen.getWidth(); |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | if (pen.getAlpha() == 1.0) { |
| | if (width >0) { |
| | double wf = 1.0; |
| |
|
| | if (paperScale > RS_TOLERANCE) { |
| | if (m_scaleLineWidth) { |
| | wf = defaultWidthFactor; |
| | } else { |
| | wf = 1.0 / paperScale; |
| | } |
| | } |
| | double screenWidth = painter->toGuiDX(width * unitFactor100 * wf); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | if (screenWidth < 1){ |
| | screenWidth = 0.0; |
| | } |
| | pen.setScreenWidth(screenWidth); |
| | } |
| | else{ |
| | pen.setScreenWidth(0.0); |
| | } |
| | } |
| | else{ |
| | |
| | if (RS_Math::round(pen.getScreenWidth()) == 1) { |
| | pen.setScreenWidth(0.0); |
| | } |
| | } |
| |
|
| | RS_Color penColor = pen.getColor(); |
| | if (penColor.isEqualIgnoringFlags(m_colorBackground) || |
| | (penColor.toIntColor() == RS_Color::Black && penColor.colorDistance(m_colorBackground) < RS_Color::MinColorDistance)) { |
| | pen.setColor(m_colorForeground); |
| | } |
| |
|
| | if (pen.getLineType() != RS2::SolidLine){ |
| | pen.setDashOffset(patternOffset * defaultWidthFactor); |
| | } |
| | |
| | if (e->getFlag(RS2::FlagTransparent) ) { |
| | pen.setColor(m_colorBackground); |
| | } |
| |
|
| | |
| | lastPaintEntityPen.updateBy(originalPen); |
| | painter->setPen(pen); |
| | #ifdef DEBUG_RENDERING |
| | setPenTime += setPenTimer.nsecsElapsed(); |
| | #endif |
| | } |
| |
|
| |
|
| | void LC_PrintViewportRenderer::loadSettings() { |
| | LC_GraphicViewportRenderer::loadSettings(); |
| | setBackground({255,255,255}); |
| | } |
| |
|
| |
|
| | void LC_PrintViewportRenderer::setupPainter(RS_Painter* painter) { |
| | LC_GraphicViewportRenderer::setupPainter(painter); |
| | painter->setDrawingMode(drawingMode); |
| | |
| | painter->disableUCS(); |
| | } |
| |
|