コード例 #1
0
ファイル: qg_layerwidget.cpp プロジェクト: Aly1029/LibreCAD
/**
 * Shows a context menu for the layer widget. Launched with a right click.
 */
void QG_LayerWidget::contextMenuEvent(QContextMenuEvent *e) {

    if (actionHandler) {
        QMenu* contextMenu = new QMenu(this);
        QLabel* caption = new QLabel(tr("Layer Menu"), this);
        QPalette palette;
        palette.setColor(caption->backgroundRole(), RS_Color(0,0,0));
        palette.setColor(caption->foregroundRole(), RS_Color(255,255,255));
        caption->setPalette(palette);
        caption->setAlignment( Qt::AlignCenter );
        contextMenu->addAction( tr("&Defreeze all Layers"), actionHandler,
                                 SLOT(slotLayersDefreezeAll()), 0);
        contextMenu->addAction( tr("&Freeze all Layers"), actionHandler,
                                 SLOT(slotLayersFreezeAll()), 0);
        contextMenu->addSeparator();
        contextMenu->addAction( tr("&Add Layer"), actionHandler,
                                 SLOT(slotLayersAdd()), 0);
        contextMenu->addAction( tr("&Remove Layer"), actionHandler,
                                 SLOT(slotLayersRemove()), 0);
        contextMenu->addAction( tr("Edit Layer &Attributes"), actionHandler,
                                 SLOT(slotLayersEdit()), 0);
        contextMenu->addAction( tr("Toggle Layer &Visibility"), actionHandler,
                                 SLOT(slotLayersToggleView()), 0);
        contextMenu->addAction( tr("Toggle Layer &Printing"), actionHandler,
                                 SLOT(slotLayersTogglePrint()), 0);
        contextMenu->addAction( tr("Toggle &Construction Layer"), actionHandler,
                                 SLOT(slotLayersToggleConstruction()), 0);
        contextMenu->exec(QCursor::pos());
        delete contextMenu;
    }

    e->accept();
}
コード例 #2
0
ファイル: rs_snapper.cpp プロジェクト: cbirla/LibreCAD
/**
 * Initialize (called by all constructors)
 */
void RS_Snapper::init() 
{
    snapMode = graphicView->getDefaultSnapMode();
	keyEntity = nullptr;
	pImpData->snapSpot = RS_Vector{false};
	pImpData->snapCoord = RS_Vector{false};
	m_SnapDistance = 1.0;

    RS_SETTINGS->beginGroup("/Appearance");
    snap_indicator->lines_state = RS_SETTINGS->readNumEntry("/indicator_lines_state", 1);
    snap_indicator->lines_type = RS_SETTINGS->readEntry("/indicator_lines_type", "Crosshair");
    snap_indicator->shape_state = RS_SETTINGS->readNumEntry("/indicator_shape_state", 1);
    snap_indicator->shape_type = RS_SETTINGS->readEntry("/indicator_shape_type", "Circle");
    RS_SETTINGS->endGroup();

    RS_SETTINGS->beginGroup("Colors");
    QString snap_color = RS_SETTINGS->readEntry("/snap_indicator", Colors::snap_indicator);
    RS_SETTINGS->endGroup();

	snap_indicator->lines_pen = RS_Pen(RS_Color(snap_color), RS2::Width00, RS2::DashLine2);
	snap_indicator->shape_pen = RS_Pen(RS_Color(snap_color), RS2::Width00, RS2::SolidLine);
	snap_indicator->shape_pen.setScreenWidth(1);

    snapRange=getSnapRange();
}
コード例 #3
0
void RS_OverlayBox::draw(RS_Painter* painter, RS_GraphicView* view, double& /*patternOffset*/) {
    if (painter==NULL || view==NULL) {
        return;
    }

    RS_Vector v1=view->toGui(getCorner1());
    RS_Vector v2=view->toGui(getCorner2());

    QRectF selectRect(
        v1.x,
        v1.y,
        v2.x - v1.x,
        v2.y - v1.y);

    if (v1.y > v2.y) {
        painter->setPen(QColor(50, 255, 50));
        painter->fillRect(selectRect, RS_Color(9, 255, 9, 90));
    }
    else {
        painter->setPen(QColor(50, 50, 255));
        painter->fillRect(selectRect, RS_Color(9, 9, 255, 90));
    }

    painter->drawRect(v1, v2);
}
コード例 #4
0
/**
 * Shows a context menu for the block widget. Launched with a right click.
 */
