1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*************************************/
/* Modules de creations de Bus Entry */
/*************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "id.h"
#include "protos.h"
#include "schframe.h"
/* Routines Locales */
/* Variables locales */
static int s_LastShape = '\\';
static wxPoint ItemInitialPosition;
/**************************************************************/
static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/
/* Routine de sortie des menus de trace */
{
DrawBusEntryStruct* BusEntry =
(DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem();
if( BusEntry ) /* trace en cours */
{
RedrawOneStruct( Panel, DC, BusEntry, g_XorMode );
if( BusEntry->m_Flags & IS_NEW )
{
delete BusEntry;
Panel->GetScreen()->SetCurItem( NULL );
}
else
{
BusEntry->m_Pos = ItemInitialPosition;
RedrawOneStruct( Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE );
BusEntry->m_Flags = 0;
}
}
g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
}
/************************************************************************/
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Dessin du Segment "BusEntry" lors des deplacements du curseur
*/
{
BASE_SCREEN* screen = panel->m_Parent->GetScreen();
DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem();
if( BusEntry == NULL )
return;
/* effacement apres deplacement curseur */
if( erase )
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */
BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
}
/**********************************************************************************/
DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_type )
/**********************************************************************************/
/* Create a new bus entry, and prepare moving function (for later place it)
*/
{
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur,
s_LastShape, entry_type );
BusEntry->m_Flags = IS_NEW;
DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
DrawPanel->CursorOn( DC ); // Display schematic cursor
GetScreen()->SetModify();
StartMoveBusEntry( BusEntry, DC );
return BusEntry;
}
/**************************************************************************/
void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
wxDC* DC )
/**************************************************************************/
{
if( BusEntry == NULL )
return;
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
}
BusEntry->m_Flags |= IS_MOVED;
ItemInitialPosition = BusEntry->m_Pos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema();
GetScreen()->SetCurItem( BusEntry );
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitBusEntry;
DrawPanel->CursorOn( DC );
}
/************************************************************/
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct* BusEntry, int entry_shape )
/************************************************************/
/* set the shape of BusEntry (shape = / or \ )
*/
{
if( BusEntry == NULL )
return;
if( BusEntry->Type() != DRAW_BUSENTRY_STRUCT_TYPE )
{
DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
return;
}
/* Put old item in undo list if it is not currently in edit */
if( BusEntry->m_Flags == 0 )
SaveCopyInUndoList( BusEntry, IS_CHANGED );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
switch( entry_shape )
{
case '\\':
s_LastShape = '\\';
BusEntry->m_Size.y = 100;
break;
case '/':
s_LastShape = '/';
BusEntry->m_Size.y = -100;
break;
}
TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
GetScreen()->SetModify();
}
/************************************************************************/
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry )
/************************************************************************/
{
int entry_shape = '\\';
if( BusEntry->m_Size.y < 0 )
entry_shape = '/';
return entry_shape;
}