Compare commits

..

No commits in common. 'master' and 'new_images' have entirely different histories.

  1. 4
      OpenBoard.pro
  2. 3
      resources/OpenBoard.qrc
  3. 48
      resources/forms/mainWindow.ui
  4. 126
      resources/images/toolbar/dashedLine.svg
  5. 145
      resources/images/toolbar/dottedLine.svg
  6. 126
      resources/images/toolbar/solidLine.svg
  7. 108
      src/adaptors/UBCFFSubsetAdaptor.cpp
  8. 1
      src/adaptors/UBCFFSubsetAdaptor.h
  9. 239
      src/adaptors/UBSvgSubsetAdaptor.cpp
  10. 4
      src/adaptors/UBSvgSubsetAdaptor.h
  11. 64
      src/board/UBBoardController.cpp
  12. 9
      src/board/UBBoardController.h
  13. 6
      src/board/UBBoardView.cpp
  14. 24
      src/board/UBDrawingController.cpp
  15. 5
      src/board/UBDrawingController.h
  16. 11
      src/core/UB.h
  17. 35
      src/core/UBSettings.cpp
  18. 6
      src/core/UBSettings.h
  19. 191
      src/domain/UBGraphicsLineItem.cpp
  20. 100
      src/domain/UBGraphicsLineItem.h
  21. 144
      src/domain/UBGraphicsScene.cpp
  22. 5
      src/domain/UBGraphicsScene.h
  23. 3
      src/domain/UBItem.cpp
  24. 2
      src/domain/domain.pri
  25. 6
      src/tools/UBGraphicsRuler.cpp
  26. 4
      src/tools/UBGraphicsTriangle.cpp

@ -9,9 +9,9 @@ CONFIG += debug_and_release \
VERSION_MAJ = 1
VERSION_MIN = 6
VERSION_PATCH = 3
VERSION_PATCH = 2
VERSION_TYPE = r # a = alpha, b = beta, rc = release candidate, r = release, other => error
VERSION_BUILD = 0613
VERSION_BUILD = 0502
VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_PATCH}-$${VERSION_TYPE}.$${VERSION_BUILD}"

@ -126,9 +126,6 @@
<file>images/toolbar/eraserTool.png</file>
<file>images/toolbar/lineTool.png</file>
<file>images/toolbar/tools.png</file>
<file>images/toolbar/solidLine.svg</file>
<file>images/toolbar/dashedLine.svg</file>
<file>images/toolbar/dottedLine.svg</file>
<file>images/stylusPalette/arrow.png</file>
<file>images/stylusPalette/arrowOn.png</file>
<file>images/stylusPalette/handPlay.png</file>

@ -1702,54 +1702,6 @@
<string>Draw intermediate grid lines</string>
</property>
</action>
<action name="actionLineSolid">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/toolbar/solidLine.svg</normaloff>:/images/toolbar/solidLine.svg</iconset>
</property>
<property name="text">
<string>Line Style</string>
</property>
<property name="toolTip">
<string>Solid Style</string>
</property>
</action>
<action name="actionLineDashed">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/toolbar/dashedLine.svg</normaloff>:/images/toolbar/dashedLine.svg</iconset>
</property>
<property name="text">
<string>Line Style</string>
</property>
<property name="toolTip">
<string>Dashed Style</string>
</property>
</action>
<action name="actionLineDotted">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/toolbar/dottedLine.svg</normaloff>:/images/toolbar/dottedLine.svg</iconset>
</property>
<property name="text">
<string>Line Style</string>
</property>
<property name="toolTip">
<string>Dotted Style</string>
</property>
</action>
</widget>
<resources>
<include location="../OpenBoard.qrc"/>

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="42"
height="42"
viewBox="0 0 42 42"
version="1.1"
id="svg38508"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="dashedLine.svg"
inkscape:export-filename="/home/dmitry/git/OpenBoard/resources/images/stylusPalette/arrow_svg.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview38510"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
units="px"
inkscape:zoom="11.313708"
inkscape:cx="18.870913"
inkscape:cy="20.903845"
inkscape:window-width="1920"
inkscape:window-height="1003"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g965"
inkscape:document-rotation="0"
inkscape:snap-others="true"
inkscape:snap-global="false"
inkscape:showpageshadow="2"
inkscape:deskcolor="#505050">
<inkscape:grid
type="xygrid"
id="grid7387"
dotted="false" />
</sodipodi:namedview>
<defs
id="defs38505">
<filter
style="color-interpolation-filters:sRGB"
id="filter37990-9-5"
inkscape:label="shadowFilter"
x="-0.067811772"
y="-0.07751945"
width="1.1356235"
height="1.1873387">
<feGaussianBlur
stdDeviation="0.29999999999999999"
id="feGaussianBlur37992-3-6" />
<feOffset
dx="0"
dy="0.29999999999999999"
id="feOffset37994-2-2" />
</filter>
<filter
style="color-interpolation-filters:sRGB"
id="filter37990-9-5-3"
inkscape:label="shadowFilter"
x="-0.067811772"
y="-0.07751945"
width="1.1356235"
height="1.1873387">
<feGaussianBlur
stdDeviation="0.29999999999999999"
id="feGaussianBlur37992-3-6-6" />
<feOffset
dx="0"
dy="0.29999999999999999"
id="feOffset37994-2-2-7" />
</filter>
</defs>
<g
inkscape:label="icon"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-152.84748,-194.2822)">
<g
id="g965"
inkscape:label="line">
<path
style="fill:none;stroke:#000000;stroke-width:3.6;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:10.8,10.8;stroke-dashoffset:0;stroke-opacity:1"
d="m 154.68586,234.52153 38.80777,-38.81827"
id="path963"
sodipodi:nodetypes="cc" />
</g>
</g>
<metadata
id="metadata854">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
</cc:License>
</rdf:RDF>
</metadata>
</svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