void QG_BlockWidget::contextMenuEvent(QContextMenuEvent *e) {

    QMenu* contextMenu = new QMenu(this);
    QLabel* caption = new QLabel(tr("Block Menu"), this);
    QPalette palette;
    palette.setColor(caption->backgroundRole(), RS_Color(0,0,0));
    palette.setColor(caption->foregroundRole(), RS_Color(255,255,255));
    caption->setPalette(palette);
    caption->setAlignment( Qt::AlignCenter );
    contextMenu->addAction( tr("&Defreeze all Blocks"), actionHandler,
                             SLOT(slotBlocksDefreezeAll()), 0);
    contextMenu->addAction( tr("&Freeze all Blocks"), actionHandler,
                             SLOT(slotBlocksFreezeAll()), 0);
    contextMenu->addAction( tr("&Add Block"), actionHandler,
                             SLOT(slotBlocksAdd()), 0);
    contextMenu->addAction( tr("&Remove Block"), actionHandler,
                             SLOT(slotBlocksRemove()), 0);
    contextMenu->addAction( tr("&Rename Block"), actionHandler,
                             SLOT(slotBlocksAttributes()), 0);
    contextMenu->addAction( tr("&Edit Block"), actionHandler,
                             SLOT(slotBlocksEdit()), 0);
    contextMenu->addAction( tr("&Insert Block"), actionHandler,
                             SLOT(slotBlocksInsert()), 0);
    contextMenu->addAction( tr("&Toggle Visibility"), actionHandler,
                             SLOT(slotBlocksToggleView()), 0);
    contextMenu->addAction( tr("&Create New Block"), actionHandler,
                             SLOT(slotBlocksCreate()), 0);
    contextMenu->exec(QCursor::pos());
    delete contextMenu;

    e->accept();
}
コード例 #5
0
ファイル: rs_painterqt.cpp プロジェクト: dinkel/LibreCAD
void RS_PainterQt::setPen(const RS_Color& color) {
    if (drawingMode==RS2::ModeBW) {
        lpen.setColor(RS_Color(0,0,0));
        QPainter::setPen(RS_Color(0,0,0));
    } else {
        lpen.setColor(color);
        QPainter::setPen(color);
    }
}
コード例 #6
0
ファイル: rs_graphicview.cpp プロジェクト: CNClaus/LibreCAD
void RS_GraphicView::setBackground(const RS_Color& bg) {
	background = bg;

	// bright background:
	if (bg.red()+bg.green()+bg.blue()>380) {
		foreground = RS_Color(0,0,0);
	} else {
		foreground = RS_Color(255,255,255);
	}
}
コード例 #7
0
ファイル: rs_preview.cpp プロジェクト: Akaur/qdraw
/**
 * Adds an entity to this preview and removes any attributes / layer
 * connectsions before that.
 */
