2007-05-06 16:03:28 +00:00
|
|
|
/*************************************/
|
|
|
|
/* 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"
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
|
|
/* Variables locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static int s_LastShape = '\\';
|
2007-05-06 16:03:28 +00:00
|
|
|
static wxPoint ItemInitialPosition;
|
|
|
|
|
|
|
|
/**************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************/
|
|
|
|
/* Routine de sortie des menus de trace */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
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;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Dessin du Segment "BusEntry" lors des deplacements du curseur
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
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 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_type )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Create a new bus entry, and prepare moving function (for later place it)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur,
|
|
|
|
s_LastShape, entry_type );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
BusEntry->m_Flags = IS_NEW;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
|
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
StartMoveBusEntry( BusEntry, DC );
|
|
|
|
return BusEntry;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
|
|
|
|
wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
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 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
|
|
|
|
DrawBusEntryStruct* BusEntry, int entry_shape )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* set the shape of BusEntry (shape = / or \ )
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( BusEntry == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( BusEntry->m_StructType != 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();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int entry_shape = '\\';
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( BusEntry->m_Size.y < 0 )
|
|
|
|
entry_shape = '/';
|
|
|
|
return entry_shape;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|