当前位置: 首页>>代码示例>>C++>>正文


C++ Duration::minutes方法代码示例

本文整理汇总了C++中Duration::minutes方法的典型用法代码示例。如果您正苦于以下问题:C++ Duration::minutes方法的具体用法?C++ Duration::minutes怎么用?C++ Duration::minutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Duration的用法示例。


在下文中一共展示了Duration::minutes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: advance

void MainWindow::advance()
{
	if( momit == simCompsPtr->moments.end() )
		return;

	if( aktCzas >= momit->first )
	{
		for( unsigned int i = 0; i < train_vector.size(); i++ )
		{
			for( unsigned int j = 0; j < momit->second.size(); j++ )
			{
				if( train_vector[i]->train == simCompsPtr->map.getTrain(momit->second[j].trainID) )
				{
					disconnect(train_vector[i]->timer, SIGNAL(timeout()), train_vector[i], SLOT(move()));

					if( simCompsPtr->map.getBlock(momit->second[j].worldBlockID)->whatIsIt() == WorldBlock::TRACK )
					{
						if( train_vector[i]->route->getSections()[train_vector[i]->index].getBlock().whatIsIt() == WorldBlock::STATION )
						{
							QStation *curr_station;
							for( int k = 0; k < station_vector.size(); k++ )
								if( station_vector[k]->block == simCompsPtr->map.getBlock(
									train_vector[i]->route->getSections()[train_vector[i]->index].getBlock().getStation().getID() ) )
								{
									curr_station = station_vector[k];
									break;
								}
							curr_station->noOfTrains--;
						}

						train_vector[i]->index ++;
						train_vector[i]->next_index ++;
						int railNo = momit->second[j].railNo;
						QTrack *curr_track;
						for( unsigned int k = 0; k < track_vector.size(); k++ )
							if( track_vector[k]->block == simCompsPtr->map.getBlock(momit->second[j].worldBlockID ))
							{
								curr_track = track_vector[k];
								break;
							}
						train_vector[i]->change = &( momit->second[j] );
						train_vector[i]->track = curr_track;

						QPointF wb( 0, 0 );
						if( train_vector[i]->route->getSections()[train_vector[i]->index-1].getBlock().whatIsIt() == WorldBlock::STATION )
						{
							wb.setX( train_vector[i]->route->getSections()[train_vector[i]->index-1].getBlock().getStation().getPosX() );
							wb.setY( train_vector[i]->route->getSections()[train_vector[i]->index-1].getBlock().getStation().getPosY() );
						}
						if( train_vector[i]->route->getSections()[train_vector[i]->index-1].getBlock().whatIsIt() == WorldBlock::JUNCT )
						{
							wb.setX( train_vector[i]->route->getSections()[train_vector[i]->index-1].getBlock().getJunction().getPosX() );
							wb.setY( train_vector[i]->route->getSections()[train_vector[i]->index-1].getBlock().getJunction().getPosY() );
						}

						QLineF line1( wb, curr_track->start_points[railNo - 1] );
						QLineF line2( wb, curr_track->end_points[railNo - 1] );
						QLineF start_line( 0, 0, 0, 0 );
						if( line1.length() < line2.length() )
							start_line = line1;
						else
							start_line = line2;
						train_vector[i]->setPos( start_line.x2() - train_vector[i]->a/2, start_line.y2() - train_vector[i]->a/2 );

						Duration time = momit->second[j].end - momit->second[j].begin;
						train_vector[i]->move_duration = 0;
						double one = 1;
						train_vector[i]->move_part = one / ( time.hours()*60 + time.minutes() );
						connect(train_vector[i]->timer, SIGNAL(timeout()), train_vector[i], SLOT(move()));
						train_vector[i]->timer->start(time_skip);
					}
					if( simCompsPtr->map.getBlock(momit->second[j].worldBlockID)->whatIsIt() == WorldBlock::STATION )
					{
						if( train_vector[i]->index == -1 )
							scene->addItem( train_vector[i] );

						train_vector[i]->index ++;
						train_vector[i]->next_index ++;

						if( train_vector[i]->route->getSections().size() == train_vector[i]->next_index + 1 )
							scene->removeItem( train_vector[i] );

						train_vector[i]->setPos( simCompsPtr->map.getBlock(momit->second[j].worldBlockID)->getStation().getPosX() - train_vector[i]->a/2 ,
												simCompsPtr->map.getBlock(momit->second[j].worldBlockID)->getStation().getPosY() - train_vector[i]->a/2 );

						QStation *curr_station;
						for( int k = 0; k < station_vector.size(); k++ )
							if( station_vector[k]->block == simCompsPtr->map.getBlock(momit->second[j].worldBlockID ) )
							{
								curr_station = station_vector[k];
								break;
							}
							curr_station->noOfTrains++;
					}
					if( simCompsPtr->map.getBlock(momit->second[j].worldBlockID)->whatIsIt() == WorldBlock::JUNCT )
					{
						if( train_vector[i]->index == -1 )
							scene->addItem( train_vector[i] );

						train_vector[i]->index ++;
//.........这里部分代码省略.........
开发者ID:rideofyourlife,项目名称:TrainSim,代码行数:101,代码来源:mainwindow.cpp


注:本文中的Duration::minutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。