void RS_Preview::addEntity(RS_Entity* entity) {
    if (entity==NULL || entity->isUndone()) {
        return;
    }

    // only border preview for complex entities:
    //if ((entity->count() > maxEntities-count()) &&

    bool addBorder = false;

    if (entity->rtti()==RS2::EntityImage || entity->rtti()==RS2::EntityHatch || 
		entity->rtti()==RS2::EntityInsert) {

        addBorder = true;
    } else {
        if (entity->isContainer() && entity->rtti()!=RS2::EntitySpline) {
            if (entity->countDeep() > maxEntities-countDeep()) {
                addBorder = true;
            }
        }
    }

    if (addBorder) {
        RS_Vector min = entity->getMin();
        RS_Vector max = entity->getMax();

        RS_Line* l1 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(min.x, min.y),
                                    RS_Vector(max.x, min.y)));
        RS_Line* l2 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(max.x, min.y),
                                    RS_Vector(max.x, max.y)));
        RS_Line* l3 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(max.x, max.y),
                                    RS_Vector(min.x, max.y)));
        RS_Line* l4 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(min.x, max.y),
                                    RS_Vector(min.x, min.y)));

        RS_EntityContainer::addEntity(l1);
        RS_EntityContainer::addEntity(l2);
        RS_EntityContainer::addEntity(l3);
        RS_EntityContainer::addEntity(l4);

        delete entity;
        entity = NULL;
    } else {
        entity->setLayer(NULL);
        entity->setSelected(false);
        entity->reparent(this);
        entity->setPen(RS_Pen(RS_Color(255,255,255),
                              RS2::Width00,
                              RS2::SolidLine));
        RS_EntityContainer::addEntity(entity);
    }
}
コード例 #8
0
void Doc_plugin_interface::setCurrentLayerProperties(QColor c, QString w, QString t){
    RS_Layer* layer = docGr->getActiveLayer();
    if (layer != NULL) {
        RS_Pen pen(RS_Color(c), Converter.str2lw(w), Converter.str2lt(t));
        layer->setPen(pen);
    }
}
コード例 #9
0
void Doc_plugin_interface::setCurrentLayerProperties(QColor c, DPI::LineWidth w, DPI::LineType t){
    RS_Layer* layer = docGr->getActiveLayer();
    if (layer != NULL) {
        RS_Pen pen(RS_Color(c), static_cast<RS2::LineWidth>(w), static_cast<RS2::LineType>(t));
        layer->setPen(pen);
    }
}
コード例 #10
0
void RS_ActionSelectWindow::mouseMoveEvent(QMouseEvent* e) {
    snapFree(e);
    drawSnapper();
    if (getStatus()==SetCorner2 && v1.valid) {
        v2 = snapFree(e);
        deletePreview();
                RS_Pen pen_f(RS_Color(50,50,255,40), RS2::Width00, RS2::SolidLine);
                RS_OverlayBox* ob=new RS_OverlayBox(preview, RS_OverlayBoxData(v1, v2));
                ob->setPen(pen_f);
                preview->addEntity(ob);

                //RLZ: not needed overlay have contour
/*                RS_Pen pen(RS_Color(218,105,24), RS2::Width00, RS2::SolidLine);

                // TODO change to a rs_box sort of entity
                RS_Line* e=new RS_Line(preview, RS_LineData(RS_Vector(v1.x, v1.y),  RS_Vector(v2.x, v1.y)));
                e->setPen(pen);
        preview->addEntity(e);

                e=new RS_Line(preview, RS_LineData(RS_Vector(v2.x, v1.y),  RS_Vector(v2.x, v2.y)));
                e->setPen(pen);
        preview->addEntity(e);

                e=new RS_Line(preview, RS_LineData(RS_Vector(v2.x, v2.y),  RS_Vector(v1.x, v2.y)));
                e->setPen(pen);
        preview->addEntity(e);

                e=new RS_Line(preview, RS_LineData(RS_Vector(v1.x, v2.y),  RS_Vector(v1.x, v1.y)));
                e->setPen(pen);
        preview->addEntity(e);*/

        drawPreview();
    }
}
コード例 #11
0
/**
 * Testing function.
 */
void LC_SimpleTests::slotTestInsertImage() {
	RS_DEBUG->print("%s\n: begin\n", __func__);

	RS_Document* d = QC_ApplicationWindow::getAppWindow()->getDocument();
	if (d) {
		RS_Graphic* graphic = (RS_Graphic*)d;
		if (graphic==NULL) {
			return;
		}

		RS_Image* image;
		RS_ImageData imageData;

		imageData = RS_ImageData(0, RS_Vector(50.0,30.0),
								 RS_Vector(0.5,0.5),
								 RS_Vector(-0.5,0.5),
								 RS_Vector(640,480),
								 "/home/andrew/data/image.png",
								 50, 50, 0);
		image = new RS_Image(graphic, imageData);

		image->setLayerToActive();
		image->setPen(RS_Pen(RS_Color(255, 0, 0),
							 RS2::Width01,
							 RS2::SolidLine));
		graphic->addEntity(image);
	}
	RS_DEBUG->print("%s\n: end\n", __func__);
}
コード例 #12
0
/**
 * Constructor.
 *
 * @param w Width
 * @param h Height
 */
RS_StaticGraphicView::RS_StaticGraphicView(int w, int h, RS_Painter* p, QSize b) {
    setBackground(RS_Color(255,255,255));
    width = w;
    height = h;
    painter = p;
    setBorders(b.width(), b.height(), b.width(), b.height());
}
コード例 #13
0
/**
 * Testing function.
 */
