void TerrainEditTool::startNewPolygon() { finalizeItem(); qDebug() << "TerrainEditTool::startNewPolygon - Starting new polygon"; _item = new DeformableGraphicsItem(); _editScene->addItem(_item); }
void BezierMode::mouseReleaseEvent(QMouseEvent *m) { const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); undoManager->setUndoEnabled(true); PageItem *currItem; m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m->accept(); // m_view->stopDragTimer(); m_canvas->setRenderModeUseBuffer(false); if ((m_doc->appMode == modeDrawBezierLine) && (m->button() == Qt::LeftButton)) { m_canvas->setRenderModeUseBuffer(true); currItem = m_doc->m_Selection->itemAt(0); currItem->ClipEdited = true; currItem->FrameType = 3; QTransform pm = currItem->getTransform(); FPoint npf = m_doc->ApplyGridF(mousePointDoc).transformPoint(pm, true); currItem->PoLine.addPoint(npf); bool ssiz = currItem->Sizing; currItem->Sizing = true; if ((currItem->PoLine.size() % 4 == 0) && (currItem->PoLine.size() > 3)) { FPoint lxy(currItem->PoLine.point(currItem->PoLine.size()-2)); FPoint lk(currItem->PoLine.point(currItem->PoLine.size()-1)); double dx = lxy.x() - lk.x(); double dy = lxy.y() - lk.y(); lk.setX(lk.x() + dx*2); lk.setY(lk.y() + dy*2); currItem->PoLine.addPoint(lxy); currItem->PoLine.addPoint(lk); } FPoint np2(getMinClipF(&currItem->PoLine)); if (np2.x() < 0) { currItem->PoLine.translate(-np2.x(), 0); m_doc->MoveItem(np2.x(), 0, currItem); } if (np2.y() < 0) { currItem->PoLine.translate(0, -np2.y()); m_doc->MoveItem(0, np2.y(), currItem); } if (FirstPoly) { FirstPoly = false; currItem->Sizing = ssiz; } else { m_doc->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false, false); m_doc->AdjustItemSize(currItem); currItem->Sizing = ssiz; currItem->ContourLine = currItem->PoLine.copy(); m_canvas->setRenderModeUseBuffer(false); currItem->update(); } m_canvas->setRenderModeFillBuffer(); int newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x()); int newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y()); m_canvas->newRedrawPolygon() << QPoint(newX - qRound(currItem->xPos()), newY - qRound(currItem->yPos())); m_view->updateCanvas(); } if ((m_doc->appMode == modeDrawBezierLine) && (m->button() == Qt::RightButton)) { currItem = m_doc->m_Selection->itemAt(0); if (currItem!=0) { finalizeItem(currItem); } if (!PrefsManager::instance()->appPrefs.uiPrefs.stickyTools) { // qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); m_view->requestMode(modeNormal); // m_view->requestMode(submodePaintingDone); } else m_view->requestMode(m_doc->appMode); m_doc->changed(); // emit DocChanged(); FirstPoly = true; inItemCreation = false; m_canvas->setRenderModeUseBuffer(false); // m_view->updateContents(); } m_doc->DragP = false; m_doc->leaveDrag = false; // m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; shiftSelItems = false; // m_doc->SubMode = -1; if (m_view->groupTransactionStarted()) { for (int i = 0; i < m_doc->m_Selection->count(); ++i) m_doc->m_Selection->itemAt(i)->checkChanges(true); m_view->endGroupTransaction(); } //??? for (int i = 0; i < m_doc->m_Selection->count(); ++i) //??? m_doc->m_Selection->itemAt(i)->checkChanges(true); // //Commit drag created items to undo manager. // if (m_doc->m_Selection->itemAt(0)!=NULL) // { // m_doc->itemAddCommit(m_doc->m_Selection->itemAt(0)->ItemNr); // } //Make sure the Zoom spinbox and page selector dont have focus if we click on the canvas m_view->m_ScMW->zoomSpinBox->clearFocus(); m_view->m_ScMW->pageSelector->clearFocus(); if (m_doc->m_Selection->itemAt(0) != 0) // is there the old clip stored for the undo action { currItem = m_doc->m_Selection->itemAt(0); m_doc->nodeEdit.finishTransaction(currItem); } else { //delete oldClip; //oldClip = 0; } }
void TerrainEditTool::deactivate() { qDebug() << "TerrainEditTool::deactivate - Deactivating"; finalizeItem(); }