Skip to content

Commit

Permalink
Merge pull request #879 from wawuwo/remove-schematic-textcorr
Browse files Browse the repository at this point in the history
Remove Schematic::textCorr
  • Loading branch information
ra3xdh authored Jul 31, 2024
2 parents 54fb26b + 5c936ef commit 2d1a86d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
31 changes: 0 additions & 31 deletions qucs/schematic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,37 +1153,6 @@ void Schematic::relativeRotation(int &newX, int &newY, int comX, int comY, int o
newY = -(oldX-comX)+comY;
}

// ---------------------------------------------------
// Correction factor for unproportional font scaling.
float Schematic::textCorr()
{
QFont Font = QucsSettings.font;
Font.setPointSizeF(Scale * float(Font.pointSize()));
// use the screen-compatible metric
QFontMetrics metrics(Font, 0);
// Line spacing is the distance from one base line to the next
// and I think it's obvious that line spacing value somehow depends on
// font size.
// For simplicity let's say that this dependency has the form of
// a coefficient <k>, i.e. line spacing is equal to
// fontSize * k.
//
// Then:
// metrics.lineSpacing = (Scale * QucsSettings.font.pointSize()) * k
//
// And then the value returned here is a fraction:
// Scale
// ———————————————————————————————————————————
// (Scale * QucsSettings.font.pointSize()) * k
//
// Which is equal to one divided by original, n o t - s c a l e d
// lines spacing:
// 1
// —————————————————————————————————
// QucsSettings.font.pointSize() * k
return (Scale / float(metrics.lineSpacing()));
}

void Schematic::updateAllBoundingRect() {
sizeOfAll(UsedX1, UsedY1, UsedX2, UsedY2);
}
Expand Down
1 change: 0 additions & 1 deletion qucs/schematic.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class Schematic : public Q3ScrollView, public QucsDoc {

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);

float textCorr();
bool sizeOfFrame(int&, int&);

/**
Expand Down
3 changes: 1 addition & 2 deletions qucs/schematic_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,6 @@ Element* Schematic::selectElement(float fX, float fY, bool flag, int *index)
Element *pe_1st = 0;
Element *pe_sel = 0;
WireLabel *pl = 0;
float Corr = textCorr(); // for selecting text

// test all nodes and their labels
for(Node *pn = Nodes->last(); pn != 0; pn = Nodes->prev())
Expand Down Expand Up @@ -1178,7 +1177,7 @@ Element* Schematic::selectElement(float fX, float fY, bool flag, int *index)
}
}

Corr = 5.0 / Scale; // size of line select and area for resizing
const double Corr = 5.0 / Scale; // size of line select and area for resizing
// test all diagrams
for(Diagram *pd = Diagrams->last(); pd != 0; pd = Diagrams->prev())
{
Expand Down

0 comments on commit 2d1a86d

Please sign in to comment.