int main(void){ FILE *archive; Memory *memory; rcp_arg args; pthread_t processesCreation, frameUpdate, buttonEventsThread; bool frame_update = true, button_event = true; fu_arg frame_update_args; numberOfSpaces memory_size; insertionMode insertionModeID; archive = fileMenu(); XInitThreads(); if(!archive){ memory_size = getSize(); memory = createMemory(memory_size); args.memory = memory; insertionModeID = ask_rcp_args(&args); } else{ memory = dropSimulationFromFile(archive, &args, &insertionModeID); setInsertionMode(insertionModeID, &args); memory_size = memory->available + memory->inUse; } frame_update_args.memory = memory; frame_update_args.frame_update = &frame_update; frame_update_args.ui_params = createUI(); frame_update_args.ui_params -> byte_size = ((double)MEMORY_UI_X/(double)memory_size); frame_update_args.ui_params -> status = 1; frame_update_args.ui_params -> button_event = &button_event; frame_update_args.aux = &args; frame_update_args.insertionID = insertionModeID; pthread_mutex_init(&mutex_listModify, NULL); pthread_mutex_init(&mutex_play, NULL); pthread_cond_init(&cond_play, NULL); pthread_create(&processesCreation, NULL, randomCreateProcesses, &args); pthread_create(&frameUpdate, NULL, plotMemoryStatus, &frame_update_args); pthread_create(&buttonEventsThread, NULL, buttonEvents, &frame_update_args); pthread_join(processesCreation, NULL); while(memory->firstProcessCase); sleep(1); frame_update = false; pthread_join(frameUpdate, NULL); pthread_cond_destroy(&cond_play); pthread_mutex_destroy(&mutex_play); pthread_mutex_destroy(&mutex_listModify); pthread_exit((void *)NULL); return 0; }
GraphicsScene::GraphicsScene(QObject *parent) : QGraphicsScene(parent), m_visualMusicModel(0) { setInsertionMode(InsertionMode::DragAndDrop); setBackgroundBrush(QBrush(QColor(0xD0, 0xD0, 0xD0))); m_itemTypes << static_cast<int>(InteractingGraphicsItemType); m_itemTypes << static_cast<int>(StaffGraphicsItemType); m_itemTypes << static_cast<int>(MeasureGraphicsItemType); m_itemTypes << static_cast<int>(SymbolGraphicsItemType); m_itemTypes << static_cast<int>(SymbolGlyphItemType); }
insertionMode ask_rcp_args(rcp_arg *args){ insertionMode mode = setInsertionMode(getInsertionMode(), args); printf("\nHow many processes do you want to create? "); scanf("%u", &(args->numberOfProcesses)); printf("Enter the maximum each process size: "); scanf("%lu", &(args->maxProcessSize)); printf("Enter the maximum each process priority value: "); scanf("%u", &(args->maxPriorityIndex)); printf("Enter the longest interval between creation processes: "); scanf("%lu", &(args->maxProcessGenerateSleep)); return mode; }