Bug 93593 - Y-axes not aligned when printing
Summary: Y-axes not aligned when printing
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-19 19:38 UTC by Andrew Walker
Modified: 2004-12-10 08:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Whoa, wrong bug! (9.07 KB, image/png)
2004-12-09 18:22 UTC, Matthew Truch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2004-11-19 19:38:31 UTC
Version:           0.99(devel) (using KDE KDE 3.2.1)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:

When printing a window with multiple plots the y-axes are not aligned.

STEPS TO REPRODUCE:

Create a window with 9 plots in it (on a 3x3 grid). Ensure that the y-axes labels are of varying lengths from plot to plot. Notice that on the screen the y-axes of plots in the same column are all aligned. Now print the window and notice that the y-axes are not aligned on the printed page.
Comment 1 Matthew Truch 2004-12-09 18:22:52 UTC
Created attachment 8591 [details]
Whoa, wrong bug!

Image of above case (with a curve exactly equal to 14).  Note how the curve is
above the tickmark.
Comment 2 Matthew Truch 2004-12-09 18:27:18 UTC
Comment #1 (and it's attachment) are for the wrong bug (bug 93548).  Whoops!
Comment 3 Andrew Walker 2004-12-10 08:56:02 UTC
CVS commit by arwalker: 

Make the axes alignment work for printing and export as well as on-screen.

CCMAIL: 93593-done@bugs.kde.org


  M +7 -8      kst2dplot.cpp   1.308
  M +1 -1      kst2dplot.h   1.128
  M +4 -3      ksttoplevelview.cpp   1.83
  M +1 -1      ksttoplevelview.h   1.49
  M +4 -1      kstviewobject.cpp   1.101
  M +1 -1      kstviewobject.h   1.83


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.307:1.308
@@ -1665,18 +1665,21 @@ void Kst2DPlot::genAxisTickLabels(QPaint
 
 
-void Kst2DPlot::internalAlignment(QRect& plotRegion) {
-  _buffer.buffer().resize(size());
-  assert(!_buffer.buffer().isNull());
-  QPainter p(&_buffer.buffer());
+void Kst2DPlot::internalAlignment(KstPaintType type, QPainter& p, QRect& plotRegion) {
+  Q_UNUSED(type);
+
   TickParameters tpx;
   TickParameters tpy;
+  QRect rectWindow;
   double x_min, x_max, y_min, y_max;
   double xleft_bdr_px, xright_bdr_px, ytop_bdr_px, ybot_bdr_px;
   bool offsetX, offsetY;
 
+  rectWindow = p.window();
+  p.setWindow(0, 0, size().width(), size().height());
   updateScale();
   getLScale(x_min, y_min, x_max, y_max);
   setBorders(xleft_bdr_px, xright_bdr_px, ytop_bdr_px, ybot_bdr_px,
              tpx, tpy, p, offsetX, offsetY);
+  p.setWindow(rectWindow);
 
   plotRegion.setLeft( d2i(xleft_bdr_px) );
@@ -1968,8 +1971,4 @@ void Kst2DPlot::draw() {
 
 void Kst2DPlot::draw(QPainter &p, KstPaintType type, double resolutionEnhancement) {
-  //
-  // draws to the buffer
-  //
-
   if (_zoomPaused) {
     return;

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.127:1.128
@@ -95,5 +95,5 @@ public:
 
   void drawDotAt(QPainter& p, double x, double y, KstBaseCurvePtr curve);
-  void internalAlignment(QRect& plotRegion);
+  void internalAlignment(KstPaintType type, QPainter& p, QRect& plotRegion);
   void addCurve(KstBaseCurvePtr curve);
   void addLabel(KstLabel* label);

--- kdeextragear-2/kst/kst/ksttoplevelview.cpp  #1.82:1.83
@@ -82,6 +82,7 @@ void KstTopLevelView::save(QTextStream& 
 void KstTopLevelView::paint(KstPaintType type, QPainter& p) {
   if (type != P_PRINT && type != P_EXPORT) {
-    updateAlignment();
+    updateAlignment(type, p);
   } else {
+    updateAlignment(type, p);
     p.fillRect(geometry(), QBrush(KstSettings::globalSettings()->backgroundColor, SolidPattern));
   }
@@ -96,10 +97,10 @@ void KstTopLevelView::resized(const QSiz
 }
 
-void KstTopLevelView::updateAlignment() {
+void KstTopLevelView::updateAlignment(KstPaintType type, QPainter& p) {
   QRect plotRegion;
 
   KST::alignment.reset();  
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
-    (*i)->internalAlignment(plotRegion);
+    (*i)->internalAlignment(type, p, plotRegion);
     KST::alignment.setPosition((*i)->geometry(), plotRegion);
   }

--- kdeextragear-2/kst/kst/ksttoplevelview.h  #1.48:1.49
@@ -43,5 +43,5 @@ class KstTopLevelView : public KstViewOb
     virtual void paint(KstPaintType type, QPainter& p);
 
-    void updateAlignment();
+    void updateAlignment(KstPaintType type, QPainter& p);
     void paint(KstPaintType type);
 

--- kdeextragear-2/kst/kst/kstviewobject.cpp  #1.100:1.101
@@ -382,5 +382,8 @@ QSize KstViewObject::size() const {
 
 
-void KstViewObject::internalAlignment(QRect& plotRegion) {
+void KstViewObject::internalAlignment(KstPaintType type, QPainter& p, QRect& plotRegion) {
+  Q_UNUSED(type);
+  Q_UNUSED(p);
+
   plotRegion.setLeft(0);
   plotRegion.setRight(0);

--- kdeextragear-2/kst/kst/kstviewobject.h  #1.82:1.83
@@ -81,5 +81,5 @@ class KstViewObject : public KstObject {
     virtual void resizeFromAspect(double x, double y, double w, double h);
     virtual QSize size() const;
-    virtual void internalAlignment(QRect& plotRegion);
+    virtual void internalAlignment(KstPaintType type, QPainter& p, QRect& plotRegion);
     virtual QPoint position() const;
     virtual const QRect& geometry() const;