2013-03-30 09:28:59 +00:00
|
|
|
/**
|
2013-04-25 16:29:35 +00:00
|
|
|
* @file dialog_edit_module_text.cpp
|
|
|
|
* @brief dialog editor for texts (fields) in footprints.
|
2013-03-30 09:28:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-04-17 10:24:35 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras
|
2013-03-30 09:28:59 +00:00
|
|
|
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
|
2016-05-30 18:17:39 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-30 09:28:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <pcbnew.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2016-04-09 20:17:19 +00:00
|
|
|
#include <wx/numformatter.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_text_mod.h>
|
2015-04-17 10:24:35 +00:00
|
|
|
#include <class_board.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
2014-07-09 12:01:06 +00:00
|
|
|
#include <dialog_edit_module_text.h>
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-12-22 21:06:44 +00:00
|
|
|
extern wxPoint MoveVector; // Move vector for move edge, imported from edtxtmod.cpp
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC )
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2018-01-14 13:24:58 +00:00
|
|
|
DIALOG_EDIT_FPTEXT dialog( this, this, TextMod, DC );
|
2009-08-11 10:27:21 +00:00
|
|
|
dialog.ShowModal();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2008-12-22 21:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-14 13:24:58 +00:00
|
|
|
DIALOG_EDIT_FPTEXT::DIALOG_EDIT_FPTEXT( wxWindow* aCaller, PCB_BASE_FRAME* aBoardEditor,
|
2011-10-18 17:28:49 +00:00
|
|
|
TEXTE_MODULE* aTextMod, wxDC* aDC ) :
|
2018-01-14 13:24:58 +00:00
|
|
|
DIALOG_EDIT_FPTEXT_BASE( aCaller ), m_OrientValidator( 1, &m_OrientValue )
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
2018-01-14 13:24:58 +00:00
|
|
|
m_boardEditor = aBoardEditor;
|
2011-10-18 17:28:49 +00:00
|
|
|
m_dc = aDC;
|
|
|
|
m_module = NULL;
|
|
|
|
m_currentText = aTextMod;
|
2016-05-11 02:36:23 +00:00
|
|
|
m_OrientValue = 0;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2016-05-30 18:17:39 +00:00
|
|
|
m_OrientValidator.SetRange( -180.0, 180.0 );
|
2016-04-09 20:17:19 +00:00
|
|
|
m_OrientValueCtrl->SetValidator( m_OrientValidator );
|
2016-04-10 22:28:06 +00:00
|
|
|
m_OrientValidator.SetWindow( m_OrientValueCtrl );
|
2016-04-09 20:17:19 +00:00
|
|
|
|
2011-10-18 17:28:49 +00:00
|
|
|
if( m_currentText )
|
|
|
|
m_module = (MODULE*) m_currentText->GetParent();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2016-07-15 10:05:13 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2016-04-09 20:17:19 +00:00
|
|
|
SetFocus();
|
2016-07-15 10:05:13 +00:00
|
|
|
|
2008-12-22 21:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-14 13:24:58 +00:00
|
|
|
bool DIALOG_EDIT_FPTEXT::TransferDataToWindow()
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
2016-04-09 20:17:19 +00:00
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
2011-10-18 17:28:49 +00:00
|
|
|
if( m_module )
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
|
|
|
wxString format = m_ModuleInfoText->GetLabel();
|
|
|
|
msg.Printf( format,
|
2013-03-13 18:53:58 +00:00
|
|
|
GetChars( m_module->GetReference() ),
|
|
|
|
GetChars( m_module->GetValue() ),
|
2013-05-01 17:32:36 +00:00
|
|
|
m_module->GetOrientation() / 10.0 );
|
2008-12-22 21:06:44 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
else
|
2011-12-22 13:28:11 +00:00
|
|
|
{
|
2009-08-11 10:27:21 +00:00
|
|
|
msg.Empty();
|
2011-12-22 13:28:11 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
|
|
|
m_ModuleInfoText->SetLabel( msg );
|
|
|
|
|
2014-09-14 15:34:37 +00:00
|
|
|
// Create a list of not allowed layers.
|
|
|
|
// could be slightly dependent of the type of footprint text.
|
|
|
|
LSET forbiddenLayers( LSET::AllCuMask() );
|
|
|
|
forbiddenLayers.set( Edge_Cuts ).set( Margin ).set( F_Paste ).set( B_Paste ).set( F_Mask ).set( B_Mask );
|
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
switch( m_currentText->GetType() )
|
|
|
|
{
|
|
|
|
case TEXTE_MODULE::TEXT_is_VALUE:
|
2008-12-22 21:06:44 +00:00
|
|
|
m_TextDataTitle->SetLabel( _( "Value:" ) );
|
2013-04-07 11:55:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXTE_MODULE::TEXT_is_DIVERS:
|
2008-12-22 21:06:44 +00:00
|
|
|
m_TextDataTitle->SetLabel( _( "Text:" ) );
|
2013-04-07 11:55:18 +00:00
|
|
|
break;
|
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
case TEXTE_MODULE::TEXT_is_REFERENCE:
|
2013-04-07 11:55:18 +00:00
|
|
|
m_TextDataTitle->SetLabel( _( "Reference:" ) );
|
|
|
|
break;
|
|
|
|
}
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
m_Name->SetValue( m_currentText->GetText() );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
m_Style->SetSelection( m_currentText->IsItalic() ? 1 : 0 );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
AddUnitSymbol( *m_SizeXTitle );
|
2017-01-23 20:30:11 +00:00
|
|
|
PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->GetTextWidth() );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
AddUnitSymbol( *m_SizeYTitle );
|
2017-01-23 20:30:11 +00:00
|
|
|
PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->GetTextHeight() );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
AddUnitSymbol( *m_PosXTitle );
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_TxtPosCtrlX, m_currentText->GetPos0().x );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
AddUnitSymbol( *m_PosYTitle );
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_TxtPosCtrlY, m_currentText->GetPos0().y );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
AddUnitSymbol( *m_WidthTitle );
|
2013-03-18 19:36:07 +00:00
|
|
|
PutValueInLocalUnits( *m_TxtWidthCtlr, m_currentText->GetThickness() );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
double text_orient = m_currentText->GetTextAngle();
|
2017-11-13 07:31:31 +00:00
|
|
|
text_orient = NormalizeAngle180( text_orient );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
if( !m_currentText->IsVisible() )
|
2014-09-14 15:34:37 +00:00
|
|
|
m_Show->SetSelection( 1 );
|
2014-09-13 06:15:16 +00:00
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
bool custom_orientation = false;
|
2016-04-10 12:23:44 +00:00
|
|
|
switch( int( text_orient ) )
|
2016-04-08 23:18:44 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_Orient->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 900:
|
2016-05-30 18:17:39 +00:00
|
|
|
case -2700:
|
2016-04-08 23:18:44 +00:00
|
|
|
m_Orient->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -900:
|
2016-05-30 18:17:39 +00:00
|
|
|
case 2700:
|
2016-04-08 23:18:44 +00:00
|
|
|
m_Orient->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
|
2016-05-30 18:17:39 +00:00
|
|
|
case -1800:
|
|
|
|
case 1800:
|
2016-04-08 23:18:44 +00:00
|
|
|
m_Orient->SetSelection( 3 );
|
2016-05-30 18:17:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_Orient->SetSelection( 4 );
|
2016-04-09 20:17:19 +00:00
|
|
|
custom_orientation = true;
|
2016-04-08 23:18:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
m_OrientValueCtrl->Enable( custom_orientation );
|
2016-04-10 12:23:44 +00:00
|
|
|
m_OrientValue = text_orient / 10.0;
|
|
|
|
m_OrientValidator.TransferToWindow();
|
2016-04-08 23:18:44 +00:00
|
|
|
|
2017-11-25 19:55:32 +00:00
|
|
|
m_unlock->SetValue( m_currentText->IsUnlocked() );
|
|
|
|
|
2014-09-13 06:15:16 +00:00
|
|
|
// Configure the layers list selector
|
2018-01-14 13:24:58 +00:00
|
|
|
if( !m_boardEditor->GetBoard()->IsLayerEnabled( m_currentText->GetLayer() ) )
|
2015-04-17 10:24:35 +00:00
|
|
|
// Footprints are built outside the current board, so items cann be
|
|
|
|
// on a not activated layer, therefore show it if happens.
|
|
|
|
m_LayerSelectionCtrl->ShowNonActivatedLayers( true );
|
|
|
|
|
2014-09-13 06:15:16 +00:00
|
|
|
m_LayerSelectionCtrl->SetLayersHotkeys( false );
|
2014-09-14 15:34:37 +00:00
|
|
|
m_LayerSelectionCtrl->SetLayerSet( forbiddenLayers );
|
2018-01-14 13:24:58 +00:00
|
|
|
m_LayerSelectionCtrl->SetBoardFrame( m_boardEditor );
|
2014-09-13 06:15:16 +00:00
|
|
|
m_LayerSelectionCtrl->Resync();
|
|
|
|
|
|
|
|
if( m_LayerSelectionCtrl->SetLayerSelection( m_currentText->GetLayer() ) < 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "This item has an illegal layer id.\n"
|
2017-12-27 17:09:27 +00:00
|
|
|
"Now, forced on the front silk screen layer. Please, fix it" ) );
|
2014-09-13 06:15:16 +00:00
|
|
|
m_LayerSelectionCtrl->SetLayerSelection( F_SilkS );
|
|
|
|
}
|
2016-04-08 23:18:44 +00:00
|
|
|
|
2017-12-27 17:09:27 +00:00
|
|
|
Layout();
|
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
return true;
|
2016-04-08 23:18:44 +00:00
|
|
|
}
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
|
2018-01-14 13:24:58 +00:00
|
|
|
bool DIALOG_EDIT_FPTEXT::TransferDataFromWindow()
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
2018-01-14 13:24:58 +00:00
|
|
|
BOARD_COMMIT commit( m_boardEditor );
|
2016-06-20 13:46:58 +00:00
|
|
|
|
2018-01-14 13:24:58 +00:00
|
|
|
if( !Validate() || !DIALOG_EDIT_FPTEXT_BASE::TransferDataFromWindow() )
|
2016-04-09 20:17:19 +00:00
|
|
|
return false;
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2014-09-13 06:15:16 +00:00
|
|
|
if( m_module )
|
2016-06-20 13:46:58 +00:00
|
|
|
commit.Modify( m_currentText );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2013-12-22 17:29:57 +00:00
|
|
|
#ifndef USE_WX_OVERLAY
|
2011-10-18 17:28:49 +00:00
|
|
|
if( m_dc ) //Erase old text on screen
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
2018-01-14 13:24:58 +00:00
|
|
|
m_currentText->Draw( m_boardEditor->GetCanvas(), m_dc, GR_XOR,
|
2011-12-21 13:42:02 +00:00
|
|
|
(m_currentText->IsMoving()) ? MoveVector : wxPoint( 0, 0 ) );
|
2008-12-22 21:06:44 +00:00
|
|
|
}
|
2013-12-22 17:29:57 +00:00
|
|
|
#endif
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
m_currentText->SetText( m_Name->GetValue() );
|
|
|
|
m_currentText->SetItalic( m_Style->GetSelection() == 1 );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
wxPoint tmp;
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
tmp.x = ValueFromString( g_UserUnit, m_TxtPosCtrlX->GetValue() );
|
|
|
|
tmp.y = ValueFromString( g_UserUnit, m_TxtPosCtrlY->GetValue() );
|
2011-12-12 08:37:05 +00:00
|
|
|
|
|
|
|
m_currentText->SetPos0( tmp );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxSize textSize( wxSize( ValueFromString( g_UserUnit, m_TxtSizeCtrlX->GetValue() ),
|
|
|
|
ValueFromString( g_UserUnit, m_TxtSizeCtrlY->GetValue() ) ) );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2014-08-13 13:15:15 +00:00
|
|
|
// Test for a reasonable size:
|
2013-03-18 19:36:07 +00:00
|
|
|
if( textSize.x < TEXTS_MIN_SIZE )
|
|
|
|
textSize.x = TEXTS_MIN_SIZE;
|
2014-08-13 13:15:15 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( textSize.y < TEXTS_MIN_SIZE )
|
|
|
|
textSize.y = TEXTS_MIN_SIZE;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
m_currentText->SetTextSize( textSize );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
int width = ValueFromString( g_UserUnit, m_TxtWidthCtlr->GetValue() );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2014-08-13 13:15:15 +00:00
|
|
|
// Test for a reasonable width:
|
2008-12-22 21:06:44 +00:00
|
|
|
if( width <= 1 )
|
|
|
|
width = 1;
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
int maxthickness = Clamp_Text_PenSize(width, m_currentText->GetTextSize() );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2009-05-30 16:06:01 +00:00
|
|
|
if( width > maxthickness )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
DisplayError( NULL,
|
|
|
|
_( "The text thickness is too large for the text size. It will be clamped" ) );
|
2009-05-30 16:06:01 +00:00
|
|
|
width = maxthickness;
|
|
|
|
}
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2011-10-18 17:28:49 +00:00
|
|
|
m_currentText->SetThickness( width );
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
m_currentText->SetVisible( m_Show->GetSelection() == 0 );
|
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
bool custom_orientation = false;
|
2016-04-08 23:18:44 +00:00
|
|
|
switch( m_Orient->GetSelection() )
|
|
|
|
{
|
2016-04-09 20:17:19 +00:00
|
|
|
case 0:
|
2017-01-23 20:30:11 +00:00
|
|
|
m_currentText->SetTextAngle( 0 );
|
2016-04-09 20:17:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2017-01-23 20:30:11 +00:00
|
|
|
m_currentText->SetTextAngle( 900 );
|
2016-04-09 20:17:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2017-01-23 20:30:11 +00:00
|
|
|
m_currentText->SetTextAngle( -900 );
|
2016-04-09 20:17:19 +00:00
|
|
|
break;
|
|
|
|
|
2016-05-30 18:17:39 +00:00
|
|
|
case 3:
|
|
|
|
m_currentText->SetTextAngle( 1800 );
|
|
|
|
break;
|
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
default:
|
|
|
|
custom_orientation = true;
|
2017-01-23 20:30:11 +00:00
|
|
|
m_currentText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
|
2016-04-08 23:18:44 +00:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
switch( int( m_currentText->GetTextAngle() ) )
|
2016-04-08 23:18:44 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_Orient->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 900:
|
|
|
|
case -2700:
|
|
|
|
m_Orient->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -900:
|
|
|
|
case 2700:
|
|
|
|
m_Orient->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
|
2016-05-30 18:17:39 +00:00
|
|
|
case -1800:
|
|
|
|
case 1800:
|
2016-04-08 23:18:44 +00:00
|
|
|
m_Orient->SetSelection( 3 );
|
2016-05-30 18:17:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_Orient->SetSelection( 4 );
|
2017-01-23 20:30:11 +00:00
|
|
|
m_currentText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
|
2016-04-09 20:17:19 +00:00
|
|
|
custom_orientation = true;
|
2016-04-08 23:18:44 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-01-23 20:30:11 +00:00
|
|
|
m_OrientValue = 10.0 * m_currentText->GetTextAngle();
|
2016-04-09 20:17:19 +00:00
|
|
|
m_OrientValueCtrl->Enable( custom_orientation );
|
|
|
|
m_OrientValidator.TransferToWindow();
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2011-10-18 17:28:49 +00:00
|
|
|
m_currentText->SetDrawCoord();
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2017-11-25 19:55:32 +00:00
|
|
|
m_currentText->SetUnlocked( m_unlock->GetValue() );
|
|
|
|
|
2014-09-13 06:15:16 +00:00
|
|
|
LAYER_NUM layer = m_LayerSelectionCtrl->GetLayerSelection();
|
|
|
|
m_currentText->SetLayer( ToLAYER_ID( layer ) );
|
2014-09-14 15:34:37 +00:00
|
|
|
m_currentText->SetMirrored( IsBackLayer( m_currentText->GetLayer() ) );
|
2014-09-13 06:15:16 +00:00
|
|
|
|
2013-12-22 17:29:57 +00:00
|
|
|
#ifndef USE_WX_OVERLAY
|
2011-10-18 17:28:49 +00:00
|
|
|
if( m_dc ) // Display new text
|
2008-12-22 21:06:44 +00:00
|
|
|
{
|
2018-01-14 13:24:58 +00:00
|
|
|
m_currentText->Draw( m_boardEditor->GetCanvas(), m_dc, GR_XOR,
|
2016-04-09 20:17:19 +00:00
|
|
|
(m_currentText->IsMoving()) ? MoveVector : wxPoint( 0, 0 ) );
|
2008-12-22 21:06:44 +00:00
|
|
|
}
|
2013-12-22 17:29:57 +00:00
|
|
|
#else
|
2018-01-14 13:24:58 +00:00
|
|
|
m_boardEditor->Refresh();
|
2013-12-22 17:29:57 +00:00
|
|
|
#endif
|
2011-12-21 13:42:02 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
commit.Push( _( "Modify module text" ) );
|
2011-12-21 13:42:02 +00:00
|
|
|
|
2011-10-18 17:28:49 +00:00
|
|
|
if( m_module )
|
2012-09-05 12:13:33 +00:00
|
|
|
m_module->SetLastEditTime();
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-14 13:24:58 +00:00
|
|
|
void DIALOG_EDIT_FPTEXT::ModuleOrientEvent( wxCommandEvent& event )
|
2016-04-09 20:17:19 +00:00
|
|
|
{
|
|
|
|
bool custom_orientation = false;
|
|
|
|
|
|
|
|
switch( m_Orient->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_OrientValue = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
m_OrientValue = 90.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
m_OrientValue = -90.0;
|
|
|
|
break;
|
|
|
|
|
2016-05-30 18:17:39 +00:00
|
|
|
case 3:
|
|
|
|
m_OrientValue = 180.0;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 20:17:19 +00:00
|
|
|
default:
|
|
|
|
custom_orientation = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_OrientValidator.TransferToWindow();
|
|
|
|
m_OrientValueCtrl->Enable( custom_orientation );
|
2008-12-22 21:06:44 +00:00
|
|
|
}
|