Пример #1
0
/* 
 * Single-threaded application that interleaves client servicing with taking
 * pictures from the camera.  This way, we do not update the framebuffer
 * while an encoding is working on it too (banding, and image artifacts).
 */
int main(int argc,char** argv)
{                                       
  long usec;
  
  rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,WIDTH,HEIGHT,8,3,BPP);
  if(!server)
    return 0;
  server->desktopName = "Live Video Feed Example";
  server->frameBuffer=(char*)malloc(WIDTH*HEIGHT*BPP);
  server->alwaysShared=(1==1);

  /* Initialize the server */
  rfbInitServer(server);           

  /* Loop, processing clients and taking pictures */
  while (rfbIsActive(server)) {
    if (TimeToTakePicture())
      if (TakePicture((unsigned char *)server->frameBuffer))
        rfbMarkRectAsModified(server,0,0,WIDTH,HEIGHT);
          
    usec = server->deferUpdateTime*1000;
    rfbProcessEvents(server,usec);
  }
  return(0);
}
Пример #2
0
void SectionViewWidget::SetSection(SailSection *pSection)
{
	m_pSailSection = pSection;
	Spline::s_bChanged = false;

	m_StackPos = -1;
	m_PicStack.clear();

	TakePicture();
}
Пример #3
0
void SectionViewWidget::Initialize(QSail *pSail, SailSection *pSection)
{
	m_pSail = pSail;
	m_pSailSection = pSection;
	Spline::s_bChanged = false;

	m_StackPos = -1;
	m_PicStack.clear();

	TakePicture();

	OnResetScale();
}
Пример #4
0
void SectionViewWidget::OnRemoveCtrlPt()
{
	//Removes a point in the spline
	if(!m_pSail->IsNURBSSail()) return;
	if(!m_pSailSection || !m_pSailSection->IsNURBSSection()) return;
	SailDlg *pSailDlg = (SailDlg*)m_pSailDlg;

	CVector Real = MousetoReal(m_PointDown);

	int n =  m_pSailSection->IsPoint(Real, m_Scale/m_RefScale);
	if (n>=0)
	{

		for(int ifr=0; ifr<m_pSail->m_oaSection.size(); ifr++)
		{
			SailSection *pSailSection = m_pSail->m_oaSection.at(ifr);
			pSailSection->RemovePoint(n);
		}
	}

	//Check the degree
	NURBSSail *pNSail = (NURBSSail*)m_pSail;

	if(pNSail->m_SplineSurface.m_ivDegree >= m_pSailSection->m_CtrlPoint.size())
	{
		//reduce the degree
		pNSail->m_SplineSurface.m_ivDegree = m_pSailSection->m_CtrlPoint.size()-1;
		pSailDlg->m_pctrlNXDegree->SetValue(pNSail->m_SplineSurface.m_ivDegree);
		m_pSail->SplineSurface();
		QString strong = tr("The degree has been reduced to be less than the number of points");
		QMessageBox::warning(window(), tr("Warning"), strong);
	}
	else
	{
		m_pSail->SplineSurface();
	}

	TakePicture();
	pSailDlg->FillPointTable();
}
Пример #5
0
void SectionViewWidget::OnInsertCtrlPt()
{
	//Inserts a point in all sections, to keep the same number of points in each
	if(!m_pSail->IsNURBSSail()) return;
	if(!m_pSailSection || !m_pSailSection->IsNURBSSection()) return;

	CVector Real = MousetoReal(m_PointDown);

	int pos = m_pSailSection->InsertPoint(Real, 1);
	for(int ifr=0; ifr<m_pSail->m_oaSection.size(); ifr++)
	{
		SailSection *pSailSection = m_pSail->m_oaSection.at(ifr);
		if(pSailSection != m_pSailSection) pSailSection->InsertPoint(pos);
	}

	m_pSail->SplineSurface();

	TakePicture();

	SailDlg *pSailDlg = (SailDlg*)m_pSailDlg;
	pSailDlg->FillPointTable();
	pSailDlg->UpdateView();
}
Пример #6
0
void SectionViewWidget::mouseReleaseEvent(QMouseEvent *event)
{
	m_bTrans = false;
	QPoint point = event->pos();
	QRect CltRect = rect();
	if(m_bZoomIn && CltRect.contains(point))
	{
		m_ZoomRect.setBottomRight(point);
		QRect ZRect = m_ZoomRect.normalized();

		if(!ZRect.isEmpty())
		{
			m_ZoomRect = ZRect;

			double ZoomFactor = qMin((double)CltRect.width()  / (double)m_ZoomRect.width() ,
									 (double)CltRect.height() / (double)m_ZoomRect.height());

			double newScale = qMin(ZoomFactor*m_Scale, 32.0*m_RefScale);

			ZoomFactor = qMin(ZoomFactor, newScale/m_Scale);

			m_Scale = ZoomFactor*m_Scale;
			int a = (int)((CltRect.right() + CltRect.left())/2);
			int b = (int)((CltRect.top()   + CltRect.bottom())/2);

			int aZoom = (int)((m_ZoomRect.right() + m_ZoomRect.left())/2);
			int bZoom = (int)((m_ZoomRect.top()   + m_ZoomRect.bottom())/2);

			//translate view
			m_ptOffset.rx() += (a - aZoom);
			m_ptOffset.ry() += (b - bZoom);
			//scale view
			m_ptOffset.rx() = (int)(ZoomFactor * (m_ptOffset.x()-a)+a);
			m_ptOffset.ry() = (int)(ZoomFactor * (m_ptOffset.y()-b)+b);

//			m_ZoomRect.setBottomRight(m_ZoomRect.topLeft());
			m_ZoomRect.setRight(m_ZoomRect.left()-1);
		}
		else
		{
			m_ZoomRect.setBottomRight(m_ZoomRect.topLeft());
			ReleaseZoom();
		}
	}
	else if(m_bZoomIn && !CltRect.contains(point))
	{
		ReleaseZoom();
	}
	else
	{
		//The user has finished dragging something
		if (m_pSailSection->m_iSelect>=0) TakePicture();

		SailDlg *pSailDlg = (SailDlg*)m_pSailDlg;
		pSailDlg->FillPointTable();
		m_pSail->SplineSurface();
		pSailDlg->UpdateSailView();
	}

	setCursor(m_hcCross);

	UpdateView();
}