void LC_SimpleTests::slotTestInsertMText() {
	RS_DEBUG->print("%s\n: begin\n", __func__);

	RS_Document* d = QC_ApplicationWindow::getAppWindow()->getDocument();
	if (d) {
		RS_Graphic* graphic = (RS_Graphic*)d;
		if (graphic==NULL) {
			return;
		}

		RS_MText* text;
		RS_MTextData textData;

		textData = RS_MTextData(RS_Vector(10.0,10.0),
								10.0, 100.0,
								RS_MTextData::VATop,
								RS_MTextData::HALeft,
								RS_MTextData::LeftToRight,
								RS_MTextData::Exact,
								1.0,
								"LibreCAD",
								"iso",
								0.0);
		text = new RS_MText(graphic, textData);

		text->setLayerToActive();
		text->setPen(RS_Pen(RS_Color(255, 0, 0),
							RS2::Width01,
							RS2::SolidLine));
		graphic->addEntity(text);
	}
	RS_DEBUG->print("%s\n: end\n", __func__);
}
コード例 #14
0
ファイル: lc_penwizard.cpp プロジェクト: lordofbikes/LibreCAD
void LC_PenWizard::setActivePenColor(QColor color)
{
    auto graphic = mdi_win->getGraphic();
    auto pen = graphic->getActivePen();
    pen.setColor(RS_Color(color));
    graphic->setActivePen(pen);
}
コード例 #15
0
/**
 * Draws / deletes the current snapper spot.
 */
void RS_Snapper::xorSnapper() {
    if (!finished && snapSpot.valid) {
        RS_Painter* painter = graphicView->createDirectPainter();
        painter->setPreviewMode();
        if (snapCoord.valid) {
            // snap point
            painter->drawCircle(graphicView->toGui(snapCoord), 4);

            // crosshairs:
            if (showCrosshairs==true) {
                painter->setPen(RS_Pen(RS_Color(0,255,255),
                                       RS2::Width00, RS2::DashLine));
                painter->drawLine(RS_Vector(0, graphicView->toGuiY(snapCoord.y)),
                                  RS_Vector(graphicView->getWidth(),
                                            graphicView->toGuiY(snapCoord.y)));
                painter->drawLine(RS_Vector(graphicView->toGuiX(snapCoord.x),0),
                                  RS_Vector(graphicView->toGuiX(snapCoord.x),
                                            graphicView->getHeight()));
            }
        }
        if (snapCoord.valid && snapCoord!=snapSpot) {
            painter->drawLine(graphicView->toGui(snapSpot)+RS_Vector(-5,0),
                              graphicView->toGui(snapSpot)+RS_Vector(-1,4));
            painter->drawLine(graphicView->toGui(snapSpot)+RS_Vector(0,5),
                              graphicView->toGui(snapSpot)+RS_Vector(4,1));
            painter->drawLine(graphicView->toGui(snapSpot)+RS_Vector(5,0),
                              graphicView->toGui(snapSpot)+RS_Vector(1,-4));
            painter->drawLine(graphicView->toGui(snapSpot)+RS_Vector(0,-5),
                              graphicView->toGui(snapSpot)+RS_Vector(-4,-1));
        }

        graphicView->destroyPainter();
        visible = !visible;
    }
}
コード例 #16
0
void QC_ActionGetPoint::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("QC_ActionGetPoint::mouseMoveEvent begin");
    if (getStatus()==SetReferencePoint ||
            getStatus()==SetTargetPoint) {

        RS_Vector mouse = snapPoint(e);
        switch (getStatus()) {
        case SetReferencePoint:
            targetPoint = mouse;
            break;

        case SetTargetPoint:
            if (referencePoint.valid) {
                targetPoint = mouse;
                deletePreview();
                RS_Line *line =new RS_Line(preview,
                                       RS_LineData(referencePoint, mouse));
                line->setPen(RS_Pen(RS_Color(0,0,0), RS2::Width00, RS2::DotLine ));
                preview->addEntity(line);
                RS_DEBUG->print("QC_ActionGetPoint::mouseMoveEvent: draw preview");
                drawPreview();
                preview->addSelectionFrom(*container);
            }
            break;

        default:
            break;
        }
    }

    RS_DEBUG->print("QC_ActionGetPoint::mouseMoveEvent end");
}
コード例 #17
0
ファイル: rs_graphicview.cpp プロジェクト: CNClaus/LibreCAD
/**
 * Draws the paper border (for print previews).
 * This function can ONLY be called from within a paintEvent because it will
 * use the painter
 *
 * @see drawIt()
 */
