How to use arc co-ordinates from .slib file to draw an arc in Qt ?
-
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:
.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 :
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.
-
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:
.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 :
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.
-
Hi,
A complete minimal example would be better so people can check things.
-
Seems to be a good answer to this same question posted on StackOverflow
Essentially this:
arc (61 * SCALE, 130 * SCALE, 61 * SCALE, 70 * SCALE,8.75 * SCALE, 100 * SCALE);
reads as, a scaled arc centred on (8.75, 100) from (61,130) to (61, 70).
The two end points are 60.25 units from the centre.
Points H(66,80) and J(66,120) are 60.64 units from the centre, so pretty close to on the arc.