/** * \fn updateFilterList * \brief Update the list of activated filters */ void updateFilterList (void) { g_signal_handler_block(stores[0], row_inserted_id); g_signal_handler_block(stores[0], row_deleted_id); GtkTreeIter iter; char *str; VF_FILTERS fil; gtk_list_store_clear (stores[0]); for (uint32_t i = 1; i < nb_active_filter; i++) { gtk_list_store_append (stores[0], &iter); fil=videofilters[i].tag; const char * name = filterGetNameFromTag(fil); const char * conf = videofilters[i].filter->printConf (); int namelen = strlen (name); while (*conf == ' ') ++conf; if (strncasecmp (name, conf, namelen) == 0) { conf += namelen; while (*conf == ' ' || *conf == ':') ++conf; } const char * smallstart = ""; const char * smallend = ""; const char * namesmallstart = ""; const char * namesmallend = ""; int conflen = strlen (conf); if (conflen > 120) { smallstart = "<small>"; smallend = "</small>"; if (conflen > 180) { namesmallstart = smallstart; namesmallend = smallend; } } str = g_strconcat("<span weight=\"bold\">", namesmallstart, name, namesmallend, "</span>\n", "<span size=\"smaller\">", smallstart, conf, smallend, "</span>", NULL); gtk_list_store_set (stores[0], &iter, 0, str, 1, videofilters[i].tag, 2, videofilters[i].conf, -1); g_free(str); } g_signal_handler_unblock(stores[0], row_inserted_id); g_signal_handler_unblock(stores[0], row_deleted_id); }
/** \fn buildActiveFilterList(void) \brief Build and display all active filters (may be empty) */ void filtermainWindow::buildActiveFilterList(void) { activeList->clear(); for (uint32_t i = 1; i < nb_active_filter; i++) { const char *name = filterGetNameFromTag(videofilters[i].tag); const char *conf = videofilters[i].filter->printConf (); int namelen = strlen (name); while (*conf == ' ') ++conf; if (strncasecmp (name, conf, namelen) == 0) { conf += namelen; while (*conf == ' ' || *conf == ':') ++conf; } QString str = QString("<b>") + name + QString("</b><br>\n<small>") + conf + QString("</small>"); QListWidgetItem *item=new QListWidgetItem(str,activeList,ACTIVE_FILTER_BASE+i); activeList->addItem(item); } }
uint8_t DIA_threshold (AVDMGenericVideoStream *in, ADMVideoThreshold * thresholdp, THRESHOLD_PARAM * param) { // Allocate space for preview video uint32_t width = in->getInfo()->width; uint32_t height = in->getInfo()->height; dialog = create_threshold_dialog(); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_register_dialog(dialog); gtk_window_set_title (GTK_WINDOW (dialog), QT_TR_NOOP("Threshold Configuration")); gtk_widget_show(dialog); myDialog = new flyThreshold (width, height, in, WID(previewVideo), WID(previewSlider), thresholdp, param); g_signal_connect (GTK_OBJECT (WID(previewVideo)), "configure-event", GTK_SIGNAL_FUNC (preview_video_configured), gpointer (myDialog)); myDialog->upload(); myDialog->sliderChanged(); // update things when settings are changed #define CNX(_widg,_signame) \ g_signal_connect(GTK_OBJECT(WID(_widg)), _signame, \ GTK_SIGNAL_FUNC(gui_update), (void *) (1)); // CNX (minValueSlider, "drag_data_received"); CNX (minValueSpinner, "value_changed"); // CNX (maxValueSlider, "drag_data_received"); CNX (maxValueSpinner, "value_changed"); CNX (outputValuesMenu, "changed"); g_signal_connect(GTK_OBJECT(WID(previewSlider)), "value_changed", GTK_SIGNAL_FUNC(frame_changed), 0); g_signal_connect(GTK_OBJECT(WID(previewVideo)), "expose_event", GTK_SIGNAL_FUNC(gui_draw), 0); g_signal_connect(GTK_OBJECT(WID(previewVideo)), "button_press_event", GTK_SIGNAL_FUNC(previewButtonEvent), gpointer(myDialog)); #if 0 g_signal_connect(GTK_OBJECT(WID(previewVideo)), "motion_notify_event", GTK_SIGNAL_FUNC(previewMotionEvent), gpointer(myDialog)); #endif GtkWidget * previewOutputMenu = WID(previewOutputMenu); uint32_t filter_count; FILTER * filters = getCurrentVideoFilterList (&filter_count); int32_t active = -1; // The " + (active < 0)" below is a bit of a hack. We know that in // on_action() in gui_filtermanager.cpp, case A_ADD, the new filter-to-be // is added to the filter list without incrementing nb_active_filter yet. // So if we get to the end of the list and haven't yet found the filter // that we're configuring, we know it's a new one and therefore that it is // one past the apparent end of the list. It's not a clean solution, but // it seems like the cleanEST solution. for (uint32_t i = 0; i < filter_count + (active < 0); i++) { const char * name = (i == 0) ? "(input)" : filterGetNameFromTag (filters [i].tag); bool free_name = false; FILTER * filter = filters + i; AVDMGenericVideoStream * source = filter->filter; uint32_t w = source->getInfo()->width; uint32_t h = source->getInfo()->height; if (w != width || h != height) { name = g_strconcat ("XX ", name, " XX", NULL); free_name = true; } printf ("filter [%d] = %s (%d) @ %p; %dx%d\n", i, name, filter->tag, source, w, h); gtk_combo_box_append_text (GTK_COMBO_BOX (previewOutputMenu), name); if (filter->filter == myDialog->getSource()) { gtk_combo_box_set_active (GTK_COMBO_BOX (previewOutputMenu), i); printf ("\tfilter [%d] is being configured now\n", i); active = i; } if (free_name) g_free (const_cast <char *> (name)); } ADM_assert (active >= 0); myDialog->this_filter_index = active; g_signal_connect (GTK_OBJECT(previewOutputMenu), "changed", GTK_SIGNAL_FUNC(previewOutputMenuChange), gpointer(myDialog)); uint8_t ret = 0; int response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_OK) { myDialog->download(); myDialog->pushParam(); ret = 1; } else myDialog->restoreParam(); gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); delete myDialog; return ret; }
uint8_t DIA_particle (AVDMGenericVideoStream *in, ADMVideoParticle * particlep, PARTICLE_PARAM * param, const MenuMapping * menu_mapping, uint32_t menu_mapping_count) { // Allocate space for preview video uint32_t width = in->getInfo()->width; uint32_t height = in->getInfo()->height; dialog = create_particle_dialog(); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_register_dialog (dialog); gtk_window_set_title (GTK_WINDOW (dialog), QT_TR_NOOP("Particle Analysis Configuration")); gtk_widget_show (dialog); // Fix up a bunch of things that Glade can't do. This is less efficient // than just editing the Glade output, but it's not that big a deal and // doing it this way makes it MUCH easier to use Glade to tweak the layout // later. // actually, nothing to fix up in this one. But if there ever is, this is // the place to do it... flyParticle * myDialog = new flyParticle (width, height, in, WID(previewVideo), WID(previewSlider), GTK_DIALOG(dialog), particlep, param, menu_mapping, menu_mapping_count); g_signal_connect (GTK_OBJECT (WID(previewVideo)), "configure-event", GTK_SIGNAL_FUNC (preview_video_configured), gpointer (myDialog)); myDialog->upload(); myDialog->sliderChanged(); g_signal_connect (GTK_OBJECT(WID(outputFileBrowseButton)), "clicked", GTK_SIGNAL_FUNC(browse_button_clicked), gpointer(myDialog)); // update things when settings are changed #define CNX(_widg,_signame) \ g_signal_connect (GTK_OBJECT(WID(_widg)), _signame, \ GTK_SIGNAL_FUNC(gui_update), gpointer(myDialog)); CNX (minAreaSpinButton, "value_changed"); CNX (maxAreaSpinButton, "value_changed"); CNX (leftCropSpinButton, "value_changed"); CNX (rightCropSpinButton, "value_changed"); CNX (topCropSpinButton, "value_changed"); CNX (bottomCropSpinButton, "value_changed"); g_signal_connect (GTK_OBJECT(WID(previewSlider)), "value_changed", GTK_SIGNAL_FUNC(frame_changed), gpointer(myDialog)); g_signal_connect (GTK_OBJECT(WID(previewVideo)), "expose_event", GTK_SIGNAL_FUNC(gui_draw), gpointer(myDialog)); g_signal_connect (GTK_OBJECT(WID(previewVideo)), "button_press_event", GTK_SIGNAL_FUNC(previewButtonEvent), gpointer(myDialog)); #if 0 g_signal_connect (GTK_OBJECT(WID(previewVideo)), "motion_notify_event", GTK_SIGNAL_FUNC(previewMotionEvent), gpointer(myDialog)); #endif GtkWidget * previewOutputMenu = WID(previewOutputMenu); uint32_t filter_count; FILTER * filters = getCurrentVideoFilterList (&filter_count); int32_t active = -1; // The " + (active < 0)" below is a bit of a hack. We know that in // on_action() in gui_filtermanager.cpp, case A_ADD, the new filter-to-be // is added to the filter list without incrementing nb_active_filter yet. // So if we get to the end of the list and haven't yet found the filter // that we're configuring, we know it's a new one and therefore that it is // one past the apparent end of the list. It's not a clean solution, but // it seems like the cleanEST solution. for (uint32_t i = 0; i < filter_count + (active < 0); i++) { const char * name = (i == 0) ? "(input)" : filterGetNameFromTag (filters [i].tag); bool free_name = false; FILTER * filter = filters + i; AVDMGenericVideoStream * source = filter->filter; uint32_t w = source->getInfo()->width; uint32_t h = source->getInfo()->height; if (w != width || h != height) { name = g_strconcat ("XX ", name, " XX", NULL); free_name = true; } printf ("filter [%d] = %s (%d) @ %p; %dx%d\n", i, name, filter->tag, source, w, h); gtk_combo_box_append_text (GTK_COMBO_BOX (previewOutputMenu), name); if (filter->filter == myDialog->getSource()) { gtk_combo_box_set_active (GTK_COMBO_BOX (previewOutputMenu), i); printf ("\tfilter [%d] is being configured now\n", i); active = i; } if (free_name) g_free (const_cast <char *> (name)); } ADM_assert (active >= 0); myDialog->this_filter_index = active; g_signal_connect (GTK_OBJECT(previewOutputMenu), "changed", GTK_SIGNAL_FUNC(previewOutputMenuChange), gpointer(myDialog)); uint8_t ret = 0; int response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_OK) { myDialog->download(); myDialog->pushParam(); ret = 1; } else myDialog->restoreParam(); gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); delete myDialog; return ret; }