Commit 1af93150 authored by Garth Corral's avatar Garth Corral

Merge trunk @ 5464

parents 16ebfafa 25b9a42e
...@@ -83,6 +83,18 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : ...@@ -83,6 +83,18 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) :
{ {
m_init = false; m_init = false;
m_shadow_init = false; m_shadow_init = false;
// set an invalide value to not yet initialized indexes managing
// textures created to enhance 3D rendering
// (they are dummy values but we do not want uninitialized values)
m_text_pcb = m_text_silk = -1;
m_text_fake_shadow_front = -1;
m_text_fake_shadow_back = -1;
m_text_fake_shadow_board = -1;
// position of the front and back layers
// (will be initialized to a better value later)
m_ZBottom = 0.0;
m_ZTop = 0.0;
// Clear all gl list identifiers: // Clear all gl list identifiers:
for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ ) for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ )
......
...@@ -83,9 +83,10 @@ private: ...@@ -83,9 +83,10 @@ private:
double m_ZBottom; // position of the back layer double m_ZBottom; // position of the back layer
double m_ZTop; // position of the front layer double m_ZTop; // position of the front layer
GLuint m_text_pcb; GLuint m_text_pcb; // an index to the texture generated for pcb texts
GLuint m_text_silk; GLuint m_text_silk; // an index to the texture generated for silk layers
// Index to the textures generated for shadows
bool m_shadow_init; bool m_shadow_init;
GLuint m_text_fake_shadow_front; GLuint m_text_fake_shadow_front;
GLuint m_text_fake_shadow_back; GLuint m_text_fake_shadow_back;
......
...@@ -66,6 +66,7 @@ INFO3D_VISU::INFO3D_VISU() ...@@ -66,6 +66,7 @@ INFO3D_VISU::INFO3D_VISU()
m_epoxyThickness = 0; m_epoxyThickness = 0;
m_nonCopperLayerThickness = 0; m_nonCopperLayerThickness = 0;
m_BiuTo3Dunits = 1.0; m_BiuTo3Dunits = 1.0;
zpos_offset = 0.0;
// Set copper color, in realistic mode // Set copper color, in realistic mode
#define LUMINANCE 0.7/255.0 #define LUMINANCE 0.7/255.0
......
...@@ -41,6 +41,9 @@ VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MASTER* aMaster ) : ...@@ -41,6 +41,9 @@ VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MASTER* aMaster ) :
{ {
m_model = NULL; m_model = NULL;
m_file = NULL; m_file = NULL;
m_Materials = NULL;
m_normalPerVertex = true;
colorPerVertex = true;
} }
......
...@@ -253,15 +253,14 @@ int VRML2_MODEL_PARSER::read_Transform() ...@@ -253,15 +253,14 @@ int VRML2_MODEL_PARSER::read_Transform()
} }
/**
* Read the DEF for a Coordinate
*/
int VRML2_MODEL_PARSER::read_DEF_Coordinate() int VRML2_MODEL_PARSER::read_DEF_Coordinate()
{ {
char text[128]; char text[128];
// Get the name of the definition. // Get the name of the definition.
GetNextTag( m_file, text, sizeof(text) ); if( !GetNextTag( m_file, text, sizeof(text) ) )
return -1;
std::string coordinateName = text; std::string coordinateName = text;
while( GetNextTag( m_file, text, sizeof(text) ) ) while( GetNextTag( m_file, text, sizeof(text) ) )
...@@ -291,7 +290,8 @@ int VRML2_MODEL_PARSER::read_DEF() ...@@ -291,7 +290,8 @@ int VRML2_MODEL_PARSER::read_DEF()
{ {
char text[128]; char text[128];
GetNextTag( m_file, text, sizeof(text) ); if( !GetNextTag( m_file, text, sizeof(text) ) )
return -1;
while( GetNextTag( m_file, text, sizeof(text) ) ) while( GetNextTag( m_file, text, sizeof(text) ) )
{ {
...@@ -348,7 +348,9 @@ int VRML2_MODEL_PARSER::read_USE() ...@@ -348,7 +348,9 @@ int VRML2_MODEL_PARSER::read_USE()
char text[128]; char text[128];
// Get the name of the definition. // Get the name of the definition.
GetNextTag( m_file, text, sizeof(text) ); if( !GetNextTag( m_file, text, sizeof(text) ) )
return -1;
std::string coordinateName = text; std::string coordinateName = text;
// Look for it in our coordinate map. // Look for it in our coordinate map.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2013 Tuomas Vaherkoski <tuomasvaherkoski@gmail.com> * Copyright (C) 2013 Tuomas Vaherkoski <tuomasvaherkoski@gmail.com>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) : X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) :
S3D_MODEL_PARSER( aMaster ) S3D_MODEL_PARSER( aMaster )
{ {
m_model = NULL;
} }
...@@ -52,7 +53,7 @@ X3D_MODEL_PARSER::~X3D_MODEL_PARSER() ...@@ -52,7 +53,7 @@ X3D_MODEL_PARSER::~X3D_MODEL_PARSER()
} }
void X3D_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits ) void X3D_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlUnitsTo3DUnits )
{ {
wxXmlDocument doc; wxXmlDocument doc;
...@@ -69,7 +70,7 @@ void X3D_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Du ...@@ -69,7 +70,7 @@ void X3D_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Du
} }
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits; float vrmlunits_to_3Dunits = aVrmlUnitsTo3DUnits;
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits ); glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
......
...@@ -223,6 +223,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) ...@@ -223,6 +223,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
endif() endif()
endif() endif()
# The MinGW compiler can use the microsoft system snprintf as standard and it has a broken
# API with respect to the C99 standard, so make sure we force it to use its own compliant
# snprintf
add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
else() else()
# We build DLL/DSOs from static libraries, so create position independent # We build DLL/DSOs from static libraries, so create position independent
# code for all cases, since we do not have DLL/DSO specific static # code for all cases, since we do not have DLL/DSO specific static
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
/// The install prefix used for KiCad's libraries. /// The install prefix used for KiCad's libraries.
/// These paths are only intended to be reasonable default values that work if /// These paths are only intended to be reasonable default values that work if
/// the user installs KiCad in the default path for a given platform. /// the user installs KiCad in the default path for a given platform.
#if defined( APPLE ) #if defined( __APPLE__ )
#define KICAD_DATA_PATH "/Library/Application Support/kicad" #define KICAD_DATA_PATH "/Library/Application Support/kicad"
#else #else
#define KICAD_DATA_PATH "@CMAKE_INSTALL_PREFIX@/@KICAD_DATA@" #define KICAD_DATA_PATH "@CMAKE_INSTALL_PREFIX@/@KICAD_DATA@"
......
...@@ -58,6 +58,7 @@ BITMAP_BASE::BITMAP_BASE( const wxPoint& pos ) ...@@ -58,6 +58,7 @@ BITMAP_BASE::BITMAP_BASE( const wxPoint& pos )
BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap ) BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap )
{ {
m_Scale = aSchBitmap.m_Scale; m_Scale = aSchBitmap.m_Scale;
m_ppi = aSchBitmap.m_ppi;
m_pixelScaleFactor = aSchBitmap.m_pixelScaleFactor; m_pixelScaleFactor = aSchBitmap.m_pixelScaleFactor;
m_image = new wxImage( *aSchBitmap.m_image ); m_image = new wxImage( *aSchBitmap.m_image );
m_bitmap = new wxBitmap( *m_image ); m_bitmap = new wxBitmap( *m_image );
......
...@@ -206,7 +206,11 @@ wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit ) ...@@ -206,7 +206,11 @@ wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit )
break; break;
case DEGREES: case DEGREES:
wxASSERT( false ); label = _( "deg" );
break;
default:
label = wxT( "??" );
break; break;
} }
......
...@@ -2,6 +2,28 @@ ...@@ -2,6 +2,28 @@
* @file common_plotDXF_functions.cpp * @file common_plotDXF_functions.cpp
* @brief KiCad: Common plot DXF Routines. * @brief KiCad: Common plot DXF Routines.
*/ */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.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>
#include <gr_basic.h> #include <gr_basic.h>
......
...@@ -221,6 +221,8 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, ...@@ -221,6 +221,8 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
paperSize.y *= 10.0 * aIusPerDecimil; paperSize.y *= 10.0 * aIusPerDecimil;
SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead
m_plotMirror = aMirror; m_plotMirror = aMirror;
penOverlap = 0;
penDiameter = 0;
} }
......
...@@ -452,7 +452,8 @@ void PDF_PLOTTER::closePdfStream() ...@@ -452,7 +452,8 @@ void PDF_PLOTTER::closePdfStream()
{ {
wxASSERT( workFile ); wxASSERT( workFile );
int stream_len = ftell( workFile ); long stream_len = ftell( workFile );
wxASSERT( stream_len >= 0 );
// Rewind the file, read in the page stream and DEFLATE it // Rewind the file, read in the page stream and DEFLATE it
fseek( workFile, 0, SEEK_SET ); fseek( workFile, 0, SEEK_SET );
...@@ -468,7 +469,7 @@ void PDF_PLOTTER::closePdfStream() ...@@ -468,7 +469,7 @@ void PDF_PLOTTER::closePdfStream()
::wxRemoveFile( workFilename ); ::wxRemoveFile( workFilename );
// NULL means memos owns the memory, but provide a hint on optimum size needed. // NULL means memos owns the memory, but provide a hint on optimum size needed.
wxMemoryOutputStream memos( NULL, std::max( 2000, stream_len ) ) ; wxMemoryOutputStream memos( NULL, std::max( 2000l, stream_len ) ) ;
{ {
/* Somewhat standard parameters to compress in DEFLATE. The PDF spec is /* Somewhat standard parameters to compress in DEFLATE. The PDF spec is
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2007-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2007-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -91,22 +91,16 @@ END_EVENT_TABLE() ...@@ -91,22 +91,16 @@ END_EVENT_TABLE()
EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
const wxPoint& pos, const wxSize& size ) : const wxPoint& pos, const wxSize& size ) :
#if wxCHECK_VERSION( 2, 9, 5 )
wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL ) wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL )
#else
wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL | wxALWAYS_SHOW_SB )
#endif
{ {
wxASSERT( parent ); wxASSERT( parent );
#if wxCHECK_VERSION( 2, 9, 5 )
#ifndef USE_OSX_MAGNIFY_EVENT #ifndef USE_OSX_MAGNIFY_EVENT
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS ); ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
#else #else
ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER ); ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
#endif #endif
DisableKeyboardScrolling(); DisableKeyboardScrolling();
#endif
m_scrollIncrementX = std::min( size.x / 8, 10 ); m_scrollIncrementX = std::min( size.x / 8, 10 );
m_scrollIncrementY = std::min( size.y / 8, 10 ); m_scrollIncrementY = std::min( size.y / 8, 10 );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* 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) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2007-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -50,9 +50,10 @@ void DSNLEXER::init() ...@@ -50,9 +50,10 @@ void DSNLEXER::init()
specctraMode = false; specctraMode = false;
space_in_quoted_tokens = false; space_in_quoted_tokens = false;
commentsAreTokens = false; commentsAreTokens = false;
curOffset = 0;
#if 1 #if 1
if( keywordCount > 11 ) if( keywordCount > 11 )
{ {
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
// Conversion to application internal units defined at build time. // Conversion to application internal units defined at build time.
#if defined( PCBNEW ) #if defined( PCBNEW )
#include <class_board_item.h> #include <class_board_item.h> // for FMT_IU
#elif defined( EESCHEMA ) #elif defined( EESCHEMA )
#include <sch_item_struct.h> #include <sch_item_struct.h> // for FMT_IU
#elif defined( GERBVIEW ) #elif defined( GERBVIEW )
#elif defined( PL_EDITOR ) #elif defined( PL_EDITOR )
#include <base_units.h> #include <base_units.h>
......
/* /*
* 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) 2010-12 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2012-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -701,7 +701,8 @@ const wxString FP_LIB_TABLE::GlobalPathEnvVariableName() ...@@ -701,7 +701,8 @@ const wxString FP_LIB_TABLE::GlobalPathEnvVariableName()
} }
bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR ) bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable )
throw (IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception )
{ {
bool tableExists = true; bool tableExists = true;
wxFileName fn = GetGlobalTableFileName(); wxFileName fn = GetGlobalTableFileName();
...@@ -761,7 +762,8 @@ void FP_LIB_TABLE::Load( const wxString& aFileName ) ...@@ -761,7 +762,8 @@ void FP_LIB_TABLE::Load( const wxString& aFileName )
} }
void FP_LIB_TABLE::Save( const wxString& aFileName ) const throw( IO_ERROR ) void FP_LIB_TABLE::Save( const wxString& aFileName )
const throw( IO_ERROR, boost::interprocess::lock_exception )
{ {
FILE_OUTPUTFORMATTER sf( aFileName ); FILE_OUTPUTFORMATTER sf( aFileName );
Format( &sf, 0 ); Format( &sf, 0 );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2014-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -57,7 +57,9 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a ...@@ -57,7 +57,9 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a
EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ), EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ),
KIWAY_HOLDER( 0 ), KIWAY_HOLDER( 0 ),
m_modal( false ), m_modal( false ),
m_modal_loop( 0 ), m_modal_resultant_parent( 0 ) m_modal_loop( 0 ),
m_modal_resultant_parent( 0 ),
m_modal_ret_val( false )
{ {
// DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );) // DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
} }
......
...@@ -35,137 +35,6 @@ ...@@ -35,137 +35,6 @@
#include <class_board.h> #include <class_board.h>
#include <3d_viewer.h> #include <3d_viewer.h>
/**
* attempts to set the environment variable given by aKiSys3Dmod to a valid path.
* (typically "KISYS3DMOD" )
* If the environment variable is already set, then it left as is to respect
* the wishes of the user.
*
* The path is determined by attempting to find the path modules/packages3d
* files in kicad tree.
* This may or may not be the best path but it provides the best solution for
* backwards compatibility with the previous 3D shapes search path implementation.
*
* @note This must be called after #SetBinDir() is called at least on Windows.
* Otherwise, the kicad path is not known (Windows specific)
*
* @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD"
* @param aProcess = the current process
* @return false if the aKiSys3Dmod path is not valid.
*/
bool Set3DShapesDefaultPath( const wxString& aKiSys3Dmod, const PGM_BASE* aProcess )
{
wxString path;
// Set the KISYS3DMOD environment variable for the current process,
// if it is not already defined in the user's environment and valid.
if( wxGetEnv( aKiSys3Dmod, &path ) && wxFileName::DirExists( path ) )
return true;
#if 1
// Try to find a valid path is standard KiCad paths
SEARCH_STACK& search = Kiface().KifaceSearch();
path = search.FindValidPath( LIB3D_FOLDER );
if( !path.IsEmpty() )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
#endif
// Attempt to determine where the 3D shape libraries were installed using the
// legacy path:
// on Unix: /usr/local/kicad/share/modules/packages3d
// oor /usr/local/kicad/share/kicad/modules/packages3d
// or /usr/share/kicad/modules/packages3d
// On Windows: bin../share/modules/packages3d
wxString relpath( wxT( "modules/" ) );
relpath += LIB3D_FOLDER;
// Apple MacOSx
#ifdef __WXMAC__
path = wxT("/Library/Application Support/kicad/modules/packages3d/");
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
path = wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT("/Library/Application Support/kicad/modules/packages3d/");
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
#elif defined(__UNIX__) // Linux and non-Apple Unix
// Try the home directory:
path.Empty();
wxGetEnv( wxT("HOME"), &path );
path += wxT("/kicad/share/") + relpath;
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
path.Empty();
wxGetEnv( wxT("HOME"), &path );
path += wxT("/kicad/share/kicad/") + relpath;
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
// Try the standard install path:
path = wxT("/usr/local/kicad/share/") + relpath;
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
// Try the new standard install path:
path = wxT("/usr/local/kicad/share/kicad/") + relpath;
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
// Try the official distrib standard install path:
path = wxT("/usr/share/kicad/") + relpath;
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
#else // Windows
// On Windows, the install path is given by the path of executables
wxFileName fn;
fn.AssignDir( aProcess->GetExecutablePath() );
fn.RemoveLastDir();
path = fn.GetPathWithSep() + wxT("share/") + relpath;
if( wxFileName::DirExists( path ) )
{
wxSetEnv( aKiSys3Dmod, path );
return true;
}
#endif
return false;
}
wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask ) wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask )
{ {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/snglinst.h> #include <wx/snglinst.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/sysopt.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <wxstruct.h> #include <wxstruct.h>
...@@ -426,11 +427,15 @@ bool PGM_BASE::initPgm() ...@@ -426,11 +427,15 @@ bool PGM_BASE::initPgm()
// Set locale option for separator used in float numbers // Set locale option for separator used in float numbers
SetLocaleTo_Default(); SetLocaleTo_Default();
#ifdef __WXMAC__
// Always show filters on Open dialog to be able to choose plugin
wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
#endif
return true; return true;
} }
bool PGM_BASE::setExecutablePath() bool PGM_BASE::setExecutablePath()
{ {
m_bin_dir = wxStandardPaths::Get().GetExecutablePath(); m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
......
...@@ -181,11 +181,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) ...@@ -181,11 +181,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
start_common( aCtlBits ); start_common( aCtlBits );
// Set 3D shape path (environment variable KISYS3DMOD (if not defined or valid)
// Currently, called here, but could be moved ( OpenProjectFiles() ? )
// if KISYS3DMOD is defined in a project config file
Set3DShapesDefaultPath( KISYS3DMOD, aProgram );
/* Now that there are no *.mod files in the standard library, this function /* Now that there are no *.mod files in the standard library, this function
has no utility. User should simply set the variable manually. has no utility. User should simply set the variable manually.
Looking for *.mod files which do not exist is fruitless. Looking for *.mod files which do not exist is fruitless.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
#include <wx/choicdlg.h> #include <wx/choicdlg.h>
void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences ) throw( IO_ERROR ) void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences )
throw( IO_ERROR, boost::bad_pointer )
{ {
// Build a flat list of components in schematic: // Build a flat list of components in schematic:
SCH_REFERENCE_LIST refs; SCH_REFERENCE_LIST refs;
......
/* /*
* 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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2009-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -397,7 +397,12 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx ...@@ -397,7 +397,12 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->GetItem( ii ); schitem = (SCH_ITEM*) block->GetItem( ii );
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
if( schitem->Type() == SCH_COMPONENT_T )
((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
g_XorMode, g_GhostColor, false );
else
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
} }
} }
...@@ -408,7 +413,12 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx ...@@ -408,7 +413,12 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->GetItem( ii ); schitem = (SCH_ITEM*) block->GetItem( ii );
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
if( schitem->Type() == SCH_COMPONENT_T )
((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
g_XorMode, g_GhostColor, false );
else
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
} }
} }
......
...@@ -442,7 +442,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) ...@@ -442,7 +442,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() ); ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() );
my_clone->Move( pos ); my_clone->Move( pos );
my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode ); my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( my_clone, DC ); PrepareMoveItem( my_clone, DC );
} }
else else
{ {
......
...@@ -245,9 +245,9 @@ LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) : ...@@ -245,9 +245,9 @@ LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) :
LIB_PART::~LIB_PART() LIB_PART::~LIB_PART()
{ {
wxLogTrace( traceSchLibMem, wxLogTrace( traceSchLibMem,
wxT( "%s: destroying part '%s' with alias list count of %u." ), wxT( "%s: destroying part '%s' with alias list count of %llu." ),
GetChars( wxString::FromAscii( __WXFUNCTION__ ) ), GetChars( GetName() ), GetChars( wxString::FromAscii( __WXFUNCTION__ ) ), GetChars( GetName() ),
m_aliases.size() ); (long long unsigned) m_aliases.size() );
// If the part is being deleted directly rather than through the library, // If the part is being deleted directly rather than through the library,
// delete all of the aliases. // delete all of the aliases.
...@@ -1697,11 +1697,11 @@ LIB_ALIAS* LIB_PART::RemoveAlias( LIB_ALIAS* aAlias ) ...@@ -1697,11 +1697,11 @@ LIB_ALIAS* LIB_PART::RemoveAlias( LIB_ALIAS* aAlias )
bool rename = aAlias->IsRoot(); bool rename = aAlias->IsRoot();
wxLogTrace( traceSchLibMem, wxLogTrace( traceSchLibMem,
wxT( "%s: part:'%s', alias:'%s', alias count %u, reference count %d." ), wxT( "%s: part:'%s', alias:'%s', alias count %llu, reference count %ld." ),
GetChars( wxString::FromAscii( __WXFUNCTION__ ) ), GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
GetChars( m_name ), GetChars( m_name ),
GetChars( aAlias->GetName() ), GetChars( aAlias->GetName() ),
m_aliases.size(), (long long unsigned) m_aliases.size(),
m_me.use_count() ); m_me.use_count() );
it = m_aliases.erase( it ); it = m_aliases.erase( it );
......
...@@ -63,6 +63,8 @@ PART_LIB::PART_LIB( int aType, const wxString& aFileName ) : ...@@ -63,6 +63,8 @@ PART_LIB::PART_LIB( int aType, const wxString& aFileName ) :
timeStamp = 0; timeStamp = 0;
isCache = false; isCache = false;
timeStamp = wxDateTime::Now(); timeStamp = wxDateTime::Now();
versionMajor = 0; // Will be updated after reading the lib file
versionMinor = 0; // Will be updated after reading the lib file
fileName = aFileName; fileName = aFileName;
...@@ -804,7 +806,8 @@ PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName ) throw( IO_ERROR, bo ...@@ -804,7 +806,8 @@ PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName ) throw( IO_ERROR, bo
} }
PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator ) throw( IO_ERROR ) PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator )
throw( IO_ERROR, boost::bad_pointer )
{ {
#if 1 #if 1
// Don't reload the library if it is already loaded. // Don't reload the library if it is already loaded.
......
...@@ -134,8 +134,8 @@ public: ...@@ -134,8 +134,8 @@ public:
* @return PART_LIB* - the new PART_LIB, which remains owned by this PART_LIBS container. * @return PART_LIB* - the new PART_LIB, which remains owned by this PART_LIBS container.
* @throw IO_ERROR if there's any problem loading. * @throw IO_ERROR if there's any problem loading.
*/ */
PART_LIB* AddLibrary( const wxString& aFileName, PART_LIB* AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator )
PART_LIBS::iterator& aIterator ) throw( IO_ERROR ); throw( IO_ERROR, boost::bad_pointer );
/** /**
* Function RemoveLibrary * Function RemoveLibrary
......
...@@ -187,8 +187,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -187,8 +187,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
copySelectedFieldToPanel();
wxToolTip::Enable( true ); wxToolTip::Enable( true );
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
...@@ -757,6 +755,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ...@@ -757,6 +755,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
// resume editing at the last row edited, last time dialog was up. // resume editing at the last row edited, last time dialog was up.
setSelectedFieldNdx( s_SelectedRow ); setSelectedFieldNdx( s_SelectedRow );
copySelectedFieldToPanel();
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -66,6 +66,7 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : ...@@ -66,6 +66,7 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
) )
{ {
m_parent = parent; m_parent = parent;
m_lastMarkerFound = NULL;
Init(); Init();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
/* /*
* 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) 1992-2012 Jean-Pierre Charras <jp.charras at wanadoo.fr * Copyright (C) 1992-2015 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2010 Lorenzo Marcantonio * Copyright (C) 1992-2010 Lorenzo Marcantonio
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* *
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -343,7 +343,15 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirecto ...@@ -343,7 +343,15 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirecto
wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT(".") + aExtension); wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT(".") + aExtension);
EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ); if( !EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ) )
{
wxString msg;
msg.Printf( _( "Could not write plot files to folder \"%s\"." ),
GetChars( outputDir.GetPath() ) );
msg << wxT( "\n" );
aReporter->Report( msg );
}
wxFileName fn( plotFileName ); wxFileName fn( plotFileName );
fn.SetPath( outputDir.GetFullPath() ); fn.SetPath( outputDir.GetFullPath() );
return fn; return fn;
......
...@@ -102,7 +102,7 @@ private: ...@@ -102,7 +102,7 @@ private:
* @param aOldsheetpath the stored old sheet path for the current sheet before the plot started * @param aOldsheetpath the stored old sheet path for the current sheet before the plot started
* @param aMsg the message which is print to the message box * @param aMsg the message which is print to the message box
*/ */
void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH aOldsheetpath, void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH& aOldsheetpath,
const wxString& aMsg ); const wxString& aMsg );
// DXF // DXF
......
...@@ -123,7 +123,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) ...@@ -123,7 +123,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
// Prepare display to move the new item // Prepare display to move the new item
textItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); textItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( (SCH_ITEM*) textItem, aDC ); PrepareMoveItem( (SCH_ITEM*) textItem, aDC );
return textItem; return textItem;
} }
......
...@@ -56,7 +56,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -56,7 +56,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
// Draw the new part, MoveItem() expects it to be already on screen. // Draw the new part, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
MoveItem( newitem, &dc ); PrepareMoveItem( newitem, &dc );
} }
break; break;
...@@ -69,7 +69,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -69,7 +69,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
// Draw the new item, MoveItem() expects it to be already on screen. // Draw the new item, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
MoveItem( newitem, &dc ); PrepareMoveItem( newitem, &dc );
} }
break; break;
......
...@@ -222,7 +222,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC, ...@@ -222,7 +222,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
SetMsgPanel( items ); SetMsgPanel( items );
component->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); component->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
component->SetFlags( IS_NEW ); component->SetFlags( IS_NEW );
MoveItem( (SCH_ITEM*) component, aDC ); PrepareMoveItem( (SCH_ITEM*) component, aDC );
return component; return component;
} }
......
...@@ -56,7 +56,8 @@ class TreeItemData : public wxTreeItemData ...@@ -56,7 +56,8 @@ class TreeItemData : public wxTreeItemData
{ {
public: public:
SCH_SHEET_PATH m_SheetPath; SCH_SHEET_PATH m_SheetPath;
TreeItemData( SCH_SHEET_PATH sheet ) : wxTreeItemData()
TreeItemData( SCH_SHEET_PATH& sheet ) : wxTreeItemData()
{ {
m_SheetPath = sheet; m_SheetPath = sheet;
} }
...@@ -70,7 +71,12 @@ private: ...@@ -70,7 +71,12 @@ private:
wxImageList* imageList; wxImageList* imageList;
public: public:
HIERARCHY_TREE() { } HIERARCHY_TREE()
{
m_Parent = NULL;
imageList = NULL;
}
HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ); HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent );
DECLARE_DYNAMIC_CLASS( HIERARCHY_TREE ) DECLARE_DYNAMIC_CLASS( HIERARCHY_TREE )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -95,6 +95,9 @@ LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent ) ...@@ -95,6 +95,9 @@ LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
m_typeName = _( "Arc" ); m_typeName = _( "Arc" );
m_editState = 0; m_editState = 0;
m_lastEditState = 0; m_lastEditState = 0;
m_editCenterDistance = 0.0;
m_editSelectPoint = ARC_STATUS_START;
m_editDirection = 0;
} }
......
/* /*
* 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) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
/* /*
* 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) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
/* /*
* 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) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -834,11 +835,12 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, ...@@ -834,11 +835,12 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
aColor = GetInvisibleItemColor(); aColor = GetInvisibleItemColor();
} }
LIB_PART* Entry = GetParent(); // aData is used here as bool: if not null, draw pin texts
bool DrawPinText = true; //(i.e = true to draw pin texts, false to draw only the pin shape, which
// is useful to draw moving component in fast mode)
if( ( aData != NULL ) && ( (bool*) aData == false ) ) LIB_PART* Entry = GetParent();
DrawPinText = false; bool drawPinText = aData ? true : false;
/* Calculate pin orient taking in account the component orientation. */ /* Calculate pin orient taking in account the component orientation. */
int orient = PinDrawOrient( aTransform ); int orient = PinDrawOrient( aTransform );
...@@ -849,7 +851,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, ...@@ -849,7 +851,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
/* Drawing from the pin and the special symbol combination */ /* Drawing from the pin and the special symbol combination */
DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor ); DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor );
if( DrawPinText ) if( drawPinText )
{ {
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(), DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(),
Entry->ShowPinNumbers(), Entry->ShowPinNames(), Entry->ShowPinNumbers(), Entry->ShowPinNames(),
......
/* /*
* 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) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -98,8 +99,21 @@ class LIB_PIN : public LIB_ITEM ...@@ -98,8 +99,21 @@ class LIB_PIN : public LIB_ITEM
///< "G6", or "12". It is stored as "12\0\0" and does not ///< "G6", or "12". It is stored as "12\0\0" and does not
///< depend on endian type. ///< depend on endian type.
int m_numTextSize; int m_numTextSize;
int m_nameTextSize; /* Pin num and Pin name sizes */ int m_nameTextSize; ///< Pin num and Pin name sizes
/**
* Draw a pin, with or without the pin texts
*
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
* @param aDC Device Context (can be null)
* @param aOffset Offset to draw
* @param aColor -1 to use the normal body item color, or use this color if >= 0
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aData = used here as bool: if not null, draw pin texts
* (i.e = true to draw pin texts, false to draw only the pin shape, which
* is useful to draw moving component in fast mode)
* @param aTransform Transform Matrix (rotation, mirror ..)
*/
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -51,6 +51,7 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_PART* aParent ) : ...@@ -51,6 +51,7 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_PART* aParent ) :
m_Width = 0; m_Width = 0;
m_isFillable = true; m_isFillable = true;
m_typeName = _( "PolyLine" ); m_typeName = _( "PolyLine" );
m_ModifyIndex = 0;
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <xnode.h> // also nests: <wx/xml/xml.h> #include <xnode.h> // also nests: <wx/xml/xml.h>
#include <build_version.h> #include <build_version.h>
#include <set> #include <set>
#include <sch_base_frame.h>
#define INTERMEDIATE_NETLIST_EXT wxT( "xml" ) #define INTERMEDIATE_NETLIST_EXT wxT( "xml" )
...@@ -197,12 +198,13 @@ class NETLIST_EXPORT_TOOL ...@@ -197,12 +198,13 @@ class NETLIST_EXPORT_TOOL
* builds the entire document tree for the generic export. This is factored * builds the entire document tree for the generic export. This is factored
* out here so we can write the tree in either S-expression file format * out here so we can write the tree in either S-expression file format
* or in XML if we put the tree built here into a wxXmlDocument. * or in XML if we put the tree built here into a wxXmlDocument.
* @return XNODE* - the root nodes
*/ */
XNODE* makeGenericRoot(); XNODE* makeGenericRoot();
/** /**
* Function makeGenericComponents * Function makeGenericComponents
* returns a sub-tree holding all the schematic components. * @return XNODE* - returns a sub-tree holding all the schematic components.
*/ */
XNODE* makeGenericComponents(); XNODE* makeGenericComponents();
...@@ -216,12 +218,14 @@ class NETLIST_EXPORT_TOOL ...@@ -216,12 +218,14 @@ class NETLIST_EXPORT_TOOL
/** /**
* Function makeGenericLibParts * Function makeGenericLibParts
* fills out an XML node with the unique library parts and returns it. * fills out an XML node with the unique library parts and returns it.
* @return XNODE* - the library parts nodes
*/ */
XNODE* makeGenericLibParts(); XNODE* makeGenericLibParts();
/** /**
* Function makeGenericListOfNets * Function makeGenericListOfNets
* fills out an XML node with a list of nets and returns it. * fills out an XML node with a list of nets and returns it.
* @return XNODE* - the list of nets nodes
*/ */
XNODE* makeGenericListOfNets(); XNODE* makeGenericListOfNets();
...@@ -229,6 +233,7 @@ class NETLIST_EXPORT_TOOL ...@@ -229,6 +233,7 @@ class NETLIST_EXPORT_TOOL
* Function makeGenericLibraries * Function makeGenericLibraries
* fills out an XML node with a list of used libraries and returns it. * fills out an XML node with a list of used libraries and returns it.
* Must have called makeGenericLibParts() before this function. * Must have called makeGenericLibParts() before this function.
* @return XNODE* - the library nodes
*/ */
XNODE* makeGenericLibraries(); XNODE* makeGenericLibraries();
...@@ -637,7 +642,13 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE ...@@ -637,7 +642,13 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE
XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader()
{ {
XNODE* xdesign = node( wxT("design") ); SCH_SCREEN* screen;
XNODE* xdesign = node( wxT("design") );
XNODE* xtitleBlock;
XNODE* xsheet;
XNODE* xcomment;
wxString sheetTxt;
wxFileName sourceFileName;
// the root sheet is a special sheet, call it source // the root sheet is a special sheet, call it source
xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) );
...@@ -647,27 +658,55 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() ...@@ -647,27 +658,55 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader()
// which Eeschema tool // which Eeschema tool
xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) );
/* @todo might do a list of schematic pages /*
Export the sheets information
<page name="">
<title/>
<revision/>
<company/>
<comments>
<comment>blah</comment> <!-- comment1 -->
<comment>blah</comment> <!-- comment2 -->
</comments>
<pagesize/>
</page>
:
and a sheet hierarchy report here
<sheets>
<sheet name="sheetname1" page="pagenameA">
<sheet name="sheetname2" page="pagenameB"/> use recursion to output?
</sheet>
</sheets>
*/ */
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* sheet = sheetList.GetFirst(); sheet; sheet = sheetList.GetNext() )
{
screen = sheet->LastScreen();
xdesign->AddChild( xsheet = node( wxT( "sheet" ) ) );
// get the string representation of the sheet index number.
// Note that sheet->GetIndex() is zero index base and we need to increment the number by one to make
// human readable
sheetTxt.Printf( wxT( "%d" ), ( sheetList.GetIndex() + 1 ) );
xsheet->AddAttribute( wxT( "number" ), sheetTxt );
xsheet->AddAttribute( wxT( "name" ), sheet->PathHumanReadable() );
xsheet->AddAttribute( wxT( "tstamps" ), sheet->Path() );
TITLE_BLOCK tb = screen->GetTitleBlock();
xsheet->AddChild( xtitleBlock = node( wxT( "title_block" ) ) );
xtitleBlock->AddChild( node( wxT( "title" ), tb.GetTitle() ) );
xtitleBlock->AddChild( node( wxT( "company" ), tb.GetCompany() ) );
xtitleBlock->AddChild( node( wxT( "rev" ), tb.GetRevision() ) );
xtitleBlock->AddChild( node( wxT( "date" ), tb.GetDate() ) );
// We are going to remove the fileName directories.
sourceFileName = wxFileName( screen->GetFileName() );
xtitleBlock->AddChild( node( wxT( "source" ), sourceFileName.GetFullName() ) );
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
xcomment->AddAttribute( wxT("number"), wxT("1") );
xcomment->AddAttribute( wxT( "value" ), tb.GetComment1() );
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
xcomment->AddAttribute( wxT("number"), wxT("2") );
xcomment->AddAttribute( wxT( "value" ), tb.GetComment2() );
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
xcomment->AddAttribute( wxT("number"), wxT("3") );
xcomment->AddAttribute( wxT( "value" ), tb.GetComment3() );
xtitleBlock->AddChild( xcomment = node( wxT( "comment" ) ) );
xcomment->AddAttribute( wxT("number"), wxT("4") );
xcomment->AddAttribute( wxT( "value" ), tb.GetComment4() );
}
return xdesign; return xdesign;
} }
......
...@@ -515,8 +515,6 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo ...@@ -515,8 +515,6 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo
void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId ) void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
{ {
bool selected = aMasterPin->IsSelected();
LIB_PART* part = GetCurPart(); LIB_PART* part = GetCurPart();
if( !part || !aMasterPin ) if( !part || !aMasterPin )
...@@ -527,6 +525,8 @@ void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId ) ...@@ -527,6 +525,8 @@ void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
OnModify( ); OnModify( );
bool selected = aMasterPin->IsSelected();
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
{ {
if( pin->GetConvert() && pin->GetConvert() != m_convert ) if( pin->GetConvert() && pin->GetConvert() != m_convert )
......
...@@ -139,7 +139,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) ...@@ -139,7 +139,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef )
void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter, void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter,
SCH_SHEET_PATH aOldsheetpath, const wxString& aMsg ) SCH_SHEET_PATH& aOldsheetpath, const wxString& aMsg )
{ {
aPlotter->EndPlot(); aPlotter->EndPlot();
delete aPlotter; delete aPlotter;
......
...@@ -10,6 +10,7 @@ set( xsl_lst ...@@ -10,6 +10,7 @@ set( xsl_lst
netlist_form_cadstar.xsl netlist_form_cadstar.xsl
netlist_form_OrcadPcb2.xsl netlist_form_OrcadPcb2.xsl
netlist_form_pads-pcb.xsl netlist_form_pads-pcb.xsl
bom_with_title_block_2_csv.xsl
) )
install( FILES ${xsl_lst} install( FILES ${xsl_lst}
......
<!--
@package
EESCHEMA BOM plugin. Creates BOM CSV files from the project net file.
Based on Stefan Helmert bom2csv.xsl
Note:
The project infomation (i.e title, company and revision) is taken from and the root sheet.
Arthur:
Ronald Sousa HashDefineElectronics.com
Usage:
on Windows:
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
on Linux:
xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I"
Ouput Example:
Source,
Kicad Rev, working director and file source
Generated Date, date this file was generated
Title, the project's tile
Company, the project's company
Rev, the project's revision
Date Source, project's issue date
Comment, This is comment 1
Comment, This is comment 2
Comment, This is comment 3
Comment, This is comment 4
Reference, Value, Fields[n], Library, Library Ref
U1, PIC32MX, Fields[n], KicadLib, PIC
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF, or LF, your choice -->
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<!-- for table head and empty table fields-->
<xsl:key name="headentr" match="field" use="@name"/>
<!-- main part -->
<xsl:template match="/export">
<xsl:text>Source,</xsl:text><xsl:value-of select="design/source"/><xsl:text>&nl;</xsl:text>
<xsl:text>Kicad Rev,</xsl:text><xsl:value-of select="design/tool"/><xsl:text>&nl;</xsl:text>
<xsl:text>Generated Date,</xsl:text><xsl:value-of select="design/date"/><xsl:text>&nl;</xsl:text>
<xsl:text>&nl;</xsl:text>
<!-- Ouput Root sheet project information -->
<xsl:apply-templates select="/export/design/sheet[1]"/>
<xsl:text>&nl;</xsl:text>
<!-- Output table header -->
<xsl:text>Reference,Value,</xsl:text>
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:value-of select="@name"/>
<xsl:text>,</xsl:text>
</xsl:for-each>
<xsl:text>Library,Library Ref</xsl:text>
<xsl:text>&nl;</xsl:text>
<!-- all table entries -->
<xsl:apply-templates select="components/comp"/>
</xsl:template>
<!-- generate the Root sheet project information -->
<xsl:template match="/export/design/sheet[1]">
<xsl:choose>
<xsl:when test="title_block/title !=''">
<xsl:text>Title,</xsl:text><xsl:value-of select="title_block/title"/><xsl:text>&nl;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Title,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="title_block/company !=''">
<xsl:text>Company,</xsl:text><xsl:value-of select="title_block/company"/><xsl:text>&nl;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Company,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="title_block/rev !=''">
<xsl:text>Revision,</xsl:text><xsl:value-of select="title_block/rev"/><xsl:text>&nl;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Revision,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="title_block/date !=''">
<xsl:text>Date Issue,</xsl:text><xsl:value-of select="title_block/date"/><xsl:text>&nl;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Date Issue,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="title_block/comment"/>
</xsl:template>
<xsl:template match="title_block/comment">
<xsl:choose>
<xsl:when test="@value !=''">
<xsl:text>Comment,</xsl:text><xsl:value-of select="@value"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- the table entries -->
<xsl:template match="components/comp">
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
<xsl:apply-templates select="fields"/>
<xsl:apply-templates select="libsource"/>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- the library selection -->
<xsl:template match="libsource">
<xsl:value-of select="@lib"/><xsl:text>,</xsl:text>
<xsl:value-of select="@part"/>
</xsl:template>
<!-- table entries with dynamic table head -->
<xsl:template match="fields">
<!-- remember current fields section -->
<xsl:variable name="fieldvar" select="field"/>
<!-- for all existing head entries -->
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:variable name="allnames" select="@name"/>
<!-- for all field entries in the remembered fields section -->
<xsl:for-each select="$fieldvar">
<!-- only if this field entry exists in this fields section -->
<xsl:if test="@name=$allnames">
<!-- content of the field -->
<xsl:value-of select="."/>
</xsl:if>
<!--
If it does not exist, use an empty cell in output for this row.
Every non-blank entry is assigned to its proper column.
-->
</xsl:for-each>
<xsl:text>,</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
...@@ -51,6 +51,14 @@ public: ...@@ -51,6 +51,14 @@ public:
~SCH_BUS_ENTRY_BASE() { } ~SCH_BUS_ENTRY_BASE() { }
/**
* Virtual function IsMovableFromAnchorPoint
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* @return false for a bus entry
*/
bool IsMovableFromAnchorPoint() { return false; }
wxPoint m_End() const; wxPoint m_End() const;
/** /**
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 20011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2011-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -255,6 +255,7 @@ public: ...@@ -255,6 +255,7 @@ public:
SetScanTypes( aScanTypes ); SetScanTypes( aScanTypes );
m_foundIndex = 0; m_foundIndex = 0;
m_forceSearch = false; m_forceSearch = false;
m_sheetPath = NULL;
} }
void Empty() void Empty()
......
/* /*
* 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) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -182,6 +182,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit, ...@@ -182,6 +182,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) : SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) :
SCH_ITEM( aComponent ) SCH_ITEM( aComponent )
{ {
m_currentSheetPath = NULL;
m_Parent = aComponent.m_Parent; m_Parent = aComponent.m_Parent;
m_Pos = aComponent.m_Pos; m_Pos = aComponent.m_Pos;
m_unit = aComponent.m_unit; m_unit = aComponent.m_unit;
...@@ -327,23 +328,26 @@ int SCH_COMPONENT::GetUnitCount() const ...@@ -327,23 +328,26 @@ int SCH_COMPONENT::GetUnitCount() const
} }
void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE DrawMode, EDA_COLOR_T Color, bool DrawPinText ) GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
bool aDrawPinText )
{ {
if( PART_SPTR part = m_part.lock() ) if( PART_SPTR part = m_part.lock() )
{ {
part->Draw( panel, DC, m_Pos + offset, m_unit, m_convert, DrawMode, Color, m_transform, DrawPinText, false ); part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, aDrawMode, aColor,
m_transform, aDrawPinText, false );
} }
else // Use dummy() part if the actual cannot be found. else // Use dummy() part if the actual cannot be found.
{ {
dummy()->Draw( panel, DC, m_Pos + offset, 0, 0, DrawMode, Color, m_transform, DrawPinText, false ); dummy()->Draw( aPanel, aDC, m_Pos + aOffset, 0, 0, aDrawMode, aColor,
m_transform, aDrawPinText, false );
} }
SCH_FIELD* field = GetField( REFERENCE ); SCH_FIELD* field = GetField( REFERENCE );
if( field->IsVisible() && !field->IsMoving() ) if( field->IsVisible() && !field->IsMoving() )
{ {
field->Draw( panel, DC, offset, DrawMode ); field->Draw( aPanel, aDC, aOffset, aDrawMode );
} }
for( int ii = VALUE; ii < GetFieldCount(); ii++ ) for( int ii = VALUE; ii < GetFieldCount(); ii++ )
...@@ -353,26 +357,26 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ...@@ -353,26 +357,26 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset
if( field->IsMoving() ) if( field->IsMoving() )
continue; continue;
field->Draw( panel, DC, offset, DrawMode ); field->Draw( aPanel, aDC, aOffset, aDrawMode );
} }
#if 0 #if 0
// Draw the component bounding box // Only for testing purposes, draw the component bounding box
{ {
EDA_RECT boundingBox = GetBoundingBox(); EDA_RECT boundingBox = GetBoundingBox();
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
#if 1 #if 1
if( GetField( REFERENCE )->IsVisible() ) if( GetField( REFERENCE )->IsVisible() )
{ {
boundingBox = GetField( REFERENCE )->GetBoundingBox(); boundingBox = GetField( REFERENCE )->GetBoundingBox();
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
} }
if( GetField( VALUE )->IsVisible() ) if( GetField( VALUE )->IsVisible() )
{ {
boundingBox = GetField( VALUE )->GetBoundingBox(); boundingBox = GetField( VALUE )->GetBoundingBox();
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
} }
#endif #endif
} }
...@@ -414,7 +418,7 @@ wxString SCH_COMPONENT::GetPath( const SCH_SHEET_PATH* sheet ) const ...@@ -414,7 +418,7 @@ wxString SCH_COMPONENT::GetPath( const SCH_SHEET_PATH* sheet ) const
wxString str; wxString str;
str.Printf( wxT( "%8.8lX" ), m_TimeStamp ); str.Printf( wxT( "%8.8lX" ), (long unsigned) m_TimeStamp );
return sheet->Path() + str; return sheet->Path() + str;
} }
...@@ -547,8 +551,8 @@ void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp ) ...@@ -547,8 +551,8 @@ void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp )
{ {
wxString string_timestamp, string_oldtimestamp; wxString string_timestamp, string_oldtimestamp;
string_timestamp.Printf( wxT( "%08lX" ), aNewTimeStamp ); string_timestamp.Printf( wxT( "%08lX" ), (long unsigned) aNewTimeStamp );
string_oldtimestamp.Printf( wxT( "%08lX" ), m_TimeStamp ); string_oldtimestamp.Printf( wxT( "%08lX" ), (long unsigned) m_TimeStamp );
EDA_ITEM::SetTimeStamp( aNewTimeStamp ); EDA_ITEM::SetTimeStamp( aNewTimeStamp );
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ ) for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
......
/* /*
* 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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -133,6 +135,16 @@ public: ...@@ -133,6 +135,16 @@ public:
return wxT( "SCH_COMPONENT" ); return wxT( "SCH_COMPONENT" );
} }
/**
* Virtual function IsMovableFromAnchorPoint
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
* @return false for a componant
*/
bool IsMovableFromAnchorPoint() { return false; }
void SetPartName( const wxString& aName, PART_LIBS* aLibs=NULL ); void SetPartName( const wxString& aName, PART_LIBS* aLibs=NULL );
const wxString& GetPartName() const { return m_part_name; } const wxString& GetPartName() const { return m_part_name; }
...@@ -287,21 +299,30 @@ public: ...@@ -287,21 +299,30 @@ public:
*/ */
LIB_PIN* GetPin( const wxString& number ); LIB_PIN* GetPin( const wxString& number );
void Draw( EDA_DRAW_PANEL* panel, /**
wxDC* DC, * Virtual function, from the base class SCH_ITEM::Draw
const wxPoint& offset, */
GR_DRAWMODE draw_mode, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T Color = UNSPECIFIED_COLOR ) GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR )
{ {
Draw( panel, DC, offset, draw_mode, Color, true ); Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true );
} }
void Draw( EDA_DRAW_PANEL* panel, /**
wxDC* DC, * Function Draw, specific to components.
const wxPoint& offset, * Draw a component, with or without pin texts.
GR_DRAWMODE draw_mode, * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
EDA_COLOR_T Color, * @param aDC Device Context (can be null)
bool DrawPinText ); * @param aOffset drawing Offset (usually wxPoint(0,0),
* but can be different when moving an object)
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aColor UNSPECIFIED_COLOR to use the normal body item color, or use this color if >= 0
* @param aDrawPinText = true to draw pin texts, false to draw only the pin shape
* usually false to draw a component when moving it, and true otherwise.
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
bool aDrawPinText );
void SwapData( SCH_ITEM* aItem ); void SwapData( SCH_ITEM* aItem );
......
/* /*
* 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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -114,8 +114,8 @@ int SCH_FIELD::GetPenSize() const ...@@ -114,8 +114,8 @@ int SCH_FIELD::GetPenSize() const
} }
void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
const wxPoint& offset, GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
{ {
int orient; int orient;
EDA_COLOR_T color; EDA_COLOR_T color;
...@@ -131,14 +131,13 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -131,14 +131,13 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
LineWidth = GetDefaultLineThickness(); LineWidth = GetDefaultLineThickness();
} }
// Clip pen size for small texts: // Clip pen size for small texts:
LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold ); LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold );
if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() ) if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() )
return; return;
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( aDC, aDrawMode );
// Calculate the text orientation according to the component orientation. // Calculate the text orientation according to the component orientation.
orient = m_Orient; orient = m_Orient;
...@@ -163,7 +162,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -163,7 +162,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
* and use GetBoundaryBox to know the text coordinate considered as centered * and use GetBoundaryBox to know the text coordinate considered as centered
*/ */
EDA_RECT boundaryBox = GetBoundingBox(); EDA_RECT boundaryBox = GetBoundingBox();
textpos = boundaryBox.Centre(); textpos = boundaryBox.Centre() + aOffset;
if( m_forceVisible ) if( m_forceVisible )
{ {
...@@ -179,8 +178,8 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -179,8 +178,8 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
color = GetLayerColor( LAYER_FIELDS ); color = GetLayerColor( LAYER_FIELDS );
} }
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, DC, textpos, color, GetFullyQualifiedText(), orient, m_Size, DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
LineWidth, m_Italic, m_Bold ); LineWidth, m_Italic, m_Bold );
...@@ -191,7 +190,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -191,7 +190,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
textpos = m_Pos - origin; textpos = m_Pos - origin;
textpos = parentComponent->GetScreenCoord( textpos ); textpos = parentComponent->GetScreenCoord( textpos );
textpos += parentComponent->GetPosition(); textpos += parentComponent->GetPosition();
GRLine( clipbox, DC, origin, textpos, 2, DARKGRAY ); GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY );
} }
/* Enable this to draw the bounding box around the text field to validate /* Enable this to draw the bounding box around the text field to validate
...@@ -200,7 +199,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -200,7 +199,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
#if 0 #if 0
// Draw boundary box: // Draw boundary box:
GRRect( panel->GetClipBox(), DC, boundaryBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundaryBox, 0, BROWN );
// Draw the text anchor point // Draw the text anchor point
...@@ -210,9 +209,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -210,9 +209,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
textpos = parentComponent->GetScreenCoord( textpos ); textpos = parentComponent->GetScreenCoord( textpos );
textpos += parentComponent->GetPosition(); textpos += parentComponent->GetPosition();
const int len = 10; const int len = 10;
GRLine( clipbox, DC, GRLine( clipbox, aDC,
textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE ); textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE );
GRLine( clipbox, DC, GRLine( clipbox, aDC,
textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE ); textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE );
#endif #endif
} }
......
/* /*
* 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) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -134,11 +134,8 @@ public: ...@@ -134,11 +134,8 @@ public:
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false; return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
} }
void Draw( EDA_DRAW_PANEL* aPanel, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -112,8 +112,7 @@ std::string SCH_ITEM::FormatInternalUnits( int aValue ) ...@@ -112,8 +112,7 @@ std::string SCH_ITEM::FormatInternalUnits( int aValue )
if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 ) if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
{ {
// printf( "f: " ); len = snprintf( buf, sizeof(buf), "%.10f", engUnits );
len = snprintf( buf, 49, "%.10f", engUnits );
while( --len > 0 && buf[len] == '0' ) while( --len > 0 && buf[len] == '0' )
buf[len] = '\0'; buf[len] = '\0';
...@@ -122,8 +121,7 @@ std::string SCH_ITEM::FormatInternalUnits( int aValue ) ...@@ -122,8 +121,7 @@ std::string SCH_ITEM::FormatInternalUnits( int aValue )
} }
else else
{ {
// printf( "g: " ); len = snprintf( buf, sizeof(buf), "%.10g", engUnits );
len = snprintf( buf, 49, "%.10g", engUnits );
} }
return std::string( buf, len ); return std::string( buf, len );
...@@ -135,7 +133,7 @@ std::string SCH_ITEM::FormatAngle( double aAngle ) ...@@ -135,7 +133,7 @@ std::string SCH_ITEM::FormatAngle( double aAngle )
char temp[50]; char temp[50];
int len; int len;
len = snprintf( temp, 49, "%.10g", aAngle / 10.0 ); len = snprintf( temp, sizeof(temp), "%.10g", aAngle / 10.0 );
return std::string( temp, len ); return std::string( temp, len );
} }
......
...@@ -117,6 +117,8 @@ class SCH_ITEM : public EDA_ITEM ...@@ -117,6 +117,8 @@ class SCH_ITEM : public EDA_ITEM
protected: protected:
LAYERSCH_ID m_Layer; LAYERSCH_ID m_Layer;
EDA_ITEMS m_connections; ///< List of items connected to this item. EDA_ITEMS m_connections; ///< List of items connected to this item.
wxPoint m_storedPos; ///< a temporary variable used in some move commands
///> to store a initial pos (of the item or mouse cursor)
public: public:
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ); SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
...@@ -141,6 +143,19 @@ public: ...@@ -141,6 +143,19 @@ public:
SCH_ITEM* Next() const { return static_cast<SCH_ITEM*>( Pnext ); } SCH_ITEM* Next() const { return static_cast<SCH_ITEM*>( Pnext ); }
SCH_ITEM* Back() const { return static_cast<SCH_ITEM*>( Pback ); } SCH_ITEM* Back() const { return static_cast<SCH_ITEM*>( Pback ); }
/**
* Virtual function IsMovableFromAnchorPoint
* @return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
*/
virtual bool IsMovableFromAnchorPoint() { return true; }
wxPoint& GetStoredPos() { return m_storedPos; }
void SetStoredPos( wxPoint aPos ) { m_storedPos = aPos; }
/** /**
* Function GetLayer * Function GetLayer
* returns the layer this item is on. * returns the layer this item is on.
...@@ -162,12 +177,17 @@ public: ...@@ -162,12 +177,17 @@ public:
/** /**
* Function Draw * Function Draw
* Draw a schematic item. Each schematic item should have its own method
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
* @param aDC Device Context (can be null)
* @param aOffset drawing Offset (usually wxPoint(0,0),
* but can be different when moving an object)
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aColor UNSPECIFIED_COLOR to use the normal body item color,
* or force this color if it is a valid color
*/ */
virtual void Draw( EDA_DRAW_PANEL* aPanel, virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
/** /**
* Function Move * Function Move
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* *
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -94,6 +94,8 @@ SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) : ...@@ -94,6 +94,8 @@ SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) :
KIWAY_HOLDER( aKiway ), KIWAY_HOLDER( aKiway ),
m_paper( wxT( "A4" ) ) m_paper( wxT( "A4" ) )
{ {
m_modification_sync = 0;
SetZoom( 32 ); SetZoom( 32 );
for( unsigned i = 0; i < DIM( SchematicZoomList ); i++ ) for( unsigned i = 0; i < DIM( SchematicZoomList ); i++ )
......
...@@ -53,8 +53,8 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : ...@@ -53,8 +53,8 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
m_sheetNameSize = GetDefaultTextSize(); m_sheetNameSize = GetDefaultTextSize();
m_fileNameSize = GetDefaultTextSize(); m_fileNameSize = GetDefaultTextSize();
m_screen = NULL; m_screen = NULL;
m_name.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp ); m_name.Printf( wxT( "Sheet%8.8lX" ), (long) m_TimeStamp );
m_fileName.Printf( wxT( "file%8.8lX.sch" ), m_TimeStamp ); m_fileName.Printf( wxT( "file%8.8lX.sch" ), (long) m_TimeStamp );
} }
...@@ -887,6 +887,14 @@ void SCH_SHEET::MirrorY( int aYaxis_position ) ...@@ -887,6 +887,14 @@ void SCH_SHEET::MirrorY( int aYaxis_position )
} }
} }
void SCH_SHEET::SetPosition( const wxPoint& aPosition )
{
// Remember the sheet and all pin sheet positions must be
// modified. So use Move function to do that.
Move( aPosition - m_pos );
}
void SCH_SHEET::Resize( const wxSize& aSize ) void SCH_SHEET::Resize( const wxSize& aSize )
{ {
......
/* /*
* 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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -95,11 +95,16 @@ public: ...@@ -95,11 +95,16 @@ public:
bool operator ==( const SCH_SHEET_PIN* aPin ) const; bool operator ==( const SCH_SHEET_PIN* aPin ) const;
void Draw( EDA_DRAW_PANEL* aPanel, /**
wxDC* aDC, * Virtual function IsMovableFromAnchorPoint
const wxPoint& aOffset, * Return true for items which are moved with the anchor point at mouse cursor
GR_DRAWMODE aDraw_mode, * and false for items moved with no reference to anchor
EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); * @return false for a hierarchical sheet pin
*/
bool IsMovableFromAnchorPoint() { return false; }
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
/** /**
* Function CreateGraphicShape (virtual) * Function CreateGraphicShape (virtual)
...@@ -247,6 +252,15 @@ public: ...@@ -247,6 +252,15 @@ public:
return wxT( "SCH_SHEET" ); return wxT( "SCH_SHEET" );
} }
/**
* Virtual function IsMovableFromAnchorPoint
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
* @return false for a hierarchical sheet
*/
bool IsMovableFromAnchorPoint() { return false; }
wxString GetName() const { return m_name; } wxString GetName() const { return m_name; }
...@@ -392,11 +406,8 @@ public: ...@@ -392,11 +406,8 @@ public:
int GetPenSize() const; int GetPenSize() const;
void Draw( EDA_DRAW_PANEL* aPanel, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
EDA_RECT const GetBoundingBox() const; EDA_RECT const GetBoundingBox() const;
...@@ -549,7 +560,7 @@ public: ...@@ -549,7 +560,7 @@ public:
wxPoint GetPosition() const { return m_pos; } wxPoint GetPosition() const { return m_pos; }
void SetPosition( const wxPoint& aPosition ) { m_pos = aPosition; } void SetPosition( const wxPoint& aPosition );
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const; bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;
......
...@@ -324,6 +324,12 @@ public: ...@@ -324,6 +324,12 @@ public:
*/ */
int GetCount() const { return m_count; } int GetCount() const { return m_count; }
/**
* Function GetIndex
* @return the last selected screen index.
*/
int GetIndex() const { return m_index; }
/** /**
* Function GetFirst * Function GetFirst
* @return the first item (sheet) in m_List and prepare calls to GetNext() * @return the first item (sheet) in m_List and prepare calls to GetNext()
......
/* /*
* 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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -131,11 +131,8 @@ public: ...@@ -131,11 +131,8 @@ public:
*/ */
virtual wxPoint GetSchematicTextOffset() const; virtual wxPoint GetSchematicTextOffset() const;
virtual void Draw( EDA_DRAW_PANEL* panel, virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
/** /**
* Function CreateGraphicShape * Function CreateGraphicShape
...@@ -230,11 +227,8 @@ public: ...@@ -230,11 +227,8 @@ public:
~SCH_LABEL() { } ~SCH_LABEL() { }
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
wxString GetClass() const wxString GetClass() const
{ {
...@@ -279,11 +273,8 @@ public: ...@@ -279,11 +273,8 @@ public:
~SCH_GLOBALLABEL() { } ~SCH_GLOBALLABEL() { }
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
wxString GetClass() const wxString GetClass() const
{ {
...@@ -332,11 +323,8 @@ public: ...@@ -332,11 +323,8 @@ public:
~SCH_HIERLABEL() { } ~SCH_HIERLABEL() { }
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
wxString GetClass() const wxString GetClass() const
{ {
......
...@@ -443,21 +443,26 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) ...@@ -443,21 +443,26 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
case SCH_FIELD_T: case SCH_FIELD_T:
MoveItem( item, &dc ); case SCH_SHEET_T:
PrepareMoveItem( item, &dc );
break; break;
case SCH_BITMAP_T: case SCH_BITMAP_T:
// move an image is a special case:
// we cannot undraw/redraw a bitmap just using our xor mode
// the MoveImage function handle this undraw/redraw difficulty
// By redrawing the full bounding box
MoveImage( (SCH_BITMAP*) item, &dc ); MoveImage( (SCH_BITMAP*) item, &dc );
break; break;
case SCH_SHEET_T:
StartMoveSheet( (SCH_SHEET*) item, &dc );
break;
case SCH_MARKER_T: case SCH_MARKER_T:
default: // Moving a marker has no sense
wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ),
GetChars( item->GetClass() ) ) ); GetChars( item->GetClass() ) ) );
default:
// Unknown items cannot be moved
wxFAIL_MSG( wxString::Format(
wxT( "Cannot move unknown item type %d" ), item->Type() ) );
break; break;
} }
...@@ -640,25 +645,44 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) ...@@ -640,25 +645,44 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC )
return false; return false;
} }
// This function is a callback function, called by the mouse cursor movin event
static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) // when an item is currently moved
static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{ {
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) ); wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
SCH_COMPONENT* cmp = NULL;
if( item->Type() == SCH_COMPONENT_T )
cmp = static_cast< SCH_COMPONENT* >( item );
#ifndef USE_WX_OVERLAY #ifndef USE_WX_OVERLAY
// Erase the current item at its current position. // Erase the current item at its current position.
if( aErase ) if( aErase )
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); {
if( cmp ) // Use fast mode (do not draw pin texts)
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
else
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}
#endif #endif
item->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
cpos -= item->GetStoredPos();
item->SetPosition( cpos );
// Draw the item item at it's new position. // Draw the item item at it's new position.
item->SetWireImage(); // While moving, the item may choose to render differently item->SetWireImage(); // While moving, the item may choose to render differently
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
if( cmp ) // Use fast mode (do not draw pin texts)
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
else
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
} }
...@@ -714,7 +738,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -714,7 +738,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
} }
void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
{ {
wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) ); wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
...@@ -729,22 +753,27 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) ...@@ -729,22 +753,27 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC )
} }
aItem->SetFlags( IS_MOVED ); aItem->SetFlags( IS_MOVED );
#ifdef USE_WX_OVERLAY
this->Refresh();
this->Update();
#endif
m_canvas->CrossHairOff( aDC );
if( aItem->Type() != SCH_SHEET_PIN_T ) // For some items, moving the cursor to anchor is not good
// (for instance large hierarchical sheets od componants can have
// the anchor position outside the canvas)
// these items return IsMovableFromAnchorPoint() == false
// For these items, do not wrap the cursor
if( aItem->IsMovableFromAnchorPoint() )
{
SetCrossHairPosition( aItem->GetPosition() ); SetCrossHairPosition( aItem->GetPosition() );
m_canvas->MoveCursorToCrossHair();
aItem->SetStoredPos( wxPoint( 0,0 ) );
}
else
aItem->SetStoredPos( GetCrossHairPosition() - aItem->GetPosition() );
m_canvas->MoveCursorToCrossHair();
OnModify(); OnModify();
m_canvas->SetMouseCapture( moveItem, abortMoveItem ); m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );
GetScreen()->SetCurItem( aItem ); GetScreen()->SetCurItem( aItem );
moveItem( m_canvas, aDC, wxDefaultPosition, true );
m_canvas->CrossHairOn( aDC ); m_canvas->Refresh();
} }
......
...@@ -203,7 +203,8 @@ protected: ...@@ -203,7 +203,8 @@ protected:
void updateFindReplaceView( wxFindDialogEvent& aEvent ); void updateFindReplaceView( wxFindDialogEvent& aEvent );
void backAnnotateFootprints( const std::string& aChangedSetOfReferences ) throw( IO_ERROR ); void backAnnotateFootprints( const std::string& aChangedSetOfReferences )
throw( IO_ERROR, boost::bad_pointer );
public: public:
SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
...@@ -845,13 +846,13 @@ private: ...@@ -845,13 +846,13 @@ private:
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false ); SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false );
/** /**
* Function MoveItem * Function PrepareMoveItem
* start moving \a aItem using the mouse. * start moving \a aItem using the mouse.
* *
* @param aItem A pointer to an SCH_ITEM to move. * @param aItem A pointer to an SCH_ITEM to move.
* @param aDC The device context to draw \a aItem. * @param aDC The device context to draw \a aItem.
*/ */
void MoveItem( SCH_ITEM* aItem, wxDC* aDC ); void PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC );
// Text, label, glabel // Text, label, glabel
SCH_TEXT* CreateNewText( wxDC* aDC, int aType ); SCH_TEXT* CreateNewText( wxDC* aDC, int aType );
...@@ -946,8 +947,6 @@ public: ...@@ -946,8 +947,6 @@ public:
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; } wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
private: private:
void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC );
/** /**
* Function CreateSheetPin * Function CreateSheetPin
* creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position. * creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position.
......
...@@ -251,9 +251,11 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -251,9 +251,11 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
/* Move selected sheet with the cursor. /* Move selected sheet with the cursor.
* Callback function use by m_mouseCaptureCallback. * Callback function used by m_mouseCaptureCallback.
* Note also now this function is aclled only when resizing the sheet
* But the (very small code) relative to sheet move is still present here
*/ */
static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
wxPoint moveVector; wxPoint moveVector;
...@@ -265,37 +267,29 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -265,37 +267,29 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
wxPoint pos = sheet->GetPosition(); wxPoint pos = sheet->GetPosition();
if( sheet->IsResized() ) int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x;
{ int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y;
int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x;
int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y;
// If the sheet doesn't have any pins, clamp the minimum size to the default values. // If the sheet doesn't have any pins, clamp the minimum size to the default values.
width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width; width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height; height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height;
if( sheet->HasPins() ) if( sheet->HasPins() )
{
int gridSizeX = KiROUND( screen->GetGridSize().x );
int gridSizeY = KiROUND( screen->GetGridSize().y );
// If the sheet has pins, use the pin positions to clamp the minimum height.
height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
sheet->GetMinHeight() + gridSizeY : height;
width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
sheet->GetMinWidth() + gridSizeX : width;
}
wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
wxPoint( pos.x + width, pos.y + height ) );
sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
}
else if( sheet->IsMoving() )
{ {
moveVector = aPanel->GetParent()->GetCrossHairPosition() - pos; int gridSizeX = KiROUND( screen->GetGridSize().x );
sheet->Move( moveVector ); int gridSizeY = KiROUND( screen->GetGridSize().y );
// If the sheet has pins, use the pin positions to clamp the minimum height.
height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
sheet->GetMinHeight() + gridSizeY : height;
width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
sheet->GetMinWidth() + gridSizeX : width;
} }
wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
wxPoint( pos.x + width, pos.y + height ) );
sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
} }
...@@ -360,7 +354,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) ...@@ -360,7 +354,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
// also need to update the hierarchy, if we are adding // also need to update the hierarchy, if we are adding
// a sheet to a screen that already has multiple instances (!) // a sheet to a screen that already has multiple instances (!)
GetScreen()->SetCurItem( sheet ); GetScreen()->SetCurItem( sheet );
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->CrossHairOff( aDC ); m_canvas->CrossHairOff( aDC );
...@@ -390,28 +384,10 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -390,28 +384,10 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
SetUndoItem( aSheet ); SetUndoItem( aSheet );
aSheet->SetFlags( IS_RESIZED ); aSheet->SetFlags( IS_RESIZED );
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
SetUndoItem( aSheet ); SetUndoItem( aSheet );
} }
void SCH_EDIT_FRAME::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
{
if( ( aSheet == NULL ) || ( aSheet->Type() != SCH_SHEET_T ) )
return;
m_canvas->CrossHairOff( aDC );
SetCrossHairPosition( aSheet->GetPosition() );
m_canvas->MoveCursorToCrossHair();
if( !aSheet->IsNew() )
SetUndoItem( aSheet );
aSheet->SetFlags( IS_MOVED );
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
m_canvas->CrossHairOn( aDC );
}
...@@ -128,7 +128,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -128,7 +128,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->SetPosition( GetCrossHairPosition() );
sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( (SCH_ITEM*) sheetPin, aDC ); PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC );
OnModify(); OnModify();
return sheetPin; return sheetPin;
...@@ -174,7 +174,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -174,7 +174,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->SetPosition( GetCrossHairPosition() );
sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( (SCH_ITEM*) sheetPin, aDC ); PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC );
return sheetPin; return sheetPin;
} }
...@@ -208,8 +208,6 @@ void LIB_VIEW_FRAME::SelectAndViewLibraryPart( int option ) ...@@ -208,8 +208,6 @@ void LIB_VIEW_FRAME::SelectAndViewLibraryPart( int option )
void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag ) void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag )
{ {
int NumOfParts = 0; int NumOfParts = 0;
LIB_ALIAS* entry;
wxString CmpName;
if( Lib ) if( Lib )
NumOfParts = Lib->GetCount(); NumOfParts = Lib->GetCount();
...@@ -220,8 +218,8 @@ void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag ) ...@@ -220,8 +218,8 @@ void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag )
return; return;
} }
if( Lib == NULL ) LIB_ALIAS* entry;
return; wxString CmpName;
if( Flag == NEW_PART ) if( Flag == NEW_PART )
DisplayListComponentsInLib( Lib, CmpName, m_entryName ); DisplayListComponentsInLib( Lib, CmpName, m_entryName );
......
...@@ -200,11 +200,16 @@ void GERBER_IMAGE::ResetDefaultValues() ...@@ -200,11 +200,16 @@ void GERBER_IMAGE::ResetDefaultValues()
m_PreviousPos.x = m_PreviousPos.y = 0; // last specified coord m_PreviousPos.x = m_PreviousPos.y = 0; // last specified coord
m_IJPos.x = m_IJPos.y = 0; // current centre coord for m_IJPos.x = m_IJPos.y = 0; // current centre coord for
// plot arcs & circles // plot arcs & circles
m_Current_File = NULL; // Gerger file to read m_Current_File = NULL; // Gerber file to read
m_FilesPtr = 0; m_FilesPtr = 0;
m_PolygonFillMode = false; m_PolygonFillMode = false;
m_PolygonFillModeState = 0; m_PolygonFillModeState = 0;
m_Selected_Tool = FIRST_DCODE; m_Selected_Tool = FIRST_DCODE;
m_Last_Pen_Command = 0;
m_Exposure = false;
for( unsigned ii = 0; ii < DIM( m_FilesList ); ii++ )
m_FilesList[ii] = NULL;
} }
/* Function HasNegativeItems /* Function HasNegativeItems
...@@ -455,7 +460,7 @@ const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx ) ...@@ -455,7 +460,7 @@ const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx )
if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() ) if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() )
gerber = m_GERBER_List[aIdx]; gerber = m_GERBER_List[aIdx];
if( IsUsed(aIdx ) ) if( gerber && IsUsed(aIdx ) )
{ {
if( gerber->m_FileFunction ) if( gerber->m_FileFunction )
name.Printf( _( "Layer %d (%s, %s)" ), aIdx + 1, name.Printf( _( "Layer %d (%s, %s)" ), aIdx + 1,
......
...@@ -225,10 +225,9 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) ...@@ -225,10 +225,9 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_FineAdjustYscaleOpt->SetValue( msg ); m_FineAdjustYscaleOpt->SetValue( msg );
bool enable = (s_Parameters.m_PrintScale == 1.0); bool enable = (s_Parameters.m_PrintScale == 1.0);
if( m_FineAdjustXscaleOpt )
m_FineAdjustXscaleOpt->Enable(enable); m_FineAdjustXscaleOpt->Enable(enable);
if( m_FineAdjustYscaleOpt ) m_FineAdjustYscaleOpt->Enable(enable);
m_FineAdjustYscaleOpt->Enable(enable);
} }
int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection() int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection()
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* 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) 2013 Jean-Pierre Charras, jpierre.charras at wanadoo * Copyright (C) 2013 Jean-Pierre Charras, jpierre.charras at wanadoo
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void* aData ) bool aPrintMirrorMode, void* aData )
{ {
wxCHECK_RET( aData != NULL, wxT( "aDate cannot be NULL." ) );
// Save current draw options, because print mode has specific options: // Save current draw options, because print mode has specific options:
GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions; GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions;
std::bitset <GERBER_DRAWLAYERS_COUNT> printLayersMask = GetGerberLayout()->GetPrintableLayers(); std::bitset <GERBER_DRAWLAYERS_COUNT> printLayersMask = GetGerberLayout()->GetPrintableLayers();
...@@ -63,7 +65,7 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, ...@@ -63,7 +65,7 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
printCurrLayerMask.set(printParameters->m_Flags); // m_Flags contains the draw layer number printCurrLayerMask.set(printParameters->m_Flags); // m_Flags contains the draw layer number
GetGerberLayout()->SetPrintableLayers( printCurrLayerMask ); GetGerberLayout()->SetPrintableLayers( printCurrLayerMask );
m_canvas->SetPrintMirrored( aPrintMirrorMode ); m_canvas->SetPrintMirrored( aPrintMirrorMode );
bool printBlackAndWhite = printParameters && printParameters->m_Print_Black_and_White; bool printBlackAndWhite = printParameters->m_Print_Black_and_White;
GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE,
wxPoint( 0, 0 ), printBlackAndWhite ); wxPoint( 0, 0 ), printBlackAndWhite );
......
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
m_DisplayPolarCood = false; m_DisplayPolarCood = false;
m_DisplayDCodes = true; m_DisplayDCodes = true;
m_IsPrinting = false; m_IsPrinting = false;
m_DisplayNegativeObjects = false;
} }
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* 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) 2007-2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2007 Kicad Developers, see change_log.txt for contributors. * Copyright (C) 2007-2015 Kicad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
/* /*
* 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) 2010-12 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2012-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -538,7 +538,8 @@ public: ...@@ -538,7 +538,8 @@ public:
* @throw IO_ERROR if an error occurs attempting to load the footprint library * @throw IO_ERROR if an error occurs attempting to load the footprint library
* table. * table.
*/ */
static bool LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR ); static bool LoadGlobalTable( FP_LIB_TABLE& aTable )
throw (IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
/** /**
* Function GetGlobalTableFileName * Function GetGlobalTableFileName
...@@ -581,7 +582,8 @@ public: ...@@ -581,7 +582,8 @@ public:
* writes this table to aFileName in s-expression form. * writes this table to aFileName in s-expression form.
* @param aFileName is the name of the file to write to. * @param aFileName is the name of the file to write to.
*/ */
void Save( const wxString& aFileName ) const throw( IO_ERROR ); void Save( const wxString& aFileName ) const
throw( IO_ERROR, boost::interprocess::lock_exception );
protected: protected:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011-2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011-2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -69,11 +69,19 @@ public: ...@@ -69,11 +69,19 @@ public:
m_Color( aColor ), m_Color( aColor ),
m_Pad( aPad ) m_Pad( aPad )
{ {
m_X = 0;
m_UpperY = 0;
m_LowerY = 0;
} }
MSG_PANEL_ITEM() : MSG_PANEL_ITEM() :
m_Pad( MSG_PANEL_DEFAULT_PAD ) m_Pad( MSG_PANEL_DEFAULT_PAD )
{ {
m_X = 0;
m_UpperY = 0;
m_LowerY = 0;
m_Color = UNSPECIFIED_COLOR;
} }
void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; } void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; }
......
...@@ -30,26 +30,6 @@ ...@@ -30,26 +30,6 @@
class PGM_BASE; class PGM_BASE;
/**
* attempts to set (when not set or valid) the environment variable given by aKiSys3Dmod
* (typically "KISYS3DMOD" ) to a valid path.
* If the environment variable is already set, then it left as is to respect
* the wishes of the user.
*
* The path is determined by attempting to find the path modules/packages3d
* files in kicad tree.
* This may or may not be the best path but it provides the best solution for
* backwards compatibility with the previous 3D shapes search path implementation.
*
* @note This must be called after #SetBinDir() is called at least on Windows.
* Otherwise, the kicad path is not known (Windows specific)
*
* @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD"
* @param aProcess = the current process
* @return false if the aKiSys3Dmod path is not valid.
*/
bool Set3DShapesDefaultPath( const wxString& aKiSys3Dmod, const PGM_BASE* aProcess );
/// Utility for comma separated lists /// Utility for comma separated lists
inline void AccumulateDescription( wxString &aDesc, const wxString &aItem ) inline void AccumulateDescription( wxString &aDesc, const wxString &aItem )
......
/* /*
* 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) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -671,6 +671,8 @@ class PDF_PLOTTER : public PSLIKE_PLOTTER ...@@ -671,6 +671,8 @@ class PDF_PLOTTER : public PSLIKE_PLOTTER
public: public:
PDF_PLOTTER() : pageStreamHandle( 0 ), workFile( NULL ) PDF_PLOTTER() : pageStreamHandle( 0 ), workFile( NULL )
{ {
// Avoid non initialized variables:
pageStreamHandle = streamLengthHandle = fontResDictHandle = 0;
} }
virtual PlotFormat GetPlotterType() const virtual PlotFormat GetPlotterType() const
...@@ -986,6 +988,8 @@ class DXF_PLOTTER : public PLOTTER ...@@ -986,6 +988,8 @@ class DXF_PLOTTER : public PLOTTER
public: public:
DXF_PLOTTER() : textAsLines( false ) DXF_PLOTTER() : textAsLines( false )
{ {
textAsLines = true;
m_currentColor = BLACK;
} }
virtual PlotFormat GetPlotterType() const virtual PlotFormat GetPlotterType() const
......
...@@ -30,9 +30,5 @@ ...@@ -30,9 +30,5 @@
<key>LSRequiresCarbon</key> <true/> <key>LSRequiresCarbon</key> <true/>
<key>NSHumanReadableCopyright</key> <string></string> <key>NSHumanReadableCopyright</key> <string></string>
<key>NSHighResolutionCapable</key> <string>True</string> <key>NSHighResolutionCapable</key> <string>True</string>
<key>LSEnvironment</key>
<dict>
<key>KIGITHUB</key> <string>https://github.com/kicad</string>
</dict>
</dict> </dict>
</plist> </plist>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 CERN (www.cern.ch) * Copyright (C) 2013 CERN (www.cern.ch)
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -79,13 +79,13 @@ static const wxChar* s_allowedExtensionsToList[] = ...@@ -79,13 +79,13 @@ static const wxChar* s_allowedExtensionsToList[] =
wxT( "^.*\\.odt$" ), wxT( "^.*\\.odt$" ),
wxT( "^.*\\.htm$" ), wxT( "^.*\\.htm$" ),
wxT( "^.*\\.html$" ), wxT( "^.*\\.html$" ),
wxT( "^.*\\.rpt$" ), // Report files wxT( "^.*\\.rpt$" ), // Report files
wxT( "^.*\\.csv$" ), // Report files in comma separateed format wxT( "^.*\\.csv$" ), // Report files in comma separated format
wxT( "^.*\\.pos$" ), // Footprint position files wxT( "^.*\\.pos$" ), // Footprint position files
wxT( "^.*\\.cmp$" ), // Cvpcb cmp/footprint link files wxT( "^.*\\.cmp$" ), // Cvpcb cmp/footprint link files
wxT( "^.*\\.drl$" ), // Excellon drill files wxT( "^.*\\.drl$" ), // Excellon drill files
wxT( "^.*\\.svg$" ), // SVG print/plot files wxT( "^.*\\.svg$" ), // SVG print/plot files
NULL // end of list NULL // end of list
}; };
...@@ -110,13 +110,13 @@ const wxChar TextFileWildcard[] = wxT( "Text files (*.txt)|*.txt" ); ...@@ -110,13 +110,13 @@ const wxChar TextFileWildcard[] = wxT( "Text files (*.txt)|*.txt" );
BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow ) BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow )
EVT_TREE_ITEM_ACTIVATED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnSelect ) EVT_TREE_ITEM_ACTIVATED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnSelect )
EVT_TREE_ITEM_EXPANDED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnExpand ) EVT_TREE_ITEM_EXPANDED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnExpand )
EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRight ) EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRight )
EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor ) EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor )
EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory ) EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory )
EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile ) EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile ) EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -125,7 +125,7 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) : ...@@ -125,7 +125,7 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) :
ID_LEFT_FRAME, ID_LEFT_FRAME,
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
wxNO_BORDER | wxSW_3D ) wxNO_BORDER | wxSW_3D | wxTAB_TRAVERSAL )
{ {
m_Parent = parent; m_Parent = parent;
m_TreeProject = NULL; m_TreeProject = NULL;
...@@ -752,7 +752,7 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& ) ...@@ -752,7 +752,7 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer ); wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user return; // canceled by user
buffer = dlg.GetValue(); buffer = dlg.GetValue();
buffer.Trim( true ); buffer.Trim( true );
...@@ -793,6 +793,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event ) ...@@ -793,6 +793,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
wxTreeItemId kid = m_TreeProject->GetFirstChild( itemId, cookie ); wxTreeItemId kid = m_TreeProject->GetFirstChild( itemId, cookie );
bool subdir_populated = false; bool subdir_populated = false;
for( ; kid.IsOk(); kid = m_TreeProject->GetNextChild( itemId, cookie ) ) for( ; kid.IsOk(); kid = m_TreeProject->GetNextChild( itemId, cookie ) )
{ {
TREEPROJECT_ITEM* itemData = GetItemIdData( kid ); TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
...@@ -866,6 +867,7 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir ) ...@@ -866,6 +867,7 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
std::stack < wxTreeItemId > subdirs_id; std::stack < wxTreeItemId > subdirs_id;
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie ); wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
while( 1 ) while( 1 )
{ {
if( ! kid.IsOk() ) if( ! kid.IsOk() )
...@@ -1018,6 +1020,7 @@ void TREE_PROJECT_FRAME::FileWatcherReset() ...@@ -1018,6 +1020,7 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
std::stack < wxTreeItemId > subdirs_id; std::stack < wxTreeItemId > subdirs_id;
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie ); wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
while( 1 ) while( 1 )
{ {
if( !kid.IsOk() ) if( !kid.IsOk() )
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#ifndef DRW_BASE_H #ifndef DRW_BASE_H
#define DRW_BASE_H #define DRW_BASE_H
#define DRW_VERSION "0.5.11" #define DRW_VERSION "0.5.13"
#include <string> #include <string>
#include <cmath> #include <cmath>
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
namespace DRW { namespace DRW {
// ! Version numbers for the DXF Format. // ! Version numbers for the DXF Format.
enum Version { enum Version
{
UNKNOWNV, /*!< UNKNOWN VERSION. */ UNKNOWNV, /*!< UNKNOWN VERSION. */
AC1006, /*!< R10. */ AC1006, /*!< R10. */
AC1009, /*!< R11 & R12. */ AC1009, /*!< R11 & R12. */
...@@ -54,7 +55,8 @@ enum Version { ...@@ -54,7 +55,8 @@ enum Version {
AC1024 /*!< ACAD 2010. */ AC1024 /*!< ACAD 2010. */
}; };
enum error { enum error
{
BAD_NONE, /*!< No error. */ BAD_NONE, /*!< No error. */
BAD_UNKNOWN, /*!< UNKNOWN. */ BAD_UNKNOWN, /*!< UNKNOWN. */
BAD_OPEN, /*!< error opening file. */ BAD_OPEN, /*!< error opening file. */
...@@ -76,7 +78,7 @@ enum error { ...@@ -76,7 +78,7 @@ enum error {
class DRW_Coord class DRW_Coord
{ {
public: public:
DRW_Coord() { x = 0; y = 0; z = 0; } DRW_Coord(): x(0), y(0), z(0) {}
DRW_Coord( double ix, double iy, double iz ) DRW_Coord( double ix, double iy, double iz )
{ {
x = ix; y = iy; z = iz; x = ix; y = iy; z = iz;
...@@ -121,15 +123,15 @@ public: ...@@ -121,15 +123,15 @@ public:
DRW_Vertex2D() DRW_Vertex2D()
{ {
// eType = DRW::LWPOLYLINE; // eType = DRW::LWPOLYLINE;
stawidth = endwidth = bulge = 0; x = y = stawidth = endwidth = bulge = 0.0;
} }
DRW_Vertex2D( double sx, double sy, double b ) DRW_Vertex2D( double sx, double sy, double b )
{ {
stawidth = endwidth = 0; stawidth = endwidth = 0;
x = sx; x = sx;
y = sy; y = sy;
bulge = b; bulge = b;
} }
public: public:
...@@ -149,7 +151,8 @@ public: ...@@ -149,7 +151,8 @@ public:
class DRW_Variant class DRW_Variant
{ {
public: public:
enum TYPE { enum TYPE
{
STRING, STRING,
INTEGER, INTEGER,
DOUBLE, DOUBLE,
...@@ -160,48 +163,66 @@ public: ...@@ -160,48 +163,66 @@ public:
DRW_Variant() DRW_Variant()
{ {
type = INVALID; type = INVALID;
code = 0;
} }
~DRW_Variant() DRW_Variant( const DRW_Variant& d )
{ {
if( type == COORD ) code = d.code;
delete content.v; type = d.type;
if( d.type == COORD ) vdata = d.vdata;
if( d.type == STRING ) sdata = d.sdata;
content = d.content;
} }
enum TYPE type; DRW_Variant( int c, UTF8STRING s ) { addString( s ); code = c; }
DRW_Variant( int c, int i ) { addInt( i ); code = c; }
DRW_Variant( int c, double d ) { addDouble( d ); code = c; }
DRW_Variant( int c, double x, double y, double z )
{
setType( COORD ); vdata.x = x; vdata.y = y;
vdata.z = z; content.v = &vdata; code = c;
}
void addString( UTF8STRING s ) { setType( STRING ); data = s; content.s = &data; } ~DRW_Variant()
{
}
void addString( UTF8STRING s ) { setType( STRING ); sdata = s; content.s = &sdata; }
void addInt( int i ) { setType( INTEGER ); content.i = i; } void addInt( int i ) { setType( INTEGER ); content.i = i; }
void addDouble( double d ) { setType( DOUBLE ); content.d = d; } void addDouble( double d ) { setType( DOUBLE ); content.d = d; }
void addCoord( DRW_Coord* v ) { setType( COORD ); content.v = v; } void addCoord()
void setType( enum TYPE t )
{ {
if( type == COORD ) setType( COORD ); vdata.x = 0.0; vdata.y = 0.0; vdata.z = 0.0; content.v =
delete content.v; &vdata;
type = t;
} }
void setCoordX( double d ) { if( type == COORD ) content.v->x = d; } void addCoord( DRW_Coord v ) { setType( COORD ); vdata = v; content.v = &vdata; }
void setCoordY( double d ) { if( type == COORD ) content.v->y = d; } void setType( enum TYPE t ) { type = t; }
void setCoordZ( double d ) { if( type == COORD ) content.v->z = d; } void setCoordX( double d ) { if( type == COORD ) vdata.x = d; }
void setCoordY( double d ) { if( type == COORD ) vdata.y = d; }
void setCoordZ( double d ) { if( type == COORD ) vdata.z = d; }
private: private:
typedef union typedef union
{ {
UTF8STRING* s; UTF8STRING* s;
int i; int i;
double d; double d;
DRW_Coord* v; DRW_Coord* v;
} DRW_VarContent; } DRW_VarContent;
public: public:
DRW_VarContent content; DRW_VarContent content;
public: enum TYPE type;
int code; int code; /*!< dxf code of this value*/
// string version;
// string codepage;
private: private:
// DRW_VarContent content; std::string sdata;
std::string data; DRW_Coord vdata;
}; };
...@@ -215,7 +236,8 @@ private: ...@@ -215,7 +236,8 @@ private:
class DRW_LW_Conv class DRW_LW_Conv
{ {
public: public:
enum lineWidth { enum lineWidth
{
width00 = 0, /*!< 0.00mm (dxf 0)*/ width00 = 0, /*!< 0.00mm (dxf 0)*/
width01 = 1, /*!< 0.05mm (dxf 5)*/ width01 = 1, /*!< 0.05mm (dxf 5)*/
width02 = 2, /*!< 0.09mm (dxf 9)*/ width02 = 2, /*!< 0.09mm (dxf 9)*/
......
...@@ -22,23 +22,33 @@ ...@@ -22,23 +22,33 @@
*/ */
void DRW_Entity::calculateAxis( DRW_Coord extPoint ) void DRW_Entity::calculateAxis( DRW_Coord extPoint )
{ {
// Follow the arbitrary DXF definitions for extrusion axes.
if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 ) if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 )
{ {
// If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
// The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
// Factoring in the fixed values for Wy gives N.z,0,-N.x
extAxisX.x = extPoint.z; extAxisX.x = extPoint.z;
extAxisX.y = 0; extAxisX.y = 0;
extAxisX.z = -extPoint.x; extAxisX.z = -extPoint.x;
} }
else else
{ {
// Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
// The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
// Factoring in the fixed values for Wz gives -N.y,N.x,0.
extAxisX.x = -extPoint.y; extAxisX.x = -extPoint.y;
extAxisX.y = extPoint.x; extAxisX.y = extPoint.x;
extAxisX.z = 0; extAxisX.z = 0;
} }
extAxisX.unitize(); extAxisX.unitize();
// Ay = N x Ax
extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z); extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x); extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y); extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
extAxisY.unitize(); extAxisY.unitize();
} }
...@@ -110,6 +120,58 @@ void DRW_Entity::parseCode( int code, dxfReader* reader ) ...@@ -110,6 +120,58 @@ void DRW_Entity::parseCode( int code, dxfReader* reader )
space = reader->getInt32(); space = reader->getInt32();
break; break;
case 1000:
case 1001:
case 1002:
case 1003:
case 1004:
case 1005:
extData.push_back( new DRW_Variant( code, reader->getString() ) );
break;
case 1010:
case 1011:
case 1012:
case 1013:
curr = new DRW_Variant();
curr->addCoord();
curr->setCoordX( reader->getDouble() );
curr->code = code;
extData.push_back( curr );
break;
case 1020:
case 1021:
case 1022:
case 1023:
if( curr )
curr->setCoordY( reader->getDouble() );
break;
case 1030:
case 1031:
case 1032:
case 1033:
if( curr )
curr->setCoordZ( reader->getDouble() );
curr = NULL;
break;
case 1040:
case 1041:
case 1042:
extData.push_back( new DRW_Variant( code, reader->getDouble() ) );
break;
case 1070:
case 1071:
extData.push_back( new DRW_Variant( code, reader->getInt32() ) );
break;
default: default:
break; break;
} }
...@@ -137,8 +199,8 @@ void DRW_Point::parseCode( int code, dxfReader* reader ) ...@@ -137,8 +199,8 @@ void DRW_Point::parseCode( int code, dxfReader* reader )
break; break;
case 210: case 210:
haveExtrusion = true; haveExtrusion = true;
extPoint.x = reader->getDouble(); extPoint.x = reader->getDouble();
break; break;
case 220: case 220:
...@@ -183,6 +245,8 @@ void DRW_Circle::applyExtrusion() ...@@ -183,6 +245,8 @@ void DRW_Circle::applyExtrusion()
{ {
if( haveExtrusion ) if( haveExtrusion )
{ {
// NOTE: Commenting these out causes the the arcs being tested to be located
// on the other side of the y axis (all x dimensions are negated).
calculateAxis( extPoint ); calculateAxis( extPoint );
extrudePoint( extPoint, &basePoint ); extrudePoint( extPoint, &basePoint );
} }
...@@ -204,6 +268,30 @@ void DRW_Circle::parseCode( int code, dxfReader* reader ) ...@@ -204,6 +268,30 @@ void DRW_Circle::parseCode( int code, dxfReader* reader )
} }
void DRW_Arc::applyExtrusion()
{
DRW_Circle::applyExtrusion();
if( haveExtrusion )
{
// If the extrusion vector has a z value less than 0, the angles for the arc
// have to be mirrored since DXF files use the right hand rule.
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 )
{
staangle = M_PI - staangle;
endangle = M_PI - endangle;
double temp = staangle;
staangle = endangle;
endangle = temp;
}
}
}
void DRW_Arc::parseCode( int code, dxfReader* reader ) void DRW_Arc::parseCode( int code, dxfReader* reader )
{ {
switch( code ) switch( code )
...@@ -309,9 +397,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts ) ...@@ -309,9 +397,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts )
radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y ); radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y );
radMinor = radMajor * ratio; radMinor = radMajor * ratio;
// calculate sin & cos of included angle // calculate sin & cos of included angle
incAngle = atan2( secPoint.y, secPoint.x ); incAngle = atan2( secPoint.y, secPoint.x );
cosRot = cos( incAngle ); cosRot = cos( incAngle );
sinRot = sin( incAngle ); sinRot = sin( incAngle );
incAngle = M_PIx2 / parts; incAngle = M_PIx2 / parts;
curAngle = staparam; curAngle = staparam;
int i = curAngle / incAngle; int i = curAngle / incAngle;
...@@ -336,9 +424,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts ) ...@@ -336,9 +424,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts )
pol->flags = 1; pol->flags = 1;
} }
pol->layer = this->layer; pol->layer = this->layer;
pol->lineType = this->lineType; pol->lineType = this->lineType;
pol->color = this->color; pol->color = this->color;
pol->lWeight = this->lWeight; pol->lWeight = this->lWeight;
pol->extPoint = this->extPoint; pol->extPoint = this->extPoint;
} }
...@@ -487,8 +575,8 @@ void DRW_LWPolyline::applyExtrusion() ...@@ -487,8 +575,8 @@ void DRW_LWPolyline::applyExtrusion()
for( unsigned int i = 0; i<vertlist.size(); i++ ) for( unsigned int i = 0; i<vertlist.size(); i++ )
{ {
DRW_Vertex2D* vert = vertlist.at( i ); DRW_Vertex2D* vert = vertlist.at( i );
DRW_Coord v( vert->x, vert->y, elevation ); DRW_Coord v( vert->x, vert->y, elevation );
extrudePoint( extPoint, &v ); extrudePoint( extPoint, &v );
vert->x = v.x; vert->x = v.x;
vert->y = v.y; vert->y = v.y;
...@@ -502,12 +590,12 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader ) ...@@ -502,12 +590,12 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader )
switch( code ) switch( code )
{ {
case 10: case 10:
{ {
vertex = new DRW_Vertex2D(); vertex = new DRW_Vertex2D();
vertlist.push_back( vertex ); vertlist.push_back( vertex );
vertex->x = reader->getDouble(); vertex->x = reader->getDouble();
break; break;
} }
case 20: case 20:
...@@ -559,8 +647,8 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader ) ...@@ -559,8 +647,8 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader )
break; break;
case 210: case 210:
haveExtrusion = true; haveExtrusion = true;
extPoint.x = reader->getDouble(); extPoint.x = reader->getDouble();
break; break;
case 220: case 220:
...@@ -779,19 +867,19 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader ) ...@@ -779,19 +867,19 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader )
{ {
break; break;
} }
else if( reader->getInt32() == 1 ) // line else if( reader->getInt32() == 1 ) // line
{ {
addLine(); addLine();
} }
else if( reader->getInt32() == 2 ) // arc else if( reader->getInt32() == 2 ) // arc
{ {
addArc(); addArc();
} }
else if( reader->getInt32() == 3 ) // elliptic arc else if( reader->getInt32() == 3 ) // elliptic arc
{ {
addEllipse(); addEllipse();
} }
else if( reader->getInt32() == 4 ) // spline else if( reader->getInt32() == 4 ) // spline
{ {
addSpline(); addSpline();
} }
...@@ -804,8 +892,8 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader ) ...@@ -804,8 +892,8 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader )
pt->basePoint.x = reader->getDouble(); pt->basePoint.x = reader->getDouble();
else if( pline ) else if( pline )
{ {
plvert = pline->addVertex(); plvert = pline->addVertex();
plvert->x = reader->getDouble(); plvert->x = reader->getDouble();
} }
break; break;
...@@ -1018,12 +1106,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader ) ...@@ -1018,12 +1106,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader )
break; break;
case 10: case 10:
{ {
controlpoint = new DRW_Coord(); controlpoint = new DRW_Coord();
controllist.push_back( controlpoint ); controllist.push_back( controlpoint );
controlpoint->x = reader->getDouble(); controlpoint->x = reader->getDouble();
break; break;
} }
case 20: case 20:
...@@ -1040,12 +1128,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader ) ...@@ -1040,12 +1128,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader )
break; break;
case 11: case 11:
{ {
fitpoint = new DRW_Coord(); fitpoint = new DRW_Coord();
fitlist.push_back( fitpoint ); fitlist.push_back( fitpoint );
fitpoint->x = reader->getDouble(); fitpoint->x = reader->getDouble();
break; break;
} }
case 21: case 21:
...@@ -1312,12 +1400,12 @@ void DRW_Leader::parseCode( int code, dxfReader* reader ) ...@@ -1312,12 +1400,12 @@ void DRW_Leader::parseCode( int code, dxfReader* reader )
break; break;
case 10: case 10:
{ {
vertexpoint = new DRW_Coord(); vertexpoint = new DRW_Coord();
vertexlist.push_back( vertexpoint ); vertexlist.push_back( vertexpoint );
vertexpoint->x = reader->getDouble(); vertexpoint->x = reader->getDouble();
break; break;
} }
case 20: case 20:
...@@ -1413,10 +1501,10 @@ void DRW_Viewport::parseCode( int code, dxfReader* reader ) ...@@ -1413,10 +1501,10 @@ void DRW_Viewport::parseCode( int code, dxfReader* reader )
break; break;
case 12: case 12:
{ {
centerPX = reader->getDouble(); centerPX = reader->getDouble();
break; break;
} }
case 22: case 22:
centerPY = reader->getDouble(); centerPY = reader->getDouble();
......
This diff is collapsed.
...@@ -40,22 +40,25 @@ public: ...@@ -40,22 +40,25 @@ public:
} }
/** Called when header is parsed. */ /** Called when header is parsed. */
virtual void addHeader( const DRW_Header* data ) = 0; virtual void addHeader( const DRW_Header* data ) = 0;
/** Called for every line Type. */ /** Called for every line Type. */
virtual void addLType( const DRW_LType& data ) = 0; virtual void addLType( const DRW_LType& data ) = 0;
/** Called for every layer. */ /** Called for every layer. */
virtual void addLayer( const DRW_Layer& data ) = 0; virtual void addLayer( const DRW_Layer& data ) = 0;
/** Called for every dim style. */ /** Called for every dim style. */
virtual void addDimStyle( const DRW_Dimstyle& data ) = 0; virtual void addDimStyle( const DRW_Dimstyle& data ) = 0;
/** Called for every VPORT table. */ /** Called for every VPORT table. */
virtual void addVport( const DRW_Vport& data ) = 0; virtual void addVport( const DRW_Vport& data ) = 0;
/** Called for every text style. */ /** Called for every text style. */
virtual void addTextStyle( const DRW_Textstyle& data ) = 0; virtual void addTextStyle( const DRW_Textstyle& data ) = 0;
/** Called for every AppId entry. */
virtual void addAppId( const DRW_AppId& data ) = 0;
/** /**
* Called for every block. Note: all entities added after this * Called for every block. Note: all entities added after this
...@@ -63,7 +66,7 @@ public: ...@@ -63,7 +66,7 @@ public:
* *
* @see endBlock() * @see endBlock()
*/ */
virtual void addBlock( const DRW_Block& data ) = 0; virtual void addBlock( const DRW_Block& data ) = 0;
/** /**
* In DWG called when the following entities corresponding to a * In DWG called when the following entities corresponding to a
...@@ -72,127 +75,127 @@ public: ...@@ -72,127 +75,127 @@ public:
* *
* int handle are the value of DRW_Block::handleBlock added with addBlock() * int handle are the value of DRW_Block::handleBlock added with addBlock()
*/ */
virtual void setBlock( const int handle ) = 0; virtual void setBlock( const int handle ) = 0;
/** Called to end the current block */ /** Called to end the current block */
virtual void endBlock() = 0; virtual void endBlock() = 0;
/** Called for every point */ /** Called for every point */
virtual void addPoint( const DRW_Point& data ) = 0; virtual void addPoint( const DRW_Point& data ) = 0;
/** Called for every line */ /** Called for every line */
virtual void addLine( const DRW_Line& data ) = 0; virtual void addLine( const DRW_Line& data ) = 0;
/** Called for every ray */ /** Called for every ray */
virtual void addRay( const DRW_Ray& data ) = 0; virtual void addRay( const DRW_Ray& data ) = 0;
/** Called for every xline */ /** Called for every xline */
virtual void addXline( const DRW_Xline& data ) = 0; virtual void addXline( const DRW_Xline& data ) = 0;
/** Called for every arc */ /** Called for every arc */
virtual void addArc( const DRW_Arc& data ) = 0; virtual void addArc( const DRW_Arc& data ) = 0;
/** Called for every circle */ /** Called for every circle */
virtual void addCircle( const DRW_Circle& data ) = 0; virtual void addCircle( const DRW_Circle& data ) = 0;
/** Called for every ellipse */ /** Called for every ellipse */
virtual void addEllipse( const DRW_Ellipse& data ) = 0; virtual void addEllipse( const DRW_Ellipse& data ) = 0;
/** Called for every lwpolyline */ /** Called for every lwpolyline */
virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0; virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0;
/** Called for every polyline start */ /** Called for every polyline start */
virtual void addPolyline( const DRW_Polyline& data ) = 0; virtual void addPolyline( const DRW_Polyline& data ) = 0;
/** Called for every spline */ /** Called for every spline */
virtual void addSpline( const DRW_Spline* data ) = 0; virtual void addSpline( const DRW_Spline* data ) = 0;
/** Called for every spline knot value */ /** Called for every spline knot value */
virtual void addKnot( const DRW_Entity& data ) = 0; virtual void addKnot( const DRW_Entity& data ) = 0;
/** Called for every insert. */ /** Called for every insert. */
virtual void addInsert( const DRW_Insert& data ) = 0; virtual void addInsert( const DRW_Insert& data ) = 0;
/** Called for every trace start */ /** Called for every trace start */
virtual void addTrace( const DRW_Trace& data ) = 0; virtual void addTrace( const DRW_Trace& data ) = 0;
/** Called for every 3dface start */ /** Called for every 3dface start */
virtual void add3dFace( const DRW_3Dface& data ) = 0; virtual void add3dFace( const DRW_3Dface& data ) = 0;
/** Called for every solid start */ /** Called for every solid start */
virtual void addSolid( const DRW_Solid& data ) = 0; virtual void addSolid( const DRW_Solid& data ) = 0;
/** Called for every Multi Text entity. */ /** Called for every Multi Text entity. */
virtual void addMText( const DRW_MText& data ) = 0; virtual void addMText( const DRW_MText& data ) = 0;
/** Called for every Text entity. */ /** Called for every Text entity. */
virtual void addText( const DRW_Text& data ) = 0; virtual void addText( const DRW_Text& data ) = 0;
/** /**
* Called for every aligned dimension entity. * Called for every aligned dimension entity.
*/ */
virtual void addDimAlign( const DRW_DimAligned* data ) = 0; virtual void addDimAlign( const DRW_DimAligned* data ) = 0;
/** /**
* Called for every linear or rotated dimension entity. * Called for every linear or rotated dimension entity.
*/ */
virtual void addDimLinear( const DRW_DimLinear* data ) = 0; virtual void addDimLinear( const DRW_DimLinear* data ) = 0;
/** /**
* Called for every radial dimension entity. * Called for every radial dimension entity.
*/ */
virtual void addDimRadial( const DRW_DimRadial* data ) = 0; virtual void addDimRadial( const DRW_DimRadial* data ) = 0;
/** /**
* Called for every diametric dimension entity. * Called for every diametric dimension entity.
*/ */
virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0; virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0;
/** /**
* Called for every angular dimension (2 lines version) entity. * Called for every angular dimension (2 lines version) entity.
*/ */
virtual void addDimAngular( const DRW_DimAngular* data ) = 0; virtual void addDimAngular( const DRW_DimAngular* data ) = 0;
/** /**
* Called for every angular dimension (3 points version) entity. * Called for every angular dimension (3 points version) entity.
*/ */
virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0; virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0;
/** /**
* Called for every ordinate dimension entity. * Called for every ordinate dimension entity.
*/ */
virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0; virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0;
/** /**
* Called for every leader start. * Called for every leader start.
*/ */
virtual void addLeader( const DRW_Leader* data ) = 0; virtual void addLeader( const DRW_Leader* data ) = 0;
/** /**
* Called for every hatch entity. * Called for every hatch entity.
*/ */
virtual void addHatch( const DRW_Hatch* data ) = 0; virtual void addHatch( const DRW_Hatch* data ) = 0;
/** /**
* Called for every viewport entity. * Called for every viewport entity.
*/ */
virtual void addViewport( const DRW_Viewport& data ) = 0; virtual void addViewport( const DRW_Viewport& data ) = 0;
/** /**
* Called for every image entity. * Called for every image entity.
*/ */
virtual void addImage( const DRW_Image* data ) = 0; virtual void addImage( const DRW_Image* data ) = 0;
/** /**
* Called for every image definition. * Called for every image definition.
*/ */
virtual void linkImage( const DRW_ImageDef* data ) = 0; virtual void linkImage( const DRW_ImageDef* data ) = 0;
/** /**
* Called for every comment in the DXF file (code 999). * Called for every comment in the DXF file (code 999).
*/ */
virtual void addComment( const char* comment ) = 0; virtual void addComment( const char* comment ) = 0;
/** Sets the current attributes for entities. */ /** Sets the current attributes for entities. */
/* void setExtrusion(double dx, double dy, double dz, double elevation) { /* void setExtrusion(double dx, double dy, double dz, double elevation) {
...@@ -208,12 +211,13 @@ public: ...@@ -208,12 +211,13 @@ public:
virtual void writeHeader( DRW_Header& data ) = 0; virtual void writeHeader( DRW_Header& data ) = 0;
virtual void writeBlocks() = 0; virtual void writeBlocks() = 0;
virtual void writeBlockRecords() = 0; virtual void writeBlockRecords() = 0;
virtual void writeEntities() = 0; virtual void writeEntities() = 0;
virtual void writeLTypes() = 0; virtual void writeLTypes() = 0;
virtual void writeLayers() = 0; virtual void writeLayers() = 0;
virtual void writeTextstyles() = 0; virtual void writeTextstyles() = 0;
virtual void writeVports() = 0; virtual void writeVports() = 0;
virtual void writeDimstyles() = 0; virtual void writeDimstyles() = 0;
virtual void writeAppId() = 0;
protected: protected:
// DL_Attributes attributes; // DL_Attributes attributes;
......
...@@ -41,6 +41,58 @@ void DRW_TableEntry::parseCode( int code, dxfReader* reader ) ...@@ -41,6 +41,58 @@ void DRW_TableEntry::parseCode( int code, dxfReader* reader )
flags = reader->getInt32(); flags = reader->getInt32();
break; break;
case 1000:
case 1001:
case 1002:
case 1003:
case 1004:
case 1005:
extData.push_back( new DRW_Variant( code, reader->getString() ) );
break;
case 1010:
case 1011:
case 1012:
case 1013:
curr = new DRW_Variant();
curr->addCoord();
curr->setCoordX( reader->getDouble() );
curr->code = code;
extData.push_back( curr );
break;
case 1020:
case 1021:
case 1022:
case 1023:
if( curr )
curr->setCoordY( reader->getDouble() );
break;
case 1030:
case 1031:
case 1032:
case 1033:
if( curr )
curr->setCoordZ( reader->getDouble() );
curr = NULL;
break;
case 1040:
case 1041:
case 1042:
extData.push_back( new DRW_Variant( code, reader->getDouble() ) );
break;
case 1070:
case 1071:
extData.push_back( new DRW_Variant( code, reader->getInt32() ) );
break;
default: default:
break; break;
} }
...@@ -747,7 +799,7 @@ void DRW_Header::parseCode( int code, dxfReader* reader ) ...@@ -747,7 +799,7 @@ void DRW_Header::parseCode( int code, dxfReader* reader )
break; break;
case 10: case 10:
curr->addCoord( new DRW_Coord() ); curr->addCoord();
curr->setCoordX( reader->getDouble() ); curr->setCoordX( reader->getDouble() );
curr->code = code; curr->code = code;
break; break;
...@@ -815,8 +867,8 @@ void DRW_Header::parseCode( int code, dxfReader* reader ) ...@@ -815,8 +867,8 @@ void DRW_Header::parseCode( int code, dxfReader* reader )
void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
{ {
/*RLZ: TODO complete all vars to AC1024*/ /*RLZ: TODO complete all vars to AC1024*/
double varDouble; double varDouble;
int varInt; int varInt;
std::string varStr; std::string varStr;
DRW_Coord varCoord; DRW_Coord varCoord;
...@@ -970,6 +1022,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -970,6 +1022,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeUtf8String( 7, varStr ); writer->writeUtf8String( 7, varStr );
else else
writer->writeString( 7, "STANDARD" ); writer->writeString( 7, "STANDARD" );
...@@ -982,6 +1036,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -982,6 +1036,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeUtf8String( 8, varStr ); writer->writeUtf8String( 8, varStr );
else else
writer->writeString( 8, "0" ); writer->writeString( 8, "0" );
...@@ -1082,6 +1138,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -1082,6 +1138,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeUtf8String( 2, varStr ); writer->writeUtf8String( 2, varStr );
else else
writer->writeString( 2, "STANDARD" ); writer->writeString( 2, "STANDARD" );
...@@ -1235,7 +1293,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -1235,7 +1293,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
#ifdef DRW_DBG #ifdef DRW_DBG
std::map<std::string, DRW_Variant*>::const_iterator it; std::map<std::string, DRW_Variant*>::const_iterator it;
for( it = vars.begin(); it != vars.end(); it++ ) for( it = vars.begin(); it != vars.end(); ++it )
{ {
// QString key = QString::fromStdString((*it).first); // QString key = QString::fromStdString((*it).first);
std::cerr << (*it).first << std::endl; std::cerr << (*it).first << std::endl;
...@@ -1245,6 +1303,42 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -1245,6 +1303,42 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
} }
void DRW_Header::addDouble( std::string key, double value, int code )
{
curr = new DRW_Variant();
curr->addDouble( value );
curr->code = code;
vars[key] = curr;
}
void DRW_Header::addInt( std::string key, int value, int code )
{
curr = new DRW_Variant();
curr->addInt( value );
curr->code = code;
vars[key] = curr;
}
void DRW_Header::addStr( std::string key, std::string value, int code )
{
curr = new DRW_Variant();
curr->addString( value );
curr->code = code;
vars[key] = curr;
}
void DRW_Header::addCoord( std::string key, DRW_Coord value, int code )
{
curr = new DRW_Variant();
curr->addCoord( value );
curr->code = code;
vars[key] = curr;
}
bool DRW_Header::getDouble( std::string key, double* varDouble ) bool DRW_Header::getDouble( std::string key, double* varDouble )
{ {
bool result = false; bool result = false;
...@@ -1258,8 +1352,8 @@ bool DRW_Header::getDouble( std::string key, double* varDouble ) ...@@ -1258,8 +1352,8 @@ bool DRW_Header::getDouble( std::string key, double* varDouble )
if( var->type == DRW_Variant::DOUBLE ) if( var->type == DRW_Variant::DOUBLE )
{ {
*varDouble = var->content.d; *varDouble = var->content.d;
result = true; result = true;
} }
vars.erase( it ); vars.erase( it );
...@@ -1330,8 +1424,8 @@ bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord ) ...@@ -1330,8 +1424,8 @@ bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord )
if( var->type == DRW_Variant::COORD ) if( var->type == DRW_Variant::COORD )
{ {
*varCoord = *var->content.v; *varCoord = *var->content.v;
result = true; result = true;
} }
vars.erase( it ); vars.erase( it );
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
DRW_TextCodec::DRW_TextCodec() DRW_TextCodec::DRW_TextCodec()
{ {
version = DRW::AC1021; version = DRW::AC1021;
conv = new DRW_Converter( NULL, 0 ); conv = new DRW_Converter( NULL, 0 );
} }
...@@ -62,16 +62,16 @@ void DRW_TextCodec::setCodePage( std::string* c ) ...@@ -62,16 +62,16 @@ void DRW_TextCodec::setCodePage( std::string* c )
conv = new DRW_ConvTable( DRW_Table874, CPLENGHTCOMMON ); conv = new DRW_ConvTable( DRW_Table874, CPLENGHTCOMMON );
else if( cp == "ANSI_932" ) else if( cp == "ANSI_932" )
conv = new DRW_Conv932Table( DRW_Table932, DRW_LeadTable932, conv = new DRW_Conv932Table( DRW_Table932, DRW_LeadTable932,
DRW_DoubleTable932, CPLENGHT932 ); DRW_DoubleTable932, CPLENGHT932 );
else if( cp == "ANSI_936" ) else if( cp == "ANSI_936" )
conv = new DRW_ConvDBCSTable( DRW_Table936, DRW_LeadTable936, conv = new DRW_ConvDBCSTable( DRW_Table936, DRW_LeadTable936,
DRW_DoubleTable936, CPLENGHT936 ); DRW_DoubleTable936, CPLENGHT936 );
else if( cp == "ANSI_949" ) else if( cp == "ANSI_949" )
conv = new DRW_ConvDBCSTable( DRW_Table949, DRW_LeadTable949, conv = new DRW_ConvDBCSTable( DRW_Table949, DRW_LeadTable949,
DRW_DoubleTable949, CPLENGHT949 ); DRW_DoubleTable949, CPLENGHT949 );
else if( cp == "ANSI_950" ) else if( cp == "ANSI_950" )
conv = new DRW_ConvDBCSTable( DRW_Table950, DRW_LeadTable950, conv = new DRW_ConvDBCSTable( DRW_Table950, DRW_LeadTable950,
DRW_DoubleTable950, CPLENGHT950 ); DRW_DoubleTable950, CPLENGHT950 );
else if( cp == "ANSI_1250" ) else if( cp == "ANSI_1250" )
conv = new DRW_ConvTable( DRW_Table1250, CPLENGHTCOMMON ); conv = new DRW_ConvTable( DRW_Table1250, CPLENGHTCOMMON );
else if( cp == "ANSI_1251" ) else if( cp == "ANSI_1251" )
...@@ -117,9 +117,9 @@ std::string DRW_TextCodec::fromUtf8( std::string s ) ...@@ -117,9 +117,9 @@ std::string DRW_TextCodec::fromUtf8( std::string s )
std::string DRW_Converter::toUtf8( std::string* s ) std::string DRW_Converter::toUtf8( std::string* s )
{ {
std::string result; std::string result;
int j = 0; int j = 0;
unsigned int i = 0; unsigned int i = 0;
for( i = 0; i < s->length(); i++ ) for( i = 0; i < s->length(); i++ )
{ {
...@@ -127,8 +127,7 @@ std::string DRW_Converter::toUtf8( std::string* s ) ...@@ -127,8 +127,7 @@ std::string DRW_Converter::toUtf8( std::string* s )
if( c < 0x80 ) // ascii check for /U+???? if( c < 0x80 ) // ascii check for /U+????
{ {
if( c == '\\' && i + 6 < s->length() && s->at( i + 1 ) == 'U' && s->at( i + 2 ) == if( c == '\\' && i + 6 < s->length() && s->at( i + 1 ) == 'U' && s->at( i + 2 ) == '+' )
'+' )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
result += encodeText( s->substr( i, 7 ) ); result += encodeText( s->substr( i, 7 ) );
...@@ -159,10 +158,10 @@ std::string DRW_Converter::toUtf8( std::string* s ) ...@@ -159,10 +158,10 @@ std::string DRW_Converter::toUtf8( std::string* s )
std::string DRW_ConvTable::fromUtf8( std::string* s ) std::string DRW_ConvTable::fromUtf8( std::string* s )
{ {
std::string result; std::string result;
bool notFound; bool notFound;
int code; int code;
int j = 0; int j = 0;
for( unsigned int i = 0; i < s->length(); i++ ) for( unsigned int i = 0; i < s->length(); i++ )
{ {
...@@ -172,17 +171,17 @@ std::string DRW_ConvTable::fromUtf8( std::string* s ) ...@@ -172,17 +171,17 @@ std::string DRW_ConvTable::fromUtf8( std::string* s )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
std::string part1 = s->substr( i, 4 ); std::string part1 = s->substr( i, 4 );
int l; int l;
code = decodeNum( part1, &l ); code = decodeNum( part1, &l );
j = i + l; j = i + l;
i = j - 1; i = j - 1;
notFound = true; notFound = true;
for( int k = 0; k<cpLenght; k++ ) for( int k = 0; k<cpLenght; k++ )
{ {
if( table[k] == code ) if( table[k] == code )
{ {
result += CPOFFSET + k; // translate from table result += CPOFFSET + k; // translate from table
notFound = false; notFound = false;
break; break;
} }
...@@ -201,10 +200,10 @@ std::string DRW_ConvTable::fromUtf8( std::string* s ) ...@@ -201,10 +200,10 @@ std::string DRW_ConvTable::fromUtf8( std::string* s )
std::string DRW_ConvTable::toUtf8( std::string* s ) std::string DRW_ConvTable::toUtf8( std::string* s )
{ {
std::string res; std::string res;
std::string::iterator it; std::string::iterator it;
for( it = s->begin(); it < s->end(); it++ ) for( it = s->begin(); it < s->end(); ++it )
{ {
unsigned char c = *it; unsigned char c = *it;
...@@ -313,21 +312,21 @@ std::string DRW_Converter::encodeNum( int c ) ...@@ -313,21 +312,21 @@ std::string DRW_Converter::encodeNum( int c )
**/ **/
int DRW_Converter::decodeNum( std::string s, int* b ) int DRW_Converter::decodeNum( std::string s, int* b )
{ {
int code = 0; int code = 0;
unsigned char c = s.at( 0 ); unsigned char c = s.at( 0 );
if( (c & 0xE0) == 0xC0 ) // 2 bytes if( (c & 0xE0) == 0xC0 ) // 2 bytes
{ {
code = ( c & 0x1F) << 6; code = ( c & 0x1F) << 6;
code = (s.at( 1 ) & 0x3F) | code; code = (s.at( 1 ) & 0x3F) | code;
*b = 2; *b = 2;
} }
else if( (c & 0xF0) == 0xE0 ) // 3 bytes else if( (c & 0xF0) == 0xE0 ) // 3 bytes
{ {
code = ( c & 0x0F) << 12; code = ( c & 0x0F) << 12;
code = ( (s.at( 1 ) & 0x3F) << 6 ) | code; code = ( (s.at( 1 ) & 0x3F) << 6 ) | code;
code = (s.at( 2 ) & 0x3F) | code; code = (s.at( 2 ) & 0x3F) | code;
*b = 3; *b = 3;
} }
else if( (c & 0xF8) == 0xF0 ) // 4 bytes else if( (c & 0xF8) == 0xF0 ) // 4 bytes
{ {
...@@ -335,7 +334,7 @@ int DRW_Converter::decodeNum( std::string s, int* b ) ...@@ -335,7 +334,7 @@ int DRW_Converter::decodeNum( std::string s, int* b )
code = ( (s.at( 1 ) & 0x3F) << 12 ) | code; code = ( (s.at( 1 ) & 0x3F) << 12 ) | code;
code = ( (s.at( 2 ) & 0x3F) << 6 ) | code; code = ( (s.at( 2 ) & 0x3F) << 6 ) | code;
code = (s.at( 3 ) & 0x3F) | code; code = (s.at( 3 ) & 0x3F) | code;
*b = 4; *b = 4;
} }
return code; return code;
...@@ -345,10 +344,10 @@ int DRW_Converter::decodeNum( std::string s, int* b ) ...@@ -345,10 +344,10 @@ int DRW_Converter::decodeNum( std::string s, int* b )
std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) std::string DRW_ConvDBCSTable::fromUtf8( std::string* s )
{ {
std::string result; std::string result;
bool notFound; bool notFound;
int code; int code;
int j = 0; int j = 0;
for( unsigned int i = 0; i < s->length(); i++ ) for( unsigned int i = 0; i < s->length(); i++ )
{ {
...@@ -358,21 +357,21 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) ...@@ -358,21 +357,21 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
std::string part1 = s->substr( i, 4 ); std::string part1 = s->substr( i, 4 );
int l; int l;
code = decodeNum( part1, &l ); code = decodeNum( part1, &l );
j = i + l; j = i + l;
i = j - 1; i = j - 1;
notFound = true; notFound = true;
for( int k = 0; k<cpLenght; k++ ) for( int k = 0; k<cpLenght; k++ )
{ {
if( doubleTable[k][1] == code ) if( doubleTable[k][1] == code )
{ {
int data = doubleTable[k][0]; int data = doubleTable[k][0];
char d[3]; char d[3];
d[0] = data >> 8; d[0] = data >> 8;
d[1] = data & 0xFF; d[1] = data & 0xFF;
d[2] = '\0'; d[2] = '\0';
result += d; // translate from table result += d; // translate from table
notFound = false; notFound = false;
break; break;
...@@ -392,13 +391,13 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) ...@@ -392,13 +391,13 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s )
std::string DRW_ConvDBCSTable::toUtf8( std::string* s ) std::string DRW_ConvDBCSTable::toUtf8( std::string* s )
{ {
std::string res; std::string res;
std::string::iterator it; std::string::iterator it;
for( it = s->begin(); it < s->end(); it++ ) for( it = s->begin(); it < s->end(); ++it )
{ {
bool notFound = true; bool notFound = true;
unsigned char c = *it; unsigned char c = *it;
if( c < 0x80 ) if( c < 0x80 )
{ {
...@@ -455,10 +454,10 @@ std::string DRW_ConvDBCSTable::toUtf8( std::string* s ) ...@@ -455,10 +454,10 @@ std::string DRW_ConvDBCSTable::toUtf8( std::string* s )
std::string DRW_Conv932Table::fromUtf8( std::string* s ) std::string DRW_Conv932Table::fromUtf8( std::string* s )
{ {
std::string result; std::string result;
bool notFound; bool notFound;
int code; int code;
int j = 0; int j = 0;
for( unsigned int i = 0; i < s->length(); i++ ) for( unsigned int i = 0; i < s->length(); i++ )
{ {
...@@ -468,16 +467,16 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) ...@@ -468,16 +467,16 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
std::string part1 = s->substr( i, 4 ); std::string part1 = s->substr( i, 4 );
int l; int l;
code = decodeNum( part1, &l ); code = decodeNum( part1, &l );
j = i + l; j = i + l;
i = j - 1; i = j - 1;
notFound = true; notFound = true;
// 1 byte table // 1 byte table
if( code > 0xff60 && code < 0xFFA0 ) if( code > 0xff60 && code < 0xFFA0 )
{ {
result += code - CPOFFSET932; // translate from table result += code - CPOFFSET932; // translate from table
notFound = false; notFound = false;
} }
...@@ -488,12 +487,12 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) ...@@ -488,12 +487,12 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s )
{ {
if( doubleTable[k][1] == code ) if( doubleTable[k][1] == code )
{ {
int data = doubleTable[k][0]; int data = doubleTable[k][0];
char d[3]; char d[3];
d[0] = data >> 8; d[0] = data >> 8;
d[1] = data & 0xFF; d[1] = data & 0xFF;
d[2] = '\0'; d[2] = '\0';
result += d; // translate from table result += d; // translate from table
notFound = false; notFound = false;
break; break;
} }
...@@ -513,13 +512,13 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) ...@@ -513,13 +512,13 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s )
std::string DRW_Conv932Table::toUtf8( std::string* s ) std::string DRW_Conv932Table::toUtf8( std::string* s )
{ {
std::string res; std::string res;
std::string::iterator it; std::string::iterator it;
for( it = s->begin(); it < s->end(); it++ ) for( it = s->begin(); it < s->end(); ++it )
{ {
bool notFound = true; bool notFound = true;
unsigned char c = *it; unsigned char c = *it;
if( c < 0x80 ) if( c < 0x80 )
{ {
...@@ -661,7 +660,7 @@ std::string DRW_TextCodec::correctCodePage( const std::string& s ) ...@@ -661,7 +660,7 @@ std::string DRW_TextCodec::correctCodePage( const std::string& s )
} }
else if( cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB" else if( cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB"
|| cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280" || cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280"
|| cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80" || cp=="GBK" || cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80"
|| cp=="ISO-IR-58" || cp=="GB18030" ) || cp=="ISO-IR-58" || cp=="GB18030" )
{ {
return "ANSI_936"; return "ANSI_936";
......
...@@ -14,20 +14,21 @@ public: ...@@ -14,20 +14,21 @@ public:
std::string toUtf8( std::string s ); std::string toUtf8( std::string s );
int getVersion() { return version; } int getVersion() { return version; }
void setVersion( std::string* v ); void setVersion( std::string* v );
void setVersion( int v ) { version = v; } void setVersion( int v ) { version = v; }
void setCodePage( std::string* c ); void setCodePage( std::string* c );
void setCodePage( std::string c ) { setCodePage( &c ); } void setCodePage( std::string c ) { setCodePage( &c ); }
std::string getCodePage() { return cp; } std::string getCodePage() { return cp; }
private: private:
std::string correctCodePage( const std::string& s ); std::string correctCodePage( const std::string& s );
private: private:
int version; int version;
std::string cp; std::string cp;
DRW_Converter* conv; DRW_Converter* conv;
}; };
class DRW_Converter class DRW_Converter
...@@ -47,8 +48,8 @@ public: ...@@ -47,8 +48,8 @@ public:
std::string encodeNum( int c ); std::string encodeNum( int c );
int decodeNum( std::string s, int* b ); int decodeNum( std::string s, int* b );
const int* table; const int* table;
int cpLenght; int cpLenght;
}; };
class DRW_ConvTable : public DRW_Converter class DRW_ConvTable : public DRW_Converter
...@@ -63,9 +64,9 @@ class DRW_ConvDBCSTable : public DRW_Converter ...@@ -63,9 +64,9 @@ class DRW_ConvDBCSTable : public DRW_Converter
{ {
public: public:
DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t, DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
l ) l )
{ {
leadTable = lt; leadTable = lt;
doubleTable = dt; doubleTable = dt;
} }
...@@ -81,9 +82,9 @@ class DRW_Conv932Table : public DRW_Converter ...@@ -81,9 +82,9 @@ class DRW_Conv932Table : public DRW_Converter
{ {
public: public:
DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t, DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
l ) l )
{ {
leadTable = lt; leadTable = lt;
doubleTable = dt; doubleTable = dt;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -119,6 +119,7 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -119,6 +119,7 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
break;
case ID_SELECT_PAGE_NUMBER: case ID_SELECT_PAGE_NUMBER:
m_canvas->Refresh(); m_canvas->Refresh();
......
...@@ -709,6 +709,7 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition ) ...@@ -709,6 +709,7 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
// because the locate requirements are very basic. // because the locate requirements are very basic.
std::vector <WS_DRAW_ITEM_BASE*> list; std::vector <WS_DRAW_ITEM_BASE*> list;
drawList.Locate( list, aPosition ); drawList.Locate( list, aPosition );
if( list.size() == 0 ) if( list.size() == 0 )
return NULL; return NULL;
......
...@@ -33,9 +33,5 @@ ...@@ -33,9 +33,5 @@
<key>LSRequiresCarbon</key> <true/> <key>LSRequiresCarbon</key> <true/>
<key>NSHumanReadableCopyright</key> <string></string> <key>NSHumanReadableCopyright</key> <string></string>
<key>NSHighResolutionCapable</key> <string>True</string> <key>NSHighResolutionCapable</key> <string>True</string>
<key>LSEnvironment</key>
<dict>
<key>KIGITHUB</key> <string>https://github.com/kicad</string>
</dict>
</dict> </dict>
</plist> </plist>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment