1/ui 部份
1/增加主菜单
![在这里插入图片描述](https://img-blog.csdnimg.cn/65e596109caf43a485505ab1b705ea94.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkDns5bnjq8,size_18,color_FFFFFF,t_70,g_se,x_16)
增加子菜单项
3/plt dxf 转换 只转换成简单连续线段
端点 0 — x y 坐标 标志 10/20
端点 1 — x y 坐标 标志 11/21
起笔 抬笔 转换成 sec 及段结束
2/显示接口
获取当前界面 组件单元列表
RS_BlockList* RS_Block::getBlockList() {
RS_Graphic* g = getGraphic();
if (g) {
return g->getBlockList();
} else {
return NULL;
}
}
4/端点绘线接口 镜像操作 负坐标处理
/**
* Adds a line to the current graphic document.
*/
void rsPyAddLine(double x1, double y1, double x2, double y2) {
//printf("c: addLine called\n");
//printf("c: parameter from python: %f\n", x1);
RS_Graphic* graphic = RS_SIMPLEPYTHON->getGraphic();
if (graphic!=NULL) {
graphic->addEntity(new RS_Line(graphic,
RS_LineData(RS_Vector(x1, y1),
RS_Vector(x2, y2))));
} else {
std::cerr << "rsPyAddLine: No graphic object set.\n";
}
}
5/鼠标滚轮控制缩放
//将下面事件操作替换
if (scroll && scrollbars) {
//scroll by scrollbars: issue #479
RS_SETTINGS->beginGroup("/Defaults");
bool inv_h = (RS_SETTINGS->readNumEntry("/WheelScrollInvertH", 0) == 1);
bool inv_v = (RS_SETTINGS->readNumEntry("/WheelScrollInvertV", 0) == 1);
RS_SETTINGS->endGroup();
int delta;
switch(direction){
case RS2::Left:
case RS2::Right:
delta = (inv_h) ? -e->delta() : e->delta();
hScrollBar->setValue(hScrollBar->value()+delta);
break;
default:
delta = (inv_v) ? -e->delta() : e->delta();
vScrollBar->setValue(vScrollBar->value()+delta);
}
// setCurrentAction(new RS_ActionZoomScroll(direction,
// *container, *this));
}
// zoom in / out:
else if (e->modifiers()==0) {
7/绘制工作空间大小,以指定缩放/对应屏幕像素及转换后实时中心点为原点画矩形
QRect(-50, -50, 300, 300)
8/添加图元及block 选中显示 tableview
添加 point 映射
添加选中映射
选中处理代码
/**
* @return True if the entity is in the given range.
*/
bool RS_Entity::isInWindow(RS_Vector v1, RS_Vector v2) const
{
double right, left, top, bottom;
right = std::max(v1.x, v2.x);
left = std::min(v1.x, v2.x);
top = std::max(v1.y, v2.y);
bottom = std::min(v1.y, v2.y);
return (getMin().x>=left &&
getMax().x<=right &&
getMin().y>=bottom &&
getMax().y<=top);
}
获取图元id
获取图元名称
// There should be a better way then this...
switch(e.rtti()) {
case RS2::EntityPoint:
os << (RS_Point&)e;
break;
case RS2::EntityLine:
os << (RS_Line&)e;
break;
case RS2::EntityPolyline:
os << (RS_Polyline&)e;
break;
case RS2::EntityArc:
os << (RS_Arc&)e;
break;
添加图元参数控制
10/多点触控/键盘方向键移动
if (e->modifiers() & Qt::ControlModifier)
{ auto value = text(); if (value.isEmpty()) value = relative_ray; QString r_string; switch (e->key()) { case Qt::Key_Up: r_string = "0," + value; break; case Qt::Key_Down: r_string = "0,-" + value; break; case Qt::Key_Right: r_string = value + ",0"; break; case Qt::Key_Left: r_string = "-" + value + ",0"; break; default: QLineEdit::keyPressEvent(e); return; }
void Widget::mouseMoveEvent(QMouseEvent * event)
{
qDebug()<<tr("%1,%2").arg(event->pos().x()).arg(event->pos().y());
}
11/系统坐标中点绘制随窗体自动拉伸定位框
QPainter painter(this);
static double wid = rect().width();
static double hei = rect().height();
painter.setRenderHints(QPainter::Antialiasing, true);//抗锯齿
double new_wid = rect().width()/wid;
double new_hei = rect().height()/hei;
painter.scale(new_wid, new_hei);