コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: rNexeR/QGV-Test
void MainWindow::on_pushButton_clicked()
{

    QGraphicsEllipseItem *ellipse2;
    QGraphicsTextItem *texto;

    QBrush redBrush(Qt::red);
    //QBrush blueBrush(Qt::blue);
    QPen blackPen(Qt::black);
    blackPen.setWidth(1);

    ellipse1 = scene->addEllipse(0, 10, 100, 100, blackPen, redBrush);
    ellipse2 = scene->addEllipse(500, 10, 100, 100, blackPen, redBrush);
    ellipse1->setAcceptDrops(true);
    ellipse2->setAcceptDrops(true);
    ellipse1->setFlag(QGraphicsItem::ItemIsMovable, true);

    texto = new QGraphicsTextItem();
    texto->setPos(0,50);
    texto->setPlainText("Nodo X");
    Nodo1->addToGroup(ellipse1);
    Nodo1->addToGroup(texto);
    Nodo1->setAcceptDrops(true);
    Nodo1->setFlag(QGraphicsItem::ItemIsMovable, true);

    scene->addItem(Nodo1);
    ui->painter->setAcceptDrops(true);
    ui->painter->setScene(scene);
    ui->painter->scale(currentScale,currentScale);
}
コード例 #2
0
ファイル: dialogsmithchart.cpp プロジェクト: blindber/MSA-Qt
dialogSmithChart::dialogSmithChart(QWidget *parent) :
  QDialog(parent),
  ui(new Ui::dialogSmithChart)
{
  ui->setupUi(this);
  resize(430,400);

  scene = new QGraphicsScene(this);
  ui->graphicsView->setScene(scene);

  QBrush redBrush(Qt::red);
  QBrush blueBrush(Qt::blue);
  QPen blackPen(Qt::black);

  //ell = scene->addEllipse(10,10,100,100,blackPen,redBrush);
  QPainterPath* path = new QPainterPath();
 path->arcMoveTo(0,0,50,50,20);
 path->arcTo(0,0,50,50,20, 90);

 scene->addPath(*path);
 //ui->graphicsView->sc
  //h = 430; w = 400
//  centerX = 195;
//  CenterY = 191;

}
コード例 #3
0
/**
 * Event: OnPaint
 *
 * Render the Notification Window
 */
LRESULT NotificationWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  PAINTSTRUCT ps;
  BeginPaint(&ps);
  {
    MyGdiplusHelper gdi_plus_autostart;
    {
      // get draw area
      RECT clientRect;
      ::GetClientRect(m_hWnd, &clientRect);
      // create Gdiplus Graphics object
      Gdiplus::Graphics graphics(m_hWnd, FALSE);
      graphics.SetClip(Gdiplus::Rect(clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top));

      // draw a background
      Gdiplus::SolidBrush backgroundBrush(Gdiplus::Color(DEFAULT_ALPHA, 255, 255, 255));
      graphics.FillRectangle(&backgroundBrush, clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);

      // shrink draw area 
      int inset = 4;
      clientRect.left += inset;
      clientRect.top += inset;
      clientRect.right -= inset;
      clientRect.bottom -= inset;

      // whack a logo TODO
      //Bitmap* bitmap = new Bitmap(m_icon.c_str(), FALSE);
      int bitmapWidth = 0;//bitmap->GetWidth(); 
      int bitmapHeight = 15;//bitmap->GetHeight(); 
      //graphics->DrawImage(bitmap, clientRect.left, clientRect.top, 
      //bitmapWidth, bitmapHeight); 

      // draw a separator
      Gdiplus::Pen blackPen(Gdiplus::Color(0, 0, 0), 1.0f);
      graphics.DrawLine(&blackPen, clientRect.left, clientRect.top + bitmapHeight + inset, clientRect.right, clientRect.top + bitmapHeight + inset);

      // setup text properties
      Gdiplus::Font titleFont(L"Verdana", 10, Gdiplus::FontStyleBold);
      Gdiplus::Font textFont(L"Verdana", 10, Gdiplus::FontStyleRegular);
      Gdiplus::RectF titleRect((float)clientRect.left + inset + bitmapWidth, (float)clientRect.top, (float)clientRect.right, 20.0f);
      Gdiplus::RectF textRect((float)clientRect.left,
        (float)clientRect.top + bitmapHeight + (inset * 2),
        (float)clientRect.right,
        (float)clientRect.bottom - bitmapHeight - (inset * 2));
      Gdiplus::StringFormat format;
      format.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter);
      format.SetFormatFlags(Gdiplus::StringFormatFlagsLineLimit);
      Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));

      // draw the message
      graphics.DrawString(m_title.c_str(), (int)m_title.length(), &titleFont, titleRect, &format, &blackBrush);
      graphics.DrawString(m_message.c_str(), (int)m_message.length(), &textFont, textRect, &format, &blackBrush);
    }
  }

  EndPaint(&ps);
  bHandled = TRUE;

  return 0;
}
コード例 #4
0
void LinkDialogProcessorGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                            QWidget* widget) {
    IVW_UNUSED_PARAM(options);
    IVW_UNUSED_PARAM(widget);
    p->save();

    QPen blackPen(QColor(0, 0, 0), 1);

    p->setPen(blackPen);
    p->setRenderHint(QPainter::Antialiasing, true);
    p->setViewTransformEnabled(false);
    QColor topColor(140, 140, 140);
    QColor middleColor(59, 61, 61);
    QColor bottomColor(40, 40, 40);
    // paint processor
    QLinearGradient grad(rect().topLeft(), rect().bottomLeft());

    grad.setColorAt(0.0f, topColor);
    grad.setColorAt(0.2f, middleColor);
    grad.setColorAt(1.0f, bottomColor);

    p->setBrush(grad);
    p->drawRoundedRect(rect(), linkdialog::processorRoundedCorners,
                       linkdialog::processorRoundedCorners);
    p->restore();
}
コード例 #5
0
ファイル: MFCArrangeView.cpp プロジェクト: dakyri/qua
void
MFCInstanceView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	Pen			blackPen(AlphaColor(250, rgb_black), 1);
	Pen			redPen(AlphaColor(250, rgb_red), 1);
	SolidBrush	blueBrush(AlphaColor(100, rgb_blue));
	SolidBrush	blackBrush(AlphaColor(100, rgb_black));

	CRect		clipBounds = bounds;
	if (clipBox.left > bounds.left) clipBounds.left = clipBox.left-1;
	if (clipBox.right < bounds.right) clipBounds.right = clipBox.right+1;

	cerr << "ondraw instance view " << clipBox.left << ", " << clipBox.right << endl;
	dc.FillRectangle(&blueBrush,
			bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
	dc.DrawRectangle(selected?&redPen:&blackPen,
			bounds.left, bounds.top, clipBounds.right-bounds.left, bounds.bottom-bounds.top);
	Font	labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL);
	wstring nm;
	const char *cp = instance->sym->uniqueName();
	while (*cp) { nm.push_back(*cp++); }
	float lbx = bounds.left+2;
