KiCad PCB EDA Suite
busentry.cpp
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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <gr_basic.h>
33 #include <sch_draw_panel.h>
34 #include <sch_edit_frame.h>
35 
36 #include <sch_bus_entry.h>
37 
38 
39 static int s_LastShape = '\\';
40 
41 
43 {
44  // Create and place a new bus entry at cursor position
46 
47  busEntry->SetFlags( IS_NEW );
48  GetScreen()->SetCurItem( busEntry );
50  return busEntry;
51 }
52 
54 {
55  // Create and place a new bus entry at cursor position
57 
58  busEntry->SetFlags( IS_NEW );
59  GetScreen()->SetCurItem( busEntry );
61  return busEntry;
62 }
63 
64 /* set the shape of BusEntry (shape = / or \ )
65  */
66 void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape )
67 {
68  if( BusEntry == NULL )
69  return;
70 
71  /* Put old item in undo list if it is not currently in edit */
72  if( BusEntry->GetFlags() == 0 )
73  SaveCopyInUndoList( BusEntry, UR_CHANGED );
74 
75  s_LastShape = entry_shape == '/' ? '/' : '\\';
76 
77  BusEntry->SetBusEntryShape( s_LastShape );
79 
80  OnModify( );
81 }
Class for a bus to bus entry.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
#define IS_NEW
New item, just created.
Definition: base_struct.h:111
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
SCH_BUS_BUS_ENTRY * CreateBusBusEntry()
Definition: busentry.cpp:42
void SetBusEntryShape(wxDC *DC, SCH_BUS_ENTRY_BASE *BusEntry, char entry_shape)
Definition: busentry.cpp:66
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void addCurrentItemToScreen(bool aRedraw=true)
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void SetBusEntryShape(char aShape)
function SetBusEntryShape
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:910
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
static int s_LastShape
Definition: busentry.cpp:39
Class for a wire to bus entry.
SCH_BUS_WIRE_ENTRY * CreateBusWireEntry()
Definition: busentry.cpp:53
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...