gschem
|
#include <config.h>
#include <stdio.h>
#include <math.h>
#include "gschem.h"
Go to the source code of this file.
Defines | |
#define | GET_BOX_WIDTH(w) abs((w)->second_wx - (w)->first_wx) |
#define | GET_BOX_HEIGHT(w) abs((w)->second_wy - (w)->first_wy) |
#define | GET_PICTURE_WIDTH(w) abs((w)->second_wx - (w)->first_wx) |
#define | GET_PICTURE_HEIGHT(w) (w)->pixbuf_wh_ratio == 0 ? 0 : abs((w)->second_wx - (w)->first_wx)/(w)->pixbuf_wh_ratio |
#define | GET_PICTURE_LEFT(w) min((w)->first_wx, (w)->second_wx) |
#define | GET_PICTURE_TOP(w) |
Functions | |
OBJECT * | o_grips_search_world (GSCHEM_TOPLEVEL *w_current, int x, int y, int *whichone) |
Check if point is inside grip. | |
static gboolean | inside_grip (int x, int y, int grip_x, int grip_y, int size) |
Check if pointer is inside the grip region. | |
OBJECT * | o_grips_search_arc_world (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int size, int *whichone) |
Check if pointer is inside arc grip. | |
OBJECT * | o_grips_search_box_world (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int size, int *whichone) |
Check if pointer is inside box grip. | |
OBJECT * | o_grips_search_path_world (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int size, int *whichone) |
Check if pointer is inside path grip. | |
OBJECT * | o_grips_search_picture_world (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int size, int *whichone) |
Check if pointer is inside picture grip. | |
OBJECT * | o_grips_search_circle_world (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int size, int *whichone) |
Check if pointer is inside circle grip. | |
OBJECT * | o_grips_search_line_world (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int size, int *whichone) |
Check if pointer is inside line grip. | |
static void | o_grips_start_arc (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int whichone) |
Initialize grip motion process for an arc. | |
static void | o_grips_start_box (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int whichone) |
Initialize grip motion process for a box. | |
static void | o_grips_start_path (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int whichone) |
Initialize grip motion process for a path. | |
static void | o_grips_start_picture (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int whichone) |
Initialize grip motion process for a picture. | |
static void | o_grips_start_circle (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int whichone) |
Initialize grip motion process for a circle. | |
static void | o_grips_start_line (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int x, int y, int whichone) |
Initialize grip motion process for a line. This function starts the move of one of the two grips of the line object o_current. | |
int | o_grips_start (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y) |
Start process of modifiying one grip. | |
void | o_grips_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y) |
Modify previously selected object according to mouse position. | |
void | o_grips_cancel (GSCHEM_TOPLEVEL *w_current) |
Cancel process of modifying object with grip. | |
static void | o_grips_end_arc (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying arc object with grip. | |
static void | o_grips_end_box (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying box object with grip. | |
static void | o_grips_end_path (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying path object with grip. | |
static void | o_grips_end_picture (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying picture object with grip. | |
static void | o_grips_end_circle (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying circle object with grip. | |
static void | o_grips_end_line (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying line object with grip. | |
static void | o_grips_end_net (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying net object with grip. | |
static void | o_grips_end_pin (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying pin object with grip. | |
static void | o_grips_end_bus (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int whichone) |
End process of modifying bus object with grip. | |
void | o_grips_end (GSCHEM_TOPLEVEL *w_current) |
End process of modifying object with grip. | |
int | o_grips_size (GSCHEM_TOPLEVEL *w_current) |
Get half the width and height of grip in screen units. | |
void | o_grips_draw (GSCHEM_TOPLEVEL *w_current, int wx, int wy) |
Draw grip centered at x, y | |
void | o_grips_draw_rubber (GSCHEM_TOPLEVEL *w_current) |
Draw objects being grip maniuplated from GSCHEM_TOPLEVEL object. |
#define GET_BOX_WIDTH | ( | w | ) | abs((w)->second_wx - (w)->first_wx) |
#define GET_BOX_HEIGHT | ( | w | ) | abs((w)->second_wy - (w)->first_wy) |
#define GET_PICTURE_WIDTH | ( | w | ) | abs((w)->second_wx - (w)->first_wx) |
#define GET_PICTURE_HEIGHT | ( | w | ) | (w)->pixbuf_wh_ratio == 0 ? 0 : abs((w)->second_wx - (w)->first_wx)/(w)->pixbuf_wh_ratio |
#define GET_PICTURE_LEFT | ( | w | ) | min((w)->first_wx, (w)->second_wx) |
#define GET_PICTURE_TOP | ( | w | ) |
OBJECT* o_grips_search_world | ( | GSCHEM_TOPLEVEL * | w_current, |
int | x, | ||
int | y, | ||
int * | whichone | ||
) |
A specific search function is provided for every kind of graphical object. The list of selected object is covered : each object is tested with the appropriate function.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 67 of file o_grips.c.
static gboolean inside_grip | ( | int | x, |
int | y, | ||
int | grip_x, | ||
int | grip_y, | ||
int | size | ||
) | [static] |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | grip_x | Current x coordinate of grip center in world units. |
[in] | grip_y | Current y coordinate of grip center in world units. |
[in] | size | Half the width of the grip square in world units. |
OBJECT* o_grips_search_arc_world | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | size, | ||
int * | whichone | ||
) |
An arc object has three grips :
The x and y parameters are in world units.
The size parameter is the width (and height) of the square representing a grip in world units.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Arc OBJECT to check. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | size | Half the width of the grip square in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 206 of file o_grips.c.
OBJECT* o_grips_search_box_world | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | size, | ||
int * | whichone | ||
) |
A box object has four grips : one at each corner of the box. The identifiers of each corner are BOX_UPPER_LEFT, BOX_UPPER_RIGHT, BOX_LOWER_LEFT and BOX_LOWER_RIGHT.
The x and y parameters are in world units.
The size parameter is half the width (and half the height) of the square representing a grip in world units.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Box OBJECT to check. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | size | Half the width of the grip square in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 271 of file o_grips.c.
OBJECT* o_grips_search_path_world | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | size, | ||
int * | whichone | ||
) |
A path object has four grips : one at each corner of the path. The identifiers of each corner are #PICTURE_UPPER_LEFT, #PICTURE_UPPER_RIGHT, #PICTURE_LOWER_LEFT and #PICTURE_LOWER_RIGHT.
The x and y parameters are in world units.
The size parameter is half the width (and half the height) of the square representing a grip in world units.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Picture OBJECT to check. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | size | Half the width of the grip square in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 336 of file o_grips.c.
OBJECT* o_grips_search_picture_world | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | size, | ||
int * | whichone | ||
) |
A picture object has four grips : one at each corner of the picture. The identifiers of each corner are #PICTURE_UPPER_LEFT, #PICTURE_UPPER_RIGHT, #PICTURE_LOWER_LEFT and #PICTURE_LOWER_RIGHT.
The x and y parameters are in world units.
The size parameter is half the width (and half the height) of the square representing a grip in world units.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Picture OBJECT to check. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | size | Half the width of the grip square in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 406 of file o_grips.c.
OBJECT* o_grips_search_circle_world | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | size, | ||
int * | whichone | ||
) |
The parameter size is half the size of the grip in world units.
A circle has only one grip on the lower right corner of the box it is inscribed in. Moving this grip change the radius of the circle. The identifier of this grip is CIRCLE_RADIUS.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Circle OBJECT to check. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | size | Half the width of the grip square in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 469 of file o_grips.c.
OBJECT* o_grips_search_line_world | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | size, | ||
int * | whichone | ||
) |
The parameter size is half the size of the grip in world units.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Line OBJECT to check. |
[in] | x | Current x coordinate of pointer in world units. |
[in] | y | Current y coordinate of pointer in world units. |
[in] | size | Half the width of the grip square in world units. |
[out] | whichone | Which grip point is selected. |
Definition at line 504 of file o_grips.c.
static void o_grips_start_arc | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | whichone | ||
) | [static] |
The coordinates of the center of the arc on x- and y-axis are stored into the first_wx and first_wy fields of the GSCHEM_TOPLEVEL structure in screen units.
The radius of the center is stored into the distance field of the GSCHEM_TOPLEVEL structure in screen units.
The two angles describing the arc on a circle are stored into the second_wx for the starting angle and second_wy for the ending angle. These angles are expressed in degrees.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Arc OBJECT to check. |
[in] | x | (unused) |
[in] | y | (unused) |
[out] | whichone | (unused) |
static void o_grips_start_box | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | whichone | ||
) | [static] |
The function first erases the grips.
The coordinates of the selected corner are put in (w_current->second_wx,w_current->second_wx).
The coordinates of the opposite corner go in (w_current->first_wx,w_current->first_wy). They are not suppose to change during the action.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Box OBJECT to check. |
[in] | x | (unused) |
[in] | y | (unused) |
[out] | whichone | Which coordinate to check. |
static void o_grips_start_path | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | whichone | ||
) | [static] |
The function first erases the grips.
The coordinates of the selected corner are put in (w_current->second_wx,w_current->second_wy).
The coordinates of the opposite corner go in (w_current->first_wx,w_current->first_wy). They are not suppose to change during the action.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Picture OBJECT to check. |
[in] | x | (unused) |
[in] | y | (unused) |
[out] | whichone | Which coordinate to check. |
static void o_grips_start_picture | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | whichone | ||
) | [static] |
The function first erases the grips.
The coordinates of the selected corner are put in (w_current->second_wx,w_current->second_wy).
The coordinates of the opposite corner go in (w_current->first_wx,w_current->first_wy). They are not suppose to change during the action.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Picture OBJECT to check. |
[in] | x | (unused) |
[in] | y | (unused) |
[out] | whichone | Which coordinate to check. |
static void o_grips_start_circle | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | whichone | ||
) | [static] |
The function first erases the grips.
The coordinates of the center are put in (w_current->first_wx,w_current->first_wy). They are not suppose to change during the action.
The radius of the circle is stored in w_current->distance.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Circle OBJECT to check. |
[in] | x | (unused) |
[in] | y | (unused) |
[out] | whichone | Which coordinate to check. |
static void o_grips_start_line | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | x, | ||
int | y, | ||
int | whichone | ||
) | [static] |
During the move of the grip, the line is described by (w_current->first_wx,w_current->first_wy) and (w_current->second_wx,w_current->second_wy).
The line end that corresponds to the moving grip is in (w_current->second_wx,w_current->second_wy).
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Line OBJECT to check. |
[in] | x | (unused) |
[in] | y | (unused) |
[out] | whichone | Which coordinate to check. |
int o_grips_start | ( | GSCHEM_TOPLEVEL * | w_current, |
int | w_x, | ||
int | w_y | ||
) |
The function returns FALSE if an error occured or if no grip have been found under (w_x,w_y). It returns TRUE if a grip has been found and modification of the object has been started.
If a grip has been found, this function modifies the GSCHEM_TOPLEVEL variables which_grip and which_object with the identifier of the grip and the object it belongs to respectively.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | w_x | Current x coordinate of pointer in world units. |
[in] | w_y | Current y coordinate of pointer in world units. |
Definition at line 862 of file o_grips.c.
void o_grips_motion | ( | GSCHEM_TOPLEVEL * | w_current, |
int | w_x, | ||
int | w_y | ||
) |
The object under modification is w_current->which_object and the grip concerned is w_current->which_grip.
Depending on the object type, a specific function is used. It erases the temporary object, updates its internal representation, and draws it again.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | w_x | Current x coordinate of pointer in world units. |
[in] | w_y | Current y coordinate of pointer in world units. |
Definition at line 945 of file o_grips.c.
void o_grips_cancel | ( | GSCHEM_TOPLEVEL * | w_current | ) |
static void o_grips_end_arc | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
If the grip at the center of the arc has been moved - modifying the radius of the arc -, the new radius is calculated expressed in world unit (the center is unchanged). It is updated with the function #o_arc_modify().
If one of the end of arc grip has been moved - modifying one of the angles describing the arc -, this angle is updated with the #o_arc_modify() function.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Arc OBJECT to end modification on. |
[in] | whichone | Which grip is pointed to. |
static void o_grips_end_box | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
static void o_grips_end_path | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
static void o_grips_end_picture | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
static void o_grips_end_circle | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
A circle with a null radius is not allowed. In this case, the process is stopped and the circle is left unchanged.
The last value of the radius is in w_current->distance in screen units.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Circle OBJECT to end modification on. |
[in] | whichone | Which grip is pointed to. |
Definition at line 1161 of file o_grips.c.
static void o_grips_end_line | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
A line with a null width, i.e. when both ends are identical, is not allowed. In this case, the process is stopped and the line unchanged.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Line OBJECT to end modification on. |
[in] | whichone | Which grip is pointed to. |
Definition at line 1195 of file o_grips.c.
static void o_grips_end_net | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
A net with zero length, i.e. when both ends are identical, is not allowed. In this case, the process is stopped and the line unchanged.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Net OBJECT to end modification on. |
[in] | whichone | Which grip is pointed to. |
Definition at line 1232 of file o_grips.c.
static void o_grips_end_pin | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
A pin with zero length, i.e. when both ends are identical, is not allowed. In this case, the process is stopped and the line unchanged.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | Net OBJECT to end modification on. |
[in] | whichone | Which grip is pointed to. |
Definition at line 1274 of file o_grips.c.
static void o_grips_end_bus | ( | GSCHEM_TOPLEVEL * | w_current, |
OBJECT * | o_current, | ||
int | whichone | ||
) | [static] |
A bus with zero length, i.e. when both ends are identical, is not allowed. In this case, the process is stopped and the bus unchanged.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | o_current | bus OBJECT to end modification on. |
[in] | whichone | Which grip is pointed to. |
Definition at line 1310 of file o_grips.c.
void o_grips_end | ( | GSCHEM_TOPLEVEL * | w_current | ) |
The object under modification is w_current->which_object and the grip concerned is w_current->which_grip.
Depending on the object type, a specific function is used. It erases the temporary object, updates the object and draws the modified object normally.
[in,out] | w_current | The GSCHEM_TOPLEVEL object. |
Definition at line 1347 of file o_grips.c.
int o_grips_size | ( | GSCHEM_TOPLEVEL * | w_current | ) |
GRIP_SIZE1 and GRIP_SIZE2 and GRIP_SIZE3 are macros defined in gschem_defines.h. They are the half width/height of a grip in world unit for a determined range of zoom factors.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
Definition at line 1441 of file o_grips.c.
void o_grips_draw | ( | GSCHEM_TOPLEVEL * | w_current, |
int | wx, | ||
int | wy | ||
) |
The size of the grip depends on the current zoom factor.
x and y are in screen unit.
[in] | w_current | The GSCHEM_TOPLEVEL object. |
[in] | wx | Center x world coordinate for drawing grip. |
[in] | wy | Center y world coordinate for drawing grip. |
Definition at line 1475 of file o_grips.c.
void o_grips_draw_rubber | ( | GSCHEM_TOPLEVEL * | w_current | ) |