#define LBLSEP 200
	if (clipBox.left > lbx) {
		int nld = clipBox.left - lbx;
		nld = nld/LBLSEP;
//		if (nld > 2) lbx += (nld-2)*LBLSEP;
	}
	PointF	p(lbx, clipBounds.top);
	do {
		dc.DrawString(nm.c_str(), -1, &labelFont, p, &blackBrush);
		p.X += LBLSEP;
	} while (p.X < clipBounds.right);
}
コード例 #6
0
ファイル: MFCUtil.cpp プロジェクト: amiel/jugglemaster
void paintDialogHeader(CDC* pDC, const CString &strTitle) {
  int nWidth = pDC->GetDeviceCaps(HORZRES);
  const int nHeaderHeight = 24;

  // paint title
  CFont *pCurrentFont = pDC->GetCurrentFont();
  LOGFONT lf;
  pCurrentFont->GetLogFont(&lf);
  lf.lfWeight = FW_BOLD;
  CFont newFont;
  newFont.CreateFontIndirect(&lf);

  CFont *pSave = pDC->SelectObject(&newFont);
  //pDC->SetBkColor(RGB(100,100,100));
  pDC->SetBkColor(::GetSysColor(COLOR_STATIC));
  pDC->SetTextColor(RGB(0, 0, 156));
  pDC->DrawText(strTitle, CRect(8, 0, nWidth, nHeaderHeight), DT_VCENTER | DT_SINGLELINE);
  pDC->SelectObject(pSave);

  // paint line
  CPen blackPen(PS_SOLID, 1, RGB(0,0,0));
  CPen *pOldPen = pDC->SelectObject(&blackPen);

  pDC->MoveTo(0, nHeaderHeight);
  pDC->LineTo(nWidth, nHeaderHeight);

  pDC->SelectObject(pOldPen);	
}
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: rao1219/qt
void MainWindow::_addLineGraph()
{
    QPen blackPen(Qt::black);
    blackPen.setWidth(0.5);
    for(int i=-200;i<200;i++){
        scene->addLine(-200*(setAlgo->_x)+2*(setAlgo->ratio),i*(setAlgo->_y)+2*(setAlgo->ratio),200*(setAlgo->_x)+2*(setAlgo->ratio),i*(setAlgo->_y)+2*(setAlgo->ratio),blackPen);
        scene->addLine(i*(setAlgo->_x)+2*(setAlgo->ratio),200*(setAlgo->_y)+2*(setAlgo->ratio),i*(setAlgo->_x)+2*(setAlgo->ratio),-200*(setAlgo->_y)+2*(setAlgo->ratio),blackPen);
    }
}
コード例 #8
0
//////////////////
// Draw tab in normal or highlighted state
//
int CFolderTab::Draw(CDC& dc, CFont& font, BOOL bSelected)
{
	COLORREF bgColor = GetSysColor(bSelected ? COLOR_WINDOW     : COLOR_3DFACE);

	CBrush brush(bgColor);					 // background brush
	dc.SetBkColor(bgColor);					 // text background
	dc.SetTextColor(m_colour);				 // text color = fg color

	CPen blackPen(PS_SOLID, 1, RGB(0,0,0));	// black
	CPen shadowPen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));

	// Fill trapezoid
	CPoint pts[4];
	CRect rc = m_rect;
	GetTrapezoid(rc, pts);
	CPen* pOldPen = dc.SelectObject(&blackPen);
	dc.FillRgn(&m_rgn, &brush);

	// Draw edges. This is requires two corrections:
	// 1) Trapezoid dimensions don't include the right and bottom edges,
	// so must use one pixel less on bottom (cybottom)
	// 2) the endpoint of LineTo is not included when drawing the line, so
	// must add one pixel (cytop)
	//
	pts[1].y--;			// correction #1: true bottom edge y-coord
	pts[2].y--;			// ...ditto
	pts[3].y--;			// correction #2:	extend final LineTo
	dc.MoveTo(pts[0]);						// upper left
	dc.LineTo(pts[1]);						// bottom left
	dc.SelectObject(&shadowPen);			// bottom line is shadow color
	dc.MoveTo(pts[1]);						// line is inside trapezoid bottom
	dc.LineTo(pts[2]);						// ...
	dc.SelectObject(&blackPen);			// upstroke is black
	dc.LineTo(pts[3]);						// y-1 to include endpoint
	if (!bSelected) {
		// if not highlighted, upstroke has a 3D shadow, one pixel inside
		pts[2].x--;		// offset left one pixel
		pts[3].x--;		// ...ditto
		dc.SelectObject(&shadowPen);
		dc.MoveTo(pts[2]);
		dc.LineTo(pts[3]);
	}
	dc.SelectObject(pOldPen);

	// draw text
	rc.DeflateRect(CXOFFSET + CXMARGIN, CYMARGIN);
	CFont* pOldFont = dc.SelectObject(&font);
	dc.DrawText(m_sText, &rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
	dc.SelectObject(pOldFont);

	return m_rect.right;
}
コード例 #9
0
void CPage_Node_Lane::DrawCentroidRadicalLines(CPaintDC *pDC, CRect PlotRect,bool bOriginAngle/*=true*/)
{
	CPen blackPen(PS_SOLID,0,RGB(0,0,0));
	CPen greyPen(PS_SOLID,2,RGB(128,128,128));
	CPen lanePen(PS_SOLID,1,RGB(0,0,0));
	CPen laneSelectedPen(PS_SOLID,2,RGB(255,0,0));

	CBrush  greyBrush(RGB(128,128,128)); 
	CBrush  whiteBrush(RGB(255,255,255)); 
	CBrush  redBrush(RGB(255,0,0)); 

	pDC->SetBkMode(TRANSPARENT);
	CPen *pOldPen = pDC->SelectObject(&blackPen);
	CBrush* pOldBrush = pDC->SelectObject(&whiteBrush);
	pDC->Rectangle(PlotRect);

	GDPoint cntPoint,lefttop,bottomright;
	CRect centerRect;

	cntPoint.x = 0.0;
	cntPoint.y = 0.0;
	int nRadius2 = m_Para.nCentroidRadius;
	lefttop.x = cntPoint.x - nRadius2;
	lefttop.y = cntPoint.y - nRadius2;
	bottomright.x = cntPoint.x + nRadius2;
	bottomright.y = cntPoint.y + nRadius2;
	
	pDC->SelectObject(&greyPen);
	pDC->SelectObject(&greyBrush);
	centerRect = CRect(NPtoSP(lefttop),NPtoSP(bottomright));
	pDC->Ellipse(centerRect);

	for(int i=0;i<m_LinkData.size();i++)
	{
		LinkRecord *pRecord = m_LinkData[i];
		pDC->SelectObject(&greyPen);
		DrawRadicalLine(pDC,pRecord,bOriginAngle);
		pDC->SelectObject(&lanePen);
		pDC->SelectObject(&greyBrush);
		DrawLanes(pDC,pRecord,bOriginAngle);
		pDC->SelectObject(&blackPen);
		if (pRecord->nLinkID == m_nSelectedLinkID)
			pDC->SelectObject(&redBrush);
		DrawLinkPinPoint(pDC,pRecord,bOriginAngle);
	}

	// draw selected link pin point

	pDC->SelectObject(pOldPen);
	pDC->SelectObject(pOldBrush);
	
}
コード例 #10
0
ファイル: HalfwayImage.cpp プロジェクト: Nuos/Image-Morphing
void HalfwayImage::paintEvent(QPaintEvent *event)
{
	if(!_image_loaded)
		return;

	QPainter painter(this);
	QPixmap pixmaptoshow;	
	
		
	if(_flag_error)
		pixmaptoshow=QPixmap::fromImage(_image_error.scaled(this->size(),Qt::KeepAspectRatio));
	else
	{
		QImage tempImage(_image);

		if (!_flag_multilayer)
		{
			QPoint MouseP(_mouse_pos.x()*_image.width(),_mouse_pos.y()*_image.height());
			int radius;
			if (_pressed)		
				radius=_image.width()/8;
			else
				radius=_image.width()/16;
			QRect rect(MouseP-QPoint(radius,radius),MouseP+QPoint(radius,radius));

			for(int y=rect.top();y<=rect.bottom();y++)
				for(int x=rect.left();x<=rect.right();x++)
				{
					if (tempImage.rect().contains(QPoint(x,y))&&(y-MouseP.y())*(y-MouseP.y())+(x-MouseP.x())*(x-MouseP.x())<radius*radius)
					{
						if (_pressed)					
							tempImage.setPixel(QPoint(x,y),_imageR.pixel(QPoint(x,y)));					
						else					
							tempImage.setPixel(QPoint(x,y),_imageL.pixel(QPoint(x,y)));	
					}
				}

				QPainter img_painter(&tempImage);			
				QPen blackPen(qRgba(0, 0, 0, 255));
				img_painter.setPen(blackPen);
				QBrush EmptyBrush(Qt::NoBrush);
				img_painter.setBrush(EmptyBrush);
				img_painter.drawEllipse(MouseP,radius,radius);
		}
		
		pixmaptoshow=QPixmap::fromImage(tempImage.scaled(this->size(),Qt::KeepAspectRatio));
	}

		
	painter.drawPixmap(0,0, pixmaptoshow);
	_real_size=pixmaptoshow.size();		
}
コード例 #11
0
ファイル: MFCDataEditor.cpp プロジェクト: dakyri/qua
void
MFCEditorItemView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	Pen			blackPen(Color(250, 0,0,0), 1);
	Pen			redPen(Color(250, 160, 10, 10), 1);
	SolidBrush	blueBrush(Color(100, 10, 10, 160));
	SolidBrush	blackBrush(Color(100, 0,0,0));

