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

3D-viewer: code cleanup.

Eeschema: annotate and netlist dialogs: enhancements.
Minor  coding policy fixes and  changes.
parent 898275fa
Loading
Loading
Loading
Loading
+6 −10
Original line number Original line Diff line number Diff line
/*
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 * 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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 *
 *
@@ -29,10 +29,6 @@


#include <fctsys.h>
#include <fctsys.h>


#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif

#include <common.h>
#include <common.h>
#include <trigo.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <wxBasePcbFrame.h>
@@ -49,7 +45,7 @@
#include <trackball.h>
#include <trackball.h>




void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices )
void S3D_MASTER::Set_Object_Coords( std::vector< S3D_VERTEX >& aVertices )
{
{
    unsigned ii;
    unsigned ii;


@@ -79,7 +75,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices )
}
}




void Set_Object_Data( std::vector< S3D_Vertex >& aVertices )
void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices )
{
{
    unsigned ii;
    unsigned ii;
    GLfloat ax, ay, az, bx, by, bz, nx, ny, nz, r;
    GLfloat ax, ay, az, bx, by, bz, nx, ny, nz, r;
@@ -271,9 +267,9 @@ VERTEX_VALUE_CTRL::~VERTEX_VALUE_CTRL()
}
}




S3D_Vertex VERTEX_VALUE_CTRL::GetValue()
S3D_VERTEX VERTEX_VALUE_CTRL::GetValue()
{
{
    S3D_Vertex value;
    S3D_VERTEX value;
    double     dtmp;
    double     dtmp;


    m_XValueCtrl->GetValue().ToDouble( &dtmp );
    m_XValueCtrl->GetValue().ToDouble( &dtmp );
@@ -286,7 +282,7 @@ S3D_Vertex VERTEX_VALUE_CTRL::GetValue()
}
}




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


+30 −6
Original line number Original line Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
/**
// Name:        3d_class.cpp
 * @file 3d_class.cpp
/////////////////////////////////////////////////////////////////////////////
 */

/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * 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
 */



#include <fctsys.h>
#include <fctsys.h>


@@ -55,7 +79,7 @@ S3D_MASTER::S3D_MASTER( EDA_ITEM* aParent ) :


S3D_MASTER:: ~S3D_MASTER()
S3D_MASTER:: ~S3D_MASTER()
{
{
    Struct3D_Shape* next;
    STRUCT_3D_SHAPE* next;
    S3D_MATERIAL*   nextmat;
    S3D_MATERIAL*   nextmat;


    for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
    for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
@@ -72,7 +96,7 @@ S3D_MASTER:: ~S3D_MASTER()
}
}




Struct3D_Shape::Struct3D_Shape( EDA_ITEM* aParent ) :
STRUCT_3D_SHAPE::STRUCT_3D_SHAPE( EDA_ITEM* aParent ) :
    EDA_ITEM( aParent, NOT_USED )
    EDA_ITEM( aParent, NOT_USED )
{
{
    m_3D_Coord = NULL;
    m_3D_Coord = NULL;
@@ -81,7 +105,7 @@ Struct3D_Shape::Struct3D_Shape( EDA_ITEM* aParent ) :
}
}




