3d_draw_basic_functions.h 6.27 KB
Newer Older
jean-pierre charras's avatar
jean-pierre charras committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
 * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
 *
 * 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, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

/**
 * @file 3d_draw_basic_functions.h
 */
#ifndef _3D_DRAW_BASIC_FUNCTIONS_H_
#define _3D_DRAW_BASIC_FUNCTIONS_H_

// angle increment to draw a circle, approximated by segments
#define ANGLE_INC( x ) ( 3600 / (x) )

/** draw all solid polygons found in aPolysList
 * @param aPolysList = the poligon list to draw
 * @param aZpos = z position in board internal units
 * @param aThickness = thickness in board internal units
 * @param aBiuTo3DUnits = board internal units to 3D units scaling value
 * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
40
 * If aThickness > 0, a solid object is drawn.
jean-pierre charras's avatar
jean-pierre charras committed
41 42 43
 *  The top side is located at aZpos + aThickness / 2
 *  The bottom side is located at aZpos - aThickness / 2
 */
44
void    Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
jean-pierre charras's avatar
jean-pierre charras committed
45 46 47 48 49 50 51 52 53
                                            int aZpos, int aThickness, double aBiuTo3DUnits );

/** draw the solid polygon found in aPolysList
 * The first polygonj is the main polygon, others are holes
 * @param aPolysList = the polygon with holes to draw
 * @param aZpos = z position in board internal units
 * @param aThickness = thickness in board internal units
 * @param aBiuTo3DUnits = board internal units to 3D units scaling value
 * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
54
 * If aThickness > 0, a solid object is drawn.
jean-pierre charras's avatar
jean-pierre charras committed
55 56 57
 *  The top side is located at aZpos + aThickness / 2
 *  The bottom side is located at aZpos - aThickness / 2
 */
58
void    Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
jean-pierre charras's avatar
jean-pierre charras committed
59 60 61
                                                int aZpos, int aThickness, double aBiuTo3DUnits );

/** draw a thick segment using 3D primitives, in a XY plane
62 63
 * @param aStart = YX position of start point in board units
 * @param aEnd = YX position of end point in board units
jean-pierre charras's avatar
jean-pierre charras committed
64 65 66
 * @param aWidth = width of segment in board units
 * @param aThickness = thickness of segment in board units
 * @param aZpos = z position of segment in board units
67
 * @param aBiuTo3DUnits = board internal units to 3D units scaling value
jean-pierre charras's avatar
jean-pierre charras committed
68
 * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
69
 * If aThickness > 0, a solid object is drawn.
jean-pierre charras's avatar
jean-pierre charras committed
70 71 72 73 74 75 76
 *  The top side is located at aZpos + aThickness / 2
 *  The bottom side is located at aZpos - aThickness / 2
 */
void    Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd,
                             int aWidth, int aThickness, int aZpos,
                             double aBiuTo3DUnits );

77 78 79 80
/** draw an arc using 3D primitives, in a XY plane
 * @param aCenterPos = XY position of the center in board units
 * @param aStartPoint = start point coordinate of arc in board units
 * @param aWidth = width of the circle in board units
jean-pierre charras's avatar
jean-pierre charras committed
81 82
 * @param aArcAngle = arc angle in 1/10 degrees
 * @param aWidth = thickness of arc
83 84 85
 * @param aThickness = thickness of segment in board units
 * @param aZpos = z position of segment in board units
 * @param aBiuTo3DUnits = board internal units to 3D units scaling value
jean-pierre charras's avatar
jean-pierre charras committed
86
 */
87
void Draw3D_ArcSegment( const wxPoint&  aCenterPos, const wxPoint& aStartPoint,
88
                        double aArcAngle, int aWidth, int aThickness,
89
                        int aZpos, double aBiuTo3DUnits );
jean-pierre charras's avatar
jean-pierre charras committed
90 91 92 93


/** draw a thick cylinder (a tube) using 3D primitives.
 * the cylinder axis is parallel to the Z axis
94
 * @param aCenterPos = XY position of the axis cylinder ( board internal units)
jean-pierre charras's avatar
jean-pierre charras committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
 * @param aRadius = radius of the cylinder ( board internal units)
 * @param aHeight = height of the cylinder ( boardinternal units)
 * @param aThickness = tichkness of tube ( boardinternal units)
 * @param aZpos = Z position of the bottom side of the cylinder ( board internal units)
 * @param aBiuTo3DUnits = board internal units to 3D units scaling value
 *
 * If aHeight = height of the cylinder is 0, only one ring will be drawn
 * If aThickness = 0, only one cylinder (not a tube) will be drawn
 */
void    Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
                              int aHeight, int aThickness,
                              int aZpos, double aBiuTo3DUnits );

/** draw an oblong cylinder (oblong tube) using 3D primitives.
 * the cylinder axis are parallel to the Z axis
 * @param aAxis1Pos = position of the first axis cylinder
 * @param aAxis2Pos = position of the second axis cylinder
 * @param aRadius = radius of the cylinder ( board internal units )
 * @param aHeight = height of the cylinder ( board internal units )
 * @param aThickness = tichkness of tube ( board internal units )
 * @param aZpos = Z position of the bottom side of the cylinder ( board internal units )
 * @param aBiuTo3DUnits = board internal units to 3D units scaling value
 */
void    Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
                                    int aRadius, int aHeight, int aThickness,
                                    int aZpos, double aBiuTo3DUnits  );
121 122 123 124 125 126 127
/**
 * Set the current 3D color from a Kicad  color, with optional transparency
 * @param aColor = a EDA_COLOR_T kicad color index
 * @param aTransparency = the color transparency (default = 1.0 = no transparency)
 */
void SetGLColor( EDA_COLOR_T aColor, double aTransparency = 1.0 );

jean-pierre charras's avatar
jean-pierre charras committed
128 129

#endif      // _3D_DRAW_BASIC_FUNCTIONS_H_