@ -1,145 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
inkscape:export-ydpi="96"
inkscape:export-xdpi="96"
inkscape:export-filename="/home/dmitry/git/OpenBoard/resources/images/stylusPalette/arrow_svg.png"
sodipodi:docname="dottedLine.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
id="svg38508"
version="1.1"
viewBox="0 0 42 42"
height="42"
width="42"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview38510"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
units="px"
inkscape:zoom="7.9999996"
inkscape:cx="41.437502"
inkscape:cy="-10.0625"
inkscape:window-width="1920"
inkscape:window-height="1003"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g965"
inkscape:document-rotation="0"
inkscape:snap-others="true"
inkscape:snap-global="false"
inkscape:showpageshadow="2"
inkscape:deskcolor="#505050">
<inkscape:grid
type="xygrid"
id="grid7387"
dotted="false" />
</sodipodi:namedview>
<defs
id="defs38505">
<filter
style="color-interpolation-filters:sRGB"
id="filter37990-9-5"
inkscape:label="shadowFilter"
x="-0.067811772"
y="-0.07751945"
width="1.1356235"
height="1.1873387">
<feGaussianBlur
stdDeviation="0.29999999999999999"
id="feGaussianBlur37992-3-6" />
<feOffset
dx="0"
dy="0.29999999999999999"
id="feOffset37994-2-2" />
</filter>
<filter
style="color-interpolation-filters:sRGB"
id="filter37990-9-5-3"
inkscape:label="shadowFilter"
x="-0.067811772"
y="-0.07751945"
width="1.1356235"
height="1.1873387">
<feGaussianBlur
stdDeviation="0.29999999999999999"
id="feGaussianBlur37992-3-6-6" />
<feOffset
dx="0"
dy="0.29999999999999999"
id="feOffset37994-2-2-7" />
</filter>
</defs>
<g
inkscape:label="icon"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-152.84748,-194.2822)">
<g
id="g965"
inkscape:label="line">
<circle
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.53588;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.878431;paint-order:stroke fill markers"
id="circle2549"
cx="157.40373"
cy="231.92728"
r="3.4577076" />
<circle
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.53588;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.878431;paint-order:stroke fill markers"
id="circle2587"
cx="168.27238"
cy="221.2583"
r="3.4577076" />
<circle
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.53588;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.878431;paint-order:stroke fill markers"
id="circle2589"
cx="179.28416"
cy="210.2368"
r="3.4577076" />
<circle
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.53588;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.878431;paint-order:stroke fill markers"
id="circle2591"
cx="190.15662"
cy="199.18091"
r="3.4577076" />
</g>
</g>
<metadata
id="metadata854">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
</cc:License>
</rdf:RDF>
</metadata>
</svg>

Before

Width:  |  Height:  |  Size: 4.8 KiB

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="42"
height="42"
viewBox="0 0 42 42"
version="1.1"
id="svg38508"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="solidLine.svg"
inkscape:export-filename="/home/dmitry/git/OpenBoard/resources/images/stylusPalette/arrow_svg.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview38510"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
units="px"
inkscape:zoom="11.313708"
inkscape:cx="18.870913"
inkscape:cy="20.903845"
inkscape:window-width="1920"
inkscape:window-height="1003"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g965"
inkscape:document-rotation="0"
inkscape:snap-others="true"
inkscape:snap-global="false"
inkscape:showpageshadow="2"
inkscape:deskcolor="#505050">
<inkscape:grid
type="xygrid"
id="grid7387"
dotted="false" />
</sodipodi:namedview>
<defs
id="defs38505">
<filter
style="color-interpolation-filters:sRGB"
id="filter37990-9-5"
inkscape:label="shadowFilter"
x="-0.067811772"
y="-0.07751945"
width="1.1356235"
height="1.1873387">
<feGaussianBlur
stdDeviation="0.29999999999999999"
id="feGaussianBlur37992-3-6" />
<feOffset
dx="0"
dy="0.29999999999999999"
id="feOffset37994-2-2" />
</filter>
<filter
style="color-interpolation-filters:sRGB"
id="filter37990-9-5-3"
inkscape:label="shadowFilter"
x="-0.067811772"
y="-0.07751945"
width="1.1356235"
height="1.1873387">
<feGaussianBlur
stdDeviation="0.29999999999999999"
id="feGaussianBlur37992-3-6-6" />
<feOffset
dx="0"
dy="0.29999999999999999"
id="feOffset37994-2-2-7" />
</filter>
</defs>
<g
inkscape:label="icon"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-152.84748,-194.2822)">
<g
id="g965"
inkscape:label="line">
<path
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 155.10847,234.22611 192.7862,196.30525"
id="path963"
sodipodi:nodetypes="cc" />
</g>
</g>
<metadata
id="metadata854">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
</cc:License>
</rdf:RDF>
</metadata>
</svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

@ -38,7 +38,6 @@
#include "domain/UBItem.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsLineItem.h"
#include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsSvgItem.h"
@ -75,7 +74,6 @@ static QString tG = "g";
static QString tSwitch = "switch";
static QString tPolygon = "polygon";
static QString tPolyline = "polyline";
static QString tLine = "line";
static QString tRect = "rect";
static QString tSvg = "svg";
static QString tText = "text";
@ -92,8 +90,6 @@ static QString aFill = "fill";
static QString aFillopacity = "fill-opacity";
static QString aX = "x";
static QString aY = "y";
static QString aX2 = "x2";
static QString aY2 = "y2";
static QString aWidth = "width";
static QString aHeight = "height";
static QString aStroke = "stroke";
@ -119,7 +115,6 @@ static QString aHref = "href";
static QString aBackground = "background";
static QString aLocked = "locked";
static QString aEditable = "editable";
static QString aLinestyle = "line-style";
//attributes part names
static QString apRotate = "rotate";
@ -586,108 +581,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
return true;
}
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgLine(const QDomElement &element)
{
QString svgPoints = element.attribute(aPoints);
QLineF line;
qreal x1 = element.attribute(aX).toDouble();
qreal y1 = element.attribute(aY).toDouble();
qreal x2 = element.attribute(aX2).toDouble();
qreal y2 = element.attribute(aY2).toDouble();
qreal width = element.attribute(aWidth).toDouble();
qreal height = element.attribute(aHeight).toDouble();
QString textStrokeColor = element.attribute(aStroke);
QString textStrokeWidth = element.attribute(aStrokewidth);
qreal style = element.attribute(aLinestyle).toDouble();
QColor strokeColor = !textStrokeColor.isNull() ? colorFromString(textStrokeColor) : QColor();
int strokeWidth = textStrokeWidth.toInt();
width += strokeWidth;
height += strokeWidth;
QPen pen;
if (strokeColor.isValid()) {
pen.setColor(strokeColor);
}
if (strokeWidth)
pen.setWidth(strokeWidth);
if (style == 2)
{
pen.setStyle(Qt::PenStyle::DotLine);
pen.setCapStyle(Qt::PenCapStyle::RoundCap);
} else if (style == 1)
{
pen.setStyle(Qt::PenStyle::DashLine);
} else
{
pen.setStyle(Qt::PenStyle::SolidLine);
}
QUuid itemUuid(element.attribute(aId).right(QUuid().toString().length()));
QUuid itemGroupUuid(element.attribute(aId).left(QUuid().toString().length()-1));
if (!itemUuid.isNull() && (itemGroupUuid!=itemUuid)) // reimported from UBZ
{
UBGraphicsLineItem *graphicsLine = new UBGraphicsLineItem(line);
UBGraphicsStroke *stroke = new UBGraphicsStroke();
//graphicsLine->setStroke(stroke);
graphicsLine->setPen(pen);
QTransform transform;
QString textTransform = element.attribute(aTransform);
graphicsLine->resetTransform();
if (!textTransform.isNull()) {
transform = transformFromString(textTransform, graphicsLine);
}
mCurrentScene->addItem(graphicsLine);
graphicsLine->setUuid(itemUuid);
mRefToUuidMap.insert(element.attribute(aId), itemUuid.toString());
}
else // simple CFF
{
QSvgGenerator *generator = createSvgGenerator(width + pen.width(), height + pen.width());
QPainter painter;
painter.begin(generator);
painter.setPen(pen);
painter.drawLine(x1, y1, x2, y2);
painter.end();
//add resulting svg file to scene
UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(QUuid(uuid));
QTransform transform;
QString textTransform = element.attribute(aTransform);
svgItem->resetTransform();
if (!textTransform.isNull()) {
transform = transformFromString(textTransform, svgItem);
}
repositionSvgItem(svgItem, width +strokeWidth, height + strokeWidth, x1 - strokeWidth/2 + transform.m31(), y1 + strokeWidth/2 + transform.m32(), transform);
hashSceneItem(element, svgItem);
if (mGSectionContainer)
{
addItemToGSection(svgItem);
}
delete generator;
}
return true;
}
void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElement &element,
qreal &fontSize, QColor &fontColor, QString &fontFamily,
QString &fontStretch, bool &italic, int &fontWeight,
@ -1208,7 +1101,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &p
else if (tagName == tEllipse && !parseSvgEllipse(parent)) return false;
else if (tagName == tPolygon && !parseSvgPolygon(parent)) return false;
else if (tagName == tPolyline && !parseSvgPolyline(parent)) return false;
else if (tagName == tLine && !parseSvgLine(parent)) return false;
else if (tagName == tText && !parseSvgText(parent)) return false;
else if (tagName == tTextarea && !parseSvgTextarea(parent)) return false;
else if (tagName == tImage && !parseSvgImage(parent)) return false;

