Compare commits

..

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

  1. 67
      resources/forms/mainWindow.ui
  2. 103
      src/adaptors/UBCFFSubsetAdaptor.cpp
  3. 1
      src/adaptors/UBCFFSubsetAdaptor.h
  4. 240
      src/adaptors/UBSvgSubsetAdaptor.cpp
  5. 4
      src/adaptors/UBSvgSubsetAdaptor.h
  6. 4
      src/api/UBWidgetUniboardAPI.cpp
  7. 36
      src/board/UBBoardController.cpp
  8. 3
      src/board/UBBoardController.h
  9. 5
      src/board/UBBoardView.cpp
  10. 27
      src/board/UBDrawingController.cpp
  11. 2
      src/board/UBDrawingController.h
  12. 12
      src/core/UB.h
  13. 30
      src/core/UBSettings.cpp
  14. 5
      src/core/UBSettings.h
  15. 103
      src/domain/UBGraphicsScene.cpp
  16. 4
      src/domain/UBGraphicsScene.h
  17. 225
      src/domain/UBGraphicsVectorItem.cpp
  18. 119
      src/domain/UBGraphicsVectorItem.h
  19. 2
      src/domain/domain.pri
  20. 1
      src/gui/UBStylusPalette.cpp
  21. 1
      src/gui/UBToolbarButtonGroup.cpp

@ -1750,73 +1750,6 @@
<string>Dotted Style</string> <string>Dotted Style</string>
</property> </property>
</action> </action>
<action name="actionVector">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/stylusPalette/line.svg</normaloff>
<normalon>:/images/stylusPalette/lineOn.svg</normalon>:/images/stylusPalette/line.svg</iconset>
</property>
<property name="text">
<string>Vector</string>
</property>
<property name="toolTip">
<string>Draw Vectors</string>
</property>
<property name="shortcut">
<string>Ctrl+J</string>
</property>
</action>
<action name="actionVectorTo">
<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>Vector Style</string>
</property>
<property name="toolTip">
<string>To Style</string>
</property>
</action>
<action name="actionVectorFrom">
<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>Vector Style</string>
</property>
<property name="toolTip">
<string>From Style</string>
</property>
</action>
<action name="actionVectorFromTo">
<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>Vector Style</string>
</property>
<property name="toolTip">
<string>FromTo Style</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../OpenBoard.qrc"/> <include location="../OpenBoard.qrc"/>

