コード例 #1
0
ファイル: route.cpp プロジェクト: caribe/Fado-Sound-Suite
Route::Route(QWidget *parent, Core *core) : QSplitter(parent)
{
	this->core = core;

	// Machine tree

	QTreeView *routeTree = new QTreeView(this);
	routeTree->setModel(core->gearsTree);
	routeTree->model()->setHeaderData(0, Qt::Horizontal, tr("Machines"));
	connect(routeTree, SIGNAL(doubleClicked(QModelIndex)), SLOT(newMachine(QModelIndex)));

	// Editor

	routeScene = new QGraphicsScene(this);
	routeScene->setSceneRect(0, 0, 1440, 768);

	routeEditor = new QGraphicsView(routeScene, this);
	routeEditor->setRenderHints(QPainter::Antialiasing);
	routeEditor->centerOn(0, 0);

	extraline = new QGraphicsPathItem();
	extraline->hide();
	routeScene->addItem(extraline);

	// Layout

	addWidget(routeTree);
	addWidget(routeEditor);

	setStretchFactor(1, 1);

}
コード例 #2
0
void Unit::BuildTractorAxles() {
  std::shared_ptr<Machine> newMachine(new CombustionEngine(unitIndex, machineGenes, bufferInUnit,0));
  for(int i=0;i<numberOfAxles;i++) {
    std::shared_ptr<Axle> newAxle;
    int axleIndex = i;
    int axlePropulsionFlag = axleGenes[i];
    if(axlePropulsionFlag==1) {
      newAxle.reset(new Axle(axleIndex, axlePropulsionFlag, newMachine));
      //std::cout<<"Axle number "<<newAxle->GetAxleIndex()<<" created with machine "<<
                                //newAxle->ReturnMachineForAxle()->ReturnMachineName()<<std::endl;
    } else {
      newAxle.reset(new Axle(axleIndex, axlePropulsionFlag, nullptr));
      //std::cout<<"Axle number "<<newAxle->GetAxleIndex()<<" created with no machine. Non-propelled axle."<<std::endl;
    }
    axlesInUnit.push_back(newAxle);
  }
}
コード例 #3
0
void Unit::BuildTrailerAxles() {
  for(int i=0;i<numberOfAxles;i++) {
    //std::cout<<"Trailer axle number "<<i<<" being created"<<std::endl;
    std::shared_ptr<Axle> newAxle;
    int axleIndex = i;
    int machineCount = 0;
    int axlePropulsionFlag = axleGenes[i];
    if(axlePropulsionFlag==1) {
      std::shared_ptr<Machine> newMachine(new ElectricMotor(unitIndex, machineGenes, bufferInUnit,i));
      newAxle.reset(new Axle(axleIndex, axlePropulsionFlag, newMachine));
      //std::cout<<"Axle number "<<newAxle->GetAxleIndex()<<" created with machine "<<
                                //newAxle->ReturnMachineForAxle()->ReturnMachineName()<<std::endl;
      machineCount++;
    } else {
      newAxle.reset(new Axle(axleIndex, axlePropulsionFlag, nullptr));
      //std::cout<<"Axle number "<<newAxle->GetAxleIndex()<<" created with no machine. Non-propelled axle."<<std::endl;
    }
    axlesInUnit.push_back(newAxle);
  }   
}
コード例 #4
0
ファイル: amlsfc.c プロジェクト: rsaber/amlsfc
int main(int argc, char * argv[]){
	WINDOW * win;
	initscr();
	clear();
	noecho();
	cbreak();
	curs_set(0);

	m = newMachine();
	if(argc == 2){
		loadMachine(m,argv[1]);
	}

	win = newwin(WINDOW_SIZE_HEIGHT,WINDOW_SIZE_WIDTH,2,2);
	keypad(win,TRUE);
	refresh();
	createDefaultView(win);
	updateView(win);

	char read;
	int c = 0;
	while(c!='q'){
		c = wgetch(win);
		switch(c){
			// all these if statements are just edge cases where we wrap around
			// the table
			case KEY_UP:
				if(section == SECTION_MEMORY){
					if(highlight[section] < 16) highlight[section] = 255 - (15 - highlight[section]);
					else highlight[section]-=16;
				}
				break;
			case KEY_DOWN:
				if(section == SECTION_MEMORY){
					if(highlight[section] < 256 && highlight[section] >= 240) highlight[section] = highlight[section] - 16*15;
					else highlight[section]+=16;
				}
				break;
			case KEY_LEFT:
				if(section == SECTION_MEMORY){
					if(highlight[section]%16==0) highlight[section] += 15;
					else highlight[section]--;
				}else if(section == SECTION_REGISTERS){
					if(highlight[section] == 0) highlight[section] = 15;
					else highlight[section]--;
				}
				break;
			case KEY_RIGHT:
				if(section == SECTION_MEMORY){
					if((highlight[section]-15) % 16 ==0 ) highlight[section] -= 15;
					else highlight[section]++;
				}else if(section == SECTION_REGISTERS){
					if(highlight[section] == 15) highlight[section] = 0;
					else highlight[section]++;
				}
				break;

			// tab key
			case 9:
				// toggle section
				section++;
				section = section%3;
				break;

			case 'r':
				run(m);
				break;

			case 's':
				saveMachine(m);
				break;

			case 'c':
				resetMachine(m);
				break;

			// enter key
			case 10:
				read = readInput(win);
				if(section == SECTION_MEMORY) writeMemoryAt(m, highlight[section], read);
				else if(section == SECTION_REGISTERS) writeRegistersAt(m, highlight[section], read);
				else writePC(m, read);
				break;

			case 'n':
				step(m);
				break;

			default:
				refresh();
				break;
		}
		updateView(win);
	}

	clrtoeol();
	refresh();
	endwin();
	return 0;
}