KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ar_matrix.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 *
8 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24
25#pragma once
26
27#include <math/box2.h>
28
29class PCB_SHAPE;
30class PAD;
31class FOOTPRINT;
32class LSET;
33
34#define AR_MAX_ROUTING_LAYERS_COUNT 2
35
36#define AR_SIDE_TOP 0
37#define AR_SIDE_BOTTOM 1
38
43{
44public:
45 typedef unsigned char MATRIX_CELL;
46 typedef int DIST_CELL;
47
56
57 AR_MATRIX();
59
60 void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell )
61 {
62 ( *this.*m_opWriteCell )( aRow, aCol, aSide, aCell );
63 }
64
70 {
71 return m_BrdBox.GetOrigin();
72 }
73
80 bool ComputeMatrixSize( const BOX2I& aBoundingBox );
81
88
90
91 // Initialize WriteCell to make the aLogicOp
92 void SetCellOperation( CELL_OP aLogicOp );
93
94 // functions to read/write one cell ( point on grid routing matrix:
95 MATRIX_CELL GetCell( int aRow, int aCol, int aSide );
96 void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
97 void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
98 void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
99 void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
100 void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
101 DIST_CELL GetDist( int aRow, int aCol, int aSide );
102 void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
103
104 void TracePcbShape( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic );
105
106 void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int margin, int aKeepOut, const LSET& aLayerMask );
107
108 void PlacePad( PAD* aPad, int color, int margin, AR_MATRIX::CELL_OP op_logic );
109
110 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& angle, const LSET& aLayerMask,
111 int color, AR_MATRIX::CELL_OP op_logic );
112
113 void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const LSET& aLayerMask, int color,
114 AR_MATRIX::CELL_OP op_logic );
115
116private:
117 void drawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, CELL_OP op_logic );
118
119 void traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic );
120
121 void traceFilledCircle( int cx, int cy, int radius, const LSET& aLayerMask, int color,
122 AR_MATRIX::CELL_OP op_logic );
123
124 void traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg, int layer, int color,
125 AR_MATRIX::CELL_OP op_logic );
126
127public:
128 MATRIX_CELL* m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides
129 DIST_CELL* m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides:
130 // distance to cells
131 int m_RoutingLayersCount; // Number of layers for autorouting (0 or 1)
132 int m_GridRouting; // Size of grid for autoplace/autoroute
133 BOX2I m_BrdBox; // Actual board bounding box
134 int m_Nrows, m_Ncols; // Matrix size
135 int m_MemSize; // Memory requirement, just for statistics
136 int m_RouteCount; // Number of routes
137
138private:
139 // a pointer to the current selected cell operation
140 void ( AR_MATRIX::*m_opWriteCell )( int aRow, int aCol, int aSide, MATRIX_CELL aCell );
141};
142
#define AR_MAX_ROUTING_LAYERS_COUNT
Definition ar_matrix.h:34
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
void UnInitRoutingMatrix()
int m_Nrows
Definition ar_matrix.h:134
unsigned char MATRIX_CELL
Definition ar_matrix.h:45
BOX2I m_BrdBox
Definition ar_matrix.h:133
void AddCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void AndCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void SetCellOperation(CELL_OP aLogicOp)
void(AR_MATRIX::* m_opWriteCell)(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition ar_matrix.h:140
void TracePcbShape(PCB_SHAPE *aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic)
int m_RouteCount
Definition ar_matrix.h:136
int DIST_CELL
Definition ar_matrix.h:46
int m_RoutingLayersCount
Definition ar_matrix.h:131
void SetCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
@ WRITE_OR_CELL
Definition ar_matrix.h:51
@ WRITE_AND_CELL
Definition ar_matrix.h:53
@ WRITE_XOR_CELL
Definition ar_matrix.h:52
@ WRITE_ADD_CELL
Definition ar_matrix.h:54
void XorCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
void SetDist(int aRow, int aCol, int aSide, DIST_CELL)
int m_MemSize
Definition ar_matrix.h:135
int InitRoutingMatrix()
Initialize the data structures.
Definition ar_matrix.cpp:79
MATRIX_CELL * m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition ar_matrix.h:128
void drawSegmentQcq(int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, CELL_OP op_logic)
bool ComputeMatrixSize(const BOX2I &aBoundingBox)
Calculate the number of rows and columns of dimensions of aBoundingBox for routing and automatic calc...
Definition ar_matrix.cpp:49
void OrCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
int m_GridRouting
Definition ar_matrix.h:132
void traceCircle(int ux0, int uy0, int ux1, int uy1, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic)
DIST_CELL * m_DistSide[AR_MAX_ROUTING_LAYERS_COUNT]
Definition ar_matrix.h:129
DIST_CELL GetDist(int aRow, int aCol, int aSide)
void CreateKeepOutRectangle(int ux0, int uy0, int ux1, int uy1, int margin, int aKeepOut, const LSET &aLayerMask)
Function CreateKeepOutRectangle builds the cost map: Cells ( in Dist map ) inside the rect x0,...
MATRIX_CELL GetCell(int aRow, int aCol, int aSide)
void traceArc(int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE &arcAngle, int lg, int layer, int color, AR_MATRIX::CELL_OP op_logic)
void TraceFilledRectangle(int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE &angle, const LSET &aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
void traceFilledCircle(int cx, int cy, int radius, const LSET &aLayerMask, int color, AR_MATRIX::CELL_OP op_logic)
VECTOR2I GetBrdCoordOrigin()
Definition ar_matrix.h:69
void WriteCell(int aRow, int aCol, int aSide, MATRIX_CELL aCell)
Definition ar_matrix.h:60
int m_Ncols
Definition ar_matrix.h:134
void PlacePad(PAD *aPad, int color, int margin, AR_MATRIX::CELL_OP op_logic)
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
int radius
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708