Commit f1e5be9a authored by jean-pierre charras's avatar jean-pierre charras

Fix @JP messages (no bugs, just comment lines)

Eeschema: Viewlib is now accessible from Libedit (to browse libs or load a component to edit)
Libedit: uses now the same dialog as the schematic editor to load a component
Some code cleaning.
parent 9ef6ae5b
......@@ -3,7 +3,6 @@
/*********************************/
#include <fctsys.h>
//#include "gr_basic.h"
#include <common.h>
#include <macros.h>
#include <wxstruct.h>
......@@ -46,6 +45,7 @@ void DIALOG_GET_COMPONENT::initDialog( wxArrayString& aHistoryList )
{
SetFocus();
m_GetExtraFunction = false;
m_selectionIsKeyword = false;
m_historyList->Append( aHistoryList );
if( !m_auxToolSelector )
{
......@@ -63,6 +63,7 @@ void DIALOG_GET_COMPONENT::OnCancel( wxCommandEvent& event )
void DIALOG_GET_COMPONENT::Accept( wxCommandEvent& event )
{
m_selectionIsKeyword = false;
switch( event.GetId() )
{
case ID_SEL_BY_LISTBOX:
......@@ -74,7 +75,8 @@ void DIALOG_GET_COMPONENT::Accept( wxCommandEvent& event )
break;
case ID_ACCEPT_KEYWORD:
m_Text = wxT( "= " ) + m_textCmpNameCtrl->GetValue();
m_selectionIsKeyword = true;
m_Text = m_textCmpNameCtrl->GetValue();
break;
case ID_LIST_ALL:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -113,10 +113,9 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
{
int i;
wxString msg;
wxString CmpName;
LIB_ALIAS* LibEntry = NULL;
LIB_ALIAS* libEntry = NULL;
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
......@@ -133,9 +132,10 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
return;
}
i = GetNameOfPartToLoad( this, m_library, CmpName );
wxArrayString historyList;
CmpName = SelectComponentFromLibrary( m_library->GetName(), historyList, true, NULL, NULL );
if( i == 0 )
if( CmpName.IsEmpty() )
return;
GetScreen()->ClrModify();
......@@ -149,19 +149,39 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
}
/* Load the new library component */
LibEntry = m_library->FindEntry( CmpName );
libEntry = m_library->FindEntry( CmpName );
CMP_LIBRARY* searchLib = m_library;
if( libEntry == NULL )
{ // Not found in the active library: search inside the full list
// (can happen when using Viewlib to load a component)
libEntry = CMP_LIBRARY::FindLibraryEntry( CmpName );
if( libEntry )
{
searchLib = libEntry->GetLibrary();
// The entry to load is not in the active lib
// Ask for a new active lib
wxString msg;
msg << _("The selected component is not in the active library");
msg << wxT("\n\n");
msg << _("Do you want to change the active library?");
if( IsOK( this, msg ) )
SelectActiveLibrary( searchLib );
}
}
if( LibEntry == NULL )
if( libEntry == NULL )
{
msg.Printf( _( "Component name \"%s\" not found in library \"%s\"." ),
GetChars( CmpName ),
GetChars( m_library->GetName() ) );
GetChars( searchLib->GetName() ) );
DisplayError( this, msg );
return;
}
if( ! LoadComponentFromCurrentLib( LibEntry ) )
return;
EXCHG( searchLib, m_library );
LoadComponentFromCurrentLib( libEntry );
EXCHG( searchLib, m_library );
DisplayLibInfos();
}
......
......@@ -100,6 +100,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::SaveActiveLibrary )
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::CreateNewLibraryPart )
EVT_TOOL( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnCreateNewPartFromExisting )
......
......@@ -23,6 +23,37 @@
*/
#include <sch_base_frame.h>
#include <viewlib_frame.h>
#include <libeditframe.h>
SCH_BASE_FRAME::SCH_BASE_FRAME( wxWindow* aParent,
id_drawframe aWindowType,
const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle ) :
EDA_DRAW_FRAME( aParent, aWindowType, aTitle, aPosition, aSize, aStyle )
{
m_ViewlibFrame = NULL;
m_LibeditFrame = NULL;
}
void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
{
if( m_ViewlibFrame )
{
m_ViewlibFrame->Show( true );
return;
}
if( m_LibeditFrame && m_LibeditFrame->m_ViewlibFrame )
{
m_LibeditFrame->m_ViewlibFrame->Show( true );
return;
}
m_ViewlibFrame = new LIB_VIEW_FRAME( this );
}
SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const
......
......@@ -27,10 +27,6 @@
* @file schframe.cpp
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <gr_basic.h>
......@@ -193,8 +189,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
m_showBorderAndTitleBlock = true; // true to show sheet references
m_CurrentSheet = new SCH_SHEET_PATH();
m_TextFieldSize = DEFAULT_SIZE_TEXT;
m_LibeditFrame = NULL; // Component editor frame.
m_ViewlibFrame = NULL; // Frame for browsing component libraries
m_DefaultSchematicFileName = NAMELESS_PROJECT;
m_DefaultSchematicFileName += wxT( ".sch" );
m_showAllPins = false;
......@@ -776,20 +770,6 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
}
}
void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
{
if( m_ViewlibFrame )
{
m_ViewlibFrame->Show( true );
}
else
{
m_ViewlibFrame = new LIB_VIEW_FRAME( this );
}
}
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
{
SCH_COMPONENT* component = NULL;
......
......@@ -118,6 +118,10 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString, KiBitmap( delete_xpm ),
_( "Delete component in current library" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString, KiBitmap( library_browse_xpm ),
HELP_RUN_LIB_VIEWER );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, KiBitmap( new_component_xpm ),
_( "Create a new component" ) );
......
......@@ -255,7 +255,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
{
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) wxGetApp().GetTopWindow();
SCH_BASE_FRAME* frame = (SCH_BASE_FRAME*) GetParent();
frame->SetLibraryViewerWindow( NULL );
}
......
......@@ -19,6 +19,7 @@ class DIALOG_GET_COMPONENT : public DIALOG_GET_COMPONENT_BASE
private:
bool m_auxToolSelector;
wxString m_Text;
bool m_selectionIsKeyword;
public:
bool m_GetExtraFunction;
......@@ -30,7 +31,21 @@ public:
bool show_extra_tool );
~DIALOG_GET_COMPONENT() {};
/**
* Function GetComponentName
* @return the selection (name or keyword)
*/
wxString GetComponentName( void );
/**
* Function IsKeyword
* @return true if the returned string is a keyword
*/
bool IsKeyword( void )
{
return m_selectionIsKeyword;
}
void SetComponentName( const wxString& name );
private:
......
......@@ -29,6 +29,8 @@
class PAGE_INFO;
class TITLE_BLOCK;
class LIB_VIEW_FRAME;
class LIB_EDIT_FRAME;
/**
......@@ -43,18 +45,27 @@ class TITLE_BLOCK;
*/
class SCH_BASE_FRAME : public EDA_DRAW_FRAME
{
protected:
LIB_VIEW_FRAME* m_ViewlibFrame; // A library viewer, common to SCH_EDIT_FRAME
// and LIB_EDIT_FRAME.
// has no meaning to LIB_VIEW_FRAME
LIB_EDIT_FRAME* m_LibeditFrame; // the library editor.
// Is used mainly in SCH_EDIT_FRAME
// but is defined here because some functions
// need to know if a library editor or a libray
// viewer is currently opened
public:
SCH_BASE_FRAME( wxWindow* aParent,
id_drawframe aWindowType,
const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE ) :
EDA_DRAW_FRAME( aParent, aWindowType, aTitle, aPosition, aSize, aStyle )
{
}
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
SCH_SCREEN* GetScreen() const; // overload EDA_DRAW_FRAME
void SetLibraryViewerWindow( LIB_VIEW_FRAME* aFrame ) { m_ViewlibFrame = aFrame; }
void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME
const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME
const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME
......@@ -64,6 +75,45 @@ public:
const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME
protected:
/**
* Function SelectComponentFromLibBrowser
* Calls the library viewer to select component to import into schematic.
* if the library viewer is currently running, it is closed and reopened
* in modal mode.
* @return the component name
*/
wxString SelectComponentFromLibBrowser( void );
/**
* Function SelectComponentFromLib
* Calls the library viewer to select component to import into schematic.
* if the library viewer is currently running, it is closed and reopened
* in modal mode.
* @param aLibname = the lib name or an empty string.
* if aLibname is empty, the full list of libraries is used
* @param aHistoryList = list of previously loaded components
* @param aUseLibBrowser = bool to call the library viewer to select the component
* @param aUnit = a point to int to return the selected unit (if any)
* @param aConvert = a point to int to return the selected De Morgan shape (if any)
*
* @return the component name
*/
wxString SelectComponentFromLibrary( const wxString& aLibname,
wxArrayString& aHistoryList,
bool aUseLibBrowser,
int* aUnit,
int* aConvert );
/**
* Function OnOpenLibraryViewer
* Open the library viewer only to browse library contents.
* If the viewed is already opened from this, raise the viewer
* If the viewed is already opened from an other window, close it and reopen
*/
void OnOpenLibraryViewer( wxCommandEvent& event );
};
#endif // SCH_BASE_FRAME_H_
......@@ -114,8 +114,6 @@ class SCH_EDIT_FRAME : public SCH_BASE_FRAME
{
private:
SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on.
LIB_VIEW_FRAME* m_ViewlibFrame;
LIB_EDIT_FRAME* m_LibeditFrame;
wxString m_DefaultSchematicFileName;
int m_TextFieldSize;
PARAM_CFG_ARRAY m_projectFileParams;
......@@ -204,8 +202,6 @@ public:
void SetLibraryEditorWindow( LIB_EDIT_FRAME* aFrame ) { m_LibeditFrame = aFrame; }
void SetLibraryViewerWindow( LIB_VIEW_FRAME* aFrame ) { m_ViewlibFrame = aFrame; }
bool GetShowAllPins() const { return m_showAllPins; }
void SetShowAllPins( bool aEnable ) { m_showAllPins = aEnable; }
......@@ -746,7 +742,6 @@ private:
void OnLoadProject( wxCommandEvent& event );
void OnOpenPcbnew( wxCommandEvent& event );
void OnOpenCvpcb( wxCommandEvent& event );
void OnOpenLibraryViewer( wxCommandEvent& event );
void OnOpenLibraryEditor( wxCommandEvent& event );
void OnSetOptions( wxCommandEvent& event );
void OnCancelCurrentCommand( wxCommandEvent& aEvent );
......@@ -874,11 +869,6 @@ private:
SCH_SHEET* CreateSheet( wxDC* DC );
void ReSizeSheet( SCH_SHEET* Sheet, wxDC* DC );
/**
* Use the component viewer to select component to import into schematic.
*/
wxString SelectFromLibBrowser( void );
public:
/**
* Function EditSheet
......
......@@ -56,7 +56,13 @@
#define BLOCK_COLOR BROWN
// Functions defined here, but used also in other files
// These 2 functions are used in modedit to rotate or mirror the whole footprint
// so they are called with force_all = true
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
// Local functions:
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
......@@ -64,8 +70,6 @@ static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
static void ClearMarkItems( MODULE* module );
static void CopyMarkedItems( MODULE* module, wxPoint offset );
static void MoveMarkedItems( MODULE* module, wxPoint offset );
static void MirrorMarkedItems( MODULE* module, wxPoint offset );
static void RotateMarkedItems( MODULE* module, wxPoint offset );
static void DeleteMarkedItems( MODULE* module );
......@@ -521,8 +525,10 @@ void DeleteMarkedItems( MODULE* module )
/** Mirror marked items, refer to a Vertical axis at position offset
* Note: because this function is used in global transform,
* if force_all is true, all items will be mirrored
*/
void MirrorMarkedItems( MODULE* module, wxPoint offset )
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
wxPoint tmp;
......@@ -533,9 +539,8 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{
// @JP why allow some pads to stay behind? Do not understand
// why this test is here.
if( !pad->IsSelected() )
// Skip pads not selected, i.e. not inside the block to mirror:
if( !pad->IsSelected() && !force_all )
continue;
tmp = pad->GetPosition();
......@@ -557,7 +562,8 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
for( EDA_ITEM* item = module->m_Drawings; item; item = item->Next() )
{
if( !item->IsSelected() ) // @JP why allow some graphics to stay behind?
// Skip items not selected, i.e. not inside the block to mirror:
if( !item->IsSelected() && !force_all )
continue;
switch( item->Type() )
......@@ -600,9 +606,11 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
}
/** Rotate marked items, refer to a Vertical axis at position offset
/** Rotate marked items, refer to a rotation point at position offset
* Note: because this function is used in global transform,
* if force_all is true, all items will be rotated
*/
void RotateMarkedItems( MODULE* module, wxPoint offset )
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
{
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
......@@ -611,7 +619,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{
if( !pad->IsSelected() )
if( !pad->IsSelected() && !force_all )
continue;
wxPoint pos = pad->GetPosition();
......@@ -624,7 +632,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
for( EDA_ITEM* item = module->m_Drawings; item; item = item->Next() )
{
if( !item->IsSelected() )
if( !item->IsSelected() && !force_all)
continue;
switch( item->Type() )
......
......@@ -178,10 +178,10 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
moduleName.MakeUpper();
if( moduleName[0] == '=' ) // Selection by keywords
if( dlg.IsKeyword() ) // Selection by keywords
{
AllowWildSeach = false;
keys = moduleName.AfterFirst( '=' );
keys = moduleName;
moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys );
if( moduleName.IsEmpty() ) /* Cancel command */
......
......@@ -28,6 +28,12 @@
#include <dialog_edit_module_for_Modedit.h>
// Functions defined in block_module_editor, but used here
// These 2 functions are used in modedit to rotate or mirror the whole footprint
// so they are called with force_all = true
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode )
{
......@@ -724,141 +730,57 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
{
D_PAD* pad = module->m_Pads;
EDA_ITEM* item = module->m_Drawings;
TEXTE_MODULE* textmod;
EDGE_MODULE* edgemod;
wxPoint pt;
wxSize size;
double angle = 900; // Necessary +- 900 (+- 90 degrees) )
TEXTE_MODULE* textmod;
wxPoint pos;
double angle = 900; // Necessary +- 900 (+- 90 degrees).
// Be prudent: because RotateMarkedItems is used to rotate some items
// used the same value as RotateMarkedItems
switch( transform )
{
case ID_MODEDIT_MODULE_ROTATE:
module->SetOrientation( angle );
for( ; pad; pad = pad->Next() )
{
pad->SetPos0( pad->GetPosition() );
pad->SetOrientation( pad->GetOrientation() - angle );
pt = pad->GetOffset();
RotatePoint( &pt, angle );
pad->SetOffset( pt );
size = pad->GetSize();
EXCHG( size.x, size.y );
pad->SetSize( size );
#define ROTATE( z ) RotatePoint( (&z), angle )
RotateMarkedItems( module, wxPoint(0,0), true );
size = pad->GetDelta();
RotatePoint( &size.x, &size.y, -angle );
pad->SetDelta( size );
}
module->m_Reference->SetPos0( module->m_Reference->m_Pos );
pos = module->m_Reference->GetPosition();
ROTATE( pos );
module->m_Reference->SetPosition( pos );
module->m_Reference->SetPos0( module->m_Reference->GetPosition() );
module->m_Reference->m_Orient += angle;
if( module->m_Reference->m_Orient >= 1800 )
module->m_Reference->m_Orient -= 1800;
pos = module->m_Value->GetPosition();
ROTATE( pos );
module->m_Value->SetPosition( pos );
module->m_Value->SetPos0( module->m_Value->m_Pos );
module->m_Value->m_Orient += angle;
if( module->m_Value->m_Orient >= 1800 )
module->m_Value->m_Orient -= 1800;
for( ; item != NULL; item = item->Next() )
{
if( item->Type() == PCB_MODULE_EDGE_T )
{
edgemod = (EDGE_MODULE*) item;
edgemod->SetStart0( edgemod->GetStart() );
edgemod->SetEnd0( edgemod->GetEnd() );
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
textmod = (TEXTE_MODULE*) item;
textmod->SetPos0( textmod->m_Pos );
}
}
module->m_Orient = 0;
break;
case ID_MODEDIT_MODULE_MIRROR:
for( ; pad; pad = pad->Next() )
{
pad->SetY( -pad->GetPosition().y );
pt = pad->GetPos0();
NEGATE( pt.y );
pad->SetPos0( pt );
pt = pad->GetOffset();
NEGATE( pt.y );
pad->SetOffset( pt );
size = pad->GetDelta();
NEGATE( size.y );
pad->SetDelta( size );
if( pad->GetOrientation() )
pad->SetOrientation( 3600 - pad->GetOrientation() );
}
// Reverse mirror of reference.
// Mirror reference.
textmod = module->m_Reference;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
NEGATE( textmod->m_Pos.x );
NEGATE( textmod->m_Pos0.x );
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
// Reverse mirror of value.
// Mirror value.
textmod = module->m_Value;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
NEGATE( textmod->m_Pos.x );
NEGATE( textmod->m_Pos0.x );
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
// Reverse mirror of footprints.
item = module->m_Drawings;
for( ; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
edgemod = (EDGE_MODULE*) item;
edgemod->SetStartY( -edgemod->GetStart().y );
edgemod->SetEndY( -edgemod->GetEnd().y );
// Invert local coordinates
NEGATE( edgemod->m_Start0.y );
NEGATE( edgemod->m_End0.y );
edgemod->SetAngle( -edgemod->GetAngle() );
break;
case PCB_MODULE_TEXT_T:
// Reverse mirror position and mirror.
textmod = (TEXTE_MODULE*) item;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
break;
default:
DisplayError( this, wxT( "Draw type undefined" ) );
break;
}
}
// Mirror pads and graphic items of the footprint:
MirrorMarkedItems( module, wxPoint(0,0), true );
break;
default:
......
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