KiCad PCB EDA Suite
attribut.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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <class_drawpanel.h>
34 #include <gr_basic.h>
35 #include <wxPcbStruct.h>
36 #include <msgpanel.h>
37 
38 #include <pcbnew.h>
39 #include <protos.h>
40 
41 #include <class_track.h>
42 #include <class_board.h>
43 
44 
45 /* Attribute change for 1 track segment.
46  * Attributes are
47  * TRACK_LOCKED protection against global delete
48  * TRACK_AR AutoRouted segment
49  */
50 void PCB_EDIT_FRAME::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On )
51 {
52  if( track == NULL )
53  return;
54 
55  OnModify();
56  m_canvas->CrossHairOff( DC ); // Erase cursor shape
57  track->SetState( TRACK_LOCKED, Flag_On );
58  track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
59  m_canvas->CrossHairOn( DC ); // Display cursor shape
60 
61  MSG_PANEL_ITEMS items;
62  track->GetMsgPanelInfo( items );
63  SetMsgPanel( items );
64 }
65 
66 
67 /* Attribute change for an entire track */
68 void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
69 {
70  TRACK* Track;
71  int nb_segm;
72 
73  if( (track == NULL ) || (track->Type() == PCB_ZONE_T) )
74  return;
75 
76  m_canvas->CrossHairOff( DC ); // Erase cursor shape
77  Track = GetBoard()->MarkTrace( track, &nb_segm, NULL, NULL, true );
78  DrawTraces( m_canvas, DC, Track, nb_segm, GR_OR | GR_HIGHLIGHT );
79 
80  for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
81  {
82  Track->SetState( TRACK_LOCKED, Flag_On );
83  Track->SetState( BUSY, false );
84  Track = Track->Next();
85  }
86 
87  m_canvas->CrossHairOn( DC ); // Display cursor shape
88 
89  OnModify();
90 }
91 
92 
93 /* Modify the flag TRACK_LOCKED according to Flag_On value,
94  * for all the segments related to net_code.
95  * if net_code < 0 all the segments are modified.
96  */
97 void PCB_EDIT_FRAME::Attribut_net( wxDC* DC, int net_code, bool Flag_On )
98 {
99  TRACK* Track = GetBoard()->m_Track;
100 
101  /* search the first segment for the selected net_code */
102  if( net_code >= 0 )
103  {
104  for( ; Track != NULL; Track = Track->Next() )
105  {
106  if( net_code == Track->GetNetCode() )
107  break;
108  }
109  }
110 
111  m_canvas->CrossHairOff( DC ); // Erase cursor shape
112 
113  while( Track ) /* Flag change */
114  {
115  if( ( net_code >= 0 ) && ( net_code != Track->GetNetCode() ) )
116  break;
117 
118  OnModify();
119  Track->SetState( TRACK_LOCKED, Flag_On );
120  Track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
121  Track = Track->Next();
122  }
123 
124  m_canvas->CrossHairOn( DC ); // Display cursor shape
125  OnModify();
126 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:993
Class BOARD to handle a board.
BOARD * GetBoard() const
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:134
Functions relatives to tracks, vias and segments used to fill zones.
void Attribut_Track(TRACK *track, wxDC *DC, bool Flag_On)
Definition: attribut.cpp:68
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:773
#define TRACK_LOCKED
Pcbnew: track locked: protected from global deletion.
Definition: base_struct.h:128
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:109
TRACK * MarkTrace(TRACK *aTrace, int *aCount, double *aTraceLength, double *aInPackageLength, bool aReorder)
Function MarkTrace marks a chain of trace segments, connected to aTrace.
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:253
void Attribut_net(wxDC *DC, int net_code, bool Flag_On)
Definition: attribut.cpp:97
Definition: gr_basic.h:42
int GetNetCode() const
Function GetNetCode.
void Attribut_Segment(TRACK *track, wxDC *DC, bool Flag_On)
Definition: attribut.cpp:50
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:260
TRACK * Next() const
Definition: class_track.h:98
void SetState(int type, int state)
Definition: base_struct.h:242
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
DLIST< TRACK > m_Track
Definition: class_board.h:246
void DrawTraces(EDA_DRAW_PANEL *panel, wxDC *DC, TRACK *aStartTrace, int nbsegment, GR_DRAWMODE mode_color)
Function DrawTraces Draws n consecutive track segments in list.
Definition: tr_modif.cpp:49
Message panel definition file.