@ -39,7 +39,6 @@
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "domain/UBGraphicsPolygonItem.h" #include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsLineItem.h" #include "domain/UBGraphicsLineItem.h"
#include "domain/UBGraphicsVectorItem.h"
#include "domain/UBGraphicsStroke.h" #include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
@ -77,7 +76,6 @@ static QString tSwitch = "switch";
static QString tPolygon = "polygon"; static QString tPolygon = "polygon";
static QString tPolyline = "polyline"; static QString tPolyline = "polyline";
static QString tLine = "line"; static QString tLine = "line";
static QString tVector = "vector";
static QString tRect = "rect"; static QString tRect = "rect";
static QString tSvg = "svg"; static QString tSvg = "svg";
static QString tText = "text"; static QString tText = "text";
@ -122,7 +120,6 @@ static QString aBackground = "background";
static QString aLocked = "locked"; static QString aLocked = "locked";
static QString aEditable = "editable"; static QString aEditable = "editable";
static QString aLinestyle = "line-style"; static QString aLinestyle = "line-style";
static QString aVectorstyle = "vector-style";
//attributes part names //attributes part names
static QString apRotate = "rotate"; static QString apRotate = "rotate";
@ -691,105 +688,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgLine(const QDomElement &elem
return true; return true;
} }
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVector(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(aVectorstyle).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);
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
{
UBGraphicsVectorItem *graphicsVector = new UBGraphicsVectorItem(line);
graphicsVector->setPen(pen);
QTransform transform;
QString textTransform = element.attribute(aTransform);
if (style == 2)
{
graphicsVector->setStyle(UBVectorStyle::FromTo);
} else if (style == 1)
{
graphicsVector->setStyle(UBVectorStyle::From);
} else
{
graphicsVector->setStyle(UBVectorStyle::To);
}
graphicsVector->resetTransform();
if (!textTransform.isNull()) {
transform = transformFromString(textTransform, graphicsVector);
}
mCurrentScene->addItem(graphicsVector);
graphicsVector->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, void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElement &element,
qreal &fontSize, QColor &fontColor, QString &fontFamily, qreal &fontSize, QColor &fontColor, QString &fontFamily,
QString &fontStretch, bool &italic, int &fontWeight, QString &fontStretch, bool &italic, int &fontWeight,
@ -1311,7 +1209,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &p
else if (tagName == tPolygon && !parseSvgPolygon(parent)) return false; else if (tagName == tPolygon && !parseSvgPolygon(parent)) return false;
else if (tagName == tPolyline && !parseSvgPolyline(parent)) return false; else if (tagName == tPolyline && !parseSvgPolyline(parent)) return false;
else if (tagName == tLine && !parseSvgLine(parent)) return false; else if (tagName == tLine && !parseSvgLine(parent)) return false;
else if (tagName == tVector && !parseSvgVector(parent)) return false;
else if (tagName == tText && !parseSvgText(parent)) return false; else if (tagName == tText && !parseSvgText(parent)) return false;
else if (tagName == tTextarea && !parseSvgTextarea(parent)) return false; else if (tagName == tTextarea && !parseSvgTextarea(parent)) return false;
else if (tagName == tImage && !parseSvgImage(parent)) return false; else if (tagName == tImage && !parseSvgImage(parent)) return false;

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

@ -41,7 +41,6 @@
#include "domain/UBGraphicsProxyWidget.h" #include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsPolygonItem.h" #include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsLineItem.h" #include "domain/UBGraphicsLineItem.h"
#include "domain/UBGraphicsVectorItem.h"
#include "domain/UBGraphicsMediaItem.h" #include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPDFItem.h" #include "domain/UBGraphicsPDFItem.h"
@ -660,45 +659,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
group->addToGroup(lineItem); group->addToGroup(lineItem);
} }
} }
else if (mXmlReader.name() == "vector")
{
UBGraphicsVectorItem* vectorItem = 0;
QString parentId = mXmlReader.attributes().value(mNamespaceUri, "parent").toString();
vectorItem = vectorItemFromVectorSvg(mScene->isDarkBackground() ? Qt::white : Qt::black);
if(parentId.isEmpty() && strokesGroup)
parentId = strokesGroup->uuid().toString();
if(parentId.isEmpty())
parentId = QUuid::createUuid().toString();
if (vectorItem)
{
vectorItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
UBGraphicsStrokesGroup* group;
if(!mStrokesList.contains(parentId)){
group = new UBGraphicsStrokesGroup();
mStrokesList.insert(parentId,group);
group->setTransform(vectorItem->transform());
UBGraphicsItem::assignZValue(group, vectorItem->zValue());
}
else
group = mStrokesList.value(parentId);
if (!currentStroke)
currentStroke = new UBGraphicsStroke();
if(vectorItem->transform().isIdentity())
vectorItem->setTransform(group->transform());
group->addToGroup(vectorItem);
vectorItem->show();
group->addToGroup(vectorItem);
}
}
else if (mXmlReader.name() == "polyline") else if (mXmlReader.name() == "polyline")
{ {
QList<UBGraphicsPolygonItem*> polygonItems = polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); QList<UBGraphicsPolygonItem*> polygonItems = polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black);
@ -1424,48 +1384,6 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(UBDocumentProxy* proxy,
continue; continue;
} }
// Is the item a vector?
UBGraphicsVectorItem *vectorItem = qgraphicsitem_cast<UBGraphicsVectorItem*> (item);
if (vectorItem && vectorItem->isVisible())
{
mXmlWriter.writeStartElement("g");
QColor colorOnDarkBackground = vectorItem->colorOnDarkBackground();
QColor colorOnLightBackground = vectorItem->colorOnLightBackground();
if (colorOnDarkBackground.isValid() && colorOnLightBackground.isValid())
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value"
, QString("%1").arg(vectorItem->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(vectorItem->uuid()));
QVariant locked = vectorItem->data(UBGraphicsItemData::ItemLocked);
if (!locked.isNull() && locked.toBool())
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "locked", xmlTrue);
QVariant layer = vectorItem->data(UBGraphicsItemData::ItemLayerType);
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "layer", QString("%1").arg(layer.toInt()));
QMatrix matrix = vectorItem->sceneMatrix();
if (!matrix.isIdentity())
mXmlWriter.writeAttribute("transform", toSvgTransform(matrix));
qDebug() << "Attributes written";
groupHoldsInfo = true;
}
vectorItemToSvgVector(vectorItem, groupHoldsInfo);
continue;
}
if (openStroke) if (openStroke)
{ {
mXmlWriter.writeEndElement(); //g mXmlWriter.writeEndElement(); //g
@ -1769,54 +1687,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::lineItemToSvgLine(UBGraphicsLineItem
} }
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::vectorItemToSvgVector(UBGraphicsVectorItem* vectorItem, bool groupHoldsInfo)
{
mXmlWriter.writeStartElement("vector");
QLineF line = vectorItem->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(vectorItem->originalWidth(), 'f', -1));
mXmlWriter.writeAttribute("stroke", vectorItem->pen().color().name());
qreal alpha = vectorItem->pen().color().alphaF();
if (alpha < 1.0)
mXmlWriter.writeAttribute("stroke-opacity", QString::number(alpha, 'f', 2));
mXmlWriter.writeAttribute("stroke-linecap", "round");
switch (vectorItem->getStyle())
{
case UBVectorStyle::From:
mXmlWriter.writeAttribute("vector-style", "1");
break;
case UBVectorStyle::FromTo:
mXmlWriter.writeAttribute("vector-style", "2");
break;
default:
mXmlWriter.writeAttribute("vector-style", "0");
}
if (!groupHoldsInfo)
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value", QString("%1").arg(vectorItem->zValue()));
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "fill-on-dark-background", vectorItem->colorOnDarkBackground().name());
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "fill-on-light-background", vectorItem->colorOnLightBackground().name());
}
mXmlWriter.writeEndElement();
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::strokeToSvgPolyline(UBGraphicsStroke* stroke, bool groupHoldsInfo) void UBSvgSubsetAdaptor::UBSvgSubsetWriter::strokeToSvgPolyline(UBGraphicsStroke* stroke, bool groupHoldsInfo)
{ {
QList<UBGraphicsPolygonItem*> pols = stroke->polygons(); QList<UBGraphicsPolygonItem*> pols = stroke->polygons();
@ -2270,116 +2140,6 @@ UBGraphicsLineItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::lineItemFromLineSvg(c
return lineItem; return lineItem;
} }
UBGraphicsVectorItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::vectorItemFromVectorSvg(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("vector-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 'vector' value";
return 0;
}
QStringRef strokeWidth = mXmlReader.attributes().value("stroke-width");
qreal lineWidth = 1.;
if (!strokeWidth.isNull())
{
lineWidth = strokeWidth.toString().toFloat();
}
UBGraphicsVectorItem* vectorItem = new UBGraphicsVectorItem(line, lineWidth);
graphicsItemFromSvg(vectorItem);
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);
}
vectorItem->setColor(penColor);
if (style == 2)
{
vectorItem->setStyle(UBVectorStyle::FromTo);
} else if (style == 1)
{
vectorItem->setStyle(UBVectorStyle::From);
} else
{
vectorItem->setStyle(UBVectorStyle::To);
}
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);
vectorItem->setColorOnDarkBackground(color);
}
else
{
QColor color = mGroupDarkBackgroundColor;
color.setAlphaF(opacity);
vectorItem->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);
vectorItem->setColorOnLightBackground(color);
}
else
{
QColor color = mGroupLightBackgroundColor;
color.setAlphaF(opacity);
vectorItem->setColorOnLightBackground(color);
}
return vectorItem;
}
QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemsFromPolylineSvg(const QColor& pDefaultColor) QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemsFromPolylineSvg(const QColor& pDefaultColor)
{ {
QStringRef strokeWidth = mXmlReader.attributes().value("stroke-width"); QStringRef strokeWidth = mXmlReader.attributes().value("stroke-width");

@ -39,7 +39,6 @@
class UBGraphicsSvgItem; class UBGraphicsSvgItem;
class UBGraphicsPolygonItem; class UBGraphicsPolygonItem;
class UBGraphicsLineItem; class UBGraphicsLineItem;
class UBGraphicsVectorItem;
class UBGraphicsPixmapItem; class UBGraphicsPixmapItem;
class UBGraphicsPDFItem; class UBGraphicsPDFItem;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
@ -129,8 +128,6 @@ class UBSvgSubsetAdaptor
UBGraphicsLineItem* lineItemFromLineSvg(const QColor& pDefaultPenColor); UBGraphicsLineItem* lineItemFromLineSvg(const QColor& pDefaultPenColor);
UBGraphicsVectorItem* vectorItemFromVectorSvg(const QColor& pDefaultPenColor);
UBGraphicsPixmapItem* pixmapItemFromSvg(); UBGraphicsPixmapItem* pixmapItemFromSvg();
UBGraphicsSvgItem* svgItemFromSvg(); UBGraphicsSvgItem* svgItemFromSvg();
@ -202,7 +199,6 @@ class UBSvgSubsetAdaptor
void polygonItemToSvgPolygon(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo); void polygonItemToSvgPolygon(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo);
void polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo); void polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo);
void lineItemToSvgLine(UBGraphicsLineItem* lineItem, bool groupHoldsInfo); void lineItemToSvgLine(UBGraphicsLineItem* lineItem, bool groupHoldsInfo);
void vectorItemToSvgVector(UBGraphicsVectorItem* vectorItem, bool groupHoldsInfo);
void strokeToSvgPolyline(UBGraphicsStroke* stroke, bool groupHoldsInfo); void strokeToSvgPolyline(UBGraphicsStroke* stroke, bool groupHoldsInfo);
void strokeToSvgPolygon(UBGraphicsStroke* stroke, bool groupHoldsInfo); void strokeToSvgPolygon(UBGraphicsStroke* stroke, bool groupHoldsInfo);

