From 9cb5ea45d886c15b26b196bc292b7a4bbf359b20 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 16 Jan 2014 12:32:45 -0200 Subject: Started the code for a grid that knows how to handle itself. The code for this item is a bit too big to be just the grid of the dives and I know that, don't bully me. :) The main idea of this grid is that it knows when it should be updated. this is a bit different than the old code where all the painting happened on the same method. This is bad because it's more code, but it's better because if I break the grid, only the grid will be broken, and it's easyer to spot the breakage. in the old code if I did the wrong thing with the graphics context, the whole graph gots messed out. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'qt-ui/profile/profilewidget2.cpp') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 49dca4c68..89f20eb9b 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -29,7 +29,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : timeAxis(new TimeAxis()), depthController(new DiveRectItem()), timeController(new DiveRectItem()), - diveProfileItem(new DiveProfileItem()) + diveProfileItem(new DiveProfileItem()), + cartesianPlane(new DiveCartesianPlane()) { setScene(new QGraphicsScene()); scene()->setSceneRect(0, 0, 100, 100); @@ -64,6 +65,10 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : timeController->setRect(0, 0, 10, 5); timeController->setX(sceneRect().width() - timeController->boundingRect().width()); // Position it on the right spot. + cartesianPlane->setBottomAxis(timeAxis); + cartesianPlane->setLeftAxis(profileYAxis); + scene()->addItem(cartesianPlane); + // insert in the same way it's declared on the Enum. This is needed so we don't use an map. QList stateItems; stateItems << background << profileYAxis << gasYAxis << timeAxis << depthController << timeController; @@ -156,6 +161,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : profileState->assignProperty(timeAxis, "y", timeAxisOnCanvas); profileState->assignProperty(depthController, "y", depthControllerOffCanvas); profileState->assignProperty(timeController, "y", timeControllerOffCanvas); + profileState->assignProperty(cartesianPlane, "verticalLine", profileYAxisExpanded); + profileState->assignProperty(cartesianPlane, "horizontalLine", timeAxis->line()); // Edit, everything but the background and gasYAxis are shown. editState->assignProperty(this, "backgroundBrush", QBrush(Qt::darkGray)); -- cgit v1.2.3-70-g09d2