void CurveLineInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea) { if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton) { if(DataSingleton::Instance()->isResetCurve()) { mPointsCount = 0; DataSingleton::Instance()->setResetCurve(false); } switch(mPointsCount) { //draw linear Bezier curve case 0: mImageCopy = *imageArea.getImage(); mStartPoint = mEndPoint = mFirstControlPoint = mSecondControlPoint = event->pos(); ++mPointsCount; break; //draw square Bezier curve case 1: mFirstControlPoint = mSecondControlPoint = event->pos(); ++mPointsCount; break; //draw cubic Bezier curve case 2: mSecondControlPoint = event->pos(); mPointsCount = 0; break; } imageArea.setIsPaint(true); makeUndoCommand(imageArea); } }
void FillInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea) { if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton) { mStartPoint = mEndPoint = event->pos(); imageArea.setIsPaint(true); makeUndoCommand(imageArea); } }
void BinarizationEffect::applyEffect(ImageArea &imageArea) { makeUndoCommand(imageArea); // TODO: add dialog for setting parameters makeBinarization(imageArea, 200, 100); imageArea.setEdited(true); imageArea.update(); }
void TextInstrument::updateText(ImageArea *imageArea, QString textString) { mText = textString; imageArea->setImage(mImageCopy); if (!mIsEdited) { makeUndoCommand(*imageArea); mIsEdited = true; } paint(*imageArea); drawBorder(*imageArea); }
void AbstractSelection::mousePressEvent(QMouseEvent *event, ImageArea &imageArea) { mButton = event->button(); mIsMouseMoved = false; if (mIsSelectionExists) { imageArea.setImage(mImageCopy); paint(imageArea); if (mButton == Qt::RightButton) { mIsSelectionAdjusting = true; startAdjusting(imageArea); } if (event->pos().x() > mTopLeftPoint.x() && event->pos().x() < mBottomRightPoint.x() && event->pos().y() > mTopLeftPoint.y() && event->pos().y() < mBottomRightPoint.y()) { if (!mIsSelectionAdjusting) { makeUndoCommand(imageArea); } if (!mIsImageSelected) { startMoving(imageArea); if (!mIsSelectionAdjusting) { mIsImageSelected = true; } } else { drawBorder(imageArea); } mIsSelectionMoving = true; mMoveDiffPoint = mBottomRightPoint - event->pos(); return; } else if (event->pos().x() >= mBottomRightPoint.x() && event->pos().x() <= mBottomRightPoint.x() + 6 && event->pos().y() >= mBottomRightPoint.y() && event->pos().y() <= mBottomRightPoint.y() + 6) { if (!mIsSelectionAdjusting) { makeUndoCommand(imageArea); } startResizing(imageArea); mIsSelectionResizing = true; return; } else { clearSelection(imageArea); } } if (event->button() == Qt::LeftButton) { mBottomRightPoint = mTopLeftPoint = event->pos(); mHeight = mWidth = 0; mImageCopy = *imageArea.getImage(); startSelection(imageArea); mIsPaint = true; } }