void SketchArea::mouseMoveEvent(QMouseEvent *event) { if ((event->buttons() & Qt::LeftButton) && scribbling) drawLineTo(event->pos()); if ((event->buttons() & Qt::RightButton) && erasing) drawLineTo(event->pos()); }
void PaintWidget::mouseMoveEvent(QMouseEvent *event) { if ((event->buttons() & Qt::LeftButton) && isPainting_) { //TODO calculate mouse position switch(paintTool_) { case PaintToolType::Pen: drawLineTo(event->pos()); break; case PaintToolType::Highlight: { QPoint p = event->pos(); p.setY(penLastPoint_.y()); drawLineTo(p); break; } case PaintToolType::Rectangle: rectTool.setWidth(event->x()-rectTool.x()); rectTool.setHeight(event->y()-rectTool.y()); this->update(); break; case PaintToolType::Text: break; case PaintToolType::Erease: break; } } }
void SaveDialog::drawButton( const I2Rectangle& rect, const char* text ) { setForeground(buttonColor3); fillRectangle(rect); setForeground(buttonColor1); moveTo(rect.left(), rect.bottom()); drawLineTo(rect.left(), rect.top()); drawLineTo(rect.right(), rect.top()); setForeground(buttonColor2); drawLineTo(rect.right(), rect.bottom()); drawLineTo(rect.left(), rect.bottom()); setForeground(textColor); int len = strlen(text); int skip = (rect.width() - editor->dx * len) / 2; if (skip < 2) skip = 2; drawString( rect.left() + skip, rect.top() + editor->statusLineMargin + editor->ascent, text ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->chatTimeout = true; this->connected = false; this->currColorId = 2; // czarny this->lastColorButton = ui->blackPushButton; this->graphicsScene = new QGraphicsScene(); ui->graphicsView->setScene(graphicsScene); this->currentPen.setColor(QColor("black")); connect(ui->graphicsView,SIGNAL(drawPoint(QPoint)),this,SLOT(drawPoint(QPoint))); connect(ui->graphicsView,SIGNAL(drawLineTo(QPoint)),this,SLOT(drawLineTo(QPoint))); connect(ui->clearPushButton,SIGNAL(clicked()),this,SLOT(clearView())); connect(ui->redPushButton,SIGNAL(clicked()),this,SLOT(switchColor())); connect(ui->greenPushButton,SIGNAL(clicked()),this,SLOT(switchColor())); connect(ui->blackPushButton,SIGNAL(clicked()),this,SLOT(switchColor())); connect(ui->sendMessagePushButton,SIGNAL(clicked()),this,SLOT(sendMessage())); connect(ui->chatLineEdit,SIGNAL(returnPressed()),this,SLOT(sendMessage())); this->socket = new KalSocket(); this->chatTimer = new QTimer(); connect(socket,SIGNAL(connected()),this,SLOT(connectionSuccess())); connect(socket,SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(displayError(QAbstractSocket::SocketError))); connect(socket,SIGNAL(pointsReceived(int,int,int,KalSocket::DrawType)), this,SLOT(pointsReceived(int,int,int,KalSocket::DrawType))); connect(socket,SIGNAL(clear()),graphicsScene,SLOT(clear())); connect(socket,SIGNAL(someoneLoggedIn(QString)),this,SLOT(someoneLoggedIn(QString))); connect(socket,SIGNAL(chatMessage(QString,QString)),this,SLOT(addMessage(QString,QString))); connect(socket,SIGNAL(nicknames(QList<QString>)),this,SLOT(getNicknames(QList<QString>))); connect(socket,SIGNAL(logout(QString)),this,SLOT(someoneLoggedOut(QString))); connect(socket,SIGNAL(drawStart(QString)),this,SLOT(drawStart(QString))); connect(socket,SIGNAL(gotSettings(ServerSettings)),this,SLOT(getSettings(ServerSettings))); connect(socket,SIGNAL(errorMessage(QString)),this,SLOT(showMessage(QString))); connect(ui->wantDrawCheckBox,SIGNAL(toggled(bool)),this,SLOT(wantDrawToggled(bool))); // actiony z menu: Polaczenie connect(ui->actionPo_cz,SIGNAL(triggered()),this,SLOT(connectWindowExec())); // laczymy sie connect(ui->actionRoz_cz,SIGNAL(triggered()),this,SLOT(disconnect())); // rozlaczamy sie connect(ui->actionZako_cz,SIGNAL(triggered()),this,SLOT(close())); // koniec programu // timer connect(chatTimer,SIGNAL(timeout()),this,SLOT(timeout())); connect(ui->progressBar,SIGNAL(full()),this,SLOT(drawTimeout())); // inne this->disableActions(false); // Polacz - aktywne, Rozlacz - nieaktywne }
void MyLine::mouseReleaseEvent(QMouseEvent *event) { //if (event->button() == Qt::LeftButton && scribbling) { drawLineTo(event->x(),event->y()); scribbling = false; //} }
void Canvas::mouseReleaseEvent(QMouseEvent *event)//from the scribble example { if (event->button() == Qt::LeftButton && scribbling){ drawLineTo(event->pos()); scribbling = false; } }
void ScribbleArea::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && scribbling) { drawLineTo(event->pos()); scribbling = false; } }
void RotoCanvas::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && isToolActive) { drawLineTo(event->pos()); isToolActive = false; } }
void PaintCanvas::closepath(void) {//Close off current path maskpath.closeSubpath(); maskpathnewpath=true; clickedToEndPath=true; drawLineTo(lastPoint); update(); }
void PaintArea::mouseMoveEvent(QMouseEvent *event) { if (_tool == 1) { if (scribbling) drawLineTo(event->pos()); } else if (_tool == 2) { if (scribbling) drawEraser(event->pos()); } else if (_tool == 3) { image = _scroll; QPoint This = lastPoint; _scroll = image; drawStraightLine(lastPoint, event->pos()); lastPoint = This; } else if (_tool == 4) { image = _scroll; QPoint This = lastPoint; _scroll = image; drawRectangle(lastPoint, event->pos()); lastPoint = This; } else if (_tool == 5) { image = _scroll; QPoint This = lastPoint; _scroll = image; drawEclipse(lastPoint, event->pos()); lastPoint = This; } else if (_tool == 8) { image = _scroll; QPoint This = lastPoint; _scroll = image; drawRectRound(lastPoint, event->pos()); lastPoint = This; } else if (_tool == 9) { image = _scroll; QPoint This = lastPoint; _scroll = image; drawCopyRect(lastPoint, event->pos()); lastPoint = This; } else if (_tool == 11) { if (scribbling) drawSpray(event->pos()); } }
void PaintArea::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::RightButton) _right = true; else _right = false; if (_tool != 0) { _redo.clear(); emit noRedo(); } if (_isselect) { Undo(); _isselect = false; emit noCopy(); } lastPoint = event->pos(); if (_tool == 7) { _history.push_back(image); emit enableUndo(); drawWord(lastPoint); } else if (_tool == 6) { _history.push_back(image); emit enableUndo(); drawBucket(event->pos()); } else if (_tool == 10) { _history.push_back(image); emit enableUndo(); Paste(event->pos()); } else if (_tool == 12) { if (event->button() == Qt::LeftButton) zoomIn(); else zoomOut(); } else { _history.push_back(image); emit enableUndo(); _scroll = image; scribbling = true; if (_tool == 1) drawLineTo(event->pos()); else if (_tool == 2) drawEraser(event->pos()); else if (_tool == 11) drawSpray(event->pos()); } }
void DrawingArea::mouseReleaseEvent(QMouseEvent *event) { if( event->button() == Qt::LeftButton && drawing) { drawLineTo(event->pos()); drawing = false; } }
void FilterBrush::mouseReleaseEvent(QMouseEvent *event, PaintArea *currentPaintArea) { if (event->button() == Qt::LeftButton ) { drawLineTo(event->pos(), currentPaintArea); this->pixels.clear(); } }
void DrawingBoard::mouseReleaseEvent(QMouseEvent * event){ if (event->button() == Qt::LeftButton && drawing){ drawLineTo(event->pos()); drawing = true; } else if (event->button() == Qt::RightButton && drawing){ erase(event->pos()); drawing = true; } }
void Canvas::mouseMoveEvent(QMouseEvent *event) { if ((event->buttons() & Qt::LeftButton)){ if(inPicker){ pickColor(event->pos()); }else{ if(drawing){ drawLineTo(event->pos()); lastPoint = event->pos(); } } } }
void SketchArea::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && scribbling) { drawLineTo(event->pos()); scribbling = false; } if (event->button() == Qt::RightButton && erasing) { drawLineTo(event->pos()); erasing = false; } if(event->button() == Qt::MidButton) { clearImage(); } if(autoSaveSketch) saveImage(saveSketchFileName, "JPG"); if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton) emit newSketchDone(saveSketchFileName); }
void DrawingContext::mouseMoveEvent(QMouseEvent *event) { if(event->buttons() & Qt::LeftButton) { if(!pEditView->supportMode) { if(scribbling && (currDrawTool == "penfill" || currDrawTool == "penvoid")) { drawLineTo(event->pos()); } } } }
/** * This event handler is called when the mouse move events occur. */ void GLWidget3D::mouseMoveEvent(QMouseEvent *e) { if (mode == MODE_SKETCH) { drawLineTo(e->pos()); } else { if (e->buttons() & Qt::LeftButton) { // Rotate camera.rotate(e->x(), e->y()); } else if (e->buttons() & Qt::MidButton) { // Move camera.move(e->x(), e->y()); } else if (e->buttons() & Qt::RightButton) { // Zoom camera.zoom(e->x(), e->y()); } } update(); }
// // Draw graph of function in a window // void MyWindow::drawGraphic() { R2Point p; double dx = 0.05; double xmax = getXMax(); p.x = getXMin(); p.y = f(p.x); moveTo(p); while (p.x < xmax) { drawLineTo(p); p.x += dx; p.y = f(p.x); } }
void PaintWidget::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && isPainting_) { //TODO calculate mouse position switch(paintTool_) { case PaintToolType::Pen: drawLineTo(event->pos()); break; case PaintToolType::Highlight: { QPoint p = event->pos(); p.setY(penLastPoint_.y()); drawLineTo(p); break; } case PaintToolType::Rectangle: { overlayPainter_.begin(&overlayImage_); QColor color(pen_.color()); color.setAlpha(100); overlayPainter_.fillRect(rectTool, color); overlayPainter_.end(); break; } case PaintToolType::Text: break; case PaintToolType::Erease: break; } isPainting_ = false; } }
void GLWidget3D::mouseMoveEvent(QMouseEvent *e) { if (ctrlPressed) { if (e->buttons() & Qt::LeftButton) { // Rotate camera.rotate(e->x(), e->y()); } else if (e->buttons() & Qt::MidButton) { // Move camera.move(e->x(), e->y()); } else if (e->buttons() & Qt::RightButton) { // Zoom camera.zoom(e->x(), e->y()); } strokes.clear(); } else { // sketch drawLineTo(e->pos()); } update(); }
void DrawingContext::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { if(pActiveImage && !pEditView->supportMode) { if(scribbling && (currDrawTool == "penfill" ||currDrawTool == "penvoid")) { drawLineTo(event->pos()); } scribbling = false; pEditView->RefreshContext(1); pEditView->SaveToUndoBuffer();//since the image is altered, save to the buffer. pEditView->ReCompress(); } } }
void PaintCanvas::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { clickedToEndPath=false; //For mask drawing if (backgroundmaskpen){ if(maskpathnewpath){ maskpath.moveTo(event->pos()); maskpathnewpath=false; lastPoint = event->pos(); } maskpath.lineTo(event->pos()); drawLineTo(event->pos()); update(); } //For head and Tail marking if(markHead){ scribbling = true; lastPoint = event->pos(); //THEN SWITCH TO OTHER PEN } if(markTail){ scribbling = true; lastPoint = event->pos(); //THEN SWITCH TO OTHER PEN } //Default other drawing if(targetpen||backgroundpen) scribbling = true; lastPoint = event->pos(); } if (event->button()==Qt::RightButton&&backgroundmaskpen){ //Close off current path closepath(); } }
void PaintCanvas::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && scribbling&&(targetpen||backgroundpen)) { drawLineTo(event->pos()); scribbling = false; } if (event->button() == Qt::LeftButton && scribbling&&(markHead)) {//Draw head dot drawMarkerDot(event->pos()); scribbling = false; } if (event->button() == Qt::LeftButton && scribbling&&(markTail)) {//Draw head dot drawMarkerDot(event->pos()); scribbling = false; } }
void Canvas::tabletEvent(QTabletEvent *ev) { //TODO: fully support tablet qreal pressure = ev->pressure(); if(pressure < 0.000001){ drawing = false; ev->accept(); return; } // pen->setWidthF(pressure*10); if(!drawing){ lastPoint = ev->pos(); drawing = true; drawPoint(lastPoint); }else{ drawLineTo(ev->pos()); lastPoint = ev->pos(); } ev->accept(); }
void PaintArea::mouseReleaseEvent(QMouseEvent *event) { if (_tool == 1) { if (event->button() == Qt::LeftButton && scribbling) { drawLineTo(event->pos()); scribbling = false; } } else if (_tool == 2) { if (event->button() == Qt::LeftButton && scribbling) { drawEraser(event->pos()); scribbling = false; } } else if (_tool == 3) { drawStraightLine(lastPoint, event->pos()); } else if (_tool == 4) { drawRectangle(lastPoint, event->pos()); } else if (_tool == 5) { drawEclipse(lastPoint, event->pos()); } else if (_tool == 8) { drawRectRound(lastPoint, event->pos()); } else if (_tool == 11) { if ((event->buttons() & Qt::LeftButton) && scribbling) drawSpray(event->pos()); } }
void CSharedPainterScene::mouseMoveEvent( QGraphicsSceneMouseEvent *evt ) { if( !freePenMode_) { QGraphicsScene::mouseMoveEvent( evt ); return; } if(!drawFlag_) return; QPointF to = evt->scenePos(); to.setX( to.x() + CURSOR_OFFSET_X ); to.setY( to.y() + CURSOR_OFFSET_Y ); if( currLineItem_ ) { drawLineTo( prevPos_, to, currLineItem_->color(), currLineItem_->width() ); currLineItem_->addPoint( to ); } prevPos_ = to; }
/*! * \brief DrawingArea::mouseReleaseEvent Действие при отпускании левой кнопки мышки. * \param event Элемент действия * * Проверяет переменную myTool и по её номеру подбирает действие, которое следует совершить с изображением. * Задаёт функцию для обработки действия и после её совершения объявляет переменную scribbling = false. * */ void DrawingArea::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && scribbling && (myTool == 1)) { drawLineTo(event->pos()); scribbling = false; } else if(event->button() == Qt::LeftButton && scribbling && (myTool == 2 || 3)) { bottomRight = event->pos(); drawFigure(topLeft, bottomRight); scribbling = false; } if(event->button() == Qt::LeftButton && scribbling && (myTool == 4)) { //lastPoint = event->pos(); printf("painting!!!1\n"); QColor clr; clr.fromRgb(image.pixel(lastPoint)); fillArea(lastPoint, clr); scribbling = false; } }
void DrawingBoard::mouseReleaseEvent(QMouseEvent *event) { if(myLine){ if (event->button() == Qt::LeftButton && drawing) { // backUp.push_back(image); store(); drawLineThru(startPoint, event->pos()); istore(); drawing = false; } else if (event->button() == Qt::RightButton) { // QString str1 = QString::number(myPenWidth); // myPenWidth = 1; // QString str2 = QString::(myPenColor); // myPenColor = Qt::red; bool ok; int newWidth = QInputDialog::getInt(this, tr("Line Size"), tr("Select the size of line:"), penWidth(), 1, 50, 1, &ok); // bool ok; //QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"), // tr("Season:"), items, 0, false, &ok); if (ok){ setPenWidth(newWidth); // statusBar()->showMessage(tr("qweewqewdasdsakdl")); } } } else if(myRect){ if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); // store(); drawRectTo(event->pos()); // istore(); drawing = false; } else if (event->button() == Qt::RightButton) { bool ok; int newWidth = QInputDialog::getInt(this, tr("Rectangle border size"), tr("Select the size of the border:"), penWidth(), 1, 50, 1, &ok); // bool ok; //QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"), // tr("Season:"), items, 0, false, &ok); if (ok){ setPenWidth(newWidth); // statusBar()->showMessage(tr("qweewqewdasdsakdl")); } } } else if(myText){ if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); store(); drawTexts(event->pos(),QString::fromStdString(text)); istore(); drawing = false; } else if (event->button() == Qt::RightButton) { // QString str =QString::fromStdString(text); bool ok; QString txt = QInputDialog::getText(this, tr("Enter the text you want to print"), tr("Message"), QLineEdit::Normal,tr("Type your message"), &ok); if (ok){ text=txt.toStdString(); //text=txt; }} } else if(myPen) { if (event->button() == Qt::LeftButton && drawing) { // backUp.push_back(image); store(); drawLineTo(event->pos()); istore(); drawing = false; } else if (event->button() == Qt::RightButton) { bool ok; int newWidth = QInputDialog::getInt(this, tr("Pen Size"), tr("Select the size of pen:"), penWidth(), 1, 50, 1, &ok); // bool ok; // QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"), // tr("Season:"), items, 0, false, &ok); if (ok){ setPenWidth(newWidth); // statusBar()->showMessage(tr("qweewqewdasdsakdl")); } //QMessageBox::about(this, tr("Pen tool properties"), // tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(mypLine){ if (event->button() == Qt::LeftButton && drawing) { // backUp.push_back(image); store(); drawLineTemp(startPoint, event->pos()); istore(); drawing = false; } else if (event->button() == Qt::RightButton) { bool ok; int newWidth = QInputDialog::getInt(this, tr("Select polyline Size"), tr("Select the size of Polyline:"), penWidth(), 1, 50, 1, &ok); if (ok) setPenWidth(newWidth); // QMessageBox::about(this, tr("PolyLine tool properties"), // tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(myRub) { if (event->button() == Qt::LeftButton && drawing) { // backUp.push_back(image); store(); erase(event->pos());//to change istore(); drawing = false; } else if (event->button() == Qt::RightButton) { bool ok; int newWidth = QInputDialog::getInt(this, tr("Eraser Size"), tr("Select the size of Eraser:"), rubWidth(), 1, 50, 1, &ok); if (ok) setRubWidth(newWidth); } } else { if (event->button() == Qt::LeftButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked Left Button. Now, close and select your preferences")); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event1 detection"), tr("You have Clicked right button. Now, close and select your preferences to see the properties of tool")); } } }
void DrawingBoard::mouseMoveEvent(QMouseEvent *event) { if(myLine){ if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); // store(); drawLineThru(startPoint,startPoint); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(myRect){ if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); //store(); drawRectTo(event->pos()); // istore(); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(myText){ if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); store(); drawTexts(startPoint,QString::fromStdString(text)); istore(); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("text Event detection"), tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(myPen) { if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); store(); drawLineTo(event->pos()); istore(); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(mypLine){ if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); store(); drawLineTemp(startPoint,startPoint); istore(); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked right button. To draw Please press left button on mouse")); } } else if(myRub) { if ((event->buttons() & Qt::LeftButton) && drawing){ // backUp.push_back(image); erase(event->pos());//to change } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked right button. To erase Please press left button on mouse")); } } else { if (event->button() == Qt::LeftButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked Left Button. Now, close and select your preferences")); } else if (event->button() == Qt::RightButton) { QMessageBox::about(this, tr("Mouse Event detection"), tr("You have Clicked right button. Now, close and select your preferences")); } } }