diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp
index f853ab00..a6e0171f 100644
--- a/src/adaptors/UBCFFSubsetAdaptor.cpp
+++ b/src/adaptors/UBCFFSubsetAdaptor.cpp
@@ -42,6 +42,7 @@ static QString tMeta = "meta";
static QString tPage = "page";
static QString tPageset = "pageset";
static QString tPolygon = "polygon";
+static QString tPolyline = "polyline";
static QString tRect = "rect";
static QString tSvg = "svg";
static QString tText = "text";
@@ -70,6 +71,7 @@ static QString aFontstretch = "font-stretch";
static QString aFontstyle = "font-style";
static QString aFontweight = "font-weight";
static QString aTextalign = "text-align";
+static QString aPoints = "points";
UBCFFSubsetAdaptor::UBCFFSubsetAdaptor()
@@ -229,6 +231,12 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseCurrentElementStart()
return false;
}
else
+ if ( elName == tPolyline)
+ {
+ if (!parsePolyline())
+ return false;
+ }
+ else
if ( elName == tPage)
{
if (!parsePage())
@@ -749,6 +757,135 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parsePolygon()
if (currentState == SVG && mCurrentScene == NULL)
createNewScene();
+ QStringRef svgPoints = mReader.attributes().value("points");
+ QPolygonF polygon;
+
+ if (!svgPoints.isNull()) {
+ QStringList ts = svgPoints.toString().split(QLatin1Char(' '),
+ QString::SkipEmptyParts);
+
+ foreach(const QString sPoint, ts) {
+ QStringList sCoord = sPoint.split(QLatin1Char(','), QString::SkipEmptyParts);
+ if (sCoord.size() == 2) {
+ QPointF point;
+ point.setX(sCoord.at(0).toFloat());
+ point.setY(sCoord.at(1).toFloat());
+ polygon << point;
+ }
+ else {
+ qWarning() << "cannot make sense of a 'point' value" << sCoord;
+ }
+ }
+ }
+
+ //bounding rect lef top corner coordinates
+ qreal x1 = polygon.boundingRect().topLeft().x();
+ qreal y1 = polygon.boundingRect().topLeft().y();
+ //bounding rect dimensions
+ qreal width = polygon.boundingRect().width();
+ qreal height = polygon.boundingRect().height();
+
+ QPen pen;
+ if (mReader.attributes().hasAttribute(aStroke))
+ pen.setColor(colorFromString(mReader.attributes().value(aStroke).toString()));
+ if (mReader.attributes().hasAttribute(aStrokewidth))
+ pen.setWidth(mReader.attributes().value(aStrokewidth).toString().toInt());
+
+ QBrush brush;
+ if (mReader.attributes().hasAttribute(aFill)) {
+ brush.setColor(colorFromString(mReader.attributes().value(aFill).toString()));
+ brush.setStyle(Qt::SolidPattern);
+ }
+
+ QSvgGenerator *generator = createSvgGenerator(width + pen.width(), height + pen.width());
+ QPainter painter;
+
+ painter.begin(generator); //drawing to svg tmp file
+
+ painter.translate(pen.widthF() / 2 - x1, pen.widthF() / 2 - y1);
+ painter.setBrush(brush);
+ painter.setPen(pen);
+ painter.drawPolygon(polygon);
+
+ painter.end();
+
+ //add resulting svg file to scene
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ QTransform transform;
+ bool hastransform = getCurElementTransorm(transform);
+ repositionSvgItem(svgItem, width + 10, height + 10, x1 - 5, y1 - 5, hastransform, transform);
+ delete generator;
+
+ return true;
+}
+
+bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parsePolyline()
+{
+ if (currentState != SVG && currentState != PAGE)
+ {
+ qWarning() << "iwb content parse error, unexpected polyline tag at line" << mReader.lineNumber();
+ return false;
+ }
+
+ //create new scene if it's not created yet (for one page document case)
+ if (currentState == SVG && mCurrentScene == NULL)
+ createNewScene();
+
+ QStringRef svgPoints = mReader.attributes().value("points");
+ QPolygonF polygon;
+
+ if (!svgPoints.isNull()) {
+ QStringList ts = svgPoints.toString().split(QLatin1Char(' '),
+ QString::SkipEmptyParts);
+
+ foreach(const QString sPoint, ts) {
+ QStringList sCoord = sPoint.split(QLatin1Char(','), QString::SkipEmptyParts);
+ if (sCoord.size() == 2) {
+ QPointF point;
+ point.setX(sCoord.at(0).toFloat());
+ point.setY(sCoord.at(1).toFloat());
+ polygon << point;
+ }
+ else {
+ qWarning() << "cannot make sense of a 'point' value" << sCoord;
+ }
+ }
+ polygon.translate(-polygon.boundingRect().topLeft());
+ }
+
+ //bounding rect lef top corner coordinates
+ qreal x1 = polygon.boundingRect().topLeft().x();
+ qreal y1 = polygon.boundingRect().topLeft().y();
+ //bounding rect dimensions
+ qreal width = polygon.boundingRect().width();
+ qreal height = polygon.boundingRect().height();
+
+ QPen pen;
+ if (mReader.attributes().hasAttribute(aStroke))
+ pen.setColor(colorFromString(mReader.attributes().value(aStroke).toString()));
+ if (mReader.attributes().hasAttribute(aStrokewidth))
+ pen.setWidth(mReader.attributes().value(aStrokewidth).toString().toInt());
+
+ pen.setColor(Qt::yellow);
+
+ QSvgGenerator *generator = createSvgGenerator(width + pen.width(), height + pen.width());
+ QPainter painter;
+
+ painter.begin(generator); //drawing to svg tmp file
+
+ painter.translate(pen.widthF() / 2, pen.widthF() / 2);
+ painter.setPen(pen);
+ painter.drawPolyline(polygon);
+
+ painter.end();
+
+ //add resulting svg file to scene
+ UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
+ QTransform transform;
+ bool hastransform = getCurElementTransorm(transform);
+ repositionSvgItem(svgItem, width + 10, height + 10, x1 - 5, y1 - 5, hastransform, transform);
+ delete generator;
+
return true;
}
diff --git a/src/adaptors/UBCFFSubsetAdaptor.h b/src/adaptors/UBCFFSubsetAdaptor.h
index 1b692a1f..2c78f1e4 100644
--- a/src/adaptors/UBCFFSubsetAdaptor.h
+++ b/src/adaptors/UBCFFSubsetAdaptor.h
@@ -84,6 +84,7 @@ private:
bool parseTextArea();
bool parseText();
bool parsePolygon();
+ bool parsePolyline();
bool parsePage();
bool parsePageSet();
bool parseIwbElementRef();
diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp
index 3af00596..a0a79cbd 100644
--- a/src/desktop/UBDesktopAnnotationController.cpp
+++ b/src/desktop/UBDesktopAnnotationController.cpp
@@ -856,6 +856,7 @@ void UBDesktopAnnotationController::refreshMask()
{
if(mIsFullyTransparent
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector
+ //Needed to work correctly when another actions on stylus are checked
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Eraser
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pointer
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen
diff --git a/src/domain/UBGraphicsAudioItem.cpp b/src/domain/UBGraphicsAudioItem.cpp
index 2890d75a..12a2eae6 100644
--- a/src/domain/UBGraphicsAudioItem.cpp
+++ b/src/domain/UBGraphicsAudioItem.cpp
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
#include "UBGraphicsAudioItem.h"
#include "UBGraphicsAudioItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
diff --git a/src/domain/UBGraphicsAudioItemDelegate.cpp b/src/domain/UBGraphicsAudioItemDelegate.cpp
index a07a8cf9..461a0445 100644
--- a/src/domain/UBGraphicsAudioItemDelegate.cpp
+++ b/src/domain/UBGraphicsAudioItemDelegate.cpp
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
#include "UBGraphicsAudioItemDelegate.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsDelegateFrame.h"
diff --git a/src/domain/UBGraphicsMediaItem.cpp b/src/domain/UBGraphicsMediaItem.cpp
index 9a41ba31..aea73e2b 100644
--- a/src/domain/UBGraphicsMediaItem.cpp
+++ b/src/domain/UBGraphicsMediaItem.cpp
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsDelegateFrame.h"
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
index 78d33d8e..e1561042 100644
--- a/src/domain/UBGraphicsScene.cpp
+++ b/src/domain/UBGraphicsScene.cpp
@@ -343,7 +343,6 @@ bool UBGraphicsScene::inputDeviceRelease()
}
UBDrawingController *dc = UBDrawingController::drawingController();
- UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool();
if (dc->isDrawingTool())
{
mCurrentStroke = 0;
diff --git a/src/domain/UBGraphicsVideoItem.cpp b/src/domain/UBGraphicsVideoItem.cpp
index 723e305a..841667cf 100644
--- a/src/domain/UBGraphicsVideoItem.cpp
+++ b/src/domain/UBGraphicsVideoItem.cpp
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
#include "UBGraphicsVideoItem.h"
#include "UBGraphicsVideoItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
diff --git a/src/domain/UBGraphicsVideoItemDelegate.cpp b/src/domain/UBGraphicsVideoItemDelegate.cpp
index 1af21b1b..a3d340e0 100644
--- a/src/domain/UBGraphicsVideoItemDelegate.cpp
+++ b/src/domain/UBGraphicsVideoItemDelegate.cpp
@@ -13,7 +13,6 @@
* along with this program. If not, see .
*/
-
#include
#include
diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp
index f645d726..1f3be2bd 100644
--- a/src/domain/UBGraphicsWidgetItem.cpp
+++ b/src/domain/UBGraphicsWidgetItem.cpp
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
#include "UBGraphicsWidgetItem.h"
#include "api/UBWidgetUniboardAPI.h"
diff --git a/src/domain/UBGraphicsWidgetItemDelegate.cpp b/src/domain/UBGraphicsWidgetItemDelegate.cpp
index 36a29427..67d256ab 100644
--- a/src/domain/UBGraphicsWidgetItemDelegate.cpp
+++ b/src/domain/UBGraphicsWidgetItemDelegate.cpp
@@ -13,7 +13,6 @@
* along with this program. If not, see .
*/
-
#include
#include
diff --git a/src/domain/UBItem.cpp b/src/domain/UBItem.cpp
index f7f20c07..4a3e1643 100644
--- a/src/domain/UBItem.cpp
+++ b/src/domain/UBItem.cpp
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
#include "UBItem.h"
#include "core/memcheck.h"
diff --git a/src/gui/UBActionPalette.cpp b/src/gui/UBActionPalette.cpp
index 5b6519d6..c5cd1ea6 100644
--- a/src/gui/UBActionPalette.cpp
+++ b/src/gui/UBActionPalette.cpp
@@ -1,8 +1,16 @@
/*
- * UBActionPalette.cpp
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * Created on: 8 oct. 2009
- * Author: Luc
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "UBActionPalette.h"
diff --git a/src/gui/UBMagnifer.cpp b/src/gui/UBMagnifer.cpp
index e36add3f..a6bbe28b 100644
--- a/src/gui/UBMagnifer.cpp
+++ b/src/gui/UBMagnifer.cpp
@@ -1,4 +1,17 @@
-
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#include
#include "UBMagnifer.h"
@@ -7,25 +20,15 @@
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
-// #include
-// #include
-// #include
-// #include
-// #include
-// #include
-// #include
-// #include
-
UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
- , gView(0)
- , mView(0)
- , inTimer(false)
- , borderPen(Qt::darkGray)
, mShouldMoveWidget(false)
, mShouldResizeWidget(false)
-
+ , inTimer(false)
+ , borderPen(Qt::darkGray)
+ , gView(0)
+ , mView(0)
{
isCusrsorAlreadyStored = false;
setMouseTracking(true);
@@ -69,29 +72,29 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
UBMagnifier::~UBMagnifier()
{
- if (timerUpdate != 0)
- {
- killTimer(timerUpdate);
- timerUpdate = 0;
- }
-
- if(sClosePixmap)
- {
- delete sClosePixmap;
- sClosePixmap = NULL;
- }
-
- if(sIncreasePixmap)
- {
- delete sIncreasePixmap;
- sIncreasePixmap = NULL;
- }
-
- if(sDecreasePixmap)
- {
- delete sDecreasePixmap;
- sDecreasePixmap = NULL;
- }
+ if (timerUpdate != 0)
+ {
+ killTimer(timerUpdate);
+ timerUpdate = 0;
+ }
+
+ if(sClosePixmap)
+ {
+ delete sClosePixmap;
+ sClosePixmap = NULL;
+ }
+
+ if(sIncreasePixmap)
+ {
+ delete sIncreasePixmap;
+ sIncreasePixmap = NULL;
+ }
+
+ if(sDecreasePixmap)
+ {
+ delete sDecreasePixmap;
+ sDecreasePixmap = NULL;
+ }
}
@@ -114,9 +117,9 @@ void UBMagnifier::setSize(qreal percentFromScene)
setGeometry(0, 0, size, size);
// prepare transparent bit mask
- QImage mask_img(width(), height(), QImage::Format_Mono);
- mask_img.fill(0xff);
- QPainter mask_ptr(&mask_img);
+ QImage mask_img(width(), height(), QImage::Format_Mono);
+ mask_img.fill(0xff);
+ QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawEllipse(QPointF(size/2, size/2), size / 2 - sClosePixmap->width(), size / 2 - sClosePixmap->width());
bmpMask = QBitmap::fromImage(mask_img);
@@ -134,10 +137,9 @@ void UBMagnifier::setZoom(qreal zoom)
void UBMagnifier::paintEvent(QPaintEvent * event)
{
+ Q_UNUSED(event);
QPainter painter(this);
-// painter.drawRect(0,0,size().width()-1, size().height()-1);
-
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
@@ -205,8 +207,8 @@ void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
event->accept();
QWidget::mouseMoveEvent(event);
- emit magnifierMoved_Signal(QPoint(this->pos().x() + size().width() / 2, this->pos().y() + size().height() / 2 ));
- return;
+ emit magnifierMoved_Signal(QPoint(this->pos().x() + size().width() / 2, this->pos().y() + size().height() / 2 ));
+ return;
}
if(mShouldResizeWidget && (event->buttons() & Qt::LeftButton))
@@ -218,7 +220,7 @@ void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
qreal newXSize = ( currGlobalPos.x() + mMousePressDelta - updPointGrab.x() ) * 2;
qreal newPercentSize = newXSize * 100 / cvW;
- emit magnifierResized_Signal(newPercentSize);
+ emit magnifierResized_Signal(newPercentSize);
event->ignore();
return;
@@ -236,8 +238,8 @@ void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
setCursor(mResizeCursor);
}
- }
- else
+ }
+ else
event->ignore();
}
@@ -255,7 +257,7 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
event->pos().y() < size().height() / 2 + sClosePixmap->height() * 2)
{
event->accept();
- emit magnifierClose_Signal();
+ emit magnifierClose_Signal();
}
else
if (event->pos().x() >= size().width() - sIncreasePixmap->width() &&
@@ -264,7 +266,7 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
event->pos().y() < size().height() / 2 + sIncreasePixmap->height() * 3.5)
{
event->accept();
- emit magnifierZoomIn_Signal();
+ emit magnifierZoomIn_Signal();
}
else
if (event->pos().x() >= size().width() - sDecreasePixmap->width() &&
@@ -273,7 +275,7 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
event->pos().y() < size().height() / 2 + sDecreasePixmap->height() * 4.6)
{
event->accept();
- emit magnifierZoomOut_Signal();
+ emit magnifierZoomOut_Signal();
}
else
QWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
@@ -283,19 +285,19 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
}
-void UBMagnifier::timerEvent(QTimerEvent *e)
-{
- if(inTimer) return;
- if (e->timerId() == timerUpdate)
- {
- inTimer = true;
- if(!(updPointGrab.isNull()))
- grabPoint(updPointGrab);
-
- if(isCusrsorAlreadyStored)
- {
- QPoint globalCursorPos = QCursor::pos();
- QPoint cursorPos = mapFromGlobal(globalCursorPos);
+void UBMagnifier::timerEvent(QTimerEvent *e)
+{
+ if(inTimer) return;
+ if (e->timerId() == timerUpdate)
+ {
+ inTimer = true;
+ if(!(updPointGrab.isNull()))
+ grabPoint(updPointGrab);
+
+ if(isCusrsorAlreadyStored)
+ {
+ QPoint globalCursorPos = QCursor::pos();
+ QPoint cursorPos = mapFromGlobal(globalCursorPos);
if (cursorPos.x() < size().width() - mResizeItem->width() - 20 ||
cursorPos.x() > size().width() - 20 ||
cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
@@ -305,12 +307,12 @@ void UBMagnifier::timerEvent(QTimerEvent *e)
isCusrsorAlreadyStored = false;
setCursor(mOldCursor);
}
-
- }
-
- inTimer = false;
- }
-}
+
+ }
+
+ inTimer = false;
+ }
+}
void UBMagnifier::grabPoint()
{
@@ -326,8 +328,8 @@ void UBMagnifier::grabPoint()
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
- UBApplication::boardController->activeScene()->update();
-
+ UBApplication::boardController->activeScene()->update();
+
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask);
@@ -350,8 +352,8 @@ void UBMagnifier::grabPoint(const QPoint &pGrab)
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
- UBApplication::boardController->activeScene()->update();
-
+ UBApplication::boardController->activeScene()->update();
+
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask);
@@ -362,8 +364,8 @@ void UBMagnifier::grabPoint(const QPoint &pGrab)
// from global
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove)
{
- updPointGrab = pGrab;
- updPointMove = pMove;
+ updPointGrab = pGrab;
+ updPointMove = pMove;
if(needGrab)
grabPoint(pGrab);
@@ -376,11 +378,11 @@ void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needG
}
}
-void UBMagnifier::setGrabView(QWidget *view)
-{
- if (timerUpdate != 0)
- killTimer(timerUpdate);
- gView = view;
- timerUpdate = startTimer(200);
-}
+void UBMagnifier::setGrabView(QWidget *view)
+{
+ if (timerUpdate != 0)
+ killTimer(timerUpdate);
+ gView = view;
+ timerUpdate = startTimer(200);
+}
diff --git a/src/gui/UBMagnifer.h b/src/gui/UBMagnifer.h
index 9032a3cd..73a81692 100644
--- a/src/gui/UBMagnifer.h
+++ b/src/gui/UBMagnifer.h
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H