2012-08-11 12:52:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-08-26 13:59:55 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-08-11 12:52:13 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-08-26 13:59:55 +00:00
|
|
|
* @file info3d_visu.h
|
2012-08-11 12:52:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INFO3D_VISU_H__
|
|
|
|
#define __INFO3D_VISU_H__
|
|
|
|
|
|
|
|
#include <layers_id_colors_and_visibility.h> // Layers id definitions
|
|
|
|
|
|
|
|
#include <wx/glcanvas.h>
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
# ifdef __DARWIN__
|
|
|
|
# include <OpenGL/glu.h>
|
|
|
|
# else
|
|
|
|
# include <glu.h>
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <GL/glu.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <3d_struct.h>
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
#define m_ROTX m_Rot[0]
|
|
|
|
#define m_ROTY m_Rot[1]
|
|
|
|
#define m_ROTZ m_Rot[2]
|
|
|
|
|
2014-01-30 08:18:47 +00:00
|
|
|
class BOARD_DESIGN_SETTINGS;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
/** Minor class to store a 3D color (R, G, B) 3 floats range 0 to 1.0
|
|
|
|
*/
|
|
|
|
class S3D_COLOR
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
double m_Red, m_Green, m_Blue;
|
|
|
|
public: S3D_COLOR()
|
|
|
|
{
|
|
|
|
m_Red = m_Green = m_Blue = 0;
|
|
|
|
}
|
|
|
|
};
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2013-10-07 14:50:23 +00:00
|
|
|
enum DISPLAY3D_FLG {
|
|
|
|
FL_AXIS=0, FL_MODULE, FL_ZONE,
|
|
|
|
FL_ADHESIVE, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE,
|
|
|
|
FL_COMMENTS, FL_ECO,
|
|
|
|
FL_GRID,
|
|
|
|
FL_USE_COPPER_THICKNESS,
|
|
|
|
FL_SHOW_BOARD_BODY,
|
|
|
|
FL_USE_REALISTIC_MODE,
|
2014-08-19 14:51:15 +00:00
|
|
|
FL_RENDER_SHADOWS,
|
|
|
|
FL_RENDER_SHOW_HOLES_IN_ZONES,
|
|
|
|
FL_RENDER_TEXTURES,
|
|
|
|
FL_RENDER_SMOOTH,
|
|
|
|
FL_RENDER_MATERIAL,
|
2013-10-07 14:50:23 +00:00
|
|
|
FL_LAST
|
|
|
|
};
|
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
/** Helper class to handle information needed to display 3D board
|
|
|
|
*/
|
2012-08-11 12:52:13 +00:00
|
|
|
class INFO3D_VISU
|
|
|
|
{
|
|
|
|
public:
|
2012-08-26 13:59:55 +00:00
|
|
|
double m_Beginx, m_Beginy; // position of mouse (used in drag commands)
|
|
|
|
double m_Quat[4]; // orientation of 3D view
|
|
|
|
double m_Rot[4]; // rotation parameters of 3D view
|
|
|
|
double m_Zoom; // 3D zoom value
|
2012-08-27 11:41:22 +00:00
|
|
|
double m_3D_Grid; // 3D grid value, in mm
|
2012-08-21 10:45:54 +00:00
|
|
|
S3D_COLOR m_BgColor;
|
2014-08-19 14:51:15 +00:00
|
|
|
S3D_COLOR m_BgColor_Top;
|
2014-08-20 08:39:19 +00:00
|
|
|
S3D_COLOR m_BoardBodyColor; // in realistic mode: FR4 board color
|
|
|
|
S3D_COLOR m_SolderMaskColor; // in realistic mode: solder mask color
|
|
|
|
S3D_COLOR m_SilkScreenColor; // in realistic mode: SilkScreen color
|
|
|
|
S3D_COLOR m_CopperColor; // in realistic mode: copper color
|
2012-08-26 13:59:55 +00:00
|
|
|
wxPoint m_BoardPos; // center board actual position in board units
|
|
|
|
wxSize m_BoardSize; // board actual size in board units
|
2012-08-21 10:45:54 +00:00
|
|
|
int m_CopperLayersCount; // Number of copper layers actually used by the board
|
2012-08-11 12:52:13 +00:00
|
|
|
|
|
|
|
const BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
double m_BiuTo3Dunits; // Normalization scale to convert board
|
|
|
|
// internal units to 3D units
|
2014-08-22 10:24:14 +00:00
|
|
|
// to normalize 3D units between -1.0 and +1.0
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
double zpos_offset;
|
2014-08-19 14:51:15 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
private:
|
2014-07-21 16:26:18 +00:00
|
|
|
double m_layerZcoord[LAYER_ID_COUNT]; // Z position of each layer (normalized)
|
|
|
|
double m_copperThickness; // Copper thickness (normalized)
|
|
|
|
double m_epoxyThickness; // Epoxy thickness (normalized)
|
|
|
|
double m_nonCopperLayerThickness; // Non copper layers thickness
|
2014-08-21 11:59:57 +00:00
|
|
|
std::bitset<FL_LAST> m_drawFlags; // Enable/disable flags (see DISPLAY3D_FLG list)
|
2012-08-11 12:52:13 +00:00
|
|
|
|
|
|
|
public: INFO3D_VISU();
|
|
|
|
~INFO3D_VISU();
|
2012-08-26 13:59:55 +00:00
|
|
|
|
2013-10-07 14:50:23 +00:00
|
|
|
// Accessors
|
|
|
|
bool GetFlag( DISPLAY3D_FLG aFlag ) const { return m_drawFlags[aFlag]; }
|
2014-08-21 11:59:57 +00:00
|
|
|
void SetFlag( DISPLAY3D_FLG aFlag, bool aState )
|
2013-10-07 14:50:23 +00:00
|
|
|
{
|
2014-08-21 11:59:57 +00:00
|
|
|
m_drawFlags[aFlag] = aState;
|
2013-10-07 14:50:23 +00:00
|
|
|
}
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
/**
|
2014-08-21 11:59:57 +00:00
|
|
|
* Initialize 3D Parameters depending on aBoard
|
2012-08-26 13:59:55 +00:00
|
|
|
* @param aBoard: the board to display
|
|
|
|
*/
|
|
|
|
void InitSettings( BOARD* aBoard );
|
|
|
|
|
2012-08-27 11:41:22 +00:00
|
|
|
/**
|
2013-03-14 16:11:05 +00:00
|
|
|
* @return the Z position of 3D shapes, in 3D Units
|
2012-08-27 11:41:22 +00:00
|
|
|
* @param aIsFlipped: true for modules on Front (top) layer, false
|
|
|
|
* if on back (bottom) layer
|
|
|
|
*/
|
2013-03-14 16:11:05 +00:00
|
|
|
double GetModulesZcoord3DIU( bool aIsFlipped );
|
2012-08-27 11:41:22 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
/**
|
|
|
|
* @return the Z coordinate of the layer aLayer, in Board Internal Units
|
2012-08-27 07:06:52 +00:00
|
|
|
* @param aLayerId: the layer number
|
2012-08-26 13:59:55 +00:00
|
|
|
*/
|
2012-08-27 07:06:52 +00:00
|
|
|
int GetLayerZcoordBIU( int aLayerId )
|
2012-08-26 13:59:55 +00:00
|
|
|
{
|
2014-07-21 16:26:18 +00:00
|
|
|
return KiROUND( m_layerZcoord[aLayerId] / m_BiuTo3Dunits );
|
2012-08-26 13:59:55 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 07:06:52 +00:00
|
|
|
/**
|
|
|
|
* @return the thickness (Z size) of the copper, in Board Internal Units
|
|
|
|
* note: the thickness (Z size) of the copper is not the thickness
|
|
|
|
* of the layer (the thickness of the layer is the epoxy thickness / layer count)
|
|
|
|
*
|
2013-10-07 14:50:23 +00:00
|
|
|
* Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set,
|
2013-10-07 11:51:08 +00:00
|
|
|
* and normal mode, returns 0
|
2012-08-27 07:06:52 +00:00
|
|
|
*/
|
2012-08-26 13:59:55 +00:00
|
|
|
int GetCopperThicknessBIU() const
|
|
|
|
{
|
2014-07-21 16:26:18 +00:00
|
|
|
bool use_thickness = GetFlag( FL_USE_COPPER_THICKNESS );
|
|
|
|
|
2014-02-28 10:51:47 +00:00
|
|
|
return use_thickness ?
|
2014-07-21 16:26:18 +00:00
|
|
|
KiROUND( m_copperThickness / m_BiuTo3Dunits )
|
2012-08-26 13:59:55 +00:00
|
|
|
: 0;
|
|
|
|
}
|
|
|
|
|
2012-08-27 07:06:52 +00:00
|
|
|
/**
|
|
|
|
* function GetEpoxyThicknessBIU
|
|
|
|
* @return the thickness (Z size) of the epoxy board, in Board Internal Units
|
|
|
|
*/
|
2012-08-26 13:59:55 +00:00
|
|
|
int GetEpoxyThicknessBIU() const
|
|
|
|
{
|
2014-07-21 16:26:18 +00:00
|
|
|
return KiROUND( m_epoxyThickness / m_BiuTo3Dunits );
|
2012-08-26 13:59:55 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 07:06:52 +00:00
|
|
|
/**
|
|
|
|
* function GetNonCopperLayerThicknessBIU
|
|
|
|
* @return the thickness (Z size) of a technical layer,
|
|
|
|
* in Board Internal Units
|
|
|
|
*
|
2013-10-07 14:50:23 +00:00
|
|
|
* Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
|
2012-08-27 07:06:52 +00:00
|
|
|
*/
|
2012-08-26 13:59:55 +00:00
|
|
|
int GetNonCopperLayerThicknessBIU() const
|
|
|
|
{
|
2014-02-28 10:51:47 +00:00
|
|
|
bool use_thickness = GetFlag( FL_USE_COPPER_THICKNESS )
|
|
|
|
// || GetFlag( FL_USE_REALISTIC_MODE )
|
|
|
|
;
|
|
|
|
return use_thickness ?
|
2014-07-21 16:26:18 +00:00
|
|
|
KiROUND( m_nonCopperLayerThickness / m_BiuTo3Dunits )
|
2012-08-26 13:59:55 +00:00
|
|
|
: 0;
|
|
|
|
}
|
2012-08-27 07:06:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* function GetNonCopperLayerThicknessBIU
|
|
|
|
* @return the thickness (Z size) of the copper or a technical layer,
|
|
|
|
* in Board Internal Units, depending on the layer id
|
|
|
|
*
|
2013-10-07 14:50:23 +00:00
|
|
|
* Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
|
2012-08-27 07:06:52 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
int GetLayerObjectThicknessBIU( int aLayerId ) const
|
2012-08-27 07:06:52 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
return IsCopperLayer( aLayerId ) ?
|
|
|
|
GetCopperThicknessBIU() :
|
|
|
|
GetNonCopperLayerThicknessBIU()
|
|
|
|
;
|
2012-08-27 07:06:52 +00:00
|
|
|
}
|
2013-10-07 11:51:08 +00:00
|
|
|
|
2013-10-07 14:50:23 +00:00
|
|
|
bool IsRealisticMode() { return GetFlag( FL_USE_REALISTIC_MODE ); }
|
2012-08-11 12:52:13 +00:00
|
|
|
};
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
extern INFO3D_VISU g_Parm_3D_Visu;
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
#endif /* __INFO3D_VISU_H__ */
|