void RS_GraphicView::drawPaper(RS_Painter *painter) {

	if (!container) {
		return;
	}

	RS_Graphic* graphic = container->getGraphic();
	if (graphic->getPaperScale()<1.0e-6) {
		return;
	}

	// draw paper:
	// RVT_PORT rewritten from     painter->setPen(Qt::gray);
	painter->setPen(QColor(Qt::gray));

	RS_Vector pinsbase = graphic->getPaperInsertionBase();
	RS_Vector size = graphic->getPaperSize();
	double scale = graphic->getPaperScale();

	RS_Vector v1 = toGui((RS_Vector(0,0)-pinsbase)/scale);
	RS_Vector v2 = toGui((size-pinsbase)/scale);

	// gray background:
	painter->fillRect(0,0, getWidth(), getHeight(),
					  RS_Color(200,200,200));

	// shadow
	painter->fillRect(
				(int)(v1.x)+6, (int)(v1.y)+6,
				(int)((v2.x-v1.x)), (int)((v2.y-v1.y)),
				RS_Color(64,64,64));

	// border:
	painter->fillRect(
				(int)(v1.x), (int)(v1.y),
				(int)((v2.x-v1.x)), (int)((v2.y-v1.y)),
				RS_Color(64,64,64));

	// paper
	painter->fillRect(
				(int)(v1.x)+1, (int)(v1.y)-1,
				(int)((v2.x-v1.x))-2, (int)((v2.y-v1.y))+2,
				RS_Color(255,255,255));

}
コード例 #18
0
/**
 * Testing function.
 */
void LC_SimpleTests::slotTestUnicode() {
	RS_DEBUG->print("%s\n: begin\n", __func__);
	auto appWin= QC_ApplicationWindow::getAppWindow();

	appWin->slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
	RS_Document* d =appWin->getDocument();
	if (d) {
		RS_Graphic* graphic = (RS_Graphic*)d;
		if (graphic==NULL) {
			return;
		}

		RS_Insert* ins;

		int col;
		int row;
		QChar uCode;       // e.g. 65 (or 'A')
		QString strCode;   // unicde as string e.g. '[0041] A'

		graphic->setAutoUpdateBorders(false);

		for (col=0x0000; col<=0xFFF0; col+=0x10) {
			printf("col: %X\n", col);
			for (row=0x0; row<=0xF; row++) {
				//printf("  row: %X\n", row);

				uCode = QChar(col+row);
				//printf("  code: %X\n", uCode.unicode());

				strCode.setNum(uCode.unicode(), 16);
				while (strCode.length()<4) {
					strCode="0"+strCode;
				}
				strCode = "[" + strCode + "] " + uCode;

				if (graphic->findBlock(strCode)) {
					RS_InsertData d(strCode,
									RS_Vector(col/0x10*20.0,row*20.0),
									RS_Vector(1.0,1.0), 0.0,
									1, 1, RS_Vector(0.0, 0.0),
									NULL, RS2::NoUpdate);
					ins = new RS_Insert(graphic, d);
					ins->setLayerToActive();
					ins->setPen(RS_Pen(RS_Color(255, 255, 255),
									   RS2::Width01,
									   RS2::SolidLine));
					ins->update();
					graphic->addEntity(ins);
				}
			}
		}
		graphic->setAutoUpdateBorders(true);
		graphic->calculateBorders();
	}
	RS_DEBUG->print("%s\n: end\n", __func__);
}
コード例 #19
0
ファイル: GeometryAdapter.cpp プロジェクト: asir6/Colt
bool GeometryAdapter::ConvertFill(MdfModel::Fill* mdffill, RS_FillStyle& rsfill)
{
    bool const1 = true, const2 = true;

    if (mdffill != NULL)
    {
        const1 = EvalColor(mdffill->GetForegroundColor(), rsfill.color());
        const2 = EvalColor(mdffill->GetBackgroundColor(), rsfill.background());
        rsfill.pattern() = mdffill->GetFillPattern();
    }
    else
    {
        // no fill => set transparent fill color
        rsfill.color() = RS_Color(RS_Color::EMPTY_COLOR_RGBA);
        rsfill.background() = RS_Color(RS_Color::EMPTY_COLOR_RGBA);
    }

    return const1 && const2;
}
コード例 #20
0
ファイル: rs_painterqt.cpp プロジェクト: dinkel/LibreCAD
void RS_PainterQt::setPen(const RS_Pen& pen) {
    lpen = pen;
    if (drawingMode==RS2::ModeBW) {
        lpen.setColor(RS_Color(0,0,0));
    }
    QPen p(lpen.getColor(), RS_Math::round(lpen.getScreenWidth()),
           RS2::rsToQtLineType(lpen.getLineType()));
    p.setJoinStyle(Qt::RoundJoin);
    p.setCapStyle(Qt::RoundCap);
    QPainter::setPen(p);
}
コード例 #21
0
ファイル: rs_painterqt.cpp プロジェクト: dinkel/LibreCAD
void RS_PainterQt::fillTriangle(const RS_Vector& p1,
                                const RS_Vector& p2,
                                const RS_Vector& p3) {

    QPolygon arr(3);
    QBrush brushSaved=brush();
    arr.putPoints(0, 3,
                  toScreenX(p1.x),toScreenY(p1.y),
                  toScreenX(p2.x),toScreenY(p2.y),
                  toScreenX(p3.x),toScreenY(p3.y));
    setBrush(RS_Color(pen().color()));
    drawPolygon(arr);
    setBrush(brushSaved);
}
コード例 #22
0
ファイル: rs_graphicview.cpp プロジェクト: Harpalus/LibreCAD
/**
 * Constructor.
 */