//	fprintf(stderr, "drawing instance view %d\n", bounds.right-bounds.left);
	dc.FillRectangle(&blueBrush, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
	dc.DrawRectangle(selected?&redPen:&blackPen, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
}
コード例 #12
0
ファイル: mainwindow.cpp プロジェクト: mangeld/QT_Fractals
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow),
  pincel(Qt::black)
{
  ui->setupUi(this);
  escena = new QGraphicsScene(this);
  ui->graphicsView->setScene(escena);
  ui->graphicsView->setRenderHint(QPainter::Antialiasing);
  QPen blackPen(Qt::black);
  this->triangle_recur(4);
  //linea = escena->addLine(10, 10, 40, 40, blackPen);
}
コード例 #13
0
	void treeVisualiserFrame::highlightPosition(double x, double y)
	{
		if(highlightItem)
		{
			graphicsScene->removeItem(highlightItem);
			delete highlightItem;
		}
		QPen blackPen(QColor("black"));
		blackPen.setStyle(Qt::NoPen);
		QBrush blackBrush(QColor("black"));
		highlightItem = graphicsScene->addEllipse(x - pointSize/2, y - pointSize/2, pointSize, pointSize, blackPen, blackBrush);
		highlightItem->setFlag(QGraphicsItem::ItemIsSelectable, false);
		highlightItem->setZValue(1);
	}
