Factory class for generating the points, composed of QGraphicsItem objects, along a GridLine.
More...
#include <GridLineFactory.h>
|
| | GridLineFactory (QGraphicsScene &scene, const DocumentModelCoords &modelCoords) |
| | Simple constructor for general use (i.e. not by Checker) More...
|
| |
| | GridLineFactory (QGraphicsScene &scene, int pointRadius, const QList< Point > &pointsToIsolate, const DocumentModelCoords &modelCoords) |
| | Constructor for use by Checker, which has points that are isolated. More...
|
| |
| GridLine * | createGridLine (double xFrom, double yFrom, double xTo, double yTo, const Transformation &transformation) |
| | Create grid line, either along constant X/theta or constant Y/radius side. More...
|
| |
| void | createGridLinesForEvenlySpacedGrid (const DocumentModelGridDisplay &modelGridDisplay, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, GridLines &gridLines) |
| | Create a rectangular (cartesian) or annular (polar) grid of evenly spaced grid lines. More...
|
| |
Factory class for generating the points, composed of QGraphicsItem objects, along a GridLine.
For polar coordinates, the grid lines will appear as an annular segments.
For the Checker class, a set of Points can be specified which will be isolated by having grid lines stop at a specified distance (or radius) from each point
Definition at line 28 of file GridLineFactory.h.
◆ GridLineFactory() [1/2]
| GridLineFactory::GridLineFactory |
( |
QGraphicsScene & |
scene, |
|
|
const DocumentModelCoords & |
modelCoords |
|
) |
| |
◆ GridLineFactory() [2/2]
| GridLineFactory::GridLineFactory |
( |
QGraphicsScene & |
scene, |
|
|
int |
pointRadius, |
|
|
const QList< Point > & |
pointsToIsolate, |
|
|
const DocumentModelCoords & |
modelCoords |
|
) |
| |
Constructor for use by Checker, which has points that are isolated.
Definition at line 45 of file GridLineFactory.cpp.
50 m_pointRadius (pointRadius),
51 m_pointsToIsolate (pointsToIsolate),
52 m_modelCoords (modelCoords),
56 <<
" pointRadius=" << pointRadius
57 <<
" pointsToIsolate=" << pointsToIsolate.count();
◆ createGridLine()
| GridLine * GridLineFactory::createGridLine |
( |
double |
xFrom, |
|
|
double |
yFrom, |
|
|
double |
xTo, |
|
|
double |
yTo, |
|
|
const Transformation & |
transformation |
|
) |
| |
Create grid line, either along constant X/theta or constant Y/radius side.
Line goes from pointFromGraph to pointToGraph. If the coordinates are polar, we go clockwise from pointFromGraph to pointToGraph (as set up by adjustPolarAngleRange).
Definition at line 73 of file GridLineFactory.cpp.
96 const int NUM_STEPS = 1000;
98 bool stateSegmentIsActive =
false;
99 QPointF posStartScreen (0, 0);
102 for (
int i = 0; i <= NUM_STEPS; i++) {
104 double s = double (i) / double (NUM_STEPS);
107 double xGraph = (1.0 - s) * xFrom + s * xTo;
108 double yGraph = (1.0 - s) * yFrom + s * yTo;
112 xGraph = qExp ((1.0 - s) * qLn (xFrom) + s * qLn (xTo));
115 yGraph = qExp ((1.0 - s) * qLn (yFrom) + s * qLn (yTo));
122 double distanceToNearestPoint = minScreenDistanceFromPoints (pointScreen);
123 if ((distanceToNearestPoint < m_pointRadius) ||
127 if (stateSegmentIsActive) {
130 finishActiveGridLine (posStartScreen,
136 stateSegmentIsActive =
false;
142 if (!stateSegmentIsActive) {
145 stateSegmentIsActive =
true;
146 posStartScreen = pointScreen;
◆ createGridLinesForEvenlySpacedGrid()
Create a rectangular (cartesian) or annular (polar) grid of evenly spaced grid lines.
Definition at line 155 of file GridLineFactory.cpp.
165 modelGridDisplay.
stable()) {
167 double startX = modelGridDisplay.
startX ();
168 double startY = modelGridDisplay.
startY ();
169 double stepX = modelGridDisplay.
stepX ();
170 double stepY = modelGridDisplay.
stepY ();
171 double stopX = modelGridDisplay.
stopX ();
172 double stopY = modelGridDisplay.
stopY ();
196 if (stepX > (isLinearX ? 0 : 1) &&
197 stepY > (isLinearY ? 0 : 1) &&
198 (isLinearX || (startX > 0)) &&
199 (isLinearY || (startY > 0))) {
202 QPen pen (QPen (color,
206 for (
double x = startX; x <= stopX; (isLinearX ? x += stepX : x *= stepX)) {
210 gridLines.
add (gridLine);
213 for (
double y = startY; y <= stopY; (isLinearY ? y += stepY : y *= stepY)) {
217 gridLines.
add (gridLine);
The documentation for this class was generated from the following files:
double stepX() const
Get method for x grid line increment.
bool stable() const
Get method for stable flag.
void limitForXTheta(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startX, double &stepX, double &stopX) const
Limit step value for x/theta coordinate. This is a noop if the maximum grid line limit in MainWindowM...
GridLine * createGridLine(double xFrom, double yFrom, double xTo, double yTo, const Transformation &transformation)
Create grid line, either along constant X/theta or constant Y/radius side.
void limitForYRadius(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startY, double &stepY, double &stopY) const
Limit step value for y/range coordinate. This is a noop if the maximum grid line limit in MainWindowM...
Single grid line drawn a straight or curved line.
double stopY() const
Get method for y grid line upper bound (inclusive).
double stepY() const
Get method for y grid line increment.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
double startX() const
Get method for x grid line lower bound (inclusive).
void setPen(const QPen &pen)
Set the pen style.
log4cpp::Category * mainCat
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
QColor ColorPaletteToQColor(ColorPalette color)
double stopX() const
Get method for x grid line upper bound (inclusive).
ColorPalette paletteColor() const
Get method for color.
#define LOG4CPP_DEBUG_S(logger)
void add(GridLine *gridLine)
Add specified grid line. Ownership of all allocated QGraphicsItems is passed to new GridLine.
const int GRID_LINE_WIDTH
double startY() const
Get method for y grid line lower bound (inclusive).
Limit the number of grid lines so a bad combination of start/step/stop value will not lead to extreme...
const Qt::PenStyle GRID_LINE_STYLE