2013-07-19 18:27:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-08-13 17:51:22 +00:00
|
|
|
* Copyright (C) 2013 CERN
|
2021-01-13 15:17:56 +00:00
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-08-13 17:51:22 +00:00
|
|
|
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-07-19 18:27:22 +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
|
|
|
|
*/
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
#include <project.h>
|
|
|
|
#include <scintilla_tricks.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2020-10-14 00:23:36 +00:00
|
|
|
#include <page_layout/ws_draw_item.h>
|
|
|
|
#include <page_layout/ws_data_item.h>
|
|
|
|
#include <page_layout/ws_data_model.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
|
|
|
|
#include "properties_frame.h"
|
|
|
|
#include "pl_draw_panel_gal.h"
|
|
|
|
#include "pl_editor_frame.h"
|
|
|
|
#include "tools/pl_selection_tool.h"
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) :
|
|
|
|
PANEL_PROPERTIES_BASE( aParent ),
|
2020-12-09 02:31:10 +00:00
|
|
|
m_scintillaTricks( nullptr ),
|
|
|
|
m_textCtrlTextSizeXBinder( aParent, m_staticTextTsizeX, m_textCtrlTextSizeX, m_TextTextSizeXUnits ),
|
|
|
|
m_textCtrlTextSizeYBinder( aParent, m_staticTextTsizeY, m_textCtrlTextSizeY, m_TextTextSizeYUnits ),
|
|
|
|
m_textCtrlConstraintXBinder( aParent, m_staticTextConstraintX, m_textCtrlConstraintX, m_TextConstraintXUnits ),
|
|
|
|
m_textCtrlConstraintYBinder( aParent, m_staticTextConstraintY, m_textCtrlConstraintY, m_TextConstraintYUnits ),
|
|
|
|
m_textCtrlPosXBinder( aParent, m_staticTextPosX, m_textCtrlPosX, m_TextPosXUnits ),
|
|
|
|
m_textCtrlPosYBinder( aParent, m_staticTextPosY, m_textCtrlPosY, m_TextPosYUnits ),
|
|
|
|
m_textCtrlEndXBinder( aParent, m_staticTextEndX, m_textCtrlEndX, m_TextEndXUnits ),
|
|
|
|
m_textCtrlEndYBinder( aParent, m_staticTextEndY, m_textCtrlEndY, m_TextEndYUnits ),
|
|
|
|
m_textCtrlStepXBinder( aParent, m_staticTextStepX, m_textCtrlStepX, m_TextStepXUnits ),
|
|
|
|
m_textCtrlStepYBinder( aParent, m_staticTextStepY, m_textCtrlStepY, m_TextStepYUnits ),
|
|
|
|
m_textCtrlDefaultTextSizeXBinder( aParent, m_staticTextDefTsX, m_textCtrlDefaultTextSizeX, m_TextDefaultTextSizeXUnits ),
|
|
|
|
m_textCtrlDefaultTextSizeYBinder( aParent, m_staticTextDefTsY, m_textCtrlDefaultTextSizeY, m_TextDefaultTextSizeYUnits ),
|
|
|
|
m_textCtrlDefaultLineWidthBinder( aParent, m_staticTextDefLineW, m_textCtrlDefaultLineWidth, m_TextDefaultLineWidthUnits ),
|
|
|
|
m_textCtrlDefaultTextThicknessBinder( aParent, m_staticTextDefTextThickness, m_textCtrlDefaultTextThickness, m_TextDefaultTextThicknessUnits ),
|
|
|
|
m_textCtrlLeftMarginBinder( aParent, m_staticTextLeftMargin, m_textCtrlLeftMargin, m_TextLeftMarginUnits ),
|
|
|
|
m_textCtrlRightMarginBinder( aParent, m_staticTextDefRightMargin, m_textCtrlRightMargin, m_TextRightMarginUnits ),
|
|
|
|
m_textCtrlTopMarginBinder( aParent, m_staticTextTopMargin, m_textCtrlTopMargin, m_TextTopMarginUnits ),
|
2020-12-09 03:38:40 +00:00
|
|
|
m_textCtrlBottomMarginBinder( aParent, m_staticTextBottomMargin, m_textCtrlBottomMargin, m_TextBottomMarginUnits ),
|
|
|
|
m_textCtrlThicknessBinder( aParent, m_staticTextThickness, m_textCtrlThickness, m_TextLineThicknessUnits )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
m_parent = aParent;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
m_stcText->SetUseVerticalScrollBar( false );
|
|
|
|
m_stcText->SetUseHorizontalScrollBar( false );
|
|
|
|
m_scintillaTricks = new SCINTILLA_TRICKS( m_stcText, wxT( "{}" ) );
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
2019-06-12 08:29:26 +00:00
|
|
|
infoFont.SetSymbolicSize( wxFONTSIZE_X_SMALL );
|
2021-01-13 18:03:36 +00:00
|
|
|
m_staticTextSizeInfo->SetFont( infoFont );
|
2019-05-24 18:29:38 +00:00
|
|
|
|
|
|
|
m_buttonOK->SetDefault();
|
2020-05-30 09:22:19 +00:00
|
|
|
|
|
|
|
m_stcText->Bind( wxEVT_STC_CHARADDED, &PROPERTIES_FRAME::onScintillaCharAdded, this );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PROPERTIES_FRAME::~PROPERTIES_FRAME()
|
|
|
|
{
|
2020-05-30 09:22:19 +00:00
|
|
|
delete m_scintillaTricks;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-24 18:29:38 +00:00
|
|
|
void PROPERTIES_FRAME::OnPageChanged( wxNotebookEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetSelection() == 0 )
|
|
|
|
m_buttonOK->SetDefault();
|
|
|
|
else
|
|
|
|
m_buttonGeneralOptsOK->SetDefault();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
wxSize PROPERTIES_FRAME::GetMinSize() const
|
|
|
|
{
|
|
|
|
return wxSize( 150, -1 );
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
// Data transfert from general properties to widgets
|
|
|
|
void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Set default parameters
|
2020-12-09 02:31:10 +00:00
|
|
|
m_textCtrlDefaultLineWidthBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, model.m_DefaultLineWidth ) );
|
|
|
|
|
|
|
|
m_textCtrlDefaultTextSizeXBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, model.m_DefaultTextSize.x ) );
|
|
|
|
|
|
|
|
m_textCtrlDefaultTextSizeYBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, model.m_DefaultTextSize.y ) );
|
|
|
|
|
|
|
|
m_textCtrlDefaultTextThicknessBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, model.m_DefaultTextThickness ) );
|
|
|
|
|
|
|
|
m_textCtrlLeftMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetLeftMargin() ) );
|
|
|
|
m_textCtrlRightMarginBinder.SetDoubleValue(From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetRightMargin() ) );
|
|
|
|
m_textCtrlTopMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetTopMargin() ) );
|
|
|
|
m_textCtrlBottomMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetBottomMargin() ) );
|
2013-07-20 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Data transfert from widgets to general properties
|
|
|
|
bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral()
|
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
// Import default parameters from widgets
|
2020-12-09 02:31:10 +00:00
|
|
|
model.m_DefaultLineWidth =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlDefaultLineWidthBinder.GetValue() );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
2020-12-09 02:31:10 +00:00
|
|
|
model.m_DefaultTextSize.x =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlDefaultTextSizeXBinder.GetValue() );
|
|
|
|
model.m_DefaultTextSize.y =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlDefaultTextSizeYBinder.GetValue() );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
2020-12-09 02:31:10 +00:00
|
|
|
model.m_DefaultTextThickness =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlDefaultTextThicknessBinder.GetValue() );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
// Get page margins values
|
2020-12-09 02:31:10 +00:00
|
|
|
model.SetRightMargin(
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlRightMarginBinder.GetValue() ) );
|
|
|
|
model.SetBottomMargin(
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlBottomMarginBinder.GetValue() ) );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
// cordinates of the left top corner are the left and top margins
|
2020-12-09 02:31:10 +00:00
|
|
|
model.SetLeftMargin(
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlLeftMarginBinder.GetValue() ) );
|
|
|
|
model.SetTopMargin(
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlTopMarginBinder.GetValue() ) );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
// Data transfert from item to widgets in properties frame
|
2019-05-25 11:05:39 +00:00
|
|
|
void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WS_DATA_ITEM* aItem )
|
2013-07-20 19:36:19 +00:00
|
|
|
{
|
2019-05-24 12:24:43 +00:00
|
|
|
if( !aItem )
|
|
|
|
{
|
|
|
|
m_SizerItemProperties->Show( false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
// Set parameters common to all WS_DATA_ITEM types
|
2019-05-20 10:23:32 +00:00
|
|
|
m_staticTextType->SetLabel( aItem->GetClassName() );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_textCtrlComment->SetValue( aItem->m_Info );
|
|
|
|
|
|
|
|
switch( aItem->GetPage1Option() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
default:
|
|
|
|
case ALL_PAGES: m_choicePageOpt->SetSelection( 0 ); break;
|
|
|
|
case FIRST_PAGE_ONLY: m_choicePageOpt->SetSelection( 1 ); break;
|
|
|
|
case SUBSEQUENT_PAGES: m_choicePageOpt->SetSelection( 2 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Position/ start point
|
2020-12-09 02:31:10 +00:00
|
|
|
m_textCtrlPosXBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_Pos.m_Pos.x ) );
|
|
|
|
|
|
|
|
m_textCtrlPosYBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_Pos.m_Pos.y ) );
|
2013-10-19 10:29:54 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( aItem->m_Pos.m_Anchor )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case RB_CORNER: m_comboBoxCornerPos->SetSelection( 2 ); break;
|
|
|
|
case RT_CORNER: m_comboBoxCornerPos->SetSelection( 0 ); break;
|
|
|
|
case LB_CORNER: m_comboBoxCornerPos->SetSelection( 3 ); break;
|
|
|
|
case LT_CORNER: m_comboBoxCornerPos->SetSelection( 1 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// End point
|
2020-12-09 02:31:10 +00:00
|
|
|
m_textCtrlEndXBinder.SetDoubleValue(
|
2021-01-13 15:17:56 +00:00
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_End.m_Pos.x ) );
|
2020-12-09 02:31:10 +00:00
|
|
|
m_textCtrlEndYBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_End.m_Pos.y ) );
|
2013-10-19 10:29:54 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( aItem->m_End.m_Anchor )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case RB_CORNER: m_comboBoxCornerEnd->SetSelection( 2 ); break;
|
|
|
|
case RT_CORNER: m_comboBoxCornerEnd->SetSelection( 0 ); break;
|
|
|
|
case LB_CORNER: m_comboBoxCornerEnd->SetSelection( 3 ); break;
|
|
|
|
case LT_CORNER: m_comboBoxCornerEnd->SetSelection( 1 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2020-12-09 03:38:40 +00:00
|
|
|
m_textCtrlThicknessBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_LineWidth ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
// Now, set prms more specific to WS_DATA_ITEM types
|
2013-07-19 18:27:22 +00:00
|
|
|
// For a given type, disable widgets which are not relevant,
|
|
|
|
// and be sure widgets which are relevant are enabled
|
2019-05-25 11:05:39 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_TEXT )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_TEXT* item = (WS_DATA_ITEM_TEXT*) aItem;
|
2013-08-18 15:49:04 +00:00
|
|
|
item->m_FullText = item->m_TextBase;
|
|
|
|
// Replace our '\' 'n' sequence by the EOL char
|
2015-01-17 08:01:16 +00:00
|
|
|
item->ReplaceAntiSlashSequence();
|
2020-05-30 09:22:19 +00:00
|
|
|
m_stcText->SetValue( item->m_FullText );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
msg.Printf( wxT("%d"), item->m_IncrementLabel );
|
|
|
|
m_textCtrlTextIncrement->SetValue( msg );
|
|
|
|
|
|
|
|
// Rotation (poly and text)
|
|
|
|
msg.Printf( wxT("%.3f"), item->m_Orient );
|
|
|
|
m_textCtrlRotation->SetValue( msg );
|
|
|
|
|
|
|
|
// Constraints:
|
2020-12-09 02:31:10 +00:00
|
|
|
m_textCtrlConstraintXBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, item->m_BoundingBoxSize.x ) );
|
|
|
|
m_textCtrlConstraintYBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, item->m_BoundingBoxSize.y ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Font Options
|
2019-05-20 10:23:32 +00:00
|
|
|
m_checkBoxBold->SetValue( item->m_Bold );
|
|
|
|
m_checkBoxItalic->SetValue( item->m_Italic );
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( item->m_Hjustify )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case GR_TEXT_HJUSTIFY_LEFT: m_choiceHjustify->SetSelection( 0 ); break;
|
|
|
|
case GR_TEXT_HJUSTIFY_CENTER: m_choiceHjustify->SetSelection( 1 ); break;
|
|
|
|
case GR_TEXT_HJUSTIFY_RIGHT: m_choiceHjustify->SetSelection( 2 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( item->m_Vjustify )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_TOP: m_choiceVjustify->SetSelection( 0 ); break;
|
|
|
|
case GR_TEXT_VJUSTIFY_CENTER: m_choiceVjustify->SetSelection( 1 ); break;
|
|
|
|
case GR_TEXT_VJUSTIFY_BOTTOM: m_choiceVjustify->SetSelection( 2 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Text size
|
2020-12-09 02:31:10 +00:00
|
|
|
m_textCtrlTextSizeXBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, item->m_TextSize.x ) );
|
|
|
|
m_textCtrlTextSizeYBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, item->m_TextSize.y ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_POLYPOLYGON )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_POLYGONS* item = (WS_DATA_ITEM_POLYGONS*) aItem;
|
2013-07-19 18:27:22 +00:00
|
|
|
// Rotation (poly and text)
|
|
|
|
msg.Printf( wxT("%.3f"), item->m_Orient );
|
|
|
|
m_textCtrlRotation->SetValue( msg );
|
|
|
|
}
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_BITMAP )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_BITMAP* item = (WS_DATA_ITEM_BITMAP*) aItem;
|
2013-10-19 10:29:54 +00:00
|
|
|
// select definition in PPI
|
|
|
|
msg.Printf( wxT("%d"), item->GetPPI() );
|
2021-01-13 18:03:36 +00:00
|
|
|
m_textCtrlBitmapDPI->SetValue( msg );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-10-19 10:29:54 +00:00
|
|
|
|
2019-05-24 12:24:43 +00:00
|
|
|
m_SizerItemProperties->Show( true );
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
m_SizerTextOptions->Show( aItem->GetType() == WS_DATA_ITEM::WS_TEXT );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2020-12-09 04:07:01 +00:00
|
|
|
m_sbSizerEndPosition->Show( aItem->GetType() == WS_DATA_ITEM::WS_SEGMENT
|
2019-05-25 11:05:39 +00:00
|
|
|
|| aItem->GetType() == WS_DATA_ITEM::WS_RECT );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-01-13 18:03:36 +00:00
|
|
|
m_textCtrlThicknessBinder.Show( aItem->GetType() != WS_DATA_ITEM::WS_BITMAP );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-01-13 18:03:36 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_TEXT
|
|
|
|
|| aItem->GetType() == WS_DATA_ITEM::WS_POLYPOLYGON )
|
|
|
|
{
|
|
|
|
m_staticTextRot->Show( true );
|
|
|
|
m_textCtrlRotation->Show( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_staticTextRot->Show( false );
|
|
|
|
m_textCtrlRotation->Show( false );
|
|
|
|
}
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-01-13 18:03:36 +00:00
|
|
|
m_staticTextBitmapDPI->Show( aItem->GetType() == WS_DATA_ITEM::WS_BITMAP );
|
|
|
|
m_textCtrlBitmapDPI->Show( aItem->GetType() == WS_DATA_ITEM::WS_BITMAP );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
m_staticTextInclabel->Show( aItem->GetType() == WS_DATA_ITEM::WS_TEXT );
|
|
|
|
m_textCtrlTextIncrement->Show( aItem->GetType() == WS_DATA_ITEM::WS_TEXT );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Repeat parameters
|
|
|
|
msg.Printf( wxT("%d"), aItem->m_RepeatCount );
|
|
|
|
m_textCtrlRepeatCount->SetValue( msg );
|
2020-12-09 02:31:10 +00:00
|
|
|
|
|
|
|
m_textCtrlStepXBinder.SetDoubleValue(
|
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_IncrementVector.x ) );
|
|
|
|
|
|
|
|
m_textCtrlStepYBinder.SetDoubleValue(
|
2021-01-12 19:33:35 +00:00
|
|
|
From_User_Unit( EDA_UNITS::MILLIMETRES, aItem->m_IncrementVector.y ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-11-05 17:37:15 +00:00
|
|
|
// The number of widgets was modified, so recalculate sizers
|
2013-07-20 19:36:19 +00:00
|
|
|
m_swItemProperties->Layout();
|
2020-11-30 17:50:36 +00:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
// This call is mandatory on wxGTK to initialize the right virtual size and therefore
|
|
|
|
// scrollbars, but for some reason, create issues on Windows (incorrect disply
|
|
|
|
// until the frame is resized). Joys of multiplatform dev.
|
2020-11-30 18:13:14 +00:00
|
|
|
m_swItemProperties->Fit();
|
2020-11-30 17:50:36 +00:00
|
|
|
#endif
|
|
|
|
// send a size event to be sure scrollbars will be added/removed as needed
|
2020-11-05 17:37:15 +00:00
|
|
|
m_swItemProperties->PostSizeEvent();
|
2013-07-20 19:36:19 +00:00
|
|
|
m_swItemProperties->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Event function called by clicking on the OK button
|
|
|
|
void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
PL_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PL_SELECTION_TOOL>();
|
2019-06-09 21:57:23 +00:00
|
|
|
PL_SELECTION& selection = selTool->GetSelection();
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-26 12:50:29 +00:00
|
|
|
m_parent->SaveCopyInUndoList();
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
WS_DRAW_ITEM_BASE* drawItem = (WS_DRAW_ITEM_BASE*) selection.Front();
|
|
|
|
|
|
|
|
if( drawItem )
|
2013-08-18 15:49:04 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM* dataItem = drawItem->GetPeer();
|
2019-05-20 10:23:32 +00:00
|
|
|
CopyPrmsFromPanelToItem( dataItem );
|
2016-09-14 16:53:24 +00:00
|
|
|
// Be sure what is displayed is what is set for item
|
2013-08-18 15:49:04 +00:00
|
|
|
// (mainly, texts can be modified if they contain "\n")
|
2019-05-20 10:23:32 +00:00
|
|
|
CopyPrmsFromItemToPanel( dataItem );
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->GetView()->Update( drawItem );
|
2013-08-18 15:49:04 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
CopyPrmsFromPanelToGeneral();
|
|
|
|
|
2016-09-14 16:53:24 +00:00
|
|
|
// Refresh values, exactly as they are converted, to avoid any mistake
|
|
|
|
CopyPrmsFromGeneralToPanel();
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_parent->OnModify();
|
2019-06-03 15:39:04 +00:00
|
|
|
|
|
|
|
// Rebuild the draw list with the new parameters
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->DisplayWorksheet();
|
|
|
|
m_parent->GetCanvas()->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-24 15:11:35 +00:00
|
|
|
void PROPERTIES_FRAME::OnSetDefaultValues( wxCommandEvent& event )
|
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
|
|
|
|
model.m_DefaultTextSize = DSIZE( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
|
|
|
|
model.m_DefaultLineWidth = 0.15;
|
|
|
|
model.m_DefaultTextThickness = 0.15;
|
2013-07-24 15:11:35 +00:00
|
|
|
|
|
|
|
CopyPrmsFromGeneralToPanel();
|
2019-06-03 15:39:04 +00:00
|
|
|
|
|
|
|
// Rebuild the draw list with the new parameters
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->DisplayWorksheet();
|
|
|
|
m_parent->GetCanvas()->Refresh();
|
2013-07-24 15:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Data transfert from properties frame to item parameters
|
2019-05-25 11:05:39 +00:00
|
|
|
bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( WS_DATA_ITEM* aItem )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
if( aItem == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
// Import common parameters:
|
|
|
|
aItem->m_Info = m_textCtrlComment->GetValue();
|
|
|
|
|
|
|
|
switch( m_choicePageOpt->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
default:
|
|
|
|
case 0: aItem->SetPage1Option( ALL_PAGES ); break;
|
|
|
|
case 1: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
|
|
|
|
case 2: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Import thickness
|
2020-12-09 03:38:40 +00:00
|
|
|
aItem->m_LineWidth = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlThicknessBinder.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import Start point
|
2020-12-09 02:31:10 +00:00
|
|
|
aItem->m_Pos.m_Pos.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlPosXBinder.GetValue() );
|
|
|
|
aItem->m_Pos.m_Pos.y = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlPosYBinder.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( m_comboBoxCornerPos->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case 2: aItem->m_Pos.m_Anchor = RB_CORNER; break;
|
|
|
|
case 0: aItem->m_Pos.m_Anchor = RT_CORNER; break;
|
|
|
|
case 3: aItem->m_Pos.m_Anchor = LB_CORNER; break;
|
|
|
|
case 1: aItem->m_Pos.m_Anchor = LT_CORNER; break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Import End point
|
2020-12-09 02:31:10 +00:00
|
|
|
aItem->m_End.m_Pos.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlEndXBinder.GetValue() );
|
|
|
|
aItem->m_End.m_Pos.y = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlEndYBinder.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( m_comboBoxCornerEnd->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case 2: aItem->m_End.m_Anchor = RB_CORNER; break;
|
|
|
|
case 0: aItem->m_End.m_Anchor = RT_CORNER; break;
|
|
|
|
case 3: aItem->m_End.m_Anchor = LB_CORNER; break;
|
|
|
|
case 1: aItem->m_End.m_Anchor = LT_CORNER; break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Import Repeat prms
|
|
|
|
long itmp;
|
|
|
|
msg = m_textCtrlRepeatCount->GetValue();
|
|
|
|
msg.ToLong( &itmp );
|
|
|
|
aItem->m_RepeatCount = itmp;
|
|
|
|
|
2020-12-09 02:31:10 +00:00
|
|
|
aItem->m_IncrementVector.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlStepXBinder.GetValue() );
|
|
|
|
aItem->m_IncrementVector.y = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlStepYBinder.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_TEXT )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_TEXT* item = (WS_DATA_ITEM_TEXT*) aItem;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
item->m_TextBase = m_stcText->GetValue();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
msg = m_textCtrlTextIncrement->GetValue();
|
|
|
|
msg.ToLong( &itmp );
|
|
|
|
item->m_IncrementLabel = itmp;
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
item->m_Bold = m_checkBoxBold->IsChecked();
|
|
|
|
item->m_Italic = m_checkBoxItalic->IsChecked();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( m_choiceHjustify->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case 0: item->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; break;
|
|
|
|
case 1: item->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER; break;
|
|
|
|
case 2: item->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT; break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( m_choiceVjustify->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break;
|
|
|
|
case 1: item->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; break;
|
|
|
|
case 2: item->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg = m_textCtrlRotation->GetValue();
|
2019-12-20 14:11:39 +00:00
|
|
|
item->m_Orient = DoubleValueFromString( EDA_UNITS::UNSCALED, msg );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import text size
|
2020-12-09 02:31:10 +00:00
|
|
|
item->m_TextSize.x =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlTextSizeXBinder.GetValue() );
|
|
|
|
item->m_TextSize.y =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlTextSizeYBinder.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import constraints:
|
2020-12-09 02:31:10 +00:00
|
|
|
item->m_BoundingBoxSize.x =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlConstraintXBinder.GetValue() );
|
|
|
|
item->m_BoundingBoxSize.y =
|
|
|
|
To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlConstraintYBinder.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_POLYPOLYGON )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_POLYGONS* item = (WS_DATA_ITEM_POLYGONS*) aItem;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
msg = m_textCtrlRotation->GetValue();
|
2019-12-20 14:11:39 +00:00
|
|
|
item->m_Orient = DoubleValueFromString( EDA_UNITS::UNSCALED, msg );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
if( aItem->GetType() == WS_DATA_ITEM::WS_BITMAP )
|
2013-10-19 10:29:54 +00:00
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_BITMAP* item = (WS_DATA_ITEM_BITMAP*) aItem;
|
2021-01-13 18:03:36 +00:00
|
|
|
long value;
|
|
|
|
|
|
|
|
msg = m_textCtrlBitmapDPI->GetValue();
|
|
|
|
|
2013-10-19 10:29:54 +00:00
|
|
|
if( msg.ToLong( &value ) )
|
|
|
|
item->SetPPI( (int)value );
|
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
|
|
|
|
void PROPERTIES_FRAME::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
|
|
|
{
|
|
|
|
wxArrayString autocompleteTokens;
|
|
|
|
int pos = m_stcText->GetCurrentPos();
|
|
|
|
int start = m_stcText->WordStartPosition( pos, true );
|
|
|
|
wxString partial;
|
|
|
|
|
|
|
|
if( start >= 2
|
|
|
|
&& m_stcText->GetCharAt( start-2 ) == '$'
|
|
|
|
&& m_stcText->GetCharAt( start-1 ) == '{' )
|
|
|
|
{
|
|
|
|
WS_DRAW_ITEM_LIST::GetTextVars( &autocompleteTokens );
|
|
|
|
|
|
|
|
partial = m_stcText->GetTextRange( start, pos );
|
|
|
|
|
|
|
|
for( std::pair<wxString, wxString> entry : m_parent->Prj().GetTextVars() )
|
|
|
|
autocompleteTokens.push_back( entry.first );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
|
|
|
|
m_stcText->SetFocus();
|
|
|
|
}
|