Cleared unused code

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 2e7efcd568
commit a289545da9
  1. 210
      src/domain/UBGraphicsScene.cpp

@ -802,216 +802,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
setModified(true); setModified(true);
} }
/*
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
{
const QLineF line(mPreviousPoint, pEndPoint);
const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth);
const QRectF eraserBoundingRect = eraserPolygon.boundingRect();
const QRectF eraserInnerRect = UBGeometryUtils::lineToInnerRect(line, pWidth);
QPainterPath eraserPathVar;
eraserPathVar.addPolygon(eraserPolygon);
const QPainterPath eraserPath = eraserPathVar;
// Get all the items that are intersecting with the eraser path
QList<QGraphicsItem*> collidItems = items(eraserBoundingRect, Qt::IntersectsItemBoundingRect);
if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){
// NOTE: I decided to reuse the 'artistic' eraser all the time in order to have a better eraser
// For this reason, the following code is not used but we will keep it for now, in case of
// futur requirements.
foreach(QGraphicsItem* poly, collidItems){
UBGraphicsStrokesGroup* pGroup = dynamic_cast<UBGraphicsStrokesGroup*>(poly);
if(NULL != pGroup){
// TODO: Ungroup the item, put back the polygons on the scene, deal with the
// eraser's bounding rect, remove the polygons that must be removed
// then create new groups.
// Get all substrokes and verify if they are part of the eraserpath then deal with it
foreach(QGraphicsItem* item, poly->childItems()){
UBGraphicsPolygonItem* polygon = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != polygon){
if(eraserBoundingRect.intersects(polygon->boundingRect())){
pGroup->removeFromGroup(polygon);
removeItem(polygon);
}
}
}
}
}
}else{
QSet<QGraphicsItem*> toBeAddedItems;
QSet<QGraphicsItem*> toBeRemovedItems;
int collidItemsSize = collidItems.size();
toBeAddedItems.reserve(collidItemsSize);
toBeRemovedItems.reserve(collidItemsSize);
if (mShouldUseOMP)
{
#pragma omp parallel for
for (int i = 0; i < collidItemsSize; i++)
{
UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems.at(i));
if(NULL != collidingPolygonItem)
{
UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup();
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect()))
{
#pragma omp critical
// Put the entire polygon into the remove list
toBeRemovedItems << collidingPolygonItem;
}
else
{
// Here we get the polygon of the colliding item
QPolygonF collidingPolygon = collidingPolygonItem->polygon();
QPainterPath collidingPath;
collidingPath.addPolygon(collidingPolygon);
// Then we substract the eraser path to the polygon and we simplify it
QTransform polyTransform = collidingPolygonItem->sceneTransform().inverted();
QPointF mTrPrevPoint = polyTransform.map(mPreviousPoint);
QPointF mTrEndPoint = polyTransform.map(pEndPoint);
const QLineF trLine(mTrPrevPoint, mTrEndPoint);
const QPolygonF trEraserPolygon = UBGeometryUtils::lineToPolygon(trLine, pWidth);
QPainterPath trEraser;
trEraser.addPolygon(trEraserPolygon);
QPainterPath croppedPath = collidingPath.subtracted(trEraser);
// Original
//QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
QPainterPath croppedPathSimplified = croppedPath.simplified();
//if (croppedPath == collidingPath)
//{
// // NOOP
// toBeRemovedItems << collidingPolygonItem;
//}
//else
if (croppedPathSimplified.isEmpty())
{
#pragma omp critical
// Put the entire polygon into the remove list if the eraser removes all its visible content
toBeRemovedItems << collidingPolygonItem;
}
else
{
// Then we convert the remaining path to a list of polygons that will be converted in
// UBGraphicsPolygonItems and added to the scene
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons())
{
UBGraphicsPolygonItem* croppedPolygonItem;
#pragma omp critical
{
croppedPolygonItem = collidingPolygonItem->deepCopy(pol);
if(NULL != pGroup){
croppedPolygonItem->setStrokesGroup(pGroup);
//pGroup->addToGroup(croppedPolygonItem);
}
// Add this new polygon to the 'added' list
toBeAddedItems << croppedPolygonItem;
}
}
#pragma omp critical
// Remove the original polygonitem because it has been replaced by many smaller polygons
toBeRemovedItems << collidingPolygonItem;
}
}
}
}
}
else
{
for (int i = 0; i < collidItemsSize; i++)
{
UBGraphicsPolygonItem *collidingPolygonItem = dynamic_cast<UBGraphicsPolygonItem*> (collidItems.at(i));
if (collidingPolygonItem)
{
UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup();
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect()))
{
toBeRemovedItems << collidingPolygonItem;
}
else
{
QPolygonF collidingPolygon = collidingPolygonItem->polygon();
QPainterPath collidingPath;
collidingPath.addPolygon(collidingPolygon);
QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
QPainterPath croppedPathSimplified = croppedPath.simplified();
if (croppedPath == collidingPath)
{
// NOOP
}
else if (croppedPathSimplified.isEmpty())
{
toBeRemovedItems << collidingPolygonItem;
}
else
{
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons())
{
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol);
toBeAddedItems << croppedPolygonItem;
if(NULL != pGroup){
croppedPolygonItem->setStrokesGroup(pGroup);
}
}
toBeRemovedItems << collidingPolygonItem;
}
}
}
}
}
if(eDrawingMode_Vector == DRAWING_MODE && !UBDrawingController::drawingController()->isInDesktopMode()){
foreach(QGraphicsItem* item, toBeRemovedItems){
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != poly){
UBGraphicsStrokesGroup* group = poly->strokesGroup();
if(NULL != group){
group->removeFromGroup(poly);
removeItem(poly);
}else{
qDebug() << "No group present";
}
}
}
}else{
removeItems(toBeRemovedItems);
mRemovedItems += toBeRemovedItems;
}
if(eDrawingMode_Vector == DRAWING_MODE && !UBDrawingController::drawingController()->isInDesktopMode()){
foreach(QGraphicsItem* item, toBeAddedItems){
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != poly && NULL != poly->strokesGroup()){
poly->setTransform(poly->strokesGroup()->transform());
poly->strokesGroup()->addToGroup(poly);
}
}
}else{
addItems(toBeAddedItems);
mAddedItems += toBeAddedItems;
}
}
mPreviousPoint = pEndPoint;
}
*/
void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle) void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle)
{ {
mDrawWithCompass = true; mDrawWithCompass = true;

Loading…
Cancel
Save