From: Drew Fisher Date: Fri, 8 Oct 2010 07:59:30 +0000 (-0700) Subject: Line drawing works. Yay! X-Git-Url: https://git.zarvox.org/?a=commitdiff_plain;h=be4cb7721b78bdcc67913b1fd93c00c2a7c14db6;p=shareboard.git Line drawing works. Yay! --- diff --git a/shareboard.cpp b/shareboard.cpp index 8a95b26..6701f07 100644 --- a/shareboard.cpp +++ b/shareboard.cpp @@ -58,6 +58,7 @@ void Shareboard::handleSegmentDrawn(QPointF start, QPointF end) { action->userID = userID; action->points.append(start); action->points.append(end); + Q_ASSERT(action->points.size() >= 2); emit actionHappened(action); //qDebug() << "shareboard.cpp: segment drawn from" << start << "to" << end; } @@ -68,12 +69,13 @@ void Shareboard::postAction(Action* action) { localHistory.removeFirst(); } history.append(action); - if(viewIndex+1 == history.size()) { + jumpToIndex(history.size()); +/* if(viewIndex+1 == history.size()) { jumpToIndex(viewIndex+1); - } else { + } else { */ qDebug() << "viewIndex = "<< viewIndex; qDebug() << "history.size = "<< history.size(); - } + //} } void Shareboard::postLocalAction(Action* action) { @@ -90,6 +92,7 @@ void Shareboard::switchToPrompt() { void Shareboard::setUserID(int id) { userID = id; + jumpToIndex(history.size()); } void Shareboard::jumpToIndex(int index) { @@ -106,6 +109,7 @@ void Shareboard::jumpToIndex(int index) { p.begin(&viewImage); while(i < history.size() && i < index) { viewTime = history[i]->timestamp; + viewIndex = i; Action* action = history[i]; // Apply action to pixmap switch(action->type) { @@ -130,7 +134,8 @@ void Shareboard::jumpToIndex(int index) { pen.setWidth(a->width); p.setPen(pen); qDebug() << "Painting line\tcolor: " << a->color << "\twidth:" << a->width; - p.drawPolyline(a->points.data(), a->points.size()); + p.drawPolyline(a->points.data(), a->points.size()-1); + qDebug() << a->points; } break; case Action::AddImage: @@ -142,6 +147,7 @@ void Shareboard::jumpToIndex(int index) { i++; } p.end(); + canvas->update(); } /* void Shareboard::jumpToTime(QDateTime time) { diff --git a/shareboardcanvas.cpp b/shareboardcanvas.cpp index 84a56f1..51e3e1a 100644 --- a/shareboardcanvas.cpp +++ b/shareboardcanvas.cpp @@ -53,9 +53,8 @@ void ShareboardCanvas::paintEvent(QPaintEvent* event) { QPainter p(this); // Paint the background from the saved state p.drawImage(0, 0, board->view()); - qDebug() << "ShareboardCanvas:" << board->view().rect(); - qDebug() << "ShareboardCanvas:" << board->viewIndex; - p.drawEllipse(0,0,100,100); + //qDebug() << "ShareboardCanvas:" << board->view().rect(); + //qDebug() << "ShareboardCanvas:" << board->viewIndex; // Now paint our local changes on top of it //p.set