Commit 671fabe1 authored by dickelbeck's avatar dickelbeck

edit component in schematic work

parent a1659e41
......@@ -5,6 +5,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Nov-25 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+eeschema
edit component in schematic editor. works except for field add, remove, move up.
2008-Nov-24 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+eeschema
......
/**********************************************************/
/* wxwineda.cpp - fonctions des classes du type WinEDAxxxx */
/**********************************************************/
/**********************************************************/
/* wxwineda.cpp - fonctions des classes du type WinEDAxxxx */
/**********************************************************/
#ifdef __GNUG__
#pragma implementation
......@@ -10,23 +10,31 @@
#include "common.h"
/**********************************************************************************/
/* Classe WinEDA_EnterText pour entrer une ligne texte au clavier dans les frames */
/**********************************************************************************/
WinEDA_EnterText::WinEDA_EnterText(wxWindow *parent, const wxString &Title,
const wxString & TextToEdit, wxBoxSizer * BoxSizer, const wxSize & Size )
WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
const wxString& Title,
const wxString& TextToEdit,
wxBoxSizer* BoxSizer,
const wxSize& Size )
{
m_Modify = FALSE;
if ( TextToEdit ) m_NewText = TextToEdit;
m_Modify = FALSE;
if( TextToEdit )
m_NewText = TextToEdit;
m_Title = new wxStaticText( parent, -1, Title );
m_Title->SetForegroundColour( wxColour( 200, 0, 0 ) );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_Title = new wxStaticText(parent, -1, Title);
m_Title->SetForegroundColour(wxColour(200,0,0) );
BoxSizer->Add(m_Title, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size );
m_FrameText = new wxTextCtrl(parent, -1, TextToEdit, wxDefaultPosition, Size);
m_FrameText->SetInsertionPoint(1);
BoxSizer->Add(m_FrameText, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_FrameText->SetInsertionPoint( 1 );
BoxSizer->Add( m_FrameText,
0,
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
}
......@@ -34,234 +42,289 @@ WinEDA_EnterText::WinEDA_EnterText(wxWindow *parent, const wxString &Title,
wxString WinEDA_EnterText::GetValue()
/****************************************/
{
m_Modify = m_FrameText->IsModified();
m_NewText = m_FrameText->GetValue();
return m_NewText;
m_Modify = m_FrameText->IsModified();
m_NewText = m_FrameText->GetValue();
return m_NewText;
}
void WinEDA_EnterText::GetValue(char * buffer, int lenmax)
void WinEDA_EnterText::GetValue( char* buffer, int lenmax )
{
m_Modify = m_FrameText->IsModified();
if (buffer)
{
m_NewText = m_FrameText->GetValue();
int ii, ll = m_NewText.Len();
for ( ii = 0; ii < ll && ii < (lenmax-1); ii++ );
buffer[ii] = m_NewText.GetChar(ii);
buffer[lenmax-1] = 0;
}
m_Modify = m_FrameText->IsModified();
if( buffer )
{
m_NewText = m_FrameText->GetValue();
int ii, ll = m_NewText.Len();
for( ii = 0; ii < ll && ii < (lenmax - 1); ii++ )
;
buffer[ii] = m_NewText.GetChar( ii );
buffer[lenmax - 1] = 0;
}
}
void WinEDA_EnterText::SetValue(const wxString & new_text)
void WinEDA_EnterText::SetValue( const wxString& new_text )
{
m_FrameText->SetValue(new_text);
m_FrameText->SetValue( new_text );
}
void WinEDA_EnterText::Enable(bool enbl)
void WinEDA_EnterText::Enable( bool enbl )
{
m_Title->Enable(enbl);
m_FrameText->Enable(enbl);
m_Title->Enable( enbl );
m_FrameText->Enable( enbl );
}
/*********************************************************************/
/* Classe pour editer un texte graphique + dimension en INCHES ou MM */
/*********************************************************************/
WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl(wxWindow *parent,
const wxString & Title,
const wxString & TextToEdit, int textsize,
int units, wxBoxSizer * BoxSizer, int framelen,
int internal_unit)
WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
const wxString& Title,
const wxString& TextToEdit, int textsize,
int units, wxBoxSizer* BoxSizer, int framelen,
int internal_unit )
{
m_Units = units;
m_Internal_Unit = internal_unit;
m_Title = NULL;
// Limitation de la taille du texte a de valeurs raisonnables
if ( textsize < 10 ) textsize = 10;
if ( textsize > 3000 ) textsize = 3000;
m_Units = units;
m_Internal_Unit = internal_unit;
m_Title = NULL;
m_Title = new wxStaticText( parent, -1, Title );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit );
m_Title = new wxStaticText(parent, -1, Title);
BoxSizer->Add(m_Title, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
BoxSizer->Add( m_FrameText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_FrameText = new wxTextCtrl(parent, -1, TextToEdit);
BoxSizer->Add(m_FrameText, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
if( !Title.IsEmpty() )
{
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_Units );
wxStaticText* text = new wxStaticText( parent, -1, msg );
if ( ! Title.IsEmpty())
{
wxString msg; msg = _("Size") + ReturnUnitSymbol(m_Units);
wxStaticText * text = new wxStaticText(parent, -1, msg);
BoxSizer->Add(text, 0, wxGROW|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
}
BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, 5 );
}
wxString value;
value.Printf(( m_Internal_Unit > 1000 ) ? wxT("%.4f") : wxT("%.3f"),
To_User_Unit(m_Units, textsize, m_Internal_Unit) );
m_FrameSize = new wxTextCtrl(parent, -1, value, wxDefaultPosition ,wxSize(70,-1));
BoxSizer->Add(m_FrameSize, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
wxString value = FormatSize( m_Internal_Unit, m_Units, textsize );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) );
BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl()
{
delete m_FrameText;
delete m_Title;
/* no, these are deleted by the BoxSizer
delete m_FrameText;
delete m_Title;
*/
}
wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, int units, int textSize )
{
wxString value;
// Limitation de la taille du texte a de valeurs raisonnables
if( textSize < 10 )
textSize = 10;
if( textSize > 3000 )
textSize = 3000;
value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
To_User_Unit( units, textSize, internalUnit ) );
return value;
}
void WinEDA_GraphicTextCtrl::SetTitle(const wxString & title)
void WinEDA_GraphicTextCtrl::SetTitle( const wxString& title )
{
m_Title->SetLabel(title);
m_Title->SetLabel( title );
}
void WinEDA_GraphicTextCtrl::SetValue(const wxString & value)
void WinEDA_GraphicTextCtrl::SetValue( const wxString& value )
{
m_FrameText->SetValue(value);
m_FrameText->SetValue( value );
}
void WinEDA_GraphicTextCtrl::SetValue(int value)
void WinEDA_GraphicTextCtrl::SetValue( int textSize )
{
wxString msg;
msg.Printf(( m_Internal_Unit > 1000 ) ? wxT("%.4f") : wxT("%.3f"),
To_User_Unit(m_Units, value, m_Internal_Unit) );
m_FrameSize->SetValue(msg);
wxString value = FormatSize( m_Internal_Unit, m_Units, textSize );
m_FrameSize->SetValue( value );
}
wxString WinEDA_GraphicTextCtrl::GetText()
{
wxString text = m_FrameText->GetValue();
return text;
wxString text = m_FrameText->GetValue();
return text;
}
int WinEDA_GraphicTextCtrl::GetTextSize()
int WinEDA_GraphicTextCtrl::ParseSize( const wxString& sizeText, int internalUnit, int units )
{
int textsize;
double dtmp;
m_FrameSize->GetValue().ToDouble(&dtmp);
textsize = (int)From_User_Unit( m_Units,
dtmp,
m_Internal_Unit);
// Limitation de la taille du texte a de valeurs raisonnables
if ( textsize < 10 ) textsize = 10;
if ( textsize > 3000 ) textsize = 3000;
return textsize;
int textsize;
double dtmp;
sizeText.ToDouble( &dtmp );
textsize = (int) From_User_Unit( units, dtmp, internalUnit );
// Limit to reasonable size
if( textsize < 10 )
textsize = 10;
if( textsize > 3000 )
textsize = 3000;
return textsize;
}
void WinEDA_GraphicTextCtrl::Enable(bool state)
int WinEDA_GraphicTextCtrl::GetTextSize()
{
m_FrameText->Enable(state);
return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_Units );
}
void WinEDA_GraphicTextCtrl::Enable( bool state )
{
m_FrameText->Enable( state );
}
/*****************************************************************/
/* Classe pour afficher et editer une coordonne en INCHES ou MM */
/*****************************************************************/
WinEDA_PositionCtrl::WinEDA_PositionCtrl(wxWindow *parent, const wxString & title,
const wxPoint & pos_to_edit, int units, wxBoxSizer * BoxSizer,
int internal_unit )
WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
const wxString& title,
const wxPoint& pos_to_edit,
int units,
wxBoxSizer* BoxSizer,
int internal_unit )
{
wxString text;
wxString text;
m_Units = units;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() )
text = _( "Pos " );
else
text = title;
text += _( "X" ) + ReturnUnitSymbol( m_Units );
m_TextX = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition );
BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_Units = units;
m_Internal_Unit = internal_unit;
if ( title.IsEmpty() ) text = _("Pos ");
else text = title;
text += _("X") + ReturnUnitSymbol(m_Units);
m_TextX = new wxStaticText(parent, -1, text );
BoxSizer->Add(m_TextX, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FramePosX = new wxTextCtrl(parent, -1, wxEmptyString, wxDefaultPosition );
BoxSizer->Add(m_FramePosX, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
if( title.IsEmpty() )
text = _( "Pos " );
else
text = title;
text += _( "Y" ) + ReturnUnitSymbol( m_Units );
m_TextY = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
if ( title.IsEmpty() ) text = _("Pos ");
else text = title;
text += _("Y") + ReturnUnitSymbol(m_Units);
m_TextY = new wxStaticText(parent, -1, text );
BoxSizer->Add(m_TextY, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString );
m_FramePosY = new wxTextCtrl(parent, -1, wxEmptyString );
BoxSizer->Add(m_FramePosY, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
SetValue(pos_to_edit.x, pos_to_edit.y);
BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
SetValue( pos_to_edit.x, pos_to_edit.y );
}
WinEDA_PositionCtrl::~WinEDA_PositionCtrl()
{
delete m_TextX;
delete m_TextY;
delete m_FramePosX;
delete m_FramePosY;
delete m_TextX;
delete m_TextY;
delete m_FramePosX;
delete m_FramePosY;
}
/******************************************/
wxPoint WinEDA_PositionCtrl::GetValue()
/******************************************/
/* Retourne (en unites internes) les coordonnes entrees (en unites utilisateur)
*/
*/
{
wxPoint coord;
double value = 0;
wxPoint coord;
double value = 0;
m_FramePosX->GetValue().ToDouble(&value);
coord.x = From_User_Unit(m_Units, value, m_Internal_Unit);
m_FramePosY->GetValue().ToDouble(&value);
coord.y = From_User_Unit(m_Units, value, m_Internal_Unit);
m_FramePosX->GetValue().ToDouble( &value );
coord.x = From_User_Unit( m_Units, value, m_Internal_Unit );
m_FramePosY->GetValue().ToDouble( &value );
coord.y = From_User_Unit( m_Units, value, m_Internal_Unit );
return coord;
return coord;
}
/************************************************************/
void WinEDA_PositionCtrl::Enable(bool x_win_on, bool y_win_on)
void WinEDA_PositionCtrl::Enable( bool x_win_on, bool y_win_on )
/************************************************************/
{
m_FramePosX->Enable(x_win_on);
m_FramePosY->Enable(y_win_on);
m_FramePosX->Enable( x_win_on );
m_FramePosY->Enable( y_win_on );
}
/***********************************************************/
void WinEDA_PositionCtrl::SetValue(int x_value, int y_value)
void WinEDA_PositionCtrl::SetValue( int x_value, int y_value )
/***********************************************************/
{
wxString msg;
m_Pos_To_Edit.x = x_value;
m_Pos_To_Edit.y = y_value;
msg = ReturnStringFromValue(m_Units, m_Pos_To_Edit.x, m_Internal_Unit);
m_FramePosX->Clear();
m_FramePosX->SetValue(msg);
msg = ReturnStringFromValue(m_Units, m_Pos_To_Edit.y, m_Internal_Unit);
m_FramePosY->Clear();
m_FramePosY->SetValue(msg);
}
/*******************/
/* WinEDA_SizeCtrl */
/*******************/
WinEDA_SizeCtrl::WinEDA_SizeCtrl(wxWindow *parent, const wxString & title,
const wxSize & size_to_edit,
int units, wxBoxSizer * BoxSizer,
int internal_unit):
WinEDA_PositionCtrl(parent, title,
wxPoint(size_to_edit.x, size_to_edit.y),
units, BoxSizer, internal_unit)
wxString msg;
m_Pos_To_Edit.x = x_value;
m_Pos_To_Edit.y = y_value;
msg = ReturnStringFromValue( m_Units, m_Pos_To_Edit.x, m_Internal_Unit );
m_FramePosX->Clear();
m_FramePosX->SetValue( msg );
msg = ReturnStringFromValue( m_Units, m_Pos_To_Edit.y, m_Internal_Unit );
m_FramePosY->Clear();
m_FramePosY->SetValue( msg );
}
/*******************/
/* WinEDA_SizeCtrl */
/*******************/
WinEDA_SizeCtrl::WinEDA_SizeCtrl( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit,
int units, wxBoxSizer* BoxSizer,
int internal_unit ) :
WinEDA_PositionCtrl( parent, title,
wxPoint( size_to_edit.x, size_to_edit.y ),
units, BoxSizer, internal_unit )
{
}
/*************************************/
wxSize WinEDA_SizeCtrl::GetValue()
/*************************************/
{
wxPoint pos = WinEDA_PositionCtrl::GetValue();
wxSize size;
size.x = pos.x;
size.y = pos.y;
return size;
wxPoint pos = WinEDA_PositionCtrl::GetValue();
wxSize size;
size.x = pos.x;
size.y = pos.y;
return size;
}
......@@ -270,110 +333,127 @@ wxSize size;
/***********************************************************************/
/* Unites:
si units = 0 : unite = inch
si units = 1 : unite = mm
si units >1 : affichage direct
*/
WinEDA_ValueCtrl::WinEDA_ValueCtrl(wxWindow *parent, const wxString & title,
int value, int units, wxBoxSizer *BoxSizer,
int internal_unit )
* si units = 0 : unite = inch
* si units = 1 : unite = mm
* si units >1 : affichage direct
*/
WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title,
int value, int units, wxBoxSizer* BoxSizer,
int internal_unit )
{
wxString label = title;
wxString label = title;
m_Units = units;
m_Internal_Unit = internal_unit;
m_Value = value;
label += ReturnUnitSymbol(m_Units);
m_Units = units;
m_Internal_Unit = internal_unit;
m_Value = value;
label += ReturnUnitSymbol( m_Units );
m_Text = new wxStaticText(parent, -1, label);
BoxSizer->Add(m_Text, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
wxString stringvalue = ReturnStringFromValue(m_Units, m_Value,m_Internal_Unit);
m_ValueCtrl = new wxTextCtrl(parent, -1, stringvalue);
BoxSizer->Add(m_ValueCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_Text = new wxStaticText( parent, -1, label );
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
wxString stringvalue = ReturnStringFromValue( m_Units, m_Value, m_Internal_Unit );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl,
0,
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
}
WinEDA_ValueCtrl::~WinEDA_ValueCtrl()
{
delete m_ValueCtrl;
delete m_Text;
delete m_ValueCtrl;
delete m_Text;
}
/***********************************/
int WinEDA_ValueCtrl::GetValue()
/***********************************/
{
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ReturnValueFromString(m_Units, txtvalue, m_Internal_Unit);
return coord;
coord = ReturnValueFromString( m_Units, txtvalue, m_Internal_Unit );
return coord;
}
/********************************************/
void WinEDA_ValueCtrl::SetValue(int new_value)
void WinEDA_ValueCtrl::SetValue( int new_value )
/********************************************/
{
wxString buffer;
m_Value = new_value;
wxString buffer;
m_Value = new_value;
buffer = ReturnStringFromValue(m_Units, m_Value, m_Internal_Unit);
m_ValueCtrl->SetValue(buffer);
buffer = ReturnStringFromValue( m_Units, m_Value, m_Internal_Unit );
m_ValueCtrl->SetValue( buffer );
}
/* Active ou desactive la frame: */
void WinEDA_ValueCtrl::Enable(bool enbl)
void WinEDA_ValueCtrl::Enable( bool enbl )
{
m_ValueCtrl->Enable(enbl);
m_Text->Enable(enbl);
m_ValueCtrl->Enable( enbl );
m_Text->Enable( enbl );
}
/***************************************************************/
/* Classe pour afficher et editer une valeur en double flottant*/
/***************************************************************/
WinEDA_DFloatValueCtrl::WinEDA_DFloatValueCtrl(wxWindow *parent, const wxString & title,
double value, wxBoxSizer * BoxSizer )
WinEDA_DFloatValueCtrl::WinEDA_DFloatValueCtrl( wxWindow* parent, const wxString& title,
double value, wxBoxSizer* BoxSizer )
{
wxString buffer;
wxString label = title;
wxString buffer;
wxString label = title;
m_Value = value;
m_Value = value;
m_Text = new wxStaticText(parent, -1, label );
BoxSizer->Add(m_Text, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
m_Text = new wxStaticText( parent, -1, label );
buffer.Printf(wxT("%lf"), m_Value);
m_ValueCtrl = new wxTextCtrl(parent, -1, buffer );
BoxSizer->Add(m_ValueCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
buffer.Printf( wxT( "%lf" ), m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, buffer );
BoxSizer->Add( m_ValueCtrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
WinEDA_DFloatValueCtrl::~WinEDA_DFloatValueCtrl()
{
delete m_ValueCtrl;
delete m_Text;
delete m_ValueCtrl;
delete m_Text;
}
double WinEDA_DFloatValueCtrl::GetValue()
{
double coord = 0;
double coord = 0;
m_ValueCtrl->GetValue().ToDouble(&coord);
return coord;
m_ValueCtrl->GetValue().ToDouble( &coord );
return coord;
}
void WinEDA_DFloatValueCtrl::SetValue(double new_value)
void WinEDA_DFloatValueCtrl::SetValue( double new_value )
{
wxString buffer;
m_Value = new_value;
wxString buffer;
m_Value = new_value;
buffer.Printf( wxT("%lf"), m_Value);
m_ValueCtrl->SetValue(buffer);
buffer.Printf( wxT( "%lf" ), m_Value );
m_ValueCtrl->SetValue( buffer );
}
/* Active ou desactive la frame: */
void WinEDA_DFloatValueCtrl::Enable(bool enbl)
void WinEDA_DFloatValueCtrl::Enable( bool enbl )
{
m_ValueCtrl->Enable(enbl);
m_Text->Enable(enbl);
m_ValueCtrl->Enable( enbl );
m_Text->Enable( enbl );
}
......@@ -683,7 +683,8 @@ int SCH_COMPONENT::GetRotationMiroir()
{
if( memcmp( TempMat, m_Transform, sizeof(MatNormal) ) == 0 )
{
found = TRUE; break;
found = TRUE;
break;
}
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
}
......@@ -697,7 +698,8 @@ int SCH_COMPONENT::GetRotationMiroir()
{
if( memcmp( TempMat, m_Transform, sizeof(MatNormal) ) == 0 )
{
found = TRUE; break;
found = TRUE;
break;
}
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
}
......@@ -712,7 +714,8 @@ int SCH_COMPONENT::GetRotationMiroir()
{
if( memcmp( TempMat, m_Transform, sizeof(MatNormal) ) == 0 )
{
found = TRUE; break;
found = TRUE;
break;
}
SetRotationMiroir( CMP_ROTATE_COUNTERCLOCKWISE );
}
......@@ -726,7 +729,8 @@ int SCH_COMPONENT::GetRotationMiroir()
}
else
{
wxBell(); return CMP_NORMAL;
wxBell();
return CMP_NORMAL;
}
}
......
......@@ -193,6 +193,12 @@ public:
*/
void AddField( const SCH_CMP_FIELD& aField );
void SetFields( const SCH_CMP_FIELDS& aFields )
{
m_Fields = aFields; // vector copying, length is changed possibly
}
/**
* Function GetFieldCount
* returns the number of fields in this component.
......
......@@ -15,6 +15,9 @@
#include "dialog_edit_component_in_schematic.h"
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
/**********************************************************************/
void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
SCH_COMPONENT* aComponent )
......@@ -35,8 +38,6 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
frame->InitBuffers( aComponent );
// frame->Layout();
frame->ShowModal();
frame->Destroy();
}
......@@ -45,54 +46,12 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
}
#if 0
/*********************************************************************/
void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/*********************************************************************/
{
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
// save old component in undo list
if( g_ItemToUndoCopy && g_ItemToUndoCopy->Type() == component->Type() )
{
component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
frame->SaveCopyInUndoList( component, IS_CHANGED );
component->SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
}
m_AddExtraText = 0;
if( m_FieldId == REFERENCE )
{
EDA_LibComponentStruct* part;
part = FindLibPart( component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( part )
{
if( part->m_UnitCount > 1 )
m_AddExtraText = 1;
}
}
Draw( frame->DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE );
m_Flags = 0;
frame->GetScreen()->SetCurItem( NULL );
frame->GetScreen()->SetModify();
}
#endif
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ) :
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( parent )
{
m_Parent = (WinEDA_SchematicFrame*) parent;
m_SelectedRow = 0;
m_LibEntry = 0;
wxListItem columnLabel;
......@@ -104,9 +63,18 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
columnLabel.SetText( _("Value") );
fieldListCtrl->InsertColumn( 1, columnLabel );
// these must go here late in the game.
fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UnitMetric );
textSizeLabel->SetLabel( label );
label = _( "Pos " );
label += _( "X" );
label += ReturnUnitSymbol( g_UnitMetric );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UnitMetric );
posYLabel->SetLabel( label );
copySelectedFieldToPanel();
......@@ -117,7 +85,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
{
D(printf("OnListItemDeselected()\n");)
copyPanelToSelectedField();
if( !copyPanelToSelectedField() )
event.Skip(); // do not go to the next row
}
......@@ -125,80 +95,163 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event
{
D(printf("OnListItemSelected()\n");)
m_SelectedRow = event.GetIndex();
// remember the selected row, statically
s_SelectedRow = event.GetIndex();
copySelectedFieldToPanel();
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
{
fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
fieldListCtrl->EnsureVisible( aFieldNdx );
EndModal( 1 );
}
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
{
return m_SelectedRow;
}
wxString newname = chipnameTextCtrl->GetValue();
newname.MakeUpper();
newname.Replace( wxT( " " ), wxT( "_" ) );
if( newname.IsEmpty() )
DisplayError( this, _( "No Component Name!" ) );
#if 0
/*****************************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
/*****************************************************************************/
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
{
if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL )
{
wxString message;
message.Printf( _( "Component [%s] not found!" ), newname.GetData() );
DisplayError( this, message );
}
else // Changement de composant!
{
m_Cmp->m_ChipName = newname;
}
}
/* Replace le composant en position normale, dimensions et positions
* fields comme definies en librairie
*/
{
EDA_LibComponentStruct* Entry;
// Mise a jour de la representation:
if( convertCheckBox->IsEnabled() )
{
m_Cmp->m_Convert = convertCheckBox->GetValue() ? 2 : 1;
}
if( m_Cmp == NULL )
return;
//Set the part selection in multiple part per pakcage
if( m_Cmp->m_Multi )
{
int unit_selection = unitChoice->GetCurrentSelection() + 1;
m_Cmp->SetUnitSelection( m_Parent->GetSheet(), unit_selection );
m_Cmp->m_Multi = unit_selection;
}
Entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
switch( orientationRadioBox->GetSelection() )
{
case 0:
m_Cmp->SetRotationMiroir( CMP_ORIENT_0 );
break;
if( Entry == NULL )
return;
case 1:
m_Cmp->SetRotationMiroir( CMP_ORIENT_90 );
break;
wxClientDC dc( m_Parent->DrawPanel );
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
case 2:
m_Cmp->SetRotationMiroir( CMP_ORIENT_180 );
break;
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
case 3:
m_Cmp->SetRotationMiroir( CMP_ORIENT_270 );
break;
}
/* Mise aux valeurs par defaut des champs et orientation */
m_Cmp->GetField( REFERENCE )->m_Pos.x =
Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x;
int mirror = mirrorRadioBox->GetSelection();
switch( mirror )
{
case 0:
break;
m_Cmp->GetField( REFERENCE )->m_Pos.y =
Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y;
case 1:
m_Cmp->SetRotationMiroir( CMP_MIROIR_X );
break;
m_Cmp->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
m_Cmp->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
m_Cmp->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
m_Cmp->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify;
case 2:
m_Cmp->SetRotationMiroir( CMP_MIROIR_Y );
break;
}
}
m_Cmp->GetField( VALUE )->m_Pos.x =
Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x;
m_Cmp->GetField( VALUE )->m_Pos.y =
Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y;
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event )
{
if( !copyPanelToSelectedField() )
return;
m_Cmp->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient;
m_Cmp->GetField( VALUE )->m_Size = Entry->m_Name.m_Size;
m_Cmp->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify;
m_Cmp->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify;
copyPanelToOptions();
m_Cmp->SetRotationMiroir( CMP_NORMAL );
/* save old cmp in undo list if not already in edit, or moving ... */
if( m_Cmp->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED );
// change all field positions from relative to absolute
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
{
m_FieldsBuf[i].m_Pos += m_Cmp->m_Pos;
}
// delete any fields with no name
for( unsigned i=FIELD1; i<m_FieldsBuf.size(); )
{
if( m_FieldsBuf[i].m_Name.IsEmpty() )
{
m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
continue;
}
++i;
}
EDA_LibComponentStruct* entry = FindLibPart(
m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( entry && entry->m_Options == ENTRY_POWER )
m_FieldsBuf[VALUE].m_Text = m_Cmp->m_ChipName;
// copy all the fields back, and change the length of m_Fields.
m_Cmp->SetFields( m_FieldsBuf );
m_Parent->GetScreen()->SetModify();
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
EndModal( 1 );
m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, NULL );
m_Parent->DrawPanel->Refresh( TRUE );
EndModal( 0 );
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
{
/* deselect old selection, but I think this is done by single selection flag within fieldListCtrl
fieldListCtrl->SetItemState( s_SelectedRow, 0, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
*/
if( aFieldNdx >= (int) m_FieldsBuf.size() )
aFieldNdx = m_FieldsBuf.size() - 1;
if( aFieldNdx < 0 )
aFieldNdx = 0;
fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
fieldListCtrl->EnsureVisible( aFieldNdx );
s_SelectedRow = aFieldNdx;
}
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
{
return s_SelectedRow;
}
#endif
/*******************************************************************************/
......@@ -207,20 +260,52 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
{
m_Cmp = aComponent;
m_LibEntry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
#if 0 && defined(DEBUG)
for( int i=0; i<aComponent->GetFieldCount(); ++i )
{
printf("Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].m_Pos.x,
aComponent->m_Fields[i].m_Pos.y );
}
#endif
// copy all the fields to a work area
m_FieldsBuf = aComponent->m_Fields;
#if 0 && defined(DEBUG)
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
{
printf("m_FieldsBuf[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
m_FieldsBuf[i].m_Pos.y );
}
#endif
m_FieldsBuf[REFERENCE].m_Text = m_Cmp->GetRef( m_Parent->GetSheet() );
for( int ii = 0; ii < aComponent->GetFieldCount(); ++ii )
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
{
// make the editable field position relative to the component
m_FieldsBuf[ii].m_Pos -= m_Cmp->m_Pos;
m_FieldsBuf[i].m_Pos -= m_Cmp->m_Pos;
setRowItem( ii, m_FieldsBuf[ii] );
setRowItem( i, m_FieldsBuf[i] );
}
setSelectedFieldNdx( REFERENCE );
#if 0 && defined(DEBUG)
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
{
printf("after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
m_FieldsBuf[i].m_Pos.y );
}
#endif
copyOptionsToPanel();
// put focus on the list ctrl
fieldListCtrl->SetFocus();
// resume editing at the last row edited, last time dialog was up.
setSelectedFieldNdx( s_SelectedRow );
}
......@@ -228,7 +313,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_CM
{
wxASSERT( aFieldNdx >= 0 );
// insert blanks if aFieldNdx is referencing a yet to be defined row
// insert blanks if aFieldNdx is referencing a "yet to be defined" row
while( aFieldNdx >= fieldListCtrl->GetItemCount() )
{
long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
......@@ -247,7 +332,6 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_CM
}
/****************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
/****************************************************************/
......@@ -259,294 +343,188 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx];
showCheckBox->SetValue( !(field.m_Attributs & TEXT_NO_VISIBLE) );
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
fieldNameTextCtrl->SetValue( field.m_Name );
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable editing
fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 );
// fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 );
fieldNameTextCtrl->SetEditable( fieldNdx >= FIELD1 );
fieldValueTextCtrl->SetValue( field.m_Text );
/*
if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER )
m_FieldTextCtrl->Enable( FALSE );
*/
fieldValueTextCtrl->Enable( FALSE );
showCheckBox->SetValue( !(field.m_Attributs & TEXT_NO_VISIBLE) );
textSizeTextCtrl->SetValue(
WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT, g_UnitMetric, field.m_Size.x ) );
// If the field value is empty and the position is zero, we set the
wxPoint coord = field.m_Pos;
wxPoint zero = -m_Cmp->m_Pos; // relative zero
// If the field value is empty and the position is at relative zero, we set the
// initial position as a small offset from the ref field, and orient
// it the same as the ref field. That is likely to put it at least
// close to the desired position.
if( field.m_Pos == wxPoint( 0, 0 ) && field.m_Text.IsEmpty() )
{
wxString dim;
// @todo look at the dedicated position control for this.
dim.Printf( wxT("%d"), m_FieldsBuf[REFERENCE].m_Pos.x + (fieldNdx-FIELD1+1)*100 );
posXTextCtrl->SetValue( dim );
dim.Printf( wxT("%d"), m_FieldsBuf[REFERENCE].m_Pos.y + (fieldNdx-FIELD1+1)*100 );
posYTextCtrl->SetValue( dim );
}
else
if( coord == zero && field.m_Text.IsEmpty() )
{
wxString dim;
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].m_Orient == TEXT_ORIENT_VERT );
dim.Printf( wxT("%d"), field.m_Pos.x );
posXTextCtrl->SetValue( dim );
coord.x = m_FieldsBuf[REFERENCE].m_Pos.x + (fieldNdx-FIELD1+1)*100;
coord.y = m_FieldsBuf[REFERENCE].m_Pos.y + (fieldNdx-FIELD1+1)*100;
dim.Printf( wxT("%d"), field.m_Pos.y );
posYTextCtrl->SetValue( dim );
// coord can compute negative if field is < FIELD1, e.g. FOOTPRINT.
// That is ok, we basically don't want all the new empty fields on
// top of each other.
}
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
#if 0
m_FieldNameCtrl->SetValue( m_FieldName[fieldNdx] );
wxString coordText = ReturnStringFromValue( g_UnitMetric, coord.x, EESCHEMA_INTERNAL_UNIT );
posXTextCtrl->SetValue( coordText );
m_FieldTextCtrl->SetValue( m_FieldText[fieldNdx] );
m_FieldTextCtrl->SetValue( m_FieldSize[fieldNdx] );
#endif
coordText = ReturnStringFromValue( g_UnitMetric, coord.y, EESCHEMA_INTERNAL_UNIT );
posYTextCtrl->SetValue( coordText );
}
/*****************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
/*****************************************************************/
{
unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx >= m_FieldsBuf.size() )
return;
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
return true;
SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx];
if( showCheckBox->GetValue() )
field.m_Attributs &= ~TEXT_NO_VISIBLE;
else
field.m_Attributs |= TEXT_NO_VISIBLE;
if( rotateCheckBox->GetValue() )
field.m_Orient = TEXT_ORIENT_VERT;
else
field.m_Orient = TEXT_ORIENT_HORIZ;
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
field.m_Name = fieldNameTextCtrl->GetValue();
field.m_Text = fieldValueTextCtrl->GetValue();
// field.m_Size =
setRowItem( fieldNdx, field ); // update fieldListCtrl
// m_FieldPosition[id] = m_FieldPositionCtrl->GetValue();
// m_FieldSize[id] = m_FieldTextCtrl->GetTextSize();
}
field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize( textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UnitMetric );
field.m_Size.y = field.m_Size.x;
double value;
#if 0
posXTextCtrl->GetValue().ToDouble( &value );
field.m_Pos.x = From_User_Unit( g_UnitMetric, value, EESCHEMA_INTERNAL_UNIT );
/*************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::fillTableModel()
/*************************************************************/
{
}
posYTextCtrl->GetValue().ToDouble( &value );
field.m_Pos.y = From_User_Unit( g_UnitMetric, value, EESCHEMA_INTERNAL_UNIT );
return true;
}
/**********************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::buildPanelBasic()
/**********************************************************/
/* create the basic panel for component properties editing
*/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
{
int Nb_Max_Unit = m_SelectUnit->GetCount();
int ii;
int nb_units = m_LibEntry ? MAX( m_LibEntry->m_UnitCount, 1 ) : 0;
int choiceCount = unitChoice->GetCount();
// Disable non existant units selection buttons
for( ii = nb_units; ii < Nb_Max_Unit; ii++ )
{
m_SelectUnit->Enable( ii, FALSE );
}
if( m_Cmp->m_Multi <= choiceCount )
unitChoice->SetSelection( m_Cmp->m_Multi - 1 );
if( m_Cmp->m_Multi <= Nb_Max_Unit )
m_SelectUnit->SetSelection( m_Cmp->m_Multi - 1 );
int orientation = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y);
ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y);
// if we don't change it, the default selection of the radio box is "0".
if( orientation == CMP_ORIENT_90 )
orientationRadioBox->SetSelection( 1 );
else if( orientation == CMP_ORIENT_180 )
orientationRadioBox->SetSelection( 2 );
else if( orientation == CMP_ORIENT_270 )
orientationRadioBox->SetSelection( 3 );
if( ii == CMP_ORIENT_90 )
m_OrientUnit->SetSelection( 1 );
else if( ii == CMP_ORIENT_180 )
m_OrientUnit->SetSelection( 2 );
else if( ii == CMP_ORIENT_270 )
m_OrientUnit->SetSelection( 3 );
int mirror = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y);
ii = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y);
if( ii == CMP_MIROIR_X )
m_MirrorUnit->SetSelection( 1 );
else if( ii == CMP_MIROIR_Y )
m_MirrorUnit->SetSelection( 2 );
if( mirror == CMP_MIROIR_X )
{
mirrorRadioBox->SetSelection( 1 );
D(printf("mirror=X,1\n");)
}
else if( mirror == CMP_MIROIR_Y )
{
mirrorRadioBox->SetSelection( 2 );
D(printf("mirror=Y,2\n");)
}
// Positionnement de la selection normal/convert
if( m_Cmp->m_Convert > 1 )
m_ConvertButt->SetValue( TRUE );
convertCheckBox->SetValue( true );
if( (m_LibEntry == NULL) || LookForConvertPart( m_LibEntry ) <= 1 )
if( m_LibEntry == NULL || LookForConvertPart( m_LibEntry ) <= 1 )
{
m_ConvertButt->Enable( FALSE );
convertCheckBox->Enable( false );
}
// Show the "Parts Locked" option:
// Show the "Parts Locked" option?
if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked )
{
m_MsgPartLocked->Show( false );
D(printf("partsAreLocked->false\n");)
partsAreLockedLabel->Show( false );
}
// Positionnement de la reference en librairie
m_RefInLib->SetValue( m_Cmp->m_ChipName );
chipnameTextCtrl->SetValue( m_Cmp->m_ChipName );
}
/*************************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::selectNewField( wxCommandEvent& event )
/*************************************************************************/
/* called when changing the current field selected
* Save the current field settings in buffer and display the new one
*/
/*****************************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
/*****************************************************************************/
{
CopyPanelFieldToData();
m_CurrentFieldId = m_FieldSelection->GetSelection();
CopyDataToPanelField();
}
EDA_LibComponentStruct* entry;
if( m_Cmp == NULL )
return;
/***********************************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::ComponentPropertiesAccept( wxCommandEvent& event )
/***********************************************************************************/
/* Update the new parameters for the current edited component
*/
{
wxPoint cmp_pos = m_Cmp->m_Pos;
wxClientDC dc( m_Parent->DrawPanel );
wxString newname;
/* save old cmp in undo list if not already in edit, or moving ... */
if( m_Cmp->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED );
entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
CopyPanelFieldToData();
if( entry == NULL )
return;
wxClientDC dc( m_Parent->DrawPanel );
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
newname = m_RefInLib->GetValue();
newname.MakeUpper();
newname.Replace( wxT( " " ), wxT( "_" ) );
if( newname.IsEmpty() )
DisplayError( this, _( "No Component Name!" ) );
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
{
if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL )
{
wxString message;
message.Printf( _( "Component [%s] not found!" ), newname.GetData() );
DisplayError( this, message );
}
else // Changement de composant!
{
m_Cmp->m_ChipName = newname;
}
}
// Mise a jour de la representation:
if( m_ConvertButt->IsEnabled() )
(m_ConvertButt->GetValue() == TRUE) ?
m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1;
//Set the part selection in multiple part per pakcage
if( m_Cmp->m_Multi )
{
int unit_selection = m_SelectUnit->GetSelection() + 1;
m_Cmp->SetUnitSelection( m_Parent->GetSheet(), unit_selection );
m_Cmp->m_Multi = unit_selection;
}
//Mise a jour de l'orientation:
switch( m_OrientUnit->GetSelection() )
{
case 0:
m_Cmp->SetRotationMiroir( CMP_ORIENT_0 );
break;
case 1:
m_Cmp->SetRotationMiroir( CMP_ORIENT_90 );
break;
case 2:
m_Cmp->SetRotationMiroir( CMP_ORIENT_180 );
break;
case 3:
m_Cmp->SetRotationMiroir( CMP_ORIENT_270 );
break;
}
switch( m_MirrorUnit->GetSelection() )
{
case 0:
break;
case 1:
m_Cmp->SetRotationMiroir( CMP_MIROIR_X );
break;
case 2:
m_Cmp->SetRotationMiroir( CMP_MIROIR_Y );
break;
}
/* Mise aux valeurs par defaut des champs et orientation */
m_Cmp->GetField( REFERENCE )->m_Pos.x =
entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x;
m_Cmp->GetField( REFERENCE )->m_Pos.y =
entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y;
m_Cmp->GetField( REFERENCE )->m_Orient = entry->m_Prefix.m_Orient;
m_Cmp->GetField( REFERENCE )->m_Size = entry->m_Prefix.m_Size;
m_Cmp->GetField( REFERENCE )->m_HJustify = entry->m_Prefix.m_HJustify;
m_Cmp->GetField( REFERENCE )->m_VJustify = entry->m_Prefix.m_VJustify;
m_Cmp->GetField( VALUE )->m_Pos.x =
entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x;
m_Cmp->GetField( VALUE )->m_Pos.y =
entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y;
m_Cmp->GetField( VALUE )->m_Orient = entry->m_Name.m_Orient;
m_Cmp->GetField( VALUE )->m_Size = entry->m_Name.m_Size;
m_Cmp->GetField( VALUE )->m_HJustify = entry->m_Name.m_HJustify;
m_Cmp->GetField( VALUE )->m_VJustify = entry->m_Name.m_VJustify;
// Mise a jour des textes (update the texts)
for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
{
if( ii == REFERENCE ) // la reference ne peut etre vide
{
if( !m_FieldText[ii].IsEmpty() )
m_Cmp->SetRef(m_Parent->GetSheet(), m_FieldText[ii]);
}
else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER
{
EDA_LibComponentStruct* Entry = FindLibPart( m_Cmp->m_ChipName.GetData(
), wxEmptyString, FIND_ROOT );
if( Entry && (Entry->m_Options == ENTRY_POWER) )
m_Cmp->GetField( ii )->m_Text = m_Cmp->m_ChipName;
else if( !m_FieldText[ii].IsEmpty() )
{
m_Cmp->GetField( ii )->m_Text = m_FieldText[ii];
}
}
else
m_Cmp->GetField( ii )->m_Text = m_FieldText[ii];
if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) )
m_Cmp->GetField( ii )->m_Name = m_FieldName[ii];
else
m_Cmp->GetField( ii )->m_Name.Empty();
m_Cmp->GetField( ii )->m_Size.x =
m_Cmp->GetField( ii )->m_Size.y = m_FieldSize[ii];
if( m_FieldFlags[ii] )
m_Cmp->GetField( ii )->m_Attributs &= ~TEXT_NO_VISIBLE;
else
m_Cmp->GetField( ii )->m_Attributs |= TEXT_NO_VISIBLE;
m_Cmp->GetField( ii )->m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
m_Cmp->GetField( ii )->m_Pos = m_FieldPosition[ii];
m_Cmp->GetField( ii )->m_Pos.x += cmp_pos.x;
m_Cmp->GetField( ii )->m_Pos.y += cmp_pos.y;
}
m_Cmp->SetRotationMiroir( CMP_NORMAL );
m_Parent->GetScreen()->SetModify();
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, &dc );
EndModal( 0 );
EndModal( 1 );
}
#endif
......@@ -198,7 +198,7 @@
<property name="name">orientationRadioBox</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="selection">0</property>
<property name="selection">3</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property>
......@@ -267,7 +267,7 @@
<property name="name">mirrorRadioBox</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="selection">1</property>
<property name="selection">0</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property>
......@@ -334,7 +334,7 @@
<property name="maximum_size"></property>
<property name="maxlength">32</property>
<property name="minimum_size"></property>
<property name="name">chipnameTxtControl</property>
<property name="name">chipnameTextCtrl</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
......@@ -381,7 +381,7 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">12</property>
<property name="border">8</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
......@@ -436,6 +436,61 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">8</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Parts are locked</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">partsAreLockedLabel</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
......@@ -453,7 +508,7 @@
<object class="sizeritem" expanded="1">
<property name="border">8</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">4</property>
<property name="proportion">5</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label"></property>
......@@ -1094,7 +1149,7 @@
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">textSizeBoxSizer</property>
<property name="orient">wxVERTICAL</property>
......@@ -1516,7 +1571,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick"></event>
<event name="OnButtonClick">SetInitCmp</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
......@@ -1575,11 +1630,11 @@
<property name="name">stdDialogButtonSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelButtonClick</event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnOKButtonClick">OnOKButtonClick</event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
......
......@@ -16,7 +16,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
SCH_COMPONENT* m_Cmp;
EDA_LibComponentStruct* m_LibEntry;
int m_SelectedRow;
static int s_SelectedRow;
/// a copy of the edited component's SCH_CMP_FIELDs
SCH_CMP_FIELDS m_FieldsBuf;
......@@ -36,17 +36,24 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
/**
* Function copyPanelToSelectedField
* copies the values displayed on the panel fields to the currently selected field
* @return bool - true if all fields are OK, else false if the user has put
* bad data into a field, and this value can be used to deny a row change.
*/
void copyPanelToSelectedField();
bool copyPanelToSelectedField();
void copyOptionsToPanel();
void fillTableModel();
void copyPanelToOptions();
void setRowItem( int aFieldNdx, const SCH_CMP_FIELD& aField );
// event handlers
void OnListItemDeselected( wxListEvent& event );
void OnListItemSelected( wxListEvent& event );
void OnCancelButtonClick( wxCommandEvent& event );
void OnOKButtonClick( wxCommandEvent& event );
void SetInitCmp( wxCommandEvent& event );
protected:
......
......@@ -39,7 +39,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
wxString orientationRadioBoxChoices[] = { _("0"), _("+90"), _("180"), _("-90") };
int orientationRadioBoxNChoices = sizeof( orientationRadioBoxChoices ) / sizeof( wxString );
orientationRadioBox = new wxRadioBox( this, wxID_ANY, _("Orientation (Degrees)"), wxDefaultPosition, wxDefaultSize, orientationRadioBoxNChoices, orientationRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
orientationRadioBox->SetSelection( 0 );
orientationRadioBox->SetSelection( 3 );
orientationRadioBox->SetToolTip( _("Select if the component is to be rotated when drawn") );
orientationSizer->Add( orientationRadioBox, 1, wxALL, 8 );
......@@ -52,7 +52,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
wxString mirrorRadioBoxChoices[] = { _("Normal"), _("Mirror ---"), _("Mirror |") };
int mirrorRadioBoxNChoices = sizeof( mirrorRadioBoxChoices ) / sizeof( wxString );
mirrorRadioBox = new wxRadioBox( this, wxID_ANY, _("Mirror"), wxDefaultPosition, wxDefaultSize, mirrorRadioBoxNChoices, mirrorRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
mirrorRadioBox->SetSelection( 1 );
mirrorRadioBox->SetSelection( 0 );
mirrorRadioBox->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") );
mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 );
......@@ -62,18 +62,22 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
wxStaticBoxSizer* chipnameSizer;
chipnameSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Chip Name") ), wxHORIZONTAL );
chipnameTxtControl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
chipnameTxtControl->SetMaxLength( 32 );
chipnameTxtControl->SetToolTip( _("The name of the symbol in the library from which this component came") );
chipnameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
chipnameTextCtrl->SetMaxLength( 32 );
chipnameTextCtrl->SetToolTip( _("The name of the symbol in the library from which this component came") );
chipnameSizer->Add( chipnameTxtControl, 1, wxALL|wxEXPAND, 5 );
chipnameSizer->Add( chipnameTextCtrl, 1, wxALL|wxEXPAND, 5 );
optionsSizer->Add( chipnameSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 );
convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 );
convertCheckBox->SetToolTip( _("No Friggin Idea what this is!") );
optionsSizer->Add( convertCheckBox, 0, wxALL, 12 );
optionsSizer->Add( convertCheckBox, 0, wxALL, 8 );
partsAreLockedLabel = new wxStaticText( this, wxID_ANY, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 );
partsAreLockedLabel->Wrap( -1 );
optionsSizer->Add( partsAreLockedLabel, 0, wxALL|wxEXPAND, 8 );
upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
......@@ -101,7 +105,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 );
fieldsSizer->Add( gridStaticBoxSizer, 4, wxALL|wxEXPAND, 8 );
fieldsSizer->Add( gridStaticBoxSizer, 5, wxALL|wxEXPAND, 8 );
wxBoxSizer* fieldEditBoxSizer;
fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL );
......@@ -223,6 +227,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
// Connect Events
fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this );
fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this );
defaultsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this );
stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCancelButtonClick ), NULL, this );
stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this );
}
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP()
......@@ -230,4 +237,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
// Disconnect Events
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this );
defaultsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this );
stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCancelButtonClick ), NULL, this );
stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this );
}
......@@ -21,9 +21,9 @@
#include <wx/radiobox.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/listctrl.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -40,8 +40,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
wxChoice* unitChoice;
wxRadioBox* orientationRadioBox;
wxRadioBox* mirrorRadioBox;
wxTextCtrl* chipnameTxtControl;
wxTextCtrl* chipnameTextCtrl;
wxCheckBox* convertCheckBox;
wxStaticText* partsAreLockedLabel;
wxListCtrl* fieldListCtrl;
wxButton* addFieldButton;
wxButton* deleteFieldButton;
......@@ -68,6 +69,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnListItemDeselected( wxListEvent& event ){ event.Skip(); }
virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }
virtual void SetInitCmp( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ){ event.Skip(); }
public:
......
......@@ -469,6 +469,14 @@ public:
void SetFocus() { m_FrameText->SetFocus(); }
void SetValue( const wxString& value );
void SetValue( int value );
/**
* Function FormatSize
* formats a string containing the size in the desired units.
*/
static wxString FormatSize( int internalUnit, int units, int textSize );
static int ParseSize( const wxString& sizeText, int internalUnit, int units );
};
......
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