void BindingIndicator::setItems(const QList<FormEditorItem *> &itemList) { clear(); if (itemList.count() == 1) { m_formEditorItem = itemList.first(); QmlItemNode qmlItemNode = m_formEditorItem->qmlItemNode(); if (qmlItemNode.hasBindingProperty("x")) { m_indicatorTopShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorTopShape->updateBindingIndicator(leftLine(qmlItemNode)); } if (qmlItemNode.hasBindingProperty("y")) { m_indicatorLeftShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorLeftShape->updateBindingIndicator(topLine(qmlItemNode)); } if (qmlItemNode.hasBindingProperty("width")) { m_indicatorRightShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorRightShape->updateBindingIndicator(rightLine(qmlItemNode)); } if (qmlItemNode.hasBindingProperty("height")) { m_indicatorBottomShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorBottomShape->updateBindingIndicator(bottomLine(qmlItemNode)); } } }
void Snake::drawBorders() { QPen myPen = QPen(Qt::black); QLineF topLine(0, 0, cellSize*nbCells, 0); QLineF leftLine(0, 0, 0, cellSize*nbCells); QLineF rightLine(cellSize*nbCells, 0, cellSize*nbCells, cellSize*nbCells); QLineF bottomLine(0, cellSize*nbCells, cellSize*nbCells, cellSize*nbCells); scene->addLine(topLine, myPen); scene->addLine(leftLine, myPen); scene->addLine(rightLine, myPen); scene-> addLine(bottomLine, myPen); }
foreach (FormEditorItem *formEditorItem, itemList) { if (formEditorItem == m_formEditorItem) { QmlItemNode qmlItemNode = m_formEditorItem->qmlItemNode(); if (qmlItemNode.hasBindingProperty("x")) { if (m_indicatorTopShape.isNull()) m_indicatorTopShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorTopShape->updateBindingIndicator(leftLine(qmlItemNode)); } else { delete m_indicatorTopShape; } if (qmlItemNode.hasBindingProperty("y")) { if (m_indicatorLeftShape.isNull()) m_indicatorLeftShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorLeftShape->updateBindingIndicator(topLine(qmlItemNode)); } else { delete m_indicatorLeftShape; } if (qmlItemNode.hasBindingProperty("width")) { if (m_indicatorRightShape.isNull()) m_indicatorRightShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorRightShape->updateBindingIndicator(rightLine(qmlItemNode)); } else { delete m_indicatorRightShape; } if (qmlItemNode.hasBindingProperty("height")) { if (m_indicatorBottomShape.isNull()) m_indicatorBottomShape = new BindingIndicatorGraphicsItem(m_layerItem.data()); m_indicatorBottomShape->updateBindingIndicator(bottomLine(qmlItemNode)); } else { delete m_indicatorBottomShape; } return; } }
void Triangle::draw(const Point& x, const double _angle) { allPixels = 0; transparentPixels = 0; borderPixels = 0; setPoints(x, _angle); //Search point with max(y) enum Position {TOP = 0, MIDDLE = 1, BOTTOM = 2}; Point sortPoints[3] = {points[0], points[1], points[2]}; std::sort(sortPoints, sortPoints + 3, ycomp); Position left, right; if(sortPoints[MIDDLE].first > sortPoints[BOTTOM].first) { left = BOTTOM; right = MIDDLE; } else { left = MIDDLE; right = BOTTOM; } int lineNumber = sortPoints[TOP].second; Point leftBorder = sortPoints[TOP], rightBorder = sortPoints[TOP]; Point bottomBorder = sortPoints[MIDDLE]; Line leftLine(sortPoints[TOP], sortPoints[left]); Line rightLine(sortPoints[TOP], sortPoints[right]); Line bottomLine(sortPoints[MIDDLE], sortPoints[BOTTOM]); while(!EQUAL(sortPoints[BOTTOM], leftBorder)) { if(leftBorder.first + 1 < rightBorder.first) { for(int i = leftBorder.first + 1; i < rightBorder.first; i++) { view->setPixel(i, lineNumber, getColor(Point(i, lineNumber))); allPixels++; } } else { for(int i = rightBorder.first + 1; i < leftBorder.first; i++) { allPixels++; view->setPixel(i, lineNumber, getColor(Point(i, lineNumber))); } } while(rightBorder.second == lineNumber) { if(EQUAL(rightBorder, sortPoints[MIDDLE])) { rightBorder = bottomBorder; rightLine = bottomLine; } if(EQUAL(rightBorder, sortPoints[BOTTOM])) { break; } rightBorder = rightLine.next(); } while(leftBorder.second == lineNumber) { if(EQUAL(leftBorder, sortPoints[BOTTOM])) { break; } if(EQUAL(leftBorder, sortPoints[MIDDLE])) { leftBorder = bottomBorder; leftLine = bottomLine; } leftBorder = leftLine.next(); } lineNumber++; } leftBorder = sortPoints[TOP]; rightBorder = sortPoints[TOP]; bottomBorder = sortPoints[MIDDLE]; leftLine = Line(sortPoints[TOP], sortPoints[left]); rightLine = Line(sortPoints[TOP], sortPoints[right]); bottomLine = Line(sortPoints[MIDDLE], sortPoints[BOTTOM]); while(leftBorder != sortPoints[left]) { view->setPixel(leftBorder.first, leftBorder.second, 0x0); leftBorder = leftLine.next(); allPixels++; borderPixels++; } while(rightBorder != sortPoints[right]) { view->setPixel(rightBorder.first, rightBorder.second, 0x0); rightBorder = rightLine.next(); allPixels++; borderPixels++; } while(bottomBorder != sortPoints[BOTTOM]) { view->setPixel(bottomBorder.first, bottomBorder.second, 0x0); bottomBorder = bottomLine.next(); allPixels++; borderPixels++; } allPixels++; borderPixels++; view->setPixel(sortPoints[BOTTOM].first, sortPoints[BOTTOM].second, 0x0); }