Minor code cleaning.
This commit is contained in:
parent
36d1818b54
commit
59af7a96f8
|
@ -172,7 +172,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
|||
down = true;
|
||||
}
|
||||
|
||||
int mods = decodeModifiers<wxMouseEvent>( static_cast<wxMouseEvent*>( &aEvent ) );
|
||||
int mods = decodeModifiers( static_cast<wxMouseEvent*>( &aEvent ) );
|
||||
int args = st->button | mods;
|
||||
|
||||
if( down ) // Handle mouse button press
|
||||
|
@ -224,8 +224,8 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
|||
if( t - st->downTimestamp > DragTimeThreshold || st->dragMaxDelta > DragDistanceThreshold )
|
||||
{
|
||||
evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_DRAG, args );
|
||||
evt->SetMouseDragOrigin( st->dragOrigin );
|
||||
evt->SetMouseDelta( m_lastMousePos - st->dragOrigin );
|
||||
evt->setMouseDragOrigin( st->dragOrigin );
|
||||
evt->setMouseDelta( m_lastMousePos - st->dragOrigin );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
type == KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
|
||||
{
|
||||
wxMouseEvent* me = static_cast<wxMouseEvent*>( &aEvent );
|
||||
int mods = decodeModifiers<wxMouseEvent>( me );
|
||||
int mods = decodeModifiers( me );
|
||||
|
||||
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetMousePosition();
|
||||
VECTOR2D pos = getView()->ToWorld( screenPos );
|
||||
|
@ -295,7 +295,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
{
|
||||
wxKeyEvent* ke = static_cast<wxKeyEvent*>( &aEvent );
|
||||
int key = ke->GetKeyCode();
|
||||
int mods = decodeModifiers<wxKeyEvent>( ke );
|
||||
int mods = decodeModifiers( ke );
|
||||
|
||||
if( mods & MD_CTRL )
|
||||
{
|
||||
|
|
|
@ -494,7 +494,7 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
if( st->waitEvents.Matches( aEvent ) )
|
||||
{
|
||||
// By default, only messages are passed further
|
||||
m_passEvent = ( aEvent.m_category == TC_MESSAGE );
|
||||
m_passEvent = ( aEvent.Category() == TC_MESSAGE );
|
||||
|
||||
// got matching event? clear wait list and wake up the coroutine
|
||||
st->wakeupEvent = aEvent;
|
||||
|
@ -563,7 +563,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
if( aEvent.IsActivate() )
|
||||
{
|
||||
std::map<std::string, TOOL_STATE*>::iterator tool = m_toolNameIndex.find( *aEvent.m_commandStr );
|
||||
std::map<std::string, TOOL_STATE*>::iterator tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
|
||||
|
||||
if( tool != m_toolNameIndex.end() )
|
||||
{
|
||||
|
|
|
@ -97,8 +97,7 @@ private:
|
|||
bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion );
|
||||
|
||||
///> Saves the state of key modifiers (Alt, Ctrl and so on).
|
||||
template <class EventType>
|
||||
static int decodeModifiers( const EventType* aState )
|
||||
static int decodeModifiers( const wxKeyboardState* aState )
|
||||
{
|
||||
int mods = 0;
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ public:
|
|||
{
|
||||
if( aCategory == TC_MOUSE )
|
||||
{
|
||||
m_mouseButtons = aExtraParam & BUT_BUTTON_MASK;
|
||||
setMouseButtons( aExtraParam & BUT_BUTTON_MASK );
|
||||
}
|
||||
else if( aCategory == TC_KEYBOARD )
|
||||
{
|
||||
|
@ -311,21 +311,6 @@ public:
|
|||
return m_actions == TA_KEY_PRESSED;
|
||||
}
|
||||
|
||||
void SetMouseDragOrigin( const VECTOR2D& aP )
|
||||
{
|
||||
m_mouseDragOrigin = aP;
|
||||
}
|
||||
|
||||
void SetMousePosition( const VECTOR2D& aP )
|
||||
{
|
||||
m_mousePos = aP;
|
||||
}
|
||||
|
||||
void SetMouseDelta( const VECTOR2D& aP )
|
||||
{
|
||||
m_mouseDelta = aP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Matches()
|
||||
* Tests whether two events match in terms of category & action or command.
|
||||
|
@ -400,8 +385,35 @@ public:
|
|||
return m_commandStr;
|
||||
}
|
||||
|
||||
void SetMousePosition( const VECTOR2D& aP )
|
||||
{
|
||||
m_mousePos = aP;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class TOOL_MANAGER;
|
||||
friend class TOOL_DISPATCHER;
|
||||
|
||||
void setMouseDragOrigin( const VECTOR2D& aP )
|
||||
{
|
||||
m_mouseDragOrigin = aP;
|
||||
}
|
||||
|
||||
void setMouseDelta( const VECTOR2D& aP )
|
||||
{
|
||||
m_mouseDelta = aP;
|
||||
}
|
||||
|
||||
void setMouseButtons( int aButtons )
|
||||
{
|
||||
assert( ( aButtons & ~BUT_BUTTON_MASK ) == 0 );
|
||||
m_mouseButtons = aButtons;
|
||||
}
|
||||
|
||||
void setModifiers( int aMods )
|
||||
{
|
||||
assert( ( aMods & ~MD_MODIFIER_MASK ) == 0 );
|
||||
m_modifiers = aMods;
|
||||
}
|
||||
|
||||
TOOL_EVENT_CATEGORY m_category;
|
||||
TOOL_ACTIONS m_actions;
|
||||
|
|
|
@ -1029,7 +1029,7 @@ bool EDIT_TOOL::hoverSelection( const SELECTION& aSelection, bool aSanitize )
|
|||
if( aSanitize )
|
||||
m_selectionTool->SanitizeSelection();
|
||||
|
||||
if( aSelection.Empty() )
|
||||
if( aSelection.Empty() ) // TODO is it necessary?
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
|
||||
return !aSelection.Empty();
|
||||
|
|
|
@ -226,7 +226,6 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::selectionCursor ) )
|
||||
{
|
||||
// GetMousePosition() is used, as it is independent of snapping settings
|
||||
selectCursor( true );
|
||||
}
|
||||
|
||||
|
@ -1166,8 +1165,6 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
|
|||
|
||||
if( item->Type() == PCB_MODULE_T && areaRatio < textToFootprintMinRatio )
|
||||
{
|
||||
//printf("rejectModuleN\n");
|
||||
|
||||
rejected.insert( item );
|
||||
}
|
||||
|
||||
|
@ -1180,7 +1177,6 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
|
|||
case PCB_MODULE_T:
|
||||
if( areaRatio > textToFeatureMinRatio )
|
||||
{
|
||||
//printf("t after moduleRejected\n");
|
||||
rejected.insert( txt );
|
||||
}
|
||||
break;
|
||||
|
@ -1199,19 +1195,19 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
|
|||
if( calcRatio( minArea, maxArea ) <= footprintAreaRatio )
|
||||
{
|
||||
for( int i = 0; i < aCollector.GetCount(); ++i )
|
||||
{
|
||||
if( MODULE* mod = dyn_cast<MODULE*>( aCollector[i] ) )
|
||||
{
|
||||
double normalizedArea = calcRatio( calcArea(mod), maxArea );
|
||||
|
||||
if( normalizedArea > footprintAreaRatio )
|
||||
{
|
||||
//printf("rejectModule1\n");
|
||||
|
||||
rejected.insert( mod );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( aCollector.CountType( PCB_PAD_T ) > 0 )
|
||||
{
|
||||
|
@ -1314,8 +1310,6 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
|
|||
{
|
||||
aCollector.Remove( item );
|
||||
}
|
||||
|
||||
//printf("Post-selection: %d\n", aCollector.GetCount() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue