Commit 1828edba authored by Maciej Suminski's avatar Maciej Suminski

Refactoring EDIT_POINTS, part 3: constraints split to EDIT_POINTs and EDIT_LINEs.

parent 0379247f
...@@ -90,8 +90,8 @@ void EC_CIRCLE::Apply( EDIT_POINT& aHandle ) ...@@ -90,8 +90,8 @@ void EC_CIRCLE::Apply( EDIT_POINT& aHandle )
EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) : EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) :
EDIT_CONSTRAINT<EDIT_POINT>( aLine.GetOrigin() ), EDIT_CONSTRAINT<EDIT_LINE>( aLine ),
m_colinearConstraint( NULL ), m_line( aLine ), m_editPoints( aPoints ) m_colinearConstraint( NULL ), m_editPoints( aPoints )
{ {
// Dragged segment endings // Dragged segment endings
EDIT_POINT& origin = aLine.GetOrigin(); EDIT_POINT& origin = aLine.GetOrigin();
...@@ -128,11 +128,11 @@ EC_CONVERGING::~EC_CONVERGING() ...@@ -128,11 +128,11 @@ EC_CONVERGING::~EC_CONVERGING()
} }
void EC_CONVERGING::Apply( EDIT_POINT& aHandle ) void EC_CONVERGING::Apply( EDIT_LINE& aHandle )
{ {
// The dragged segment endpoints // The dragged segment endpoints
EDIT_POINT& origin = m_line.GetOrigin(); EDIT_POINT& origin = m_constrained.GetOrigin();
EDIT_POINT& end = m_line.GetEnd(); EDIT_POINT& end = m_constrained.GetEnd();
if( m_colinearConstraint ) if( m_colinearConstraint )
{ {
......
...@@ -127,8 +127,8 @@ private: ...@@ -127,8 +127,8 @@ private:
/** /**
* Class EC_45DEGREE * Class EC_45DEGREE
* *
* EDIT_CONSTRAINT that imposes a constraint that two to be located at angle of 45 degree * EDIT_CONSTRAINT that imposes a constraint that two points have to be located at angle of 45
* multiplicity. * degree multiplicity.
*/ */
class EC_45DEGREE : public EDIT_CONSTRAINT<EDIT_POINT> class EC_45DEGREE : public EDIT_CONSTRAINT<EDIT_POINT>
{ {
...@@ -205,10 +205,10 @@ private: ...@@ -205,10 +205,10 @@ private:
/** /**
* Class EC_CONVERGING * Class EC_CONVERGING
* *
* EDIT_CONSTRAINT for 3 segment: dragged and two adjacent ones, enforcing to keep their slopes * EDIT_CONSTRAINT for 3 segments: dragged and two adjacent ones, enforcing to keep their slopes
* and allows only to change ending points. Applied to zones. * and allows only to change ending points. Applied to zones.
*/ */
class EC_CONVERGING : public EDIT_CONSTRAINT<EDIT_POINT> class EC_CONVERGING : public EDIT_CONSTRAINT<EDIT_LINE>
{ {
public: public:
EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ); EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints );
...@@ -216,7 +216,7 @@ public: ...@@ -216,7 +216,7 @@ public:
virtual ~EC_CONVERGING(); virtual ~EC_CONVERGING();
///> @copydoc EDIT_CONSTRAINT::Apply() ///> @copydoc EDIT_CONSTRAINT::Apply()
virtual void Apply( EDIT_POINT& aHandle ); virtual void Apply( EDIT_LINE& aHandle );
private: private:
///> Constraint for origin side segment. ///> Constraint for origin side segment.
...@@ -229,9 +229,6 @@ private: ...@@ -229,9 +229,6 @@ private:
///> m_[origin/end]SideConstraint, so it should not be freed. ///> m_[origin/end]SideConstraint, so it should not be freed.
EDIT_CONSTRAINT<EDIT_POINT>* m_colinearConstraint; EDIT_CONSTRAINT<EDIT_POINT>* m_colinearConstraint;
///> Dragged segment.
EDIT_LINE& m_line;
///> EDIT_POINTS instance that stores currently modified lines. ///> EDIT_POINTS instance that stores currently modified lines.
EDIT_POINTS& m_editPoints; EDIT_POINTS& m_editPoints;
......
...@@ -165,7 +165,7 @@ public: ...@@ -165,7 +165,7 @@ public:
///> Single point size in pixels ///> Single point size in pixels
static const int POINT_SIZE = 10; static const int POINT_SIZE = 10;
protected: private:
///> Position of EDIT_POINT ///> Position of EDIT_POINT
VECTOR2I m_position; VECTOR2I m_position;
...@@ -221,6 +221,29 @@ public: ...@@ -221,6 +221,29 @@ public:
m_constraint->Apply(); m_constraint->Apply();
} }
/**
* Function SetConstraint()
*
* Sets a constraint for and EDIT_POINT.
* @param aConstraint is the constraint to be set.
*/
void SetConstraint( EDIT_CONSTRAINT<EDIT_LINE>* aConstraint )
{
m_constraint.reset( aConstraint );
}
/**
* Function GetConstraint()
*
* Returns the constraint imposed on an EDIT_POINT. If there are no constraints, NULL is
* returned.
*/
EDIT_CONSTRAINT<EDIT_LINE>* GetConstraint() const
{
return m_constraint.get();
}
/** /**
* Function GetOrigin() * Function GetOrigin()
* *
...@@ -264,6 +287,9 @@ public: ...@@ -264,6 +287,9 @@ public:
private: private:
EDIT_POINT& m_origin; ///< Origin point for a line EDIT_POINT& m_origin; ///< Origin point for a line
EDIT_POINT& m_end; ///< End point for a line EDIT_POINT& m_end; ///< End point for a line
///> Constraint for the point, NULL if none
boost::shared_ptr<EDIT_CONSTRAINT<EDIT_LINE> > m_constraint;
}; };
......
...@@ -575,12 +575,11 @@ void POINT_EDITOR::setAltConstraint( bool aEnabled ) ...@@ -575,12 +575,11 @@ void POINT_EDITOR::setAltConstraint( bool aEnabled )
if( aEnabled ) if( aEnabled )
{ {
EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_dragPoint ); EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_dragPoint );
if( line ) if( line )
{ {
if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T ) if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
{ m_altConstraint.reset( (EDIT_CONSTRAINT<EDIT_POINT>*)( new EC_CONVERGING( *line, *m_editPoints ) ) );
m_altConstraint.reset( new EC_CONVERGING( *line, *m_editPoints ) );
}
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment