Bug 143805

Summary: Ellipse object does not correctly limit border width
Product: [Applications] kst Reporter: Andrew Walker <arwalker>
Component: generalAssignee: kst
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Proposed patch

Description Andrew Walker 2007-04-03 20:37:41 UTC
Version:           HEAD (using KDE KDE 3.5.1)
OS:                Linux

PROBLEM:

If the border width specified for a border exceeds the minor or major axis of the ellipse then the border will extend outside of the ellipse.

STEPS TO REPRODUCE:

Start Kst
Draw an ellipse
Switch to layout mode
Edit the ellipse and set the Border width to 99
Shrink the ellipse until one of its axes is less than the border width

RESULTS:

The border is drawn outside of the ellipse. If the ellipse is shrunk enough it will look like a box.

EXPECTED RESULTS:

The border is constrained to lie within the ellipse. If the ellipse is shrunk it should always resemble an ellipse.
Comment 1 Andrew Walker 2007-04-05 21:46:30 UTC
Created attachment 20192 [details]
Proposed patch
Comment 2 Andrew Walker 2007-04-12 19:34:51 UTC
SVN commit 653120 by arwalker:

BUG:143805 Limit the border width of an ellipse so it doesn't extend beyond its own edge

 M  +10 -3     kstviewellipse.cpp  


--- branches/work/kst/1.5/kst/src/libkstapp/kstviewellipse.cpp #653119:653120
@@ -95,15 +95,22 @@
     }
   }
 
-  const int bw(_borderWidth * p.lineWidthAdjustmentFactor());
+  const QRect g(geometry());
+  int bw(_borderWidth * p.lineWidthAdjustmentFactor());
+  if (bw > g.width()/2) {
+    bw = g.width()/2;
+  }
+  if (bw > g.height()/2) {
+    bw = g.height()/2;
+  }
   QPen pen(bw > 0 ? _borderColor : _foregroundColor, bw);
   p.setPen(pen);
   if (_transparentFill) {
-    p.setBrush(Qt::NoBrush);  
+    p.setBrush(Qt::NoBrush);
   } else {
     p.setBrush(_foregroundColor);
   }
-  const QRect g(geometry());
+
   p.drawEllipse(g.x() + bw/2, g.y() + bw/2, g.width() - bw, g.height() - bw);
   p.restore();
 }