/** * @brief Finishes drawing a rectangle. */ void TilesetView::end_state_drawing_rectangle() { QRect rectangle = current_area_item->rect().toRect(); if (!rectangle.isEmpty() && sceneRect().contains(rectangle) && get_items_intersecting_current_area().isEmpty() && model->is_selection_empty() && !is_read_only()) { // Context menu to create a pattern. QMenu menu; EnumMenus<Ground>::create_actions( menu, EnumMenuCheckableOption::NON_CHECKABLE, [=](Ground ground) { QString pattern_id; do { ++last_integer_pattern_id; pattern_id = QString::number(last_integer_pattern_id); } while (model->id_to_index(pattern_id) != -1); emit create_pattern_requested(pattern_id, rectangle, ground); }); // Put most actions in a submenu to make the context menu smaller. QMenu sub_menu(tr("New pattern (more options)")); int i = 0; for (QAction* action : menu.actions()) { Ground ground = static_cast<Ground>(action->data().toInt()); if (ground == Ground::TRAVERSABLE || ground == Ground::WALL) { action->setText(tr("New pattern (%1)").arg(GroundTraits::get_friendly_name(ground))); } else { menu.removeAction(action); sub_menu.addAction(action); } ++i; } menu.addMenu(&sub_menu); menu.addSeparator(); menu.addAction(tr("Cancel")); menu.exec(cursor().pos() + QPoint(1, 1)); } scene->removeItem(current_area_item); delete current_area_item; current_area_item = nullptr; initially_selected_items.clear(); start_state_normal(); }
void Start() { menu sub_menu(std::make_tuple(100,150,"腕立てスタート"), std::make_tuple(100,250,"設定")); bool return_flag=false; while(!ScreenFlip()&&!ProcessMessage()&&!ClearDrawScreen()){ sub_menu.effectiving(); switch(sub_menu.Drow_menus()){ case 0: begin(sub_menu); return; case 1: Setting(sub_menu); return; case -1: ; } } }
int main(void){ int i = 0, j = 0; int choix; char nomfichier[]=""; char newLab=' '; struct Labyrinthe lab = {NULL,0,0}; struct Labyrinthe lab_copy = { NULL, 0, 0 }; struct Labyrinthe lab_copy2 = { NULL, 0, 0 }; do{ main_menu(); scanf("%d",&choix); clear(); switch(choix) { case 1 : //Création initiale du labyrinthe fixe, puis affichage lab = createFixedLab(lab, LAB_L_FIX, LAB_C_FIX, 0, 0, 3, 3); //allocation d'un autre tableau lab_copy.tab2D = tabAlloc(lab_copy.tab2D, LAB_L_FIX, LAB_C_FIX); researchPath(lab); choix = ' '; do{ duplicate_struct(lab, &lab_copy); sub_menu(lab, choix); scanf("%d", &choix); clear(); switch (choix) { case 0: printf("Mode Sans Solutions : \n"); afficherLab(lab_copy, choix); break; case 1: display_multiple_paths(lab_copy); break; case 2: display_shortest_path(lab_copy); break; case 3: break; case 4: exit(0); default: printf("\nVous n'avez pas entrer la bonne valeur ! \n"); break; } } while (choix!=3); free_memory(&lab); free_memory(&lab_copy); break; case 2 : printf("Entrez le nom de votre fichier a charger (matrice.txt est le fichier a tester) : \n"); scanf("%s", nomfichier); //initialisation des labyrinthes lab = createLabFromFile(lab, nomfichier); lab_copy.tab2D = tabAlloc(lab_copy.tab2D, lab.l, lab.c); lab_copy2.tab2D = tabAlloc(lab_copy.tab2D, lab.l, lab.c); duplicate_struct(lab,&lab_copy2); researchPath(lab); choix = ' '; printf("\n"); do{ duplicate_struct(lab,&lab_copy); sub_menu(lab, choix); if (is_solved(lab)){ if (choix != 5){ printf("5-Afficher UN seul chemin possible [quelconque]\n\n"); } } scanf("%d", &choix); clear(); switch (choix) { case 0 : printf("Mode Sans Solutions : \n"); afficherLab(lab_copy, choix); break; case 1 : display_multiple_paths(lab_copy); break; case 2: display_shortest_path(lab_copy); break; case 3: break; case 4: exit(0); case 5: if (is_solved(lab)){ display_one_path(lab_copy2); } break; default : printf("\nVous n'avez pas entrer la bonne valeur ! \n"); break; } } while (choix!=3); //free_memory(&lab); free_memory(&lab_copy); free_memory(&lab_copy2); break; case 3 : printf("Quel est le nombre de ligne et de colonne? \n(exemple: taper '3 2' pour ligne = 3, colonne = 2)\n"); scanf("%d %d", &lab.l, &lab.c); clear(); lab = createRandomLab(lab); afficherLab(lab, 0); printf("\nEntrer les coordonees de l'entrer du labyrinthe (exemple : '3 2' pour ligne numero 3 et colonne numero 2) : \n"); do{ scanf("%d %d", &lab.xentrer, &lab.yentrer); if(lab.xentrer > (lab.l-1) || lab.yentrer > (lab.c-1) || lab.xentrer < 0 || lab.yentrer <0){printf("Erreur de saisie, ressaisir les coordonnees de l'entrer :\n" );} } while((lab.xentrer > (lab.l-1) || lab.yentrer > (lab.c-1)) || (lab.xentrer < 0 || lab.yentrer <0)); clear(); afficherLab(lab, 0); printf("\nEntrer les coordonees de la sortie du labyrinthe (exemple : '3 2' pour ligne numero 3 et colonne numero 2) :\n"); do{ scanf("%d %d", &lab.xsortie, &lab.ysortie); if(lab.xsortie > (lab.l-1) || lab.ysortie > (lab.c-1) || lab.xsortie < 0 || lab.ysortie <0){printf("Erreur de saisie, ressaisir les coordonnees de la sortie :\n" );} } while(lab.xsortie > (lab.l-1) || lab.ysortie > (lab.c-1) || lab.xsortie < 0 || lab.ysortie <0); clear(); afficherLab(lab, 0); lab_copy.tab2D = tabAlloc(lab_copy.tab2D, lab.l, lab.c); researchPath(lab); choix = ' '; printf("\n"); do{ duplicate_struct(lab, &lab_copy); sub_menu(lab, choix); scanf("%d", &choix); clear(); switch (choix) { case 0: printf("Mode Sans Solutions : \n"); afficherLab(lab_copy, choix); break; case 1: display_multiple_paths(lab_copy); break; case 2: display_shortest_path(lab_copy); break; case 3: break; case 4: exit(0); default: printf("\nVous n'avez pas entrer la bonne valeur ! \n"); break; } } while (choix != 3); free_memory(&lab); free_memory(&lab_copy); break; case 4 : exit(0); break; default : printf("Le numero du menu est incorrect !\n"); break; } }while(1); }