kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #23206
[PATCH 19/19] 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 dddd573..8536064 100644
--- a/eeschema/class_netlist_object.h
+++ b/eeschema/class_netlist_object.h
@@ -107,7 +107,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 2be1d87..2d8b243 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 048ffb1..52cdd5d 100644
--- a/eeschema/sch_sheet_pin.cpp
+++ b/eeschema/sch_sheet_pin.cpp
@@ -466,7 +466,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 c84852c..964409a 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 a570bfc..e80448d 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.
@@ -120,9 +120,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 23a9bb0..8d1ca8f 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;
@@ -173,7 +175,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 aeca483..a2f4faa 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;
References
-
[PATCH 00/19] Pin shape and type refactoring
From: Simon Richter, 2016-02-17
-
[PATCH 01/19] Replace DrawPinShape enum with PinShape
From: Simon Richter, 2016-02-17
-
[PATCH 02/19] PinShapeComboBox: Introduce widget
From: Simon Richter, 2016-02-17
-
[PATCH 03/19] PinShapeComboBox: Fully initialize in c'tor
From: Simon Richter, 2016-02-17
-
[PATCH 04/19] PinShapeComboBox: typesafe Get/Set
From: Simon Richter, 2016-02-17
-
[PATCH 05/19] PinShape: move enum to own header
From: Simon Richter, 2016-02-17
-
[PATCH 06/19] PinShape: move text lookup
From: Simon Richter, 2016-02-17
-
[PATCH 07/19] PinShape: drop list interfaces
From: Simon Richter, 2016-02-17
-
[PATCH 08/19] PinShape: move bitmap lookup
From: Simon Richter, 2016-02-17
-
[PATCH 09/19] ElectricPinType: move definition to pin_type.h
From: Simon Richter, 2016-02-17
-
[PATCH 10/19] ElectricPinType: Use enum rather than int where possible
From: Simon Richter, 2016-02-17
-
[PATCH 11/19] ElectricPinType: Rename PIN_NMAX to PINTYPE_COUNT
From: Simon Richter, 2016-02-17
-
[PATCH 12/19] ElectricPinType: Separate PINTYPE_COUNT from enum
From: Simon Richter, 2016-02-17
-
[PATCH 13/19] PinTypeComboBox: Introduce widget
From: Simon Richter, 2016-02-17
-
[PATCH 14/19] PinTypeComboBox: fully initialize in c'tor
From: Simon Richter, 2016-02-17
-
[PATCH 15/19] PinTypeComboBox: typesafe Get/Set
From: Simon Richter, 2016-02-17
-
[PATCH 16/19] ElectricPinType: move text lookup
From: Simon Richter, 2016-02-17
-
[PATCH 17/19] ElectricPinType: remove list interfaces
From: Simon Richter, 2016-02-17
-
[PATCH 18/19] ElectricPinType: move bitmap lookup
From: Simon Richter, 2016-02-17