21 #include <QPushButton>
32 Brush = QBrush(Qt::lightGray);
47 p->
Painter->setPen(QPen(Qt::darkGray,
Pen.width()+5));
50 p->
Painter->setPen(QPen(Qt::white,
Pen.width(),
Pen.style()));
51 p->
Painter->setBrush(Qt::NoBrush);
54 p->
Painter->setPen(QPen(Qt::darkRed,2));
64 p->
Painter->setBrush(Qt::NoBrush);
84 if(relative) {
cx += x;
cy += y; }
85 else {
cx = x-(
x2>>1);
cy = y-(
y2>>1); }
97 Name = QObject::tr(
"Ellipse");
98 BitmapFile = (
char *)
"ellipse";
100 if(getNewOne)
return new Ellipse();
107 Name = QObject::tr(
"filled Ellipse");
108 BitmapFile = (
char *)
"filledellipse";
110 if(getNewOne)
return new Ellipse(
true);
120 n = s.section(
' ',1,1);
122 if(!ok)
return false;
124 n = s.section(
' ',2,2);
126 if(!ok)
return false;
128 n = s.section(
' ',3,3);
130 if(!ok)
return false;
132 n = s.section(
' ',4,4);
134 if(!ok)
return false;
136 n = s.section(
' ',5,5);
140 if(!
Pen.color().isValid())
return false;
142 n = s.section(
' ',6,6);
143 Pen.setWidth(n.toInt(&ok));
144 if(!ok)
return false;
146 n = s.section(
' ',7,7);
147 Pen.setStyle((Qt::PenStyle)n.toInt(&ok));
148 if(!ok)
return false;
150 n = s.section(
' ',8,8);
153 if(!
Brush.color().isValid())
return false;
155 n = s.section(
' ',9,9);
156 Brush.setStyle((Qt::BrushStyle)n.toInt(&ok));
157 if(!ok)
return false;
159 n = s.section(
' ',10,10);
160 if(n.toInt(&ok) == 0)
filled =
false;
162 if(!ok)
return false;
171 QString::number(
cx) +
" " + QString::number(
cy) +
" " +
172 QString::number(
x2) +
" " + QString::number(
y2) +
" " +
173 Pen.color().name() +
" " + QString::number(
Pen.width()) +
" " +
174 QString::number(
Pen.style()) +
" " +
175 Brush.color().name() +
" " + QString::number(
Brush.style());
185 QString (
", QBrush (QColor (\"%1\"), %2)").
188 QString (
"new Area (%1, %2, %3, %4, "
189 "QPen (QColor (\"%5\"), %6, %7)%8)").
193 s =
"Ellips.append (" + s +
");";
200 QString (
"\"colorfill\" : \"%1\", \"stylefill\" : \"%2\"").
203 QString(
"{\"type\" : \"ellipse\", "
204 "\"x\" : %1, \"y\" : %2, \"w\" : %3, \"h\" : %4,"
205 "\"color\" : \"%5\", \"thick\" : %6, \"style\" : \"%7\", %8},").
216 float fCX = float(
cx), fCY = float(
cy);
217 float fX2 = float(
cx+
x2), fY2 = float(
cy+
y2);
220 if(fX < fCX-len)
return false;
221 if(fY < fCY-len)
return false;
222 if(fX > fX2+len)
return false;
223 if(fY > fY2+len)
return false;
226 if(fX < fCX+len)
State = 1;
227 else if(fX <= fX2-len) {
State = -1;
return false; }
228 if(fY < fCY+len)
State |= 2;
229 else if(fY <= fY2-len) {
State = -1;
return false; }
242 case 1:
x2 -= x-
cx; cx = x;
y2 = y-
cy;
244 case 2:
x2 = x-
cx;
y2 -= y-
cy; cy = y;
246 case 3:
x2 -= x-
cx; cx = x;
y2 -= y-
cy; cy = y;
259 Schematic *paintScale,
int,
int,
int gx,
int gy,
271 else {
x2 = gx;
y2 = gy; }
315 float fX2 = float(
x2);
316 float fY2 = float(
y2);
317 fX -= float(
cx) + fX2/2.0;
318 fY -= float(
cy) + fY2/2.0;
321 float a = 2.0 * fX / fX2; a *= a;
322 float b = 2.0 * fY / fY2; b *= b;
328 float a1 = fX / (fX2/2.0 - w); a1 *= a1;
329 float a2 = fX / (fX2/2.0 + w); a2 *= a2;
330 float b1 = fY / (fY2/2.0 - w); b1 *= b1;
331 float b2 = fY / (fY2/2.0 + w); b2 *= b2;
333 if(a1+b1 < 1.0)
return false;
334 if(a2+b2 > 1.0)
return false;
370 bool changed =
false;
381 if(d->exec() == QDialog::Rejected) {
386 if(
Pen.color() != d->
ColorButt->paletteBackgroundColor()) {
394 if(
Pen.style() != (Qt::PenStyle)(d->
StyleBox->currentItem()+1)) {
395 Pen.setStyle((Qt::PenStyle)(d->
StyleBox->currentItem()+1));
bool resizeTouched(float, float, float)
void drawResizeRect(int, int)
void MouseResizeMoving(int, int, Schematic *)
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_filled(QString &, char *&, bool getNewOne=false)
void setCenter(int, int, bool relative=false)
void getCenter(int &, int &)
void MouseMoving(Schematic *, int, int, int, int, Schematic *, int, int, bool)
void paintScheme(Schematic *)
void slotCheckFilled(bool on)
Superclass of all schematic drawing elements.
QPushButton * FillColorButt
static Element * info(QString &, char *&, bool getNewOne=false)
void paint(ViewPainter *)
bool getSelected(float, float, float)
bool load(const QString &)
Ellipse(bool _filled=false)
QString toBrushString(int)
void drawEllipse(int, int, int, int)