Commit cd85ee62 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Cosmetic enhancement: change plot icon in menus.

3dviewer: back to double (from float) in class S3D_MASTER for 3 members (m_MatScale, m_MatRotation, m_MatPosition) which are used in dialogs and r/w file functions, which expect double.
Using float create minor but unwanted issues in  r/w file functions.
S3D_MATERIAL: enable all color options: if a 3d shape has bad color parameters, the shape must be modified, not the 3d rendering.
The rendering now matches what we see in other vrml viewer like FreeCAD.
Some minor coding style fixes.
parent 468e9e4a
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ void TransfertToGLlist( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUni
    glEnd();
}

VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* aParent, wxBoxSizer* aBoxSizer )
S3DPOINT_VALUE_CTRL::S3DPOINT_VALUE_CTRL( wxWindow* aParent, wxBoxSizer* aBoxSizer )
{
    wxString text;

@@ -187,14 +187,15 @@ VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* aParent, wxBoxSizer* aBoxSizer )
}


VERTEX_VALUE_CTRL::~VERTEX_VALUE_CTRL()
S3DPOINT_VALUE_CTRL::~S3DPOINT_VALUE_CTRL()
{
    // Nothing to delete: all items are managed by the parent window.
}


S3D_VERTEX VERTEX_VALUE_CTRL::GetValue()
S3DPOINT S3DPOINT_VALUE_CTRL::GetValue()
{
    S3D_VERTEX value;
    S3DPOINT value;
    double   dtmp;

    m_XValueCtrl->GetValue().ToDouble( &dtmp );
@@ -207,7 +208,7 @@ S3D_VERTEX VERTEX_VALUE_CTRL::GetValue()
}


void VERTEX_VALUE_CTRL::SetValue( S3D_VERTEX vertex )
void S3DPOINT_VALUE_CTRL::SetValue( S3DPOINT vertex )
{
    wxString text;

@@ -225,7 +226,7 @@ void VERTEX_VALUE_CTRL::SetValue( S3D_VERTEX vertex )
}


void VERTEX_VALUE_CTRL::Enable( bool onoff )
void S3DPOINT_VALUE_CTRL::Enable( bool onoff )
{
    m_XValueCtrl->Enable( onoff );
    m_YValueCtrl->Enable( onoff );
+4 −4
Original line number Diff line number Diff line
@@ -78,11 +78,11 @@ S3D_MASTER::S3D_MASTER( EDA_ITEM* aParent ) :
    m_ShapeType   = FILE3D_NONE;

    m_use_modelfile_diffuseColor = true;
    m_use_modelfile_emissiveColor = false;
    m_use_modelfile_specularColor = false;
    m_use_modelfile_ambientIntensity = false;
    m_use_modelfile_emissiveColor = true;
    m_use_modelfile_specularColor = true;
    m_use_modelfile_ambientIntensity = true;
    m_use_modelfile_transparency = true;
    m_use_modelfile_shininess = false;
    m_use_modelfile_shininess = true;
}


+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@

class S3D_MASTER;

class S3D_MATERIAL : public EDA_ITEM       /* openGL "material" data*/
class S3D_MATERIAL : public EDA_ITEM       // openGL "material" data
{
public:
    wxString   m_Name;
+45 −21
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2014 Mario Luzeiro <mrluzeiro@gmail.com>
 * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 *
@@ -36,8 +36,9 @@
#include <3d_material.h>
#include <gal/opengl/glm/glm.hpp>

/* 3D modeling units -> PCB units conversion scale:
 * 1 "3D model unit" wings3d = 1 unit = 2.54 mm = 0.1 inch = 100 mils
/**
 * @note For historical reasons the 3D modeling unit is 0.1 inch
 * 1 3Dunit = 2.54 mm = 0.1 inch = 100 mils
 */
#define UNITS3D_TO_UNITSPCB (IU_PER_MILS * 100)

@@ -45,19 +46,42 @@
class S3D_MASTER;
class STRUCT_3D_SHAPE;

/*  S3D_VERTEX manages a 3D coordinate (3 float numbers: x,y,z coordinates)*/
// S3D_VERTEX manages a opengl 3D coordinate (3 float numbers: x,y,z coordinates)
// float are widely used in opengl functions.
// they are used here in coordinates which are also used in opengl functions.
#define S3D_VERTEX glm::vec3

// S3DPOINT manages a set of 3 double values (x,y,z )
// It is used for values which are not directly used in opengl functions.
// It is used in dialogs, or when reading/writing files for instance
class S3DPOINT
{
public:
    double x, y, z;

public:
    S3DPOINT()
    {
        x = y = z = 0.0;
    }

    S3DPOINT( double px, double py, double pz)
    {
        x = px;
        y = py;
        z = pz;
    }
};

/* Master structure for a 3D item description */
// Master structure for a 3D footprint shape description
class S3D_MASTER : public EDA_ITEM
{
public:
    S3D_VERTEX      m_MatScale;
    S3D_VERTEX      m_MatRotation;
    S3D_VERTEX      m_MatPosition;
    STRUCT_3D_SHAPE* m_3D_Drawings;
    S3D_MATERIAL*   m_Materials;
    S3DPOINT      m_MatScale;       ///< a scaling factor for the entire 3D footprint shape
    S3DPOINT      m_MatRotation;    ///< a grotation for the entire 3D footprint shape
    S3DPOINT      m_MatPosition;    ///< an offset for the entire 3D footprint shape
    STRUCT_3D_SHAPE* m_3D_Drawings; ///< the list of basic shapes
    S3D_MATERIAL*   m_Materials;    ///< the list of materiels used by the shapes

