// -------------------------------------------------------------------------- void Arrow::paint(ViewPainter *p) { Q3PointArray Points; int x1_, y1_, x2_, y2_, x3_, y3_; if(isSelected) { p->Painter->setPen(QPen(Qt::darkGray,Pen.width()+5)); p->drawLine(cx, cy, cx+x2, cy+y2); p->drawLine(cx+x2, cy+y2, cx+xp1, cy+yp1); p->drawLine(cx+x2, cy+y2, cx+xp2, cy+yp2); if(Style == 0) { // arrow head with two lines ? p->Painter->setPen(QPen(Qt::white, Pen.width(), Pen.style())); p->drawLine(cx, cy, cx+x2, cy+y2); p->Painter->setPen(QPen(Qt::white, Pen.width(), Qt::SolidLine)); p->drawLine(cx+x2, cy+y2, cx+xp1, cy+yp1); p->drawLine(cx+x2, cy+y2, cx+xp2, cy+yp2); } else { // filled arrow head p->drawLine(cx+xp1, cy+yp1, cx+xp2, cy+yp2); p->Painter->setPen(QPen(Qt::white, Pen.width(), Pen.style())); p->drawLine(cx, cy, cx+x2, cy+y2); p->Painter->setPen(QPen(Qt::white, Pen.width(), Qt::SolidLine)); p->Painter->setBrush(Qt::white); p->map(cx+xp1, cy+yp1, x1_, y1_); p->map(cx+x2, cy+y2, x2_, y2_); p->map(cx+xp2, cy+yp2, x3_, y3_); Points.setPoints(3, x1_, y1_, x2_, y2_, x3_, y3_); p->Painter->drawConvexPolygon(Points); p->Painter->setBrush(Qt::NoBrush); // no filling for next paintings } p->Painter->setPen(QPen(Qt::darkRed,2)); p->drawResizeRect(cx, cy); // markers for changing the size p->drawResizeRect(cx+x2, cy+y2); return; } p->Painter->setPen(Pen); p->drawLine(cx, cy, cx+x2, cy+y2); p->Painter->setPen(QPen(Pen.color(), Pen.width(), Qt::SolidLine)); if(Style == 0) { // arrow head with two lines ? p->drawLine(cx+x2, cy+y2, cx+xp1, cy+yp1); p->drawLine(cx+x2, cy+y2, cx+xp2, cy+yp2); } else { // filled arrow head p->Painter->setBrush(Pen.color()); p->map(cx+xp1, cy+yp1, x1_, y1_); p->map(cx+x2, cy+y2, x2_, y2_); p->map(cx+xp2, cy+yp2, x3_, y3_); Points.setPoints(3, x1_, y1_, x2_, y2_, x3_, y3_); p->Painter->drawConvexPolygon(Points); p->Painter->setBrush(Qt::NoBrush); // no filling for next paintings } }
void OutputFlowNode::drawShape ( QPainter &p ) { const int _x = ( int ) x(); const int _y = ( int ) y(); if ( m_dir == 0 ) p.drawLine ( _x, _y, _x-8, _y ); else if ( m_dir == 90 ) p.drawLine ( _x, _y, _x, _y-8 ); else if ( m_dir == 180 ) p.drawLine ( _x, _y, _x+8, _y ); else if ( m_dir == 270 ) p.drawLine ( _x, _y, _x, _y+8 ); Q3PointArray pa ( 3 ); switch ( m_dir ) { case 0: // right pa = arrowPoints ( 0 ); break; case 180: // left pa = arrowPoints ( 180 ); break; case 90: // down pa = arrowPoints ( 90 ); break; case 270: // up pa = arrowPoints ( 270 ); break; default: kError() << k_funcinfo << "BUG: m_dir = " << m_dir << endl; } // Note: I have not tested the positioning of the arrows for all combinations. // In fact, most almost definitely do not work. So feel free to change the code // as you see fit if necessary. if ( m_dir == 0 ) pa.translate ( -5, 0 ); else if ( m_dir == 90 ) pa.translate ( 0, -5 ); else if ( m_dir == 180 ) pa.translate ( 5, 0 ); else if ( m_dir == 270 ) pa.translate ( 0, 5 ); pa.translate ( _x, _y ); p.drawPolygon ( pa ); }
void DigitView::addSampleMatchPoint(const Q3PointArray &samplePointPixels) { // remove stale handles removeHandles(); // add new handles //ASSERT_ENGAUGE(samplePointPixels); addHandles(samplePointPixels.boundingRect()); }
void JunctionFlowNode::drawShape ( QPainter &p ) { const int _x = ( int ) x(); const int _y = ( int ) y(); if ( !m_inFlowConnList.isEmpty() ) { const FlowConnectorList::iterator end = m_inFlowConnList.end(); for ( FlowConnectorList::iterator it = m_inFlowConnList.begin(); it != end; ++ it ) { Connector * connector = *it; if ( !connector ) continue; // Work out the direction of the connector const QPointList points = connector->connectorPoints ( false ); const int count = points.size(); if ( count < 2 ) continue; QPoint end_0 = points[count-1]; QPoint end_1 = points[count-2]; Q3PointArray pa; if ( end_0.x() < end_1.x() ) { pa = arrowPoints ( 180 ); pa.translate ( 4, 0 ); } else if ( end_0.x() > end_1.x() ) { pa = arrowPoints ( 0 ); pa.translate ( -4, 0 ); } else if ( end_0.y() < end_1.y() ) { pa = arrowPoints ( 270 ); pa.translate ( 0, 4 ); } else if ( end_0.y() > end_1.y() ) { pa = arrowPoints ( 90 ); pa.translate ( 0, -4 ); } else continue; pa.translate ( _x, _y ); p.setPen ( connector->isSelected() ? m_selectedColor : Qt::black ); p.drawPolygon ( pa ); } return; } if ( m_dir == 0 ) p.drawLine ( _x, _y, _x-8, _y ); else if ( m_dir == 90 ) p.drawLine ( _x, _y, _x, _y-8 ); else if ( m_dir == 180 ) p.drawLine ( _x, _y, _x+8, _y ); else if ( m_dir == 270 ) p.drawLine ( _x, _y, _x, _y+8 ); }
void RDMarkerBar::DrawMap() { QPixmap *pix=new QPixmap(size()); QPainter *p=new QPainter(pix); Q3PointArray *pt; p->fillRect(0,0,size().width(),size().height(),backgroundColor()); if(marker_length>0) { p->setPen(RD_CUEEDITOR_START_MARKER); p->setBrush(RD_CUEEDITOR_START_MARKER); p->fillRect(size().width()*marker_pos[RDMarkerBar::Start]/marker_length-2,0, 4,size().height(),RD_CUEEDITOR_START_MARKER); pt=new Q3PointArray(3); pt->setPoint(0,size().width()*marker_pos[RDMarkerBar::Start]/marker_length-2, size().height()/2-1); pt->setPoint(1,size().width()*marker_pos[RDMarkerBar::Start]/marker_length-12, size().height()-2); pt->setPoint(2,size().width()*marker_pos[RDMarkerBar::Start]/marker_length-12, 1); p->drawPolygon(*pt); p->fillRect(size().width()*marker_pos[RDMarkerBar::End]/marker_length-2,0, 4,size().height(),RD_CUEEDITOR_START_MARKER); pt->setPoint(0,size().width()*marker_pos[RDMarkerBar::End]/marker_length+2, size().height()/2-1); pt->setPoint(1,size().width()*marker_pos[RDMarkerBar::End]/marker_length+12, size().height()-2); pt->setPoint(2,size().width()*marker_pos[RDMarkerBar::End]/marker_length+12, 1); p->drawPolygon(*pt); delete pt; p->setPen(RD_CUEEDITOR_PLAY_MARKER); p->setBrush(RD_CUEEDITOR_PLAY_MARKER); p->fillRect(size().width()*marker_pos[RDMarkerBar::Play]/marker_length-1,0, 2,size().height(),RD_CUEEDITOR_PLAY_MARKER); } p->end(); setPixmap(*pix); delete p; delete pix; }
void VerticalLine::draw (QPixmap &buffer, Scaler &, int startIndex, int pixelspace, int startX) { QPainter painter; painter.begin(&buffer); int x2 = data->getX(date); if (x2 == -1) return; int x = startX + (x2 * pixelspace) - (startIndex * pixelspace); if (x == -1) return; painter.setPen(getColor()); painter.drawLine (x, 0, x, buffer.height()); clearSelectionArea(); Q3PointArray array; array.putPoints(0, 4, x - (HANDLE_WIDTH / 2), 0, x + (HANDLE_WIDTH / 2), 0, x + (HANDLE_WIDTH / 2), buffer.height(), x - (HANDLE_WIDTH / 2), buffer.height()); setSelectionArea(new QRegion(array)); if (getStatus() == COBase::Selected) { clearGrabHandles(); int t = (int) buffer.height() / 4; setGrabHandle(new QRegion(x - (HANDLE_WIDTH / 2), 0, HANDLE_WIDTH, HANDLE_WIDTH, QRegion::Rectangle)); painter.fillRect(x - (HANDLE_WIDTH / 2), 0, HANDLE_WIDTH, HANDLE_WIDTH, getColor()); setGrabHandle(new QRegion(x - (HANDLE_WIDTH / 2), t, HANDLE_WIDTH, HANDLE_WIDTH, QRegion::Rectangle)); painter.fillRect(x - (HANDLE_WIDTH / 2), t, HANDLE_WIDTH, HANDLE_WIDTH, getColor()); setGrabHandle(new QRegion(x - (HANDLE_WIDTH / 2), t * 2, HANDLE_WIDTH, HANDLE_WIDTH, QRegion::Rectangle)); painter.fillRect(x - (HANDLE_WIDTH / 2), t * 2, HANDLE_WIDTH, HANDLE_WIDTH, getColor()); setGrabHandle(new QRegion(x - (HANDLE_WIDTH / 2), t * 3, HANDLE_WIDTH, HANDLE_WIDTH, QRegion::Rectangle)); painter.fillRect(x - (HANDLE_WIDTH / 2), t * 3, HANDLE_WIDTH, HANDLE_WIDTH, getColor()); setGrabHandle(new QRegion(x - (HANDLE_WIDTH / 2), t * 4, HANDLE_WIDTH, HANDLE_WIDTH, QRegion::Rectangle)); painter.fillRect(x - (HANDLE_WIDTH / 2), t * 4, HANDLE_WIDTH, HANDLE_WIDTH, getColor()); } painter.end(); }
void ScalePlot::drawScale () { QPainter painter; painter.begin(&buffer); painter.setFont(plotFont); painter.setPen(QPen(borderColor, 1, Qt::SolidLine)); painter.fillRect(0, 0, buffer.width(), buffer.height(), backgroundColor); QVector<double> scaleArray; scaler.getScaleArray(scaleArray); QFontMetrics fm(plotFont); int x = 0; int loop; for (loop = 0; loop < (int) scaleArray.size(); loop++) { int y = scaler.convertToY(scaleArray[loop]); painter.drawLine (x, y, x + 4, y); // draw the text QString s; strip(scaleArray[loop], 4, s); // abbreviate too many (>=3) trailing zeroes in large numbers on y-axes if (! mainFlag) { bool flag = FALSE; if (s.toDouble() < 0) { flag = TRUE; s.remove(0, 1); } if (s.toDouble() >= 1000000000) { strip(s.toDouble() / 1000000000, 4, s); s.append("b"); } else { if (s.toDouble() >= 1000000) { strip(s.toDouble() / 1000000, 4, s); s.append("m"); } // else // { // if (s.toDouble() >= 1000) // { // strip(s.toDouble() / 1000, 4, s); // s.append("k"); // } // } } if (flag) s.prepend("-"); } painter.drawText(x + 7, y + (fm.height() / 2), s); } painter.drawLine (x, 0, x, buffer.height()); // draw the last value pointer on the scale of main plot int y = scaler.convertToY(close); Q3PointArray array; array.setPoints(3, x + 2, y, x + 8, y - 4, x + 8, y + 4); painter.setBrush(borderColor); painter.drawPolygon(array, TRUE, 0, -1); painter.end(); }
void CPencilLine::setControlPoints (Q3PointArray clo, bool cl){ polyline = Q3PointArray (clo.size ()); polyline = clo; }
void PointSetStyles::drawShape(QPainter &p, int xScreen, int yScreen, PointSetStyle pointSetStyle) { p.setPen(pointSetPen(pointSetStyle.pointLineColor, pointSetStyle.pointLineSize)); p.setBrush(pointSetBrush(pointSetStyle.pointInColor)); Q3PointArray arr; int hPS = pointSizeToHalfwidth(pointSetStyle.pointSize); // half point size, excluding point line size switch (pointSetStyle.pointShape) { case Cross: arr.resize(9); arr.setPoint(0, QPoint(-hPS + xScreen, 0 + yScreen)); arr.setPoint(1, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(2, QPoint( 0 + xScreen, -hPS + yScreen)); arr.setPoint(3, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(4, QPoint( hPS + xScreen, 0 + yScreen)); arr.setPoint(5, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(6, QPoint( 0 + xScreen, hPS + yScreen)); arr.setPoint(7, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(8, QPoint(-hPS + xScreen, 0 + yScreen)); break; case Diamond: arr.resize(5); arr.setPoint(0, QPoint(-hPS + xScreen, 0 + yScreen)); arr.setPoint(1, QPoint( 0 + xScreen, -hPS + yScreen)); arr.setPoint(2, QPoint( hPS + xScreen, 0 + yScreen)); arr.setPoint(3, QPoint( 0 + xScreen, hPS + yScreen)); arr.setPoint(4, QPoint(-hPS + xScreen, 0 + yScreen)); break; case Square: arr.resize(5); arr.setPoint(0, QPoint(-hPS + xScreen, -hPS + yScreen)); arr.setPoint(1, QPoint( hPS + xScreen, -hPS + yScreen)); arr.setPoint(2, QPoint( hPS + xScreen, hPS + yScreen)); arr.setPoint(3, QPoint(-hPS + xScreen, hPS + yScreen)); arr.setPoint(4, QPoint(-hPS + xScreen, -hPS + yScreen)); break; case Triangle: arr.resize(4); arr.setPoint(0, QPoint(-hPS + xScreen, hPS + yScreen)); arr.setPoint(1, QPoint( hPS + xScreen, hPS + yScreen)); arr.setPoint(2, QPoint( 0 + xScreen, -hPS + yScreen)); arr.setPoint(3, QPoint(-hPS + xScreen, hPS + yScreen)); break; case X: default: arr.resize(9); arr.setPoint(0, QPoint(-hPS + xScreen, -hPS + yScreen)); arr.setPoint(1, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(2, QPoint(-hPS + xScreen, hPS + yScreen)); arr.setPoint(3, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(4, QPoint( hPS + xScreen, hPS + yScreen)); arr.setPoint(5, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(6, QPoint( hPS + xScreen, -hPS + yScreen)); arr.setPoint(7, QPoint( 0 + xScreen, 0 + yScreen)); arr.setPoint(8, QPoint(-hPS + xScreen, -hPS + yScreen)); break; } p.drawPolygon(arr); }
Q3PointArray PointSetStyles::areaPoints(int xScreen, int yScreen, PointSetStyle pointSetStyle) const { Q3PointArray arr; int fudgeFactor = 1; // add an extra pixel around the perimeter to allow for roundoff error // half point size int hPS = pointSizeToHalfwidth(pointSetStyle.pointSize) + pointSetStyle.pointLineSize + fudgeFactor; switch (pointSetStyle.pointShape) { case Cross: case Diamond: arr.resize(5); arr.setPoint(0, QPoint(-hPS + xScreen, 0 + yScreen)); arr.setPoint(1, QPoint( 0 + xScreen, -hPS + yScreen)); arr.setPoint(2, QPoint( hPS + xScreen, 0 + yScreen)); arr.setPoint(3, QPoint( 0 + xScreen, hPS + yScreen)); arr.setPoint(4, QPoint(-hPS + xScreen, 0 + yScreen)); break; case Square: case X: default: arr.resize(5); arr.setPoint(0, QPoint(-hPS + xScreen, -hPS + yScreen)); arr.setPoint(1, QPoint( hPS + xScreen, -hPS + yScreen)); arr.setPoint(2, QPoint( hPS + xScreen, hPS + yScreen)); arr.setPoint(3, QPoint(-hPS + xScreen, hPS + yScreen)); arr.setPoint(4, QPoint(-hPS + xScreen, -hPS + yScreen)); break; case Triangle: arr.resize(4); arr.setPoint(0, QPoint(-hPS + xScreen, hPS + yScreen)); arr.setPoint(1, QPoint( hPS + xScreen, hPS + yScreen)); arr.setPoint(2, QPoint( 0 + xScreen, -hPS + yScreen)); arr.setPoint(3, QPoint(-hPS + xScreen, hPS + yScreen)); break; } return arr; }