zvalue for strokes handled correctly

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 849ed076a2
commit 26f96b7619
  1. 13
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 3
      src/domain/UBGraphicsItemTransformUndoCommand.cpp
  3. 28
      src/domain/UBGraphicsScene.cpp
  4. 1
      src/domain/UBGraphicsStrokesGroup.cpp
  5. 1
      src/gui/UBThumbnailWidget.h

@ -571,12 +571,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mStrokesList.insert(parentId,group);
currentStroke = new UBGraphicsStroke();
group->setTransform(polygonItem->transform());
UBGraphicsItem::assignZValue(group, zFromSvg);
}
else
group = mStrokesList.value(parentId);
if(polygonItem->transform().isIdentity())
polygonItem->setTransform(group->transform());
group->addToGroup(polygonItem);
polygonItem->setStrokesGroup(group);
polygonItem->setStroke(currentStroke);
@ -602,12 +604,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mStrokesList.insert(parentId,group);
currentStroke = new UBGraphicsStroke();
group->setTransform(polygonItem->transform());
UBGraphicsItem::assignZValue(group, zFromSvg);
}
else
group = mStrokesList.value(parentId);
if(polygonItem->transform().isIdentity())
polygonItem->setTransform(group->transform());
group->addToGroup(polygonItem);
polygonItem->setStrokesGroup(group);
polygonItem->setStroke(currentStroke);
@ -990,10 +994,13 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
qDebug() << "Number of detected strokes: " << mStrokesList.count();
QHashIterator<QString, UBGraphicsStrokesGroup*> iterator(mStrokesList);
qreal zValue = 0;
while (iterator.hasNext()) {
iterator.next();
zValue = iterator.value()->zValue();
qDebug() << "Number of polygons : " << (int)(((UBGraphicsStrokesGroup*)iterator.value())->childItems().count());
mScene->addItem(iterator.value());
iterator.value()->setZValue(zValue);
}
if (mScene)
@ -1229,12 +1236,13 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
items.removeOne(poly);
}
if (resultPoly) {
resultPoly->setZValue(strokesGroupItem->zValue());
//Claudio: the painter path simplification remove all the polygons overlap
QPainterPath painterPath;
painterPath.addPolygon(resultPoly->polygon());
painterPath = painterPath.simplified();
resultPoly->setPolygon(painterPath.toFillPolygon());
polygonItemToSvgPolygon(resultPoly, true);
polygonItemToSvgPolygon(resultPoly, false);
items.removeOne(resultPoly);
}
}
@ -1701,8 +1709,7 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
if (!svgPoints.isNull())
{
QStringList ts = svgPoints.toString().split(QLatin1Char(' '),
QString::SkipEmptyParts);
QStringList ts = svgPoints.toString().split(QLatin1Char(' '), QString::SkipEmptyParts);
foreach(const QString sPoint, ts)
{

@ -58,7 +58,6 @@ void UBGraphicsItemTransformUndoCommand::undo()
mItem->setPos(mPreviousPosition);
mItem->setTransform(mPreviousTransform);
mItem->setZValue(mPreviousZValue);
// UBGraphicsItem::assignZValue(mItem, mPreviousZValue);
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(mItem);
@ -72,8 +71,6 @@ void UBGraphicsItemTransformUndoCommand::redo()
mItem->setTransform(mCurrentTransform);
mItem->setZValue(mCurrentZValue);
// UBGraphicsItem::assignZValue(mItem, /*mCurrentZValue*/mItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(mItem);
if (resizableItem)

@ -80,17 +80,17 @@ UBZLayerController::UBZLayerController(QGraphicsScene *scene) :
{
scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber));
scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-10000000.0, -10000000.0 ));
scopeMap.insert(itemLayerType::ObjectItem, ItemLayerTypeData(-10000000.0, 0.0 ));
scopeMap.insert(itemLayerType::DrawingItem, ItemLayerTypeData( 0.0, 10000000.0 ));
scopeMap.insert(itemLayerType::ToolItem, ItemLayerTypeData( 10000000.0, 10000100.0 ));
scopeMap.insert(itemLayerType::CppTool, ItemLayerTypeData( 10000100.0, 10000200.0 ));
scopeMap.insert(itemLayerType::Curtain, ItemLayerTypeData( 10000200.0, 10001000.0 ));
scopeMap.insert(itemLayerType::Eraiser, ItemLayerTypeData( 10001000.0, 10001100.0 ));
scopeMap.insert(itemLayerType::Pointer, ItemLayerTypeData( 10001100.0, 10001200.0 ));
scopeMap.insert(itemLayerType::Cache, ItemLayerTypeData( 10001300.0, 10001400.0 ));
scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-1000000.0, -1000000.0 ));
scopeMap.insert(itemLayerType::ObjectItem, ItemLayerTypeData(-1000000.0, 0.0 ));
scopeMap.insert(itemLayerType::DrawingItem, ItemLayerTypeData( 0.0, 1000000.0 ));
scopeMap.insert(itemLayerType::ToolItem, ItemLayerTypeData( 1000000.0, 1000100.0 ));
scopeMap.insert(itemLayerType::CppTool, ItemLayerTypeData( 1000100.0, 1000200.0 ));
scopeMap.insert(itemLayerType::Curtain, ItemLayerTypeData( 1000200.0, 1001000.0 ));
scopeMap.insert(itemLayerType::Eraiser, ItemLayerTypeData( 1001000.0, 1001100.0 ));
scopeMap.insert(itemLayerType::Pointer, ItemLayerTypeData( 1001100.0, 1001200.0 ));
scopeMap.insert(itemLayerType::Cache, ItemLayerTypeData( 1001300.0, 1001400.0 ));
scopeMap.insert(itemLayerType::SelectedItem, ItemLayerTypeData( 10001000.0, 10001000.0 ));
scopeMap.insert(itemLayerType::SelectedItem, ItemLayerTypeData( 1001000.0, 1001000.0 ));
}
qreal UBZLayerController::generateZLevel(itemLayerType::Enum key)
@ -568,8 +568,8 @@ bool UBGraphicsScene::inputDeviceRelease()
mAddedItems.clear();
mAddedItems << pStrokes;
addItem(pStrokes);
mDrawWithCompass = false;
mDrawWithCompass = false;
}
else if (mCurrentStroke){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
@ -1524,7 +1524,6 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
format.setForeground(QBrush(color));
curCursor.mergeCharFormat(format);
textItem->setTextCursor(curCursor);
// textItem->setSelected(true);
textItem->contentsChanged();
}
@ -1619,7 +1618,10 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
{
UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
qDebug() << item->zValue();
qreal zvalue = mZLayerController->generateZLevel(item);
UBGraphicsItem::assignZValue(item, zvalue);
if (!mTools.contains(item))
++mItemCount;

@ -43,6 +43,7 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
}
UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()

@ -161,7 +161,6 @@ class UBThumbnail
{
item->scene()->addItem(mSelectionItem);
mSelectionItem->setZValue(item->zValue() - 1);
// UBGraphicsItem::assignZValue(mSelectionItem, item->zValue() - 1);
mAddedToScene = true;
}

Loading…
Cancel
Save