RS_GraphicView::RS_GraphicView()
	:container(nullptr)
	,eventHandler(new RS_EventHandler(this))
	,background()
	,foreground()
	,gridColor(Qt::gray)
	,metaGridColor(RS_Color(64,64,64))
	,grid(new RS_Grid(this))
	,drawingMode(RS2::ModeFull)
	,savedViews(16)
	,previousViewTime(QDateTime::currentDateTime())
{
	init();
}
コード例 #23
0
ファイル: rs_overlaycircle.cpp プロジェクト: DietmarK/LC2DK
void RS_OverlayCircle::draw(RS_Painter* painter, RS_GraphicView* view, double& /*patternOffset*/) {
    if (painter==NULL || view==NULL) {
        return;
    }
	
	RS_Vector v1=view->toGui(getCorner1());
	RS_Vector v2=view->toGui(getCorner2());
	
   RS_Vector cc = (v1 + v2) / 2.0;
           
   double radius = v2.distanceTo(cc);
   
       if (v1.x > v2.x) 	       /* see "cross" in rs_actionselectcircle.cpp  */
     {
	
	RS_Pen p(RS_Color(50,255,50),RS2::Width00,RS2::DashLine);   /* green */
	        painter->setPen(p);
	//        painter->setPen(QColor(50, 255, 50));
	        painter->fillCircle(cc, radius, RS_Color(9, 255, 9, 90));
	     }
	     else {
	         painter->setPen(QColor(50, 50, 255));
	         painter->fillCircle(cc, radius, RS_Color(9, 9, 255, 90));
	     }
	 
	 
   
// old in LC1:	QBrush brush(QColor(9,9,255,90));
   
	// painter->fillRect(v1.x, v1.y, v2.x-v1.x, v2.y-v1.y, QColor(9,9,255,90) );
	
   // painter->fillCircle(cc, radius, brush );
   
   painter->drawCircle(cc, radius);   
   
}
コード例 #24
0
ファイル: lc_penwizard.cpp プロジェクト: lordofbikes/LibreCAD
void LC_PenWizard::setColorForSelected(QColor color)
{
    auto graphic = mdi_win->getGraphic();
    auto pen = graphic->getActivePen();
    pen.setColor(RS_Color(color));

    foreach (auto e, graphic->getEntityList())
    {
        if (e->isSelected())
        {
            e->setPen(pen);
            e->setSelected(false);
        }
    }
    mdi_win->getGraphicView()->redraw(RS2::RedrawDrawing);
}
コード例 #25
0
/**
 * Constructor.
 */