@ -145,10 +145,6 @@ void UBWidgetUniboardAPI::setTool(const QString& toolString)
{ {
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line);
} }
else if (lower == "vector")
{
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Vector);
}
} }

@ -399,28 +399,6 @@ void UBBoardController::setupToolbar()
//-----------------------------------------------------------// //-----------------------------------------------------------//
// Setup vector style choice widget
QList<QAction *> vectorStyleActions;
vectorStyleActions.append(mMainWindow->actionVectorTo);
vectorStyleActions.append(mMainWindow->actionVectorFrom);
vectorStyleActions.append(mMainWindow->actionVectorFromTo);
UBToolbarButtonGroup *vectorStyleChoice =
new UBToolbarButtonGroup(mMainWindow->boardToolBar, vectorStyleActions);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), vectorStyleChoice, SLOT(displayText(QVariant)));
connect(vectorStyleChoice, SIGNAL(activated(int)),
UBDrawingController::drawingController(), SLOT(setVectorStyleIndex(int)));
vectorStyleChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, vectorStyleChoice);
vectorStyleChoice->setCurrentIndex(settings->vectorStyleIndex());
vectorStyleActions.at(settings->vectorStyleIndex())->setChecked(true);
mPropertyPaletteWidgets.insert(vectorStyle, newPropertyPaletteWidget);
//-----------------------------------------------------------//
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBackgrounds); UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBackgrounds);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard, 40); UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard, 40);
UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu); UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu);
@ -2027,7 +2005,6 @@ void UBBoardController::setColorIndex(int pColorIndex)
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker && if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line && UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Vector &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Text && UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Text &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Selector) UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Selector)
{ {
@ -2036,7 +2013,6 @@ void UBBoardController::setColorIndex(int pColorIndex)
if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen || if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Vector ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Text || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Text ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector) UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{ {
@ -2255,7 +2231,6 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(true); mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false); mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false); mPropertyPaletteWidgets[lineStyle]->setVisible(false);
mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} else } else
if (eTool == UBStylusTool::Eraser) if (eTool == UBStylusTool::Eraser)
{ {
@ -2263,7 +2238,6 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(false); mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(true); mPropertyPaletteWidgets[eraserWidth]->setVisible(true);
mPropertyPaletteWidgets[lineStyle]->setVisible(false); mPropertyPaletteWidgets[lineStyle]->setVisible(false);
mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} else } else
if (eTool == UBStylusTool::Line) if (eTool == UBStylusTool::Line)
{ {
@ -2271,22 +2245,12 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(true); mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false); mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(true); mPropertyPaletteWidgets[lineStyle]->setVisible(true);
mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Vector)
{
mPropertyPaletteWidgets[color]->setVisible(true);
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
mPropertyPaletteWidgets[vectorStyle]->setVisible(true);
} else } else
{ {
mPropertyPaletteWidgets[color]->setVisible(false); mPropertyPaletteWidgets[color]->setVisible(false);
mPropertyPaletteWidgets[lineWidth]->setVisible(false); mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false); mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false); mPropertyPaletteWidgets[lineStyle]->setVisible(false);
mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} }

@ -327,8 +327,7 @@ class UBBoardController : public UBDocumentContainer
color, color,
lineWidth, lineWidth,
eraserWidth, eraserWidth,
lineStyle, lineStyle
vectorStyle
}; };
QMap<PropertyPalette, QAction*> mPropertyPaletteWidgets; QMap<PropertyPalette, QAction*> mPropertyPaletteWidgets;

@ -368,7 +368,7 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
QPointF scenePos = viewportTransform ().inverted ().map (tabletPos); QPointF scenePos = viewportTransform ().inverted ().map (tabletPos);
qreal pressure = 1.0; qreal pressure = 1.0;
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line || currentTool == UBStylusTool::Vector) && mPenPressureSensitive) || if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) && mPenPressureSensitive) ||
(currentTool == UBStylusTool::Marker && mMarkerPressureSensitive)) (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
pressure = event->pressure (); pressure = event->pressure ();
else{ else{
@ -1823,9 +1823,6 @@ void UBBoardView::setToolCursor (int tool)
case UBStylusTool::Line: case UBStylusTool::Line:
controlViewport->setCursor (UBResources::resources ()->penCursor); controlViewport->setCursor (UBResources::resources ()->penCursor);
break; break;
case UBStylusTool::Vector:
controlViewport->setCursor (UBResources::resources ()->penCursor);
break;
case UBStylusTool::Text: case UBStylusTool::Text:
controlViewport->setCursor (UBResources::resources ()->textCursor); controlViewport->setCursor (UBResources::resources ()->textCursor);
break; break;

@ -75,7 +75,6 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool))); connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool)));
connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered(bool)), this, SLOT(pointerToolSelected(bool))); connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered(bool)), this, SLOT(pointerToolSelected(bool)));
connect(UBApplication::mainWindow->actionLine, SIGNAL(triggered(bool)), this, SLOT(lineToolSelected(bool))); connect(UBApplication::mainWindow->actionLine, SIGNAL(triggered(bool)), this, SLOT(lineToolSelected(bool)));
connect(UBApplication::mainWindow->actionVector, SIGNAL(triggered(bool)), this, SLOT(vectorToolSelected(bool)));
connect(UBApplication::mainWindow->actionText, SIGNAL(triggered(bool)), this, SLOT(textToolSelected(bool))); connect(UBApplication::mainWindow->actionText, SIGNAL(triggered(bool)), this, SLOT(textToolSelected(bool)));
connect(UBApplication::mainWindow->actionCapture, SIGNAL(triggered(bool)), this, SLOT(captureToolSelected(bool))); connect(UBApplication::mainWindow->actionCapture, SIGNAL(triggered(bool)), this, SLOT(captureToolSelected(bool)));
} }
@ -105,12 +104,12 @@ void UBDrawingController::setStylusTool(int tool)
{ {
UBApplication::boardController->activeScene()->deselectAllItems(); UBApplication::boardController->activeScene()->deselectAllItems();
if (mStylusTool == UBStylusTool::Pen || mStylusTool == UBStylusTool::Marker if (mStylusTool == UBStylusTool::Pen || mStylusTool == UBStylusTool::Marker
|| mStylusTool == UBStylusTool::Line || mStylusTool == UBStylusTool::Vector) || mStylusTool == UBStylusTool::Line)
{ {
mLatestDrawingTool = mStylusTool; mLatestDrawingTool = mStylusTool;
} }
if (tool == UBStylusTool::Pen || tool == UBStylusTool::Line || tool == UBStylusTool::Vector) if (tool == UBStylusTool::Pen || tool == UBStylusTool::Line)
{ {
emit lineWidthIndexChanged(UBSettings::settings()->penWidthIndex()); emit lineWidthIndexChanged(UBSettings::settings()->penWidthIndex());
emit colorIndexChanged(UBSettings::settings()->penColorIndex()); emit colorIndexChanged(UBSettings::settings()->penColorIndex());
@ -145,8 +144,6 @@ void UBDrawingController::setStylusTool(int tool)
UBApplication::mainWindow->actionPointer->setChecked(true); UBApplication::mainWindow->actionPointer->setChecked(true);
else if (mStylusTool == UBStylusTool::Line) else if (mStylusTool == UBStylusTool::Line)
UBApplication::mainWindow->actionLine->setChecked(true); UBApplication::mainWindow->actionLine->setChecked(true);
else if (mStylusTool == UBStylusTool::Vector)
UBApplication::mainWindow->actionVector->setChecked(true);
else if (mStylusTool == UBStylusTool::Text) else if (mStylusTool == UBStylusTool::Text)
UBApplication::mainWindow->actionText->setChecked(true); UBApplication::mainWindow->actionText->setChecked(true);
else if (mStylusTool == UBStylusTool::Capture) else if (mStylusTool == UBStylusTool::Capture)
@ -163,14 +160,13 @@ bool UBDrawingController::isDrawingTool()
{ {
return (stylusTool() == UBStylusTool::Pen) return (stylusTool() == UBStylusTool::Pen)
|| (stylusTool() == UBStylusTool::Marker) || (stylusTool() == UBStylusTool::Marker)
|| (stylusTool() == UBStylusTool::Vector)
|| (stylusTool() == UBStylusTool::Line); || (stylusTool() == UBStylusTool::Line);
} }
int UBDrawingController::currentToolWidthIndex() int UBDrawingController::currentToolWidthIndex()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line)
return UBSettings::settings()->penWidthIndex(); return UBSettings::settings()->penWidthIndex();
else if (stylusTool() == UBStylusTool::Marker) else if (stylusTool() == UBStylusTool::Marker)
return UBSettings::settings()->markerWidthIndex(); return UBSettings::settings()->markerWidthIndex();
@ -181,7 +177,7 @@ int UBDrawingController::currentToolWidthIndex()
qreal UBDrawingController::currentToolWidth() qreal UBDrawingController::currentToolWidth()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line)
return UBSettings::settings()->currentPenWidth(); return UBSettings::settings()->currentPenWidth();
else if (stylusTool() == UBStylusTool::Marker) else if (stylusTool() == UBStylusTool::Marker)
return UBSettings::settings()->currentMarkerWidth(); return UBSettings::settings()->currentMarkerWidth();
@ -202,7 +198,6 @@ void UBDrawingController::setLineWidthIndex(int index)
UBSettings::settings()->setPenWidthIndex(index); UBSettings::settings()->setPenWidthIndex(index);
if(stylusTool() != UBStylusTool::Line if(stylusTool() != UBStylusTool::Line
&& stylusTool() != UBStylusTool::Vector
&& stylusTool() != UBStylusTool::Selector) && stylusTool() != UBStylusTool::Selector)
{ {
setStylusTool(UBStylusTool::Pen); setStylusTool(UBStylusTool::Pen);
@ -215,7 +210,7 @@ void UBDrawingController::setLineWidthIndex(int index)
int UBDrawingController::currentToolColorIndex() int UBDrawingController::currentToolColorIndex()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line)
{ {
return UBSettings::settings()->penColorIndex(); return UBSettings::settings()->penColorIndex();
} }
@ -238,7 +233,7 @@ QColor UBDrawingController::currentToolColor()
QColor UBDrawingController::toolColor(bool onDarkBackground) QColor UBDrawingController::toolColor(bool onDarkBackground)
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line)
{ {
return UBSettings::settings()->penColor(onDarkBackground); return UBSettings::settings()->penColor(onDarkBackground);
} }
@ -289,11 +284,6 @@ void UBDrawingController::setLineStyleIndex(int index)
UBSettings::settings()->setLineStyleIndex(index); UBSettings::settings()->setLineStyleIndex(index);
} }
void UBDrawingController::setVectorStyleIndex(int index)
{
UBSettings::settings()->setVectorStyleIndex(index);
}
void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex) void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{ {
if (onDarkBackground) if (onDarkBackground)
@ -422,11 +412,6 @@ void UBDrawingController::lineToolSelected(bool checked)
setStylusTool(UBStylusTool::Line); setStylusTool(UBStylusTool::Line);
} }
void UBDrawingController::vectorToolSelected(bool checked)
{
if (checked)
setStylusTool(UBStylusTool::Vector);
}
void UBDrawingController::textToolSelected(bool checked) void UBDrawingController::textToolSelected(bool checked)
{ {

@ -82,7 +82,6 @@ class UBDrawingController : public QObject
void setColorIndex(int index); void setColorIndex(int index);
void setEraserWidthIndex(int index); void setEraserWidthIndex(int index);
void setLineStyleIndex(int index); void setLineStyleIndex(int index);
void setVectorStyleIndex(int index);
signals: signals:
void stylusToolChanged(int tool, int previousTool = -1); void stylusToolChanged(int tool, int previousTool = -1);
@ -111,7 +110,6 @@ class UBDrawingController : public QObject
void zoomOutToolSelected(bool checked); void zoomOutToolSelected(bool checked);
void pointerToolSelected(bool checked); void pointerToolSelected(bool checked);
void lineToolSelected(bool checked); void lineToolSelected(bool checked);
void vectorToolSelected(bool checked);
void textToolSelected(bool checked); void textToolSelected(bool checked);
void captureToolSelected(bool checked); void captureToolSelected(bool checked);
}; };

