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

Merge trunk @ 5423

parents ebec4e69 b0ad779e
......@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Mario Luzeiro <mrluzeiro@gmail.com>
* Copyright (C) 1992-2014 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
* modify it under the terms of the GNU General Public License
......@@ -46,8 +46,8 @@ S3D_MESH::S3D_MESH()
m_translation = glm::vec3( 0.0f, 0.0f, 0.0f );
m_rotation = glm::vec4( 0.0f, 0.0f, 0.0f, 0.0f );
m_scale = glm::vec3( 1.0f, 1.0f, 1.0f );
m_scaleOrientation = glm::vec4( 0.0f, 0.0f, 1.0f, 0.0f ); // not used
m_center = glm::vec3( 0.0f, 0.0f, 0.0f ); // not used
m_scaleOrientation = glm::vec4( 0.0f, 0.0f, 1.0f, 0.0f ); // not used
m_center = glm::vec3( 0.0f, 0.0f, 0.0f ); // not used
}
......@@ -55,10 +55,11 @@ S3D_MESH::~S3D_MESH()
{
for( unsigned int idx = 0; idx < childs.size(); idx++ )
{
delete childs[idx];
delete childs[idx];
}
}
void S3D_MESH::openGL_RenderAllChilds()
{
//DBG( printf( "openGL_RenderAllChilds") );
......@@ -82,7 +83,6 @@ void S3D_MESH::openGL_RenderAllChilds()
SetOpenGlDefaultMaterial();
glPopMatrix();
}
......@@ -94,15 +94,10 @@ void S3D_MESH::openGL_Render()
&& g_Parm_3D_Visu.GetFlag( FL_RENDER_SMOOTH );
if( m_Materials )
{
m_Materials->SetOpenGLMaterial( 0, useMaterial );
}
if( m_CoordIndex.size() == 0)
{
if( m_CoordIndex.size() == 0 )
return;
}
glPushMatrix();
glTranslatef( m_translation.x, m_translation.y, m_translation.z );
......@@ -117,9 +112,7 @@ void S3D_MESH::openGL_Render()
if( m_PerVertexNormalsNormalized.size() == 0 )
{
if( smoothShapes )
{
calcPerPointNormals();
}
}
for( unsigned int idx = 0; idx < m_CoordIndex.size(); idx++ )
......@@ -127,17 +120,21 @@ void S3D_MESH::openGL_Render()
if( m_MaterialIndex.size() > 1 )
{
if( m_Materials )
{
m_Materials->SetOpenGLMaterial( m_MaterialIndex[idx], useMaterial );
}
}
switch( m_CoordIndex[idx].size() )
{
case 3: glBegin( GL_TRIANGLES );break;
case 4: glBegin( GL_QUADS ); break;
default: glBegin( GL_POLYGON ); break;
case 3:
glBegin( GL_TRIANGLES );
break;
case 4:
glBegin( GL_QUADS );
break;
default:
glBegin( GL_POLYGON );
break;
}
......@@ -187,34 +184,36 @@ void S3D_MESH::openGL_Render()
}
void S3D_MESH::calcPointNormalized ()
void S3D_MESH::calcPointNormalized()
{
//DBG( printf( "calcPointNormalized\n" ) );
if( isPointNormalizedComputed == true )
{
return;
}
isPointNormalizedComputed = true;
if( m_PerVertexNormalsNormalized.size() > 0 )
{
return;
}
m_PointNormalized.clear();
float biggerPoint = 0.0f;
for( unsigned int i = 0; i< m_Point.size(); i++ )
{
if( fabs( m_Point[i].x ) > biggerPoint) biggerPoint = fabs( m_Point[i].x );
if( fabs( m_Point[i].y ) > biggerPoint) biggerPoint = fabs( m_Point[i].y );
if( fabs( m_Point[i].z ) > biggerPoint) biggerPoint = fabs( m_Point[i].z );
if( fabs( m_Point[i].x ) > biggerPoint )
biggerPoint = fabs( m_Point[i].x );
if( fabs( m_Point[i].y ) > biggerPoint )
biggerPoint = fabs( m_Point[i].y );
if( fabs( m_Point[i].z ) > biggerPoint )
biggerPoint = fabs( m_Point[i].z );
}
biggerPoint = 1.0 / biggerPoint;
for( unsigned int i= 0; i< m_Point.size(); i++ )
for( unsigned int i = 0; i < m_Point.size(); i++ )
{
glm::vec3 p;
p = m_Point[i] * biggerPoint;
......@@ -237,30 +236,22 @@ bool IsClockwise( glm::vec3 v0, glm::vec3 v1, glm::vec3 v2 )
}
void S3D_MESH::calcPerFaceNormals ()
void S3D_MESH::calcPerFaceNormals()
{
//DBG( printf( "calcPerFaceNormals" ) );
if( isPerFaceNormalsComputed == true )
{
return;
}
isPerFaceNormalsComputed = true;
isPerFaceNormalsComputed = true;
if( m_PerVertexNormalsNormalized.size() > 0 )
{
return;
}
bool haveAlreadyNormals_from_model_file = false;
if( m_PerFaceNormalsNormalized.size() > 0 )
{
haveAlreadyNormals_from_model_file = true;
}
m_PerFaceNormalsRaw.clear();
m_PerFaceSquaredArea.clear();
......@@ -268,9 +259,15 @@ void S3D_MESH::calcPerFaceNormals ()
//DBG( printf("m_CoordIndex.size %u\n", m_CoordIndex.size()) );
//DBG( printf("m_PointNormalized.size %u\n", m_PointNormalized.size()) );
for( unsigned int idx = 0; idx < m_CoordIndex.size(); idx++ )
// There are no points defined for the coordIndex
if( m_PointNormalized.size() == 0 )
{
m_CoordIndex.clear();
return;
}
for( unsigned int idx = 0; idx < m_CoordIndex.size(); idx++ )
{
// User normalized and multiply to get better resolution
glm::vec3 v0 = m_PointNormalized[m_CoordIndex[idx][0]];
glm::vec3 v1 = m_PointNormalized[m_CoordIndex[idx][1]];
......@@ -300,14 +297,10 @@ void S3D_MESH::calcPerFaceNormals ()
float area = glm::dot( cross_prod, cross_prod );
if( cross_prod[2] < 0.0 )
{
area = -area;
}
if( area < FLT_EPSILON )
{
area = FLT_EPSILON * 2.0f;
}
m_PerFaceSquaredArea.push_back( area );
......@@ -315,52 +308,55 @@ void S3D_MESH::calcPerFaceNormals ()
if( haveAlreadyNormals_from_model_file == false )
{
// normalize vertex normal
float l = glm::length( cross_prod );
if( l > FLT_EPSILON ) // avoid division by zero
{
cross_prod = cross_prod / l;
cross_prod = cross_prod / l;
}
else
{
// Cannot calc normal
if( ( cross_prod.x > cross_prod.y ) && ( cross_prod.x > cross_prod.z ) )
{
cross_prod.x = 1.0; cross_prod.y = 0.0; cross_prod.z = 0.0;
} else if( ( cross_prod.y > cross_prod.x ) && ( cross_prod.y > cross_prod.z ))
cross_prod.x = 1.0;
cross_prod.y = 0.0;
cross_prod.z = 0.0;
}
else if( ( cross_prod.y > cross_prod.x ) && ( cross_prod.y > cross_prod.z ) )
{
cross_prod.x = 0.0; cross_prod.y = 1.0; cross_prod.z = 0.0;
} else
cross_prod.x = 0.0;
cross_prod.y = 1.0;
cross_prod.z = 0.0;
}
else
{
cross_prod.x = 0.0; cross_prod.y = 1.0; cross_prod.z = 0.0;
cross_prod.x = 0.0;
cross_prod.y = 0.0;
cross_prod.z = 1.0;
}
}
m_PerFaceNormalsNormalized.push_back( cross_prod );
}
}
}
// http://www.bytehazard.com/code/vertnorm.html
// http://www.emeyex.com/site/tuts/VertexNormals.pdf
void S3D_MESH::calcPerPointNormals ()
void S3D_MESH::calcPerPointNormals()
{
//DBG( printf( "calcPerPointNormals" ) );
if( isPerPointNormalsComputed == true )
{
return;
}
isPerPointNormalsComputed = true;
if( m_PerVertexNormalsNormalized.size() > 0 )
{
return;
}
m_PerFaceVertexNormals.clear();
......@@ -371,6 +367,7 @@ void S3D_MESH::calcPerPointNormals ()
#ifdef USE_OPENMP
#pragma omp parallel for
#endif /* USE_OPENMP */
for( unsigned int each_face_A_idx = 0; each_face_A_idx < m_CoordIndex.size(); each_face_A_idx++ )
{
// n = face A facet normal
......@@ -390,15 +387,16 @@ void S3D_MESH::calcPerPointNormals ()
for( unsigned int each_face_B_idx = 0; each_face_B_idx < m_CoordIndex.size(); each_face_B_idx++ )
{
//if A != B { // ignore self
if ( each_face_A_idx != each_face_B_idx)
if( each_face_A_idx != each_face_B_idx )
{
if( (m_CoordIndex[each_face_B_idx][0] == vertexIndex) ||
(m_CoordIndex[each_face_B_idx][1] == vertexIndex) ||
(m_CoordIndex[each_face_B_idx][2] == vertexIndex) )
if( (m_CoordIndex[each_face_B_idx][0] == vertexIndex)
|| (m_CoordIndex[each_face_B_idx][1] == vertexIndex)
|| (m_CoordIndex[each_face_B_idx][2] == vertexIndex) )
{
glm::vec3 vector_face_B = m_PerFaceNormalsNormalized[each_face_B_idx];
float dot_prod = glm::dot(vector_face_A, vector_face_B);
float dot_prod = glm::dot( vector_face_A, vector_face_B );
if( dot_prod > 0.05f )
{
face_A_normals[each_vert_A_idx] += m_PerFaceNormalsRaw[each_face_B_idx] * (m_PerFaceSquaredArea[each_face_B_idx] * dot_prod);
......@@ -411,10 +409,7 @@ void S3D_MESH::calcPerPointNormals ()
float l = glm::length( face_A_normals[each_vert_A_idx] );
if( l > FLT_EPSILON ) // avoid division by zero
{
face_A_normals[each_vert_A_idx] /= l;
}
}
}
}
......@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
* modify it under the terms of the GNU General Public License
......@@ -45,7 +45,7 @@ class X3D_MODEL_PARSER;
class S3D_MODEL_PARSER
{
public:
S3D_MODEL_PARSER(S3D_MASTER* aMaster) :
S3D_MODEL_PARSER( S3D_MASTER* aMaster ) :
master( aMaster )
{}
......@@ -96,7 +96,7 @@ public:
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
typedef std::map< wxString, wxString > PROPERTY_MAP;
typedef std::vector< wxXmlNode* > NODE_LIST;
typedef std::vector< wxXmlNode* > NODE_LIST;
/**
* Function GetChildsByName
......@@ -125,9 +125,9 @@ public:
wxString VRML2_representation();
private:
wxString m_Filename;
S3D_MESH *m_model;
std::vector<S3D_MESH *> childs;
wxString m_Filename;
S3D_MESH* m_model;
std::vector< S3D_MESH* > childs;
std::vector< wxString > vrml_materials;
std::vector< wxString > vrml_points;
......@@ -142,6 +142,7 @@ private:
};
typedef std::map< std::string, std::vector< glm::vec3 > > VRML2_COORDINATE_MAP;
/**
* class VRML2_MODEL_PARSER
......@@ -165,25 +166,30 @@ public:
private:
int read_Transform();
int read_DEF();
int read_DEF_Coordinate();
int read_Shape();
int read_Appearance();
int read_material();
int read_Material();
int read_IndexedFaceSet();
int read_IndexedLineSet();
int read_Coordinate();
int read_CoordinateDef();
int read_Normal();
int read_NormalIndex();
int read_Color();
int read_coordIndex();
int read_colorIndex();
bool m_normalPerVertex;
bool colorPerVertex;
S3D_MESH *m_model;
std::vector<S3D_MESH *> childs;
FILE *m_file;
S3D_MATERIAL *m_Materials;
wxString m_Filename;
int read_USE();
bool m_normalPerVertex;
bool colorPerVertex;
S3D_MESH* m_model;
std::vector< S3D_MESH* > childs;
FILE* m_file;
S3D_MATERIAL* m_Materials;
wxString m_Filename;
VRML2_COORDINATE_MAP m_defCoordinateMap;
};
......@@ -224,13 +230,13 @@ private:
int readIndexedFaceSet_coordIndex();
int readIndexedFaceSet_materialIndex();
bool m_normalPerVertex;
bool colorPerVertex;
S3D_MESH *m_model;
std::vector<S3D_MESH *> childs;
S3D_MATERIAL *m_Materials;
FILE *m_file;
wxString m_Filename;
bool m_normalPerVertex;
bool colorPerVertex;
S3D_MESH* m_model;
std::vector< S3D_MESH* > childs;
S3D_MATERIAL* m_Materials;
FILE* m_file;
wxString m_Filename;
};
/**
......@@ -246,8 +252,8 @@ public:
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
private:
VRML1_MODEL_PARSER *vrml1_parser;
VRML2_MODEL_PARSER *vrml2_parser;
VRML1_MODEL_PARSER* vrml1_parser;
VRML2_MODEL_PARSER* vrml2_parser;
};
......
This diff is collapsed.
......@@ -639,7 +639,6 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
# FindPythonInterp unless the user specifically defined a custom path.
if( NOT PYTHON_SITE_PACKAGE_PATH )
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig;print\"%s\"%distutils.sysconfig.get_python_lib(plat_specific=0, standard_lib=0, prefix='')"
# execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig;print\"%s\"%distutils.sysconfig.get_python_lib()"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
......@@ -666,6 +665,33 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
find_package( PythonLibs 2.6 )
if( KICAD_SCRIPTING_WXPYTHON )
# Check to see if the correct version of wxPython is installed based on the version of
# wxWidgets found. At least the major an minor version should match.
set( _wxpy_version "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}" )
set( _py_cmd "import wxversion;print wxversion.checkInstalled('${_wxpy_version}')" )
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "${_py_cmd}"
RESULT_VARIABLE WXPYTHON_VERSION_RESULT
OUTPUT_VARIABLE WXPYTHON_VERSION_FOUND
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# message( STATUS "WXPYTHON_VERSION_FOUND: ${WXPYTHON_VERSION_FOUND}" )
# message( STATUS "WXPYTHON_VERSION_RESULT: ${WXPYTHON_VERSION_RESULT}" )
# Check to see if any version of wxPython is installed on the system.
if( WXPYTHON_VERSION_RESULT GREATER 0 )
message( FATAL_ERROR "wxPython does not appear to be installed on the system." )
endif()
if( NOT WXPYTHON_VERSION_FOUND STREQUAL "True" )
message( FATAL_ERROR "wxPython version ${_wxpy_version} does not appear to be installed on the system." )
else()
set( WXPYTHON_VERSION_FOUND "${_wxpy_version}"
CACHE STRING "wxPython version found." )
endif()
endif()
#message( STATUS "PYTHON_INCLUDE_DIRS:${PYTHON_INCLUDE_DIRS}" )
# Infrequently needed headers go at end of search paths, append to INC_AFTER which
......
......@@ -70,6 +70,11 @@
#define KICAD_DATA_PATH "@CMAKE_INSTALL_PREFIX@/@KICAD_DATA@"
#endif
/// The wxPython version found during configuration.
#if defined( KICAD_SCRIPTING_WXPYTHON )
#define WXPYTHON_VERSION "@WXPYTHON_VERSION_FOUND@"
#endif
/// When defined, build the GITHUB_PLUGIN for pcbnew.
#cmakedefine BUILD_GITHUB_PLUGIN
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2014 CERN
* Copyright (C) 2013-2015 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -28,6 +29,7 @@
#include <wx/event.h>
#include <wx/colour.h>
#include <wx/filename.h>
#include <confirm.h>
#include <kiface_i.h>
#include <class_draw_panel_gal.h>
......@@ -133,30 +135,30 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_pendingRefresh = false;
m_lastRefresh = wxGetLocalTimeMillis();
if( !m_drawing )
{
m_drawing = true;
if( m_drawing )
return;
m_view->UpdateItems();
m_gal->BeginDrawing();
m_gal->ClearScreen( m_painter->GetSettings()->GetBackgroundColor() );
m_drawing = true;
if( m_view->IsDirty() )
{
m_view->ClearTargets();
m_view->UpdateItems();
m_gal->BeginDrawing();
m_gal->ClearScreen( m_painter->GetSettings()->GetBackgroundColor() );
// Grid has to be redrawn only when the NONCACHED target is redrawn
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
if( m_view->IsDirty() )
{
m_view->ClearTargets();
// Grid has to be redrawn only when the NONCACHED target is redrawn
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
m_gal->DrawGrid();
m_view->Redraw();
}
m_view->Redraw();
}
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
m_gal->EndDrawing();
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
m_gal->EndDrawing();
m_drawing = false;
}
m_drawing = false;
}
......@@ -250,7 +252,8 @@ void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
void EDA_DRAW_PANEL_GAL::StartDrawing()
{
m_pendingRefresh = false;
m_drawing = false;
m_pendingRefresh = true;
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
wxPaintEvent redrawEvent;
......@@ -260,7 +263,8 @@ void EDA_DRAW_PANEL_GAL::StartDrawing()
void EDA_DRAW_PANEL_GAL::StopDrawing()
{
m_pendingRefresh = true;
m_pendingRefresh = false;
m_drawing = true;
m_refreshTimer.Stop();
Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
}
......@@ -288,41 +292,54 @@ void EDA_DRAW_PANEL_GAL::SetTopLayer( LAYER_ID aLayer )
}
void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
bool EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
{
// Do not do anything if the currently used GAL is correct
if( aGalType == m_backend && m_gal != NULL )
return;
return true;
// Prevent refreshing canvas during backend switch
StopDrawing();
delete m_gal;
KIGFX::GAL* new_gal = NULL;
switch( aGalType )
try
{
case GAL_TYPE_OPENGL:
m_gal = new KIGFX::OPENGL_GAL( this, this, this );
break;
switch( aGalType )
{
case GAL_TYPE_OPENGL:
new_gal = new KIGFX::OPENGL_GAL( this, this, this );
break;
case GAL_TYPE_CAIRO:
m_gal = new KIGFX::CAIRO_GAL( this, this, this );
break;
case GAL_TYPE_CAIRO:
new_gal = new KIGFX::CAIRO_GAL( this, this, this );
break;
case GAL_TYPE_NONE:
return;
}
case GAL_TYPE_NONE:
return false;
}
wxSize size = GetClientSize();
m_gal->ResizeScreen( size.GetX(), size.GetY() );
delete m_gal;
m_gal = new_gal;
if( m_painter )
m_painter->SetGAL( m_gal );
wxSize size = GetClientSize();
m_gal->ResizeScreen( size.GetX(), size.GetY() );
if( m_view )
m_view->SetGAL( m_gal );
if( m_painter )
m_painter->SetGAL( m_gal );
if( m_view )
m_view->SetGAL( m_gal );
m_backend = aGalType;
}
catch (std::runtime_error& err)
{
DisplayError( m_parent, wxString( err.what() ) );
return false;
}
m_backend = aGalType;
return true;
}
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2013-2015 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
......@@ -24,13 +24,14 @@
/**
* @file opengl_compositor.cpp
* @brief Class that handles multitarget rendering (ie. to different textures/surfaces) and
* @brief Class that handles multitarget rendering (i.e. to different textures/surfaces) and
* later compositing into a single image (OpenGL flavour).
*/
#include <gal/opengl/opengl_compositor.h>
#include <wx/msgdlg.h>
#include <confirm.h>
#include <stdexcept>
#include <cassert>
using namespace KIGFX;
......@@ -89,7 +90,7 @@ void OPENGL_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
unsigned int OPENGL_COMPOSITOR::CreateBuffer()
{
wxASSERT( m_initialized );
assert( m_initialized );
unsigned int maxBuffers;
......@@ -98,10 +99,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
if( usedBuffers() >= maxBuffers )
{
DisplayError( NULL, wxT( "Cannot create more framebuffers. OpenGL rendering "
throw std::runtime_error("Cannot create more framebuffers. OpenGL rendering "
"backend requires at least 3 framebuffers. You may try to update/change "
"your graphic drivers." ) );
return 0; // Unfortunately we have no more free buffers left
"your graphic drivers.");
}
// GL_COLOR_ATTACHMENTn are consecutive integers
......@@ -133,38 +133,38 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
switch( status )
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
DisplayError( NULL,wxT( "Cannot create the framebuffer." ) );
throw std::runtime_error( "Cannot create the framebuffer." );
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
DisplayError( NULL, wxT( "The framebuffer attachment points are incomplete." ) );
throw std::runtime_error( "The framebuffer attachment points are incomplete." );
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
DisplayError( NULL, wxT( "The framebuffer does not have at least "
"one image attached to it." ) );
throw std::runtime_error( "The framebuffer does not have at least one "
"image attached to it." );
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
DisplayError( NULL, wxT( "The framebuffer read buffer is incomplete." ) );
throw std::runtime_error( "The framebuffer read buffer is incomplete." );
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
DisplayError( NULL, wxT( "The combination of internal formats of the attached images "
"violates an implementation-dependent set of restrictions." ) );
throw std::runtime_error( "The combination of internal formats of the attached "
"images violates an implementation-dependent set of restrictions." );
break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
DisplayError( NULL, wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
"for all attached renderbuffers" ) );
throw std::runtime_error( "GL_RENDERBUFFER_SAMPLES is not the same for "
"all attached renderbuffers" );
break;
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
DisplayError( NULL, wxT( "Framebuffer incomplete layer targets errors." ) );
throw std::runtime_error( "Framebuffer incomplete layer targets errors." );
break;
default:
DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
throw std::runtime_error( "Cannot create the framebuffer." );
break;
}
......@@ -211,7 +211,7 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
void OPENGL_COMPOSITOR::ClearBuffer()
{
wxASSERT( m_initialized );
assert( m_initialized );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
......@@ -220,8 +220,8 @@ void OPENGL_COMPOSITOR::ClearBuffer()
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
{
wxASSERT( m_initialized );
wxASSERT( aBufferHandle != 0 && aBufferHandle <= usedBuffers() );
assert( m_initialized );
assert( aBufferHandle != 0 && aBufferHandle <= usedBuffers() );
// Switch to the main framebuffer and blit the scene
glBindFramebufferEXT( GL_FRAMEBUFFER, DIRECT_RENDERING );
......@@ -267,7 +267,7 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
void OPENGL_COMPOSITOR::clean()
{
wxASSERT( m_initialized );
assert( m_initialized );
glBindFramebufferEXT( GL_FRAMEBUFFER, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;
......
......@@ -3,7 +3,7 @@
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2013 CERN
* Copyright (C) 2013-2015 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* Graphics Abstraction Layer (GAL) for OpenGL
......@@ -31,7 +31,6 @@
#include <wx/log.h>
#include <macros.h>
#include <confirm.h>
#ifdef __WXDEBUG__
#include <profile.h>
#endif /* __WXDEBUG__ */
......@@ -51,6 +50,9 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
wxEvtHandler* aPaintListener, const wxString& aName ) :
wxGLCanvas( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize,
wxEXPAND, aName ),
parentWindow( aParent ),
mouseListener( aMouseListener ),
paintListener( aPaintListener ),
cachedManager( true ),
nonCachedManager( false ),
overlayManager( false )
......@@ -59,14 +61,29 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
if( glContext == NULL )
glContext = new wxGLContext( this );
parentWindow = aParent;
mouseListener = aMouseListener;
paintListener = aPaintListener;
aParent->Show(); // wxWidgets require the window to be visible to set its GL context
// Initialize GLEW, FBOs & VBOs
SetCurrent( *glContext );
initGlew();
// Prepare shaders
if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) )
throw std::runtime_error( "Cannot compile vertex shader!" );
if( !shader.LoadBuiltinShader( 1, SHADER_TYPE_FRAGMENT ) )
throw std::runtime_error( "Cannot compile fragment shader!" );
if( !shader.Link() )
throw std::runtime_error( "Cannot link the shaders!" );
// Make VBOs use shaders
cachedManager.SetShader( shader );
nonCachedManager.SetShader( shader );
overlayManager.SetShader( shader );
// Initialize the flags
isGlewInitialized = false;
isFramebufferInitialized = false;
isShaderInitialized = false;
isGrouping = false;
groupCounter = 0;
......@@ -103,10 +120,7 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
InitTesselatorCallbacks( tesselator );
if( tesselator == NULL )
{
DisplayError( parentWindow, wxT( "Could not create the tesselator" ) );
exit( 1 );
}
throw std::runtime_error( "Could not create the tesselator" );
gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
......@@ -126,13 +140,8 @@ OPENGL_GAL::~OPENGL_GAL()
void OPENGL_GAL::BeginDrawing()
{
SetCurrent( *glContext );
clientDC = new wxClientDC( this );
// Initialize GLEW, FBOs & VBOs
if( !isGlewInitialized )
initGlew();
// Set up the view port
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
......@@ -151,35 +160,6 @@ void OPENGL_GAL::BeginDrawing()
isFramebufferInitialized = true;
}
// Compile the shaders
if( !isShaderInitialized )
{
if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) )
{
DisplayError( parentWindow, wxT( "Cannot compile vertex shader!" ) );
exit( 1 );
}
if( !shader.LoadBuiltinShader( 1, SHADER_TYPE_FRAGMENT ) )
{
DisplayError( parentWindow, wxT( "Cannot compile fragment shader!" ) );
exit( 1 );
}
if( !shader.Link() )
{
DisplayError( parentWindow, wxT( "Cannot link the shaders!" ) );
exit( 1 );
}
// Make VBOs use shaders
cachedManager.SetShader( shader );
nonCachedManager.SetShader( shader );
overlayManager.SetShader( shader );
isShaderInitialized = true;
}
// Disable 2D Textures
glDisable( GL_TEXTURE_2D );
......@@ -818,7 +798,7 @@ void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd
if( lineLength <= 0.0 )
return;
double scale = 0.5 * lineWidth / lineLength;
// The perpendicular vector also needs transformations
......@@ -944,8 +924,7 @@ void OPENGL_GAL::initGlew()
if( GLEW_OK != err )
{
DisplayError( parentWindow, wxString::FromUTF8( (char*) glewGetErrorString( err ) ) );
exit( 1 );
throw std::runtime_error( (const char*) glewGetErrorString( err ) );
}
else
{
......@@ -955,30 +934,17 @@ void OPENGL_GAL::initGlew()
// Check the OpenGL version (minimum 2.1 is required)
if( GLEW_VERSION_2_1 )
{
wxLogInfo( wxT( "OpenGL 2.1 supported." ) );
}
else
{
DisplayError( parentWindow, wxT( "OpenGL 2.1 or higher is required!" ) );
exit( 1 );
}
throw std::runtime_error( "OpenGL 2.1 or higher is required!" );
// Framebuffers have to be supported
if( !GLEW_EXT_framebuffer_object )
{
DisplayError( parentWindow, wxT( "Framebuffer objects are not supported!" ) );
exit( 1 );
}
throw std::runtime_error( "Framebuffer objects are not supported!" );
// Vertex buffer has to be supported
if( !GLEW_ARB_vertex_buffer_object )
{
DisplayError( parentWindow, wxT( "Vertex buffer objects are not supported!" ) );
exit( 1 );
}
isGlewInitialized = true;
throw std::runtime_error( "Vertex buffer objects are not supported!" );
}
......@@ -1061,12 +1027,8 @@ void CALLBACK EdgeCallback( GLboolean aEdgeFlag )
void CALLBACK ErrorCallback( GLenum aErrorCode )
{
const GLubyte* eString = gluErrorString( aErrorCode );
DisplayError( NULL, wxT( "Tessellation error: " ) +
wxString( (const char*)( eString ), wxConvUTF8 ) );
exit( 1 );
//throw std::runtime_error( std::string( "Tessellation error: " ) +
//std::string( (const char*) gluErrorString( aErrorCode ) );
}
......
......@@ -28,10 +28,10 @@
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <wx/log.h>
#include <wx/gdicmn.h>
#include <confirm.h>
#include <cstring>
#include <cassert>
#include <gal/opengl/shader.h>
#include "shader_src.h"
......@@ -102,8 +102,7 @@ bool SHADER::Link()
glGetObjectParameterivARB( programNumber, GL_OBJECT_LINK_STATUS_ARB,
(GLint*) &isShaderLinked );
#ifdef __WXDEBUG__
#ifdef DEBUG
if( !isShaderLinked )
{
int maxLength;
......@@ -115,8 +114,7 @@ bool SHADER::Link()
std::cerr << linkInfoLog;
delete[] linkInfoLog;
}
#endif /* __WXDEBUG__ */
#endif /* DEBUG */
return isShaderLinked;
}
......@@ -127,9 +125,7 @@ int SHADER::AddParameter( const std::string& aParameterName )
GLint location = glGetUniformLocation( programNumber, aParameterName.c_str() );
if( location != -1 )
{
parameterLocation.push_back( location );
}
return location;
}
......@@ -167,7 +163,7 @@ void SHADER::programInfo( GLuint aProgram )
GLchar* glInfoLog = new GLchar[glInfoLogLength];
glGetProgramInfoLog( aProgram, glInfoLogLength, &writtenChars, glInfoLog );
wxLogInfo( wxString::FromUTF8( (char*) glInfoLog ) );
std::cerr << glInfoLog << std::endl;
delete[] glInfoLog;
}
......@@ -188,7 +184,7 @@ void SHADER::shaderInfo( GLuint aShader )
GLchar* glInfoLog = new GLchar[glInfoLogLength];
glGetShaderInfoLog( aShader, glInfoLogLength, &writtenChars, glInfoLog );
wxLogInfo( wxString::FromUTF8( (char*) glInfoLog ) );
std::cerr << glInfoLog << std::endl;
delete[] glInfoLog;
}
......@@ -202,11 +198,7 @@ std::string SHADER::readSource( std::string aShaderSourceName )
std::string shaderSource;
if( !inputFile )
{
DisplayError( NULL, wxString::FromUTF8( "Can't read the shader source: " ) +
wxString( aShaderSourceName.c_str(), wxConvUTF8 ) );
exit( 1 );
}
throw std::runtime_error( "Can't read the shader source: " + aShaderSourceName );
std::string shaderSourceLine;
......@@ -223,10 +215,7 @@ std::string SHADER::readSource( std::string aShaderSourceName )
bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderType )
{
if( isShaderLinked )
{
wxLogDebug( wxT( "Shader is already linked!" ) );
}
assert( !isShaderLinked );
// Create the program
if( !isProgramCreated )
......@@ -244,7 +233,7 @@ bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderTyp
// Copy to char array
char* source = new char[aShaderSource.size() + 1];
strcpy( source, aShaderSource.c_str() );
strncpy( source, aShaderSource.c_str(), aShaderSource.size() + 1 );
const char** source_ = (const char**) ( &source );
// Attach the source
......@@ -261,11 +250,8 @@ bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderTyp
if( status != GL_TRUE )
{
DisplayError( NULL, wxT( "Shader compilation error" ) );
shaderInfo( shaderNumber );
return false;
throw std::runtime_error( "Shader compilation error" );
}
glAttachShader( programNumber, shaderNumber );
......
......@@ -222,22 +222,20 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
// Under Linux, every submenu can have a separate event handler, under
// Windows all submenus are handled by the main menu.
#ifdef __WINDOWS__
if( !evt ) {
if( !evt )
{
// Try to find the submenu which holds the selected item
wxMenu*menu = NULL;
wxMenu* menu = NULL;
FindItem( m_selected, &menu );
if( menu )
if( menu && menu != this )
{
menu->ProcessEvent( aEvent );
return;
}
assert( false ); // The event should be handled above
}
#else
#endif
evt = m_customHandler( aEvent );
#endif /* else __WINDOWS__ */
// Handling non-action menu entries (e.g. items in clarification list)
if( !evt )
......
......@@ -101,7 +101,7 @@ struct TOOL_MANAGER::TOOL_STATE
CONTEXT_MENU_TRIGGER contextMenuTrigger;
/// Tool execution context
COROUTINE<int, TOOL_EVENT&>* cofunc;
COROUTINE<int, const TOOL_EVENT&>* cofunc;
/// The event that triggered the execution/wakeup of the tool after Wait() call
TOOL_EVENT wakeupEvent;
......@@ -464,7 +464,7 @@ optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool,
}
void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
{
// iterate over all registered tools
BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
......@@ -512,7 +512,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
// as the state changes, the transition table has to be set up again
st->transitions.clear();
st->cofunc = new COROUTINE<int, TOOL_EVENT&>( tr.second );
st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( tr.second );
// got match? Run the handler.
st->cofunc->Call( aEvent );
......@@ -529,7 +529,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
}
bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::dispatchStandardEvents( const TOOL_EVENT& aEvent )
{
if( aEvent.Action() == TA_KEY_PRESSED )
{
......@@ -542,7 +542,7 @@ bool TOOL_MANAGER::dispatchStandardEvents( TOOL_EVENT& aEvent )
}
bool TOOL_MANAGER::dispatchActivation( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
{
if( aEvent.IsActivate() )
{
......@@ -559,7 +559,7 @@ bool TOOL_MANAGER::dispatchActivation( TOOL_EVENT& aEvent )
}
void TOOL_MANAGER::dispatchContextMenu( TOOL_EVENT& aEvent )
void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
{
BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
{
......@@ -614,7 +614,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
}
bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
{
// Early dispatch of events destined for the TOOL_MANAGER
if( !dispatchStandardEvents( aEvent ) )
......
......@@ -81,7 +81,16 @@ void DIALOG_CHOOSE_COMPONENT::OnSearchBoxChange( wxCommandEvent& aEvent )
{
m_search_container->UpdateSearchTerm( m_searchBox->GetLineText( 0 ) );
updateSelection();
// On Windows, but not on Linux, the focus is given to
// the m_libraryComponentTree, after modificatuons.
// We want the focus for m_searchBox.
//
// We cannot call SetFocus on Linux because it changes the current text selection
// and the text edit cursor position.
#ifdef __WINDOWS__
m_searchBox->SetFocus();
#endif
}
......
......@@ -66,7 +66,7 @@ public:
* Switches method of rendering graphics.
* @param aGalType is a type of rendering engine that you want to use.
*/
void SwitchBackend( GalType aGalType );
bool SwitchBackend( GalType aGalType );
/**
* Function GetBackend
......
......@@ -277,9 +277,7 @@ private:
SHADER shader; ///< There is only one shader used for different objects
// Internal flags
bool isGlewInitialized; ///< Is GLEW initialized?
bool isFramebufferInitialized; ///< Are the framebuffers initialized?
bool isShaderInitialized; ///< Was the shader initialized?
bool isGrouping; ///< Was a group started?
// Polygon tesselation
......
......@@ -51,7 +51,7 @@ enum TOOL_TYPE
/// Unique identifier for tools
typedef int TOOL_ID;
typedef DELEGATE<int, TOOL_EVENT&> TOOL_STATE_FUNC;
typedef DELEGATE<int, const TOOL_EVENT&> TOOL_STATE_FUNC;
/**
* Class TOOL_BASE
......
......@@ -70,7 +70,7 @@ public:
* No conditions means any event.
*/
template <class T>
void Go( int (T::* aStateFunc)( TOOL_EVENT& ),
void Go( int (T::* aStateFunc)( const TOOL_EVENT& ),
const TOOL_EVENT_LIST& aConditions = TOOL_EVENT( TC_ANY, TA_ANY ) );
/**
......@@ -110,7 +110,7 @@ private:
// hide TOOL_MANAGER implementation
template <class T>
void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( TOOL_EVENT& ),
void TOOL_INTERACTIVE::Go( int (T::* aStateFunc)( const TOOL_EVENT& ),
const TOOL_EVENT_LIST& aConditions )
{
TOOL_STATE_FUNC sptr( static_cast<T*>( this ), aStateFunc );
......
......@@ -169,7 +169,7 @@ public:
* Propagates an event to tools that requested events of matching type(s).
* @param aEvent is the event to be processed.
*/
bool ProcessEvent( TOOL_EVENT& aEvent );
bool ProcessEvent( const TOOL_EVENT& aEvent );
/**
* Puts an event to the event queue to be processed at the end of event processing cycle.
......@@ -309,7 +309,7 @@ private:
* Function dispatchInternal
* Passes an event at first to the active tools, then to all others.
*/
void dispatchInternal( TOOL_EVENT& aEvent );
void dispatchInternal( const TOOL_EVENT& aEvent );
/**
* Function dispatchStandardEvents()
......@@ -317,7 +317,7 @@ private:
* @param aEvent is the event to be processed.
* @return False if the event was processed and should not go any further.
*/
bool dispatchStandardEvents( TOOL_EVENT& aEvent );
bool dispatchStandardEvents( const TOOL_EVENT& aEvent );
/**
* Function dispatchActivation()
......@@ -325,13 +325,13 @@ private:
* @param aEvent is an event to be tested.
* @return True if a tool was invoked, false otherwise.
*/
bool dispatchActivation( TOOL_EVENT& aEvent );
bool dispatchActivation( const TOOL_EVENT& aEvent );
/**
* Function dispatchContextMenu()
* Handles context menu related events.
*/
void dispatchContextMenu( TOOL_EVENT& aEvent );
void dispatchContextMenu( const TOOL_EVENT& aEvent );
/**
* Function invokeTool()
......
......@@ -492,7 +492,14 @@ public:
{
wxASSERT( aLayer < (int) m_layers.size() );
return m_layers.at( aLayer ).target == TARGET_CACHED;
try
{
return m_layers.at( aLayer ).target == TARGET_CACHED;
}
catch( std::out_of_range )
{
return false;
}
}
/**
......
......@@ -848,12 +848,14 @@ public:
/**
* Function AppendBoardFile
* appends a board file onto the current one, creating God knows what.
* the main purpose is only to allow panelizing boards.
*/
bool AppendBoardFile( const wxString& aFullFileName, int aCtl );
/**
* Function SavePcbFile
* writes the board data structures to \a a aFileName
* Creates backup when requested and update flags (modified and saved flgs)
*
* @param aFileName The file name to write or wxEmptyString to prompt user for
* file name.
......@@ -864,8 +866,18 @@ public:
*/
bool SavePcbFile( const wxString& aFileName, bool aCreateBackupFile = CREATE_BACKUP_FILE );
int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( FILE* File );
/**
* Function SavePcbCopy
* writes the board data structures to \a a aFileName
* but unlike SavePcbFile, does not make anything else
* (no backup, borad fliename change, no flag changes ...)
* Used under a project mgr to save under a new name the current board
*
* When not under a project mgr, the full SavePcbFile is used.
* @param aFileName The file name to write.
* @return True if file was saved successfully.
*/
bool SavePcbCopy( const wxString& aFileName );
// BOARD handling
......
......@@ -314,6 +314,32 @@ bool BOARD::SetLayerDescr( LAYER_ID aIndex, const LAYER& aLayer )
return false;
}
#include <stdio.h>
const LAYER_ID BOARD::GetLayerID(wxString aLayerName) const
{
// Look for the BOARD specific copper layer names
for( LAYER_NUM layer = 0; layer < LAYER_ID_COUNT; ++layer )
{
if ( IsCopperLayer( layer ) &&
( m_Layer[ layer ].m_name == aLayerName) )
{
return ToLAYER_ID( layer );
}
}
// Otherwise fall back to the system standard layer names
for ( LAYER_NUM layer = 0; layer < LAYER_ID_COUNT; ++layer )
{
if ( GetStandardLayerName( ToLAYER_ID( layer ) ) == aLayerName )
{
return ToLAYER_ID( layer );
}
}
return UNDEFINED_LAYER;
}
const wxString BOARD::GetLayerName( LAYER_ID aLayer ) const
{
......@@ -331,7 +357,6 @@ const wxString BOARD::GetLayerName( LAYER_ID aLayer ) const
return GetStandardLayerName( aLayer );
}
bool BOARD::SetLayerName( LAYER_ID aLayer, const wxString& aLayerName )
{
if( !IsCopperLayer( aLayer ) )
......
......@@ -621,6 +621,18 @@ public:
*/
void ConvertBrdLayerToPolygonalContours( LAYER_ID aLayer, CPOLYGONS_LIST& aOutlines );
/**
* Function GetLayerID
* returns the ID of a layer given by aLayerName. Copper layers may
* have custom names.
*
* @param aLayerName = A layer name, like wxT("B.Cu"), etc.
*
* @return LAYER_ID - the layer id, which for copper layers may
* be custom, else standard.
*/
const LAYER_ID GetLayerID( wxString aLayerName ) const;
/**
* Function GetLayerName
* returns the name of a layer given by aLayer. Copper layers may
......
......@@ -82,6 +82,8 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
m_PcbTextSize = wxSize( DEFAULT_TEXT_PCB_SIZE,
DEFAULT_TEXT_PCB_SIZE ); // current Pcb (not module) Text size
m_useCustomTrackVia = false;
m_customTrackWidth = DMils2iu( 100 );
m_TrackMinWidth = DMils2iu( 100 ); // track min value for width (min copper size value)
m_ViasMinSize = DMils2iu( 350 ); // vias (not micro vias) min diameter
m_ViasMinDrill = DMils2iu( 200 ); // vias (not micro vias) min drill diameter
......
......@@ -800,14 +800,21 @@ EDA_ITEM* MODULE::Clone() const
void MODULE::RunOnChildren( boost::function<void (BOARD_ITEM*)> aFunction )
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
aFunction( static_cast<BOARD_ITEM*>( pad ) );
try
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
aFunction( static_cast<BOARD_ITEM*>( pad ) );
for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() )
aFunction( drawing );
for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() )
aFunction( drawing );
aFunction( static_cast<BOARD_ITEM*>( m_Reference ) );
aFunction( static_cast<BOARD_ITEM*>( m_Value ) );
aFunction( static_cast<BOARD_ITEM*>( m_Reference ) );
aFunction( static_cast<BOARD_ITEM*>( m_Value ) );
}
catch( boost::bad_function_call& e )
{
DisplayError( NULL, wxT( "Error running MODULE::RunOnChildren" ) );
}
}
......
......@@ -25,6 +25,8 @@
#include <collectors.h>
#include <pcbnew.h>
#include <tools/common_actions.h>
#include <pcb_draw_panel_gal.h>
/* Execute a remote command send by Eeschema via a socket,
* port KICAD_PCB_PORT_SERVICE_NUMBER
......@@ -127,8 +129,17 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( module ) // if found, center the module on screen, and redraw the screen.
{
SetCrossHairPosition( pos );
RedrawScreen( pos, false );
if( IsGalCanvasActive() )
{
GetGalCanvas()->GetView()->SetCenter( VECTOR2D( module->GetPosition() ) );
m_toolManager->RunAction( COMMON_ACTIONS::selectionClear, true );
m_toolManager->RunAction( COMMON_ACTIONS::selectItem, true, module );
}
else
{
SetCrossHairPosition( pos );
RedrawScreen( pos, false );
}
}
}
......
......@@ -27,6 +27,10 @@
DIALOG_ENUM_PADS::DIALOG_ENUM_PADS( wxWindow* aParent ) :
DIALOG_ENUM_PADS_BASE( aParent )
{
// Calling SetSizeHints after all widgets are built is mandatory
// to set the correct size of the dialog
GetSizer()->SetSizeHints( this );
Center();
}
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -9,43 +9,46 @@
///////////////////////////////////////////////////////////////////////////
DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bPrefixSizer;
bPrefixSizer = new wxBoxSizer( wxHORIZONTAL );
m_lblInfo = new wxStaticText( this, wxID_ANY, _("Pad names are restricted to 4 characters (including number)."), wxDefaultPosition, wxDefaultSize, 0 );
m_lblInfo->Wrap( -1 );
bMainSizer->Add( m_lblInfo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bMainSizer->Add( 0, 0, 0, wxTOP|wxBOTTOM, 5 );
wxFlexGridSizer* fgSizer;
fgSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer->AddGrowableCol( 1 );
fgSizer->SetFlexibleDirection( wxBOTH );
fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_lblPadPrefix = new wxStaticText( this, wxID_ANY, _("Pad name prefix:"), wxDefaultPosition, wxDefaultSize, 0 );
m_lblPadPrefix->Wrap( -1 );
bPrefixSizer->Add( m_lblPadPrefix, 1, wxALL, 5 );
fgSizer->Add( m_lblPadPrefix, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_padPrefix = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_padPrefix->SetMaxLength( 4 );
bPrefixSizer->Add( m_padPrefix, 0, wxALL, 5 );
bMainSizer->Add( bPrefixSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bPadNumSizer;
bPadNumSizer = new wxBoxSizer( wxHORIZONTAL );
fgSizer->Add( m_padPrefix, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_lblPadStartNum = new wxStaticText( this, wxID_ANY, _("First pad number:"), wxDefaultPosition, wxDefaultSize, 0 );
m_lblPadStartNum->Wrap( -1 );
bPadNumSizer->Add( m_lblPadStartNum, 1, wxALL, 5 );
fgSizer->Add( m_lblPadStartNum, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_padStartNum = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 999, 1 );
bPadNumSizer->Add( m_padStartNum, 0, wxALL, 5 );
fgSizer->Add( m_padStartNum, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( bPadNumSizer, 1, wxEXPAND, 5 );
bMainSizer->Add( fgSizer, 1, wxEXPAND|wxALL, 5 );
m_lblInfo = new wxStaticText( this, wxID_ANY, _("Pad names are restricted to 4 characters (including number)."), wxDefaultPosition, wxDefaultSize, 0 );
m_lblInfo->Wrap( 320 );
bMainSizer->Add( m_lblInfo, 0, wxALL, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_stdButtons = new wxStdDialogButtonSizer();
m_stdButtonsOK = new wxButton( this, wxID_OK );
......@@ -54,7 +57,7 @@ DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id, c
m_stdButtons->AddButton( m_stdButtonsCancel );
m_stdButtons->Realize();
bMainSizer->Add( m_stdButtons, 2, wxEXPAND, 5 );
bMainSizer->Add( m_stdButtons, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bMainSizer );
......
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
......@@ -18,8 +21,9 @@
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/spinctrl.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -29,23 +33,24 @@
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_ENUM_PADS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_ENUM_PADS_BASE : public wxDialog
class DIALOG_ENUM_PADS_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_lblInfo;
wxStaticText* m_lblPadPrefix;
wxTextCtrl* m_padPrefix;
wxStaticText* m_lblPadStartNum;
wxSpinCtrl* m_padStartNum;
wxStaticText* m_lblInfo;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_stdButtons;
wxButton* m_stdButtonsOK;
wxButton* m_stdButtonsCancel;
public:
DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pad enumeration settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,240 ), long style = wxDEFAULT_DIALOG_STYLE );
DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pad enumeration settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,187 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_ENUM_PADS_BASE();
};
......
......@@ -327,14 +327,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
break;
}
// Fall through
case ID_SAVE_BOARD_AS:
case ID_COPY_BOARD_AS:
case ID_SAVE_BOARD_AS:
{
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
wxFileName fn( pro_dir, _( "noname" ), KiCadPcbFileExtension );
wxString filename = fn.GetFullPath();
if( AskSaveBoardFileName( this, &filename ) )
SavePcbFile( filename, true );
{
if( id == ID_COPY_BOARD_AS )
SavePcbCopy( filename );
else
SavePcbFile( filename, NO_BACKUP_FILE );
}
}
break;
......@@ -412,7 +418,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( response == wxID_CANCEL )
return false;
else if( response == wxID_YES )
SavePcbFile( GetBoard()->GetFileName(), true );
SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE );
else
{
// response == wxID_NO, fall thru
......@@ -660,6 +666,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
wxString backupFileName;
// aCreateBackupFile == false is mainly used to write autosave files
// or new files in save as... command
if( aCreateBackupFile )
{
backupFileName = create_backup_file( aFileName );
......@@ -733,6 +741,58 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
}
bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName )
{
wxFileName pcbFileName = aFileName;
// Ensure the file ext is the right ext:
pcbFileName.SetExt( KiCadPcbFileExtension );
if( !IsWritable( pcbFileName ) )
{
wxString msg = wxString::Format( _(
"No access rights to write to file '%s'" ),
GetChars( pcbFileName.GetFullPath() )
);
DisplayError( this, msg );
return false;
}
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
GetBoard()->SynchronizeNetsAndNetClasses();
// Select default Netclass before writing file.
// Useful to save default values in headers
SetCurrentNetClass( NETCLASS::Default );
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD ) );
wxASSERT( pcbFileName.IsAbsolute() );
pi->Save( pcbFileName.GetFullPath(), GetBoard(), NULL );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"Error saving board file '%s'.\n%s" ),
GetChars( pcbFileName.GetFullPath() ),
GetChars( ioe.errorText )
);
DisplayError( this, msg );
return false;
}
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n'%s'" ),
GetChars( pcbFileName.GetFullPath() ) ) );
return true;
}
bool PCB_EDIT_FRAME::doAutoSave()
{
wxFileName tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
......
......@@ -110,8 +110,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
if( module )
{
// Add the object to board
module->SetParent( (EDA_ITEM*) GetBoard() );
GetBoard()->m_Modules.Append( module );
GetBoard()->Add( module, ADD_APPEND );
module->SetPosition( wxPoint( 0, 0 ) );
}
else
......
......@@ -111,14 +111,29 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Save current board" ),
KiBitmap( save_xpm ) );
if( Kiface().IsSingle() ) // not when under a project mgr
// Save as menu:
// under a project mgr we do not want to modify the board filename
// to keep consistency with the project mgr which expects files names same as prj name
// for main files
// when not under a project mgr, we are free to change filenames, cwd ...
if( Kiface().IsSingle() ) // not when under a project mgr (pcbnew is run as stand alone)
{
text = AddHotkeyName( _( "Sa&ve As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS );
AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, text,
_( "Save the current board as..." ),
KiBitmap( save_as_xpm ) );
filesMenu->AppendSeparator();
}
// under a project mgr, we can save a copy of the board,
// but do not change the current board file name
else
{
text = AddHotkeyName( _( "Sa&ve Copy As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS );
AddMenuItem( filesMenu, ID_COPY_BOARD_AS, text,
_( "Save a copy of the current board as..." ),
KiBitmap( save_as_xpm ) );
}
filesMenu->AppendSeparator();
AddMenuItem( filesMenu, ID_MENU_READ_BOARD_BACKUP_FILE,
_( "Revert to Last" ),
......
......@@ -120,8 +120,8 @@ BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode )
{
wxMenu itemMenu;
// Give a title to the selection menu. This is also a cancel menu item *
wxMenuItem* item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
// Give a title to the selection menu. It also allow to close the popup menu without any action
wxMenuItem* item_title = new wxMenuItem( &itemMenu, wxID_NONE, _( "Selection Clarification" ) );
#ifdef __WINDOWS__
wxFont bold_font( *wxNORMAL_FONT );
......@@ -195,7 +195,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
bool redraw = false;
INSTALL_UNBUFFERED_DC( dc, m_canvas );
......@@ -308,7 +307,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// module the defaults are used)
// This is mandatory to handle and draw pads
GetBoard()->BuildListOfNets();
redraw = true;
module->SetPosition( wxPoint( 0, 0 ) );
if( GetBoard()->m_Modules )
......@@ -317,8 +315,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Zoom_Automatique( false );
}
if( IsGalCanvasActive() )
updateView();
updateView();
m_canvas->Refresh();
GetScreen()->ClrModify();
}
......@@ -349,18 +347,18 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCrossHairPosition( wxPoint( 0, 0 ) );
// Add the new object to board
module->SetParent( (EDA_ITEM*)GetBoard() );
GetBoard()->m_Modules.Append( module );
GetBoard()->Add( module, ADD_APPEND );
// Initialize data relative to nets and netclasses (for a new
// module the defaults are used)
// This is mandatory to handle and draw pads
GetBoard()->BuildListOfNets();
redraw = true;
module->SetPosition( wxPoint( 0, 0 ) );
module->ClearFlags();
Zoom_Automatique( false );
updateView();
m_canvas->Refresh();
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
......@@ -492,13 +490,13 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCrossHairPosition( wxPoint( 0, 0 ) );
Import_Module();
redraw = true;
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->ClearFlags();
GetScreen()->ClrModify();
Zoom_Automatique( false );
m_canvas->Refresh();
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
......@@ -532,7 +530,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCrossHairPosition( wxPoint( 0, 0 ) );
LoadModuleFromLibrary( GetCurrentLib(), Prj().PcbFootprintLibs(), true );
redraw = true;
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->ClearFlags();
......@@ -564,7 +561,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_Draw3DFrame->NewDisplay();
GetScreen()->ClrModify();
updateView();
m_canvas->Refresh();
break;
......@@ -600,24 +599,22 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
m_canvas->MoveCursorToCrossHair();
Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), 900, true );
redraw = true;
m_canvas->Refresh();
break;
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
m_canvas->MoveCursorToCrossHair();
Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), -900, true );
redraw = true;
m_canvas->Refresh();
break;
case ID_POPUP_PCB_EDIT_MODULE_PRMS:
{
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
int ret = dialog.ShowModal();
dialog.ShowModal();
GetScreen()->GetCurItem()->ClearFlags();
m_canvas->MoveCursorToCrossHair();
if( ret > 0 )
m_canvas->Refresh();
m_canvas->Refresh();
}
break;
......@@ -696,6 +693,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_MODEDIT_ENTER_EDGE_WIDTH:
{
EDGE_MODULE* edge = NULL;
if( GetScreen()->GetCurItem()
&& ( GetScreen()->GetCurItem()->Type() == PCB_MODULE_EDGE_T ) )
{
......@@ -739,7 +737,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_MODULE_MIRROR:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Transform( (MODULE*) GetScreen()->GetCurItem(), id );
redraw = true;
m_canvas->Refresh();
break;
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
......@@ -811,9 +809,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
break;
}
if( redraw )
m_canvas->Refresh();
}
......
......@@ -161,9 +161,10 @@ void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
// Add the new pad to end of the module pad list.
aModule->Pads().PushBack( pad );
// Update the pad properties.
// Update the pad properties,
// and keep NETINFO_LIST::ORPHANED as net info
// which is the default when nets cannot be handled.
Import_Pad_Settings( pad, false );
pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
pad->SetPosition( GetCrossHairPosition() );
......
......@@ -120,6 +120,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_APPEND_FILE, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_SAVE_BOARD_AS, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_COPY_BOARD_AS, PCB_EDIT_FRAME::Files_io )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, PCB_EDIT_FRAME::OnFileHistory )
EVT_MENU( ID_GEN_PLOT, PCB_EDIT_FRAME::ToPlotter )
......@@ -693,24 +694,26 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
bool use_gal = false;
switch( id )
{
case ID_MENU_CANVAS_DEFAULT:
Compile_Ratsnest( NULL, true );
UseGalCanvas( false );
break;
case ID_MENU_CANVAS_CAIRO:
GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
UseGalCanvas( true );
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
break;
case ID_MENU_CANVAS_OPENGL:
GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
UseGalCanvas( true );
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
break;
}
if( !use_gal )
Compile_Ratsnest( NULL, true );
UseGalCanvas( use_gal );
}
......
......@@ -3,7 +3,7 @@
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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
* modify it under the terms of the GNU General Public License
......@@ -109,57 +109,46 @@ static struct IFACE : public KIFACE_I
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 )
{
wxWindow* frame = NULL;
switch( aClassId )
{
case FRAME_PCB:
{
PCB_EDIT_FRAME* frame = new PCB_EDIT_FRAME( aKiway, aParent );
frame = dynamic_cast< wxWindow* >( new PCB_EDIT_FRAME( aKiway, aParent ) );
#if defined(KICAD_SCRIPTING)
// give the scripting helpers access to our frame
ScriptingSetPcbEditFrame( frame );
#if defined( KICAD_SCRIPTING )
// give the scripting helpers access to our frame
ScriptingSetPcbEditFrame( (PCB_EDIT_FRAME*) frame );
#endif
if( Kiface().IsSingle() )
{
// only run this under single_top, not under a project manager.
CreateServer( frame, KICAD_PCB_PORT_SERVICE_NUMBER );
}
return frame;
if( Kiface().IsSingle() )
{
// only run this under single_top, not under a project manager.
CreateServer( frame, KICAD_PCB_PORT_SERVICE_NUMBER );
}
break;
case FRAME_PCB_MODULE_EDITOR:
{
FOOTPRINT_EDIT_FRAME* frame = new FOOTPRINT_EDIT_FRAME( aKiway, aParent );
return frame;
}
frame = dynamic_cast< wxWindow* >( new FOOTPRINT_EDIT_FRAME( aKiway, aParent ) );
break;
case FRAME_PCB_MODULE_VIEWER:
case FRAME_PCB_MODULE_VIEWER_MODAL:
{
FOOTPRINT_VIEWER_FRAME* frame = new FOOTPRINT_VIEWER_FRAME(
aKiway, aParent, FRAME_T( aClassId ) );
return frame;
}
frame = dynamic_cast< wxWindow* >( new FOOTPRINT_VIEWER_FRAME( aKiway, aParent,
FRAME_T( aClassId ) ) );
break;
case FRAME_PCB_FOOTPRINT_WIZARD_MODAL:
{
FOOTPRINT_WIZARD_FRAME* frame = new FOOTPRINT_WIZARD_FRAME(
aKiway, aParent, FRAME_T( aClassId ) );
return frame;
}
frame = dynamic_cast< wxWindow* >( new FOOTPRINT_WIZARD_FRAME( aKiway, aParent,
FRAME_T( aClassId ) ) );
break;
default:
;
}
return NULL;
return frame;
}
/**
......@@ -193,13 +182,13 @@ KIFACE_I& Kiface() { return kiface; }
// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
#if defined(BUILD_KIWAY_DLL)
#if defined( BUILD_KIWAY_DLL )
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
......@@ -208,7 +197,7 @@ PGM_BASE& Pgm()
#endif
#if defined(KICAD_SCRIPTING)
#if defined( KICAD_SCRIPTING )
static bool scriptingSetup()
{
wxString path_frag;
......@@ -218,7 +207,7 @@ static bool scriptingSetup()
const wxString python_us( "python27_us" );
// Build our python path inside kicad
wxString kipython = FindKicadFile( python_us + wxT("/python.exe") );
wxString kipython = FindKicadFile( python_us + wxT( "/python.exe" ) );
//we need only the path:
wxFileName fn( kipython );
......@@ -231,19 +220,20 @@ static bool scriptingSetup()
if( !wxGetEnv( wxT( "PYTHONPATH" ), &ppath ) || !ppath.Contains( python_us ) )
{
ppath << kipython << wxT("/pylib;");
ppath << kipython << wxT("/lib;");
ppath << kipython << wxT("/dll");
ppath << kipython << wxT( "/pylib;" );
ppath << kipython << wxT( "/lib;" );
ppath << kipython << wxT( "/dll" );
wxSetEnv( wxT( "PYTHONPATH" ), ppath );
DBG( std::cout << "set PYTHONPATH to " << TO_UTF8(ppath) << "\n"; )
// DBG( std::cout << "set PYTHONPATH to " << TO_UTF8( ppath ) << "\n"; )
// Add python executable path:
wxGetEnv( wxT( "PATH" ), &ppath );
if( !ppath.Contains( python_us ) )
{
kipython << wxT(";") << ppath;
kipython << wxT( ";" ) << ppath;
wxSetEnv( wxT( "PATH" ), kipython );
DBG( std::cout << "set PATH to " << TO_UTF8(kipython) << "\n"; )
// DBG( std::cout << "set PATH to " << TO_UTF8( kipython ) << "\n"; )
}
}
}
......@@ -263,14 +253,20 @@ static bool scriptingSetup()
// Add default paths to PYTHONPATH
wxString pypath;
// User scripting folder (~/Library/Application Support/kicad/scripting/plugins)
pypath = GetOSXKicadUserDataDir() + wxT( "/scripting/plugins" );
// Machine scripting folder (/Library/Application Support/kicad/scripting/plugins)
pypath += wxT( ":" ) + GetOSXKicadMachineDataDir() + wxT( "/scripting/plugins" );
// Bundle scripting folder (<kicad.app>/Contents/SharedSupport/scripting/plugins)
pypath += wxT( ":" ) + GetOSXKicadDataDir() + wxT( "/scripting/plugins" );
// Bundle wxPython folder (<kicad.app>/Contents/Frameworks/python/site-packages)
pypath += wxT( ":" ) + Pgm().GetExecutablePath() + wxT( "Contents/Frameworks/python/site-packages" );
pypath += wxT( ":" ) + Pgm().GetExecutablePath() +
wxT( "Contents/Frameworks/python/site-packages" );
// Original content of $PYTHONPATH
if( wxGetenv("PYTHONPATH") != NULL )
{
......@@ -289,6 +285,7 @@ static bool scriptingSetup()
wxLogSysError( wxT( "pcbnewInitPythonScripting() failed." ) );
return false;
}
return true;
}
#endif // KICAD_SCRIPTING
......
......@@ -21,6 +21,7 @@ enum pcbnew_ids
ID_OPEN_MODULE_VIEWER,
ID_READ_NETLIST,
ID_SET_RELATIVE_OFFSET,
ID_COPY_BOARD_AS,
// Right vertical tool bar command IDs.
ID_PCB_HIGHLIGHT_BUTT,
......
......@@ -725,7 +725,7 @@ void ROUTER_TOOL::performRouting()
}
int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
int ROUTER_TOOL::Main( const TOOL_EVENT& aEvent )
{
VIEW_CONTROLS* ctls = getViewControls();
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
......
......@@ -41,7 +41,7 @@ public:
~ROUTER_TOOL();
void Reset( RESET_REASON aReason );
int Main( TOOL_EVENT& aEvent );
int Main( const TOOL_EVENT& aEvent );
private:
PNS_ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1 );
......
......@@ -52,7 +52,8 @@
#include <class_module.h>
DRAWING_TOOL::DRAWING_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveDrawing" ), m_editModules( false )
TOOL_INTERACTIVE( "pcbnew.InteractiveDrawing" ), m_view( NULL ),
m_controls( NULL ), m_board( NULL ), m_frame( NULL ), m_editModules( false ), m_lineWidth( 1 )
{
}
......@@ -74,7 +75,7 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
}
int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
{
boost::optional<VECTOR2D> startingPoint;
......@@ -135,7 +136,7 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
{
if( m_editModules )
{
......@@ -184,7 +185,7 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
{
if( m_editModules )
{
......@@ -233,7 +234,7 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::PlaceText( TOOL_EVENT& aEvent )
int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
{
if( m_editModules )
return placeTextModule();
......@@ -242,7 +243,7 @@ int DRAWING_TOOL::PlaceText( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
{
DIMENSION* dimension = NULL;
int width, maxThickness;
......@@ -421,7 +422,7 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::DrawZone( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
......@@ -429,7 +430,7 @@ int DRAWING_TOOL::DrawZone( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::DrawKeepout( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawKeepout( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
......@@ -437,7 +438,7 @@ int DRAWING_TOOL::DrawKeepout( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
int DRAWING_TOOL::PlaceTarget( const TOOL_EVENT& aEvent )
{
PCB_TARGET* target = new PCB_TARGET( m_board );
......@@ -525,7 +526,7 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent )
int DRAWING_TOOL::PlaceModule( const TOOL_EVENT& aEvent )
{
MODULE* module = NULL;
......@@ -635,7 +636,7 @@ int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::PlaceDXF( TOOL_EVENT& aEvent )
int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
{
DIALOG_DXF_IMPORT dlg( m_frame );
int dlgResult = dlg.ShowModal();
......@@ -825,7 +826,7 @@ int DRAWING_TOOL::PlaceDXF( TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::SetAnchor( TOOL_EVENT& aEvent )
int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
{
assert( m_editModules );
......@@ -901,7 +902,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
// Init the new item attributes
aGraphic->SetShape( (STROKE_T) aShape );
aGraphic->SetWidth( lineWidth );
aGraphic->SetWidth( m_lineWidth );
aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
aGraphic->SetLayer( layer );
......@@ -963,8 +964,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
{
// Init the new item attributes
aGraphic->SetShape( (STROKE_T) aShape );
lineWidth = getSegmentWidth( layer );
aGraphic->SetWidth( lineWidth );
m_lineWidth = getSegmentWidth( layer );
aGraphic->SetWidth( m_lineWidth );
aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
aGraphic->SetLayer( layer );
......@@ -1012,17 +1013,17 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) )
{
lineWidth += WIDTH_STEP;
aGraphic->SetWidth( lineWidth );
m_lineWidth += WIDTH_STEP;
aGraphic->SetWidth( m_lineWidth );
updatePreview = true;
}
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) )
{
if( lineWidth > (unsigned) WIDTH_STEP )
if( m_lineWidth > (unsigned) WIDTH_STEP )
{
lineWidth -= WIDTH_STEP;
aGraphic->SetWidth( lineWidth );
m_lineWidth -= WIDTH_STEP;
aGraphic->SetWidth( m_lineWidth );
updatePreview = true;
}
}
......
......@@ -58,7 +58,7 @@ public:
* to click at least two times to determine the origin and the end for a line. If there are
* more clicks, the line is drawn as a continous polyline.
*/
int DrawLine( TOOL_EVENT& aEvent );
int DrawLine( const TOOL_EVENT& aEvent );
/**
* Function DrawCircle()
......@@ -66,7 +66,7 @@ public:
* to first click on a point that is going to be used as the center of the circle. The second
* click determines the circle radius.
*/
int DrawCircle( TOOL_EVENT& aEvent );
int DrawCircle( const TOOL_EVENT& aEvent );
/**
* Function DrawArc()
......@@ -74,14 +74,14 @@ public:
* to first click on a point that is going to be used as the center of the arc. The second
* click determines the origin and radius, the third one - the angle.
*/
int DrawArc( TOOL_EVENT& aEvent );
int DrawArc( const TOOL_EVENT& aEvent );
/**
* Function PlaceText()
* Displays a dialog that allows to input text and its settings and then lets the user decide
* where to place the text in editor.
*/
int PlaceText( TOOL_EVENT& aEvent );
int PlaceText( const TOOL_EVENT& aEvent );
/**
* Function DrawDimension()
......@@ -89,7 +89,7 @@ public:
* to first click on a point that is going to be used as the origin of the dimension.
* The second click determines the end and the third click modifies its height.
*/
int DrawDimension( TOOL_EVENT& aEvent );
int DrawDimension( const TOOL_EVENT& aEvent );
/**
* Function DrawZone()
......@@ -98,7 +98,7 @@ public:
* as a boundary polygon of the zone. Double click or clicking on the origin of the boundary
* polyline finishes the drawing.
*/
int DrawZone( TOOL_EVENT& aEvent );
int DrawZone( const TOOL_EVENT& aEvent );
/**
* Function DrawKeepout()
......@@ -107,31 +107,31 @@ public:
* be used as a boundary polygon of the area. Double click or clicking on the origin of the
* boundary polyline finishes the drawing.
*/
int DrawKeepout( TOOL_EVENT& aEvent );
int DrawKeepout( const TOOL_EVENT& aEvent );
/**
* Function PlaceTarget()
* Allows user to place a layer alignment target.
*/
int PlaceTarget( TOOL_EVENT& aEvent );
int PlaceTarget( const TOOL_EVENT& aEvent );
/**
* Function PlaceModule()
* Displays a dialog to select a module to be added and allows the user to set its position.
*/
int PlaceModule( TOOL_EVENT& aEvent );
int PlaceModule( const TOOL_EVENT& aEvent );
/**
* Function PlaceDXF()
* Places a drawing imported from a DXF file in module editor.
*/
int PlaceDXF( TOOL_EVENT& aEvent );
int PlaceDXF( const TOOL_EVENT& aEvent );
/**
* Function SetAnchor()
* Places the footprint anchor (only in module editor).
*/
int SetAnchor( TOOL_EVENT& aEvent );
int SetAnchor( const TOOL_EVENT& aEvent );
/**
* Function EditModules()
......@@ -203,7 +203,7 @@ private:
bool m_editModules;
/// Stores the current line width for multisegment drawing.
unsigned int lineWidth;
unsigned int m_lineWidth;
// How does line width change after one -/+ key press.
static const int WIDTH_STEP = 100000;
......
......@@ -43,7 +43,8 @@
#include "edit_tool.h"
EDIT_TOOL::EDIT_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ), m_editModules( false )
TOOL_INTERACTIVE( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
m_dragging( false ), m_editModules( false ), m_updateFlag( KIGFX::VIEW_ITEM::NONE )
{
}
......@@ -51,6 +52,7 @@ EDIT_TOOL::EDIT_TOOL() :
void EDIT_TOOL::Reset( RESET_REASON aReason )
{
m_dragging = false;
m_updateFlag = KIGFX::VIEW_ITEM::NONE;
}
......@@ -81,7 +83,7 @@ bool EDIT_TOOL::Init()
}
int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -238,7 +240,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
}
int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
......@@ -307,7 +309,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
}
int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
......@@ -361,7 +363,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
}
int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
......@@ -415,7 +417,7 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
}
int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......
......@@ -61,35 +61,35 @@ public:
* Main loop in which events are handled.
* @param aEvent is the handled event.
*/
int Main( TOOL_EVENT& aEvent );
int Main( const TOOL_EVENT& aEvent );
/**
* Function Edit()
*
* Displays properties window for the selected object.
*/
int Properties( TOOL_EVENT& aEvent );
int Properties( const TOOL_EVENT& aEvent );
/**
* Function Rotate()
*
* Rotates currently selected items.
*/
int Rotate( TOOL_EVENT& aEvent );
int Rotate( const TOOL_EVENT& aEvent );
/**
* Function Flip()
*
* Rotates currently selected items. The rotation point is the current cursor position.
*/
int Flip( TOOL_EVENT& aEvent );
int Flip( const TOOL_EVENT& aEvent );
/**
* Function Remove()
*
* Deletes currently selected items. The rotation point is the current cursor position.
*/
int Remove( TOOL_EVENT& aEvent );
int Remove( const TOOL_EVENT& aEvent );
/**
* Function EditModules()
......
......@@ -47,7 +47,8 @@
#include <wx/defs.h>
MODULE_TOOLS::MODULE_TOOLS() :
TOOL_INTERACTIVE( "pcbnew.ModuleEditor" )
TOOL_INTERACTIVE( "pcbnew.ModuleEditor" ), m_view( NULL ), m_controls( NULL ),
m_board( NULL ), m_frame( NULL )
{
}
......@@ -119,7 +120,7 @@ static wxString getNextPadName( MODULE* aModule )
}
int MODULE_TOOLS::PlacePad( TOOL_EVENT& aEvent )
int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
......@@ -222,7 +223,7 @@ int MODULE_TOOLS::PlacePad( TOOL_EVENT& aEvent )
}
int MODULE_TOOLS::EnumeratePads( TOOL_EVENT& aEvent )
int MODULE_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
{
std::list<D_PAD*> pads;
std::set<D_PAD*> allPads;
......@@ -329,7 +330,7 @@ int MODULE_TOOLS::EnumeratePads( TOOL_EVENT& aEvent )
}
int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
int MODULE_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
......@@ -401,7 +402,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
}
int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
{
// Parse clipboard
PCB_IO io( CTL_FOR_CLIPBOARD );
......@@ -533,7 +534,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
}
int MODULE_TOOLS::ModuleTextOutlines( TOOL_EVENT& aEvent )
int MODULE_TOOLS::ModuleTextOutlines( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -570,7 +571,7 @@ int MODULE_TOOLS::ModuleTextOutlines( TOOL_EVENT& aEvent )
}
int MODULE_TOOLS::ModuleEdgeOutlines( TOOL_EVENT& aEvent )
int MODULE_TOOLS::ModuleEdgeOutlines( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......
......@@ -55,41 +55,41 @@ public:
* Function PlacePad()
* Places a pad in module editor.
*/
int PlacePad( TOOL_EVENT& aEvent );
int PlacePad( const TOOL_EVENT& aEvent );
/**
* Function EnumeratePads()
* Tool for quick pad enumeration.
*/
int EnumeratePads( TOOL_EVENT& aEvent );
int EnumeratePads( const TOOL_EVENT& aEvent );
/**
* Function CopyItems()
*
* Copies selected items to the clipboard. Works only in "edit modules" mode.
*/
int CopyItems( TOOL_EVENT& aEvent );
int CopyItems( const TOOL_EVENT& aEvent );
/**
* Function PastePad()
*
* Pastes items from the clipboard. Works only in "edit modules" mode.
*/
int PasteItems( TOOL_EVENT& aEvent );
int PasteItems( const TOOL_EVENT& aEvent );
/**
* Function ModuleTextOutlines()
*
* Toggles display mode for module texts (outline/filled).
*/
int ModuleTextOutlines( TOOL_EVENT& aEvent );
int ModuleTextOutlines( const TOOL_EVENT& aEvent );
/**
* Function ModuleEdgeOutlines()
*
* Toggles display mode for module edges (outline/filled).
*/
int ModuleEdgeOutlines( TOOL_EVENT& aEvent );
int ModuleEdgeOutlines( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
......
......@@ -47,7 +47,7 @@ public:
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.EditorControl" )
TOOL_INTERACTIVE( "pcbnew.EditorControl" ), m_frame( NULL )
{
}
......@@ -75,7 +75,7 @@ bool PCB_EDITOR_CONTROL::Init()
// Track & via size control
int PCB_EDITOR_CONTROL::TrackWidthInc( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
......@@ -96,7 +96,7 @@ int PCB_EDITOR_CONTROL::TrackWidthInc( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::TrackWidthDec( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
......@@ -117,7 +117,7 @@ int PCB_EDITOR_CONTROL::TrackWidthDec( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ViaSizeInc( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
......@@ -138,7 +138,7 @@ int PCB_EDITOR_CONTROL::ViaSizeInc( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
......@@ -160,7 +160,7 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent )
// Zone actions
int PCB_EDITOR_CONTROL::ZoneFill( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ZoneFill( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
......@@ -181,7 +181,7 @@ int PCB_EDITOR_CONTROL::ZoneFill( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ZoneFillAll( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ZoneFillAll( const TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
......@@ -199,7 +199,7 @@ int PCB_EDITOR_CONTROL::ZoneFillAll( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ZoneUnfill( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ZoneUnfill( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
......@@ -220,7 +220,7 @@ int PCB_EDITOR_CONTROL::ZoneUnfill( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ZoneUnfillAll( TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
......@@ -238,6 +238,20 @@ int PCB_EDITOR_CONTROL::ZoneUnfillAll( TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
if( selection.Size() == 1 )
m_frame->SendMessageToEESCHEMA( selection.Item<BOARD_ITEM>( 0 ) );
setTransitions();
return 0;
}
void PCB_EDITOR_CONTROL::setTransitions()
{
// Track & via size control
......@@ -251,4 +265,6 @@ void PCB_EDITOR_CONTROL::setTransitions()
Go( &PCB_EDITOR_CONTROL::ZoneFillAll, COMMON_ACTIONS::zoneFillAll.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ZoneUnfill, COMMON_ACTIONS::zoneUnfill.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ZoneUnfillAll, COMMON_ACTIONS::zoneUnfillAll.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::SelectionCrossProbe, SELECTION_TOOL::SelectedEvent );
}
......@@ -46,16 +46,19 @@ public:
bool Init();
// Track & via size control
int TrackWidthInc( TOOL_EVENT& aEvent );
int TrackWidthDec( TOOL_EVENT& aEvent );
int ViaSizeInc( TOOL_EVENT& aEvent );
int ViaSizeDec( TOOL_EVENT& aEvent );
int TrackWidthInc( const TOOL_EVENT& aEvent );
int TrackWidthDec( const TOOL_EVENT& aEvent );
int ViaSizeInc( const TOOL_EVENT& aEvent );
int ViaSizeDec( const TOOL_EVENT& aEvent );
// Zone actions
int ZoneFill( TOOL_EVENT& aEvent );
int ZoneFillAll( TOOL_EVENT& aEvent );
int ZoneUnfill( TOOL_EVENT& aEvent );
int ZoneUnfillAll( TOOL_EVENT& aEvent );
int ZoneFill( const TOOL_EVENT& aEvent );
int ZoneFillAll( const TOOL_EVENT& aEvent );
int ZoneUnfill( const TOOL_EVENT& aEvent );
int ZoneUnfillAll( const TOOL_EVENT& aEvent );
///> Notifies eeschema about the selected item.
int SelectionCrossProbe( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
......
......@@ -41,7 +41,7 @@
PCBNEW_CONTROL::PCBNEW_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.Control" )
TOOL_INTERACTIVE( "pcbnew.Control" ), m_frame( NULL )
{
}
......@@ -60,7 +60,7 @@ bool PCBNEW_CONTROL::Init()
}
int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoomInOut( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
double zoomScale = 1.0;
......@@ -77,7 +77,7 @@ int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ZoomInOutCenter( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoomInOutCenter( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
double zoomScale = 1.0;
......@@ -94,7 +94,7 @@ int PCBNEW_CONTROL::ZoomInOutCenter( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoomCenter( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
view->SetCenter( getViewControls()->GetCursorPosition() );
......@@ -104,7 +104,7 @@ int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
......@@ -140,7 +140,7 @@ int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -165,7 +165,7 @@ int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -190,7 +190,7 @@ int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -215,7 +215,7 @@ int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ZoneDisplayMode( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -246,7 +246,7 @@ int PCBNEW_CONTROL::ZoneDisplayMode( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::HighContrastMode( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -264,7 +264,7 @@ int PCBNEW_CONTROL::HighContrastMode( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::HighContrastInc( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::HighContrastInc( const TOOL_EVENT& aEvent )
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
setTransitions();
......@@ -273,7 +273,7 @@ int PCBNEW_CONTROL::HighContrastInc( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::HighContrastDec( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::HighContrastDec( const TOOL_EVENT& aEvent )
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
setTransitions();
......@@ -283,7 +283,7 @@ int PCBNEW_CONTROL::HighContrastDec( TOOL_EVENT& aEvent )
// Layer control
int PCBNEW_CONTROL::LayerSwitch( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent )
{
if( aEvent.IsAction( &COMMON_ACTIONS::layerTop ) )
m_frame->SwitchLayer( NULL, F_Cu );
......@@ -308,7 +308,7 @@ int PCBNEW_CONTROL::LayerSwitch( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::LayerNext( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
{
PCB_BASE_FRAME* editFrame = m_frame;
LAYER_NUM layer = editFrame->GetActiveLayer();
......@@ -336,7 +336,7 @@ int PCBNEW_CONTROL::LayerNext( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
{
PCB_BASE_FRAME* editFrame = m_frame;
LAYER_NUM layer = editFrame->GetActiveLayer();
......@@ -364,7 +364,7 @@ int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -387,7 +387,7 @@ int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::LayerAlphaDec( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
......@@ -411,7 +411,7 @@ int PCBNEW_CONTROL::LayerAlphaDec( TOOL_EVENT& aEvent )
// Grid control
int PCBNEW_CONTROL::GridFast1( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent )
{
m_frame->SetFastGrid1();
setTransitions();
......@@ -420,7 +420,7 @@ int PCBNEW_CONTROL::GridFast1( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::GridFast2( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridFast2( const TOOL_EVENT& aEvent )
{
m_frame->SetFastGrid2();
setTransitions();
......@@ -429,7 +429,7 @@ int PCBNEW_CONTROL::GridFast2( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::GridNext( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridNext( const TOOL_EVENT& aEvent )
{
m_frame->SetNextGrid();
setTransitions();
......@@ -438,7 +438,7 @@ int PCBNEW_CONTROL::GridNext( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::GridPrev( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridPrev( const TOOL_EVENT& aEvent )
{
m_frame->SetPrevGrid();
setTransitions();
......@@ -447,7 +447,7 @@ int PCBNEW_CONTROL::GridPrev( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::GridSetOrigin( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
{
Activate();
m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL,
......@@ -481,7 +481,7 @@ int PCBNEW_CONTROL::GridSetOrigin( TOOL_EVENT& aEvent )
// Miscellaneous
int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
......@@ -493,7 +493,7 @@ int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::SwitchCursor( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
{
const unsigned int BIG_CURSOR = 4000;
const unsigned int SMALL_CURSOR = 80;
......@@ -511,7 +511,7 @@ int PCBNEW_CONTROL::SwitchCursor( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
{
// TODO should not it be refactored to pcb_frame member function?
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
......@@ -528,7 +528,7 @@ int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
{
// TODO
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
......@@ -538,7 +538,7 @@ int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ToBeDone( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
{
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
setTransitions();
......
......@@ -47,40 +47,40 @@ public:
bool Init();
// View controls
int ZoomInOut( TOOL_EVENT& aEvent );
int ZoomInOutCenter( TOOL_EVENT& aEvent );
int ZoomCenter( TOOL_EVENT& aEvent );
int ZoomFitScreen( TOOL_EVENT& aEvent );
int ZoomInOut( const TOOL_EVENT& aEvent );
int ZoomInOutCenter( const TOOL_EVENT& aEvent );
int ZoomCenter( const TOOL_EVENT& aEvent );
int ZoomFitScreen( const TOOL_EVENT& aEvent );
// Display modes
int TrackDisplayMode( TOOL_EVENT& aEvent );
int PadDisplayMode( TOOL_EVENT& aEvent );
int ViaDisplayMode( TOOL_EVENT& aEvent );
int ZoneDisplayMode( TOOL_EVENT& aEvent );
int HighContrastMode( TOOL_EVENT& aEvent );
int HighContrastInc( TOOL_EVENT& aEvent );
int HighContrastDec( TOOL_EVENT& aEvent );
int TrackDisplayMode( const TOOL_EVENT& aEvent );
int PadDisplayMode( const TOOL_EVENT& aEvent );
int ViaDisplayMode( const TOOL_EVENT& aEvent );
int ZoneDisplayMode( const TOOL_EVENT& aEvent );
int HighContrastMode( const TOOL_EVENT& aEvent );
int HighContrastInc( const TOOL_EVENT& aEvent );
int HighContrastDec( const TOOL_EVENT& aEvent );
// Layer control
int LayerSwitch( TOOL_EVENT& aEvent );
int LayerNext( TOOL_EVENT& aEvent );
int LayerPrev( TOOL_EVENT& aEvent );
int LayerAlphaInc( TOOL_EVENT& aEvent );
int LayerAlphaDec( TOOL_EVENT& aEvent );
int LayerSwitch( const TOOL_EVENT& aEvent );
int LayerNext( const TOOL_EVENT& aEvent );
int LayerPrev( const TOOL_EVENT& aEvent );
int LayerAlphaInc( const TOOL_EVENT& aEvent );
int LayerAlphaDec( const TOOL_EVENT& aEvent );
// Grid control
int GridFast1( TOOL_EVENT& aEvent );
int GridFast2( TOOL_EVENT& aEvent );
int GridNext( TOOL_EVENT& aEvent );
int GridPrev( TOOL_EVENT& aEvent );
int GridSetOrigin( TOOL_EVENT& aEvent );
int GridFast1( const TOOL_EVENT& aEvent );
int GridFast2( const TOOL_EVENT& aEvent );
int GridNext( const TOOL_EVENT& aEvent );
int GridPrev( const TOOL_EVENT& aEvent );
int GridSetOrigin( const TOOL_EVENT& aEvent );
// Miscellaneous
int ResetCoords( TOOL_EVENT& aEvent );
int SwitchCursor( TOOL_EVENT& aEvent );
int SwitchUnits( TOOL_EVENT& aEvent );
int ShowHelp( TOOL_EVENT& aEvent );
int ToBeDone( TOOL_EVENT& aEvent );
int ResetCoords( const TOOL_EVENT& aEvent );
int SwitchCursor( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent );
int ShowHelp( const TOOL_EVENT& aEvent );
int ToBeDone( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
......
......@@ -34,7 +34,7 @@
#include <boost/foreach.hpp>
PLACEMENT_TOOL::PLACEMENT_TOOL() :
TOOL_INTERACTIVE( "pcbnew.Placement" )
TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL )
{
}
......@@ -72,7 +72,7 @@ bool PLACEMENT_TOOL::Init()
}
int PLACEMENT_TOOL::AlignTop( TOOL_EVENT& aEvent )
int PLACEMENT_TOOL::AlignTop( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -115,7 +115,7 @@ int PLACEMENT_TOOL::AlignTop( TOOL_EVENT& aEvent )
}
int PLACEMENT_TOOL::AlignBottom( TOOL_EVENT& aEvent )
int PLACEMENT_TOOL::AlignBottom( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -158,7 +158,7 @@ int PLACEMENT_TOOL::AlignBottom( TOOL_EVENT& aEvent )
}
int PLACEMENT_TOOL::AlignLeft( TOOL_EVENT& aEvent )
int PLACEMENT_TOOL::AlignLeft( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -201,7 +201,7 @@ int PLACEMENT_TOOL::AlignLeft( TOOL_EVENT& aEvent )
}
int PLACEMENT_TOOL::AlignRight( TOOL_EVENT& aEvent )
int PLACEMENT_TOOL::AlignRight( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -256,7 +256,7 @@ static bool compareY( const BOARD_ITEM* aA, const BOARD_ITEM* aB )
}
int PLACEMENT_TOOL::DistributeHorizontally( TOOL_EVENT& aEvent )
int PLACEMENT_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -305,7 +305,7 @@ int PLACEMENT_TOOL::DistributeHorizontally( TOOL_EVENT& aEvent )
}
int PLACEMENT_TOOL::DistributeVertically( TOOL_EVENT& aEvent )
int PLACEMENT_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......
......@@ -29,10 +29,6 @@
class SELECTION_TOOL;
/**
* TODO description
*/
class PLACEMENT_TOOL : public TOOL_INTERACTIVE
{
public:
......@@ -45,26 +41,44 @@ public:
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init();
/// TODO
int AlignTop( TOOL_EVENT& aEvent );
/// TODO
int AlignBottom( TOOL_EVENT& aEvent );
/// TODO
int AlignLeft( TOOL_EVENT& aEvent );
/// TODO
int AlignRight( TOOL_EVENT& aEvent );
/// TODO
int DistributeHorizontally( TOOL_EVENT& aEvent );
/// TODO
int DistributeVertically( TOOL_EVENT& aEvent );
/**
* Function AlignTop()
* Sets Y coordinate of the selected items to the value of the top-most selected item Y coordinate.
*/
int AlignTop( const TOOL_EVENT& aEvent );
/**
* Function AlignBottom()
* Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate.
*/
int AlignBottom( const TOOL_EVENT& aEvent );
/**
* Function AlignLeft()
* Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.
*/
int AlignLeft( const TOOL_EVENT& aEvent );
/**
* Function AlignRight()
* Sets X coordinate of the selected items to the value of the right-most selected item X coordinate.
*/
int AlignRight( const TOOL_EVENT& aEvent );
/**
* Function DistributeHorizontally()
* Distributes the selected items along the X axis.
*/
int DistributeHorizontally( const TOOL_EVENT& aEvent );
/**
* Function DistributeVertically()
* Distributes the selected items along the Y axis.
*/
int DistributeVertically( const TOOL_EVENT& aEvent );
private:
/// TODO
///> Sets up handlers for various events.
void setTransitions();
SELECTION_TOOL* m_selectionTool;
......
......@@ -219,7 +219,7 @@ bool POINT_EDITOR::Init()
}
int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
......@@ -797,8 +797,8 @@ void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint )
void POINT_EDITOR::setTransitions()
{
Go( &POINT_EDITOR::OnSelectionChange, m_selectionTool->SelectedEvent );
Go( &POINT_EDITOR::OnSelectionChange, m_selectionTool->UnselectedEvent );
Go( &POINT_EDITOR::OnSelectionChange, SELECTION_TOOL::SelectedEvent );
Go( &POINT_EDITOR::OnSelectionChange, SELECTION_TOOL::UnselectedEvent );
}
......
......@@ -53,7 +53,7 @@ public:
*
* Change selection event handler.
*/
int OnSelectionChange( TOOL_EVENT& aEvent );
int OnSelectionChange( const TOOL_EVENT& aEvent );
private:
///> Selection tool used for obtaining selected items
......
......@@ -51,9 +51,6 @@
SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ),
SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ),
UnselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.unselected" ),
ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ),
m_frame( NULL ), m_additive( false ), m_multiple( false ),
m_editModules( false ), m_locked( true )
{
......@@ -90,7 +87,7 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
}
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
......@@ -234,8 +231,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
unselect( aItem );
// Inform other potentially interested tools
TOOL_EVENT unselectEvent( UnselectedEvent );
m_toolMgr->ProcessEvent( unselectEvent );
m_toolMgr->ProcessEvent( UnselectedEvent );
}
else
{
......@@ -248,8 +244,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
select( aItem );
// Inform other potentially interested tools
TOOL_EVENT selectEvent( SelectedEvent );
m_toolMgr->ProcessEvent( selectEvent );
m_toolMgr->ProcessEvent( SelectedEvent );
}
}
}
......@@ -384,8 +379,7 @@ bool SELECTION_TOOL::selectMultiple()
if( !m_selection.Empty() )
{
// Inform other potentially interested tools
TOOL_EVENT selectEvent( SelectedEvent );
m_toolMgr->ProcessEvent( selectEvent );
m_toolMgr->ProcessEvent( SelectedEvent );
}
break; // Stop waiting for events
......@@ -456,7 +450,7 @@ bool SELECTION_TOOL::CheckLock()
}
int SELECTION_TOOL::CursorSelection( TOOL_EVENT& aEvent )
int SELECTION_TOOL::CursorSelection( const TOOL_EVENT& aEvent )
{
selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ) );
setTransitions();
......@@ -465,7 +459,7 @@ int SELECTION_TOOL::CursorSelection( TOOL_EVENT& aEvent )
}
int SELECTION_TOOL::ClearSelection( TOOL_EVENT& aEvent )
int SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent )
{
clearSelection();
setTransitions();
......@@ -473,7 +467,7 @@ int SELECTION_TOOL::ClearSelection( TOOL_EVENT& aEvent )
return 0;
}
int SELECTION_TOOL::SelectItem( TOOL_EVENT& aEvent )
int SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
{
// Check if there is an item to be selected
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aEvent.Parameter() );
......@@ -483,8 +477,7 @@ int SELECTION_TOOL::SelectItem( TOOL_EVENT& aEvent )
select( item );
// Inform other potentially interested tools
TOOL_EVENT select( SelectedEvent );
m_toolMgr->ProcessEvent( select );
m_toolMgr->ProcessEvent( SelectedEvent );
}
setTransitions();
......@@ -492,7 +485,7 @@ int SELECTION_TOOL::SelectItem( TOOL_EVENT& aEvent )
return 0;
}
int SELECTION_TOOL::UnselectItem( TOOL_EVENT& aEvent )
int SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent )
{
// Check if there is an item to be selected
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aEvent.Parameter() );
......@@ -502,8 +495,7 @@ int SELECTION_TOOL::UnselectItem( TOOL_EVENT& aEvent )
unselect( item );
// Inform other potentially interested tools
TOOL_EVENT unselect( UnselectedEvent );
m_toolMgr->ProcessEvent( unselect );
m_toolMgr->ProcessEvent( UnselectedEvent );
}
setTransitions();
......@@ -519,17 +511,17 @@ void SELECTION_TOOL::findCallback( BOARD_ITEM* aItem )
{
clearSelection();
select( aItem );
getView()->SetCenter( VECTOR2D( aItem->GetPosition() ) );
// Inform other potentially interested tools
TOOL_EVENT selectEvent( SelectedEvent );
m_toolMgr->ProcessEvent( selectEvent );
m_toolMgr->ProcessEvent( SelectedEvent );
}
m_frame->GetGalCanvas()->ForceRefresh();
}
int SELECTION_TOOL::find( TOOL_EVENT& aEvent )
int SELECTION_TOOL::find( const TOOL_EVENT& aEvent )
{
DIALOG_FIND dlg( m_frame );
dlg.EnableWarp( false );
......@@ -541,7 +533,7 @@ int SELECTION_TOOL::find( TOOL_EVENT& aEvent )
}
int SELECTION_TOOL::findMove( TOOL_EVENT& aEvent )
int SELECTION_TOOL::findMove( const TOOL_EVENT& aEvent )
{
MODULE* module = m_frame->GetModuleByName();
......@@ -579,8 +571,7 @@ void SELECTION_TOOL::clearSelection()
m_locked = true;
// Inform other potentially interested tools
TOOL_EVENT clearEvent( ClearedEvent );
m_toolMgr->ProcessEvent( clearEvent );
m_toolMgr->ProcessEvent( ClearedEvent );
}
......@@ -811,8 +802,7 @@ void SELECTION_TOOL::unselect( BOARD_ITEM* aItem )
}
// Inform other potentially interested tools
TOOL_EVENT unselected( UnselectedEvent );
m_toolMgr->ProcessEvent( unselected );
m_toolMgr->ProcessEvent( UnselectedEvent );
}
......@@ -939,3 +929,8 @@ void SELECTION::clear()
items.ClearItemsList();
group->Clear();
}
const TOOL_EVENT SELECTION_TOOL::SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" );
const TOOL_EVENT SELECTION_TOOL::UnselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.unselected" );
const TOOL_EVENT SELECTION_TOOL::ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" );
......@@ -103,7 +103,7 @@ public:
*
* The main loop.
*/
int Main( TOOL_EVENT& aEvent );
int Main( const TOOL_EVENT& aEvent );
/**
* Function GetSelection()
......@@ -152,25 +152,25 @@ public:
bool CheckLock();
///> Select a single item under cursor event handler.
int CursorSelection( TOOL_EVENT& aEvent );
int CursorSelection( const TOOL_EVENT& aEvent );
///> Clear current selection event handler.
int ClearSelection( TOOL_EVENT& aEvent );
int ClearSelection( const TOOL_EVENT& aEvent );
///> Item selection event handler.
int SelectItem( TOOL_EVENT& aEvent );
int SelectItem( const TOOL_EVENT& aEvent );
///> Item unselection event handler.
int UnselectItem( TOOL_EVENT& aEvent );
int UnselectItem( const TOOL_EVENT& aEvent );
///> Event sent after an item is selected.
const TOOL_EVENT SelectedEvent;
static const TOOL_EVENT SelectedEvent;
///> Event sent after an item is unselected.
const TOOL_EVENT UnselectedEvent;
static const TOOL_EVENT UnselectedEvent;
///> Event sent after selection is cleared.
const TOOL_EVENT ClearedEvent;
static const TOOL_EVENT ClearedEvent;
private:
/**
......@@ -197,10 +197,10 @@ private:
void findCallback( BOARD_ITEM* aItem );
///> Find an item.
int find( TOOL_EVENT& aEvent );
int find( const TOOL_EVENT& aEvent );
///> Find an item and start moving.
int findMove( TOOL_EVENT& aEvent );
int findMove( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions();
......
......@@ -8,6 +8,12 @@ import tempfile
from pcbnew import *
BACK_COPPER = 'Back_Copper'
B_CU = 'B.Cu'
NEW_NAME = 'My_Fancy_Layer_Name'
class TestBoardClass(unittest.TestCase):
def setUp(self):
......@@ -97,9 +103,30 @@ class TestBoardClass(unittest.TestCase):
os.remove(self.FILENAME)
def test_pcb_layer_name_set_get(self):
pcb = BOARD()
pcb.SetLayerName(31, BACK_COPPER)
self.assertEqual(pcb.GetLayerName(31), BACK_COPPER)
def test_pcb_layer_name_set_get(self):
pcb = BOARD()
pcb.SetLayerName(31, BACK_COPPER)
self.assertEqual(pcb.GetLayerName(31), BACK_COPPER)
def test_pcb_layer_id_get(self):
pcb = BOARD()
b_cu_id = pcb.GetLayerID(B_CU)
pcb.SetLayerName(b_cu_id, NEW_NAME)
# ensure we can get the ID for the new name
self.assertEqual(pcb.GetLayerID(NEW_NAME), b_cu_id)
# ensure we can get to the ID via the STD name too
self.assertEqual(pcb.GetLayerID(B_CU), b_cu_id)
#def test_interactive(self):
# code.interact(local=locals())
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
......@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <miguelangel@nbee.es>
* 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
* modify it under the terms of the GNU General Public License
......@@ -68,7 +68,7 @@ static void swigAddModule( const char* name, void (* initfunc)() )
}
/* Add the builting python modules */
/* Add the builtin python modules */
static void swigAddBuiltin()
{
......@@ -140,6 +140,13 @@ bool pcbnewInitPythonScripting( const char * aUserPluginsPath )
#ifdef KICAD_SCRIPTING_WXPYTHON
PyEval_InitThreads();
char cmd[1024];
// Make sure that that the correct version of wxPython is loaded. In systems where there
// are different versions of wxPython installed this can lead to select wrong wxPython
// version being selected.
snprintf( cmd, 1023, "import wxversion; wxversion.select('%s')", WXPYTHON_VERSION );
PyRun_SimpleString( cmd );
// Load the wxPython core API. Imports the wx._core_ module and sets a
// local pointer to a function table located there. The pointer is used
// internally by the rest of the API functions.
......@@ -181,7 +188,7 @@ void pcbnewFinishPythonScripting()
}
#if defined(KICAD_SCRIPTING_WXPYTHON)
#if defined( KICAD_SCRIPTING_WXPYTHON )
void RedirectStdio()
{
......
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