static void cv_tree_move(chan * ch, int delta) { GtkTreeIter parent; /* do nothing if this is a server row */ if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(ch->cv->store), &parent, &ch->iter)) move_row(ch, delta, &parent); }
// move - move into the given direction unsigned move(board b, dir d, int* moved) { unsigned i; unsigned s=0; *moved = 0; for (i=0; i<4; i++) { s += move_row(&b[start[d]+i*row_inc[d]], col_inc[d], moved); } return s; }
int Ndb_move_data::move_batch() { int ret = 0; Op& op = m_op; op.rows_in_batch = 0; op.truncated_in_batch = 0; do { int res; CHK2((res = op.scanop->nextResult(true)) != -1, (op.scanop->getNdbError())); require(res == 0 || res == 1); if (res == 1) { op.end_of_scan = true; op.ndb->closeTransaction(op.scantrans); op.scantrans = 0; break; } require(op.updatetrans == 0); op.updatetrans = op.ndb->startTransaction(); CHK2(op.updatetrans != 0, (op.ndb->getNdbError())); do { CHK1(move_row() == 0); op.rows_in_batch++; CHK2((res = op.scanop->nextResult(false)) != -1, (op.scanop->getNdbError())); require(res == 0 || res == 2); } while (res == 0); CHK1(ret == 0); if (m_error_insert && ndb_rand() % 5 == 0) { invoke_error_insert(); CHK1(false); } CHK2(op.updatetrans->execute(NdbTransaction::Commit) == 0, (op.updatetrans->getNdbError())); op.ndb->closeTransaction(op.updatetrans); op.updatetrans = 0; } while (0); release_data(); return ret; }
static gboolean view_column_model_drag_data_received (GtkTreeDragDest *drag_dest, GtkTreePath *dest, GtkSelectionData *selection_data) { GtkTreeModel *src_model; GtkTreePath *src_path = NULL; gboolean retval = FALSE; if (gtk_tree_get_row_drag_data (selection_data, &src_model, &src_path)) { GtkTreeIter src_iter; GtkTreeIter dest_iter; gboolean have_dest; /* We are a little lazy here, and assume if we can't convert dest * to an iter, we need to append. See gtkliststore.c for a more * careful handling of this. */ have_dest = gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_dest), &dest_iter, dest); if (gtk_tree_model_get_iter (src_model, &src_iter, src_path)) { if (src_model == left_tree_model || src_model == top_right_tree_model || src_model == bottom_right_tree_model) { move_row (src_model, &src_iter, GTK_TREE_MODEL (drag_dest), have_dest ? &dest_iter : NULL); retval = TRUE; } } gtk_tree_path_free (src_path); } return retval; }
int compute_M_shift_start(double new_t_start, int k, int new_position, int flavor_ins, MAT & M, const operator_container_t & annihilation_operators, const HYB & F, double BETA, SCALAR det_rat) { std::vector<SCALAR> R(M.size1(), 0), M_k(M.size1(), 0), Fs(M.size1(), 0); operator_container_t::const_iterator ita = annihilation_operators.begin(); for (int i = 0; i < (int) M_k.size(); i++) { M_k[i] = M(k, i); Fs[i] = interpolate_F(ita->time() - new_t_start, BETA, F[ita->flavor()][flavor_ins]); ita++; } for (int i = 0; i < (int) R.size(); i++) { if (i != k) { for (int j = 0; j < (int) R.size(); j++) R[i] += M(i, j) * Fs[j]; } } for (int n = 0; n < (int) M.size1(); n++) { if (n != k) { for (int m = 0; m < (int) M.size1(); m++) { M(n, m) -= M_k[m] * R[n] / det_rat; } } else { for (int m = 0; m < (int) M.size1(); m++) { M(n, m) = M_k[m] / det_rat; } } } //swap rows move_row(M, k, new_position); return std::abs(k-new_position); }
static void cv_tree_move_family (chan *ch, int delta) { move_row (ch, delta, NULL); }
int init_pan_or_recalc(int do_zoomout) /* decide to recalc, or to chg worklist & pan */ { int i,j,row,col,y,alignmask,listfull; if (zwidth == 0.0) return(0); /* no zoombox, leave calc_status as is */ /* got a zoombox */ if ((alignmask=check_pan()-1) < 0) { calc_status = 0; /* can't pan, trigger recalc */ return(0); } if (zbx == 0.0 && zby == 0.0) { clearbox(); return(0); } /* box is full screen, leave calc_status as is */ col = (int)(zbx*(dxsize+PIXELROUND)); /* calc dest col,row of topleft pixel */ row = (int)(zby*(dysize+PIXELROUND)); if (do_zoomout) { /* invert row and col */ row = 0-row; col = 0-col; } if ((row&alignmask) != 0 || (col&alignmask) != 0) { calc_status = 0; /* not on useable pixel alignment, trigger recalc */ return(0); } /* pan */ num_worklist = 0; if (calc_status == 2) { start_resume(); get_resume(sizeof(int),&num_worklist,sizeof(worklist),worklist,0); } /* don't do end_resume! we might still change our mind */ /* adjust existing worklist entries */ for (i=0; i<num_worklist; ++i) { worklist[i].yystart -= row; worklist[i].yystop -= row; worklist[i].yybegin -= row; worklist[i].xxstart -= col; worklist[i].xxstop -= col; } /* add worklist entries for the new edges */ listfull = i = 0; j = ydots-1; if (row < 0) { listfull |= add_worklist(0,xdots-1,0,0-row-1,0,0,0); i = 0 - row; } if (row > 0) { listfull |= add_worklist(0,xdots-1,ydots-row,ydots-1,ydots-row,0,0); j = ydots - row - 1; } if (col < 0) listfull |= add_worklist(0,0-col-1,i,j,i,0,0); if (col > 0) listfull |= add_worklist(xdots-col,xdots-1,i,j,i,0,0); if (listfull != 0) { static FCODE msg[] = {"\ Tables full, can't pan current image.\n\ Cancel resumes old image, continue pans and calculates a new one."}; if (stopmsg(2,msg)) { zwidth = 0; /* cancel the zoombox */ drawbox(1); } else calc_status = 0; /* trigger recalc */ return(0); } /* now we're committed */ calc_status = 2; clearbox(); if (row > 0) /* move image up */ for (y=0; y<ydots; ++y) move_row(y+row,y,col); else /* move image down */ for (y=ydots; --y>=0;) move_row(y+row,y,col); fix_worklist(); /* fixup any out of bounds worklist entries */ alloc_resume(sizeof(worklist)+10,1); /* post the new worklist */ put_resume(sizeof(int),&num_worklist,sizeof(worklist),worklist,0); return(0); }