如何使用.slib文件中的ARC坐标在QT中绘制ARC?

发布于 2025-02-07 08:50:28 字数 1672 浏览 1 评论 0原文

我试图通过阅读.slib file。 但是,我从.slib文件中读取arc相关的坐标时遇到了问题。

我不明白如何使用这些坐标并绘制弧线?
.slib文件中的弧的格式令人困惑。

这是一个例子:

.slib arc的格式和line

line (66 * SCALE, 80 * SCALE, 0 * SCALE, 80 * SCALE); 
line (94 * SCALE, 70 * SCALE, 62 * SCALE, 70 * SCALE);
              .
              .

arc (145 * SCALE, 100 * SCALE, 94 * SCALE, 70 * SCALE,94.9268 * SCALE,126.774 * SCALE);     
arc (94 * SCALE, 130 * SCALE, 145 * SCALE, 100 * SCALE,94.9268 * SCALE, 73.2256 * SCALE);    
arc (61 * SCALE, 130 * SCALE, 61 * SCALE, 70 * SCALE,8.75 * SCALE, 100 * SCALE);

1st行说,从O(145,100)绘制弧线F(94,70)
第二行说,从L(94,130)到O(145,100)
绘制弧线 第三行说,从k(62,30)绘制弧线到e(62,70),

我试图通过使用第1个4坐标来绘制弧线(但不知道如何使用剩余的2个坐标?)

 QPainterPath path;  // arc from L --->  F 
 path.moveTo(94,70);
 QRect bound1 (44,70,102,60);
 path.arcTo(bound1,90,-180);
        
 QPainterPath path1;  // arc from K ---> E
 path1.moveTo(62,70);
 QRect bound2 (42,70,40,60);
 path1.arcTo(bound2,90,-180);
      
    

我得到了以下输出:

”在此处输入图像描述”

但是,

输入线或门没有附加到 第一弧
我只使用前四个坐标。如何使用剩余的2个坐标绘制弧?

那么如何使用.slib的所有给定的坐标绘制arc
注意:比例在文件开始时定义。

I am trying to generate various gate symbols ( AND,NOT,XNOR,MUX etc) by reading .slib file.
But I faced a problem while reading an arc related co-ordinate from .slib file.

I am not understanding how to use those co-ordinates and draw an arc ?
The format of an arc in .slib file is confusing.

Here is the example:
enter image description here

.slib format for an arc and for line

line (66 * SCALE, 80 * SCALE, 0 * SCALE, 80 * SCALE); 
line (94 * SCALE, 70 * SCALE, 62 * SCALE, 70 * SCALE);
              .
              .

arc (145 * SCALE, 100 * SCALE, 94 * SCALE, 70 * SCALE,94.9268 * SCALE,126.774 * SCALE);     
arc (94 * SCALE, 130 * SCALE, 145 * SCALE, 100 * SCALE,94.9268 * SCALE, 73.2256 * SCALE);    
arc (61 * SCALE, 130 * SCALE, 61 * SCALE, 70 * SCALE,8.75 * SCALE, 100 * SCALE);

1st line says draw an arc from O (145,100) to F(94,70)
2nd line says draw an arc from L(94,130) to O(145,100)
3rd line says draw an arc from K(62,30) to E(62,70)

I tried to draw an arc by using 1st 4 co-ordinates from line ( but do not know how to use remaining 2 co-ordinates ? )

 QPainterPath path;  // arc from L --->  F 
 path.moveTo(94,70);
 QRect bound1 (44,70,102,60);
 path.arcTo(bound1,90,-180);
        
 QPainterPath path1;  // arc from K ---> E
 path1.moveTo(62,70);
 QRect bound2 (42,70,40,60);
 path1.arcTo(bound2,90,-180);
      
    

And I got following output :

enter image description here

But,

Input lines to OR gate are not attached to
1st arc.
I am using only first four co-ordinates. How to use remaining 2 co-ordinates to draw an arc ?

So how to use all given co-ordinates from.slib to draw an arc ?
Note : SCALE is defined at the start of the file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿咻 2025-02-14 08:50:29

看起来前两个坐标对是虚构圆上的两个点,第三对是该圆圈的中心。这些共同描述了一个圆弧部分。为此,我们可以使用arcto,我们构造了qRectf界限圆,即用给定的中心和侧面2*RADIUS

因此,以下内容应该工作:

QPointF from, to; // first and second coordinate pair
QPointF center; // third coordinate pair

// Bounding rectangle is a square around center.
QLineF lineFrom{center, from};
QLineF lineTo{center, to};
qreal radius = lineFrom.length();
QRectF bounding{ center - QPointF{radius, radius}, center + QPointF{radius, radius}};

// Use QLineF to calculate angles wrt horizontal axis.
qreal startAngle = lineFrom.angle();
qreal sweep = lineFrom.angleTo(lineTo);

QPainterPath path;
path.moveTo(from);
path.arcTo(bounding, startAngle, sweep);

It looks like the first two coordinate pairs are two points on an imaginary circle and the third pair is the center of that circle. Together, those describe a circle arc section. For this to work with arcTo, we construct a QRectF bounding the circle, ie with the given center and side 2*radius.

Thus, the following ought to work:

QPointF from, to; // first and second coordinate pair
QPointF center; // third coordinate pair

// Bounding rectangle is a square around center.
QLineF lineFrom{center, from};
QLineF lineTo{center, to};
qreal radius = lineFrom.length();
QRectF bounding{ center - QPointF{radius, radius}, center + QPointF{radius, radius}};

// Use QLineF to calculate angles wrt horizontal axis.
qreal startAngle = lineFrom.angle();
qreal sweep = lineFrom.angleTo(lineTo);

QPainterPath path;
path.moveTo(from);
path.arcTo(bounding, startAngle, sweep);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文