]> Shamusworld >> Repos - architektonas/blobdiff - src/drawingview.cpp
Miscellaneous fixes/updates:
[architektonas] / src / drawingview.cpp
index ca352c2cb7c8de575b6a59b2e3f250d609f89f27..9acf00cd7e29fb1878b4c9c04a9c7d856c3fe68a 100644 (file)
 #include "global.h"
 #include "mathconstants.h"
 #include "painter.h"
+#include "penwidget.h"
 #include "structs.h"
 #include "utils.h"
 
-
 #define BACKGROUND_MAX_SIZE    512
 
-
 DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
        // The value in the settings file will override this.
        useAntialiasing(true), numHovered(0), shiftDown(false),
        ctrlDown(false), altDown(false),
        gridBackground(BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE),
-       scale(1.0), offsetX(-10), offsetY(-10), document(true),
+       scale(1.0), offsetX(-10), offsetY(-10), supressSelected(false),
+       document(true),
        gridPixels(0), collided(false), scrollDrag(false), hoverPointValid(false),
        hoveringIntersection(false), dragged(NULL), draggingObject(false),
        angleSnap(false), dirty(false)
@@ -60,6 +60,9 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
        setBackgroundRole(QPalette::Base);
        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
+       curMarker = QCursor(QPixmap(":/res/cursor-marker.png"), 1, 18);
+       curDropper = QCursor(QPixmap(":/res/cursor-dropper.png"), 1, 20);
+
        Global::gridSpacing = 12.0;             // In base units (inch is default)
 
        Line * line = new Line(Vector(5, 5), Vector(50, 40), 2.0, 0xFF7F00, LSDash);
@@ -118,13 +121,9 @@ 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)
 {
        Point ul = Painter::QtToCartesianCoords(Vector(0, 0));
@@ -174,7 +173,6 @@ void DrawingView::DrawBackground(Painter * painter)
                painter->DrawHLine(bottomy + i);
 }
 
-
 void DrawingView::DrawSubGrid(Painter * painter, uint32_t color, double step, Vector start, Vector size)
 {
        painter->SetPen(color, 1, 1);
@@ -186,184 +184,6 @@ void DrawingView::DrawSubGrid(Painter * painter, uint32_t color, double step, Ve
                painter->DrawHLine(start.y + i);
 }
 
-
-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
-}
-
-
 //
 // 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
@@ -398,23 +218,28 @@ void DrawingView::DeleteCurrentLayer(int layer)
        update();
 }
 
-
 void DrawingView::HandleLayerToggle(void)
 {
        // A layer's visibility was toggled, so update the screen...
        update();
 }
 
-
 //
 // A layer was moved up or down in the layer list, so we have to swap the
 // document's object's layer numbers in the layers that were swapped.
 //
 void DrawingView::HandleLayerSwap(int layer1, int layer2)
 {
-// !!! FIX !!! This doesn't properly handle container contents...
 //printf("DrawingView: Swapping layers %i and %i.\n", layer1, layer2);
-       for(VPVectorIter i=document.objects.begin(); i!=document.objects.end(); i++)
+       HandleLayerSwap(layer1, layer2, document.objects);
+}
+
+/*
+We can roll this into the main one above, by having the LayerWidget's emit() call sending NULL for the VPVector, which we can test for and set to document.objects to grab the top layer.  Or, keep it a top level call and a recursive call.  Which is worse?  :-P
+*/
+void DrawingView::HandleLayerSwap(int layer1, int layer2, VPVector & v)
+{
+       for(VPVectorIter i=v.begin(); i!=v.end(); i++)
        {
                Object * obj = (Object *)(*i);
 
@@ -422,10 +247,12 @@ void DrawingView::HandleLayerSwap(int layer1, int layer2)
                        obj->layer = layer2;
                else if (obj->layer == layer2)
                        obj->layer = layer1;
+
+               if (obj->type == OTContainer)
+                       HandleLayerSwap(layer1, layer2, ((Container *)obj)->objects);
        }
 }
 
-
 void DrawingView::HandlePenWidth(float width)
 {
        for(VPVectorIter i=select.begin(); i!=select.end(); i++)
@@ -433,8 +260,10 @@ void DrawingView::HandlePenWidth(float width)
                Object * obj = (Object *)(*i);
                obj->thickness = width;
        }
