void TiePointEditor::addPoint() { if (mpLayer.get() == NULL) { return; } TiePointList* pTiePointList = dynamic_cast<TiePointList*>(mpLayer->getDataElement()); if (pTiePointList == NULL) { return; } const vector<TiePoint>& oldPoints = pTiePointList->getTiePoints(); vector<TiePoint> tiePoints = oldPoints; tiePoints.push_back(TiePoint()); View* pView = mpLayer->getView(); if (pView != NULL) { pView->addUndoAction(new SetTiePoints(pTiePointList, oldPoints, tiePoints)); } int numTiePoints = static_cast<int>(tiePoints.size()); pTiePointList->adoptTiePoints(tiePoints); goToRow(numTiePoints - 1); }
void SetTiePoints::executeRedo() { TiePointList* pList = static_cast<TiePointList*>(getSessionItem()); if (pList != NULL) { vector<TiePoint> vertices = mNewVertices; pList->adoptTiePoints(vertices); } }
void TiePointEditor::deletePoint() { if (mpLayer.get() == NULL) { return; } TiePointList* pTiePointList = dynamic_cast<TiePointList*>(mpLayer->getDataElement()); if (pTiePointList == NULL) { return; } QModelIndex index = mpTableView->currentIndex(); if (index.isValid() == false) { QMessageBox::warning(this, "Tie Point Editor", "Please select a tie point to delete."); return; } int currentRow = index.row(); const vector<TiePoint>& oldPoints = pTiePointList->getTiePoints(); vector<TiePoint> points = oldPoints; vector<TiePoint>::iterator pPoint = points.begin() + index.row(); points.erase(pPoint); View* pView = mpLayer->getView(); if (pView != NULL) { pView->addUndoAction(new SetTiePoints(pTiePointList, oldPoints, points)); } pTiePointList->adoptTiePoints(points); if (currentRow == mpTableModel->rowCount()) { --currentRow; } goToRow(currentRow); }
bool TiePointLayerImp::processMouseRelease(const QPoint& screenCoord, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) { if (mIsMission == false) { if (button == Qt::LeftButton) { LocationType point; ViewImp* pView = dynamic_cast<ViewImp*>(getView()); VERIFY(pView != NULL); pView->setSelectionBox(QRect()); pView->translateScreenToWorld(screenCoord.x(), screenCoord.y(), point.mX, point.mY); translateWorldToData(point.mX, point.mY, point.mX, point.mY); TiePointList* pElement = dynamic_cast<TiePointList*>(getDataElement()); int bounds[4]; bounds[0] = sAnchor.mX; bounds[1] = sAnchor.mY; bounds[2] = point.mX; bounds[3] = point.mY; if (bounds[0] > bounds[2]) { int temp = bounds[0]; bounds[0] = bounds[2]; bounds[2] = temp; } if (bounds[1] > bounds[3]) { int temp = bounds[1]; bounds[1] = bounds[3]; bounds[3] = temp; } vector<TiePoint> remainingPoints; const vector<TiePoint>& oldPoints = pElement->getTiePoints(); vector<TiePoint>::const_iterator pPoint; for (pPoint = oldPoints.begin(); pPoint != oldPoints.end(); ++pPoint) { LocationType point = getPoint(*pPoint); if (!isInBounds(point, bounds)) { remainingPoints.push_back(*pPoint); } } if (remainingPoints != oldPoints) { pView->addUndoAction(new SetTiePoints(pElement, oldPoints, remainingPoints)); pElement->adoptTiePoints(remainingPoints); } return true; } } return false; }