Merge pull request #446 from letsfindaway/tool-axes+intermediate-lines

Tool axes+intermediate lines
preferencesAboutTextFull
kaamui 3 years ago committed by GitHub
commit c656810b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      resources/OpenBoard.qrc
  2. 16
      resources/forms/mainWindow.ui
  3. 12
      resources/i18n/OpenBoard_de.ts
  4. 63
      resources/images/numbersTool.svg
  5. BIN
      resources/images/toolPalette/axesTool.png
  6. 109
      src/adaptors/UBSvgSubsetAdaptor.cpp
  7. 4
      src/adaptors/UBSvgSubsetAdaptor.h
  8. 5
      src/board/UBBoardController.cpp
  9. 31
      src/board/UBBoardView.cpp
  10. 1
      src/core/UB.h
  11. 10
      src/core/UBSettings.cpp
  12. 4
      src/core/UBSettings.h
  13. 25
      src/domain/UBGraphicsScene.cpp
  14. 8
      src/domain/UBGraphicsScene.h
  15. 38
      src/gui/UBBackgroundPalette.cpp
  16. 4
      src/gui/UBBackgroundPalette.h
  17. 580
      src/tools/UBGraphicsAxes.cpp
  18. 138
      src/tools/UBGraphicsAxes.h
  19. 9
      src/tools/UBToolsManager.cpp
  20. 6
      src/tools/UBToolsManager.h
  21. 2
      src/tools/tools.pri

@ -364,5 +364,7 @@
<file>images/expand-all.png</file>
<file>images/asc.png</file>
<file>images/desc.png</file>
<file>images/toolPalette/axesTool.png</file>
<file>images/numbersTool.svg</file>
</qresource>
</RCC>

@ -1686,6 +1686,22 @@
<string>Reset grid size</string>
</property>
</action>
<action name="actionDrawIntermediateGridLines">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/minus.svg</normaloff>
<normalon>:/images/save.svg</normalon>:/images/minus.svg</iconset>
</property>
<property name="text">
<string>Draw intermediate grid lines</string>
</property>
<property name="toolTip">
<string>Draw intermediate grid lines</string>
</property>
</action>
</widget>
<resources>
<include location="../OpenBoard.qrc"/>

@ -835,6 +835,10 @@
<source>Color 5</source>
<translation>Farbe 5</translation>
</message>
<message>
<source>Draw intermediate grid lines</source>
<translation>Gitter-Zwischenlinien zeichnen</translation>
</message>
</context>
<context>
<name>PasswordDialog</name>
@ -937,6 +941,10 @@
<source>Grid size</source>
<translation>Gittergrösse</translation>
</message>
<message>
<source>Draw intermediate grid lines</source>
<translation>Gitter-Zwischenlinien zeichnen</translation>
</message>
</context>
<context>
<name>UBBoardController</name>
@ -2226,6 +2234,10 @@ Miniaturansicht der Seite %1 wird geladen</translation>
<source>Cache</source>
<translation>Zwischenspeicher</translation>
</message>
<message>
<source>Axes</source>
<translation>Achsen</translation>
</message>
</context>
<context>
<name>UBTrapFlashController</name>

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="26.703px"
height="22.297px"
viewBox="0 0 26.703 22.297"
enable-background="new 0 0 26.703 22.297"
xml:space="preserve"
sodipodi:docname="numbersTool.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata13"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs11" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview9"
showgrid="false"
inkscape:zoom="11.313708"
inkscape:cx="13.836098"
inkscape:cy="1.5919993"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g6" /><g
id="g6"><path
stroke-miterlimit="3.8637"
d="m 17.978,0.507 c 4.547,0 8.231,3.686 8.231,8.232 v 4.838 c 0,4.547 -3.685,8.232 -8.231,8.232 H 8.732 c -4.546,0 -8.231,-3.686 -8.231,-8.232 V 8.739 c 0,-4.547 3.686,-8.232 8.231,-8.232 z"
id="path2"
inkscape:connector-curvature="0"
style="clip-rule:evenodd;fill:#333333;fill-rule:evenodd;stroke:#cdcccc;stroke-miterlimit:3.86369991" /><text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-size:17.90173149px;line-height:1.25;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Semi-Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#cccccc;fill-opacity:1;stroke:none;stroke-width:0.44756019"
x="8.2361794"
y="17.963972"
id="text854"
transform="scale(1.0088516,0.9912261)"><tspan
sodipodi:role="line"
id="tspan852"
x="8.2361794"
y="17.963972"
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-size:17.90173149px;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Semi-Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#cccccc;stroke-width:0.44756019">1</tspan></text>
</g></svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

@ -51,6 +51,7 @@
#include "domain/UBItem.h"
#include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsAxes.h"
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsCurtainItem.h"
@ -468,6 +469,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
mScene->setBackgroundGridSize(gridSize);
}
QStringRef ubIntermediateLines = mXmlReader.attributes().value(mNamespaceUri, "intermediate-lines");
if (!ubIntermediateLines.isNull()) {
bool intermediateLines = ubIntermediateLines.toInt();
mScene->setIntermediateLines(intermediateLines);
}
}
QStringRef ubRuledBackground = mXmlReader.attributes().value(mNamespaceUri, "ruled-background");
@ -483,6 +492,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
mScene->setBackgroundGridSize(gridSize);
}
QStringRef ubIntermediateLines = mXmlReader.attributes().value(mNamespaceUri, "intermediate-lines");
if (!ubIntermediateLines.isNull()) {
bool intermediateLines = ubIntermediateLines.toInt();
mScene->setIntermediateLines(intermediateLines);
}
}
UBPageBackground bg;
@ -754,6 +771,17 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
mScene->registerTool(ruler);
}
}
else if (mXmlReader.name() == "axes")
{
UBGraphicsAxes *axes = axesFromSvg();
if (axes)
{
mScene->addItem(axes);
mScene->registerTool(axes);
}
}
else if (mXmlReader.name() == "compass")
{
@ -1128,8 +1156,10 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement(UBDocumentProxy* pro
if (crossedBackground || ruledBackground) {
int gridSize = mScene->backgroundGridSize();
bool intermediateLines = mScene->intermediateLines();
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "grid-size", QString::number(gridSize));
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "intermediate-lines", QString::number(intermediateLines));
}
QDesktopWidget* desktop = UBApplication::desktop();
@ -1353,6 +1383,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(UBDocumentProxy* proxy,
continue;
}
// Is the item a axes?
UBGraphicsAxes *axes = qgraphicsitem_cast<UBGraphicsAxes*> (item);
if (axes && axes->isVisible())
{
axesToSvg(axes);
continue;
}
// Is the item a cache?
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item);
if(cache && cache->isVisible())
@ -2859,6 +2897,40 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::rulerToSvg(UBGraphicsRuler* item)
mXmlWriter.writeEndElement();
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::axesToSvg(UBGraphicsAxes *item)
{
/**
*
* sample
*
<ub:axes x="250" y="150" left="65" top="28" width="122" height="67" numbers="1"...>
</ub:ruler>
*/
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "axes");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->pos().x()));
mXmlWriter.writeAttribute("y", QString("%1").arg(item->pos().y()));
mXmlWriter.writeAttribute("left", QString("%1").arg(item->bounds().left()));
mXmlWriter.writeAttribute("top", QString("%1").arg(item->bounds().top()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->bounds().width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->bounds().height()));
mXmlWriter.writeAttribute("numbers", QString("%1").arg(item->showNumbes()));
QString zs;
zs.setNum(item->zValue(), 'f'); // 'f' keeps precision
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value", zs);
UBItem* ubItem = dynamic_cast<UBItem*>(item);
if (ubItem)
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(ubItem->uuid()));
}
mXmlWriter.writeEndElement();
}
UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg()
{
@ -2883,6 +2955,43 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg()
return ruler;
}
UBGraphicsAxes *UBSvgSubsetAdaptor::UBSvgSubsetReader::axesFromSvg()
{
UBGraphicsAxes* axes = new UBGraphicsAxes();
graphicsItemFromSvg(axes);
axes->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
QStringRef svgX = mXmlReader.attributes().value("x");
QStringRef svgY = mXmlReader.attributes().value("y");
QStringRef svgLeft = mXmlReader.attributes().value("left");
QStringRef svgTop = mXmlReader.attributes().value("top");
QStringRef svgWidth = mXmlReader.attributes().value("width");
QStringRef svgHeight = mXmlReader.attributes().value("height");
QStringRef svgNumbers = mXmlReader.attributes().value("numbers");
if (!svgX.isNull() && !svgY.isNull())
{
axes->setPos(svgX.toString().toFloat(), svgY.toString().toFloat());
}
if (!svgWidth.isNull() && !svgHeight.isNull() && !svgLeft.isNull() && !svgTop.isNull())
{
axes->setRect(svgLeft.toString().toFloat(), svgTop.toString().toFloat(),
svgWidth.toString().toFloat(), svgHeight.toString().toFloat());
}
if (!svgNumbers.isNull())
{
axes->setShowNumbers(svgNumbers.toInt());
}
axes->setVisible(true);
return axes;
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::compassToSvg(UBGraphicsCompass* item)
{

@ -49,6 +49,7 @@ class UBGraphicsW3CWidgetItem;
class UBGraphicsTextItem;
class UBGraphicsCurtainItem;
class UBGraphicsRuler;
class UBGraphicsAxes;
class UBGraphicsCompass;
class UBGraphicsProtractor;
class UBGraphicsScene;
@ -144,6 +145,8 @@ class UBSvgSubsetAdaptor
UBGraphicsRuler* rulerFromSvg();
UBGraphicsAxes* axesFromSvg();
UBGraphicsCompass* compassFromSvg();
UBGraphicsProtractor* protractorFromSvg();
@ -247,6 +250,7 @@ class UBSvgSubsetAdaptor
void textItemToSvg(UBGraphicsTextItem *item);
void curtainItemToSvg(UBGraphicsCurtainItem *item);
void rulerToSvg(UBGraphicsRuler *item);
void axesToSvg(UBGraphicsAxes *item);
void compassToSvg(UBGraphicsCompass *item);
void protractorToSvg(UBGraphicsProtractor *item);
void cacheToSvg(UBGraphicsCache* item);

@ -1441,6 +1441,11 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
mActiveScene->addRuler(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
else if (sourceUrl.toString() == UBToolsManager::manager()->axes.id)
{
mActiveScene->addAxes(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
else if (sourceUrl.toString() == UBToolsManager::manager()->protractor.id)
{
mActiveScene->addProtractor(pPos);

@ -77,6 +77,7 @@
#include "document/UBDocumentProxy.h"
#include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsAxes.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h"
@ -467,6 +468,7 @@ bool UBBoardView::isCppTool(QGraphicsItem *item)
{
return (item->type() == UBGraphicsItemType::CompassItemType
|| item->type() == UBGraphicsItemType::RulerItemType
|| item->type() == UBGraphicsItemType::AxesItemType
|| item->type() == UBGraphicsItemType::ProtractorItemType
|| item->type() == UBGraphicsItemType::TriangleItemType
|| item->type() == UBGraphicsItemType::CurtainItemType);
@ -537,6 +539,7 @@ Here we determines cases when items should to get mouse press event at pressing
{
case UBGraphicsProtractor::Type:
case UBGraphicsRuler::Type:
case UBGraphicsAxes::Type:
case UBGraphicsTriangle::Type:
case UBGraphicsCompass::Type:
case UBGraphicsCache::Type:
@ -1626,6 +1629,7 @@ void UBBoardView::drawBackground (QPainter *painter, const QRectF &rect)
}
qreal gridSize = scene()->backgroundGridSize();
bool intermediateLines = scene()->intermediateLines();
painter->setPen (bgCrossColor);
@ -1644,6 +1648,22 @@ void UBBoardView::drawBackground (QPainter *painter, const QRectF &rect)
{
painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
}
if (intermediateLines) {
QColor intermediateColor = bgCrossColor;
intermediateColor.setAlphaF(0.5 * bgCrossColor.alphaF());
painter->setPen(intermediateColor);
for (qreal yPos = firstY - gridSize/2; yPos < rect.y () + rect.height (); yPos += gridSize)
{
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
}
for (qreal xPos = firstX - gridSize/2; xPos < rect.x () + rect.width (); xPos += gridSize)
{
painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
}
}
}
if (scene() && scene()->pageBackground() == UBPageBackground::ruled)
@ -1654,6 +1674,17 @@ void UBBoardView::drawBackground (QPainter *painter, const QRectF &rect)
{
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
}
if (intermediateLines) {
QColor intermediateColor = bgCrossColor;
intermediateColor.setAlphaF(0.5 * bgCrossColor.alphaF());
painter->setPen(intermediateColor);
for (qreal yPos = firstY - gridSize/2; yPos < rect.y () + rect.height (); yPos += gridSize)
{
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
}
}
}
}

@ -172,6 +172,7 @@ struct UBGraphicsItemType
ToolWidgetItemType, //65555
GraphicsWidgetItemType, //65556
UserTypesCount, //65557
AxesItemType, //65558
SelectionFrameType // this line must be the last line in this enum because it is types counter.
};
};

@ -50,6 +50,7 @@ int UBSettings::crossSize = 24;
int UBSettings::defaultCrossSize = 24;
int UBSettings::minCrossSize = 12;
int UBSettings::maxCrossSize = 96; //TODO: user-settable?
bool UBSettings::intermediateLines = false;
int UBSettings::colorPaletteSize = 5;
int UBSettings::objectFrameWidth = 20;
int UBSettings::boardMargin = 10;
@ -427,6 +428,15 @@ void UBSettings::init()
communityPsw = new UBSetting(this, "Community", "Password", "");
communityCredentialsPersistence = new UBSetting(this,"Community", "CredentialsPersistence",false);
enableToolAxes = new UBSetting(this, "Board", "EnableToolAxes", false);
enableIntermediateLines = new UBSetting(this, "Board", "EnableIntermediateLines", false);
if (enableToolAxes->get().toBool())
{
// add axes tool id to list
UBToolsManager::manager()->addTool(UBToolsManager::manager()->axes);
}
QStringList uris = UBToolsManager::manager()->allToolIDs();
favoritesNativeToolUris = new UBSetting(this, "App", "FavoriteToolURIs", uris);

@ -191,6 +191,7 @@ class UBSettings : public QObject
static int defaultCrossSize;
static int minCrossSize;
static int maxCrossSize;
static bool intermediateLines;
static int colorPaletteSize;
static int objectFrameWidth;
@ -425,6 +426,9 @@ class UBSettings : public QObject
UBSetting* magnifierDrawingMode;
UBSetting* autoSaveInterval;
UBSetting* enableToolAxes;
UBSetting* enableIntermediateLines;
public slots:
void setPenWidthIndex(int index);

@ -50,6 +50,7 @@
#include "gui/UBResources.h"
#include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsAxes.h"
#include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsTriangle.h"
@ -359,6 +360,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
}
mBackgroundGridSize = UBSettings::settings()->crossSize;
mIntermediateLines = UBSettings::settings()->intermediateLines;
// Just for debug. Do not delete please
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
@ -1164,6 +1166,15 @@ void UBGraphicsScene::setBackgroundGridSize(int pSize)
}
}
void UBGraphicsScene::setIntermediateLines(bool checked)
{
mIntermediateLines = checked;
setModified(true);
foreach(QGraphicsView* view, views())
view->resetCachedContent();
}
void UBGraphicsScene::setDrawingMode(bool bModeDesktop)
{
mIsDesktopMode = bModeDesktop;
@ -2201,6 +2212,20 @@ void UBGraphicsScene::addRuler(QPointF center)
ruler->setVisible(true);
}
void UBGraphicsScene::addAxes(QPointF center)
{
UBGraphicsAxes* axes = new UBGraphicsAxes(); // mem : owned and destroyed by the scene
axes->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
addItem(axes);
QPointF itemSceneCenter = axes->sceneBoundingRect().center();
axes->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
axes->setVisible(true);
}
void UBGraphicsScene::addProtractor(QPointF center)
{
// Protractor

@ -230,12 +230,18 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mBackgroundGridSize;
}
bool intermediateLines() const
{
return mIntermediateLines;
}
bool hasBackground()
{
return (mBackgroundObject != 0);
}
void addRuler(QPointF center);
void addAxes(QPointF center);
void addProtractor(QPointF center);
void addCompass(QPointF center);
void addTriangle(QPointF center);
@ -358,6 +364,7 @@ public slots:
void setBackground(bool pIsDark, UBPageBackground pBackground);
void setBackgroundZoomFactor(qreal zoom);
void setBackgroundGridSize(int pSize);
void setIntermediateLines(bool checked);
void setDrawingMode(bool bModeDesktop);
void deselectAllItems();
@ -443,6 +450,7 @@ public slots:
bool mDarkBackground;
UBPageBackground mPageBackground;
int mBackgroundGridSize;
bool mIntermediateLines;
bool mIsDesktopMode;
qreal mZoomFactor;

@ -48,6 +48,7 @@ void UBBackgroundPalette::init()
mSlider->setTracking(true); // valueChanged() is emitted during movement and not just upon releasing the slider
mSliderLabel = new QLabel(tr("Grid size"));
mIntermediateLinesLabel = new QLabel(tr("Draw intermediate grid lines"));
mResetDefaultGridSizeButton = createPaletteButton(UBApplication::mainWindow->actionDefaultGridSize, this);
mResetDefaultGridSizeButton->setFixedSize(24,24);
@ -55,12 +56,32 @@ void UBBackgroundPalette::init()
connect(UBApplication::mainWindow->actionDefaultGridSize, SIGNAL(triggered()), this, SLOT(defaultBackgroundGridSize()));
bool enableIntermediateLines = UBSettings::settings()->enableIntermediateLines->get().toBool();
if (enableIntermediateLines)
{
mDrawIntermediateLinesCheckBox = createPaletteButton(UBApplication::mainWindow->actionDrawIntermediateGridLines, this);
mDrawIntermediateLinesCheckBox->setFixedSize(24,24);
mDrawIntermediateLinesCheckBox->setCheckable(true);
mActions << UBApplication::mainWindow->actionDrawIntermediateGridLines;
mButtons.removeLast(); // don't add to button group
connect(UBApplication::mainWindow->actionDrawIntermediateGridLines, SIGNAL(toggled(bool)), this, SLOT(toggleIntermediateLines(bool)));
}
mBottomLayout->addSpacing(16);
mBottomLayout->addWidget(mSliderLabel);
mBottomLayout->addWidget(mSlider);
mBottomLayout->addWidget(mResetDefaultGridSizeButton);
mBottomLayout->addSpacing(16);
if (enableIntermediateLines)
{
mBottomLayout->addWidget(mIntermediateLinesLabel);
mBottomLayout->addWidget(mDrawIntermediateLinesCheckBox);
mBottomLayout->addSpacing(16);
}
updateLayout();
}
@ -137,6 +158,11 @@ void UBBackgroundPalette::showEvent(QShowEvent* event)
connect(mSlider, SIGNAL(valueChanged(int)),
this, SLOT(sliderValueChanged(int)));
if (UBSettings::settings()->enableIntermediateLines->get().toBool())
{
mDrawIntermediateLinesCheckBox->setChecked(UBApplication::boardController->activeScene()->intermediateLines());
}
QWidget::showEvent(event);
}
@ -152,14 +178,26 @@ void UBBackgroundPalette::defaultBackgroundGridSize()
sliderValueChanged(UBSettings::settings()->defaultCrossSize);
}
void UBBackgroundPalette::toggleIntermediateLines(bool checked)
{
UBApplication::boardController->activeScene()->setIntermediateLines(checked);
UBSettings::settings()->intermediateLines = checked; // since this function is called (indirectly, by refresh) when we switch scenes, the settings will always have the current scene's value.
}
void UBBackgroundPalette::backgroundChanged()
{
bool dark = UBApplication::boardController->activeScene()->isDarkBackground();
if (dark)
{
mSliderLabel->setStyleSheet("QLabel { color : white; }");
mIntermediateLinesLabel->setStyleSheet("QLabel { color : white; }");
}
else
{
mSliderLabel->setStyleSheet("QLabel { color : black; }");
mIntermediateLinesLabel->setStyleSheet("QLabel { color : black; }");
}
}
void UBBackgroundPalette::refresh()

@ -28,6 +28,7 @@ class UBBackgroundPalette : public UBActionPalette
protected slots:
void sliderValueChanged(int value);
void defaultBackgroundGridSize();
void toggleIntermediateLines(bool checked);
protected:
virtual void updateLayout();
@ -40,8 +41,9 @@ class UBBackgroundPalette : public UBActionPalette
QSlider* mSlider;
QLabel* mSliderLabel;
QLabel* mIntermediateLinesLabel;
UBActionPaletteButton* mResetDefaultGridSizeButton;
UBActionPaletteButton* mDrawIntermediateLinesCheckBox;
};

@ -0,0 +1,580 @@
/*
* Copyright (C) 2015-2018 Département de l'Instruction Publique (DIP-SEM)
*
* Copyright (C) 2013 Open Education Foundation
*
* Copyright (C) 2010-2013 Groupement d'Intérêt Public pour
* l'Education Numérique en Afrique (GIP ENA)
*
* This file is part of OpenBoard.
*
* OpenBoard 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, version 3 of the License,
* with a specific linking exception for the OpenSSL project's
* "OpenSSL" library (or with modified versions of it that use the
* same license as the "OpenSSL" library).
*
* OpenBoard 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 OpenBoard. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QPixmap>
#include "tools/UBGraphicsAxes.h"
#include "domain/UBGraphicsScene.h"
#include "frameworks/UBGeometryUtils.h"
#include "core/UBApplication.h"
#include "gui/UBResources.h"
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBDrawingController.h"
#include "core/memcheck.h"
const QRect UBGraphicsAxes::sDefaultRect = QRect(-200, -200, 400, 400);
const QColor UBGraphicsAxes::sLightBackgroundDrawColor = QColor(0x33, 0x33, 0x33, sDrawTransparency);
const QColor UBGraphicsAxes::sDarkBackgroundDrawColor = QColor(0xff, 0xff, 0xff, sDrawTransparency);
UBGraphicsAxes::UBGraphicsAxes()
: QGraphicsPolygonItem()
, mResizing(false)
{
setRect(sDefaultRect);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setAcceptHoverEvents(true);
mCloseSvgItem = new QGraphicsSvgItem(":/images/closeTool.svg", this);
mCloseSvgItem->setVisible(false);
mCloseSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mNumbersSvgItem = new QGraphicsSvgItem(":/images/numbersTool.svg", this);
mNumbersSvgItem->setVisible(false);
mNumbersSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mShowNumbers = true;
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
updateResizeCursor();
connect(UBApplication::boardController, &UBBoardController::zoomChanged, [this](qreal){
// recalculate shape when zoom factor changes
setRect(mBounds);
});
}
UBGraphicsAxes::~UBGraphicsAxes()
{
// NOOP
}
UBItem* UBGraphicsAxes::deepCopy() const
{
UBGraphicsAxes* copy = new UBGraphicsAxes();
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsAxes::copyItemParameters(UBItem *copy) const
{
UBGraphicsAxes *cp = dynamic_cast<UBGraphicsAxes*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->mBounds);
cp->setTransform(this->transform());
}
}
void UBGraphicsAxes::setRect(qreal x, qreal y, qreal w, qreal h)
{
// Save the bounds rect
mBounds.setX(x); mBounds.setY(y); mBounds.setWidth(w); mBounds.setHeight(h);
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
qreal range = sItemWidth * mAntiScaleRatio;
QPolygonF polygon;
polygon << QPointF(-range, -range)
<< QPointF(-range, mBounds.top())
<< QPointF(range, mBounds.top())
<< QPointF(range, -range)
<< QPointF(mBounds.right(), -range)
<< QPointF(mBounds.right(), range)
<< QPointF(range, range)
<< QPointF(range, mBounds.bottom())
<< QPointF(-range, mBounds.bottom())
<< QPointF(-range, range)
<< QPointF(mBounds.left(), range)
<< QPointF(mBounds.left(), -range);
setPolygon(polygon);
}
QRectF UBGraphicsAxes::bounds() const
{
return mBounds;
}
void UBGraphicsAxes::setShowNumbers(bool showNumbers)
{
mShowNumbers = showNumbers;
}
bool UBGraphicsAxes::showNumbes() const
{
return mShowNumbers;
}
void UBGraphicsAxes::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget)
{
Q_UNUSED(styleOption);
Q_UNUSED(widget);
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
QTransform antiScaleTransform;
antiScaleTransform.scale(mAntiScaleRatio, mAntiScaleRatio);
mCloseSvgItem->setTransform(antiScaleTransform);
mCloseSvgItem->setPos(closeButtonRect().topLeft());
mNumbersSvgItem->setTransform(antiScaleTransform);
mNumbersSvgItem->setPos(numbersButtonRect().topLeft());
QTransform antiScaleTransform2;
qreal ratio = mAntiScaleRatio > 1.0 ? mAntiScaleRatio : 1.0;
antiScaleTransform2.scale(ratio, 1.0);
QPen pen(drawColor());
pen.setWidthF(2);
painter->setPen(pen);
painter->setRenderHint(QPainter::Antialiasing, true);
painter->drawLine(xAxis());
painter->drawLine(yAxis());
// draw arrows at end
QPointF tip = xAxis().p1();
painter->drawLine(tip.x(), tip.y(), tip.x() + sArrowLength, tip.y() + sArrowWidth);
painter->drawLine(tip.x(), tip.y(), tip.x() + sArrowLength, tip.y() - sArrowWidth);
tip = xAxis().p2();
painter->drawLine(tip.x(), tip.y(), tip.x() - sArrowLength, tip.y() + sArrowWidth);
painter->drawLine(tip.x(), tip.y(), tip.x() - sArrowLength, tip.y() - sArrowWidth);
tip = yAxis().p1();
painter->drawLine(tip.x(), tip.y(), tip.x() + sArrowWidth, tip.y() - sArrowLength);
painter->drawLine(tip.x(), tip.y(), tip.x() - sArrowWidth, tip.y() - sArrowLength);
tip = yAxis().p2();
painter->drawLine(tip.x(), tip.y(), tip.x() + sArrowWidth, tip.y() + sArrowLength);
painter->drawLine(tip.x(), tip.y(), tip.x() - sArrowWidth, tip.y() + sArrowLength);
pen.setWidthF(1);
painter->setPen(pen);
paintGraduations(painter);
}
QVariant UBGraphicsAxes::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemVisibleHasChanged)
{
mCloseSvgItem->setParentItem(this);
mNumbersSvgItem->setParentItem(this);
}
return QGraphicsPolygonItem::itemChange(change, value);
}
void UBGraphicsAxes::paintGraduations(QPainter *painter)
{
painter->save();
painter->setFont(font());
QFontMetricsF fontMetrics(painter->font());
// Update the width of one "centimeter" to correspond to the width of the background grid (whether it is displayed or not)
mPixelsPerCentimeter = UBApplication::boardController->activeScene()->backgroundGridSize();
// When a "centimeter" is too narrow, we only display every 5th number
double numbersWidth = fontMetrics.boundingRect("-00").width();
bool shouldDisplayAllNumbers = (numbersWidth <= (mPixelsPerCentimeter - 5));
// draw numbers on x axis
int fromX = (xAxis().x1() + sMargin) / mPixelsPerCentimeter;
int toX = (xAxis().x2() - sMargin) / mPixelsPerCentimeter;
for (int centimeters(fromX); centimeters <= toX; centimeters++)
{
bool isImportant = abs(centimeters) == 1 || abs(centimeters) % 5 == 0;
double graduationX = mPixelsPerCentimeter * centimeters;
double graduationHeight = UBGeometryUtils::millimeterGraduationHeight;
painter->drawLine(QLineF(graduationX, graduationHeight, graduationX, -graduationHeight));
if (mShowNumbers && (shouldDisplayAllNumbers || isImportant) && centimeters != 0)
{
QString text = QString("%1").arg(centimeters);
if (graduationX + fontMetrics.width(text) / 2 < xAxis().x2())
{
qreal textWidth = fontMetrics.width(text);
qreal textHeight = fontMetrics.tightBoundingRect(text).height();
painter->drawText(
QRectF(graduationX - textWidth / 2, textHeight - 5, textWidth, textHeight),
Qt::AlignVCenter, text);
}
}
}
// draw numbers on y axis
int fromY = (-yAxis().y1() + sMargin) / mPixelsPerCentimeter;
int toY = (-yAxis().y2() - sMargin) / mPixelsPerCentimeter;
for (int centimeters(fromY); centimeters <= toY; centimeters++)
{
bool isImportant = abs(centimeters) == 1 || abs(centimeters) % 5 == 0;
double graduationY = - mPixelsPerCentimeter * centimeters;
double graduationHeight = UBGeometryUtils::millimeterGraduationHeight;
painter->drawLine(QLineF(graduationHeight, graduationY, - graduationHeight, graduationY));
if (mShowNumbers && (shouldDisplayAllNumbers || isImportant) && centimeters != 0)
{
QString text = QString("%1").arg(centimeters);
qreal textWidth = fontMetrics.width(text);
qreal textHeight = fontMetrics.tightBoundingRect(text).height();
painter->drawText(
QRectF(- textWidth - 10, graduationY - textHeight / 2, textWidth, textHeight),
Qt::AlignVCenter, text);
}
}
painter->restore();
}
void UBGraphicsAxes::setRect(const QRectF &rect)
{
setRect(rect.x(), rect.y(), rect.width(), rect.height());
}
void UBGraphicsAxes::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (resizeLeftRect().contains(event->pos()))
{
mResizeDirection = Left;
mResizing = true;
event->accept();
}
else if (resizeRightRect().contains(event->pos()))
{
mResizeDirection = Right;
mResizing = true;
event->accept();
}
else if (resizeTopRect().contains(event->pos()))
{
mResizeDirection = Top;
mResizing = true;
event->accept();
}
else if (resizeBottomRect().contains(event->pos()))
{
mResizeDirection = Bottom;
mResizing = true;
event->accept();
}
else
{
mResizing = false;
QGraphicsItem::mousePressEvent(event);
}
mCloseSvgItem->setVisible(false);
mNumbersSvgItem->setVisible(false);
}
void UBGraphicsAxes::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mResizing)
{
QGraphicsItem::mouseMoveEvent(event);
}
else
{
QPointF delta = event->pos() - event->lastPos();
prepareGeometryChange();
switch (mResizeDirection)
{
case Left:
delta.setY(0);
if (delta.x() > -mBounds.left() - sMinLength)
delta.setX(-mBounds.left() - sMinLength);
setRect(mBounds.x() + delta.x(), mBounds.y(), mBounds.width() - delta.x(), mBounds.height());
break;
case Right:
if (-delta.x() > mBounds.right() - sMinLength)
delta.setX(sMinLength - mBounds.right());
setRect(mBounds.x(), mBounds.y(), mBounds.width() + delta.x(), mBounds.height());
break;
case Top:
delta.setX(0);
if (delta.y() > -mBounds.top() - sMinLength)
delta.setY(-mBounds.top() - sMinLength);
setRect(mBounds.x(), mBounds.y() + delta.y(), mBounds.width(), mBounds.height() - delta.y());
break;
case Bottom:
if (-delta.y() > mBounds.bottom() - sMinLength)
delta.setY(sMinLength - mBounds.bottom());
setRect(mBounds.x(), mBounds.y(), mBounds.width(), mBounds.height() + delta.y());
break;
}
event->accept();
}
}
void UBGraphicsAxes::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (mResizing)
{
mResizing = false;
event->accept();
}
else if (closeButtonRect().contains(event->pos()))
{
hide();
event->accept();
}
else if (numbersButtonRect().contains(event->pos()))
{
mShowNumbers = !mShowNumbers;
update(boundingRect());
event->accept();
}
else
{
// snap to grid
if (true) {
QPointF delta = pos();
qreal gridSize = scene()->backgroundGridSize();
qreal deltaX = delta.x() - round(delta.x() / gridSize) * gridSize;
qreal deltaY = delta.y() - round(delta.y() / gridSize) * gridSize;
setPos(pos() - QPointF(deltaX, deltaY));
}
QGraphicsItem::mouseReleaseEvent(event);
}
if (scene())
scene()->setModified(true);
}
void UBGraphicsAxes::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play)
{
mCloseSvgItem->setParentItem(this);
mNumbersSvgItem->setParentItem(this);
mShowButtons = true;
mCloseSvgItem->setVisible(mShowButtons);
mNumbersSvgItem->setVisible(mShowButtons);
selectCursor(event);
event->accept();
update();
}
}
void UBGraphicsAxes::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play)
{
mCloseSvgItem->setVisible(mShowButtons);
mNumbersSvgItem->setVisible(mShowButtons);
selectCursor(event);
event->accept();
}
}
void UBGraphicsAxes::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
mShowButtons = false;
setCursor(Qt::ArrowCursor);
mCloseSvgItem->setVisible(mShowButtons);
mNumbersSvgItem->setVisible(mShowButtons);
UBDrawingController::drawingController()->mActiveRuler = NULL;
event->accept();
update();
}
void UBGraphicsAxes::updateResizeCursor()
{
QPixmap pix(":/images/cursors/resize.png");
QTransform tr;
tr.rotate(-90);
mResizeCursorH = QCursor(pix, pix.width() / 2, pix.height() / 2);
mResizeCursorV = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2);
}
QCursor UBGraphicsAxes::resizeCursor() const
{
switch (mResizeDirection)
{
case Left:
case Right:
return mResizeCursorH;
default:
break;
}
return mResizeCursorV;
}
QCursor UBGraphicsAxes::closeCursor() const
{
return Qt::ArrowCursor;
}
QCursor UBGraphicsAxes::moveCursor() const
{
return Qt::SizeAllCursor;
}
void UBGraphicsAxes::selectCursor(QGraphicsSceneHoverEvent *event)
{
if (resizeLeftRect().contains(event->pos()))
{
mResizeDirection = Left;
setCursor(resizeCursor());
}
else if (resizeRightRect().contains(event->pos()))
{
mResizeDirection = Right;
setCursor(resizeCursor());
}
else if (resizeTopRect().contains(event->pos()))
{
mResizeDirection = Top;
setCursor(resizeCursor());
}
else if (resizeBottomRect().contains(event->pos()))
{
mResizeDirection = Bottom;
setCursor(resizeCursor());
} else if (closeButtonRect().contains(event->pos()))
setCursor(closeCursor());
else if (numbersButtonRect().contains(event->pos())) {
setCursor(closeCursor());
} else {
setCursor(moveCursor());
}
}
QRectF UBGraphicsAxes::resizeLeftRect() const
{
qreal range = sItemWidth * mAntiScaleRatio;
return QRectF(xAxis().x1(), xAxis().y1() - range, sArrowLength, 2 * range);
}
QRectF UBGraphicsAxes::resizeRightRect() const
{
qreal range = sItemWidth * mAntiScaleRatio;
return QRectF(xAxis().x2() - sArrowLength, xAxis().y2() - range, sArrowLength, 2 * range);
}
QRectF UBGraphicsAxes::resizeBottomRect() const
{
qreal range = sItemWidth * mAntiScaleRatio;
return QRectF(yAxis().x1() - range, yAxis().y1() - sArrowLength, 2 * range, sArrowLength);
}
QRectF UBGraphicsAxes::resizeTopRect() const
{
qreal range = sItemWidth * mAntiScaleRatio;
return QRectF(yAxis().x2() - range, yAxis().y2(), 2 * range, sArrowLength);
}
QRectF UBGraphicsAxes::closeButtonRect() const
{
QPixmap closePixmap(":/images/closeTool.svg");
QSizeF closeRectSize(
closePixmap.width() * mAntiScaleRatio,
closePixmap.height() * mAntiScaleRatio);
QPointF closeRectTopLeft(
-sItemWidth * mAntiScaleRatio,
-sItemWidth * mAntiScaleRatio);
return QRectF(closeRectTopLeft, closeRectSize);
}
QRectF UBGraphicsAxes::numbersButtonRect() const
{
QPixmap numbersPixmap(":/images/numbersTool.svg");
QSizeF numbersRectSize(
numbersPixmap.width() * mAntiScaleRatio,
numbersPixmap.height() * mAntiScaleRatio);
QPointF numbersRectTopLeft(
sItemWidth * mAntiScaleRatio - numbersRectSize.width(),
sItemWidth * mAntiScaleRatio - numbersRectSize.height());
return QRectF(numbersRectTopLeft, numbersRectSize);
}
QLineF UBGraphicsAxes::xAxis() const
{
return QLineF(mBounds.left(), 0, mBounds.right(), 0);
}
QLineF UBGraphicsAxes::yAxis() const
{
return QLineF(0, mBounds.bottom(), 0, mBounds.top());
}
UBGraphicsScene* UBGraphicsAxes::scene() const
{
return static_cast<UBGraphicsScene*>(QGraphicsPolygonItem::scene());
}
QColor UBGraphicsAxes::drawColor() const
{
return scene()->isDarkBackground() ? sDarkBackgroundDrawColor : sLightBackgroundDrawColor;
}
QFont UBGraphicsAxes::font() const
{
QFont font("Arial");
font.setPixelSize(16);
font.setBold(true);
return font;
}

@ -0,0 +1,138 @@
/*
* Copyright (C) 2015-2018 Département de l'Instruction Publique (DIP-SEM)
*
* Copyright (C) 2013 Open Education Foundation
*
* Copyright (C) 2010-2013 Groupement d'Intérêt Public pour
* l'Education Numérique en Afrique (GIP ENA)
*
* This file is part of OpenBoard.
*
* OpenBoard 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, version 3 of the License,
* with a specific linking exception for the OpenSSL project's
* "OpenSSL" library (or with modified versions of it that use the
* same license as the "OpenSSL" library).
*
* OpenBoard 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 OpenBoard. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSAXES_H
#define UBGRAPHICSAXES_H
#include <QtGui>
#include <QtSvg>
#include "core/UB.h"
#include "domain/UBItem.h"
class UBGraphicsScene;
class UBGraphicsAxes : public QObject, public QGraphicsPolygonItem, public UBItem
{
Q_OBJECT
public:
UBGraphicsAxes();
virtual ~UBGraphicsAxes();
enum { Type = UBGraphicsItemType::AxesItemType };
virtual int type() const
{
return Type;
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
void setRect(qreal x, qreal y, qreal w, qreal h);
QRectF bounds() const;
void setShowNumbers(bool showNumbers);
bool showNumbes() const;
enum UBGraphicsAxesDirection
{
Left = 0,
Right,
Bottom,
Top
};
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void paintGraduations(QPainter *painter);
void setRect(const QRectF &rect);
// Events
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
private:
// Helpers
void updateResizeCursor();
QCursor resizeCursor() const;
QCursor closeCursor() const;
QCursor moveCursor() const;
void selectCursor(QGraphicsSceneHoverEvent *event);
virtual QRectF resizeLeftRect() const;
virtual QRectF resizeRightRect() const;
virtual QRectF resizeBottomRect() const;
virtual QRectF resizeTopRect() const;
virtual QRectF closeButtonRect() const;
virtual QRectF numbersButtonRect() const;
virtual QLineF xAxis() const;
virtual QLineF yAxis() const;
virtual UBGraphicsScene* scene() const;
QColor drawColor() const;
QFont font() const;
QGraphicsSvgItem* mCloseSvgItem;
QGraphicsSvgItem* mNumbersSvgItem;
bool mResizing;
UBGraphicsAxesDirection mResizeDirection;
bool mShowButtons;
bool mShowNumbers;
QCursor mResizeCursorH;
QCursor mResizeCursorV;
qreal mAntiScaleRatio;
qreal mPixelsPerCentimeter;
QRectF mBounds;
// Constants
static const QRect sDefaultRect;
static const int sMinLength = 50; // 1sm
static const int sMaxLength = 35000; // 700sm
static const int sArrowLength = 12;
static const int sArrowWidth = 5;
static const int sMargin = 5;
static const int sItemWidth = 30;
static const int sDrawTransparency = 255;
static const QColor sLightBackgroundDrawColor;
static const QColor sDarkBackgroundDrawColor;
};
#endif // UBGRAPHICSAXES_H

@ -68,6 +68,15 @@ UBToolsManager::UBToolsManager(QObject *parent)
mDescriptors << ruler;
axes.id = "openboardtool://axes";
axes.icon = QPixmap(":/images/toolPalette/axesTool.png");
axes.label = tr("Axes");
axes.version = "1.0";
mToolsIcon.insert(axes.id, ":/images/toolPalette/axesTool.png");
// disabled by default, added later in UBSettings:init if enabled
// mDescriptors << axes;
compass.id = "openboardtool://compass";
compass.icon = QPixmap(":/images/toolPalette/compassTool.png");
compass.label = tr("Compass");

@ -83,7 +83,13 @@ class UBToolsManager : public QObject
return UBToolDescriptor();
}
void addTool(const UBToolDescriptor& tool)
{
mDescriptors << tool;
}
UBToolDescriptor ruler;
UBToolDescriptor axes;
UBToolDescriptor protractor;
UBToolDescriptor compass;
UBToolDescriptor mask;

@ -1,4 +1,5 @@
HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBGraphicsAxes.h \
src/tools/UBGraphicsTriangle.h \
src/tools/UBGraphicsProtractor.h \
src/tools/UBGraphicsCompass.h \
@ -9,6 +10,7 @@ HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBGraphicsCache.h
SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBGraphicsAxes.cpp \
src/tools/UBGraphicsTriangle.cpp \
src/tools/UBGraphicsProtractor.cpp \
src/tools/UBGraphicsCompass.cpp \

Loading…
Cancel
Save