gschem

m_basic.c File Reference

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

Go to the source code of this file.

Data Structures

struct  st_halfspace

Typedefs

typedef struct st_halfspace HALFSPACE

Functions

int mil_x (GSCHEM_TOPLEVEL *w_current, int val)
 Convert a x coordinate to mils.
int mil_y (GSCHEM_TOPLEVEL *w_current, int val)
 Convert a y coordinate to mils.
int pix_x (GSCHEM_TOPLEVEL *w_current, int val)
 Convert a x coordinate to pixels.
int pix_y (GSCHEM_TOPLEVEL *w_current, int val)
 Convert a y coordinate to pixels.
void WORLDtoSCREEN (GSCHEM_TOPLEVEL *w_current, int x, int y, int *px, int *py)
 Transform WORLD coordinates to SCREEN coordinates.
void SCREENtoWORLD (GSCHEM_TOPLEVEL *w_current, int mx, int my, int *x, int *y)
 Transform WORLD coordinates to WORLD coordinates.
int snap_grid (GSCHEM_TOPLEVEL *w_current, int input)
 Find the closest grid coordinate.
int SCREENabs (GSCHEM_TOPLEVEL *w_current, int val)
 Get absolute SCREEN coordinate.
int WORLDabs (GSCHEM_TOPLEVEL *w_current, int val)
 Get absolute WORLD coordinate.
static void WORLDencode_halfspace (GSCHEM_TOPLEVEL *w_current, sPOINT *point, HALFSPACE *halfspace)
 Encode WORLD coordinates as halfspace matrix.
int WORLDclip_change (GSCHEM_TOPLEVEL *w_current, int *x1, int *y1, int *x2, int *y2)
 Calculate the cliping region for a set of coordinates.
int clip_nochange (GSCHEM_TOPLEVEL *w_current, int x1, int y1, int x2, int y2)
 Check if a set of coordinates are within a clipping region.
int visible (GSCHEM_TOPLEVEL *w_current, int wleft, int wtop, int wright, int wbottom)
 Check if a bounding box is visible on the screen.
double round_5_2_1 (double unrounded)
 Rounds numbers by a power of 10.

Typedef Documentation

typedef struct st_halfspace HALFSPACE

Definition at line 297 of file m_basic.c.


Function Documentation

int mil_x ( GSCHEM_TOPLEVEL w_current,
int  val 
)
Function Description
Convert a x coordinate to mils.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object
[in]valThe x coordinate to convert
Returns:
The coordinate value in mils.

Definition at line 40 of file m_basic.c.

int mil_y ( GSCHEM_TOPLEVEL w_current,
int  val 
)
Function Description
Convert a y coordinate to mils
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]valThe y coordinate to convert.
Returns:
The coordinate value in mils.

Definition at line 67 of file m_basic.c.

int pix_x ( GSCHEM_TOPLEVEL w_current,
int  val 
)
Function Description
Convert a x coordinate to pixels.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object
[in]valThe x coordinate to convert
Returns:
The coordinate value in pixels.

Definition at line 94 of file m_basic.c.

int pix_y ( GSCHEM_TOPLEVEL w_current,
int  val 
)
Function Description
Convert a y coordinate to pixels.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object
[in]valThe y coordinate to convert
Returns:
The coordinate value in pixels.

Definition at line 129 of file m_basic.c.

void WORLDtoSCREEN ( GSCHEM_TOPLEVEL w_current,
int  x,
int  y,
int *  px,
int *  py 
)
Function Description
This function takes in WORLD x/y coordinates and transforms them to SCREEN x/y coordinates.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]xThe x coordinate in WORLD units.
[in]yThe y coordinate in WORLD units.
[out]pxThe x coordinate in SCREEN units.
[out]pyThe y coordinate in SCREEN units.

Definition at line 167 of file m_basic.c.

Here is the call graph for this function:

void SCREENtoWORLD ( GSCHEM_TOPLEVEL w_current,
int  mx,
int  my,
int *  x,
int *  y 
)
Function Description
This function takes in SCREEN x/y coordinates and transforms them to WORLD x/y coordinates.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]mxThe x coordinate in SCREEN units.
[in]myThe y coordinate in SCREEN units.
[out]xThe x coordinate in WORLD units.
[out]yThe y coordinate in WORLD units.
Note:
Question: why are we returning in x and y if this is SCREEN to WORLD shouldn't WORLD coordinates be returned in mx and my?

