void TSensorView::ColumnViewer(TDC& dc,PSHORTREAL pData)
{
  m_xSize = m_nDimSize[0];
  m_ySize = m_nDimSize[1];
  m_yAdd = (int) (500L * m_ySize / m_xSize / 2);
  dc.SetWindowExt(TSize(m_xSize * 2 +  m_ySize,500 + m_yAdd));
  Grid3D(dc);
  TBrush brGray(SYSCOLOR(COLOR_BTNFACE)),
			brWhite(SYSCOLOR(COLOR_BTNHIGHLIGHT)),
			brDark(SYSCOLOR(COLOR_BTNSHADOW));
  for (int y = 0; y < m_nDimSize[1]; y++)
    for (int x = 0; x < m_nDimSize[0]; x++)
    {
      SHORTREAL r = pData[x + (LONGINT) m_nDimSize[0] * y];
      TPoint pt[4] =
      {
        Project2D(x,y+1,r),
        Project2D(x+1,y+1,r),
        Project2D(x+1,y,r),
        Project2D(x,y,r)
      };
      dc.SelectObject(brWhite);
      POLY(dc,pt,4);
      SHORTREAL r2 = y == m_nDimSize[1]-1
                     ? 0
                     : pData[x + (LONGINT) m_nDimSize[0] * (y+1)];
      if(r2 < r)
      {
        pt[2] = Project2D(x+1,y+1,r2);
        pt[3] = Project2D(x,y+1,r2);
        dc.SelectObject(brGray);
        POLY(dc,pt,4);
      }
      r2 = x == m_nDimSize[0]-1 ? 0
                  : pData[x+1 + (LONGINT) m_nDimSize[0] * y];
      if (r2 < r)
      {
        pt[0] = Project2D(x+1,y,r);
        pt[2] = Project2D(x+1,y+1,r2);
        pt[3] = Project2D(x+1,y,r2);
        dc.SelectObject(brDark);
        POLY(dc,pt,4);
      }
    }
  dc.RestoreBrush();
}
Ejemplo n.º 2
0
void Slider::drawSlider(QPainter *p, const QRect &r)
{
	const QPalette& pal = palette();
	QBrush brBack(pal.window());
	QBrush brMid;
	QBrush brDark(pal.dark());

	QRect cr;

	int ipos, dist1;
	double rpos;
	int lineDist;

	if (d_bwTrough > 0)
	{
		//      qDrawShadePanel(p, r.x(), r.y(),
		//r.width(), r.height(),
		//pal, TRUE, d_bwTrough,0);
		cr.setRect(r.x() + d_bwTrough,
				r.y() + d_bwTrough,
				r.width() - 2 * d_bwTrough,
				r.height() - 2 * d_bwTrough);
		brMid = pal.mid();
	}
	else
	{
		cr = r;
		brMid = brBack;
	}

	rpos = (value() - minValue()) / (maxValue() - minValue());

	lineDist = d_borderWidth - 1;
	if (lineDist < 1) lineDist = 1;

	if (d_orient == Qt::Horizontal)
	{

		dist1 = int(double(cr.width() - d_thumbLength) * rpos);
		ipos = cr.x() + dist1;
		markerPos = ipos + d_thumbHalf;

		//
		// draw background
		//
		if (d_bgStyle & BgSlot)
		{
			drawHsBgSlot(p, cr, QRect(ipos, cr.y(), d_thumbLength, cr.height()), brMid);
		}
		else
		{
			//p->fillRect(cr.x(), cr.y(), dist1, cr.height(), brMid);
			//p->fillRect(ipos + d_thumbLength, cr.y(),
			//		cr.width() - d_thumbLength - dist1, cr.height(), brMid);
		}

		//
		//  Draw thumb
		//
		//qDrawShadePanel(p,ipos, cr.y(), d_thumbLength, cr.height(),
		//    pal, FALSE, d_borderWidth, &brBack);
		QPixmap thumbp;
		bool loaded = thumbp.load(":images/slider_thumb_new_h.png");
		if (loaded)
		{
			p->setCompositionMode(QPainter::CompositionMode_SourceAtop); //QPainter::CompositionMode_SourceOver);
			p->setClipping(false);
			p->drawPixmap(ipos, cr.y()-2, thumbp);
		}

		/*if (lineDist > 1)
			qDrawShadeLine(p, markerPos, cr.y() + lineDist, markerPos,
				cr.y() + cr.height() - lineDist,
				pal, TRUE, 1);
		else
		{
			p->setPen(pal.dark().color());
			p->drawLine(markerPos - 1, cr.y() + lineDist, markerPos - 1,
					cr.y() + cr.height() - lineDist - 1);
			p->setPen(pal.light().color());
			p->drawLine(markerPos, cr.y() + lineDist, markerPos,
					cr.y() + cr.height() - lineDist - 1);
		}*/


	}
	else
	{//Vertical slider
		dist1 = int(double(cr.height() - d_thumbLength) * (1.0 - rpos));
		ipos = cr.y() + dist1;
		markerPos = ipos + d_thumbHalf;

		//NOTE: this is adding the middle line in the slider
		if (d_bgStyle & BgSlot)
		{
			drawVsBgSlot(p, cr, QRect(cr.left(), ipos, cr.width(), d_thumbLength), brMid);
		}
		else
		{
			//p->fillRect(cr.x(),cr.y(),cr.width(),ipos,brMid);
			//p->fillRect(cr.x(), ipos + d_thumbLength, cr.width(),
			//cr.height() - d_thumbLength - dist1, brMid);
		}

		//This adds the thumb slider
		//qDrawShadePanel(p,cr.x(),ipos , cr.width(), d_thumbLength,
		//    pal,FALSE,d_borderWidth, &brBack);
		QPixmap thumbp;
		bool loaded = thumbp.load(":images/slider_thumb_new.png");
		int knobx = cr.x() + 2;
		int knoby = ipos - 12;
		QRect knobRect(knobx, knoby, 18, 33);
		//printf("Slider: Knob position X: %d  Y: %d\n", knobx, knoby);
		if (loaded)
		{
			p->setCompositionMode(QPainter::CompositionMode_SourceAtop); //QPainter::CompositionMode_SourceOver);
			//p->drawPixmap(knobx, knoby, thumbp);
			p->setClipping(false);
			p->drawPixmap(knobRect, thumbp);
		}
		// if (lineDist > 1)
		//    qDrawShadeLine(p, cr.x() + lineDist , markerPos,
		//       cr.x() + cr.width() - lineDist, markerPos,
		//       pal, TRUE, 1);
		// else
		// {
		//
		//   p->setPen(pal.dark().color());
		//   p->drawLine(cr.x() + lineDist, markerPos - 1 ,
		//         cr.x() + cr.width() -  lineDist - 1, markerPos - 1);
		//   p->setPen(pal.light().color());
		//   p->drawLine(cr.x() + lineDist, markerPos,
		//         cr.x() + cr.width() -  lineDist - 1 , markerPos);
		// }
	}

}
Ejemplo n.º 3
0
void ThinSlider::drawSlider(QPainter *p, const QRect &r)
{
    p->setRenderHint(QPainter::Antialiasing);

    const QPalette& pal = palette();
    QBrush brBack(pal.window());
    QBrush brMid(pal.mid());
    QBrush brDark(pal.dark());

    QRect cr;
    
    int ipos,dist1;
    double rpos;

    int xrad = 4;
    int yrad = 4;

    // for the empty side
    QColor e_mask_edge = pal.mid().color();
    QColor e_mask_center = pal.midlight().color();
    int e_alpha = 215;
    e_mask_edge.setAlpha(e_alpha);
    e_mask_center.setAlpha(e_alpha);
    
    QLinearGradient e_mask;
    e_mask.setColorAt(0, e_mask_edge);
    e_mask.setColorAt(0.5, e_mask_center);
    e_mask.setColorAt(1, e_mask_edge);
    
    // for the full side
    rpos = (value()  - minValue()) / (maxValue() - minValue());
    
    int f_brightness = 155 * rpos + 100;
    int f_alpha;
    int f_edge;
    if (pal.currentColorGroup() == QPalette::Disabled)
        {
        f_alpha = 185;
        f_edge = 100;
        }
    else
        {
        f_alpha = 127;
        f_edge = 0;
        }
	   
    QColor f_mask_center = QColor(f_brightness, f_brightness, f_brightness, f_alpha);
    QColor f_mask_edge = QColor(f_edge, f_edge, f_edge, f_alpha);
    QLinearGradient f_mask;
	   
    f_mask.setColorAt(0, f_mask_edge);
    f_mask.setColorAt(0.5, f_mask_center);
    f_mask.setColorAt(1, f_mask_edge);
    
    // for the thumb
    QLinearGradient thumbGrad;
    QColor thumb_edge = pal.dark().color();
    QColor thumb_center = pal.midlight().color();
    
    thumbGrad.setColorAt(0, thumb_edge);
    thumbGrad.setColorAt(0.5, thumb_center);
    thumbGrad.setColorAt(1, thumb_edge);
    
    
    if (d_orient == Qt::Horizontal)
        {

        cr.setRect(r.x(),
                   r.y() + d_mMargin,
                   r.width(),
                   r.height() - 2*d_mMargin);


        //
        // Draw background
        //
        QPainterPath bg_rect = MusECore::roundedPath(cr, 
                                           xrad, yrad, 
                                           (MusECore::Corner) (MusECore::UpperLeft | MusECore::UpperRight | MusECore::LowerLeft | MusECore::LowerRight) );
	   
        p->fillPath(bg_rect, d_fillColor);
	   
        dist1 = int(double(cr.width() - d_thumbLength) * rpos);
        ipos =  cr.x() + dist1;
        markerPos = ipos + d_thumbHalf;
	   

        //
        // Draw empty right side
        // 
	   
        e_mask.setStart(QPointF(0, cr.y()));
        e_mask.setFinalStop(QPointF(0, cr.y() + cr.height()));

        QPainterPath e_rect = MusECore::roundedPath(ipos + d_thumbLength, cr.y(), 
                                          cr.width() - d_thumbLength - dist1, cr.height(), 
                                          xrad, yrad, (MusECore::Corner) (MusECore::UpperRight | MusECore::LowerRight) );
   
        p->fillPath(e_rect, QBrush(e_mask));
   
   
        //
        // Draw full left side
        //
           
        f_mask.setStart(QPointF(0, cr.y()));
        f_mask.setFinalStop(QPointF(0, cr.y() + cr.height()));
          
        QPainterPath f_rect = MusECore::roundedPath(cr.x(), cr.y(), 
                                          ipos + 1, cr.height(),
                                          xrad, yrad, 
                                          (MusECore::Corner) (MusECore::LowerLeft | MusECore::UpperLeft) );

        p->fillPath(f_rect, QBrush(f_mask));
          
           
        //
        //  Draw thumb
        //
	   
        QPainterPath thumb_rect = MusECore::roundedPath(ipos, r.y(), 
                                              d_thumbLength, r.height(), 
                                              2, 2, 
                                              (MusECore::Corner) (MusECore::UpperLeft | MusECore::UpperRight | MusECore::LowerLeft | MusECore::LowerRight) );
   
        thumbGrad.setStart(QPointF(0, cr.y()));
        thumbGrad.setFinalStop(QPointF(0, cr.y() + cr.height()));
           
           
        p->fillPath(thumb_rect, QBrush(thumbGrad));
           
        // center line
        p->fillRect(ipos + d_thumbHalf, cr.y(), 1, cr.height(), pal.dark().color());
           

        }
    else // (d_orient == Qt::Vertical)
        {
	      
        cr.setRect(r.x() + d_mMargin,
                   r.y(),
                   r.width() - 2*d_mMargin,
                   r.height());
	    

        //
        // Draw background
        //
        QPainterPath bg_rect = MusECore::roundedPath(cr,
                                           xrad, yrad, 
                                           (MusECore::Corner) (MusECore::UpperLeft | MusECore::UpperRight | MusECore::LowerLeft | MusECore::LowerRight) );
	    
        p->fillPath(bg_rect, d_fillColor);

        dist1 = int(double(cr.height() - d_thumbLength) * (1.0 - rpos));
        ipos = cr.y() + dist1;
        markerPos = ipos + d_thumbHalf;

  
        //
        // Draw empty upper filling
        // 

        e_mask.setStart(QPointF(cr.x(), 0));
        e_mask.setFinalStop(QPointF(cr.x() + cr.width(), 0));
	    
        QPainterPath e_rect = MusECore::roundedPath(cr.x(), cr.y(), 
                                          cr.width(), ipos + 1,
                                          xrad, yrad, 
                                          (MusECore::Corner) (MusECore::UpperLeft | MusECore::UpperRight) );
	    
        p->fillPath(e_rect, QBrush(e_mask));
            
            
        //
        // Draw lower filling mask
        //

        f_mask.setStart(QPointF(cr.x(), 0));
        f_mask.setFinalStop(QPointF(cr.x() + cr.width(), 0));
            
        QPainterPath f_rect = MusECore::roundedPath(cr.x(), ipos + d_thumbLength, 
                                          cr.width(), cr.height() - d_thumbLength - dist1,
                                          xrad, yrad, (MusECore::Corner) (MusECore::LowerLeft | MusECore::LowerRight) );
	    
        p->fillPath(f_rect, QBrush(f_mask));
            
            
        //
        //  Draw thumb
        //
            
        QPainterPath thumb_rect = MusECore::roundedPath(r.x(), ipos, 
                                              r.width(), d_thumbLength,
                                              2, 2, 
                                              (MusECore::Corner) (MusECore::UpperLeft | MusECore::UpperRight | MusECore::LowerLeft | MusECore::LowerRight) );
	    
        thumbGrad.setStart(QPointF(cr.x(), 0));
        thumbGrad.setFinalStop(QPointF(cr.x() + cr.width(), 0));
            
            
        p->fillPath(thumb_rect, QBrush(thumbGrad));
            
        // center line
        p->fillRect(cr.x(), ipos + d_thumbHalf, cr.width(), 1, pal.dark().color());
            
        }

}