@ -110,7 +110,6 @@ private:
inline bool parseSvgEllipse(const QDomElement &element);
inline bool parseSvgPolygon(const QDomElement &element);
inline bool parseSvgPolyline(const QDomElement &element);
inline bool parseSvgLine(const QDomElement &element);
inline bool parseSvgText(const QDomElement &element);
inline bool parseSvgTextarea(const QDomElement &element);
inline bool parseSvgImage(const QDomElement &element);

@ -40,7 +40,6 @@
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsLineItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPDFItem.h"
@ -619,46 +618,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
group->addToGroup(polygonItem);
}
}
else if (mXmlReader.name() == "lineL")
{
UBGraphicsLineItem* lineItem = 0;
QString parentId = mXmlReader.attributes().value(mNamespaceUri, "parent").toString();
lineItem = lineItemFromLineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black);
if(parentId.isEmpty() && strokesGroup)
parentId = strokesGroup->uuid().toString();
if(parentId.isEmpty())
parentId = QUuid::createUuid().toString();
if (lineItem)
{
lineItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
UBGraphicsStrokesGroup* group;
if(!mStrokesList.contains(parentId)){
group = new UBGraphicsStrokesGroup();
mStrokesList.insert(parentId,group);
group->setTransform(lineItem->transform());
UBGraphicsItem::assignZValue(group, lineItem->zValue());
}
else
group = mStrokesList.value(parentId);
if (!currentStroke)
currentStroke = new UBGraphicsStroke();
if(lineItem->transform().isIdentity())
lineItem->setTransform(group->transform());
group->addToGroup(lineItem);
lineItem->show();
group->addToGroup(lineItem);
}
}
else if (mXmlReader.name() == "polyline")
{
QList<UBGraphicsPolygonItem*> polygonItems = polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black);
@ -1341,49 +1300,6 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(UBDocumentProxy* proxy,
continue;
}
// Is the item a line?
UBGraphicsLineItem *lineItem = qgraphicsitem_cast<UBGraphicsLineItem*> (item);
if (lineItem && lineItem->isVisible())
{
mXmlWriter.writeStartElement("g");
QColor colorOnDarkBackground = lineItem->colorOnDarkBackground();
QColor colorOnLightBackground = lineItem->colorOnLightBackground();
if (colorOnDarkBackground.isValid() && colorOnLightBackground.isValid() && lineItem)
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value"
, QString("%1").arg(lineItem->zValue()));
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri
, "fill-on-dark-background", colorOnDarkBackground.name());
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri
, "fill-on-light-background", colorOnLightBackground.name());
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(lineItem->uuid()));
QVariant locked = lineItem->data(UBGraphicsItemData::ItemLocked);
if (!locked.isNull() && locked.toBool())
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "locked", xmlTrue);
QVariant layer = lineItem->data(UBGraphicsItemData::ItemLayerType);
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "layer", QString("%1").arg(layer.toInt()));
QMatrix matrix = lineItem->sceneMatrix();
if (!matrix.isIdentity())
mXmlWriter.writeAttribute("transform", toSvgTransform(matrix));
qDebug() << "Attributes written";
groupHoldsInfo = true;
}
lineItemToSvgLine(lineItem, groupHoldsInfo);
continue;
}
if (openStroke)
{
mXmlWriter.writeEndElement(); //g
@ -1639,53 +1555,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolyg
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::lineItemToSvgLine(UBGraphicsLineItem* lineItem, bool groupHoldsInfo)
{
mXmlWriter.writeStartElement("lineL");
QLineF line = lineItem->originalLine();
mXmlWriter.writeAttribute("x1", QString::number(line.p1().x(), 'f', 2));
mXmlWriter.writeAttribute("y1", QString::number(line.p1().y(), 'f', 2));
// SVG renderers (Chrome) do not like line where (x1, y1) == (x2, y2)
qreal x2 = line.p2().x();
if (line.p1() == line.p2())
x2 += 0.01;
mXmlWriter.writeAttribute("x2", QString::number(x2, 'f', 2));
mXmlWriter.writeAttribute("y2", QString::number(line.p2().y(), 'f', 2));
mXmlWriter.writeAttribute("stroke-width", QString::number(lineItem->originalWidth(), 'f', -1));
mXmlWriter.writeAttribute("stroke", lineItem->pen().color().name());
qreal alpha = lineItem->pen().color().alphaF();
if (alpha < 1.0)
mXmlWriter.writeAttribute("stroke-opacity", QString::number(alpha, 'f', 2));
mXmlWriter.writeAttribute("stroke-linecap", "round");
switch (lineItem->style())
{
case Qt::PenStyle::DotLine:
mXmlWriter.writeAttribute("line-style", "2");
break;
case Qt::PenStyle::DashLine:
mXmlWriter.writeAttribute("line-style", "1");
break;
default:
mXmlWriter.writeAttribute("line-style", "0");
}
if (!groupHoldsInfo)
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value", QString("%1").arg(lineItem->zValue()));
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "fill-on-dark-background", lineItem->colorOnDarkBackground().name());
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "fill-on-light-background", lineItem->colorOnLightBackground().name());
}
mXmlWriter.writeEndElement();
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::strokeToSvgPolyline(UBGraphicsStroke* stroke, bool groupHoldsInfo)
{
@ -2032,114 +1901,6 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
return polygonItem;
}
UBGraphicsLineItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::lineItemFromLineSvg(const QColor& pDefaultColor)
{
QStringRef svgX1 = mXmlReader.attributes().value("x1");
QStringRef svgY1 = mXmlReader.attributes().value("y1");
QStringRef svgX2 = mXmlReader.attributes().value("x2");
QStringRef svgY2 = mXmlReader.attributes().value("y2");
qreal style = mXmlReader.attributes().value("line-style").toDouble();
QLineF line;
if (!svgX1.isNull() && !svgY1.isNull() && !svgX2.isNull() && !svgY2.isNull())
{
qreal x1 = svgX1.toString().toFloat();
qreal y1 = svgY1.toString().toFloat();
qreal x2 = svgX2.toString().toFloat();
qreal y2 = svgY2.toString().toFloat();
line.setLine(x1, y1, x2, y2);
}
else
{
qWarning() << "cannot make sense of 'line' value";
return 0;
}
QStringRef strokeWidth = mXmlReader.attributes().value("stroke-width");
qreal lineWidth = 1.;
if (!strokeWidth.isNull())
{
lineWidth = strokeWidth.toString().toFloat();
}
UBGraphicsLineItem* lineItem = new UBGraphicsLineItem(line, lineWidth);
graphicsItemFromSvg(lineItem);
QStringRef svgStroke = mXmlReader.attributes().value("stroke");
QColor penColor = pDefaultColor;
if (!svgStroke.isNull())
{
penColor.setNamedColor(svgStroke.toString());
}
QStringRef svgStrokeOpacity = mXmlReader.attributes().value("stroke-opacity");
qreal opacity = 1.0;
if (!svgStrokeOpacity.isNull())
{
opacity = svgStrokeOpacity.toString().toFloat();
penColor.setAlphaF(opacity);
}
lineItem->setColor(penColor);
if (style == 2)
{
lineItem->setStyle(Qt::PenStyle::DotLine);
} else if (style == 1)
{
lineItem->setStyle(Qt::PenStyle::DashLine);
} else
{
lineItem->setStyle(Qt::PenStyle::SolidLine);
}
QStringRef ubFillOnDarkBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-dark-background");
if (!ubFillOnDarkBackground.isNull())
{
QColor color;
color.setNamedColor(ubFillOnDarkBackground.toString());
if (!color.isValid())
color = Qt::white;
color.setAlphaF(opacity);
lineItem->setColorOnDarkBackground(color);
}
else
{
QColor color = mGroupDarkBackgroundColor;
color.setAlphaF(opacity);
lineItem->setColorOnDarkBackground(color);
}
QStringRef ubFillOnLightBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-light-background");
if (!ubFillOnLightBackground.isNull())
{
QColor color;
color.setNamedColor(ubFillOnLightBackground.toString());
if (!color.isValid())
color = Qt::black;
color.setAlphaF(opacity);
lineItem->setColorOnLightBackground(color);
}
else
{
QColor color = mGroupLightBackgroundColor;
color.setAlphaF(opacity);
lineItem->setColorOnLightBackground(color);
}
return lineItem;
}
QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemsFromPolylineSvg(const QColor& pDefaultColor)
{
QStringRef strokeWidth = mXmlReader.attributes().value("stroke-width");

@ -38,7 +38,6 @@
class UBGraphicsSvgItem;
class UBGraphicsPolygonItem;
class UBGraphicsLineItem;
class UBGraphicsPixmapItem;
class UBGraphicsPDFItem;
class UBGraphicsWidgetItem;
@ -126,8 +125,6 @@ class UBSvgSubsetAdaptor
QList<UBGraphicsPolygonItem*> polygonItemsFromPolylineSvg(const QColor& pDefaultColor);
UBGraphicsLineItem* lineItemFromLineSvg(const QColor& pDefaultPenColor);
UBGraphicsPixmapItem* pixmapItemFromSvg();
UBGraphicsSvgItem* svgItemFromSvg();
@ -198,7 +195,6 @@ class UBSvgSubsetAdaptor
void persistStrokeToDom(QGraphicsItem *strokeItem, QDomElement *curParent, QDomDocument *curDomDocument);
void polygonItemToSvgPolygon(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo);
void polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo);
void lineItemToSvgLine(UBGraphicsLineItem* lineItem, bool groupHoldsInfo);
void strokeToSvgPolyline(UBGraphicsStroke* stroke, bool groupHoldsInfo);
void strokeToSvgPolygon(UBGraphicsStroke* stroke, bool groupHoldsInfo);

