Example #1
0
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();
    }
}
Example #2
0
void CanvasModel::handleLocalCommand(protocol::MessagePtr cmd)
{
	m_statetracker->localCommand(cmd);
	emit canvasModified();
}
Example #3
0
void CanvasModel::handleDrawingCommand(protocol::MessagePtr cmd)
{
	m_statetracker->receiveQueuedCommand(cmd);
	emit canvasModified();
}