本文整理汇总了C++中DIMENSION类的典型用法代码示例。如果您正苦于以下问题:C++ DIMENSION类的具体用法?C++ DIMENSION怎么用?C++ DIMENSION使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DIMENSION类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MoveDimensionText
/* 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->Text().SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() );
dimension->Draw( aPanel, aDC, GR_XOR );
}
示例2: AbortMoveDimensionText
/*
* 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->Text().SetTextPosition( initialTextPosition );
dimension->ClearFlags();
dimension->Draw( aPanel, aDC, GR_OR );
}
示例3: AbortBuildDimension
static void AbortBuildDimension( EDA_DRAW_PANEL* Panel, wxDC* aDC )
{
DIMENSION* Dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
if( Dimension )
{
if( Dimension->IsNew() )
{
Dimension->Draw( Panel, aDC, GR_XOR );
Dimension->DeleteStructure();
}
else
{
Dimension->Draw( Panel, aDC, GR_OR );
}
}
status_dimension = 0;
((PCB_EDIT_FRAME*)Panel->GetParent())->SetCurItem( NULL );
}
示例4: OnDimensionUnitsChange
void DIALOG_TEXT_PROPERTIES::OnDimensionUnitsChange( wxCommandEvent& event )
{
DIMENSION* dimension = (DIMENSION*) m_item;
EDA_UNITS_T units;
bool useMils;
// Get default units in case dimension text doesn't contain units.
dimension->GetUnits( units, useMils );
double value = ValueFromString( units, m_DimensionText->GetValue(), useMils );
switch( event.GetSelection() )
{
case 0: units = INCHES; useMils = false; break;
case 1: units = INCHES; useMils = true; break;
case 2: units = MILLIMETRES; useMils = false; break;
default: break;
}
m_DimensionText->SetValue( StringFromValue( units, value, true, useMils ) );
}
示例5: BuildDimension
static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{
PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem();
wxPoint pos = aPanel->GetParent()->GetCrossHairPosition();
if( Dimension == NULL )
return;
// Erase previous dimension.
if( aErase )
{
Dimension->Draw( aPanel, aDC, GR_XOR );
}
Dimension->SetLayer( screen->m_Active_Layer );
if( status_dimension == 1 )
{
Dimension->m_featureLineDO = pos;
Dimension->m_crossBarF = Dimension->m_featureLineDO;
Dimension->AdjustDimensionDetails( );
}
else
{
wxPoint delta;
int dx, dy;
double angle, depl;
delta = Dimension->m_featureLineDO - Dimension->m_featureLineGO;
/* Calculating the direction of travel perpendicular to the selected axis. */
angle = atan2( delta.y, delta.x ) + (M_PI / 2);
delta = pos - Dimension->m_featureLineDO;
depl = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
dx = KiROUND( depl * cos( angle ) );
dy = KiROUND( depl * sin( angle ) );
Dimension->m_crossBarO.x = Dimension->m_featureLineGO.x + dx;
Dimension->m_crossBarO.y = Dimension->m_featureLineGO.y + dy;
Dimension->m_crossBarF.x = Dimension->m_featureLineDO.x + dx;
Dimension->m_crossBarF.y = Dimension->m_featureLineDO.y + dy;
Dimension->AdjustDimensionDetails( );
}
Dimension->Draw( aPanel, aDC, GR_XOR );
}
示例6: OnOKClick
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() );
if( !m_Parent->GetBoard()->IsLayerEnabled( newlayer ) )
{
wxMessageBox( _( "The layer currently selected is not enabled for this board\n"
"You cannot use it" ) );
return;
}
#ifndef USE_WX_OVERLAY
if( m_DC ) // Delete old text.
{
CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
}
#endif
m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED);
if( m_Name->GetValue() != wxEmptyString )
{
CurrentDimension->SetText( m_Name->GetValue() );
}
wxString msg;
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->Text().SetWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->Text().SetHeight( ValueFromString( g_UserUnit, msg ) );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
wxPoint pos;
pos.x = ValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
pos.y = ValueFromString( g_UserUnit, msg );
CurrentDimension->Text().SetTextPosition( pos );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->Text().GetSize() );
if( width > maxthickness )
{
DisplayError( NULL,
_( "The text thickness is too large for the text size. "
"It will be clamped" ) );
width = maxthickness;
}
CurrentDimension->SetWidth( width );
CurrentDimension->Text().SetThickness( width );
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
CurrentDimension->SetLayer( newlayer );
#ifndef USE_WX_OVERLAY
if( m_DC ) // Display new text
{
CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_Parent->Refresh();
#endif
m_Parent->OnModify();
EndModal( 1 );
}
示例7: OnOKClick
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
if( m_DC ) // Delete old text.
{
CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
}
m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED);
if( m_Name->GetValue() != wxEmptyString )
{
CurrentDimension->SetText( m_Name->GetValue() );
}
wxString msg;
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->Text().SetWidth( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->Text().SetHeight( ReturnValueFromString( g_UserUnit, msg ) );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
wxPoint pos;
pos.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
pos.y = ReturnValueFromString( g_UserUnit, msg );
CurrentDimension->Text().SetTextPosition( pos );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ReturnValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->Text().GetSize() );
if( width > maxthickness )
{
DisplayError( NULL,
_( "The text thickness is too large for the text size. It will be clamped") );
width = maxthickness;
}
CurrentDimension->SetWidth( width );
CurrentDimension->Text().SetThickness( width );
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
CurrentDimension->SetLayer( m_SelLayerBox->GetLayerSelection() );
if( m_DC ) // Display new text
{
CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
}
m_Parent->OnModify();
EndModal( 1 );
}
示例8: switch
//.........这里部分代码省略.........
break;
}
case S_CIRCLE:
{
const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
{
wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
segment->Move( moveVector );
}
else
{
segment->SetEnd( wxPoint( end.x, end.y ) );
}
break;
}
default: // suppress warnings
break;
}
// Update relative coordinates for module edges
if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
edge->SetLocalCoord();
break;
}
case PCB_ZONE_AREA_T:
{
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
zone->ClearFilledPolysList();
CPolyLine* outline = zone->Outline();
for( int i = 0; i < outline->GetCornersCount(); ++i )
{
VECTOR2I point = m_editPoints->Point( i ).GetPosition();
outline->SetX( i, point.x );
outline->SetY( i, point.y );
}
break;
}
case PCB_DIMENSION_T:
{
DIMENSION* dimension = static_cast<DIMENSION*>( item );
// Check which point is currently modified and updated dimension's points respectively
if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
{
VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
if( featureLine.Cross( crossBar ) > 0 )
dimension->SetHeight( -featureLine.EuclideanNorm() );
else
dimension->SetHeight( featureLine.EuclideanNorm() );
}
else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
{
VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
if( featureLine.Cross( crossBar ) > 0 )
dimension->SetHeight( -featureLine.EuclideanNorm() );
else
dimension->SetHeight( featureLine.EuclideanNorm() );
}
else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
{
dimension->SetOrigin( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) );
m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
m_editPoints->Point( DIM_FEATUREGO ) ) );
m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
m_editPoints->Point( DIM_FEATUREDO ) ) );
}
else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
{
dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) );
m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
m_editPoints->Point( DIM_FEATUREGO ) ) );
m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
m_editPoints->Point( DIM_FEATUREDO ) ) );
}
break;
}
default:
break;
}
}
示例9: assert
int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
{
DIMENSION* dimension = NULL;
int width, maxThickness;
// if one day it is possible to draw dimensions in the footprint editor,
// then hereby I'm letting you know that this tool does not handle UR_MODEDIT undo yet
assert( !m_editModules );
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX::VIEW_GROUP preview( m_view );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
m_controls->SetSnapping( true );
Activate();
m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
enum DIMENSION_STEPS
{
SET_ORIGIN = 0,
SET_END,
SET_HEIGHT,
FINISHED
};
int step = SET_ORIGIN;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
VECTOR2I cursorPos = m_controls->GetCursorPosition();
if( evt->IsCancel() || evt->IsActivate() )
{
if( step != SET_ORIGIN ) // start from the beginning
{
preview.Clear();
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
delete dimension;
step = SET_ORIGIN;
}
else
break;
if( evt->IsActivate() ) // now finish unconditionally
break;
}
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) && step != SET_ORIGIN )
{
dimension->SetWidth( dimension->GetWidth() + WIDTH_STEP );
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) && step != SET_ORIGIN )
{
int width = dimension->GetWidth();
if( width > WIDTH_STEP )
{
dimension->SetWidth( width - WIDTH_STEP );
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
}
else if( evt->IsClick( BUT_LEFT ) )
{
switch( step )
{
case SET_ORIGIN:
{
LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer;
if( IsCopperLayer( layer ) || layer == Edge_Cuts )
{
DisplayInfoMessage( NULL, _( "Dimension not allowed on Copper or Edge Cut layers" ) );
--step;
}
else
{
// Init the new item attributes
dimension = new DIMENSION( m_board );
dimension->SetLayer( layer );
dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) );
dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
dimension->Text().SetSize( m_board->GetDesignSettings().m_PcbTextSize );
width = m_board->GetDesignSettings().m_PcbTextWidth;
maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetSize() );
if( width > maxThickness )
width = maxThickness;
dimension->Text().SetThickness( width );
dimension->SetWidth( width );
dimension->AdjustDimensionDetails();
//.........这里部分代码省略.........
示例10: DIALOG_TEXT_PROPERTIES_BASE
DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BOARD_ITEM* aItem ) :
DIALOG_TEXT_PROPERTIES_BASE( aParent ),
m_Parent( aParent ), m_item( aItem ),
m_edaText( nullptr ), m_modText( nullptr ), m_pcbText( nullptr ),
m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits, true ),
m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits, true ),
m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits, true ),
m_posX( aParent, m_PositionXLabel, m_PositionXCtrl, m_PositionXUnits ),
m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ),
m_OrientValidator( 1, &m_OrientValue )
{
wxString title;
if( m_item->Type() == PCB_DIMENSION_T )
{
title = _( "Dimension Text Properties" );
DIMENSION* dimension = (DIMENSION*) m_item;
m_edaText = &dimension->Text();
m_pcbText = &dimension->Text();
SetInitialFocus( m_DimensionText );
m_SingleLineSizer->Show( false );
m_MultiLineSizer->Show( false );
m_KeepUpright->Show( false );
m_statusLine->Show( false );
}
else if( m_item->Type() == PCB_MODULE_TEXT_T )
{
title = _( "Footprint Text Properties" );
m_modText = (TEXTE_MODULE*) m_item;
m_edaText = static_cast<EDA_TEXT*>( m_modText );
switch( m_modText->GetType() )
{
case TEXTE_MODULE::TEXT_is_REFERENCE: m_TextLabel->SetLabel( _( "Reference:" ) ); break;
case TEXTE_MODULE::TEXT_is_VALUE: m_TextLabel->SetLabel( _( "Value:" ) ); break;
case TEXTE_MODULE::TEXT_is_DIVERS: m_TextLabel->SetLabel( _( "Text:" ) ); break;
}
SetInitialFocus( m_SingleLineText );
m_MultiLineSizer->Show( false );
m_DimensionTextSizer->Show( false );
}
else
{
title = _( "Text Properties" );
m_pcbText = (TEXTE_PCB*) aItem;
m_edaText = static_cast<EDA_TEXT*>( m_pcbText );
SetInitialFocus( m_MultiLineText );
m_SingleLineSizer->Show( false );
m_DimensionTextSizer->Show( false );
// This option make sense only for footprint texts,
// Texts on board are always visible:
m_Visible->SetValue( true );
m_Visible->Show( false );
m_KeepUpright->Show( false );
m_statusLine->Show( false );
}
SetTitle( title );
m_hash_key = title;
// Configure the layers list selector. Note that footprints are built outside the current
// board and so we may need to show all layers if the text is on an unactivated layer.
if( !m_Parent->GetBoard()->IsLayerEnabled( m_item->GetLayer() ) )
m_LayerSelectionCtrl->ShowNonActivatedLayers( true );
m_LayerSelectionCtrl->SetLayersHotkeys( false );
m_LayerSelectionCtrl->SetNotAllowedLayerSet( LSET::ForbiddenTextLayers() );
m_LayerSelectionCtrl->SetBoardFrame( m_Parent );
m_LayerSelectionCtrl->Resync();
m_OrientValue = 0.0;
m_OrientValidator.SetRange( -360.0, 360.0 );
m_OrientCtrl->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_OrientCtrl );
// Handle decimal separators in combo dropdown
for( size_t i = 0; i < m_OrientCtrl->GetCount(); ++i )
{
wxString item = m_OrientCtrl->GetString( i );
item.Replace( '.', localeconv()->decimal_point[0] );
m_OrientCtrl->SetString( i, item );
}
// Set font sizes
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
m_statusLine->SetFont( infoFont );
m_sdbSizerOK->SetDefault();
// Tab down the left side first
//.........这里部分代码省略.........
示例11: commit
bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
{
if( !DIALOG_TEXT_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
if( !m_textWidth.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE )
|| !m_textHeight.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) )
return false;
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_item );
// If no other command in progress, prepare undo command
// (for a command in progress, will be made later, at the completion of command)
bool pushCommit = ( m_item->GetEditFlags() == 0 );
/* set flag in edit to force undo/redo/abort proper operation,
* and avoid new calls to SaveCopyInUndoList for the same text
* this can occurs when a text is moved, and then rotated, edited ..
*/
if( !pushCommit )
m_item->SetFlags( IN_EDIT );
// Set the new text content
if( m_SingleLineText->IsShown() )
{
if( !m_SingleLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_SingleLineText->GetValue() );
}
else if( m_MultiLineText->IsShown() )
{
if( !m_MultiLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_MultiLineText->GetValue() );
}
else if( m_DimensionText->IsShown() )
{
if( !m_DimensionText->GetValue().IsEmpty() )
m_edaText->SetText( m_DimensionText->GetValue() );
DIMENSION* dimension = (DIMENSION*) m_item;
switch( m_DimensionUnitsOpt->GetSelection() )
{
case 0: dimension->SetUnits( INCHES, false ); break;
case 1: dimension->SetUnits( INCHES, true ); break;
case 2: dimension->SetUnits( MILLIMETRES, false ); break;
default: break;
}
}
m_item->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
m_edaText->SetTextSize( wxSize( m_textWidth.GetValue(), m_textHeight.GetValue() ) );
m_edaText->SetThickness( m_thickness.GetValue() );
m_edaText->SetTextPos( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) );
if( m_modText )
m_modText->SetLocalCoord();
// Test for acceptable values for thickness and size and clamp if fails
int maxthickness = Clamp_Text_PenSize( m_edaText->GetThickness(), m_edaText->GetTextSize() );
if( m_edaText->GetThickness() > maxthickness )
{
DisplayError( this, _( "The text thickness is too large for the text size.\n"
"It will be clamped." ) );
m_edaText->SetThickness( maxthickness );
}
m_edaText->SetVisible( m_Visible->GetValue() );
m_edaText->SetItalic( m_Italic->GetValue() );
m_edaText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
m_edaText->SetMirrored( m_Mirrored->GetValue() );
if( m_modText )
m_modText->SetKeepUpright( m_KeepUpright->GetValue() );
switch( m_JustifyChoice->GetSelection() )
{
case 0: m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break;
case 1: m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break;
case 2: m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break;
default: break;
}
m_Parent->Refresh();
if( pushCommit )
commit.Push( _( "Change text properties" ) );
return true;
}
示例12: SelectReferenceNumber
bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
{
if( m_SingleLineText->IsShown() )
{
m_SingleLineText->SetValue( m_edaText->GetText() );
if( m_modText && m_modText->GetType() == TEXTE_MODULE::TEXT_is_REFERENCE )
SelectReferenceNumber( static_cast<wxTextEntry*>( m_SingleLineText ) );
else
m_SingleLineText->SetSelection( -1, -1 );
}
else if( m_MultiLineText->IsShown() )
{
m_MultiLineText->SetValue( m_edaText->GetText() );
m_MultiLineText->SetSelection( -1, -1 );
}
else if (m_DimensionText->IsShown() )
{
m_DimensionText->SetValue( m_edaText->GetText() );
m_DimensionText->SetSelection( -1, -1 );
DIMENSION* dimension = (DIMENSION*) m_item;
EDA_UNITS_T units;
bool useMils;
dimension->GetUnits( units, useMils );
m_DimensionUnitsOpt->SetSelection( units == MILLIMETRES ? 2 : useMils ? 1 : 0 );
}
if( m_item->Type() == PCB_MODULE_TEXT_T && m_modText )
{
MODULE* module = dynamic_cast<MODULE*>( m_modText->GetParent() );
wxString msg;
if( module )
{
msg.Printf( _("Footprint %s (%s), %s, rotated %.1f deg"),
module->GetReference(),
module->GetValue(),
module->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
module->GetOrientation() / 10.0 );
}
m_statusLine->SetLabel( msg );
}
else
{
m_statusLine->Show( false );
}
if( m_LayerSelectionCtrl->SetLayerSelection( m_item->GetLayer() ) < 0 )
{
wxMessageBox( _( "This item was on a non-existing or forbidden layer.\n"
"It has been moved to the first allowed layer." ) );
m_LayerSelectionCtrl->SetSelection( 0 );
}
m_textWidth.SetValue( m_edaText->GetTextSize().x );
m_textHeight.SetValue( m_edaText->GetTextSize().y );
m_thickness.SetValue( m_edaText->GetThickness() );
m_posX.SetValue( m_edaText->GetTextPos().x );
m_posY.SetValue( m_edaText->GetTextPos().y );
m_Visible->SetValue( m_edaText->IsVisible() );
m_Italic->SetValue( m_edaText->IsItalic() );
EDA_TEXT_HJUSTIFY_T hJustify = m_edaText->GetHorizJustify();
m_JustifyChoice->SetSelection( (int) hJustify + 1 );
m_OrientValue = m_edaText->GetTextAngleDegrees();
m_Mirrored->SetValue( m_edaText->IsMirrored() );
if( m_modText )
m_KeepUpright->SetValue( m_modText->IsKeepUpright() );
return DIALOG_TEXT_PROPERTIES_BASE::TransferDataToWindow();
}
示例13: OnOKClick
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
BOARD_COMMIT commit( m_parent );
PCB_LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() );
if( !m_parent->GetBoard()->IsLayerEnabled( newlayer ) )
{
wxMessageBox( _( "The layer currently selected is not enabled for this board\n"
"You cannot use it" ) );
return;
}
#ifndef USE_WX_OVERLAY
if( m_DC ) // Delete old text.
{
m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
}
#endif
commit.Modify( m_currentDimension );
if( m_Name->GetValue() != wxEmptyString )
{
m_currentDimension->SetText( m_Name->GetValue() );
}
wxString msg;
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
m_currentDimension->Text().SetTextWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue();
m_currentDimension->Text().SetTextHeight( ValueFromString( g_UserUnit, msg ) );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
wxPoint pos;
pos.x = ValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
pos.y = ValueFromString( g_UserUnit, msg );
m_currentDimension->Text().SetTextPos( pos );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetTextSize() );
if( width > maxthickness )
{
DisplayError( NULL,
_( "The text thickness is too large for the text size. "
"It will be clamped" ) );
width = maxthickness;
}
m_currentDimension->SetWidth( width );
m_currentDimension->Text().SetThickness( width );
m_currentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
m_currentDimension->SetLayer( newlayer );
#ifndef USE_WX_OVERLAY
if( m_DC ) // Display new text
{
m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_parent->Refresh();
#endif
commit.Push( _( "Modifed dimensions properties" ) );
event.Skip(); // ends returning wxID_OK (default behavior)
}