-}
 
+       supressSelected = true;
+       update();
+}
 
 void DrawingView::HandlePenStyle(int style)
 {
@@ -443,8 +272,10 @@ void DrawingView::HandlePenStyle(int style)
                Object * obj = (Object *)(*i);
                obj->style = style;
        }
-}
 
+       supressSelected = true;
+       update();
+}
 
 void DrawingView::HandlePenColor(uint32_t color)
 {
@@ -453,27 +284,43 @@ void DrawingView::HandlePenColor(uint32_t color)
                Object * obj = (Object *)(*i);
                obj->color = color;
        }
-}
 
+       supressSelected = true;
+       update();
+}
 
-void DrawingView::HandlePenStamp(void)
+void DrawingView::HandlePenStamp(QAction * action)
 {
-       VPVector flat = Flatten(select);
+       PenWidget * pw = (PenWidget *)action->parentWidget();
+       pw->dropperAction->setChecked(false);
+       Global::penDropper = false;
+       Global::penStamp = action->isChecked();
 
-       for(VPVectorIter i=flat.begin(); i!=flat.end(); i++)
-       {
-               Object * obj = (Object *)(*i);
-
-               if (obj->type != OTText)
-                       obj->thickness = Global::penWidth;
+       if (Global::penStamp)
+               setCursor(curMarker);
+       else
+               setCursor(Qt::ArrowCursor);
 
-               obj->style = Global::penStyle;
-               obj->color = Global::penColor;
-       }
+       if (Global::penStamp == false)
+               ClearSelected(document.objects);
 
        update();
 }
 
+void DrawingView::HandlePenDropper(QAction * action)
+{
+       PenWidget * pw = (PenWidget *)action->parentWidget();
+       pw->stampAction->setChecked(false);
+       Global::penStamp = false;
+       Global::penDropper = action->isChecked();
+
+       if (Global::penDropper)
+               setCursor(curDropper);
+       else
+               setCursor(Qt::ArrowCursor);
+
+       update();
+}
 
 QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event)
 {
@@ -483,7 +330,6 @@ QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event)
        return QPoint(offsetX + event->x(), offsetY + (size().height() - event->y()));
 }
 
-
 QPoint DrawingView::GetAdjustedClientPosition(int x, int y)
 {
        // VOODOO ALERT (ON Y COMPONENT!!!!) (eh?)
@@ -492,7 +338,6 @@ QPoint DrawingView::GetAdjustedClientPosition(int x, int y)
        return QPoint(-offsetX + x, (size().height() - (-offsetY + y)) * +1.0);
 }
 
-
 void DrawingView::focusOutEvent(QFocusEvent * /*event*/)
 {
 //     printf("DrawingView::focusOutEvent()...\n");
@@ -504,6 +349,16 @@ void DrawingView::focusOutEvent(QFocusEvent * /*event*/)
        setCursor(Qt::ArrowCursor);
 }
 
+void DrawingView::focusInEvent(QFocusEvent * /*event*/)
+{
+       if (Global::penStamp)
+               setCursor(curMarker);
+       else if (Global::penDropper)
+               setCursor(curDropper);
+//FocusOut already set this...
+//     else
+//             setCursor(Qt::ArrowCursor);
+}
 
 void DrawingView::paintEvent(QPaintEvent * /*event*/)
 {
@@ -555,7 +410,6 @@ void DrawingView::paintEvent(QPaintEvent * /*event*/)
                painter.DrawInformativeText(informativeText);
 }
 
-
 //
 // Renders objects in the passed in vector
 //
@@ -585,7 +439,16 @@ void DrawingView::RenderObjects(Painter * painter, VPVector & v, int layer, bool
                        painter->SetPen(obj->color, Global::zoom * scaledThickness, obj->style);
                        painter->SetBrush(obj->color);
 
-                       if (obj->selected || obj->hitObject)
+                       // penStamp supresses object highlighting, so that changes can be seen.
+                       if (supressSelected || Global::penStamp)
+                       {
+                               if (obj->hitObject)
+                               {
+                                       painter->SetPen(Global::penColor, Global::zoom * Global::scale * Global::penWidth, Global::penStyle);
+                                       painter->SetBrush(Global::penColor);
+                               }
+                       }
+                       else if (obj->selected || obj->hitObject)
                                painter->SetPen(0xFF0000, Global::zoom * scaledThickness, LSDash);
                }
 
