neuron_tipspicker_dialog::neuron_tipspicker_dialog(V3DPluginCallback2 * cb, V3dR_MainWindow* inwin) { if(!inwin) return; v3dwin=inwin; callback = cb; v3dcontrol = callback->getView3DControl_Any3DViewer(v3dwin); ntList=cb->getHandleNeuronTrees_Any3DViewer(v3dwin); if(ntList->size()<=0){ //this should not happen v3d_msg("No neuron in the window!"); return; } //reset the color of neuron list mList = cb->getHandleLandmarkList_Any3DViewer(v3dwin); creat(); //update markers link_new_marker_neuron(); update_tip(); curIdx=0; checkStatus(); }
void neuron_tipspicker_dialog::search() { checkwindow(); mList->clear(); int dir=cb_dir->currentIndex(); int side=cb_side->currentIndex(); double zscale=spin_zscale->value(); double span=spin_searchspan->value(); double gapThr=spin_gapthr->value(); double angThr=cos(spin_angthr->value()/180*M_PI); double segmentThr=spin_segthr->value(); double spineLengthThr = 0; double spineRadiusThr = 0; double spineAngThr = 1; if(check_spine->isChecked()){ spineLengthThr = spin_spineLen->value(); spineAngThr = cos(spin_spineAng->value()/180*M_PI); spineRadiusThr = spin_spineRadius->value(); } QList<Candidate> cands; searchBorderTips(ntList, cands, side, dir, zscale, span, gapThr, angThr, segmentThr, spineLengthThr, spineAngThr, spineRadiusThr); qDebug()<<"found "<<cands.size()<<" border tips"; for(int i=0; i<cands.size(); i++){ V3DLONG nid=cands.at(i).nid; V3DLONG pid=cands.at(i).pid; LocationSimple S0 = LocationSimple(ntList->at(nid).listNeuron[pid].x, ntList->at(nid).listNeuron[pid].y, ntList->at(nid).listNeuron[pid].z); S0.color.r = 0; S0.color.g = 0; S0.color.b = 255; S0.name = QString::number(i+1).toStdString(); QString c0 = QString::number(nid)+" "+QString::number(pid)+" 0"; S0.comments = c0.toStdString(); mList->append(S0); } update_tip(); }
void title_screen::pre_show(window& win) { win.set_click_dismiss(false); win.set_enter_disabled(true); win.set_escape_disabled(true); // Each time the dialog shows, we set this to false redraw_background_ = false; #ifdef DEBUG_TOOLTIP win.connect_signal<event::SDL_MOUSE_MOTION>( std::bind(debug_tooltip, std::ref(win), _3, _5), event::dispatcher::front_child); #endif win.connect_signal<event::SDL_VIDEO_RESIZE>(std::bind(&title_screen::on_resize, this, std::ref(win))); // // General hotkeys // win.register_hotkey(hotkey::TITLE_SCREEN__RELOAD_WML, [](event::dispatcher& w, hotkey::HOTKEY_COMMAND) { dynamic_cast<window&>(w).set_retval(RELOAD_GAME_DATA); return true; }); win.register_hotkey(hotkey::HOTKEY_FULLSCREEN, std::bind(fullscreen, std::ref(win.video()))); win.register_hotkey(hotkey::LUA_CONSOLE, std::bind(&launch_lua_console, std::ref(win))); // // Background and logo images // if(game_config::images::game_title.empty()) { ERR_CF << "No title image defined" << std::endl; } win.get_canvas()[0].set_variable("title_image", variant(game_config::images::game_title)); if(game_config::images::game_title_background.empty()) { ERR_CF << "No title background image defined" << std::endl; } win.get_canvas()[0].set_variable("background_image", variant(game_config::images::game_title_background)); find_widget<image>(&win, "logo-bg", false).set_image(game_config::images::game_logo_background); find_widget<image>(&win, "logo", false).set_image(game_config::images::game_logo); // // Version string // const std::string version_string = formatter() << ("Version") << " " << game_config::revision; if(label* version_label = find_widget<label>(&win, "revision_number", false, false)) { version_label->set_label(version_string); } win.get_canvas()[0].set_variable("revision_number", variant(version_string)); // // Tip-of-the-day browser // multi_page& tip_pages = find_widget<multi_page>(&win, "tips", false); std::vector<game_tip> tips(settings::get_tips()); if(tips.empty()) { WRN_CF << "There are no tips of day available." << std::endl; } for(const auto& tip : tips) { string_map widget; std::map<std::string, string_map> page; widget["use_markup"] = "true"; widget["label"] = tip.text(); page.emplace("tip", widget); widget["label"] = tip.source(); page.emplace("source", widget); tip_pages.add_page(page); } update_tip(win, true); register_button(win, "next_tip", hotkey::TITLE_SCREEN__NEXT_TIP, std::bind(&title_screen::update_tip, this, std::ref(win), true)); register_button(win, "previous_tip", hotkey::TITLE_SCREEN__PREVIOUS_TIP, std::bind(&title_screen::update_tip, this, std::ref(win), false)); // // Help // register_button(win, "help", hotkey::HOTKEY_HELP, [this](window&) { help::help_manager help_manager(&game_config_manager::get()->game_config()); help::show_help(game_.video()); }); // // About // register_button(win, "about", hotkey::HOTKEY_NULL, std::bind(&game_version::display, std::ref(win.video()))); // // Tutorial // register_button(win, "tutorial", hotkey::TITLE_SCREEN__TUTORIAL, [this](window& w) { game_.set_tutorial(); w.set_retval(LAUNCH_GAME); }); // // Campaign // register_button(win, "campaign", hotkey::TITLE_SCREEN__CAMPAIGN, [this](window& w) { try{ if(game_.new_campaign()) { w.set_retval(LAUNCH_GAME); } } catch (const config::error& e) { gui2::show_error_message(game_.video(), e.what()); } }); // // Multiplayer // register_button(win, "multiplayer", hotkey::TITLE_SCREEN__MULTIPLAYER, [this](window& w) { while(true) { gui2::dialogs::mp_method_selection dlg; dlg.show(game_.video()); if(dlg.get_retval() != gui2::window::OK) { return; } const int res = dlg.get_choice(); if(res == 2 && preferences::mp_server_warning_disabled() < 2) { if(!gui2::dialogs::mp_host_game_prompt::execute(game_.video())) { continue; } } switch(res) { case 0: game_.select_mp_server(preferences::server_list().front().address); w.set_retval(MP_CONNECT); break; case 1: game_.select_mp_server(""); w.set_retval(MP_CONNECT); break; case 2: game_.select_mp_server("localhost"); w.set_retval(MP_HOST); break; case 3: w.set_retval(MP_LOCAL); break; } return; } }); // // Load game // register_button(win, "load", hotkey::HOTKEY_LOAD_GAME, [this](window& w) { if(game_.load_game()) { w.set_retval(LAUNCH_GAME); } else { game_.clear_loaded_game(); } }); // // Addons // register_button(win, "addons", hotkey::TITLE_SCREEN__ADDONS, [this](window&) { // NOTE: we need the help_manager to get access to the Add-ons section in the game help! help::help_manager help_manager(&game_config_manager::get()->game_config()); if(manage_addons(game_.video())) { game_config_manager::get()->reload_changed_game_config(); } }); // // Editor // register_button(win, "editor", hotkey::TITLE_SCREEN__EDITOR, [&](window& w) { w.set_retval(MAP_EDITOR); }); // // Cores // register_button(win, "cores", hotkey::TITLE_SCREEN__CORES, [this](window&) { int current = 0; std::vector<config> cores; for(const config& core : game_config_manager::get()->game_config().child_range("core")) { cores.push_back(core); if(core["id"] == preferences::core_id()) { current = cores.size() - 1; } } gui2::dialogs::core_selection core_dlg(cores, current); if(core_dlg.show(game_.video())) { const std::string& core_id = cores[core_dlg.get_choice()]["id"]; preferences::set_core_id(core_id); game_config_manager::get()->reload_changed_game_config(); } }); if(game_config_manager::get()->game_config().child_range("core").size() <= 1) { find_widget<button>(&win, "cores", false).set_visible(window::visibility::invisible); } // // Language // register_button(win, "language", hotkey::HOTKEY_LANGUAGE, [this](window& w) { try { if(game_.change_language()) { t_string::reset_translations(); ::image::flush_cache(); on_resize(w); } } catch(std::runtime_error& e) { gui2::show_error_message(game_.video(), e.what()); } }); // // Preferences // register_button(win, "preferences", hotkey::HOTKEY_PREFERENCES, [this](window&) { game_.show_preferences(); }); // // Credits // register_button(win, "credits", hotkey::TITLE_SCREEN__CREDITS, [&](window& w) { w.set_retval(SHOW_ABOUT); }); // // Quit // register_button(win, "quit", hotkey::HOTKEY_QUIT_TO_DESKTOP, [&](window& w) { w.set_retval(QUIT_GAME); }); // // Debug clock // register_button(win, "clock", hotkey::HOTKEY_NULL, std::bind(&title_screen::show_debug_clock_window, this, std::ref(win.video()))); find_widget<button>(&win, "clock", false).set_visible(show_debug_clock_button ? widget::visibility::visible : widget::visibility::invisible); }
void neuron_tipspicker_dialog::creat() { gridLayout = new QGridLayout(); //border tips zone group_marker = new QGroupBox("search for border tips"); group_marker->setCheckable(false); cb_dir = new QComboBox(); cb_dir->addItem("x"); cb_dir->addItem("y"); cb_dir->addItem("z"); cb_dir->setCurrentIndex(2); spin_zscale = new QDoubleSpinBox(); spin_zscale->setRange(0,100000); spin_zscale->setValue(1); spin_searchspan = new QDoubleSpinBox(); spin_searchspan->setRange(0,100000); spin_searchspan->setValue(20); spin_segthr = new QDoubleSpinBox(); spin_segthr->setRange(0,100000); spin_segthr->setValue(0); spin_gapthr = new QDoubleSpinBox(); spin_gapthr->setRange(0,100000); spin_gapthr->setValue(0); spin_angthr = new QDoubleSpinBox(); spin_angthr->setRange(0,180); spin_angthr->setValue(100); spin_spineLen = new QSpinBox(); spin_spineLen->setRange(0,100000); spin_spineLen->setValue(5); spin_spineLen->setEnabled(false); spin_spineAng = new QDoubleSpinBox(); spin_spineAng->setRange(0,180); spin_spineAng->setValue(30); spin_spineAng->setEnabled(false); spin_spineRadius = new QDoubleSpinBox(); spin_spineRadius->setRange(0,100000); spin_spineRadius->setValue(3); spin_spineRadius->setEnabled(false); check_spine = new QCheckBox("filter spines when searching:"); check_spine -> setChecked(false); cb_side = new QComboBox(); cb_side->addItem("search side A"); cb_side->addItem("search side B"); cb_side->setCurrentIndex(0); btn_search = new QPushButton("Search"); btn_search->setAutoDefault(false); connect(btn_search, SIGNAL(clicked()), this, SLOT(search())); connect(check_spine, SIGNAL(stateChanged(int)), this, SLOT(spineCheck(int))); QGridLayout* groupLayout = new QGridLayout(); QLabel* label_0 = new QLabel("stacking direction: "); groupLayout->addWidget(label_0,9,0,1,2,Qt::AlignRight); groupLayout->addWidget(cb_dir,9,2,1,1); QLabel* label_1 = new QLabel("resacle stacking direction: "); groupLayout->addWidget(label_1,9,3,1,2,Qt::AlignRight); groupLayout->addWidget(spin_zscale,9,5,1,1); QLabel* label_4 = new QLabel("border tips searching span: "); groupLayout->addWidget(label_4,13,0,1,2,Qt::AlignRight); groupLayout->addWidget(spin_searchspan,13,2,1,1); QLabel* label_62 = new QLabel("small gap filter (gap size): "); groupLayout->addWidget(label_62,13,3,1,2,Qt::AlignRight); groupLayout->addWidget(spin_gapthr,13,5,1,1); QLabel* label_6 = new QLabel("small segment filter (0=keep all): "); groupLayout->addWidget(label_6,14,0,1,2,Qt::AlignRight); groupLayout->addWidget(spin_segthr,14,2,1,1); QLabel* label_3 = new QLabel("max angle with section plan (0-180): "); groupLayout->addWidget(label_3,14,3,1,2,Qt::AlignRight); groupLayout->addWidget(spin_angthr,14,5,1,1); groupLayout->addWidget(check_spine,15,0,1,2); QLabel* label_7 = new QLabel("point #:"); groupLayout->addWidget(label_7,16,0,1,1,Qt::AlignRight); groupLayout->addWidget(spin_spineLen,16,1,1,1); QLabel* label_8 = new QLabel("turning angle:"); groupLayout->addWidget(label_8,16,2,1,1,Qt::AlignRight); groupLayout->addWidget(spin_spineAng,16,3,1,1); QLabel* label_9 = new QLabel("radius:"); groupLayout->addWidget(label_9,16,4,1,1,Qt::AlignRight); groupLayout->addWidget(spin_spineRadius,16,5,1,1); groupLayout->addWidget(cb_side,17,3,1,2); groupLayout->addWidget(btn_search,17,5,1,1); group_marker->setLayout(groupLayout); gridLayout->addWidget(group_marker, 1,0,1,6); //selection zone group_check = new QGroupBox("check border tips"); group_check->setCheckable(false); cb_tips = new QComboBox(); btn_reset = new QPushButton("Reset"); btn_reset->setAutoDefault(false); btn_update = new QPushButton("Update"); btn_update->setAutoDefault(false); btn_accept = new QPushButton("Accept"); btn_accept->setAutoDefault(false); btn_skip = new QPushButton("Skip"); btn_skip->setAutoDefault(false); btn_reject = new QPushButton("Reject"); btn_reject->setAutoDefault(false); check_syncTriView = new QCheckBox("Sync View"); check_syncTriView->setChecked(true); spin_roisize = new QSpinBox(); spin_roisize->setRange(0,100000); spin_roisize->setValue(50); connect(btn_reset, SIGNAL(clicked()), this, SLOT(reset_tip())); connect(btn_update, SIGNAL(clicked()), this, SLOT(update_tip())); connect(btn_accept, SIGNAL(clicked()), this, SLOT(accept_tip())); connect(btn_skip, SIGNAL(clicked()), this, SLOT(skip_tip())); connect(btn_reject, SIGNAL(clicked()), this, SLOT(reject_tip())); connect(cb_tips, SIGNAL(currentIndexChanged(int)), this, SLOT(change_tip(int))); QGridLayout* checkLayout = new QGridLayout(); checkLayout->addWidget(btn_reset,1,0,1,1); checkLayout->addWidget(btn_update,1,1,1,1); checkLayout->addWidget(check_syncTriView,1,2,1,1); QLabel* label_10 = new QLabel("View Size"); checkLayout->addWidget(label_10,1,3,1,1,Qt::AlignRight); checkLayout->addWidget(spin_roisize,1,4,1,1); checkLayout->addWidget(cb_tips,2,0,1,1); checkLayout->addWidget(btn_accept,2,1,1,1); checkLayout->addWidget(btn_skip,2,2,1,1); checkLayout->addWidget(btn_reject,2,3,1,1); group_check->setLayout(checkLayout); gridLayout->addWidget(group_check, 2,0,1,6); //output zone btn_save = new QPushButton("Save"); btn_save->setAutoDefault(false); btn_quit = new QPushButton("Quit"); btn_quit->setAutoDefault(false); connect(btn_save, SIGNAL(clicked()), this, SLOT(save())); connect(btn_quit, SIGNAL(clicked()), this, SLOT(reject())); gridLayout->addWidget(btn_save,3,4,1,1); gridLayout->addWidget(btn_quit,3,5,1,1); setLayout(gridLayout); // qDebug()<<"dialog created"; }
void ttitle_screen::pre_show(twindow& window) { set_restore(false); window.set_click_dismiss(false); window.set_enter_disabled(true); window.set_escape_disabled(true); #ifdef DEBUG_TOOLTIP window.connect_signal<event::SDL_MOUSE_MOTION>( std::bind(debug_tooltip, std::ref(window), _3, _5), event::tdispatcher::front_child); #endif /**** Set the version number ****/ if(tcontrol* control = find_widget<tcontrol>(&window, "revision_number", false, false)) { control->set_label(_("Version ") + game_config::revision); } window.canvas()[0].set_variable( "revision_number", variant(_("Version") + std::string(" ") + game_config::revision)); /**** Set the tip of the day ****/ tmulti_page& tip_pages = find_widget<tmulti_page>(&window, "tips", false); std::vector<ttip> tips(settings::get_tips()); if(tips.empty()) { WRN_CF << "There are not tips of day available." << std::endl; } for(const auto & tip : tips) { string_map widget; std::map<std::string, string_map> page; widget["label"] = tip.text(); widget["use_markup"] = "true"; page["tip"] = widget; widget["label"] = tip.source(); widget["use_markup"] = "true"; page["source"] = widget; tip_pages.add_page(page); } update_tip(window, true); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "next_tip", false), std::bind(&ttitle_screen::update_tip, this, std::ref(window), true)); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "previous_tip", false), std::bind(&ttitle_screen::update_tip, this, std::ref(window), false)); if(game_config::images::game_title.empty()) { ERR_CF << "No title image defined" << std::endl; } else { window.canvas()[0].set_variable( "title_image", variant(game_config::images::game_title)); } if(game_config::images::game_title_background.empty()) { ERR_CF << "No title background image defined" << std::endl; } else { window.canvas()[0].set_variable( "background_image", variant(game_config::images::game_title_background)); } /***** Logo *****/ find_widget<timage>(&window, "logo", false).set_image("misc/logo.png"); /***** About dialog button *****/ tbutton& about = find_widget<tbutton>(&window, "about", false); connect_signal_mouse_left_click( about, std::bind(&tgame_version::display, std::ref(window.video()))); /***** Set the clock button. *****/ tbutton& clock = find_widget<tbutton>(&window, "clock", false); clock.set_visible(show_debug_clock_button ? twidget::tvisible::visible : twidget::tvisible::invisible); connect_signal_mouse_left_click( clock, std::bind(&ttitle_screen::show_debug_clock_window, this, std::ref(window.video()))); }
bool EditorLayersGui::event(SDL_Event& ev) { switch (ev.type) { case SDL_MOUSEBUTTONDOWN: { if (ev.button.button == SDL_BUTTON_LEFT) { switch (hovered_item) { case HI_SECTOR: Editor::current()->disable_keyboard(); MenuManager::instance().set_menu(MenuStorage::EDITOR_SECTORS_MENU); break; case HI_LAYERS: if (hovered_layer >= layers.size()) { break; } if ( layers[hovered_layer]->is_tilemap ) { if (selected_tilemap) { ((TileMap*)selected_tilemap)->editor_active = false; } selected_tilemap = layers[hovered_layer]->layer; ((TileMap*)selected_tilemap)->editor_active = true; Editor::current()->inputcenter.edit_path(((TileMap*)selected_tilemap)->get_path().get(), selected_tilemap); } else { auto cam = dynamic_cast<Camera*>(layers[hovered_layer]->layer); if (cam) { Editor::current()->inputcenter.edit_path(cam->get_path(), cam); } } break; default: return false; break; } } else if (ev.button.button == SDL_BUTTON_RIGHT) { if (hovered_item == HI_LAYERS && hovered_layer < layers.size()) { std::unique_ptr<Menu> om(new ObjectMenu(layers[hovered_layer]->layer)); Editor::current()->deactivate_request = true; MenuManager::instance().push_menu(move(om)); } else { return false; } } } break; case SDL_MOUSEMOTION: { Vector mouse_pos = VideoSystem::current()->get_renderer().to_logical(ev.motion.x, ev.motion.y); float x = mouse_pos.x - Xpos; float y = mouse_pos.y - Ypos; if (y < 0 || x > Width) { hovered_item = HI_NONE; object_tip = NULL; return false; } if (x < 0) { hovered_item = HI_SPAWNPOINTS; object_tip = NULL; break; } else { if (x <= sector_text_width) { hovered_item = HI_SECTOR; object_tip = NULL; } else { unsigned int new_hovered_layer = get_layer_pos(mouse_pos); if (hovered_layer != new_hovered_layer || hovered_item != HI_LAYERS) { hovered_layer = new_hovered_layer; update_tip(); } hovered_item = HI_LAYERS; } } } break; default: return false; } return true; }