22 #include <qpushbutton.h>
23 #include <qlineedit.h>
24 #include <qcombobox.h>
45 p->
Painter->setPen(QPen(QPen::darkGray,
Pen.width()+5));
47 p->
Painter->setPen(QPen(QPen::white,
Pen.width(),
Pen.style()));
50 p->
Painter->setPen(QPen(QPen::darkRed,2));
78 if(relative) {
cx +=
x;
cy += y; }
79 else {
cx = x-(
x2>>1);
cy = y-(
y2>>1); }
91 Name = QObject::tr(
"Elliptic Arc");
92 BitmapFile = (
char *)
"ellipsearc";
104 n = s.section(
' ',1,1);
106 if(!ok)
return false;
108 n = s.section(
' ',2,2);
110 if(!ok)
return false;
112 n = s.section(
' ',3,3);
114 if(!ok)
return false;
116 n = s.section(
' ',4,4);
118 if(!ok)
return false;
120 n = s.section(
' ',5,5);
121 Angle = n.toInt(&ok);
122 if(!ok)
return false;
124 n = s.section(
' ',6,6);
126 if(!ok)
return false;
128 n = s.section(
' ',7,7);
132 if(!
Pen.color().isValid())
return false;
134 n = s.section(
' ',8,8);
135 Pen.setWidth(n.toInt(&ok));
136 if(!ok)
return false;
138 n = s.section(
' ',9,9);
139 Pen.setStyle((Qt::PenStyle)n.toInt(&ok));
140 if(!ok)
return false;
149 QString::number(
cx) +
" " + QString::number(
cy) +
" " +
150 QString::number(
x2) +
" " + QString::number(
y2) +
" " +
151 QString::number(
Angle) +
" " + QString::number(
ArcLen) +
" " +
152 Pen.color().name() +
" " + QString::number(
Pen.width()) +
" " +
153 QString::number(
Pen.style());
161 QString (
"new Arc (%1, %2, %3, %4, %5, %6, "
162 "QPen (QColor (\"%7\"), %8, %8))").
165 s =
"Arcs.append (" + s +
");";
173 float fCX = float(
cx), fCY = float(
cy);
174 float fX2 = float(
cx+
x2), fY2 = float(
cy+
y2);
177 if(fX < fCX-len)
return false;
178 if(fY < fCY-len)
return false;
179 if(fX > fX2+len)
return false;
180 if(fY > fY2+len)
return false;
183 if(fX < fCX+len)
State = 1;
184 else if(fX <= fX2-len) {
State = -1;
return false; }
185 if(fY < fCY+len)
State |= 2;
186 else if(fY <= fY2-len) {
State = -1;
return false; }
201 case 2:
x2 = x-
cx;
y2 -= y-
cy; cy = y;
203 case 3:
x2 -= x-
cx; cx =
x;
y2 -= y-
cy; cy = y;
216 QPainter *paintScale,
int fx,
int fy,
int gx,
int gy,
217 QPainter *p,
int x,
int y,
bool drawn)
228 paintScale->drawArc(cx, cy,
x2,
y2, 0, 16*360);
231 paintScale->drawArc(cx, cy,
x2,
y2, 0, 16*360);
234 paintScale->drawArc(cx, cy,
x2,
y2, 0, 16*360);
238 paintScale->drawArc(cx, cy,
x2,
y2, 0, 16*360);
239 if(
x2 < 0) { cx +=
x2;
x2 *= -1; }
240 if(
y2 < 0) { cy +=
y2;
y2 *= -1; }
244 double(
y2*(fx - cx-(
x2>>1)))));
246 paintScale->drawArc(cx, cy,
x2,
y2,
Angle, 16*180);
249 paintScale->drawArc(cx, cy,
x2,
y2,
Angle, 16*180);
252 double(
y2*(fx - cx-(
x2>>1)))));
254 paintScale->drawArc(cx, cy,
x2,
y2,
Angle, 16*180);
258 paintScale->drawArc(cx, cy,
x2,
y2,
Angle, 16*180);
261 double(
y2*(fx - cx-(
x2>>1)))));
270 double(
y2*(fx - cx-(
x2>>1)))));
278 p->setPen(Qt::SolidLine);
280 p->drawArc(
x1+13,
y1, 18, 12, 16*45, 16*200);
284 p->drawArc(
x1+13,
y1, 18, 12, 16*45, 16*200);
308 float fX2 = float(
x2)/2.0;
309 float fY2 = float(
y2)/2.0;
310 fX -= float(
cx) + fX2;
311 fY -= float(
cy) + fY2;
314 int(16.0*180.0/
M_PI *
315 atan2(-
double(
x2)*
double(fY),
double(
y2)*
double(fX)));
317 while(Phase < 0) Phase += 16*360;
322 float a1 = fX / (fX2 - w); a1 *= a1;
323 float a2 = fX / (fX2 + w); a2 *= a2;
324 float b1 = fY / (fY2 - w); b1 *=
b1;
325 float b2 = fY / (fY2 + w); b2 *= b2;
327 if(a1+b1 < 1.0)
return false;
328 if(a2+b2 > 1.0)
return false;
373 bool changed =
false;
380 if(d->exec() == QDialog::Rejected) {
385 if(
Pen.color() != d->
ColorButt->paletteBackgroundColor()) {
393 if(
Pen.style() != (Qt::PenStyle)(d->
StyleBox->currentItem()+1)) {
394 Pen.setStyle((Qt::PenStyle)(d->
StyleBox->currentItem()+1));