Merge pull request #753 from frohro/frohro

Frohro
presentation
andreasb242 7 years ago committed by GitHub
commit 08bd4e91ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/control/tools/BaseStrokeHandler.cpp
  2. 14
      src/control/tools/CircleHandler.cpp
  3. 15
      src/control/tools/CoordinateSystemHandler.cpp
  4. 2
      src/control/tools/RectangleHandler.cpp

@ -27,10 +27,11 @@ void BaseStrokeHandler::snapToGrid(double& x, double& y)
* fix the point to the grid intersection value
*/
double gridSize = 14.17;
double t = xournal->getControl()->getSettings()->getSnapGridTolerance();
double tolerance = (gridSize/2) - (1/t);
double xRem = fmod(x,gridSize);
double xRem = fmod(x,gridSize);
double yRem = fmod(y,gridSize);
bool snapX = false;

@ -20,6 +20,16 @@ CircleHandler::~CircleHandler()
void CircleHandler::drawShape(Point& c, bool shiftDown)
{
/**
* Snap first point to grid (if enabled)
*/
if (!shiftDown && xournal->getControl()->getSettings()->isSnapGrid())
{
Point firstPoint = stroke->getPoint(0);
snapToGrid(firstPoint.x,firstPoint.y);
stroke->setFirstPoint(firstPoint.x,firstPoint.y);
}
int count = stroke->getPointCount();
if (count < 2)
@ -29,6 +39,10 @@ void CircleHandler::drawShape(Point& c, bool shiftDown)
else
{
Point p = stroke->getPoint(0);
if (xournal->getControl()->getSettings()->isSnapGrid())
{
snapToGrid(c.x,c.y);
}
// set resolution proportional to radius
double diameter = sqrt(pow(c.x - p.x, 2.0) + pow(c.y - p.y, 2.0));
int npts = (int) (diameter * 2.0);

@ -27,6 +27,15 @@ CoordinateSystemHandler::~CoordinateSystemHandler()
*/
void CoordinateSystemHandler::drawShape(Point& currentPoint, bool shiftDown)
{
/**
* Snap first point to grid (if enabled)
*/
if (!shiftDown && xournal->getControl()->getSettings()->isSnapGrid())
{
Point firstPoint = stroke->getPoint(0);
snapToGrid(firstPoint.x,firstPoint.y);
stroke->setFirstPoint(firstPoint.x,firstPoint.y);
}
int count = stroke->getPointCount();
if (count < 1)
@ -45,7 +54,11 @@ void CoordinateSystemHandler::drawShape(Point& currentPoint, bool shiftDown)
stroke->deletePoint(2);
stroke->deletePoint(1);
}
if (xournal->getControl()->getSettings()->isSnapGrid())
{
snapToGrid(startingPoint.x,startingPoint.y);
snapToGrid(currentPoint.x,currentPoint.y);
}
// Draw the other two points
if (shiftDown || !xournal->getControl()->getSettings()->isSnapRotation())
{

@ -77,7 +77,7 @@ void RectangleHandler::drawShape(Point& c, bool shiftDown)
{
snapToGrid(c.x,c.y);
}
stroke->addPoint(Point(p.x, c.y)); // was p.y
stroke->addPoint(Point(p.x, c.y));
stroke->addPoint(c);
stroke->addPoint(Point(c.x, p.y));
stroke->addPoint(p);

Loading…
Cancel
Save