Display GRID_HELPER auxiliary axes and snap points
This commit is contained in:
parent
b8c621a991
commit
e8345dce51
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include <origin_viewitem.h>
|
#include <origin_viewitem.h>
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
#include <class_track.h>
|
|
||||||
|
|
||||||
using namespace KIGFX;
|
using namespace KIGFX;
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,25 @@ using namespace std::placeholders;
|
||||||
|
|
||||||
#include "grid_helper.h"
|
#include "grid_helper.h"
|
||||||
|
|
||||||
|
|
||||||
GRID_HELPER::GRID_HELPER( PCB_BASE_FRAME* aFrame ) :
|
GRID_HELPER::GRID_HELPER( PCB_BASE_FRAME* aFrame ) :
|
||||||
m_frame( aFrame )
|
m_frame( aFrame )
|
||||||
{
|
{
|
||||||
m_diagonalAuxAxesEnable = true;
|
m_diagonalAuxAxesEnable = true;
|
||||||
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
|
||||||
|
m_viewAxis.SetSize( 20000 );
|
||||||
|
m_viewAxis.SetStyle( KIGFX::ORIGIN_VIEWITEM::CROSS );
|
||||||
|
m_viewAxis.SetColor( COLOR4D( 1.0, 1.0, 1.0, 0.4 ) );
|
||||||
|
m_viewAxis.SetDrawAtZero( true );
|
||||||
|
view->Add( &m_viewAxis );
|
||||||
|
view->SetVisible( &m_viewAxis, false );
|
||||||
|
|
||||||
|
m_viewSnapPoint.SetStyle( KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
|
||||||
|
m_viewSnapPoint.SetColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
||||||
|
m_viewSnapPoint.SetDrawAtZero( true );
|
||||||
|
view->Add( &m_viewSnapPoint );
|
||||||
|
view->SetVisible( &m_viewSnapPoint, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,10 +98,19 @@ VECTOR2I GRID_HELPER::GetOrigin() const
|
||||||
|
|
||||||
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin, bool aEnableDiagonal )
|
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin, bool aEnableDiagonal )
|
||||||
{
|
{
|
||||||
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
|
||||||
if( aEnable )
|
if( aEnable )
|
||||||
|
{
|
||||||
m_auxAxis = aOrigin;
|
m_auxAxis = aOrigin;
|
||||||
|
m_viewAxis.SetPosition( aOrigin );
|
||||||
|
view->SetVisible( &m_viewAxis, true );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_auxAxis = boost::optional<VECTOR2I>();
|
m_auxAxis = boost::optional<VECTOR2I>();
|
||||||
|
view->SetVisible( &m_viewAxis, false );
|
||||||
|
}
|
||||||
|
|
||||||
m_diagonalAuxAxesEnable = aEnable;
|
m_diagonalAuxAxesEnable = aEnable;
|
||||||
}
|
}
|
||||||
|
@ -238,9 +262,14 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDrag
|
||||||
double snapDist = nearest->Distance( aOrigin );
|
double snapDist = nearest->Distance( aOrigin );
|
||||||
|
|
||||||
if( nearest && snapDist < gridDist )
|
if( nearest && snapDist < gridDist )
|
||||||
|
{
|
||||||
|
m_viewSnapPoint.SetPosition( nearest->pos );
|
||||||
|
m_frame->GetGalCanvas()->GetView()->SetVisible( &m_viewSnapPoint, true );
|
||||||
return nearest->pos;
|
return nearest->pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_frame->GetGalCanvas()->GetView()->SetVisible( &m_viewSnapPoint, false );
|
||||||
return nearestGrid;
|
return nearestGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
#include <origin_viewitem.h>
|
||||||
|
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@ private:
|
||||||
PCB_BASE_FRAME* m_frame;
|
PCB_BASE_FRAME* m_frame;
|
||||||
boost::optional<VECTOR2I> m_auxAxis;
|
boost::optional<VECTOR2I> m_auxAxis;
|
||||||
bool m_diagonalAuxAxesEnable;
|
bool m_diagonalAuxAxesEnable;
|
||||||
|
KIGFX::ORIGIN_VIEWITEM m_viewSnapPoint, m_viewAxis;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue