graphic items properties dialog: fix incorrect handling of S_POLYGON DRAWSEGMENT items

This commit is contained in:
jean-pierre charras 2017-12-21 19:47:03 +01:00
parent 900ddca0b4
commit 7586afd530
5 changed files with 80 additions and 56 deletions

View File

@ -30,6 +30,7 @@
* Lines
* Circles
* Arcs
* polygon (only layer and contour thickness)
* used as graphic elements found on non copper layers in boards
* items on edge layers are considered as graphic items
* Pcb texts are not always graphic items and are not handled here
@ -53,6 +54,7 @@
#include <dialog_graphic_item_properties_base.h>
#include <class_pcb_layer_box_selector.h>
#include <html_messagebox.h>
#include <widgets/text_ctrl_eval.h>
class DIALOG_GRAPHIC_ITEM_PROPERTIES : public DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE
@ -137,6 +139,14 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() );
}
// Only an arc has a angle parameter. So do not show this parameter for other shapes
if( m_item->GetShape() != S_ARC )
{
m_AngleText->Show( false );
m_AngleCtrl->Show( false );
m_AngleUnit->Show( false );
}
wxString msg;
// Change texts according to the segment shape:
@ -148,9 +158,6 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
m_StartPointYLabel->SetLabel( _( "Center Y:" ) );
m_EndPointXLabel->SetLabel( _( "Point X:" ) );
m_EndPointYLabel->SetLabel( _( "Point Y:" ) );
m_AngleText->Show( false );
m_AngleCtrl->Show( false );
m_AngleUnit->Show( false );
break;
case S_ARC:
@ -163,14 +170,16 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
m_AngleValue = m_item->GetAngle() / 10.0;
break;
case S_POLYGON:
SetTitle( _( "Polygon Properties" ) );
m_fgUpperLeftGridSizer->Show( false );
break;
case S_SEGMENT:
SetTitle( _( "Line Segment Properties" ) );
break;
// Fall through.
default:
m_AngleText->Show( false );
m_AngleCtrl->Show( false );
m_AngleUnit->Show( false );
break;
}
@ -304,7 +313,6 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate()
// Fall through.
case S_CIRCLE:
// Check radius.
if( (startx == endx) && (starty == endy) )
{
@ -317,7 +325,6 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate()
break;
default:
// Check start and end are not the same.
if( (startx == endx) && (starty == endy) )
{

View File

@ -1,11 +1,12 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "class_pcb_layer_box_selector.h"
#include "widgets/text_ctrl_eval.h"
#include "dialog_graphic_item_properties_base.h"
@ -21,58 +22,57 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind
wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer* fgUpperLeftGridSizer;
fgUpperLeftGridSizer = new wxFlexGridSizer( 4, 3, 0, 0 );
fgUpperLeftGridSizer->AddGrowableCol( 1 );
fgUpperLeftGridSizer->SetFlexibleDirection( wxBOTH );
fgUpperLeftGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_fgUpperLeftGridSizer = new wxFlexGridSizer( 4, 3, 0, 0 );
m_fgUpperLeftGridSizer->AddGrowableCol( 1 );
m_fgUpperLeftGridSizer->SetFlexibleDirection( wxBOTH );
m_fgUpperLeftGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_StartPointXLabel = new wxStaticText( this, wxID_ANY, _("Start point X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_StartPointXLabel->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_StartPointXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_fgUpperLeftGridSizer->Add( m_StartPointXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_Center_StartXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperLeftGridSizer->Add( m_Center_StartXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_Center_StartXCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fgUpperLeftGridSizer->Add( m_Center_StartXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_StartPointXUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_StartPointXUnit->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_StartPointXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_fgUpperLeftGridSizer->Add( m_StartPointXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_StartPointYLabel = new wxStaticText( this, wxID_ANY, _("Start point Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_StartPointYLabel->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_StartPointYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_fgUpperLeftGridSizer->Add( m_StartPointYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_Center_StartYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperLeftGridSizer->Add( m_Center_StartYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_Center_StartYCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fgUpperLeftGridSizer->Add( m_Center_StartYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_StartPointYUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_StartPointYUnit->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_StartPointYUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_fgUpperLeftGridSizer->Add( m_StartPointYUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_EndPointXLabel = new wxStaticText( this, wxID_ANY, _("End point X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_EndPointXLabel->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_EndPointXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_fgUpperLeftGridSizer->Add( m_EndPointXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_EndX_Radius_Ctrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperLeftGridSizer->Add( m_EndX_Radius_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_EndX_Radius_Ctrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fgUpperLeftGridSizer->Add( m_EndX_Radius_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_EndPointXUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_EndPointXUnit->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_EndPointXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_fgUpperLeftGridSizer->Add( m_EndPointXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_EndPointYLabel = new wxStaticText( this, wxID_ANY, _("End point Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_EndPointYLabel->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_EndPointYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_fgUpperLeftGridSizer->Add( m_EndPointYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_EndY_Ctrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperLeftGridSizer->Add( m_EndY_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_EndY_Ctrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fgUpperLeftGridSizer->Add( m_EndY_Ctrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_EndPointYUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_EndPointYUnit->Wrap( -1 );
fgUpperLeftGridSizer->Add( m_EndPointYUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP, 5 );
m_fgUpperLeftGridSizer->Add( m_EndPointYUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP, 5 );
bUpperSizer->Add( fgUpperLeftGridSizer, 1, wxEXPAND, 5 );
bUpperSizer->Add( m_fgUpperLeftGridSizer, 1, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
bUpperSizer->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );
@ -90,7 +90,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind
m_AngleText->Wrap( -1 );
fgUpperRightGridSizer->Add( m_AngleText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_AngleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_AngleCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperRightGridSizer->Add( m_AngleCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_AngleUnit = new wxStaticText( this, wxID_ANY, _("degrees"), wxDefaultPosition, wxDefaultSize, 0 );
@ -101,7 +101,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind
m_ThicknessLabel->Wrap( -1 );
fgUpperRightGridSizer->Add( m_ThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_ThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_ThicknessCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperRightGridSizer->Add( m_ThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_ThicknessTextUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
@ -112,7 +112,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind
m_DefaultThicknessLabel->Wrap( -1 );
fgUpperRightGridSizer->Add( m_DefaultThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_DefaultThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DefaultThicknessCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgUpperRightGridSizer->Add( m_DefaultThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
m_DefaulThicknessTextUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );

View File

@ -113,9 +113,9 @@
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgUpperLeftGridSizer</property>
<property name="name">m_fgUpperLeftGridSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<property name="rows">4</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -13,6 +13,7 @@
#include <wx/intl.h>
class DIALOG_SHIM;
class PCB_LAYER_BOX_SELECTOR;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
#include <wx/string.h>
@ -39,27 +40,28 @@ class DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE : public DIALOG_SHIM
private:
protected:
wxFlexGridSizer* m_fgUpperLeftGridSizer;
wxStaticText* m_StartPointXLabel;
wxTextCtrl* m_Center_StartXCtrl;
TEXT_CTRL_EVAL* m_Center_StartXCtrl;
wxStaticText* m_StartPointXUnit;
wxStaticText* m_StartPointYLabel;
wxTextCtrl* m_Center_StartYCtrl;
TEXT_CTRL_EVAL* m_Center_StartYCtrl;
wxStaticText* m_StartPointYUnit;
wxStaticText* m_EndPointXLabel;
wxTextCtrl* m_EndX_Radius_Ctrl;
TEXT_CTRL_EVAL* m_EndX_Radius_Ctrl;
wxStaticText* m_EndPointXUnit;
wxStaticText* m_EndPointYLabel;
wxTextCtrl* m_EndY_Ctrl;
TEXT_CTRL_EVAL* m_EndY_Ctrl;
wxStaticText* m_EndPointYUnit;
wxStaticLine* m_staticline2;
wxStaticText* m_AngleText;
wxTextCtrl* m_AngleCtrl;
TEXT_CTRL_EVAL* m_AngleCtrl;
wxStaticText* m_AngleUnit;
wxStaticText* m_ThicknessLabel;
wxTextCtrl* m_ThicknessCtrl;
TEXT_CTRL_EVAL* m_ThicknessCtrl;
wxStaticText* m_ThicknessTextUnit;
wxStaticText* m_DefaultThicknessLabel;
wxTextCtrl* m_DefaultThicknessCtrl;
TEXT_CTRL_EVAL* m_DefaultThicknessCtrl;
wxStaticText* m_DefaulThicknessTextUnit;
wxStaticText* m_LayerLabel;
PCB_LAYER_BOX_SELECTOR* m_LayerSelectionCtrl;

View File

@ -52,6 +52,7 @@
#include <dialog_graphic_item_properties_base.h>
#include <class_pcb_layer_box_selector.h>
#include <html_messagebox.h>
#include <widgets/text_ctrl_eval.h>
class DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES : public DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE
{
@ -140,6 +141,14 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow()
texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() );
}
// Only an arc has a angle parameter. So do not show this parameter for other shapes
if( m_item->GetShape() != S_ARC )
{
m_AngleText->Show( false );
m_AngleCtrl->Show( false );
m_AngleUnit->Show( false );
}
wxString msg;
// Change texts according to the segment shape:
@ -151,9 +160,6 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow()
m_StartPointYLabel->SetLabel( _( "Center Y" ) );
m_EndPointXLabel->SetLabel( _( "Point X" ) );
m_EndPointYLabel->SetLabel( _( "Point Y" ) );
m_AngleText->Show( false );
m_AngleCtrl->Show( false );
m_AngleUnit->Show( false );
break;
case S_ARC:
@ -166,14 +172,16 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow()
m_AngleValue = m_item->GetAngle() / 10.0;
break;
case S_POLYGON:
SetTitle( _( "Polygon Properties" ) );
m_fgUpperLeftGridSizer->Show( false );
break;
case S_SEGMENT:
SetTitle( _( "Line Segment Properties" ) );
break;
// Fall through.
default:
m_AngleText->Show( false );
m_AngleCtrl->Show( false );
m_AngleUnit->Show( false );
break;
}
@ -223,10 +231,14 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataFromWindow()
if( IsCopperLayer( layer ) )
{
/* an edge is put on a copper layer: this it is very dangerous. a
* confirmation is requested */
// An graphic item is put on a copper layer.
// This is sometimes useful, for instance for microwave applications ans net tees.
// Because the DRC does not handle graphic items, it can break boards.
// Therefore a confirmation is requested
if( !IsOK( NULL,
_( "The graphic item will be on a copper layer. This is very dangerous. Are you sure?" ) ) )
_( "The graphic item will be on a copper layer.\n"
"This is very dangerous because DRC does not handle it.\n"
"Are you sure?" ) ) )
return false;
}
@ -262,7 +274,7 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataFromWindow()
m_item->SetAngle( m_AngleValue * 10.0 );
}
commit.Push( _( "Modify module graphic item" ) );
commit.Push( "Modify footprint graphic item" );
m_parent->SetMsgPanel( m_item );
@ -306,6 +318,9 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::Validate()
break;
case S_POLYGON:
break;
default:
// Check start and end are not the same.