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

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

@ -80,17 +80,17 @@ UBZLayerController::UBZLayerController(QGraphicsScene *scene) :
{ {
scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber)); scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber));
scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-10000000.0, -10000000.0 )); scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-1000000.0, -1000000.0 ));
scopeMap.insert(itemLayerType::ObjectItem, ItemLayerTypeData(-10000000.0, 0.0 )); scopeMap.insert(itemLayerType::ObjectItem, ItemLayerTypeData(-1000000.0, 0.0 ));
scopeMap.insert(itemLayerType::DrawingItem, ItemLayerTypeData( 0.0, 10000000.0 )); scopeMap.insert(itemLayerType::DrawingItem, ItemLayerTypeData( 0.0, 1000000.0 ));
scopeMap.insert(itemLayerType::ToolItem, ItemLayerTypeData( 10000000.0, 10000100.0 )); scopeMap.insert(itemLayerType::ToolItem, ItemLayerTypeData( 1000000.0, 1000100.0 ));
scopeMap.insert(itemLayerType::CppTool, ItemLayerTypeData( 10000100.0, 10000200.0 )); scopeMap.insert(itemLayerType::CppTool, ItemLayerTypeData( 1000100.0, 1000200.0 ));
scopeMap.insert(itemLayerType::Curtain, ItemLayerTypeData( 10000200.0, 10001000.0 )); scopeMap.insert(itemLayerType::Curtain, ItemLayerTypeData( 1000200.0, 1001000.0 ));
scopeMap.insert(itemLayerType::Eraiser, ItemLayerTypeData( 10001000.0, 10001100.0 )); scopeMap.insert(itemLayerType::Eraiser, ItemLayerTypeData( 1001000.0, 1001100.0 ));
scopeMap.insert(itemLayerType::Pointer, ItemLayerTypeData( 10001100.0, 10001200.0 )); scopeMap.insert(itemLayerType::Pointer, ItemLayerTypeData( 1001100.0, 1001200.0 ));
scopeMap.insert(itemLayerType::Cache, ItemLayerTypeData( 10001300.0, 10001400.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) qreal UBZLayerController::generateZLevel(itemLayerType::Enum key)
@ -547,47 +547,47 @@ bool UBGraphicsScene::inputDeviceRelease()
{ {
if(mArcPolygonItem){ if(mArcPolygonItem){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Add the arc // Add the arc
mAddedItems.remove(mArcPolygonItem); mAddedItems.remove(mArcPolygonItem);
removeItem(mArcPolygonItem); removeItem(mArcPolygonItem);
UBCoreGraphicsScene::removeItemFromDeletion(mArcPolygonItem); UBCoreGraphicsScene::removeItemFromDeletion(mArcPolygonItem);
mArcPolygonItem->setStrokesGroup(pStrokes);
pStrokes->addToGroup(mArcPolygonItem);
// Add the center cross
foreach(QGraphicsItem* item, mAddedItems){
mAddedItems.remove(item);
removeItem(item);
UBCoreGraphicsScene::removeItemFromDeletion(item);
mArcPolygonItem->setStrokesGroup(pStrokes); mArcPolygonItem->setStrokesGroup(pStrokes);
pStrokes->addToGroup(mArcPolygonItem); pStrokes->addToGroup(item);
}
// Add the center cross
foreach(QGraphicsItem* item, mAddedItems){
mAddedItems.remove(item);
removeItem(item);
UBCoreGraphicsScene::removeItemFromDeletion(item);
mArcPolygonItem->setStrokesGroup(pStrokes);
pStrokes->addToGroup(item);
}
mAddedItems.clear(); mAddedItems.clear();
mAddedItems << pStrokes; mAddedItems << pStrokes;
addItem(pStrokes); addItem(pStrokes);
mDrawWithCompass = false;
mDrawWithCompass = false;
} }
else if (mCurrentStroke){ else if (mCurrentStroke){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item // Remove the strokes that were just drawn here and replace them by a stroke item
foreach(UBGraphicsPolygonItem* poly, mCurrentStroke->polygons()){ foreach(UBGraphicsPolygonItem* poly, mCurrentStroke->polygons()){
mPreviousPolygonItems.removeAll(poly); mPreviousPolygonItems.removeAll(poly);
removeItem(poly); removeItem(poly);
UBCoreGraphicsScene::removeItemFromDeletion(poly); UBCoreGraphicsScene::removeItemFromDeletion(poly);
poly->setStrokesGroup(pStrokes); poly->setStrokesGroup(pStrokes);
pStrokes->addToGroup(poly); pStrokes->addToGroup(poly);
} }
// TODO LATER : Generate well pressure-interpolated polygons and create the line group with them // TODO LATER : Generate well pressure-interpolated polygons and create the line group with them
mAddedItems.clear(); mAddedItems.clear();
mAddedItems << pStrokes; mAddedItems << pStrokes;
addItem(pStrokes); addItem(pStrokes);
if (mCurrentStroke->polygons().empty()){ if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke; delete mCurrentStroke;
@ -1524,7 +1524,6 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
format.setForeground(QBrush(color)); format.setForeground(QBrush(color));
curCursor.mergeCharFormat(format); curCursor.mergeCharFormat(format);
textItem->setTextCursor(curCursor); textItem->setTextCursor(curCursor);
// textItem->setSelected(true);
textItem->contentsChanged(); textItem->contentsChanged();
} }
@ -1619,7 +1618,10 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
{ {
UBCoreGraphicsScene::addItem(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)) if (!mTools.contains(item))
++mItemCount; ++mItemCount;

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

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

Loading…
Cancel
Save