Struct3D_Shape:: ~Struct3D_Shape()
STRUCT_3D_SHAPE:: ~STRUCT_3D_SHAPE()
{
{
    delete m_3D_Coord;
    delete m_3D_Coord;
    delete m_3D_CoordIndex;
    delete m_3D_CoordIndex;
+444 −259

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Original line Diff line number Diff line
@@ -431,7 +431,7 @@ void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
 */
 */
void EDA_3D_FRAME::Set3DBgColor()
void EDA_3D_FRAME::Set3DBgColor()
{
{
    S3D_Color color;
    S3D_COLOR color;
    wxColour  newcolor, oldcolor;
    wxColour  newcolor, oldcolor;


    oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
    oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
+31 −29
Original line number Original line Diff line number Diff line
/*
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 * 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) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 *
 *
@@ -35,6 +35,8 @@


#include <3d_viewer.h>
#include <3d_viewer.h>


// separator chars
static const char* sep_chars = " \t\n\r";


int S3D_MASTER::ReadData()
int S3D_MASTER::ReadData()
{
{
@@ -85,13 +87,13 @@ int S3D_MASTER::ReadData()


    while( GetLine( file, line, &LineNum, 512 ) )
    while( GetLine( file, line, &LineNum, 512 ) )
    {
    {
        text = strtok( line, " \t\n\r" );
        text = strtok( line, sep_chars );


        if( stricmp( text, "DEF" ) == 0 )
        if( stricmp( text, "DEF" ) == 0 )
        {
        {
            while( GetLine( file, line, &LineNum, 512 ) )
            while( GetLine( file, line, &LineNum, 512 ) )
            {
            {
                text = strtok( line, " \t\n\r" );
                text = strtok( line, sep_chars );


                if( text == NULL )
                if( text == NULL )
                    continue;
                    continue;
@@ -119,8 +121,8 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum )
    wxString      mat_name;
    wxString      mat_name;
    S3D_MATERIAL* material = NULL;
    S3D_MATERIAL* material = NULL;


    command  = strtok( NULL, " \t\n\r" );
    command  = strtok( NULL, sep_chars );
    text     = strtok( NULL, " \t\n\r" );
    text     = strtok( NULL, sep_chars );
    mat_name = FROM_UTF8( text );
    mat_name = FROM_UTF8( text );


    if( stricmp( command, "USE" ) == 0 )
    if( stricmp( command, "USE" ) == 0 )
@@ -134,7 +136,7 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum )
            }
            }
        }
        }


        printf( "ReadMaterial error: material not found\n" );
        D( printf( "ReadMaterial error: material not found\n" ) );
        return 0;
        return 0;
    }
    }


@@ -146,7 +148,7 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum )


        while( GetLine( file, line, LineNum, 512 ) )
        while( GetLine( file, line, LineNum, 512 ) )
        {
        {
            text = strtok( line, " \t\n\r" );
            text = strtok( line, sep_chars );


            if( text == NULL )
            if( text == NULL )
                continue;
                continue;
@@ -159,44 +161,44 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum )


            if( stricmp( text, "diffuseColor" ) == 0 )
            if( stricmp( text, "diffuseColor" ) == 0 )
            {
            {
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_DiffuseColor.x = atof( text );
                material->m_DiffuseColor.x = atof( text );
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_DiffuseColor.y = atof( text );
                material->m_DiffuseColor.y = atof( text );
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_DiffuseColor.z = atof( text );
                material->m_DiffuseColor.z = atof( text );
            }
            }
            else if( stricmp( text, "emissiveColor" ) == 0 )
            else if( stricmp( text, "emissiveColor" ) == 0 )
            {
            {
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_EmissiveColor.x = atof( text );
                material->m_EmissiveColor.x = atof( text );
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_EmissiveColor.y = atof( text );
                material->m_EmissiveColor.y = atof( text );
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_EmissiveColor.z = atof( text );
                material->m_EmissiveColor.z = atof( text );
            }
            }
            else if( strnicmp( text, "specularColor", 13 ) == 0 )
            else if( strnicmp( text, "specularColor", 13 ) == 0 )
            {
            {
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_SpecularColor.x = atof( text );
                material->m_SpecularColor.x = atof( text );
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_SpecularColor.y = atof( text );
                material->m_SpecularColor.y = atof( text );
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_SpecularColor.z = atof( text );
                material->m_SpecularColor.z = atof( text );
            }
            }
            else if( strnicmp( text, "ambientIntensity", 16 ) == 0 )
            else if( strnicmp( text, "ambientIntensity", 16 ) == 0 )
            {
            {
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_AmbientIntensity = atof( text );
                material->m_AmbientIntensity = atof( text );
            }
            }
            else if( strnicmp( text, "transparency", 12 ) == 0 )
            else if( strnicmp( text, "transparency", 12 ) == 0 )
            {
            {
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_Transparency = atof( text );
                material->m_Transparency = atof( text );
            }
            }
            else if( strnicmp( text, "shininess", 9 ) == 0 )
            else if( strnicmp( text, "shininess", 9 ) == 0 )
            {
            {
                text = strtok( NULL, " \t\n\r" );
                text = strtok( NULL, sep_chars );
                material->m_Shininess = atof( text );
                material->m_Shininess = atof( text );
            }
            }
        }
        }
@@ -212,7 +214,7 @@ int S3D_MASTER::ReadChildren( FILE* file, int* LineNum )


    while( GetLine( file, line, LineNum, 512 ) )
    while( GetLine( file, line, LineNum, 512 ) )
    {
    {
        text = strtok( line, " \t\n\r" );
        text = strtok( line, sep_chars );


        if( *text == ']' )
        if( *text == ']' )
            return 0;
            return 0;
@@ -226,7 +228,7 @@ int S3D_MASTER::ReadChildren( FILE* file, int* LineNum )
        }
        }
        else
        else
        {
        {
            printf( "ReadChildren error line %d <%s> \n", *LineNum, text );
            D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
            break;
            break;
        }
        }
    }
    }
@@ -242,7 +244,7 @@ int S3D_MASTER::ReadShape( FILE* file, int* LineNum )


    while( GetLine( file, line, LineNum, 512 ) )
    while( GetLine( file, line, LineNum, 512 ) )
    {
    {
        text = strtok( line, " \t\n\r" );
        text = strtok( line, sep_chars );


        if( *text == '}' )
        if( *text == '}' )
        {
        {
@@ -260,7 +262,7 @@ int S3D_MASTER::ReadShape( FILE* file, int* LineNum )
        }
        }
        else
        else
        {
        {
            printf( "ReadShape error line %d <%s> \n", *LineNum, text );
            D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
            break;
            break;
        }
        }
    }
    }
@@ -276,7 +278,7 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum )


    while( GetLine( file, line, LineNum, 512 ) )
    while( GetLine( file, line, LineNum, 512 ) )
    {
    {
        text = strtok( line, " \t\n\r" );
        text = strtok( line, sep_chars );


        if( *text == '}' )
        if( *text == '}' )
        {
        {
@@ -289,7 +291,7 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum )
        }
        }
        else
        else
        {
        {
            printf( "ReadAppearance error line %d <%s> \n", *LineNum, text );
            D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
            break;
            break;
        }
        }
    }
    }
@@ -402,7 +404,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
    while( GetLine( file, line, LineNum, 512 ) )
    while( GetLine( file, line, LineNum, 512 ) )
    {
    {
        strcpy( buffer, line );
        strcpy( buffer, line );
        text = strtok( buffer, " \t\n\r" );
        text = strtok( buffer, sep_chars );


        if( *text == '}' )
        if( *text == '}' )
        {
        {
@@ -507,7 +509,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
            }
            }


            std::vector< int > coordIndex;
            std::vector< int > coordIndex;
            std::vector< S3D_Vertex > vertices;
            std::vector< S3D_VERTEX > vertices;


            while( GetLine( file, line, LineNum, 512 ) )
            while( GetLine( file, line, LineNum, 512 ) )
            {
            {
@@ -535,7 +537,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
                                break;
                                break;
                            }
                            }


                            S3D_Vertex vertex;
                            S3D_VERTEX vertex;
                            vertex.x = points[kk];
                            vertex.x = points[kk];
                            vertex.y = points[kk + 1];
                            vertex.y = points[kk + 1];
                            vertex.z = points[kk + 2];
                            vertex.z = points[kk + 2];
@@ -572,7 +574,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
}
}




int Struct3D_Shape::ReadData( FILE* file, int* LineNum )
int STRUCT_3D_SHAPE::ReadData( FILE* file, int* LineNum )
{
{
    char line[512];
    char line[512];


Loading