@ -300,7 +300,6 @@ QRectF UBBoardController::controlGeometry()
void UBBoardController::setupToolbar()
{
QAction* newPropertyPaletteWidget;
UBSettings *settings = UBSettings::settings();
// Setup color choice widget
@ -315,7 +314,7 @@ void UBBoardController::setupToolbar()
new UBToolbarButtonGroup(mMainWindow->boardToolBar, colorActions);
colorChoice->setLabel(tr("Color"));
newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, colorChoice);
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, colorChoice);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), colorChoice, SLOT(displayText(QVariant)));
connect(colorChoice, SIGNAL(activated(int)), this, SLOT(setColorIndex(int)));
@ -328,7 +327,6 @@ void UBBoardController::setupToolbar()
colorChoice->colorPaletteChanged();
colorChoice->setCurrentIndex(settings->penColorIndex());
colorActions.at(settings->penColorIndex())->setChecked(true);
mPropertyPaletteWidgets.insert(color, newPropertyPaletteWidget);
// Setup line width choice widget
QList<QAction *> lineWidthActions;
@ -351,8 +349,7 @@ void UBBoardController::setupToolbar()
lineWidthChoice->setCurrentIndex(settings->penWidthIndex());
lineWidthActions.at(settings->penWidthIndex())->setChecked(true);
newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineWidthChoice);
mPropertyPaletteWidgets.insert(lineWidth, newPropertyPaletteWidget);
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineWidthChoice);
//-----------------------------------------------------------//
// Setup eraser width choice widget
@ -365,7 +362,7 @@ void UBBoardController::setupToolbar()
UBToolbarButtonGroup *eraserWidthChoice =
new UBToolbarButtonGroup(mMainWindow->boardToolBar, eraserWidthActions);
newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, eraserWidthChoice);
mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, eraserWidthChoice);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), eraserWidthChoice, SLOT(displayText(QVariant)));
connect(eraserWidthChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setEraserWidthIndex(int)));
@ -375,32 +372,11 @@ void UBBoardController::setupToolbar()
eraserWidthActions.at(settings->eraserWidthIndex())->setChecked(true);
mMainWindow->boardToolBar->insertSeparator(mMainWindow->actionBackgrounds);
mPropertyPaletteWidgets.insert(eraserWidth, newPropertyPaletteWidget);
//-----------------------------------------------------------//
// Setup line style choice widget
QList<QAction *> lineStyleActions;
lineStyleActions.append(mMainWindow->actionLineSolid);
lineStyleActions.append(mMainWindow->actionLineDashed);
lineStyleActions.append(mMainWindow->actionLineDotted);
UBToolbarButtonGroup *lineStyleChoice =
new UBToolbarButtonGroup(mMainWindow->boardToolBar, lineStyleActions);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), lineStyleChoice, SLOT(displayText(QVariant)));
connect(lineStyleChoice, SIGNAL(activated(int)),
UBDrawingController::drawingController(), SLOT(setLineStyleIndex(int)));
lineStyleChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineStyleChoice);
lineStyleChoice->setCurrentIndex(settings->lineStyleIndex());
lineStyleActions.at(settings->lineStyleIndex())->setChecked(true);
mPropertyPaletteWidgets.insert(lineStyle, newPropertyPaletteWidget);
//-----------------------------------------------------------//
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBackgrounds);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard, 40);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard);
UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu);
mMainWindow->actionBoard->setVisible(false);
@ -2209,9 +2185,9 @@ void UBBoardController::saveViewState()
void UBBoardController::stylusToolChanged(int tool)
{
UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
if (UBPlatformUtils::hasVirtualKeyboard() && mPaletteManager->mKeyboardPalette)
{
UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
if(eTool != UBStylusTool::Selector && eTool != UBStylusTool::Text)
{
if(mPaletteManager->mKeyboardPalette->m_isVisible)
@ -2225,34 +2201,6 @@ void UBBoardController::stylusToolChanged(int tool)
}
}
}
if (eTool == UBStylusTool::Pen || eTool == UBStylusTool::Marker)
{
mPropertyPaletteWidgets[color]->setVisible(true);
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Eraser)
{
mPropertyPaletteWidgets[color]->setVisible(false);
mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(true);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Line)
{
mPropertyPaletteWidgets[color]->setVisible(true);
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(true);
} else
{
mPropertyPaletteWidgets[color]->setVisible(false);
mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
}
}

@ -322,15 +322,6 @@ class UBBoardController : public UBDocumentContainer
QTimer *mAutosaveTimer;
enum PropertyPalette
{
color,
lineWidth,
eraserWidth,
lineStyle
};
QMap<PropertyPalette, QAction*> mPropertyPaletteWidgets;
private slots:
void stylusToolDoubleClicked(int tool);
void boardViewResized(QResizeEvent* event);

@ -67,7 +67,6 @@
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsLineItem.h"
#include "domain/UBItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsSvgItem.h"
@ -1105,7 +1104,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
break;
default:
if (UBDrawingController::drawingController()->activeRuler() == nullptr) {
if(UBDrawingController::drawingController()->mActiveRuler==NULL) {
viewport()->setCursor (QCursor (Qt::BlankCursor));
}
if (scene () && !mTabletStylusIsPressed) {
@ -1211,8 +1210,7 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event)
|| item->type() == UBGraphicsSvgItem::Type
|| item->type() == UBGraphicsTextItem::Type
|| item->type() == UBGraphicsStrokesGroup::Type
|| item->type() == UBGraphicsGroupContainerItem::Type
|| item->type() == UBGraphicsLineItem::Type) {
|| item->type() == UBGraphicsGroupContainerItem::Type) {
if (!mJustSelectedItems.contains(item)) {

@ -34,7 +34,6 @@
#include "domain/UBGraphicsScene.h"
#include "board/UBBoardController.h"
#include "tools/UBAbstractDrawRuler.h"
#include "gui/UBMainWindow.h"
#include "core/memcheck.h"
@ -59,6 +58,7 @@ void UBDrawingController::destroy()
UBDrawingController::UBDrawingController(QObject * parent)
: QObject(parent)
, mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1)
, mIsDesktopMode(false)
@ -279,11 +279,6 @@ void UBDrawingController::setEraserWidthIndex(int index)
UBSettings::settings()->setEraserWidthIndex(index);
}
void UBDrawingController::setLineStyleIndex(int index)
{
UBSettings::settings()->setLineStyleIndex(index);
}
void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{
if (onDarkBackground)
@ -327,23 +322,6 @@ void UBDrawingController::setMarkerAlpha(qreal alpha)
emit colorPaletteChanged();
}
void UBDrawingController::setActiveRuler(UBAbstractDrawRuler* ruler)
{
mActiveRuler = ruler;
}
UBAbstractDrawRuler* UBDrawingController::activeRuler() const
{
QGraphicsItem* item = dynamic_cast<QGraphicsItem*>(mActiveRuler.data());
if (item && item->isVisible())
{
return mActiveRuler;
}
return nullptr;
}
void UBDrawingController::penToolSelected(bool checked)
{

@ -64,8 +64,7 @@ class UBDrawingController : public QObject
void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerAlpha(qreal alpha);
void setActiveRuler(UBAbstractDrawRuler* ruler);
UBAbstractDrawRuler* activeRuler() const;
UBAbstractDrawRuler* mActiveRuler;
void setInDesktopMode(bool mode){
mIsDesktopMode = mode;
@ -81,7 +80,6 @@ class UBDrawingController : public QObject
void setLineWidthIndex(int index);
void setColorIndex(int index);
void setEraserWidthIndex(int index);
void setLineStyleIndex(int index);
signals:
void stylusToolChanged(int tool, int previousTool = -1);
@ -91,7 +89,6 @@ class UBDrawingController : public QObject
void colorIndexChanged(int index);
private:
QPointer<UBAbstractDrawRuler> mActiveRuler;
UBStylusTool::Enum mStylusTool;
UBStylusTool::Enum mLatestDrawingTool;
bool mIsDesktopMode;

@ -84,16 +84,6 @@ struct UBWidth
};
};
struct UBLineStyle
{
enum Enum
{
Solid = 0,
Dashed = 1,
Dotted = 2
};
};
struct UBZoom
{
enum Enum
@ -183,7 +173,6 @@ struct UBGraphicsItemType
GraphicsWidgetItemType, //65556
UserTypesCount, //65557
AxesItemType, //65558
LineItemType, //65559
SelectionFrameType // this line must be the last line in this enum because it is types counter.
};
};