コード例 #14
0
ファイル: attitudeindicator.cpp プロジェクト: dgrat/rpicopter
void qAttitudeIndicator::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPoint center(0,0);
    QPen whitePen(Qt::white);
    QPen blackPen(Qt::black);
    QBrush bgSky(QColor(48,172,220));
    QBrush bgGround(QColor(247,168,21));
    whitePen.setWidth(2);
    blackPen.setWidth(1);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.translate(width() / 2, height() / 2);
    int side = qMin(width(), height());
    painter.scale(side / (qreal)(size), side / (qreal)(size));
    painter.setPen(blackPen);
    painter.rotate(roll);
    painter.setBrush(bgSky);

    int y = 0.25*size*pitch/20.;

    int x = sqrt(size*size/4 - y*y);
    qreal gr = atan((double)(y)/x);
    gr = gr * 180./3.1415926;
    painter.drawChord(-side/2,-side/2,side,side,gr*16,(180-2*gr)*16);
    painter.setBrush(bgGround);
    painter.drawChord(-side/2,-side/2,side,side,gr*16,-(180+2*gr)*16);
    painter.setPen(whitePen);

    painter.drawLine(-x,-y,x,-y);
    painter.setPen(blackPen);
    painter.rotate(-180.);
    for(int i=0;i<numbRollLine;i++)
    {
        painter.rotate(rollRotate[i]);
        painter.drawLine(rollPoint[i][0],rollPoint[i][1]);
    }
    whitePen.setWidth(1);
    painter.setPen(whitePen);
    painter.rotate(-90.);
    for(int i=0;i<numbPitchLine;i++)
    {
        painter.drawLine(pitchPoint[i][0],pitchPoint[i][1]);
    }
    painter.rotate(-roll);
    blackPen.setWidth(3);
    painter.setPen(blackPen);
    painter.drawLines(target);
    painter.drawLines(rollPointer);
}
コード例 #15
0
void subObservationVisualiserBase::constructStandardPoints(const observation& subObs)
{
    assert(standardPointsItem);
    std::size_t nVertices = boost::num_vertices(contextObj.getGraph());
    const std::vector<context::vertexPosition>& vertexPositions = contextObj.getVertexPositions();
    const vertexState* state = subObs.getState();

    QPen blackPen(QColor("black"));
    QBrush blackBrush(QColor("black"));

    QPen redPen(QColor("red"));
    QBrush redBrush(QColor("red"));

    QBrush noBrush;
    noBrush.setStyle(Qt::NoBrush);

    for(std::size_t vertexCounter = 0; vertexCounter < nVertices; vertexCounter++)
    {
        context::vertexPosition currentPosition = vertexPositions[vertexCounter];
        float x = currentPosition.first;
        float y = currentPosition.second;
        QGraphicsEllipseItem* newItem = new QGraphicsEllipseItem(x - pointSize/2, y - pointSize/2, pointSize, pointSize, standardPointsItem);
        if(state[vertexCounter].state == FIXED_OFF)
        {
            newItem->setBrush(noBrush);
            newItem->setPen(blackPen);
        }
        else if(state[vertexCounter].state == FIXED_ON)
        {
            newItem->setBrush(blackBrush);
            newItem->setPen(blackPen);
        }
        else if(state[vertexCounter].state == UNFIXED_OFF)
        {
            newItem->setBrush(noBrush);
            newItem->setPen(redPen);
        }
        else if(state[vertexCounter].state == UNFIXED_ON)
        {
            newItem->setBrush(redBrush);
            newItem->setPen(redPen);
        }
        else
        {
            throw std::runtime_error("Internal error");
        }
    }
}
コード例 #16
0
//////////////////
// Paint function
//
void CFolderTabCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	int xOrigin = m_cxButtons - GetTab(m_iFirstTab)->GetRect().left;
	dc.SetViewportOrg(xOrigin,0);

	CRect rc;
	GetClientRect(&rc);

	CFolderTab* pCurTab = NULL;

	// draw all the normal (non-selected) tabs
	int n = GetItemCount();
	for (int i=0; i<n; i++) {
		CFolderTab* pTab = GetTab(i);
		ASSERT(pTab);
		if (i==m_iCurItem) {
			pCurTab = pTab;
		} else {
			pTab->Draw(dc, m_fontNormal, FALSE);
		}
	}
	// draw selected tab last so it will be "on top" of the others
	if (pCurTab)
		pCurTab->Draw(dc, m_fontSelected, TRUE);

	// draw border: line along the top edge, excluding seleted tab
	CRect rcCurTab(0,0,0,0);
	if (pCurTab)
		rcCurTab = pCurTab->GetRect();

	rc.right -= xOrigin;
	CPen blackPen(PS_SOLID, 1, RGB(0,0,0));	// black
	CPen* pOldPen = dc.SelectObject(&blackPen);
	dc.MoveTo(rcCurTab.right, rcCurTab.top);
	dc.LineTo(rc.right, rc.top);
	if (m_dwFtabStyle & FTS_FULLBORDER) {
		dc.MoveTo(rc.right-1, rc.top);
		dc.LineTo(rc.right-1, rc.bottom-1);
		dc.LineTo(rc.left,  rc.bottom-1);
		dc.LineTo(rc.left,  rc.top);
	} else {
		dc.MoveTo(rc.left, rc.top);
	}
	dc.LineTo(rcCurTab.TopLeft());
	dc.SelectObject(pOldPen);
}
コード例 #17
0
ファイル: canvas.cpp プロジェクト: trec21/452p1
void Canvas::initialize() {

    painter->resize(width(), height());
    painter->move(-width()/2, 0);
    painter->setXOffset(width()/2);
    addWidget(painter);

    QBrush blackBrush(Qt::black);
    QPen blackPen(Qt::black);
    blackPen.setWidth(1);

    Axis* axis;
    vector<double> heights;
    for(int i=0; i< NUM_LINKS+1; i++) {

        if (i==0) {
            axis = new Axis(0, 0);
            heights.push_back(0);
        } else if(i==1) {
            axis = new Axis(0, 150);
            heights.push_back(150);
        } else if (i==2) {
            axis = new Axis(0, 250);
            heights.push_back(250);
        } else if (i==3) {
            axis = new Axis(0, 325);
            heights.push_back(325);
        }
        axes.push_back(axis);
    }

    setUpAxes();


    for(int i=0; i< NUM_LINKS; i++) {
        Link* link = new Link();
        link->length = heights[i+1] - heights[i];

        link->ellipse = this->addEllipse(-WIDTH/2,heights[i],WIDTH,link->length,blackPen,blackBrush);
        link->ellipse->setTransformOriginPoint(0,heights[i]);

        link->frontAxis = axes[i+1];
        link->backAxis = axes[i];
        link->orientation = 0;

        links.push_back(link);
    }
}
コード例 #18
0
ファイル: graphicswindow.cpp プロジェクト: thln/math_puzzle
/** Default Constructor*/
GraphicsWindow::GraphicsWindow()  {
    //We need a scene and a view to do graphics in QT
    scene = new QGraphicsScene();
    setScene(scene);
    setWindowTitle( "Programming Assignment #4: Math Puzzles");
    //view = new QGraphicsView( scene );

    //To fill a rectangle use a QBrush. To draw the border of a shape, use a QPen
    QBrush redBrush(Qt::red);
    QPen blackPen(Qt::black);
    QBrush blueBrush(Qt::blue);
    QBrush yellowBrush(Qt::yellow);
    QBrush greenBrush(Qt::green);

  	
}
コード例 #19
0
ファイル: speckles.cpp プロジェクト: celalcakiroglu/Qt
speckles::speckles(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::speckles)
{
    ui->setupUi(this);
    scene=new QGraphicsScene(this);

    ui->graphicsView->setScene(scene);
    QBrush redBrush(Qt::red);
    QBrush blueBrush(Qt::blue);
    QPen blackPen(Qt::black);
    blackPen.setWidth(6);
    ellipse=scene->addEllipse(10, 10, 100, 500, blackPen, redBrush);
    rectangle=scene->addRect(-10, -10, 100, 50, blackPen, blueBrush);
    qDebug()<<"The width of the scene is: "<<scene->width();
    qDebug()<<"The height of the scene is: "<<scene->height();
}
コード例 #20
0
void subObservationVisualiserBase::constructStandardLines(const observation& subObs)
{
    assert(standardLinesItem);
    const vertexState* state = subObs.getState();
    const context::inputGraph& graph = contextObj.getGraph();
    const std::vector<context::vertexPosition>& vertexPositions = contextObj.getVertexPositions();

    QPen blackPen(QColor("black"));
    blackPen.setWidthF(pointSize/10);

    QPen redPen(QColor("red"));
    redPen.setWidthF(pointSize/10);

    QVector<qreal> dashPattern;
    dashPattern.push_back(8);
    dashPattern.push_back(8);

    QPen dashedBlackPen(QColor("black"));
    dashedBlackPen.setDashPattern(dashPattern);

    QPen dashedRedPen(QColor("red"));
    dashedRedPen.setDashPattern(dashPattern);

    context::inputGraph::edge_iterator start, end;
    boost::tie(start, end) = boost::edges(graph);

    while(start != end)
    {
        context::vertexPosition sourcePosition = vertexPositions[start->m_source], targetPosition = vertexPositions[start->m_target];
        QGraphicsLineItem* newItem = new QGraphicsLineItem(sourcePosition.first, sourcePosition.second, targetPosition.first, targetPosition.second, standardLinesItem);
        if(state[start->m_source].state == FIXED_ON && state[start->m_target].state == FIXED_ON)
        {
            newItem->setPen(blackPen);
        }
        else if(state[start->m_source].state == FIXED_OFF || state[start->m_target].state == FIXED_OFF)
        {
            newItem->setPen(dashedBlackPen);
        }
        else
        {
            newItem->setPen(redPen);
        }
        start++;
    }
}
コード例 #21
0
void LinkDialogProcessorGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                            QWidget* widget) {
    IVW_UNUSED_PARAM(options);
    IVW_UNUSED_PARAM(widget);
    p->save();

    QPen blackPen(QColor(0, 0, 0), 1);

    p->setPen(blackPen);
    p->setRenderHint(QPainter::Antialiasing, true);
    p->setViewTransformEnabled(false);
    QColor topColor(140, 140, 140);
    QColor middleColor(59, 61, 61);
    QColor bottomColor(40, 40, 40);
    // paint processor
    QLinearGradient grad(rect().topLeft(), rect().bottomLeft());

    grad.setColorAt(0.0f, topColor);
    grad.setColorAt(0.2f, middleColor);
    grad.setColorAt(1.0f, bottomColor);

    p->setBrush(grad);
    QPainterPath roundRectPath;
    QRectF bRect = rect();
    roundRectPath.moveTo(bRect.left(), bRect.top() + linkdialog::processorRoundedCorners);
    roundRectPath.lineTo(bRect.left(), bRect.bottom() - linkdialog::processorRoundedCorners);
    roundRectPath.arcTo(bRect.left(), bRect.bottom() - (2 * linkdialog::processorRoundedCorners),
                        (2 * linkdialog::processorRoundedCorners),
                        (2 * linkdialog::processorRoundedCorners), 180.0, 90.0);
    roundRectPath.lineTo(bRect.right() - linkdialog::processorRoundedCorners, bRect.bottom());
    roundRectPath.arcTo(bRect.right() - (2 * linkdialog::processorRoundedCorners),
                        bRect.bottom() - (2 * linkdialog::processorRoundedCorners),
                        (2 * linkdialog::processorRoundedCorners),
                        (2 * linkdialog::processorRoundedCorners), 270.0, 90.0);
    roundRectPath.lineTo(bRect.right(), bRect.top() + linkdialog::processorRoundedCorners);
    roundRectPath.arcTo(bRect.right() - (2 * linkdialog::processorRoundedCorners), bRect.top(),
                        (2 * linkdialog::processorRoundedCorners),
                        (2 * linkdialog::processorRoundedCorners), 0.0, 90.0);
    roundRectPath.lineTo(bRect.left() + linkdialog::processorRoundedCorners, bRect.top());
    roundRectPath.arcTo(bRect.left(), bRect.top(), (2 * linkdialog::processorRoundedCorners),
                        (2 * linkdialog::processorRoundedCorners), 90.0, 90.0);
    p->drawPath(roundRectPath);
    p->restore();
}
コード例 #22
0
/**
 * @brief Constructor.
 * @param[in] parent widget.
 */
