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. 3
      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)
@ -547,47 +547,47 @@ bool UBGraphicsScene::inputDeviceRelease()
{
if(mArcPolygonItem){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Add the arc
mAddedItems.remove(mArcPolygonItem);
removeItem(mArcPolygonItem);
UBCoreGraphicsScene::removeItemFromDeletion(mArcPolygonItem);
// Add the arc
mAddedItems.remove(mArcPolygonItem);
removeItem(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);
pStrokes->addToGroup(mArcPolygonItem);
// Add the center cross
foreach(QGraphicsItem* item, mAddedItems){
mAddedItems.remove(item);
removeItem(item);
UBCoreGraphicsScene::removeItemFromDeletion(item);
mArcPolygonItem->setStrokesGroup(pStrokes);
pStrokes->addToGroup(item);
}
pStrokes->addToGroup(item);
}
mAddedItems.clear();
mAddedItems << pStrokes;
addItem(pStrokes);
mDrawWithCompass = false;
mAddedItems.clear();
mAddedItems << pStrokes;
addItem(pStrokes);
mDrawWithCompass = false;
}
else if (mCurrentStroke){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item
foreach(UBGraphicsPolygonItem* poly, mCurrentStroke->polygons()){
mPreviousPolygonItems.removeAll(poly);
removeItem(poly);
UBCoreGraphicsScene::removeItemFromDeletion(poly);
poly->setStrokesGroup(pStrokes);
pStrokes->addToGroup(poly);
}
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item
foreach(UBGraphicsPolygonItem* poly, mCurrentStroke->polygons()){
mPreviousPolygonItems.removeAll(poly);
removeItem(poly);
UBCoreGraphicsScene::removeItemFromDeletion(poly);
poly->setStrokesGroup(pStrokes);
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 << pStrokes;
addItem(pStrokes);
mAddedItems.clear();
mAddedItems << pStrokes;
addItem(pStrokes);
if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
@ -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()

@ -97,7 +97,7 @@ class UBThumbnailWidget : public QGraphicsView
QList<QUrl> mItemsPaths;
QStringList mLabels;
bool bSelectionInProgress;
bool bCanDrag;
bool bCanDrag;
private:
void selectAll();
@ -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