@@ -823,11 +686,16 @@ Where is the text offset?  It looks like it's drawing in the center, but obvious
                        break;
                }
 
+               case OTPolyline:
+               {
+                       break;
+               }
+
                case OTContainer:
                {
                        // Containers require recursive rendering...
                        Container * c = (Container *)obj;
-printf("About to render container: # objs=%i, layer=%i\n", (*c).objects.size(), layer);
+//printf("About to render container: # objs=%i, layer=%i\n", (*c).objects.size(), layer);
                        RenderObjects(painter, (*c).objects, layer, ignoreLayer);
 
 //printf("Container extents: <%lf, %lf>, <%lf, %lf>\nsize: %i\n", r.l, r.t, r.r, r.b, c->objects.size());
@@ -846,8 +714,9 @@ printf("About to render container: # objs=%i, layer=%i\n", (*c).objects.size(),
                        break;
                }
        }
-}
 
+       supressSelected = false;
+}
 
 //
 // This toggles the selection being hovered (typically, only 1 object)
@@ -862,7 +731,6 @@ void DrawingView::AddHoveredToSelection(void)
        }
 }
 
-
 VPVector DrawingView::GetSelection(void)
 {
        VPVector v;
@@ -876,28 +744,40 @@ VPVector DrawingView::GetSelection(void)
        return v;
 }
 
-
-VPVector DrawingView::GetHovered(void)
+//
+// When testing for hovered intersections, we need to be able to exclude some
+// objects which have funky characteristics or handles; so we allow for that
+// here.
+//
+VPVector DrawingView::GetHovered(bool exclude/*= false*/)
 {
        VPVector v;
 
        for(VPVectorIter i=document.objects.begin(); i!=document.objects.end(); i++)
        {
-               if (((Object *)(*i))->hovered)
+               Object * obj = (Object *)(*i);
+
+               if (obj->hovered)
+               {
+                       if (exclude
+                               && ((obj->type == OTDimension)
+                                       || ((obj->type == OTCircle) && (obj->hitPoint[0] == true))
+                                       || ((obj->type == OTArc) && (obj->hitPoint[0] == true))
+                                       || (draggingObject && (obj == dragged))))
+                               continue;
+
                        v.push_back(*i);
+               }
        }
 
        return v;
 }
 
-
 void DrawingView::resizeEvent(QResizeEvent * /*event*/)
 {
        Global::screenSize = Vector(size().width(), size().height());
-       UpdateGridBackground();
 }
 
-
 void DrawingView::ToolHandler(int mode, Point p)
 {
        // Drop angle snap until it's needed
@@ -923,7 +803,6 @@ void DrawingView::ToolHandler(int mode, Point p)
                ParallelHandler(mode, p);
 }
 
-
 void DrawingView::ToolDraw(Painter * painter)
 {
        if (Global::tool == TTLine)
@@ -1083,12 +962,24 @@ void DrawingView::ToolDraw(Painter * painter)
        }
 }
 
