void BitmapCanvas::mouseMoveEvent(QMouseEvent *event) { int col = event->pos().x() / GRID_SIZE; int row = event->pos().y() / GRID_SIZE; if (col >= mBitmap.size().width() || row >= mBitmap.size().height() || col < 0 || row < 0) { return; } emit canvasModified(); if ((event->buttons() & Qt::LeftButton) && mBitmap.pixelIndex(col, row) == 0) { mBitmap.setPixel(col, row, 1); repaint(); } else if ((event->buttons() & Qt::RightButton) && mBitmap.pixelIndex(col, row) == 1) { mBitmap.setPixel(col, row, 0); repaint(); } }
void CanvasModel::handleLocalCommand(protocol::MessagePtr cmd) { m_statetracker->localCommand(cmd); emit canvasModified(); }
void CanvasModel::handleDrawingCommand(protocol::MessagePtr cmd) { m_statetracker->receiveQueuedCommand(cmd); emit canvasModified(); }