Loading include/length.h→include/length.h.usuned +0 −0 File moved. View file pcbnew/class_dimension.cpp +199 −250 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : m_Text( this ) m_Text( this ) { { m_Layer = DRAW_LAYER; m_Layer = DRAW_LAYER; m_Width = 50; m_Width = Millimeter2iu( 0.2 ); m_Value = 0; m_Value = 0; m_Shape = 0; m_Shape = 0; m_Unit = INCHES; m_Unit = INCHES; Loading @@ -64,11 +64,16 @@ DIMENSION::~DIMENSION() void DIMENSION::SetPosition( const wxPoint& aPos ) void DIMENSION::SetPosition( const wxPoint& aPos ) { { m_Pos = aPos; m_Text.SetPos( aPos ); m_Text.SetPos( aPos ); } } const wxPoint& DIMENSION::GetPosition() const { return m_Text.GetPosition(); } void DIMENSION::SetText( const wxString& aNewText ) void DIMENSION::SetText( const wxString& aNewText ) { { m_Text.SetText( aNewText ); m_Text.SetText( aNewText ); Loading @@ -93,82 +98,50 @@ void DIMENSION::Copy( DIMENSION* source ) m_Value = source->m_Value; m_Value = source->m_Value; SetLayer( source->GetLayer() ); SetLayer( source->GetLayer() ); m_Width = source->m_Width; m_Width = source->m_Width; m_Pos = source->m_Pos; m_Shape = source->m_Shape; m_Shape = source->m_Shape; m_Unit = source->m_Unit; m_Unit = source->m_Unit; SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() ); m_Text.Copy( &source->m_Text ); m_Text.Copy( &source->m_Text ); m_crossBarOx = source->m_crossBarOx; m_crossBarO = source->m_crossBarO; m_crossBarOy = source->m_crossBarOy; m_crossBarF = source->m_crossBarF; m_crossBarFx = source->m_crossBarFx; m_featureLineGO = source->m_featureLineGO; m_crossBarFy = source->m_crossBarFy; m_featureLineGF = source->m_featureLineGF; m_featureLineGOx = source->m_featureLineGOx; m_featureLineDO = source->m_featureLineDO; m_featureLineGOy = source->m_featureLineGOy; m_featureLineDF = source->m_featureLineDF; m_featureLineGFx = source->m_featureLineGFx; m_arrowD1O = source->m_arrowD1O; m_featureLineGFy = source->m_featureLineGFy; m_arrowD1F = source->m_arrowD1F; m_featureLineDOx = source->m_featureLineDOx; m_arrowD2O = source->m_arrowD2O; m_featureLineDOy = source->m_featureLineDOy; m_arrowD2F = source->m_arrowD2F; m_featureLineDFx = source->m_featureLineDFx; m_arrowG1O = source->m_arrowG1O; m_featureLineDFy = source->m_featureLineDFy; m_arrowG1F = source->m_arrowG1F; m_arrowD1Ox = source->m_arrowD1Ox; m_arrowG2O = source->m_arrowG2O; m_arrowD1Oy = source->m_arrowD1Oy; m_arrowG2F = source->m_arrowG2F; m_arrowD1Fx = source->m_arrowD1Fx; m_arrowD1Fy = source->m_arrowD1Fy; m_arrowD2Ox = source->m_arrowD2Ox; m_arrowD2Oy = source->m_arrowD2Oy; m_arrowD2Fx = source->m_arrowD2Fx; m_arrowD2Fy = source->m_arrowD2Fy; m_arrowG1Ox = source->m_arrowG1Ox; m_arrowG1Oy = source->m_arrowG1Oy; m_arrowG1Fx = source->m_arrowG1Fx; m_arrowG1Fy = source->m_arrowG1Fy; m_arrowG2Ox = source->m_arrowG2Ox; m_arrowG2Oy = source->m_arrowG2Oy; m_arrowG2Fx = source->m_arrowG2Fx; m_arrowG2Fy = source->m_arrowG2Fy; } } void DIMENSION::Move( const wxPoint& offset ) void DIMENSION::Move( const wxPoint& offset ) { { m_Pos += offset; m_Text.m_Pos += offset; m_Text.m_Pos += offset; m_crossBarOx += offset.x; m_crossBarO += offset; m_crossBarOy += offset.y; m_crossBarF += offset; m_crossBarFx += offset.x; m_featureLineGO += offset; m_crossBarFy += offset.y; m_featureLineGF += offset; m_featureLineGOx += offset.x; m_featureLineDO += offset; m_featureLineGOy += offset.y; m_featureLineDF += offset; m_featureLineGFx += offset.x; m_arrowG1O += offset; m_featureLineGFy += offset.y; m_arrowG1F += offset; m_featureLineDOx += offset.x; m_arrowG2O += offset; m_featureLineDOy += offset.y; m_arrowG2F += offset; m_featureLineDFx += offset.x; m_arrowD1O += offset; m_featureLineDFy += offset.y; m_arrowD1F += offset; m_arrowG1Ox += offset.x; m_arrowD2O += offset; m_arrowG1Oy += offset.y; m_arrowD2F += offset; m_arrowG1Fx += offset.x; m_arrowG1Fy += offset.y; m_arrowG2Ox += offset.x; m_arrowG2Oy += offset.y; m_arrowG2Fx += offset.x; m_arrowG2Fy += offset.y; m_arrowD1Ox += offset.x; m_arrowD1Oy += offset.y; m_arrowD1Fx += offset.x; m_arrowD1Fy += offset.y; m_arrowD2Ox += offset.x; m_arrowD2Oy += offset.y; m_arrowD2Fx += offset.x; m_arrowD2Fy += offset.y; } } void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) { { RotatePoint( &m_Pos, aRotCentre, aAngle ); RotatePoint( &m_Text.m_Pos, aRotCentre, aAngle ); RotatePoint( &m_Text.m_Pos, aRotCentre, aAngle ); double newAngle = m_Text.GetOrientation() + aAngle; double newAngle = m_Text.GetOrientation() + aAngle; Loading @@ -181,20 +154,20 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) m_Text.SetOrientation( newAngle ); m_Text.SetOrientation( newAngle ); RotatePoint( &m_crossBarOx, &m_crossBarOy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_crossBarO, aRotCentre, aAngle ); RotatePoint( &m_crossBarFx, &m_crossBarFy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_crossBarF, aRotCentre, aAngle ); RotatePoint( &m_featureLineGOx, &m_featureLineGOy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineGO, aRotCentre, aAngle ); RotatePoint( &m_featureLineGFx, &m_featureLineGFy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineGF, aRotCentre, aAngle ); RotatePoint( &m_featureLineDOx, &m_featureLineDOy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineDO, aRotCentre, aAngle ); RotatePoint( &m_featureLineDFx, &m_featureLineDFy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineDF, aRotCentre, aAngle ); RotatePoint( &m_arrowG1Ox, &m_arrowG1Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG1O, aRotCentre, aAngle ); RotatePoint( &m_arrowG1Fx, &m_arrowG1Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG1F, aRotCentre, aAngle ); RotatePoint( &m_arrowG2Ox, &m_arrowG2Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG2O, aRotCentre, aAngle ); RotatePoint( &m_arrowG2Fx, &m_arrowG2Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG2F, aRotCentre, aAngle ); RotatePoint( &m_arrowD1Ox, &m_arrowD1Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD1O, aRotCentre, aAngle ); RotatePoint( &m_arrowD1Fx, &m_arrowD1Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD1F, aRotCentre, aAngle ); RotatePoint( &m_arrowD2Ox, &m_arrowD2Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD2O, aRotCentre, aAngle ); RotatePoint( &m_arrowD2Fx, &m_arrowD2Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD2F, aRotCentre, aAngle ); } } Loading @@ -208,11 +181,11 @@ void DIMENSION::Flip( const wxPoint& aCentre ) void DIMENSION::Mirror( const wxPoint& axis_pos ) void DIMENSION::Mirror( const wxPoint& axis_pos ) { { #define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) #define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) INVERT( m_Pos.y ); INVERT( m_Text.m_Pos.y ); INVERT( m_Text.m_Pos.y ); // invert angle // invert angle double newAngle = m_Text.GetOrientation(); double newAngle = m_Text.GetOrientation(); if( newAngle >= 3600 ) if( newAngle >= 3600 ) newAngle -= 3600; newAngle -= 3600; Loading @@ -221,20 +194,20 @@ void DIMENSION::Mirror( const wxPoint& axis_pos ) m_Text.SetOrientation( newAngle ); m_Text.SetOrientation( newAngle ); INVERT( m_crossBarOy ); INVERT( m_crossBarO.y ); INVERT( m_crossBarFy ); INVERT( m_crossBarF.y ); INVERT( m_featureLineGOy ); INVERT( m_featureLineGO.y ); INVERT( m_featureLineGFy ); INVERT( m_featureLineGF.y ); INVERT( m_featureLineDOy ); INVERT( m_featureLineDO.y ); INVERT( m_featureLineDFy ); INVERT( m_featureLineDF.y ); INVERT( m_arrowG1Oy ); INVERT( m_arrowG1O.y ); INVERT( m_arrowG1Fy ); INVERT( m_arrowG1F.y ); INVERT( m_arrowG2Oy ); INVERT( m_arrowG2O.y ); INVERT( m_arrowG2Fy ); INVERT( m_arrowG2F.y ); INVERT( m_arrowD1Oy ); INVERT( m_arrowD1O.y ); INVERT( m_arrowD1Fy ); INVERT( m_arrowD1F.y ); INVERT( m_arrowD2Oy ); INVERT( m_arrowD2O.y ); INVERT( m_arrowD2Fy ); INVERT( m_arrowD2F.y ); } } Loading @@ -256,8 +229,8 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) ii = m_Text.m_Size.y + ii = m_Text.m_Size.y + m_Text.GetThickness() + (m_Width * 3); m_Text.GetThickness() + (m_Width * 3); deltax = m_featureLineDOx - m_featureLineGOx; deltax = m_featureLineDO.x - m_featureLineGO.x; deltay = m_featureLineDOy - m_featureLineGOy; deltay = m_featureLineDO.y - m_featureLineGO.y; // Calculate dimension value // Calculate dimension value measure = KiROUND( hypot( (double) deltax, (double) deltay ) ); measure = KiROUND( hypot( (double) deltax, (double) deltay ) ); Loading @@ -276,16 +249,16 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) hx = (abs) ( (int) ( ( (double) deltay * hx ) / measure ) ); hx = (abs) ( (int) ( ( (double) deltay * hx ) / measure ) ); hy = (abs) ( (int) ( ( (double) deltax * hy ) / measure ) ); hy = (abs) ( (int) ( ( (double) deltax * hy ) / measure ) ); if( m_featureLineGOx > m_crossBarOx ) if( m_featureLineGO.x > m_crossBarO.x ) hx = -hx; hx = -hx; if( m_featureLineGOx == m_crossBarOx ) if( m_featureLineGO.x == m_crossBarO.x ) hx = 0; hx = 0; if( m_featureLineGOy > m_crossBarOy ) if( m_featureLineGO.y > m_crossBarO.y ) hy = -hy; hy = -hy; if( m_featureLineGOy == m_crossBarOy ) if( m_featureLineGO.y == m_crossBarO.y ) hy = 0; hy = 0; angle_f = angle + (M_PI * 27.5 / 180); angle_f = angle + (M_PI * 27.5 / 180); Loading @@ -296,41 +269,42 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) arrow_dw_Y = (int) ( arrowz * sin( angle_f ) ); arrow_dw_Y = (int) ( arrowz * sin( angle_f ) ); } } m_arrowG1Ox = m_crossBarOx; m_arrowG1O.x = m_crossBarO.x; m_arrowG1Oy = m_crossBarOy; m_arrowG1O.y = m_crossBarO.y; m_arrowG1Fx = m_crossBarOx + arrow_up_X; m_arrowG1F.x = m_crossBarO.x + arrow_up_X; m_arrowG1Fy = m_crossBarOy + arrow_up_Y; m_arrowG1F.y = m_crossBarO.y + arrow_up_Y; m_arrowG2Ox = m_crossBarOx; m_arrowG2O.x = m_crossBarO.x; m_arrowG2Oy = m_crossBarOy; m_arrowG2O.y = m_crossBarO.y; m_arrowG2Fx = m_crossBarOx + arrow_dw_X; m_arrowG2F.x = m_crossBarO.x + arrow_dw_X; m_arrowG2Fy = m_crossBarOy + arrow_dw_Y; m_arrowG2F.y = m_crossBarO.y + arrow_dw_Y; /* The right arrow is symmetrical to the left. /* The right arrow is symmetrical to the left. * / = -\ and \ = -/ * / = -\ and \ = -/ */ */ m_arrowD1Ox = m_crossBarFx; m_arrowD1O.x = m_crossBarF.x; m_arrowD1Oy = m_crossBarFy; m_arrowD1O.y = m_crossBarF.y; m_arrowD1Fx = m_crossBarFx - arrow_dw_X; m_arrowD1F.x = m_crossBarF.x - arrow_dw_X; m_arrowD1Fy = m_crossBarFy - arrow_dw_Y; m_arrowD1F.y = m_crossBarF.y - arrow_dw_Y; m_arrowD2Ox = m_crossBarFx; m_arrowD2O.x = m_crossBarF.x; m_arrowD2Oy = m_crossBarFy; m_arrowD2O.y = m_crossBarF.y; m_arrowD2Fx = m_crossBarFx - arrow_up_X; m_arrowD2F.x = m_crossBarF.x - arrow_up_X; m_arrowD2Fy = m_crossBarFy - arrow_up_Y; m_arrowD2F.y = m_crossBarF.y - arrow_up_Y; m_featureLineGFx = m_crossBarOx + hx; m_featureLineGF.x = m_crossBarO.x + hx; m_featureLineGFy = m_crossBarOy + hy; m_featureLineGF.y = m_crossBarO.y + hy; m_featureLineDFx = m_crossBarFx + hx; m_featureLineDF.x = m_crossBarF.x + hx; m_featureLineDFy = m_crossBarFy + hy; m_featureLineDF.y = m_crossBarF.y + hy; // Calculate the better text position and orientation: // Calculate the better text position and orientation: m_Pos.x = m_Text.m_Pos.x = (m_crossBarFx + m_featureLineGFx) / 2; m_Text.m_Pos.x = (m_crossBarF.x + m_featureLineGF.x) / 2; m_Pos.y = m_Text.m_Pos.y = (m_crossBarFy + m_featureLineGFy) / 2; m_Text.m_Pos.y = (m_crossBarF.y + m_featureLineGF.y) / 2; double newAngle = -(angle * 1800 / M_PI); double newAngle = -(angle * 1800 / M_PI); if( newAngle < 0 ) if( newAngle < 0 ) newAngle += 3600; newAngle += 3600; Loading @@ -354,19 +328,15 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, const wxPoint& offset ) const wxPoint& offset ) { { int ox, oy, typeaff, width; int typeaff, width; EDA_COLOR_T gcolor; EDA_COLOR_T gcolor; ox = -offset.x; oy = -offset.y; m_Text.Draw( panel, DC, mode_color, offset ); BOARD* brd = GetBoard(); BOARD* brd = GetBoard(); if( brd->IsLayerVisible( m_Layer ) == false ) if( brd->IsLayerVisible( m_Layer ) == false ) return; return; m_Text.Draw( panel, DC, mode_color, offset ); gcolor = brd->GetLayerColor( m_Layer ); gcolor = brd->GetLayerColor( m_Layer ); GRSetDrawMode( DC, mode_color ); GRSetDrawMode( DC, mode_color ); Loading @@ -382,58 +352,37 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, width = 0; width = 0; case FILLED: case FILLED: GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC, m_crossBarO + offset, m_crossBarOx - ox, m_crossBarOy - oy, m_crossBarF + offset, width, gcolor ); m_crossBarFx - ox, m_crossBarFy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_featureLineGO + offset, GRLine( panel->GetClipBox(), DC, m_featureLineGF + offset, width, gcolor ); m_featureLineGOx - ox, m_featureLineGOy - oy, GRLine( panel->GetClipBox(), DC, m_featureLineDO + offset, m_featureLineGFx - ox, m_featureLineGFy - oy, width, gcolor ); m_featureLineDF + offset, width, gcolor ); GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC, m_arrowD1O + offset, m_featureLineDOx - ox, m_featureLineDOy - oy, m_arrowD1F + offset, width, gcolor ); m_featureLineDFx - ox, m_featureLineDFy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_arrowD2O + offset, GRLine( panel->GetClipBox(), DC, m_arrowD2F + offset, width, gcolor ); m_arrowD1Ox - ox, m_arrowD1Oy - oy, GRLine( panel->GetClipBox(), DC, m_arrowG1O + offset, m_arrowD1Fx - ox, m_arrowD1Fy - oy, width, gcolor ); m_arrowG1F + offset, width, gcolor ); GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC, m_arrowG2O + offset, m_arrowD2Ox - ox, m_arrowD2Oy - oy, m_arrowG2F + offset, width, gcolor ); m_arrowD2Fx - ox, m_arrowD2Fy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_arrowG1Ox - ox, m_arrowG1Oy - oy, m_arrowG1Fx - ox, m_arrowG1Fy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_arrowG2Ox - ox, m_arrowG2Oy - oy, m_arrowG2Fx - ox, m_arrowG2Fy - oy, width, gcolor ); break; break; case SKETCH: case SKETCH: GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset, m_crossBarOx - ox, m_crossBarOy - oy, m_crossBarF + offset, width, gcolor ); m_crossBarFx - ox, m_crossBarFy - oy, GRCSegm( panel->GetClipBox(), DC, m_featureLineGO + offset, width, gcolor ); m_featureLineGF + offset, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_featureLineDO + offset, m_featureLineGOx - ox, m_featureLineGOy - oy, m_featureLineDF + offset, width, gcolor ); m_featureLineGFx - ox, m_featureLineGFy - oy, GRCSegm( panel->GetClipBox(), DC, m_arrowD1O + offset, width, gcolor ); m_arrowD1F + offset, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_arrowD2O + offset, m_featureLineDOx - ox, m_featureLineDOy - oy, m_arrowD2F + offset, width, gcolor ); m_featureLineDFx - ox, m_featureLineDFy - oy, GRCSegm( panel->GetClipBox(), DC, m_arrowG1O + offset, width, gcolor ); m_arrowG1F + offset, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_arrowG2O + offset, m_arrowD1Ox - ox, m_arrowD1Oy - oy, m_arrowG2F + offset, width, gcolor ); m_arrowD1Fx - ox, m_arrowD1Fy - oy, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, m_arrowD2Ox - ox, m_arrowD2Oy - oy, m_arrowD2Fx - ox, m_arrowD2Fy - oy, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, m_arrowG1Ox - ox, m_arrowG1Oy - oy, m_arrowG1Fx - ox, m_arrowG1Fy - oy, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, m_arrowG2Ox - ox, m_arrowG2Oy - oy, m_arrowG2Fx - ox, m_arrowG2Fy - oy, width, gcolor ); break; break; } } } } Loading @@ -456,12 +405,12 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) return true; return true; // Locate SEGMENTS? // Locate SEGMENTS? ux0 = m_crossBarOx; ux0 = m_crossBarO.x; uy0 = m_crossBarOy; uy0 = m_crossBarO.y; // Recalculate coordinates with ux0, uy0 = origin. // Recalculate coordinates with ux0, uy0 = origin. dx = m_crossBarFx - ux0; dx = m_crossBarF.x - ux0; dy = m_crossBarFy - uy0; dy = m_crossBarF.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -469,11 +418,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_featureLineGOx; ux0 = m_featureLineGO.x; uy0 = m_featureLineGOy; uy0 = m_featureLineGO.y; dx = m_featureLineGFx - ux0; dx = m_featureLineGF.x - ux0; dy = m_featureLineGFy - uy0; dy = m_featureLineGF.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -481,11 +430,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_featureLineDOx; ux0 = m_featureLineDO.x; uy0 = m_featureLineDOy; uy0 = m_featureLineDO.y; dx = m_featureLineDFx - ux0; dx = m_featureLineDF.x - ux0; dy = m_featureLineDFy - uy0; dy = m_featureLineDF.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -493,11 +442,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowD1Ox; ux0 = m_arrowD1O.x; uy0 = m_arrowD1Oy; uy0 = m_arrowD1O.y; dx = m_arrowD1Fx - ux0; dx = m_arrowD1F.x - ux0; dy = m_arrowD1Fy - uy0; dy = m_arrowD1F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -505,11 +454,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowD2Ox; ux0 = m_arrowD2O.x; uy0 = m_arrowD2Oy; uy0 = m_arrowD2O.y; dx = m_arrowD2Fx - ux0; dx = m_arrowD2F.x - ux0; dy = m_arrowD2Fy - uy0; dy = m_arrowD2F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -517,11 +466,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowG1Ox; ux0 = m_arrowG1O.x; uy0 = m_arrowG1Oy; uy0 = m_arrowG1O.y; dx = m_arrowG1Fx - ux0; dx = m_arrowG1F.x - ux0; dy = m_arrowG1Fy - uy0; dy = m_arrowG1F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -529,11 +478,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowG2Ox; ux0 = m_arrowG2O.x; uy0 = m_arrowG2Oy; uy0 = m_arrowG2O.y; dx = m_arrowG2Fx - ux0; dx = m_arrowG2F.x - ux0; dy = m_arrowG2Fy - uy0; dy = m_arrowG2F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -547,7 +496,7 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) bool DIMENSION::HitTest( const EDA_RECT& aRect ) const bool DIMENSION::HitTest( const EDA_RECT& aRect ) const { { if( aRect.Contains( m_Pos ) ) if( aRect.Contains( GetPosition() ) ) return true; return true; return false; return false; Loading @@ -565,23 +514,23 @@ EDA_RECT DIMENSION::GetBoundingBox() const ymin = bBox.GetY(); ymin = bBox.GetY(); ymax = bBox.GetBottom(); ymax = bBox.GetBottom(); xmin = std::min( xmin, m_crossBarOx ); xmin = std::min( xmin, m_crossBarO.x ); xmin = std::min( xmin, m_crossBarFx ); xmin = std::min( xmin, m_crossBarF.x ); ymin = std::min( ymin, m_crossBarOy ); ymin = std::min( ymin, m_crossBarO.y ); ymin = std::min( ymin, m_crossBarFy ); ymin = std::min( ymin, m_crossBarF.y ); xmax = std::max( xmax, m_crossBarOx ); xmax = std::max( xmax, m_crossBarO.x ); xmax = std::max( xmax, m_crossBarFx ); xmax = std::max( xmax, m_crossBarF.x ); ymax = std::max( ymax, m_crossBarOy ); ymax = std::max( ymax, m_crossBarO.y ); ymax = std::max( ymax, m_crossBarFy ); ymax = std::max( ymax, m_crossBarF.y ); xmin = std::min( xmin, m_featureLineGOx ); xmin = std::min( xmin, m_featureLineGO.x ); xmin = std::min( xmin, m_featureLineGFx ); xmin = std::min( xmin, m_featureLineGF.x ); ymin = std::min( ymin, m_featureLineGOy ); ymin = std::min( ymin, m_featureLineGO.y ); ymin = std::min( ymin, m_featureLineGFy ); ymin = std::min( ymin, m_featureLineGF.y ); xmax = std::max( xmax, m_featureLineGOx ); xmax = std::max( xmax, m_featureLineGO.x ); xmax = std::max( xmax, m_featureLineGFx ); xmax = std::max( xmax, m_featureLineGF.x ); ymax = std::max( ymax, m_featureLineGOy ); ymax = std::max( ymax, m_featureLineGO.y ); ymax = std::max( ymax, m_featureLineGFy ); ymax = std::max( ymax, m_featureLineGF.y ); bBox.SetX( xmin ); bBox.SetX( xmin ); bBox.SetY( ymin ); bBox.SetY( ymin ); Loading pcbnew/class_dimension.h +38 −38 Original line number Original line Diff line number Diff line Loading @@ -44,20 +44,20 @@ class DIMENSION : public BOARD_ITEM { { public: public: int m_Width; int m_Width; wxPoint m_Pos; int m_Shape; // / Currently always 0. int m_Shape; /// Current always 0. int m_Unit; // / 0 = inches, 1 = mm int m_Unit; // / 0 = inches, 1 = mm int m_Value; // / value of PCB dimensions. int m_Value; // / value of PCB dimensions. TEXTE_PCB m_Text; TEXTE_PCB m_Text; int m_crossBarOx, m_crossBarOy, m_crossBarFx, m_crossBarFy; int m_featureLineGOx, m_featureLineGOy, m_featureLineGFx, m_featureLineGFy; int m_featureLineDOx, m_featureLineDOy, m_featureLineDFx, m_featureLineDFy; int m_arrowD1Ox, m_arrowD1Oy, m_arrowD1Fx, m_arrowD1Fy; int m_arrowD2Ox, m_arrowD2Oy, m_arrowD2Fx, m_arrowD2Fy; int m_arrowG1Ox, m_arrowG1Oy, m_arrowG1Fx, m_arrowG1Fy; int m_arrowG2Ox, m_arrowG2Oy, m_arrowG2Fx, m_arrowG2Fy; // private: These member should be private. they are public only due to legacy code wxPoint m_crossBarO, m_crossBarF; wxPoint m_featureLineGO, m_featureLineGF; wxPoint m_featureLineDO, m_featureLineDF; wxPoint m_arrowD1O, m_arrowD1F; wxPoint m_arrowD2O, m_arrowD2F; wxPoint m_arrowG1O, m_arrowG1F; wxPoint m_arrowG2O, m_arrowG2F; public: public: DIMENSION( BOARD_ITEM* aParent ); DIMENSION( BOARD_ITEM* aParent ); Loading @@ -65,7 +65,7 @@ public: ~DIMENSION(); ~DIMENSION(); const wxPoint& GetPosition() const { return m_Pos; } const wxPoint& GetPosition() const; void SetPosition( const wxPoint& aPos ); // override, sets m_Text's position too void SetPosition( const wxPoint& aPos ); // override, sets m_Text's position too Loading Loading
pcbnew/class_dimension.cpp +199 −250 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : m_Text( this ) m_Text( this ) { { m_Layer = DRAW_LAYER; m_Layer = DRAW_LAYER; m_Width = 50; m_Width = Millimeter2iu( 0.2 ); m_Value = 0; m_Value = 0; m_Shape = 0; m_Shape = 0; m_Unit = INCHES; m_Unit = INCHES; Loading @@ -64,11 +64,16 @@ DIMENSION::~DIMENSION() void DIMENSION::SetPosition( const wxPoint& aPos ) void DIMENSION::SetPosition( const wxPoint& aPos ) { { m_Pos = aPos; m_Text.SetPos( aPos ); m_Text.SetPos( aPos ); } } const wxPoint& DIMENSION::GetPosition() const { return m_Text.GetPosition(); } void DIMENSION::SetText( const wxString& aNewText ) void DIMENSION::SetText( const wxString& aNewText ) { { m_Text.SetText( aNewText ); m_Text.SetText( aNewText ); Loading @@ -93,82 +98,50 @@ void DIMENSION::Copy( DIMENSION* source ) m_Value = source->m_Value; m_Value = source->m_Value; SetLayer( source->GetLayer() ); SetLayer( source->GetLayer() ); m_Width = source->m_Width; m_Width = source->m_Width; m_Pos = source->m_Pos; m_Shape = source->m_Shape; m_Shape = source->m_Shape; m_Unit = source->m_Unit; m_Unit = source->m_Unit; SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() ); m_Text.Copy( &source->m_Text ); m_Text.Copy( &source->m_Text ); m_crossBarOx = source->m_crossBarOx; m_crossBarO = source->m_crossBarO; m_crossBarOy = source->m_crossBarOy; m_crossBarF = source->m_crossBarF; m_crossBarFx = source->m_crossBarFx; m_featureLineGO = source->m_featureLineGO; m_crossBarFy = source->m_crossBarFy; m_featureLineGF = source->m_featureLineGF; m_featureLineGOx = source->m_featureLineGOx; m_featureLineDO = source->m_featureLineDO; m_featureLineGOy = source->m_featureLineGOy; m_featureLineDF = source->m_featureLineDF; m_featureLineGFx = source->m_featureLineGFx; m_arrowD1O = source->m_arrowD1O; m_featureLineGFy = source->m_featureLineGFy; m_arrowD1F = source->m_arrowD1F; m_featureLineDOx = source->m_featureLineDOx; m_arrowD2O = source->m_arrowD2O; m_featureLineDOy = source->m_featureLineDOy; m_arrowD2F = source->m_arrowD2F; m_featureLineDFx = source->m_featureLineDFx; m_arrowG1O = source->m_arrowG1O; m_featureLineDFy = source->m_featureLineDFy; m_arrowG1F = source->m_arrowG1F; m_arrowD1Ox = source->m_arrowD1Ox; m_arrowG2O = source->m_arrowG2O; m_arrowD1Oy = source->m_arrowD1Oy; m_arrowG2F = source->m_arrowG2F; m_arrowD1Fx = source->m_arrowD1Fx; m_arrowD1Fy = source->m_arrowD1Fy; m_arrowD2Ox = source->m_arrowD2Ox; m_arrowD2Oy = source->m_arrowD2Oy; m_arrowD2Fx = source->m_arrowD2Fx; m_arrowD2Fy = source->m_arrowD2Fy; m_arrowG1Ox = source->m_arrowG1Ox; m_arrowG1Oy = source->m_arrowG1Oy; m_arrowG1Fx = source->m_arrowG1Fx; m_arrowG1Fy = source->m_arrowG1Fy; m_arrowG2Ox = source->m_arrowG2Ox; m_arrowG2Oy = source->m_arrowG2Oy; m_arrowG2Fx = source->m_arrowG2Fx; m_arrowG2Fy = source->m_arrowG2Fy; } } void DIMENSION::Move( const wxPoint& offset ) void DIMENSION::Move( const wxPoint& offset ) { { m_Pos += offset; m_Text.m_Pos += offset; m_Text.m_Pos += offset; m_crossBarOx += offset.x; m_crossBarO += offset; m_crossBarOy += offset.y; m_crossBarF += offset; m_crossBarFx += offset.x; m_featureLineGO += offset; m_crossBarFy += offset.y; m_featureLineGF += offset; m_featureLineGOx += offset.x; m_featureLineDO += offset; m_featureLineGOy += offset.y; m_featureLineDF += offset; m_featureLineGFx += offset.x; m_arrowG1O += offset; m_featureLineGFy += offset.y; m_arrowG1F += offset; m_featureLineDOx += offset.x; m_arrowG2O += offset; m_featureLineDOy += offset.y; m_arrowG2F += offset; m_featureLineDFx += offset.x; m_arrowD1O += offset; m_featureLineDFy += offset.y; m_arrowD1F += offset; m_arrowG1Ox += offset.x; m_arrowD2O += offset; m_arrowG1Oy += offset.y; m_arrowD2F += offset; m_arrowG1Fx += offset.x; m_arrowG1Fy += offset.y; m_arrowG2Ox += offset.x; m_arrowG2Oy += offset.y; m_arrowG2Fx += offset.x; m_arrowG2Fy += offset.y; m_arrowD1Ox += offset.x; m_arrowD1Oy += offset.y; m_arrowD1Fx += offset.x; m_arrowD1Fy += offset.y; m_arrowD2Ox += offset.x; m_arrowD2Oy += offset.y; m_arrowD2Fx += offset.x; m_arrowD2Fy += offset.y; } } void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) { { RotatePoint( &m_Pos, aRotCentre, aAngle ); RotatePoint( &m_Text.m_Pos, aRotCentre, aAngle ); RotatePoint( &m_Text.m_Pos, aRotCentre, aAngle ); double newAngle = m_Text.GetOrientation() + aAngle; double newAngle = m_Text.GetOrientation() + aAngle; Loading @@ -181,20 +154,20 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) m_Text.SetOrientation( newAngle ); m_Text.SetOrientation( newAngle ); RotatePoint( &m_crossBarOx, &m_crossBarOy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_crossBarO, aRotCentre, aAngle ); RotatePoint( &m_crossBarFx, &m_crossBarFy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_crossBarF, aRotCentre, aAngle ); RotatePoint( &m_featureLineGOx, &m_featureLineGOy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineGO, aRotCentre, aAngle ); RotatePoint( &m_featureLineGFx, &m_featureLineGFy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineGF, aRotCentre, aAngle ); RotatePoint( &m_featureLineDOx, &m_featureLineDOy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineDO, aRotCentre, aAngle ); RotatePoint( &m_featureLineDFx, &m_featureLineDFy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_featureLineDF, aRotCentre, aAngle ); RotatePoint( &m_arrowG1Ox, &m_arrowG1Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG1O, aRotCentre, aAngle ); RotatePoint( &m_arrowG1Fx, &m_arrowG1Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG1F, aRotCentre, aAngle ); RotatePoint( &m_arrowG2Ox, &m_arrowG2Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG2O, aRotCentre, aAngle ); RotatePoint( &m_arrowG2Fx, &m_arrowG2Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowG2F, aRotCentre, aAngle ); RotatePoint( &m_arrowD1Ox, &m_arrowD1Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD1O, aRotCentre, aAngle ); RotatePoint( &m_arrowD1Fx, &m_arrowD1Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD1F, aRotCentre, aAngle ); RotatePoint( &m_arrowD2Ox, &m_arrowD2Oy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD2O, aRotCentre, aAngle ); RotatePoint( &m_arrowD2Fx, &m_arrowD2Fy, aRotCentre.x, aRotCentre.y, aAngle ); RotatePoint( &m_arrowD2F, aRotCentre, aAngle ); } } Loading @@ -208,11 +181,11 @@ void DIMENSION::Flip( const wxPoint& aCentre ) void DIMENSION::Mirror( const wxPoint& axis_pos ) void DIMENSION::Mirror( const wxPoint& axis_pos ) { { #define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) #define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) INVERT( m_Pos.y ); INVERT( m_Text.m_Pos.y ); INVERT( m_Text.m_Pos.y ); // invert angle // invert angle double newAngle = m_Text.GetOrientation(); double newAngle = m_Text.GetOrientation(); if( newAngle >= 3600 ) if( newAngle >= 3600 ) newAngle -= 3600; newAngle -= 3600; Loading @@ -221,20 +194,20 @@ void DIMENSION::Mirror( const wxPoint& axis_pos ) m_Text.SetOrientation( newAngle ); m_Text.SetOrientation( newAngle ); INVERT( m_crossBarOy ); INVERT( m_crossBarO.y ); INVERT( m_crossBarFy ); INVERT( m_crossBarF.y ); INVERT( m_featureLineGOy ); INVERT( m_featureLineGO.y ); INVERT( m_featureLineGFy ); INVERT( m_featureLineGF.y ); INVERT( m_featureLineDOy ); INVERT( m_featureLineDO.y ); INVERT( m_featureLineDFy ); INVERT( m_featureLineDF.y ); INVERT( m_arrowG1Oy ); INVERT( m_arrowG1O.y ); INVERT( m_arrowG1Fy ); INVERT( m_arrowG1F.y ); INVERT( m_arrowG2Oy ); INVERT( m_arrowG2O.y ); INVERT( m_arrowG2Fy ); INVERT( m_arrowG2F.y ); INVERT( m_arrowD1Oy ); INVERT( m_arrowD1O.y ); INVERT( m_arrowD1Fy ); INVERT( m_arrowD1F.y ); INVERT( m_arrowD2Oy ); INVERT( m_arrowD2O.y ); INVERT( m_arrowD2Fy ); INVERT( m_arrowD2F.y ); } } Loading @@ -256,8 +229,8 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) ii = m_Text.m_Size.y + ii = m_Text.m_Size.y + m_Text.GetThickness() + (m_Width * 3); m_Text.GetThickness() + (m_Width * 3); deltax = m_featureLineDOx - m_featureLineGOx; deltax = m_featureLineDO.x - m_featureLineGO.x; deltay = m_featureLineDOy - m_featureLineGOy; deltay = m_featureLineDO.y - m_featureLineGO.y; // Calculate dimension value // Calculate dimension value measure = KiROUND( hypot( (double) deltax, (double) deltay ) ); measure = KiROUND( hypot( (double) deltax, (double) deltay ) ); Loading @@ -276,16 +249,16 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) hx = (abs) ( (int) ( ( (double) deltay * hx ) / measure ) ); hx = (abs) ( (int) ( ( (double) deltay * hx ) / measure ) ); hy = (abs) ( (int) ( ( (double) deltax * hy ) / measure ) ); hy = (abs) ( (int) ( ( (double) deltax * hy ) / measure ) ); if( m_featureLineGOx > m_crossBarOx ) if( m_featureLineGO.x > m_crossBarO.x ) hx = -hx; hx = -hx; if( m_featureLineGOx == m_crossBarOx ) if( m_featureLineGO.x == m_crossBarO.x ) hx = 0; hx = 0; if( m_featureLineGOy > m_crossBarOy ) if( m_featureLineGO.y > m_crossBarO.y ) hy = -hy; hy = -hy; if( m_featureLineGOy == m_crossBarOy ) if( m_featureLineGO.y == m_crossBarO.y ) hy = 0; hy = 0; angle_f = angle + (M_PI * 27.5 / 180); angle_f = angle + (M_PI * 27.5 / 180); Loading @@ -296,41 +269,42 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) arrow_dw_Y = (int) ( arrowz * sin( angle_f ) ); arrow_dw_Y = (int) ( arrowz * sin( angle_f ) ); } } m_arrowG1Ox = m_crossBarOx; m_arrowG1O.x = m_crossBarO.x; m_arrowG1Oy = m_crossBarOy; m_arrowG1O.y = m_crossBarO.y; m_arrowG1Fx = m_crossBarOx + arrow_up_X; m_arrowG1F.x = m_crossBarO.x + arrow_up_X; m_arrowG1Fy = m_crossBarOy + arrow_up_Y; m_arrowG1F.y = m_crossBarO.y + arrow_up_Y; m_arrowG2Ox = m_crossBarOx; m_arrowG2O.x = m_crossBarO.x; m_arrowG2Oy = m_crossBarOy; m_arrowG2O.y = m_crossBarO.y; m_arrowG2Fx = m_crossBarOx + arrow_dw_X; m_arrowG2F.x = m_crossBarO.x + arrow_dw_X; m_arrowG2Fy = m_crossBarOy + arrow_dw_Y; m_arrowG2F.y = m_crossBarO.y + arrow_dw_Y; /* The right arrow is symmetrical to the left. /* The right arrow is symmetrical to the left. * / = -\ and \ = -/ * / = -\ and \ = -/ */ */ m_arrowD1Ox = m_crossBarFx; m_arrowD1O.x = m_crossBarF.x; m_arrowD1Oy = m_crossBarFy; m_arrowD1O.y = m_crossBarF.y; m_arrowD1Fx = m_crossBarFx - arrow_dw_X; m_arrowD1F.x = m_crossBarF.x - arrow_dw_X; m_arrowD1Fy = m_crossBarFy - arrow_dw_Y; m_arrowD1F.y = m_crossBarF.y - arrow_dw_Y; m_arrowD2Ox = m_crossBarFx; m_arrowD2O.x = m_crossBarF.x; m_arrowD2Oy = m_crossBarFy; m_arrowD2O.y = m_crossBarF.y; m_arrowD2Fx = m_crossBarFx - arrow_up_X; m_arrowD2F.x = m_crossBarF.x - arrow_up_X; m_arrowD2Fy = m_crossBarFy - arrow_up_Y; m_arrowD2F.y = m_crossBarF.y - arrow_up_Y; m_featureLineGFx = m_crossBarOx + hx; m_featureLineGF.x = m_crossBarO.x + hx; m_featureLineGFy = m_crossBarOy + hy; m_featureLineGF.y = m_crossBarO.y + hy; m_featureLineDFx = m_crossBarFx + hx; m_featureLineDF.x = m_crossBarF.x + hx; m_featureLineDFy = m_crossBarFy + hy; m_featureLineDF.y = m_crossBarF.y + hy; // Calculate the better text position and orientation: // Calculate the better text position and orientation: m_Pos.x = m_Text.m_Pos.x = (m_crossBarFx + m_featureLineGFx) / 2; m_Text.m_Pos.x = (m_crossBarF.x + m_featureLineGF.x) / 2; m_Pos.y = m_Text.m_Pos.y = (m_crossBarFy + m_featureLineGFy) / 2; m_Text.m_Pos.y = (m_crossBarF.y + m_featureLineGF.y) / 2; double newAngle = -(angle * 1800 / M_PI); double newAngle = -(angle * 1800 / M_PI); if( newAngle < 0 ) if( newAngle < 0 ) newAngle += 3600; newAngle += 3600; Loading @@ -354,19 +328,15 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, const wxPoint& offset ) const wxPoint& offset ) { { int ox, oy, typeaff, width; int typeaff, width; EDA_COLOR_T gcolor; EDA_COLOR_T gcolor; ox = -offset.x; oy = -offset.y; m_Text.Draw( panel, DC, mode_color, offset ); BOARD* brd = GetBoard(); BOARD* brd = GetBoard(); if( brd->IsLayerVisible( m_Layer ) == false ) if( brd->IsLayerVisible( m_Layer ) == false ) return; return; m_Text.Draw( panel, DC, mode_color, offset ); gcolor = brd->GetLayerColor( m_Layer ); gcolor = brd->GetLayerColor( m_Layer ); GRSetDrawMode( DC, mode_color ); GRSetDrawMode( DC, mode_color ); Loading @@ -382,58 +352,37 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, width = 0; width = 0; case FILLED: case FILLED: GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC, m_crossBarO + offset, m_crossBarOx - ox, m_crossBarOy - oy, m_crossBarF + offset, width, gcolor ); m_crossBarFx - ox, m_crossBarFy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_featureLineGO + offset, GRLine( panel->GetClipBox(), DC, m_featureLineGF + offset, width, gcolor ); m_featureLineGOx - ox, m_featureLineGOy - oy, GRLine( panel->GetClipBox(), DC, m_featureLineDO + offset, m_featureLineGFx - ox, m_featureLineGFy - oy, width, gcolor ); m_featureLineDF + offset, width, gcolor ); GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC, m_arrowD1O + offset, m_featureLineDOx - ox, m_featureLineDOy - oy, m_arrowD1F + offset, width, gcolor ); m_featureLineDFx - ox, m_featureLineDFy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_arrowD2O + offset, GRLine( panel->GetClipBox(), DC, m_arrowD2F + offset, width, gcolor ); m_arrowD1Ox - ox, m_arrowD1Oy - oy, GRLine( panel->GetClipBox(), DC, m_arrowG1O + offset, m_arrowD1Fx - ox, m_arrowD1Fy - oy, width, gcolor ); m_arrowG1F + offset, width, gcolor ); GRLine( panel->GetClipBox(), DC, GRLine( panel->GetClipBox(), DC, m_arrowG2O + offset, m_arrowD2Ox - ox, m_arrowD2Oy - oy, m_arrowG2F + offset, width, gcolor ); m_arrowD2Fx - ox, m_arrowD2Fy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_arrowG1Ox - ox, m_arrowG1Oy - oy, m_arrowG1Fx - ox, m_arrowG1Fy - oy, width, gcolor ); GRLine( panel->GetClipBox(), DC, m_arrowG2Ox - ox, m_arrowG2Oy - oy, m_arrowG2Fx - ox, m_arrowG2Fy - oy, width, gcolor ); break; break; case SKETCH: case SKETCH: GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset, m_crossBarOx - ox, m_crossBarOy - oy, m_crossBarF + offset, width, gcolor ); m_crossBarFx - ox, m_crossBarFy - oy, GRCSegm( panel->GetClipBox(), DC, m_featureLineGO + offset, width, gcolor ); m_featureLineGF + offset, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_featureLineDO + offset, m_featureLineGOx - ox, m_featureLineGOy - oy, m_featureLineDF + offset, width, gcolor ); m_featureLineGFx - ox, m_featureLineGFy - oy, GRCSegm( panel->GetClipBox(), DC, m_arrowD1O + offset, width, gcolor ); m_arrowD1F + offset, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_arrowD2O + offset, m_featureLineDOx - ox, m_featureLineDOy - oy, m_arrowD2F + offset, width, gcolor ); m_featureLineDFx - ox, m_featureLineDFy - oy, GRCSegm( panel->GetClipBox(), DC, m_arrowG1O + offset, width, gcolor ); m_arrowG1F + offset, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, GRCSegm( panel->GetClipBox(), DC, m_arrowG2O + offset, m_arrowD1Ox - ox, m_arrowD1Oy - oy, m_arrowG2F + offset, width, gcolor ); m_arrowD1Fx - ox, m_arrowD1Fy - oy, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, m_arrowD2Ox - ox, m_arrowD2Oy - oy, m_arrowD2Fx - ox, m_arrowD2Fy - oy, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, m_arrowG1Ox - ox, m_arrowG1Oy - oy, m_arrowG1Fx - ox, m_arrowG1Fy - oy, width, gcolor ); GRCSegm( panel->GetClipBox(), DC, m_arrowG2Ox - ox, m_arrowG2Oy - oy, m_arrowG2Fx - ox, m_arrowG2Fy - oy, width, gcolor ); break; break; } } } } Loading @@ -456,12 +405,12 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) return true; return true; // Locate SEGMENTS? // Locate SEGMENTS? ux0 = m_crossBarOx; ux0 = m_crossBarO.x; uy0 = m_crossBarOy; uy0 = m_crossBarO.y; // Recalculate coordinates with ux0, uy0 = origin. // Recalculate coordinates with ux0, uy0 = origin. dx = m_crossBarFx - ux0; dx = m_crossBarF.x - ux0; dy = m_crossBarFy - uy0; dy = m_crossBarF.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -469,11 +418,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_featureLineGOx; ux0 = m_featureLineGO.x; uy0 = m_featureLineGOy; uy0 = m_featureLineGO.y; dx = m_featureLineGFx - ux0; dx = m_featureLineGF.x - ux0; dy = m_featureLineGFy - uy0; dy = m_featureLineGF.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -481,11 +430,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_featureLineDOx; ux0 = m_featureLineDO.x; uy0 = m_featureLineDOy; uy0 = m_featureLineDO.y; dx = m_featureLineDFx - ux0; dx = m_featureLineDF.x - ux0; dy = m_featureLineDFy - uy0; dy = m_featureLineDF.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -493,11 +442,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowD1Ox; ux0 = m_arrowD1O.x; uy0 = m_arrowD1Oy; uy0 = m_arrowD1O.y; dx = m_arrowD1Fx - ux0; dx = m_arrowD1F.x - ux0; dy = m_arrowD1Fy - uy0; dy = m_arrowD1F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -505,11 +454,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowD2Ox; ux0 = m_arrowD2O.x; uy0 = m_arrowD2Oy; uy0 = m_arrowD2O.y; dx = m_arrowD2Fx - ux0; dx = m_arrowD2F.x - ux0; dy = m_arrowD2Fy - uy0; dy = m_arrowD2F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -517,11 +466,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowG1Ox; ux0 = m_arrowG1O.x; uy0 = m_arrowG1Oy; uy0 = m_arrowG1O.y; dx = m_arrowG1Fx - ux0; dx = m_arrowG1F.x - ux0; dy = m_arrowG1Fy - uy0; dy = m_arrowG1F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -529,11 +478,11 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) ) return true; return true; ux0 = m_arrowG2Ox; ux0 = m_arrowG2O.x; uy0 = m_arrowG2Oy; uy0 = m_arrowG2O.y; dx = m_arrowG2Fx - ux0; dx = m_arrowG2F.x - ux0; dy = m_arrowG2Fy - uy0; dy = m_arrowG2F.y - uy0; spot_cX = aPosition.x - ux0; spot_cX = aPosition.x - ux0; spot_cY = aPosition.y - uy0; spot_cY = aPosition.y - uy0; Loading @@ -547,7 +496,7 @@ bool DIMENSION::HitTest( const wxPoint& aPosition ) bool DIMENSION::HitTest( const EDA_RECT& aRect ) const bool DIMENSION::HitTest( const EDA_RECT& aRect ) const { { if( aRect.Contains( m_Pos ) ) if( aRect.Contains( GetPosition() ) ) return true; return true; return false; return false; Loading @@ -565,23 +514,23 @@ EDA_RECT DIMENSION::GetBoundingBox() const ymin = bBox.GetY(); ymin = bBox.GetY(); ymax = bBox.GetBottom(); ymax = bBox.GetBottom(); xmin = std::min( xmin, m_crossBarOx ); xmin = std::min( xmin, m_crossBarO.x ); xmin = std::min( xmin, m_crossBarFx ); xmin = std::min( xmin, m_crossBarF.x ); ymin = std::min( ymin, m_crossBarOy ); ymin = std::min( ymin, m_crossBarO.y ); ymin = std::min( ymin, m_crossBarFy ); ymin = std::min( ymin, m_crossBarF.y ); xmax = std::max( xmax, m_crossBarOx ); xmax = std::max( xmax, m_crossBarO.x ); xmax = std::max( xmax, m_crossBarFx ); xmax = std::max( xmax, m_crossBarF.x ); ymax = std::max( ymax, m_crossBarOy ); ymax = std::max( ymax, m_crossBarO.y ); ymax = std::max( ymax, m_crossBarFy ); ymax = std::max( ymax, m_crossBarF.y ); xmin = std::min( xmin, m_featureLineGOx ); xmin = std::min( xmin, m_featureLineGO.x ); xmin = std::min( xmin, m_featureLineGFx ); xmin = std::min( xmin, m_featureLineGF.x ); ymin = std::min( ymin, m_featureLineGOy ); ymin = std::min( ymin, m_featureLineGO.y ); ymin = std::min( ymin, m_featureLineGFy ); ymin = std::min( ymin, m_featureLineGF.y ); xmax = std::max( xmax, m_featureLineGOx ); xmax = std::max( xmax, m_featureLineGO.x ); xmax = std::max( xmax, m_featureLineGFx ); xmax = std::max( xmax, m_featureLineGF.x ); ymax = std::max( ymax, m_featureLineGOy ); ymax = std::max( ymax, m_featureLineGO.y ); ymax = std::max( ymax, m_featureLineGFy ); ymax = std::max( ymax, m_featureLineGF.y ); bBox.SetX( xmin ); bBox.SetX( xmin ); bBox.SetY( ymin ); bBox.SetY( ymin ); Loading
pcbnew/class_dimension.h +38 −38 Original line number Original line Diff line number Diff line Loading @@ -44,20 +44,20 @@ class DIMENSION : public BOARD_ITEM { { public: public: int m_Width; int m_Width; wxPoint m_Pos; int m_Shape; // / Currently always 0. int m_Shape; /// Current always 0. int m_Unit; // / 0 = inches, 1 = mm int m_Unit; // / 0 = inches, 1 = mm int m_Value; // / value of PCB dimensions. int m_Value; // / value of PCB dimensions. TEXTE_PCB m_Text; TEXTE_PCB m_Text; int m_crossBarOx, m_crossBarOy, m_crossBarFx, m_crossBarFy; int m_featureLineGOx, m_featureLineGOy, m_featureLineGFx, m_featureLineGFy; int m_featureLineDOx, m_featureLineDOy, m_featureLineDFx, m_featureLineDFy; int m_arrowD1Ox, m_arrowD1Oy, m_arrowD1Fx, m_arrowD1Fy; int m_arrowD2Ox, m_arrowD2Oy, m_arrowD2Fx, m_arrowD2Fy; int m_arrowG1Ox, m_arrowG1Oy, m_arrowG1Fx, m_arrowG1Fy; int m_arrowG2Ox, m_arrowG2Oy, m_arrowG2Fx, m_arrowG2Fy; // private: These member should be private. they are public only due to legacy code wxPoint m_crossBarO, m_crossBarF; wxPoint m_featureLineGO, m_featureLineGF; wxPoint m_featureLineDO, m_featureLineDF; wxPoint m_arrowD1O, m_arrowD1F; wxPoint m_arrowD2O, m_arrowD2F; wxPoint m_arrowG1O, m_arrowG1F; wxPoint m_arrowG2O, m_arrowG2F; public: public: DIMENSION( BOARD_ITEM* aParent ); DIMENSION( BOARD_ITEM* aParent ); Loading @@ -65,7 +65,7 @@ public: ~DIMENSION(); ~DIMENSION(); const wxPoint& GetPosition() const { return m_Pos; } const wxPoint& GetPosition() const; void SetPosition( const wxPoint& aPos ); // override, sets m_Text's position too void SetPosition( const wxPoint& aPos ); // override, sets m_Text's position too Loading