/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_complex_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) { int x, y; g_return_if_fail( object != NULL ); g_return_if_fail( (object->type == OBJ_COMPLEX || object->type == OBJ_PLACEHOLDER) ); g_return_if_fail( object->complex != NULL ); x = 2 * world_centerx - object->complex->x; y = object->complex->y; o_complex_translate_world(toplevel, -object->complex->x, -object->complex->y, object); o_glist_mirror_world (toplevel, 0, 0, object->complex->prim_objs); switch(object->complex->angle) { case(90): object->complex->angle = 270; break; case(270): object->complex->angle = 90; break; } object->complex->mirror = !object->complex->mirror; o_complex_translate_world(toplevel, x, y, object); }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_mirror_world_update(GschemToplevel *w_current, int centerx, int centery, GList *list) { TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current); OBJECT *o_current; GList *o_iter; if (list == NULL) { i_action_stop (w_current); i_set_state(w_current, SELECT); return; } o_invalidate_glist (w_current, list); /* Find connected objects, removing each object in turn from the * connection list. We only _really_ want those objects connected * to the selection, not those within in it. */ for (o_iter = list; o_iter != NULL; o_iter = g_list_next (o_iter)) { o_current = o_iter->data; s_conn_remove_object_connections (toplevel, o_current); } o_glist_mirror_world( toplevel, centerx, centery, list ); /* Find connected objects, adding each object in turn back to the * connection list. We only _really_ want those objects connected * to the selection, not those within in it. */ for (o_iter = list; o_iter != NULL; o_iter = g_list_next (o_iter)) { o_current = o_iter->data; s_conn_update_object (o_current->page, o_current); } o_invalidate_glist (w_current, list); /* Run mirror-objects-hook */ g_run_hook_object_list (w_current, "%mirror-objects-hook", list); gschem_toplevel_page_content_changed (w_current, toplevel->page_current); o_undo_savestate_old(w_current, UNDO_ALL); if (w_current->event_state == MIRRORMODE) { i_set_state(w_current, SELECT); } }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_mirror_world_update(GSCHEM_TOPLEVEL *w_current, int centerx, int centery, GList *list) { TOPLEVEL *toplevel = w_current->toplevel; OBJECT *o_current; GList *o_iter; if (list == NULL) { w_current->inside_action = 0; i_set_state(w_current, SELECT); return; } o_invalidate_glist (w_current, list); /* Find connected objects, removing each object in turn from the * connection list. We only _really_ want those objects connected * to the selection, not those within in it. */ for (o_iter = list; o_iter != NULL; o_iter = g_list_next (o_iter)) { o_current = o_iter->data; s_conn_remove_object (toplevel, o_current); } o_glist_mirror_world( toplevel, centerx, centery, list ); /* Find connected objects, adding each object in turn back to the * connection list. We only _really_ want those objects connected * to the selection, not those within in it. */ for (o_iter = list; o_iter != NULL; o_iter = g_list_next (o_iter)) { o_current = o_iter->data; s_conn_update_object (toplevel, o_current); } o_invalidate_glist (w_current, list); /* Run mirror-objects-hook */ g_run_hook_object_list ("%mirror-objects-hook", list); toplevel->page_current->CHANGED=1; o_undo_savestate(w_current, UNDO_ALL); }
/*! \brief Mirror the objects being placed * * \par Function Description * This function erases the objects in the place list, mirrors * them, runs %mirror-objects-hook, and redraws the objects after * mirroring. * * \param [in] w_current The GschemToplevel object. */ void o_place_mirror (GschemToplevel *w_current) { GschemPageView *page_view = gschem_toplevel_get_current_page_view (w_current); g_return_if_fail (page_view != NULL); PAGE *page = gschem_page_view_get_page (page_view); g_return_if_fail (page != NULL); o_place_invalidate_rubber (w_current, FALSE); o_glist_mirror_world (page->toplevel, w_current->first_wx, w_current->first_wy, page->place_list); /* Run mirror-objects-hook */ g_run_hook_object_list (w_current, "%mirror-objects-hook", page->place_list); o_place_invalidate_rubber (w_current, TRUE); }
/*! \brief * \par Function Description * */ OBJECT *o_complex_new(TOPLEVEL *toplevel, char type, int color, int x, int y, int angle, int mirror, const CLibSymbol *clib, const gchar *basename, int selectable) { OBJECT *new_node=NULL; OBJECT *new_prim_obj; GList *prim_objs; GList *iter; int loaded_normally = FALSE; gchar *buffer = NULL; new_node = s_basic_new_object(type, "complex"); if (clib != NULL) { new_node->complex_basename = g_strdup (s_clib_symbol_get_name (clib)); } else { new_node->complex_basename = g_strdup (basename); } new_node->complex_embedded = FALSE; new_node->color = color; new_node->selectable = selectable; new_node->complex = (COMPLEX *) g_malloc(sizeof(COMPLEX)); new_node->complex->angle = angle; new_node->complex->mirror = mirror; new_node->complex->x = x; new_node->complex->y = y; prim_objs = NULL; /* get the symbol data */ if (clib != NULL) { buffer = s_clib_symbol_get_data (clib); } if (clib == NULL || buffer == NULL) { char *not_found_text = NULL; int left, right, top, bottom; int x_offset, y_offset; /* filename was NOT found */ loaded_normally = FALSE; /* Put placeholder into object list. Changed by SDB on * 1.19.2005 to fix problem that symbols were silently * deleted by gattrib when RC files were messed up. */ new_node->type = OBJ_PLACEHOLDER; /* Mark the origin of the missing component */ new_prim_obj = o_line_new(toplevel, OBJ_LINE, DETACHED_ATTRIBUTE_COLOR, x - 50, y, x + 50, y); prim_objs = g_list_append (prim_objs, new_prim_obj); new_prim_obj = o_line_new(toplevel, OBJ_LINE, DETACHED_ATTRIBUTE_COLOR, x, y + 50, x, y - 50); prim_objs = g_list_append (prim_objs, new_prim_obj); /* Add some useful text */ not_found_text = g_strdup_printf (_("Component not found:\n %s"), new_node->complex_basename); new_prim_obj = o_text_new(toplevel, OBJ_TEXT, DETACHED_ATTRIBUTE_COLOR, x + NOT_FOUND_TEXT_X, y + NOT_FOUND_TEXT_Y, LOWER_LEFT, 0, not_found_text, 8, VISIBLE, SHOW_NAME_VALUE); prim_objs = g_list_append (prim_objs, new_prim_obj); g_free(not_found_text); /* figure out where to put the hazard triangle */ world_get_text_bounds (toplevel, new_prim_obj, &left, &top, &right, &bottom); x_offset = (right - left) / 4; y_offset = bottom - top + 100; /* 100 is just an additional offset */ /* add hazard triangle */ new_prim_obj = o_line_new(toplevel, OBJ_LINE, DETACHED_ATTRIBUTE_COLOR, x + NOT_FOUND_TEXT_X + x_offset, y + NOT_FOUND_TEXT_Y + y_offset, x + NOT_FOUND_TEXT_X + x_offset + 600, y + NOT_FOUND_TEXT_Y + y_offset); o_set_line_options(toplevel, new_prim_obj, END_ROUND, TYPE_SOLID, 50, -1, -1); prim_objs = g_list_append (prim_objs, new_prim_obj); new_prim_obj = o_line_new(toplevel, OBJ_LINE, DETACHED_ATTRIBUTE_COLOR, x + NOT_FOUND_TEXT_X + x_offset, y + NOT_FOUND_TEXT_Y + y_offset, x + NOT_FOUND_TEXT_X + x_offset + 300, y + NOT_FOUND_TEXT_Y + y_offset + 500); o_set_line_options(toplevel, new_prim_obj, END_ROUND, TYPE_SOLID, 50, -1, -1); prim_objs = g_list_append (prim_objs, new_prim_obj); new_prim_obj = o_line_new(toplevel, OBJ_LINE, DETACHED_ATTRIBUTE_COLOR, x + NOT_FOUND_TEXT_X + x_offset + 300, y + NOT_FOUND_TEXT_Y + y_offset + 500, x + NOT_FOUND_TEXT_X + x_offset + 600, y + NOT_FOUND_TEXT_Y + y_offset); o_set_line_options(toplevel, new_prim_obj, END_ROUND, TYPE_SOLID, 50, -1, -1); prim_objs = g_list_append (prim_objs, new_prim_obj); new_prim_obj = o_text_new(toplevel, OBJ_TEXT, DETACHED_ATTRIBUTE_COLOR, x + NOT_FOUND_TEXT_X + x_offset + 270, y + NOT_FOUND_TEXT_Y + y_offset + 90, LOWER_LEFT, 0, "!", 18, VISIBLE, SHOW_NAME_VALUE); prim_objs = g_list_append (prim_objs, new_prim_obj); } else { /* filename was found */ loaded_normally = TRUE; /* add connections till translated */ prim_objs = o_read_buffer (toplevel, prim_objs, buffer, -1, new_node->complex_basename); g_free (buffer); } /* do not mirror/rotate/translate/connect the primitive objects if the * component was not loaded via o_read */ if (loaded_normally == TRUE) { if (mirror) { o_glist_mirror_world (toplevel, 0, 0, prim_objs); } o_glist_rotate_world (toplevel, 0, 0, angle, prim_objs); o_glist_translate_world (toplevel, x, y, prim_objs); } new_node->complex->prim_objs = prim_objs; /* set the parent field now */ for (iter = prim_objs; iter != NULL; iter = g_list_next (iter)) { OBJECT *tmp = iter->data; tmp->parent = new_node; } o_complex_recalc(toplevel, new_node); return new_node; }