void WTextSourceViewerLine::mousePressEvent ( QMouseEvent * e )
{
  QRectF lineRect;
  QPoint pos=e->pos();
  if (e->button() != Qt::LeftButton)
     return;
  pos.setY(pos.y()+translation_y);
  int i;
  QBitArray hidden_lines;
  hidden_lines.resize(number_of_lines);
  for (i=0;i<number_of_lines;i++) hidden_lines[i]=true;
  int current_line=-1;
  int block_end=-1;
  int block_start=-1;
  bool hide_current_line=true;
  bool found=false;
  for (QTextBlock textBlock=text_document_p->begin();
      textBlock!=text_document_p->end();
      textBlock=textBlock.next())
  {
    TextSourceInstrumentationData *instrumentationData=dynamic_cast<TextSourceInstrumentationData*> (textBlock.userData());
    if (instrumentationData)
    {
      lineRect=text_document_p->documentLayout()->blockBoundingRect(textBlock);
      QRectF hitRect(0,lineRect.y(),width(),lineRect.height());
      hidden_lines[instrumentationData->current_line-1]=false;
      if (hitRect.contains(pos))
      {
        current_line = instrumentationData->current_line;
        hide_current_line = (instrumentationData->instrumentations.isEmpty()) ;
        if (hide_current_line)
          found=true;
      }
      if (instrumentationData->instrumentations.isEmpty()) 
      {
        block_end=instrumentationData->current_line;
        if (block_start==-1)
          block_start=instrumentationData->current_line;
      }
      else
      {
        if (!hide_current_line)
          found=false;
        if (found)
        {
          found=false;
          for (i=block_start-1;i<=block_end-1;i++)
            hidden_lines[i]=hide_current_line;
        }
        block_end=-1;
        block_start=-1;
      }
    }
  }
  if (found)
  {
    found=false;
    for (i=block_start-1;i<=block_end-1;i++)
      hidden_lines[i]=hide_current_line;
  }
  if (current_line<0)
  {
    e->accept();
    return;
  }
  
  int scroll_to_line=current_line;
  if (!hide_current_line)
  {
    int i;
    for (i=current_line;i<number_of_lines && hidden_lines[i];i++)
      hidden_lines[i]=false;
    for (i=current_line-2;i>=0 && hidden_lines[i];i--)
      hidden_lines[i]=false;
  }
  else
  {
    for (int i=current_line;i<number_of_lines && hidden_lines[i];i++)
       scroll_to_line=i+2;
  }

  emit hideLines(scroll_to_line,hidden_lines);
  e->accept();
}
Пример #2
0
void CLogGraph::OnLButtonDown(UINT nFlags, CPoint point)
{
	CMenu menu;

	
	
	if (hitRect(point, m_rectHome)) {
		m_nCurrentPos = 0; 
		redraw();
		setNavMode(true);
	}
	else if (hitRect(point, m_rectPgUp)) {
		if (m_nCurrentPos - getWndQueLength() < 0) 
			m_nCurrentPos = 0;
		else 
			m_nCurrentPos -= getWndQueLength();

		redraw();
		setNavMode(true);
	}
	else if (hitRect(point, m_rectPgDn)) {
		int mqlast = getLast();
		if (m_nCurrentPos + getWndQueLength() >= mqlast) {
			m_nCurrentPos = mqlast - getWndQueLength();
			if (m_nCurrentPos < 0)
				m_nCurrentPos = 0;
		}
		else
			m_nCurrentPos += getWndQueLength();
		redraw();
		setNavMode(true);
	}
	else if (hitRect(point, m_rectEnd)) {
		m_nCurrentPos = getLast() - getWndQueLength();
		if (m_nCurrentPos < 0)
			m_nCurrentPos = 0;
		redraw();
		setNavMode(false);
		sendMsg(LG_NAV_END);
	}
	else if (hitRect(point, m_rectZoom)) {
		if (!menu.CreatePopupMenu())
			return;
		menu.AppendMenu(MF_STRING, 1, "Zoom Fit");
		menu.AppendMenu(MF_SEPARATOR);
		menu.AppendMenu(MF_STRING, 2, "Zoom 1:1");
		menu.AppendMenu(MF_STRING, 3, "Zoom 2:1");
		menu.AppendMenu(MF_STRING, 4, "Zoom 4:1");
		menu.AppendMenu(MF_STRING, 5, "Zoom 10:1");
		menu.AppendMenu(MF_STRING, 6, "Zoom 60:1");
		menu.AppendMenu(MF_STRING, 7, "Zoom 3600:1");
		ClientToScreen(&point);
		int n = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, point.x, point.y, this);

		menu.DestroyMenu();
		switch (n) {
			case 2: setZoom(1.0); redraw(); break;
			case 3: setZoom(2.0); redraw(); break;
			case 4: setZoom(4.0); redraw(); break;
			case 5: setZoom(10.0); redraw(); break;
			case 6: setZoom(60.0); redraw(); break;
			case 7: setZoom(3600.0); redraw(); break;
			case 1: setZoomFit(); redraw(); break;
				break;
		}
	//	if (!m_bNav)
	//		goLast();
//		setNavMode();
	}
	else if (hitRect(point, m_rectHeader)) {
		TRACE("header click\n");
	}
	else if (hitRect(point, m_rectScale)) {
		TRACE("scale click\n");
	}else {
		m_bLdown = true;
		m_ptStMouse = point;
	}

//	TRACE("%s : cpos %d\n", __FUNCTION__, m_nCurrentPos);
	CWnd::OnLButtonDown(nFlags, point);
}
Пример #3
0
void CLogGraph::OnRButtonDown(UINT nCode, CPoint point)
{
	if (hitRect(point, m_rectGraph)) {
	
//		Channel* pCh;
		CMenu menu;
	
		if (!menu.CreatePopupMenu())
			return;
		
		/*
		menu.AppendMenu(MF_STRING, 3, "Mark Begin");
		menu.AppendMenu(MF_STRING, 4, "Mark End");
		menu.AppendMenu(MF_STRING, 5, "Mark Clear");
		*/
		menu.AppendMenu(MF_STRING, 3, "Lower/Upper Limit");
		menu.AppendMenu(MF_SEPARATOR);
		menu.AppendMenu(MF_STRING, 4, "Copy Graph");
		
// 		for (int i = 0; i < (int)m_aChannels.size(); i++) {
// 			pCh = m_aChannels[i];
// 			if (!pCh->show) 
// 				menu.AppendMenu(MF_STRING | MF_UNCHECKED, 100+i, pCh->name);
// 			else
// 				menu.AppendMenu(MF_STRING | MF_CHECKED, 100+i, pCh->name);
// 		}

		ClientToScreen(&point);
		int n = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, point.x, point.y, this);

		switch (n) {
			case 3:
				{
					if (m_nScaleIndex >= 0 && m_nScaleIndex < (int)m_aChannels.size()) {
						CDialogRange dlg;
						dlg.getValue(this, m_aChannels[m_nScaleIndex]->high, m_aChannels[m_nScaleIndex]->low);
						for (int i = 0; i<(int)m_aChannels.size(); i++){
							m_aChannels[i]->high = m_aChannels[m_nScaleIndex]->high;
							m_aChannels[i]->low = m_aChannels[m_nScaleIndex]->low;
						}

						if (m_nID == 1) //volt graph
						{
							config->g_fMaxTemp =  m_aChannels[m_nScaleIndex]->high;
							config->g_fMinTemp =  m_aChannels[m_nScaleIndex]->low;
							redraw();
						}
//						config->saveConfig();
					}
				}
				break;
			case 4:
				CopyToClipboard();
				break;
			default:
						
				{
					UINT state = menu.GetMenuState(n, MF_BYCOMMAND);
//					TRACE("%d -> %04x [%04x]\n", n-100, state, MF_CHECKED);
					if (state & MF_CHECKED) 
					{
						hide(n-100);
						::PostMessage(m_hWnd, LG_CH_SHOW, (DWORD)(n-100), 0);
					}else
					{
						show(n-100);
						::PostMessage(m_hWnd, LG_CH_SHOW, (DWORD)(n-100), 1);
					}
					redraw();
				}
			}
		menu.DestroyMenu();
	}
	CWnd::OnRButtonDown(nCode, point);
}
Пример #4
0
void CLogGraph::OnMouseMove(UINT nFlags, CPoint point)
{
	if (hitRect(point, m_rectGraph) && m_bNav) {
		CDC* pDC = GetDC();
		if (pDC) {
			int oldRop = pDC->GetROP2();
			pDC->SetROP2(R2_XORPEN);

			CPen pen(PS_DOT, 1, RGB(255, 255, 255));
			CPen* pOldPen = pDC->SelectObject(&pen);

			if (m_nLastCursorPos != -1) {
				pDC->MoveTo(m_rectGraph.left + m_nLastCursorPos, m_rectGraph.top);
				pDC->LineTo(m_rectGraph.left + m_nLastCursorPos, m_rectGraph.bottom);
			}

			m_nLastCursorPos = (point.x - m_rectGraph.left);
			pDC->MoveTo(m_rectGraph.left + m_nLastCursorPos, m_rectGraph.top);
			pDC->LineTo(m_rectGraph.left + m_nLastCursorPos, m_rectGraph.bottom);
			pDC->SelectObject(pOldPen);
			pDC->SetROP2(oldRop);

			if (m_bNav) {
				int pos = m_nCurrentPos + int(m_fZoomFactor * m_nLastCursorPos);
//				lib->mque_getn(m_hQue, pos, m_aTmp);
//				calcStat(m_aTmp, false);
				sendMsg(LG_NAV_MSG, pos);
				m_tLastNav = time(NULL);
			}
			ReleaseDC(pDC);
		}
	}

	if (m_bLdown)
	{
		m_bDragSel = true;
		m_ptEtMouse = point;
		redraw();
	}

	if (m_bLoad){
		tdata *tp = getTptr(m_nCurrentPos); //getPtrLeftPos();

		int x = point.x - m_rectGraph.left;	
		if (x < 0) goto NOMATCH;
		int last = getLength(); 
		int pos = m_nCurrentPos + point.x * (int)m_fZoomFactor - m_rectGraph.left;
		if (pos > last){
			goto NOMATCH;		
		}

		tp = tp+ x*((int)m_fZoomFactor);


		Channel* pCh = m_aChannels[0];
		int ey = m_rectGraph.top + m_rectGraph.Height();
		int ry = ey - int(pCh->C * (int(tp->temp) / pCh->scale - pCh->low));

	//	TRACE("%s %d\n", __FUNCTION__ , tp->temp);
	
		CString strTemp;
		CString stime = tformat("%Y-%m-%d %H:%M:%S", tp->time);
		strTemp.Format("%s\t  %d℃",stime, tp->temp/100 );
		//        strTemp.Format("%5ld",lUnitSize);
		m_ctrTooltip.Activate(TRUE);
		m_ctrTooltip.AddTool(this,strTemp, CRect(point.x-1,point.y-1,point.x+1,point.y+1), TRUE);    // skin[i].rc    각 버튼들의 Rect...
		m_ctrTooltip.Update();
	}
NOMATCH:	
//	TRACE("%s : cpos %d\n", __FUNCTION__, m_nCurrentPos);
	CWnd::OnMouseMove(nFlags, point);
}