Exemplo n.º 1
0
void SketchArea::mouseMoveEvent(QMouseEvent *event)
{
     if ((event->buttons() & Qt::LeftButton) && scribbling)
         drawLineTo(event->pos());
     if ((event->buttons() & Qt::RightButton) && erasing)
         drawLineTo(event->pos());
}
Exemplo n.º 2
0
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;
        }
    }
}
Exemplo n.º 3
0
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
    );
}
Exemplo n.º 4
0
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
}
Exemplo n.º 5
0
 void MyLine::mouseReleaseEvent(QMouseEvent *event)
 {
     //if (event->button() == Qt::LeftButton && scribbling) {
         drawLineTo(event->x(),event->y());
         scribbling = false;
     //}
 }
Exemplo n.º 6
0
void Canvas::mouseReleaseEvent(QMouseEvent *event)//from the scribble example
{
    if (event->button() == Qt::LeftButton && scribbling){
        drawLineTo(event->pos());
        scribbling = false;
    }
}
Exemplo n.º 7
0
void ScribbleArea::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton && scribbling) {
        drawLineTo(event->pos());
        scribbling = false;
    }
}
Exemplo n.º 8
0
void RotoCanvas::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton && isToolActive) {
        drawLineTo(event->pos());
        isToolActive = false;
    }
}
Exemplo n.º 9
0
void PaintCanvas::closepath(void)
{//Close off current path
    maskpath.closeSubpath();
    maskpathnewpath=true;
    clickedToEndPath=true;
    drawLineTo(lastPoint);
   update();
}
Exemplo n.º 10
0
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());
    }
}
Exemplo n.º 11
0
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());
    }
}
Exemplo n.º 12
0
void DrawingArea::mouseReleaseEvent(QMouseEvent *event)
{
    if( event->button() == Qt::LeftButton && drawing)
    {
        drawLineTo(event->pos());
        drawing = false;
    }

}
Exemplo n.º 13
0
void  FilterBrush::mouseReleaseEvent(QMouseEvent *event, PaintArea *currentPaintArea)
{
	if (event->button() == Qt::LeftButton ) {

		drawLineTo(event->pos(), currentPaintArea);

		this->pixels.clear();
	}

}
Exemplo n.º 14
0
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;
  }
}
Exemplo n.º 15
0
void Canvas::mouseMoveEvent(QMouseEvent *event)
{
    if ((event->buttons() & Qt::LeftButton)){
        if(inPicker){
            pickColor(event->pos());
        }else{
            if(drawing){
                drawLineTo(event->pos());
                lastPoint = event->pos();
            }
        }
    }
}
Exemplo n.º 16
0
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);
}
Exemplo n.º 17
0
 void DrawingContext::mouseMoveEvent(QMouseEvent *event)
 {
     if(event->buttons() & Qt::LeftButton) 
	 {
		if(!pEditView->supportMode)
		{
			if(scribbling && (currDrawTool == "penfill" || currDrawTool == "penvoid"))
			{
				drawLineTo(event->pos());
			}	 
		}
	 }
	
 }
Exemplo n.º 18
0
/**
 * 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();
}
Exemplo n.º 19
0
//
// 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);
    }
}
Exemplo n.º 20
0
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;
    }
}
Exemplo n.º 21
0
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();
}
Exemplo n.º 22
0
 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();
		 }
     }
 }
Exemplo n.º 23
0
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();
    }
}
Exemplo n.º 24
0
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;
    }
}
Exemplo n.º 25
0
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();
}
Exemplo n.º 26
0
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());
    }
}
Exemplo n.º 27
0
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;
}
Exemplo n.º 28
0
/*!
 * \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;
    }
}
Exemplo n.º 29
0
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"));
        }

}
}
Exemplo n.º 30
0
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"));
        }

}
}