Loading pcbnew/class_dimension.cpp +23 −17 Original line number Original line Diff line number Diff line Loading @@ -47,13 +47,9 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : BOARD_ITEM( aParent, PCB_DIMENSION_T ), BOARD_ITEM( aParent, PCB_DIMENSION_T ), m_Text( this ) m_Width( Millimeter2iu( 0.2 ) ), m_Unit( INCHES ), m_Value( 0 ), m_Height( 0 ), m_Text( this ) { { m_Layer = DRAW_N; m_Layer = DRAW_N; m_Width = Millimeter2iu( 0.2 ); m_Value = 0; m_Shape = 0; m_Unit = INCHES; } } Loading Loading @@ -99,6 +95,7 @@ void DIMENSION::Copy( DIMENSION* source ) SetLayer( source->GetLayer() ); SetLayer( source->GetLayer() ); m_Width = source->m_Width; m_Width = source->m_Width; m_Shape = source->m_Shape; m_Shape = source->m_Shape; m_Height = source->m_Height; 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 ); Loading Loading @@ -195,7 +192,6 @@ void DIMENSION::Mirror( const wxPoint& axis_pos ) void DIMENSION::SetOrigin( const wxPoint& aOrigin ) void DIMENSION::SetOrigin( const wxPoint& aOrigin ) { { m_crossBarO = aOrigin; m_featureLineGO = aOrigin; m_featureLineGO = aOrigin; AdjustDimensionDetails(); AdjustDimensionDetails(); Loading @@ -204,29 +200,32 @@ void DIMENSION::SetOrigin( const wxPoint& aOrigin ) void DIMENSION::SetEnd( const wxPoint& aEnd ) void DIMENSION::SetEnd( const wxPoint& aEnd ) { { m_crossBarF = aEnd; m_featureLineDO = aEnd; m_featureLineDO = aEnd; AdjustDimensionDetails(); AdjustDimensionDetails(); } } void DIMENSION::SetHeight( double aHeight ) void DIMENSION::SetHeight( int aHeight ) { { /* Calculating the direction of travel perpendicular to the selected axis. */ m_Height = aHeight; double angle = GetAngle() + ( M_PI / 2 ); int dx = KiROUND( aHeight * cos( angle ) ); int dy = KiROUND( aHeight * sin( angle ) ); m_crossBarO.x = m_featureLineGO.x + dx; m_crossBarO.y = m_featureLineGO.y + dy; m_crossBarF.x = m_featureLineDO.x + dx; m_crossBarF.y = m_featureLineDO.y + dy; AdjustDimensionDetails(); AdjustDimensionDetails(); } } void DIMENSION::UpdateHeight() { VECTOR2D featureLine( m_crossBarO - m_featureLineGO ); VECTOR2D crossBar( m_featureLineDO - m_featureLineGO ); if( featureLine.Cross( crossBar ) > 0 ) m_Height = -featureLine.EuclideanNorm(); else m_Height = featureLine.EuclideanNorm(); } void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) { { const int arrowz = DMils2iu( 500 ); // size of arrows const int arrowz = DMils2iu( 500 ); // size of arrows Loading Loading @@ -281,6 +280,13 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) arrow_dw_Y = wxRound( arrowz * sin( angle_f ) ); arrow_dw_Y = wxRound( arrowz * sin( angle_f ) ); } } int dx = KiROUND( m_Height * cos( angle + M_PI / 2 ) ); int dy = KiROUND( m_Height * sin( angle + M_PI / 2 ) ); m_crossBarO.x = m_featureLineGO.x + dx; m_crossBarO.y = m_featureLineGO.y + dy; m_crossBarF.x = m_featureLineDO.x + dx; m_crossBarF.y = m_featureLineDO.y + dy; m_arrowG1F.x = m_crossBarO.x + arrow_up_X; m_arrowG1F.x = m_crossBarO.x + arrow_up_X; m_arrowG1F.y = m_crossBarO.y + arrow_up_Y; m_arrowG1F.y = m_crossBarO.y + arrow_up_Y; Loading pcbnew/class_dimension.h +24 −10 Original line number Original line Diff line number Diff line Loading @@ -61,14 +61,13 @@ class MSG_PANEL_ITEM; */ */ class DIMENSION : public BOARD_ITEM class DIMENSION : public BOARD_ITEM { { int m_Width; int m_Width; ///< Line width int m_Shape; // / Currently always 0. int m_Shape; ///< Currently always 0. int m_Unit; // / 0 = inches, 1 = mm EDA_UNITS_T m_Unit; ///< 0 = inches, 1 = mm int m_Value; // / value of PCB dimensions. int m_Value; ///< value of PCB dimensions. int m_Height; ///< length of feature lines TEXTE_PCB m_Text; TEXTE_PCB m_Text; public: public: // TODO private: These member should be private. they are public only due to legacy code // TODO private: These member should be private. they are public only due to legacy code wxPoint m_crossBarO, m_crossBarF; wxPoint m_crossBarO, m_crossBarF; Loading Loading @@ -117,7 +116,7 @@ public: */ */ const wxPoint& GetOrigin() const const wxPoint& GetOrigin() const { { return m_crossBarO; return m_featureLineGO; } } /** /** Loading @@ -133,7 +132,7 @@ public: */ */ const wxPoint& GetEnd() const wxPoint& GetEnd() { { return m_crossBarF; return m_featureLineDO; } } /** /** Loading @@ -141,12 +140,27 @@ public: * Sets the length of feature lines. * Sets the length of feature lines. * @param aHeight is the new height. * @param aHeight is the new height. */ */ void SetHeight( double aHeight ); void SetHeight( int aHeight ); /** * Function GetHeight * Returns the length of feature lines. */ int GetHeight() const { return m_Height; } /** * Function UpdateHeight * Updates stored height basing on points coordinates. */ void UpdateHeight(); /** /** * Function GetAngle * Function GetAngle * Returns angle of the crossbar. * Returns angle of the crossbar. * @return Angle of the crossbar line. * @return Angle of the crossbar line expressed in radians. */ */ double GetAngle() const double GetAngle() const { { Loading pcbnew/pcb_parser.cpp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -1438,6 +1438,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) parseXY( &dimension->m_featureLineDO.x, &dimension->m_featureLineDO.y ); parseXY( &dimension->m_featureLineDO.x, &dimension->m_featureLineDO.y ); parseXY( &dimension->m_featureLineDF.x, &dimension->m_featureLineDF.y ); parseXY( &dimension->m_featureLineDF.x, &dimension->m_featureLineDF.y ); dimension->UpdateHeight(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); break; break; Loading @@ -1451,6 +1452,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) parseXY( &dimension->m_featureLineGO.x, &dimension->m_featureLineGO.y ); parseXY( &dimension->m_featureLineGO.x, &dimension->m_featureLineGO.y ); parseXY( &dimension->m_featureLineGF.x, &dimension->m_featureLineGF.y ); parseXY( &dimension->m_featureLineGF.x, &dimension->m_featureLineGF.y ); dimension->UpdateHeight(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); break; break; Loading @@ -1465,6 +1467,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) parseXY( &dimension->m_crossBarO.x, &dimension->m_crossBarO.y ); parseXY( &dimension->m_crossBarO.x, &dimension->m_crossBarO.y ); parseXY( &dimension->m_crossBarF.x, &dimension->m_crossBarF.y ); parseXY( &dimension->m_crossBarF.x, &dimension->m_crossBarF.y ); dimension->UpdateHeight(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); break; break; Loading pcbnew/tools/edit_points.cpp +37 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,7 @@ bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const { { // Corners of the square // Corners of the EDIT_POINT square VECTOR2I topLeft = GetPosition() - aSize; VECTOR2I topLeft = GetPosition() - aSize; VECTOR2I bottomRight = GetPosition() + aSize; VECTOR2I bottomRight = GetPosition() + aSize; Loading Loading @@ -162,6 +162,42 @@ void EPC_45DEGREE::Apply() } } EPC_LINE::EPC_LINE( EDIT_POINT& aConstrained, EDIT_POINT& aConstrainer ) : EDIT_POINT_CONSTRAINT( aConstrained ), m_constrainer( aConstrainer ) { Update(); } void EPC_LINE::Apply() { VECTOR2I position = m_constrained.GetPosition(); if( std::isfinite( m_coefA ) ) { if( abs( m_coefA ) < 1 ) position.y = m_coefA * position.x + m_coefB; else position.x = ( position.y - m_coefB ) / m_coefA; } else // vertical line { position.x = m_constrainer.GetX(); } m_constrained.SetPosition( position ); } void EPC_LINE::Update() { // Compute line coefficients VECTOR2D delta = m_constrainer.GetPosition() - m_constrained.GetPosition(); m_coefA = delta.y / delta.x; m_coefB = m_constrainer.GetY() - m_coefA * m_constrainer.GetX(); } void EPC_CIRCLE::Apply() void EPC_CIRCLE::Apply() { { VECTOR2I centerToEnd = m_end.GetPosition() - m_center.GetPosition(); VECTOR2I centerToEnd = m_end.GetPosition() - m_center.GetPosition(); Loading pcbnew/tools/edit_points.h +57 −0 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,26 @@ public: return m_position; return m_position; } } /** * Function GetX() * * Returns X coordinate of an EDIT_POINT. */ int GetX() const { return GetPosition().x; } /** * Function GetX() * * Returns Y coordinate of an EDIT_POINT. */ int GetY() const { return GetPosition().y; } /** /** * Function SetPosition() * Function SetPosition() * * Loading Loading @@ -132,6 +152,17 @@ public: m_constraint = aConstraint; m_constraint = aConstraint; } } /** * Function GetConstraint() * * Returns the constraint imposed on an EDIT_POINT. If there are no constraints, NULL is * returned. */ EDIT_POINT_CONSTRAINT* GetConstraint() const { return m_constraint; } /** /** * Function ClearConstraint() * Function ClearConstraint() * * Loading Loading @@ -468,6 +499,32 @@ private: }; }; /** * Class EPC_LINE * * EDIT_POINT_CONSTRAINT that imposes a constraint that a point has to lie on a line (determined * by 2 points). */ class EPC_LINE : public EDIT_POINT_CONSTRAINT { public: EPC_LINE( EDIT_POINT& aConstrained, EDIT_POINT& aConstrainer ); ///> @copydoc EDIT_POINT_CONSTRAINT::Apply() virtual void Apply(); /** * Function Update() * Updates line coefficients that make the constraining line. */ void Update(); private: EDIT_POINT& m_constrainer; ///< Point that imposes the constraint. double m_coefA, m_coefB; }; /** /** * Class EPC_CIRCLE. * Class EPC_CIRCLE. * * Loading Loading
pcbnew/class_dimension.cpp +23 −17 Original line number Original line Diff line number Diff line Loading @@ -47,13 +47,9 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : BOARD_ITEM( aParent, PCB_DIMENSION_T ), BOARD_ITEM( aParent, PCB_DIMENSION_T ), m_Text( this ) m_Width( Millimeter2iu( 0.2 ) ), m_Unit( INCHES ), m_Value( 0 ), m_Height( 0 ), m_Text( this ) { { m_Layer = DRAW_N; m_Layer = DRAW_N; m_Width = Millimeter2iu( 0.2 ); m_Value = 0; m_Shape = 0; m_Unit = INCHES; } } Loading Loading @@ -99,6 +95,7 @@ void DIMENSION::Copy( DIMENSION* source ) SetLayer( source->GetLayer() ); SetLayer( source->GetLayer() ); m_Width = source->m_Width; m_Width = source->m_Width; m_Shape = source->m_Shape; m_Shape = source->m_Shape; m_Height = source->m_Height; 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 ); Loading Loading @@ -195,7 +192,6 @@ void DIMENSION::Mirror( const wxPoint& axis_pos ) void DIMENSION::SetOrigin( const wxPoint& aOrigin ) void DIMENSION::SetOrigin( const wxPoint& aOrigin ) { { m_crossBarO = aOrigin; m_featureLineGO = aOrigin; m_featureLineGO = aOrigin; AdjustDimensionDetails(); AdjustDimensionDetails(); Loading @@ -204,29 +200,32 @@ void DIMENSION::SetOrigin( const wxPoint& aOrigin ) void DIMENSION::SetEnd( const wxPoint& aEnd ) void DIMENSION::SetEnd( const wxPoint& aEnd ) { { m_crossBarF = aEnd; m_featureLineDO = aEnd; m_featureLineDO = aEnd; AdjustDimensionDetails(); AdjustDimensionDetails(); } } void DIMENSION::SetHeight( double aHeight ) void DIMENSION::SetHeight( int aHeight ) { { /* Calculating the direction of travel perpendicular to the selected axis. */ m_Height = aHeight; double angle = GetAngle() + ( M_PI / 2 ); int dx = KiROUND( aHeight * cos( angle ) ); int dy = KiROUND( aHeight * sin( angle ) ); m_crossBarO.x = m_featureLineGO.x + dx; m_crossBarO.y = m_featureLineGO.y + dy; m_crossBarF.x = m_featureLineDO.x + dx; m_crossBarF.y = m_featureLineDO.y + dy; AdjustDimensionDetails(); AdjustDimensionDetails(); } } void DIMENSION::UpdateHeight() { VECTOR2D featureLine( m_crossBarO - m_featureLineGO ); VECTOR2D crossBar( m_featureLineDO - m_featureLineGO ); if( featureLine.Cross( crossBar ) > 0 ) m_Height = -featureLine.EuclideanNorm(); else m_Height = featureLine.EuclideanNorm(); } void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) { { const int arrowz = DMils2iu( 500 ); // size of arrows const int arrowz = DMils2iu( 500 ); // size of arrows Loading Loading @@ -281,6 +280,13 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) arrow_dw_Y = wxRound( arrowz * sin( angle_f ) ); arrow_dw_Y = wxRound( arrowz * sin( angle_f ) ); } } int dx = KiROUND( m_Height * cos( angle + M_PI / 2 ) ); int dy = KiROUND( m_Height * sin( angle + M_PI / 2 ) ); m_crossBarO.x = m_featureLineGO.x + dx; m_crossBarO.y = m_featureLineGO.y + dy; m_crossBarF.x = m_featureLineDO.x + dx; m_crossBarF.y = m_featureLineDO.y + dy; m_arrowG1F.x = m_crossBarO.x + arrow_up_X; m_arrowG1F.x = m_crossBarO.x + arrow_up_X; m_arrowG1F.y = m_crossBarO.y + arrow_up_Y; m_arrowG1F.y = m_crossBarO.y + arrow_up_Y; Loading
pcbnew/class_dimension.h +24 −10 Original line number Original line Diff line number Diff line Loading @@ -61,14 +61,13 @@ class MSG_PANEL_ITEM; */ */ class DIMENSION : public BOARD_ITEM class DIMENSION : public BOARD_ITEM { { int m_Width; int m_Width; ///< Line width int m_Shape; // / Currently always 0. int m_Shape; ///< Currently always 0. int m_Unit; // / 0 = inches, 1 = mm EDA_UNITS_T m_Unit; ///< 0 = inches, 1 = mm int m_Value; // / value of PCB dimensions. int m_Value; ///< value of PCB dimensions. int m_Height; ///< length of feature lines TEXTE_PCB m_Text; TEXTE_PCB m_Text; public: public: // TODO private: These member should be private. they are public only due to legacy code // TODO private: These member should be private. they are public only due to legacy code wxPoint m_crossBarO, m_crossBarF; wxPoint m_crossBarO, m_crossBarF; Loading Loading @@ -117,7 +116,7 @@ public: */ */ const wxPoint& GetOrigin() const const wxPoint& GetOrigin() const { { return m_crossBarO; return m_featureLineGO; } } /** /** Loading @@ -133,7 +132,7 @@ public: */ */ const wxPoint& GetEnd() const wxPoint& GetEnd() { { return m_crossBarF; return m_featureLineDO; } } /** /** Loading @@ -141,12 +140,27 @@ public: * Sets the length of feature lines. * Sets the length of feature lines. * @param aHeight is the new height. * @param aHeight is the new height. */ */ void SetHeight( double aHeight ); void SetHeight( int aHeight ); /** * Function GetHeight * Returns the length of feature lines. */ int GetHeight() const { return m_Height; } /** * Function UpdateHeight * Updates stored height basing on points coordinates. */ void UpdateHeight(); /** /** * Function GetAngle * Function GetAngle * Returns angle of the crossbar. * Returns angle of the crossbar. * @return Angle of the crossbar line. * @return Angle of the crossbar line expressed in radians. */ */ double GetAngle() const double GetAngle() const { { Loading
pcbnew/pcb_parser.cpp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -1438,6 +1438,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) parseXY( &dimension->m_featureLineDO.x, &dimension->m_featureLineDO.y ); parseXY( &dimension->m_featureLineDO.x, &dimension->m_featureLineDO.y ); parseXY( &dimension->m_featureLineDF.x, &dimension->m_featureLineDF.y ); parseXY( &dimension->m_featureLineDF.x, &dimension->m_featureLineDF.y ); dimension->UpdateHeight(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); break; break; Loading @@ -1451,6 +1452,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) parseXY( &dimension->m_featureLineGO.x, &dimension->m_featureLineGO.y ); parseXY( &dimension->m_featureLineGO.x, &dimension->m_featureLineGO.y ); parseXY( &dimension->m_featureLineGF.x, &dimension->m_featureLineGF.y ); parseXY( &dimension->m_featureLineGF.x, &dimension->m_featureLineGF.y ); dimension->UpdateHeight(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); break; break; Loading @@ -1465,6 +1467,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) parseXY( &dimension->m_crossBarO.x, &dimension->m_crossBarO.y ); parseXY( &dimension->m_crossBarO.x, &dimension->m_crossBarO.y ); parseXY( &dimension->m_crossBarF.x, &dimension->m_crossBarF.y ); parseXY( &dimension->m_crossBarF.x, &dimension->m_crossBarF.y ); dimension->UpdateHeight(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); NeedRIGHT(); break; break; Loading
pcbnew/tools/edit_points.cpp +37 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,7 @@ bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const { { // Corners of the square // Corners of the EDIT_POINT square VECTOR2I topLeft = GetPosition() - aSize; VECTOR2I topLeft = GetPosition() - aSize; VECTOR2I bottomRight = GetPosition() + aSize; VECTOR2I bottomRight = GetPosition() + aSize; Loading Loading @@ -162,6 +162,42 @@ void EPC_45DEGREE::Apply() } } EPC_LINE::EPC_LINE( EDIT_POINT& aConstrained, EDIT_POINT& aConstrainer ) : EDIT_POINT_CONSTRAINT( aConstrained ), m_constrainer( aConstrainer ) { Update(); } void EPC_LINE::Apply() { VECTOR2I position = m_constrained.GetPosition(); if( std::isfinite( m_coefA ) ) { if( abs( m_coefA ) < 1 ) position.y = m_coefA * position.x + m_coefB; else position.x = ( position.y - m_coefB ) / m_coefA; } else // vertical line { position.x = m_constrainer.GetX(); } m_constrained.SetPosition( position ); } void EPC_LINE::Update() { // Compute line coefficients VECTOR2D delta = m_constrainer.GetPosition() - m_constrained.GetPosition(); m_coefA = delta.y / delta.x; m_coefB = m_constrainer.GetY() - m_coefA * m_constrainer.GetX(); } void EPC_CIRCLE::Apply() void EPC_CIRCLE::Apply() { { VECTOR2I centerToEnd = m_end.GetPosition() - m_center.GetPosition(); VECTOR2I centerToEnd = m_end.GetPosition() - m_center.GetPosition(); Loading
pcbnew/tools/edit_points.h +57 −0 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,26 @@ public: return m_position; return m_position; } } /** * Function GetX() * * Returns X coordinate of an EDIT_POINT. */ int GetX() const { return GetPosition().x; } /** * Function GetX() * * Returns Y coordinate of an EDIT_POINT. */ int GetY() const { return GetPosition().y; } /** /** * Function SetPosition() * Function SetPosition() * * Loading Loading @@ -132,6 +152,17 @@ public: m_constraint = aConstraint; m_constraint = aConstraint; } } /** * Function GetConstraint() * * Returns the constraint imposed on an EDIT_POINT. If there are no constraints, NULL is * returned. */ EDIT_POINT_CONSTRAINT* GetConstraint() const { return m_constraint; } /** /** * Function ClearConstraint() * Function ClearConstraint() * * Loading Loading @@ -468,6 +499,32 @@ private: }; }; /** * Class EPC_LINE * * EDIT_POINT_CONSTRAINT that imposes a constraint that a point has to lie on a line (determined * by 2 points). */ class EPC_LINE : public EDIT_POINT_CONSTRAINT { public: EPC_LINE( EDIT_POINT& aConstrained, EDIT_POINT& aConstrainer ); ///> @copydoc EDIT_POINT_CONSTRAINT::Apply() virtual void Apply(); /** * Function Update() * Updates line coefficients that make the constraining line. */ void Update(); private: EDIT_POINT& m_constrainer; ///< Point that imposes the constraint. double m_coefA, m_coefB; }; /** /** * Class EPC_CIRCLE. * Class EPC_CIRCLE. * * Loading