+void DrawingView::SetAddCircleToolActive(bool state/*= true*/)
+{
+ if (state)// && toolAction == NULL)
+ {
+ if (toolAction)
+ delete toolAction;
+
+ addLineTool = false;
+ toolAction = new DrawCircleAction();
+ connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
+ SLOT(AddNewObjectToDocument(Object *)));
+ }
+ else if (!state && addCircleTool && toolAction)
+ {
+ delete toolAction;
+ toolAction = NULL;
+ }
+
+ addCircleTool = state;
+ update();
+//printf("DrawingView::SetAddCircleToolActive(). toolAction=%08X\n", toolAction);
+}
+
+void DrawingView::UpdateGridBackground(void)
+{
+#if 0
+// Shift the background to match our scrolling...
+QBrush newBrush = *backgroundBrush;
+//QMatrix brushMatrix = backgroundBrush->matrix();
+QTransform brushMatrix = backgroundBrush->transform();
+brushMatrix.translate(Painter::origin.x, Painter::origin.y);
+//brushMatrix.translate(15.0, 15.0);
+//backgroundBrush->setMatrix(brushMatrix);
+//backgroundBrush->setTransform(brushMatrix);
+newBrush.setTransform(brushMatrix);
+QPalette pal = palette();
+//pal.setBrush(backgroundRole(), *backgroundBrush);
+pal.setBrush(backgroundRole(), newBrush);
+setPalette(pal);
+//Background painting does not honor the transformation matrix (either one)...
+// So...
+#else
+//was: 128
+#define BG_BRUSH_SPAN 72
+ // 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
+ // Problem with mod 128: Negative numbers screw it up... [FIXED]
+ x = (x < 0 ? 0 : BG_BRUSH_SPAN - 1) - (x % BG_BRUSH_SPAN);
+ y = (y < 0 ? 0 : BG_BRUSH_SPAN - 1) - (y % BG_BRUSH_SPAN);
+
+ // Here we grab a section of the bigger pixmap, so that the background
+ // *looks* like it's scrolling...
+ QPixmap pm = gridBackground.copy(x, y, BG_BRUSH_SPAN, BG_BRUSH_SPAN);
+ QPalette pal = palette();
+ pal.setBrush(backgroundRole(), QBrush(pm));
+ setAutoFillBackground(true);
+ setPalette(pal);
+#endif
+}
+