kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #17924
[PATCH 25/27] TypeSheetLabel: use enum
---
eeschema/class_netlist_object.h | 2 +-
eeschema/dialogs/dialog_edit_label.cpp | 3 ++-
eeschema/dialogs/dialog_sch_edit_sheet_pin.h | 8 ++++++--
eeschema/edit_label.cpp | 8 ++++----
eeschema/sch_sheet_pin.cpp | 2 +-
eeschema/sch_text.cpp | 4 ++--
eeschema/sch_text.h | 6 +++---
eeschema/schframe.h | 4 +++-
eeschema/sheetlab.cpp | 2 +-
9 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h
index cd82dc1..a2935c8 100644
--- a/eeschema/class_netlist_object.h
+++ b/eeschema/class_netlist_object.h
@@ -106,7 +106,7 @@ public:
union
{
ElectricPinType pin;
- int label;
+ TypeSheetLabel label;
} m_ElectricalType; /* Has meaning only for Pins and
* hierarchical pins: electrical type */
int m_BusNetCode; /* Used for BUS connections */
diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp
index e861a39..2bdb167 100644
--- a/eeschema/dialogs/dialog_edit_label.cpp
+++ b/eeschema/dialogs/dialog_edit_label.cpp
@@ -301,7 +301,8 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
m_CurrentText->SetSize( wxSize( value, value ) );
if( m_TextShape )
- m_CurrentText->SetShape( m_TextShape->GetSelection() );
+ /// @todo move cast to widget
+ m_CurrentText->SetShape( static_cast<TypeSheetLabel>( m_TextShape->GetSelection() ) );
int style = m_TextStyle->GetSelection();
diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin.h b/eeschema/dialogs/dialog_sch_edit_sheet_pin.h
index fc35864..4d02b01 100644
--- a/eeschema/dialogs/dialog_sch_edit_sheet_pin.h
+++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin.h
@@ -34,6 +34,9 @@
#include <dialog_sch_edit_sheet_pin_base.h>
+// enum TypeSheetLabel
+#include <sch_text.h>
+
class DIALOG_SCH_EDIT_SHEET_PIN : public DIALOG_SCH_EDIT_SHEET_PIN_BASE
{
@@ -49,8 +52,9 @@ public:
void SetTextWidth( const wxString& aWidth ) { m_textWidth->SetValue( aWidth ); }
wxString GetTextWidth() const { return m_textWidth->GetValue(); }
- void SetConnectionType( int aType ) { m_choiceConnectionType->SetSelection( aType ); }
- int GetConnectionType() const { return m_choiceConnectionType->GetCurrentSelection(); }
+ void SetConnectionType( TypeSheetLabel aType ) { m_choiceConnectionType->SetSelection( aType ); }
+ /// @todo move cast to widget
+ TypeSheetLabel GetConnectionType() const { return static_cast<TypeSheetLabel>( m_choiceConnectionType->GetCurrentSelection() ); }
void SetTextHeightUnits( const wxString& aUnit ) { m_staticHeightUnits->SetLabel( aUnit ); }
void SetTextWidthUnits( const wxString& aUnit ) { m_staticWidthUnits->SetLabel( aUnit ); }
diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp
index 049bdc8..780f91f 100644
--- a/eeschema/edit_label.cpp
+++ b/eeschema/edit_label.cpp
@@ -41,10 +41,10 @@
#include <eeschema_id.h>
-static int lastGlobalLabelShape = (int) NET_INPUT;
-static int lastTextOrientation = 0;
-static bool lastTextBold = false;
-static bool lastTextItalic = false;
+static TypeSheetLabel lastGlobalLabelShape = NET_INPUT;
+static int lastTextOrientation = 0;
+static bool lastTextBold = false;
+static bool lastTextItalic = false;
void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC )
diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp
index 045b257..bd9f0ca 100644
--- a/eeschema/sch_sheet_pin.cpp
+++ b/eeschema/sch_sheet_pin.cpp
@@ -447,7 +447,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx
* for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL
* for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL
*/
- int tmp = m_shape;
+ TypeSheetLabel tmp = m_shape;
switch( m_shape )
{
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index 12a9940..e6d11b7 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -102,11 +102,11 @@ static int* TemplateShape[5][4] =
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
SCH_ITEM( NULL, aType ),
- EDA_TEXT( text )
+ EDA_TEXT( text ),
+ m_shape( NET_INPUT )
{
m_Layer = LAYER_NOTES;
m_Pos = pos;
- m_shape = 0;
m_isDangling = false;
m_MultilineAllowed = true;
m_schematicOrientation = 0;
diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h
index 6c068da..e876af3 100644
--- a/eeschema/sch_text.h
+++ b/eeschema/sch_text.h
@@ -58,7 +58,7 @@ extern const char* SheetLabelType[]; /* names of types of labels */
class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
{
protected:
- int m_shape;
+ TypeSheetLabel m_shape;
/// True if not connected to another object if the object derive from SCH_TEXT
/// supports connections.
@@ -118,9 +118,9 @@ public:
int GetOrientation() { return m_schematicOrientation; }
- int GetShape() const { return m_shape; }
+ TypeSheetLabel GetShape() const { return m_shape; }
- void SetShape( int aShape ) { m_shape = aShape; }
+ void SetShape( TypeSheetLabel aShape ) { m_shape = aShape; }
/**
* Function GetSchematicTextOffset (virtual)
diff --git a/eeschema/schframe.h b/eeschema/schframe.h
index f2675c4..013ceb4 100644
--- a/eeschema/schframe.h
+++ b/eeschema/schframe.h
@@ -38,6 +38,8 @@
#include <class_sch_screen.h>
#include <sch_collectors.h>
+// enum TypeSheetLabel
+#include <sch_text.h>
class LIB_EDIT_FRAME;
class LIB_VIEW_FRAME;
@@ -168,7 +170,7 @@ private:
wxArrayString m_componentLibFiles;
*/
- static int m_lastSheetPinType; ///< Last sheet pin type.
+ static TypeSheetLabel m_lastSheetPinType; ///< Last sheet pin type.
static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size.
static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp
index 9f90792..9b4425e 100644
--- a/eeschema/sheetlab.cpp
+++ b/eeschema/sheetlab.cpp
@@ -43,7 +43,7 @@
#include <dialogs/dialog_sch_edit_sheet_pin.h>
-int SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
+TypeSheetLabel SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( -1, -1 );
wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition;
Follow ups
References
-
[PATCH 00/27] My current patch stack
From: Simon Richter, 2015-04-13
-
[PATCH 01/27] Move feature check before dependent tests
From: Simon Richter, 2015-04-13
-
[PATCH 02/27] Use Link Time Optimization with GCC in Release builds
From: Simon Richter, 2015-04-13
-
[PATCH 03/27] Make NETLIST_OBJECT::GetConnectionType() const
From: Simon Richter, 2015-04-13
-
[PATCH 04/27] Remove superfluous cast
From: Simon Richter, 2015-04-13
-
[PATCH 05/27] Separate ElectricPinType and TypeSheetLabel
From: Simon Richter, 2015-04-13
-
[PATCH 06/27] Regenerate "Edit Pin" dialog with newer wxFormBuilder
From: Simon Richter, 2015-04-13
-
[PATCH 07/27] Replace DrawPinShape enum with PinShape
From: Simon Richter, 2015-04-13
-
[PATCH 08/27] PinShapeComboBox: Introduce widget
From: Simon Richter, 2015-04-13
-
[PATCH 09/27] PinShapeComboBox: Fully initialize in c'tor
From: Simon Richter, 2015-04-13
-
[PATCH 10/27] PinShapeComboBox: typesafe Get/Set
From: Simon Richter, 2015-04-13
-
[PATCH 11/27] PinShape: move enum to own header
From: Simon Richter, 2015-04-13
-
[PATCH 12/27] PinShape: move text lookup
From: Simon Richter, 2015-04-13
-
[PATCH 13/27] PinShape: drop list interfaces
From: Simon Richter, 2015-04-13
-
[PATCH 14/27] PinShape: move bitmap lookup
From: Simon Richter, 2015-04-13
-
[PATCH 15/27] ElectricPinType: move definition to pin_type.h
From: Simon Richter, 2015-04-13
-
[PATCH 16/27] ElectricPinType: Use enum rather than int where possible
From: Simon Richter, 2015-04-13
-
[PATCH 17/27] ElectricPinType: Rename PIN_NMAX to PINTYPE_COUNT
From: Simon Richter, 2015-04-13
-
[PATCH 18/27] ElectricPinType: Separate PINTYPE_COUNT from enum
From: Simon Richter, 2015-04-13
-
[PATCH 19/27] PinTypeComboBox: Introduce widget
From: Simon Richter, 2015-04-13
-
[PATCH 20/27] PinTypeComboBox: fully initialize in c'tor
From: Simon Richter, 2015-04-13
-
[PATCH 21/27] PinTypeComboBox: typesafe Get/Set
From: Simon Richter, 2015-04-13
-
[PATCH 22/27] ElectricPinType: move text lookup
From: Simon Richter, 2015-04-13
-
[PATCH 23/27] ElectricPinType: remove list interfaces
From: Simon Richter, 2015-04-13
-
[PATCH 24/27] ElectricPinType: move bitmap lookup
From: Simon Richter, 2015-04-13