gschem

o_picture.c File Reference

#include <config.h>
#include <math.h>
#include <stdio.h>
#include "gschem.h"
Include dependency graph for o_picture.c:

Go to the source code of this file.

Defines

#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

void o_picture_start (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 Start process to input a new picture.
void o_picture_end (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 End the input of a circle.
void picture_selection_dialog (GSCHEM_TOPLEVEL *w_current)
 Creates the add image dialog.
void o_picture_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
void o_picture_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 Draw temporary picture while dragging edge.
void o_picture_draw_rubber (GSCHEM_TOPLEVEL *w_current)
 Draw picture from GSCHEM_TOPLEVEL object.
void o_picture_draw (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
 Draw a picture on the screen.
void o_picture_draw_grips (GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
 Draw grip marks on picture.
void o_picture_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
 Draw a picture described by OBJECT with translation.
gboolean o_picture_exchange (GSCHEM_TOPLEVEL *w_current, const gchar *filename, GError **error)
 Replace all selected pictures with a new picture.
void picture_change_filename_dialog (GSCHEM_TOPLEVEL *w_current)
 Create dialog to exchange picture objects.
void o_picture_set_pixbuf (GSCHEM_TOPLEVEL *w_current, GdkPixbuf *pixbuf, char *filename)

Define Documentation

#define GET_PICTURE_WIDTH (   w)    abs((w)->second_wx - (w)->first_wx)

Definition at line 27 of file o_picture.c.

#define GET_PICTURE_HEIGHT (   w)    (w)->pixbuf_wh_ratio == 0 ? 0 : abs((w)->second_wx - (w)->first_wx)/(w)->pixbuf_wh_ratio

Definition at line 29 of file o_picture.c.

#define GET_PICTURE_LEFT (   w)    min((w)->first_wx, (w)->second_wx)

Definition at line 31 of file o_picture.c.

#define GET_PICTURE_TOP (   w)
Value:
(w)->first_wy > (w)->second_wy ? (w)->first_wy  :           \
  (w)->first_wy+abs((w)->second_wx - (w)->first_wx)/(w)->pixbuf_wh_ratio

Definition at line 33 of file o_picture.c.


Function Documentation

void o_picture_start ( GSCHEM_TOPLEVEL w_current,
int  w_x,
int  w_y 
)
Function Description
This function starts the process to input a new picture. Parameters for this picture are put into/extracted from the w_current toplevel structure. w_x and w_y are current coordinates of the pointer in world coordinates.

The first step is to input one corner of the picture. This corner is (w_x,w_y) snapped to the grid and saved in w_current->first_wx and w_current->first_wy.

The other corner will be saved in (w_current->second_wx, w_current->second_wy).

Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]w_xCurrent x coordinate of pointer in world units.
[in]w_yCurrent y coordinate of pointer in world units.

Definition at line 56 of file o_picture.c.

Here is the call graph for this function:

void o_picture_end ( GSCHEM_TOPLEVEL w_current,
int  w_x,
int  w_y 
)
Function Description
This function ends the input of the second corner of a picture. The picture is defined by (w_current->first_wx,w_current->first_wy and (w_current->second_wx,w_current->second_wy.

The temporary picture frame is erased ; a new picture object is allocated, initialized and linked to the object list ; The object is finally drawn on the current sheet.

Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]w_x(unused)
[in]w_y(unused)

Definition at line 81 of file o_picture.c.

Here is the call graph for this function:

void picture_selection_dialog ( GSCHEM_TOPLEVEL w_current)
Function Description
This function creates the add image dialog and loads the selected picture.

Definition at line 126 of file o_picture.c.

Here is the call graph for this function:

void o_picture_invalidate_rubber ( GSCHEM_TOPLEVEL w_current)
Todo:
Finish function documentation!!!
Function Description
Note:
used in button cancel code in x_events.c

Definition at line 205 of file o_picture.c.

Here is the call graph for this function:

void o_picture_motion ( GSCHEM_TOPLEVEL w_current,
int  w_x,
int  w_y 
)
Function Description
This function is used to draw the box while dragging one of its edge or angle. It erases the previous temporary box drawn before, and draws a new updated one. w_x and w_y are the new position of the mobile point, ie the mouse.

The old values are inside the w_current pointed structure. Old width, height and left and top values are recomputed by the corresponding macros.

Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]w_xCurrent x coordinate of pointer in world units.
[in]w_yCurrent y coordinate of pointer in world units.

Definition at line 236 of file o_picture.c.

Here is the call graph for this function:

void o_picture_draw_rubber ( GSCHEM_TOPLEVEL w_current)
Function Description
This function draws the box from the variables in the GSCHEM_TOPLEVEL structure *w_current. One corner of the box is at (w_current->first_wx, w_current->first_wy) and the second corner is at (w_current->second_wx,w_current->second_wy.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.

Definition at line 272 of file o_picture.c.

Here is the call graph for this function:

void o_picture_draw ( GSCHEM_TOPLEVEL w_current,
OBJECT *  o_current 
)
Function Description
This function is used to draw a picture on screen. The picture is described in the OBJECT which is referred by o_current. The picture is displayed according to the current state, described in the GSCHEM_TOPLEVEL object pointed by w_current.

It first checks if the OBJECT pointed is valid or not. If not it returns and do not output anything. That should never happen though.

Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]o_currentPicture OBJECT to draw.

Definition at line 302 of file o_picture.c.

Here is the call graph for this function:

void o_picture_draw_grips ( GSCHEM_TOPLEVEL w_current,
OBJECT *  o_current 
)
Function Description
This function draws four grips on the corners of the picture described by *o_current.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]o_currentPicture OBJECT to draw grip points on.

Definition at line 395 of file o_picture.c.

Here is the call graph for this function:

void o_picture_draw_place ( GSCHEM_TOPLEVEL w_current,
int  dx,
int  dy,
OBJECT *  o_current 
)
Function Description
This function daws the picture object described by *o_current translated by the vector (dx,dy). The translation vector is in world unit.

The picture is displayed with the color of the object.

Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]dxDelta x coordinate for picture.
[in]dyDelta y coordinate for picture.
[in]o_currentPicture OBJECT to draw.

Definition at line 440 of file o_picture.c.

Here is the call graph for this function:

gboolean o_picture_exchange ( GSCHEM_TOPLEVEL w_current,
const gchar *  filename,
GError **  error 
)
Function Description
Replaces all pictures in the current selection with a new image.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object
[in]filenameThe filename of the new picture
[out]errorThe location to return error information.
Returns:
TRUE on success, FALSE on failure.

Definition at line 466 of file o_picture.c.

Here is the call graph for this function:

void picture_change_filename_dialog ( GSCHEM_TOPLEVEL w_current)
Function Description
This function opens a file chooser and replaces all pictures of the selections with the new picture.
Todo:
Maybe merge this dialog function with picture_selection_dialog()

Definition at line 502 of file o_picture.c.

Here is the call graph for this function:

void o_picture_set_pixbuf ( GSCHEM_TOPLEVEL w_current,
GdkPixbuf *  pixbuf,
char *  filename 
)
Todo:
Finish function documentation!!!
Function Description
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]pixbuf
[in]filename

Definition at line 572 of file o_picture.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines