void RS_GraphicView::drawLayer3(RS_Painter *painter) {
	// drawing zero points:
	if (!isPrintPreview()) {
		drawRelativeZero(painter);
		drawOverlay(painter);
	}
}
示例#2
0
void RS_GraphicView::drawLayer2(RS_Painter *painter)
{
	drawEntity(painter, container);	//	Draw all entities.

	//	If not in print preview, draw the absolute zero reference.
	//	----------------------------------------------------------
	if (!isPrintPreview())
		drawAbsoluteZero(painter);
}
/**
 * Draws the entities.
 * This function can only be called from within the paint event
 *
 */
void RS_GraphicView::drawLayer1(RS_Painter *painter) {

    // drawing paper border:
    if (isPrintPreview()) {
        drawPaper(painter);
    }

    // drawing meta grid:
    if (!isPrintPreview()) {

        //only drawGrid updates the grid layout (updatePointArray())
        drawMetaGrid(painter);
        //draw grid after metaGrid to avoid overwriting grid points by metaGrid lines
        //bug# 3430258
        drawGrid(painter);

    }

}
示例#4
0
void RS_GraphicView::setPenForEntity(RS_Painter *painter,RS_Entity *e)
{
	if (draftMode) {
		painter->setPen(RS_Pen(foreground,
							   RS2::Width00, RS2::SolidLine));
	}

	// Getting pen from entity (or layer)
	RS_Pen pen = e->getPen(true);

	int w = pen.getWidth();
	if (w<0) {
		w = 0;
	}

#if 1 /*TRUE*/
	// - Scale pen width.
	// - Notes: pen width is not scaled on print and print preview.
	//   This is the standard (AutoCAD like) behaviour.
	// bug# 3437941
	// ------------------------------------------------------------
	if (!draftMode)
	{
		double	uf = 1.0;	// Unit factor.
		double	wf = 1.0;	// Width factor.

		RS_Graphic* graphic = container->getGraphic();

        if (graphic)
		{
			uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());

			if (	(isPrinting() || isPrintPreview()) &&
					graphic->getPaperScale() > RS_TOLERANCE )
			{
				wf = 1.0 / graphic->getPaperScale();
			}
		}

		pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
	}
	else
	{
		//		pen.setWidth(RS2::Width00);
		pen.setScreenWidth(0);
	}

#else

	// - Scale pen width.
	// - Notes: pen width is scaled on print and print preview.
	//   This is not the standard (AutoCAD like) behaviour.
	// --------------------------------------------------------
	if (!draftMode)
	{
		double	uf = 1.0;	//	Unit factor.

		RS_Graphic* graphic = container->getGraphic();

        if (graphic)
			uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());

		pen.setScreenWidth(toGuiDX(w / 100.0 * uf));
	}
	else
		pen.setScreenWidth(0);
