Merge branch 'release-candidate' of github.com:Sankore/Sankore-3.1 into release-candidate

preferencesAboutTextFull
Claudio Valerio 12 years ago
commit 4dc6465f51
  1. 10
      src/board/UBBoardView.cpp
  2. 12
      src/domain/UBGraphicsItemUndoCommand.cpp
  3. 39
      src/domain/UBGraphicsScene.cpp

@ -733,7 +733,13 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
else else
{ {
if (movingItem) if (movingItem)
{
UBGraphicsItem *graphicsItem = dynamic_cast<UBGraphicsItem*>(movingItem);
if (graphicsItem)
graphicsItem->Delegate()->startUndoStep();
movingItem->clearFocus(); movingItem->clearFocus();
}
if (suspendedMousePressEvent) if (suspendedMousePressEvent)
{ {
@ -1115,6 +1121,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
return; return;
} }
UBGraphicsItem *graphicsItem = dynamic_cast<UBGraphicsItem*>(movingItem);
if (graphicsItem)
graphicsItem->Delegate()->commitUndoStep();
bool bReleaseIsNeed = true; bool bReleaseIsNeed = true;
if (movingItem != determineItemToPress(scene()->itemAt(this->mapToScene(event->posF().toPoint())))) if (movingItem != determineItemToPress(scene()->itemAt(this->mapToScene(event->posF().toPoint()))))
{ {

@ -25,6 +25,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsPolygonItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap) const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap)
@ -107,6 +108,13 @@ void UBGraphicsItemUndoCommand::undo()
else else
mScene->addItem(item); mScene->addItem(item);
if (UBGraphicsPolygonItem::Type == item->type())
{
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item);
if (polygonItem)
polygonItem->strokesGroup()->addToGroup(polygonItem);
}
UBApplication::boardController->freezeW3CWidget(item, false); UBApplication::boardController->freezeW3CWidget(item, false);
} }
} }
@ -206,6 +214,10 @@ void UBGraphicsItemUndoCommand::redo()
mScene->setAsBackgroundObject(item); mScene->setAsBackgroundObject(item);
else else
mScene->addItem(item); mScene->addItem(item);
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item);
if (polygonItem)
polygonItem->strokesGroup()->addToGroup(polygonItem);
} }
} }

@ -629,9 +629,9 @@ bool UBGraphicsScene::inputDeviceRelease()
if (mCurrentStroke && mCurrentStroke->polygons().empty()){ if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke; delete mCurrentStroke;
mCurrentStroke = NULL;
} }
mCurrentStroke = NULL;
return accepted; return accepted;
} }
@ -794,7 +794,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
{ {
#pragma omp critical #pragma omp critical
{ {
// Compele remove item // Compete remove item
intersectedItems << pi; intersectedItems << pi;
intersectedPolygons << QList<QPolygonF>(); intersectedPolygons << QList<QPolygonF>();
} }
@ -813,30 +813,29 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
for(int i=0; i<intersectedItems.size(); i++) for(int i=0; i<intersectedItems.size(); i++)
{ {
if (intersectedPolygons[i].empty()) // item who intersects with eraser
{ UBGraphicsPolygonItem *intersectedPolygonItem = intersectedItems[i];
removeItem(intersectedItems[i]);
}
else
{
UBGraphicsPolygonItem *pi = intersectedItems[i];
for(int j = 0; j < intersectedPolygons[i].size(); j++) if (!intersectedPolygons[i].empty())
{ {
QPolygonF p = intersectedPolygons[i][j]; // intersected polygons generated as QList<QPolygon> QPainterPath::toFillPolygons(),
if (j==0) // so each intersectedPolygonItem has one or couple of QPolygons who should be removed from it.
pi->setPolygon(intersectedPolygons[i][j]); for(int j = 0; j < intersectedPolygons[i].size(); j++)
else
{ {
UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(intersectedPolygons[i][j], pi->parentItem()); // create small polygon from couple of polygons to replace particular erased polygon
pi->copyItemParameters(polygonItem); UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(intersectedPolygons[i][j], intersectedPolygonItem->parentItem());
polygonItem->setStroke(pi->stroke()); intersectedPolygonItem->copyItemParameters(polygonItem);
polygonItem->setStrokesGroup(pi->strokesGroup()); polygonItem->setStroke(intersectedPolygonItem->stroke());
pi->strokesGroup()->addToGroup(polygonItem); polygonItem->setStrokesGroup(intersectedPolygonItem->strokesGroup());
} intersectedPolygonItem->strokesGroup()->addToGroup(polygonItem);
mAddedItems << polygonItem;
} }
} }
//remove full polygon item for replace it by couple of polygons who creates the same stroke without a part which intersects with eraser
mRemovedItems << intersectedPolygonItem;
removeItem(intersectedPolygonItem);
} }
if (!intersectedItems.empty()) if (!intersectedItems.empty())

Loading…
Cancel
Save