2011-11-10 15:55:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file 3d_struct.h
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifndef STRUCT_3D_H
|
|
|
|
#define STRUCT_3D_H
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "common.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "base_struct.h"
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
/* 3D modeling units -> PCB units conversion scale:
|
|
|
|
* 1 "3D model unit" wings3d = 1 unit = 2.54 mm = 0.1 inch
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
#define UNITS3D_TO_UNITSPCB 1000
|
|
|
|
|
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
class S3D_MASTER;
|
2007-06-05 12:10:51 +00:00
|
|
|
class Struct3D_Shape;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
class S3D_Color /* 3D color (R, G, G) 3 floats range 0 to 1.0*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-11-24 06:53:43 +00:00
|
|
|
double m_Red, m_Green, m_Blue;
|
2009-11-04 20:46:53 +00:00
|
|
|
public: S3D_Color()
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Red = m_Green = m_Blue = 0;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
class S3D_Vertex /* 3D coordinate (3 float numbers: x,y,z coordinates)*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-11-24 06:53:43 +00:00
|
|
|
double x, y, z;
|
2011-11-10 15:55:05 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
S3D_Vertex();
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
class S3D_MATERIAL : public EDA_ITEM /* openGL "material" data*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-11-24 06:53:43 +00:00
|
|
|
wxString m_Name;
|
|
|
|
S3D_Vertex m_DiffuseColor;
|
2007-06-05 12:10:51 +00:00
|
|
|
S3D_Vertex m_EmissiveColor;
|
|
|
|
S3D_Vertex m_SpecularColor;
|
2008-11-24 06:53:43 +00:00
|
|
|
float m_AmbientIntensity;
|
|
|
|
float m_Transparency;
|
|
|
|
float m_Shininess;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
public:
|
|
|
|
S3D_MATERIAL( S3D_MASTER* father, const wxString& name );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MATERIAL* Next() const { return (S3D_MATERIAL*) Pnext; }
|
|
|
|
S3D_MATERIAL* Back() const { return (S3D_MATERIAL*) Pback; }
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
void SetMaterial();
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Master structure for a 3D item description */
|
2010-12-08 20:12:46 +00:00
|
|
|
class S3D_MASTER : public EDA_ITEM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-11-24 06:53:43 +00:00
|
|
|
wxString m_Shape3DName; /* 3D shape name in 3D library */
|
|
|
|
S3D_Vertex m_MatScale;
|
|
|
|
S3D_Vertex m_MatRotation;
|
|
|
|
S3D_Vertex m_MatPosition;
|
|
|
|
Struct3D_Shape* m_3D_Drawings;
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MATERIAL* m_Materials;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
public:
|
|
|
|
S3D_MASTER( EDA_ITEM* aParent );
|
2008-12-06 08:21:54 +00:00
|
|
|
~S3D_MASTER();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MASTER* Next() const { return (S3D_MASTER*) Pnext; }
|
|
|
|
S3D_MASTER* Back() const { return (S3D_MASTER*) Pback; }
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
void Insert( S3D_MATERIAL* aMaterial )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
aMaterial->SetNext( m_Materials );
|
|
|
|
m_Materials = aMaterial;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
void Copy( S3D_MASTER* pattern );
|
|
|
|
int ReadData();
|
2011-11-10 15:55:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ReadMaterial
|
|
|
|
* read the description of a 3D material definition in the form:
|
|
|
|
* DEF yellow material Material (
|
|
|
|
* DiffuseColor 1.00000 1.00000 0.00000e 0
|
|
|
|
* EmissiveColor 0.00000e 0 0.00000e 0 0.00000e 0
|
|
|
|
* SpecularColor 1.00000 1.00000 1.00000
|
|
|
|
* AmbientIntensity 1.00000
|
|
|
|
* Transparency 0.00000e 0
|
|
|
|
* Shininess 1.00000
|
|
|
|
*)
|
|
|
|
* Or type:
|
|
|
|
* USE yellow material
|
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
int ReadMaterial( FILE* file, int* LineNum );
|
|
|
|
int ReadChildren( FILE* file, int* LineNum );
|
|
|
|
int ReadShape( FILE* file, int* LineNum );
|
|
|
|
int ReadAppearance( FILE* file, int* LineNum );
|
|
|
|
int ReadGeometry( FILE* file, int* LineNum );
|
2011-11-10 15:55:05 +00:00
|
|
|
void Set_Object_Coords( std::vector< S3D_Vertex >& aVertices );
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Describes a complex 3D */
|
2010-12-08 20:12:46 +00:00
|
|
|
class Struct3D_Shape : public EDA_ITEM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-11-24 06:53:43 +00:00
|
|
|
S3D_Vertex* m_3D_Coord;
|
|
|
|
int* m_3D_CoordIndex;
|
|
|
|
int m_3D_Points;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
public:
|
|
|
|
Struct3D_Shape( EDA_ITEM* aParent );
|
2008-11-24 06:53:43 +00:00
|
|
|
~Struct3D_Shape();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; }
|
|
|
|
Struct3D_Shape* Back() const { return (Struct3D_Shape*) Pback; }
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
int ReadData( FILE* file, int* LineNum );
|
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
/**
|
|
|
|
* Class WinEDA_VertexCtrl
|
|
|
|
* displays a vertex for editing. A vertex is a triplet of values in INCHES, MM,
|
|
|
|
* or without units.
|
|
|
|
*
|
|
|
|
* Internal_units are the internal units by inch which is 1000 for Eeschema and
|
|
|
|
* 10000 for Pcbnew
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
class WinEDA_VertexCtrl
|
|
|
|
{
|
|
|
|
private:
|
2008-11-24 06:53:43 +00:00
|
|
|
int m_Units;
|
|
|
|
int m_Internal_Unit;
|
|
|
|
wxTextCtrl* m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl;
|
|
|
|
wxStaticText* m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
|
2011-09-06 19:42:46 +00:00
|
|
|
wxBoxSizer* BoxSizer, EDA_UNITS_T units, int internal_unit );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
~WinEDA_VertexCtrl();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
/**
|
|
|
|
* Function GetValue
|
|
|
|
* @return the vertex in internal units.
|
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
S3D_Vertex GetValue();
|
|
|
|
void SetValue( S3D_Vertex vertex );
|
|
|
|
void Enable( bool enbl );
|
|
|
|
void SetToolTip( const wxString& text );
|
2008-11-24 06:53:43 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* STRUCT_3D_H */
|