pcb 4.1.1
An interactive printed circuit board layout editor.

create.c File Reference

Functions used to create vias, pins ... More...

#include <assert.h>
#include <memory.h>
#include <setjmp.h>
#include <stdlib.h>
#include "global.h"
#include "create.h"
#include "data.h"
#include "draw.h"
#include "error.h"
#include "mymem.h"
#include "misc.h"
#include "parse_l.h"
#include "pcb-printf.h"
#include "polygon.h"
#include "rtree.h"
#include "search.h"
#include "set.h"
#include "undo.h"
#include "vendor.h"
Include dependency graph for create.c:

Go to the source code of this file.

Data Structures

struct  line_info

Functions

static void AddTextToElement (TextType *Text, FontType *PCBFont, Coord X, Coord Y, unsigned Direction, char *TextString, int Scale, FlagType Flags)
 Creates a new textobject as part of an element.
void CreateBeLenient (bool v)
 Set the lenience mode.
DataTypeCreateNewBuffer (void)
 Creates a new paste buffer.
void pcb_colors_from_settings (PCBType *ptr)
 Perhaps PCB should internally just use the Settings colors?
PCBTypeCreateNewPCB (void)
 Creates a new PCB.
int CreateNewPCBPost (PCBType *pcb, int use_defaults)
 This post-processing step adds the top and bottom silk layers to a pre-existing PCB.
PinTypeCreateNewVia (DataType *Data, Coord X, Coord Y, Coord Thickness, Coord Clearance, Coord Mask, Coord DrillingHole, char *Name, FlagType Flags)
 Creates a new via.
PinTypeCreateNewViaEx (DataType *Data, Coord X, Coord Y, Coord Thickness, Coord Clearance, Coord Mask, Coord DrillingHole, char *Name, FlagType Flags, Cardinal buried_from, Cardinal buried_to)
 Creates a new via with buried info.
static int line_callback (const BoxType *b, void *cl)
LineTypeCreateDrawnLineOnLayer (LayerType *Layer, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness, Coord Clearance, FlagType Flags)
 Creates a new line on a layer and checks for overlap and extension.
LineTypeCreateNewLineOnLayer (LayerType *Layer, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness, Coord Clearance, FlagType Flags)
RatTypeCreateNewRat (DataType *Data, Coord X1, Coord Y1, Coord X2, Coord Y2, Cardinal group1, Cardinal group2, Coord Thickness, FlagType Flags)
 Creates a new rat-line.
ArcTypeCreateNewArcOnLayer (LayerType *Layer, Coord X1, Coord Y1, Coord width, Coord height, Angle sa, Angle dir, Coord Thickness, Coord Clearance, FlagType Flags)
 Creates a new arc on a layer.
PolygonTypeCreateNewPolygonFromRectangle (LayerType *Layer, Coord X1, Coord Y1, Coord X2, Coord Y2, FlagType Flags)
 Creates a new polygon from the old formats rectangle data.
TextTypeCreateNewText (LayerType *Layer, FontType *PCBFont, Coord X, Coord Y, unsigned Direction, int Scale, char *TextString, FlagType Flags)
 Creates a new text on a layer.
PolygonTypeCreateNewPolygon (LayerType *Layer, FlagType Flags)
 Creates a new polygon on a layer.
PointTypeCreateNewPointInPolygon (PolygonType *Polygon, Coord X, Coord Y)
 Creates a new point in a polygon.
PolygonTypeCreateNewHoleInPolygon (PolygonType *Polygon)
 Creates a new hole in a polygon.
ElementTypeCreateNewElement (DataType *Data, FontType *PCBFont, FlagType Flags, char *Description, char *NameOnPCB, char *Value, Coord TextX, Coord TextY, BYTE Direction, int TextScale, FlagType TextFlags, bool uniqueName)
 Creates an new element.
ArcTypeCreateNewArcInElement (ElementType *Element, Coord X, Coord Y, Coord Width, Coord Height, Angle angle, Angle delta, Coord Thickness)
 Creates a new arc in an element.
LineTypeCreateNewLineInElement (ElementType *Element, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness)
 Creates a new line for an element.
PinTypeCreateNewPin (ElementType *Element, Coord X, Coord Y, Coord Thickness, Coord Clearance, Coord Mask, Coord DrillingHole, char *Name, char *Number, FlagType Flags)
 Creates a new pin in an element.
