KiCad PCB EDA Suite
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,
5  * Copyright (C) 1992-2011 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
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  *
20  * or you may search the 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  */
29 #ifndef _SCH_LINE_H_
30 #define _SCH_LINE_H_
33 #include <sch_item_struct.h>
42 class SCH_LINE : public SCH_ITEM
43 {
49 public:
50  SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
52  SCH_LINE( const SCH_LINE& aLine );
54  ~SCH_LINE() { }
56  SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
57  SCH_LINE* Back() const { return (SCH_LINE*) Pback; }
59  wxString GetClass() const override
60  {
61  return wxT( "SCH_LINE" );
62  }
64  bool IsEndPoint( const wxPoint& aPoint ) const
65  {
66  return aPoint == m_start || aPoint == m_end;
67  }
69  bool IsNull() const { return m_start == m_end; }
71  wxPoint GetStartPoint() const { return m_start; }
73  void SetStartPoint( const wxPoint& aPosition ) { m_start = aPosition; }
75  wxPoint GetEndPoint() const { return m_end; }
77  void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
79  const EDA_RECT GetBoundingBox() const override;
85  double GetLength() const;
87  void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
88  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
90  bool Save( FILE* aFile ) const override;
92  bool Load( LINE_READER& aLine, wxString& aErrorMsg ) override;
94  int GetPenSize() const override;
96  void Move( const wxPoint& aMoveVector ) override;
98  void MirrorX( int aXaxis_position ) override;
100  void MirrorY( int aYaxis_position ) override;
102  void Rotate( wxPoint aPosition ) override;
114  bool MergeOverlap( SCH_LINE* aLine );
116  void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
118  bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) override;
120  bool IsDangling() const override { return m_startIsDangling || m_endIsDangling; }
122  bool IsSelectStateChanged( const wxRect& aRect ) override;
124  bool IsConnectable() const override;
126  void GetConnectionPoints(std::vector< wxPoint >& aPoints ) const override;
128  wxString GetSelectMenuText() const override;
130  BITMAP_DEF GetMenuImage() const override;
132  void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
134  bool operator <( const SCH_ITEM& aItem ) const override;
136  wxPoint GetPosition() const override { return m_start; }
138  void SetPosition( const wxPoint& aPosition ) override;
140  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
142  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
144  void Plot( PLOTTER* aPlotter ) override;
146  EDA_ITEM* Clone() const override;
148 #if defined(DEBUG)
149  void Show( int nestLevel, std::ostream& os ) const override;
150 #endif
152 private:
153  bool doIsConnected( const wxPoint& aPosition ) const override;
154 };
157 #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:263
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_line.cpp:446
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:354
EDA_ITEM * Pback
previous in linked list
Definition: base_struct.h:165
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:59
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_line.cpp:409
PNG memory record (file in memory).
Definition: bitmap_types.h:38
Base schematic object class definition.
bool m_endIsDangling
True if end point is not connected.
Definition: sch_line.h:45
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_line.cpp:580
wxPoint GetEndPoint() const
Definition: sch_line.h:75
SCH_LINE * Next() const
Definition: sch_line.h:56
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_line.cpp:82
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:77
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
wxPoint GetStartPoint() const
Definition: sch_line.h:71
bool MergeOverlap(SCH_LINE *aLine)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:274
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item...
Definition: sch_line.cpp:437
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:548
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_line.cpp:249
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_line.cpp:490
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:73
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:44
bool IsDangling() const override
Definition: sch_line.h:120
Definition: sch_line.h:54
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:571
wxPoint m_end
Line end point.
Definition: sch_line.h:47
bool IsNull() const
Definition: sch_line.h:69
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_line.cpp:453
bool IsEndPoint(const wxPoint &aPoint) const
Definition: sch_line.h:64
Base plotter engine class.
Definition: plot_common.h:86
Class SCH_LINE is a segment description base class to describe items which have 2 end points (track...
Definition: sch_line.h:42
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_line.cpp:76
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:528
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_line.h:136
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:151
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_line.cpp:166
SCH_LINE * Back() const
Definition: sch_line.h:57
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_line.cpp:256
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:204
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_line.cpp:115
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:214
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_line.cpp:596
double GetLength() const
Function GetLength.
Definition: sch_line.cpp:132
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_line.cpp:138
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:46
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:164
SCH_LINE(const wxPoint &pos=wxPoint(0, 0), int layer=LAYER_NOTES)
Definition: sch_line.cpp:43
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:501
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:372