Example #1
0
void PlayerControls::tick(QTime pos, QTime len)
{
    QTime length(0,0);
    QTime curpos(0,0);

    length = len;
    curpos = pos;

    m_wlCurTime->setText(curpos.toString("m:ss"));
    m_wlTotTime->setText(length.toString("mm:ss"));

    if(m_bTickSlider) {
        if (length != QTime(0,0)) {
            int curVal = curpos.msecsTo(QTime()) * 1000 / length.msecsTo(QTime());
            m_wSeekSlider->setValue(curVal);
            if(curVal < 999)
                curVal+=1;
        } else {
            m_wSeekSlider->setValue(0);
        }
    }

//    if (curpos != QTime(0,0)) {
//        m_positionLabel->setEnabled(true);
//        m_positionSlider->setEnabled(true);
//    }
}
Example #2
0
/* Called when the positionChanged() is received from the player */
void MediaApp::onPositionChanged()
{
    QTime length(0,0);
    QTime curpos(0,0);

    if (m_player->state() != QGst::StateReady &&
        m_player->state() != QGst::StateNull)
    {
        length = m_player->length();
        curpos = m_player->position();
    }

    m_positionLabel->setText(curpos.toString("hh:mm:ss.zzz")
                                        + "/" +
                             length.toString("hh:mm:ss.zzz"));

    if (length != QTime(0,0)) {
        m_positionSlider->setValue(curpos.msecsTo(QTime(0,0)) * 1000 / length.msecsTo(QTime(0,0)));
    } else {
        m_positionSlider->setValue(0);
    }

    if (curpos != QTime(0,0)) {
        m_positionLabel->setEnabled(true);
        m_positionSlider->setEnabled(true);
    }
}
Example #3
0
int main ()
{
  n = getN ();

  for (int i = 0; i <= n; i++)
    state[i] = 2;

  int code = curpos ();
  while (code < 0)
  {
    int mr = 1000000;
    int mi;
    for (int a = 0; a <= 60; a++)
    {
      int c = eval (a);
      if (c < mr) mr = c, mi = a;
    }
    int x = query (mi + 1);
    emulate (mi, x);
    memcpy (state, state2, sizeof state);
    code = curpos ();
  }
  answer (code + 1);
                    /*
  while (l < r)
  {
    int k = (l + r) / 2;
    int a = query (k + 1);
    if (!lied)
    {
      int a2 = query (k + 1);
      if (a != a2)
      {
        a = query (k + 1);
        lied = true;
      }
    }
    if (a == 1)
      r = k;
    else
      l = k + 1;
  }
  answer (l + 1);    */

  return 0;
}
Example #4
0
bool CMapObject::CalculateEnemyPath(int* ObjectMap, int* DirectionMap)
{
	int* TraceMap = new int[data->Width*data->Height];
	memset(TraceMap, 0, (data->Width)*(data->Height)*sizeof(int));
	TraceMap[data->DestinationPosition.y*data->Width+data->DestinationPosition.x] = 1;

	
	

	LogicPosition* Queue = new LogicPosition[(data->Width)*(data->Height)];	//allocate queue
	int cur = 0;	//current index of queue
	int last = 0;	//last index of queue
	Queue[0] = data->DestinationPosition;	//add destination to queue
	while (cur<=last)
	{
		LogicPosition curpos = Queue[cur];
		for (int i=1; i<=4; i++)
		{
			LogicPosition nextpos = curpos + OppositeMove[i];
			if (	(nextpos.x>=0) && (nextpos.x<data->Width) && (nextpos.y>=0) && (nextpos.y<data->Height) 
					&&(ObjectMap[nextpos.y*data->Width+nextpos.x]!=E_OBJ_TOWER)
					&& (ObjectMap[nextpos.y*data->Width+nextpos.x]!=E_OBJ_OBSTACLE)
					&& (TraceMap[nextpos.y*data->Width+nextpos.x]== 0))
			{
				TraceMap[nextpos.y*data->Width+nextpos.x] = TraceMap[curpos.y*data->Width+curpos.x] + 1;
				DirectionMap[nextpos.y*data->Width+nextpos.x] = i;
				Queue[++last] = nextpos;
			}
		}
		cur++;
	}

	bool isValid = true;

	for (int i=0; i<data->Width; i++)
	{
		for (int j=0; j<data->Height; j++)
		{
			LogicPosition curpos(i,j);
			if (	(curpos.x>=0) && (curpos.x<data->Width) && (curpos.y>=0) && (curpos.y<data->Height) 
					&&(ObjectMap[curpos.y*data->Width+curpos.x]!=E_OBJ_TOWER)
					&& (ObjectMap[curpos.y*data->Width+curpos.x]!=E_OBJ_OBSTACLE)
					&& (TraceMap[curpos.y*data->Width+curpos.x]==0))
			{
				isValid = false;
				break;
			}
		}
		if (!isValid) break;
	}
	SAFE_DEL(TraceMap);
	return isValid;
}
Example #5
0
void creat_main()
{
	int		ct,BID_ct;
	int		ct_id;
	int		bid_cnt;
	int		total_cnt[2];
	int		edit_cc;
	struct	BN_LIST *BN_ptr;
	unsigned char WKpath[PATHSIZE+1];

	if ( (BATCH_infof =fileopen(BATCH_INFO,"w+")) == 0)	/* DL VT ctrw -> w+ */
	{
		disperr("COULD NOT creat %s",BATCH_INFO);
		pr_exit(-1);
	}
	setmidwin();
	clrscr();

	BN_ptr= BN_list; 
	for (ct =0; BN_cnt > ct; ct++)
	{
		BID_ct= BN_ptr->bnbid_cnt;
		charfill(Pathbuf,PATHSIZE+1,NULL);
		strcatl(Pathbuf,Path_bn,"/",BN_ptr->bnptr_bn,NULL);

		bid_cnt = 0;
		total_cnt[0] = total_cnt[1] = 0;	/* total rec ccount	*/

		for( ct_id=0;BID_ct >ct_id;ct_id++)
		{
			charfill(WKpath,PATHSIZE+1,NULL);
			strcatl(WKpath,Pathbuf,"/.",BN_ptr->bnptr_bid[ct_id],NULL); /* DL VT . added */
			if ((Infile= fileopen(WKpath,"r") ) == NULL)
			{
				disperr("COULD NOT open fci_file(%s)",WKpath);
				continue;
			}
			edit_cc = edit_data(Create_sel, total_cnt);
			if (edit_cc == 1)
			{
				curpos(0,14);
				display("FILE= %s",WKpath);
				rollup();
				edit_out();
				bid_cnt++;
			}
			fileclose(Infile);
		}
		BN_ptr++;
	}
	resetwin();
	fileclose(BATCH_infof);
}
Example #6
0
void Widget_editor::Event(const ALLEGRO_EVENT &event)
{
	if(ALLEGRO_EVENT_MOUSE_BUTTON_DOWN == event.type)
	{
		if(event.mouse.button == 1)
		{
			Rect brect = Get_bounding_rect();
			if(brect.Contains_point(event.mouse.x, event.mouse.y))
			{
				pressed = true;
				if(event.mouse.x < brect.Topleft().x+5)
				{
					pos.x = brect.Topleft().x;
					left = true;
				}
				else if(event.mouse.x > brect.Bottomright().x-5)
				{
					pos.x = brect.Bottomright().x;
					right = true;
				}
				if(event.mouse.y < brect.Topleft().y+5)
				{
					pos.y = brect.Topleft().y;
					top = true;
				}
				else if(event.mouse.y > brect.Bottomright().y-5)
				{
					pos.y = brect.Bottomright().y;
					bottom = true;
				}
				if(!(left || right || top || bottom))
				{
					move = true;
					pos = brect.Topleft();
				}
				if(!selected)
				{
					selected = true;
					Set_dirty(true);
				}
			}
			else if(selected)
			{
				selected = false;
				Set_dirty(true);
			}
		}
	}
	if(ALLEGRO_EVENT_MOUSE_BUTTON_UP == event.type)
	{
		if(event.mouse.button == 1)
		{
			pressed = false;
			left = false;
			right = false;
			top = false;
			bottom = false;
			move = false;

			Rect brect = Get_bounding_rect();
			if(selected && !brect.Contains_point(event.mouse.x, event.mouse.y))
			{
				selected = false;
				Set_dirty(true);
			}
		}
		if(event.mouse.button == 2)
		{
			Rect brect = Get_bounding_rect();
			if(brect.Contains_point(event.mouse.x, event.mouse.y))
			{
				editing_attributes = true;
				attribute_group->Move_to(event.mouse.x, event.mouse.y);
				for(Attribute_groups::iterator i = attribute_groups.begin(); i != attribute_groups.end(); ++i)
				{
					(*i)->Move_to(event.mouse.x, event.mouse.y+attributes_height);
				}
				w_top.Set_value(brect.Topleft().y);
				w_left.Set_value(brect.Topleft().x);
				w_width.Set_value(brect.Size().x);
				w_height.Set_value(brect.Size().y);
			}
		}
	}
	if(ALLEGRO_EVENT_MOUSE_AXES == event.type)
	{
		if(pressed)
		{
			pos += Vector2(event.mouse.dx, event.mouse.dy);
			Vector2 curpos(pos);
			ALLEGRO_KEYBOARD_STATE keyboard_state;
			al_get_keyboard_state(&keyboard_state);
			if(al_key_down(&keyboard_state, ALLEGRO_KEY_LCTRL))
			{
				curpos.x = int(pos.x/10)*10;
				curpos.y = int(pos.y/10)*10;
			}
			if(move)
			{
				Rect n = widget->Get_bounding_rect();
				n.Move_to(curpos.x, curpos.y);
				widget->Set_bounding_rect(n);
				Set_bounding_rect(n);
			}

			Vector2 topleft = Get_bounding_rect().Topleft();
			Vector2 bottomright = Get_bounding_rect().Bottomright();
			if(left && curpos.x < bottomright.x-15)
				topleft.x = curpos.x;
			if(right && curpos.x > topleft.x+15)
				bottomright.x = curpos.x;
			if(top && curpos.y < bottomright.y-15)
				topleft.y = curpos.y;
			if(bottom && curpos.y > topleft.y+15)
				bottomright.y = curpos.y;
			
			Rect n(topleft, bottomright);
			widget->Set_bounding_rect(n);
			Set_bounding_rect(n);

			w_top.Set_value(n.Topleft().y);
			w_left.Set_value(n.Topleft().x);
			w_width.Set_value(n.Size().x);
			w_height.Set_value(n.Size().y);

			Set_dirty(true);
		}
	}
	if (ALLEGRO_EVENT_KEY_DOWN == event.type)
	{
		if (ALLEGRO_KEY_ESCAPE == event.keyboard.keycode)
		{
			editing_attributes = false;
		}
	}
	if(editing_attributes)
	{
		attribute_group->Event(event);
		float top = w_top.Get_value();
		float left = w_left.Get_value();
		float width = w_width.Get_value();
		float height = w_height.Get_value();
		Rect n(left, top, width, height);
		widget->Set_bounding_rect(n);
		Set_bounding_rect(n);
		
		for(Attribute_groups::iterator i = attribute_groups.begin(); i != attribute_groups.end(); ++i)
		{
			(*i)->Set_widget(widget);
			(*i)->Event(event);
		}
	}
}
Example #7
0
void CPredView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
	// TODO: Add your specialized code here and/or call the base class
	int i,j;
	CFCCDoc* pDoc=(CFCCDoc*)GetDocument();
	CCompound* pCompound;
	CString tmpstr;
	int nHeight=pDC->GetTextExtent("ID").cy;
	POSITION pos=pDoc->list_CompoundTest.GetHeadPosition();
	CPoint curpos(pInfo->m_rectDraw.left,pInfo->m_rectDraw.top);
	//int LeftMargin=(pInfo->m_rectDraw.Width()-(printWidthName+printWidthID+printWidthClass+printWidthValue+printFieldMargin*3+printColMargin)
	//	*printCol)/2;
	int LeftMargin=0;
	int pagenum=1;
	//pDC->StartDocA("FCC Printing Job");
	while(pos)
	{
		pDC->StartPage();
		pDoc->strMessage.Format("Printing page No. %d ....",pagenum++);
		pDoc->MessageCenter(IDS_MESSAGE_CUSTOM);
		for(i=0;i<printCol && pos;i++)
		{
			curpos.x=LeftMargin+pInfo->m_rectDraw.left+(printWidthName+printWidthID+printWidthClass+printWidthValue+printFieldMargin*3+printColMargin)*i;
			pDC->TextOutA(curpos.x,curpos.y,"ID");
			curpos.x+=printWidthID+printFieldMargin;
			pDC->TextOutA(curpos.x,curpos.y,"Compound Name");
			curpos.x+=printWidthName+printFieldMargin;
			pDC->TextOutA(curpos.x,curpos.y,"Prediction");
			curpos.x+=printWidthClass+printFieldMargin;
			pDC->TextOutA(curpos.x,curpos.y,"Raw Value");
			curpos.x+=printWidthValue+printFieldMargin;
			curpos.x=LeftMargin+pInfo->m_rectDraw.left+(printWidthName+printWidthID+printWidthClass+printWidthValue+printFieldMargin*3+printColMargin)*i;
			curpos.y=curpos.y-printRowMargin-nHeight;
			for(j=1;j<printRow && pos;j++)
			{
				pCompound=(CCompound*)pDoc->list_CompoundTest.GetNext(pos);
				tmpstr.Format("%d",pCompound->id);
				pDC->TextOutA(curpos.x,curpos.y,tmpstr);
				curpos.x+=printWidthID+printFieldMargin;
				pDC->TextOutA(curpos.x,curpos.y,pCompound->strCompoundName);
				curpos.x+=printWidthName+printFieldMargin;
				if(pCompound->yhat>abs(pDoc->fRejectBoundary))
					pDC->TextOutA(curpos.x,curpos.y,pDoc->strPositiveSet);
				if(pCompound->yhat<abs(pDoc->fRejectBoundary)*(-1))
					pDC->TextOutA(curpos.x,curpos.y,pDoc->strNegativeSet);
				if(pCompound->yhat>=abs(pDoc->fRejectBoundary)*(-1) && pCompound->yhat<=abs(pDoc->fRejectBoundary))
					pDC->TextOutA(curpos.x,curpos.y,"Unknown");
				curpos.x+=printWidthClass+printFieldMargin;
				tmpstr.Format("%.3f",pCompound->yhat);
				pDC->TextOutA(curpos.x,curpos.y,tmpstr);
				curpos.x=LeftMargin+pInfo->m_rectDraw.left+(printWidthName+printWidthID+printWidthClass+printWidthValue+printFieldMargin*3+printColMargin)*i;
				curpos.y=curpos.y-printRowMargin-nHeight;
			}
			curpos.y=pInfo->m_rectDraw.top;
		}
		pDC->EndPage();
		TRACE("Ending page\n");
	}
	//pDC->EndDoc();
	//CScrollView::OnPrint(pDC, pInfo);
}