]> Shamusworld >> Repos - architektonas/blobdiff - src/drawingview.cpp
Fix for Print Preview for centering of drawing on page.
[architektonas] / src / drawingview.cpp
index 5b0eeeef6b214c5d4ef4b67f8f87b6af9c2c195c..911ca677dd3b4269bde8f864038faba0ef518120 100644 (file)
@@ -121,10 +121,7 @@ scaled the same way as the arrowheads.
 Need a way to scale line widths as well. :-/ Shouldn't be too difficult, just
 need a thickness parameter similar to the "size" param for dimensions. (And now
 we do! :-)
-
 */
-//     gridPixels = 12; //tmp???
-//     SetGridSize(12.0);      // This is in pixels
 }
 
 void DrawingView::DrawBackground(Painter * painter)
@@ -187,182 +184,6 @@ void DrawingView::DrawSubGrid(Painter * painter, uint32_t color, double step, Ve
                painter->DrawHLine(start.y + i);
 }
 
-#if 0
-void DrawingView::SetGridSize(uint32_t size)
-{
-#if 0
-       // Sanity check
-       if (size == gridPixels)
-               return;
-
-       // tmp...
-       if (size <= 1)
-               return;
-
-       // Recreate the background bitmap
-       gridPixels = size;
-       QPainter pmp(&gridBackground);
-       pmp.fillRect(0, 0, BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE, QColor(240, 240, 240));
-       pmp.setPen(QPen(QColor(210, 210, 255), 2.0, Qt::SolidLine));
-
-       for(int i=0; i<(BACKGROUND_MAX_SIZE-1); i+=gridPixels)
-       {
-               pmp.drawLine(i, 0, i, BACKGROUND_MAX_SIZE - 1);
-               pmp.drawLine(0, i, BACKGROUND_MAX_SIZE - 1, i);
-       }
-
-       pmp.end();
-
-       // Set up new BG brush & zoom level (pixels per base unit)
-// This shouldn't be done here, because it fucks up the scrollwheel zooming...
-//     Global::zoom = gridPixels / Global::gridSpacing;
-       UpdateGridBackground();
-#endif
-}
-
-void DrawingView::UpdateGridBackground(void)
-{
-#if 0
-       // Transform the origin to Qt coordinates
-       Vector pixmapOrigin = Painter::CartesianToQtCoords(Vector());
-       int x = (int)pixmapOrigin.x;
-       int y = (int)pixmapOrigin.y;
-       // Use mod arithmetic to grab the correct swatch of background
-/*
-Negative numbers still screw it up... Need to think about what we're
-trying to do here. The fact that it worked with 72 seems to have been pure luck.
-It seems the problem is negative numbers: We can't let that happen.
-When taking away the zero, it pops over 1 px at zero, then goes about 1/2 a
-grid at x<0.
-
-The bitmap looks like this:
-
-+---+---+---+---+---
-|   |   |   |   |
-|   |   |   |   |
-+---+---+---+---+---
-|   |   |   |   |
-|   |   |   |   |
-|   |   |   |   |
-
-@ x = 1, we want it to look like:
-
--+---+---+---+---+---
- |   |   |   |   |
- |   |   |   |   |
--+---+---+---+---+---
- |   |   |   |   |
- |   |   |   |   |
- |   |   |   |   |
-
-Which means we need to grab the sample from x = 3. @ x = -1:
-
----+---+---+---+---
-   |   |   |   |
-   |   |   |   |
----+---+---+---+---
-   |   |   |   |
-   |   |   |   |
-   |   |   |   |
-
-Which means we need to grab the sample from x = 1. Which means we have to take
-the mirror of the modulus of gridPixels.
-
-Doing a mod of a negative number is problematic: 1st, the compiler converts the
-negative number to an unsigned int, then it does the mod. Gets you wrong answers
-most of the time, unless you use a power of 2. :-P So what we do here is just
-take the modulus of the negation, which means we don't have to worry about
-mirroring it later.
-
-The positive case looks gruesome (and it is) but it boils down to this: We take
-the modulus of the X coordinate, then mirror it by subtraction from the
-maximum (in this case, gridPixels). This gives us a number in the range of 1 to
-gridPixels. But we need the case where the result equalling gridPixels to be
-zero; so we do another modulus operation on the result to achieve this.
-*/
-       if (x < 0)
-               x = -x % gridPixels;
-       else
-               x = (gridPixels - (x % gridPixels)) % gridPixels;
-
-       if (y < 0)
-               y = -y % gridPixels;
-       else
-               y = (gridPixels - (y % gridPixels)) % gridPixels;
-
-       // Here we grab a section of the bigger pixmap, so that the background
-       // *looks* like it's scrolling...
-       QPixmap pm = gridBackground.copy(x, y, gridPixels, gridPixels);
-       QPalette pal = palette();
-       pal.setBrush(backgroundRole(), QBrush(pm));
-       setAutoFillBackground(true);
-       setPalette(pal);
-#endif
-}
-
-void DrawingView::SetGridSize(double size)
-{
-#if 0
-       // Sanity check
-       if (size == gridPixelsF)
-               return;
-
-       // tmp...
-       if (size <= 1)
-               return;
-
-       // Recreate the background bitmap
-       gridPixelsF = size;
-       QPainter pmp(&gridBackground);
-       pmp.fillRect(0, 0, BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE, QColor(240, 240, 240));
-       pmp.setPen(QPen(QColor(210, 210, 255), 2.0, Qt::SolidLine));
-
-       for(double i=0; i<(BACKGROUND_MAX_SIZE-1); i+=gridPixelsF)
-       {
-               pmp.drawLine(i, 0, i, (double)(BACKGROUND_MAX_SIZE - 1));
-               pmp.drawLine(0, i, (double)(BACKGROUND_MAX_SIZE - 1), i);
-       }
-
-       pmp.end();
-
-       // Set up new BG brush & zoom level (pixels per base unit)
-// This shouldn't be done here, because it fucks up the scrollwheel zooming...
-//     Global::zoom = gridPixels / Global::gridSpacing;
-       UpdateGridBackgroundF();
-#endif
-}
-
-
-void DrawingView::UpdateGridBackgroundF(void)
-{
-#if 0
-       // Transform the origin to Qt coordinates
-       Vector pixmapOrigin = Painter::CartesianToQtCoords(Vector());
-       int x = 0;// (int)pixmapOrigin.x;
-       int y = 0;// (int)pixmapOrigin.y;
-       // Use mod arithmetic to grab the correct swatch of background
-
-/*     if (x < 0)
-               x = -x % gridPixels;
-       else
-               x = (gridPixels - (x % gridPixels)) % gridPixels;
-
-       if (y < 0)
-               y = -y % gridPixels;
-       else
-               y = (gridPixels - (y % gridPixels)) % gridPixels;*/
-
-       // Here we grab a section of the bigger pixmap, so that the background
-       // *looks* like it's scrolling...
-       QPixmap pm = gridBackground.copy(x, y, gridPixelsF, gridPixelsF);
-       QPalette pal = palette();
-       pal.setBrush(backgroundRole(), QBrush(pm));
-       setAutoFillBackground(true);
-       setPalette(pal);
-#endif
-}
-#endif
-
 //
 // Basically, we just make a single pass through the Container. If the layer #
 // is less than the layer # being deleted, then do nothing. If the layer # is
@@ -934,7 +755,6 @@ VPVector DrawingView::GetHovered(void)
 void DrawingView::resizeEvent(QResizeEvent * /*event*/)
 {
        Global::screenSize = Vector(size().width(), size().height());
-//     UpdateGridBackground();
 }
 
 void DrawingView::ToolHandler(int mode, Point p)