2007-08-20 01:20:48 +00:00
|
|
|
/*****************************************/
|
|
|
|
/* Edition du pcb: Gestion des cotations */
|
|
|
|
/*****************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Routines Locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void Montre_Position_New_Cotation( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
static void Ajuste_Details_Cotation( COTATION* pts );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Variables "locales" : */
|
2007-08-20 01:20:48 +00:00
|
|
|
static int status_cotation; /* = 0 : pas de cotation en cours
|
|
|
|
* = 1 : debut place, fin a placer
|
|
|
|
* = 2 : fin placee, texte a ajuster */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*
|
2007-08-20 01:20:48 +00:00
|
|
|
* Les routines generent une cotation de la forme
|
|
|
|
* - cote usuelle:
|
2008-03-04 04:22:27 +00:00
|
|
|
*
|
2007-08-20 01:20:48 +00:00
|
|
|
| |
|
|
|
|
| dist |
|
|
|
|
|<---------->|
|
|
|
|
| |
|
2008-03-04 04:22:27 +00:00
|
|
|
*
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_CHAR 40 /* longueur maxi de la cotation */
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Dimension des fleches */
|
|
|
|
#define FLECHE_L 500
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
enum id_Cotation_properties {
|
2007-10-07 03:08:24 +00:00
|
|
|
ID_TEXTPCB_SELECT_LAYER = 1900
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
|
|
|
/* class WinEDA_CotationPropertiesFrame */
|
|
|
|
/************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
class WinEDA_CotationPropertiesFrame : public wxDialog
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_PcbFrame* m_Parent;
|
|
|
|
wxDC* m_DC;
|
|
|
|
COTATION* CurrentCotation;
|
|
|
|
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
|
|
|
|
WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* parent,
|
|
|
|
COTATION* Cotation, wxDC* DC, const wxPoint& pos );
|
2007-09-01 12:00:30 +00:00
|
|
|
~WinEDA_CotationPropertiesFrame()
|
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
|
|
|
};
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_CotationPropertiesFrame, wxDialog )
|
2007-10-07 03:08:24 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_CotationPropertiesFrame::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_CotationPropertiesFrame::OnCancelClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* parent,
|
|
|
|
COTATION* Cotation, wxDC* DC,
|
|
|
|
const wxPoint& framepos ) :
|
2007-10-12 03:24:46 +00:00
|
|
|
wxDialog( parent, -1, _( "Dimension properties" ), framepos, wxSize( 340, 270 ),
|
2007-08-20 01:20:48 +00:00
|
|
|
DIALOG_STYLE )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxButton* Button;
|
|
|
|
|
|
|
|
m_Parent = parent;
|
|
|
|
SetFont( *g_DialogFont );
|
|
|
|
m_DC = DC;
|
|
|
|
Centre();
|
|
|
|
|
|
|
|
CurrentCotation = Cotation;
|
|
|
|
|
|
|
|
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
|
|
|
Button->SetForegroundColour( *wxRED );
|
|
|
|
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
|
|
|
Button->SetForegroundColour( *wxBLUE );
|
|
|
|
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 );
|
|
|
|
if( !Cotation->m_Text->m_Miroir )
|
|
|
|
m_Mirror->SetSelection( 1 );;
|
|
|
|
RightBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_Name = new WinEDA_EnterText( this, wxT( "Text:" ),
|
|
|
|
Cotation->m_Text->m_Text,
|
|
|
|
LeftBoxSizer, wxSize( 200, -1 ) );
|
|
|
|
|
|
|
|
m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ),
|
|
|
|
Cotation->m_Text->m_Size,
|
|
|
|
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
m_TxtWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ),
|
|
|
|
Cotation->m_Width,
|
|
|
|
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
wxStaticText* text = new wxStaticText( this, -1, _( "Layer:" ) );
|
|
|
|
LeftBoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
|
|
|
m_SelLayerBox = new WinEDAChoiceBox( this, ID_TEXTPCB_SELECT_LAYER,
|
|
|
|
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
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
m_SelLayerBox->Append( parent->m_Pcb->GetLayerName( layer ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
m_SelLayerBox->SetSelection( Cotation->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
|
|
|
/**********************************************************************/
|
2007-10-07 03:08:24 +00:00
|
|
|
void WinEDA_CotationPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
2007-10-07 03:08:24 +00:00
|
|
|
void WinEDA_CotationPropertiesFrame::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
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
CurrentCotation->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_Name->GetValue() != wxEmptyString )
|
|
|
|
{
|
|
|
|
CurrentCotation->SetText( m_Name->GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrentCotation->m_Text->m_Size = m_TxtSizeCtrl->GetValue();
|
|
|
|
CurrentCotation->m_Text->m_Width = CurrentCotation->m_Width =
|
|
|
|
m_TxtWidthCtrl->GetValue();
|
|
|
|
CurrentCotation->m_Text->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
CurrentCotation->SetLayer( m_SelLayerBox->GetChoice() + FIRST_NO_COPPER_LAYER );
|
2007-11-01 05:27:31 +00:00
|
|
|
CurrentCotation->m_Text->SetLayer( m_SelLayerBox->GetChoice() + FIRST_NO_COPPER_LAYER );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
CurrentCotation->m_Text->CreateDrawData();
|
|
|
|
|
|
|
|
if( m_DC ) // Affichage nouveau texte
|
|
|
|
{
|
|
|
|
/* Redessin du Texte */
|
2008-04-01 05:21:50 +00:00
|
|
|
CurrentCotation->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
m_Parent->GetScreen()->SetModify();
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
COTATION* Cotation = (COTATION*) Panel->GetScreen()->GetCurItem();
|
|
|
|
|
|
|
|
if( Cotation )
|
|
|
|
{
|
|
|
|
if( Cotation->m_Flags & IS_NEW )
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( Panel, DC, GR_XOR );
|
2007-10-07 03:08:24 +00:00
|
|
|
Cotation->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( Panel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
status_cotation = 0;
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2008-03-04 04:22:27 +00:00
|
|
|
((WinEDA_PcbFrame*)Panel->m_Parent)->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
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, 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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Cotation == NULL ) /* debut reel du trace */
|
|
|
|
{
|
|
|
|
status_cotation = 1;
|
2008-04-17 16:25:29 +00:00
|
|
|
pos = GetScreen()->m_Curseur;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation = new COTATION( m_Pcb );
|
|
|
|
Cotation->m_Flags = IS_NEW;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
Cotation->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->m_Width = g_DesignSettings.m_DrawSegmentWidth;
|
|
|
|
Cotation->m_Text->m_Width = Cotation->m_Width;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->Barre_ox = Cotation->Barre_fx = pos.x;
|
|
|
|
Cotation->Barre_oy = Cotation->Barre_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->TraitD_ox = Cotation->TraitD_fx = pos.x;
|
|
|
|
Cotation->TraitD_oy = Cotation->TraitD_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->TraitG_ox = Cotation->TraitG_fx = pos.x;
|
|
|
|
Cotation->TraitG_oy = Cotation->TraitG_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->FlecheG1_ox = Cotation->FlecheG1_fx = pos.x;
|
|
|
|
Cotation->FlecheG1_oy = Cotation->FlecheG1_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->FlecheG2_ox = Cotation->FlecheG2_fx = pos.x;
|
|
|
|
Cotation->FlecheG2_oy = Cotation->FlecheG2_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->FlecheD1_ox = Cotation->FlecheD1_fx = pos.x;
|
|
|
|
Cotation->FlecheD1_oy = Cotation->FlecheD1_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->FlecheD2_ox = Cotation->FlecheD2_fx = pos.x;
|
|
|
|
Cotation->FlecheD2_oy = Cotation->FlecheD2_fy = pos.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->m_Text->m_Miroir = 1;
|
|
|
|
Cotation->m_Text->m_Size = g_DesignSettings.m_PcbTextSize;
|
|
|
|
Cotation->m_Text->m_Width = g_DesignSettings.m_PcbTextWidth;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Ajuste_Details_Cotation( Cotation );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( DrawPanel, DC, GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = Montre_Position_New_Cotation;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_EditCotation;
|
|
|
|
return Cotation;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
// Cotation != NULL
|
|
|
|
if( status_cotation == 1 )
|
|
|
|
{
|
|
|
|
status_cotation = 2;
|
|
|
|
return Cotation;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( DrawPanel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
Cotation->m_Flags = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Insertion de la structure dans le Chainage .Drawings du PCB */
|
|
|
|
Cotation->Pback = m_Pcb;
|
|
|
|
Cotation->Pnext = m_Pcb->m_Drawings;
|
|
|
|
if( m_Pcb->m_Drawings )
|
|
|
|
m_Pcb->m_Drawings->Pback = Cotation;
|
|
|
|
m_Pcb->m_Drawings = Cotation;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Montre_Position_New_Cotation( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************************************/
|
|
|
|
/* redessin du contour de la piste lors des deplacements de la souris */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen();
|
|
|
|
COTATION* Cotation = (COTATION*) screen->GetCurItem();
|
|
|
|
wxPoint pos = screen->m_Curseur;
|
|
|
|
|
|
|
|
if( Cotation == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* efface ancienne position */
|
|
|
|
if( erase )
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
Cotation->SetLayer( screen->m_Active_Layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( status_cotation == 1 )
|
|
|
|
{
|
|
|
|
Cotation->TraitD_ox = pos.x;
|
|
|
|
Cotation->TraitD_oy = pos.y;
|
|
|
|
Cotation->Barre_fx = Cotation->TraitD_ox;
|
|
|
|
Cotation->Barre_fy = Cotation->TraitD_oy;
|
|
|
|
Ajuste_Details_Cotation( Cotation );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int deltax, deltay, dx, dy;
|
|
|
|
float angle, depl;
|
|
|
|
deltax = Cotation->TraitD_ox - Cotation->TraitG_ox;
|
|
|
|
deltay = Cotation->TraitD_oy - Cotation->TraitG_oy;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
deltax = pos.x - Cotation->TraitD_ox;
|
|
|
|
deltay = pos.y - Cotation->TraitD_oy;
|
|
|
|
depl = ( deltax * cos( angle ) ) + ( deltay * sin( angle ) );
|
|
|
|
dx = (int) ( depl * cos( angle ) );
|
|
|
|
dy = (int) ( depl * sin( angle ) );
|
|
|
|
Cotation->Barre_ox = Cotation->TraitG_ox + dx;
|
|
|
|
Cotation->Barre_oy = Cotation->TraitG_oy + dy;
|
|
|
|
Cotation->Barre_fx = Cotation->TraitD_ox + dx;
|
|
|
|
Cotation->Barre_fy = Cotation->TraitD_oy + dy;
|
|
|
|
|
|
|
|
Ajuste_Details_Cotation( Cotation );
|
|
|
|
}
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( panel, DC, GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Install_Edit_Cotation( COTATION* Cotation,
|
|
|
|
wxDC* DC, const wxPoint& pos )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Cotation == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_CotationPropertiesFrame* frame = new WinEDA_CotationPropertiesFrame( this,
|
|
|
|
Cotation, DC, pos );
|
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
|
|
|
/*******************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Cotation == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
2008-04-01 05:21:50 +00:00
|
|
|
Cotation->Draw( DrawPanel, DC, GR_XOR );
|
2007-10-07 03:08:24 +00:00
|
|
|
Cotation->DeleteStructure();
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Ajuste_Details_Cotation( COTATION* Cotation )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Calcule les details des coordonnees des differents segments constitutifs
|
2007-08-20 01:20:48 +00:00
|
|
|
* de la cotation
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
int mesure, deltax, deltay; /* valeur de la mesure sur les axes X et Y */
|
|
|
|
int fleche_up_X = 0, fleche_up_Y = 0; /* coord des fleches : barre / */
|
|
|
|
int fleche_dw_X = 0, fleche_dw_Y = 0; /* coord des fleches : barre \ */
|
|
|
|
int hx, hy; /* coord des traits de rappel de cote */
|
|
|
|
float angle, angle_f;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
/* Init des couches : */
|
2007-08-23 04:28:46 +00:00
|
|
|
Cotation->m_Text->SetLayer( Cotation->GetLayer() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* calcul de la hauteur du texte + trait de cotation */
|
|
|
|
ii = Cotation->m_Text->m_Size.y +
|
|
|
|
Cotation->m_Text->m_Width + (Cotation->m_Width * 3);
|
|
|
|
|
|
|
|
deltax = Cotation->TraitD_ox - Cotation->TraitG_ox;
|
|
|
|
deltay = Cotation->TraitD_oy - Cotation->TraitG_oy;
|
|
|
|
|
|
|
|
/* Calcul de la cote */
|
2008-10-29 15:26:53 +00:00
|
|
|
mesure = (int) (hypot( (double) deltax, (double) deltay ) + 0.5 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( deltax || deltay )
|
2008-10-29 15:26:53 +00:00
|
|
|
angle = atan2( (double) deltay, (double) deltax );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
angle = 0.0;
|
|
|
|
|
|
|
|
/* Calcul des parametre dimensions X et Y des fleches et traits de cotes */
|
|
|
|
hx = hy = ii;
|
|
|
|
|
|
|
|
/* On tient compte de l'inclinaison de la cote */
|
|
|
|
if( mesure )
|
|
|
|
{
|
|
|
|
hx = (abs) ( (int) ( ( (float) deltay * hx ) / mesure ) );
|
|
|
|
hy = (abs) ( (int) ( ( (float) deltax * hy ) / mesure ) );
|
|
|
|
|
|
|
|
if( Cotation->TraitG_ox > Cotation->Barre_ox )
|
|
|
|
hx = -hx;
|
|
|
|
if( Cotation->TraitG_ox == Cotation->Barre_ox )
|
|
|
|
hx = 0;
|
|
|
|
if( Cotation->TraitG_oy > Cotation->Barre_oy )
|
|
|
|
hy = -hy;
|
|
|
|
if( Cotation->TraitG_oy == Cotation->Barre_oy )
|
|
|
|
hy = 0;
|
|
|
|
|
|
|
|
angle_f = angle + (M_PI * 27.5 / 180);
|
|
|
|
fleche_up_X = (int) ( FLECHE_L * cos( angle_f ) );
|
|
|
|
fleche_up_Y = (int) ( FLECHE_L * sin( angle_f ) );
|
|
|
|
angle_f = angle - (M_PI * 27.5 / 180);
|
|
|
|
fleche_dw_X = (int) ( FLECHE_L * cos( angle_f ) );
|
|
|
|
fleche_dw_Y = (int) ( FLECHE_L * sin( angle_f ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cotation->FlecheG1_ox = Cotation->Barre_ox;
|
|
|
|
Cotation->FlecheG1_oy = Cotation->Barre_oy;
|
|
|
|
Cotation->FlecheG1_fx = Cotation->Barre_ox + fleche_up_X;
|
|
|
|
Cotation->FlecheG1_fy = Cotation->Barre_oy + fleche_up_Y;
|
|
|
|
|
|
|
|
Cotation->FlecheG2_ox = Cotation->Barre_ox;
|
|
|
|
Cotation->FlecheG2_oy = Cotation->Barre_oy;
|
|
|
|
Cotation->FlecheG2_fx = Cotation->Barre_ox + fleche_dw_X;
|
|
|
|
Cotation->FlecheG2_fy = Cotation->Barre_oy + fleche_dw_Y;
|
|
|
|
|
|
|
|
/*la fleche de droite est symetrique a celle de gauche:
|
|
|
|
* / = -\ et \ = -/
|
|
|
|
*/
|
|
|
|
Cotation->FlecheD1_ox = Cotation->Barre_fx;
|
|
|
|
Cotation->FlecheD1_oy = Cotation->Barre_fy;
|
|
|
|
Cotation->FlecheD1_fx = Cotation->Barre_fx - fleche_dw_X;
|
|
|
|
Cotation->FlecheD1_fy = Cotation->Barre_fy - fleche_dw_Y;
|
|
|
|
|
|
|
|
Cotation->FlecheD2_ox = Cotation->Barre_fx;
|
|
|
|
Cotation->FlecheD2_oy = Cotation->Barre_fy;
|
|
|
|
Cotation->FlecheD2_fx = Cotation->Barre_fx - fleche_up_X;
|
|
|
|
Cotation->FlecheD2_fy = Cotation->Barre_fy - fleche_up_Y;
|
|
|
|
|
|
|
|
|
|
|
|
Cotation->TraitG_fx = Cotation->Barre_ox + hx;
|
|
|
|
Cotation->TraitG_fy = Cotation->Barre_oy + hy;
|
|
|
|
|
|
|
|
Cotation->TraitD_fx = Cotation->Barre_fx + hx;
|
|
|
|
Cotation->TraitD_fy = Cotation->Barre_fy + hy;
|
|
|
|
|
|
|
|
/* Calcul de la position du centre du texte et son orientation: */
|
|
|
|
Cotation->m_Pos.x = Cotation->m_Text->m_Pos.x
|
|
|
|
= (Cotation->Barre_fx + Cotation->TraitG_fx) / 2;
|
|
|
|
Cotation->m_Pos.y = Cotation->m_Text->m_Pos.y
|
|
|
|
= (Cotation->Barre_fy + Cotation->TraitG_fy) / 2;
|
|
|
|
|
|
|
|
Cotation->m_Text->m_Orient = -(int) (angle * 1800 / M_PI);
|
|
|
|
if( Cotation->m_Text->m_Orient < 0 )
|
|
|
|
Cotation->m_Text->m_Orient += 3600;
|
|
|
|
if( Cotation->m_Text->m_Orient >= 3600 )
|
|
|
|
Cotation->m_Text->m_Orient -= 3600;
|
|
|
|
if( (Cotation->m_Text->m_Orient > 900) && (Cotation->m_Text->m_Orient <2700) )
|
|
|
|
Cotation->m_Text->m_Orient -= 1800;
|
|
|
|
|
|
|
|
Cotation->m_Value = mesure;
|
|
|
|
valeur_param( Cotation->m_Value, msg );
|
|
|
|
Cotation->SetText( msg );
|
|
|
|
Cotation->m_Text->CreateDrawData();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|