22 #include <QPushButton>
45 p->
Painter->setPen(QPen(Qt::darkGray,
Pen.width()+5));
47 p->
Painter->setPen(QPen(Qt::white,
Pen.width(),
Pen.style()));
50 p->
Painter->setPen(QPen(Qt::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, %9))").
165 s =
"Arcs.append (" + s +
");";
172 QString (
"{\"type\" : \"ellipsearc\", "
173 "\"x\" : %1, \"y\" : %2, \"w\" : %3, \"h\" : %4, "
174 "\"angle\" : %5, \"arclen\" : %6, "
175 "\"color\" : \"%7\", \"thick\" : %8, \"style\" : \"%9\"},").
185 float fCX = float(
cx), fCY = float(
cy);
186 float fX2 = float(
cx+
x2), fY2 = float(
cy+
y2);
189 if(fX < fCX-len)
return false;
190 if(fY < fCY-len)
return false;
191 if(fX > fX2+len)
return false;
192 if(fY > fY2+len)
return false;
195 if(fX < fCX+len)
State = 1;
196 else if(fX <= fX2-len) {
State = -1;
return false; }
197 if(fY < fCY+len)
State |= 2;
198 else if(fY <= fY2-len) {
State = -1;
return false; }
211 case 1:
x2 -= x-
cx; cx = x;
y2 = y-
cy;
213 case 2:
x2 = x-
cx;
y2 -= y-
cy; cy = y;
215 case 3:
x2 -= x-
cx; cx = x;
y2 -= y-
cy; cy = y;
228 Schematic *paintScale,
int fx,
int fy,
int gx,
int gy,
251 if(
x2 < 0) { cx +=
x2;
x2 *= -1; }
252 if(
y2 < 0) { cy +=
y2;
y2 *= -1; }
255 * atan2(
double(
x2*(cy+(
y2>>1) - fy)),
256 double(
y2*(fx - cx-(
x2>>1)))));
263 * atan2(
double(
x2*(cy+(
y2>>1) - fy)),
264 double(
y2*(fx - cx-(
x2>>1)))));
272 * atan2(
double(
x2*(cy+(
y2>>1) - fy)),
273 double(
y2*(fx - cx-(
x2>>1)))));
281 * atan2(
double(
x2*(cy+(
y2>>1) - fy)),
282 double(
y2*(fx - cx-(
x2>>1)))));
320 float fX2 = float(
x2)/2.0;
321 float fY2 = float(
y2)/2.0;
322 fX -= float(
cx) + fX2;
323 fY -= float(
cy) + fY2;
326 int(16.0*180.0/
M_PI *
327 atan2(-
double(
x2)*
double(fY),
double(
y2)*
double(fX)));
329 while(Phase < 0) Phase += 16*360;
334 float a1 = fX / (fX2 - w); a1 *= a1;
335 float a2 = fX / (fX2 + w); a2 *= a2;
336 float b1 = fY / (fY2 - w); b1 *= b1;
337 float b2 = fY / (fY2 + w); b2 *= b2;
339 if(a1+b1 < 1.0)
return false;
340 if(a2+b2 > 1.0)
return false;
385 bool changed =
false;
392 if(d->exec() == QDialog::Rejected) {
397 if(
Pen.color() != d->
ColorButt->paletteBackgroundColor()) {
405 if(
Pen.style() != (Qt::PenStyle)(d->
StyleBox->currentItem()+1)) {
406 Pen.setStyle((Qt::PenStyle)(d->
StyleBox->currentItem()+1));
void drawResizeRect(int, int)
void paint(ViewPainter *)
bool getSelected(float, float, float)
void PostPaintEvent(PE pe, int x1=0, int y1=0, int x2=0, int y2=0, int a=0, int b=0, bool PaintOnViewport=false)
static Element * info(QString &, char *&, bool getNewOne=false)
void MouseMoving(Schematic *, int, int, int, int, Schematic *, int, int, bool)
bool load(const QString &)
Definitions and declarations for the main application.
void getCenter(int &, int &)
void drawArc(int, int, int, int, int, int)
Superclass of all schematic drawing elements.
void MouseResizeMoving(int, int, Schematic *)
void setCenter(int, int, bool relative=false)
bool resizeTouched(float, float, float)
void paintScheme(Schematic *)