@ -785,41 +785,6 @@ qreal UBSettings::currentEraserWidth()
return width;
}
//----------------------------------------//
// line
int UBSettings::lineStyleIndex()
{
return value("Board/LineStyleIndex", 0).toInt();
}
void UBSettings::setLineStyleIndex(int index)
{
setValue("Board/LineStyleIndex", index);
}
Qt::PenStyle UBSettings::currentLineStyle()
{
Qt::PenStyle style = Qt::SolidLine;
switch (lineStyleIndex())
{
case UBLineStyle::Solid:
style = Qt::SolidLine;
break;
case UBLineStyle::Dotted:
style = Qt::DotLine;
break;
case UBLineStyle::Dashed:
style = Qt::DashLine;
break;
default:
Q_ASSERT(false);
style = Qt::SolidLine;
break;
}
return style;
}
bool UBSettings::isDarkBackground()
{
return value("Board/DarkBackground", 0).toBool();

@ -85,10 +85,6 @@ class UBSettings : public QObject
qreal eraserStrongWidth();
qreal currentEraserWidth();
// Line related
int lineStyleIndex();
Qt::PenStyle currentLineStyle();
// Background related
bool isDarkBackground();
UBPageBackground pageBackground();
@ -447,8 +443,6 @@ class UBSettings : public QObject
void setEraserMediumWidth(qreal width);
void setEraserStrongWidth(qreal width);
void setLineStyleIndex(int index);
void setStylusPaletteVisible(bool visible);
void setPenPressureSensitive(bool sensitive);

@ -1,191 +0,0 @@
#include "UBGraphicsLineItem.h"
#include "frameworks/UBGeometryUtils.h"
#include "UBGraphicsScene.h"
#include "core/memcheck.h"
UBGraphicsLineItem::UBGraphicsLineItem (QGraphicsItem * parent)
: QGraphicsLineItem(parent)
, mHasAlpha(false)
, mOriginalWidth(-1)
, mIsNominalLine(false)
{
// NOOP
initialize();
}
UBGraphicsLineItem::UBGraphicsLineItem (const QLineF & line, QGraphicsItem * parent)
: QGraphicsLineItem(line, parent)
, mOriginalWidth(-1)
, mIsNominalLine(false)
{
// NOOP
initialize();
}
UBGraphicsLineItem::UBGraphicsLineItem (const QLineF& pLine, qreal pWidth)
: QGraphicsLineItem(pLine)
, mOriginalLine(pLine)
, mOriginalWidth(pWidth)
, mIsNominalLine(true)
{
// NOOP
initialize();
}
UBGraphicsLineItem::UBGraphicsLineItem (const QLineF& pLine, qreal pStartWidth, qreal pEndWidth)
: QGraphicsLineItem(pLine)
, mOriginalLine(pLine)
, mOriginalWidth(pEndWidth)
, mIsNominalLine(true)
{
// NOOP
initialize();
}
void UBGraphicsLineItem::initialize()
{
//setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::DrawingItem)); //Necessary to set if we want z value to be assigned correctly
setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
| GF_RESPECT_RATIO
| GF_REVOLVABLE
| GF_FLIPPABLE_ALL_AXIS));
setUuid(QUuid::createUuid());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
}
void UBGraphicsLineItem::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
UBGraphicsLineItem::~UBGraphicsLineItem()
{
}
void UBGraphicsLineItem::setColor(const QColor& pColor)
{
QPen pen = QPen(pColor);
pen.setStyle(style());
if (style()==Qt::PenStyle::DotLine)
{
pen.setCapStyle(Qt::PenCapStyle::RoundCap);
}
pen.setWidth(mOriginalWidth);
QGraphicsLineItem::setPen(pen);
mHasAlpha = (pColor.alphaF() < 1.0);
}
QColor UBGraphicsLineItem::color() const
{
return QGraphicsLineItem::pen().color();
}
void UBGraphicsLineItem::setStyle(const Qt::PenStyle& style)
{
QPen pen = QPen(color());
pen.setStyle(style);
if (style==Qt::PenStyle::DotLine)
{
pen.setCapStyle(Qt::PenCapStyle::RoundCap);
}
pen.setWidth(mOriginalWidth);
QGraphicsLineItem::setPen(pen);
}
Qt::PenStyle UBGraphicsLineItem::style() const
{
return QGraphicsLineItem::pen().style();
}
QList<QPointF> UBGraphicsLineItem::linePoints()
{
QList<QPointF> points = QList<QPointF>();
qreal incr = 1/line().length();
if (incr<0) incr*=-1;
if (incr>0)
{
for (qreal t = 0; t <= 1; t+=incr)
{
points.push_back(line().pointAt(t));
}
}
return points;
}
UBItem* UBGraphicsLineItem::deepCopy() const
{
UBGraphicsLineItem* copy = new UBGraphicsLineItem(line());
copyItemParameters(copy);
return copy;
}
void UBGraphicsLineItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsLineItem *cp = dynamic_cast<UBGraphicsLineItem*>(copy);
if (cp)
{
cp->mOriginalLine = this->mOriginalLine;
cp->mOriginalWidth = this->mOriginalWidth;
cp->mIsNominalLine = this->mIsNominalLine;
cp->setTransform(transform());
cp->setPos(pos());
cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha;
cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setZValue(this->zValue());
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
}
}
void UBGraphicsLineItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option);
if(mHasAlpha && scene() && scene()->isLightBackground())
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
painter->setRenderHints(QPainter::Antialiasing);
QGraphicsLineItem::paint(painter, option, widget);
Delegate()->postpaint(painter, &styleOption, widget);
}
UBGraphicsScene* UBGraphicsLineItem::scene()
{
return qobject_cast<UBGraphicsScene*>(QGraphicsLineItem::scene());
}
void UBGraphicsLineItem::SetDelegate()
{
Delegate()->createControls();
}
QVariant UBGraphicsLineItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant newValue = Delegate()->itemChange(change, value);
UBGraphicsItem *item = dynamic_cast<UBGraphicsItem*>(this);
if (item)
{
item->Delegate()->positionHandles();
}
return QGraphicsItem::itemChange(change, newValue);
}

