Commit 683921f9 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix crash in intermediate netlist generation when a component has no...

Eeschema: fix crash in intermediate netlist generation when a component has no pins (like logos or images).
Pcbnew: texts in dimensions can be now moved.
Gerbview: fix incorrect number of layers  in export to pcbnew function.
parent cc097762
......@@ -328,8 +328,16 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
{
// Temporary change the help filename
wxString tmp = wxGetApp().m_HelpFileName;
// Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf"
wxGetApp().m_HelpFileName = wxT( "getting_started_in_kicad.pdf" );
wxString helpFile = wxGetApp().GetHelpFile();
if( !helpFile )
{ // Try to find "Getting_Started_in_KiCad.pdf"
wxGetApp().m_HelpFileName = wxT( "Getting_Started_in_KiCad.pdf" );
wxString helpFile = wxGetApp().GetHelpFile();
}
if( !helpFile )
{
......
......@@ -787,7 +787,7 @@ XNODE* EXPORT_HELP::makeGenericLibParts()
* Common pins (VCC, GND) can also be found more than once.
*/
sort( pinList.begin(), pinList.end(), sortPinsByNumber );
for( unsigned ii = 0; ii < pinList.size()-1; ii++ )
for( int ii = 0; ii < (int)pinList.size()-1; ii++ )
{
if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() )
{ // 2 pins have the same number, remove the redundant pin at index i+1
......
......@@ -66,19 +66,17 @@ GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER()
*/
void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
{
int ii = 0;
bool no_used_layers = true; // Changed to false if any used layer found
int layercount = 0;
// Check whether any of the Gerber layers are actually currently used
while( no_used_layers && ii < 32 )
// Count the Gerber layers which are actually currently used
for( int ii = 0; ii < 32; ii++ )
{
if( g_GERBER_List[ii] != NULL )
no_used_layers = false;
layercount++;
ii++;
}
if( no_used_layers )
if( layercount == 0 )
{
DisplayInfoMessage( this,
_( "None of the Gerber layers contain any data" ) );
......@@ -233,6 +231,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
}
cleanBoard();
m_pcb->SetCopperLayerCount( LayerLookUpTable[32] );
// Switch the locale to standard C (needed to print floating point numbers)
SetLocaleTo_C_standard();
......@@ -297,7 +296,7 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aL
break;
case GBR_ARC:
// export_segarc_copper_item( aGbrItem, aLayer );
export_segarc_copper_item( aGbrItem, aLayer );
break;
default:
......@@ -325,6 +324,7 @@ void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem
void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
#if 0 // TODO: does not work in all cases, so needs some work
double a = atan2( (double)( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
(double)( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
double b = atan2( (double)( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
......@@ -374,6 +374,7 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem,
NEGATE( newtrack->m_End.y );
m_pcb->Add( newtrack );
}
#endif
}
......
......@@ -94,7 +94,7 @@ void LAYERS_MAP_DIALOG::initDialog()
// Ensure we have:
// at least 2 copper layers and NB_COPPER_LAYERS copper layers max
// an even layers count because board *must* have even layers count
// and even layers count because a board *must* have even layers count
// and maxi NB_COPPER_LAYERS copper layers count
normalizeBrdLayersCount();
......@@ -279,7 +279,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
}
/* Stores the current mayers selection in config
/* Stores the current layers selection in config
*/
void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
{
......
......@@ -1253,6 +1253,9 @@ public:
void ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* aDC );
DIMENSION* EditDimension( DIMENSION* aDimension, wxDC* aDC );
void DeleteDimension( DIMENSION* aDimension, wxDC* aDC );
void BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC );
void PlaceDimensionText( DIMENSION* aItem, wxDC* DC );
// netlist handling:
void InstallNetlistFrame( wxDC* DC );
......
......@@ -21,6 +21,7 @@ set(PCBNEW_DIALOGS
dialogs/dialog_copper_zones_base.cpp
dialogs/dialog_design_rules.cpp
dialogs/dialog_design_rules_base.cpp
dialogs/dialog_dimension_editor_base.cpp
dialogs/dialog_display_options.cpp
dialogs/dialog_display_options_base.cpp
dialogs/dialog_drc_base.cpp
......
......@@ -235,6 +235,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
( (DIMENSION*) aImage )->SetText( txt );
EXCHG( ( (DIMENSION*) aItem )->m_Width, ( (DIMENSION*) aImage )->m_Width );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Size, ( (DIMENSION*) aImage )->m_Text->m_Size );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Pos, ( (DIMENSION*) aImage )->m_Text->m_Pos );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Thickness,
( (DIMENSION*) aImage )->m_Text->m_Thickness );
EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Mirror,
......
/**
* @file clean.cpp
* functions to clean tracks: remove null and redundant segments
* @brief functions to clean tracks: remove null lenght and redundant segments
*/
#include "fctsys.h"
#include "class_drawpanel.h"
//#include "gr_basic.h"
#include "pcbcommon.h"
#include "wxPcbStruct.h"
#include "pcbnew.h"
//#include "protos.h"
#include "class_board.h"
#include "class_track.h"
typedef long long int64;
/* local functions : */
static void clean_segments( PCB_EDIT_FRAME* frame );
static void clean_segments( PCB_EDIT_FRAME* aFrame );
static void clean_vias( BOARD* aPcb );
static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame );
static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* aFrame );
static TRACK* MergeColinearSegmentIfPossible( BOARD* aPcb, TRACK* aTrackRef, TRACK* aCandidate, int aEndType );
static void CleanupTracks( PCB_EDIT_FRAME* frame,
static void CleanupTracks( PCB_EDIT_FRAME* aFrame,
bool aCleanVias, bool aMergeSegments,
bool aDeleteUnconnectedSegm, bool aConnectToPads );
......@@ -56,32 +50,31 @@ void PCB_EDIT_FRAME::Clean_Pcb( wxDC* DC )
* Delete
* - Redundant points on tracks (merge aligned segments)
* - vias on pad
* - null segments
* - Redundant segments
* - null lenght segments
* Create segments when track ends are incorrectly connected:
* i.e. when a track end covers a pad or a via but is not exactly on the pad or the via center
*/
void CleanupTracks( PCB_EDIT_FRAME* frame,
void CleanupTracks( PCB_EDIT_FRAME* aFrame,
bool aCleanVias, bool aMergeSegments,
bool aDeleteUnconnectedSegm, bool aConnectToPads )
{
wxBusyCursor( dummy );
frame->MsgPanel->EraseMsgBox();
frame->GetBoard()->GetNumSegmTrack(); // update the count
aFrame->MsgPanel->EraseMsgBox();
aFrame->GetBoard()->GetNumSegmTrack(); // update the count
// Clear undo and redo lists to avoid inconsistencies between lists
frame->GetScreen()->ClearUndoRedoList();
frame->SetCurItem( NULL );
aFrame->GetScreen()->ClearUndoRedoList();
aFrame->SetCurItem( NULL );
/* Rebuild the pad infos (pad list and netcodes) to ensure an up to date info */
frame->GetBoard()->m_Status_Pcb = 0;
frame->GetBoard()->m_NetInfo->BuildListOfNets();
aFrame->GetBoard()->m_Status_Pcb = 0;
aFrame->GetBoard()->m_NetInfo->BuildListOfNets();
if( aCleanVias ) // delete redundant vias
{
frame->SetStatusText( _( "Clean vias" ) );
clean_vias( frame->GetBoard() );
aFrame->SetStatusText( _( "Clean vias" ) );
clean_vias( aFrame->GetBoard() );
}
#ifdef CONN2PAD_ENBL
......@@ -89,35 +82,35 @@ void CleanupTracks( PCB_EDIT_FRAME* frame,
* but is not on the pad or the via center */
if( aConnectToPads )
{
frame->SetStatusText( _( "Reconnect pads" ) );
aFrame->SetStatusText( _( "Reconnect pads" ) );
/* Create missing segments when a track end covers a pad, but is not on the pad center */
ConnectDanglingEndToPad( frame );
ConnectDanglingEndToPad( aFrame );
/* Create missing segments when a track end covers a via, but is not on the via center */
ConnectDanglingEndToVia( frame->GetBoard() );
ConnectDanglingEndToVia( aFrame->GetBoard() );
}
#endif
/* Remove null segments and intermediate points on aligned segments */
if( aMergeSegments )
{
frame->SetStatusText( _( "Merge track segments" ) );
clean_segments( frame );
aFrame->SetStatusText( _( "Merge track segments" ) );
clean_segments( aFrame );
}
/* Delete dangling tracks */
if( aDeleteUnconnectedSegm )
{
frame->SetStatusText( _( "Delete unconnected tracks" ) );
DeleteUnconnectedTracks( frame );
aFrame->SetStatusText( _( "Delete unconnected tracks" ) );
DeleteUnconnectedTracks( aFrame );
}
frame->SetStatusText( _( "Cleanup finished" ) );
aFrame->SetStatusText( _( "Cleanup finished" ) );
frame->Compile_Ratsnest( NULL, true );
aFrame->Compile_Ratsnest( NULL, true );
frame->OnModify();
aFrame->OnModify();
}
......@@ -175,7 +168,7 @@ void clean_vias( BOARD * aPcb )
* Vias:
* If a via is only connected to a dangling track, it also will be removed
*/
static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* aFrame )
{
TRACK* segment;
TRACK* other;
......@@ -185,13 +178,13 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
int masklayer, oldnetcode;
int type_end, flag_erase;
if( frame->GetBoard()->m_Track == NULL )
if( aFrame->GetBoard()->m_Track == NULL )
return;
frame->DrawPanel->m_AbortRequest = false;
aFrame->DrawPanel->m_AbortRequest = false;
// correct via m_End defects
for( segment = frame->GetBoard()->m_Track; segment; segment = next )
for( segment = aFrame->GetBoard()->m_Track; segment; segment = next )
{
next = segment->Next();
......@@ -205,14 +198,14 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
}
// removal of unconnected tracks
segment = startNetcode = frame->GetBoard()->m_Track;
segment = startNetcode = aFrame->GetBoard()->m_Track;
oldnetcode = segment->GetNet();
for( int ii = 0; segment ; segment = next, ii++ )
{
next = segment->Next();
if( frame->DrawPanel->m_AbortRequest )
if( aFrame->DrawPanel->m_AbortRequest )
break;
if( segment->GetNet() != oldnetcode )
......@@ -230,7 +223,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
D_PAD* pad;
pad = frame->GetBoard()->GetPadFast( segment->m_Start, masklayer );
pad = aFrame->GetBoard()->GetPadFast( segment->m_Start, masklayer );
if( pad != NULL )
{
......@@ -238,7 +231,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
type_end |= START_ON_PAD;
}
pad = frame->GetBoard()->GetPadFast( segment->m_End, masklayer );
pad = aFrame->GetBoard()->GetPadFast( segment->m_End, masklayer );
if( pad != NULL )
{
......@@ -253,19 +246,19 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
if( (type_end & START_ON_PAD ) == 0 )
{
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, START );
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START );
if( other == NULL ) // Test a connection to zones
{
if( segment->Type() != PCB_VIA_T )
{
zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_Start,
zone = aFrame->GetBoard()->HitTestForAnyFilledArea( segment->m_Start,
segment->GetLayer() );
}
else
{
((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer );
zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_Start,
zone = aFrame->GetBoard()->HitTestForAnyFilledArea( segment->m_Start,
top_layer, bottom_layer );
}
}
......@@ -287,12 +280,12 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
segment->SetState( BUSY, ON );
SEGVIA* via = (SEGVIA*) other;
other = via->GetTrace( frame->GetBoard()->m_Track, NULL, START );
other = via->GetTrace( aFrame->GetBoard()->m_Track, NULL, START );
if( other == NULL )
{
via->ReturnLayerPair( &top_layer, &bottom_layer );
zone = frame->GetBoard()->HitTestForAnyFilledArea( via->m_Start,
zone = aFrame->GetBoard()->HitTestForAnyFilledArea( via->m_Start,
bottom_layer,
top_layer );
}
......@@ -308,19 +301,19 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
// if not connected to a pad, test if segment's END is connected to another track
if( (type_end & END_ON_PAD ) == 0 )
{
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, END );
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END );
if( other == NULL ) // Test a connection to zones
{
if( segment->Type() != PCB_VIA_T )
{
zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_End,
zone = aFrame->GetBoard()->HitTestForAnyFilledArea( segment->m_End,
segment->GetLayer() );
}
else
{
((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer );
zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_End,
zone = aFrame->GetBoard()->HitTestForAnyFilledArea( segment->m_End,
top_layer, bottom_layer );
}
}
......@@ -343,12 +336,12 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
segment->SetState( BUSY, ON );
SEGVIA* via = (SEGVIA*) other;
other = via->GetTrace( frame->GetBoard()->m_Track, NULL, END );
other = via->GetTrace( aFrame->GetBoard()->m_Track, NULL, END );
if( other == NULL )
{
via->ReturnLayerPair( &top_layer, &bottom_layer );
zone = frame->GetBoard()->HitTestForAnyFilledArea( via->m_End,
zone = aFrame->GetBoard()->HitTestForAnyFilledArea( via->m_End,
bottom_layer,
top_layer );
}
......@@ -385,7 +378,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame )
/* Delete null length segments, and intermediate points .. */
static void clean_segments( PCB_EDIT_FRAME* frame )
static void clean_segments( PCB_EDIT_FRAME* aFrame )
{
TRACK* segment, * nextsegment;
TRACK* other;
......@@ -393,10 +386,10 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
int flag, no_inc;
wxString msg;
frame->DrawPanel->m_AbortRequest = false;
aFrame->DrawPanel->m_AbortRequest = false;
// Delete null segments
for( segment = frame->GetBoard()->m_Track; segment; segment = nextsegment )
for( segment = aFrame->GetBoard()->m_Track; segment; segment = nextsegment )
{
nextsegment = segment->Next();
......@@ -408,7 +401,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
}
/* Delete redundant segments */
for( segment = frame->GetBoard()->m_Track, ii = 0; segment; segment = segment->Next(), ii++ )
for( segment = aFrame->GetBoard()->m_Track, ii = 0; segment; segment = segment->Next(), ii++ )
{
for( other = segment->Next(); other; other = nextsegment )
{
......@@ -448,7 +441,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
/* delete intermediate points */
ii = 0;
for( segment = frame->GetBoard()->m_Track; segment; segment = nextsegment )
for( segment = aFrame->GetBoard()->m_Track; segment; segment = nextsegment )
{
TRACK* segStart;
TRACK* segEnd;
......@@ -456,7 +449,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
nextsegment = segment->Next();
if( frame->DrawPanel->m_AbortRequest )
if( aFrame->DrawPanel->m_AbortRequest )
return;
if( segment->Type() != PCB_TRACE_T )
......@@ -481,7 +474,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
/* We must have only one segment connected */
segStart->SetState( BUSY, ON );
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, START );
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START );
segStart->SetState( BUSY, OFF );
if( other == NULL )
......@@ -494,7 +487,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
if( flag ) // We have the starting point of the segment is connected to an other segment
{
segDelete = MergeColinearSegmentIfPossible( frame->GetBoard(), segment, segStart, START );
segDelete = MergeColinearSegmentIfPossible( aFrame->GetBoard(), segment, segStart, START );
if( segDelete )
{
......@@ -518,7 +511,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
/* We must have only one segment connected */
segEnd->SetState( BUSY, ON );
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, END );
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END );
segEnd->SetState( BUSY, OFF );
if( other == NULL )
......@@ -534,7 +527,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
if( flag & 2 ) // We have the ending point of the segment is connected to an other segment
{
segDelete = MergeColinearSegmentIfPossible( frame->GetBoard(), segment, segEnd, END );
segDelete = MergeColinearSegmentIfPossible( aFrame->GetBoard(), segment, segEnd, END );
if( segDelete )
{
......@@ -608,11 +601,12 @@ TRACK* MergeColinearSegmentIfPossible( BOARD* aPcb,
}
/* test if alignment in other cases
* We must have refdy/refdx == (+/-)segmdy/segmdx, (i.e. same orientation) */
* We must have refdy/refdx == segmdy/segmdx, (i.e. same slope)
* or refdy * segmdx == segmdy * refdx
*/
if( is_colinear == false )
{
if( ( (int64)refdy * segmdx != (int64)refdx * segmdy )
&& ( (int64)refdy * segmdx != -(int64)refdx * segmdy ) )
if( ( double)refdy * segmdx != (double)refdx * segmdy )
return NULL;
is_colinear = true;
......@@ -830,33 +824,33 @@ static void ConnectDanglingEndToVia( BOARD* pcb )
* connected into the center of the pad. This allows faster control of
* connections.
*/
void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame )
void ConnectDanglingEndToPad( PCB_EDIT_FRAME* aFrame )
{
TRACK* segment;
int nb_new_trace = 0;
wxString msg;
frame->DrawPanel->m_AbortRequest = false;
aFrame->DrawPanel->m_AbortRequest = false;
for( segment = frame->GetBoard()->m_Track; segment; segment = segment->Next() )
for( segment = aFrame->GetBoard()->m_Track; segment; segment = segment->Next() )
{
D_PAD* pad;
if( frame->DrawPanel->m_AbortRequest )
if( aFrame->DrawPanel->m_AbortRequest )
return;
pad = frame->GetBoard()->GetPad( segment, START );
pad = aFrame->GetBoard()->GetPad( segment, START );
if( pad )
{
// test if the track start point is not exactly starting on the pad
if( segment->m_Start != pad->m_Pos )
{
if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, START ) == NULL )
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START ) == NULL )
{
TRACK* newTrack = segment->Copy();
frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
aFrame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
newTrack->m_End = pad->m_Pos;
newTrack->start = segment;
......@@ -867,18 +861,18 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame )
}
}
pad = frame->GetBoard()->GetPad( segment, END );
pad = aFrame->GetBoard()->GetPad( segment, END );
if( pad )
{
// test if the track end point is not exactly on the pad
if( segment->m_End != pad->m_Pos )
{
if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, END ) == NULL )
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END ) == NULL )
{
TRACK* newTrack = segment->Copy();
frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
aFrame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
newTrack->m_Start = pad->m_Pos;
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_dimension_editor_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_staticTextDim = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDim->Wrap( -1 );
bSizerMain->Add( m_staticTextDim, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Name = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_Name->SetMinSize( wxSize( 400,-1 ) );
bSizerMain->Add( m_Name, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
m_staticTextSizeX = new wxStaticText( this, wxID_ANY, _("Size X"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeX->Wrap( -1 );
bSizerLeft->Add( m_staticTextSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtSizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_TxtSizeXCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Size Y"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeY->Wrap( -1 );
bSizerLeft->Add( m_staticTextSizeY, 0, wxRIGHT|wxLEFT, 5 );
m_TxtSizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_TxtSizeYCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Width"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextWidth->Wrap( -1 );
bSizerLeft->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_TxtWidthCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosX = new wxStaticText( this, wxID_ANY, _("Text position X"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosX->Wrap( -1 );
bSizerLeft->Add( m_staticTextPosX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlPosX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_textCtrlPosX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosY = new wxStaticText( this, wxID_ANY, _("Text position Y"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosY->Wrap( -1 );
bSizerLeft->Add( m_staticTextPosY, 0, wxRIGHT|wxLEFT, 5 );
m_textCtrlPosY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_textCtrlPosY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerUpper->Add( bSizerLeft, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
wxString m_rbMirrorChoices[] = { _("Normal"), _("Mirror") };
int m_rbMirrorNChoices = sizeof( m_rbMirrorChoices ) / sizeof( wxString );
m_rbMirror = new wxRadioBox( this, wxID_ANY, _("Display"), wxDefaultPosition, wxDefaultSize, m_rbMirrorNChoices, m_rbMirrorChoices, 1, wxRA_SPECIFY_COLS );
m_rbMirror->SetSelection( 0 );
bSizerRight->Add( m_rbMirror, 0, wxALL|wxEXPAND, 5 );
m_staticTextLayer = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextLayer->Wrap( -1 );
bSizerRight->Add( m_staticTextLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SelLayerBox = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bSizerRight->Add( m_SelLayerBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerUpper->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizerBts = new wxStdDialogButtonSizer();
m_sdbSizerBtsOK = new wxButton( this, wxID_OK );
m_sdbSizerBts->AddButton( m_sdbSizerBtsOK );
m_sdbSizerBtsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerBts->AddButton( m_sdbSizerBtsCancel );
m_sdbSizerBts->Realize();
bSizerMain->Add( m_sdbSizerBts, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_sdbSizerBtsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerBtsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
}
DIALOG_DIMENSION_EDITOR_BASE::~DIALOG_DIMENSION_EDITOR_BASE()
{
// Disconnect Events
m_sdbSizerBtsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerBtsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_DIMENSION_EDITOR_BASE_H__
#define __DIALOG_DIMENSION_EDITOR_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/radiobox.h>
#include <wx/combobox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_DIMENSION_EDITOR_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_DIMENSION_EDITOR_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticTextDim;
wxTextCtrl* m_Name;
wxStaticText* m_staticTextSizeX;
wxTextCtrl* m_TxtSizeXCtrl;
wxStaticText* m_staticTextSizeY;
wxTextCtrl* m_TxtSizeYCtrl;
wxStaticText* m_staticTextWidth;
wxTextCtrl* m_TxtWidthCtrl;
wxStaticText* m_staticTextPosX;
wxTextCtrl* m_textCtrlPosX;
wxStaticText* m_staticTextPosY;
wxTextCtrl* m_textCtrlPosY;
wxRadioBox* m_rbMirror;
wxStaticText* m_staticTextLayer;
wxComboBox* m_SelLayerBox;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerBts;
wxButton* m_sdbSizerBtsOK;
wxButton* m_sdbSizerBtsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Dimension Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 378,328 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_DIMENSION_EDITOR_BASE();
};
#endif //__DIALOG_DIMENSION_EDITOR_BASE_H__
......@@ -10,17 +10,23 @@
#include "wxPcbStruct.h"
#include "drawtxt.h"
#include "dialog_helpers.h"
#include "macros.h"
#include "class_board.h"
#include "class_pcb_text.h"
#include "class_dimension.h"
#include "pcbnew.h"
#include "dialog_dimension_editor_base.h"
/* Local functions */
static void MoveDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
static void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
/* Local variables : */
static int status_dimension; /* Used in dimension creation:
......@@ -40,105 +46,70 @@ static int status_dimension; /* Used in dimension creation:
/*********************************/
/* class DIMENSION_EDITOR_DIALOG */
/* class DIALOG_DIMENSION_EDITOR */
/*********************************/
class DIMENSION_EDITOR_DIALOG : public wxDialog
class DIALOG_DIMENSION_EDITOR : public DIALOG_DIMENSION_EDITOR_BASE
{
private:
PCB_EDIT_FRAME* m_Parent;
wxDC* m_DC;
DIMENSION* CurrentDimension;
wxTextCtrl* m_Name;
EDA_SIZE_CTRL* m_TxtSizeCtrl;
EDA_VALUE_CTRL* m_TxtWidthCtrl;
wxRadioBox* m_Mirror;
wxComboBox* m_SelLayerBox;
public:
// Constructor and destructor
DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* aParent, DIMENSION* aDimension, wxDC* aDC );
~DIMENSION_EDITOR_DIALOG()
DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, DIMENSION* aDimension, wxDC* aDC );
~DIALOG_DIMENSION_EDITOR()
{
}
private:
void OnCancelClick( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
void OnOKClick( wxCommandEvent& event );
};
BEGIN_EVENT_TABLE( DIMENSION_EDITOR_DIALOG, wxDialog )
EVT_BUTTON( wxID_OK, DIMENSION_EDITOR_DIALOG::OnOkClick )
EVT_BUTTON( wxID_CANCEL, DIMENSION_EDITOR_DIALOG::OnCancelClick )
END_EVENT_TABLE()
DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* aParent,
DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
DIMENSION* aDimension, wxDC* aDC ) :
wxDialog( aParent, -1, wxString( _( "Dimension Properties" ) ) )
DIALOG_DIMENSION_EDITOR_BASE( aParent )
{
SetFocus();
wxButton* Button;
m_Parent = aParent;
m_DC = aDC;
CurrentDimension = aDimension;
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 );
/* Create command buttons. */
Button = new wxButton( this, wxID_OK, _( "OK" ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
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( aDimension->m_Text->m_Mirror )
m_Mirror->SetSelection( 1 );
RightBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 );
LeftBoxSizer->Add( new wxStaticText( this, -1, _( "Text:" ) ),
0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_Name = new wxTextCtrl( this, -1, aDimension->m_Text->m_Text,
wxDefaultPosition, wxSize( 200, -1 ) );
m_Name->SetInsertionPoint( 1 );
LeftBoxSizer->Add( m_Name,
0,
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
m_TxtSizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), aDimension->m_Text->m_Size,
g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits );
m_TxtWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ), aDimension->m_Width,
g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits );
wxStaticText* text = new wxStaticText( this, -1, _( "Layer:" ) );
LeftBoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_SelLayerBox = new wxComboBox( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY );
LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_rbMirror->SetSelection( 1 );
else
m_rbMirror->SetSelection( 0 );
m_Name->SetValue( aDimension->m_Text->m_Text );
// Enter size value in dialog
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->m_Text->m_Size.x,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextSizeX );
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->m_Text->m_Size.y,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextSizeY );
// Enter lines thickness value in dialog
PutValueInLocalUnits( *m_TxtWidthCtrl, aDimension->m_Width,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextWidth );
// Enter position value in dialog
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->m_Text->m_Pos.x,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextPosX );
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->m_Text->m_Pos.y,
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_staticTextPosY );
for( int layer = FIRST_NO_COPPER_LAYER; layer<NB_LAYERS; layer++ )
{
......@@ -153,13 +124,13 @@ DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* aParent,
}
void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& event )
void DIALOG_DIMENSION_EDITOR::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event )
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
if( m_DC ) // Delete old text.
{
......@@ -173,9 +144,29 @@ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event )
CurrentDimension->SetText( m_Name->GetValue() );
}
CurrentDimension->m_Text->m_Size = m_TxtSizeCtrl->GetValue();
int width = m_TxtWidthCtrl->GetValue();
wxString msg;
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->m_Text->m_Size.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->m_Text->m_Size.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
CurrentDimension->m_Text->m_Pos.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_textCtrlPosY->GetValue();
CurrentDimension->m_Text->m_Pos.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text->m_Size );
if( width > maxthickness )
......@@ -187,12 +178,10 @@ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event )
CurrentDimension->m_Text->m_Thickness = CurrentDimension->m_Width = width ;
CurrentDimension->m_Text->m_Mirror = ( m_Mirror->GetSelection() == 1 ) ? true : false;
CurrentDimension->m_Text->m_Mirror = ( m_rbMirror->GetSelection() == 1 ) ? true : false;
CurrentDimension->SetLayer( m_SelLayerBox->GetCurrentSelection() + FIRST_NO_COPPER_LAYER );
CurrentDimension->AdjustDimensionDetails( true );
if( m_DC ) // Display new text
{
CurrentDimension->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
......@@ -203,7 +192,7 @@ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event )
}
static void AbortMoveDimension( EDA_DRAW_PANEL* Panel, wxDC* aDC )
static void AbortBuildDimension( EDA_DRAW_PANEL* Panel, wxDC* aDC )
{
DIMENSION* Dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
......@@ -275,7 +264,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->Draw( DrawPanel, aDC, GR_XOR );
DrawPanel->SetMouseCapture( MoveDimension, AbortMoveDimension );
DrawPanel->SetMouseCapture( BuildDimension, AbortBuildDimension );
return aDimension;
}
......@@ -302,7 +291,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
}
static void MoveDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{
PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
......@@ -360,7 +349,7 @@ void PCB_EDIT_FRAME::ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* a
if( aDimension == NULL )
return;
DIMENSION_EDITOR_DIALOG* frame = new DIMENSION_EDITOR_DIALOG( this, aDimension, aDC );
DIALOG_DIMENSION_EDITOR* frame = new DIALOG_DIMENSION_EDITOR( this, aDimension, aDC );
frame->ShowModal();
frame->Destroy();
}
......@@ -378,3 +367,86 @@ void PCB_EDIT_FRAME::DeleteDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->UnLink();
OnModify();
}
/* Initialize parameters to move a pcb text
*/
static wxPoint initialTextPosition;
void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC )
{
if( aItem == NULL )
return;
// Store the initial position for undo/abort command
initialTextPosition = aItem->m_Text->m_Pos;
aItem->Draw( DrawPanel, DC, GR_XOR );
aItem->m_Flags |= IS_MOVED;
aItem->DisplayInfo( this );
GetScreen()->SetCrossHairPosition( aItem->m_Text->m_Pos );
DrawPanel->MoveCursorToCrossHair();
DrawPanel->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText );
SetCurItem( aItem );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
}
/* Move dimension text following the cursor. */
static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
if( dimension == NULL )
return;
if( aErase )
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->m_Text->m_Pos = aPanel->GetScreen()->GetCrossHairPosition();
dimension->Draw( aPanel, aDC, GR_XOR );
}
/*
* Abort current text edit progress.
*
* If a text is selected, its initial coord are regenerated
*/
void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL );
aPanel->SetMouseCapture( NULL, NULL );
if( dimension == NULL ) // Should not occur
return;
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->m_Text->m_Pos = initialTextPosition;
dimension->m_Flags = 0;
dimension->Draw( aPanel, aDC, GR_OR );
}
/*
* Place the current dimension text being moving
*/
void PCB_EDIT_FRAME::PlaceDimensionText( DIMENSION* aItem, wxDC* DC )
{
DrawPanel->SetMouseCapture( NULL, NULL );
SetCurItem( NULL );
if( aItem == NULL )
return;
aItem->Draw( DrawPanel, DC, GR_OR );
OnModify();
EXCHG( aItem->m_Text->m_Pos, initialTextPosition );
SaveCopyInUndoList( aItem, UR_CHANGED );
EXCHG( aItem->m_Text->m_Pos, initialTextPosition );
aItem->m_Flags = 0;
}
......@@ -55,9 +55,6 @@
// Uncomment following line to enable wxBell() command (which beeps speaker)
// #include <wx/utils.h>
static void Process_Move_Item( PCB_EDIT_FRAME* frame, EDA_ITEM* DrawStruct, wxDC* DC );
/* Handles the selection of command events. */
void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
......@@ -142,6 +139,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_COPY_BLOCK:
case ID_POPUP_PCB_EDIT_DRAWING:
case ID_POPUP_PCB_GETINFO_MARKER:
case ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST:
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
......@@ -574,7 +572,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST:
Process_Move_Item( this, GetCurItem(), &dc );
StartMoveTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
DrawPanel->m_AutoPAN_Request = true;
break;
......@@ -938,6 +936,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST:
BeginMoveDimensionText( (DIMENSION*) GetCurItem(), &dc );
break;
case ID_POPUP_PCB_DELETE_DRAWING:
Delete_Segment_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
DrawPanel->MoveCursorToCrossHair();
......@@ -1091,27 +1093,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
static void Process_Move_Item( PCB_EDIT_FRAME* frame, EDA_ITEM* DrawStruct, wxDC* DC )
{
if( DrawStruct == NULL )
return;
switch( DrawStruct->Type() )
{
case PCB_TEXT_T:
frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC );
break;
default:
wxString msg;
msg.Printf( wxT( "PCB_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),
DrawStruct->Type() );
DisplayError( frame, msg );
break;
}
}
void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
{
if( Item == NULL )
......
......@@ -878,6 +878,11 @@ bool PCB_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand )
break;
case PCB_DIMENSION_T:
if( aIdCommand == HK_MOVE_ITEM )
evt_type = ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST;
break;
default:
break;
}
......
......@@ -119,7 +119,11 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case PCB_DIMENSION_T:
// see above.
if( ! DrawStruct->IsNew() )
{ // We are moving the text of an existing dimension. Place it
PlaceDimensionText( (DIMENSION*) DrawStruct, aDC );
exit = true;
}
break;
default:
......
......@@ -5,7 +5,6 @@
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "macros.h"
#include "class_board.h"
......@@ -223,10 +222,14 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
msg = AddHotkeyName( _( "Edit Dimension" ), g_Board_Editor_Hokeys_Descr,
HK_EDIT_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_DIMENSION, msg, KiBitmap( edit_xpm ) );
msg = AddHotkeyName( _( "Move Dimension Text" ), g_Board_Editor_Hokeys_Descr,
HK_MOVE_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST,
msg, KiBitmap( move_text_xpm ) );
msg = AddHotkeyName( _( "Delete Dimension" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_DIMENSION,
_( "Delete Dimension" ), KiBitmap( delete_xpm ) );
msg, KiBitmap( delete_xpm ) );
}
break;
case PCB_TARGET_T:
......@@ -238,8 +241,9 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
msg = AddHotkeyName( _( "Edit Target" ), g_Board_Editor_Hokeys_Descr,
HK_EDIT_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_MIRE, msg, KiBitmap( edit_xpm ) );
msg = AddHotkeyName( _( "Delete Target" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_MIRE,
_( "Delete Target" ), KiBitmap( delete_xpm ) );
msg, KiBitmap( delete_xpm ) );
}
break;
......@@ -250,14 +254,14 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
case PCB_T:
msg.Printf( wxT( "PCB_EDIT_FRAME::OnRightClick() Error: unexpected DrawType %d" ),
item->Type() );
DisplayError( this, msg );
wxMessageBox( msg );
SetCurItem( NULL );
break;
default:
msg.Printf( wxT( "PCB_EDIT_FRAME::OnRightClick() Error: unknown DrawType %d" ),
item->Type() );
DisplayError( this, msg );
wxMessageBox( msg );
// Attempt to clear error (but should no occurs )
if( item->Type() >= MAX_STRUCT_TYPE_ID )
......@@ -277,7 +281,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
msg, KiBitmap( move_module_xpm ) );
}
/* Display context sensitive comands: */
/* Display context sensitive commands: */
switch( GetToolId() )
{
case ID_PCB_ZONES_BUTT:
......@@ -655,8 +659,9 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE, msg, KiBitmap( edit_module_xpm ) );
sub_menu_footprint->AppendSeparator();
msg = AddHotkeyName( _( "Delete Module" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE,
_( "Delete Module" ), KiBitmap( delete_module_xpm ) );
msg, KiBitmap( delete_module_xpm ) );
}
}
......@@ -724,9 +729,12 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
if( flags ) // Currently in edit, no others commands possible
return;
if( GetBoard()->m_CurrentNetClassName != Pad->GetNetClassName() )
{
GetBoard()->SetCurrentNetClass( Pad->GetNetClassName() );
updateTraceWidthSelectBox();
updateViaSizeSelectBox();
}
wxString msg = Pad->GetSelectMenuText();
......@@ -798,7 +806,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
_( "Reset Size" ), KiBitmap( reset_text_xpm ) );
sub_menu_Text->AppendSeparator();
AddMenuItem( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, _( "Delete" ), KiBitmap( delete_text_xpm ) );
msg = AddHotkeyName( _( "Delete" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
AddMenuItem( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, msg, KiBitmap( delete_text_xpm ) );
}
......
......@@ -100,7 +100,9 @@ enum pcbnew_ids
ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE,
ID_POPUP_PCB_DELETE_MARKER,
ID_POPUP_PCB_DELETE_DIMENSION,
ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST,
ID_POPUP_PCB_MOVE_MIRE_REQUEST,
ID_POPUP_PCB_DELETE_MIRE,
......
......@@ -586,6 +586,7 @@ void PCB_EDIT_FRAME::updateTraceWidthSelectBox()
if( GetBoard()->m_TrackWidthSelector >= GetBoard()->m_TrackWidthList.size() )
GetBoard()->m_TrackWidthSelector = 0;
m_SelTrackWidthBox->SetSelection( GetBoard()->m_TrackWidthSelector );
}
......@@ -615,6 +616,7 @@ void PCB_EDIT_FRAME::updateViaSizeSelectBox()
if( GetBoard()->m_ViaSizeSelector >= GetBoard()->m_ViasDimensionsList.size() )
GetBoard()->m_ViaSizeSelector = 0;
m_SelViaSizeBox->SetSelection( GetBoard()->m_ViaSizeSelector );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment