예제 #1
0
void EBackGroundFore::initElement()
{
    this->clearAllPolygon();
    QPolygon polygon;

//    switch(GameInfo::gameStatus)
//    {
//    case MainMenu:
//    case ModeSelect:
//    case GamePlay:
//    case GameOver:
        polygon.putPoints(0, 3,  0,0,   -884,0,     -442,-765);
        this->addPolygon(polygon);
        polygon.clear();
        polygon.putPoints(0, 3,  0,0,   442,-765,   884,0);
        this->addPolygon(polygon);
        polygon.clear();
        polygon.putPoints(0, 3,  0,0,   442,765,     -442,765);
        this->addPolygon(polygon);
        polygon.clear();
//        break;
//    }

    this->pen.setWidth(1);
    this->brush.setStyle(Qt::SolidPattern);
}
예제 #2
0
void Dialog::paintEvent(QPaintEvent *event)
{
    bool animation = true;
    if (animation) {
        QPainter painter(this);
        m_ball.render(painter, m_counter);
        m_counter++;
    }
    else {
        QPainter painter(this);
        QPen pen;
        pen.setWidth(3);
        pen.setColor(Qt::black);
        QBrush brush(Qt::yellow);

        painter.setPen (pen);
        painter.setBrush(brush);
        painter.drawEllipse(30, 30, 100, 100);

        brush.setColor("#C36241");
        painter.setBrush(brush);
        pen.setWidth(1);

        QPolygon roof;
        roof.putPoints(0, 3, 250, 260, 290, 220, 330, 260);
        painter.drawPolygon(roof);

        brush.setColor("#835C3B");
        painter.setBrush(brush);

        QPolygon house;
        house.putPoints(0, 4, 260, 260, 260, 299, 320, 299, 320, 260);
        painter.drawPolygon(house);
    }
}
예제 #3
0
void ECentralHexagon::initElement()
{
    /// init polygon ///
    this->clearAllPolygon();
    QPolygon polygon;

    polygon.putPoints(0, 6,  30,-50,  59,0,  30,50,  -30,50, -59,0, -30,-50);
    this->addPolygon(polygon);

    /// ///
    this->isAnimeFinished = false;
    if(GameInfo::gameStatus == GameOver)
    {
        this->isGameOver = true;
        this->zoomPolygon(4);
    }
    else
    {
        this->isGameOver = false;
    }

    this->pen.setWidth(6);
    this->pen.setJoinStyle(Qt::MiterJoin);
    this->brush.setStyle(Qt::SolidPattern);
}
예제 #4
0
/**
 * Draw a solid (triangular) arrowhead pointing in the given direction.
 * The direction can be either Qt::LeftArrow or Qt::RightArrow.
 */
void MessageWidget::paintSolidArrowhead(QPainter *p, int x, int y, Qt::ArrowType direction)
{
    int arrowheadExtentX = 4;
    if (direction == Qt::RightArrow) {
        arrowheadExtentX = -arrowheadExtentX;
    }
    QPolygon points;
    points.putPoints(0, 3, x, y, x + arrowheadExtentX, y - 3, x + arrowheadExtentX, y + 3);
    p->setBrush(QBrush(p->pen().color()));
    p->drawPolygon(points);
}
예제 #5
0
void Square::draw(QPainter *p, int y, int x)
{
    x*=SIDE_LENGTH;
    y*=SIDE_LENGTH;

    QPolygon polygon;
    int ar[8] = {x,y, x+SIDE_LENGTH, y, x+SIDE_LENGTH, y+SIDE_LENGTH, x, y+SIDE_LENGTH};

    polygon.putPoints(0, 4, ar);

    p->drawPolygon(polygon);
}
예제 #6
0
void
dmz::QtCanvasLink::set_arrow_state (const Boolean State) {

   if (State) {

      if (!_arrow1) { _arrow1 = new QGraphicsPolygonItem (this); }
      if (!_arrow2) { _arrow2 = new QGraphicsPolygonItem (this); }

      QPolygon poly (4);

      poly.putPoints (0, 4,
         0, -9 * _arrowSizeMultiplier,
         9 * _arrowSizeMultiplier, 5 * _arrowSizeMultiplier,
         0, 0,
         -9 * _arrowSizeMultiplier, 5 * _arrowSizeMultiplier);

      if (_arrow1) {

         _arrow1->setPolygon (poly);
         _arrow1->setZValue (zValue () - 1.0f);
         _arrow1->setBrush (QBrush (Qt::SolidPattern));
      }

      if (_arrow2) {

         _arrow2->setPolygon (poly);
         _arrow2->setZValue (zValue () - 1.0f);
         _arrow2->setBrush (QBrush (Qt::SolidPattern));
      }

      setColorAll (pen ());
      _set_arrow_transform ();
   }
   else {

      if (_arrow1) { delete _arrow1; _arrow1 = 0; }
      if (_arrow2) { delete _arrow2; _arrow2 = 0; }
   }
}
예제 #7
0
int
MarkerSell::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
  Marker *sell = (Marker *) m;
  Entity *e = sell->settings();
  
  PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) sell->plot()->axisScaleDraw(QwtPlot::xBottom);

  QVariant *date = e->get(QString("date"));
  if (! date)
  {
    qDebug() << "MarkerSell::draw: date missing";
    return 0;
  }
  
  int x = xMap.transform(dsd->dateToX(date->toDateTime()));
  if (x == -1)
    return 1;

  QVariant *price = e->get(QString("price"));
  if (! price)
  {
    qDebug() << "MarkerSell::draw: price missing";
    return 0;
  }
  
  int y = yMap.transform(price->toDouble());

  QVariant *tset = e->get(QString("color"));
  if (! tset)
  {
    qDebug() << "MarkerSell::draw: color missing";
    return 0;
  }
  QColor color(tset->toString());
  
  p->setBrush(color);

  QPolygon arrow;
  arrow.putPoints(0, 7, x, y,
                  x + 5, y - 5,
                  x + 2, y - 5,
                  x + 2, y - 11,
                  x - 2, y - 11,
                  x - 2, y - 5,
                  x - 5, y - 5);

  p->drawPolygon(arrow, Qt::OddEvenFill);

  sell->clearSelectionArea();

  sell->appendSelectionArea(QRegion(arrow));
  
  int handleWidth = sell->handleWidth();

  if (sell->selected())
  {
    sell->clearGrabHandles();

    sell->appendGrabHandle(QRegion(x - (handleWidth / 2),
                           y - handleWidth,
                           handleWidth,
                           handleWidth,
                           QRegion::Rectangle));

    p->fillRect(x - (handleWidth / 2),
                y + (handleWidth / 2),
                handleWidth,
                handleWidth,
                color);
  }
  
  return 1;
}
예제 #8
0
void SourceItemDelegate::paintArrows(QPainter *p,
				     const QStyleOptionViewItem &option,
				     const QModelIndex &index) const
{
    QTreeWidget *lv = _parent;
    if ( !lv ) return;
    SourceView* sv = (SourceView*) lv;
    SourceItem* item = static_cast<SourceItem*>(index.internalPointer());
    const QRect& rect = option.rect;
    int height = rect.height();

    p->save();
    drawBackground(p, option, index);
    p->translate(rect.topLeft());

    int marg = 1;
    int yy = height/2, y1, y2;
    QColor c;

    int start = -1, end = -1;

    TraceLineJump* lineJump = item->lineJump();
    uint lineno = item->lineno();
    TraceLineCall* lineCall = item->lineCall();

    // draw line borders, detect start/stop of a line
    for(int i=0; i< item->jumpCount(); i++) {
        TraceLineJump* jump = item->jump(i);
        if (jump == 0) continue;

        y1 = 0;
        y2 = height;
        if (lineJump &&
            (lineJump->lineTo() == jump->lineTo()) &&
            (jump->lineFrom()->lineno() == lineno)) {

            if (start<0) start = i;
            if (lineJump == jump) {
                if (jump->lineTo()->lineno() <= lineno)
                    y2 = yy;
                else
                    y1 = yy;
            }
        }
        else if (!lineJump && !lineCall &&
                 (jump->lineTo()->lineno() == lineno)) {
            if (end<0) end = i;
            if (jump->lineFrom()->lineno() < lineno)
                y2 = yy;
            else
                y1 = yy;
        }

        c = jump->isCondJump() ? Qt::red : Qt::blue;
        p->fillRect( marg + 6*i, y1, 4, y2, c);
        p->setPen(c.light());
        p->drawLine( marg + 6*i, y1, marg + 6*i, y2);
        p->setPen(c.dark());
        p->drawLine( marg + 6*i +3, y1, marg + 6*i +3, y2);
    }

    // draw start/stop horizontal line
    int x, y = yy-2, w, h = 4;
    if (start >= 0) {
        c = item->jump(start)->isCondJump() ? Qt::red : Qt::blue;
        x = marg + 6*start;
        w = 6*(sv->arrowLevels() - start) + 10;
        p->fillRect( x, y, w, h, c);
        p->setPen(c.light());
        p->drawLine(x, y, x+w-1, y);
        p->drawLine(x, y, x, y+h-1);
        p->setPen(c.dark());
        p->drawLine(x+w-1, y, x+w-1, y+h-1);
        p->drawLine(x+1, y+h-1, x+w-1, y+h-1);
    }
    if (end >= 0) {
        c = item->jump(end)->isCondJump() ? Qt::red : Qt::blue;
        x = marg + 6*end;
        w = 6*(sv->arrowLevels() - end) + 10;

        QPolygon a;
        a.putPoints(0, 8, x,y+h,
                    x,y, x+w-8,y, x+w-8,y-2,
                    x+w,yy,
                    x+w-8,y+h+2, x+w-8,y+h,
                    x,y+h);
        p->setBrush(c);
        p->drawConvexPolygon(a);

        p->setPen(c.light());
        p->drawPolyline(a.constData(), 5);
        p->setPen(c.dark());
        p->drawPolyline(a.constData() + 4, 2);
        p->setPen(c.light());
        p->drawPolyline(a.constData() + 5, 2);
        p->setPen(c.dark());
        p->drawPolyline(a.constData() + 6, 2);
    }

    // draw inner vertical line for start/stop
    // this overwrites borders of horizontal line
    for(int i=0;i< item->jumpCount();i++) {
        TraceLineJump* jump = item->jump(i);
        if (jump == 0) continue;

        c = jump->isCondJump() ? Qt::red : Qt::blue;

        if (jump->lineFrom()->lineno() == lineno) {
            bool drawUp = true;
            if (jump->lineTo()->lineno() == lineno)
                if (start<0) drawUp = false;
            if (jump->lineTo()->lineno() > lineno) drawUp = false;
            if (drawUp)
                p->fillRect( marg + 6*i +1, 0, 2, yy, c);
            else
                p->fillRect( marg + 6*i +1, yy, 2, height-yy, c);
        }
        else if (jump->lineTo()->lineno() == lineno) {
            if (end<0) end = i;
            if (jump->lineFrom()->lineno() < lineno)
                p->fillRect( marg + 6*i +1, 0, 2, yy, c);
            else
                p->fillRect( marg + 6*i +1, yy, 2, height-yy, c);
        }
    }
    p->restore();
}
예제 #9
0
// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow(QPainter *p, Qt::ArrowType type, bool down,
                             int x, int y, int w, int h,
                             const QPalette &pal, bool)
{
    QPolygon bFill;                                // fill polygon
    QPolygon bTop;                                // top shadow.
    QPolygon bBot;                                // bottom shadow.
    QPolygon bLeft;                                // left shadow.
    QTransform matrix;                            // xform matrix
    bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
    bool horizontal = !vertical;
    int         dim = w < h ? w : h;
    int         colspec = 0x0000;                        // color specification array

    if (dim < 2)                                // too small arrow
        return;

    if (dim > 3) {
        if (dim > 6)
            bFill.resize(dim & 1 ? 3 : 4);
        bTop.resize((dim/2)*2);
        bBot.resize(dim & 1 ? dim + 1 : dim);
        bLeft.resize(dim > 4 ? 4 : 2);
        bLeft.putPoints(0, 2, 0,0, 0,dim-1);
        if (dim > 4)
            bLeft.putPoints(2, 2, 1,2, 1,dim-3);
        bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
        bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);

        for(int i=0; i<dim/2-2 ; i++) {
            bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
            bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
        }
        if (dim & 1)                                // odd number size: extra line
            bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
        if (dim > 6) {                        // dim>6: must fill interior
            bFill.putPoints(0, 2, 1,dim-3, 1,2);
            if (dim & 1)                        // if size is an odd number
                bFill.setPoint(2, dim - 3, dim / 2);
            else
                bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
        }
    }
    else {
        if (dim == 3) {                        // 3x3 arrow pattern
            bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
            bTop .setPoints(2, 1,0, 1,0);
            bBot .setPoints(2, 1,2, 2,1);
        }
        else {                                        // 2x2 arrow pattern
            bLeft.setPoints(2, 0,0, 0,1);
            bTop .setPoints(2, 1,0, 1,0);
            bBot .setPoints(2, 1,1, 1,1);
        }
    }

    if (type == Qt::UpArrow || type == Qt::LeftArrow) {
        matrix.translate(x, y);
        if (vertical) {
            matrix.translate(0, h - 1);
            matrix.rotate(-90);
        } else {
            matrix.translate(w - 1, h - 1);
            matrix.rotate(180);
        }
        if (down)
            colspec = horizontal ? 0x2334 : 0x2343;
        else
            colspec = horizontal ? 0x1443 : 0x1434;
    }
    else if (type == Qt::DownArrow || type == Qt::RightArrow) {
        matrix.translate(x, y);
        if (vertical) {
            matrix.translate(w-1, 0);
            matrix.rotate(90);
        }
        if (down)
            colspec = horizontal ? 0x2443 : 0x2434;
        else
            colspec = horizontal ? 0x1334 : 0x1343;
    }

    const QColor *cols[5];
    cols[0] = 0;
    cols[1] = &pal.button().color();
    cols[2] = &pal.mid().color();
    cols[3] = &pal.light().color();
    cols[4] = &pal.dark().color();
#define CMID        *cols[(colspec>>12) & 0xf]
#define CLEFT        *cols[(colspec>>8) & 0xf]
#define CTOP        *cols[(colspec>>4) & 0xf]
#define CBOT        *cols[colspec & 0xf]

    QPen     savePen   = p->pen();                // save current pen
    QBrush   saveBrush = p->brush();                // save current brush
    QTransform wxm = p->transform();
    QPen     pen(Qt::NoPen);
    const QBrush &brush = pal.brush(QPalette::Button);

    p->setPen(pen);
    p->setBrush(brush);
    p->setTransform(matrix, true);                // set transformation matrix
    p->drawPolygon(bFill);                        // fill arrow
    p->setBrush(Qt::NoBrush);                        // don't fill

    p->setPen(CLEFT);
    p->drawLines(bLeft);
    p->setPen(CTOP);
    p->drawLines(bTop);
    p->setPen(CBOT);
    p->drawLines(bBot);

    p->setTransform(wxm);
    p->setBrush(saveBrush);                        // restore brush
    p->setPen(savePen);                        // restore pen

#undef CMID
#undef CLEFT
#undef CTOP
#undef CBOT
}
예제 #10
0
void MainWindowImpl::readPolygon(QXmlStreamReader * xmlReader)
{
	
	myitem *local_item = new myitem();
	float position_x = 0,position_y = 0;
	int w = 1,h = 1, fiducial = 1,count = 0;
	QPolygon *mypolygon = new QPolygon;
	
	
    tangibleId++ ;
    local_item->OSCdata->ID = tangibleId ;
    local_item->OSCdata->tagID = tangibleId ;

	
	while (!xmlReader->atEnd())
	{
		xmlReader->readNext();
		if (xmlReader->isStartElement()) 
		{
			if (xmlReader->name() ==  "EndItem" ) 
			{
				local_item->setPolygon(*mypolygon);
				scene->addItem(local_item);
				if ( Verbose ) std::cout << "Position is " << position_x << position_y << "\n" ;
				local_item->moveBy(position_x,position_y);
				//std::cout << "Moving ploygon " << position_x <<"\t"<< position_y << "\n";
    			local_item->animation->setItem(local_item);
    			local_item->animation->setTimeLine(timer);
    			update();
    			//QMessageBox::information(this,"QMTSim","Added Polygon");
				return ;
			}
			
			
			
			else if (xmlReader->name() ==  "Position" )
			{
				QString str_x,str_y;
				float test ;
				position_x = (xmlReader->attributes().value("Position_x")).toString().toFloat();
				position_y = (xmlReader->attributes().value("Position_y")).toString().toFloat();
				str_x = (xmlReader->attributes().value("Position_x")).toString() ;
				test = str_x.toFloat();
				if ( Verbose ) qDebug() << "Position in string  " << str_x  <<  "In float  "<<test << "\n" ;
				//std::cout << "Moving cursor " << position_x <<"\t"<< position_y << "\n";
				//QMessageBox::information(this,"QMTSim","Setting Position");
			}
				
			else if (xmlReader->name() == "Vertex" )
			{
				
				
				w = (xmlReader->attributes().value("Vertex_x")).toString().toInt();
				h = (xmlReader->attributes().value("Vertex_y")).toString().toInt();
				//QMessageBox::information(this,"QMTSim","Setting Vertices");
				mypolygon->putPoints(count,1,w,h);
				local_item->vertex_x.insert(count,w);
				local_item->vertex_y.insert(count,h);
				count = count + 1;
				
			}
			
			else if (xmlReader->name() == "Fiducial" )
			{
				fiducial = (xmlReader->attributes().value("Value")).toString().toInt();
				local_item->fiducial.append(fiducial);
				//QMessageBox::information(this,"QMTSim","Setting Fiducial");
			}
			
			else if (xmlReader->name() == "Colour")
			{
				int r,g,b,a;
				r = (xmlReader->attributes().value("R")).toString().toInt();
				g = (xmlReader->attributes().value("G")).toString().toInt();
				b = (xmlReader->attributes().value("B")).toString().toInt();
				a = (xmlReader->attributes().value("A")).toString().toInt();
				
				local_item->colour.setRgb(r,g,b,a);
				QBrush *local_brush = new QBrush;
				local_brush->setColor(local_item->colour);
				local_brush->setStyle(Qt::Dense2Pattern);
				local_item->setBrush(*local_brush);
			}
			
			else if (xmlReader->name() == "Path" )
			{
				int i = 0 ;
				bool pathx = false ,pathy = false ;
				double x = 0 ,y = 0 ;
				while(xmlReader->name() != "EndPath" )
				{
					xmlReader->readNext();
					if (xmlReader->isStartElement())
					{
						if (xmlReader->name() == "Path_x" )
						{
							x = (xmlReader->attributes().value("X")).toString().toDouble();
							pathx = true ;
						}
						
						if (xmlReader->name() == "Path_y" )
						{
							y = (xmlReader->attributes().value("Y")).toString().toDouble();
							pathy = true ;
						}
						
						if (pathx && pathy)
						{
							pathx = false;
							pathy = false;
							local_item->animation->setPosAt(i / 500.0, QPointF(x,y));
         					local_item->path_x.replace(i,x);
         					local_item->path_y.replace(i,y);
							i++;
						}
						
					}
				}
			}
				
			
			
			
			
			
			
		}
		
		
		
	}
}
예제 #11
0
int
MarkerRetracement::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
  Marker *ret = (Marker *) m;
  Entity *e = ret->settings();
  
  QVariant *date = e->get(QString("date"));
  if (! date)
    return 0;
  
  QVariant *date2 = e->get(QString("date2"));
  if (! date2)
    return 0;

  QVariant *high = e->get(QString("high"));
  if (! high)
    return 0;

  QVariant *low = e->get(QString("low"));
  if (! low)
    return 0;

  QVariant *tset = e->get(QString("color"));
  if (! tset)
    return 0;
  QColor color(tset->toString());

  QVariant *extend = e->get(QString("extend"));
  if (! extend)
    return 0;

  QVariant *l1 = e->get(QString("level1"));
  if (! l1)
    return 0;

  QVariant *l2 = e->get(QString("level2"));
  if (! l2)
    return 0;

  QVariant *l3 = e->get(QString("level3"));
  if (! l3)
    return 0;

  QVariant *l4 = e->get(QString("level4"));
  if (! l4)
    return 0;

  QVariant *l5 = e->get(QString("level5"));
  if (! l5)
    return 0;

  QVariant *l6 = e->get(QString("level6"));
  if (! l6)
    return 0;
  
  PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) ret->plot()->axisScaleDraw(QwtPlot::xBottom);
  int x = xMap.transform(dsd->dateToX(date->toDateTime()));

  QDateTime dt = date2->toDateTime();
  if (extend->toBool())
  {
    int s, e;
    g_symbol->startEndRange(s, e);
    Bar *bar = g_symbol->bar(e);
    if (! bar)
      return 0;
    
    dt = bar->date();
  }

  int x2 = xMap.transform(dsd->dateToX(dt));

  p->setPen(color);

  ret->clearSelectionArea();

  QList<double> lineList;
  lineList.append(l1->toDouble());
  lineList.append(l2->toDouble());
  lineList.append(l3->toDouble());
  lineList.append(l4->toDouble());
  lineList.append(l5->toDouble());
  lineList.append(l6->toDouble());

  for (int loop = 0; loop < lineList.size(); loop++)
  {
    double td = lineList.at(loop);
    if (td != 0)
    {
      double range = high->toDouble() - low->toDouble();
      double r = 0;
      if (td < 0)
        r = low->toDouble() + (range * td);
      else
      {
        if (td > 0)
          r = low->toDouble() + (range * td);
        else
        {
          if (td < 0)
            r = high->toDouble();
          else
            r = low->toDouble();
        }
      }

      int y = yMap.transform(r);
      p->drawLine (x, y, x2, y);
      p->drawText(x, y - 1, QString::number(td * 100) + "% - " + QString::number(r));

      QPolygon array;
      array.putPoints(0, 4, x, y - 4, x, y + 4, x2, y + 4, x2, y - 4);
      ret->appendSelectionArea(QRegion(array));
    }
  }

  // draw the low line
  int y = yMap.transform(low->toDouble());
  p->drawLine (x, y, x2, y);
  
  Strip strip;
  QString ts;
  strip.strip(low->toDouble(), 4, ts);
  p->drawText(x, y - 1, "0% - " + ts);

  // store the selectable area the low line occupies
  QPolygon array;
  array.putPoints(0, 4, x, y - 4, x, y + 4, x2, y + 4, x2, y - 4);
  ret->appendSelectionArea(QRegion(array));

  // draw the high line
  int y2 = yMap.transform(high->toDouble());
  p->drawLine (x, y2, x2, y2);
  
  strip.strip(high->toDouble(), 4, ts);
  p->drawText(x, y2 - 1, "100% - " + ts);

  // store the selectable area the high line occupies
  array.clear();
  array.putPoints(0, 4, x, y2 - 4, x, y2 + 4, x2, y2 + 4, x2, y2 - 4);
  ret->appendSelectionArea(QRegion(array));

  if (ret->selected())
  {
    int handleWidth = ret->handleWidth();
    
    ret->clearGrabHandles();

    //top left corner
    ret->appendGrabHandle(QRegion(x, y2 - (handleWidth / 2),
                          handleWidth,
                          handleWidth,
                          QRegion::Rectangle));

    p->fillRect(x,
                y2 - (handleWidth / 2),
                handleWidth,
                handleWidth,
                color);

    //bottom right corner
    ret->appendGrabHandle(QRegion(x2, y - (handleWidth / 2),
                          handleWidth,
                          handleWidth,
                          QRegion::Rectangle));

    p->fillRect(x2,
                y - (handleWidth / 2),
                handleWidth,
                handleWidth,
                color);
  }
  
  return 1;
}
예제 #12
0
int
MarkerTLine::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
  Marker *tline = (Marker *) m;
  
  Entity *e = tline->settings();
  
  QVariant *date = e->get(QString("date"));
  if (! date)
    return 0;
  
  QVariant *date2 = e->get(QString("date2"));
  if (! date2)
    return 0;

  QVariant *price = e->get(QString("price"));
  if (! price)
    return 0;

  QVariant *price2 = e->get(QString("price2"));
  if (! price2)
    return 0;

  QVariant *tset = e->get(QString("color"));
  if (! tset)
    return 0;
  QColor color(tset->toString());

  QVariant *extend = e->get(QString("extend"));
  if (! extend)
    return 0;

  PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) tline->plot()->axisScaleDraw(QwtPlot::xBottom);
  int x = xMap.transform(dsd->dateToX(date->toDateTime()));
  int x2 = xMap.transform(dsd->dateToX(date2->toDateTime()));
  int y = yMap.transform(price->toDouble());
  int y2 = yMap.transform(price2->toDouble());

  p->setPen(color);

  p->drawLine (x, y, x2, y2);

  // save old values;
  int tx2 = x2;
  int ty2 = y2;
  int tx = x;
  int ty = y;

  if (extend->toBool())
  {
    int ydiff = y - y2;
    int xdiff = x2 - x;
    if (xdiff > 0)
    {
      while (x2 < p->window().width())
      {
        x = x2;
        y = y2;
        x2 = x2 + xdiff;
        y2 = y2 - ydiff;
        p->drawLine (x, y, x2, y2);
      }
    }
  }

  // store the selectable area the line occupies
  tline->clearSelectionArea();

  QPolygon array;
  array.putPoints(0, 4, tx, ty - 4, tx, ty + 4, x2, y2 + 4, x2, y2 - 4);
  tline->appendSelectionArea(QRegion(array));

  if (tline->selected())
  {
    int handleWidth = tline->handleWidth();
    
    tline->clearGrabHandles();

    tline->appendGrabHandle(QRegion(tx,
                            ty - (handleWidth / 2),
                            handleWidth,
                            handleWidth,
                            QRegion::Rectangle));

    p->fillRect(tx,
                ty - (handleWidth / 2),
                handleWidth,
                handleWidth,
                color);

    tline->appendGrabHandle(QRegion(tx2,
                            ty2 - (handleWidth / 2),
                            handleWidth,
                            handleWidth,
                            QRegion::Rectangle));

    p->fillRect(tx2,
                ty2 - (handleWidth / 2),
                handleWidth,
                handleWidth,
                color);
  }
  
  return 1;
}