MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / paint

Method paint

src/openms_gui/source/VISUAL/TOPPASEdge.cpp:133–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 }
132
133 void TOPPASEdge::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
134 {
135 painter->setBrush(Qt::white);
136
137 QPen pen(color_);
138 if (isSelected())
139 {
140 pen.setWidth(3);
141 }
142 else
143 {
144 pen.setWidth(2);
145 }
146
147 TOPPASToolVertex* ttv_source = qobject_cast<TOPPASToolVertex*>(this->getSourceVertex());
148 // when copying parameters (using CTRL); only for incomplete edges drawn from tool nodes
149 if ((QGuiApplication::keyboardModifiers() & Qt::ControlModifier) && !this->to_ && ttv_source)
150 {
151 pen.setColor(Qt::darkMagenta);
152 pen.setWidth(1);
153 }
154
155 painter->setPen(pen);
156
157 // angle of line
158 qreal angle = -QLineF(endPos(), startPos()).angle() + 180; // negate since angle() reports counter-clockwise; +180 since painter.rotate() is more intuitive then
159
160 // draw the actual line
161 QPainterPath path_line(startPos());
162 path_line.lineTo(endPos());
163 painter->drawPath(path_line);
164
165 // print names
166 qreal text_angle = angle;
167 bool invert_text_direction = endPos().x() < startPos().x();
168 if (invert_text_direction)
169 {
170 text_angle += 180;
171 }
172 QPainterPath path_line_short(borderPoint_(false));
173 path_line_short.lineTo(endPos());
174
175 // y offset for printing text; we add -1 to make "_" in param names visible (e.g. in "out_annotation")
176 // otherwise they are too close to the edge itself
177 int y_text = -pen.width() - 1;
178
179 // source name
180 QString str = getSourceOutParamName();
181 if (!str.isEmpty())
182 {
183 painter->save(); // hard to avoid multiple calls to save() and restore() since we first translate and then rotate
184 QPointF point = path_line_short.pointAtPercent(0.05);
185 painter->translate(point);
186 painter->rotate(text_angle);
187 if (invert_text_direction)
188 {
189 QFontMetrics fm(painter->fontMetrics());
190 int text_width=fm.width(str);

Callers 2

paintEventMethod · 0.45
saveAsImageMethod · 0.45

Calls 9

getSourceVertexMethod · 0.95
widthMethod · 0.80
translateMethod · 0.80
drawTextMethod · 0.80
heightMethod · 0.80
QPointClass · 0.50
setWidthMethod · 0.45
setColorMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected