本文整理汇总了C++中DIMENSION::SetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ DIMENSION::SetWidth方法的具体用法?C++ DIMENSION::SetWidth怎么用?C++ DIMENSION::SetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIMENSION
的用法示例。
在下文中一共展示了DIMENSION::SetWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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 );
}
示例3: DrawDimension
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();
//.........这里部分代码省略.........
示例4: 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)
}