Commit 3c372703 authored by jean-pierre charras's avatar jean-pierre charras

minor enhancements. fixed issues in microwave tools.

finished replacement of Get_Message (not very useful) by wxTextEntryDialog
parents e286b6f8 42022cfc
...@@ -175,6 +175,13 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint ...@@ -175,6 +175,13 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
return DrawStruct; return DrawStruct;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), LABELITEM );
if( DrawStruct )
{
ClearMsgPanel();
return DrawStruct;
}
/* search for a pin */ /* search for a pin */
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint,
&LibItem ); &LibItem );
......
...@@ -132,6 +132,8 @@ modified!\nYou must create a new power" ) ); ...@@ -132,6 +132,8 @@ modified!\nYou must create a new power" ) );
wxTextEntryDialog dlg( this, Field->m_Name, _( "Component field text" ), newtext ); wxTextEntryDialog dlg( this, Field->m_Name, _( "Component field text" ), newtext );
int diag = dlg.ShowModal(); int diag = dlg.ShowModal();
newtext = dlg.GetValue( ); newtext = dlg.GetValue( );
newtext.Trim( true );
newtext.Trim( false );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
...@@ -306,6 +308,8 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -306,6 +308,8 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
return; // cancelled by user return; // cancelled by user
ref = dlg.GetValue( ); ref = dlg.GetValue( );
ref.Trim( true );
ref.Trim( false );
if( !ref.IsEmpty() ) // New text entered if( !ref.IsEmpty() ) // New text entered
{ {
...@@ -351,6 +355,8 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -351,6 +355,8 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
return; // cancelled by user return; // cancelled by user
message = dlg.GetValue( ); message = dlg.GetValue( );
message.Trim( true );
message.Trim( false );
if( !message.IsEmpty() ) if( !message.IsEmpty() )
{ {
...@@ -390,6 +396,8 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -390,6 +396,8 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
return; // cancelled by user return; // cancelled by user
message = dlg.GetValue( ); message = dlg.GetValue( );
message.Trim( true );
message.Trim( false );
bool wasEmpty = false; bool wasEmpty = false;
if( TextField->m_Text.IsEmpty() ) if( TextField->m_Text.IsEmpty() )
......
...@@ -858,6 +858,8 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& ) ...@@ -858,6 +858,8 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
return; // cancelled by user return; // cancelled by user
buffer = dlg.GetValue( ); buffer = dlg.GetValue( );
buffer.Trim( true );
buffer.Trim( false );
if( buffer.IsEmpty() ) if( buffer.IsEmpty() )
return; // empty file name not allowed return; // empty file name not allowed
......
...@@ -661,6 +661,8 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event ) ...@@ -661,6 +661,8 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
return; // cancelled by user return; // cancelled by user
class_name = dlg.GetValue( ); class_name = dlg.GetValue( );
class_name.Trim( true );
class_name.Trim( false );
if( class_name.IsEmpty() ) if( class_name.IsEmpty() )
return; // empty name not allowed return; // empty name not allowed
......
...@@ -525,6 +525,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -525,6 +525,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp ); wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return 0; // cancelled by user return 0; // cancelled by user
Name_Cmp = dlg.GetValue();
Name_Cmp.Trim( true ); Name_Cmp.Trim( true );
Name_Cmp.Trim( false ); Name_Cmp.Trim( false );
if( Name_Cmp.IsEmpty() ) if( Name_Cmp.IsEmpty() )
...@@ -735,9 +736,9 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( const wxString& aModuleName ) ...@@ -735,9 +736,9 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( const wxString& aModuleName )
{ {
wxTextEntryDialog dlg( this, _( "Module Reference:" ), wxTextEntryDialog dlg( this, _( "Module Reference:" ),
_( "Module Creation" ), moduleName ); _( "Module Creation" ), moduleName );
int diag = dlg.ShowModal(); if( dlg.ShowModal() != wxID_OK )
if( diag != wxID_OK )
return NULL; //Aborted by user return NULL; //Aborted by user
moduleName = dlg.GetValue();
} }
moduleName.Trim( true ); moduleName.Trim( true );
moduleName.Trim( false ); moduleName.Trim( false );
......
...@@ -70,10 +70,10 @@ MODULE* WinEDA_BasePcbFrame::GetModuleByName() ...@@ -70,10 +70,10 @@ MODULE* WinEDA_BasePcbFrame::GetModuleByName()
MODULE* module = NULL; MODULE* module = NULL;
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Search footprint" ), moduleName ); wxTextEntryDialog dlg( this, _( "Name:" ), _( "Search footprint" ), moduleName );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user return NULL; //Aborted by user
moduleName = dlg.GetValue();
moduleName.Trim( true ); moduleName.Trim( true );
moduleName.Trim( false ); moduleName.Trim( false );
if( !moduleName.IsEmpty() ) if( !moduleName.IsEmpty() )
......
...@@ -203,7 +203,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -203,7 +203,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return NULL; // cancelled by user return NULL; // cancelled by user
msg = dlg.GetValue( ); msg = dlg.GetValue();
Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Control values (ii = minimum length) */ /* Control values (ii = minimum length) */
...@@ -313,7 +313,7 @@ static void gen_arc( std::vector <wxPoint>& aBuffer, ...@@ -313,7 +313,7 @@ static void gen_arc( std::vector <wxPoint>& aBuffer,
{ {
#define SEGM_COUNT_PER_360DEG 16 #define SEGM_COUNT_PER_360DEG 16
wxPoint first_point = aStartPoint - aCenter; wxPoint first_point = aStartPoint - aCenter;
int seg_count = ( (abs( a_ArcAngle ) ) * SEGM_COUNT_PER_360DEG) / 3600; int seg_count = ( ( abs( a_ArcAngle ) ) * SEGM_COUNT_PER_360DEG ) / 3600;
if( seg_count == 0 ) if( seg_count == 0 )
seg_count = 1; seg_count = 1;
...@@ -440,8 +440,9 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer, ...@@ -440,8 +440,9 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
// Adjust len by adjusting segm_len: // Adjust len by adjusting segm_len:
int delta_size = full_len - aLength; int delta_size = full_len - aLength;
// reduce len of the segm_count segments + 2 half size segments (= 1 full size segment) // reduce len of the segm_count segments + 2 half size segments (= 1 full size segment)
segm_len -= delta_size / (segm_count+1); segm_len -= delta_size / (segm_count + 1);
// Generate first line (the first stub) and first arc (90 deg arc) // Generate first line (the first stub) and first arc (90 deg arc)
pt = aStartPoint; pt = aStartPoint;
...@@ -524,15 +525,21 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name, ...@@ -524,15 +525,21 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name,
if( Module == NULL ) if( Module == NULL )
return NULL; return NULL;
#define DEFAULT_SIZE 30
Module->m_TimeStamp = GetTimeStamp(); Module->m_TimeStamp = GetTimeStamp();
Module->m_Value->m_Size = wxSize( 30, 30 ); Module->m_Value->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
Module->m_Value->m_Pos0.y = -30; Module->m_Value->m_Pos0.y = -DEFAULT_SIZE;
Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y; Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y;
Module->m_Reference->m_Size = wxSize( 30, 30 ); Module->m_Value->m_Width = DEFAULT_SIZE / 4;
Module->m_Reference->m_Pos0.y = 30; Module->m_Reference->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
Module->m_Reference->m_Pos0.y = DEFAULT_SIZE;
Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y; Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y;
Module->m_Reference->m_Width = DEFAULT_SIZE / 4;
/* Create dots forming the gap. */ /* Create 2 pads used in gaps and stubs.
* The gap is between these 2 pads
* the stub is the pad 2
*/
while( pad_count-- ) while( pad_count-- )
{ {
D_PAD* pad = new D_PAD( Module ); D_PAD* pad = new D_PAD( Module );
...@@ -553,33 +560,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name, ...@@ -553,33 +560,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name,
} }
#if 0
static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
{
MODULE* Module = (MODULE*) frame->GetScreen()->GetCurItem();
if( Module )
{
if( Module->m_Flags & IS_NEW )
{
Module->Draw( frame->DrawPanel, DC, GR_XOR );
Module->DeleteStructure();
}
else
{
Module->Draw( frame->DrawPanel, DC, GR_XOR );
}
}
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
frame->SetCurItem( NULL );
}
#endif
/* Create a module "GAP" or "STUB" /* Create a module "GAP" or "STUB"
* This a "gap" or "stub" used in micro wave designs * This a "gap" or "stub" used in micro wave designs
* This module has 2 pads: * This module has 2 pads:
...@@ -622,24 +602,31 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) ...@@ -622,24 +602,31 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
break; break;
} }
msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() ); wxString value = ReturnStringFromValue( g_UserUnit, gap_size,
wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), wxEmptyString ); GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
{ {
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
return NULL; // cancelled by user return NULL; // cancelled by user
} }
msg = dlg.GetValue( ); value = dlg.GetValue();
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); gap_size = ReturnValueFromString( g_UserUnit, value, GetScreen()->GetInternalUnits() );
bool abort = false; bool abort = false;
if( shape_type == 2 ) if( shape_type == 2 )
{ {
double fcoeff = 10.0, fval; double fcoeff = 10.0, fval;
msg.Printf( wxT( "%3.1f" ), angle / fcoeff ); msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), _( "Create microwave module" ), msg ); wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), _(
msg = angledlg.GetValue( ); "Create microwave module" ), msg );
if( angledlg.ShowModal() != wxID_OK )
{
DrawPanel->MouseToCursorSchema();
return NULL; // cancelled by user
}
msg = angledlg.GetValue();
if( !msg.ToDouble( &fval ) ) if( !msg.ToDouble( &fval ) )
{ {
DisplayError( this, _( "Incorrect number, abort" ) ); DisplayError( this, _( "Incorrect number, abort" ) );
...@@ -1105,7 +1092,7 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module ) ...@@ -1105,7 +1092,7 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user return; // cancelled by user
msg = dlg.GetValue( ); msg = dlg.GetValue();
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Updating sizes of pads forming the gap. */ /* Updating sizes of pads forming the gap. */
......
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