PadTypeCreateNewPad (ElementType *Element, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness, Coord Clearance, Coord Mask, char *Name, char *Number, FlagType Flags)
 Creates a new pad in an element.
LineTypeCreateNewLineInSymbol (SymbolType *Symbol, Coord X1, Coord Y1, Coord X2, Coord Y2, Coord Thickness)
 Creates a new line in a symbol.
void CreateDefaultFont (PCBType *pcb)
 Parses a file with font information and installs it into the provided PCB.
RubberbandTypeCreateNewRubberbandEntry (LayerType *Layer, LineType *Line, PointType *MovedPoint)
 Adds a new line to the rubberband list of 'Crosshair.AttachedObject'.
LibraryMenuTypeCreateNewNet (LibraryType *lib, char *name, char *style)
 Add a new net to the netlist menu.
LibraryEntryTypeCreateNewConnection (LibraryMenuType *net, char *conn)
 Add a connection to the net.
AttributeTypeCreateNewAttribute (AttributeListType *list, char *name, char *value)
 Add an attribute to a list..

Variables

static long int ID = 1
static bool be_lenient = false

Detailed Description

Functions used to create vias, pins ...


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996, 2005 Thomas Nau

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact addresses for paper mail and Email: Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany Thomas.Nau@rz.uni-ulm.de

Definition in file create.c.


Function Documentation

static void AddTextToElement ( TextType Text,
FontType PCBFont,
Coord  X,
Coord  Y,
unsigned  Direction,
char *  TextString,
int  Scale,
FlagType  Flags 
) [static]

Creates a new textobject as part of an element.

Copies the values to the appropriate text object.

Definition at line 945 of file create.c.

References TextType::Direction, line_info::Flags, ID, TextType::Scale, SetTextBoundingBox(), TextType::TextString, X, TextType::X, Y, and TextType::Y.

Referenced by CreateNewElement().

Here is the call graph for this function:

void CreateBeLenient ( bool  v)

Set the lenience mode.

TRUE during file loads, for example to allow overlapping vias.
FALSE otherwise, to stop the user from doing normally dangerous things.

Definition at line 86 of file create.c.

References be_lenient.

Referenced by Parse().

void CreateDefaultFont ( PCBType pcb)

Parses a file with font information and installs it into the provided PCB.

Checks directories given as colon separated list by resource fontPath if the fonts filename doesn't contain a directory component.

Definition at line 999 of file create.c.

References _, PCBType::Font, SettingType::FontFile, Message(), ParseFont(), and Settings.

Referenced by CreateNewPCB().

Here is the call graph for this function:

LineType* CreateDrawnLineOnLayer ( LayerType Layer,
Coord  X1,
Coord  Y1,
Coord  X2,
Coord  Y2,
Coord  Thickness,
Coord  Clearance,
FlagType  Flags 
)
ArcType* CreateNewArcInElement ( ElementType Element,
Coord  X,
Coord  Y,
Coord  Width,
Coord  Height,
Angle  angle,
Angle  delta,
Coord  Thickness 
)

Creates a new arc in an element.

Definition at line 769 of file create.c.

References ElementType::Arc, ElementType::ArcN, ArcType::Delta, ArcType::Height, ID, NormalizeAngle(), ArcType::StartAngle, line_info::Thickness, ArcType::Thickness, ArcType::Width, X, ArcType::X, Y, and ArcType::Y.

Referenced by ConvertBufferToElement(), and CopyElementLowLevel().

Here is the call graph for this function:

AttributeType* CreateNewAttribute ( AttributeListType list,
char *  name,
char *  value 
)

Add an attribute to a list..

Definition at line 1062 of file create.c.

References AttributeListType::List, AttributeListType::Max, AttributeType::name, AttributeListType::Number, realloc(), STRDUP, and AttributeType::value.

Referenced by ActionElementSetAttr(), and CopyElementLowLevel().

Here is the call graph for this function:

DataType* CreateNewBuffer ( void  )

Creates a new paste buffer.

Definition at line 95 of file create.c.

References PCB, and DataType::pcb.

Referenced by CopyObjectToUndoList(), CreateNewPCB(), InitBuffers(), MoveObjectToRemoveUndoList(), and UndoCopyOrCreate().

