Skip to content

Commit

Permalink
Add "QPainter" version of Node::paint
Browse files Browse the repository at this point in the history
  • Loading branch information
wawuwo committed May 18, 2024
1 parent 794b2d2 commit 4e9e968
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions qucs/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,39 @@ void Node::paint(ViewPainter *p)
}
}

void Node::paint(QPainter* painter) const {
painter->save();

switch(Connections.count()) {
case 1:
if (Label) {
painter->fillRect(cx-2, cy-2, 4, 4, Qt::darkBlue); // open but labeled
} else {
painter->setPen(QPen(Qt::red,1)); // node is open
painter->drawEllipse(cx-4, cy-4, 8, 8);
}
painter->restore();
return;

case 2:
if (Connections.getFirst()->Type == isWire) {
if (Connections.getLast()->Type == isWire) {
painter->restore();
return;
}
painter->fillRect(cx-2, cy-2, 4, 4, Qt::darkBlue);
}
break;

default:
painter->setBrush(Qt::darkBlue); // more than 2 connections
painter->setPen(QPen(Qt::darkBlue,1));
painter->drawEllipse(cx-3, cy-3, 6, 6);
painter->setBrush(Qt::NoBrush);
}
painter->restore();
}

// ----------------------------------------------------------------
bool Node::getSelected(int x_, int y_)
{
Expand Down
1 change: 1 addition & 0 deletions qucs/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Node : public Conductor {
~Node();

void paint(ViewPainter*);
void paint(QPainter* painter) const;
bool getSelected(int, int);
void setName(const QString&, const QString&, int x_=0, int y_=0);

Expand Down

0 comments on commit 4e9e968

Please sign in to comment.