RS_GraphicView::RS_GraphicView()
    : background(), foreground(),
      savedViews(16), savedViewIndex(0),savedViewCount(0),previousViewTime(QDateTime::currentDateTime())
    ,m_bIsCleanUp(false)
{
    drawingMode = RS2::ModeFull;
    printing = false;
    deleteMode = false;
    factor = RS_Vector(1.0,1.0);
    offsetX = 0;
    offsetY = 0;
    container = NULL;
    eventHandler = new RS_EventHandler(this);
    gridColor = Qt::gray;
    metaGridColor = RS_Color(64,64,64);
    grid = new RS_Grid(this);
    zoomFrozen = false;
    //gridVisible = true;
    draftMode = false;

    borderLeft = 0;
    borderTop = 0;
    borderRight = 0;
    borderBottom = 0;

    relativeZero = RS_Vector(false);
    relativeZeroLocked=false;

    mx = my = 0;

    RS_SETTINGS->beginGroup("/Appearance");
    setBackground(QColor(RS_SETTINGS->readEntry("/BackgroundColor", "#000000")));
    setGridColor(QColor(RS_SETTINGS->readEntry("/GridColor", "#7F7F7F")));
    setMetaGridColor(QColor(RS_SETTINGS->readEntry("/MetaGridColor", "#3F3F3F")));
    setSelectedColor(QColor(RS_SETTINGS->readEntry("/SelectedColor", "#A54747")));
	setHighlightedColor(QColor(RS_SETTINGS->readEntry("/HighlightedColor", "#739373")));
	setStartHandleColor(QColor(RS_SETTINGS->readEntry("/StartHandleColor", "#00FFFF")));
	setHandleColor(QColor(RS_SETTINGS->readEntry("/HandleColor", "#0000FF")));
	setEndHandleColor(QColor(RS_SETTINGS->readEntry("/EndHandleColor", "#0000FF")));

    RS_SETTINGS->endGroup();

    printPreview = false;

    QC_ApplicationWindow::getAppWindow()->setPreviousZoomEnable(false);
    //currentInsert = NULL;
}
コード例 #26
0
ファイル: rs_graphicview.cpp プロジェクト: borneq/LibreCAD
/**
 * Constructor.
 */
RS_GraphicView::RS_GraphicView()
    : background(), foreground() {
    drawingMode = RS2::ModeFull;
    printing = false;
    deleteMode = false;
    factor = RS_Vector(1.0,1.0);
    offsetX = 0;
    offsetY = 0;
    previousFactor = RS_Vector(1.0,1.0);
    previousOffsetX = 0;
    previousOffsetY = 0;
    container = NULL;
    eventHandler = new RS_EventHandler(this);
    gridColor = Qt::gray;
    metaGridColor = RS_Color(64,64,64);
    grid = new RS_Grid(this);
    zoomFrozen = false;
    //gridVisible = true;
    draftMode = false;

    borderLeft = 0;
    borderTop = 0;
    borderRight = 0;
    borderBottom = 0;

    relativeZero = RS_Vector(false);
    relativeZeroLocked=false;

    mx = my = 0;

    RS_SETTINGS->beginGroup("/Appearance");
    setBackground(QColor(RS_SETTINGS->readEntry("/BackgroundColor", "#000000")));
    setGridColor(QColor(RS_SETTINGS->readEntry("/GridColor", "#7F7F7F")));
    setMetaGridColor(QColor(RS_SETTINGS->readEntry("/MetaGridColor", "#3F3F3F")));
    setSelectedColor(QColor(RS_SETTINGS->readEntry("/SelectedColor", "#A54747")));
    setHighlightedColor(QColor(RS_SETTINGS->readEntry("/HighlightedColor",
                                                      "#739373")));
    RS_SETTINGS->endGroup();

    printPreview = false;


    //currentInsert = NULL;
}
コード例 #27
0
ファイル: rs_graphicview.cpp プロジェクト: CNClaus/LibreCAD
/**
 * This virtual method can be overwritten to draw the absolute
 * zero. It's called from within drawIt(). The default implemetation
 * draws a simple red cross on the zero of thge sheet
 * THis function can ONLY be called from within a paintEvent because it will
 * use the painter
 *
 * @see drawIt()
 */