-
 void DrawingView::LineHandler(int mode, Point p)
 {
        switch (mode)
        {
        case ToolMouseDown:
+/*             toolObj[0] = NULL;
+
+               // Check to see if we can do a circle tangent snap
+               if (numHovered == 1)
+               {
+                       VPVector hover = GetHovered();
+                       Object * obj = (Object *)hover[0];
+
+                       // Save for later if the object clicked was a circle (need to check that it wasn't the center clicked on, because that will fuck up connecting centers of circles with lines... and now we do! :-)
+                       if ((obj->type == OTCircle) && (obj->hitPoint[0] == false))
+                               toolObj[0] = obj;
+               }*/
+
                if (Global::toolState == TSNone)
                        toolPoint[0] = p;
                else
@@ -1100,7 +991,54 @@ void DrawingView::LineHandler(int mode, Point p)
                if (Global::toolState == TSNone)
                        toolPoint[0] = p;
                else
+               {
                        toolPoint[1] = p;
+/*                     bool isCircle = false;
+
+                       if (numHovered == 1)
+                       {
+                               VPVector hover = GetHovered();
+                               Object * obj = (Object *)hover[0];
+
+                               if ((obj->type == OTCircle) && (obj->hitPoint[0] == false))
+                               {
+                                       isCircle = true;
+                                       toolObj[1] = obj;
+                               }
+                       }
+
+                       // Adjust initial point if it's on a circle (tangent point)
+                       if (toolObj[0] != NULL)
+                       {
+                               if (isCircle)
+                               {
+                                       Geometry::FindTangents(toolObj[0], toolObj[1]);
+
+                                       if (Global::numIntersectPoints > 0)
+                                       {
+                                               toolPoint[0] = Global::intersectPoint[0];
+                                               toolPoint[1] = Global::intersectPoint[1];
+                                       }
+                               }
+                               else
+                               {
+                                       Geometry::FindTangents(toolObj[0], p);
+
+                                       if (Global::numIntersectPoints > 0)
+                                               toolPoint[0] = Global::intersectPoint[0];
+                               }
+                       }
+                       else
+                       {
+                               if (isCircle)
+                               {
+                                       Geometry::FindTangents(toolObj[1], toolPoint[0]);
+
+                                       if (Global::numIntersectPoints > 0)
+                                               toolPoint[1] = Global::intersectPoint[0];
+                               }
+                       }*/
+               }
 
                break;
 
@@ -1127,7 +1065,6 @@ void DrawingView::LineHandler(int mode, Point p)
        }
 }
 
-
 void DrawingView::CircleHandler(int mode, Point p)
 {
        switch (mode)
@@ -1173,7 +1110,6 @@ void DrawingView::CircleHandler(int mode, Point p)
        }
 }
 
-
 void DrawingView::ArcHandler(int mode, Point p)
 {
        switch (mode)
@@ -1251,7 +1187,6 @@ void DrawingView::ArcHandler(int mode, Point p)
        }
 }
 
-
 void DrawingView::RotateHandler(int mode, Point p)
 {
        switch (mode)
@@ -1406,7 +1341,6 @@ void DrawingView::RotateHandler(int mode, Point p)
        }
 }
 
-
 void DrawingView::MirrorHandler(int mode, Point p)
 {
        switch (mode)
@@ -1520,7 +1454,6 @@ N.B.: When mirroring an arc thru a horizontal axis, this causes the arc to have
        }
 }
 
-
 void DrawingView::DimensionHandler(int mode, Point p)
 {
        switch (mode)
@@ -1564,7 +1497,6 @@ void DrawingView::DimensionHandler(int mode, Point p)
        }
 }
 
-
 void DrawingView::TriangulateHandler(int mode, Point/*p*/)
 {
        switch (mode)
@@ -1652,11 +1584,11 @@ void DrawingView::TriangulateHandler(int mode, Point/*p*/)
        }
 }
 
-
 void DrawingView::TrimHandler(int mode, Point p)
 {
 /*
-n.b.: this code is lifted straight out of the old oo code.  needs to be updated.
+N.B.: this code is lifted straight out of the old oo code.  needs to be updated.
+      Also: trim tool should ignore snap.
 */
        switch (mode)
        {
@@ -1793,7 +1725,6 @@ n.b.: this code is lifted straight out of the old oo code.  needs to be updated.
        }
 }
 
-
 void DrawingView::ParallelHandler(int mode, Point /*p*/)
 {
        switch (mode)
@@ -1818,7 +1749,6 @@ void DrawingView::ParallelHandler(int mode, Point /*p*/)
        }
 }
 
-
 void DrawingView::mousePressEvent(QMouseEvent * event)
 {
        if (event->button() == Qt::LeftButton)
@@ -1864,7 +1794,25 @@ void DrawingView::mousePressEvent(QMouseEvent * event)
 //printf("mousePressEvent::numHovered > 0 (hover2[0]=$%llx, type=%s)\n", dragged, objName[dragged->type]);
 
                        // Alert the pen widget
-                       emit ObjectSelected(dragged);
+// Maybe do this with an eyedropper tool on the pen bar?  [YES]
+//                     emit ObjectSelected(dragged);
+                       if (Global::penDropper)
+                       {
+                               Global::penColor = dragged->color;
+                               Global::penWidth = dragged->thickness;
+                               Global::penStyle = dragged->style;
+                               emit ObjectSelected(dragged);
+                               ClearSelected(document.objects);
+                               return;
+                       }
+
+                       if (Global::penStamp)
+                       {
+                               dragged->color = Global::penColor;
+                               dragged->thickness = Global::penWidth;
+                               dragged->style = Global::penStyle;
+                               return;
+                       }
 
                        // See if anything is using just a straight click on a handle
                        if (HandleObjectClicked())
@@ -1917,7 +1865,6 @@ void DrawingView::mousePressEvent(QMouseEvent * event)
        }
 }
 