BARSongAreaScene::BARSongAreaScene(QObject *parent) : QGraphicsScene(parent)
{
    timeLineSize=100; /**< length of each rectangle composing the timeline. */

    QBrush redBrush(Qt::white); /**< desired color for the background of the rectangles when empty. */
    QPen blackPen(Qt::black); /**< desired color for the outline of the rectangle. */
    blackPen.setWidth(1); /**< sets width of the outline of the rectangle. */

    for(int i=0;i<50;i++) /**< this boucle creates the 50 rectangles of the timeline. */
    {
        QGraphicsRectItem *rectangle=new QGraphicsRectItem(i*timeLineSize,0,timeLineSize,60); /**< create the new rectangle on the right of the last one. */
        QGraphicsTextItem *label=new QGraphicsTextItem(QString::number(i)); /**< displays the number of the rectangle in the timeline. */
        label->setPos(i*timeLineSize-timeLineSize/20,-25); /**< position the label in the top left corner of the rectangle. */
        rectangle->setBrush(redBrush); /**< set the background color. */
        rectangle->setPen(blackPen); /**< set the outline. */
        addItem(rectangle); /**< the last three lines add the rectangle to the timeline. */
        addItem(label);
        stock.push_back(rectangle);
    }
}
コード例 #23
0
ファイル: mainwindow.cpp プロジェクト: rao1219/qt
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    QApplication::setStyle("macintosh");

    ui->setupUi(this);
  //  this->setStyleSheet("background-color:gray;");
    this->setMinimumSize(1621,924);
    this->setMaximumSize(1621,924);

    QPen blackPen(Qt::black);
    blackPen.setWidth(0.5);

    scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
   // this->_addLineGraph();
    out = "";
    m=1;n=0;
}
コード例 #24
0
ファイル: CSelectionPanel.cpp プロジェクト: housemeow/AOE2
	void CSelectionPanel::OnShowHPLine(){
		set<CSprite*>::iterator it;
		CDC *pDC = CDDraw::GetBackCDC();			// 取得 Back Plain 的 CDC
		CBrush *pb,redBrush(RGB(255,0,0)),greenBrush(RGB(0,255,0));
		CPen *pp,blackPen(PS_SOLID,1,RGB(0,0,0));
		pp = pDC->SelectObject(&blackPen);

		pb = pDC->SelectObject(&redBrush);
		for(it = selectedSprites.begin();it!=selectedSprites.end();it++){
			CPoint screenPoint(CConvert::GetScreenPointByMapPoint((*it)->MapPoint()));
			CRect redRect(CPoint(screenPoint.x-25,screenPoint.y),CSize(50,5));
			pDC->Rectangle(redRect);

			CRect greenRect(CPoint(screenPoint.x-25,screenPoint.y),CSize(50*(*it)->HP()/(*it)->MaxHP(),5));
			pDC->SelectObject(&greenBrush);
			pDC->Rectangle(greenRect);
			pDC->SelectObject(&redBrush);
		}
		pDC->SelectObject(pb);						//
		pDC->SelectObject(pp);
		CDDraw::ReleaseBackCDC();					// 放掉 Back Plain 的 CDC
		//if(isSelected){
		//	//畫圓圈
		//	CDC *pDC = CDDraw::GetBackCDC();			// 取得 Back Plain 的 CDC
		//	CBrush *pb,redBrush(RGB(255,0,0)),greenBrush(RGB(0,255,0));
		//	CPen *pp,nullPen(PS_NULL,0,RGB(0,0,0));

		//	pb = pDC->SelectObject(&redBrush);
		//	pp = pDC->SelectObject(&nullPen);
		//	CPoint screenPoint(CConvert::GetScreenPointByMapPoint(mapPoint));
		//	CRect redRect(CPoint(screenPoint.x-25,screenPoint.y),CSize(50,5));
		//	CRect greenRect(CPoint(screenPoint.x-25,screenPoint.y),CSize(50*hp/maxHp,5));
		//	pDC->Rectangle(redRect);
		//	pDC->SelectObject(&greenBrush);
		//	pDC->Rectangle(greenRect);

		//	pDC->SelectObject(pb);						//
		//	pDC->SelectObject(pp);
		//	CDDraw::ReleaseBackCDC();					// 放掉 Back Plain 的 CDC
		//}
	}
コード例 #25
0
void Location::CutsceneView::CameraManipulatable::DrawCore(QGraphicsScene * pScene, QList<QGraphicsItem *> & addedItems)
{
    QBrush blackBrush(qRgba(0, 0, 0, 255));
    QPen blackPen(blackBrush, 4);
    QPen whitePen(QBrush(qRgba(255, 255, 255, 255)), 2);

    pOutsideCameraPathItem = new QGraphicsPathItem();
    pOutsideCameraPathItem->setBrush(blackBrush);

    QGraphicsOpacityEffect *pOutsideCameraOpacityEffect = new QGraphicsOpacityEffect();
    pOutsideCameraOpacityEffect->setOpacity(0.5);

    pOutsideCameraPathItem->setGraphicsEffect(pOutsideCameraOpacityEffect);

    pScene->addItem(pOutsideCameraPathItem);
    addedItems.append(pOutsideCameraPathItem);

    pCameraCenterHorizontalOuterLineItem = new QGraphicsLineItem();
    pCameraCenterVerticalOuterLineItem = new QGraphicsLineItem();
    pCameraCenterHorizontalInnerLineItem = new QGraphicsLineItem();
    pCameraCenterVerticalInnerLineItem = new QGraphicsLineItem();

    pCameraCenterHorizontalOuterLineItem->setPen(blackPen);
    pCameraCenterVerticalOuterLineItem->setPen(blackPen);
    pCameraCenterHorizontalInnerLineItem->setPen(whitePen);
    pCameraCenterVerticalInnerLineItem->setPen(whitePen);

    pCameraCenterGraphicsItemGroup = new QGraphicsItemGroup();
    pCameraCenterGraphicsItemGroup->addToGroup(pCameraCenterHorizontalOuterLineItem);
    pCameraCenterGraphicsItemGroup->addToGroup(pCameraCenterVerticalOuterLineItem);
    pCameraCenterGraphicsItemGroup->addToGroup(pCameraCenterHorizontalInnerLineItem);
    pCameraCenterGraphicsItemGroup->addToGroup(pCameraCenterVerticalInnerLineItem);

    pCameraCenterOpacityEffect = new QGraphicsOpacityEffect();
    pCameraCenterOpacityEffect->setOpacity(1.0);

    pCameraCenterGraphicsItemGroup->setGraphicsEffect(pCameraCenterOpacityEffect);

    pScene->addItem(pCameraCenterGraphicsItemGroup);
    addedItems.append(pCameraCenterGraphicsItemGroup);
}
コード例 #26
0
ファイル: mainwindow.cpp プロジェクト: gregorius2514/Max-Flow
void MainWindow::paintEvent(QPaintEvent *e)
{
    wierzcholek tmp;
    QPen blackPen(Qt::black);
    blackPen.setWidth(1);

    int x_src, x_dst, y_src, y_dst;
    x_src = x_dst = y_src = y_dst = 0;

    for(std::list<wierzcholek>::iterator itr = wierzcholki.begin(); itr != wierzcholki.end(); itr++) {

        scene->addEllipse(itr->x, itr->y, ECLIPSE_WIDTH, ECLIPSE_WIDTH, blackPen);

        QGraphicsTextItem *io = new QGraphicsTextItem;
        io->setPos(itr->x + ECLIPSE_WIDTH/4 - itr->nazwa.length(), itr->y + ECLIPSE_WIDTH/3);
        io->setPlainText(itr->nazwa);
        scene->addItem(io);

        for(std::list<krawedz>::iterator itr2 = itr->krawedzie.begin(); itr2 != itr->krawedzie.end(); itr2++){
            get_node(itr2->cel, tmp);
            x_src = itr->x+ECLIPSE_WIDTH;
            y_src = itr->y+ECLIPSE_WIDTH/2;
            x_dst = tmp.x;
            y_dst = tmp.y+ECLIPSE_WIDTH/2;

            if(itr2->cel != "ujscie") {
                QGraphicsTextItem *number = new QGraphicsTextItem;
                number->setPos((x_src + x_dst)/2, (y_src + y_dst)/2);
                number->setPlainText(QString::number(itr2->pojemnosc));
                scene->addItem(number);
            }

            scene->addLine(x_src, y_src, x_dst, y_dst,  blackPen);
        }
    }
}
コード例 #27
0
void CalendarWidget::calculateAndDrawMonth(int j_y, int j_m, int j_d)
{
    monthPixmap = QPixmap(this->size());

    //Must be done.
    //`Qt::transparent` is equivalent to `QColor::fromRgb(0,0,0,0)` or `QColor::fromRgba(0)`.
    //We could also have used `palette().color(QPalette::Window)`.
    monthPixmap.fill(Qt::transparent);

    QPainter p(&monthPixmap);
    QPen blackPen(QColor(0, 0, 0));
    QPen grayPen(QColor(192, 192, 192));
    QPen blueThickPen(QColor(0, 0, 255), 2);

    p.setPen(blackPen);

    int hUnit = this->width() / 7;
    int vUnit = this->height() / 7;

    QString title = Ct::Date::PersianDate::nameOfMonth(j_m) + " " + QString::number(j_y);
    QRect titleRect(0, 0, this->width(), vUnit);
    titleRect.adjust(1, 1, -1, -1);
    p.fillRect(titleRect, QColor(64, 128, 255));
    QFont boldFont = this->font();
    boldFont.setBold(true);
    p.setFont(boldFont);
    p.drawText(titleRect, Qt::AlignCenter, title);

    for (int i = 0; i < 7; i++)
    {
        QRect cellRect((6 - i) * hUnit, vUnit, hUnit, vUnit);
        cellRect.adjust(1, 1, -1, -1);
        if (i == 6)
            p.fillRect(cellRect, QColor(96, 160, 255));
        else
            p.fillRect(cellRect, QColor(128, 192, 255));
        p.drawText(cellRect, Qt::AlignCenter, Ct::Date::PersianDate::nameOfPersianWeekDay(i + 1));

        for (int j = 0; j < 7; j++)
            datestamps[j][i] = 0;
    }

    QDate firstDayOfJalaliMonth;
    Ct::Date::PersianDate::JalaliToGregorian(firstDayOfJalaliMonth, j_y, j_m, 1);

    //Without the QTime of 12 P.M, we got problems on 26/27 Esfand 1391 = 16/17 March 2013:
    //  Both shows the same date! This was on Win7. On WinXP it was on the same month at different
    //  days and in linux I did not test.
    QDateTime dateStamp(firstDayOfJalaliMonth, QTime(12, 0, 0));

    int hPos = 0;
    int vPos = 2;

    int mapWeekStartDayFromMondayToSaturday[] = { 0, 3, 4, 5, 6, 7, 1, 2 };
    int PersianWeekStartDay = mapWeekStartDayFromMondayToSaturday[firstDayOfJalaliMonth.dayOfWeek()];
    hPos = PersianWeekStartDay - 1;

    int modFridays = (8 - PersianWeekStartDay) % 7;

    int jalaliMonthDayCount = Ct::Date::PersianDate::numberOfDaysInJalaliMonth(j_y, j_m);

    QFont smallEnglishFont("Tahoma", 8, QFont::Bold);
    for (int i = 1; i <= jalaliMonthDayCount; i++)
    {
        QRect cellRect((6 - hPos) * hUnit, vPos * vUnit, hUnit, vUnit);
        cellRect.adjust(1, 1, -1, -1);
        if (i % 7 == modFridays)
            p.fillRect(cellRect, QColor(128, 192, 255));
        else
            p.fillRect(cellRect, Qt::white);
        if (i == j_d) //Today
        {
            p.setPen(blueThickPen);
            p.drawRect(cellRect);
        }

        //Draw the Gregorian number FIRST so that it goes lower than the Persian day in high-DPI.
        if (settings.showGregorianDates)
        {
            p.setPen(grayPen);
            p.setFont(smallEnglishFont);

            QString dayText = "";
            //In case either Persian or Gregorian day is 1, we add the short month name (MMM). Since
            //  in Persian locale the month name is localized, we also add space before it to have
            //  some right margin.
            if (i == 1 || dateStamp.date().day() == 1)
                dayText = " " + dateStamp.date().toString("MMM") + " ";
            //We add space after the day because some right margin is always useful! Of course this space
            //  is used if a localized month name wasn't added to the day number.
            dayText += QString::number(dateStamp.date().day()) + " ";

            p.drawText(cellRect, Qt::AlignRight | Qt::AlignBottom, dayText);
        }

        p.setPen(blackPen);
        p.setFont(this->font());
        p.drawText(cellRect, Qt::AlignCenter, QString::number(i));

        //FIRST save the datestamps
        datestamps[(6 - hPos)][vPos] = dateStamp.toMSecsSinceEpoch();
        dateStamp = dateStamp.addDays(1);

        //THEN 'increase' hPos/vPos
        hPos++;
        if (hPos == 7)
        {
            hPos = 0;
            vPos++;

            if (vPos == 7)
                vPos = 2; //Draw the excess 30th and 31th day in the top row.
        }
    }
}
コード例 #28
0
ファイル: canvas.cpp プロジェクト: trec21/452p1
// Maybe i just need the final 3 points
// TODO get the points correctly
//void Canvas::update(vector<QPoint>* points) {
void Canvas::updateLinks(Link* _link, double _angle) {

    // There is four positions to keep track of:
    // targetBackJointPos
    // targetFrontJointPos
    // currentBackJointPos
    // currentFrontJointPos
    // BackJoint = i
    // FrontJoint = i+1
    // i = link number

    rotate_axis(_link->backAxis, _link->frontAxis, _angle, _link);

    QPointF targetBackJointPos;
    QPointF targetFrontJointPos;
    vector<QPointF> targetPoints;

    for(int i=0;i<axes.size() - 1;i++)
    {
        Axis* axis = axes[i];
        QPointF point (axis->loc_x, axis->loc_y);
        qDebug() << "Next X: " << axis->loc_x << "Next Y: " << axis->loc_y;
        targetPoints.push_back(point);
    }



    QBrush blackBrush(Qt::black);
    QPen blackPen(Qt::black);
    blackPen.setWidth(1);

    for(int i=0; i< NUM_LINKS; i++) {

        Link* link = links[i];
        Axis* front = link->frontAxis;
        Axis* back  = link->backAxis;
        double angleX = front->loc_x - back->loc_x;
        double angleY = front->loc_y - back->loc_y;
        double angle = atan2(angleY,angleX) * RAD_TO_DEG - 90; // to degrees
        qDebug() << "Front:  "<< front->loc_x << "," << front->loc_y;
        qDebug() << "Back:   "<< back->loc_x << "," << back->loc_y;


        qDebug() << "AngleX: "<< angle;

        delete link->ellipse;
        link->ellipse = this->addEllipse(-1*WIDTH/2,0, WIDTH,link->length,blackPen,blackBrush);
        link->ellipse->setRotation(angle);
        link->ellipse->setX(targetPoints[i].x());
        link->ellipse->setY(targetPoints[i].y());
        //link->ellipse->setTransformOriginPoint(targetPoints[i].x(), targetPoints[i].y());

       // link->ellipse->setPos(targetFrontJointPos.x(),targetFrontJointPos.y());
    }




    /****
     *Almost working
     *
     *
     * QBrush blackBrush(Qt::black);
    QPen blackPen(Qt::black);
    blackPen.setWidth(1);

    for(int i=0; i< NUM_LINKS; i++) {

        Link* link = links[i];

        double angleX = link->frontAxis->loc_x - link->backAxis->loc_x;
        double angleY = link->frontAxis->loc_y - link->backAxis->loc_y;
        double angle = atan2(angleY,angleX) * RAD_TO_DEG - 90; // to degrees


        delete link->ellipse;
        link->ellipse = this->addEllipse(-1*WIDTH/2,0, WIDTH,link->length,blackPen,blackBrush);
        link->ellipse->setRotation(angle);
        link->ellipse->setX(targetPoints[i].x());
        link->ellipse->setY(targetPoints[i].y());
        //link->ellipse->setTransformOriginPoint(targetPoints[i].x(), targetPoints[i].y());

       // link->ellipse->setPos(targetFrontJointPos.x(),targetFrontJointPos.y());
    }*/





    /*

    Link* link;
    for(size_t i=0; i<links.size(); i++) {
        targetFrontJointPos = targetPoints[i+1];
        link = links[i];

        currentBackJointPos = link->ellipse->mapToScene(link->ellipse->pos());
        double angleX = targetFrontJointPos.x() - targetBackJointPos.x();
        double angleY = targetFrontJointPos.y() - targetBackJointPos.y();
        double angle = atan2(angleY,angleX) * RAD_TO_DEG - 90; // to degrees

        currentFrontJointPos = QPointF(link->length * sin(link->ellipse->rotation() * DEG_TO_RAD) + currentFrontJointPos.x(),
                                       link->length * cos(link->ellipse->rotation() * DEG_TO_RAD) + currentFrontJointPos.y());
        // Absolute in scene

        qDebug() << "CurrentFront: " << currentFrontJointPos << "CurrentBack: " <<  currentBackJointPos << "angle: " << angle;
        qDebug() << "TargetFront: " << targetFrontJointPos << "TargetBack: " <<  targetBackJointPos << '\n';

        // This works because of reasons
        //link->ellipse->setPos(shiftPoint);
        link->ellipse->moveBy(shiftPoint.x(), shiftPoint.y());
        link->ellipse->setRotation( angle);


        double shitfX = targetFrontJointPos.x() + -1*currentFrontJointPos.x()  ;
        double shitfY = targetFrontJointPos.y() + -1*currentFrontJointPos.y()  ;

        shiftPoint = QPointF(shitfX, shitfY);
        qDebug() << "Shift: " << shiftPoint << " FROM: " << link->ellipse->mapToScene(shiftPoint) << "\n\n";

        targetBackJointPos = targetFrontJointPos;
    }

*/

}
コード例 #29
0
ファイル: sashwin.cpp プロジェクト: ACanadianKernel/pcsx2
// Draw the sash
void wxSashWindow::DrawSash(wxSashEdgePosition edge, wxDC& dc)
{
    int w, h;
    GetClientSize(&w, &h);

    wxPen facePen(m_faceColour, 1, wxSOLID);
    wxBrush faceBrush(m_faceColour, wxSOLID);
    wxPen mediumShadowPen(m_mediumShadowColour, 1, wxSOLID);
    wxPen darkShadowPen(m_darkShadowColour, 1, wxSOLID);
    wxPen lightShadowPen(m_lightShadowColour, 1, wxSOLID);
    wxPen hilightPen(m_hilightColour, 1, wxSOLID);
    wxColour blackClr(0, 0, 0);
    wxColour whiteClr(255, 255, 255);
    wxPen blackPen(blackClr, 1, wxSOLID);
    wxPen whitePen(whiteClr, 1, wxSOLID);

    if ( edge == wxSASH_LEFT || edge == wxSASH_RIGHT )
    {
        int sashPosition = (edge == wxSASH_LEFT) ? 0 : ( w - GetEdgeMargin(edge) );

        dc.SetPen(facePen);
        dc.SetBrush(faceBrush);
        dc.DrawRectangle(sashPosition, 0, GetEdgeMargin(edge), h);

        if (GetWindowStyleFlag() & wxSW_3DSASH)
        {
            if (edge == wxSASH_LEFT)
            {
                // Draw a dark grey line on the left to indicate that the
                // sash is raised
                dc.SetPen(mediumShadowPen);
                dc.DrawLine(GetEdgeMargin(edge), 0, GetEdgeMargin(edge), h);
            }
            else
            {
                // Draw a highlight line on the right to indicate that the
                // sash is raised
                dc.SetPen(hilightPen);
                dc.DrawLine(w - GetEdgeMargin(edge), 0, w - GetEdgeMargin(edge), h);
            }
        }
    }
    else // top or bottom
    {
        int sashPosition = (edge == wxSASH_TOP) ? 0 : ( h - GetEdgeMargin(edge) );

        dc.SetPen(facePen);
        dc.SetBrush(faceBrush);
        dc.DrawRectangle(0, sashPosition, w, GetEdgeMargin(edge));

        if (GetWindowStyleFlag() & wxSW_3DSASH)
        {
            if (edge == wxSASH_BOTTOM)
            {
                // Draw a highlight line on the bottom to indicate that the
                // sash is raised
                dc.SetPen(hilightPen);
                dc.DrawLine(0, h - GetEdgeMargin(edge), w, h - GetEdgeMargin(edge));
            }
            else
            {
                // Draw a drak grey line on the top to indicate that the
                // sash is raised
                dc.SetPen(mediumShadowPen);
                dc.DrawLine(1, GetEdgeMargin(edge), w-1, GetEdgeMargin(edge));
            }
        }
    }

    dc.SetPen(wxNullPen);
    dc.SetBrush(wxNullBrush);
}
コード例 #30
0
//-----------------------------------------------------------------------------
void vktraceviewer_QTimelineView::paint(QPainter *painter, QPaintEvent *event)
{
    m_threadHeight = event->rect().height();
    if (m_threadIdList.count() > 0)
    {
        m_threadHeight /= m_threadIdList.count();
    }

    int arrowHeight = 12;
    int arrowTop = 2;
    int arrowHalfWidth = 4;

    QPolygon triangle(3);
    triangle.setPoint(0, 0, arrowTop);
    triangle.setPoint(1, -arrowHalfWidth, arrowTop+arrowHeight);
    triangle.setPoint(2, arrowHalfWidth, arrowTop+arrowHeight);

    QList<uint32_t> threadList = getModelThreadList();

    calculateRectsIfNecessary();

    if (m_pPixmap == NULL)
    {
        int pixmapHeight = event->rect().height();
        int pixmapWidth = event->rect().width();

        m_pPixmap = new QPixmap(pixmapWidth, pixmapHeight);

        for (int t = 0; t < m_threadIdList.size(); t++)
        {
            m_threadMask[m_threadIdList[t]] = QVector<int>(pixmapWidth, 0);
        }

        QPainter pixmapPainter(m_pPixmap);

        // fill entire background with background color
        pixmapPainter.fillRect(event->rect(), m_background);
        drawBaseTimelines(&pixmapPainter, event->rect(), threadList);

        if (model() != NULL)
        {
            int numRows = model()->rowCount();

            for (int r = 0; r < numRows; r++)
            {
                QModelIndex index = model()->index(r, vktraceviewer_QTraceFileModel::Column_EntrypointName);

                drawTimelineItem(&pixmapPainter, index);
            }
        }
    }
    painter->drawPixmap(event->rect(), *m_pPixmap, m_pPixmap->rect());

    if (model() == NULL)
    {
        return;
    }

    // draw current api call marker
    int currentIndexRow = currentIndex().row();
    if (currentIndexRow >= 0)
    {
        // Overlay a black rectangle around the current item.
        // For more information on how rects are drawn as outlines,
        // see here: http://qt-project.org/doc/qt-4.8/qrectf.html#rendering
        int penWidth = 2;
        int penWidthHalf = 1;
        QPen blackPen(Qt::black);
        blackPen.setWidth(penWidth);
        blackPen.setJoinStyle(Qt::MiterJoin);
        painter->setPen(blackPen);

        // Don't fill the rectangle
        painter->setBrush(Qt::NoBrush);

        QModelIndex index = model()->index(currentIndexRow, vktraceviewer_QTraceFileModel::Column_EntrypointName);
        QRectF rect = visualRect(index);
        rect.adjust(-penWidthHalf, -penWidthHalf, penWidthHalf, penWidthHalf);
        painter->drawRect(rect);

        // Draw marker underneath the current rect
        painter->save();
        QPainter::RenderHints hints = painter->renderHints();
        painter->setRenderHints(QPainter::Antialiasing);
        painter->setPen(m_trianglePen);
        painter->setBrush(QColor(Qt::yellow));
        painter->translate(rect.center().x(), rect.bottom());
        painter->drawPolygon(triangle);
        painter->setRenderHints(hints, false);
        painter->restore();
    }
}