📄 arrange.cpp
字号:
y3 = polar_to_y(r, 90+angle+hangle_l+angle_s) + center_y; x4 = polar_to_x(r, 90+angle+hangle_l+angle_s+angle_l) + center_x; y4 = polar_to_y(r, 90+angle+hangle_l+angle_s+angle_l) + center_y; tl.set(x1, y1, 0); tr.set(x2, y2, 0); bl.set(x3, y3, 0); br.set(x4, y4, 0);#if 0 if (i == 0) { msgout(DEBUG, "hangle_l=%f\n", hangle_l); msgout(DEBUG, "cx=%f cy=%f\n", center_x, center_y); msgout(DEBUG, "r=%f\n", r); msgout(DEBUG, "x=%f y=%f\n", x1, y1); msgout(DEBUG, "x=%f y=%f\n", x2, y2); msgout(DEBUG, "x=%f y=%f\n", x3, y3); msgout(DEBUG, "x=%f y=%f\n", x4, y4); }#endif face_set->set_face (i, tl, tr, bl, br); } goto_face_val = -current_face * between_angle; make_display_list();}int ViewMasterArrangement::get_type () { return FACE_TYPE_VIEWMASTER;}// this has to by overridden because of the 'current_face' variable// which is private to this classvoid ViewMasterArrangement::goto_random_face(void){ int which_one; do { which_one = get_randomi (0, (n_columns * n_rows) - 1); } while (which_one == (current_col + (current_row * n_rows))); current_face = which_one; goto_face (which_one);}void ViewMasterArrangement::goto_right(void) { current_face++; if (current_face == n_faces) current_face = 0; // cycle around // we are "unrolling" rows and columns so map the linear // "current_face" back to rows and columns current_col = current_face % n_columns; current_row = current_face / n_columns; if (goto_face_mv.at_destination()) { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val - per_face_change, cfg->options->face_change_steps, move_type); } else { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() - per_face_change, cfg->options->face_change_steps, move_type); }}void ViewMasterArrangement::goto_left(void) { if (current_face == 0) current_face = n_faces - 1; // cycle around else current_face--; // we are "unrolling" rows and columns so map the linear // "current_face" back to rows and columns current_col = current_face % n_columns; current_row = current_face / n_columns; if (goto_face_mv.at_destination()) { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val + per_face_change, cfg->options->face_change_steps, move_type); } else { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() + per_face_change, cfg->options->face_change_steps, move_type); }}void ViewMasterArrangement::set_current_face (int c, int r) { current_col = c; current_row = r; current_face = c + (r * n_columns); goto_face_val = -current_face * between_angle; goto_face_mv.disable();}float ViewMasterArrangement::get_distant_z_offset(void){ return -(z_offset_distance);}float ViewMasterArrangement::get_base_z_offset(void){ return 0.0;}void ViewMasterArrangement::do_position_GL(void) { glTranslatef(0.0f,0.0f, z_offset); glTranslatef(-center_distance, 0.0f, 0.0f); glRotatef(goto_face_val, 0.0f, 0.0f, 1.0f);}void ViewMasterArrangement::do_movement(void) { if (!goto_face_mv.at_destination()) goto_face_mv.change_a_bit(); else clamp_degrees (&goto_face_val);}// ==============================================================// PriceIsRightArrangement// ==============================================================PriceIsRightArrangement::PriceIsRightArrangement(VDesktops &vdesks, float fw, float fh, FaceSet *fs, Config *c) : Arrangement (fs, c){ face_width = fw; face_height = fh; calculate_faces(vdesks); goto_face_mv.disable();}void PriceIsRightArrangement::calculate_faces(VDesktops & vdesks){ vdesks.get_vdesktop_info (¤t_col, ¤t_row, &n_columns, &n_rows); // current_face becomes the unrolled current face current_face = current_col + (current_row * n_columns); // n_faces becomes the total number of desktops n_faces = n_columns * n_rows; side_angle = 360.0 / (float)n_faces; per_face_change = -side_angle; goto_face_val = 360 + (side_angle * current_face); float circum = face_height * 1.8 * n_faces; radius = circum / (2.0 * PI); float my_angle = ((FOV / 2.0) * PI) / 180.0; z_offset_close = z_offset = -(float)((face_height/2.0) / tan(my_angle) + get_base_z_offset()); int i; float half_face_height = face_height / 2.0; float half_face_width = face_width / 2.0; Point tl,tr,bl,br; for (i = 0; i < n_faces; i++) { tl.set (-half_face_width, half_face_height, 0); tr.set ( half_face_width, half_face_height, 0); bl.set (-half_face_width, -half_face_height, 0); br.set ( half_face_width, -half_face_height, 0); translate (tl.v, 0, 0, radius); rotate_x (tl.v, -side_angle * i); translate (tr.v, 0, 0, radius); rotate_x (tr.v, -side_angle * i); translate (bl.v, 0, 0, radius); rotate_x (bl.v, -side_angle * i); translate (br.v, 0, 0, radius); rotate_x (br.v, -side_angle * i); //msgout(DEBUG, "[%i] = %f, %f, %f\n", i, tl.v[0], tl.v[1], tl.v[2]); face_set->set_face (i, tl, tr, bl, br); } make_display_list();}int PriceIsRightArrangement::get_type () { return FACE_TYPE_PRICEISRIGHT;}// this has to by overridden because of the 'current_face' variable// which is private to this classvoid PriceIsRightArrangement::goto_random_face(void){ int which_one; do { which_one = get_randomi (0, (n_columns * n_rows) - 1); } while (which_one == (current_col + (current_row * n_rows))); current_face = which_one; goto_face (which_one);}void PriceIsRightArrangement::goto_right(void) { current_face++; if (current_face == n_faces) current_face = 0; // cycle around // we are "unrolling" rows and columns so map the linear // "current_face" back to rows and columns current_col = current_face % n_columns; current_row = current_face / n_columns; if (goto_face_mv.at_destination()) { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val - per_face_change, cfg->options->face_change_steps, move_type); } else { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() - per_face_change, cfg->options->face_change_steps, move_type); }}void PriceIsRightArrangement::goto_left(void) { if (current_face == 0) current_face = n_faces - 1; // cycle around else current_face--; // we are "unrolling" rows and columns so map the linear // "current_face" back to rows and columns current_col = current_face % n_columns; current_row = current_face / n_columns; if (goto_face_mv.at_destination()) { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val + per_face_change, cfg->options->face_change_steps, move_type); } else { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() + per_face_change, cfg->options->face_change_steps, move_type); }}void PriceIsRightArrangement::set_current_face (int c, int r) { current_col = c; current_row = r; current_face = c + (r * n_columns); goto_face_val = 360 + (side_angle * current_face); goto_face_mv.disable();}float PriceIsRightArrangement::get_distant_z_offset(void) { return -(z_offset_distance + get_base_z_offset());}float PriceIsRightArrangement::get_base_z_offset(void) { return (radius ); //(face_width/2.0) / tan (deg_to_rad(side_angle/2.0)));}void PriceIsRightArrangement::do_movement(void) { if (!goto_face_mv.at_destination()) goto_face_mv.change_a_bit (); else clamp_degrees(&goto_face_val);}void PriceIsRightArrangement::do_position_GL(void) { glTranslatef(0.0f,0.0f, z_offset); glRotatef(goto_face_val, 1.0f, 0.0f, 0.0f);}// ==============================================================// LinearArrangement// ==============================================================LinearArrangement::LinearArrangement(VDesktops &vdesks, float fw, float fh, FaceSet *fs, Config *c) : Arrangement (fs, c){ z_offset_distance = 10.0; spin_z_rot = 0; //cfg->options->zoom_steps = 60; face_width = fw; face_height = fh; calculate_faces(vdesks); x_trans_mv.disable(); y_trans_mv.disable(); spin_mv.disable();}void LinearArrangement::calculate_faces(VDesktops & vdesks){ vdesks.get_vdesktop_info (¤t_col, ¤t_row, &n_columns, &n_rows); between = cfg->options->linear_spacing; float my_angle = ((FOV / 2.0) * PI) / 180.0; z_offset_close = z_offset = -(float)((face_height/2.0) / tan(my_angle) + get_base_z_offset()); //msgout(DEBUG, "z_offset_close = %lf\n", z_offset_close); Point tl,tr,bl,br; int i, j, count = 0; float x, y; float half_face_height = face_height / 2.0; float half_face_width = face_width / 2.0; X_Trans = -(half_face_width + (current_col * (face_width + between))); Y_Trans = ((current_row * (face_height + between)) + half_face_height); //msgout (DEBUG, "constructor: Y_Trans = %f\n", Y_Trans); for (i = 0; i < n_rows; i++) { for (j = 0; j < n_columns; j++) { y = i * (face_height + between); x = j * (face_width + between); tl.set(x, -y, 0); tr.set(x + face_width, -y, 0); bl.set(x, -y - face_height, 0); br.set(x + face_width, -y - face_height, 0); face_set->set_face (count, tl, tr, bl, br); count ++; } } make_display_list();}int LinearArrangement::get_type () { return FACE_TYPE_LINEAR;}void LinearArrangement::set_current_face (int c, int r) { float half_face_width = face_width / 2.0; float half_face_height = face_height / 2.0; current_row = r; current_col = c; X_Trans = -(half_face_width + (current_col * (face_width + between))); Y_Trans = ((current_row * (face_height + between)) + half_face_height); msgout (DEBUG, "set_current_face: Y_Trans = %f, " "current_col=%d, current_row=%d, face_height=%f, " "between=%f, hfh=%f\n", Y_Trans, current_col, current_row, face_height, between, half_face_height); x_trans_mv.disable(); y_trans_mv.disable();}float LinearArrangement::get_distant_z_offset(void){ return -(z_offset_distance);}float LinearArrangement::get_base_z_offset(void){ return 0.0;}int LinearArrangement::in_goto (void){ return !x_trans_mv.at_destination() || !y_trans_mv.at_destination();}void LinearArrangement::goto_left(void) { if (current_col != 0) current_col--; else return; if (x_trans_mv.at_destination()) { //if ((X_Trans + (face_width+between)) > MIN_X_Trans) // because its negative // break; x_trans_mv.init (&X_Trans, X_Trans, X_Trans + (face_width+between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { //if ((x_trans_mv.destination() + (face_width+between)) > MIN_X_Trans) // because its negative // break; x_trans_mv.init (&X_Trans, X_Trans, x_trans_mv.destination() + (face_width+between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); }}void LinearArrangement::goto_right(void) { if (current_col != (n_columns - 1)) current_col++; else return; if (x_trans_mv.at_destination()) { x_trans_mv.init (&X_Trans, X_Trans, X_Trans - (face_width + between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { x_trans_mv.init (&X_Trans, X_Trans, x_trans_mv.destination() - (face_width+between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); }}void LinearArrangement::goto_up(void){ if (current_row != 0) current_row--; else return; if (y_trans_mv.at_destination()) { y_trans_mv.init (&Y_Trans, Y_Trans, Y_Trans - (face_height+between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { y_trans_mv.init (&Y_Trans, Y_Trans, y_trans_mv.destination() - (face_height+between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -