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(
"Rectangle");
98 BitmapFile = (
char *)
"rectangle";
107 Name = QObject::tr(
"filled Rectangle");
108 BitmapFile = (
char *)
"filledrect";
110 if(getNewOne)
return new Rectangle(
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 =
"Rects.append (" + s +
");";
200 QString (
"\"colorfill\" : \"%1\", \"stylefill\" : \"%2\"").
204 QString(
"{\"type\" : \"rectangle\", "
205 "\"x\" : %1, \"y\" : %2, \"w\" : %3, \"h\" : %4, "
206 "\"color\" : \"%5\", \"thick\" : %6, \"style\" : \"%7\", %8},").
217 float fCX = float(
cx), fCY = float(
cy);
218 float fX2 = float(
cx+
x2), fY2 = float(
cy+
y2);
221 if(fX < fCX-len)
return false;
222 if(fY < fCY-len)
return false;
223 if(fX > fX2+len)
return false;
224 if(fY > fY2+len)
return false;
227 if(fX < fCX+len)
State = 1;
228 else if(fX < fX2-len) {
State = -1;
return false; }
229 if(fY < fCY+len)
State |= 2;
230 else if(fY < fY2-len) {
State = -1;
return false; }
243 case 1:
x2 -= x-
cx; cx = x;
y2 = y-
cy;
245 case 2:
x2 = x-
cx;
y2 -= y-
cy; cy = y;
247 case 3:
x2 -= x-
cx; cx = x;
y2 -= y-
cy; cy = y;
260 Schematic *paintScale,
int,
int,
int gx,
int gy,
271 else {
x2 = gx;
y2 = gy; }
318 if(
int(fX) >
cx+
x2)
return false;
319 if(
int(fY) >
cy+
y2)
return false;
320 if(
int(fX) <
cx)
return false;
321 if(
int(fY) <
cy)
return false;
326 float fX2 = float(
x2);
327 float fY2 = float(
y2);
329 if(fX > fX2+w)
return false;
330 if(fY > fY2+w)
return false;
331 if(fX < -w)
return false;
332 if(fY < -w)
return false;
335 if(fX < fX2-w)
if(fX > w)
if(fY < fY2-w)
if(fY > w)
372 bool changed =
false;
383 if(d->exec() == QDialog::Rejected) {
388 if(
Pen.color() != d->
ColorButt->paletteBackgroundColor()) {
396 if(
Pen.style() != (Qt::PenStyle)(d->
StyleBox->currentItem()+1)) {
397 Pen.setStyle((Qt::PenStyle)(d->
StyleBox->currentItem()+1));
void drawResizeRect(int, int)
bool load(const QString &)
Rectangle(bool _filled=false)
static Element * info(QString &, char *&, bool getNewOne=false)
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)
bool resizeTouched(float, float, float)
static Element * info_filled(QString &, char *&, bool getNewOne=false)
void MouseMoving(Schematic *, int, int, int, int, Schematic *, int, int, bool)
void getCenter(int &, int &)
void slotCheckFilled(bool on)
void paintScheme(Schematic *)
void MouseResizeMoving(int, int, Schematic *)
bool getSelected(float, float, float)
void drawRect(int, int, int, int)
Superclass of all schematic drawing elements.
void paint(ViewPainter *)
QPushButton * FillColorButt
QString toBrushString(int)
void setCenter(int, int, bool relative=false)