    enum FILE3D_TYPE
    {
@@ -76,7 +100,7 @@ public:
    bool        m_use_modelfile_shininess;

private:
    wxString    m_Shape3DName;  /* 3D shape name in 3D library */
    wxString    m_Shape3DName;      // the 3D shape filename in 3D library
    FILE3D_TYPE m_ShapeType;
    double      m_lastTransparency;         // last transparency value from
                                            // last material in use
@@ -185,26 +209,26 @@ public:


/**
 * Class VERTEX_VALUE_CTRL
 * displays a vertex for editing.  A vertex is a triplet of values
 * Class S3DPOINT_VALUE_CTRL
 * displays a S3DPOINT for editing (in dialogs).  A S3DPOINT is a triplet of values
 * Values can be scale, rotation, offset...
 */
class VERTEX_VALUE_CTRL
class S3DPOINT_VALUE_CTRL
{
private:
    wxTextCtrl*   m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl;

public:
    VERTEX_VALUE_CTRL( wxWindow* parent, wxBoxSizer* BoxSizer );
    S3DPOINT_VALUE_CTRL( wxWindow* parent, wxBoxSizer* BoxSizer );

    ~VERTEX_VALUE_CTRL();
    ~S3DPOINT_VALUE_CTRL();

    /**
     * Function GetValue
     * @return the vertex in internal units.
     * @return the 3D point in internal units.
     */
    S3D_VERTEX GetValue();
    void       SetValue( S3D_VERTEX vertex );
    S3DPOINT   GetValue();
    void       SetValue( S3DPOINT a3Dpoint );
    void       Enable( bool enbl );
    void       SetToolTip( const wxString& text );
};
+34 −23
Original line number Diff line number Diff line
@@ -103,9 +103,7 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
        if( strcmp( text, "Separator" ) == 0 )
        {
            m_model = new S3D_MESH();

            childs.push_back( m_model );

            read_separator();
        }
    }
@@ -137,13 +135,16 @@ int VRML1_MODEL_PARSER::read_separator()
        if( strcmp( text, "Material" ) == 0 )
        {
            readMaterial( );
        } else if( strcmp( text, "Coordinate3" ) == 0 )
        }
        else if( strcmp( text, "Coordinate3" ) == 0 )
        {
            readCoordinate3();
        } else if( strcmp( text, "IndexedFaceSet" ) == 0 )
        }
        else if( strcmp( text, "IndexedFaceSet" ) == 0 )
        {
            readIndexedFaceSet();
        } else if( strcmp( text, "Separator" ) == 0 )
        }
        else if( strcmp( text, "Separator" ) == 0 )
        {
            S3D_MESH *parent = m_model;

@@ -157,11 +158,13 @@ int VRML1_MODEL_PARSER::read_separator()
            read_separator();

            m_model = parent;
        }else if ( ( *text != '}' ) )
        }
        else if ( ( *text != '}' ) )
        {
            //DBG( printf( "read_NotImplemented %s\n", text ) );
            read_NotImplemented( m_file, '}');
        } else
        }
        else
        {
            break;
        }
@@ -201,19 +204,24 @@ int VRML1_MODEL_PARSER::readMaterial()
        if( strcmp( text, "ambientColor" ) == 0 )
        {
            readMaterial_ambientColor();
        } else if( strcmp( text, "diffuseColor" ) == 0 )
        }
        else if( strcmp( text, "diffuseColor" ) == 0 )
        {
            readMaterial_diffuseColor( );
        } else if( strcmp( text, "emissiveColor" ) == 0 )
        }
        else if( strcmp( text, "emissiveColor" ) == 0 )
        {
            readMaterial_emissiveColor( );
        }else if( strcmp( text, "specularColor" ) == 0 )
        }
        else if( strcmp( text, "specularColor" ) == 0 )
        {
            readMaterial_specularColor( );
        }else if( strcmp( text, "shininess" ) == 0 )
        }
        else if( strcmp( text, "shininess" ) == 0 )
        {
            readMaterial_shininess( );
        }else if( strcmp( text, "transparency" ) == 0 )
        }
        else if( strcmp( text, "transparency" ) == 0 )
        {
            readMaterial_transparency( );
        }
@@ -272,7 +280,8 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet( )
        if( strcmp( text, "coordIndex" ) == 0 )
        {
            readIndexedFaceSet_coordIndex( );
        } else if( strcmp( text, "materialIndex" ) == 0 )
        }
        else if( strcmp( text, "materialIndex" ) == 0 )
        {
            readIndexedFaceSet_materialIndex( );
        }
@@ -334,6 +343,7 @@ int VRML1_MODEL_PARSER::readMaterial_shininess( )
    m_model->m_Materials->m_Shininess.clear();

    float shininess_value;

    while( fscanf( m_file, "%f,", &shininess_value ) )
    {
        // VRML value is normalized and openGL expects a value 0 - 128
@@ -359,6 +369,7 @@ int VRML1_MODEL_PARSER::readMaterial_transparency()
    m_model->m_Materials->m_Transparency.clear();

    float tmp;

    while( fscanf (m_file, "%f,", &tmp) )
    {
        m_model->m_Materials->m_Transparency.push_back( tmp );
Loading