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 <class_drawpanel.h>
34 #include <schframe.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->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
78  BusEntry->SetBusEntryShape( s_LastShape );
80  BusEntry->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
81 
82  OnModify( );
83 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
Class SCH_BUS_WIRE_ENTRY.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:269
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))
Function SaveCopyInUndoList.
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:769
void addCurrentItemToList(bool aRedraw=true)
Function addCurrentItemToList adds the item currently being edited to the schematic and adds the chan...
Definition: schframe.cpp:1290
Class SCH_BUS_ENTRY_BASE.
Definition: sch_bus_entry.h:43
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:528
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:267
void SetBusEntryShape(char aShape)
function SetBusEntryShape
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
bool TestDanglingEnds()
Function TestDanglingEnds tests all of the connectible objects in the schematic for unused connection...
Definition: sch_screen.cpp:915
void SetCurItem(SCH_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
static int s_LastShape
Definition: busentry.cpp:39
Class SCH_BUS_WIRE_ENTRY.
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.
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...