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, 260.0, 60.0); // x, y, w, h
+ QRectF textRect(10.0, 10.0, 270.0, 70.0); // x, y, w, h
painter->DrawRoundedRect(textRect, 7.0, 7.0);
textRect.setLeft(textRect.left() + 14);
painter->SetFont(*Object::font);
- pen = QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine);
+// pen = QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine);
+ pen = QPen(QColor(0x00, 0x5F, 0xDF));
painter->SetPen(pen);
painter->DrawText(textRect, Qt::AlignVCenter, text);
+ painter->SetPen(QPen(QColor(0xDF, 0x5F, 0x00)));
}
}
else
/*virtual*/ void Circle::PointerMoved(Vector point)
{
+ if (selectionInProgress)
+ {
+ // Check for whether or not the rect contains this circle
+ if (selection.normalized().contains(Extents()))
+ state = OSSelected;
+ else
+ state = OSInactive;
+
+ return;
+ }
+
// Hit test tells us what we hit (if anything) through boolean variables. It
// also tells us whether or not the state changed.
needUpdate = HitTest(point);
gridSpacing(12.0), collided(false), rotateTool(false), rx(150.0), ry(150.0),
scrollDrag(false), addLineTool(false), addCircleTool(false),
addDimensionTool(false),
- selectionInProgress(false),
+// selectionInProgress(false),
toolAction(NULL)
{
document.isTopLevelContainer = true;
if (toolAction)
toolAction->Draw(&painter);
- if (selectionInProgress)
+ if (Object::selectionInProgress)
{
// painter.SetPen(QPen(Qt::green, 1.0, Qt::SolidLine));
painter.SetPen(QPen(QColor(255, 127, 0, 255)));
// painter.SetBrush(QBrush(Qt::NoBrush));
painter.SetBrush(QBrush(QColor(255, 127, 0, 100)));
- painter.DrawRect(selection);
+ painter.DrawRect(Object::selection);
}
}
// Didn't hit any object and not using a tool, so do a selection rectangle
if (!(collided || toolAction))
{
- selectionInProgress = true;
- selection.setTopLeft(QPointF(point.x, point.y));
- selection.setBottomRight(QPointF(point.x, point.y));
+ Object::selectionInProgress = true;
+ Object::selection.setTopLeft(QPointF(point.x, point.y));
+ Object::selection.setBottomRight(QPointF(point.x, point.y));
}
}
else if (event->button() == Qt::MiddleButton)
void DrawingView::mouseMoveEvent(QMouseEvent * event)
{
Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y()));
- selection.setBottomRight(QPointF(point.x, point.y));
+ Object::selection.setBottomRight(QPointF(point.x, point.y));
if (event->buttons() & Qt::MiddleButton)
{
//changed...
document.PointerMoved(point);
- if (document.NeedsUpdate() || selectionInProgress)
+ if (document.NeedsUpdate() || Object::selectionInProgress)
update();
if (toolAction)
if (toolAction)
toolAction->MouseReleased();
- if (selectionInProgress)
+ if (Object::selectionInProgress)
{
// Select all the stuff inside of selection
- selectionInProgress = false;
+ Object::selectionInProgress = false;
}
}
else if (event->button() == Qt::MiddleButton)
bool addLineTool;
bool addCircleTool;
bool addDimensionTool;
- bool selectionInProgress;
- QRectF selection;
+// bool selectionInProgress;
+// QRectF selection;
public:
Action * toolAction;
oldPoint = point;
needUpdate = true;
+
+//doesn't work QMainWindow::statusBar()->setText("You are manipulating a line");
}
/*
More elegant ways:
- Pass the point in a notification function (how?)
- - Pass the point as a reference to the class instance object (&endpoint). This way, the line
- doesn't have to care about keeping track of Dimensions connected to it. But still have to
- care about other connected entities (other Lines, Circles, Arcs, Splines, Texts, etc). I
- think I'd be OK with this.
- Since the Dimension has a pointer to our object, all we have to do is update our coordinates
- and the Dimension object will adjust itself on the next repaint. Problem solved, and we don't
- have to know anything about how many Dimensions are connected to us, or where! \o/
+ - Pass the point as a reference to the class instance object (&endpoint). This
+ way, the line doesn't have to care about keeping track of Dimensions
+ connected to it. But still have to care about other connected entities
+ (other Lines, Circles, Arcs, Splines, Texts, etc). I think I'd be OK with
+ this. Since the Dimension has a pointer to our object, all we have to do is
+ update our coordinates and the Dimension object will adjust itself on the
+ next repaint. Problem solved, and we don't have to know anything about how
+ many Dimensions are connected to us, or where! \o/
The question then becomes, how do we do this kind of coupling???
-We need to know about connected entities so that we can have them either move in expected ways
-or constrain the movement of this Line object. This is how we will be a cut above all other CAD
-software currently out there: the GUI will try to do the right thing, most of the time. :-)
+We need to know about connected entities so that we can have them either move
+in expected ways or constrain the movement of this Line object. This is how we
+will be a cut above all other CAD software currently out there: the GUI will
+try to do the right thing, most of the time. :-)
*/
if (needUpdate)
{
//snapToPoints all well here?
bool Object::ignoreClicks = false;
bool Object::dontMove = false;
+bool Object::selectionInProgress = false;
+QRectF Object::selection;
Object::Object(): position(Vector(0, 0)), parent(0), type(OTObject),
static bool snapToGrid;
static bool ignoreClicks;
static bool dontMove;
+ public:
+ static bool selectionInProgress;
+ static QRectF selection;
};
#endif // __OBJECT_H__