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

Eeschema: Minor changes in dialogs to ensure a better likeness between dialogs...

Eeschema: Minor changes in dialogs to ensure a better likeness between dialogs on Linux and Windows (mainly, remove some useless wxStaticBoxSizer in dialogs)
Update Clipper version.
parents e18404ee fd1cd36f
...@@ -102,18 +102,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -102,18 +102,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
columnLabel.SetText( _( "Value" ) ); columnLabel.SetText( _( "Value" ) );
fieldListCtrl->InsertColumn( 1, columnLabel ); fieldListCtrl->InsertColumn( 1, columnLabel );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UserUnit ); m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
textSizeLabel->SetLabel( label ); m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
label = _( "Pos " );
label += _( "X" );
label += ReturnUnitSymbol( g_UserUnit );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UserUnit );
posYLabel->SetLabel( label );
copySelectedFieldToPanel(); copySelectedFieldToPanel();
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_edit_component_in_schematic_fbp.h" #include "dialog_edit_component_in_schematic_fbp.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{ {
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer; wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxVERTICAL ); mainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* upperSizer; wxBoxSizer* upperSizer;
upperSizer = new wxBoxSizer( wxHORIZONTAL ); upperSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* optionsSizer; wxStaticBoxSizer* optionsSizer;
optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component") ), wxVERTICAL );
wxStaticBoxSizer* unitSizer; m_staticTextUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
unitSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Unit") ), wxVERTICAL ); m_staticTextUnit->Wrap( -1 );
optionsSizer->Add( m_staticTextUnit, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxString unitChoiceChoices[] = { _("1"), _("2"), _("3"), _("4"), _("5"), _("6"), _("7"), _("8"), _("9"), _("10"), _("11"), _("12"), _("13"), _("14"), _("15"), _("16"), _("17"), _("18"), _("19"), _("20"), _("21"), _("22"), _("23"), _("24"), _("25"), _("26") };
int unitChoiceNChoices = sizeof( unitChoiceChoices ) / sizeof( wxString ); wxString unitChoiceChoices[] = { _("1"), _("2"), _("3"), _("4"), _("5"), _("6"), _("7"), _("8"), _("9"), _("10"), _("11"), _("12"), _("13"), _("14"), _("15"), _("16"), _("17"), _("18"), _("19"), _("20"), _("21"), _("22"), _("23"), _("24"), _("25"), _("26") };
unitChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, unitChoiceNChoices, unitChoiceChoices, 0 ); int unitChoiceNChoices = sizeof( unitChoiceChoices ) / sizeof( wxString );
unitChoice->SetSelection( 0 ); unitChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, unitChoiceNChoices, unitChoiceChoices, 0 );
unitSizer->Add( unitChoice, 0, wxALL|wxEXPAND, 5 ); unitChoice->SetSelection( 0 );
optionsSizer->Add( unitChoice, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
optionsSizer->Add( unitSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 );
wxBoxSizer* orientationSizer;
wxBoxSizer* orientationSizer; orientationSizer = new wxBoxSizer( wxHORIZONTAL );
orientationSizer = new wxBoxSizer( wxHORIZONTAL );
wxString orientationRadioBoxChoices[] = { _("0"), _("+90"), _("180"), _("-90") };
wxString orientationRadioBoxChoices[] = { _("0"), _("+90"), _("180"), _("-90") }; int orientationRadioBoxNChoices = sizeof( orientationRadioBoxChoices ) / sizeof( wxString );
int orientationRadioBoxNChoices = sizeof( orientationRadioBoxChoices ) / sizeof( wxString ); orientationRadioBox = new wxRadioBox( this, wxID_ANY, _("Orientation (Degrees)"), wxDefaultPosition, wxDefaultSize, orientationRadioBoxNChoices, orientationRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
orientationRadioBox = new wxRadioBox( this, wxID_ANY, _("Orientation (Degrees)"), wxDefaultPosition, wxDefaultSize, orientationRadioBoxNChoices, orientationRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); orientationRadioBox->SetSelection( 0 );
orientationRadioBox->SetSelection( 0 ); orientationRadioBox->SetToolTip( _("Select if the component is to be rotated when drawn") );
orientationRadioBox->SetToolTip( _("Select if the component is to be rotated when drawn") );
orientationSizer->Add( orientationRadioBox, 1, wxALL|wxEXPAND, 8 );
orientationSizer->Add( orientationRadioBox, 1, wxALL|wxEXPAND, 8 );
optionsSizer->Add( orientationSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); optionsSizer->Add( orientationSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 );
wxBoxSizer* mirrorSizer; wxBoxSizer* mirrorSizer;
mirrorSizer = new wxBoxSizer( wxHORIZONTAL ); mirrorSizer = new wxBoxSizer( wxHORIZONTAL );
wxString mirrorRadioBoxChoices[] = { _("Normal"), _("Mirror ---"), _("Mirror |") }; wxString mirrorRadioBoxChoices[] = { _("Normal"), _("Mirror ---"), _("Mirror |") };
int mirrorRadioBoxNChoices = sizeof( mirrorRadioBoxChoices ) / sizeof( wxString ); int mirrorRadioBoxNChoices = sizeof( mirrorRadioBoxChoices ) / sizeof( wxString );
mirrorRadioBox = new wxRadioBox( this, wxID_ANY, _("Mirror"), wxDefaultPosition, wxDefaultSize, mirrorRadioBoxNChoices, mirrorRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); mirrorRadioBox = new wxRadioBox( this, wxID_ANY, _("Mirror"), wxDefaultPosition, wxDefaultSize, mirrorRadioBoxNChoices, mirrorRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
mirrorRadioBox->SetSelection( 0 ); mirrorRadioBox->SetSelection( 0 );
mirrorRadioBox->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); mirrorRadioBox->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") );
mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 ); mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 );
optionsSizer->Add( mirrorSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 );
optionsSizer->Add( mirrorSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 );
wxStaticBoxSizer* chipnameSizer;
chipnameSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Chip Name") ), wxHORIZONTAL ); m_staticTextChipname = new wxStaticText( this, wxID_ANY, _("Chip Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextChipname->Wrap( -1 );
chipnameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); optionsSizer->Add( m_staticTextChipname, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
chipnameTextCtrl->SetMaxLength( 32 );
chipnameTextCtrl->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 );
chipnameSizer->Add( chipnameTextCtrl, 1, wxALL|wxEXPAND, 5 ); chipnameTextCtrl->SetToolTip( _("The name of the symbol in the library from which this component came") );
optionsSizer->Add( chipnameSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); optionsSizer->Add( chipnameTextCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 ); convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 );
convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") ); convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") );
optionsSizer->Add( convertCheckBox, 0, wxALL, 8 ); optionsSizer->Add( convertCheckBox, 0, wxALL, 8 );
partsAreLockedLabel = new wxStaticText( this, wxID_ANY, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 ); partsAreLockedLabel = new wxStaticText( this, wxID_ANY, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 );
partsAreLockedLabel->Wrap( -1 ); partsAreLockedLabel->Wrap( -1 );
optionsSizer->Add( partsAreLockedLabel, 0, wxALL|wxEXPAND, 8 ); optionsSizer->Add( partsAreLockedLabel, 0, wxALL|wxEXPAND, 8 );
defaultsButton = new wxButton( this, wxID_ANY, _("Reset to Library Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); defaultsButton = new wxButton( this, wxID_ANY, _("Reset to Library Defaults"), wxDefaultPosition, wxDefaultSize, 0 );
defaultsButton->SetToolTip( _("Set position and style of fields and component orientation to default lib value.\nFields texts are not modified.") ); defaultsButton->SetToolTip( _("Set position and style of fields and component orientation to default lib value.\nFields texts are not modified.") );
optionsSizer->Add( defaultsButton, 0, wxALL|wxEXPAND, 5 ); optionsSizer->Add( defaultsButton, 0, wxALL|wxEXPAND, 5 );
upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* fieldsSizer;
fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL ); wxStaticBoxSizer* fieldsSizer;
fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL );
wxStaticBoxSizer* gridStaticBoxSizer;
gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); wxStaticBoxSizer* gridStaticBoxSizer;
gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL );
fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
fieldListCtrl->SetMinSize( wxSize( 220,-1 ) ); fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
fieldListCtrl->SetMinSize( wxSize( 220,-1 ) );
gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 );
gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 );
addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 );
addFieldButton->SetToolTip( _("Add a new custom field") ); addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 );
addFieldButton->SetToolTip( _("Add a new custom field") );
gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 );
gridStaticBoxSizer->Add( addFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 );
deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 );
deleteFieldButton->SetToolTip( _("Delete one of the optional fields") );
gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 );
gridStaticBoxSizer->Add( deleteFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
moveUpButton->SetToolTip( _("Move the selected optional fields up one position") );
gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 );
gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 );
fieldsSizer->Add( gridStaticBoxSizer, 3, wxEXPAND|wxRIGHT|wxLEFT, 8 );
wxBoxSizer* fieldEditBoxSizer; fieldsSizer->Add( gridStaticBoxSizer, 3, wxEXPAND|wxRIGHT|wxLEFT, 8 );
fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* fieldEditBoxSizer;
wxStaticBoxSizer* sbSizerOptions; fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL );
sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Text Justification:") ), wxHORIZONTAL );
wxBoxSizer* bSizerJustification;
wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") }; bSizerJustification = new wxBoxSizer( wxHORIZONTAL );
int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString );
m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") };
m_FieldHJustifyCtrl->SetSelection( 0 ); int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString );
sbSizerOptions->Add( m_FieldHJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 ); m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_FieldHJustifyCtrl->SetSelection( 0 );
wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") }; bSizerJustification->Add( m_FieldHJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 );
int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString );
m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") };
m_FieldVJustifyCtrl->SetSelection( 2 ); int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString );
sbSizerOptions->Add( m_FieldVJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 ); m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_FieldVJustifyCtrl->SetSelection( 0 );
fieldEditBoxSizer->Add( sbSizerOptions, 0, wxEXPAND, 5 ); bSizerJustification->Add( m_FieldVJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* visibilitySizer;
visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL ); fieldEditBoxSizer->Add( bSizerJustification, 0, wxEXPAND|wxBOTTOM, 5 );
wxBoxSizer* bShowRotateSizer; wxBoxSizer* bSizerStyle;
bShowRotateSizer = new wxBoxSizer( wxVERTICAL ); bSizerStyle = new wxBoxSizer( wxHORIZONTAL );
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticBoxSizer* visibilitySizer;
showCheckBox->SetToolTip( _("Check if you want this field visible") ); visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxVERTICAL );
bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
showCheckBox->SetToolTip( _("Check if you want this field visible") );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); visibilitySizer->Add( showCheckBox, 0, wxALL, 5 );
bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 );
visibilitySizer->Add( rotateCheckBox, 0, wxALL, 5 );
wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString );
m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); bSizerStyle->Add( visibilitySizer, 1, wxEXPAND|wxALL, 5 );
m_StyleRadioBox->SetSelection( 3 );
m_StyleRadioBox->SetToolTip( _("The style of the currently selected field's text in the schemati") ); wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString );
visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
m_StyleRadioBox->SetSelection( 3 );
fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND|wxTOP, 5 ); m_StyleRadioBox->SetToolTip( _("The style of the currently selected field's text in the schemati") );
wxBoxSizer* fieldNameBoxSizer; bSizerStyle->Add( m_StyleRadioBox, 1, wxEXPAND|wxALL, 5 );
fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 ); fieldEditBoxSizer->Add( bSizerStyle, 1, wxEXPAND, 5 );
fieldNameLabel->Wrap( -1 );
fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); wxBoxSizer* fieldNameBoxSizer;
fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldNameTextCtrl->SetToolTip( _("The name of the currently selected field\nSome fixed fields names are not editable") ); fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 );
fieldNameLabel->Wrap( -1 );
fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 ); fieldNameBoxSizer->Add( fieldNameLabel, 0, wxTOP, 5 );
fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 ); fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldNameTextCtrl->SetMaxLength( 0 );
wxBoxSizer* fieldTextBoxSizer; fieldNameTextCtrl->SetToolTip( _("The name of the currently selected field\nSome fixed fields names are not editable") );
fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 );
fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldValueLabel->Wrap( -1 );
fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 ); fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxEXPAND, 5 );
fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); wxBoxSizer* fieldTextBoxSizer;
fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldValueLabel->Wrap( -1 );
fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 ); fieldTextBoxSizer->Add( fieldValueLabel, 0, wxTOP, 5 );
wxBoxSizer* textSizeBoxSizer; fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
textSizeBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldValueTextCtrl->SetMaxLength( 0 );
fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 );
textSizeLabel->Wrap( -1 ); fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 );
textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 );
textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxEXPAND, 5 );
textSizeTextCtrl->SetToolTip( _("The size of the currently selected field's text in the schematic") );
wxFlexGridSizer* fgSizerPosSize;
textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize = new wxFlexGridSizer( 3, 3, 0, 0 );
fgSizerPosSize->AddGrowableCol( 1 );
fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); fgSizerPosSize->SetFlexibleDirection( wxBOTH );
fgSizerPosSize->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxBoxSizer* positionBoxSizer;
positionBoxSizer = new wxBoxSizer( wxHORIZONTAL ); textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
textSizeLabel->Wrap( -1 );
wxBoxSizer* posXBoxSizer; fgSizerPosSize->Add( textSizeLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posXBoxSizer = new wxBoxSizer( wxVERTICAL );
textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 ); textSizeTextCtrl->SetMaxLength( 0 );
posXLabel->Wrap( -1 ); textSizeTextCtrl->SetToolTip( _("The size of the currently selected field's text in the schematic") );
posXBoxSizer->Add( posXLabel, 0, 0, 5 );
fgSizerPosSize->Add( textSizeTextCtrl, 0, wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 );
posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posXTextCtrl->SetToolTip( _("The X coordinate of the text relative to the component") ); m_staticTextUnitSize = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitSize->Wrap( -1 );
posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( m_staticTextUnitSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 ); posXLabel = new wxStaticText( this, wxID_ANY, _("PosX"), wxDefaultPosition, wxDefaultSize, 0 );
posXLabel->Wrap( -1 );
wxBoxSizer* posYBoxSizer; fgSizerPosSize->Add( posXLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posYBoxSizer = new wxBoxSizer( wxVERTICAL );
posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 ); posXTextCtrl->SetMaxLength( 0 );
posYLabel->Wrap( -1 ); posXTextCtrl->SetToolTip( _("The X coordinate of the text relative to the component") );
posYBoxSizer->Add( posYLabel, 0, 0, 5 );
fgSizerPosSize->Add( posXTextCtrl, 0, wxEXPAND|wxTOP|wxALIGN_CENTER_VERTICAL, 5 );
posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); m_staticTextUnitPosX = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitPosX->Wrap( -1 );
posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( m_staticTextUnitPosX, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); posYLabel = new wxStaticText( this, wxID_ANY, _("PosY"), wxDefaultPosition, wxDefaultSize, 0 );
posYLabel->Wrap( -1 );
fieldEditBoxSizer->Add( positionBoxSizer, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( posYLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
fieldsSizer->Add( fieldEditBoxSizer, 2, wxEXPAND, 5 ); posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posYTextCtrl->SetMaxLength( 0 );
upperSizer->Add( fieldsSizer, 1, wxALL|wxEXPAND, 5 ); posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") );
mainSizer->Add( upperSizer, 1, wxEXPAND, 5 ); fgSizerPosSize->Add( posYTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
stdDialogButtonSizer = new wxStdDialogButtonSizer(); m_staticTextUnitPosY = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
stdDialogButtonSizerOK = new wxButton( this, wxID_OK ); m_staticTextUnitPosY->Wrap( -1 );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerOK ); fgSizerPosSize->Add( m_staticTextUnitPosY, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel );
stdDialogButtonSizer->Realize(); fieldEditBoxSizer->Add( fgSizerPosSize, 1, wxEXPAND|wxTOP, 5 );
mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 );
this->SetSizer( mainSizer ); fieldsSizer->Add( fieldEditBoxSizer, 2, wxEXPAND, 5 );
this->Layout();
// Connect Events upperSizer->Add( fieldsSizer, 1, wxALL|wxEXPAND, 5 );
defaultsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this );
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 ); mainSizer->Add( upperSizer, 1, wxEXPAND, 5 );
addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this );
deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this ); stdDialogButtonSizer = new wxStdDialogButtonSizer();
moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), NULL, this ); stdDialogButtonSizerOK = new wxButton( this, wxID_OK );
stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCancelButtonClick ), NULL, this ); stdDialogButtonSizer->AddButton( stdDialogButtonSizerOK );
stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this ); stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL );
} stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel );
stdDialogButtonSizer->Realize();
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP()
{ mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 );
// Disconnect Events
defaultsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); this->SetSizer( mainSizer );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); this->Layout();
addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this );
deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this ); // Connect Events
moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), NULL, this ); defaultsButton->Connect( 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 ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this );
stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this );
addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this );
} deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this );
moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), 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()
{
// Disconnect Events
defaultsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this );
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 );
addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this );
deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this );
moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), 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 );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP_H__ #ifndef __DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP_H__
#define __DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP_H__ #define __DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP_H__
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/choice.h> #include <wx/stattext.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/sizer.h> #include <wx/choice.h>
#include <wx/statbox.h> #include <wx/radiobox.h>
#include <wx/radiobox.h> #include <wx/sizer.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/stattext.h> #include <wx/button.h>
#include <wx/button.h> #include <wx/statbox.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP /// Class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
{ {
private: private:
protected: protected:
wxChoice* unitChoice; wxStaticText* m_staticTextUnit;
wxRadioBox* orientationRadioBox; wxChoice* unitChoice;
wxRadioBox* mirrorRadioBox; wxRadioBox* orientationRadioBox;
wxTextCtrl* chipnameTextCtrl; wxRadioBox* mirrorRadioBox;
wxCheckBox* convertCheckBox; wxStaticText* m_staticTextChipname;
wxStaticText* partsAreLockedLabel; wxTextCtrl* chipnameTextCtrl;
wxButton* defaultsButton; wxCheckBox* convertCheckBox;
wxListCtrl* fieldListCtrl; wxStaticText* partsAreLockedLabel;
wxButton* addFieldButton; wxButton* defaultsButton;
wxButton* deleteFieldButton; wxListCtrl* fieldListCtrl;
wxButton* moveUpButton; wxButton* addFieldButton;
wxRadioBox* m_FieldHJustifyCtrl; wxButton* deleteFieldButton;
wxRadioBox* m_FieldVJustifyCtrl; wxButton* moveUpButton;
wxCheckBox* showCheckBox; wxRadioBox* m_FieldHJustifyCtrl;
wxCheckBox* rotateCheckBox; wxRadioBox* m_FieldVJustifyCtrl;
wxRadioBox* m_StyleRadioBox; wxCheckBox* showCheckBox;
wxStaticText* fieldNameLabel; wxCheckBox* rotateCheckBox;
wxTextCtrl* fieldNameTextCtrl; wxRadioBox* m_StyleRadioBox;
wxStaticText* fieldValueLabel; wxStaticText* fieldNameLabel;
wxTextCtrl* fieldValueTextCtrl; wxTextCtrl* fieldNameTextCtrl;
wxStaticText* textSizeLabel; wxStaticText* fieldValueLabel;
wxTextCtrl* textSizeTextCtrl; wxTextCtrl* fieldValueTextCtrl;
wxStaticText* posXLabel; wxStaticText* textSizeLabel;
wxTextCtrl* posXTextCtrl; wxTextCtrl* textSizeTextCtrl;
wxStaticText* posYLabel; wxStaticText* m_staticTextUnitSize;
wxTextCtrl* posYTextCtrl; wxStaticText* posXLabel;
wxStdDialogButtonSizer* stdDialogButtonSizer; wxTextCtrl* posXTextCtrl;
wxButton* stdDialogButtonSizerOK; wxStaticText* m_staticTextUnitPosX;
wxButton* stdDialogButtonSizerCancel; wxStaticText* posYLabel;
wxTextCtrl* posYTextCtrl;
// Virtual event handlers, overide them in your derived class wxStaticText* m_staticTextUnitPosY;
virtual void SetInitCmp( wxCommandEvent& event ) { event.Skip(); } wxStdDialogButtonSizer* stdDialogButtonSizer;
virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } wxButton* stdDialogButtonSizerOK;
virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } wxButton* stdDialogButtonSizerCancel;
virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); }
virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } // Virtual event handlers, overide them in your derived class
virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); } virtual void SetInitCmp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); }
virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); }
virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); }
public: virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 700,521 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP();
}; public:
#endif //__DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP_H__ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 700,496 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP();
};
#endif //__DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP_H__
...@@ -34,8 +34,8 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN ...@@ -34,8 +34,8 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN
/*****************************************************************************************/ /*****************************************************************************************/
{ {
private: private:
LIB_EDIT_FRAME* m_Parent; LIB_EDIT_FRAME* m_parent;
LIB_COMPONENT* m_LibEntry; LIB_COMPONENT* m_libEntry;
bool m_skipCopyFromPanel; bool m_skipCopyFromPanel;
/// a copy of the edited component's LIB_FIELDs /// a copy of the edited component's LIB_FIELDs
...@@ -64,10 +64,10 @@ private: ...@@ -64,10 +64,10 @@ private:
int getSelectedFieldNdx(); int getSelectedFieldNdx();
/** /**
* Function InitBuffers * Function initBuffers
* sets up to edit the given component. * sets up to edit the given component.
*/ */
void InitBuffers(); void initBuffers();
/** /**
* Function findField * Function findField
...@@ -133,8 +133,8 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( ...@@ -133,8 +133,8 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent ) DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
/***********************************************************************/ /***********************************************************************/
{ {
m_Parent = aParent; m_parent = aParent;
m_LibEntry = aLibEntry; m_libEntry = aLibEntry;
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
Centre(); Centre();
...@@ -163,20 +163,11 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event ...@@ -163,20 +163,11 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event
columnLabel.SetText( _( "Value" ) ); columnLabel.SetText( _( "Value" ) );
fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel ); fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UserUnit ); m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
textSizeLabel->SetLabel( label ); m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
label = _( "Pos " ); initBuffers();
label += _( "X" );
label += ReturnUnitSymbol( g_UserUnit );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UserUnit );
posYLabel->SetLabel( label );
InitBuffers();
copySelectedFieldToPanel(); copySelectedFieldToPanel();
stdDialogButtonSizerOK->SetDefault(); stdDialogButtonSizerOK->SetDefault();
...@@ -237,7 +228,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event ...@@ -237,7 +228,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
* or root alias of the component */ * or root alias of the component */
wxString newvalue = m_FieldsBuf[VALUE].GetText(); wxString newvalue = m_FieldsBuf[VALUE].GetText();
if( m_LibEntry->HasAlias( newvalue ) && !m_LibEntry->GetAlias( newvalue )->IsRoot() ) if( m_libEntry->HasAlias( newvalue ) && !m_libEntry->GetAlias( newvalue )->IsRoot() )
{ {
wxString msg; wxString msg;
msg.Printf( _( "A new name is entered for this component\n\ msg.Printf( _( "A new name is entered for this component\n\
...@@ -249,7 +240,7 @@ An alias %s already exists!\nCannot update this component" ), ...@@ -249,7 +240,7 @@ An alias %s already exists!\nCannot update this component" ),
/* End unused code */ /* End unused code */
/* save old cmp in undo list */ /* save old cmp in undo list */
m_Parent->SaveCopyInUndoList( m_LibEntry, IS_CHANGED ); m_parent->SaveCopyInUndoList( m_libEntry, IS_CHANGED );
// delete any fields with no name or no value before we copy all of m_FieldsBuf // delete any fields with no name or no value before we copy all of m_FieldsBuf
// back into the component // back into the component
...@@ -274,12 +265,12 @@ An alias %s already exists!\nCannot update this component" ), ...@@ -274,12 +265,12 @@ An alias %s already exists!\nCannot update this component" ),
#endif #endif
// copy all the fields back, fully replacing any previous fields // copy all the fields back, fully replacing any previous fields
m_LibEntry->SetFields( m_FieldsBuf ); m_libEntry->SetFields( m_FieldsBuf );
// We need to keep the name and the value the same at the moment! // We need to keep the name and the value the same at the moment!
SetName( m_LibEntry->GetValueField().GetText() ); SetName( m_libEntry->GetValueField().GetText() );
m_Parent->OnModify(); m_parent->OnModify();
EndModal( 0 ); EndModal( 0 );
} }
...@@ -445,13 +436,11 @@ LIB_FIELD* DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::findField( const wxString& aField ...@@ -445,13 +436,11 @@ LIB_FIELD* DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::findField( const wxString& aField
} }
/***********************************************************/ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers()
/***********************************************************/
{ {
LIB_FIELDS cmpFields; LIB_FIELDS cmpFields;
m_LibEntry->GetFields( cmpFields ); m_libEntry->GetFields( cmpFields );
#if defined(DEBUG) #if defined(DEBUG)
for( unsigned i=0; i<cmpFields.size(); ++i ) for( unsigned i=0; i<cmpFields.size(); ++i )
...@@ -492,7 +481,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers() ...@@ -492,7 +481,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers()
// Now copy in the template fields, in the order that they are present in the // Now copy in the template fields, in the order that they are present in the
// template field editor UI. // template field editor UI.
const TEMPLATE_FIELDNAMES& tfnames = const TEMPLATE_FIELDNAMES& tfnames =
((SCH_EDIT_FRAME*)m_Parent->GetParent())->GetTemplateFieldNames(); ((SCH_EDIT_FRAME*)m_parent->GetParent())->GetTemplateFieldNames();
for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it ) for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
{ {
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_edit_libentry_fields_in_lib_base.h" #include "dialog_edit_libentry_fields_in_lib_base.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{ {
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer; wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxVERTICAL ); mainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* fieldsSizer; wxBoxSizer* bSizerFieldsSetup;
fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL ); bSizerFieldsSetup = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* gridStaticBoxSizer; wxBoxSizer* bSizerFiledsList;
gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); bSizerFiledsList = new wxBoxSizer( wxVERTICAL );
fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES ); fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
fieldListCtrl->SetMinSize( wxSize( 220,-1 ) ); fieldListCtrl->SetMinSize( wxSize( 220,-1 ) );
gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 ); bSizerFiledsList->Add( fieldListCtrl, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 );
addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 ); addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 );
addFieldButton->SetToolTip( _("Add a new custom field") ); addFieldButton->SetToolTip( _("Add a new custom field") );
gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 ); bSizerFiledsList->Add( addFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 );
deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); deleteFieldButton->SetToolTip( _("Delete one of the optional fields") );
gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 ); bSizerFiledsList->Add( deleteFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); moveUpButton->SetToolTip( _("Move the selected optional fields up one position") );
gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); bSizerFiledsList->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 );
fieldsSizer->Add( gridStaticBoxSizer, 5, wxEXPAND|wxRIGHT, 8 );
bSizerFieldsSetup->Add( bSizerFiledsList, 1, wxEXPAND, 5 );
wxBoxSizer* fieldEditBoxSizer;
fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* fieldEditBoxSizer;
fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* optionsSizer;
optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Text Justification:") ), wxHORIZONTAL ); wxBoxSizer* bSizerJustify;
bSizerJustify = new wxBoxSizer( wxHORIZONTAL );
wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") };
int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") };
m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString );
m_FieldHJustifyCtrl->SetSelection( 1 ); m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") ); m_FieldHJustifyCtrl->SetSelection( 1 );
m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") );
optionsSizer->Add( m_FieldHJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT, 8 );
bSizerJustify->Add( m_FieldHJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") };
int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString ); wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") };
m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString );
m_FieldVJustifyCtrl->SetSelection( 0 ); m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_FieldVJustifyCtrl->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); m_FieldVJustifyCtrl->SetSelection( 0 );
m_FieldVJustifyCtrl->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") );
optionsSizer->Add( m_FieldVJustifyCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 8 );
bSizerJustify->Add( m_FieldVJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
fieldEditBoxSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxEXPAND|wxBOTTOM, 5 );
wxStaticBoxSizer* visibilitySizer; fieldEditBoxSizer->Add( bSizerJustify, 0, wxEXPAND|wxBOTTOM, 5 );
visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL );
wxBoxSizer* bSizerAspect;
wxBoxSizer* bShowRotateSizer; bSizerAspect = new wxBoxSizer( wxHORIZONTAL );
bShowRotateSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* visibilitySizer;
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxVERTICAL );
showCheckBox->SetToolTip( _("Check if you want this field visible") );
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); showCheckBox->SetToolTip( _("Check if you want this field visible") );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); visibilitySizer->Add( showCheckBox, 0, wxALL, 5 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 ); visibilitySizer->Add( rotateCheckBox, 0, wxALL, 5 );
wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString ); bSizerAspect->Add( visibilitySizer, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
m_StyleRadioBox->SetSelection( 1 ); wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString );
m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND, 5 ); m_StyleRadioBox->SetSelection( 0 );
bSizerAspect->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* fieldNameBoxSizer;
fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldEditBoxSizer->Add( bSizerAspect, 0, wxEXPAND|wxTOP, 5 );
fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 );
fieldNameLabel->Wrap( -1 ); wxBoxSizer* fieldNameBoxSizer;
fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 );
fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); fieldNameLabel->Wrap( -1 );
fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 );
fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 );
fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 ); fieldNameTextCtrl->SetMaxLength( 0 );
fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
wxBoxSizer* fieldTextBoxSizer;
fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 );
fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldValueLabel->Wrap( -1 ); fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 );
fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 );
wxBoxSizer* fieldTextBoxSizer;
fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); fieldValueLabel->Wrap( -1 );
fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 );
fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 );
fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
wxBoxSizer* textSizeBoxSizer; fieldValueTextCtrl->SetMaxLength( 0 );
textSizeBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 ); fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 );
textSizeLabel->Wrap( -1 );
textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 );
fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 );
textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") ); wxFlexGridSizer* fgSizerPosSize;
fgSizerPosSize = new wxFlexGridSizer( 3, 3, 0, 0 );
textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->AddGrowableCol( 1 );
fgSizerPosSize->SetFlexibleDirection( wxBOTH );
fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); fgSizerPosSize->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxBoxSizer* positionBoxSizer; textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
positionBoxSizer = new wxBoxSizer( wxHORIZONTAL ); textSizeLabel->Wrap( -1 );
fgSizerPosSize->Add( textSizeLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* posXBoxSizer;
posXBoxSizer = new wxBoxSizer( wxVERTICAL ); textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
textSizeTextCtrl->SetMaxLength( 0 );
posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 ); textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") );
posXLabel->Wrap( -1 );
posXBoxSizer->Add( posXLabel, 0, 0, 5 ); fgSizerPosSize->Add( textSizeTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextUnitSize = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); m_staticTextUnitSize->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 );
posXLabel = new wxStaticText( this, wxID_ANY, _("PosX"), wxDefaultPosition, wxDefaultSize, 0 );
wxBoxSizer* posYBoxSizer; posXLabel->Wrap( -1 );
posYBoxSizer = new wxBoxSizer( wxVERTICAL ); fgSizerPosSize->Add( posXLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 ); posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posYLabel->Wrap( -1 ); posXTextCtrl->SetMaxLength( 0 );
posYBoxSizer->Add( posYLabel, 0, 0, 5 ); fgSizerPosSize->Add( posXTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextUnitPosX = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); m_staticTextUnitPosX->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitPosX, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 );
posYLabel = new wxStaticText( this, wxID_ANY, _("PosY"), wxDefaultPosition, wxDefaultSize, 0 );
positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); posYLabel->Wrap( -1 );
fgSizerPosSize->Add( posYLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
fieldEditBoxSizer->Add( positionBoxSizer, 1, wxEXPAND, 5 );
posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldsSizer->Add( fieldEditBoxSizer, 3, wxEXPAND, 5 ); posYTextCtrl->SetMaxLength( 0 );
posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") );
mainSizer->Add( fieldsSizer, 1, wxEXPAND|wxALL, 5 );
fgSizerPosSize->Add( posYTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
stdDialogButtonSizer = new wxStdDialogButtonSizer();
stdDialogButtonSizerOK = new wxButton( this, wxID_OK ); m_staticTextUnitPosY = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerOK ); m_staticTextUnitPosY->Wrap( -1 );
stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL ); fgSizerPosSize->Add( m_staticTextUnitPosY, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel );
stdDialogButtonSizer->Realize();
mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 ); fieldEditBoxSizer->Add( fgSizerPosSize, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
this->SetSizer( mainSizer );
this->Layout(); bSizerFieldsSetup->Add( fieldEditBoxSizer, 0, wxEXPAND, 5 );
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); mainSizer->Add( bSizerFieldsSetup, 1, wxEXPAND, 5 );
fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this );
fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this ); mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this );
moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this ); stdDialogButtonSizer = new wxStdDialogButtonSizer();
stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this ); stdDialogButtonSizerOK = new wxButton( this, wxID_OK );
stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this ); stdDialogButtonSizer->AddButton( stdDialogButtonSizerOK );
} stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel );
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE() stdDialogButtonSizer->Realize();
{
// Disconnect Events mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 );
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); this->SetSizer( mainSizer );
addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this ); this->Layout();
deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this );
moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this ); // Connect Events
stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this ); this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) );
stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this );
fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this );
} addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this );
deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this );
moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this );
stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this );
stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this );
}
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this );
fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this );
addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this );
deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this );
moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this );
stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this );
stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE_H__ #ifndef __DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE_H__
#define __DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE_H__ #define __DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE_H__
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/string.h> #include <wx/gdicmn.h>
#include <wx/gdicmn.h> #include <wx/font.h>
#include <wx/font.h> #include <wx/colour.h>
#include <wx/colour.h> #include <wx/settings.h>
#include <wx/settings.h> #include <wx/string.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/radiobox.h>
#include <wx/radiobox.h> #include <wx/checkbox.h>
#include <wx/checkbox.h> #include <wx/statbox.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/dialog.h> #include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE ///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog ///////////////////////////////////////////////////////////////////////////////
{ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog
private: {
private:
protected:
wxListCtrl* fieldListCtrl; protected:
wxButton* addFieldButton; wxListCtrl* fieldListCtrl;
wxButton* deleteFieldButton; wxButton* addFieldButton;
wxButton* moveUpButton; wxButton* deleteFieldButton;
wxRadioBox* m_FieldHJustifyCtrl; wxButton* moveUpButton;
wxRadioBox* m_FieldVJustifyCtrl; wxRadioBox* m_FieldHJustifyCtrl;
wxCheckBox* showCheckBox; wxRadioBox* m_FieldVJustifyCtrl;
wxCheckBox* rotateCheckBox; wxCheckBox* showCheckBox;
wxRadioBox* m_StyleRadioBox; wxCheckBox* rotateCheckBox;
wxStaticText* fieldNameLabel; wxRadioBox* m_StyleRadioBox;
wxTextCtrl* fieldNameTextCtrl; wxStaticText* fieldNameLabel;
wxStaticText* fieldValueLabel; wxTextCtrl* fieldNameTextCtrl;
wxTextCtrl* fieldValueTextCtrl; wxStaticText* fieldValueLabel;
wxStaticText* textSizeLabel; wxTextCtrl* fieldValueTextCtrl;
wxTextCtrl* textSizeTextCtrl; wxStaticText* textSizeLabel;
wxStaticText* posXLabel; wxTextCtrl* textSizeTextCtrl;
wxTextCtrl* posXTextCtrl; wxStaticText* m_staticTextUnitSize;
wxStaticText* posYLabel; wxStaticText* posXLabel;
wxTextCtrl* posYTextCtrl; wxTextCtrl* posXTextCtrl;
wxStdDialogButtonSizer* stdDialogButtonSizer; wxStaticText* m_staticTextUnitPosX;
wxButton* stdDialogButtonSizerOK; wxStaticText* posYLabel;
wxButton* stdDialogButtonSizerCancel; wxTextCtrl* posYTextCtrl;
wxStaticText* m_staticTextUnitPosY;
// Virtual event handlers, overide them in your derived class wxStaticLine* m_staticline1;
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); } wxStdDialogButtonSizer* stdDialogButtonSizer;
virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } wxButton* stdDialogButtonSizerOK;
virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } wxButton* stdDialogButtonSizerCancel;
virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); }
virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } // Virtual event handlers, overide them in your derived class
virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); } virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); }
virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); }
virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); }
public: virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 615,550 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE();
}; public:
#endif //__DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE_H__ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 615,456 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE();
};
#endif //__DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE_H__
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 5.0.3 * * Version : 5.1.4 *
* Date : 12 January 2013 * * Date : 24 March 2013 *
* Website : http://www.angusj.com * * Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2013 * * Copyright : Angus Johnson 2010-2013 *
* * * *
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* Paper no. DETC2005-85513 pp. 565-575 * * Paper no. DETC2005-85513 pp. 565-575 *
* ASME 2005 International Design Engineering Technical Conferences * * ASME 2005 International Design Engineering Technical Conferences *
* and Computers and Information in Engineering Conference (IDETC/CIE2005) * * and Computers and Information in Engineering Conference (IDETC/CIE2005) *
* September 2428, 2005 , Long Beach, California, USA * * September 24-28, 2005 , Long Beach, California, USA *
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * * http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
* * * *
*******************************************************************************/ *******************************************************************************/
...@@ -63,8 +63,90 @@ inline long64 Abs(long64 val) ...@@ -63,8 +63,90 @@ inline long64 Abs(long64 val)
{ {
return val < 0 ? -val : val; return val < 0 ? -val : val;
} }
//------------------------------------------------------------------------------
// PolyTree methods ...
//------------------------------------------------------------------------------
void PolyTree::Clear()
{
for (PolyNodes::size_type i = 0; i < AllNodes.size(); ++i)
delete AllNodes[i];
AllNodes.resize(0);
Childs.resize(0);
}
//------------------------------------------------------------------------------
PolyNode* PolyTree::GetFirst() const
{
if (Childs.size() > 0)
return Childs[0];
else
return 0;
}
//------------------------------------------------------------------------------
int PolyTree::Total() const
{
return AllNodes.size();
}
//------------------------------------------------------------------------------
// PolyNode methods ...
//------------------------------------------------------------------------------
PolyNode::PolyNode(): Childs(), Parent(0), Index(0)
{
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int PolyNode::ChildCount() const
{
return Childs.size();
}
//------------------------------------------------------------------------------
void PolyNode::AddChild(PolyNode& child)
{
unsigned cnt = Childs.size();
Childs.push_back(&child);
child.Parent = this;
child.Index = cnt;
}
//------------------------------------------------------------------------------
PolyNode* PolyNode::GetNext() const
{
if (Childs.size() > 0)
return Childs[0];
else
return GetNextSiblingUp();
}
//------------------------------------------------------------------------------
PolyNode* PolyNode::GetNextSiblingUp() const
{
if (!Parent) //protects against PolyTree.GetNextSiblingUp()
return 0;
else if (Index == Parent->Childs.size() - 1)
return Parent->GetNextSiblingUp();
else
return Parent->Childs[Index + 1];
}
//------------------------------------------------------------------------------
bool PolyNode::IsHole() const
{
bool result = true;
PolyNode* node = Parent;
while (node)
{
result = !result;
node = node->Parent;
}
return result;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Int128 class (enables safe math on signed 64bit integers) // Int128 class (enables safe math on signed 64bit integers)
// eg Int128 val1((long64)9223372036854775807); //ie 2^63 -1 // eg Int128 val1((long64)9223372036854775807); //ie 2^63 -1
...@@ -77,19 +159,20 @@ class Int128 ...@@ -77,19 +159,20 @@ class Int128
{ {
public: public:
long64 hi;
ulong64 lo; ulong64 lo;
long64 hi;
Int128(long64 _lo = 0) Int128(long64 _lo = 0)
{ {
lo = (ulong64)_lo; lo = (ulong64)_lo;
if (_lo < 0) hi = -1; else hi = 0; if (_lo < 0) hi = -1; else hi = 0;
} }
Int128(const Int128 &val): hi(val.hi), lo(val.lo){}
Int128(const long64& _hi, const ulong64& _lo): hi(_hi), lo(_lo){} Int128(const Int128 &val): lo(val.lo), hi(val.hi){}
Int128(const long64& _hi, const ulong64& _lo): lo(_lo), hi(_hi){}
long64 operator = (const long64 &val) long64 operator = (const long64 &val)
{ {
lo = (ulong64)val; lo = (ulong64)val;
...@@ -157,7 +240,7 @@ class Int128 ...@@ -157,7 +240,7 @@ class Int128
{ {
if (lo == 0) if (lo == 0)
return Int128(-hi,0); return Int128(-hi,0);
else else
return Int128(~hi,~lo +1); return Int128(~hi,~lo +1);
} }
...@@ -188,12 +271,12 @@ class Int128 ...@@ -188,12 +271,12 @@ class Int128
} }
divisor.lo >>= 1; divisor.lo >>= 1;
if ((divisor.hi & 1) == 1) if ((divisor.hi & 1) == 1)
divisor.lo |= 0x8000000000000000LL; divisor.lo |= 0x8000000000000000LL;
divisor.hi = (ulong64)divisor.hi >> 1; divisor.hi = (ulong64)divisor.hi >> 1;
cntr.lo >>= 1; cntr.lo >>= 1;
if ((cntr.hi & 1) == 1) if ((cntr.hi & 1) == 1)
cntr.lo |= 0x8000000000000000LL; cntr.lo |= 0x8000000000000000LL;
cntr.hi >>= 1; cntr.hi >>= 1;
while (cntr.hi != 0 || cntr.lo != 0) while (cntr.hi != 0 || cntr.lo != 0)
...@@ -206,12 +289,12 @@ class Int128 ...@@ -206,12 +289,12 @@ class Int128
} }
divisor.lo >>= 1; divisor.lo >>= 1;
if ((divisor.hi & 1) == 1) if ((divisor.hi & 1) == 1)
divisor.lo |= 0x8000000000000000LL; divisor.lo |= 0x8000000000000000LL;
divisor.hi >>= 1; divisor.hi >>= 1;
cntr.lo >>= 1; cntr.lo >>= 1;
if ((cntr.hi & 1) == 1) if ((cntr.hi & 1) == 1)
cntr.lo |= 0x8000000000000000LL; cntr.lo |= 0x8000000000000000LL;
cntr.hi >>= 1; cntr.hi >>= 1;
} }
if (negate) result = -result; if (negate) result = -result;
...@@ -278,7 +361,7 @@ bool FullRangeNeeded(const Polygon &pts) ...@@ -278,7 +361,7 @@ bool FullRangeNeeded(const Polygon &pts)
return result; return result;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool Orientation(const Polygon &poly) bool Orientation(const Polygon &poly)
{ {
return Area(poly) >= 0; return Area(poly) >= 0;
...@@ -360,8 +443,8 @@ bool PointInPolygon(const IntPoint &pt, OutPt *pp, bool UseFullInt64Range) ...@@ -360,8 +443,8 @@ bool PointInPolygon(const IntPoint &pt, OutPt *pp, bool UseFullInt64Range)
{ {
if ((((pp2->pt.Y <= pt.Y) && (pt.Y < pp2->prev->pt.Y)) || if ((((pp2->pt.Y <= pt.Y) && (pt.Y < pp2->prev->pt.Y)) ||
((pp2->prev->pt.Y <= pt.Y) && (pt.Y < pp2->pt.Y))) && ((pp2->prev->pt.Y <= pt.Y) && (pt.Y < pp2->pt.Y))) &&
Int128(pt.X - pp2->pt.X) < Int128(pt.X - pp2->pt.X) <
Int128Mul(pp2->prev->pt.X - pp2->pt.X, pt.Y - pp2->pt.Y) / Int128Mul(pp2->prev->pt.X - pp2->pt.X, pt.Y - pp2->pt.Y) /
Int128(pp2->prev->pt.Y - pp2->pt.Y)) Int128(pp2->prev->pt.Y - pp2->pt.Y))
result = !result; result = !result;
pp2 = pp2->next; pp2 = pp2->next;
...@@ -423,7 +506,7 @@ void SetDx(TEdge &e) ...@@ -423,7 +506,7 @@ void SetDx(TEdge &e)
e.deltaY = (e.ytop - e.ybot); e.deltaY = (e.ytop - e.ybot);
if (e.deltaY == 0) e.dx = HORIZONTAL; if (e.deltaY == 0) e.dx = HORIZONTAL;
else e.dx = (double)(e.deltaX) / (e.deltaY); else e.dx = (double)(e.deltaX) / e.deltaY;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -460,14 +543,18 @@ bool IntersectPoint(TEdge &edge1, TEdge &edge2, ...@@ -460,14 +543,18 @@ bool IntersectPoint(TEdge &edge1, TEdge &edge2,
IntPoint &ip, bool UseFullInt64Range) IntPoint &ip, bool UseFullInt64Range)
{ {
double b1, b2; double b1, b2;
if (SlopesEqual(edge1, edge2, UseFullInt64Range)) return false; if (SlopesEqual(edge1, edge2, UseFullInt64Range))
{
if (edge2.ybot > edge1.ybot) ip.Y = edge2.ybot;
else ip.Y = edge1.ybot;
return false;
}
else if (NEAR_ZERO(edge1.dx)) else if (NEAR_ZERO(edge1.dx))
{ {
ip.X = edge1.xbot; ip.X = edge1.xbot;
if (NEAR_EQUAL(edge2.dx, HORIZONTAL)) if (NEAR_EQUAL(edge2.dx, HORIZONTAL))
{
ip.Y = edge2.ybot; ip.Y = edge2.ybot;
} else else
{ {
b2 = edge2.ybot - (edge2.xbot / edge2.dx); b2 = edge2.ybot - (edge2.xbot / edge2.dx);
ip.Y = Round(ip.X / edge2.dx + b2); ip.Y = Round(ip.X / edge2.dx + b2);
...@@ -477,14 +564,14 @@ bool IntersectPoint(TEdge &edge1, TEdge &edge2, ...@@ -477,14 +564,14 @@ bool IntersectPoint(TEdge &edge1, TEdge &edge2,
{ {
ip.X = edge2.xbot; ip.X = edge2.xbot;
if (NEAR_EQUAL(edge1.dx, HORIZONTAL)) if (NEAR_EQUAL(edge1.dx, HORIZONTAL))
{
ip.Y = edge1.ybot; ip.Y = edge1.ybot;
} else else
{ {
b1 = edge1.ybot - (edge1.xbot / edge1.dx); b1 = edge1.ybot - (edge1.xbot / edge1.dx);
ip.Y = Round(ip.X / edge1.dx + b1); ip.Y = Round(ip.X / edge1.dx + b1);
} }
} else }
else
{ {
b1 = edge1.xbot - edge1.ybot * edge1.dx; b1 = edge1.xbot - edge1.ybot * edge1.dx;
b2 = edge2.xbot - edge2.ybot * edge2.dx; b2 = edge2.xbot - edge2.ybot * edge2.dx;
...@@ -492,25 +579,26 @@ bool IntersectPoint(TEdge &edge1, TEdge &edge2, ...@@ -492,25 +579,26 @@ bool IntersectPoint(TEdge &edge1, TEdge &edge2,
ip.Y = Round(q); ip.Y = Round(q);
if (std::fabs(edge1.dx) < std::fabs(edge2.dx)) if (std::fabs(edge1.dx) < std::fabs(edge2.dx))
ip.X = Round(edge1.dx * q + b1); ip.X = Round(edge1.dx * q + b1);
else else
ip.X = Round(edge2.dx * q + b2); ip.X = Round(edge2.dx * q + b2);
} }
if (ip.Y < edge1.ytop || ip.Y < edge2.ytop) if (ip.Y < edge1.ytop || ip.Y < edge2.ytop)
{ {
if (edge1.ytop > edge2.ytop) if (edge1.ytop > edge2.ytop)
{ {
ip.X = edge1.xtop; ip.X = edge1.xtop;
ip.Y = edge1.ytop; ip.Y = edge1.ytop;
return TopX(edge2, edge1.ytop) < edge1.xtop; return TopX(edge2, edge1.ytop) < edge1.xtop;
} else }
else
{ {
ip.X = edge2.xtop; ip.X = edge2.xtop;
ip.Y = edge2.ytop; ip.Y = edge2.ytop;
return TopX(edge1, edge2.ytop) > edge2.xtop; return TopX(edge1, edge2.ytop) > edge2.xtop;
} }
} }
else else
return true; return true;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -670,7 +758,8 @@ OutPt* GetBottomPt(OutPt *pp) ...@@ -670,7 +758,8 @@ OutPt* GetBottomPt(OutPt *pp)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool FindSegment(OutPt* &pp, IntPoint &pt1, IntPoint &pt2) bool FindSegment(OutPt* &pp, bool UseFullInt64Range,
IntPoint &pt1, IntPoint &pt2)
{ {
//outPt1 & outPt2 => the overlap segment (if the function returns true) //outPt1 & outPt2 => the overlap segment (if the function returns true)
if (!pp) return false; if (!pp) return false;
...@@ -678,8 +767,8 @@ bool FindSegment(OutPt* &pp, IntPoint &pt1, IntPoint &pt2) ...@@ -678,8 +767,8 @@ bool FindSegment(OutPt* &pp, IntPoint &pt1, IntPoint &pt2)
IntPoint pt1a = pt1, pt2a = pt2; IntPoint pt1a = pt1, pt2a = pt2;
do do
{ {
if (SlopesEqual(pt1a, pt2a, pp->pt, pp->prev->pt, true) && if (SlopesEqual(pt1a, pt2a, pp->pt, pp->prev->pt, UseFullInt64Range) &&
SlopesEqual(pt1a, pt2a, pp->pt, true) && SlopesEqual(pt1a, pt2a, pp->pt, UseFullInt64Range) &&
GetOverlapSegment(pt1a, pt2a, pp->pt, pp->prev->pt, pt1, pt2)) GetOverlapSegment(pt1a, pt2a, pp->pt, pp->prev->pt, pt1, pt2))
return true; return true;
pp = pp->next; pp = pp->next;
...@@ -1081,7 +1170,7 @@ bool Clipper::Execute(ClipType clipType, Polygons &solution, ...@@ -1081,7 +1170,7 @@ bool Clipper::Execute(ClipType clipType, Polygons &solution,
m_SubjFillType = subjFillType; m_SubjFillType = subjFillType;
m_ClipFillType = clipFillType; m_ClipFillType = clipFillType;
m_ClipType = clipType; m_ClipType = clipType;
m_UsingExPolygons = false; m_UsingPolyTree = false;
bool succeeded = ExecuteInternal(); bool succeeded = ExecuteInternal();
if (succeeded) BuildResult(solution); if (succeeded) BuildResult(solution);
m_ExecuteLocked = false; m_ExecuteLocked = false;
...@@ -1089,79 +1178,34 @@ bool Clipper::Execute(ClipType clipType, Polygons &solution, ...@@ -1089,79 +1178,34 @@ bool Clipper::Execute(ClipType clipType, Polygons &solution,
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool Clipper::Execute(ClipType clipType, ExPolygons &solution, bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
PolyFillType subjFillType, PolyFillType clipFillType) PolyFillType subjFillType, PolyFillType clipFillType)
{ {
if( m_ExecuteLocked ) return false; if( m_ExecuteLocked ) return false;
m_ExecuteLocked = true; m_ExecuteLocked = true;
solution.resize(0);
m_SubjFillType = subjFillType; m_SubjFillType = subjFillType;
m_ClipFillType = clipFillType; m_ClipFillType = clipFillType;
m_ClipType = clipType; m_ClipType = clipType;
m_UsingExPolygons = true; m_UsingPolyTree = true;
bool succeeded = ExecuteInternal(); bool succeeded = ExecuteInternal();
if (succeeded) BuildResultEx(solution); if (succeeded) BuildResult2(polytree);
m_ExecuteLocked = false; m_ExecuteLocked = false;
return succeeded; return succeeded;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool PolySort(OutRec *or1, OutRec *or2) void Clipper::FixHoleLinkage(OutRec &outRec)
{
if (or1 == or2) return false;
if (!or1->pts || !or2->pts)
{
if (or1->pts != or2->pts)
{
return or1->pts ? true : false;
}
else return false;
}
int i1, i2;
if (or1->isHole)
i1 = or1->FirstLeft->idx; else
i1 = or1->idx;
if (or2->isHole)
i2 = or2->FirstLeft->idx; else
i2 = or2->idx;
int result = i1 - i2;
if (result == 0 && (or1->isHole != or2->isHole))
{
return or1->isHole ? false : true;
}
else return result < 0;
}
//------------------------------------------------------------------------------
OutRec* FindAppendLinkEnd(OutRec *outRec)
{ {
while (outRec->AppendLink) outRec = outRec->AppendLink; //skip OutRecs that (a) contain outermost polygons or
return outRec; //(b) already have the correct owner/child linkage ...
} if (!outRec.FirstLeft ||
//------------------------------------------------------------------------------ (outRec.isHole != outRec.FirstLeft->isHole &&
outRec.FirstLeft->pts)) return;
void Clipper::FixHoleLinkage(OutRec *outRec)
{
OutRec *tmp;
if (outRec->bottomPt)
tmp = m_PolyOuts[outRec->bottomPt->idx]->FirstLeft;
else
tmp = outRec->FirstLeft;
if (outRec == tmp) throw clipperException("HoleLinkage error");
if (tmp) OutRec* orfl = outRec.FirstLeft;
{ while (orfl && ((orfl->isHole == outRec.isHole) || !orfl->pts))
if (tmp->AppendLink) tmp = FindAppendLinkEnd(tmp); orfl = orfl->FirstLeft;
if (tmp == outRec) tmp = 0; outRec.FirstLeft = orfl;
else if (tmp->isHole)
{
FixHoleLinkage(tmp);
tmp = tmp->FirstLeft;
}
}
outRec->FirstLeft = tmp;
if (!tmp) outRec->isHole = false;
outRec->AppendLink = 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -1196,15 +1240,12 @@ bool Clipper::ExecuteInternal() ...@@ -1196,15 +1240,12 @@ bool Clipper::ExecuteInternal()
if (!outRec->pts) continue; if (!outRec->pts) continue;
FixupOutPolygon(*outRec); FixupOutPolygon(*outRec);
if (!outRec->pts) continue; if (!outRec->pts) continue;
if (outRec->isHole && m_UsingExPolygons) FixHoleLinkage(outRec);
if ((outRec->isHole ^ m_ReverseOutput) == (Area(*outRec, m_UseFullRange) > 0)) if ((outRec->isHole ^ m_ReverseOutput) == (Area(*outRec, m_UseFullRange) > 0))
ReversePolyPtLinks(outRec->pts); ReversePolyPtLinks(outRec->pts);
} }
if (m_Joins.size() > 0) JoinCommonEdges(); if (m_Joins.size() > 0) JoinCommonEdges();
if (m_UsingExPolygons)
std::sort(m_PolyOuts.begin(), m_PolyOuts.end(), PolySort);
} }
ClearJoins(); ClearJoins();
...@@ -1357,11 +1398,11 @@ bool Clipper::IsContributing(const TEdge& edge) const ...@@ -1357,11 +1398,11 @@ bool Clipper::IsContributing(const TEdge& edge) const
switch(pft) switch(pft)
{ {
case pftEvenOdd: case pftEvenOdd:
case pftNonZero: case pftNonZero:
if (Abs(edge.windCnt) != 1) return false; if (Abs(edge.windCnt) != 1) return false;
break; break;
case pftPositive: case pftPositive:
if (edge.windCnt != 1) return false; if (edge.windCnt != 1) return false;
break; break;
default: //pftNegative default: //pftNegative
...@@ -1373,46 +1414,46 @@ bool Clipper::IsContributing(const TEdge& edge) const ...@@ -1373,46 +1414,46 @@ bool Clipper::IsContributing(const TEdge& edge) const
case ctIntersection: case ctIntersection:
switch(pft2) switch(pft2)
{ {
case pftEvenOdd: case pftEvenOdd:
case pftNonZero: case pftNonZero:
return (edge.windCnt2 != 0); return (edge.windCnt2 != 0);
case pftPositive: case pftPositive:
return (edge.windCnt2 > 0); return (edge.windCnt2 > 0);
default: default:
return (edge.windCnt2 < 0); return (edge.windCnt2 < 0);
} }
case ctUnion: case ctUnion:
switch(pft2) switch(pft2)
{ {
case pftEvenOdd: case pftEvenOdd:
case pftNonZero: case pftNonZero:
return (edge.windCnt2 == 0); return (edge.windCnt2 == 0);
case pftPositive: case pftPositive:
return (edge.windCnt2 <= 0); return (edge.windCnt2 <= 0);
default: default:
return (edge.windCnt2 >= 0); return (edge.windCnt2 >= 0);
} }
case ctDifference: case ctDifference:
if (edge.polyType == ptSubject) if (edge.polyType == ptSubject)
switch(pft2) switch(pft2)
{ {
case pftEvenOdd: case pftEvenOdd:
case pftNonZero: case pftNonZero:
return (edge.windCnt2 == 0); return (edge.windCnt2 == 0);
case pftPositive: case pftPositive:
return (edge.windCnt2 <= 0); return (edge.windCnt2 <= 0);
default: default:
return (edge.windCnt2 >= 0); return (edge.windCnt2 >= 0);
} }
else else
switch(pft2) switch(pft2)
{ {
case pftEvenOdd: case pftEvenOdd:
case pftNonZero: case pftNonZero:
return (edge.windCnt2 != 0); return (edge.windCnt2 != 0);
case pftPositive: case pftPositive:
return (edge.windCnt2 > 0); return (edge.windCnt2 > 0);
default: default:
return (edge.windCnt2 < 0); return (edge.windCnt2 < 0);
} }
default: default:
...@@ -1432,7 +1473,7 @@ void Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt) ...@@ -1432,7 +1473,7 @@ void Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt)
e2->side = esRight; e2->side = esRight;
e = e1; e = e1;
if (e->prevInAEL == e2) if (e->prevInAEL == e2)
prevE = e2->prevInAEL; prevE = e2->prevInAEL;
else else
prevE = e->prevInAEL; prevE = e->prevInAEL;
} else } else
...@@ -1462,9 +1503,9 @@ void Clipper::AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt) ...@@ -1462,9 +1503,9 @@ void Clipper::AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt)
e1->outIdx = -1; e1->outIdx = -1;
e2->outIdx = -1; e2->outIdx = -1;
} }
else if (e1->outIdx < e2->outIdx) else if (e1->outIdx < e2->outIdx)
AppendPolygon(e1, e2); AppendPolygon(e1, e2);
else else
AppendPolygon(e2, e1); AppendPolygon(e2, e1);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -1493,14 +1534,10 @@ void Clipper::CopyAELToSEL() ...@@ -1493,14 +1534,10 @@ void Clipper::CopyAELToSEL()
{ {
TEdge* e = m_ActiveEdges; TEdge* e = m_ActiveEdges;
m_SortedEdges = e; m_SortedEdges = e;
if (!m_ActiveEdges) return;
m_SortedEdges->prevInSEL = 0;
e = e->nextInAEL;
while ( e ) while ( e )
{ {
e->prevInSEL = e->prevInAEL; e->prevInSEL = e->prevInAEL;
e->prevInSEL->nextInSEL = e; e->nextInSEL = e->nextInAEL;
e->nextInSEL = 0;
e = e->nextInAEL; e = e->nextInAEL;
} }
} }
...@@ -1585,21 +1622,18 @@ void Clipper::InsertLocalMinimaIntoAEL(const long64 botY) ...@@ -1585,21 +1622,18 @@ void Clipper::InsertLocalMinimaIntoAEL(const long64 botY)
AddLocalMinPoly( lb, rb, IntPoint(lb->xcurr, m_CurrentLM->Y) ); AddLocalMinPoly( lb, rb, IntPoint(lb->xcurr, m_CurrentLM->Y) );
//if any output polygons share an edge, they'll need joining later ... //if any output polygons share an edge, they'll need joining later ...
if (rb->outIdx >= 0) if (rb->outIdx >= 0 && NEAR_EQUAL(rb->dx, HORIZONTAL))
{ {
if (NEAR_EQUAL(rb->dx, HORIZONTAL)) for (HorzJoinList::size_type i = 0; i < m_HorizJoins.size(); ++i)
{ {
for (HorzJoinList::size_type i = 0; i < m_HorizJoins.size(); ++i) IntPoint pt, pt2; //returned by GetOverlapSegment() but unused here.
{ HorzJoinRec* hj = m_HorizJoins[i];
IntPoint pt, pt2; //returned by GetOverlapSegment() but unused here. //if horizontals rb and hj.edge overlap, flag for joining later ...
HorzJoinRec* hj = m_HorizJoins[i]; if (GetOverlapSegment(IntPoint(hj->edge->xbot, hj->edge->ybot),
//if horizontals rb and hj.edge overlap, flag for joining later ... IntPoint(hj->edge->xtop, hj->edge->ytop),
if (GetOverlapSegment(IntPoint(hj->edge->xbot, hj->edge->ybot), IntPoint(rb->xbot, rb->ybot),
IntPoint(hj->edge->xtop, hj->edge->ytop), IntPoint(rb->xtop, rb->ytop), pt, pt2))
IntPoint(rb->xbot, rb->ybot), AddJoin(hj->edge, rb, hj->savedIdx);
IntPoint(rb->xtop, rb->ytop), pt, pt2))
AddJoin(hj->edge, rb, hj->savedIdx);
}
} }
} }
...@@ -1723,28 +1757,22 @@ void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, ...@@ -1723,28 +1757,22 @@ void Clipper::IntersectEdges(TEdge *e1, TEdge *e2,
if ( e1Contributing && e2contributing ) if ( e1Contributing && e2contributing )
{ {
if ( e1stops || e2stops || if ( e1stops || e2stops ||
(e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) || (e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) ||
(e1->polyType != e2->polyType && m_ClipType != ctXor) ) (e1->polyType != e2->polyType && m_ClipType != ctXor) )
AddLocalMaxPoly(e1, e2, pt); AddLocalMaxPoly(e1, e2, pt);
else else
DoBothEdges( e1, e2, pt ); DoBothEdges( e1, e2, pt );
} }
else if ( e1Contributing ) else if ( e1Contributing )
{ {
if ((e2Wc == 0 || e2Wc == 1) && if (e2Wc == 0 || e2Wc == 1) DoEdge1(e1, e2, pt);
(m_ClipType != ctIntersection ||
e2->polyType == ptSubject || (e2->windCnt2 != 0)))
DoEdge1(e1, e2, pt);
} }
else if ( e2contributing ) else if ( e2contributing )
{ {
if ((e1Wc == 0 || e1Wc == 1) && if (e1Wc == 0 || e1Wc == 1) DoEdge2(e1, e2, pt);
(m_ClipType != ctIntersection || }
e1->polyType == ptSubject || (e1->windCnt2 != 0))) else if ( (e1Wc == 0 || e1Wc == 1) &&
DoEdge2(e1, e2, pt);
}
else if ( (e1Wc == 0 || e1Wc == 1) &&
(e2Wc == 0 || e2Wc == 1) && !e1stops && !e2stops ) (e2Wc == 0 || e2Wc == 1) && !e1stops && !e2stops )
{ {
//neither edge is currently contributing ... //neither edge is currently contributing ...
...@@ -1852,11 +1880,11 @@ void Clipper::AppendPolygon(TEdge *e1, TEdge *e2) ...@@ -1852,11 +1880,11 @@ void Clipper::AppendPolygon(TEdge *e1, TEdge *e2)
OutRec *outRec2 = m_PolyOuts[e2->outIdx]; OutRec *outRec2 = m_PolyOuts[e2->outIdx];
OutRec *holeStateRec; OutRec *holeStateRec;
if (Param1RightOfParam2(outRec1, outRec2)) if (Param1RightOfParam2(outRec1, outRec2))
holeStateRec = outRec2; holeStateRec = outRec2;
else if (Param1RightOfParam2(outRec2, outRec1)) else if (Param1RightOfParam2(outRec2, outRec1))
holeStateRec = outRec1; holeStateRec = outRec1;
else else
holeStateRec = GetLowermostRec(outRec1, outRec2); holeStateRec = GetLowermostRec(outRec1, outRec2);
OutPt* p1_lft = outRec1->pts; OutPt* p1_lft = outRec1->pts;
...@@ -1918,7 +1946,9 @@ void Clipper::AppendPolygon(TEdge *e1, TEdge *e2) ...@@ -1918,7 +1946,9 @@ void Clipper::AppendPolygon(TEdge *e1, TEdge *e2)
} }
outRec2->pts = 0; outRec2->pts = 0;
outRec2->bottomPt = 0; outRec2->bottomPt = 0;
outRec2->AppendLink = outRec1;
outRec2->FirstLeft = outRec1;
int OKIdx = e1->outIdx; int OKIdx = e1->outIdx;
int ObsoleteIdx = e2->outIdx; int ObsoleteIdx = e2->outIdx;
...@@ -1957,9 +1987,9 @@ OutRec* Clipper::CreateOutRec() ...@@ -1957,9 +1987,9 @@ OutRec* Clipper::CreateOutRec()
OutRec* result = new OutRec; OutRec* result = new OutRec;
result->isHole = false; result->isHole = false;
result->FirstLeft = 0; result->FirstLeft = 0;
result->AppendLink = 0;
result->pts = 0; result->pts = 0;
result->bottomPt = 0; result->bottomPt = 0;
result->polyNode = 0;
return result; return result;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -2056,9 +2086,6 @@ TEdge *GetMaximaPair(TEdge *e) ...@@ -2056,9 +2086,6 @@ TEdge *GetMaximaPair(TEdge *e)
void Clipper::SwapPositionsInAEL(TEdge *edge1, TEdge *edge2) void Clipper::SwapPositionsInAEL(TEdge *edge1, TEdge *edge2)
{ {
if( !edge1->nextInAEL && !edge1->prevInAEL ) return;
if( !edge2->nextInAEL && !edge2->prevInAEL ) return;
if( edge1->nextInAEL == edge2 ) if( edge1->nextInAEL == edge2 )
{ {
TEdge* next = edge2->nextInAEL; TEdge* next = edge2->nextInAEL;
...@@ -2176,28 +2203,28 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) ...@@ -2176,28 +2203,28 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
TEdge* e = GetNextInAEL( horzEdge , dir ); TEdge* e = GetNextInAEL( horzEdge , dir );
while( e ) while( e )
{ {
TEdge* eNext = GetNextInAEL( e, dir ); if ( e->xcurr == horzEdge->xtop && !eMaxPair )
if (eMaxPair ||
((dir == dLeftToRight) && (e->xcurr <= horzRight)) ||
((dir == dRightToLeft) && (e->xcurr >= horzLeft)))
{ {
//ok, so far it looks like we're still in range of the horizontal edge if (SlopesEqual(*e, *horzEdge->nextInLML, m_UseFullRange))
if ( e->xcurr == horzEdge->xtop && !eMaxPair )
{ {
if (SlopesEqual(*e, *horzEdge->nextInLML, m_UseFullRange)) //if output polygons share an edge, they'll need joining later ...
{ if (horzEdge->outIdx >= 0 && e->outIdx >= 0)
//if output polygons share an edge, they'll need joining later ... AddJoin(horzEdge->nextInLML, e, horzEdge->outIdx);
if (horzEdge->outIdx >= 0 && e->outIdx >= 0) break; //we've reached the end of the horizontal line
AddJoin(horzEdge->nextInLML, e, horzEdge->outIdx);
break; //we've reached the end of the horizontal line
}
else if (e->dx < horzEdge->nextInLML->dx)
//we really have got to the end of the intermediate horz edge so quit.
//nb: More -ve slopes follow more +ve slopes ABOVE the horizontal.
break;
} }
else if (e->dx < horzEdge->nextInLML->dx)
//we really have got to the end of the intermediate horz edge so quit.
//nb: More -ve slopes follow more +ve slopes ABOVE the horizontal.
break;
}
TEdge* eNext = GetNextInAEL( e, dir );
if (eMaxPair ||
((dir == dLeftToRight) && (e->xcurr < horzRight)) ||
((dir == dRightToLeft) && (e->xcurr > horzLeft)))
{
//so far we're still in range of the horizontal edge
if( e == eMaxPair ) if( e == eMaxPair )
{ {
//horzEdge is evidently a maxima horizontal and we've arrived at its end. //horzEdge is evidently a maxima horizontal and we've arrived at its end.
...@@ -2233,8 +2260,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) ...@@ -2233,8 +2260,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
} }
SwapPositionsInAEL( horzEdge, e ); SwapPositionsInAEL( horzEdge, e );
} }
else if( (dir == dLeftToRight && e->xcurr > horzRight && m_SortedEdges) || else if( (dir == dLeftToRight && e->xcurr >= horzRight) ||
(dir == dRightToLeft && e->xcurr < horzLeft && m_SortedEdges) ) break; (dir == dRightToLeft && e->xcurr <= horzLeft) ) break;
e = eNext; e = eNext;
} //end while } //end while
...@@ -2283,7 +2310,7 @@ bool Clipper::ProcessIntersections(const long64 botY, const long64 topY) ...@@ -2283,7 +2310,7 @@ bool Clipper::ProcessIntersections(const long64 botY, const long64 topY)
try { try {
BuildIntersectList(botY, topY); BuildIntersectList(botY, topY);
if ( !m_IntersectNodes) return true; if ( !m_IntersectNodes) return true;
if ( FixupIntersections() ) ProcessIntersectList(); if ( FixupIntersectionOrder() ) ProcessIntersectList();
else return false; else return false;
} }
catch(...) { catch(...) {
...@@ -2312,16 +2339,12 @@ void Clipper::BuildIntersectList(const long64 botY, const long64 topY) ...@@ -2312,16 +2339,12 @@ void Clipper::BuildIntersectList(const long64 botY, const long64 topY)
//prepare for sorting ... //prepare for sorting ...
TEdge* e = m_ActiveEdges; TEdge* e = m_ActiveEdges;
e->tmpX = TopX( *e, topY );
m_SortedEdges = e; m_SortedEdges = e;
m_SortedEdges->prevInSEL = 0;
e = e->nextInAEL;
while( e ) while( e )
{ {
e->prevInSEL = e->prevInAEL; e->prevInSEL = e->prevInAEL;
e->prevInSEL->nextInSEL = e; e->nextInSEL = e->nextInAEL;
e->nextInSEL = 0; e->xcurr = TopX( *e, topY );
e->tmpX = TopX( *e, topY );
e = e->nextInAEL; e = e->nextInAEL;
} }
...@@ -2335,9 +2358,10 @@ void Clipper::BuildIntersectList(const long64 botY, const long64 topY) ...@@ -2335,9 +2358,10 @@ void Clipper::BuildIntersectList(const long64 botY, const long64 topY)
{ {
TEdge *eNext = e->nextInSEL; TEdge *eNext = e->nextInSEL;
IntPoint pt; IntPoint pt;
if(e->tmpX > eNext->tmpX && if(e->xcurr > eNext->xcurr)
IntersectPoint(*e, *eNext, pt, m_UseFullRange))
{ {
if (!IntersectPoint(*e, *eNext, pt, m_UseFullRange) && e->xcurr > eNext->xcurr +1)
throw clipperException("Intersection error");
if (pt.Y > botY) if (pt.Y > botY)
{ {
pt.Y = botY; pt.Y = botY;
...@@ -2427,7 +2451,8 @@ void Clipper::DoMaxima(TEdge *e, long64 topY) ...@@ -2427,7 +2451,8 @@ void Clipper::DoMaxima(TEdge *e, long64 topY)
{ {
if (!eNext) throw clipperException("DoMaxima error"); if (!eNext) throw clipperException("DoMaxima error");
IntersectEdges( e, eNext, IntPoint(X, topY), ipBoth ); IntersectEdges( e, eNext, IntPoint(X, topY), ipBoth );
eNext = eNext->nextInAEL; SwapPositionsInAEL(e, eNext);
eNext = e->nextInAEL;
} }
if( e->outIdx < 0 && eMaxPair->outIdx < 0 ) if( e->outIdx < 0 && eMaxPair->outIdx < 0 )
{ {
...@@ -2575,61 +2600,77 @@ void Clipper::FixupOutPolygon(OutRec &outRec) ...@@ -2575,61 +2600,77 @@ void Clipper::FixupOutPolygon(OutRec &outRec)
void Clipper::BuildResult(Polygons &polys) void Clipper::BuildResult(Polygons &polys)
{ {
int k = 0; polys.reserve(m_PolyOuts.size());
polys.resize(m_PolyOuts.size());
for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
{ {
if (m_PolyOuts[i]->pts) if (m_PolyOuts[i]->pts)
{ {
Polygon* pg = &polys[k]; Polygon pg;
pg->clear();
OutPt* p = m_PolyOuts[i]->pts; OutPt* p = m_PolyOuts[i]->pts;
do do
{ {
pg->push_back(p->pt); pg.push_back(p->pt);
p = p->prev; p = p->prev;
} while (p != m_PolyOuts[i]->pts); } while (p != m_PolyOuts[i]->pts);
//make sure each polygon has at least 3 vertices ... if (pg.size() > 2)
if (pg->size() < 3) pg->clear(); else k++; polys.push_back(pg);
} }
} }
polys.resize(k);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Clipper::BuildResultEx(ExPolygons &polys) int PointCount(OutPt *pts)
{ {
PolyOutList::size_type i = 0; if (!pts) return 0;
int k = 0; int result = 0;
polys.resize(0); OutPt* p = pts;
polys.reserve(m_PolyOuts.size()); do
while (i < m_PolyOuts.size() && m_PolyOuts[i]->pts)
{
ExPolygon epg;
OutPt* p = m_PolyOuts[i]->pts;
do {
epg.outer.push_back(p->pt);
p = p->prev;
} while (p != m_PolyOuts[i]->pts);
i++;
//make sure polygons have at least 3 vertices ...
if (epg.outer.size() < 3) continue;
while (i < m_PolyOuts.size()
&& m_PolyOuts[i]->pts && m_PolyOuts[i]->isHole)
{ {
Polygon pg; result++;
p = m_PolyOuts[i]->pts; p = p->next;
do { }
pg.push_back(p->pt); while (p != pts);
p = p->prev; return result;
} while (p != m_PolyOuts[i]->pts); }
epg.holes.push_back(pg); //------------------------------------------------------------------------------
i++;
void Clipper::BuildResult2(PolyTree& polytree)
{
polytree.Clear();
polytree.AllNodes.reserve(m_PolyOuts.size());
//add each output polygon/contour to polytree ...
for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
{
OutRec* outRec = m_PolyOuts[i];
int cnt = PointCount(outRec->pts);
if (cnt < 3) continue;
FixHoleLinkage(*outRec);
PolyNode* pn = new PolyNode();
//nb: polytree takes ownership of all the PolyNodes
polytree.AllNodes.push_back(pn);
outRec->polyNode = pn;
pn->Parent = 0;
pn->Index = 0;
pn->Contour.reserve(cnt);
OutPt *op = outRec->pts;
for (int j = 0; j < cnt; j++)
{
pn->Contour.push_back(op->pt);
op = op->prev;
}
}
//fixup PolyNode links etc ...
polytree.Childs.reserve(m_PolyOuts.size());
for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
{
OutRec* outRec = m_PolyOuts[i];
if (!outRec->polyNode) continue;
if (outRec->FirstLeft)
outRec->FirstLeft->polyNode->AddChild(*outRec->polyNode);
else
polytree.AddChild(*outRec->polyNode);
} }
polys.push_back(epg);
k++;
}
polys.resize(k);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -2649,7 +2690,7 @@ void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2) ...@@ -2649,7 +2690,7 @@ void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool Clipper::FixupIntersections() bool Clipper::FixupIntersectionOrder()
{ {
if ( !m_IntersectNodes->next ) return true; if ( !m_IntersectNodes->next ) return true;
...@@ -2664,8 +2705,8 @@ bool Clipper::FixupIntersections() ...@@ -2664,8 +2705,8 @@ bool Clipper::FixupIntersections()
else if (e1->nextInSEL == int1->edge2) e2 = e1->nextInSEL; else if (e1->nextInSEL == int1->edge2) e2 = e1->nextInSEL;
else else
{ {
//The current intersection is out of order, so try and swap it with //The current intersection (Int1) is out of order (since it doesn't
//a subsequent intersection ... //contain adjacent edges), so swap it with a subsequent intersection ...
while (int2) while (int2)
{ {
if (int2->edge1->nextInSEL == int2->edge2 || if (int2->edge1->nextInSEL == int2->edge2 ||
...@@ -2674,7 +2715,8 @@ bool Clipper::FixupIntersections() ...@@ -2674,7 +2715,8 @@ bool Clipper::FixupIntersections()
} }
if ( !int2 ) return false; //oops!!! if ( !int2 ) return false; //oops!!!
//found an intersect node that can be swapped ... //found an intersect node (Int2) that does contain adjacent edges,
//so prepare to process it before Int1 ...
SwapIntersectNodes(*int1, *int2); SwapIntersectNodes(*int1, *int2);
e1 = int1->edge1; e1 = int1->edge1;
e2 = int1->edge2; e2 = int1->edge2;
...@@ -2751,72 +2793,73 @@ void Clipper::DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt) ...@@ -2751,72 +2793,73 @@ void Clipper::DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt)
bool Clipper::JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2) bool Clipper::JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2)
{ {
OutRec *outRec1 = m_PolyOuts[j->poly1Idx]; OutRec *outRec1 = m_PolyOuts[j->poly1Idx];
OutRec *outRec2 = m_PolyOuts[j->poly2Idx]; OutRec *outRec2 = m_PolyOuts[j->poly2Idx];
if (!outRec1 || !outRec2) return false; if (!outRec1 || !outRec2) return false;
OutPt *pp1a = outRec1->pts; OutPt *pp1a = outRec1->pts;
OutPt *pp2a = outRec2->pts; OutPt *pp2a = outRec2->pts;
IntPoint pt1 = j->pt2a, pt2 = j->pt2b; IntPoint pt1 = j->pt2a, pt2 = j->pt2b;
IntPoint pt3 = j->pt1a, pt4 = j->pt1b; IntPoint pt3 = j->pt1a, pt4 = j->pt1b;
if (!FindSegment(pp1a, pt1, pt2)) return false; if (!FindSegment(pp1a, m_UseFullRange, pt1, pt2)) return false;
if (outRec1 == outRec2) if (outRec1 == outRec2)
{ {
//we're searching the same polygon for overlapping segments so //we're searching the same polygon for overlapping segments so
//segment 2 mustn't be the same as segment 1 ... //segment 2 mustn't be the same as segment 1 ...
pp2a = pp1a->next; pp2a = pp1a->next;
if (!FindSegment(pp2a, pt3, pt4) || (pp2a == pp1a)) return false; if (!FindSegment(pp2a, m_UseFullRange, pt3, pt4) || (pp2a == pp1a))
} return false;
else if (!FindSegment(pp2a, pt3, pt4)) return false; }
else if (!FindSegment(pp2a, m_UseFullRange, pt3, pt4)) return false;
if (!GetOverlapSegment(pt1, pt2, pt3, pt4, pt1, pt2)) return false;
if (!GetOverlapSegment(pt1, pt2, pt3, pt4, pt1, pt2)) return false;
OutPt *p3, *p4, *prev = pp1a->prev;
//get p1 & p2 polypts - the overlap start & endpoints on poly1 OutPt *p3, *p4, *prev = pp1a->prev;
if (PointsEqual(pp1a->pt, pt1)) p1 = pp1a; //get p1 & p2 polypts - the overlap start & endpoints on poly1
else if (PointsEqual(prev->pt, pt1)) p1 = prev; if (PointsEqual(pp1a->pt, pt1)) p1 = pp1a;
else p1 = InsertPolyPtBetween(pp1a, prev, pt1); else if (PointsEqual(prev->pt, pt1)) p1 = prev;
else p1 = InsertPolyPtBetween(pp1a, prev, pt1);
if (PointsEqual(pp1a->pt, pt2)) p2 = pp1a;
else if (PointsEqual(prev->pt, pt2)) p2 = prev; if (PointsEqual(pp1a->pt, pt2)) p2 = pp1a;
else if ((p1 == pp1a) || (p1 == prev)) else if (PointsEqual(prev->pt, pt2)) p2 = prev;
p2 = InsertPolyPtBetween(pp1a, prev, pt2); else if ((p1 == pp1a) || (p1 == prev))
else if (Pt3IsBetweenPt1AndPt2(pp1a->pt, p1->pt, pt2)) p2 = InsertPolyPtBetween(pp1a, prev, pt2);
p2 = InsertPolyPtBetween(pp1a, p1, pt2); else else if (Pt3IsBetweenPt1AndPt2(pp1a->pt, p1->pt, pt2))
p2 = InsertPolyPtBetween(p1, prev, pt2); p2 = InsertPolyPtBetween(pp1a, p1, pt2); else
p2 = InsertPolyPtBetween(p1, prev, pt2);
//get p3 & p4 polypts - the overlap start & endpoints on poly2
prev = pp2a->prev; //get p3 & p4 polypts - the overlap start & endpoints on poly2
if (PointsEqual(pp2a->pt, pt1)) p3 = pp2a; prev = pp2a->prev;
else if (PointsEqual(prev->pt, pt1)) p3 = prev; if (PointsEqual(pp2a->pt, pt1)) p3 = pp2a;
else p3 = InsertPolyPtBetween(pp2a, prev, pt1); else if (PointsEqual(prev->pt, pt1)) p3 = prev;
else p3 = InsertPolyPtBetween(pp2a, prev, pt1);
if (PointsEqual(pp2a->pt, pt2)) p4 = pp2a;
else if (PointsEqual(prev->pt, pt2)) p4 = prev; if (PointsEqual(pp2a->pt, pt2)) p4 = pp2a;
else if ((p3 == pp2a) || (p3 == prev)) else if (PointsEqual(prev->pt, pt2)) p4 = prev;
p4 = InsertPolyPtBetween(pp2a, prev, pt2); else if ((p3 == pp2a) || (p3 == prev))
else if (Pt3IsBetweenPt1AndPt2(pp2a->pt, p3->pt, pt2)) p4 = InsertPolyPtBetween(pp2a, prev, pt2);
p4 = InsertPolyPtBetween(pp2a, p3, pt2); else else if (Pt3IsBetweenPt1AndPt2(pp2a->pt, p3->pt, pt2))
p4 = InsertPolyPtBetween(p3, prev, pt2); p4 = InsertPolyPtBetween(pp2a, p3, pt2); else
p4 = InsertPolyPtBetween(p3, prev, pt2);
//p1.pt == p3.pt and p2.pt == p4.pt so join p1 to p3 and p2 to p4 ...
if (p1->next == p2 && p3->prev == p4) //p1.pt == p3.pt and p2.pt == p4.pt so join p1 to p3 and p2 to p4 ...
{ if (p1->next == p2 && p3->prev == p4)
p1->next = p3; {
p3->prev = p1; p1->next = p3;
p2->prev = p4; p3->prev = p1;
p4->next = p2; p2->prev = p4;
return true; p4->next = p2;
} return true;
else if (p1->prev == p2 && p3->next == p4) }
{ else if (p1->prev == p2 && p3->next == p4)
p1->prev = p3; {
p3->next = p1; p1->prev = p3;
p2->next = p4; p3->next = p1;
p4->prev = p2; p2->next = p4;
return true; p4->prev = p2;
} return true;
else }
return false; //an orientation is probably wrong else
return false; //an orientation is probably wrong
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
...@@ -2833,17 +2876,76 @@ void Clipper::FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx) ...@@ -2833,17 +2876,76 @@ void Clipper::FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool Poly2ContainsPoly1(OutPt* outPt1, OutPt* outPt2, bool UseFullInt64Range)
{
//find the first pt in outPt1 that isn't also a vertex of outPt2 ...
OutPt* outPt = outPt1;
do
{
if (!PointIsVertex(outPt->pt, outPt2)) break;
outPt = outPt->next;
}
while (outPt != outPt1);
bool result;
//sometimes a point on one polygon can be touching the other polygon
//so to be totally confident outPt1 is inside outPt2 repeat ...
do
{
result = PointInPolygon(outPt->pt, outPt2, UseFullInt64Range);
outPt = outPt->next;
}
while (result && outPt != outPt1);
return result;
}
//----------------------------------------------------------------------
void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec)
{
for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
{
OutRec* outRec = m_PolyOuts[i];
if (outRec->pts && outRec->FirstLeft == OldOutRec)
{
if (Poly2ContainsPoly1(outRec->pts, NewOutRec->pts, m_UseFullRange))
outRec->FirstLeft = NewOutRec;
}
}
}
//----------------------------------------------------------------------
void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec)
{
for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
{
OutRec* outRec = m_PolyOuts[i];
if (outRec->FirstLeft == OldOutRec) outRec->FirstLeft = NewOutRec;
}
}
//----------------------------------------------------------------------
void Clipper::JoinCommonEdges() void Clipper::JoinCommonEdges()
{ {
for (JoinList::size_type i = 0; i < m_Joins.size(); i++) for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
{ {
JoinRec* j = m_Joins[i]; JoinRec* j = m_Joins[i];
OutPt *p1, *p2;
if (!JoinPoints(j, p1, p2)) continue;
OutRec *outRec1 = m_PolyOuts[j->poly1Idx]; OutRec *outRec1 = m_PolyOuts[j->poly1Idx];
OutRec *outRec2 = m_PolyOuts[j->poly2Idx]; OutRec *outRec2 = m_PolyOuts[j->poly2Idx];
if (!outRec1->pts || !outRec2->pts) continue;
//get the polygon fragment with the correct hole state (FirstLeft)
//before calling JoinPoints() ...
OutRec *holeStateRec;
if (outRec1 == outRec2) holeStateRec = outRec1;
else if (Param1RightOfParam2(outRec1, outRec2)) holeStateRec = outRec2;
else if (Param1RightOfParam2(outRec2, outRec1)) holeStateRec = outRec1;
else holeStateRec = GetLowermostRec(outRec1, outRec2);
OutPt *p1, *p2;
if (!JoinPoints(j, p1, p2)) continue;
if (outRec1 == outRec2) if (outRec1 == outRec2)
{ {
//instead of joining two polygons, we've just created a new one by //instead of joining two polygons, we've just created a new one by
...@@ -2859,21 +2961,25 @@ void Clipper::JoinCommonEdges() ...@@ -2859,21 +2961,25 @@ void Clipper::JoinCommonEdges()
outRec2->bottomPt = outRec2->pts; outRec2->bottomPt = outRec2->pts;
outRec2->bottomPt->idx = outRec2->idx; outRec2->bottomPt->idx = outRec2->idx;
if (PointInPolygon(outRec2->pts->pt, outRec1->pts, m_UseFullRange)) if (Poly2ContainsPoly1(outRec2->pts, outRec1->pts, m_UseFullRange))
{ {
//outRec2 is contained by outRec1 ... //outRec2 is contained by outRec1 ...
outRec2->isHole = !outRec1->isHole; outRec2->isHole = !outRec1->isHole;
outRec2->FirstLeft = outRec1; outRec2->FirstLeft = outRec1;
FixupJoinRecs(j, p2, i+1); FixupJoinRecs(j, p2, i+1);
//fixup FirstLeft pointers that may need reassigning to OutRec1
if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
FixupOutPolygon(*outRec1); //nb: do this BEFORE testing orientation FixupOutPolygon(*outRec1); //nb: do this BEFORE testing orientation
FixupOutPolygon(*outRec2); // but AFTER calling FixupJoinRecs() FixupOutPolygon(*outRec2); // but AFTER calling FixupJoinRecs()
if ((outRec2->isHole ^ m_ReverseOutput) == (Area(*outRec2, m_UseFullRange) > 0)) if ((outRec2->isHole ^ m_ReverseOutput) == (Area(*outRec2, m_UseFullRange) > 0))
ReversePolyPtLinks(outRec2->pts); ReversePolyPtLinks(outRec2->pts);
} else if (PointInPolygon(outRec1->pts->pt, outRec2->pts, m_UseFullRange)) } else if (Poly2ContainsPoly1(outRec1->pts, outRec2->pts, m_UseFullRange))
{ {
//outRec1 is contained by outRec2 ... //outRec1 is contained by outRec2 ...
outRec2->isHole = outRec1->isHole; outRec2->isHole = outRec1->isHole;
...@@ -2882,20 +2988,16 @@ void Clipper::JoinCommonEdges() ...@@ -2882,20 +2988,16 @@ void Clipper::JoinCommonEdges()
outRec1->FirstLeft = outRec2; outRec1->FirstLeft = outRec2;
FixupJoinRecs(j, p2, i+1); FixupJoinRecs(j, p2, i+1);
//fixup FirstLeft pointers that may need reassigning to OutRec1
if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2);
FixupOutPolygon(*outRec1); //nb: do this BEFORE testing orientation FixupOutPolygon(*outRec1); //nb: do this BEFORE testing orientation
FixupOutPolygon(*outRec2); // but AFTER calling FixupJoinRecs() FixupOutPolygon(*outRec2); // but AFTER calling FixupJoinRecs()
if ((outRec1->isHole ^ m_ReverseOutput) == (Area(*outRec1, m_UseFullRange) > 0)) if ((outRec1->isHole ^ m_ReverseOutput) == (Area(*outRec1, m_UseFullRange) > 0))
ReversePolyPtLinks(outRec1->pts); ReversePolyPtLinks(outRec1->pts);
//make sure any contained holes now link to the correct polygon ... }
if (m_UsingExPolygons && outRec1->isHole)
for (PolyOutList::size_type k = 0; k < m_PolyOuts.size(); ++k)
{
OutRec *orec = m_PolyOuts[k];
if (orec->isHole && orec->bottomPt && orec->FirstLeft == outRec1)
orec->FirstLeft = outRec2;
}
}
else else
{ {
//the 2 polygons are completely separate ... //the 2 polygons are completely separate ...
...@@ -2903,47 +3005,31 @@ void Clipper::JoinCommonEdges() ...@@ -2903,47 +3005,31 @@ void Clipper::JoinCommonEdges()
outRec2->FirstLeft = outRec1->FirstLeft; outRec2->FirstLeft = outRec1->FirstLeft;
FixupJoinRecs(j, p2, i+1); FixupJoinRecs(j, p2, i+1);
//fixup FirstLeft pointers that may need reassigning to OutRec2
if (m_UsingPolyTree) FixupFirstLefts1(outRec1, outRec2);
FixupOutPolygon(*outRec1); //nb: do this BEFORE testing orientation FixupOutPolygon(*outRec1); //nb: do this BEFORE testing orientation
FixupOutPolygon(*outRec2); // but AFTER calling FixupJoinRecs() FixupOutPolygon(*outRec2); // but AFTER calling FixupJoinRecs()
if (m_UsingExPolygons && outRec2->pts)
for (PolyOutList::size_type k = 0; k < m_PolyOuts.size(); ++k)
{
OutRec *orec = m_PolyOuts[k];
if (orec->isHole && orec->bottomPt && orec->FirstLeft == outRec1 &&
PointInPolygon(orec->bottomPt->pt, outRec2->pts, m_UseFullRange))
orec->FirstLeft = outRec2;
}
} }
} else } else
{ {
//joined 2 polygons together ... //joined 2 polygons together ...
//make sure any holes contained by outRec2 now link to outRec1 ... //cleanup redundant edges ...
if (m_UsingExPolygons)
for (PolyOutList::size_type k = 0; k < m_PolyOuts.size(); ++k)
if (m_PolyOuts[k]->isHole && m_PolyOuts[k]->bottomPt &&
m_PolyOuts[k]->FirstLeft == outRec2)
m_PolyOuts[k]->FirstLeft = outRec1;
//and cleanup redundant edges too ...
FixupOutPolygon(*outRec1); FixupOutPolygon(*outRec1);
if (outRec1->pts)
{
outRec1->isHole = Area(*outRec1, m_UseFullRange) < 0;
if (outRec1->isHole && !outRec1->FirstLeft)
outRec1->FirstLeft = outRec2->FirstLeft;
}
//delete the obsolete pointer ... //delete the obsolete pointer ...
int OKIdx = outRec1->idx; int OKIdx = outRec1->idx;
int ObsoleteIdx = outRec2->idx; int ObsoleteIdx = outRec2->idx;
outRec2->pts = 0; outRec2->pts = 0;
outRec2->bottomPt = 0; outRec2->bottomPt = 0;
outRec2->AppendLink = outRec1;
outRec1->isHole = holeStateRec->isHole;
if (holeStateRec == outRec2)
outRec1->FirstLeft = outRec2->FirstLeft;
outRec2->FirstLeft = outRec1;
//now fixup any subsequent Joins that match this polygon //now fixup any subsequent Joins that match this polygon
for (JoinList::size_type k = i+1; k < m_Joins.size(); k++) for (JoinList::size_type k = i+1; k < m_Joins.size(); k++)
...@@ -2952,6 +3038,9 @@ void Clipper::JoinCommonEdges() ...@@ -2952,6 +3038,9 @@ void Clipper::JoinCommonEdges()
if (j2->poly1Idx == ObsoleteIdx) j2->poly1Idx = OKIdx; if (j2->poly1Idx == ObsoleteIdx) j2->poly1Idx = OKIdx;
if (j2->poly2Idx == ObsoleteIdx) j2->poly2Idx = OKIdx; if (j2->poly2Idx == ObsoleteIdx) j2->poly2Idx = OKIdx;
} }
//fixup FirstLeft pointers that may need reassigning to OutRec1
if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
} }
} }
} }
...@@ -2982,19 +3071,26 @@ struct DoublePoint ...@@ -2982,19 +3071,26 @@ struct DoublePoint
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Polygon BuildArc(const IntPoint &pt, Polygon BuildArc(const IntPoint &pt,
const double a1, const double a2, const double r) const double a1, const double a2, const double r, double limit)
{ {
long64 steps = std::max(6, int(std::sqrt(std::fabs(r)) * std::fabs(a2 - a1))); //see notes in clipper.pas regarding steps
if (steps > 0x100) steps = 0x100; double arcFrac = std::fabs(a2 - a1) / (2 * pi);
int n = (unsigned)steps; int steps = (int)(arcFrac * pi / std::acos(1 - limit / std::fabs(r)));
Polygon result(n); if (steps < 2) steps = 2;
double da = (a2 - a1) / (n -1); else if (steps > (int)(222.0 * arcFrac)) steps = (int)(222.0 * arcFrac);
double a = a1;
for (int i = 0; i < n; ++i) double x = std::cos(a1);
{ double y = std::sin(a1);
result[i].X = pt.X + Round(std::cos(a)*r); double c = std::cos((a2 - a1) / steps);
result[i].Y = pt.Y + Round(std::sin(a)*r); double s = std::sin((a2 - a1) / steps);
a += da; Polygon result(steps +1);
for (int i = 0; i <= steps; ++i)
{
result[i].X = pt.X + Round(x * r);
result[i].Y = pt.Y + Round(y * r);
double x2 = x;
x = x * c - s * y; //cross product
y = x2 * s + y * c; //dot product
} }
return result; return result;
} }
...@@ -3002,7 +3098,7 @@ Polygon BuildArc(const IntPoint &pt, ...@@ -3002,7 +3098,7 @@ Polygon BuildArc(const IntPoint &pt,
DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2) DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2)
{ {
if(pt2.X == pt1.X && pt2.Y == pt1.Y) if(pt2.X == pt1.X && pt2.Y == pt1.Y)
return DoublePoint(0, 0); return DoublePoint(0, 0);
double dx = (double)(pt2.X - pt1.X); double dx = (double)(pt2.X - pt1.X);
...@@ -3026,11 +3122,11 @@ private: ...@@ -3026,11 +3122,11 @@ private:
size_t m_i, m_j, m_k; size_t m_i, m_j, m_k;
static const int buffLength = 128; static const int buffLength = 128;
JoinType m_jointype; JoinType m_jointype;
public: public:
PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
double delta, JoinType jointype, double MiterLimit, bool AutoFix) double delta, JoinType jointype, double limit, bool autoFix)
{ {
//nb precondition - out_polys != ptsin_polys //nb precondition - out_polys != ptsin_polys
if (NEAR_ZERO(delta)) if (NEAR_ZERO(delta))
...@@ -3043,20 +3139,20 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, ...@@ -3043,20 +3139,20 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
this->m_delta = delta; this->m_delta = delta;
this->m_jointype = jointype; this->m_jointype = jointype;
//ChecksInput - fixes polygon orientation if necessary and removes //ChecksInput - fixes polygon orientation if necessary and removes
//duplicate vertices. Can be set false when you're sure that polygon //duplicate vertices. Can be set false when you're sure that polygon
//orientation is correct and that there are no duplicate vertices. //orientation is correct and that there are no duplicate vertices.
if (AutoFix) if (autoFix)
{ {
size_t Len = m_p.size(), botI = 0; size_t Len = m_p.size(), botI = 0;
while (botI < Len && m_p[botI].size() == 0) botI++; while (botI < Len && m_p[botI].size() == 0) botI++;
if (botI == Len) return; if (botI == Len) return;
//botPt: used to find the lowermost (in inverted Y-axis) & leftmost point //botPt: used to find the lowermost (in inverted Y-axis) & leftmost point
//This point (on m_p[botI]) must be on an outer polygon ring and if //This point (on m_p[botI]) must be on an outer polygon ring and if
//its orientation is false (counterclockwise) then assume all polygons //its orientation is false (counterclockwise) then assume all polygons
//need reversing ... //need reversing ...
IntPoint botPt = m_p[botI][0]; IntPoint botPt = m_p[botI][0];
for (size_t i = botI; i < Len; ++i) for (size_t i = botI; i < Len; ++i)
{ {
if (m_p[i].size() < 3) continue; if (m_p[i].size() < 3) continue;
...@@ -3066,7 +3162,7 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, ...@@ -3066,7 +3162,7 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
{ {
if (PointsEqual(*it, *(it -1))) if (PointsEqual(*it, *(it -1)))
it = m_p[i].erase(it); it = m_p[i].erase(it);
else else
{ {
if (UpdateBotPt(*it, botPt)) botI = i; if (UpdateBotPt(*it, botPt)) botI = i;
++it; ++it;
...@@ -3077,9 +3173,20 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, ...@@ -3077,9 +3173,20 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
ReversePolygons(m_p); ReversePolygons(m_p);
} }
if (MiterLimit <= 1) MiterLimit = 1; switch (jointype)
m_RMin = 2.0/(MiterLimit*MiterLimit); {
case jtRound:
if (limit <= 0) limit = 0.25;
else if (limit > std::fabs(delta)) limit = std::fabs(delta);
break;
case jtMiter:
if (limit < 2) limit = 2;
break;
default: //unused
limit = 1;
}
m_RMin = 2.0/(limit*limit);
double deltaSq = delta*delta; double deltaSq = delta*delta;
out_polys.clear(); out_polys.clear();
out_polys.resize(m_p.size()); out_polys.resize(m_p.size());
...@@ -3101,7 +3208,7 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, ...@@ -3101,7 +3208,7 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
else if (len == 1) else if (len == 1)
{ {
Polygon arc; Polygon arc;
arc = BuildArc(m_p[m_i][len-1], 0, 2 * pi, delta); arc = BuildArc(m_p[m_i][len-1], 0, 2 * pi, delta, limit);
out_polys[m_i] = arc; out_polys[m_i] = arc;
continue; continue;
} }
...@@ -3112,7 +3219,7 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, ...@@ -3112,7 +3219,7 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
normals[len-1] = GetUnitNormal(m_p[m_i][len-1], m_p[m_i][0]); normals[len-1] = GetUnitNormal(m_p[m_i][len-1], m_p[m_i][0]);
for (m_j = 0; m_j < len -1; ++m_j) for (m_j = 0; m_j < len -1; ++m_j)
normals[m_j] = GetUnitNormal(m_p[m_i][m_j], m_p[m_i][m_j+1]); normals[m_j] = GetUnitNormal(m_p[m_i][m_j], m_p[m_i][m_j+1]);
m_k = len -1; m_k = len -1;
for (m_j = 0; m_j < len; ++m_j) for (m_j = 0; m_j < len; ++m_j)
{ {
...@@ -3120,13 +3227,13 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys, ...@@ -3120,13 +3227,13 @@ PolyOffsetBuilder(const Polygons& in_polys, Polygons& out_polys,
{ {
case jtMiter: case jtMiter:
{ {
m_R = 1 + (normals[m_j].X*normals[m_k].X + m_R = 1 + (normals[m_j].X*normals[m_k].X +
normals[m_j].Y*normals[m_k].Y); normals[m_j].Y*normals[m_k].Y);
if (m_R >= m_RMin) DoMiter(); else DoSquare(MiterLimit); if (m_R >= m_RMin) DoMiter(); else DoSquare(limit);
break; break;
} }
case jtSquare: DoSquare(); break; case jtSquare: DoSquare(1.0); break;
case jtRound: DoRound(); break; case jtRound: DoRound(limit); break;
} }
m_k = m_j; m_k = m_j;
} }
...@@ -3165,14 +3272,13 @@ private: ...@@ -3165,14 +3272,13 @@ private:
void AddPoint(const IntPoint& pt) void AddPoint(const IntPoint& pt)
{ {
Polygon::size_type len = m_curr_poly->size(); if (m_curr_poly->size() == m_curr_poly->capacity())
if (len == m_curr_poly->capacity()) m_curr_poly->reserve(m_curr_poly->capacity() + buffLength);
m_curr_poly->reserve(len + buffLength);
m_curr_poly->push_back(pt); m_curr_poly->push_back(pt);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void DoSquare(double mul = 1.0) void DoSquare(double mul)
{ {
IntPoint pt1 = IntPoint((long64)Round(m_p[m_i][m_j].X + normals[m_k].X * m_delta), IntPoint pt1 = IntPoint((long64)Round(m_p[m_i][m_j].X + normals[m_k].X * m_delta),
(long64)Round(m_p[m_i][m_j].Y + normals[m_k].Y * m_delta)); (long64)Round(m_p[m_i][m_j].Y + normals[m_k].Y * m_delta));
...@@ -3206,7 +3312,7 @@ void DoMiter() ...@@ -3206,7 +3312,7 @@ void DoMiter()
if ((normals[m_k].X * normals[m_j].Y - normals[m_j].X * normals[m_k].Y) * m_delta >= 0) if ((normals[m_k].X * normals[m_j].Y - normals[m_j].X * normals[m_k].Y) * m_delta >= 0)
{ {
double q = m_delta / m_R; double q = m_delta / m_R;
AddPoint(IntPoint((long64)Round(m_p[m_i][m_j].X + AddPoint(IntPoint((long64)Round(m_p[m_i][m_j].X +
(normals[m_k].X + normals[m_j].X) * q), (normals[m_k].X + normals[m_j].X) * q),
(long64)Round(m_p[m_i][m_j].Y + (normals[m_k].Y + normals[m_j].Y) * q))); (long64)Round(m_p[m_i][m_j].Y + (normals[m_k].Y + normals[m_j].Y) * q)));
} }
...@@ -3223,7 +3329,7 @@ void DoMiter() ...@@ -3223,7 +3329,7 @@ void DoMiter()
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void DoRound() void DoRound(double limit)
{ {
IntPoint pt1 = IntPoint((long64)Round(m_p[m_i][m_j].X + normals[m_k].X * m_delta), IntPoint pt1 = IntPoint((long64)Round(m_p[m_i][m_j].X + normals[m_k].X * m_delta),
(long64)Round(m_p[m_i][m_j].Y + normals[m_k].Y * m_delta)); (long64)Round(m_p[m_i][m_j].Y + normals[m_k].Y * m_delta));
...@@ -3239,7 +3345,7 @@ void DoRound() ...@@ -3239,7 +3345,7 @@ void DoRound()
double a2 = std::atan2(normals[m_j].Y, normals[m_j].X); double a2 = std::atan2(normals[m_j].Y, normals[m_j].X);
if (m_delta > 0 && a2 < a1) a2 += pi *2; if (m_delta > 0 && a2 < a1) a2 += pi *2;
else if (m_delta < 0 && a2 > a1) a2 -= pi *2; else if (m_delta < 0 && a2 > a1) a2 -= pi *2;
Polygon arc = BuildArc(m_p[m_i][m_j], a1, a2, m_delta); Polygon arc = BuildArc(m_p[m_i][m_j], a1, a2, m_delta, limit);
for (Polygon::size_type m = 0; m < arc.size(); m++) for (Polygon::size_type m = 0; m < arc.size(); m++)
AddPoint(arc[m]); AddPoint(arc[m]);
} }
...@@ -3267,14 +3373,14 @@ bool UpdateBotPt(const IntPoint &pt, IntPoint &botPt) ...@@ -3267,14 +3373,14 @@ bool UpdateBotPt(const IntPoint &pt, IntPoint &botPt)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
double delta, JoinType jointype, double MiterLimit, bool AutoFix) double delta, JoinType jointype, double limit, bool autoFix)
{ {
if (&out_polys == &in_polys) if (&out_polys == &in_polys)
{ {
Polygons poly2(in_polys); Polygons poly2(in_polys);
PolyOffsetBuilder(poly2, out_polys, delta, jointype, MiterLimit, AutoFix); PolyOffsetBuilder(poly2, out_polys, delta, jointype, limit, autoFix);
} }
else PolyOffsetBuilder(in_polys, out_polys, delta, jointype, MiterLimit, AutoFix); else PolyOffsetBuilder(in_polys, out_polys, delta, jointype, limit, autoFix);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -3300,6 +3406,86 @@ void SimplifyPolygons(Polygons &polys, PolyFillType fillType) ...@@ -3300,6 +3406,86 @@ void SimplifyPolygons(Polygons &polys, PolyFillType fillType)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool PointsAreClose(IntPoint pt1, IntPoint pt2, long64 distSqrd)
{
long64 dx = pt1.X - pt2.X;
long64 dy = pt1.Y - pt2.Y;
return ((dx * dx) + (dy * dy) <= distSqrd);
}
//------------------------------------------------------------------------------
void CleanPolygon(Polygon& in_poly, Polygon& out_poly, double distance)
{
//distance = proximity in units/pixels below which vertices
//will be stripped. Default ~= sqrt(2).
int highI = in_poly.size() -1;
long64 d = (int)(distance * distance);
while (highI > 0 && PointsAreClose(in_poly[highI], in_poly[0], d)) highI--;
if (highI < 2)
{
out_poly.clear();
return;
}
out_poly.resize(highI + 1);
bool UseFullRange = FullRangeNeeded(in_poly);
IntPoint pt = in_poly[highI];
int i = 0;
int k = 0;
for (;;)
{
if (i >= highI) break;
int j = i + 1;
if (PointsAreClose(pt, in_poly[j], d))
{
i = j + 1;
while (i <= highI && PointsAreClose(pt, in_poly[i], d)) i++;
continue;
}
if (PointsAreClose(in_poly[i], in_poly[j], d) ||
SlopesEqual(pt, in_poly[i], in_poly[j], UseFullRange))
{
i = j;
continue;
}
pt = in_poly[i++];
out_poly[k++] = pt;
}
if (i <= highI) out_poly[k++] = in_poly[i];
if (k > 2 && SlopesEqual(out_poly[k -2], out_poly[k -1], out_poly[0], UseFullRange))
k--;
if (k < 3) out_poly.clear();
else if (k <= highI) out_poly.resize(k);
}
//------------------------------------------------------------------------------
void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance)
{
for (Polygons::size_type i = 0; i < in_polys.size(); ++i)
CleanPolygon(in_polys[i], out_polys[i], distance);
}
//------------------------------------------------------------------------------
void AddPolyNodeToPolygons(PolyNode& polynode, Polygons& polygons)
{
if (polynode.Contour.size() > 0)
polygons.push_back(polynode.Contour);
for (int i = 0; i < polynode.ChildCount(); ++i)
AddPolyNodeToPolygons(*polynode.Childs[i], polygons);
}
//------------------------------------------------------------------------------
void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons)
{
polygons.resize(0);
polygons.reserve(polytree.Total());
AddPolyNodeToPolygons(polytree, polygons);
}
//------------------------------------------------------------------------------
std::ostream& operator <<(std::ostream &s, IntPoint& p) std::ostream& operator <<(std::ostream &s, IntPoint& p)
{ {
s << p.X << ' ' << p.Y << "\n"; s << p.X << ' ' << p.Y << "\n";
......
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 5.0.3 * * Version : 5.1.4 *
* Date : 12 January 2013 * * Date : 24 March 2013 *
* Website : http://www.angusj.com * * Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2013 * * Copyright : Angus Johnson 2010-2013 *
* * * *
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* Paper no. DETC2005-85513 pp. 565-575 * * Paper no. DETC2005-85513 pp. 565-575 *
* ASME 2005 International Design Engineering Technical Conferences * * ASME 2005 International Design Engineering Technical Conferences *
* and Computers and Information in Engineering Conference (IDETC/CIE2005) * * and Computers and Information in Engineering Conference (IDETC/CIE2005) *
* September 2428, 2005 , Long Beach, California, USA * * September 24-28, 2005 , Long Beach, California, USA *
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * * http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
* * * *
*******************************************************************************/ *******************************************************************************/
...@@ -64,25 +64,59 @@ public: ...@@ -64,25 +64,59 @@ public:
typedef std::vector< IntPoint > Polygon; typedef std::vector< IntPoint > Polygon;
typedef std::vector< Polygon > Polygons; typedef std::vector< Polygon > Polygons;
std::ostream& operator <<(std::ostream &s, Polygon &p); std::ostream& operator <<(std::ostream &s, Polygon &p);
std::ostream& operator <<(std::ostream &s, Polygons &p); std::ostream& operator <<(std::ostream &s, Polygons &p);
struct ExPolygon { class PolyNode;
Polygon outer; typedef std::vector< PolyNode* > PolyNodes;
Polygons holes;
class PolyNode
{
public:
PolyNode();
Polygon Contour;
PolyNodes Childs;
PolyNode* Parent;
PolyNode* GetNext() const;
bool IsHole() const;
int ChildCount() const;
private:
PolyNode* GetNextSiblingUp() const;
unsigned Index; //node index in Parent.Childs
void AddChild(PolyNode& child);
friend class Clipper; //to access Index
}; };
typedef std::vector< ExPolygon > ExPolygons;
class PolyTree: public PolyNode
{
public:
~PolyTree(){Clear();};
PolyNode* GetFirst() const;
void Clear();
int Total() const;
private:
PolyNodes AllNodes;
friend class Clipper; //to access AllNodes
};
enum JoinType { jtSquare, jtRound, jtMiter }; enum JoinType { jtSquare, jtRound, jtMiter };
bool Orientation(const Polygon &poly); bool Orientation(const Polygon &poly);
double Area(const Polygon &poly); double Area(const Polygon &poly);
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
double delta, JoinType jointype = jtSquare, double MiterLimit = 2, bool AutoFix = true); double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFix = true);
void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd);
void CleanPolygon(Polygon& in_poly, Polygon& out_poly, double distance = 1.415);
void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance = 1.415);
void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons);
void ReversePolygon(Polygon& p); void ReversePolygon(Polygon& p);
void ReversePolygons(Polygons& p); void ReversePolygons(Polygons& p);
...@@ -100,7 +134,6 @@ struct TEdge { ...@@ -100,7 +134,6 @@ struct TEdge {
double dx; double dx;
long64 deltaX; long64 deltaX;
long64 deltaY; long64 deltaY;
long64 tmpX;
PolyType polyType; PolyType polyType;
EdgeSide side; EdgeSide side;
int windDelta; //1 or -1 depending on winding direction int windDelta; //1 or -1 depending on winding direction
...@@ -140,8 +173,8 @@ struct OutPt; //forward declaration ...@@ -140,8 +173,8 @@ struct OutPt; //forward declaration
struct OutRec { struct OutRec {
int idx; int idx;
bool isHole; bool isHole;
OutRec *FirstLeft; OutRec *FirstLeft; //see comments in clipper.pas
OutRec *AppendLink; PolyNode *polyNode;
OutPt *pts; OutPt *pts;
OutPt *bottomPt; OutPt *bottomPt;
}; };
...@@ -204,13 +237,13 @@ public: ...@@ -204,13 +237,13 @@ public:
Clipper(); Clipper();
~Clipper(); ~Clipper();
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
Polygons &solution, Polygons &solution,
PolyFillType subjFillType = pftEvenOdd, PolyFillType subjFillType = pftEvenOdd,
PolyFillType clipFillType = pftEvenOdd); PolyFillType clipFillType = pftEvenOdd);
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
ExPolygons &solution, PolyTree &polytree,
PolyFillType subjFillType = pftEvenOdd, PolyFillType subjFillType = pftEvenOdd,
PolyFillType clipFillType = pftEvenOdd); PolyFillType clipFillType = pftEvenOdd);
void Clear(); void Clear();
bool ReverseSolution() {return m_ReverseOutput;}; bool ReverseSolution() {return m_ReverseOutput;};
void ReverseSolution(bool value) {m_ReverseOutput = value;}; void ReverseSolution(bool value) {m_ReverseOutput = value;};
...@@ -225,12 +258,12 @@ private: ...@@ -225,12 +258,12 @@ private:
Scanbeam *m_Scanbeam; Scanbeam *m_Scanbeam;
TEdge *m_ActiveEdges; TEdge *m_ActiveEdges;
TEdge *m_SortedEdges; TEdge *m_SortedEdges;
IntersectNode *m_IntersectNodes; IntersectNode *m_IntersectNodes;
bool m_ExecuteLocked; bool m_ExecuteLocked;
PolyFillType m_ClipFillType; PolyFillType m_ClipFillType;
PolyFillType m_SubjFillType; PolyFillType m_SubjFillType;
bool m_ReverseOutput; bool m_ReverseOutput;
bool m_UsingExPolygons; bool m_UsingPolyTree;
void DisposeScanbeamList(); void DisposeScanbeamList();
void SetWindingCount(TEdge& edge); void SetWindingCount(TEdge& edge);
bool IsEvenOddFillType(const TEdge& edge) const; bool IsEvenOddFillType(const TEdge& edge) const;
...@@ -269,13 +302,13 @@ private: ...@@ -269,13 +302,13 @@ private:
void ProcessIntersectList(); void ProcessIntersectList();
void ProcessEdgesAtTopOfScanbeam(const long64 topY); void ProcessEdgesAtTopOfScanbeam(const long64 topY);
void BuildResult(Polygons& polys); void BuildResult(Polygons& polys);
void BuildResultEx(ExPolygons& polys); void BuildResult2(PolyTree& polytree);
void SetHoleState(TEdge *e, OutRec *OutRec); void SetHoleState(TEdge *e, OutRec *OutRec);
void DisposeIntersectNodes(); void DisposeIntersectNodes();
bool FixupIntersections(); bool FixupIntersectionOrder();
void FixupOutPolygon(OutRec &outRec); void FixupOutPolygon(OutRec &outRec);
bool IsHole(TEdge *e); bool IsHole(TEdge *e);
void FixHoleLinkage(OutRec *outRec); void FixHoleLinkage(OutRec &outRec);
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1); void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1);
void ClearJoins(); void ClearJoins();
void AddHorzJoin(TEdge *e, int idx); void AddHorzJoin(TEdge *e, int idx);
...@@ -283,6 +316,8 @@ private: ...@@ -283,6 +316,8 @@ private:
bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2); bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2);
void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx); void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx);
void JoinCommonEdges(); void JoinCommonEdges();
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
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