void GridLabel::deselect(void) { RectF r; r.setLeft(-2); r.setRight(-2); r.setTop(-1); r.setBottom(-1); m_pEditData->setCatchRect(r); update(); }
void GridLabel::selectAll(void) { RectF r; EditData::ImageData *p = m_pEditData->getImageDataFromNo(m_Index); if (!p) { return; } int img_w = p->Image.width(); int img_h = p->Image.height(); r.setLeft(0); r.setRight(img_w); r.setTop(0); r.setBottom(img_h); m_pEditData->setCatchRect(r); update(); }
// 範囲選択終了 void GridLabel::mouseReleaseEvent(QMouseEvent *ev) { if (!m_pEditData || !m_bCatchable) { return; } if (!bCatching) { return; } bCatching = false; if (m_bRectMove) { // 範囲移動中 m_bRectMove = false; return; } m_bRectMove = false; EditData::ImageData *p = m_pEditData->getImageDataFromNo(m_Index); if (!p) { return; } int img_w = p->Image.width(); int img_h = p->Image.height(); RectF r = m_pEditData->getCatchRect(); float x = ev->pos().x() / mScale; float y = ev->pos().y() / mScale; if (x < 0) { x = 0; } if (x > img_w) { x = img_w; } if (x < r.left()) { x = r.left(); } if (y < 0) { y = 0; } if (y > img_h) { y = img_h; } if (y < r.top()) { y = r.top(); } r.setRight(x); r.setBottom(y); if (r.width() <= 1 || r.height() <= 1) { r.setLeft(-2); r.setRight(-2); r.setTop(-1); r.setBottom(-1); } m_pEditData->setCatchRect(r); emit sig_changeCatchRect(r); repaint(); }
// 範囲選択中 void GridLabel::mouseMoveEvent(QMouseEvent *ev) { if (!m_pEditData || !m_bCatchable) { return; } if (!bCatching) { return; } RectF r = m_pEditData->getCatchRect(); EditData::ImageData *p = m_pEditData->getImageDataFromNo(m_Index); if (!p) { return; } int img_w = p->Image.width(); int img_h = p->Image.height(); int x = ev->pos().x() / mScale; int y = ev->pos().y() / mScale; if (m_bRectMove) { // 範囲移動中 if (!m_bPressCtrl) { return; } // Ctrlキー押してたら QPoint add = ev->pos() - m_MovePos; r.setLeft(r.left() + add.x()); r.setRight(r.right() + add.x()); r.setTop(r.top() + add.y()); r.setBottom(r.bottom() + add.y()); if (r.left() < 0) { r.setRight(r.right() - r.left()); r.setLeft(0); } if (r.right() > img_w - 1) { r.setLeft(r.left() - (r.right() - (img_w - 1))); r.setRight(img_w - 1); } if (r.top() < 0) { r.setBottom(r.bottom() - r.top()); r.setTop(0); } if (r.bottom() > img_h - 1) { r.setTop(r.top() - (r.bottom() - (img_h - 1))); r.setBottom(img_h - 1); } emit sig_changeSelectLayerUV(r); m_MovePos = ev->pos(); } else { if (x < 0) { x = 0; } if (x >= img_w) { x = img_w; } if (x < r.left()) { x = r.left(); } if (y < 0) { y = 0; } if (y >= img_h) { y = img_h; } if (y < r.top()) { y = r.top(); } r.setRight(x); r.setBottom(y); } m_pEditData->setCatchRect(r); emit sig_changeCatchRect(r); repaint(); }