Show Place & Drill origin in GAL.

This commit is contained in:
Maciej Suminski 2015-06-18 17:51:54 +02:00
parent 28a270a328
commit a16dd894d5
2 changed files with 28 additions and 2 deletions

View File

@ -45,6 +45,7 @@
#include <view/view_group.h>
#include <view/view_controls.h>
#include <origin_viewitem.h>
class ZONE_CONTEXT_MENU : public CONTEXT_MENU
@ -64,12 +65,27 @@ public:
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.EditorControl" ), m_frame( NULL )
{
m_placeOrigin = new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
KIGFX::ORIGIN_VIEWITEM::CROSS );
}
PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL()
{
delete m_placeOrigin;
}
void PCB_EDITOR_CONTROL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<PCB_EDIT_FRAME>();
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
{
m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
getView()->Remove( m_placeOrigin );
getView()->Add( m_placeOrigin );
}
}
@ -469,9 +485,12 @@ int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
}
static bool setDrillOrigin( PCB_BASE_FRAME* aFrame, const VECTOR2D& aPosition )
static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPosition )
{
aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
aItem->SetPosition( aPosition );
aView->MarkDirty();
return true;
}
@ -483,7 +502,7 @@ int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
assert( picker );
m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust zero" ) );
picker->SetClickHandler( boost::bind( setDrillOrigin, m_frame, _1 ) );
picker->SetClickHandler( boost::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin, _1 ) );
picker->Activate();
return 0;

View File

@ -27,6 +27,9 @@
#include <tool/tool_interactive.h>
namespace KIGFX {
class ORIGIN_VIEWITEM;
}
class PCB_EDIT_FRAME;
/**
@ -38,6 +41,7 @@ class PCB_EDITOR_CONTROL : public TOOL_INTERACTIVE
{
public:
PCB_EDITOR_CONTROL();
~PCB_EDITOR_CONTROL();
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason );
@ -88,6 +92,9 @@ private:
///> Pointer to the currently used edit frame.
PCB_EDIT_FRAME* m_frame;
///> Place & drill origin marker.
KIGFX::ORIGIN_VIEWITEM* m_placeOrigin;
// How does line width change after one -/+ key press.
static const int WIDTH_STEP;
};