2007-08-20 01:20:48 +00:00
|
|
|
|
/********************************/
|
|
|
|
|
/* Scehematic component edition */
|
|
|
|
|
/********************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "program.h"
|
|
|
|
|
#include "libcmp.h"
|
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
|
|
#include "wx/checklst.h"
|
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
|
#include "schframe.h"
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
/* Fonctions exportees */
|
|
|
|
|
|
|
|
|
|
/* Fonctions locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
|
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
/* variables locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static PartTextStruct* CurrentField;
|
|
|
|
|
static int Multiflag;
|
|
|
|
|
static int TextFieldSize = DEFAULT_SIZE_TEXT;
|
|
|
|
|
static wxPoint OldPos;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/************************************/
|
|
|
|
|
/* class WinEDA_PartPropertiesFrame */
|
|
|
|
|
/************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#define ID_ON_SELECT_FIELD 3000
|
|
|
|
|
|
|
|
|
|
#include "dialog_edit_component_in_schematic.cpp"
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
|
|
|
|
|
EDA_SchComponentStruct* cmp )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Create the dialog box for the current component edition
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( cmp->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
DisplayError( parent,
|
|
|
|
|
wxT( "InstallCmpeditFrame() error: This struct is not a component" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WinEDA_ComponentPropertiesFrame* frame =
|
|
|
|
|
new WinEDA_ComponentPropertiesFrame( parent, cmp );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
frame->ShowModal();
|
|
|
|
|
frame->Destroy();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent->DrawPanel->MouseToCursorSchema();
|
|
|
|
|
parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::InitBuffers()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Init the buffers to a default value,
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* or to values from Component!= NULL
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
|
|
m_CurrentFieldId = REFERENCE;
|
|
|
|
|
|
|
|
|
|
/* Init default values */
|
|
|
|
|
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
|
|
|
|
|
{
|
|
|
|
|
m_FieldSize[ii] = DEFAULT_SIZE_TEXT;
|
|
|
|
|
m_FieldFlags[ii] = 1;
|
|
|
|
|
m_FieldOrient[ii] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_Cmp == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
|
|
|
|
|
{
|
|
|
|
|
m_FieldName[ii] = m_Cmp->ReturnFieldName( ii );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if(ii == REFERENCE)
|
|
|
|
|
m_FieldText[ii] = m_Cmp->GetRef(m_Parent->GetSheet());
|
|
|
|
|
else
|
|
|
|
|
m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x;
|
|
|
|
|
m_FieldFlags[ii] =
|
|
|
|
|
(m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1;
|
|
|
|
|
m_FieldOrient[ii] = m_Cmp->m_Field[ii].m_Orient == TEXT_ORIENT_VERT ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
if( m_Cmp->m_Field[ii].m_Text.IsEmpty() )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// These values have meaning only if this field is not void:
|
|
|
|
|
m_FieldPosition[ii] = m_Cmp->m_Field[ii].m_Pos;
|
|
|
|
|
m_FieldPosition[ii].x -= m_Cmp->m_Pos.x;
|
|
|
|
|
m_FieldPosition[ii].y -= m_Cmp->m_Pos.y;
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Set the values displayed on the panel field according to
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* the current field number
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int fieldId = m_CurrentFieldId;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ){
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_FieldSelection->SetString( ii, m_FieldName[ii] );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
if( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER )
|
|
|
|
|
m_FieldTextCtrl->Enable( FALSE );
|
|
|
|
|
|
|
|
|
|
if( m_FieldFlags[fieldId] )
|
|
|
|
|
m_ShowFieldTextCtrl->SetValue( TRUE );
|
|
|
|
|
else
|
|
|
|
|
m_ShowFieldTextCtrl->SetValue( FALSE );
|
|
|
|
|
|
|
|
|
|
// If the field value is empty and the position is 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( ( m_FieldPosition[fieldId] == wxPoint( 0, 0 ) )
|
|
|
|
|
&& m_FieldText[fieldId].IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_VorientFieldText->SetValue( m_FieldOrient[REFERENCE] != 0 );
|
|
|
|
|
m_FieldPositionCtrl->SetValue( m_FieldPosition[REFERENCE].x + 100,
|
|
|
|
|
m_FieldPosition[REFERENCE].y + 100 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_FieldPositionCtrl->SetValue( m_FieldPosition[fieldId].x, m_FieldPosition[fieldId].y );
|
|
|
|
|
m_VorientFieldText->SetValue( m_FieldOrient[fieldId] != 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_FieldNameCtrl->SetValue( m_FieldName[fieldId] );
|
|
|
|
|
if( fieldId < FIELD1 )
|
|
|
|
|
m_FieldNameCtrl->Enable( FALSE );
|
|
|
|
|
else
|
|
|
|
|
m_FieldNameCtrl->Enable( TRUE );
|
|
|
|
|
m_FieldTextCtrl->SetValue( m_FieldText[fieldId] );
|
|
|
|
|
m_FieldTextCtrl->SetValue( m_FieldSize[fieldId] );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::CopyPanelFieldToData()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Copy the values displayed on the panel field to the buffers according to
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* the current field number
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int id = m_CurrentFieldId;
|
|
|
|
|
|
|
|
|
|
m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue();
|
|
|
|
|
m_FieldOrient[id] = m_VorientFieldText->GetValue();
|
|
|
|
|
m_FieldText[id] = m_FieldTextCtrl->GetText();
|
|
|
|
|
m_FieldName[id] = m_FieldNameCtrl->GetValue();
|
|
|
|
|
m_FieldPosition[id] = m_FieldPositionCtrl->GetValue();
|
|
|
|
|
m_FieldSize[id] = m_FieldTextCtrl->GetTextSize();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::BuildPanelFields()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************************/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int ii, FieldId;
|
|
|
|
|
wxPoint field_pos;
|
|
|
|
|
|
|
|
|
|
m_CurrentFieldId = FieldId = REFERENCE;
|
|
|
|
|
|
|
|
|
|
// Create the box field selection:
|
|
|
|
|
wxString fieldnamelist[NUMBER_OF_FIELDS];
|
|
|
|
|
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_FieldName[ii].IsEmpty() )
|
|
|
|
|
fieldnamelist[ii] = ReturnDefaultFieldName( ii );
|
|
|
|
|
else
|
|
|
|
|
fieldnamelist[ii] = m_FieldName[ii];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_FieldSelection = new wxRadioBox( m_PanelField, ID_ON_SELECT_FIELD,
|
|
|
|
|
_( "Field to edit" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
|
NUMBER_OF_FIELDS, fieldnamelist, 2, wxRA_SPECIFY_COLS );
|
|
|
|
|
m_FieldSelectionBoxSizer->Add( m_FieldSelection, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
|
|
// Create the box for field name display
|
|
|
|
|
m_FieldNameCtrl = new WinEDA_EnterText( m_PanelField,
|
|
|
|
|
_( "Field Name:" ), m_FieldName[FieldId],
|
|
|
|
|
m_FieldDatasBoxSizer, wxSize( 200, -1 ) );
|
|
|
|
|
if( FieldId < FIELD1 )
|
|
|
|
|
m_FieldNameCtrl->Enable( FALSE );
|
|
|
|
|
else
|
|
|
|
|
m_FieldNameCtrl->Enable( TRUE );
|
|
|
|
|
|
|
|
|
|
// Create the box for text editing (text, size)
|
|
|
|
|
m_FieldTextCtrl = new WinEDA_GraphicTextCtrl( m_PanelField,
|
|
|
|
|
_(
|
2007-11-22 07:09:29 +00:00
|
|
|
|
"Field Text:" ),
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_FieldText[FieldId],
|
|
|
|
|
m_FieldSize[FieldId],
|
|
|
|
|
g_UnitMetric,
|
|
|
|
|
m_FieldDatasBoxSizer, 200,
|
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
|
|
// Create the box for text editing (position)
|
|
|
|
|
m_FieldPositionCtrl = new WinEDA_PositionCtrl( m_PanelField, _( "Pos" ),
|
|
|
|
|
m_FieldPosition[FieldId],
|
|
|
|
|
g_UnitMetric,
|
|
|
|
|
m_FieldDatasBoxSizer,
|
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
|
|
CopyDataToPanelField();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::BuildPanelBasic()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* create the basic panel for component properties editing
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int Nb_Max_Unit = m_SelectUnit->GetCount();
|
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
|
|
int nb_units = m_LibEntry ? MAX( m_LibEntry->m_UnitCount, 1 ) : 0;
|
|
|
|
|
|
|
|
|
|
// 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 <= Nb_Max_Unit )
|
|
|
|
|
m_SelectUnit->SetSelection( m_Cmp->m_Multi - 1 );
|
|
|
|
|
|
|
|
|
|
ii = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y);
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
|
// Positionnement de la selection normal/convert
|
|
|
|
|
if( m_Cmp->m_Convert > 1 )
|
|
|
|
|
m_ConvertButt->SetValue( TRUE );
|
|
|
|
|
|
|
|
|
|
if( (m_LibEntry == NULL) || LookForConvertPart( m_LibEntry ) <= 1 )
|
|
|
|
|
{
|
|
|
|
|
m_ConvertButt->Enable( FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show the "Parts Locked" option:
|
|
|
|
|
if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked )
|
|
|
|
|
{
|
|
|
|
|
m_MsgPartLocked->Show( false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Positionnement de la reference en librairie
|
|
|
|
|
m_RefInLib->SetValue( m_Cmp->m_ChipName );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::SelectNewField( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* called when changing the current field selected
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Save the current field settings in buffer and display the new one
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
CopyPanelFieldToData();
|
|
|
|
|
m_CurrentFieldId = m_FieldSelection->GetSelection();
|
|
|
|
|
CopyDataToPanelField();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Update the new parameters for the current edited component
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
|
CopyPanelFieldToData();
|
|
|
|
|
|
|
|
|
|
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 msg;
|
|
|
|
|
msg.Printf( _( "Component [%s] not found!" ), newname.GetData() );
|
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
//Mise a jour de la selection de l'<27>l<EFBFBD>ment dans le boitier
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( m_Cmp->m_Multi )
|
|
|
|
|
m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1;
|
|
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
// Mise a jour des textes (update the texts)
|
2007-08-20 01:20:48 +00:00
|
|
|
|
for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( ii == REFERENCE ) // la reference ne peut etre vide
|
|
|
|
|
{
|
|
|
|
|
if( !m_FieldText[ii].IsEmpty() )
|
2008-02-12 21:12:46 +00:00
|
|
|
|
m_Cmp->SetRef(m_Parent->GetSheet(), m_FieldText[ii]);
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
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->m_Field[ii].m_Text = m_Cmp->m_ChipName;
|
|
|
|
|
else if( !m_FieldText[ii].IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_Cmp->m_Field[ii].m_Text = m_FieldText[ii];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_Cmp->m_Field[ii].m_Text = m_FieldText[ii];
|
|
|
|
|
|
|
|
|
|
if( ii >= FIELD1 && m_FieldName[ii] != ReturnDefaultFieldName( ii ) )
|
|
|
|
|
m_Cmp->m_Field[ii].m_Name = m_FieldName[ii];
|
|
|
|
|
else
|
|
|
|
|
m_Cmp->m_Field[ii].m_Name.Empty();
|
|
|
|
|
|
|
|
|
|
m_Cmp->m_Field[ii].m_Size.x =
|
|
|
|
|
m_Cmp->m_Field[ii].m_Size.y = m_FieldSize[ii];
|
|
|
|
|
if( m_FieldFlags[ii] )
|
|
|
|
|
m_Cmp->m_Field[ii].m_Attributs &= ~TEXT_NO_VISIBLE;
|
|
|
|
|
else
|
|
|
|
|
m_Cmp->m_Field[ii].m_Attributs |= TEXT_NO_VISIBLE;
|
|
|
|
|
m_Cmp->m_Field[ii].m_Orient = m_FieldOrient[ii] ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
|
|
|
|
|
m_Cmp->m_Field[ii].m_Pos = m_FieldPosition[ii];
|
|
|
|
|
m_Cmp->m_Field[ii].m_Pos.x += cmp_pos.x;
|
|
|
|
|
m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-11-07 04:24:25 +00:00
|
|
|
|
EndModal( 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Prepare le deplacement du texte en cours d'edition
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CurrentField = Field;
|
|
|
|
|
if( Field == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( Field->m_Text == wxEmptyString )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "No Field to move" ), 10 );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxPoint pos, newpos;
|
|
|
|
|
int x1, y1;
|
|
|
|
|
EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToUndoCopy = Cmp->GenCopy();
|
|
|
|
|
|
|
|
|
|
pos = Cmp->m_Pos;
|
|
|
|
|
|
|
|
|
|
/* Les positions sont calculees par la matrice TRANSPOSEE de la matrice
|
|
|
|
|
* de rotation-miroir */
|
|
|
|
|
x1 = Field->m_Pos.x - pos.x;
|
|
|
|
|
y1 = Field->m_Pos.y - pos.y;
|
|
|
|
|
|
|
|
|
|
// Empirically this is necessary. The Y coordinate appears to be inverted
|
|
|
|
|
// under some circumstances, but that inversion is not preserved by all
|
|
|
|
|
// combinations of mirroring and rotation. The following clause is true
|
|
|
|
|
// when the number of rotations and the number of mirrorings are both odd.
|
|
|
|
|
if( Cmp->m_Transform[1][0] * Cmp->m_Transform[0][1] < 0 )
|
|
|
|
|
{
|
|
|
|
|
y1 = -y1;
|
|
|
|
|
}
|
|
|
|
|
newpos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1;
|
|
|
|
|
newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1;
|
|
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
GetScreen()->m_Curseur = newpos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
|
|
|
|
|
OldPos = Field->m_Pos;
|
|
|
|
|
Multiflag = 0;
|
|
|
|
|
if( Field->m_FieldId == REFERENCE )
|
|
|
|
|
{
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry != NULL )
|
|
|
|
|
{
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
Multiflag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField;
|
|
|
|
|
DrawPanel->ManageCurseur = MoveCmpField;
|
|
|
|
|
Field->m_Flags = IS_MOVED;
|
|
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
/* Edit the field Field (text, size) */
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int FieldNumber, flag;
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
|
|
|
|
|
if( Field == NULL )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "No Field To Edit" ), 10 );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) Field->m_Parent;
|
|
|
|
|
|
|
|
|
|
FieldNumber = Field->m_FieldId;
|
|
|
|
|
if( FieldNumber == VALUE )
|
|
|
|
|
{
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry && (Entry->m_Options == ENTRY_POWER) )
|
|
|
|
|
{
|
|
|
|
|
DisplayInfo( this,
|
|
|
|
|
_(
|
|
|
|
|
"Part is a POWER, value cannot be modified!\nYou must create a new power" )
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
if( FieldNumber == REFERENCE )
|
|
|
|
|
{
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry != NULL )
|
|
|
|
|
{
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
flag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
|
if( Field->m_Flags == 0 )
|
|
|
|
|
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
|
|
|
|
|
|
|
|
|
wxString newtext = Field->m_Text;
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
|
Get_Message( Field->m_Name, newtext, this );
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
|
|
|
|
|
|
DrawTextField( DrawPanel, DC, Field, flag, g_XorMode );
|
|
|
|
|
|
|
|
|
|
if( !newtext.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
if( Field->m_Text.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
Field->m_Pos = Cmp->m_Pos;
|
|
|
|
|
Field->m_Size.x = Field->m_Size.y = TextFieldSize;
|
|
|
|
|
}
|
|
|
|
|
Field->m_Text = newtext;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( FieldNumber == REFERENCE ){
|
|
|
|
|
Cmp->SetRef(GetSheet(), newtext);
|
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
else /* Nouveau texte NULL */
|
|
|
|
|
{
|
|
|
|
|
if( FieldNumber == REFERENCE )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "Reference needed !, No change" ) );
|
|
|
|
|
}
|
|
|
|
|
else if( FieldNumber == VALUE )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "Value needed !, No change" ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Field->m_Text = wxT( "~" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawTextField( DrawPanel, DC, Field, flag, g_XorMode );
|
|
|
|
|
Cmp->Display_Infos( this );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine de deplacement d'un texte type Field.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Celle routine est normalement attachee au deplacement du curseur
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint pos;
|
|
|
|
|
int x1, y1;
|
|
|
|
|
int FieldNumber;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( CurrentField == NULL )
|
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent;
|
|
|
|
|
FieldNumber = CurrentField->m_FieldId;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Effacement: */
|
|
|
|
|
if( erase )
|
|
|
|
|
DrawTextField( panel, DC, CurrentField, Multiflag, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
pos = ( (EDA_SchComponentStruct*) CurrentField->m_Parent )->m_Pos;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Les positions sont caculees par la matrice TRANSPOSEE de la matrice
|
|
|
|
|
* de rotation-miroir */
|
|
|
|
|
x1 = panel->GetScreen()->m_Curseur.x - pos.x;
|
|
|
|
|
y1 = panel->GetScreen()->m_Curseur.y - pos.y;
|
|
|
|
|
CurrentField->m_Pos.x = pos.x + Cmp->m_Transform[0][0] * x1 + Cmp->m_Transform[1][0] * y1;
|
|
|
|
|
CurrentField->m_Pos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawTextField( panel, DC, CurrentField, Multiflag, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************************/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
|
if( CurrentField )
|
|
|
|
|
{
|
|
|
|
|
DrawTextField( Panel, DC, CurrentField, Multiflag, g_XorMode );
|
|
|
|
|
CurrentField->m_Flags = 0;
|
|
|
|
|
CurrentField->m_Pos = OldPos;
|
|
|
|
|
DrawTextField( Panel, DC, CurrentField, Multiflag, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
}
|
|
|
|
|
CurrentField = NULL;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::RotateCmpField( PartTextStruct* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************************************/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int FieldNumber, flag;
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
|
|
|
|
|
if( Field == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( Field->m_Text == wxEmptyString )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) Field->m_Parent;
|
|
|
|
|
|
|
|
|
|
FieldNumber = Field->m_FieldId;
|
|
|
|
|
flag = 0;
|
|
|
|
|
if( FieldNumber == REFERENCE )
|
|
|
|
|
{
|
|
|
|
|
Entry = FindLibPart( ( (EDA_SchComponentStruct*) Field->m_Parent )->m_ChipName.GetData(),
|
|
|
|
|
wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry != NULL )
|
|
|
|
|
{
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
flag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
|
if( Field->m_Flags == 0 )
|
|
|
|
|
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
|
|
|
|
|
|
|
|
|
DrawTextField( DrawPanel, DC, Field, flag, g_XorMode );
|
|
|
|
|
|
|
|
|
|
if( Field->m_Orient == TEXT_ORIENT_HORIZ )
|
|
|
|
|
Field->m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
|
else
|
|
|
|
|
Field->m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
|
DrawTextField( DrawPanel, DC, Field, flag, g_XorMode );
|
|
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void PartTextStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************************/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int FieldNumber, flag;
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
|
|
|
|
|
frame->DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
frame->DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
|
|
|
|
|
EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) m_Parent;
|
|
|
|
|
/* save old cmp in undo list */
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( g_ItemToUndoCopy && ( g_ItemToUndoCopy->Type() == Cmp->Type()) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy );
|
|
|
|
|
( (WinEDA_SchematicFrame*) frame )->SaveCopyInUndoList( Cmp, IS_CHANGED );
|
|
|
|
|
Cmp->SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FieldNumber = m_FieldId;
|
|
|
|
|
flag = 0;
|
|
|
|
|
if( FieldNumber == REFERENCE )
|
|
|
|
|
{
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(),
|
|
|
|
|
wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry != NULL )
|
|
|
|
|
{
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
flag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawTextField( frame->DrawPanel, DC, this, flag, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
m_Flags = 0;
|
|
|
|
|
frame->GetScreen()->SetCurItem( NULL );
|
|
|
|
|
frame->GetScreen()->SetModify();
|
|
|
|
|
CurrentField = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* Cmp, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************************************************/
|
|
|
|
|
/* Edit the component text reference*/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
|
|
if( Cmp == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
wxString ref = Cmp->GetRef(GetSheet());
|
|
|
|
|
Get_Message( _( "Reference" ), ref, this );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( !ref.IsEmpty() ) // New text entered
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
|
if( Cmp->m_Flags == 0 )
|
|
|
|
|
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
Cmp->SetRef(GetSheet(), ref);
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, g_XorMode );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
Cmp->SetRef(GetSheet(), ref );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag,
|
|
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
}
|
|
|
|
|
Cmp->Display_Infos( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::EditComponentValue( EDA_SchComponentStruct* Cmp, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************************************************/
|
|
|
|
|
/* Routine de changement du texte selectionne */
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
|
|
if( Cmp == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
|
|
PartTextStruct* TextField = &Cmp->m_Field[VALUE];
|
|
|
|
|
|
|
|
|
|
msg = TextField->m_Text;
|
2007-12-11 16:41:43 +00:00
|
|
|
|
if( Get_Message( _( "Value" ), msg, this ) )
|
|
|
|
|
msg.Empty(); //allow the user to remove the value.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
|
if( !msg.IsEmpty() && !msg.IsEmpty())
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
|
if( Cmp->m_Flags == 0 )
|
|
|
|
|
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
|
|
|
|
|
|
|
|
|
DrawTextField( DrawPanel, DC, &Cmp->m_Field[VALUE], flag, g_XorMode );
|
|
|
|
|
TextField->m_Text = msg;
|
|
|
|
|
DrawTextField( DrawPanel, DC, &Cmp->m_Field[VALUE], flag,
|
|
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
GetScreen()->SetModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Cmp->Display_Infos( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
|
/*****************************************************************************************/
|
|
|
|
|
void WinEDA_SchematicFrame::EditComponentFootprint( EDA_SchComponentStruct* Cmp, wxDC* DC )
|
|
|
|
|
/*****************************************************************************************/
|
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
|
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
|
int flag = 0;
|
|
|
|
|
bool wasEmpty = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
|
if( Cmp == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Entry = FindLibPart( Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
if( Entry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
|
|
PartTextStruct* TextField = &Cmp->m_Field[FOOTPRINT];
|
|
|
|
|
|
|
|
|
|
msg = TextField->m_Text;
|
|
|
|
|
if(msg.IsEmpty() )
|
|
|
|
|
wasEmpty = true;
|
|
|
|
|
if( Get_Message( _( "Footprint" ), msg, this ) )
|
|
|
|
|
msg.Empty(); //allow the user to remove the value.
|
|
|
|
|
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
|
if( Cmp->m_Flags == 0 )
|
|
|
|
|
SaveCopyInUndoList( Cmp, IS_CHANGED );
|
|
|
|
|
DrawTextField( DrawPanel, DC, &Cmp->m_Field[FOOTPRINT], flag, g_XorMode );
|
|
|
|
|
//move the field if it was new.
|
|
|
|
|
if(wasEmpty && !msg.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
Cmp->m_Field[FOOTPRINT].m_Pos = Cmp->m_Field[REFERENCE].m_Pos;
|
|
|
|
|
//add offset here - ? suitable heuristic below?
|
|
|
|
|
Cmp->m_Field[FOOTPRINT].m_Pos.x +=
|
|
|
|
|
(Cmp->m_Field[REFERENCE].m_Pos.x - Cmp->m_Pos.x) > 0 ?
|
|
|
|
|
(Cmp->m_Field[REFERENCE].m_Size.x) : (-1*Cmp->m_Field[REFERENCE].m_Size.x);
|
|
|
|
|
Cmp->m_Field[FOOTPRINT].m_Pos.y +=
|
|
|
|
|
(Cmp->m_Field[REFERENCE].m_Pos.y - Cmp->m_Pos.y) > 0 ?
|
|
|
|
|
(Cmp->m_Field[REFERENCE].m_Size.y) : (-1*Cmp->m_Field[REFERENCE].m_Size.y);
|
|
|
|
|
|
|
|
|
|
Cmp->m_Field[FOOTPRINT].m_Orient = Cmp->m_Field[REFERENCE].m_Orient;
|
|
|
|
|
}
|
|
|
|
|
TextField->m_Text = msg;
|
|
|
|
|
|
|
|
|
|
DrawTextField( DrawPanel, DC, &Cmp->m_Field[FOOTPRINT], flag,
|
|
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
GetScreen()->SetModify();
|
2007-12-11 16:41:43 +00:00
|
|
|
|
|
|
|
|
|
Cmp->Display_Infos( this );
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event )
|
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Replace le composant en position normale, dimensions et positions
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* fields comme definies en librairie
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_LibComponentStruct* Entry;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( m_Cmp == NULL )
|
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( Entry == NULL )
|
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxClientDC dc( m_Parent->DrawPanel );
|
|
|
|
|
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Mise aux valeurs par defaut des champs et orientation */
|
|
|
|
|
m_Cmp->m_Field[REFERENCE].m_Pos.x =
|
|
|
|
|
Entry->m_Prefix.m_Pos.x + m_Cmp->m_Pos.x;
|
|
|
|
|
m_Cmp->m_Field[REFERENCE].m_Pos.y =
|
|
|
|
|
Entry->m_Prefix.m_Pos.y + m_Cmp->m_Pos.y;
|
|
|
|
|
m_Cmp->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient;
|
|
|
|
|
m_Cmp->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size;
|
|
|
|
|
m_Cmp->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify;
|
|
|
|
|
m_Cmp->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_Cmp->m_Field[VALUE].m_Pos.x =
|
|
|
|
|
Entry->m_Name.m_Pos.x + m_Cmp->m_Pos.x;
|
|
|
|
|
m_Cmp->m_Field[VALUE].m_Pos.y =
|
|
|
|
|
Entry->m_Name.m_Pos.y + m_Cmp->m_Pos.y;
|
|
|
|
|
m_Cmp->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient;
|
|
|
|
|
m_Cmp->m_Field[VALUE].m_Size = Entry->m_Name.m_Size;
|
|
|
|
|
m_Cmp->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify;
|
|
|
|
|
m_Cmp->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_NORMAL );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
|
2007-11-07 04:24:25 +00:00
|
|
|
|
EndModal( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|