]> git.zarvox.org Git - shareboard.git/commitdiff
Line drawing works. Yay!
authorDrew Fisher <drew.m.fisher@gmail.com>
Fri, 8 Oct 2010 07:59:30 +0000 (00:59 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Fri, 8 Oct 2010 07:59:30 +0000 (00:59 -0700)
shareboard.cpp
shareboardcanvas.cpp

index 8a95b2667c49831121f1a45d41fc91ccad5ae897..6701f0778c206fe0aea0650b9403389b7c5f9134 100644 (file)
@@ -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) {
index 84a56f11e5bcf648fa7dbe7dd37e0d9d0d4262c6..51e3e1a55da3928c00721be3df87ab4ee69e03f9 100644 (file)
@@ -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