-
 void DrawingView::mouseMoveEvent(QMouseEvent * event)
 {
        // It seems that wheelEvent() triggers this for some reason...
@@ -1946,7 +1893,7 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event)
                delta.y = -delta.y;
                Global::origin -= delta;
 
-               UpdateGridBackground();
+//             UpdateGridBackground();
                update();
                oldPoint = point;
                return;
@@ -1960,7 +1907,11 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event)
 
                // Make sure previously selected objects stay selected (CTRL held)
                for(VPVectorIter i=select.begin(); i!=select.end(); i++)
-                       ((Object *)(*i))->selected = true;
+               {
+                       // Make sure *not* to select items on hidden layers
+                       if (Global::layerHidden[((Object *)(*i))->layer] == false)
+                               ((Object *)(*i))->selected = true;
+               }
 
                update();
                return;
@@ -1968,7 +1919,7 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event)
 
        // Do object hit testing...
        bool needUpdate = HitTestObjects(point);
-       VPVector hover2 = GetHovered();
+       VPVector hover2 = GetHovered(true); // Exclude dimension objects and circle centers (probably need to add arc centers too) from hover (also dragged objects...)
 #if 0
 {
 if (needUpdate)
@@ -1982,9 +1933,9 @@ if (needUpdate)
 #endif
 
        // Check for multi-hover...
-       if (numHovered > 1)
+       if (hover2.size() > 1)
        {
-//need to check for case where hover is over 2 circles and a 3rd's center...
+//need to check for case where hover is over 2 circles and a 3rd's center (no longer a problem, I think)...
                Object * obj1 = (Object *)hover2[0], * obj2 = (Object *)hover2[1];
 
                Geometry::Intersects(obj1, obj2);
@@ -2023,7 +1974,7 @@ if (needUpdate)
                        intersectionPoint = v1;
                }
        }
-       else if (numHovered == 1)
+       else if (hover2.size() == 1)
        {
                Object * obj = (Object *)hover2[0];
 
@@ -2031,7 +1982,6 @@ if (needUpdate)
                {
 /*
 Not sure that this is the best way to handle this, but it works(TM)...
-Except when lines are overlapping, then it doesn't work... !!! FIX !!!
 */
                        Point midpoint = Geometry::Midpoint((Line *)obj);
                        Vector v1 = Vector::Magnitude(midpoint, point);
@@ -2045,6 +1995,30 @@ Except when lines are overlapping, then it doesn't work... !!! FIX !!!
                                needUpdate = true;
                        }
                }
+               else if (obj->type == OTCircle)
+               {
+                       if ((draggingObject && (dragged->type == OTLine)) && (dragged->hitPoint[0] || dragged->hitPoint[1]))
+                       {
+                               Point p = (dragged->hitPoint[0] ? dragged->p[1] : dragged->p[0]);
+                               Geometry::FindTangents(obj, p);
+
+                               if (Global::numIntersectPoints > 0)
+                               {
+                                       hoveringIntersection = true;
+                                       intersectionPoint = Geometry::NearestTo(point, Global::intersectPoint[0], Global::intersectPoint[1]);
+                               }
+                       }
+                       else if ((Global::tool == TTLine) && (Global::toolState == TSPoint2))
+                       {
+                               Geometry::FindTangents(obj, toolPoint[0]);
+
+                               if (Global::numIntersectPoints > 0)
+                               {
+                                       hoveringIntersection = true;
+                                       intersectionPoint = Geometry::NearestTo(point, Global::intersectPoint[0], Global::intersectPoint[1]);
+                               }
+                       }
+               }
        }
 
        // Handle object movement (left button down & over an object)
@@ -2088,7 +2062,6 @@ Except when lines are overlapping, then it doesn't work... !!! FIX !!!
                update();
 }
 
-
 void DrawingView::mouseReleaseEvent(QMouseEvent * event)
 {
        if (event->button() == Qt::LeftButton)
@@ -2125,11 +2098,19 @@ void DrawingView::mouseReleaseEvent(QMouseEvent * event)
        else if (event->button() == Qt::MiddleButton)
        {
                scrollDrag = false;
-               setCursor(Qt::ArrowCursor);
+
+               if (Global::penStamp)
+                       setCursor(curMarker);
+               else if (Global::penDropper)
+                       setCursor(curDropper);
+               else
+                       setCursor(Qt::ArrowCursor);
+
+               // Need to convert this, since it's in Qt coordinates (for wheelEvent)
+               oldPoint = Painter::QtToCartesianCoords(oldPoint);
        }
 }
 
-
 void DrawingView::wheelEvent(QWheelEvent * event)
 {
        double zoomFactor = 1.20;
@@ -2156,7 +2137,6 @@ void DrawingView::wheelEvent(QWheelEvent * event)
        emit(NeedZoomUpdate());
 }
 
-
 void DrawingView::keyPressEvent(QKeyEvent * event)
 {
        bool oldShift = shiftDown;
@@ -2212,7 +2192,6 @@ void DrawingView::keyPressEvent(QKeyEvent * event)
        }
 }
 
-
 void DrawingView::keyReleaseEvent(QKeyEvent * event)
 {
        bool oldShift = shiftDown;
@@ -2237,11 +2216,16 @@ void DrawingView::keyReleaseEvent(QKeyEvent * event)
        if (oldAlt != altDown)
        {
                scrollDrag = false;
-               setCursor(Qt::ArrowCursor);
+
+               if (Global::penStamp)
+                       setCursor(curMarker);
+               else if (Global::penDropper)
+                       setCursor(curDropper);
+               else
+                       setCursor(Qt::ArrowCursor);
        }
 }
 
-
 //
 // This looks strange, but it's really quite simple: We want a point that's
 // more than half-way to the next grid point to snap there while conversely we
@@ -2261,7 +2245,6 @@ Point DrawingView::SnapPointToGrid(Point point)
        return point;
 }
 
-
 Point DrawingView::SnapPointToAngle(Point point)
 {
        // Snap to a single digit angle (using toolpoint #1 as the center)
@@ -2279,7 +2262,6 @@ Point DrawingView::SnapPointToAngle(Point point)
        return point;
 }
 
-
 Rect DrawingView::GetObjectExtents(Object * obj)
 {
        // Default to empty rect, if object checks below fail for some reason
@@ -2365,7 +2347,6 @@ Rect DrawingView::GetObjectExtents(Object * obj)
        return rect;
 }
 
-
 void DrawingView::CheckObjectBounds(void)
 {
        VPVectorIter i;
@@ -2378,7 +2359,7 @@ void DrawingView::CheckObjectBounds(void)
                switch (obj->type)
                {
                case OTLine:
-               case OTDimension:
+               case OTDimension: // N.B.: We don't check this properly...
                {
                        Line * l = (Line *)obj;
 
@@ -2492,7 +2473,6 @@ void DrawingView::CheckObjectBounds(void)
        }
 }
 
-
 bool DrawingView::HitTestObjects(Point point)
 {
        VPVectorIter i;
@@ -2522,7 +2502,6 @@ bool DrawingView::HitTestObjects(Point point)
        return needUpdate;
 }
 
-
 bool DrawingView::HitTest(Object * obj, Point point)
 {
        bool needUpdate = false;
@@ -2808,7 +2787,6 @@ Well, you could if there was only one object in the Container.  But since there
        return needUpdate;
 }
 
-
 bool DrawingView::HandleObjectClicked(void)
 {
        if (dragged->type == OTDimension)
@@ -2852,7 +2830,6 @@ bool DrawingView::HandleObjectClicked(void)
        return false;
 }
 
-
 void DrawingView::HandleObjectMovement(Point point)
 {
        Point delta = point - oldPoint;
@@ -3028,7 +3005,6 @@ The idea is to make it so whichever point on the object in question is being dra
        }
 }
 
-
 void DrawingView::AddDimensionTo(void * o)
 {
        Object * obj = (Object *)o;
@@ -3048,4 +3024,3 @@ void DrawingView::AddDimensionTo(void * o)
                break;
        }
 }
-