Commit 4a15b358 authored by Brian Sidebotham's avatar Brian Sidebotham

Merge in changes

parents d5a029ff 1c5a997f
...@@ -190,9 +190,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) ...@@ -190,9 +190,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( TO_LINKER -Wl ) set( TO_LINKER -Wl )
endif() endif()
# Thou shalt not link vaporware and tell us it's a valid DSO: # Thou shalt not link vaporware and tell us it's a valid DSO (apple ld doesn't support it)
if( NOT APPLE )
set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" ) set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "${TO_LINKER},--no-undefined" ) set( CMAKE_MODULE_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
endif()
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" ) set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
endif() endif()
...@@ -361,6 +363,9 @@ add_custom_target( lib-wxpython ) ...@@ -361,6 +363,9 @@ add_custom_target( lib-wxpython )
if( KICAD_BUILD_STATIC ) if( KICAD_BUILD_STATIC )
message(STATUS "KICAD_BUILD_STATIC set") message(STATUS "KICAD_BUILD_STATIC set")
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_WXPYTHON OR KICAD_SCRIPTING_MODULES )
message(FATAL_ERROR "KICAD_SCRIPTING* is not supported with KICAD_BUILD_STATIC, please select KICAD_BUILD_DYNAMIC" )
endif()
endif() endif()
if( KICAD_BUILD_DYNAMIC ) if( KICAD_BUILD_DYNAMIC )
...@@ -374,6 +379,9 @@ add_custom_target( lib-wxpython ) ...@@ -374,6 +379,9 @@ add_custom_target( lib-wxpython )
include( download_libpng ) include( download_libpng )
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_WXPYTHON OR KICAD_SCRIPTING_MODULES ) if( KICAD_SCRIPTING OR KICAD_SCRIPTING_WXPYTHON OR KICAD_SCRIPTING_MODULES )
message(STATUS "Scripting ENABLED")
set( SWIG_EXECUTABLE ${SWIG_ROOT}/bin/swig ) set( SWIG_EXECUTABLE ${SWIG_ROOT}/bin/swig )
set( SWIG_INCLUDE ${SWIG_ROOT}/include ) set( SWIG_INCLUDE ${SWIG_ROOT}/include )
set( PYTHON_DEST ${LIBWXPYTHON_ROOT}/wxPython/lib/python2.6/site-packages ) set( PYTHON_DEST ${LIBWXPYTHON_ROOT}/wxPython/lib/python2.6/site-packages )
...@@ -505,18 +513,24 @@ set( INC_AFTER ...@@ -505,18 +513,24 @@ set( INC_AFTER
# Find Python and other scripting resources # Find Python and other scripting resources
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
if( NOT APPLE ) if( APPLE )
set( PythonInterp_FIND_VERSION )
else()
set( PYTHON_LIBRARY /System/Library/Frameworks/Python.framework/Versions/2.6/Python ) set( PYTHON_LIBRARY /System/Library/Frameworks/Python.framework/Versions/2.6/Python )
set( PYTHON_INCLUDE_DIR /System/Library/Frameworks/Python.framework/Versions//2.6/include/python2.6 ) set( PYTHON_INCLUDE_DIR /System/Library/Frameworks/Python.framework/Versions//2.6/include/python2.6 )
set( PythonInterp_FIND_VERSION 2.6 ) set( PythonInterp_FIND_VERSION 2.6 )
set( PythonLibs_FIND_VERSION 2.6 ) set( PythonLibs_FIND_VERSION 2.6 )
endif() endif()
# force a python version < 3.0
set( PythonInterp_FIND_VERSION 2.6)
set( PythonLibs_FIND_VERSION 2.6 )
find_package( PythonInterp ) find_package( PythonInterp )
check_find_package_result( PYTHONINTERP_FOUND "Python Interpreter" ) check_find_package_result( PYTHONINTERP_FOUND "Python Interpreter" )
if( NOT PYTHON_VERSION_MAJOR EQUAL 2 )
message( FATAL_ERROR "Python 2.x is required." )
endif()
# Get the correct Python site package install path from the Python interpreter found by # Get the correct Python site package install path from the Python interpreter found by
# FindPythonInterp unless the user specifically defined a custom path. # FindPythonInterp unless the user specifically defined a custom path.
if( NOT PYTHON_SITE_PACKAGE_PATH ) if( NOT PYTHON_SITE_PACKAGE_PATH )
...@@ -534,7 +548,7 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) ...@@ -534,7 +548,7 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
mark_as_advanced( PYTHON_DEST ) mark_as_advanced( PYTHON_DEST )
message( STATUS "Python module install path: ${PYTHON_DEST}" ) message( STATUS "Python module install path: ${PYTHON_DEST}" )
find_package( PythonLibs ) find_package( PythonLibs 2.6 )
#message( STATUS "PYTHON_INCLUDE_DIRS:${PYTHON_INCLUDE_DIRS}" ) #message( STATUS "PYTHON_INCLUDE_DIRS:${PYTHON_INCLUDE_DIRS}" )
......
...@@ -138,9 +138,17 @@ bzr branch lp:kicad/stable kicad_src ...@@ -138,9 +138,17 @@ bzr branch lp:kicad/stable kicad_src
Components and Footprints libraries Components and Footprints libraries
all (schematic libs, 3D shapes ...) but new footprints libraries (use Download zip tool) all (schematic libs, 3D shapes ...) but new footprints libraries (use Download zip tool)
https://github.com/KiCad/kicad-library/ https://github.com/KiCad/kicad-library/
New footprints libraries (use Download zip tool for each lib you want) New footprints libraries (use Download zip tool for each lib you want)
https://github.com/KiCad/ for footprint libs (*.pretty folders) https://github.com/KiCad/ for footprint libs (*.pretty folders)
A mirror of github is available, using bzr:
(schematic libs, 3D shapes ... all but new footprints libraries)
bzr checkout lp:~kicad-product-committers/kicad/library
Old legacy libraries:
bzr checkout lp:~dickelbeck/kicad/library-read-only
Note also Kicad is able to read on github.com/KiCad/ the *.pretty folders Note also Kicad is able to read on github.com/KiCad/ the *.pretty folders
without download, using github plugin. without download, using github plugin.
(however the time to read them can be long) (however the time to read them can be long)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -623,18 +623,10 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines, ...@@ -623,18 +623,10 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
aClipBox->Inflate(-aWidth/2); aClipBox->Inflate(-aWidth/2);
} }
// Draw the outline of a thick segment wih rounded ends
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, EDA_COLOR_T Color ) int width, int aPenSize, EDA_COLOR_T Color )
{ {
long radius;
int dwx, dwy;
long dx, dy, dwx2, dwy2;
long sx1, sy1, ex1, ey1;
long sx2, sy2, ex2, ey2;
bool swap_ends = false;
GRLastMoveToX = x2; GRLastMoveToX = x2;
GRLastMoveToY = y2; GRLastMoveToY = y2;
...@@ -658,114 +650,63 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -658,114 +650,63 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
GRSetColorPen( DC, Color, aPenSize ); GRSetColorPen( DC, Color, aPenSize );
GRSetBrush( DC, Color, false ); GRSetBrush( DC, Color, false );
radius = (width + 1) >> 1; int radius = (width + 1) >> 1;
int dx = x2 - x1;
dx = x2 - x1; int dy = y2 - y1;
dy = y2 - y1; double angle = -ArcTangente( dy, dx );
wxPoint start;
if( dx == 0 ) /* segment vertical */ wxPoint end;
{ wxPoint org( x1, y1);
dwx = radius; int len = (int) hypot( dx, dy );
if( dy >= 0 )
dwx = -dwx; // We know if the DC is mirrored, to draw arcs
int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
sx1 = x1 - dwx; int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
sy1 = y1; bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
ex1 = x2 - dwx; // first edge
ey1 = y2; start.x = 0;
start.y = radius;
DC->DrawLine( sx1, sy1, ex1, ey1 ); end.x = len;
end.y = radius;
sx2 = x1 + dwx; RotatePoint( &start, angle);
sy2 = y1; RotatePoint( &end, angle);
ex2 = x2 + dwx; start += org;
ey2 = y2; end += org;
DC->DrawLine( sx2, sy2, ex2, ey2 ); DC->DrawLine( start, end );
}
else if( dy == 0 ) /* segment horizontal */ // first rounded end
{ end.x = 0;
dwy = radius; end.y = -radius;
if( dx < 0 ) RotatePoint( &end, angle);
dwy = -dwy; end += org;
sx1 = x1; if( !mirrored )
sy1 = y1 - dwy; DC->DrawArc( end, start, org );
ex1 = x2;
ey1 = y2 - dwy;
DC->DrawLine( sx1, sy1, ex1, ey1 );
sx2 = x1;
sy2 = y1 + dwy;
ex2 = x2;
ey2 = y2 + dwy;
DC->DrawLine( sx2, sy2, ex2, ey2 );
}
else else
{ DC->DrawArc( start, end, org );
if( std::abs( dx ) == std::abs( dy ) ) // segment 45 degrees
{
dwx = dwy = ( (width * 5) + 4 ) / 7; // = width / 2 * 0.707
if( dy < 0 )
{
if( dx <= 0 )
{
dwx = -dwx; swap_ends = true;
}
}
else // dy >= 0
{
if( dx > 0 )
{
dwy = -dwy; swap_ends = true;
}
else
swap_ends = true;
}
}
else
{
double delta_angle = ArcTangente( dy, dx );
dwx = 0;
dwy = width;
RotatePoint( &dwx, &dwy, -delta_angle );
}
dwx2 = dwx >> 1;
dwy2 = dwy >> 1;
sx1 = x1 - dwx2;
sy1 = y1 - dwy2;
ex1 = x2 - dwx2;
ey1 = y2 - dwy2;
DC->DrawLine( sx1, sy1, ex1, ey1 );
sx2 = x1 + dwx2; // second edge
sy2 = y1 + dwy2; start.x = len;
start.y = -radius;
RotatePoint( &start, angle);
start += org;
ex2 = x2 + dwx2; DC->DrawLine( start, end );
ey2 = y2 + dwy2;
DC->DrawLine( sx2, sy2, ex2, ey2 ); // second rounded end
} end.x = len;
end.y = radius;
RotatePoint( &end, angle);
end += org;
if( swap_ends ) if( !mirrored )
{ DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
DC->DrawArc( sx2, sy2, sx1, sy1, x1, y1 );
DC->DrawArc( ex1, ey1, ex2, ey2, x2, y2 );
}
else else
{ DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
DC->DrawArc( sx1, sy1, sx2, sy2, x1, y1 );
DC->DrawArc( ex2, ey2, ex1, ey1, x2, y2 );
}
} }
......
...@@ -19,6 +19,8 @@ set( EESCHEMA_DLGS ...@@ -19,6 +19,8 @@ set( EESCHEMA_DLGS
dialogs/dialog_bom.cpp dialogs/dialog_bom.cpp
dialogs/dialog_bom_base.cpp dialogs/dialog_bom_base.cpp
dialogs/dialog_bom_cfg_keywords.cpp dialogs/dialog_bom_cfg_keywords.cpp
dialogs/dialog_choose_component.cpp
dialogs/dialog_choose_component_base.cpp
dialogs/dialog_lib_edit_text.cpp dialogs/dialog_lib_edit_text.cpp
dialogs/dialog_lib_edit_text_base.cpp dialogs/dialog_lib_edit_text_base.cpp
dialogs/dialog_edit_component_in_lib.cpp dialogs/dialog_edit_component_in_lib.cpp
...@@ -88,6 +90,7 @@ set( EESCHEMA_SRCS ...@@ -88,6 +90,7 @@ set( EESCHEMA_SRCS
files-io.cpp files-io.cpp
find.cpp find.cpp
getpart.cpp getpart.cpp
component_tree_search_container.cpp
hierarch.cpp hierarch.cpp
hotkeys.cpp hotkeys.cpp
libarch.cpp libarch.cpp
......
This diff is collapsed.
/* -*- c++ -*-
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http: *www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http: *www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vector>
#include <wx/string.h>
class LIB_COMPONENT;
class CMP_LIBRARY;
class wxTreeCtrl;
class wxArrayString;
// class COMPONENT_TREE_SEARCH_CONTAINER
// A container for components that allows to search them matching their name, keywords
// and descripotions, updating a wxTreeCtrl with the results (toplevel nodes:
// libraries, leafs: components), scored by relevance.
//
// The scored result list is adpated on each update on the search-term: this allows
// to have a search-as-you-type experience.
class COMPONENT_TREE_SEARCH_CONTAINER
{
public:
COMPONENT_TREE_SEARCH_CONTAINER();
~COMPONENT_TREE_SEARCH_CONTAINER();
/** Function AddLibrary
* Add the components of this library to be searched.
* To be called in the setup phase to fill this container.
*
* @param aLib containting all the components to be added.
*/
void AddLibrary( CMP_LIBRARY& aLib );
/** Function AddComponentList
* Add the given list of components, given by name, to be searched.
* To be called in the setup phase to fill this container.
*
* @param aNodeName The parent node name the components will show up as leaf.
* @param aComponentNameList List of component names.
* @param aOptionalLib Library to look up the component names (if NULL: global lookup)
* @param aNormallyExpanded Should the node in the tree be expanded by default.
*/
void AddComponentList( const wxString& aNodeName, const wxArrayString& aComponentNameList,
CMP_LIBRARY* aOptionalLib, bool aNormallyExpanded );
/** Function SetPreselectNode
* Set the component name to be selected in absence of any search-result.
*
* @param aComponentName the component name to be selected.
*/
void SetPreselectNode( const wxString& aComponentName );
/** Function SetTree
* Set the tree to be manipulated.
* Each update of the search term will update the tree, with the most
* scoring component at the top and selected. If a preselect node is set, this
* is displayed. Does not take ownership of the tree.
*
* @param aTree that is to be modified on search updates.
*/
void SetTree( wxTreeCtrl* aTree );
/** Function UpdateSearchTerm
* Update the search string provided by the user and narrow down the result list.
*
* This string is a space-separated list of terms, each of which
* is applied to the components list to narrow it down. Results are scored by
* relevancy (e.g. exact match scores higher than prefix-match which in turn scores
* higher than substring match). This updates the search and tree on each call.
*
* @param aSearch is the user-provided search string.
*/
void UpdateSearchTerm( const wxString& aSearch );
/** Function GetSelectedComponent
*
* @return the selected component or NULL if there is none.
*/
LIB_COMPONENT* GetSelectedComponent();
private:
struct TREE_NODE;
static bool scoreComparator( const TREE_NODE* a1, const TREE_NODE* a2 );
std::vector<TREE_NODE*> nodes;
wxString preselect_node_name;
wxTreeCtrl* tree;
};
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <dialog_choose_component.h>
#include <set>
#include <boost/foreach.hpp>
#include <wx/tokenzr.h>
#include <class_library.h>
#include <component_tree_search_container.h>
#include <sch_base_frame.h>
// Tree navigation helpers.
static wxTreeItemId GetPrevItem( const wxTreeCtrl& tree, const wxTreeItemId& item );
static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& item );
// Combine descriptions of all aliases from given component.
static wxString combineDescriptions( LIB_COMPONENT* aComponent )
{
std::set<wxString> descriptions;
for( size_t i = 0; i < aComponent->GetAliasCount(); ++i )
{
LIB_ALIAS* a = aComponent->GetAlias( i );
if ( !a->GetDescription().empty() )
descriptions.insert( a->GetDescription() );
}
wxString result;
BOOST_FOREACH( const wxString& s, descriptions )
result += s + wxT("\n");
return result;
}
// Combine keywords. Keywords come as a string, but are considered space-separated
// individual words. Return a string with a unique set of these.
static wxString combineKeywords( LIB_COMPONENT* aComponent )
{
std::set<wxString> keywords;
for( size_t i = 0; i < aComponent->GetAliasCount(); ++i )
{
LIB_ALIAS* a = aComponent->GetAlias( i );
wxStringTokenizer tokenizer( a->GetKeyWords() );
while ( tokenizer.HasMoreTokens() )
keywords.insert( tokenizer.GetNextToken() );
}
wxString result;
BOOST_FOREACH( const wxString& s, keywords )
result += s + wxT(" ");
return result;
}
DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxString& aTitle,
COMPONENT_TREE_SEARCH_CONTAINER* aContainer )
: DIALOG_CHOOSE_COMPONENT_BASE( aParent, wxID_ANY, aTitle ),
m_search_container( aContainer ),
m_selected_component( NULL ),
m_external_browser_requested( false ),
m_received_doubleclick_in_tree( false )
{
// TODO: restore last size user was choosing.
m_search_container->SetTree( m_libraryComponentTree );
m_searchBox->SetFocus();
m_componentDetails->SetEditable( false );
}
// After this dialog is done: return the component that has been selected, or an
// empty string if there is none.
wxString DIALOG_CHOOSE_COMPONENT::GetSelectedComponentName() const
{
if ( m_selected_component == NULL )
return wxEmptyString;
return m_selected_component->GetName();
}
void DIALOG_CHOOSE_COMPONENT::OnSearchBoxChange( wxCommandEvent& aEvent )
{
m_selected_component = NULL;
m_search_container->UpdateSearchTerm( m_searchBox->GetLineText(0) );
updateSelection();
}
void DIALOG_CHOOSE_COMPONENT::OnSearchBoxEnter( wxCommandEvent& aEvent )
{
EndModal( wxID_OK ); // We are done.
}
void DIALOG_CHOOSE_COMPONENT::SelectIfValid( const wxTreeItemId& aTreeId )
{
if ( aTreeId.IsOk() && aTreeId != m_libraryComponentTree->GetRootItem() )
m_libraryComponentTree->SelectItem( aTreeId );
}
void DIALOG_CHOOSE_COMPONENT::OnInterceptSearchBoxKey( wxKeyEvent& aKeyStroke )
{
// Cursor up/down are forwarded to the tree. This is done by intercepting some navigational
// keystrokes that normally would go to the text search box (which has the focus by default).
const wxTreeItemId sel = m_libraryComponentTree->GetSelection();
switch ( aKeyStroke.GetKeyCode() )
{
case WXK_UP:
SelectIfValid( GetPrevItem( *m_libraryComponentTree, sel ) );
break;
case WXK_DOWN:
SelectIfValid( GetNextItem( *m_libraryComponentTree, sel ) );
break;
default:
aKeyStroke.Skip(); // Pass on to search box.
break;
}
}
void DIALOG_CHOOSE_COMPONENT::OnTreeSelect( wxTreeEvent& aEvent )
{
updateSelection();
}
void DIALOG_CHOOSE_COMPONENT::OnDoubleClickTreeSelect( wxTreeEvent& aEvent )
{
updateSelection();
if ( m_selected_component == NULL )
return;
// Ok, got selection. We don't just end the modal dialog here, but
// wait for the MouseUp event to occur. Otherwise something (broken?)
// happens: the dialog will close and will deliver the 'MouseUp' event
// to the eeschema canvas, that will immediately place the component.
m_received_doubleclick_in_tree = true;
}
void DIALOG_CHOOSE_COMPONENT::OnTreeMouseUp( wxMouseEvent& aMouseEvent )
{
if ( m_received_doubleclick_in_tree )
EndModal( wxID_OK ); // We are done (see OnDoubleClickTreeSelect)
else
aMouseEvent.Skip(); // Let upstream handle it.
}
void DIALOG_CHOOSE_COMPONENT::OnStartComponentBrowser( wxMouseEvent& aEvent )
{
m_external_browser_requested = true;
EndModal( wxID_OK ); // We are done.
}
void DIALOG_CHOOSE_COMPONENT::updateSelection()
{
LIB_COMPONENT* selection = m_search_container->GetSelectedComponent();
if ( selection == m_selected_component )
return; // no change.
m_selected_component = selection;
m_componentDetails->Clear();
if ( m_selected_component == NULL )
return;
wxFont font_normal = m_componentDetails->GetFont();
wxFont font_bold = m_componentDetails->GetFont();
font_bold.SetWeight( wxFONTWEIGHT_BOLD );
wxTextAttr headline_attribute;
headline_attribute.SetFont(font_bold);
wxTextAttr text_attribute;
text_attribute.SetFont(font_normal);
const wxString description = combineDescriptions( selection );
if ( !description.empty() )
{
m_componentDetails->SetDefaultStyle( headline_attribute );
m_componentDetails->AppendText( _("Description\n") );
m_componentDetails->SetDefaultStyle( text_attribute );
m_componentDetails->AppendText( description );
m_componentDetails->AppendText( wxT("\n") );
}
const wxString keywords = combineKeywords( selection );
if ( !keywords.empty() )
{
m_componentDetails->SetDefaultStyle( headline_attribute );
m_componentDetails->AppendText( _("Keywords\n") );
m_componentDetails->SetDefaultStyle( text_attribute );
m_componentDetails->AppendText( keywords );
}
m_componentDetails->SetInsertionPoint( 0 ); // scroll up.
}
static wxTreeItemId GetPrevItem( const wxTreeCtrl& tree, const wxTreeItemId& item )
{
wxTreeItemId prevItem = tree.GetPrevSibling( item );
if ( !prevItem.IsOk() )
{
const wxTreeItemId parent = tree.GetItemParent( item );
prevItem = tree.GetLastChild( tree.GetPrevSibling( parent ) );
}
return prevItem;
}
static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& item )
{
wxTreeItemId nextItem = tree.GetNextSibling( item );
if ( !nextItem.IsOk() )
{
const wxTreeItemId parent = tree.GetItemParent( item );
wxTreeItemIdValue dummy;
nextItem = tree.GetFirstChild( tree.GetNextSibling( parent ), dummy );
}
return nextItem;
}
/* -*- c++ -*-
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <dialog_choose_component_base.h>
class COMPONENT_TREE_SEARCH_CONTAINER;
class LIB_COMPONENT;
class wxTreeItemId;
class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
{
public:
DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxString& aTitle,
COMPONENT_TREE_SEARCH_CONTAINER* aSearch_container );
/** Function GetSelectedComponentName
* To be called after this dialog returns from ShowModal().
*
* @return the component that has been selected, or an empty string if there is none.
*/
wxString GetSelectedComponentName() const;
/** Function IsExternalBrowserSelected
*
* @return true, iff the browser pressed the browsing button.
*/
bool IsExternalBrowserSelected() const { return m_external_browser_requested; }
protected:
virtual void OnSearchBoxChange( wxCommandEvent& aEvent );
virtual void OnSearchBoxEnter( wxCommandEvent& aEvent );
virtual void OnInterceptSearchBoxKey( wxKeyEvent& aEvent );
virtual void OnTreeSelect( wxTreeEvent& aEvent );
virtual void OnDoubleClickTreeSelect( wxTreeEvent& aEvent );
virtual void OnTreeMouseUp( wxMouseEvent& aMouseEvent );
virtual void OnStartComponentBrowser( wxMouseEvent& aEvent );
private:
void updateSelection();
void SelectIfValid( const wxTreeItemId& aTreeId );
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
LIB_COMPONENT* m_selected_component;
bool m_external_browser_requested;
bool m_received_doubleclick_in_tree;
};
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_choose_component_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_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( wxSize( 450,-1 ), wxDefaultSize );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSearchSizer;
bSearchSizer = new wxBoxSizer( wxHORIZONTAL );
m_searchLabel = new wxStaticText( this, wxID_ANY, wxT("Search"), wxDefaultPosition, wxDefaultSize, 0 );
m_searchLabel->Wrap( -1 );
bSearchSizer->Add( m_searchLabel, 0, wxALL, 5 );
m_searchBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
bSearchSizer->Add( m_searchBox, 1, wxALL, 5 );
bSizer1->Add( bSearchSizer, 0, wxEXPAND, 5 );
m_libraryComponentTree = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT );
m_libraryComponentTree->SetMinSize( wxSize( -1,50 ) );
bSizer1->Add( m_libraryComponentTree, 2, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
m_componentView = new wxStaticText( this, wxID_ANY, wxT("TODO\n(mini. comp image)"), wxDefaultPosition, wxSize( 100,100 ), 0 );
m_componentView->Wrap( -1 );
m_componentView->SetMinSize( wxSize( 100,100 ) );
bSizer3->Add( m_componentView, 0, wxALL, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
m_componentDetails = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,100 ), wxTE_MULTILINE );
bSizer6->Add( m_componentDetails, 1, wxALL|wxEXPAND, 5 );
m_unitChoice = new wxComboBox( this, wxID_ANY, wxT("Unit A"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_unitChoice->Enable( false );
m_unitChoice->Hide();
bSizer6->Add( m_unitChoice, 0, wxALL, 5 );
bSizer3->Add( bSizer6, 2, wxEXPAND, 5 );
bSizer1->Add( bSizer3, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
m_button = new wxStdDialogButtonSizer();
m_buttonOK = new wxButton( this, wxID_OK );
m_button->AddButton( m_buttonOK );
m_buttonCancel = new wxButton( this, wxID_CANCEL );
m_button->AddButton( m_buttonCancel );
m_button->Realize();
bSizer5->Add( m_button, 0, wxEXPAND, 5 );
bSizer1->Add( bSizer5, 0, wxEXPAND, 5 );
this->SetSizer( bSizer1 );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_searchBox->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptSearchBoxKey ), NULL, this );
m_searchBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxChange ), NULL, this );
m_searchBox->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxEnter ), NULL, this );
m_libraryComponentTree->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeMouseUp ), NULL, this );
m_libraryComponentTree->Connect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnDoubleClickTreeSelect ), NULL, this );
m_libraryComponentTree->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeSelect ), NULL, this );
m_componentView->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnStartComponentBrowser ), NULL, this );
}
DIALOG_CHOOSE_COMPONENT_BASE::~DIALOG_CHOOSE_COMPONENT_BASE()
{
// Disconnect Events
m_searchBox->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnInterceptSearchBoxKey ), NULL, this );
m_searchBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxChange ), NULL, this );
m_searchBox->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnSearchBoxEnter ), NULL, this );
m_libraryComponentTree->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeMouseUp ), NULL, this );
m_libraryComponentTree->Disconnect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnDoubleClickTreeSelect ), NULL, this );
m_libraryComponentTree->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeSelect ), NULL, this );
m_componentView->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnStartComponentBrowser ), NULL, this );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_CHOOSE_COMPONENT_BASE_H__
#define __DIALOG_CHOOSE_COMPONENT_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/treectrl.h>
#include <wx/combobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_CHOOSE_COMPONENT_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_CHOOSE_COMPONENT_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_searchLabel;
wxTextCtrl* m_searchBox;
wxTreeCtrl* m_libraryComponentTree;
wxStaticText* m_componentView;
wxTextCtrl* m_componentDetails;
wxComboBox* m_unitChoice;
wxStdDialogButtonSizer* m_button;
wxButton* m_buttonOK;
wxButton* m_buttonCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInterceptSearchBoxKey( wxKeyEvent& event ) { event.Skip(); }
virtual void OnSearchBoxChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSearchBoxEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTreeMouseUp( wxMouseEvent& event ) { event.Skip(); }
virtual void OnDoubleClickTreeSelect( wxTreeEvent& event ) { event.Skip(); }
virtual void OnTreeSelect( wxTreeEvent& event ) { event.Skip(); }
virtual void OnStartComponentBrowser( wxMouseEvent& event ) { event.Skip(); }
public:
DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 450,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_CHOOSE_COMPONENT_BASE();
};
#endif //__DIALOG_CHOOSE_COMPONENT_BASE_H__
...@@ -45,11 +45,14 @@ ...@@ -45,11 +45,14 @@
#include <viewlib_frame.h> #include <viewlib_frame.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <dialog_choose_component.h>
#include <component_tree_search_container.h>
#include <dialog_get_component.h> #include <dialog_get_component.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
// TODO(hzeller): would be good if we could give a pre-selected component.
wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void ) wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void )
{ {
wxSemaphore semaphore( 0, 1 ); wxSemaphore semaphore( 0, 1 );
...@@ -76,118 +79,66 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void ) ...@@ -76,118 +79,66 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void )
return cmpname; return cmpname;
} }
wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname, wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
wxArrayString& aHistoryList, wxArrayString& aHistoryList,
bool aUseLibBrowser, bool aUseLibBrowser,
int* aUnit, int* aUnit,
int* aConvert ) int* aConvert )
{ {
int CmpCount = 0; int cmpCount = 0;
LIB_COMPONENT* libEntry = NULL; wxString dialogTitle;
CMP_LIBRARY* currLibrary = NULL;
wxString cmpName, keys, msg; COMPONENT_TREE_SEARCH_CONTAINER search_container; // Container doing search-as-you-type
bool allowWildSeach = true;
if( !aLibname.IsEmpty() ) if( !aLibname.IsEmpty() )
{ {
currLibrary = CMP_LIBRARY::FindLibrary( aLibname ); CMP_LIBRARY* currLibrary = CMP_LIBRARY::FindLibrary( aLibname );
if( currLibrary != NULL ) if( currLibrary != NULL )
CmpCount = currLibrary->GetCount(); {
cmpCount = currLibrary->GetCount();
search_container.AddLibrary( *currLibrary );
}
} }
else else
{ {
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() ) BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{ {
CmpCount += lib.GetCount(); cmpCount += lib.GetCount();
} search_container.AddLibrary( lib );
} }
// Ask for a component name or key words
msg.Printf( _( "Component selection (%d items loaded):" ), CmpCount );
DIALOG_GET_COMPONENT dlg( this, aHistoryList, msg, aUseLibBrowser );
if( aHistoryList.GetCount() )
dlg.SetComponentName( aHistoryList[0] );
if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString;
if( dlg.m_GetExtraFunction )
{
cmpName = SelectComponentFromLibBrowser();
if( aUnit )
*aUnit = LIB_VIEW_FRAME::GetUnit();
if( aConvert )
*aConvert = LIB_VIEW_FRAME::GetConvert();
if( !cmpName.IsEmpty() )
AddHistoryComponentName( aHistoryList, cmpName );
return cmpName;
} }
else
cmpName = dlg.GetComponentName();
if( cmpName.IsEmpty() )
return wxEmptyString;
// Here, cmpName contains the component name, if( !aHistoryList.empty() )
// or "*" if the Select All dialog button was pressed
#ifndef KICAD_KEEPCASE
cmpName.MakeUpper();
#endif
if( dlg.IsKeyword() )
{ {
allowWildSeach = false; // This is good for a transition for experineced users: giving them a History. Ideally,
keys = cmpName; // we actually make this part even faster to access with a popup on ALT-a or something.
cmpName = DataBaseGetName( this, keys, cmpName ); search_container.AddComponentList( _("-- History --"), aHistoryList, NULL, true );
search_container.SetPreselectNode( aHistoryList[0] );
if( cmpName.IsEmpty() )
return wxEmptyString;
} }
else if( cmpName == wxT( "*" ) )
{
allowWildSeach = false;
if( GetNameOfPartToLoad( this, currLibrary, cmpName ) == 0 ) dialogTitle.Printf( _( "Choose Component (%d items loaded)" ), cmpCount );
return wxEmptyString; DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, &search_container );
}
else if( cmpName.Contains( wxT( "?" ) ) || cmpName.Contains( wxT( "*" ) ) )
{
allowWildSeach = false;
cmpName = DataBaseGetName( this, keys, cmpName );
if( cmpName.IsEmpty() ) if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString; return wxEmptyString;
}
libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname ); wxString cmpName = dlg.GetSelectedComponentName();
if( !libEntry && allowWildSeach ) // Search with wildcard if( dlg.IsExternalBrowserSelected() )
{ {
allowWildSeach = false; cmpName = SelectComponentFromLibBrowser(); // Would be good if we could pre-select.
wxString wildname = wxChar( '*' ) + cmpName + wxChar( '*' );
cmpName = wildname;
cmpName = DataBaseGetName( this, keys, cmpName );
if( !cmpName.IsEmpty() )
libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname );
if( !libEntry ) if( aUnit )
return wxEmptyString; *aUnit = LIB_VIEW_FRAME::GetUnit();
}
if( !libEntry ) if( aConvert )
{ *aConvert = LIB_VIEW_FRAME::GetConvert();
msg.Printf( _( "Failed to find part <%s> in library" ), GetChars( cmpName ) );
DisplayError( this, msg );
return wxEmptyString;
} }
if ( !cmpName.empty() )
AddHistoryComponentName( aHistoryList, cmpName ); AddHistoryComponentName( aHistoryList, cmpName );
return cmpName; return cmpName;
} }
......
...@@ -200,8 +200,16 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, ...@@ -200,8 +200,16 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
StAngle = ArcTangente( dy - uy0, dx - ux0 ); StAngle = ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + m_Angle; EndAngle = StAngle + m_Angle;
if( !panel->GetPrintMirrored() )
{
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); EXCHG( StAngle, EndAngle );
}
else // Mirrored mode: arc orientation is reversed
{
if( StAngle < EndAngle )
EXCHG( StAngle, EndAngle );
}
if( typeaff == LINE ) if( typeaff == LINE )
{ {
......
...@@ -799,7 +799,7 @@ void MODULE::Flip( const wxPoint& aCentre ) ...@@ -799,7 +799,7 @@ void MODULE::Flip( const wxPoint& aCentre )
// Mirror pads to other side of board about the x axis, i.e. vertically. // Mirror pads to other side of board about the x axis, i.e. vertically.
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
pad->Flip( m_Pos.y ); pad->Flip( m_Pos );
// Mirror reference. // Mirror reference.
text = m_Reference; text = m_Reference;
......
...@@ -214,13 +214,13 @@ void D_PAD::SetOrientation( double aAngle ) ...@@ -214,13 +214,13 @@ void D_PAD::SetOrientation( double aAngle )
} }
void D_PAD::Flip( int aTranslationY ) void D_PAD::Flip( const wxPoint& aCentre )
{ {
int y = GetPosition().y - aTranslationY; int y = GetPosition().y - aCentre.y;
y = -y; // invert about x axis. y = -y; // invert about x axis.
y += aTranslationY; y += aCentre.y;
SetY( y ); SetY( y );
......
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
void SetOffset( const wxPoint& aOffset ) { m_Offset = aOffset; } void SetOffset( const wxPoint& aOffset ) { m_Offset = aOffset; }
const wxPoint& GetOffset() const { return m_Offset; } const wxPoint& GetOffset() const { return m_Offset; }
void Flip( int aTranslationY ); void Flip( const wxPoint& aCentre ); // Virtual function
/** /**
* Function SetOrientation * Function SetOrientation
......
...@@ -169,9 +169,13 @@ bool EDA_APP::OnInit() ...@@ -169,9 +169,13 @@ bool EDA_APP::OnInit()
bundledir.RemoveLastDir(); bundledir.RemoveLastDir();
// Prepend in PYTHONPATH the content of the bundle libraries ! // Prepend in PYTHONPATH the content of the bundle libraries !
wxSetEnv("PYTHONPATH",((wxGetenv("PYTHONPATH") != NULL ) ? (wxString(wxGetenv("PYTHONPATH")) + ":") : wxString("")) wxSetEnv("PYTHONPATH",((wxGetenv("PYTHONPATH") != NULL ) ? (wxString(wxGetenv("PYTHONPATH")) + ":") : wxString("")) +
+ bundledir.GetPath() + "/Library/Application Support/kicad/scripting" + ":" +
"/Frameworks/wxPython/lib/python2.6/site-packages/wx-3.0-osx_cocoa" ); bundledir.GetPath() + "/PlugIns" + ":" +
wxString( wxGetenv("HOME") ) + "/Library/Application Support/kicad/scripting" +
bundledir.GetPath() +
"/Frameworks/wxPython/lib/python2.6/site-packages/wx-3.0-osx_cocoa"
);
#endif #endif
#endif #endif
// On linux and osx, 2 others paths are // On linux and osx, 2 others paths are
......
...@@ -282,7 +282,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -282,7 +282,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
if( printMirror ) if( printMirror )
{ {
// Calculate the mirrored center of the board. // Calculate the mirrored center of the board.
center.y = m_Parent->GetPageSizeIU().y - boardBoundingBox.Centre().y; center.x = m_Parent->GetPageSizeIU().x - boardBoundingBox.Centre().x;
} }
offset += center; offset += center;
...@@ -301,21 +301,29 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -301,21 +301,29 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
screen->m_IsPrinting = true; screen->m_IsPrinting = true;
EDA_COLOR_T bg_color = g_DrawBgColor; EDA_COLOR_T bg_color = g_DrawBgColor;
// Print frame reference, if reqquested, before
if( m_PrintParams.m_Print_Black_and_White )
GRForceBlackPen( true );
if( m_PrintParams.PrintBorderAndTitleBlock() )
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS, titleblockFilename );
if( printMirror ) if( printMirror )
{ {
// To plot mirror, we reverse the y axis, and modify the plot y origin // To plot mirror, we reverse the x axis, and modify the plot x origin
dc->SetAxisOrientation( true, true ); dc->SetAxisOrientation( false, false);
/* Plot offset y is moved by the y plot area size in order to have /* Plot offset x is moved by the x plot area size in order to have
* the old draw area in the new draw area, because the draw origin has not moved * the old draw area in the new draw area, because the draw origin has not moved
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area * (this is the upper left corner) but the X axis is reversed, therefore the plotting area
* is the y coordinate values from - PlotAreaSize.y to 0 */ * is the x coordinate values from - PlotAreaSize.x to 0 */
int y_dc_offset = PlotAreaSizeInPixels.y; int x_dc_offset = PlotAreaSizeInPixels.x;
y_dc_offset = KiROUND( y_dc_offset * userscale ); x_dc_offset = KiROUND( x_dc_offset * userscale );
dc->SetDeviceOrigin( 0, y_dc_offset ); dc->SetDeviceOrigin( x_dc_offset, 0 );
wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ), wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ),
0, y_dc_offset ); x_dc_offset, 0 );
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ), panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ),
panel->GetClipBox()->GetSize() ) ); panel->GetClipBox()->GetSize() ) );
...@@ -359,13 +367,9 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -359,13 +367,9 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
printMirror, &m_PrintParams ); printMirror, &m_PrintParams );
GRForceBlackPen( false ); GRForceBlackPen( false );
} }
else
if( m_PrintParams.m_Print_Black_and_White )
GRForceBlackPen( true ); GRForceBlackPen( true );
if( m_PrintParams.PrintBorderAndTitleBlock() )
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS, titleblockFilename );
#if defined (GERBVIEW) #if defined (GERBVIEW)
// In B&W mode, do not force black pen for Gerbview // In B&W mode, do not force black pen for Gerbview
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
str_filename = str(filename) str_filename = str(filename)
if str_filename.endswith(".brd"): if str_filename.endswith(".brd"):
format = IO_MGR.LEGACY format = IO_MGR.LEGACY
if str_filename.endswith(".kicad_brd"): if str_filename.endswith(".kicad_pcb"):
format = IO_MGR.KICAD format = IO_MGR.KICAD
return SaveBoard(filename,self,format) return SaveBoard(filename,self,format)
......
...@@ -50,10 +50,11 @@ e.SetShape(S_SEGMENT) ...@@ -50,10 +50,11 @@ e.SetShape(S_SEGMENT)
module.Add(e) module.Add(e)
# save the PCB to disk # save the PCB to disk
module.SetLibRef("FPC"+str(pads)) fpid = FPID("FPC"+str(pads)) #the name in library
module.SetFPID( fpid )
try: try:
FootprintLibCreate("fpc40.mod") FootprintLibCreate("fpc40.mod")
except: except:
pass # we try to create, but may be it exists already pass # we try to create, but may be it exists already
FootprintSave("fpc40.mod",module) FootprintSave("fpc40.mod",module)
...@@ -33,10 +33,10 @@ for y in range (0,10): ...@@ -33,10 +33,10 @@ for y in range (0,10):
# save the PCB to disk # save the PCB to disk
pcb.Save("/tmp/my2.kicad_brd") pcb.Save("my2.kicad_pcb")
pcb.Save("/tmp/my2.brd") pcb.Save("my2.brd")
pcb = LoadBoard("/tmp/my2.brd") pcb = LoadBoard("my2.kicad_pcb")
print map( lambda x: x.GetReference() , list(pcb.GetModules())) print map( lambda x: x.GetReference() , list(pcb.GetModules()))
......
...@@ -109,18 +109,22 @@ class QFPWizard(pcbnew.FootprintWizardPlugin): ...@@ -109,18 +109,22 @@ class QFPWizard(pcbnew.FootprintWizardPlugin):
pad_size = pad_size_left_right pad_size = pad_size_left_right
pad_pos_x = -(pad_horizontal_pitch / 2) pad_pos_x = -(pad_horizontal_pitch / 2)
pad_pos_y = (cur_pad % (num_pads / 4)) * pad_pitch - (side_length / 2)
if side == 2: if side == 2:
pad_pos_x = -pad_pos_x pad_pos_x = -pad_pos_x
pad_pos_y = -pad_pos_y
pad_pos_y = (cur_pad % (num_pads / 4)) * pad_pitch - (side_length / 2)
else: else:
pad_size = pad_size_bottom_top pad_size = pad_size_bottom_top
pad_pos_x = (cur_pad % (num_pads / 4)) * pad_pitch - (side_length / 2) pad_pos_x = (cur_pad % (num_pads / 4)) * pad_pitch - (side_length / 2)
pad_pos_y = -(pad_vertical_pitch / 2) pad_pos_y = -(pad_vertical_pitch / 2)
if side == 1: if side == 1:
pad_pos_y = -pad_pos_y pad_pos_y = -pad_pos_y
else:
pad_pos_x = -pad_pos_x
pad_pos = pcbnew.wxPoint(pad_pos_x, pad_pos_y) pad_pos = pcbnew.wxPoint(pad_pos_x, pad_pos_y)
......
...@@ -307,7 +307,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar() ...@@ -307,7 +307,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
// Access to the scripting console // Access to the scripting console
#ifdef KICAD_SCRIPTING_WXPYTHON #ifdef KICAD_SCRIPTING_WXPYTHON
m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString, m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
KiBitmap( book_xpm ), KiBitmap( py_script_xpm ),
_( "Show/Hide the Scripting console" ) ); _( "Show/Hide the Scripting console" ) );
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
......
#!/bin/bash #!/bin/bash
# v 1.1 Supports migration of links (limited to the same directory) - I should add checks..
# usage osx_fixbundle.sh <bundle-name> <bzr_root> # usage osx_fixbundle.sh <bundle-name> <bzr_root>
if [[ ! -f version.h ]]; then if [[ ! -f version.h ]]; then
...@@ -11,7 +12,6 @@ fi ...@@ -11,7 +12,6 @@ fi
EXECUTABLES="`find . -name '*.app'`" EXECUTABLES="`find . -name '*.app'`"
# #
# Copies libraries under <bzr_root> in the bundle and relocates them in the binary # Copies libraries under <bzr_root> in the bundle and relocates them in the binary
# #
...@@ -29,7 +29,11 @@ function fixbundle() { ...@@ -29,7 +29,11 @@ function fixbundle() {
if [[ "$library" =~ "$bzroot" ]]; then if [[ "$library" =~ "$bzroot" ]]; then
echo "${exec}: Migrating `basename $library` in the bundle" echo "${exec}: Migrating `basename $library` in the bundle"
if [ ! -f ${exec}.app/Contents/Frameworks/`basename $library` ]; then if [ ! -f ${exec}.app/Contents/Frameworks/`basename $library` ]; then
if [ ! -L $library ]; then
cp -f $library ${execpath}${exec}.app/Contents/Frameworks cp -f $library ${execpath}${exec}.app/Contents/Frameworks
else
resolvelink "$library" "`dirname $library`" "${execpath}/${exec}.app/Contents/Frameworks"
fi
fi fi
install_name_tool -change $library @executable_path/../Frameworks/`basename $library` ${execpath}${exec}.app/Contents/MacOS/${exec} install_name_tool -change $library @executable_path/../Frameworks/`basename $library` ${execpath}${exec}.app/Contents/MacOS/${exec}
fi fi
...@@ -46,7 +50,11 @@ function fixbundle() { ...@@ -46,7 +50,11 @@ function fixbundle() {
for library in $LIBRARIES; do for library in $LIBRARIES; do
if [[ "$library" =~ "$bzroot" ]]; then if [[ "$library" =~ "$bzroot" ]]; then
if [ ! -f ${exec}.app/Contents/Frameworks/`basename $library` ]; then if [ ! -f ${exec}.app/Contents/Frameworks/`basename $library` ]; then
if [ ! -L $library ]; then
cp -f $library ${exec}.app/Contents/Frameworks cp -f $library ${exec}.app/Contents/Frameworks
else
resolvelink "$library" "`dirname $library`" "${execpath}/${exec}.app/Contents/Frameworks"
fi
fi fi
install_name_tool -change $library @executable_path/../Frameworks/`basename $library` $module install_name_tool -change $library @executable_path/../Frameworks/`basename $library` $module
fi fi
...@@ -70,7 +78,11 @@ function fixbundle() { ...@@ -70,7 +78,11 @@ function fixbundle() {
for library in $LIBRARIES; do for library in $LIBRARIES; do
if [[ "$library" =~ "$bzroot" ]]; then if [[ "$library" =~ "$bzroot" ]]; then
if [ ! -f ${exec}.app/Contents/Frameworks/`basename $library` ]; then if [ ! -f ${exec}.app/Contents/Frameworks/`basename $library` ]; then
if [ ! -L $library ]; then
cp -f $library ${exec}.app/Contents/Frameworks cp -f $library ${exec}.app/Contents/Frameworks
else
resolvelink "$library" "`dirname $library`" "${execpath}/${exec}.app/Contents/Frameworks"
fi
echo "copied `basename $library` into bundle" echo "copied `basename $library` into bundle"
(( dynlib_migrate += 1)) (( dynlib_migrate += 1))
fi fi
...@@ -84,8 +96,27 @@ function fixbundle() { ...@@ -84,8 +96,27 @@ function fixbundle() {
cd - >/dev/null cd - >/dev/null
} }
#
# This supports only links on the same dir (TODO ?)
#
#fixbundle $1 $2 $3 function resolvelink() {
local srclib="`basename $1`"
local srcpath="$2"
local destpath="$3"
#if is a file i expect a pointed ""
local pointed="`readlink ${srcpath}/${srclib}`"
if [ ! -f ${pointed} ]; then
resolvelink "${pointed}" "${srcpath}" "${destpath}"
echo "Link ${srclib} -> ${pointed} "
(cd "${destpath}"; ln -s "${pointed}" "${srclib}" )
else
echo "Copy ${srcpath}/${srclib} -> ${destpath} "
cp "${srcpath}/${srclib}" ${destpath}
fi
}
for executable in $EXECUTABLES; for executable in $EXECUTABLES;
do do
......
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