コード例 #1
0
ファイル: RGraphicsView.cpp プロジェクト: fallenwind/qcad
bool RGraphicsView::isPathVisible(const RPainterPath &path) const {
    double featureSize = path.getFeatureSize();

    // no feature size given, always visible:
    if (fabs(featureSize)<RS::PointTolerance) {
        return true;
    }

    int featureSizePx = (int)mapDistanceToView(fabs(featureSize));

    if (featureSize>RS::PointTolerance) {
        // paths feature size is too small to be displayed (display real text):
        if (!isPrinting() && featureSizePx<=textHeightThreshold) {
            return false;
        }
    }
    else if (featureSize<-RS::PointTolerance) {
        // paths feature size is too large to be displayed (bounding box):
        if (isPrinting() || featureSizePx>textHeightThreshold) {
            return false;
        }
    }

    return true;
}
コード例 #2
0
void FabAtHomePrinter::equipBay(const string& bayName, const string& materialCalibrationName)
{
     Util::assertTrue(tool.bays.find(bayName) != tool.bays.end(),"Trying to equip "+bayName+" with "+materialCalibrationName+" but bay has not been loaded.",__LINE__,__FILE__);
     Util::assertTrue(materialCalibrationName.compare("") == 0 || materialCalibrations.find(materialCalibrationName) != materialCalibrations.end(),"Trying to equip "+bayName+" with "+materialCalibrationName+" but material calibration has not been loaded.",__LINE__,__FILE__);
     Util::assertTrue(!isPrinting() || isPaused(),"Cannot equip bay at this time.",__LINE__,__FILE__);
     MaterialCalibration* materialCalibration = materialCalibrationName.compare("") == 0 ? NULL : &(materialCalibrations.find(materialCalibrationName)->second);
     tool.bays.find(bayName)->second.materialCalibration = materialCalibration;
}
コード例 #3
0
ファイル: rs_graphicview.cpp プロジェクト: CNClaus/LibreCAD
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);
}
コード例 #4
0
ファイル: rs_graphicview.cpp プロジェクト: CNClaus/LibreCAD
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");
}