LibraryEntryType* CreateNewConnection ( LibraryMenuType net,
char *  conn 
)

Add a connection to the net.

Definition at line 1050 of file create.c.

References GetLibraryEntryMemory(), LibraryEntryType::ListEntry, and STRDUP.

Referenced by netlist_add().

Here is the call graph for this function:

ElementType* CreateNewElement ( DataType Data,
FontType PCBFont,
FlagType  Flags,
char *  Description,
char *  NameOnPCB,
char *  Value,
Coord  TextX,
Coord  TextY,
BYTE  Direction,
int  TextScale,
FlagType  TextFlags,
bool  uniqueName 
)

Creates an new element.

Note:
Memory is allocated if needed.

Definition at line 729 of file create.c.

References AddTextToElement(), DESCRIPTION_TEXT, line_info::Flags, GetElementMemory(), ID, MAX, NAMEONPCB_TEXT, UniqueElementName(), and VALUE_TEXT.

Referenced by ConvertBufferToElement(), and CopyElementLowLevel().

Here is the call graph for this function:

PolygonType* CreateNewHoleInPolygon ( PolygonType Polygon)

Creates a new hole in a polygon.

Definition at line 716 of file create.c.

References GetHoleIndexMemoryInPolygon(), polygon_st::PointN, and Polygon.

Referenced by CopyPolygonLowLevel(), and PolyToPolygonsOnLayer().

Here is the call graph for this function:

LineType* CreateNewLineInElement ( ElementType Element,
Coord  X1,
Coord  Y1,
Coord  X2,
Coord  Y2,
Coord  Thickness 
)

Creates a new line for an element.

Definition at line 807 of file create.c.

References ID, ElementType::Line, line, ElementType::LineN, NoFlags, line_info::Thickness, line_info::X1, line_info::X2, line_info::Y1, and line_info::Y2.

Referenced by ConvertBufferToElement(), and CopyElementLowLevel().

LineType* CreateNewLineInSymbol ( SymbolType Symbol,
Coord  X1,
Coord  Y1,
Coord  X2,
Coord  Y2,
Coord  Thickness 
)

Creates a new line in a symbol.

Definition at line 966 of file create.c.

References SymbolType::Line, line, SymbolType::LineMax, SymbolType::LineN, realloc(), STEP_SYMBOLLINE, line_info::Thickness, line_info::X1, line_info::X2, line_info::Y1, and line_info::Y2.

Referenced by FontSave().

Here is the call graph for this function:

LibraryMenuType* CreateNewNet ( LibraryType lib,
char *  name,
char *  style 
)

Add a new net to the netlist menu.

Definition at line 1030 of file create.c.

References LibraryMenuType::flag, GetLibraryMenuMemory(), LibraryMenuType::Name, NSTRCMP, and LibraryMenuType::Style.

Referenced by netlist_add().

Here is the call graph for this function:

PadType* CreateNewPad ( ElementType Element,
Coord  X1,
Coord  Y1,
Coord  X2,
Coord  Y2,
Coord  Thickness,
Coord  Clearance,
Coord  Mask,
char *  Name,
char *  Number,
FlagType  Flags 
)

Creates a new pad in an element.

Definition at line 905 of file create.c.

References CLEAR_FLAG, line_info::Clearance, pad_st::Element, line_info::Flags, GetPadMemory(), ID, Mask, pad_st::Mask, pad_st::Name, pad_st::Number, STRDUP, line_info::Thickness, line_info::X1, line_info::X2, line_info::Y1, and line_info::Y2.

Referenced by ConvertBufferToElement(), and CopyElementLowLevel().

Here is the call graph for this function:

int CreateNewPCBPost ( PCBType pcb,
int  use_defaults 
)

This post-processing step adds the top and bottom silk layers to a pre-existing PCB.

Called after PCB->Data->LayerN is set.

Returns:
Returns zero if no errors, else nonzero.

Definition at line 231 of file create.c.

References bottom_silk_layer, PCBType::Data, SettingType::Groups, DataType::Layer, PCBType::LayerGroups, DataType::LayerN, LT_SILK, LayerType::Name, ParseGroupString(), pcb_colors_from_settings(), Settings, top_silk_layer, and LayerType::Type.

Referenced by ActionNew(), main(), and real_load_pcb().

