/* Allows the R user to set the variables within a given display */ USER_OBJECT_ RS_GGOBI(setDisplayVariables)(USER_OBJECT_ vars, USER_OBJECT_ varPrev, USER_OBJECT_ dpy) { displayd *display, *prev_display; USER_OBJECT_ ans = NULL_USER_OBJECT; display = toDisplay(dpy); g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT); /* ensure that display is current before changing variables */ prev_display = display->ggobi->current_display; display_set_current(display, display->ggobi); /* If any of the requested variables AREN'T selected, select them */ toggle_display_variables(display, vars, false); varpanel_refresh(display, display->ggobi); /* If any of the obsolete variables ARE still selected, select (toggle) them */ toggle_display_variables(display, varPrev, true); /* refresh everything */ varpanel_refresh(display, display->ggobi); display_tailpipe(display, FULL, display->ggobi); while(gtk_events_pending()) /* ensure display is redrawn */ gtk_main_iteration(); /* revert to previously selected display */ display_set_current(prev_display, prev_display->ggobi); return(ans); }
/* Expects a 2 column matrix with the X and Y coefficients for each var */ USER_OBJECT_ RS_GGOBI(setTourProjection)(USER_OBJECT_ s_display, USER_OBJECT_ s_mode_name, USER_OBJECT_ matrix) { displayd *display = toDisplay(s_display); ProjectionMode mode = GGOBI(getPModeId)(asCString(s_mode_name)); gint k, n; gdouble *x = NULL, *y = NULL; g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT); RS_INTERNAL_GGOBI(getTourVectorsFromMode)(display, mode, &x, &y); g_return_val_if_fail(x != NULL, NULL_USER_OBJECT); n = display->d->ncols; for (k = 0; k < n; k++) { x[k] = REAL(matrix)[k]; if (y) y[k] = REAL(matrix)[k+n]; } display_tailpipe (display, FULL, display->ggobi); varcircles_refresh (display->d, display->ggobi); return NULL_USER_OBJECT; }
void tour1d_scramble(GGobiSession *gg) { int i, j; displayd *dsp = gg->current_display; GGobiStage *d = dsp->d; gint nc = d->n_cols; for (i=0; i<1; i++) for (j=0; j<nc; j++) dsp->t1d.Fa.vals[i][j] = dsp->t1d.Fz.vals[i][j] = dsp->t1d.F.vals[i][j] = dsp->t1d.Ga.vals[i][j] = dsp->t1d.Gz.vals[i][j] = 0.0; gt_basis(dsp->t1d.Fa, dsp->t1d.nactive, dsp->t1d.active_vars, d->n_cols, (gint) 1); arrayd_copy(&dsp->t1d.Fa, &dsp->t1d.F); /* copy_mat(dsp->t1d.F.vals, dsp->t1d.Fa.vals, d->n_cols, 1);*/ dsp->t1d.get_new_target = true; display_tailpipe (dsp, FULL, gg); varcircles_refresh (d, gg); if (dsp->t1d_window != NULL && GTK_WIDGET_VISIBLE (dsp->t1d_window)) t1d_pp_reinit(dsp, gg); }
void tour1d_reinit(GGobiSession *gg) { gint i, j; displayd *dsp = gg->current_display; GGobiStage *d = dsp->d; splotd *sp = gg->current_splot; for (i=0; i<1; i++) { for (j=0; j<d->n_cols; j++) { dsp->t1d.Fa.vals[i][j] = 0.; dsp->t1d.F.vals[i][j] = 0.; } dsp->t1d.Fa.vals[i][dsp->t1d.active_vars.els[i]] = 1.; dsp->t1d.F.vals[i][dsp->t1d.active_vars.els[i]] = 1.; } /* Reinits the vertical height for the ashes */ sp->tour1d.initmax = true; dsp->t1d.get_new_target = true; display_tailpipe (dsp, FULL, gg); varcircles_refresh (d, gg); if (dsp->t1d_window != NULL && GTK_WIDGET_VISIBLE (dsp->t1d_window)) t1d_pp_reinit(dsp, gg); }
void receive_timeSeries_drag(GtkWidget *src, GdkDragContext *context, int x, int y, const GtkSelectionData *data, unsigned int info, unsigned int event_time, gpointer *udata) { splotd *to = GGOBI_SPLOT(src), *from, *sp; displayd *display; display = to->displayptr; GList *l; gint k; GList *ivars = NULL; gint xvar; from = GGOBI_SPLOT(gtk_drag_get_source_widget(context)); if(from->displayptr != display) { gg_write_to_statusbar("the source and destination of the parallel coordinate plots are not from the same display.\n", display->ggobi); return; } /* Get the x variable */ sp = (splotd *) (display->splots)->data; xvar = sp->xyvars.x; /* Gather a list of indices of the vertically plotted variables */ l = display->splots; while (l) { sp = (splotd *) l->data; ivars = g_list_append(ivars, GINT_TO_POINTER(sp->xyvars.y)); l = l->next; } /* Find the index of the to element */ k = g_list_index(ivars, GINT_TO_POINTER(to->xyvars.y)); /* Remove the from element */ ivars = g_list_remove(ivars, GINT_TO_POINTER(from->xyvars.y)); /* Insert the from element in the position of the to element */ ivars = g_list_insert(ivars, GINT_TO_POINTER(from->xyvars.y), k); /* Assign them to the existing plots */ k = 0; l = display->splots; while (l) { sp = (splotd *) l->data; sp->xyvars.y = GPOINTER_TO_INT(g_list_nth_data(ivars, k)); k++; l = l->next; } g_list_free(ivars); display_tailpipe (display, FULL, display->ggobi); varpanel_refresh (display, display->ggobi); }
void tour1d_pause (cpaneld *cpanel, gboolean state, displayd *dsp, GGobiSession *gg) { if (dsp == NULL) return; cpanel->t1d.paused = state; tour1d_func (!cpanel->t1d.paused, dsp, gg); if (cpanel->t1d.paused) { /*-- whenever motion stops, we need a FULL redraw --*/ display_tailpipe (dsp, FULL, gg); } }
/** This is called when we have reset all the variables in the different splots within a display. The intent is that this will recompute everything, including the positions of the points/glyphs. Currently this is not doing that. Need to call some other method. */ USER_OBJECT_ RS_GGOBI(updateDisplay)(USER_OBJECT_ dpy, USER_OBJECT_ ggobiId) { USER_OBJECT_ ans = NEW_LOGICAL(1); ggobid *gg; displayd *display; gg = toGGobi(ggobiId); g_return_val_if_fail(GGOBI_IS_GGOBI(gg), NULL_USER_OBJECT); display = toDisplay(dpy); g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT); display_tailpipe(display, FULL, gg); LOGICAL_DATA(ans)[0] = TRUE; return(ans); }
void tour1d_manip_end(splotd *sp) { displayd *dsp = (displayd *) sp->displayptr; cpaneld *cpanel = &dsp->cpanel; GGobiSession *gg = GGobiFromSPlot(sp); disconnect_motion_signal (sp); arrayd_copy(&dsp->t1d.F, &dsp->t1d.Fa); /* copy_mat(dsp->t1d.Fa.vals, dsp->t1d.F.vals, d->n_cols, 1);*/ dsp->t1d.get_new_target = true; /* need to turn on tour? */ if (!cpanel->t1d.paused) { tour1d_pause(cpanel, T1DOFF, dsp, gg); /*-- whenever motion stops, we need a FULL redraw --*/ display_tailpipe (dsp, FULL, gg); } }
void tour1d_manip(gint p1, gint p2, splotd *sp, GGobiSession *gg) { displayd *dsp = (displayd *) sp->displayptr; GGobiStage *d = dsp->d; cpaneld *cpanel = &dsp->cpanel; gdouble xcosphi=1., xsinphi=0.; gdouble distx, disty; gdouble denom = MIN(sp->max.x, sp->max.y)/2.; gint actual_nxvars = dsp->t1d.nactive; gint j; gboolean offscreen = false; gboolean pp_problem = false; /* check if off the plot window */ if (p1 > sp->max.x || p1 < 0 || p2 > sp->max.y || p2 <0) offscreen = true; if (dsp->t1d_manipvar_inc) actual_nxvars = dsp->t1d.nactive-1; if (!offscreen) { dsp->t1d_pos_old = dsp->t1d_pos; dsp->t1d_pos = p1; if (actual_nxvars > 0) { if (cpanel->t1d.vert) { distx = 0.; disty = dsp->tc2_pos_old - dsp->tc2_pos; } else { distx = dsp->t1d_pos - dsp->t1d_pos_old; disty = 0.; } dsp->t1d_phi = dsp->t1d_phi + distx / denom; xcosphi = (gdouble) cos((gdouble) dsp->t1d_phi); xsinphi = (gdouble) sin((gdouble) dsp->t1d_phi); if (xcosphi > 1.0) { xcosphi = 1.0; xsinphi = 0.0; } else if (xcosphi < -1.0) { xcosphi = -1.0; xsinphi = 0.0; } } /* generate the projection basis */ if (actual_nxvars > 0) { for (j=0; j<d->n_cols; j++) dsp->t1d.F.vals[0][j] = xcosphi * dsp->t1d_manbasis.vals[0][j] + xsinphi * dsp->t1d_manbasis.vals[1][j]; } /* plot pp index */ /* if (dsp->t1d_ppda != NULL) {*/ if (dsp->t1d_window != NULL && GTK_WIDGET_VISIBLE (dsp->t1d_window)) { dsp->t1d.oppval = dsp->t1d.ppval; pp_problem = t1d_switch_index(cpanel->t1d.pp_indx, 0, dsp, gg); t1d_ppdraw(dsp->t1d.ppval, dsp, gg); } display_tailpipe (dsp, FULL, gg); varcircles_refresh (d, gg); } else { disconnect_motion_signal (sp); arrayd_copy(&dsp->t1d.F, &dsp->t1d.Fa); /* copy_mat(dsp->t1d.Fa.vals, dsp->t1d.F.vals, d->n_cols, 1);*/ dsp->t1d.get_new_target = true; if (!cpanel->t1d.paused) tour1d_func(T1DON, gg->current_display, gg); } }
void tour1d_run(displayd *dsp, GGobiSession *gg) { GGobiStage *d = dsp->d; cpaneld *cpanel = &dsp->cpanel; /* static gint count = 0;*/ gboolean revert_random = false; gint pathprob = 0; gint i, nv; extern void t1d_ppdraw_think(displayd *, GGobiSession *); /* Controls interpolation steps */ if (!dsp->t1d.get_new_target && !reached_target(dsp->t1d.tang, dsp->t1d.dist_az, dsp->t1d.target_selection_method,&dsp->t1d.ppval, &dsp->t1d.oppval)) { increment_tour(dsp->t1d.tinc, dsp->t1d.tau, dsp->t1d.dist_az, dsp->t1d.delta, &dsp->t1d.tang, (gint) 1); tour_reproject(dsp->t1d.tinc, dsp->t1d.G, dsp->t1d.Ga, dsp->t1d.Gz, dsp->t1d.F, dsp->t1d.Va, d->n_cols, (gint) 1); /* plot pp indx */ if (dsp->t1d_window != NULL && GTK_WIDGET_VISIBLE (dsp->t1d_window)) { /* if (dsp->t1d_ppda != NULL) {*/ dsp->t1d.oppval = dsp->t1d.ppval; revert_random = t1d_switch_index(cpanel->t1d.pp_indx, 0, dsp, gg); t1d_ppdraw(dsp->t1d.ppval, dsp, gg); } } else { /* we're at the target plane */ if (dsp->t1d.get_new_target) { /* store the pp parameters */ if (dsp->t1d.target_selection_method == TOUR_PP) { /* dsp->t1d_pp_op.index_best = dsp->t1d.ppval; for (j=0; j<dsp->t1d.nactive; j++) dsp->t1d_pp_op.proj_best.vals[0][j] = dsp->t1d.F.vals[0][dsp->t1d.active_vars.els[j]];*/ } } else { /* make sure the ending projection is the same as the target */ if (dsp->t1d.target_selection_method == TOUR_RANDOM) { do_last_increment(dsp->t1d.tinc, dsp->t1d.tau, dsp->t1d.dist_az, (gint) 1); tour_reproject(dsp->t1d.tinc, dsp->t1d.G, dsp->t1d.Ga, dsp->t1d.Gz, dsp->t1d.F, dsp->t1d.Va, d->n_cols, (gint) 1); } } /* now cleanup: store the current basis into the starting basis */ arrayd_copy(&dsp->t1d.F, &dsp->t1d.Fa); nv = 0; for (i=0; i<d->n_cols; i++) if (fabs(dsp->t1d.Fa.vals[0][i]) > 0.01) { nv++; } if (nv == 1 && dsp->t1d.nactive == 1) /* only generate new dir if num of active/used variables is > 2 */ dsp->t1d.get_new_target = true; else { if (dsp->t1d.target_selection_method == TOUR_RANDOM) { gt_basis(dsp->t1d.Fz, dsp->t1d.nactive, dsp->t1d.active_vars, d->n_cols, (gint) 1); } else if (dsp->t1d.target_selection_method == TOUR_PP) { /* pp guided tour */ /* get new target according to the selected pp index */ for (i=0; i<d->n_cols; i++) dsp->t1d.Fz.vals[0][i] = 0.0; dsp->t1d.Fz.vals[0][dsp->t1d.active_vars.els[0]]=1.0; dsp->t1d.oppval = -1.0; t1d_ppdraw_think(dsp, gg); gdk_flush (); revert_random = t1d_switch_index(cpanel->t1d.pp_indx, dsp->t1d.target_selection_method, dsp, gg); if (!revert_random) { for (i=0; i<dsp->t1d.nactive; i++) { if (isfinite((gdouble)dsp->t1d_pp_op.proj_best.vals[0][i]) != 0) dsp->t1d.Fz.vals[0][dsp->t1d.active_vars.els[i]] = dsp->t1d_pp_op.proj_best.vals[0][i]; } dsp->t1d_pp_op.index_best = 0.0; /*g_printerr ("tour_run:index_best %f temp %f \n", dsp->t1d_pp_op.index_best, dsp->t1d_pp_op.temp); g_printerr ("proj: "); for (i=0; i<dsp->t1d_pp_op.proj_best.ncols; i++) g_printerr ("%f ", dsp->t1d_pp_op.proj_best.vals[0][i]); g_printerr ("\n");*/ /* if the best projection is the same as the previous one, switch to a random projection */ /* if (!checkequiv(dsp->t1d.Fa.vals, dsp->t1d.Fz.vals, d->n_cols, 1)) { g_printerr ("Using random projection\n"); gt_basis(dsp->t1d.Fz, dsp->t1d.nactive, dsp->t1d.active_vars, d->n_cols, (gint) 1); for (j=0; j<dsp->t1d.nactive; j++) dsp->t1d_pp_op.proj_best.vals[0][j] = dsp->t1d.Fz.vals[0][dsp->t1d.active_vars.els[j]]; revert_random = t1d_switch_index(cpanel->t1d.pp_indx, dsp->t1d.target_selection_method, dsp, gg); }*/ /* t1d_ppdraw(dsp->t1d.ppval, dsp, gg);*/ /* count = 0;*/ ggobi_sleep(0); } else /* Use random target */ { /* gt_basis(dsp->t1d.Fz, dsp->t1d.nactive, dsp->t1d.active_vars, d->n_cols, (gint) 1); g_printerr ("Using random projection 2\n");*/ } } pathprob = tour_path(dsp->t1d.Fa, dsp->t1d.Fz, dsp->t1d.F, d->n_cols, (gint) 1, dsp->t1d.Ga, dsp->t1d.Gz, dsp->t1d.G, dsp->t1d.lambda, dsp->t1d.tv, dsp->t1d.Va, dsp->t1d.Vz, dsp->t1d.tau, dsp->t1d.tinc, &dsp->t1d.dist_az, &dsp->t1d.tang); if (pathprob == 0) dsp->t1d.get_new_target = false; else if (pathprob == 1) { /* problems with Fa so need to force a jump */ tour1d_scramble(gg); pathprob = tour_path(dsp->t1d.Fa, dsp->t1d.Fz, dsp->t1d.F, d->n_cols, (gint) 1, dsp->t1d.Ga, dsp->t1d.Gz, dsp->t1d.G, dsp->t1d.lambda, dsp->t1d.tv, dsp->t1d.Va, dsp->t1d.Vz, dsp->t1d.tau, dsp->t1d.tinc, &dsp->t1d.dist_az, &dsp->t1d.tang); } else if (pathprob == 2 || pathprob == 3) { /* problems with Fz, so will force a new choice of Fz */ dsp->t1d.get_new_target = true; } } } /* tour_reproject(dsp, 2);*/ #ifdef TESTING_TOUR_STEP { GGobiDisplayClass *klass; klass = GGOBI_DISPLAY_GET_CLASS(dsp); g_signal_emit(G_OBJECT(dsp), klass->signals[TOUR_STEP_SIGNAL], 0, dsp->t1d, (gint) 1, gg); } #endif display_tailpipe (dsp, FULL, gg); varcircles_refresh (d, gg); if (dsp->t1d_video) tour1d_write_video(gg); }