pagelayout editor: Add tests for invalid parameters.
Invalid parameters are repeat count < 1, size < 0 and default size < 0.01 mm
This commit is contained in:
parent
449a3ba3dd
commit
0d903d43a0
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -113,7 +113,6 @@ private:
|
|||
void readPngdata( DS_DATA_ITEM_BITMAP * aItem );
|
||||
};
|
||||
|
||||
// PCB_PLOT_PARAMS_PARSER
|
||||
|
||||
DRAWING_SHEET_PARSER::DRAWING_SHEET_PARSER( const char* aLine,
|
||||
const wxString& aSource ) :
|
||||
|
@ -233,7 +232,7 @@ void DRAWING_SHEET_PARSER::Parse( DS_DATA_MODEL* aLayout )
|
|||
|
||||
case T_polygon:
|
||||
item = new DS_DATA_ITEM_POLYGONS();
|
||||
parsePolygon( (DS_DATA_ITEM_POLYGONS*) item );
|
||||
parsePolygon( (DS_DATA_ITEM_POLYGONS*) item );
|
||||
aLayout->Append( item );
|
||||
break;
|
||||
|
||||
|
@ -406,7 +405,7 @@ void DRAWING_SHEET_PARSER::parsePolygon( DS_DATA_ITEM_POLYGONS * aItem )
|
|||
break;
|
||||
|
||||
case T_repeat:
|
||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
||||
aItem->m_RepeatCount = parseInt( 1, 100 );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -483,7 +482,7 @@ void DRAWING_SHEET_PARSER::parseBitmap( DS_DATA_ITEM_BITMAP * aItem )
|
|||
break;
|
||||
|
||||
case T_repeat:
|
||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
||||
aItem->m_RepeatCount = parseInt( 1, 100 );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -619,7 +618,7 @@ void DRAWING_SHEET_PARSER::parseGraphic( DS_DATA_ITEM * aItem )
|
|||
break;
|
||||
|
||||
case T_repeat:
|
||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
||||
aItem->m_RepeatCount = parseInt( 1, 100 );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -679,7 +678,7 @@ void DRAWING_SHEET_PARSER::parseText( DS_DATA_ITEM_TEXT* aItem )
|
|||
break;
|
||||
|
||||
case T_repeat:
|
||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
||||
aItem->m_RepeatCount = parseInt( 1, 100 );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
#include <dialogs/html_message_box.h>
|
||||
|
||||
|
||||
#define DLG_MIN_TEXTSIZE 0.01 // min drawing sheet text default size in mm from PROPERTIES_FRAME
|
||||
// Note also 0.0 is allowed for a given text to use the default size
|
||||
#define DLG_MAX_TEXTSIZE 100.0 // max drawing sheet text size in mm from PROPERTIES_FRAME
|
||||
|
||||
|
||||
PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) :
|
||||
PANEL_PROPERTIES_BASE( aParent ),
|
||||
m_scintillaTricks( nullptr ),
|
||||
|
@ -175,14 +180,26 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral()
|
|||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
|
||||
// Import default parameters from widgets
|
||||
m_defaultLineWidth.Validate( 0.0, 10.0, EDA_UNITS::MILLIMETRES );
|
||||
model.m_DefaultLineWidth = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_defaultLineWidth.GetValue() );
|
||||
|
||||
model.m_DefaultTextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_defaultTextSizeX.GetValue() );
|
||||
model.m_DefaultTextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
bool is_valid = m_defaultTextSizeX.Validate( DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE,
|
||||
EDA_UNITS::MILLIMETRES );
|
||||
if( is_valid )
|
||||
model.m_DefaultTextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_defaultTextSizeX.GetValue() );
|
||||
|
||||
is_valid = m_defaultTextSizeY.Validate( DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES );
|
||||
|
||||
if( is_valid )
|
||||
model.m_DefaultTextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_defaultTextSizeY.GetValue() );
|
||||
model.m_DefaultTextThickness = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
|
||||
is_valid = m_defaultTextThickness.Validate( 0.0, 5.0, EDA_UNITS::MILLIMETRES );
|
||||
|
||||
if( is_valid )
|
||||
model.m_DefaultTextThickness = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_defaultTextThickness.GetValue() );
|
||||
|
||||
// Get page margins values
|
||||
|
@ -462,7 +479,10 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
|
|||
}
|
||||
|
||||
// Import thickness
|
||||
aItem->m_LineWidth =
|
||||
bool is_valid = m_lineWidth.Validate( 0.0, 10.0, EDA_UNITS::MILLIMETRES );
|
||||
|
||||
if( is_valid )
|
||||
aItem->m_LineWidth =
|
||||
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_lineWidth.GetValue() );
|
||||
|
||||
// Import Start point
|
||||
|
@ -497,6 +517,15 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
|
|||
long itmp;
|
||||
msg = m_textCtrlRepeatCount->GetValue();
|
||||
msg.ToLong( &itmp );
|
||||
// Ensure m_RepeatCount is > 0. Otherwise it create issues because a repeat
|
||||
// count < 1 make no sense
|
||||
if( itmp < 1l )
|
||||
{
|
||||
itmp = 1;
|
||||
msg.Printf( wxT( "%ld" ), itmp );
|
||||
m_textCtrlRepeatCount->SetValue( msg );
|
||||
}
|
||||
|
||||
aItem->m_RepeatCount = itmp;
|
||||
|
||||
aItem->m_IncrementVector.x =
|
||||
|
@ -539,10 +568,16 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
|
|||
item->m_Orient = EDA_UNIT_UTILS::UI::DoubleValueFromString( drawSheetIUScale, EDA_UNITS::UNSCALED, msg );
|
||||
|
||||
// Import text size
|
||||
item->m_TextSize.x =
|
||||
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textSizeX.GetValue() );
|
||||
item->m_TextSize.y =
|
||||
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textSizeY.GetValue() );
|
||||
is_valid = m_textSizeX.Validate( 0.0, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES );
|
||||
|
||||
if( is_valid )
|
||||
item->m_TextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_textSizeX.GetValue() );
|
||||
is_valid = m_textSizeY.Validate( 0.0, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES );
|
||||
|
||||
if( is_valid )
|
||||
item->m_TextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
||||
m_textSizeY.GetValue() );
|
||||
|
||||
// Import constraints:
|
||||
item->m_BoundingBoxSize.x =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -28,7 +28,7 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
|
|||
|
||||
m_staticTextType = new wxStaticText( m_swItemProperties, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextType->Wrap( -1 );
|
||||
m_staticTextType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_SLANT, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_staticTextType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
|
||||
|
||||
bSizerButt->Add( m_staticTextType, 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 4 );
|
||||
|
||||
|
@ -56,6 +56,7 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
|
|||
m_stcText->SetViewWhiteSpace( false );
|
||||
m_stcText->SetMarginWidth( 2, 0 );
|
||||
m_stcText->SetIndentationGuides( false );
|
||||
m_stcText->SetReadOnly( false );
|
||||
m_stcText->SetMarginWidth( 1, 0 );
|
||||
m_stcText->SetMarginWidth( 0, 0 );
|
||||
m_stcText->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS );
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="15" />
|
||||
<FileVersion major="1" minor="16" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -14,6 +14,7 @@
|
|||
<property name="file">properties_frame_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">properties_frame_base</property>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">1</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Panel" expanded="1">
|
||||
|
@ -46,6 +48,7 @@
|
|||
<property name="size">-1,-1</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
|
@ -257,6 +260,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -442,6 +446,7 @@
|
|||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="read_only">0</property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
|
@ -507,6 +512,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -579,6 +585,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -651,6 +658,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -723,6 +731,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -795,6 +804,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -867,6 +877,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -939,6 +950,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -1011,6 +1023,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -1083,6 +1096,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -1155,6 +1169,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -1227,6 +1242,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -4786,6 +4802,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -5748,6 +5765,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -6637,6 +6655,7 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -20,10 +20,10 @@ class FONT_CHOICE;
|
|||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stc/stc.h>
|
||||
|
@ -148,7 +148,7 @@ class PANEL_PROPERTIES_BASE : public wxPanel
|
|||
wxStaticText* m_bottomMarginUnits;
|
||||
wxButton* m_buttonGeneralOptsOK;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void OnPageChanged( wxNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void onHelp( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnAcceptPrms( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
@ -158,6 +158,7 @@ class PANEL_PROPERTIES_BASE : public wxPanel
|
|||
public:
|
||||
|
||||
PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
|
||||
~PANEL_PROPERTIES_BASE();
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue