void qAttitudeIndicator::initRollChar() { QLine line; line.setLine(-size/32,14*size/32,0,15*size/32); target.append(line); line.setLine(0,15*size/32,size/32,14*size/32); target.append(line); line.setLine(size/32,14*size/32,-size/32,14*size/32); target.append(line); }
void qAttitudeIndicator::initTargetChar() { QLine line; line.setLine(-size/4,0,-size/16,0); target.append(line); line.setLine(-size/16,0,0,-size/32); target.append(line); line.setLine(0,-size/32,size/16,0); target.append(line); line.setLine(size/16,0,size/4,0); target.append(line); }
void WidgetArea::addPlacementLine(int val, bool vertical, bool& changed) { QLine l; if(vertical) l.setLine(val, -PLACEMENT_SHOW, val, height()+PLACEMENT_SHOW); else l.setLine(-PLACEMENT_SHOW, val, width()+PLACEMENT_SHOW, val); if(m_placementLines.contains(l)) return; m_placementLines.push_back(l); changed = true; }
void tst_QLine::testSet() { { QLine l; l.setP1(QPoint(1, 2)); l.setP2(QPoint(3, 4)); QCOMPARE(l.x1(), 1); QCOMPARE(l.y1(), 2); QCOMPARE(l.x2(), 3); QCOMPARE(l.y2(), 4); l.setPoints(QPoint(5, 6), QPoint(7, 8)); QCOMPARE(l.x1(), 5); QCOMPARE(l.y1(), 6); QCOMPARE(l.x2(), 7); QCOMPARE(l.y2(), 8); l.setLine(9, 10, 11, 12); QCOMPARE(l.x1(), 9); QCOMPARE(l.y1(), 10); QCOMPARE(l.x2(), 11); QCOMPARE(l.y2(), 12); } { QLineF l; l.setP1(QPointF(1, 2)); l.setP2(QPointF(3, 4)); QCOMPARE(l.x1(), 1.0); QCOMPARE(l.y1(), 2.0); QCOMPARE(l.x2(), 3.0); QCOMPARE(l.y2(), 4.0); l.setPoints(QPointF(5, 6), QPointF(7, 8)); QCOMPARE(l.x1(), 5.0); QCOMPARE(l.y1(), 6.0); QCOMPARE(l.x2(), 7.0); QCOMPARE(l.y2(), 8.0); l.setLine(9.0, 10.0, 11.0, 12.0); QCOMPARE(l.x1(), 9.0); QCOMPARE(l.y1(), 10.0); QCOMPARE(l.x2(), 11.0); QCOMPARE(l.y2(), 12.0); } }
void PuzzlePrinter::drawKillerSudokuCages (const SKGraph* graph, const QVector<int> & edges) { // Killer Sudokus have cages AND groups: so the cages are drawn differently. // We keep the outer wall of the cage on our left and draw a dashed line // just inside that boundary. This reduces ugly criss-crossing of lines. // // Directions and related arrays are all in clockwise order. enum Direction {East, South, West, North, nDirections}; const Direction rightTurn [nDirections] = {South, West, North, East}; const Direction leftTurn [nDirections] = {North, East, South, West}; const int wallOnLeft [nDirections] = {1 << Above, 1 << Right, 1 << Below, 1 << Left}; const int wallAhead [nDirections] = {1 << Right, 1 << Below, 1 << Left, 1 << Above}; const int deltaX [nDirections] = {+1, 0, -1, 0}; const int deltaY [nDirections] = {0, +1, 0, -1}; int cellInc [nDirections] = {graph->order(), +1, -graph->order(), -1}; int offset = (m_sCell + 6) / 12; int longSide = m_sCell; int shortSide = m_sCell - offset - offset; m_p->setPen (m_dashes); for (int n = 0; n < graph->cageCount(); n++) { int topLeft = graph->cageTopLeft(n); int cell = topLeft; int edge = edges.at (cell); int startX = m_topX + m_sCell * graph->cellPosX (cell) + offset; int startY = m_topY + m_sCell * graph->cellPosY (cell) + offset; int dx = 0; int dy = 0; QLine line (startX, startY, startX, startY); Direction direction = East; // Keep drawing until we get back to the starting cell and direction. do { // If there is a wall on the left, follow it. if (edge & wallOnLeft [direction]) { if (edge & wallAhead [direction]) { // Go to wall (shortSide), draw line, turn right, new line. dx = deltaX [direction] * shortSide; dy = deltaY [direction] * shortSide; line.setLine (line.x1(), line.y1(), line.x2() + dx, line.y2() + dy); m_p->drawLine (line); direction = rightTurn [direction]; line.setLine (line.x2(), line.y2(), line.x2(), line.y2()); } else { // Extend to start of next cell (longSide). dx = deltaX [direction] * longSide; dy = deltaY [direction] * longSide; line.setLine (line.x1(), line.y1(), line.x2() + dx, line.y2() + dy); cell = cell + cellInc [direction]; edge = edges.at (cell); } } // Else, if there is no wall on the left ... else { // Draw line, turn left, new line, go to start of next cell. m_p->drawLine (line); direction = leftTurn [direction]; dx = deltaX [direction] * (longSide - shortSide); dy = deltaY [direction] * (longSide - shortSide); line.setLine (line.x2(), line.y2(), line.x2() + dx, line.y2() + dy); cell = cell + cellInc [direction]; edge = edges.at (cell); } } while (! ((cell == topLeft) && (direction == East))); } // Draw next cage. }