@ -72,7 +72,6 @@ struct UBStylusTool
Pointer, Pointer,
Line, Line,
Text, Text,
Vector,
Capture Capture
}; };
}; };
@ -95,16 +94,6 @@ struct UBLineStyle
}; };
}; };
struct UBVectorStyle
{
enum Enum
{
To = 0,
From = 1,
FromTo = 2
};
};
struct UBZoom struct UBZoom
{ {
enum Enum enum Enum
@ -195,7 +184,6 @@ struct UBGraphicsItemType
UserTypesCount, //65557 UserTypesCount, //65557
AxesItemType, //65558 AxesItemType, //65558
LineItemType, //65559 LineItemType, //65559
VectorItemType, //65560
SelectionFrameType // this line must be the last line in this enum because it is types counter. SelectionFrameType // this line must be the last line in this enum because it is types counter.
}; };
}; };

@ -820,36 +820,6 @@ Qt::PenStyle UBSettings::currentLineStyle()
return style; return style;
} }
int UBSettings::vectorStyleIndex()
{
return value("Board/VectorStyleIndex", 0).toInt();
}
void UBSettings::setVectorStyleIndex(int index)
{
setValue("Board/VectorStyleIndex", index);
}
UBVectorStyle::Enum UBSettings::currentVectorStyle()
{
switch (vectorStyleIndex())
{
case UBVectorStyle::To:
return UBVectorStyle::To;
break;
case UBVectorStyle::From:
return UBVectorStyle::From;
break;
case UBVectorStyle::FromTo:
return UBVectorStyle::FromTo;
break;
default:
Q_ASSERT(false);
return UBVectorStyle::To;
break;
}
return UBVectorStyle::To;
}
bool UBSettings::isDarkBackground() bool UBSettings::isDarkBackground()
{ {
return value("Board/DarkBackground", 0).toBool(); return value("Board/DarkBackground", 0).toBool();

@ -89,10 +89,6 @@ class UBSettings : public QObject
int lineStyleIndex(); int lineStyleIndex();
Qt::PenStyle currentLineStyle(); Qt::PenStyle currentLineStyle();
// Line related
int vectorStyleIndex();
UBVectorStyle::Enum currentVectorStyle();
// Background related // Background related
bool isDarkBackground(); bool isDarkBackground();
UBPageBackground pageBackground(); UBPageBackground pageBackground();
@ -452,7 +448,6 @@ class UBSettings : public QObject
void setEraserStrongWidth(qreal width); void setEraserStrongWidth(qreal width);
void setLineStyleIndex(int index); void setLineStyleIndex(int index);
void setVectorStyleIndex(int index);
void setStylusPaletteVisible(bool visible); void setStylusPaletteVisible(bool visible);

@ -71,7 +71,6 @@
#include "UBGraphicsSvgItem.h" #include "UBGraphicsSvgItem.h"
#include "UBGraphicsPolygonItem.h" #include "UBGraphicsPolygonItem.h"
#include "UBGraphicsLineItem.h" #include "UBGraphicsLineItem.h"
#include "UBGraphicsVectorItem.h"
#include "UBGraphicsMediaItem.h" #include "UBGraphicsMediaItem.h"
#include "UBGraphicsWidgetItem.h" #include "UBGraphicsWidgetItem.h"
#include "UBGraphicsPDFItem.h" #include "UBGraphicsPDFItem.h"
@ -541,7 +540,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width /= UBApplication::boardController->systemScaleFactor(); width /= UBApplication::boardController->systemScaleFactor();
width /= UBApplication::boardController->currentZoom(); width /= UBApplication::boardController->currentZoom();
if (currentTool == UBStylusTool::Line || dc->activeRuler()|| currentTool == UBStylusTool::Vector) if (currentTool == UBStylusTool::Line || dc->activeRuler())
{ {
QLineF radius(mPreviousPoint, position); QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle(); qreal angle = radius.angle();
@ -565,9 +564,6 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
else if (currentTool == UBStylusTool::Line) { else if (currentTool == UBStylusTool::Line) {
drawLineTo(position, width, true); drawLineTo(position, width, true);
} }
else if (currentTool == UBStylusTool::Vector) {
drawLineTo(position, width, true);
}
else { else {
bool interpolate = false; bool interpolate = false;
@ -662,16 +658,6 @@ bool UBGraphicsScene::inputDeviceRelease(int tool)
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, NULL, mpLastLine); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, NULL, mpLastLine);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
mAddedItems.clear();
}
} else
if(currentTool == UBStylusTool::Vector)
{
if (mUndoRedoStackEnabled)
{ //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, NULL, mpLastVector);
UBApplication::undoStack->push(uc);
mAddedItems.clear(); mAddedItems.clear();
} }
} else{ } else{
@ -928,7 +914,6 @@ void UBGraphicsScene::moveTo(const QPointF &pPoint)
} }
void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, bool bLineStyle) void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, bool bLineStyle)
{ {
if(UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Vector) bLineStyle = true;
drawLineTo(pEndPoint, pWidth, pWidth, bLineStyle); drawLineTo(pEndPoint, pWidth, pWidth, bLineStyle);
} }
@ -952,12 +937,6 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &startWid
mAddedItems.clear(); mAddedItems.clear();
} }
if(UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Vector)
{
UBGraphicsVectorItem *vectorItem = new UBGraphicsVectorItem(QLineF(mPreviousPoint, pEndPoint), initialWidth, endWidth);
initVectorItem(vectorItem);
addVectorItemToCurrentStroke(vectorItem);
} else
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line) if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line)
{ {
UBGraphicsPolygonItem *polygonItem = lineToPolygonItem(QLineF(mPreviousPoint, pEndPoint), initialWidth, endWidth); UBGraphicsPolygonItem *polygonItem = lineToPolygonItem(QLineF(mPreviousPoint, pEndPoint), initialWidth, endWidth);
@ -1036,20 +1015,6 @@ void UBGraphicsScene::addLineItemToCurrentStroke(UBGraphicsLineItem* lineItem)
} }
void UBGraphicsScene::addVectorItemToCurrentStroke(UBGraphicsVectorItem* vectorItem)
{
vectorItem->setFlag(QGraphicsItem::ItemIsMovable, true);
vectorItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
vectorItem->SetDelegate();
mpLastVector = vectorItem;
mAddedItems.insert(vectorItem->StrokeGroup());
// Here we add the item to the scene
addItem(vectorItem->StrokeGroup());
}
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
{ {
const QLineF line(mPreviousPoint, pEndPoint); const QLineF line(mPreviousPoint, pEndPoint);
@ -1071,14 +1036,11 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
QList<UBGraphicsLineItem*> intersectedLineItems; QList<UBGraphicsLineItem*> intersectedLineItems;
QList<UBGraphicsVectorItem*> intersectedVectorItems;
#pragma omp parallel for #pragma omp parallel for
for(int i=0; i<collidItems.size(); i++) for(int i=0; i<collidItems.size(); i++)
{ {
UBGraphicsPolygonItem *pi = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems[i]); UBGraphicsPolygonItem *pi = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems[i]);
UBGraphicsLineItem *li = qgraphicsitem_cast<UBGraphicsLineItem*>(collidItems[i]); UBGraphicsLineItem *li = qgraphicsitem_cast<UBGraphicsLineItem*>(collidItems[i]);
UBGraphicsVectorItem *vi = qgraphicsitem_cast<UBGraphicsVectorItem*>(collidItems[i]);
if(pi != NULL) if(pi != NULL)
{ {
QPainterPath itemPainterPath; QPainterPath itemPainterPath;
@ -1119,24 +1081,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
intersectedLineItems << li; intersectedLineItems << li;
} }
} }
}else if (vi != NULL)
{
QPainterPath itemPainterPath;
QList<QPointF> linePoints = vi->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
intersectedVectorItems << vi;
}
}
} }
} }
for(int i=0; i<intersectedItems.size(); i++) for(int i=0; i<intersectedItems.size(); i++)
@ -1198,21 +1143,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
} }
} }
for (int i=0; i<intersectedVectorItems.size(); i++) if (!intersectedItems.empty() || !intersectedLineItems.empty())
{
UBGraphicsVectorItem *intersectedVectorItem = intersectedVectorItems[i];
mRemovedItems << intersectedVectorItem;
QTransform t;
bool bApplyTransform = false;
removeItem(intersectedVectorItem);
if (bApplyTransform)
{
intersectedVectorItem->setTransform(t);
}
}
if (!intersectedItems.empty() || !intersectedLineItems.empty()||!intersectedVectorItems.empty())
setModified(true); setModified(true);
} }
@ -1421,29 +1352,6 @@ void UBGraphicsScene::initLineItem(UBGraphicsLineItem* lineItem)
lineItem->setPen(linePen); lineItem->setPen(linePen);
} }
void UBGraphicsScene::initVectorItem(UBGraphicsVectorItem* vectorItem)
{
QColor colorOnDarkBG;
QColor colorOnLightBG;
colorOnDarkBG = UBApplication::boardController->penColorOnDarkBackground();
colorOnLightBG = UBApplication::boardController->penColorOnLightBackground();
if (mDarkBackground)
{
vectorItem->setColor(colorOnDarkBG);
}
else
{
vectorItem->setColor(colorOnLightBG);
}
vectorItem->setColorOnDarkBackground(colorOnDarkBG);
vectorItem->setColorOnLightBackground(colorOnLightBG);
vectorItem->setStyle(UBSettings::settings()->currentVectorStyle());
vectorItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
}
UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth) UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth)
{ {
QPolygonF polygon = UBGeometryUtils::arcToPolygon(pStartRadius, pSpanAngle, pWidth); QPolygonF polygon = UBGeometryUtils::arcToPolygon(pStartRadius, pSpanAngle, pWidth);
@ -1664,8 +1572,7 @@ void UBGraphicsScene::clearContent(clearCase pCase)
? qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item->parentItem()) ? qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item->parentItem())
: 0; : 0;
UBGraphicsItemDelegate *curDelegate = UBGraphicsItem::Delegate(item); UBGraphicsItemDelegate *curDelegate = UBGraphicsItem::Delegate(item);
if (!curDelegate && item->type() != UBGraphicsLineItem::Type if (!curDelegate && item->type() != UBGraphicsLineItem::Type) {
&& item->type() != UBGraphicsVectorItem::Type) {
continue; continue;
} }
@ -1674,10 +1581,6 @@ void UBGraphicsScene::clearContent(clearCase pCase)
bool shouldDelete = false; bool shouldDelete = false;
if(item->type()==UBGraphicsLineItem::Type) if(item->type()==UBGraphicsLineItem::Type)
{
removedItems << item;
this->removeItem(item);
} else if(item->type()==UBGraphicsVectorItem::Type)
{ {
removedItems << item; removedItems << item;
this->removeItem(item); this->removeItem(item);

@ -42,7 +42,6 @@ class UBGraphicsProxyWidget;
class UBGraphicsSvgItem; class UBGraphicsSvgItem;
class UBGraphicsPolygonItem; class UBGraphicsPolygonItem;
class UBGraphicsLineItem; class UBGraphicsLineItem;
class UBGraphicsVectorItem;
class UBGraphicsMediaItem; class UBGraphicsMediaItem;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
class UBGraphicsW3CWidgetItem; class UBGraphicsW3CWidgetItem;
@ -403,11 +402,9 @@ public slots:
UBGraphicsPolygonItem* curveToPolygonItem(const QList<QPointF> &points, qreal startWidth, qreal endWidth); UBGraphicsPolygonItem* curveToPolygonItem(const QList<QPointF> &points, qreal startWidth, qreal endWidth);
void addPolygonItemToCurrentStroke(UBGraphicsPolygonItem* polygonItem); void addPolygonItemToCurrentStroke(UBGraphicsPolygonItem* polygonItem);
void addLineItemToCurrentStroke(UBGraphicsLineItem* lineItem); void addLineItemToCurrentStroke(UBGraphicsLineItem* lineItem);
void addVectorItemToCurrentStroke(UBGraphicsVectorItem* vectorItem);
void initPolygonItem(UBGraphicsPolygonItem*); void initPolygonItem(UBGraphicsPolygonItem*);
void initLineItem(UBGraphicsLineItem*); void initLineItem(UBGraphicsLineItem*);
void initVectorItem(UBGraphicsVectorItem*);
void drawEraser(const QPointF& pEndPoint, bool pressed = true); void drawEraser(const QPointF& pEndPoint, bool pressed = true);
@ -501,7 +498,6 @@ public slots:
UBGraphicsPolygonItem* mpLastPolygon; UBGraphicsPolygonItem* mpLastPolygon;
UBGraphicsPolygonItem* mTempPolygon; UBGraphicsPolygonItem* mTempPolygon;
UBGraphicsLineItem* mpLastLine; UBGraphicsLineItem* mpLastLine;
UBGraphicsVectorItem* mpLastVector;
bool mDrawWithCompass; bool mDrawWithCompass;
UBGraphicsPolygonItem *mCurrentPolygon; UBGraphicsPolygonItem *mCurrentPolygon;

@ -1,225 +0,0 @@
#include "UBGraphicsVectorItem.h"
#include "frameworks/UBGeometryUtils.h"
#include "UBGraphicsScene.h"
#include "core/memcheck.h"
#include <iostream>
UBGraphicsVectorItem::UBGraphicsVectorItem (QGraphicsItem * parent)
: QGraphicsLineItem(parent)
, mHasAlpha(false)
, mOriginalWidth(-1)
, mIsNominalLine(false)
{
// NOOP
initialize();
}
UBGraphicsVectorItem::UBGraphicsVectorItem (const QLineF & line, QGraphicsItem * parent)
: QGraphicsLineItem(line, parent)
, mOriginalWidth(-1)
, mIsNominalLine(false)
{
// NOOP
initialize();
}
UBGraphicsVectorItem::UBGraphicsVectorItem (const QLineF& pLine, qreal pWidth)
: QGraphicsLineItem(pLine)
, mOriginalLine(pLine)
, mOriginalWidth(pWidth)
, mIsNominalLine(true)
{
// NOOP
initialize();
}
UBGraphicsVectorItem::UBGraphicsVectorItem (const QLineF& pLine, qreal pStartWidth, qreal pEndWidth)
: QGraphicsLineItem(pLine)
, mOriginalLine(pLine)
, mOriginalWidth(pEndWidth)
, mIsNominalLine(true)
{
// NOOP
initialize();
}
void UBGraphicsVectorItem::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);
setSublines();
mStrokeGroup = new UBGraphicsStrokesGroup();
mStrokeGroup->setTransform(this->transform());
UBGraphicsItem::assignZValue(mStrokeGroup, this->zValue());
if(this->transform().isIdentity())
this->setTransform(mStrokeGroup->transform());
mStrokeGroup->addToGroup(this);
}
void UBGraphicsVectorItem::setSublines()
{
for(int i = 0; i < sublines.length(); ++i)
{
delete sublines[i];
}
if ((style == UBVectorStyle::To) || (style == UBVectorStyle::FromTo))
{
QLineF thisLine = QLineF(this->line().p2().x(), this->line().p2().y(),this->line().p2().x()+this->line().length()/10, this->line().p2().y());
thisLine.setAngle(this->line().angle() - 135);
sublines.push_back(new QGraphicsLineItem(thisLine));
thisLine = QLineF(this->line().p2().x(), this->line().p2().y(),this->line().p2().x()+this->line().length()/10, this->line().p2().y());
thisLine.setAngle(this->line().angle() + 135);
sublines.push_back(new QGraphicsLineItem(thisLine));
}
if ((style == UBVectorStyle::From) || (style == UBVectorStyle::FromTo))
{
QLineF thisLine = QLineF(this->line().p1().x(), this->line().p1().y(),this->line().p1().x()+this->line().length()/10, this->line().p1().y());
thisLine.setAngle(this->line().angle() - 45);
sublines.push_back(new QGraphicsLineItem(thisLine));
thisLine = QLineF(this->line().p1().x(), this->line().p1().y(),this->line().p1().x()+this->line().length()/10, this->line().p1().y());
thisLine.setAngle(this->line().angle() + 45);
sublines.push_back(new QGraphicsLineItem(thisLine));
}
}
void UBGraphicsVectorItem::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
}
UBGraphicsVectorItem::~UBGraphicsVectorItem()
{
for (int i = 0; i < sublines.size(); ++i)
delete sublines[i];
sublines.clear();
}
void UBGraphicsVectorItem::setColor(const QColor& pColor)
{
QPen pen = QPen(pColor);
pen.setCapStyle(Qt::PenCapStyle::RoundCap);
pen.setWidth(mOriginalWidth);
QGraphicsLineItem::setPen(pen);
for (int i = 0; i < sublines.size(); ++i)
sublines[i]->setPen(pen);
mHasAlpha = (pColor.alphaF() < 1.0);
}
QColor UBGraphicsVectorItem::color() const
{
return QGraphicsLineItem::pen().color();
}
void UBGraphicsVectorItem::setStyle(const UBVectorStyle::Enum& _style)
{
style = _style;
setSublines();
for (int i = 0; i < sublines.size(); ++i)
sublines[i]->setPen(this->pen());
}
QList<QPointF> UBGraphicsVectorItem::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* UBGraphicsVectorItem::deepCopy() const
{
UBGraphicsVectorItem* copy = new UBGraphicsVectorItem(line());
copyItemParameters(copy);
return copy;
}
void UBGraphicsVectorItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsVectorItem *cp = dynamic_cast<UBGraphicsVectorItem*>(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 UBGraphicsVectorItem::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);
for (int i = 0; i <sublines.size(); ++i)
{
sublines[i]->paint(painter, option, widget);
}
Delegate()->postpaint(painter, &styleOption, widget);
}
UBGraphicsScene* UBGraphicsVectorItem::scene()
{
return qobject_cast<UBGraphicsScene*>(QGraphicsLineItem::scene());
}
void UBGraphicsVectorItem::SetDelegate()
{
Delegate()->createControls();
}
QVariant UBGraphicsVectorItem::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,119 +0,0 @@
#ifndef UBGRAPHICSVECTORITEM_H
#define UBGRAPHICSVECTORITEM_H
#include <QtGui>
#include "core/UB.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "UBItem.h"
class UBItem;
class UBGraphicsScene;
class UBGraphicsVectorItem: public QGraphicsLineItem, public UBItem, public UBGraphicsItem
{
public:
UBGraphicsVectorItem();
public:
UBGraphicsVectorItem(QGraphicsItem * parent = 0 );
UBGraphicsVectorItem(const QLineF& line, qreal pWidth);
UBGraphicsVectorItem(const QLineF& pLine, qreal pStartWidth, qreal pEndWidth);
UBGraphicsVectorItem(const QLineF & line, QGraphicsItem * parent = 0);
~UBGraphicsVectorItem();
void initialize();
void setUuid(const QUuid &pUuid);
void setColor(const QColor& color);
void setStyle(const UBVectorStyle::Enum& _style);
UBVectorStyle::Enum getStyle()
{
return style;
}
QColor color() const;
virtual UBGraphicsScene* scene();
enum { Type = UBGraphicsItemType::VectorItemType };
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();
QList<QGraphicsLineItem*> SubLines()
{
return sublines;
}
UBGraphicsStrokesGroup* StrokeGroup()
{
return mStrokeGroup;
}
protected:
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void setSublines();
private:
bool mHasAlpha;
QLineF mOriginalLine;
qreal mOriginalWidth;
bool mIsNominalLine;
QColor mColorOnDarkBackground;
QColor mColorOnLightBackground;
QList<QGraphicsLineItem *> sublines;
UBVectorStyle::Enum style;
UBGraphicsStrokesGroup* mStrokeGroup;
};
#endif // UBGRAPHICSVECTORITEM_H

