本文整理汇总了C++中RS_Pen函数的典型用法代码示例。如果您正苦于以下问题:C++ RS_Pen函数的具体用法?C++ RS_Pen怎么用?C++ RS_Pen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RS_Pen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RS_Pen
/**
* 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();
}
开发者ID:cbirla,项目名称:LibreCAD,代码行数:28,代码来源:rs_snapper.cpp
示例2: RS_MTextData
/**
* 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__);
}
开发者ID:miguelramosfdz,项目名称:LibreCAD,代码行数:36,代码来源:lc_simpletests.cpp
示例3: RS_ImageData
/**
* 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__);
}
开发者ID:miguelramosfdz,项目名称:LibreCAD,代码行数:32,代码来源:lc_simpletests.cpp
示例4: getStatus
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");
}
开发者ID:Samsagax,项目名称:LibreCAD,代码行数:32,代码来源:qc_actiongetpoint.cpp
示例5: xorSnapper
/**
* 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;
}
}
开发者ID:jacklibj,项目名称:2.0.5.0-1-community.src,代码行数:38,代码来源:rs_snapper.cpp
示例6: RS_Line
/**
* 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);
}
}
开发者ID:Akaur,项目名称:qdraw,代码行数:64,代码来源:rs_preview.cpp
示例7: removeEntity
/**
* Implementation of update. Updates the arrow.
*/
void RS_Leader::update() {
// find and delete arrow:
for(auto e: entities){
if (e->rtti()==RS2::EntitySolid) {
removeEntity(e);
break;
}
}
if (isUndone()) {
return;
}
RS_Entity* fe = firstEntity();
if (fe && fe->isAtomic()) {
RS_Vector p1 = ((RS_AtomicEntity*)fe)->getStartpoint();
RS_Vector p2 = ((RS_AtomicEntity*)fe)->getEndpoint();
// first entity must be the line which gets the arrow:
if (hasArrowHead()) {
RS_Solid* s = new RS_Solid(this, RS_SolidData());
s->shapeArrow(p1,
p2.angleTo(p1),
getGraphicVariableDouble("$DIMASZ", 2.5)* getGraphicVariableDouble("$DIMSCALE", 1.0));
s->setPen(RS_Pen(RS2::FlagInvalid));
s->setLayer(nullptr);
RS_EntityContainer::addEntity(s);
}
}
calculateBorders();
}
开发者ID:Azen2011,项目名称:LibreCAD,代码行数:35,代码来源:rs_leader.cpp
示例8: removeEntity
/**
* Implementation of update. Updates the arrow.
*/
void RS_Leader::update() {
// find and delete arrow:
for (RS_Entity* e=firstEntity(); e!=NULL; e=nextEntity()) {
if (e->rtti()==RS2::EntitySolid) {
removeEntity(e);
break;
}
}
if (isUndone()) {
setVisible(false);
return;
}
RS_Entity* fe = firstEntity();
if (fe!=NULL && fe->isAtomic()) {
RS_Vector p1 = ((RS_AtomicEntity*)fe)->getStartpoint();
RS_Vector p2 = ((RS_AtomicEntity*)fe)->getEndpoint();
// first entity must be the line which gets the arrow:
if (hasArrowHead()) {
RS_Solid* s = new RS_Solid(this, RS_SolidData());
s->shapeArrow(p1,
p2.angleTo(p1),
getGraphicVariableDouble("$DIMASZ", 2.5));
s->setPen(RS_Pen(RS2::FlagInvalid));
s->setLayer(NULL);
RS_EntityContainer::addEntity(s);
}
}
}
开发者ID:jacklibj,项目名称:2.0.5.0-1-community.src,代码行数:35,代码来源:rs_leader.cpp
示例9: printf
/**
* 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__);
}
开发者ID:miguelramosfdz,项目名称:LibreCAD,代码行数:59,代码来源:lc_simpletests.cpp
示例10: RS_EntityContainer
/**
* Constructor.
*
* @param parent Parent of the document. Often that's NULL but
* for blocks it's the blocklist.
*/
RS_Document::RS_Document(RS_EntityContainer* parent)
: RS_EntityContainer(parent), RS_Undo() {
RS_DEBUG->print("RS_Document::RS_Document() ");
filename = "";
formatType = RS2::FormatUnknown;
setModified(false);
RS_Color col(RS2::FlagByLayer);
activePen = RS_Pen(col, RS2::WidthByLayer, RS2::LineByLayer);
}
开发者ID:Seablade,项目名称:vec2web,代码行数:17,代码来源:rs_document.cpp
示例11: ArraySize
void DL_Jww::CreateTen(DL_CreationInterface* creationInterface, CDataTen& DTen)
{
string lName = HEX[DTen.m_nGLayer > ArraySize(HEX)-1 ? ArraySize(HEX)-1: DTen.m_nGLayer] + "-" +
HEX[DTen.m_nLayer > ArraySize(HEX)-1 ? ArraySize(HEX)-1: DTen.m_nLayer];
// add layer
creationInterface->addLayer(DL_LayerData(lName,0));
int width;
if(DTen.m_nPenWidth > 26)
width = 0;
else
width = DTen.m_nPenWidth;
int color = colTable[DTen.m_nPenColor > ArraySize(colTable)-1 ? ArraySize(colTable)-1 : DTen.m_nPenColor];
attrib = DL_Attributes(values[8], // layer
color, // color
width, // width
lTable[DTen.m_nPenStyle > ArraySize(lTable)-1 ? ArraySize(lTable)-1 : DTen.m_nPenStyle]); // linetype
creationInterface->setAttributes(attrib);
creationInterface->setExtrusion(0.0, 0.0, 1.0, 0.0 );
DL_PointData d(DTen.m_start.x, DTen.m_start.y, 0.0);
creationInterface->addPoint(d);
#ifdef FINISHED
RS_PointData data2(RS_Vector(0.0, 0.0));
RS_Point* point;
data2.pos = RS_Vector(DTen.m_start.x, DTen.m_start.y);
point = new RS_Point(graphic, data2);
RS2::LineType ltype = lTable[DTen.m_nPenStyle];
RS_Color col = colTable[DTen.m_nPenColor];
RS2::LineWidth lw = lWidth[DTen.m_nPenWidth > 26 ? 0 :DTen.m_nPenWidth];//RS2::Width12
point->setPen(RS_Pen(col, RS2::Width23, ltype));
//画層設定
RS_String lName = HEX[DTen.m_nGLayer > 0x0f ? 0 : DTen.m_nGLayer] + "-" +
HEX[DTen.m_nLayer > 0x0f ? 0: DTen.m_nLayer];
if( graphic->findLayer(lName) == (RS_Layer*)NULL ){
#ifdef DEBUG
std::cout << lName.ascii() << std::endl;
#endif
RS_Layer* layer = new RS_Layer(lName);
graphic->addLayer(layer);
}
point->setLayer(lName);
// add the line to the graphic
graphic->addEntity(point);
#ifdef DEBUG
std::cout << *point;
#endif
#endif
}
开发者ID:LibreCAD,项目名称:LibreCAD,代码行数:51,代码来源:dl_jww.cpp
示例12: snapPoint
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");
}
开发者ID:DietmarK,项目名称:LC2DK,代码行数:22,代码来源:qc_actiongetpoint.cpp
示例13: RS_Pen
void QG_GraphicView::layerActivated(RS_Layer *layer) {
RS_SETTINGS->beginGroup("/Modify");
bool toActivated= (RS_SETTINGS->readNumEntry("/ModifyEntitiesToActiveLayer", 0)==1);
RS_SETTINGS->endGroup();
if(!toActivated) return;
RS_EntityContainer *container = this->getContainer();
//allow undo cycle for layer change of selected
RS_AttributesData data;
data.pen = RS_Pen();
data.layer = layer->getName();
data.changeColor = false;
data.changeLineType = false;
data.changeWidth = false;
data.changeLayer = true;
RS_Modification m(*container, this);
m.changeAttributes(data);
container->setSelected(false);
redraw(RS2::RedrawDrawing);
}
开发者ID:SkipUFO,项目名称:LibreCAD,代码行数:22,代码来源:qg_graphicview.cpp
示例14: RS_Vector
/**
* Adds a vertex from the endpoint of the last element or
* sets the startpoint to the point 'v'.
*
* The very first vertex added is the starting point.
*
* @param v vertex coordinate
*
* @return Pointer to the entity that was addded or NULL if this
* was the first vertex added.
*/
RS_Entity* RS_Leader::addVertex(const RS_Vector& v) {
RS_Entity* entity=NULL;
static RS_Vector last = RS_Vector(false);
if (empty) {
last = v;
empty = false;
} else {
// add line to the leader:
entity = new RS_Line(this, RS_LineData(last, v));
entity->setPen(RS_Pen(RS2::FlagInvalid));
entity->setLayer(NULL);
RS_EntityContainer::addEntity(entity);
if (count()==1 && hasArrowHead()) {
update();
}
last = v;
}
return entity;
}
开发者ID:0825732889,项目名称:LibreCAD,代码行数:35,代码来源:rs_leader.cpp
示例15: addVertex
/**
* Adds a vertex from the endpoint of the last element or
* sets the startpoint to the point 'v'.
*
* The very first vertex added is the starting point.
*
* @param v vertex coordinate
*
* @return Pointer to the entity that was added or nullptr if this
* was the first vertex added.
*/
RS_Entity* RS_Leader::addVertex(const RS_Vector& v) {
RS_Entity* entity{nullptr};
static RS_Vector last = RS_Vector{false};
if (empty) {
last = v;
empty = false;
} else {
// add line to the leader:
entity = new RS_Line{this, {last, v}};
entity->setPen(RS_Pen(RS2::FlagInvalid));
entity->setLayer(nullptr);
RS_EntityContainer::addEntity(entity);
if (count()==1 && hasArrowHead()) {
update();
}
last = v;
}
return entity;
}
开发者ID:Azen2011,项目名称:LibreCAD,代码行数:35,代码来源:rs_leader.cpp
示例16: count
//.........这里部分代码省略.........
}
#if QT_VERSION < 0x040400
emu_qt44_removeOne(is, av);
#else
is.removeOne(av);
#endif
av.reset();
}
} while(!done);
}
is2.append(std::shared_ptr<RS_Vector>(new RS_Vector(endPoint)));
// add small cut lines / arcs to tmp2:
for (int i = 1; i < is2.size(); ++i) {
auto v1 = is2.at(i-1);
auto v2 = is2.at(i);
if (line) {
tmp2.addEntity(new RS_Line{&tmp2, *v1, *v2});
} else if (arc || circle) {
if(fabs(center.angleTo(*v2)-center.angleTo(*v1)) > RS_TOLERANCE_ANGLE)
{//don't create an arc with a too small angle
tmp2.addEntity(new RS_Arc(&tmp2,
RS_ArcData(center,
center.distanceTo(*v1),
center.angleTo(*v1),
center.angleTo(*v2),
reversed)));
}
}
}
}
// updating hatch / adding entities that are inside
RS_DEBUG->print("RS_Hatch::update: cutting pattern carpet: OK");
//RS_EntityContainer* rubbish = new RS_EntityContainer(getGraphic());
// the hatch pattern entities:
hatch = new RS_EntityContainer(this);
hatch->setPen(RS_Pen(RS2::FlagInvalid));
hatch->setLayer(nullptr);
hatch->setFlag(RS2::FlagTemp);
//calculateBorders();
for(auto e: tmp2){
RS_Vector middlePoint;
RS_Vector middlePoint2;
if (e->rtti()==RS2::EntityLine) {
RS_Line* line = static_cast<RS_Line*>(e);
middlePoint = line->getMiddlePoint();
middlePoint2 = line->getNearestDist(line->getLength()/2.1,
line->getStartpoint());
} else if (e->rtti()==RS2::EntityArc) {
RS_Arc* arc = static_cast<RS_Arc*>(e);
middlePoint = arc->getMiddlePoint();
middlePoint2 = arc->getNearestDist(arc->getLength()/2.1,
arc->getStartpoint());
} else {
middlePoint = RS_Vector{false};
middlePoint2 = RS_Vector{false};
}
if (middlePoint.valid) {
bool onContour=false;
if (RS_Information::isPointInsideContour(
middlePoint,
this, &onContour) ||
RS_Information::isPointInsideContour(middlePoint2, this)) {
RS_Entity* te = e->clone();
te->setPen(RS2::FlagInvalid);
te->setLayer(nullptr);
te->reparent(hatch);
hatch->addEntity(te);
}
}
}
addEntity(hatch);
//getGraphic()->addEntity(rubbish);
forcedCalculateBorders();
// deactivate contour:
activateContour(false);
updateRunning = false;
RS_DEBUG->print("RS_Hatch::update: OK");
}
开发者ID:rmamba,项目名称:LibreCAD,代码行数:101,代码来源:rs_hatch.cpp
示例17: RS_Hatch
void RS_ActionDrawHatch::trigger() {
RS_DEBUG->print("RS_ActionDrawHatch::trigger()");
//if (pos.valid) {
//deletePreview();
RS_Entity* e;
// deselect unhatchable entities:
for(auto e: *container){
if (e->isSelected() &&
(e->rtti()==RS2::EntityHatch ||
/* e->rtti()==RS2::EntityEllipse ||*/ e->rtti()==RS2::EntityPoint ||
e->rtti()==RS2::EntityMText || e->rtti()==RS2::EntityText ||
RS_Information::isDimension(e->rtti()))) {
e->setSelected(false);
}
}
for (e=container->firstEntity(RS2::ResolveAll); e;
e=container->nextEntity(RS2::ResolveAll)) {
if (e->isSelected() &&
(e->rtti()==RS2::EntityHatch ||
/* e->rtti()==RS2::EntityEllipse ||*/ e->rtti()==RS2::EntityPoint ||
e->rtti()==RS2::EntityMText || e->rtti()==RS2::EntityText ||
RS_Information::isDimension(e->rtti()))) {
e->setSelected(false);
}
}
// look for selected contours:
bool haveContour = false;
for (e=container->firstEntity(RS2::ResolveAll); e;
e=container->nextEntity(RS2::ResolveAll)) {
if (e->isSelected()) {
haveContour = true;
}
}
if (!haveContour) {
std::cerr << "no contour selected\n";
return;
}
hatch = new RS_Hatch(container, data);
hatch->setLayerToActive();
hatch->setPenToActive();
RS_EntityContainer* loop = new RS_EntityContainer(hatch);
loop->setPen(RS_Pen(RS2::FlagInvalid));
// add selected contour:
for (RS_Entity* e=container->firstEntity(RS2::ResolveAll); e;
e=container->nextEntity(RS2::ResolveAll)) {
if (e->isSelected()) {
e->setSelected(false);
// entity is part of a complex entity (spline, polyline, ..):
if (e->getParent() &&
// RVT - Don't de-delect the parent EntityPolyline, this is messing up the getFirst and getNext iterators
// (e->getParent()->rtti()==RS2::EntitySpline ||
// e->getParent()->rtti()==RS2::EntityPolyline)) {
(e->getParent()->rtti()==RS2::EntitySpline)) {
e->getParent()->setSelected(false);
}
RS_Entity* cp = e->clone();
cp->setPen(RS_Pen(RS2::FlagInvalid));
cp->reparent(loop);
loop->addEntity(cp);
}
}
hatch->addEntity(loop);
if (hatch->validate()) {
container->addEntity(hatch);
if (document) {
document->startUndoCycle();
document->addUndoable(hatch);
document->endUndoCycle();
}
hatch->update();
graphicView->redraw(RS2::RedrawDrawing);
bool printArea=true;
switch( hatch->getUpdateError()) {
case RS_Hatch::HATCH_OK :
RS_DIALOGFACTORY->commandMessage(tr("Hatch created successfully."));
break;
case RS_Hatch::HATCH_INVALID_CONTOUR :
RS_DIALOGFACTORY->commandMessage(tr("Hatch Error: Invalid contour found!"));
printArea=false;
break;
case RS_Hatch::HATCH_PATTERN_NOT_FOUND :
RS_DIALOGFACTORY->commandMessage(tr("Hatch Error: Pattern not found!"));
break;
case RS_Hatch::HATCH_TOO_SMALL :
RS_DIALOGFACTORY->commandMessage(tr("Hatch Error: Contour or pattern too small!"));
break;
case RS_Hatch::HATCH_AREA_TOO_BIG :
RS_DIALOGFACTORY->commandMessage(tr("Hatch Error: Contour too big!"));
//.........这里部分代码省略.........
开发者ID:rmamba,项目名称:LibreCAD,代码行数:101,代码来源:rs_actiondrawhatch.cpp
示例18: getGeneralScale
/**
* Creates a dimensioning line (line with one, two or no arrows and a text).
*
* @param forceAutoText Automatically reposition the text label.
*/
void RS_Dimension::updateCreateDimensionLine(const RS_Vector& p1,
const RS_Vector& p2, bool arrow1, bool arrow2, bool forceAutoText) {
// general scale (DIMSCALE)
double dimscale = getGeneralScale();
// text height (DIMTXT)
double dimtxt = getTextHeight()*dimscale;
// text distance to line (DIMGAP)
double dimgap = getDimensionLineGap()*dimscale;
// length of dimension line:
double distance = p1.distanceTo(p2);
// arrow size:
double arrowSize = getArrowSize()*dimscale;
// do we have to put the arrows outside of the line?
bool outsideArrows = (distance<arrowSize*2.5);
// arrow angles:
double arrowAngle1, arrowAngle2;
// Create dimension line:
RS_Line* dimensionLine = new RS_Line(this, RS_LineData(p1, p2));
dimensionLine->setPen(RS_Pen(RS2::FlagInvalid));
dimensionLine->setLayer(NULL);
addEntity(dimensionLine);
if (outsideArrows==false) {
arrowAngle1 = dimensionLine->getAngle2();
arrowAngle2 = dimensionLine->getAngle1();
} else {
arrowAngle1 = dimensionLine->getAngle1();
arrowAngle2 = dimensionLine->getAngle2();
// extend dimension line outside arrows
RS_Vector dir;
dir.setPolar(arrowSize*2, arrowAngle2);
dimensionLine->setStartpoint(p1 + dir);
dimensionLine->setEndpoint(p2 - dir);
}
double dimtsz=getTickSize()*dimscale;
if(dimtsz < 0.01) {
//display arrow
// Arrows:
RS_SolidData sd;
RS_Solid* arrow;
if (arrow1) {
// arrow 1
arrow = new RS_Solid(this, sd);
arrow->shapeArrow(p1,
arrowAngle1,
arrowSize);
arrow->setPen(RS_Pen(RS2::FlagInvalid));
arrow->setLayer(NULL);
addEntity(arrow);
}
if (arrow2) {
// arrow 2:
arrow = new RS_Solid(this, sd);
arrow->shapeArrow(p2,
arrowAngle2,
arrowSize);
arrow->setPen(RS_Pen(RS2::FlagInvalid));
arrow->setLayer(NULL);
addEntity(arrow);
}
}else{
//display ticks
// Arrows:
RS_Line* tick;
RS_Vector tickVector;
tickVector.setPolar(dimtsz,arrowAngle1 + M_PI*0.25); //tick is 45 degree away
if (arrow1) {
// tick 1
tick = new RS_Line(this, p1-tickVector, p1+tickVector);
tick->setPen(RS_Pen(RS2::FlagInvalid));
tick->setLayer(NULL);
addEntity(tick);
}
if (arrow2) {
// tick 2:
tick = new RS_Line(this, p2-tickVector, p2+tickVector);
tick->setPen(RS_Pen(RS2::FlagInvalid));
tick->setLayer(NULL);
addEntity(tick);
}
}
// Text label:
RS_MTextData textData;
RS_Vector textPos;
//.........这里部分代码省略.........
开发者ID:TNick2,项目名称:LibreCAD,代码行数:101,代码来源:rs_dimension.cpp
示例19: RS_Line
/**
* Creates a vertex from the endpoint of the last element or
* sets the startpoint to the point 'v'.
*
* The very first vertex added is the starting point.
*
* @param v vertex coordinate
* @param bulge The bulge of the arc (see DXF documentation)
* @param prepend true: Prepend instead of append at end
*
* @return Pointer to the entity that was created or NULL if this
* was the first vertex added.
*/
RS_Entity* RS_Polyline::createVertex(const RS_Vector& v, double bulge, bool prepend) {
RS_Entity* entity=NULL;
RS_DEBUG->print("RS_Polyline::createVertex: %f/%f to %f/%f bulge: %f",
data.endpoint.x, data.endpoint.y, v.x, v.y, bulge);
// create line for the polyline:
if (fabs(bulge)<RS_TOLERANCE) {
if (prepend==false) {
entity = new RS_Line(this, RS_LineData(data.endpoint, v));
}
else {
entity = new RS_Line(this, RS_LineData(v, data.startpoint));
}
entity->setSelected(isSelected());
entity->setPen(RS_Pen(RS2::FlagInvalid));
entity->setLayer(NULL);
//RS_EntityContainer::addEntity(entity);
//data.endpoint = v;
}
// create arc for the polyline:
else {
bool reversed = (bulge<0.0);
double alpha = atan(bulge)*4.0;
double radius;
RS_Vector center;
RS_Vector middle;
double dist;
double angle;
if (prepend==false) {
middle = (data.endpoint+v)/2.0;
dist = data.endpoint.distanceTo(v)/2.0;
angle = data.endpoint.angleTo(v);
}
else {
middle = (data.startpoint+v)/2.0;
dist = data.startpoint.distanceTo(v)/2.0;
angle = v.angleTo(data.startpoint);
}
// alpha can't be 0.0 at this point
radius = fabs(dist / sin(alpha/2.0));
double wu = fabs(RS_Math::pow(radius, 2.0) - RS_Math::pow(dist, 2.0));
double h = sqrt(wu);
if (bulge>0.0) {
angle+=M_PI_2;
} else {
angle-=M_PI_2;
}
if (fabs(alpha)>M_PI) {
h*=-1.0;
}
center.setPolar(h, angle);
center+=middle;
double a1;
double a2;
if (prepend==false) {
a1 = center.angleTo(data.endpoint);
a2 = center.angleTo(v);
}
else {
a1 = center.angleTo(v);
a2 = center.angleTo(data.startpoint);
}
RS_ArcData d(center, radius,
a1, a2,
reversed);
entity = new RS_Arc(this, d);
entity->setSelected(isSelected());
entity->setPen(RS_Pen(RS2::FlagInvalid));
entity->setLayer(NULL);
}
return entity;
}
开发者ID:chenchizhao,项目名称:LibreCAD,代码行数:100,代码来源:rs_polyline.cpp
示例20: clear
/**
* Updates the sub entities of this dimension. Called when the
* dimension or the position, alignment, .. changes.
*
* @param autoText Automatically reposition the text label
*/
void RS_DimAngular::update(bool /*autoText*/) {
RS_DEBUG->print("RS_DimAngular::update");
clear();
if (isUndone()) {
return;
}
// distance from entities (DIMEXO)
double dimexo = getExtensionLineOffset();
// extension line extension (DIMEXE)
double dimexe = getExtensionLineExtension();
// text height (DIMTXT)
double dimtxt = getTextHeight();
// text distance to line (DIMGAP)
double dimgap = getDimensionLineGap();
// find out center:
RS_Vector center = getCenter();
if (!center.valid) {
return;
}
double ang1 = 0.0;
double ang2 = 0.0;
bool reversed = false;
RS_Vector p1;
RS_Vector p2;
getAngles(ang1, ang2, reversed, p1, p2);
double rad = edata.definitionPoint4.distanceTo(center);
RS_Line* line;
RS_Vector dir;
double len;
double dist;
// 1st extension line:
dist = center.distanceTo(p1);
len = rad - dist + dimexe;
dir.setPolar(1.0, ang1);
line = new RS_Line(this,
RS_LineData(center + dir*dist + dir*dimexo,
center + dir*dist + dir*len));
line->setPen(RS_Pen(RS2::FlagInvalid));
line->setLayer(NULL);
addEntity(line);
// 2nd extension line:
dist = center.distanceTo(p2);
len = rad - dist + dimexe;
dir.setPolar(1.0, ang2);
line = new RS_Line(this,
RS_LineData(center + dir*dist + dir*dimexo,
center + dir*dist + dir*len));
line->setPen(RS_Pen(RS2::FlagInvalid));
line->setLayer(NULL);
addEntity(line);
// Create dimension line (arc):
RS_Arc* arc = new RS_Arc(this,
RS_ArcData(center,
rad, ang1, ang2, reversed));
arc->setPen(RS_Pen(RS2::FlagInvalid));
arc->setLayer(NULL);
addEntity(arc);
// length of dimension arc:
double distance = arc->getLength();
// do we have to put the arrows outside of the arc?
bool outsideArrows = (distance<getArrowSize()*2);
// arrow angles:
double arrowAngle1, arrowAngle2;
double arrowAng;
if (rad>1.0e-6) {
arrowAng = getArrowSize() / rad;
}
else {
arrowAng = 0.0;
}
RS_Vector v1, v2;
if (!arc->isReversed()) {
v1.setPolar(rad, arc->getAngle1()+arrowAng);
} else {
v1.setPolar(rad, arc->getAngle1()-arrowAng);
}
v1+=arc->getCenter();
arrowAngle1 = arc->getStartpoint().angleTo(v1);
//.........这里部分代码省略.........
开发者ID:JGabriel85,项目名称:LibreCAD,代码行数:101,代码来源:rs_dimangular.cpp
注:本文中的RS_Pen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论