KiCad PCB EDA Suite
sch_line.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #ifndef _SCH_LINE_H_
30 #define _SCH_LINE_H_
31 
32 
33 #include <sch_item_struct.h>
34 
36 
41 class SCH_LINE : public SCH_ITEM
42 {
47  int m_size;
48  int m_style;
50 
51 public:
52 
53  static const enum wxPenStyle PenStyle[];
54 
55  SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
56 
57  SCH_LINE( const SCH_LINE& aLine );
58 
59  ~SCH_LINE() { }
60 
61  SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
62  SCH_LINE* Back() const { return (SCH_LINE*) Pback; }
63 
64  wxString GetClass() const override
65  {
66  return wxT( "SCH_LINE" );
67  }
68 
69  bool IsEndPoint( const wxPoint& aPoint ) const
70  {
71  return aPoint == m_start || aPoint == m_end;
72  }
73 
74  bool IsNull() const { return m_start == m_end; }
75 
76  wxPoint GetStartPoint() const { return m_start; }
77 
78  void SetStartPoint( const wxPoint& aPosition ) { m_start = aPosition; }
79 
80  wxPoint GetEndPoint() const { return m_end; }
81 
82  void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
83 
84  int GetDefaultStyle() const;
85 
86  void SetLineStyle( const int aStyle );
87 
88  int GetLineStyle() const;
89 
92  static const char* GetLineStyleName( int aStyle );
93 
96  static int GetLineStyleInternalId( const wxString& aStyleName );
97 
98  void SetLineColor( const COLOR4D aColor );
99 
100  void SetLineColor( const double r, const double g, const double b, const double a );
101 
102  COLOR4D GetLineColor() const;
103 
104  COLOR4D GetDefaultColor() const;
105 
106  int GetDefaultWidth() const;
107 
108  void SetLineWidth( const int aSize );
109 
110  int GetLineSize() const { return m_size; }
111 
112  const EDA_RECT GetBoundingBox() const override;
113 
118  double GetLength() const;
119 
120  void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
121  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
122 
123  int GetPenSize() const override;
124 
125  void Move( const wxPoint& aMoveVector ) override;
126 
127  void MirrorX( int aXaxis_position ) override;
128 
129  void MirrorY( int aYaxis_position ) override;
130 
131  void Rotate( wxPoint aPosition ) override;
132 
143  EDA_ITEM* MergeOverlap( SCH_LINE* aLine );
144 
153  bool IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition );
154 
155  bool IsParallel( SCH_LINE* aLine );
156 
157  void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
158 
159  bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) override;
160 
161  bool IsDangling() const override { return m_startIsDangling || m_endIsDangling; }
162 
163  bool IsSelectStateChanged( const wxRect& aRect ) override;
164 
165  bool IsConnectable() const override;
166 
167  void GetConnectionPoints(std::vector< wxPoint >& aPoints ) const override;
168 
169  wxString GetSelectMenuText() const override;
170 
171  BITMAP_DEF GetMenuImage() const override;
172 
173  void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
174 
175  bool operator <( const SCH_ITEM& aItem ) const override;
176 
177  wxPoint GetPosition() const override { return m_start; }
178 
179  void SetPosition( const wxPoint& aPosition ) override;
180 
181  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
182 
183  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
184 
185  void Plot( PLOTTER* aPlotter ) override;
186 
187  wxPoint MidPoint();
188 
189  EDA_ITEM* Clone() const override;
190 
191  void SwapData( SCH_ITEM* aItem ) override;
192 
193 #if defined(DEBUG)
194  void Show( int nestLevel, std::ostream& os ) const override;
195 #endif
196 
197 private:
198  bool doIsConnected( const wxPoint& aPosition ) const override;
199 };
200 
201 
202 #endif // _SCH_LINE_H_
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_line.cpp:355
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:582
int m_style
Line style.
Definition: sch_line.h:48
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points...
Definition: sch_line.cpp:487
EDA_ITEM * Pback
previous in linked list
Definition: base_struct.h:192
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:64
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_line.cpp:545
PNG memory record (file in memory).
Definition: bitmap_types.h:38
Base schematic object class definition.
COLOR4D GetLineColor() const
Definition: sch_line.cpp:241
bool m_endIsDangling
True if end point is not connected.
Definition: sch_line.h:44
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:285
bool IsParallel(SCH_LINE *aLine)
Definition: sch_line.cpp:386
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_line.cpp:732
wxPoint GetEndPoint() const
Definition: sch_line.h:80
SCH_LINE * Next() const
Definition: sch_line.h:61
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_line.cpp:155
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:82
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
wxPoint GetStartPoint() const
Definition: sch_line.h:76
void SetLineColor(const COLOR4D aColor)
Definition: sch_line.cpp:217
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item...
Definition: sch_line.cpp:573
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:211
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_line.cpp:684
void SetLineStyle(const int aStyle)
Definition: sch_line.cpp:258
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:341
COLOR4D m_color
Line color.
Definition: sch_line.h:49
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_line.cpp:626
wxPoint MidPoint()
Definition: sch_line.cpp:757
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:78
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:43
bool IsDangling() const override
Definition: sch_line.h:161
~SCH_LINE()
Definition: sch_line.h:59
Class SCH_SHEET_PATH.
static int GetLineStyleInternalId(const wxString &aStyleName)
Definition: sch_line.cpp:138
bool doIsConnected(const wxPoint &aPosition) const override
Function doIsConnected provides the object specific test to see if it is connected to aPosition...
Definition: sch_line.cpp:723
int GetLineStyle() const
Definition: sch_line.cpp:267
wxPoint m_end
Line end point.
Definition: sch_line.h:46
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_line.cpp:707
bool IsNull() const
Definition: sch_line.h:74
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_line.cpp:589
bool IsSameQuadrant(SCH_LINE *aLine, const wxPoint &aPosition)
Check if two lines are in the same quadrant as each other, using a reference point as the origin...
Definition: sch_line.cpp:362
int m_size
Line pensize.
Definition: sch_line.h:47
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:69
int GetDefaultWidth() const
Definition: sch_line.cpp:276
Base plotter engine class.
Definition: class_plotter.h:96
EDA_ITEM * MergeOverlap(SCH_LINE *aLine)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:399
int GetLineSize() const
Definition: sch_line.h:110
static enum wxPenStyle PenStyle[]
Definition: sch_line.h:53
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_line.cpp:100
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:664
static const char * GetLineStyleName(int aStyle)
Definition: sch_line.cpp:110
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_line.h:177
Class EDA_RECT handles the component boundary box.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
SCH_LINE * Back() const
Definition: sch_line.h:62
int GetDefaultStyle() const
Definition: sch_line.cpp:249
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_line.cpp:348
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:294
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_line.cpp:188
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_line.cpp:306
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_line.cpp:750
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:205
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
wxPoint m_start
Line start point.
Definition: sch_line.h:45
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:191
SCH_LINE(const wxPoint &pos=wxPoint(0, 0), int layer=LAYER_NOTES)
Definition: sch_line.cpp:61
void GetNetListItem(NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
Function GetNetListItem creates a new NETLIST_OBJECT for the schematic object and adds it to aNetList...
Definition: sch_line.cpp:637
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool IsDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_line.cpp:505