From 8d5a6531f9e285382f1057d05d5951c54ba34c12 Mon Sep 17 00:00:00 2001 From: faa Date: Mon, 3 Aug 2009 12:12:29 +0000 Subject: [PATCH] pcbnew: remove old of two To_User_Unit(), redraw ratsnest on/off, magnetic cursor to start move/drag module --- common/common.cpp | 30 ++---------------------------- pcbnew/dialog_general_options.cpp | 2 ++ pcbnew/editrack-part2.cpp | 2 -- pcbnew/modules.cpp | 13 +++++++++++++ pcbnew/tool_modedit.cpp | 2 +- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index 45a7df54cb..d7dfe30301 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -323,7 +323,7 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit, StringValue << aValue; else { - value_to_print = To_User_Unit( (bool) aUnits, aValue, aInternal_Unit ); + value_to_print = To_User_Unit( (bool) aUnits, (double) aValue, aInternal_Unit ); StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ), value_to_print ); } @@ -407,33 +407,7 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter ) /******************************************************************/ -double To_User_Unit( bool is_metric, int val, int internal_unit_value ) -/******************************************************************/ - -/** - * Function To_User_Unit - * Convert in inch or mm the variable "val" (double)given in internal units - * @return the converted value, in double - * @param is_metric : true if the result must be returned in mm , false if inches - * @param val : integer : the given value - * @param internal_unit_value = internal units per inch - */ -{ - double value; - - if( is_metric ) - value = (double) ( val ) * 25.4 / internal_unit_value; - else - value = (double) ( val ) / internal_unit_value; - - return value; -} - - -/******************************************************************/ -double To_User_Unit( bool is_metric, - double val, - int internal_unit_value ) +double To_User_Unit( bool is_metric, double val, int internal_unit_value ) /******************************************************************/ /** diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index 1249b1eeed..e8ed95a3f1 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -113,6 +113,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) { g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue(); m_Parent->Ratsnest_On_Off( m_DC ); + m_Parent->RedrawActiveWindow( m_DC, TRUE); } g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); @@ -208,6 +209,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) wxClientDC dc( DrawPanel ); DrawPanel->PrepareGraphicContext( &dc ); Ratsnest_On_Off( &dc ); + RedrawActiveWindow( &dc, TRUE); } break; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 7d8b941bb3..55cd7d9ba0 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -65,8 +65,6 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC ) { GetBoard()->m_FullRatsnest[ii].m_Status |= CH_VISIBLE; } - - DrawGeneralRatsnest( DC, 0 ); } else { diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 2f39fdd6bc..3d3d23950c 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -98,6 +98,9 @@ MODULE* WinEDA_BasePcbFrame::GetModuleByName() void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) /**********************************************************************/ { + + wxPoint Mouse; + if( module == NULL ) return; @@ -107,6 +110,11 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) ModuleInitOrient = module->m_Orient; ModuleInitLayer = module->GetLayer(); + GetScreen()->m_Curseur = module->m_Pos; + Mouse.x = wxRound( module->m_Pos.x ); + Mouse.y = wxRound( module->m_Pos.y ); + DrawPanel->MouseTo( Mouse ); + /* Effacement chevelu general si necessaire */ if( g_Show_Ratsnest ) DrawGeneralRatsnest( DC ); @@ -330,6 +338,7 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDe // redraw the area where the module was if( DC ) DrawPanel->PostDirtyRect( module->GetBoundingBox() ); + RedrawActiveWindow( DC, TRUE); return TRUE; } @@ -463,6 +472,9 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRec if( !aDoNotRecreateRatsnest ) Compile_Ratsnest( DC, true ); + if( DC ) + RedrawActiveWindow( DC, TRUE); + module->DisplayInfo( this ); DrawPanel->ManageCurseur = NULL; @@ -539,6 +551,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module, DrawModuleOutlines( DrawPanel, DC, module ); Dessine_Segments_Dragges( DrawPanel, DC ); } + RedrawActiveWindow( DC, TRUE); } } diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 289f303911..279d3dc689 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -298,7 +298,7 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ ) { double value = To_User_Unit( g_UnitMetric, - (int)GetScreen()->m_GridList[i].m_Size.x, + GetScreen()->m_GridList[i].m_Size.x, PCB_INTERNAL_UNIT ); if( GetScreen()->m_GridList[i].m_Id != ID_POPUP_GRID_USER ) {