2007-08-20 01:20:48 +00:00
|
|
|
/*****************************************/
|
2010-04-23 09:54:40 +00:00
|
|
|
/* Edition du pcb: Gestion des dimensions */
|
2007-08-20 01:20:48 +00:00
|
|
|
/*****************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2010-04-22 17:47:10 +00:00
|
|
|
#include "confirm.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2010-04-22 17:47:10 +00:00
|
|
|
#include "drawtxt.h"
|
2010-11-18 21:16:28 +00:00
|
|
|
#include "dialog_helpers.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
/* Loca functions */
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Exit_EditDimension( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Montre_Position_New_Dimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
/* Local variables : */
|
|
|
|
static int status_dimension; /* Used in cimension creation:
|
2010-08-23 17:30:51 +00:00
|
|
|
* = 0 : initial value: no dimension in progress
|
|
|
|
* = 1 : First point created
|
|
|
|
* = 2 : Secont point created, the text must be placed */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*
|
2010-08-10 18:34:26 +00:00
|
|
|
* A dimension has this shape:
|
|
|
|
* It has 2 reference points, and a text
|
2010-04-22 17:47:10 +00:00
|
|
|
* | |
|
|
|
|
* | dist |
|
|
|
|
* |<---------->|
|
|
|
|
* | |
|
2008-03-04 04:22:27 +00:00
|
|
|
*
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
2010-04-22 17:47:10 +00:00
|
|
|
/* class DIMENSION_EDITOR_DIALOG */
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
class DIMENSION_EDITOR_DIALOG : public wxDialog
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* m_Parent;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxDC* m_DC;
|
2010-04-23 09:54:40 +00:00
|
|
|
DIMENSION* CurrentDimension;
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_EnterText* m_Name;
|
|
|
|
WinEDA_SizeCtrl* m_TxtSizeCtrl;
|
|
|
|
WinEDA_ValueCtrl* m_TxtWidthCtrl;
|
|
|
|
wxRadioBox* m_Mirror;
|
|
|
|
WinEDAChoiceBox* m_SelLayerBox;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Constructor and destructor
|
2011-03-01 19:26:17 +00:00
|
|
|
DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* parent, DIMENSION* Dimension, wxDC* DC );
|
2010-04-22 17:47:10 +00:00
|
|
|
~DIMENSION_EDITOR_DIALOG()
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2007-10-07 03:08:24 +00:00
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
|
|
|
void OnOkClick( wxCommandEvent& event );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
BEGIN_EVENT_TABLE( DIMENSION_EDITOR_DIALOG, wxDialog )
|
2010-08-23 17:30:51 +00:00
|
|
|
EVT_BUTTON( wxID_OK, DIMENSION_EDITOR_DIALOG::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, DIMENSION_EDITOR_DIALOG::OnCancelClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* parent,
|
2010-08-10 18:34:26 +00:00
|
|
|
DIMENSION* Dimension, wxDC* DC
|
|
|
|
) :
|
2010-08-23 17:30:51 +00:00
|
|
|
wxDialog( parent, -1, wxString( _( "Dimension properties" ) ) )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxButton* Button;
|
|
|
|
|
|
|
|
m_Parent = parent;
|
|
|
|
m_DC = DC;
|
|
|
|
Centre();
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension = Dimension;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
SetSizer( MainBoxSizer );
|
|
|
|
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
/* Creation des boutons de commande */
|
2007-10-07 03:08:24 +00:00
|
|
|
Button = new wxButton( this, wxID_OK, _( "OK" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxString display_msg[2] = { _( "Normal" ), _( "Mirror" ) };
|
|
|
|
m_Mirror = new wxRadioBox( this, -1, _( "Display" ),
|
|
|
|
wxDefaultPosition, wxSize( -1, -1 ), 2, display_msg,
|
|
|
|
1, wxRA_SPECIFY_COLS );
|
2010-04-23 09:54:40 +00:00
|
|
|
if( Dimension->m_Text->m_Mirror )
|
2011-03-03 19:08:13 +00:00
|
|
|
m_Mirror->SetSelection( 1 );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_Name = new WinEDA_EnterText( this, wxT( "Text:" ),
|
2010-08-23 17:30:51 +00:00
|
|
|
Dimension->m_Text->m_Text,
|
|
|
|
LeftBoxSizer, wxSize( 200, -1 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ),
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->m_Text->m_Size,
|
2010-07-12 14:07:09 +00:00
|
|
|
g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
m_TxtWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ),
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->m_Width,
|
2010-07-12 14:07:09 +00:00
|
|
|
g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxStaticText* text = new wxStaticText( this, -1, _( "Layer:" ) );
|
|
|
|
LeftBoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2010-04-23 09:54:40 +00:00
|
|
|
m_SelLayerBox = new WinEDAChoiceBox( this, wxID_ANY,
|
2007-08-20 01:20:48 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
for( int layer = FIRST_NO_COPPER_LAYER; layer<NB_LAYERS; layer++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
m_SelLayerBox->Append( parent->GetBoard()->GetLayerName( layer ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
m_SelLayerBox->SetSelection( Dimension->GetLayer() - FIRST_NO_COPPER_LAYER );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
2010-12-21 15:13:09 +00:00
|
|
|
void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
|
|
|
{
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
2010-04-22 17:47:10 +00:00
|
|
|
void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_DC ) // Effacement ancien texte
|
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED);
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_Name->GetValue() != wxEmptyString )
|
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension->SetText( m_Name->GetValue() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension->m_Text->m_Size = m_TxtSizeCtrl->GetValue();
|
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
int width = m_TxtWidthCtrl->GetValue();
|
2010-08-23 17:30:51 +00:00
|
|
|
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text->m_Size );
|
2010-04-22 17:47:10 +00:00
|
|
|
if( width > maxthickness )
|
|
|
|
{
|
2010-08-23 17:30:51 +00:00
|
|
|
DisplayError( NULL,
|
|
|
|
_( "The text thickness is too large for the text size. It will be clamped") );
|
2010-04-22 17:47:10 +00:00
|
|
|
width = maxthickness;
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
CurrentDimension->m_Text->m_Thickness = CurrentDimension->m_Width = width ;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2010-08-23 17:30:51 +00:00
|
|
|
CurrentDimension->m_Text->m_Mirror = ( m_Mirror->GetSelection() == 1 ) ? true : false;
|
2010-04-22 17:47:10 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension->SetLayer( m_SelLayerBox->GetChoice() + FIRST_NO_COPPER_LAYER );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension->AdjustDimensionDetails( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( m_DC ) // Affichage nouveau texte
|
|
|
|
{
|
|
|
|
/* Redessin du Texte */
|
2010-04-23 09:54:40 +00:00
|
|
|
CurrentDimension->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
m_Parent->OnModify();
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Exit_EditDimension( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
DIMENSION* Dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( Dimension )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
if( Dimension->IsNew() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Draw( Panel, DC, GR_XOR );
|
|
|
|
Dimension->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Draw( Panel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
status_dimension = 0;
|
2011-03-01 19:26:17 +00:00
|
|
|
((PCB_EDIT_FRAME*)Panel->GetParent())->SetCurItem( NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************/
|
2011-03-01 19:26:17 +00:00
|
|
|
DIMENSION* PCB_EDIT_FRAME::Begin_Dimension( DIMENSION* Dimension, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint pos;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( Dimension == NULL ) /* debut reel du trace */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
status_dimension = 1;
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = GetScreen()->GetCrossHairPosition();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension = new DIMENSION( GetBoard() );
|
|
|
|
Dimension->m_Flags = IS_NEW;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->SetLayer( getActiveLayer() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Barre_ox = Dimension->Barre_fx = pos.x;
|
|
|
|
Dimension->Barre_oy = Dimension->Barre_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->TraitD_ox = Dimension->TraitD_fx = pos.x;
|
|
|
|
Dimension->TraitD_oy = Dimension->TraitD_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->TraitG_ox = Dimension->TraitG_fx = pos.x;
|
|
|
|
Dimension->TraitG_oy = Dimension->TraitG_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->FlecheG1_ox = Dimension->FlecheG1_fx = pos.x;
|
|
|
|
Dimension->FlecheG1_oy = Dimension->FlecheG1_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->FlecheG2_ox = Dimension->FlecheG2_fx = pos.x;
|
|
|
|
Dimension->FlecheG2_oy = Dimension->FlecheG2_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->FlecheD1_ox = Dimension->FlecheD1_fx = pos.x;
|
|
|
|
Dimension->FlecheD1_oy = Dimension->FlecheD1_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->FlecheD2_ox = Dimension->FlecheD2_fx = pos.x;
|
|
|
|
Dimension->FlecheD2_oy = Dimension->FlecheD2_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->m_Text->m_Size = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize;
|
2010-04-22 17:47:10 +00:00
|
|
|
int width = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth;
|
2010-04-23 09:54:40 +00:00
|
|
|
int maxthickness = Clamp_Text_PenSize(width, Dimension->m_Text->m_Size );
|
2010-04-22 17:47:10 +00:00
|
|
|
if( width > maxthickness )
|
|
|
|
{
|
|
|
|
width = maxthickness;
|
|
|
|
}
|
2010-11-27 13:09:18 +00:00
|
|
|
Dimension->m_Text->m_Thickness = Dimension->m_Width = width ;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->AdjustDimensionDetails( );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Draw( DrawPanel, DC, GR_XOR );
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( Montre_Position_New_Dimension, Exit_EditDimension );
|
2010-04-23 09:54:40 +00:00
|
|
|
return Dimension;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
// Dimension != NULL
|
|
|
|
if( status_dimension == 1 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
status_dimension = 2;
|
|
|
|
return Dimension;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Draw( DrawPanel, DC, GR_OR );
|
|
|
|
Dimension->m_Flags = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
/* ADD this new item in list */
|
2010-04-23 09:54:40 +00:00
|
|
|
GetBoard()->Add( Dimension );
|
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
// Add store it in undo/redo list
|
2010-04-23 09:54:40 +00:00
|
|
|
SaveCopyInUndoList( Dimension, UR_NEW );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Montre_Position_New_Dimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
|
|
|
|
DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem();
|
2011-02-11 20:48:13 +00:00
|
|
|
wxPoint pos = screen->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( Dimension == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
// Erase previous dimension.
|
|
|
|
if( aErase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
Dimension->Draw( aPanel, aDC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->SetLayer( screen->m_Active_Layer );
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( status_dimension == 1 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->TraitD_ox = pos.x;
|
|
|
|
Dimension->TraitD_oy = pos.y;
|
|
|
|
Dimension->Barre_fx = Dimension->TraitD_ox;
|
|
|
|
Dimension->Barre_fy = Dimension->TraitD_oy;
|
|
|
|
Dimension->AdjustDimensionDetails( );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int deltax, deltay, dx, dy;
|
|
|
|
float angle, depl;
|
2010-04-23 09:54:40 +00:00
|
|
|
deltax = Dimension->TraitD_ox - Dimension->TraitG_ox;
|
|
|
|
deltay = Dimension->TraitD_oy - Dimension->TraitG_oy;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Calcul de la direction de deplacement
|
|
|
|
* ( perpendiculaire a l'axe de la cote ) */
|
2008-10-29 15:26:53 +00:00
|
|
|
angle = atan2( (double)deltay, (double)deltax ) + (M_PI / 2);
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
deltax = pos.x - Dimension->TraitD_ox;
|
|
|
|
deltay = pos.y - Dimension->TraitD_oy;
|
2007-08-20 01:20:48 +00:00
|
|
|
depl = ( deltax * cos( angle ) ) + ( deltay * sin( angle ) );
|
|
|
|
dx = (int) ( depl * cos( angle ) );
|
|
|
|
dy = (int) ( depl * sin( angle ) );
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Barre_ox = Dimension->TraitG_ox + dx;
|
|
|
|
Dimension->Barre_oy = Dimension->TraitG_oy + dy;
|
|
|
|
Dimension->Barre_fx = Dimension->TraitD_ox + dx;
|
|
|
|
Dimension->Barre_fy = Dimension->TraitD_oy + dy;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->AdjustDimensionDetails( );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
Dimension->Draw( aPanel, aDC, GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Install_Edit_Dimension( DIMENSION* Dimension, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
if( Dimension == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
DIMENSION_EDITOR_DIALOG* frame = new DIMENSION_EDITOR_DIALOG( this, Dimension, DC );
|
2007-10-07 03:08:24 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Delete_Dimension( DIMENSION* Dimension, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
if( Dimension == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
2010-04-23 09:54:40 +00:00
|
|
|
Dimension->Draw( DrawPanel, DC, GR_XOR );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
SaveCopyInUndoList(Dimension, UR_DELETED);
|
|
|
|
Dimension->UnLink();
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|