@ -1,100 +0,0 @@
#ifndef UBGRAPHICSLINEITEM_H
#define UBGRAPHICSLINEITEM_H
#include <QtGui>
#include "core/UB.h"
#include "UBItem.h"
class UBItem;
class UBGraphicsScene;
class UBGraphicsLineItem : public QGraphicsLineItem, public UBItem, public UBGraphicsItem
{
public:
UBGraphicsLineItem(QGraphicsItem * parent = 0 );
UBGraphicsLineItem(const QLineF& line, qreal pWidth);
UBGraphicsLineItem(const QLineF& pLine, qreal pStartWidth, qreal pEndWidth);
UBGraphicsLineItem(const QLineF & line, QGraphicsItem * parent = 0);
~UBGraphicsLineItem();
void initialize();
void setUuid(const QUuid &pUuid);
void setColor(const QColor& color);
void setStyle(const Qt::PenStyle& style);
QColor color() const;
Qt::PenStyle style() const;
virtual UBGraphicsScene* scene();
enum { Type = UBGraphicsItemType::LineItemType };
virtual int type() const
{
return Type;
}
void setLine(const QLineF pLine)
{
mIsNominalLine = false;
QGraphicsLineItem::setLine(pLine);
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
QLineF originalLine() { return mOriginalLine;}
qreal originalWidth() { return mOriginalWidth;}
bool isNominalLine() {return mIsNominalLine;}
void setNominalLine(bool isNominalLine) { mIsNominalLine = isNominalLine; }
QList<QPointF> linePoints();
QColor colorOnDarkBackground() const
{
return mColorOnDarkBackground;
}
void setColorOnDarkBackground(QColor pColorOnDarkBackground)
{
mColorOnDarkBackground = pColorOnDarkBackground;
}
QColor colorOnLightBackground() const
{
return mColorOnLightBackground;
}
void setColorOnLightBackground(QColor pColorOnLightBackground)
{
mColorOnLightBackground = pColorOnLightBackground;
}
void SetDelegate();
protected:
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
bool mHasAlpha;
QLineF mOriginalLine;
qreal mOriginalWidth;
bool mIsNominalLine;
QColor mColorOnDarkBackground;
QColor mColorOnLightBackground;
};
#endif // UBGRAPHICSLINEITEM_H

@ -70,7 +70,6 @@
#include "UBGraphicsPixmapItem.h"
#include "UBGraphicsSvgItem.h"
#include "UBGraphicsPolygonItem.h"
#include "UBGraphicsLineItem.h"
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsWidgetItem.h"
#include "UBGraphicsPDFItem.h"
@ -452,8 +451,8 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mAddedItems.clear();
mRemovedItems.clear();
if (UBDrawingController::drawingController()->activeRuler())
UBDrawingController::drawingController()->activeRuler()->StartLine(scenePos, width);
if (UBDrawingController::drawingController()->mActiveRuler)
UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width);
else {
moveTo(scenePos);
drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
@ -540,8 +539,25 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width /= UBApplication::boardController->systemScaleFactor();
width /= UBApplication::boardController->currentZoom();
if (currentTool == UBStylusTool::Line || dc->activeRuler())
if (currentTool == UBStylusTool::Line || dc->mActiveRuler)
{
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker)
if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){
UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon);
mAddedItems.remove(mpLastPolygon);
mCurrentStroke->remove(mpLastPolygon);
if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
removeItem(mpLastPolygon);
mPreviousPolygonItems.removeAll(mpLastPolygon);
}
// ------------------------------------------------------------------------
// Here we wanna make sure that the Line will 'grip' at i*45, i*90 degrees
// ------------------------------------------------------------------------
QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle();
angle = qRound(angle / 45) * 45;
@ -557,8 +573,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
if (!mCurrentStroke)
mCurrentStroke = new UBGraphicsStroke(this);
if(dc->activeRuler()){
dc->activeRuler()->DrawLine(position, width);
if(dc->mActiveRuler){
dc->mActiveRuler->DrawLine(position, width);
}
else if (currentTool == UBStylusTool::Line) {
@ -651,16 +667,7 @@ bool UBGraphicsScene::inputDeviceRelease(int tool)
if (currentTool == UBStylusTool::Eraser)
hideEraser();
if(currentTool == UBStylusTool::Line)
{
if (mUndoRedoStackEnabled)
{ //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, NULL, mpLastLine);
UBApplication::undoStack->push(uc);
mAddedItems.clear();
}
} else{
UBDrawingController *dc = UBDrawingController::drawingController();
@ -734,7 +741,6 @@ bool UBGraphicsScene::inputDeviceRelease(int tool)
mCurrentPolygon = 0;
}
}
}
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0)
{
@ -853,7 +859,7 @@ void UBGraphicsScene::drawPenCircle(const QPointF &pPoint)
cursor = UBResources::resources()->penCursor;
}
if (!UBDrawingController::drawingController()->activeRuler())
if (!UBDrawingController::drawingController()->mActiveRuler)
{
// set cursor only if no active ruler
if (controlView() && controlView()->viewport())
@ -937,17 +943,8 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &startWid
mAddedItems.clear();
}
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line)
{
UBGraphicsPolygonItem *polygonItem = lineToPolygonItem(QLineF(mPreviousPoint, pEndPoint), initialWidth, endWidth);
addPolygonItemToCurrentStroke(polygonItem);
} else
{
UBGraphicsLineItem *lineItem = new UBGraphicsLineItem(QLineF(mPreviousPoint, pEndPoint), initialWidth, endWidth);
initLineItem(lineItem);
addLineItemToCurrentStroke(lineItem);
}
if (!bLineStyle) {
mPreviousPoint = pEndPoint;
@ -1001,20 +998,6 @@ void UBGraphicsScene::addPolygonItemToCurrentStroke(UBGraphicsPolygonItem* polyg
}
void UBGraphicsScene::addLineItemToCurrentStroke(UBGraphicsLineItem* lineItem)
{
lineItem->setFlag(QGraphicsItem::ItemIsMovable, true);
lineItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
lineItem->SetDelegate();
mpLastLine = lineItem;
mAddedItems.insert(lineItem);
// Here we add the item to the scene
addItem(lineItem);
}
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
{
const QLineF line(mPreviousPoint, pEndPoint);
@ -1034,15 +1017,13 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
typedef QList<QPolygonF> POLYGONSLIST;
QList<POLYGONSLIST> intersectedPolygons;
QList<UBGraphicsLineItem*> intersectedLineItems;
#pragma omp parallel for
for(int i=0; i<collidItems.size(); i++)
{
UBGraphicsPolygonItem *pi = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems[i]);
UBGraphicsLineItem *li = qgraphicsitem_cast<UBGraphicsLineItem*>(collidItems[i]);
if(pi != NULL)
{
if(pi == NULL)
continue;
QPainterPath itemPainterPath;
itemPainterPath.addPolygon(pi->sceneTransform().map(pi->polygon()));
@ -1065,23 +1046,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
intersectedPolygons << newPath.simplified().toFillPolygons(pi->sceneTransform().inverted());
}
}
} else if (li != NULL)
{
QPainterPath itemPainterPath;
QList<QPointF> linePoints = li->linePoints();
for (int i=0; i < linePoints.count(); ++i)
{
itemPainterPath.addEllipse(linePoints[i], 1, 1);
}
if (eraserPath.contains(itemPainterPath) || eraserPath.intersects(itemPainterPath))
{
#pragma omp critical
{
// Compete remove item
intersectedLineItems << li;
}
}
}
}
for(int i=0; i<intersectedItems.size(); i++)
@ -1129,21 +1093,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
intersectedPolygonItem->setTransform(t);
}
for (int i=0; i<intersectedLineItems.size(); i++)
{
UBGraphicsLineItem *intersectedLineItem = intersectedLineItems[i];
mRemovedItems << intersectedLineItem;
QTransform t;
bool bApplyTransform = false;
removeItem(intersectedLineItem);
if (bApplyTransform)
{
intersectedLineItem ->setTransform(t);
}
}
if (!intersectedItems.empty() || !intersectedLineItems.empty())
if (!intersectedItems.empty())
setModified(true);
}
@ -1321,37 +1271,6 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem)
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
}
void UBGraphicsScene::initLineItem(UBGraphicsLineItem* lineItem)
{
QColor colorOnDarkBG;
QColor colorOnLightBG;
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker)
{
colorOnDarkBG = UBApplication::boardController->penColorOnDarkBackground();
colorOnLightBG = UBApplication::boardController->penColorOnLightBackground();
}
if (mDarkBackground)
{
lineItem->setColor(colorOnDarkBG);
}
else
{
lineItem->setColor(colorOnLightBG);
}
lineItem->setColorOnDarkBackground(colorOnDarkBG);
lineItem->setColorOnLightBackground(colorOnLightBG);
lineItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
lineItem->setStyle(UBSettings::settings()->currentLineStyle());
QPen linePen = lineItem->pen();
linePen.setWidth(lineItem->originalWidth());
lineItem->setPen(linePen);
}
UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth)
{
QPolygonF polygon = UBGeometryUtils::arcToPolygon(pStartRadius, pSpanAngle, pWidth);
@ -1572,7 +1491,7 @@ void UBGraphicsScene::clearContent(clearCase pCase)
? qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item->parentItem())
: 0;
UBGraphicsItemDelegate *curDelegate = UBGraphicsItem::Delegate(item);
if (!curDelegate && item->type() != UBGraphicsLineItem::Type) {
if (!curDelegate) {
continue;
}
@ -1580,12 +1499,6 @@ void UBGraphicsScene::clearContent(clearCase pCase)
bool isStrokesGroup = item->type() == UBGraphicsStrokesGroup::Type;
bool shouldDelete = false;
if(item->type()==UBGraphicsLineItem::Type)
{
removedItems << item;
this->removeItem(item);
} else
{
switch (static_cast<int>(pCase)) {
case clearAnnotations :
shouldDelete = isStrokesGroup;
@ -1597,7 +1510,6 @@ void UBGraphicsScene::clearContent(clearCase pCase)
shouldDelete = !isGroup && !isBackgroundObject(item);
break;
}
}
if(shouldDelete) {
if (itemGroup) {

@ -41,7 +41,6 @@ class UBGraphicsPixmapItem;
class UBGraphicsProxyWidget;
class UBGraphicsSvgItem;
class UBGraphicsPolygonItem;
class UBGraphicsLineItem;
class UBGraphicsMediaItem;
class UBGraphicsWidgetItem;
class UBGraphicsW3CWidgetItem;
@ -401,11 +400,8 @@ public slots:
UBGraphicsPolygonItem* curveToPolygonItem(const QList<QPair<QPointF, qreal> > &points);
UBGraphicsPolygonItem* curveToPolygonItem(const QList<QPointF> &points, qreal startWidth, qreal endWidth);
void addPolygonItemToCurrentStroke(UBGraphicsPolygonItem* polygonItem);
void addLineItemToCurrentStroke(UBGraphicsLineItem* lineItem);
void initPolygonItem(UBGraphicsPolygonItem*);
void initLineItem(UBGraphicsLineItem*);
void drawEraser(const QPointF& pEndPoint, bool pressed = true);
void redrawEraser(bool pressed);
@ -497,7 +493,6 @@ public slots:
UBZLayerController *mZLayerController;
UBGraphicsPolygonItem* mpLastPolygon;
UBGraphicsPolygonItem* mTempPolygon;
UBGraphicsLineItem* mpLastLine;
bool mDrawWithCompass;
UBGraphicsPolygonItem *mCurrentPolygon;

@ -41,7 +41,6 @@
#include "domain/UBGraphicsScene.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/UBGraphicsLineItem.h"
UBItem::UBItem()
: mUuid(QUuid())
@ -136,8 +135,6 @@ UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem)
case UBGraphicsCurtainItem::Type :
result = (static_cast<UBGraphicsCurtainItem*>(pItem))->Delegate();
break;
case UBGraphicsLineItem::Type :
result = (static_cast<UBGraphicsLineItem*>(pItem))->Delegate();
}
return result;

@ -6,7 +6,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBPageSizeUndoCommand.h \
src/domain/UBGraphicsProxyWidget.h \
src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsLineItem.h \
src/domain/UBGraphicsPolygonItem.h \
src/domain/UBItem.h \
src/domain/UBGraphicsWidgetItem.h \
@ -36,7 +35,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBPageSizeUndoCommand.cpp \
src/domain/UBGraphicsProxyWidget.cpp \
src/domain/UBGraphicsSvgItem.cpp \
src/domain/UBGraphicsLineItem.cpp \
src/domain/UBGraphicsPolygonItem.cpp \
src/domain/UBItem.cpp \
src/domain/UBGraphicsWidgetItem.cpp \

@ -420,6 +420,9 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (UBDrawingController::drawingController()->mActiveRuler == nullptr)
UBDrawingController::drawingController()->mActiveRuler = this;
if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play)
{
@ -450,7 +453,6 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
else if (UBDrawingController::drawingController()->isDrawingTool())
{
setCursor(drawRulerLineCursor());
UBDrawingController::drawingController()->setActiveRuler(this);
event->accept();
}
}
@ -462,7 +464,7 @@ void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mCloseSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons);
UBDrawingController::drawingController()->setActiveRuler(nullptr);
UBDrawingController::drawingController()->mActiveRuler = nullptr;
event->accept();
update();
}

@ -886,7 +886,7 @@ void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
} else if (UBDrawingController::drawingController()->isDrawingTool()) {
setCursor(drawRulerLineCursor());
UBDrawingController::drawingController()->setActiveRuler(this);
UBDrawingController::drawingController()->mActiveRuler = this;
event->accept();
}
@ -904,7 +904,7 @@ void UBGraphicsTriangle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mVFlipSvgItem->setVisible(false);
mHFlipSvgItem->setVisible(false);
mRotateSvgItem->setVisible(false);
UBDrawingController::drawingController()->setActiveRuler(nullptr);
UBDrawingController::drawingController()->mActiveRuler = NULL;
event->accept();
update();
}

Loading…
Cancel
Save