Definition at line 187 of file m_basic.c.

Here is the call graph for this function:

int snap_grid ( GSCHEM_TOPLEVEL w_current,
int  input 
)
Function Description
This function snaps the current input coordinate to the closest grid coordinate.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]inputThe coordinate to snap.
Returns:
The closest grid coordinate to the input.

Definition at line 202 of file m_basic.c.

Here is the call graph for this function:

int SCREENabs ( GSCHEM_TOPLEVEL w_current,
int  val 
)
Function Description
Get absolute SCREEN coordinate.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]valThe coordinate to convert.
Returns:
The converted SCREEN coordinate.

Definition at line 243 of file m_basic.c.

int WORLDabs ( GSCHEM_TOPLEVEL w_current,
int  val 
)
Function Description
Get absolute WORLD coordinate.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]valThe coordinate to convert.
Returns:
The converted WORLD coordinate.

Definition at line 273 of file m_basic.c.

static void WORLDencode_halfspace ( GSCHEM_TOPLEVEL w_current,
sPOINT *  point,
HALFSPACE halfspace 
) [static]
Function Description
This function takes a point and checks if it is in the bounds of the current TOPLEVEL object's page coordinates. It handles points with WORLD coordinates.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]pointThe point in WORLD coordinates to be checked.
[out]halfspaceThe created HALFSPACE structure.
Warning:
halfspace must be allocated before this function is called

Definition at line 323 of file m_basic.c.

int WORLDclip_change ( GSCHEM_TOPLEVEL w_current,
int *  x1,
int *  y1,
int *  x2,
int *  y2 
)
Function Description
This function will check the provided set of coordinates to see if they fall within a clipping region. If they do the coordinates will be changed to reflect only the region no covered by the clipping window. All coordinates should be in WORLD units.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in,out]x1x coordinate of the first screen point.
[in,out]y1y coordinate of the first screen point.
[in,out]x2x coordinate of the second screen point.
[in,out]y2y coordinate of the second screen point.
Returns:
TRUE if coordinates are now visible, FALSE otherwise.

Definition at line 346 of file m_basic.c.

Here is the call graph for this function:

int clip_nochange ( GSCHEM_TOPLEVEL w_current,
int  x1,
int  y1,
int  x2,
int  y2 
)
Function Description
This function will check if the given set of coordinates are within a clipping region. No action will be taken to change the coordinates.
Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in,out]x1x coordinate of the first screen point.
[in,out]y1y coordinate of the first screen point.
[in,out]x2x coordinate of the second screen point.
[in,out]y2y coordinate of the second screen point.
Returns:
TRUE if coordinates are now visible, FALSE otherwise.

Definition at line 477 of file m_basic.c.

Here is the call graph for this function:

int visible ( GSCHEM_TOPLEVEL w_current,
int  wleft,
int  wtop,
int  wright,
int  wbottom 
)
Function Description
This function checks if a given bounding box is visible on the screen.

WARNING: top and bottom are mis-named in world-coords, top is the smallest "y" value, and bottom is the largest. Be careful! This doesn't correspond to what you'd expect.

Parameters:
[in]w_currentThe GSCHEM_TOPLEVEL object.
[in]wleftLeft coordinate of the bounding box.
[in]wtopTop coordinate of the bounding box.
[in]wrightRight coordinate of the bounding box.
[in]wbottomBottom coordinate of the bounding box.
Returns:
TRUE if bounding box is visible, FALSE otherwise

Definition at line 606 of file m_basic.c.

Here is the call graph for this function:

double round_5_2_1 ( double  unrounded)
Function Description
This function will round numbers using a power of 10 method. For example: 1235 rounds to 1000 670 rounds to 500 0.234 rounds to 0.2 integer values would be enough if there are no numbers smaller than 1 (hw)
Parameters:
[in]unroundedThe number to be rounded.
Returns:
The rounded number.

Definition at line 693 of file m_basic.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines