#include "drawing.h"
#include "graphicview.h"
-//#include "graphicview.h"
#include "settings.h"
#include "units.h"
#include "vector.h"
#warning "!!! Clean out all references to RS_GraphicView here and in header !!!"
-#if 0
/**
* Constructor.
*/
-RS_Grid::RS_Grid(RS_GraphicView * gv): graphicView(gv), pt(NULL), number(0),
- metaX(NULL), numMetaX(0), metaY(NULL), numMetaY(0)
-{
-}
-#endif
-
-/**
- * Constructor II.
- */
-RS_Grid::RS_Grid(GraphicView * gv): graphicView(gv), pt(NULL), number(0),
+Grid::Grid(GraphicView * gv): graphicView(gv), pt(NULL), number(0),
metaX(NULL), numMetaX(0), metaY(NULL), numMetaY(0)
{
}
/**
* Destructor.
*/
-RS_Grid::~RS_Grid()
+Grid::~Grid()
{
if (pt != NULL)
delete[] pt;
/**
* Updates the grid point array.
*/
-void RS_Grid::update()
+void Grid::update()
{
- RS_DEBUG->print("RS_Grid::update");
+ DEBUG->print("Grid::update");
if (!graphicView->isGridOn())
return;
numMetaX = 0;
numMetaY = 0;
- RS_DEBUG->print("RS_Grid::update: 001");
+ DEBUG->print("Grid::update: 001");
// find out unit:
RS2::Unit unit = RS2::None;
Vector gridWidth;
Vector metaGridWidth;
- RS_DEBUG->print("RS_Grid::update: 002");
+ DEBUG->print("Grid::update: 002");
// init grid spacing:
// metric grid:
- if (RS_Units::isMetric(unit) || unit == RS2::None
+ if (Units::isMetric(unit) || unit == RS2::None
|| format == RS2::Decimal || format == RS2::Engineering)
{
if (userGrid.x > 0.0)
else
gridWidth.y = 0.000001;
- RS_DEBUG->print("RS_Grid::update: 003");
+ DEBUG->print("Grid::update: 003");
// auto scale grid
if (scaleGrid)
metaGridWidth.x = gridWidth.x * 10;
metaGridWidth.y = gridWidth.y * 10;
- RS_DEBUG->print("RS_Grid::update: 004");
+ DEBUG->print("Grid::update: 004");
}
// imperial grid:
else
{
- RS_DEBUG->print("RS_Grid::update: 005");
+ DEBUG->print("Grid::update: 005");
if (userGrid.x > 0.0)
gridWidth.x = userGrid.x;
else
gridWidth.y = 1.0 / 1024.0;
- RS_DEBUG->print("RS_Grid::update: 006");
+ DEBUG->print("Grid::update: 006");
if (unit == RS2::Inch)
{
- RS_DEBUG->print("RS_Grid::update: 007");
+ DEBUG->print("Grid::update: 007");
// auto scale grid
if (scaleGrid)
{
while (graphicView->toGuiDX(gridWidth.x) < minGridSpacing)
{
- if (RS_Math::round(gridWidth.x) >= 36)
+ if (Math::round(gridWidth.x) >= 36)
{
gridWidth.x *= 2;
}
- else if (RS_Math::round(gridWidth.x) >= 12)
+ else if (Math::round(gridWidth.x) >= 12)
{
gridWidth.x *= 3;
}
- else if (RS_Math::round(gridWidth.x) >= 4)
+ else if (Math::round(gridWidth.x) >= 4)
{
gridWidth.x *= 3;
}
- else if (RS_Math::round(gridWidth.x) >= 1)
+ else if (Math::round(gridWidth.x) >= 1)
{
gridWidth.x *= 2;
}
while (graphicView->toGuiDY(gridWidth.y) < minGridSpacing)
{
- if (RS_Math::round(gridWidth.y) >= 36)
+ if (Math::round(gridWidth.y) >= 36)
{
gridWidth.y *= 2;
}
- else if (RS_Math::round(gridWidth.y) >= 12)
+ else if (Math::round(gridWidth.y) >= 12)
{
gridWidth.y *= 3;
}
- else if (RS_Math::round(gridWidth.y) >= 4)
+ else if (Math::round(gridWidth.y) >= 4)
{
gridWidth.y *= 3;
}
- else if (RS_Math::round(gridWidth.y) >= 1)
+ else if (Math::round(gridWidth.y) >= 1)
{
gridWidth.y *= 2;
}
}
}
- RS_DEBUG->print("RS_Grid::update: 008");
+ DEBUG->print("Grid::update: 008");
// metagrid X shows inches..
metaGridWidth.x = 1.0;
}
}
- RS_DEBUG->print("RS_Grid::update: 009");
+ DEBUG->print("Grid::update: 009");
// metagrid Y shows inches..
metaGridWidth.y = 1.0;
}
}
- RS_DEBUG->print("RS_Grid::update: 010");
+ DEBUG->print("Grid::update: 010");
}
else
{
- RS_DEBUG->print("RS_Grid::update: 011");
+ DEBUG->print("Grid::update: 011");
if (scaleGrid)
{
metaGridWidth.y = -1.0;
}
- RS_DEBUG->print("RS_Grid::update: 012");
+ DEBUG->print("Grid::update: 012");
}
//gridWidth.y = gridWidth.x;
//metaGridWidth.y = metaGridWidth.x;
}
- RS_DEBUG->print("RS_Grid::update: 013");
+ DEBUG->print("Grid::update: 013");
// for grid info:
spacing = gridWidth.x;
bottom -= gridWidth.y;
// calculate number of visible grid points
- int numberX = (RS_Math::round((right-left) / gridWidth.x) + 1);
- int numberY = (RS_Math::round((top-bottom) / gridWidth.y) + 1);
+ int numberX = (Math::round((right-left) / gridWidth.x) + 1);
+ int numberY = (Math::round((top-bottom) / gridWidth.y) + 1);
number = numberX * numberY;
- RS_DEBUG->print("RS_Grid::update: 014");
+ DEBUG->print("Grid::update: 014");
// create grid array:
if (number > 0 && number < 1000000)
pt = NULL;
}
- RS_DEBUG->print("RS_Grid::update: 015");
+ DEBUG->print("Grid::update: 015");
}
// find meta grid boundaries
mbottom -= metaGridWidth.y;
// calculate number of visible meta grid lines:
- numMetaX = (RS_Math::round((mright - mleft) / metaGridWidth.x) + 1);
- numMetaY = (RS_Math::round((mtop - mbottom) / metaGridWidth.y) + 1);
+ numMetaX = (Math::round((mright - mleft) / metaGridWidth.x) + 1);
+ numMetaY = (Math::round((mtop - mbottom) / metaGridWidth.y) + 1);
if (numMetaX > 0 && numMetaY > 0)
{
}
}
- RS_DEBUG->print("RS_Grid::update: OK");
+ DEBUG->print("Grid::update: OK");
}
/**
* @return Array of all visible grid points.
*/
-Vector * RS_Grid::getPoints()
+Vector * Grid::getPoints()
{
return pt;
}
/**
* @return Number of visible grid points.
*/
-int RS_Grid::count()
+int Grid::count()
{
return number;
}
/**
* @return Grid info for status widget.
*/
-QString RS_Grid::getInfo()
+QString Grid::getInfo()
{
return QString("%1 / %2").arg(spacing).arg(metaSpacing);
}
/**
* @return Meta grid positions in X.
*/
-double * RS_Grid::getMetaX()
+double * Grid::getMetaX()
{
return metaX;
}
/**
* @return Number of visible meta grid lines in X.
*/
-int RS_Grid::countMetaX()
+int Grid::countMetaX()
{
return numMetaX;
}
/**
* @return Meta grid positions in Y.
*/
-double * RS_Grid::getMetaY()
+double * Grid::getMetaY()
{
return metaY;
}
/**
* @return Number of visible meta grid lines in Y.
*/
-int RS_Grid::countMetaY()
+int Grid::countMetaY()
{
return numMetaY;
}