2009-11-04 20:46:53 +00:00
|
|
|
/**********************************************************/
|
|
|
|
/* sheetlab.cpp create and edit the SCH_SHEET_PIN items */
|
|
|
|
/**********************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
static int CurrentTypeLabel = NET_INPUT;
|
2009-09-25 18:49:04 +00:00
|
|
|
static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/****************************************/
|
|
|
|
/* class WinEDA_PinSheetPropertiesFrame */
|
|
|
|
/****************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
class WinEDA_PinSheetPropertiesFrame : public wxDialog
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_SchematicFrame* m_Parent;
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* m_CurrentPinSheet;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxRadioBox* m_PinSheetType;
|
|
|
|
wxRadioBox* m_PinSheetShape;
|
|
|
|
WinEDA_GraphicTextCtrl* m_TextWin;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
public: WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent,
|
|
|
|
SCH_SHEET_PIN* curr_pinsheet,
|
|
|
|
const wxPoint& framepos =
|
|
|
|
wxPoint( -1, -1 ) );
|
2007-09-01 12:00:30 +00:00
|
|
|
~WinEDA_PinSheetPropertiesFrame() { };
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2009-11-04 20:46:53 +00:00
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog )
|
2009-04-29 17:09:00 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_PinSheetPropertiesFrame::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_PinSheetPropertiesFrame::OnCancelClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame(
|
|
|
|
WinEDA_SchematicFrame* parent,
|
|
|
|
SCH_SHEET_PIN* curr_pinsheet,
|
|
|
|
const wxPoint& framepos ) :
|
|
|
|
wxDialog( parent, -1, _( "PinSheet Properties:" ), framepos,
|
|
|
|
wxSize( 340, 220 ), DIALOG_STYLE )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint pos;
|
|
|
|
wxString number;
|
|
|
|
wxButton* Button;
|
|
|
|
|
|
|
|
m_Parent = parent;
|
|
|
|
Centre();
|
|
|
|
|
|
|
|
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
SetSizer( MainBoxSizer );
|
|
|
|
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
m_CurrentPinSheet = curr_pinsheet;
|
|
|
|
|
2009-06-06 18:08:49 +00:00
|
|
|
/* Create buttons: */
|
2007-10-07 03:08:24 +00:00
|
|
|
Button = new wxButton( this, wxID_OK, _( "OK" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_TextWin = new WinEDA_GraphicTextCtrl( this, _( "Text:" ),
|
2009-04-29 17:09:00 +00:00
|
|
|
m_CurrentPinSheet->m_Text,
|
|
|
|
m_CurrentPinSheet->m_Size.x,
|
2007-08-20 01:20:48 +00:00
|
|
|
g_UnitMetric, LeftBoxSizer, 200 );
|
|
|
|
|
2009-06-06 18:08:49 +00:00
|
|
|
// Display shape selection :
|
|
|
|
#define NBSHAPES 5
|
|
|
|
wxString shape_list[NBSHAPES] =
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
_( "Input" ), _( "Output" ), _( "Bidi" ), _( "TriState" ),
|
|
|
|
_( "Passive" )
|
2009-06-06 18:08:49 +00:00
|
|
|
};
|
2007-08-20 01:20:48 +00:00
|
|
|
m_PinSheetShape = new wxRadioBox( this, -1, _( "PinSheet Shape:" ),
|
|
|
|
wxDefaultPosition, wxSize( -1, -1 ),
|
|
|
|
NBSHAPES, shape_list, 1 );
|
|
|
|
m_PinSheetShape->SetSelection( m_CurrentPinSheet->m_Shape );
|
|
|
|
LeftBoxSizer->Add( m_PinSheetShape, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_PinSheetPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED(
|
|
|
|
event ) )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_CurrentPinSheet->m_Text = m_TextWin->GetText();
|
2009-11-04 20:46:53 +00:00
|
|
|
m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y =
|
|
|
|
m_TextWin->GetTextSize();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection();
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* SheetLabel =
|
|
|
|
(SCH_SHEET_PIN*) Panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( SheetLabel == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( SheetLabel->m_Flags & IS_NEW )
|
2009-11-04 20:46:53 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode );
|
2008-03-20 01:50:21 +00:00
|
|
|
SAFE_DELETE( SheetLabel );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RedrawOneStruct( Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
|
|
|
|
SheetLabel->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Panel->GetScreen()->SetCurItem( NULL );
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( m_Flags & IS_NEW )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( Sheet->m_Label == NULL )
|
|
|
|
Sheet->m_Label = this;
|
|
|
|
else
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* pinsheet = Sheet->m_Label;
|
2007-08-20 01:20:48 +00:00
|
|
|
while( pinsheet )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
if( pinsheet->Next() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
pinsheet->SetNext( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
pinsheet = pinsheet->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Flags = 0;
|
|
|
|
m_Pos.x = Sheet->m_Pos.x;
|
|
|
|
m_Edge = 0;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
if( frame->GetScreen()->m_Curseur.x
|
|
|
|
> ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
m_Edge = 1;
|
|
|
|
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Pos.y = frame->GetScreen()->m_Curseur.y;
|
|
|
|
if( m_Pos.y < Sheet->m_Pos.y )
|
|
|
|
m_Pos.y = Sheet->m_Pos.y;
|
|
|
|
if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
|
|
|
|
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
|
|
|
|
|
|
|
|
RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
|
|
|
frame->DrawPanel->ManageCurseur = NULL;
|
|
|
|
frame->DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel,
|
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
NetSheetTextSize = SheetLabel->m_Size;
|
|
|
|
CurrentTypeLabel = SheetLabel->m_Shape;
|
|
|
|
SheetLabel->m_Flags |= IS_MOVED;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = Move_PinSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* SheetLabel =
|
|
|
|
(SCH_SHEET_PIN*) panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( SheetLabel == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* Sheet = (SCH_SHEET*) SheetLabel->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Sheet == NULL )
|
|
|
|
return;
|
|
|
|
if( erase )
|
|
|
|
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
|
|
|
|
|
|
|
|
SheetLabel->m_Edge = 0;
|
|
|
|
SheetLabel->m_Pos.x = Sheet->m_Pos.x;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
if( panel->GetScreen()->m_Curseur.x
|
|
|
|
> ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
SheetLabel->m_Edge = 1;
|
|
|
|
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
SheetLabel->m_Pos.y = panel->GetScreen()->m_Curseur.y;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( SheetLabel->m_Pos.y < Sheet->m_Pos.y )
|
|
|
|
SheetLabel->m_Pos.y = Sheet->m_Pos.y;
|
|
|
|
if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
|
|
|
|
SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
|
|
|
|
|
|
|
|
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel,
|
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( SheetLabel == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( DrawPanel, DC, SheetLabel, g_XorMode );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_PinSheetPropertiesFrame* frame =
|
|
|
|
new WinEDA_PinSheetPropertiesFrame( this, SheetLabel );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
frame->ShowModal(); frame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Add a new sheet pin to the sheet at the current cursor position.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet,
|
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
wxString Line, Text;
|
|
|
|
SCH_SHEET_PIN* NewSheetLabel;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
switch( CurrentTypeLabel )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
CurrentTypeLabel = NET_INPUT;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case NET_INPUT:
|
|
|
|
Text = wxT( "Pin Input: " );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case NET_OUTPUT:
|
|
|
|
Text = wxT( "Pin Output: " );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case NET_BIDI:
|
|
|
|
Text = wxT( "Pin BiDi: " );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case NET_TRISTATE:
|
|
|
|
Text = wxT( "Pin TriStat: " );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case NET_UNSPECIFIED:
|
|
|
|
Text = wxT( "Pin Unspec.: " );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
Get_Message( Text, _( "PinSheet" ), Line, this );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Line.IsEmpty() )
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
NewSheetLabel = new SCH_SHEET_PIN( Sheet, wxPoint( 0, 0 ), Line );
|
2007-08-20 01:20:48 +00:00
|
|
|
NewSheetLabel->m_Flags = IS_NEW;
|
|
|
|
NewSheetLabel->m_Size = NetSheetTextSize;
|
|
|
|
NewSheetLabel->m_Shape = CurrentTypeLabel;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetCurItem( NewSheetLabel );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = Move_PinSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return NewSheetLabel;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Automatically create a sheet labels from global labels for each node in
|
|
|
|
* the corresponding hierarchy.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet,
|
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
EDA_BaseStruct* DrawStruct;
|
|
|
|
SCH_SHEET_PIN* NewSheetLabel, * SheetLabel = NULL;
|
|
|
|
SCH_HIERLABEL* HLabel = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( !Sheet->m_AssociatedScreen )
|
|
|
|
return NULL;
|
2008-02-26 19:19:54 +00:00
|
|
|
DrawStruct = Sheet->m_AssociatedScreen->EEDrawList;
|
2009-11-04 20:46:53 +00:00
|
|
|
HLabel = NULL;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2008-03-20 01:50:21 +00:00
|
|
|
HLabel = (SCH_HIERLABEL*) DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* A global label has been found: check is there a corresponding
|
|
|
|
* sheet label. */
|
2007-08-20 01:20:48 +00:00
|
|
|
SheetLabel = Sheet->m_Label;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
if( SheetLabel->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( SheetLabel == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
if( (HLabel == NULL ) || SheetLabel )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
DisplayError( this, _( "No new hierarchical labels found" ), 10 );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
NewSheetLabel = new SCH_SHEET_PIN( Sheet, wxPoint( 0, 0 ), HLabel->m_Text );
|
2007-08-20 01:20:48 +00:00
|
|
|
NewSheetLabel->m_Flags = IS_NEW;
|
|
|
|
NewSheetLabel->m_Size = NetSheetTextSize;
|
2008-02-12 21:12:46 +00:00
|
|
|
CurrentTypeLabel = NewSheetLabel->m_Shape = HLabel->m_Shape;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
GetScreen()->SetCurItem( NewSheetLabel );
|
|
|
|
DrawPanel->ManageCurseur = Move_PinSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
|
|
|
|
Move_PinSheet( DrawPanel, DC, FALSE );
|
|
|
|
|
|
|
|
return NewSheetLabel;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-04 20:46:53 +00:00
|
|
|
* Remove sheet label.
|
|
|
|
*
|
|
|
|
* This sheet label can not be put in a pile "undelete" because it would not
|
|
|
|
* Possible to link it back it's 'SCH_SHEET' parent.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw,
|
|
|
|
SCH_SHEET_PIN* aSheetLabelToDel )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* parent = (SCH_SHEET*) aSheetLabelToDel->GetParent();
|
2008-04-22 16:38:23 +00:00
|
|
|
|
|
|
|
wxASSERT( parent );
|
|
|
|
wxASSERT( parent->Type() == DRAW_SHEET_STRUCT_TYPE );
|
|
|
|
|
|
|
|
#if 0 && defined(DEBUG)
|
|
|
|
std::cout << "\n\nbefore deleting:\n" << std::flush;
|
|
|
|
parent->Show( 0, std::cout );
|
|
|
|
std::cout << "\n\n\n" << std::flush;
|
|
|
|
#endif
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* prev = NULL;
|
|
|
|
SCH_SHEET_PIN* label = parent->m_Label;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
for( ; label; prev = label, label = label->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-25 07:33:45 +00:00
|
|
|
if( label == aSheetLabelToDel )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-22 17:19:28 +00:00
|
|
|
if( prev )
|
2008-11-24 06:53:43 +00:00
|
|
|
prev->SetNext( label->Next() );
|
2008-04-22 17:19:28 +00:00
|
|
|
else
|
|
|
|
parent->m_Label = label->Next();
|
|
|
|
|
2008-04-25 07:33:45 +00:00
|
|
|
delete aSheetLabelToDel;
|
2008-04-22 17:22:08 +00:00
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-25 07:33:45 +00:00
|
|
|
if( aRedraw )
|
|
|
|
DrawPanel->PostDirtyRect( parent->GetBoundingBox() );
|
|
|
|
|
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
|
|
|
std::cout << "\n\nafter deleting:\n" << std::flush;
|
|
|
|
parent->Show( 0, std::cout );
|
|
|
|
std::cout << "~after deleting\n\n" << std::flush;
|
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|