X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fgrid.cpp;h=163a12bdb9b0071e1f4f810ca38f9332b78eb9e0;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=d6e5fbd719b8ec52270d3a58896ae43a21de60f0;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/grid.cpp b/src/base/grid.cpp index d6e5fbd..163a12b 100644 --- a/src/base/grid.cpp +++ b/src/base/grid.cpp @@ -18,26 +18,15 @@ #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) { } @@ -45,7 +34,7 @@ RS_Grid::RS_Grid(GraphicView * gv): graphicView(gv), pt(NULL), number(0), /** * Destructor. */ -RS_Grid::~RS_Grid() +Grid::~Grid() { if (pt != NULL) delete[] pt; @@ -60,9 +49,9 @@ RS_Grid::~RS_Grid() /** * 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; @@ -104,7 +93,7 @@ void RS_Grid::update() numMetaX = 0; numMetaY = 0; - RS_DEBUG->print("RS_Grid::update: 001"); + DEBUG->print("Grid::update: 001"); // find out unit: RS2::Unit unit = RS2::None; @@ -119,11 +108,11 @@ void RS_Grid::update() 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) @@ -136,7 +125,7 @@ void RS_Grid::update() else gridWidth.y = 0.000001; - RS_DEBUG->print("RS_Grid::update: 003"); + DEBUG->print("Grid::update: 003"); // auto scale grid if (scaleGrid) @@ -151,12 +140,12 @@ void RS_Grid::update() 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; @@ -168,30 +157,30 @@ void RS_Grid::update() 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; } @@ -203,19 +192,19 @@ void RS_Grid::update() 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; } @@ -226,7 +215,7 @@ void RS_Grid::update() } } - RS_DEBUG->print("RS_Grid::update: 008"); + DEBUG->print("Grid::update: 008"); // metagrid X shows inches.. metaGridWidth.x = 1.0; @@ -253,7 +242,7 @@ void RS_Grid::update() } } - RS_DEBUG->print("RS_Grid::update: 009"); + DEBUG->print("Grid::update: 009"); // metagrid Y shows inches.. metaGridWidth.y = 1.0; @@ -282,11 +271,11 @@ void RS_Grid::update() } } - 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) { @@ -304,13 +293,13 @@ void RS_Grid::update() 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; @@ -338,11 +327,11 @@ void RS_Grid::update() 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) @@ -364,7 +353,7 @@ void RS_Grid::update() pt = NULL; } - RS_DEBUG->print("RS_Grid::update: 015"); + DEBUG->print("Grid::update: 015"); } // find meta grid boundaries @@ -387,8 +376,8 @@ void RS_Grid::update() 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) { @@ -415,13 +404,13 @@ void RS_Grid::update() } } - 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; } @@ -429,7 +418,7 @@ Vector * RS_Grid::getPoints() /** * @return Number of visible grid points. */ -int RS_Grid::count() +int Grid::count() { return number; } @@ -437,7 +426,7 @@ int RS_Grid::count() /** * @return Grid info for status widget. */ -QString RS_Grid::getInfo() +QString Grid::getInfo() { return QString("%1 / %2").arg(spacing).arg(metaSpacing); } @@ -445,7 +434,7 @@ QString RS_Grid::getInfo() /** * @return Meta grid positions in X. */ -double * RS_Grid::getMetaX() +double * Grid::getMetaX() { return metaX; } @@ -453,7 +442,7 @@ double * RS_Grid::getMetaX() /** * @return Number of visible meta grid lines in X. */ -int RS_Grid::countMetaX() +int Grid::countMetaX() { return numMetaX; } @@ -461,7 +450,7 @@ int RS_Grid::countMetaX() /** * @return Meta grid positions in Y. */ -double * RS_Grid::getMetaY() +double * Grid::getMetaY() { return metaY; } @@ -469,7 +458,7 @@ double * RS_Grid::getMetaY() /** * @return Number of visible meta grid lines in Y. */ -int RS_Grid::countMetaY() +int Grid::countMetaY() { return numMetaY; }