Here is the call graph for this function:

PinType* CreateNewPin ( ElementType Element,
Coord  X,
Coord  Y,
Coord  Thickness,
Coord  Clearance,
Coord  Mask,
Coord  DrillingHole,
char *  Name,
char *  Number,
FlagType  Flags 
)
PointType* CreateNewPointInPolygon ( PolygonType Polygon,
Coord  X,
Coord  Y 
)

Creates a new point in a polygon.

Definition at line 701 of file create.c.

References GetPointMemoryInPolygon(), ID, PointType::ID, X, PointType::X, Y, and PointType::Y.

Referenced by CopyPolygonLowLevel(), CreateNewPolygonFromRectangle(), InsertPointIntoPolygon(), MorphPolygon(), NotifyMode(), and PolyToPolygonsOnLayer().

Here is the call graph for this function:

PolygonType* CreateNewPolygon ( LayerType Layer,
FlagType  Flags 
)

Creates a new polygon on a layer.

Definition at line 684 of file create.c.

References polygon_st::Clipped, line_info::Flags, GetPolygonMemory(), ID, polygon_st::NoHoles, and polygon_st::NoHolesValid.

Referenced by AddPolygonToBuffer(), CopyAttachedPolygonToLayer(), CopyPolygon(), CreateNewPolygonFromRectangle(), MorphPolygon(), and PolyToPolygonsOnLayer().

Here is the call graph for this function:

PolygonType* CreateNewPolygonFromRectangle ( LayerType Layer,
Coord  X1,
Coord  Y1,
Coord  X2,
Coord  Y2,
FlagType  Flags 
)

Creates a new polygon from the old formats rectangle data.

Definition at line 624 of file create.c.

References CreateNewPointInPolygon(), CreateNewPolygon(), LayerType::polygon_tree, r_create_tree(), r_insert_entry(), and SetPolygonBoundingBox().

Referenced by NotifyMode().

Here is the call graph for this function:

RatType* CreateNewRat ( DataType Data,
Coord  X1,
Coord  Y1,
Coord  X2,
Coord  Y2,
Cardinal  group1,
Cardinal  group2,
Coord  Thickness,
FlagType  Flags 
)
RubberbandType* CreateNewRubberbandEntry ( LayerType Layer,
LineType Line,
PointType MovedPoint 
)

Adds a new line to the rubberband list of 'Crosshair.AttachedObject'.

If Layer == 0 it is a rat line.

Definition at line 1012 of file create.c.

References GetRubberbandMemory(), Layer, RubberbandType::Layer, line_info::Line, RubberbandType::Line, RubberbandType::MovedPoint, ptr, and TOGGLE_FLAG.

Referenced by CheckPolygonForRubberbandConnection(), rat_callback(), and rubber_callback().

Here is the call graph for this function:

TextType* CreateNewText ( LayerType Layer,
FontType PCBFont,
Coord  X,
Coord  Y,
unsigned  Direction,
int  Scale,
char *  TextString,
FlagType  Flags 
)

Creates a new text on a layer.

Definition at line 648 of file create.c.

References TextType::Direction, line_info::Flags, GetTextMemory(), ID, r_create_tree(), r_insert_entry(), TextType::Scale, SetTextBoundingBox(), LayerType::text_tree, TextType::TextString, X, TextType::X, Y, and TextType::Y.

Referenced by AddTextToBuffer(), CopyText(), and NotifyMode().

Here is the call graph for this function:

PinType* CreateNewViaEx ( DataType Data,
Coord  X,
Coord  Y,
Coord  Thickness,
Coord  Clearance,
Coord  Mask,
Coord  DrillingHole,
char *  Name,
FlagType  Flags,
Cardinal  buried_from,
Cardinal  buried_to 
)

Creates a new via with buried info.

*

Definition at line 325 of file create.c.

References pin_st::BuriedFrom, pin_st::BuriedTo, and CreateNewVia().

Referenced by AddViaToBuffer(), CopyVia(), moveline_callback(), and NotifyMode().

Here is the call graph for this function:

static int line_callback ( const BoxType b,
void *  cl 
) [static]

Variable Documentation

bool be_lenient = false [static]

Definition at line 69 of file create.c.

Referenced by CreateBeLenient(), and CreateNewVia().