#endif

	// prevent drawing with 1-width which is slow:
	if (RS_Math::round(pen.getScreenWidth())==1) {
		pen.setScreenWidth(0.0);
	}

	// prevent background color on background drawing:
	if (pen.getColor().stripFlags()==background.stripFlags()) {
		pen.setColor(foreground);
	}

	// this entity is selected:
	if (e->isSelected()) {
		pen.setLineType(RS2::DotLine);
		pen.setColor(selectedColor);
	}

	// this entity is highlighted:
	if (e->isHighlighted()) {
		pen.setColor(highlightedColor);
	}

	// deleting not drawing:
	if (getDeleteMode()) {
		pen.setColor(background);
	}

	painter->setPen(pen);
}
示例#5
0
void RS_GraphicView::drawEntity(RS_Painter *painter, RS_Entity* e, double& patternOffset) {

	// update is diabled:
    // given entity is nullptr:
	if (!e) {
		return;
	}

	// entity is not visible:
	if (!e->isVisible()) {
		return;
	}
	if( isPrintPreview() || isPrinting() ) {
		// do not draw construction layer on print preview or print
		if( ! e->isPrint()
				||  e->isConstruction())
			return;
	}

	// test if the entity is in the viewport
	/* temporary disabled so rs_overlaylien can be drawn
	if (!e->isContainer() && !isPrinting() &&
            (painter==nullptr || !painter->isPreviewMode()) &&
			(toGuiX(e->getMax().x)<0 || toGuiX(e->getMin().x)>getWidth() ||
			 toGuiY(e->getMin().y)<0 || toGuiY(e->getMax().y)>getHeight())) {
		return;
	} */

	// set pen (color):
	setPenForEntity(painter, e );

	//RS_DEBUG->print("draw plain");
	if (isDraftMode()) {
        switch(e->rtti()){
        case RS2::EntityMText:
        case RS2::EntityText:
            if (toGuiDX(((RS_MText*)e)->getHeight())<4 || e->countDeep()>100) {
                // large or tiny texts as rectangles:
                painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
            } else {
                drawEntityPlain(painter, e, patternOffset);
            }
            break;
        case RS2::EntityImage:
            // all images as rectangles:
            painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
            break;
        case RS2::EntityHatch:
            //skip hatches
            break;
        default:
            drawEntityPlain(painter, e, patternOffset);
        }
	} else {
		drawEntityPlain(painter, e, patternOffset);
	}

	// draw reference points:
	if (e->isSelected()) {
		if (!e->isParentSelected()) {
			RS_VectorSolutions const& s = e->getRefPoints();

			for (size_t i=0; i<s.getNumber(); ++i) {
				int sz = -1;
				RS_Color col = handleColor;
				if (i == 0) {
					col = startHandleColor;
				}
				else if (i == s.getNumber() - 1) {
					col = endHandleColor;
				}
				if (getDeleteMode()) {
					painter->drawHandle(toGui(s.get(i)), background, sz);
				} else {
					painter->drawHandle(toGui(s.get(i)), col, sz);
				}
			}
		}
	}

	//RS_DEBUG->print("draw plain OK");


	//RS_DEBUG->print("RS_GraphicView::drawEntity() end");
}
void RS_GraphicView::drawEntity(RS_Painter *painter, RS_Entity* e, double& patternOffset) {

    // update is diabled:
    // given entity is NULL:
    if (e==NULL) {
        return;
    }

    // entity is not visible:
    if (!e->isVisible()) {
        return;
    }
    if( isPrintPreview() ) {
        //do not draw help layer on print preview
            if(e->isHelpLayer()) return;
    }

    // test if the entity is in the viewport
    /* temporary disabled so rs_overlaylien can be drawn
    if (!e->isContainer() && !isPrinting() &&
            (painter==NULL || !painter->isPreviewMode()) &&
            (toGuiX(e->getMax().x)<0 || toGuiX(e->getMin().x)>getWidth() ||
             toGuiY(e->getMin().y)<0 || toGuiY(e->getMax().y)>getHeight())) {
        return;
    } */

    // set pen (color):
    setPenForEntity(painter, e );

    //RS_DEBUG->print("draw plain");
    if (isDraftMode()) {
        // large mtexts as rectangles:
        if (e->rtti()==RS2::EntityMText) {
            if (toGuiDX(((RS_MText*)e)->getHeight())<4 || e->countDeep()>100) {
                painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
            } else {
                drawEntityPlain(painter, e, patternOffset);
            }
        }
        // large texts as rectangles:
        else if (e->rtti()==RS2::EntityText) {
            if (toGuiDX(((RS_Text*)e)->getHeight())<4 || e->countDeep()>100) {
                painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
            } else {
                drawEntityPlain(painter, e, patternOffset);
            }
        }

        // all images as rectangles:
        else if (e->rtti()==RS2::EntityImage) {
            painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
        }

        // hide hatches:
        else if (e->rtti()==RS2::EntityHatch) {
            // nothing
        }

        else {
            drawEntityPlain(painter, e, patternOffset);
        }
    } else {
        drawEntityPlain(painter, e, patternOffset);
    }

    // draw reference points:
    if (e->isSelected()) {
        if (!e->isParentSelected()) {
            RS_VectorSolutions s = e->getRefPoints();

            for (int i=0; i<s.getNumber(); ++i) {
                int sz = -1;
                RS_Color col = RS_Color(0,0,255);
                if (e->rtti()==RS2::EntityPolyline) {
                    if (i==0 || i==s.getNumber()-1) {
                        if (i==0) {
                            sz = 4;
                            col = QColor(0,64,255);
                        }
                        else {
                            sz = 3;
                            col = QColor(0,0,128);
                        }
                    }
                }
                if (getDeleteMode()) {
                    painter->drawHandle(toGui(s.get(i)), background, sz);
                } else {
                    painter->drawHandle(toGui(s.get(i)), col, sz);
                }
            }
        }
    }

    //RS_DEBUG->print("draw plain OK");


    //RS_DEBUG->print("RS_GraphicView::drawEntity() end");
}