@@ -105,7 +105,10 @@ void StandardGraphicsGate::paint(QPainter* painter, const QStyleOptionGraphicsIt
105105 }
106106 else
107107 {
108- painter->setPen (QPen (mColor ,12 ));
108+ QPen pathPen (mColor ,mPathWidth );
109+ pathPen.setJoinStyle (Qt::MiterJoin);
110+ pathPen.setMiterLimit (20 );
111+ painter->setPen (pathPen);
109112 painter->setBrush (GraphicsQssAdapter::instance ()->nodeBackgroundColor ());
110113 painter->drawPath (mPath );
111114 }
@@ -135,7 +138,6 @@ void StandardGraphicsGate::paint(QPainter* painter, const QStyleOptionGraphicsIt
135138 sPen .setColor (sTextColor );
136139 painter->setPen (sPen );
137140
138- int yFirstTextline = sColorBarHeight + sPinUpperVerticalSpacing + sPinFontAscent + sBaseline ;
139141
140142 for (const struct GraphicsGatePin & inpPin : mInputPinStruct )
141143 {
@@ -200,12 +202,13 @@ void StandardGraphicsGate::paint(QPainter* painter, const QStyleOptionGraphicsIt
200202
201203void StandardGraphicsGate::paintPin (QPainter* painter, QStyle::State state, const GraphicsGatePin& pin, FocusType focusType)
202204{
203- int yFirstTextline = sColorBarHeight + sPinUpperVerticalSpacing + sPinFontAscent + sBaseline ;
204-
205- float yText = yFirstTextline + pin.index * (sPinFontHeight + sPinInnerVerticalSpacing );
206- float xText = pin.isInput ? sPinOuterHorizontalSpacing : mWidth - sPinOuterHorizontalSpacing - pin.textWidth ;
205+ float xText = pin.isInput ? pin.x : pin.x - pin.textWidth ;
207206
208207 QPen storeCurrentPen = painter->pen ();
208+ QBrush storeCurrentBrush = painter->brush ();
209+
210+ float wbox = pin.textWidth > sPinFontHeight ? pin.textWidth : sPinFontHeight ;
211+ float xbox = pin.isInput ? pin.x : pin.x - wbox;
209212
210213 switch (focusType) {
211214 case PinFocus:
@@ -223,22 +226,27 @@ void StandardGraphicsGate::paintPin(QPainter* painter, QStyle::State state, cons
223226 QColor pinBackground = gContentManager ->getGroupingManagerWidget ()->getModel ()->colorForItem (ItemType::Net, pin.netId );
224227 if (pinBackground.isValid ())
225228 {
226- QBrush storeCurrentBrush = painter->brush ();
227229 painter->setBrush (pinBackground);
228230 painter->setPen (QPen (pinBackground,0 ));
229- float wbox = pin.textWidth > sPinFontHeight ? pin.textWidth : sPinFontHeight ;
230- float xbox = pin.isInput ? sPinOuterHorizontalSpacing : mWidth - sPinOuterHorizontalSpacing - wbox;
231- painter->drawRoundRect (xbox,yText-sPinFontAscent ,wbox,sPinFontHeight ,35 ,35 );
232- painter->setBrush (storeCurrentBrush);
231+ painter->drawRoundRect (xbox,pin.y -sPinFontAscent ,wbox,sPinFontHeight ,35 ,35 );
233232 pinTextColor = legibleColor (pinBackground);
234233 }
235234 }
236235 }
237236 sPen .setColor (pinTextColor);
238237 }
238+
239+ if (mShapeType != StandardShape)
240+ {
241+ painter->setPen (QPen (mColor ,1 ));
242+ painter->setBrush (Qt::NoBrush);
243+ painter->drawRoundRect (xbox,pin.y -sPinFontAscent ,wbox,sPinFontHeight ,35 ,35 );
244+ }
245+
239246 painter->setPen (sPen );
240- painter->drawText (QPointF (xText, yText ), pin.name );
247+ painter->drawText (QPointF (xText, pin. y ), pin.name );
241248 painter->setPen (storeCurrentPen);
249+ painter->setBrush (storeCurrentBrush);
242250}
243251
244252QColor StandardGraphicsGate::legibleColor (const QColor& bgColor)
@@ -271,22 +279,21 @@ QPointF StandardGraphicsGate::endpointPositionByIndex(int index, bool isInput) c
271279void StandardGraphicsGate::format (const bool & adjust_size_to_grid)
272280{
273281 QFontMetricsF pin_fm (sPinFont );
274- qreal max_pin_width = 0 ;
275282
276283 for (auto it = mInputPinStruct .begin (); it != mInputPinStruct .end (); ++it)
277284 {
278285 qreal width = pin_fm.size (0 , it->name ).rwidth ();
279286 it->textWidth = width;
280- if (width > max_pin_width )
281- max_pin_width = width;
287+ if (width > mMaxInputPinWidth )
288+ mMaxInputPinWidth = width;
282289 }
283290
284291 for (auto it = mOutputPinStruct .begin (); it != mOutputPinStruct .end (); ++it)
285292 {
286293 qreal width = pin_fm.size (0 , it->name ).rwidth ();
287294 it->textWidth = width;
288- if (width > max_pin_width )
289- max_pin_width = width;
295+ if (width > mMaxOutputPinWidth )
296+ mMaxOutputPinWidth = width;
290297 }
291298
292299 qreal total_input_pin_height = 0 ;
@@ -312,7 +319,7 @@ void StandardGraphicsGate::format(const bool& adjust_size_to_grid)
312319 }
313320
314321
315- mWidth = max_pin_width * 2 + sPinInnerHorizontalSpacing * 2 + sPinOuterHorizontalSpacing * 2 + mMaxTextWidth ;
322+ mWidth = mMaxInputPinWidth + mMaxOutputPinWidth + sPinInnerHorizontalSpacing * 2 + sPinOuterHorizontalSpacing * 2 + mMaxTextWidth ;
316323 mHeight = std::max (max_pin_height, min_body_height) + sColorBarHeight ;
317324 if (mShapeType == StandardShape)
318325 mHeight = std::max (max_pin_height, min_body_height) + sColorBarHeight ;
@@ -342,22 +349,21 @@ void StandardGraphicsGate::format(const bool& adjust_size_to_grid)
342349 qreal y = sColorBarHeight + sPinUpperVerticalSpacing + sPinFontAscent + sBaseline ;
343350
344351
345- int mLineWidth = 12 ;
346- int x0 = mLineWidth /2 ;
347- int y0 = mLineWidth /2 ;
348- int x1 = mWidth - mLineWidth /2 ;
349- int y1 = mHeight - mLineWidth /2 ;
352+ int x0 = mPathWidth /2 + mMaxInputPinWidth + sPinOuterHorizontalSpacing ;
353+ int y0 = mPathWidth /2 ;
354+ int x1 = mWidth - mPathWidth /2 ;
355+ int y1 = mHeight - mPathWidth /2 ;
350356
351357 mPath .clear ();
352358 switch (mShapeType )
353359 {
354360 case InverterShape:
355361 {
356362 float top = (y1-y0)/2 .;
357- float diam = top/3 ;
363+ float diam = top/2 ;
358364 mPath .moveTo (x0,y0);
359365 mPath .lineTo (x0+top+diam,y0+top);
360- mPath .arcTo (x0+top+diam,y0+top-diam/2 ,diam,diam,-180 ,360 );
366+ mPath .arcTo (x0+top+diam,y0+top-diam/3 ,diam,diam,-180 ,360 );
361367 mPath .lineTo (x0,y1);
362368 mPath .closeSubpath ();
363369 break ;
@@ -383,13 +389,42 @@ void StandardGraphicsGate::format(const bool& adjust_size_to_grid)
383389 mPath .arcTo (x1-x60deg-diam/2 ,y0,diam,diam,90 ,-60 );
384390 mPath .arcTo (x1-x60deg-diam/2 ,y1-diam,diam,diam,-30 ,-60 );
385391 mPath .lineTo (x0,y1);
386- mPath .arcTo (x0-x60deg-diam/2 ,y0-diam/4 ,diam,diam,-30 ,60 );
392+ mPath .lineTo (x0+mPathWidth /4 ,y1-mPathWidth /2 ); // line in arc direction for pointy corner
393+ double arcSpan = sin ((diam/2 -mPathWidth )/diam)*180 ./M_PI;
394+ mPath .arcTo (x0-x60deg-diam/2 ,y0-diam/4 ,diam,diam,-arcSpan,2 *arcSpan);
395+ mPath .closeSubpath ();
387396 break ;
388397 }
389398
390399 default :
391400 break ;
392401 }
393402
403+ setPinPosition ();
404+ }
405+
406+ void StandardGraphicsGate::setPinPosition ()
407+ {
408+ int yFirstTextline = sColorBarHeight + sPinUpperVerticalSpacing + sPinFontAscent + sBaseline ;
409+
410+ for (auto it = mInputPinStruct .begin (); it != mInputPinStruct .end (); ++it)
411+ {
412+ it->x = sPinOuterHorizontalSpacing ;
413+ it->y = yFirstTextline + it->index * (sPinFontHeight + sPinInnerVerticalSpacing );
414+ }
415+
416+ if (mShapeType != StandardShape && mOutputPinStruct .size () == 1 )
417+ {
418+ mOutputPinStruct [0 ].x = mShapeType == InverterShape ? mWidth + mPathWidth /2 : mWidth - mPathWidth ;
419+ mOutputPinStruct [0 ].y = (mHeight + sPinFontAscent ) / 2 ;
420+ }
421+ else
422+ {
423+ for (auto it = mOutputPinStruct .begin (); it != mOutputPinStruct .end (); ++it)
424+ {
425+ it->x = mWidth - sPinOuterHorizontalSpacing ;
426+ it->y = yFirstTextline + it->index * (sPinFontHeight + sPinInnerVerticalSpacing );
427+ }
428+ }
394429}
395430}
0 commit comments