2007-08-24 15:10:46 +00:00
|
|
|
/*********************************************************************/
|
2009-09-04 18:57:37 +00:00
|
|
|
/* EESchema - symbdraw.cpp */
|
2007-08-24 15:10:46 +00:00
|
|
|
/* Create, move .. graphic shapes used to build and draw a component */
|
2009-09-04 18:57:37 +00:00
|
|
|
/* (lines, arcs .. */
|
2007-08-24 15:10:46 +00:00
|
|
|
/*********************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
#include "protos.h"
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
/* Routines locales */
|
2007-08-24 15:10:46 +00:00
|
|
|
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre );
|
2008-12-08 15:27:13 +00:00
|
|
|
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
2007-08-24 15:10:46 +00:00
|
|
|
static void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Variables locales */
|
2007-08-24 15:10:46 +00:00
|
|
|
static int StateDrawArc, ArcStartX, ArcStartY, ArcEndX, ArcEndY;
|
2007-05-06 16:03:28 +00:00
|
|
|
static wxPoint InitPosition, StartCursor, ItemPreviousPos;
|
2008-09-09 16:56:47 +00:00
|
|
|
static FILL_T FlSymbol_Fill = NO_FILL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
/************************************/
|
|
|
|
/* class WinEDA_PartPropertiesFrame */
|
|
|
|
/************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "dialog_cmp_graphic_properties.cpp"
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2009-06-18 13:30:52 +00:00
|
|
|
void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Update the current draw item
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE;
|
|
|
|
g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE;
|
2008-09-09 16:56:47 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
if( m_Filled )
|
2008-09-09 16:56:47 +00:00
|
|
|
FlSymbol_Fill = (FILL_T) m_Filled->GetSelection();
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
g_LibSymbolDefaultLineWidth = m_GraphicShapeWidthCtrl->GetValue();
|
|
|
|
|
|
|
|
if( CurrentDrawItem )
|
|
|
|
{
|
|
|
|
if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
|
|
|
|
m_Parent->SaveCopyInUndoList( CurrentLibEntry );
|
|
|
|
wxClientDC dc( m_Parent->DrawPanel );
|
|
|
|
|
|
|
|
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1,
|
|
|
|
g_XorMode, NULL, DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
if( g_FlDrawSpecificUnit )
|
|
|
|
CurrentDrawItem->m_Unit = CurrentUnit;
|
|
|
|
else
|
|
|
|
CurrentDrawItem->m_Unit = 0;
|
|
|
|
if( g_FlDrawSpecificConvert )
|
|
|
|
CurrentDrawItem->m_Convert = CurrentConvert;
|
|
|
|
else
|
|
|
|
CurrentDrawItem->m_Convert = 0;
|
|
|
|
if( m_Filled )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( CurrentDrawItem->Type() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
2008-12-08 15:27:13 +00:00
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Width =
|
|
|
|
m_GraphicShapeWidthCtrl->GetValue();
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
2008-12-08 15:27:13 +00:00
|
|
|
( (LibDrawCircle*) CurrentDrawItem )->m_Width =
|
|
|
|
m_GraphicShapeWidthCtrl->GetValue();
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
2008-12-08 15:27:13 +00:00
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_Width =
|
|
|
|
m_GraphicShapeWidthCtrl->GetValue();
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
2008-12-08 15:27:13 +00:00
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill =
|
|
|
|
FlSymbol_Fill;
|
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->m_Width =
|
|
|
|
m_GraphicShapeWidthCtrl->
|
|
|
|
GetValue();
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CurrentLibEntry->SortDrawItems();
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
m_Parent->GetScreen()->SetModify();
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ),
|
|
|
|
-1, g_XorMode, NULL, DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Close();
|
|
|
|
|
|
|
|
if( CurrentDrawItem )
|
2009-04-05 20:49:15 +00:00
|
|
|
CurrentDrawItem->DisplayInfo( m_Parent );
|
2008-12-20 13:12:57 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC,
|
|
|
|
LibEDA_BaseStruct* DrawItem )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Install the dialog box for editing a graphical item properties
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
if( DrawItem == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_bodygraphics_PropertiesFrame* frame =
|
|
|
|
new WinEDA_bodygraphics_PropertiesFrame( this );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
frame->ShowModal(); frame->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************/
|
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
StateDrawArc = 0;
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( CurrentDrawItem->m_Flags & IS_NEW )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
Panel->m_Parent->RedrawActiveWindow( DC, TRUE );
|
|
|
|
}
|
|
|
|
else
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
|
|
|
CurrentDrawItem->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
|
|
|
NULL, DefaultTransformMatrix );
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
SAFE_DELETE( CurrentDrawItem );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxPoint curpos;
|
|
|
|
curpos = Panel->GetScreen()->m_Curseur;
|
|
|
|
Panel->GetScreen()->m_Curseur = StartCursor;
|
|
|
|
RedrawWhileMovingCursor( Panel, DC, TRUE );
|
|
|
|
Panel->GetScreen()->m_Curseur = curpos;
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( Panel, DC, wxPoint( 0, 0 ), -1,
|
|
|
|
GR_DEFAULT_DRAWMODE, NULL,
|
|
|
|
DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
CurrentDrawItem->m_Flags = 0;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
/*******************************************************************************************/
|
|
|
|
LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( EDA_LibComponentStruct* LibEntry,
|
|
|
|
wxDC* DC )
|
|
|
|
/*******************************************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Routine de creation d'un nouvel element type LibraryDrawStruct
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
int DrawType;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
|
|
|
|
// Creation du nouvel element
|
|
|
|
switch( m_ID_current_state )
|
|
|
|
{
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
|
|
|
DrawType = COMPONENT_POLYLINE_DRAW_TYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
|
|
|
DrawType = COMPONENT_ARC_DRAW_TYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
|
|
|
DrawType = COMPONENT_CIRCLE_DRAW_TYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
|
|
|
DrawType = COMPONENT_RECT_DRAW_TYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
|
|
|
DrawType = COMPONENT_GRAPHIC_TEXT_DRAW_TYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-06-18 13:30:52 +00:00
|
|
|
DisplayError( this, wxT( "WinEDA_LibeditFrame::CreateGraphicItem() error" ) );
|
2007-08-24 15:10:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = SymbolDisplayDraw;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn;
|
|
|
|
|
|
|
|
switch( DrawType )
|
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawArc* Arc = new LibDrawArc( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
CurrentDrawItem = Arc;
|
2008-04-17 16:25:29 +00:00
|
|
|
ArcStartX = ArcEndX = GetScreen()->m_Curseur.x;
|
|
|
|
ArcStartY = ArcEndY = -( GetScreen()->m_Curseur.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
StateDrawArc = 1;
|
|
|
|
Arc->m_Fill = FlSymbol_Fill;
|
|
|
|
Arc->m_Width = g_LibSymbolDefaultLineWidth;
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawCircle* Circle = new LibDrawCircle( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
CurrentDrawItem = Circle;
|
2009-06-18 13:30:52 +00:00
|
|
|
Circle->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
NEGATE( Circle->m_Pos.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
Circle->m_Fill = FlSymbol_Fill;
|
|
|
|
Circle->m_Width = g_LibSymbolDefaultLineWidth;
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawSquare* Square = new LibDrawSquare( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
CurrentDrawItem = Square;
|
2009-06-18 13:30:52 +00:00
|
|
|
Square->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
NEGATE( Square->m_Pos.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
Square->m_End = Square->m_Pos;
|
|
|
|
Square->m_Fill = FlSymbol_Fill;
|
|
|
|
Square->m_Width = g_LibSymbolDefaultLineWidth;
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawPolyline* polyline = new LibDrawPolyline( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
CurrentDrawItem = polyline;
|
2009-06-18 13:30:52 +00:00
|
|
|
wxPoint point = GetScreen()->m_Curseur;
|
2009-01-02 13:19:34 +00:00
|
|
|
NEGATE( point.y );
|
|
|
|
polyline->AddPoint( point ); // Start point of the current segment
|
|
|
|
polyline->AddPoint( point ); // End point of the current segment
|
2007-08-24 15:10:46 +00:00
|
|
|
polyline->m_Fill = FlSymbol_Fill;
|
|
|
|
polyline->m_Width = g_LibSymbolDefaultLineWidth;
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawSegment* Segment = new LibDrawSegment( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
CurrentDrawItem = Segment;
|
|
|
|
Segment->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
NEGATE( Segment->m_Pos.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
Segment->m_End = Segment->m_Pos;
|
|
|
|
Segment->m_Width = g_LibSymbolDefaultLineWidth;
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawText* Text = new LibDrawText( LibEntry );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
CurrentDrawItem = Text;
|
|
|
|
Text->m_Size.x = Text->m_Size.y = g_LastTextSize;
|
2008-12-28 18:00:37 +00:00
|
|
|
Text->m_Orient = g_LastTextOrient;
|
2009-06-18 13:30:52 +00:00
|
|
|
Text->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
NEGATE( Text->m_Pos.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
EditSymbolText( NULL, Text );
|
|
|
|
if( Text->m_Text.IsEmpty() )
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
SAFE_DELETE( Text );
|
2007-08-24 15:10:46 +00:00
|
|
|
CurrentDrawItem = NULL;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StartMoveDrawSymbol( DC );
|
2009-09-04 18:57:37 +00:00
|
|
|
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
|
|
|
|
DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( CurrentDrawItem )
|
|
|
|
{
|
|
|
|
CurrentDrawItem->m_Flags |= IS_NEW;
|
|
|
|
if( g_FlDrawSpecificUnit )
|
|
|
|
CurrentDrawItem->m_Unit = CurrentUnit;
|
|
|
|
if( g_FlDrawSpecificConvert )
|
|
|
|
CurrentDrawItem->m_Convert = CurrentConvert;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
|
|
|
|
return CurrentDrawItem;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Routine de creation d'un nouvel element type LibraryDrawStruct
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
return;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( CurrentDrawItem->Type() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
if( StateDrawArc == 1 )
|
|
|
|
{
|
|
|
|
SymbolDisplayDraw( DrawPanel, DC, FALSE );
|
|
|
|
StateDrawArc = 2;
|
|
|
|
SymbolDisplayDraw( DrawPanel, DC, FALSE );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( StateDrawArc > 1 )
|
|
|
|
{
|
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
return;
|
|
|
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
wxPoint pos = GetScreen()->m_Curseur;
|
2009-06-18 13:30:52 +00:00
|
|
|
NEGATE( pos.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->AddPoint( pos );
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Redraw the graphoc shape while moving
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
BASE_SCREEN* Screen = panel->GetScreen();
|
2008-12-08 15:27:13 +00:00
|
|
|
wxPoint pos;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
/* Erase shape in the old positon*/
|
|
|
|
if( erase )
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
pos = ItemPreviousPos - StartCursor;
|
|
|
|
CurrentDrawItem->Draw( panel, DC, pos, -1, g_XorMode, NULL,
|
|
|
|
DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Redraw moved shape */
|
2009-09-04 18:57:37 +00:00
|
|
|
pos = Screen->m_Curseur - StartCursor;
|
|
|
|
CurrentDrawItem->Draw( panel, DC, pos, -1, g_XorMode, NULL,
|
|
|
|
DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
ItemPreviousPos = Screen->m_Curseur;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************/
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
NEGATE( newpos.y );
|
2009-01-02 13:19:34 +00:00
|
|
|
wxPoint size;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawItem->Type() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
{
|
2009-01-02 13:19:34 +00:00
|
|
|
wxPoint offset = newpos - ( (LibDrawArc*) CurrentDrawItem )->m_Pos;
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Pos = newpos;
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_ArcStart += offset;
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_ArcEnd += offset;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
2009-01-02 13:19:34 +00:00
|
|
|
( (LibDrawCircle*) CurrentDrawItem )->m_Pos = newpos;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
2009-06-18 13:30:52 +00:00
|
|
|
size = ( (LibDrawSquare*) CurrentDrawItem )->m_End -
|
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_Pos;
|
2009-01-02 13:19:34 +00:00
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_Pos = newpos;
|
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_End = newpos + size;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->GetCornerCount();
|
2009-01-02 13:19:34 +00:00
|
|
|
wxPoint offset = newpos - ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[0];
|
2009-06-18 13:30:52 +00:00
|
|
|
for( ii = 0; ii < imax; ii++ )
|
2009-01-02 13:19:34 +00:00
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[ii] += offset;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
2009-01-02 13:19:34 +00:00
|
|
|
( (LibDrawText*) CurrentDrawItem )->m_Pos = newpos;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************/
|
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
SetCursor( wxCURSOR_HAND );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
CurrentDrawItem->m_Flags |= IS_MOVED;
|
2008-04-17 16:25:29 +00:00
|
|
|
StartCursor = GetScreen()->m_Curseur;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( CurrentDrawItem->Type() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
InitPosition = ( (LibDrawArc*) CurrentDrawItem )->m_Pos;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
InitPosition = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
InitPosition = ( (LibDrawSquare*) CurrentDrawItem )->m_Pos;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
2009-01-02 13:19:34 +00:00
|
|
|
InitPosition = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[0];
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
|
|
|
InitPosition = ( (LibDrawText*) CurrentDrawItem )->m_Pos;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
ItemPreviousPos = GetScreen()->m_Curseur;
|
2007-08-24 15:10:46 +00:00
|
|
|
DrawPanel->ManageCurseur = RedrawWhileMovingCursor;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
/* Routine de Gestion des evenements souris lors de la creation */
|
2009-09-04 18:57:37 +00:00
|
|
|
/* d'un nouvel element type LibraryDrawStruct */
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int DrawMode = g_XorMode;
|
|
|
|
int dx, dy;
|
2009-06-18 13:30:52 +00:00
|
|
|
BASE_SCREEN* Screen = panel->GetScreen();
|
|
|
|
wxPoint curr_pos = Screen->m_Curseur;
|
2009-01-02 13:19:34 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
NEGATE( curr_pos.y );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
|
|
|
if( erase )
|
|
|
|
{
|
|
|
|
if( StateDrawArc == 1 )
|
|
|
|
{
|
|
|
|
int Color = ReturnLayerColor( LAYER_DEVICE );
|
2008-12-08 15:27:13 +00:00
|
|
|
GRLine( &panel->m_ClipBox,
|
|
|
|
DC,
|
|
|
|
ArcStartX,
|
|
|
|
-ArcStartY,
|
|
|
|
ArcEndX,
|
|
|
|
-ArcEndY,
|
|
|
|
0,
|
|
|
|
Color );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode,
|
|
|
|
NULL, DefaultTransformMatrix );
|
2007-09-01 12:00:30 +00:00
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
int Color = ReturnLayerColor( LAYER_DEVICE );
|
|
|
|
GRDashedLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY,
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x,
|
|
|
|
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y,
|
|
|
|
0, Color );
|
|
|
|
GRDashedLine( &panel->m_ClipBox, DC, ArcEndX, -ArcEndY,
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x,
|
|
|
|
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y,
|
|
|
|
0, Color );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( CurrentDrawItem->Type() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
if( StateDrawArc == 1 )
|
|
|
|
{
|
2009-01-02 13:19:34 +00:00
|
|
|
ArcEndX = curr_pos.x; ArcEndY = curr_pos.y;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( StateDrawArc == 2 )
|
|
|
|
{
|
|
|
|
ComputeArc( (LibDrawArc*) CurrentDrawItem, Screen->m_Curseur );
|
|
|
|
}
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
2009-01-02 13:19:34 +00:00
|
|
|
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - curr_pos.x;
|
|
|
|
dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y - curr_pos.y;
|
2008-12-08 15:27:13 +00:00
|
|
|
( (LibDrawCircle*) CurrentDrawItem )->m_Rayon =
|
|
|
|
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
|
|
|
|
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
2009-06-18 13:30:52 +00:00
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_End = curr_pos;
|
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
2009-01-02 13:19:34 +00:00
|
|
|
{
|
|
|
|
unsigned idx = ( (LibDrawPolyline*) CurrentDrawItem )->GetCornerCount() - 1;
|
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[idx] = curr_pos;
|
2007-08-24 15:10:46 +00:00
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
2009-01-02 13:19:34 +00:00
|
|
|
}
|
2009-06-18 13:30:52 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
2009-01-02 13:19:34 +00:00
|
|
|
( (LibDrawSegment*) CurrentDrawItem )->m_End = curr_pos;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( StateDrawArc == 1 )
|
|
|
|
{
|
|
|
|
int Color = ReturnLayerColor( LAYER_DEVICE );
|
2008-12-08 15:27:13 +00:00
|
|
|
GRLine( &panel->m_ClipBox,
|
|
|
|
DC,
|
|
|
|
ArcStartX,
|
|
|
|
-ArcStartY,
|
|
|
|
ArcEndX,
|
|
|
|
-ArcEndY,
|
|
|
|
0,
|
|
|
|
Color );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode,
|
|
|
|
NULL, DefaultTransformMatrix );
|
2007-09-01 12:00:30 +00:00
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
int Color = ReturnLayerColor( LAYER_DEVICE );
|
|
|
|
GRDashedLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY,
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x,
|
|
|
|
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y,
|
|
|
|
0, Color );
|
|
|
|
GRDashedLine( &panel->m_ClipBox, DC, ArcEndX, -ArcEndY,
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x,
|
|
|
|
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y,
|
|
|
|
0, Color );
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Place la structure courante en liste des structures du composant
|
2007-08-24 15:10:46 +00:00
|
|
|
* courant, si elle existe et redessine toujours celle ci
|
|
|
|
* Parametres: (tous globaux)
|
|
|
|
* CurrentDrawItem
|
|
|
|
* CurrentLibEntry
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
return;
|
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
return;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
if( StateDrawArc == 1 ) /* Trace d'arc en cours: doit etre termine */
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "Arc in progress.." ), 10 ); return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (CurrentDrawItem->m_Flags & IS_MOVED) == 0 )
|
|
|
|
SymbolDisplayDraw( DrawPanel, DC, FALSE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StateDrawArc = 0;
|
|
|
|
|
|
|
|
if( CurrentDrawItem->m_Flags & IS_NEW )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( CurrentLibEntry );
|
2008-11-24 06:53:43 +00:00
|
|
|
CurrentDrawItem->SetNext( CurrentLibEntry->m_Drawings );
|
2007-08-24 15:10:46 +00:00
|
|
|
CurrentLibEntry->m_Drawings = CurrentDrawItem;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( CurrentDrawItem->Type() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
|
|
|
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
|
|
|
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_PIN_DRAW_TYPE:
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrentLibEntry->SortDrawItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_ID_current_state )
|
|
|
|
SetCursor( wxCURSOR_PENCIL );
|
|
|
|
else
|
|
|
|
SetCursor( wxCURSOR_ARROW );
|
|
|
|
|
|
|
|
if( (CurrentDrawItem->m_Flags & IS_MOVED) )
|
|
|
|
{
|
|
|
|
wxPoint pos;
|
|
|
|
pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x,
|
|
|
|
pos.y = GetScreen()->m_Curseur.y - InitPosition.y - StartCursor.y;
|
|
|
|
MoveLibDrawItemAt( CurrentDrawItem, pos );
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentLibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), CurrentUnit,
|
|
|
|
CurrentConvert, GR_DEFAULT_DRAWMODE );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
CurrentDrawItem->m_Flags = 0;
|
|
|
|
CurrentDrawItem = NULL;
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***************************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* routine d'ajustage des parametres de l'arc en cours de trace
|
2007-08-24 15:10:46 +00:00
|
|
|
* calcule le centre, rayon, angles pour que l'arc en cours
|
|
|
|
* passe par les points ArcStartX,Y et ArcEndX,Y avec le centre le plus proche
|
|
|
|
* de la pos souris
|
|
|
|
* Remarque: le centre n'est evidemment pas sur la grille
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-24 15:10:46 +00:00
|
|
|
int dx, dy;
|
|
|
|
int cX, cY; /* Coord centre de l'arc */
|
|
|
|
int angle;
|
|
|
|
|
|
|
|
cX = ArcCentre.x; cY = ArcCentre.y;
|
|
|
|
|
|
|
|
cY = -cY; /* Attention a l'orientation de l'axe Y */
|
|
|
|
|
|
|
|
/* calcul de cX et cY pour que l'arc passe par ArcStartX,Y et ArcEndX,Y */
|
|
|
|
dx = ArcEndX - ArcStartX; dy = ArcEndY - ArcStartY;
|
|
|
|
cX -= ArcStartX; cY -= ArcStartY;
|
2008-12-08 15:27:13 +00:00
|
|
|
angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
|
|
|
|
RotatePoint( &dx, &dy, angle ); /* Le segment dx, dy est horizontal */
|
|
|
|
/* -> dx = longueur, dy = 0 */
|
2007-08-24 15:10:46 +00:00
|
|
|
RotatePoint( &cX, &cY, angle );
|
2008-12-08 15:27:13 +00:00
|
|
|
cX = dx / 2; /* cX, cY est sur la mediane du segment 0,0 a dx,0 */
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
RotatePoint( &cX, &cY, -angle );
|
|
|
|
cX += ArcStartX; cY += ArcStartY;
|
|
|
|
|
|
|
|
DrawItem->m_Pos.x = cX; DrawItem->m_Pos.y = cY;
|
|
|
|
|
|
|
|
dx = ArcStartX - DrawItem->m_Pos.x;
|
|
|
|
dy = ArcStartY - DrawItem->m_Pos.y;
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawItem->m_Rayon = (int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawItem->t1 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
dx = ArcEndX - DrawItem->m_Pos.x;
|
|
|
|
dy = ArcEndY - DrawItem->m_Pos.y;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawItem->t2 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
DrawItem->m_ArcStart.x = ArcStartX;
|
|
|
|
DrawItem->m_ArcStart.y = ArcStartY;
|
|
|
|
DrawItem->m_ArcEnd.x = ArcEndX;
|
|
|
|
DrawItem->m_ArcEnd.y = ArcEndY;
|
|
|
|
|
|
|
|
NORMALIZE_ANGLE( DrawItem->t1 );
|
|
|
|
NORMALIZE_ANGLE( DrawItem->t2 ); // angles = 0 .. 3600
|
|
|
|
|
|
|
|
// limitation val abs a < 1800 (1/2 cercle) pour eviter Pbs d'affichage en miroir
|
|
|
|
// car en trace on suppose que l'arc fait moins de 180 deg pour trouver
|
|
|
|
// son orientation apres rot, miroir...
|
|
|
|
if( (DrawItem->t2 - DrawItem->t1) > 1800 )
|
|
|
|
DrawItem->t2 -= 3600;
|
|
|
|
else if( (DrawItem->t2 - DrawItem->t1) <= -1800 )
|
|
|
|
DrawItem->t2 += 3600;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
angle = DrawItem->t2 - DrawItem->t1;
|
|
|
|
msg.Printf( _( "Arc %.1f deg" ), (float) angle / 10 );
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_SchematicFrame* frame =
|
|
|
|
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
|
|
|
frame->m_LibeditFrame->PrintMsg( msg );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
while( (DrawItem->t2 - DrawItem->t1) >= 1800 )
|
|
|
|
{
|
|
|
|
DrawItem->t2--;
|
|
|
|
DrawItem->t1++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( (DrawItem->t1 - DrawItem->t2) >= 1800 )
|
|
|
|
{
|
|
|
|
DrawItem->t2++;
|
|
|
|
DrawItem->t1--;
|
|
|
|
}
|
|
|
|
|
|
|
|
NORMALIZE_ANGLE( DrawItem->t1 );
|
|
|
|
NORMALIZE_ANGLE( DrawItem->t2 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************/
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Used for deleting last entered segment while creating a Polyline
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
if( CurrentDrawItem == NULL
|
|
|
|
|| CurrentDrawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
|
2007-08-24 15:10:46 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem;
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
|
|
|
NULL, DefaultTransformMatrix );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
while( Poly->GetCornerCount() > 2 ) // First segment is kept, only its end point is changed
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-01-02 13:19:34 +00:00
|
|
|
Poly->m_PolyPoints.pop_back();
|
2009-06-18 13:30:52 +00:00
|
|
|
unsigned idx = Poly->GetCornerCount() - 1;
|
|
|
|
wxPoint point = GetScreen()->m_Curseur;
|
2009-01-02 13:19:34 +00:00
|
|
|
NEGATE( point.y );
|
|
|
|
if( Poly->m_PolyPoints[idx] != point )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-01-02 13:19:34 +00:00
|
|
|
Poly->m_PolyPoints[idx] = point;
|
2007-08-24 15:10:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentDrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
|
|
|
NULL, DefaultTransformMatrix );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|