]> Shamusworld >> Repos - architektonas/blobdiff - src/line.cpp
Readded click to add dimension to object (for Line).
[architektonas] / src / line.cpp
index 8fc9b9c83f3e764940dc07dece9a67457f73a3cb..efd92e50900088804ef25b9ee6eed570ea8a7f4e 100644 (file)
@@ -106,21 +106,7 @@ Line::~Line()
 
                QString text = QObject::tr("Length: %1 in.\n") + QChar(0x2221) + QObject::tr(": %2");
                text = text.arg(absLength).arg(absAngle);
-#if 0
-               QPen pen = QPen(QColor(0x00, 0xFF, 0x00), 1.0, Qt::SolidLine);
-               painter->SetPen(pen);
-               painter->SetBrush(QBrush(QColor(0x40, 0xFF, 0x40, 0x9F)));
-               QRectF textRect(10.0, 10.0, 270.0, 70.0);       // x, y, w, h (in Qt coords)
-               painter->DrawRoundedRect(textRect, 7.0, 7.0);
-
-               textRect.setLeft(textRect.left() + 14);
-               painter->SetFont(*Object::font);
-               pen = QPen(QColor(0x00, 0x5F, 0xDF));
-               painter->SetPen(pen);
-               painter->DrawText(textRect, Qt::AlignVCenter, text);
-#else
                painter->DrawInformativeText(text);
-#endif
        }
 }
 
@@ -137,14 +123,16 @@ Line::~Line()
 what we can do here is set ignoreClicks to true to keep other objects that are
 selected from deselecting themselves. Will that fuck up something else? Not sure
 yet... :-/
+Actually, this is done here to keep tools from selecting stuff inadvertantly...
 */
-       // Someone told us to fuck off, so we'll fuck off. :-)
-       if (ignoreClicks)
-               return false;
-
        // We can assume this, since this is a mouse down event here.
        objectWasDragged = false;
-       HitTest(point);
+       bool hit = HitTest(point);
+
+       // Someone told us to fuck off, so we'll fuck off. :-)
+       if (ignoreClicks)
+//             return false;
+               return hit;
 
        // Now that we've done our hit testing on the non-snapped point, snap it if
        // necessary...
@@ -637,23 +625,25 @@ same reference number.
 void Line::SetDimensionOnLine(Dimension * dimension/*= NULL*/)
 {
        // If they don't pass one in, create it for the caller.
-       if (dimension == NULL)
+       // But ONLY if this line has a parent container!
+       // This is really bad to do here, it should be done in the parent container, always!
+#warning "!!! Parent container should be creating Dimension object !!!"
+       if ((dimension == NULL) && (parent != NULL))
        {
 //printf("Line::SetDimensionOnLine(): Creating new dimension...\n");
-//             dimension = new Dimension(position, endpoint, DTLinear, this);
-               dimension = new Dimension(Connection(this, 0), Connection(this, 1.0), DTLinear, this);
+               dimension = new Dimension(position, endpoint, DTLinear, parent);
+//             dimension = new Dimension(Connection(this, 0), Connection(this, 1.0), DTLinear, this);
 
-               if (parent)
+               // THIS IS SERIOUS!!! WITHOUT A PARENT, THIS OBJECT IS IN LIMBO!!!
+//             if (parent)
 //{
 //printf("Line::SetDimensionOnLine(): Adding to parent...\n");
-                       parent->Add(dimension);
+               parent->Add(dimension);
 //}
        }
-       else
-       {
-               dimension->Connect(this, 0);
-               dimension->Connect(this, 1.0);
-       }
+
+       dimension->Connect(this, 0);
+       dimension->Connect(this, 1.0);
 
        // Make sure the Dimension is connected to us...
        Connect(dimension, 0);