void RS_GraphicView::drawAbsoluteZero(RS_Painter *painter) {

    int const zr = 20;

    RS_Pen p(RS_Color(255,0,0), RS2::Width00, RS2::SolidLine);
	p.setScreenWidth(0);
	painter->setPen(p);
	//painter->setBrush(Qt::NoBrush);
    auto vp=toGui(RS_Vector(0,0));
    if( vp.x +zr<0 || vp.x-zr>getWidth()) return;
    if( vp.y +zr<0 || vp.y-zr>getHeight()) return;

    painter->drawLine(RS_Vector(vp.x-zr, vp.y),
                      RS_Vector(vp.x+zr, vp.y)
                      );
    painter->drawLine(RS_Vector(vp.x, vp.y-zr),
                      RS_Vector(vp.x, vp.y+zr)
                      );
}
コード例 #28
0
ファイル: rs_graphicview.cpp プロジェクト: SkipUFO/LibreCAD
/**
 * Constructor.
 */
RS_GraphicView::RS_GraphicView(QWidget* parent, Qt::WindowFlags f)
    :QWidget(parent, f)
	,eventHandler(new RS_EventHandler(this))
	,gridColor(Qt::gray)
	,metaGridColor(RS_Color(64,64,64))
	,grid(new RS_Grid(this))
	,drawingMode(RS2::ModeFull)
	,savedViews(16)
	,previousViewTime(QDateTime::currentDateTime())
{
    RS_SETTINGS->beginGroup("Colors");
    setBackground(QColor(RS_SETTINGS->readEntry("/background", Colors::background)));
    setGridColor(QColor(RS_SETTINGS->readEntry("/grid", Colors::grid)));
    setMetaGridColor(QColor(RS_SETTINGS->readEntry("/meta_grid", Colors::meta_grid)));
    setSelectedColor(QColor(RS_SETTINGS->readEntry("/select", Colors::select)));
    setHighlightedColor(QColor(RS_SETTINGS->readEntry("/highlight", Colors::highlight)));
    setStartHandleColor(QColor(RS_SETTINGS->readEntry("/start_handle", Colors::start_handle)));
    setHandleColor(QColor(RS_SETTINGS->readEntry("/handle", Colors::handle)));
    setEndHandleColor(QColor(RS_SETTINGS->readEntry("/end_handle", Colors::end_handle)));
    RS_SETTINGS->endGroup();
}
コード例 #29
0
ファイル: GeometryAdapter.cpp プロジェクト: asir6/Colt
bool GeometryAdapter::ConvertStroke(MdfModel::Stroke* stroke, RS_LineStroke& rsstroke)
{
    double val;

    if (stroke != NULL)
    {
        bool const1 = EvalDouble(stroke->GetThickness(), val);
        rsstroke.width() = MdfModel::LengthConverter::UnitToMeters(stroke->GetUnit(), val);
        rsstroke.style() = stroke->GetLineStyle();
        rsstroke.units() = (stroke->GetSizeContext() == MdfModel::MappingUnits)? RS_Units_Model : RS_Units_Device;
        bool const2 = EvalColor(stroke->GetColor(), rsstroke.color());

        // if all members are constant, the stroke is constant
        return const1 && const2;
    }
    else
    {
        // no stroke => set transparent outline
        rsstroke.color() = RS_Color(RS_Color::EMPTY_COLOR_RGBA);
        return true;
    }
}
コード例 #30
0
ファイル: qc_actiongetpoint.cpp プロジェクト: DietmarK/LC2DK
void QC_ActionGetPoint::mouseMoveEvent(QMouseEvent* e) {
  RS_DEBUG->print("QC_ActionGetPoint::mouseMoveEvent begin");
  
  RS_Vector mouse = snapPoint(e);
  if(setTargetPoint){
    if (referencePoint.valid) {
      targetPoint = mouse;
      deletePreview();
      RS_Line *line =new RS_Line(preview,
				 RS_LineData(referencePoint, mouse));
      line->setPen(RS_Pen(RS_Color(0,0,0), RS2::Width00, RS2::DotLine ));
      preview->addEntity(line);
      RS_DEBUG->print("QC_ActionGetPoint::mouseMoveEvent: draw preview");
      drawPreview();
      preview->addSelectionFrom(*container);
    }
  } else {
    targetPoint = mouse;
  }
  
  RS_DEBUG->print("QC_ActionGetPoint::mouseMoveEvent end");
}