*** empty log message ***

This commit is contained in:
margraf 2004-10-13 19:51:59 +00:00
parent 31232e7414
commit 9919faa72b
25 changed files with 157 additions and 156 deletions

View File

@ -1,3 +1,10 @@
2004-10-13 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
* fixed bug in paint routine of the markers
* new paintGrid routine in QucsDoc (also works with zoom)
* class graphictext works with rotation
* changed the font handling to avoid problems with Qt bug
2004-10-11 Stefan Jahn <stefan@lkcc.org>
* README.translations: Added a brief description about the

View File

@ -23,15 +23,10 @@ AC_Sim::AC_Sim()
{
Description = QObject::tr("ac simulation");
QFontMetrics metrics(QucsSettings.largeFont);
QSize r = metrics.size(0, Description);
int xb = r.width() + 15;
int yb = r.height() + 15;
Texts.append(new Text(0, 0, Description));
x1 = -10; y1 = -9;
x2 = x1+xb+8; y2 = y1+yb+8;
x2 = x1+115; y2 = y1+28;
tx = 0;
ty = y2+1;

View File

@ -145,14 +145,14 @@ bool Component::getSelected(int x_, int y_)
void Component::paint(ViewPainter *p)
{
Text *pt;
int x, y, a, b, Size;
int x, y, a, b, xb, yb; //, Size;
QFont f = p->Painter->font(); // save current font
QFont newFont = f;
if(Model.at(0) == '.') { // is simulation component (dc, ac, ...)
Size = QucsSettings.largeFont.pointSize();
QucsSettings.largeFont.setPointSizeFloat(
float(p->Scale * double(Size)) );
p->Painter->setFont(QucsSettings.largeFont);
newFont.setPointSizeFloat(float(p->Scale) * QucsSettings.largeFontSize);
newFont.setWeight(QFont::DemiBold);
p->Painter->setFont(newFont);
p->map(cx, cy, &x, &y);
p->Painter->setPen(QPen(QPen::darkBlue,2));
@ -163,8 +163,8 @@ void Component::paint(ViewPainter *p)
b +=r.height();
if(a < r.width()) a = r.width();
}
int xb = a + int(12.0*p->Scale);
int yb = b + int(10.0*p->Scale);
xb = a + int(12.0*p->Scale);
yb = b + int(10.0*p->Scale);
x2 = x1+25 + int(double(a) / p->Scale);
y2 = y1+23 + int(double(b) / p->Scale);
ty = y2 + 1;
@ -177,8 +177,6 @@ void Component::paint(ViewPainter *p)
p->Painter->drawLine(x+xb-1, y+yb, a+xb, b+yb);
p->Painter->drawLine(x+xb-1, y+yb, x+xb-1, y);
p->Painter->drawLine(x+xb-1, y, a+xb, b);
QucsSettings.largeFont.setPointSize(Size);
}
else { // normal components go here
@ -194,17 +192,16 @@ void Component::paint(ViewPainter *p)
p->drawArc(cx+p3->x, cy+p3->y, p3->w, p3->h, p3->angle, p3->arclen);
}
newFont.setPointSizeFloat(float(p->Scale) * QucsSettings.smallFontSize);
newFont.setWeight(QFont::Light);
p->Painter->setFont(newFont);
p->Painter->setPen(QPen(QPen::black,1));
Size = QucsSettings.smallFont.pointSize();
QucsSettings.smallFont.setPointSizeFloat(
float(p->Scale * double(Size)) );
p->Painter->setFont(QucsSettings.smallFont);
// write all text
for(pt = Texts.first(); pt != 0; pt = Texts.next()) {
p->map(cx+pt->x, cy+pt->y, &x, &y);
p->Painter->drawText(x, y, pt->s);
}
QucsSettings.smallFont.setPointSize(Size);
}
p->Painter->setFont(f);
@ -406,7 +403,9 @@ void Component::mirrorY()
}
int tmp;
QFontMetrics smallMetrics(QucsSettings.smallFont);
QFont f = QucsSettings.font;
f.setPointSizeFloat(QucsSettings.smallFontSize);
QFontMetrics smallMetrics(f);
// mirror all text
for(Text *pt = Texts.first(); pt != 0; pt = Texts.next()) {
tmp = smallMetrics.width(pt->s); // width of text

View File

@ -23,15 +23,10 @@ DC_Sim::DC_Sim()
{
Description = QObject::tr("dc simulation");
QFontMetrics metrics(QucsSettings.largeFont);
QSize r = metrics.size(0, Description);
int xb = r.width() + 15;
int yb = r.height() + 15;
Texts.append(new Text(0, 0, Description));
x1 = -10; y1 = -9;
x2 = x1+xb+8; y2 = y1+yb+8;
x2 = x1+115; y2 = y1+28;
tx = 0;
ty = y2+1;

View File

@ -23,9 +23,10 @@ Equation::Equation()
{
Description = QObject::tr("equation");
QFontMetrics metrics(QucsSettings.smallFont);
QRect r = metrics.boundingRect(0,0,0,0, Qt::AlignAuto,
QObject::tr("Equation"));
QFont f = QucsSettings.font;
f.setPointSizeFloat(QucsSettings.smallFontSize);
QFontMetrics metrics(f);
QSize r = metrics.size(0, QObject::tr("Equation"));
int xb = r.width() >> 1;
int yb = r.height() >> 1;

View File

@ -26,16 +26,12 @@ HB_Sim::HB_Sim()
QString s = Description;
int a = s.findRev(" ");
if (a != -1) s[a] = '\n'; // break line before the word "simulation"
QFontMetrics metrics(QucsSettings.largeFont);
QSize r = metrics.size(0, s);
int xb = r.width() + 15;
int yb = r.height() + 15;
Texts.append(new Text(0, 0, s.left(a)));
if (a != -1) Texts.append(new Text(0, 0, s.mid(a+1)));
x1 = -10; y1 = -9;
x2 = x1+xb+8; y2 = y1+yb+8;
x2 = x1+150; y2 = y1+46;
tx = 0;
ty = y2+1;

View File

@ -22,11 +22,11 @@ Inductor::Inductor()
{
Description = QObject::tr("inductor");
Arcs.append(new Arc(-17, -6, 13, 13, 0, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc(-18, -6, 13, 13, 0, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( -6, -6, 13, 13, 0, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 5, -6, 13, 13, 0, 16*180,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-30, 0,-17, 0,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 17, 0, 30, 0,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 6, -6, 13, 13, 0, 16*180,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-30, 0,-18, 0,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 18, 0, 30, 0,QPen(QPen::darkBlue,2)));
Ports.append(new Port(-30, 0));
Ports.append(new Port( 30, 0));

View File

@ -179,7 +179,8 @@ Component* MOSFET::info_p(QString& Name, char* &BitmapFile, bool getNewOne)
if(getNewOne) {
MOSFET* p = new MOSFET();
p->Props.getFirst()->Value = "pfet";
p->Props.first()->Value = "pfet";
p->Props.next()->Value = "-1.0 V";
p->recreate();
return p;
}

View File

@ -181,7 +181,8 @@ Component* MOSFET_sub::info_p(QString& Name,
if(getNewOne) {
MOSFET_sub* p = new MOSFET_sub();
p->Props.getFirst()->Value = "pfet";
p->Props.first()->Value = "pfet";
p->Props.next()->Value = "-1.0 V";
p->recreate();
return p;
}

View File

@ -26,16 +26,12 @@ Param_Sweep::Param_Sweep()
QString s = Description;
int a = s.findRev(" ");
if (a != -1) s[a] = '\n'; // break line
QFontMetrics metrics(QucsSettings.largeFont);
QSize r = metrics.size(0, s);
int xb = r.width() + 15;
int yb = r.height() + 15;
Texts.append(new Text(0, 0, s.left(a)));
if (a != -1) Texts.append(new Text(0, 0, s.mid(a+1)));
x1 = -10; y1 = -9;
x2 = x1+xb+8; y2 = y1+yb+8;
x2 = x1+91; y2 = y1+46;
tx = 0;
ty = y2+1;

View File

@ -30,16 +30,12 @@ SP_Sim::SP_Sim()
if (a > (int) s.length() - b) b = a;
}
if (b != -1) s[b] = '\n';
QFontMetrics metrics(QucsSettings.largeFont);
QSize r = metrics.size(0, s);
int xb = r.width() + 15;
int yb = r.height() + 15;
Texts.append(new Text(0, 0, s.left(b)));
if (b != -1) Texts.append(new Text(0, 0, s.mid(b+1)));
x1 = -10; y1 = -9;
x2 = x1+xb+8; y2 = y1+yb+8;
x2 = x1+108; y2 = y1+46;
tx = 0;
ty = y2+1;

View File

@ -26,16 +26,12 @@ TR_Sim::TR_Sim()
QString s = Description;
int a = s.find(" ");
if (a != -1) s[a] = '\n';
QFontMetrics metrics(QucsSettings.largeFont);
QSize r = metrics.size(0, s);
int xb = r.width() + 15;
int yb = r.height() + 15;
Texts.append(new Text(0, 0, s.left(a)));
if (a != -1) Texts.append(new Text(0, 0, s.mid(a+1)));
x1 = -10; y1 = -9;
x2 = x1+xb+8; y2 = y1+yb+8;
x2 = x1+91; y2 = y1+46;
tx = 0;
ty = y2+1;

View File

@ -22,19 +22,19 @@ Transformer::Transformer()
{
Description = QObject::tr("ideal transformer");
Arcs.append(new Arc(-16,-18, 13, 13, 16*270, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc(-16, -6, 13, 13, 16*270, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc(-16, 5, 13, 13, 16*270, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 4,-18, 13, 13, 16*90, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 4, -6, 13, 13, 16*90, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 4, 5, 13, 13, 16*90, 16*180,QPen(QPen::darkBlue,2)));
Arcs.append(new Arc(-16,-18,13,13, 16*270,16*180, QPen(QPen::darkBlue,2)));
Arcs.append(new Arc(-16, -6,13,13, 16*270,16*180, QPen(QPen::darkBlue,2)));
Arcs.append(new Arc(-16, 6,13,13, 16*270,16*180, QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 4,-18,13,13, 16*90,16*180, QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 4, -6,13,13, 16*90,16*180, QPen(QPen::darkBlue,2)));
Arcs.append(new Arc( 4, 6,13,13, 16*90,16*180, QPen(QPen::darkBlue,2)));
Lines.append(new Line(-10,-18,-10,-30,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-10,-30,-30,-30,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 10,-18, 10,-30,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 10,-30, 30,-30,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-10, 17,-10, 30,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-10, 18,-10, 30,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-10, 30,-30, 30,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 10, 17, 10, 30,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 10, 18, 10, 30,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 10, 30, 30, 30,QPen(QPen::darkBlue,2)));
Lines.append(new Line( -1,-20, -1, 20,QPen(QPen::darkBlue,1)));
Lines.append(new Line( 1,-20, 1, 20,QPen(QPen::darkBlue,1)));

View File

@ -285,8 +285,8 @@ void Marker::paint(ViewPainter *p, int x0, int y0)
p->eraseRect(x0+x1, y0+y1, x2, y2);
p->drawText(Text, x0+x1+3, y0+y1+3);
}
p->Painter->setWorldXForm(false);
p->Painter->setWorldMatrix(wm);
p->Painter->setWorldXForm(false);
p->Painter->setPen(QPen(QPen::darkMagenta,0));
p->drawRectD(x0+x1, y0+y1, x2, y2);

View File

@ -36,8 +36,7 @@
tQucsSettings QucsSettings
= {0, 0, 600, 400, // position and size
QFont("Helvetica", 12), QFont("Helvetica", 16, QFont::DemiBold),
QFont("Helvetica", 10, QFont::Light),
QFont("Helvetica", 12), 16.0, 10.0,
QColor(255, 250, 225), 20,
BINARYDIR "qucsedit"};
@ -74,14 +73,9 @@ bool loadSettings()
QucsSettings.font.fromString(Line);
savingFont = QucsSettings.font;
QucsSettings.largeFont = QucsSettings.font;
int i = QucsSettings.font.pointSize(); i += i/3;
QucsSettings.largeFont.setPointSize(i); // large font greater
QucsSettings.largeFont.setWeight(QFont::DemiBold);
QucsSettings.smallFont = QucsSettings.font;
QucsSettings.smallFont.setPointSize(10); // small font 10pt
QucsSettings.smallFont.setWeight(QFont::Light);
QucsSettings.largeFontSize
= floor(4.0/3.0 * QucsSettings.font.pointSize());
QucsSettings.smallFontSize = 10.0;
}
else if(Setting == "BGColor") {
QucsSettings.BGColor.setNamedColor(Line);

View File

@ -32,7 +32,8 @@ class QucsApp;
struct tQucsSettings {
int x, y, dx, dy; // position and size of main window
QFont font, largeFont, smallFont;
QFont font;
float largeFontSize, smallFontSize;
QColor BGColor; // background color of view area
unsigned int maxUndo; // size of undo stack

View File

@ -158,16 +158,16 @@ QString Ellipse::save()
bool Ellipse::ResizeTouched(int x, int y)
{
State = -1;
if(x < cx) return false;
if(y < cy) return false;
if(x > cx+x2) return false;
if(y > cy+y2) return false;
if(x < cx-5) return false;
if(y < cy-5) return false;
if(x > cx+x2+5) return false;
if(y > cy+y2+5) return false;
State = 0;
if(x < cx+10) State = 1;
else if(x <= cx+x2-10) { State = -1; return false; }
if(y < cy+10) State |= 2;
else if(y <= cy+y2-10) { State = -1; return false; }
if(x < cx+5) State = 1;
else if(x <= cx+x2-5) { State = -1; return false; }
if(y < cy+5) State |= 2;
else if(y <= cy+y2-5) { State = -1; return false; }
return true;
}

View File

@ -144,16 +144,16 @@ QString EllipseArc::save()
bool EllipseArc::ResizeTouched(int x, int y)
{
State = -1;
if(x < cx) return false;
if(y < cy) return false;
if(x > cx+x2) return false;
if(y > cy+y2) return false;
if(x < cx-5) return false;
if(y < cy-5) return false;
if(x > cx+x2+5) return false;
if(y > cy+y2+5) return false;
State = 0;
if(x < cx+10) State = 1;
else if(x <= cx+x2-10) { State = -1; return false; }
if(y < cy+10) State |= 2;
else if(y <= cy+y2-10) { State = -1; return false; }
if(x < cx+5) State = 1;
else if(x <= cx+x2-5) { State = -1; return false; }
if(y < cy+5) State |= 2;
else if(y <= cy+y2-5) { State = -1; return false; }
return true;
}

View File

@ -37,7 +37,6 @@ GraphicText::GraphicText()
Color = QColor(0,0,0);
Font = QucsSettings.font;
cx = cy = 0;
cx_d = cy_d = 0.0;
x1 = x2 = 0;
y1 = y2 = 0;
Angle = 0;
@ -51,39 +50,47 @@ GraphicText::~GraphicText()
void GraphicText::paint(ViewPainter *p)
{
QWMatrix wm = p->Painter->worldMatrix();
p->Painter->setWorldMatrix(QWMatrix());
QWMatrix Mat(1.0, 0.0, 0.0, 1.0, p->DX + double(cx) * p->Scale,
p->DY + double(cy) * p->Scale);
p->Painter->setWorldMatrix(Mat);
p->Painter->rotate(-Angle); // automatically enables transformation
int Size = Font.pointSize();
Font.setPointSizeFloat( float(p->Scale * double(Size)) );
Font.setPointSizeFloat( float(p->Scale) * float(Size) );
int x = int(cx_d), y = int(cy_d);
// int x = int(cx_d + wm.dx()), y = int(cy_d + wm.dy());
p->Painter->setPen(Color);
p->Painter->setFont(Font);
x2 = p->drawText(Text, x, y, &y2);
Font.setPointSize(Size);
QRect r;
// Because of a bug in Qt 3.1, drawing this text is dangerous, if it
// contains linefeeds. Qt has problems with linefeeds. It remembers the
// last font metrics (within the font ???) and does not calculate it again.
// The error often appears at a very different drawText function !!!
p->Painter->drawText(0, 0, 0, 0, Qt::DontClip, Text, -1, &r);
x2 = int(double(x2) / p->Scale);
y2 = int(double(y2) / p->Scale);
if(isSelected) {
p->Painter->setPen(QPen(QPen::darkGray,3));
p->drawRect(x-2, y-2, x2+6, y2+5);
p->Painter->drawRect(-3, -2, r.width()+6, r.height()+5);
}
Font.setPointSize(Size); // restore real font size
p->Painter->setWorldMatrix(wm);
p->Painter->setWorldXForm(false);
x2 = int(double(r.width()) / p->Scale);
y2 = int(double(r.height()) / p->Scale);
}
// -----------------------------------------------------------------------
void GraphicText::paintScheme(QPainter *p)
{
p->save();
QWMatrix wm = p->worldMatrix();
QWMatrix Mat (wm.m11(), 0.0, 0.0, wm.m22(),
wm.dx() + double(cx) * wm.m11(),
wm.dy() + double(cy) * wm.m22());
p->setWorldMatrix(Mat);
p->rotate(-Angle);
p->drawRect(0, 0, x2, y2);
p->drawRect(int(cx_d), int(cy_d), x2, y2);
p->restore();
p->setWorldMatrix(wm);
}
// ------------------------------------------------------------------------
@ -99,11 +106,6 @@ void GraphicText::setCenter(int x, int y, bool relative)
{
if(relative) { cx += x; cy += y; }
else { cx = x; cy = y; }
double phi = M_PI/180.0*double(Angle);
double sine = sin(phi), cosine = cos(phi);
cx_d = double(cx)*cosine - double(cy)*sine;
cy_d = double(cy)*cosine + double(cx)*sine;
}
// -----------------------------------------------------------------------
@ -138,8 +140,6 @@ bool GraphicText::load(const QString& s)
Angle = n.toInt(&ok);
if(!ok) return false;
setCenter(cx, cy);
Text = s.mid(s.find('"')+1); // Text
Text = Text.left(Text.length()-1);
if(Text.isEmpty()) return false;
@ -243,7 +243,6 @@ void GraphicText::rotate()
{
Angle += 90;
Angle %= 360;
setCenter(cx, cy);
}
// -----------------------------------------------------------------------
@ -291,7 +290,6 @@ bool GraphicText::Dialog()
Angle = tmp % 360;
changed = true;
}
setCenter(cx, cy);
QString _Text = "";
_Text = d->text->text();

View File

@ -51,7 +51,6 @@ public:
QFont Font;
QString Text;
int Angle;
double cx_d, cy_d; // cx/cy coordinates already rotated
};
#endif

View File

@ -2325,6 +2325,22 @@ Verwendung: qucsedit [-r] Datei
<source>overestimation of local truncation error</source>
<translation>Überschätzung des lokalen Abbruchfehlers</translation>
</message>
<message>
<source>initial phase in degrees</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>relative tolerance of local truncation error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>absolute tolerance of local truncation error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>overestimation of local truncation error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QucsActions</name>

View File

@ -294,37 +294,52 @@ void QucsDoc::setOnGrid(int& x, int& y)
}
// ---------------------------------------------------
void QucsDoc::paintGrid(QPainter *p, int cX, int cY, int Width, int Height)
void QucsDoc::paintGrid(ViewPainter *p, int cX, int cY, int Width, int Height)
{
if(!GridOn) return;
p->setPen(QPen(QPen::black,1));
int dx = -int(Scale*double(ViewX1));
int dy = -int(Scale*double(ViewY1));
p->drawLine(-3+dx, dy, 4+dx, dy); // small cross at origin
p->drawLine( dx,-3+dy, dx, 4+dy);
p->Painter->setPen(QPen(QPen::black,1));
int dx = -int(Scale*double(ViewX1)) - cX;
int dy = -int(Scale*double(ViewY1)) - cY;
p->Painter->drawLine(-3+dx, dy, 4+dx, dy); // small cross at origin
p->Painter->drawLine( dx,-3+dy, dx, 4+dy);
int x1 = int(cX/Scale)+ViewX1;
int x1 = int(cX/Scale) + ViewX1;
int y1 = int(cY/Scale) + ViewY1;
// setOnGrid(x1, y1) for 2*Grid
if(x1<0) x1 -= GridX - 1;
else x1 += GridX;
x1 -= x1 % (GridX << 1);
x1 -= ViewX1; x1 = int(x1*Scale);
int y1 = int(cY/Scale)+ViewY1;
if(y1<0) y1 -= GridY - 1;
else y1 += GridY;
y1 -= y1 % (GridY << 1);
y1 -= ViewY1; y1 = int(y1*Scale);
int x2 = x1+Width, y2 = y1+Height;
dx = int(double(2*GridX)*Scale);
dy = int(double(2*GridY)*Scale);
if(dx < 5) dx = 5; // grid not too dense
if(dy < 5) dy = 5;
double X, Y, Y0;
X = double(x1)*Scale + p->DX;
Y = Y0 = double(y1)*Scale + p->DY;
x1 = X > 0.0 ? int(X + 0.5) : int(X - 0.5);
y1 = Y > 0.0 ? int(Y + 0.5) : int(Y - 0.5);
for(int x=x1; x<x2; x+=dx)
for(int y=y1; y<y2; y+=dy)
p->drawPoint(x,y); // paint grid
int xEnd = x1 + Width;
int yEnd = y1 + Height;
double DX = double(GridX << 1) * Scale; // every second grid a point
double DY = double(GridY << 1) * Scale;
while(x1 < xEnd) {
Y = Y0;
y1 = Y > 0.0 ? int(Y + 0.5) : int(Y - 0.5);
while(y1 < yEnd) {
p->Painter->drawPoint(x1, y1); // paint grid
Y += DY;
y1 = Y > 0.0 ? int(Y + 0.5) : int(Y - 0.5);
}
X += DX;
x1 = X > 0.0 ? int(X + 0.5) : int(X - 0.5);
}
}
// ---------------------------------------------------
@ -1459,7 +1474,7 @@ int QucsDoc::selectElements(int x1, int y1, int x2, int y2, bool flag)
if(pw->Label) {
pl = pw->Label;
if(pl->x1 >= x1) if((pl->x1+pl->x2) <= x2)
if(pl->y1 >= y2) if((pl->y1+pl->y2) <= y1) {
if(pl->y1 >= y1) if((pl->y1+pl->y2) <= y2) {
pl->isSelected = true; z++;
continue;
}

View File

@ -46,7 +46,7 @@ public:
void setChanged(bool, bool fillStack=false, char Op='*');
void paint(ViewPainter*);
void paintGrid(QPainter*, int, int, int, int);
void paintGrid(ViewPainter*, int, int, int, int);
void paintSelected(QPainter*);
int insertWireNode1(Wire*);

View File

@ -74,12 +74,13 @@ QucsView::~QucsView()
void QucsView::drawContents(QPainter *p, int, int, int, int)
{
QucsDoc *d = Docs.current();
d->paintGrid(p, contentsX(), contentsY(), visibleWidth(), visibleHeight());
Painter.init(p, d->Scale, -d->ViewX1, -d->ViewY1);
Painter.DX -= double(contentsX());
Painter.DY -= double(contentsY());
d->paintGrid(&Painter, contentsX(), contentsY(),
visibleWidth(), visibleHeight());
d->paint(&Painter);
// drawn = false;
}
@ -156,12 +157,20 @@ void QucsView::enlargeView(int x1, int y1, int x2, int y2)
if(x2 > d->UsedX2) d->UsedX2 = x2;
if(y2 > d->UsedY2) d->UsedY2 = y2;
if(x1 < d->ViewX1) { dx = d->ViewX1-x1+40; d->ViewX1 = x1-40; }
if(y1 < d->ViewY1) { dy = d->ViewY1-y1+40; d->ViewY1 = y1-40; }
if(x1 < d->ViewX1) {
dx = int(d->Scale * double(d->ViewX1-x1+40));
d->ViewX1 = x1-40;
}
if(y1 < d->ViewY1) {
dy = int(d->Scale * double(d->ViewY1-y1+40));
d->ViewY1 = y1-40;
}
if(x2 > d->ViewX2) d->ViewX2 = x2+40;
if(y2 > d->ViewY2) d->ViewY2 = y2+40;
resizeContents(d->ViewX2-d->ViewX1,d->ViewY2-d->ViewY1);
resizeContents(int(d->Scale*double(d->ViewX2 - d->ViewX1)),
int(d->Scale*double(d->ViewY2 - d->ViewY1)));
// resizeContents(d->ViewX2-d->ViewX1,d->ViewY2-d->ViewY1);
scrollBy(dx,dy);
}
@ -1755,7 +1764,7 @@ void QucsView::contentsWheelEvent(QWheelEvent *Event)
if(delta < 0) Scaling = double(-delta)/60.0/1.1;
else Scaling = 1.1*60.0/double(delta);
Scaling = Zoom(Scaling);
center(int(Event->x()*Scaling), int(Event->y()*Scaling));
// center(Event->x(), Event->y());
viewport()->repaint();
drawn = false;
}

View File

@ -38,12 +38,10 @@ void ViewPainter::init(QPainter *p, double Scale_, int DX_, int DY_)
DY = floor(double(DY_) * Scale);
QFont f = p->font();
f.setPointSizeFloat( float(Scale * double(f.pointSize())) );
f.setPointSizeFloat( float(Scale) * float(f.pointSize()) );
p->setFont(f);
LineSpacing = p->fontMetrics().lineSpacing();
p->setWorldXForm(false); // we use our own coordinate transformation
// Painter->setWorldMatrix(QWMatrix()); // no scaling for original painter
}
// -------------------------------------------------------------
@ -84,18 +82,6 @@ void ViewPainter::drawLine(int x1, int y1, int x2, int y2)
Painter->drawLine(x1, y1, x2, y2);
}
// -------------------------------------------------------------
/*void ViewPainter::drawLineD(int x1, int y1, int dx, int dy)
{
double z;
z = double(x1)*Scale + DX;
x1 = z > 0.0 ? int(z + 0.5) : int(z - 0.5);
z = double(y1)*Scale + DY;
y1 = z > 0.0 ? int(z + 0.5) : int(z - 0.5);
Painter->drawLine(x1, y1, x1+dx, y1+dy);
}
*/
// -------------------------------------------------------------
void ViewPainter::drawRect(int x1, int y1, int dx, int dy)
{