@ -1,5 +1,4 @@
HEADERS += src/domain/UBGraphicsScene.h \ HEADERS += src/domain/UBGraphicsScene.h \
$$PWD/UBGraphicsVectorItem.h \
src/domain/UBGraphicsItemUndoCommand.h \ src/domain/UBGraphicsItemUndoCommand.h \
src/domain/UBGraphicsTextItemUndoCommand.h \ src/domain/UBGraphicsTextItemUndoCommand.h \
src/domain/UBGraphicsItemTransformUndoCommand.h \ src/domain/UBGraphicsItemTransformUndoCommand.h \
@ -30,7 +29,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsItemZLevelUndoCommand.h src/domain/UBGraphicsItemZLevelUndoCommand.h
SOURCES += src/domain/UBGraphicsScene.cpp \ SOURCES += src/domain/UBGraphicsScene.cpp \
$$PWD/UBGraphicsVectorItem.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \ src/domain/UBGraphicsItemUndoCommand.cpp \
src/domain/UBGraphicsTextItemUndoCommand.cpp \ src/domain/UBGraphicsTextItemUndoCommand.cpp \
src/domain/UBGraphicsItemTransformUndoCommand.cpp \ src/domain/UBGraphicsItemTransformUndoCommand.cpp \

@ -61,7 +61,6 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
actions << UBApplication::mainWindow->actionLine; actions << UBApplication::mainWindow->actionLine;
actions << UBApplication::mainWindow->actionVector;
actions << UBApplication::mainWindow->actionText; actions << UBApplication::mainWindow->actionText;
actions << UBApplication::mainWindow->actionCapture; actions << UBApplication::mainWindow->actionCapture;

@ -210,7 +210,6 @@ void UBToolbarButtonGroup::colorPaletteChanged()
QList<QColor> colors; QList<QColor> colors;
if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Vector
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line) || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line)
{ {
colors = UBSettings::settings()->penColors(isDarkBackground); colors = UBSettings::settings()->penColors(isDarkBackground);

Loading…
Cancel
Save