Refactoring EDIT_POINTS, part 3: constraints split to EDIT_POINTs and EDIT_LINEs.
This commit is contained in:
parent
0379247fd4
commit
1828edbabe
|
@ -90,8 +90,8 @@ void EC_CIRCLE::Apply( EDIT_POINT& aHandle )
|
|||
|
||||
|
||||
EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) :
|
||||
EDIT_CONSTRAINT<EDIT_POINT>( aLine.GetOrigin() ),
|
||||
m_colinearConstraint( NULL ), m_line( aLine ), m_editPoints( aPoints )
|
||||
EDIT_CONSTRAINT<EDIT_LINE>( aLine ),
|
||||
m_colinearConstraint( NULL ), m_editPoints( aPoints )
|
||||
{
|
||||
// Dragged segment endings
|
||||
EDIT_POINT& origin = aLine.GetOrigin();
|
||||
|
@ -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
|
||||
EDIT_POINT& origin = m_line.GetOrigin();
|
||||
EDIT_POINT& end = m_line.GetEnd();
|
||||
EDIT_POINT& origin = m_constrained.GetOrigin();
|
||||
EDIT_POINT& end = m_constrained.GetEnd();
|
||||
|
||||
if( m_colinearConstraint )
|
||||
{
|
||||
|
|
|
@ -127,8 +127,8 @@ private:
|
|||
/**
|
||||
* Class EC_45DEGREE
|
||||
*
|
||||
* EDIT_CONSTRAINT that imposes a constraint that two to be located at angle of 45 degree
|
||||
* multiplicity.
|
||||
* EDIT_CONSTRAINT that imposes a constraint that two points have to be located at angle of 45
|
||||
* degree multiplicity.
|
||||
*/
|
||||
class EC_45DEGREE : public EDIT_CONSTRAINT<EDIT_POINT>
|
||||
{
|
||||
|
@ -205,10 +205,10 @@ private:
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
class EC_CONVERGING : public EDIT_CONSTRAINT<EDIT_POINT>
|
||||
class EC_CONVERGING : public EDIT_CONSTRAINT<EDIT_LINE>
|
||||
{
|
||||
public:
|
||||
EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints );
|
||||
|
@ -216,7 +216,7 @@ public:
|
|||
virtual ~EC_CONVERGING();
|
||||
|
||||
///> @copydoc EDIT_CONSTRAINT::Apply()
|
||||
virtual void Apply( EDIT_POINT& aHandle );
|
||||
virtual void Apply( EDIT_LINE& aHandle );
|
||||
|
||||
private:
|
||||
///> Constraint for origin side segment.
|
||||
|
@ -229,9 +229,6 @@ private:
|
|||
///> m_[origin/end]SideConstraint, so it should not be freed.
|
||||
EDIT_CONSTRAINT<EDIT_POINT>* m_colinearConstraint;
|
||||
|
||||
///> Dragged segment.
|
||||
EDIT_LINE& m_line;
|
||||
|
||||
///> EDIT_POINTS instance that stores currently modified lines.
|
||||
EDIT_POINTS& m_editPoints;
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
///> Single point size in pixels
|
||||
static const int POINT_SIZE = 10;
|
||||
|
||||
protected:
|
||||
private:
|
||||
///> Position of EDIT_POINT
|
||||
VECTOR2I m_position;
|
||||
|
||||
|
@ -221,6 +221,29 @@ public:
|
|||
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()
|
||||
*
|
||||
|
@ -264,6 +287,9 @@ public:
|
|||
private:
|
||||
EDIT_POINT& m_origin; ///< Origin 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 )
|
|||
if( aEnabled )
|
||||
{
|
||||
EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_dragPoint );
|
||||
|
||||
if( line )
|
||||
{
|
||||
if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
|
||||
{
|
||||
m_altConstraint.reset( new EC_CONVERGING( *line, *m_editPoints ) );
|
||||
}
|
||||
m_altConstraint.reset( (EDIT_CONSTRAINT<EDIT_POINT>*)( new EC_CONVERGING( *line, *m_editPoints ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue