2014-02-27 16:29:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
#include <boost/make_shared.hpp>
|
2014-04-02 13:57:21 +00:00
|
|
|
#include <boost/bind.hpp>
|
2014-02-28 15:53:28 +00:00
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <view/view_controls.h>
|
2014-03-06 13:41:25 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2014-03-18 13:52:22 +00:00
|
|
|
#include <geometry/seg.h>
|
2014-02-27 16:29:08 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
|
|
|
|
#include "common_actions.h"
|
|
|
|
#include "selection_tool.h"
|
|
|
|
#include "point_editor.h"
|
|
|
|
|
2014-03-06 10:49:08 +00:00
|
|
|
#include <wxPcbStruct.h>
|
2014-07-09 11:50:27 +00:00
|
|
|
#include <class_edge_mod.h>
|
2014-03-12 09:46:11 +00:00
|
|
|
#include <class_dimension.h>
|
2014-02-28 17:24:29 +00:00
|
|
|
#include <class_zone.h>
|
2014-03-18 14:46:38 +00:00
|
|
|
#include <class_board.h>
|
2014-07-09 13:02:56 +00:00
|
|
|
#include <class_module.h>
|
2014-02-27 16:29:08 +00:00
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
// Few constants to avoid using bare numbers for point indices
|
|
|
|
enum SEG_POINTS
|
|
|
|
{
|
|
|
|
SEG_START, SEG_END
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ARC_POINTS
|
|
|
|
{
|
|
|
|
ARC_CENTER, ARC_START, ARC_END
|
|
|
|
};
|
|
|
|
|
|
|
|
enum CIRCLE_POINTS
|
|
|
|
{
|
|
|
|
CIRC_CENTER, CIRC_END
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DIMENSION_POINTS
|
|
|
|
{
|
|
|
|
DIM_CROSSBARO,
|
|
|
|
DIM_CROSSBARF,
|
|
|
|
DIM_FEATUREGO,
|
|
|
|
DIM_FEATUREDO,
|
|
|
|
};
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
class EDIT_POINTS_FACTORY
|
|
|
|
{
|
|
|
|
public:
|
2014-04-02 13:57:21 +00:00
|
|
|
static boost::shared_ptr<EDIT_POINTS> Make( EDA_ITEM* aItem, KIGFX::GAL* aGal )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 15:53:28 +00:00
|
|
|
boost::shared_ptr<EDIT_POINTS> points = boost::make_shared<EDIT_POINTS>( aItem );
|
2014-02-27 16:29:08 +00:00
|
|
|
|
2014-03-06 11:36:20 +00:00
|
|
|
// Generate list of edit points basing on the item type
|
2014-02-27 16:29:08 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_LINE_T:
|
2014-07-09 11:50:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 17:24:29 +00:00
|
|
|
const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( aItem );
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
switch( segment->GetShape() )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2014-04-01 15:41:24 +00:00
|
|
|
points->AddPoint( segment->GetStart() );
|
|
|
|
points->AddPoint( segment->GetEnd() );
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2014-04-01 15:41:24 +00:00
|
|
|
points->AddPoint( segment->GetCenter() );
|
|
|
|
points->AddPoint( segment->GetArcStart() );
|
|
|
|
points->AddPoint( segment->GetArcEnd() );
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
// Set constraints
|
|
|
|
// Arc end has to stay at the same radius as the start
|
2014-04-01 15:41:24 +00:00
|
|
|
points->Point( ARC_END ).SetConstraint( new EC_CIRCLE( points->Point( ARC_END ),
|
|
|
|
points->Point( ARC_CENTER ),
|
|
|
|
points->Point( ARC_START ) ) );
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-28 17:24:13 +00:00
|
|
|
case S_CIRCLE:
|
2014-04-01 15:41:24 +00:00
|
|
|
points->AddPoint( segment->GetCenter() );
|
|
|
|
points->AddPoint( segment->GetEnd() );
|
2014-03-06 16:34:04 +00:00
|
|
|
break;
|
2014-02-28 17:24:13 +00:00
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
default: // suppress warnings
|
|
|
|
break;
|
|
|
|
}
|
2014-02-28 17:24:29 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
{
|
|
|
|
const CPolyLine* outline = static_cast<const ZONE_CONTAINER*>( aItem )->Outline();
|
2014-03-06 16:34:04 +00:00
|
|
|
int cornersCount = outline->GetCornersCount();
|
|
|
|
|
|
|
|
for( int i = 0; i < cornersCount; ++i )
|
|
|
|
points->AddPoint( outline->GetPos( i ) );
|
2014-02-28 17:24:29 +00:00
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
// Lines have to be added after creating edit points,
|
|
|
|
// as they use EDIT_POINT references
|
2014-03-06 16:34:04 +00:00
|
|
|
for( int i = 0; i < cornersCount - 1; ++i )
|
2014-04-02 13:57:21 +00:00
|
|
|
{
|
2014-04-01 15:18:43 +00:00
|
|
|
points->AddLine( points->Point( i ), points->Point( i + 1 ) );
|
2014-04-02 13:57:21 +00:00
|
|
|
points->Line( i ).SetConstraint(
|
|
|
|
new EC_SNAPLINE( points->Line( i ),
|
|
|
|
boost::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
|
|
|
|
}
|
2014-03-06 16:34:04 +00:00
|
|
|
|
2014-03-12 09:46:11 +00:00
|
|
|
// The last missing line, connecting the last and the first polygon point
|
2014-04-01 15:18:43 +00:00
|
|
|
points->AddLine( points->Point( cornersCount - 1 ), points->Point( 0 ) );
|
2014-04-02 13:57:21 +00:00
|
|
|
points->Line( points->LinesSize() - 1 ).SetConstraint(
|
|
|
|
new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
|
|
|
|
boost::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
|
2014-03-12 09:46:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
{
|
|
|
|
const DIMENSION* dimension = static_cast<const DIMENSION*>( aItem );
|
|
|
|
|
|
|
|
points->AddPoint( dimension->m_crossBarO );
|
|
|
|
points->AddPoint( dimension->m_crossBarF );
|
2014-03-12 09:53:42 +00:00
|
|
|
points->AddPoint( dimension->m_featureLineGO );
|
|
|
|
points->AddPoint( dimension->m_featureLineDO );
|
2014-03-12 09:46:11 +00:00
|
|
|
|
|
|
|
// Dimension height setting - edit points should move only along the feature lines
|
2014-04-01 15:41:24 +00:00
|
|
|
points->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARO ),
|
|
|
|
points->Point( DIM_FEATUREGO ) ) );
|
|
|
|
points->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARF ),
|
|
|
|
points->Point( DIM_FEATUREDO ) ) );
|
2014-02-28 17:24:29 +00:00
|
|
|
|
|
|
|
break;
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2014-03-06 13:41:25 +00:00
|
|
|
points.reset();
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
EDIT_POINTS_FACTORY() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
POINT_EDITOR::POINT_EDITOR() :
|
2014-03-13 10:48:19 +00:00
|
|
|
TOOL_INTERACTIVE( "pcbnew.PointEditor" ), m_selectionTool( NULL ), m_dragPoint( NULL ),
|
2014-03-14 14:37:55 +00:00
|
|
|
m_original( VECTOR2I( 0, 0 ) ), m_altConstrainer( VECTOR2I( 0, 0 ) )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-28 16:20:10 +00:00
|
|
|
void POINT_EDITOR::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
m_editPoints.reset();
|
2014-03-14 14:37:55 +00:00
|
|
|
m_altConstraint.reset();
|
2014-02-28 16:20:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
bool POINT_EDITOR::Init()
|
|
|
|
{
|
|
|
|
// Find the selection tool, so they can cooperate
|
|
|
|
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
|
|
|
|
|
|
|
|
if( !m_selectionTool )
|
|
|
|
{
|
|
|
|
DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-09 14:50:31 +00:00
|
|
|
m_selectionTool->AddMenuItem( COMMON_ACTIONS::pointEditorBreakOutline,
|
|
|
|
POINT_EDITOR::breakOutlineCondition );
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-07-09 13:10:32 +00:00
|
|
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
if( selection.Size() == 1 )
|
|
|
|
{
|
2014-03-06 13:41:25 +00:00
|
|
|
Activate();
|
|
|
|
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
2014-03-06 16:34:04 +00:00
|
|
|
KIGFX::VIEW* view = getView();
|
2014-07-09 11:50:27 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
2014-02-27 16:29:08 +00:00
|
|
|
EDA_ITEM* item = selection.items.GetPickedItem( 0 );
|
2014-03-06 13:41:25 +00:00
|
|
|
|
2014-06-04 15:46:43 +00:00
|
|
|
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
2014-03-06 13:41:25 +00:00
|
|
|
if( !m_editPoints )
|
|
|
|
{
|
|
|
|
setTransitions();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
view->Add( m_editPoints.get() );
|
2014-03-06 11:36:20 +00:00
|
|
|
m_dragPoint = NULL;
|
|
|
|
bool modified = false;
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
// Main loop: keep receiving events
|
|
|
|
while( OPT_TOOL_EVENT evt = Wait() )
|
|
|
|
{
|
2014-03-06 11:36:20 +00:00
|
|
|
if( !m_editPoints ||
|
2014-02-28 16:20:10 +00:00
|
|
|
evt->Matches( m_selectionTool->ClearedEvent ) ||
|
|
|
|
evt->Matches( m_selectionTool->DeselectedEvent ) ||
|
|
|
|
evt->Matches( m_selectionTool->SelectedEvent ) )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
if( evt->IsMotion() )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 15:53:28 +00:00
|
|
|
EDIT_POINT* point = m_editPoints->FindPoint( evt->Position() );
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
if( m_dragPoint != point )
|
|
|
|
{
|
|
|
|
if( point )
|
|
|
|
{
|
|
|
|
controls->ShowCursor( true );
|
|
|
|
controls->SetSnapping( true );
|
2014-03-10 15:25:40 +00:00
|
|
|
controls->ForceCursorPosition( true, point->GetPosition() );
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
controls->ShowCursor( false );
|
|
|
|
controls->SetSnapping( false );
|
2014-03-10 15:25:40 +00:00
|
|
|
controls->ForceCursorPosition( false );
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_dragPoint = point;
|
|
|
|
}
|
|
|
|
|
2014-07-09 14:50:31 +00:00
|
|
|
else if( evt->IsAction( &COMMON_ACTIONS::pointEditorBreakOutline ) )
|
2014-03-18 13:52:22 +00:00
|
|
|
{
|
|
|
|
breakOutline( controls->GetCursorPosition() );
|
2014-07-09 14:50:31 +00:00
|
|
|
updatePoints();
|
2014-03-18 13:52:22 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
else if( evt->IsDrag( BUT_LEFT ) && m_dragPoint )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-03-06 11:36:20 +00:00
|
|
|
if( !modified )
|
|
|
|
{
|
|
|
|
// Save items, so changes can be undone
|
|
|
|
editFrame->OnModify();
|
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
2014-03-10 15:25:40 +00:00
|
|
|
controls->ForceCursorPosition( false );
|
2014-03-13 10:48:19 +00:00
|
|
|
m_original = *m_dragPoint; // Save the original position
|
2014-04-01 12:13:00 +00:00
|
|
|
controls->SetAutoPan( true );
|
2014-03-06 11:36:20 +00:00
|
|
|
modified = true;
|
|
|
|
}
|
|
|
|
|
2014-03-14 14:37:55 +00:00
|
|
|
bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
|
|
|
|
if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
|
|
|
|
setAltConstraint( enableAltConstraint );
|
2014-03-06 13:41:25 +00:00
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
m_dragPoint->SetPosition( controls->GetCursorPosition() );
|
2014-03-13 10:48:19 +00:00
|
|
|
|
2014-03-14 14:37:55 +00:00
|
|
|
if( m_altConstraint )
|
|
|
|
m_altConstraint->Apply();
|
2014-03-13 10:48:19 +00:00
|
|
|
else
|
|
|
|
m_dragPoint->ApplyConstraint();
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
updateItem();
|
|
|
|
updatePoints();
|
2014-02-27 16:29:08 +00:00
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
m_editPoints->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( evt->IsAction( &COMMON_ACTIONS::pointEditorUpdate ) )
|
|
|
|
{
|
|
|
|
updatePoints();
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 11:36:20 +00:00
|
|
|
else if( evt->IsMouseUp( BUT_LEFT ) )
|
|
|
|
{
|
2014-04-01 12:13:00 +00:00
|
|
|
controls->SetAutoPan( false );
|
2014-03-14 14:37:55 +00:00
|
|
|
setAltConstraint( false );
|
2014-03-06 11:36:20 +00:00
|
|
|
modified = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( evt->IsCancel() )
|
|
|
|
{
|
|
|
|
if( modified ) // Restore the last change
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
2014-07-09 11:50:27 +00:00
|
|
|
editFrame->RestoreCopyFromUndoList( dummy );
|
2014-03-06 11:36:20 +00:00
|
|
|
|
|
|
|
updatePoints();
|
|
|
|
modified = false;
|
|
|
|
}
|
|
|
|
|
2014-04-07 11:59:27 +00:00
|
|
|
// Let the selection tool receive the event too
|
|
|
|
m_toolMgr->PassEvent();
|
|
|
|
|
2014-03-06 11:36:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
else
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
|
|
|
m_toolMgr->PassEvent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 16:20:10 +00:00
|
|
|
if( m_editPoints )
|
|
|
|
{
|
2014-03-06 10:49:08 +00:00
|
|
|
finishItem();
|
2014-02-28 16:20:10 +00:00
|
|
|
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
2014-03-06 13:41:25 +00:00
|
|
|
view->Remove( m_editPoints.get() );
|
2014-02-28 16:20:10 +00:00
|
|
|
m_editPoints.reset();
|
|
|
|
}
|
2014-02-27 16:29:08 +00:00
|
|
|
|
2014-03-06 13:41:25 +00:00
|
|
|
controls->ShowCursor( false );
|
|
|
|
controls->SetAutoPan( false );
|
|
|
|
controls->SetSnapping( false );
|
2014-04-07 12:30:38 +00:00
|
|
|
controls->ForceCursorPosition( false );
|
2014-03-06 13:41:25 +00:00
|
|
|
}
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
void POINT_EDITOR::updateItem() const
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 15:53:28 +00:00
|
|
|
EDA_ITEM* item = m_editPoints->GetParent();
|
2014-02-27 16:29:08 +00:00
|
|
|
|
2014-02-28 15:53:28 +00:00
|
|
|
switch( item->Type() )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
|
|
|
case PCB_LINE_T:
|
2014-07-09 11:50:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 15:53:28 +00:00
|
|
|
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
|
2014-02-27 16:29:08 +00:00
|
|
|
switch( segment->GetShape() )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2014-04-01 15:41:24 +00:00
|
|
|
if( isModified( m_editPoints->Point( SEG_START ) ) )
|
|
|
|
segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
|
|
|
|
m_editPoints->Point( SEG_START ).GetPosition().y ) );
|
2014-02-28 17:24:13 +00:00
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
else if( isModified( m_editPoints->Point( SEG_END ) ) )
|
|
|
|
segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
|
|
|
|
m_editPoints->Point( SEG_END ).GetPosition().y ) );
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
|
|
|
{
|
2014-04-01 15:41:24 +00:00
|
|
|
const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
|
|
|
|
const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
|
|
|
|
const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
|
2014-02-27 16:29:08 +00:00
|
|
|
|
|
|
|
if( center != segment->GetCenter() )
|
|
|
|
{
|
|
|
|
wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
|
|
|
|
segment->Move( moveVector );
|
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
|
|
|
|
m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
segment->SetArcStart( wxPoint( start.x, start.y ) );
|
|
|
|
|
|
|
|
VECTOR2D startLine = start - center;
|
|
|
|
VECTOR2I endLine = end - center;
|
|
|
|
double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
|
|
|
|
|
|
|
|
// Adjust the new angle to (counter)clockwise setting
|
|
|
|
bool clockwise = ( segment->GetAngle() > 0 );
|
2014-02-28 17:24:13 +00:00
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
if( clockwise && newAngle < 0.0 )
|
|
|
|
newAngle += 3600.0;
|
|
|
|
else if( !clockwise && newAngle > 0.0 )
|
|
|
|
newAngle -= 3600.0;
|
|
|
|
|
|
|
|
segment->SetAngle( newAngle );
|
|
|
|
}
|
2014-02-28 17:24:13 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
{
|
2014-04-01 15:41:24 +00:00
|
|
|
const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
|
|
|
|
const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
|
2014-02-28 17:24:13 +00:00
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
|
2014-02-28 17:24:13 +00:00
|
|
|
{
|
|
|
|
wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
|
|
|
|
segment->Move( moveVector );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
segment->SetEnd( wxPoint( end.x, end.y ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default: // suppress warnings
|
|
|
|
break;
|
|
|
|
}
|
2014-02-28 17:24:29 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
// Update relative coordinates for module edges
|
|
|
|
if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
|
|
|
|
edge->SetLocalCoord();
|
|
|
|
|
2014-02-28 17:24:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
|
2014-03-14 15:05:30 +00:00
|
|
|
zone->ClearFilledPolysList();
|
2014-02-28 17:24:29 +00:00
|
|
|
CPolyLine* outline = zone->Outline();
|
|
|
|
|
|
|
|
for( int i = 0; i < outline->GetCornersCount(); ++i )
|
|
|
|
{
|
2014-07-09 14:50:31 +00:00
|
|
|
VECTOR2I point = m_editPoints->Point( i ).GetPosition();
|
|
|
|
outline->SetX( i, point.x );
|
|
|
|
outline->SetY( i, point.y );
|
2014-02-28 17:24:29 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-12 09:46:11 +00:00
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
{
|
|
|
|
DIMENSION* dimension = static_cast<DIMENSION*>( item );
|
|
|
|
|
|
|
|
// Check which point is currently modified and updated dimension's points respectively
|
2014-04-01 15:41:24 +00:00
|
|
|
if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
|
2014-03-12 09:46:11 +00:00
|
|
|
{
|
|
|
|
VECTOR2D featureLine( m_dragPoint->GetPosition() - dimension->GetOrigin() );
|
|
|
|
VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
|
|
|
|
|
|
|
|
if( featureLine.Cross( crossBar ) > 0 )
|
|
|
|
dimension->SetHeight( -featureLine.EuclideanNorm() );
|
|
|
|
else
|
|
|
|
dimension->SetHeight( featureLine.EuclideanNorm() );
|
|
|
|
}
|
2014-03-12 09:53:42 +00:00
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
|
2014-03-12 09:46:11 +00:00
|
|
|
{
|
|
|
|
VECTOR2D featureLine( m_dragPoint->GetPosition() - dimension->GetEnd() );
|
|
|
|
VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
|
|
|
|
|
|
|
|
if( featureLine.Cross( crossBar ) > 0 )
|
|
|
|
dimension->SetHeight( -featureLine.EuclideanNorm() );
|
|
|
|
else
|
|
|
|
dimension->SetHeight( featureLine.EuclideanNorm() );
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
|
2014-03-12 09:53:42 +00:00
|
|
|
{
|
|
|
|
dimension->SetOrigin( wxPoint( m_dragPoint->GetPosition().x, m_dragPoint->GetPosition().y ) );
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
|
|
|
|
m_editPoints->Point( DIM_FEATUREGO ) ) );
|
|
|
|
m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
|
|
|
|
m_editPoints->Point( DIM_FEATUREDO ) ) );
|
2014-03-12 09:53:42 +00:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
|
2014-03-12 09:53:42 +00:00
|
|
|
{
|
|
|
|
dimension->SetEnd( wxPoint( m_dragPoint->GetPosition().x, m_dragPoint->GetPosition().y ) );
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
|
|
|
|
m_editPoints->Point( DIM_FEATUREGO ) ) );
|
|
|
|
m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
|
|
|
|
m_editPoints->Point( DIM_FEATUREDO ) ) );
|
2014-03-12 09:53:42 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 09:46:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-06 10:49:08 +00:00
|
|
|
void POINT_EDITOR::finishItem() const
|
|
|
|
{
|
|
|
|
EDA_ITEM* item = m_editPoints->GetParent();
|
|
|
|
|
|
|
|
if( item->Type() == PCB_ZONE_AREA_T )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
|
|
|
|
|
|
|
|
if( zone->IsFilled() )
|
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 14:50:31 +00:00
|
|
|
void POINT_EDITOR::updatePoints()
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 15:53:28 +00:00
|
|
|
EDA_ITEM* item = m_editPoints->GetParent();
|
|
|
|
|
|
|
|
switch( item->Type() )
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
|
|
|
case PCB_LINE_T:
|
2014-07-09 11:50:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
2014-02-28 15:53:28 +00:00
|
|
|
const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
|
2014-02-27 16:29:08 +00:00
|
|
|
{
|
|
|
|
switch( segment->GetShape() )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
|
|
|
|
m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
|
|
|
|
m_editPoints->Point( ARC_START).SetPosition( segment->GetArcStart() );
|
|
|
|
m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-28 17:24:13 +00:00
|
|
|
case S_CIRCLE:
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
|
|
|
|
m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
|
2014-02-28 17:24:13 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
default: // suppress warnings
|
|
|
|
break;
|
|
|
|
}
|
2014-02-28 17:24:29 +00:00
|
|
|
|
|
|
|
break;
|
2014-02-27 16:29:08 +00:00
|
|
|
}
|
2014-02-28 17:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
{
|
|
|
|
const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( item );
|
|
|
|
const CPolyLine* outline = zone->Outline();
|
|
|
|
|
2014-07-09 14:50:31 +00:00
|
|
|
if( m_editPoints->PointsSize() != (unsigned) outline->GetCornersCount() )
|
|
|
|
{
|
|
|
|
getView()->Remove( m_editPoints.get() );
|
|
|
|
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
|
|
|
getView()->Add( m_editPoints.get() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( int i = 0; i < outline->GetCornersCount(); ++i )
|
|
|
|
m_editPoints->Point( i ).SetPosition( outline->GetPos( i ) );
|
|
|
|
}
|
2014-02-28 17:24:29 +00:00
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-12 09:46:11 +00:00
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
{
|
|
|
|
const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
|
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
|
|
|
|
m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
|
|
|
|
m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
|
|
|
|
m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
|
2014-03-12 09:46:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-27 16:29:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-03-06 16:34:04 +00:00
|
|
|
|
|
|
|
|
2014-03-14 14:37:55 +00:00
|
|
|
void POINT_EDITOR::setAltConstraint( bool aEnabled )
|
|
|
|
{
|
|
|
|
if( aEnabled )
|
|
|
|
{
|
|
|
|
EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_dragPoint );
|
2014-04-02 07:31:35 +00:00
|
|
|
|
2014-03-14 14:37:55 +00:00
|
|
|
if( line )
|
|
|
|
{
|
|
|
|
if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
|
2014-04-02 07:31:35 +00:00
|
|
|
m_altConstraint.reset( (EDIT_CONSTRAINT<EDIT_POINT>*)( new EC_CONVERGING( *line, *m_editPoints ) ) );
|
2014-03-14 14:37:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Find a proper constraining point for 45 degrees mode
|
|
|
|
m_altConstrainer = get45DegConstrainer();
|
|
|
|
m_altConstraint.reset( new EC_45DEGREE( *m_dragPoint, m_altConstrainer ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_altConstraint.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-06 16:34:04 +00:00
|
|
|
EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
|
|
|
|
{
|
|
|
|
EDA_ITEM* item = m_editPoints->GetParent();
|
|
|
|
|
2014-03-13 10:48:19 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_LINE_T:
|
2014-07-09 11:50:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2014-03-06 16:34:04 +00:00
|
|
|
{
|
|
|
|
const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
|
|
|
|
{
|
|
|
|
switch( segment->GetShape() )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
|
|
|
return *( m_editPoints->Next( *m_dragPoint ) ); // select the other end of line
|
|
|
|
|
|
|
|
case S_ARC:
|
|
|
|
case S_CIRCLE:
|
2014-04-01 15:41:24 +00:00
|
|
|
return m_editPoints->Point( CIRC_CENTER );
|
2014-03-06 16:34:04 +00:00
|
|
|
|
|
|
|
default: // suppress warnings
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-03-13 10:48:19 +00:00
|
|
|
|
|
|
|
break;
|
2014-03-06 16:34:04 +00:00
|
|
|
}
|
2014-03-13 10:48:19 +00:00
|
|
|
|
|
|
|
case PCB_DIMENSION_T:
|
2014-03-12 09:46:11 +00:00
|
|
|
{
|
|
|
|
// Constraint for crossbar
|
2014-04-01 15:41:24 +00:00
|
|
|
if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
|
|
|
|
return m_editPoints->Point( DIM_FEATUREDO );
|
2014-03-12 09:53:42 +00:00
|
|
|
|
2014-04-01 15:41:24 +00:00
|
|
|
else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
|
|
|
|
return m_editPoints->Point( DIM_FEATUREGO );
|
2014-03-13 10:48:19 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
return EDIT_POINT( m_dragPoint->GetPosition() ); // no constraint
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-03-12 09:46:11 +00:00
|
|
|
}
|
2014-03-06 16:34:04 +00:00
|
|
|
|
2014-03-14 14:15:38 +00:00
|
|
|
// In any other case we may align item to its original position
|
2014-03-13 10:48:19 +00:00
|
|
|
return m_original;
|
2014-03-06 16:34:04 +00:00
|
|
|
}
|
2014-03-18 13:52:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint )
|
|
|
|
{
|
|
|
|
EDA_ITEM* item = m_editPoints->GetParent();
|
2014-07-09 13:10:32 +00:00
|
|
|
const SELECTION& selection = m_selectionTool->GetSelection();
|
2014-03-18 13:52:22 +00:00
|
|
|
|
|
|
|
if( item->Type() == PCB_ZONE_AREA_T )
|
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
getEditFrame<PCB_BASE_FRAME>()->OnModify();
|
|
|
|
getEditFrame<PCB_BASE_FRAME>()->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
2014-03-18 13:52:22 +00:00
|
|
|
|
|
|
|
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
|
|
|
|
CPolyLine* outline = zone->Outline();
|
|
|
|
|
|
|
|
// Handle the last segment, so other segments can be easily handled in a loop
|
|
|
|
unsigned int nearestIdx = outline->GetCornersCount() - 1, nextNearestIdx = 0;
|
|
|
|
SEG side( VECTOR2I( outline->GetPos( nearestIdx ) ),
|
|
|
|
VECTOR2I( outline->GetPos( nextNearestIdx ) ) );
|
|
|
|
unsigned int nearestDist = side.Distance( aBreakPoint );
|
|
|
|
|
2014-04-07 12:30:38 +00:00
|
|
|
for( int i = 0; i < outline->GetCornersCount() - 1; ++i )
|
2014-03-18 13:52:22 +00:00
|
|
|
{
|
2014-04-07 12:30:38 +00:00
|
|
|
side = SEG( VECTOR2I( outline->GetPos( i ) ), VECTOR2I( outline->GetPos( i + 1 ) ) );
|
2014-03-18 13:52:22 +00:00
|
|
|
|
|
|
|
unsigned int distance = side.Distance( aBreakPoint );
|
|
|
|
if( distance < nearestDist )
|
|
|
|
{
|
|
|
|
nearestDist = distance;
|
|
|
|
nearestIdx = i;
|
|
|
|
nextNearestIdx = i + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the point on the closest segment
|
2014-03-18 16:02:10 +00:00
|
|
|
VECTOR2I sideOrigin( outline->GetPos( nearestIdx ) );
|
|
|
|
VECTOR2I sideEnd( outline->GetPos( nextNearestIdx ) );
|
|
|
|
SEG nearestSide( sideOrigin, sideEnd );
|
2014-03-18 13:52:22 +00:00
|
|
|
VECTOR2I nearestPoint = nearestSide.NearestPoint( aBreakPoint );
|
|
|
|
|
2014-03-18 16:02:10 +00:00
|
|
|
// Do not add points that have the same coordinates as ones that already belong to polygon
|
|
|
|
// instead, add a point in the middle of the side
|
|
|
|
if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
|
|
|
|
nearestPoint = ( sideOrigin + sideEnd ) / 2;
|
|
|
|
|
2014-03-18 13:52:22 +00:00
|
|
|
outline->InsertCorner( nearestIdx, nearestPoint.x, nearestPoint.y );
|
|
|
|
}
|
2014-03-18 14:46:38 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
|
2014-03-18 14:46:38 +00:00
|
|
|
{
|
2014-07-09 13:02:56 +00:00
|
|
|
bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
getEditFrame<PCB_BASE_FRAME>()->OnModify();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
if( moduleEdge )
|
|
|
|
getEditFrame<PCB_BASE_FRAME>()->SaveCopyInUndoList( getModel<BOARD>()->m_Modules, UR_MODEDIT );
|
|
|
|
else
|
|
|
|
getEditFrame<PCB_BASE_FRAME>()->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
2014-03-18 14:46:38 +00:00
|
|
|
|
|
|
|
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
|
|
|
|
|
|
|
|
if( segment->GetShape() == S_SEGMENT )
|
|
|
|
{
|
|
|
|
SEG seg( segment->GetStart(), segment->GetEnd() );
|
|
|
|
VECTOR2I nearestPoint = seg.NearestPoint( aBreakPoint );
|
|
|
|
|
|
|
|
// Move the end of the line to the break point..
|
|
|
|
segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
|
|
|
|
|
|
|
|
// and add another one starting from the break point
|
2014-07-09 13:02:56 +00:00
|
|
|
DRAWSEGMENT* newSegment;
|
|
|
|
|
|
|
|
if( moduleEdge )
|
|
|
|
{
|
|
|
|
EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
|
|
|
|
assert( segment->GetParent()->Type() == PCB_MODULE_T );
|
|
|
|
newSegment = new EDGE_MODULE( *edge );
|
|
|
|
edge->SetLocalCoord();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newSegment = new DRAWSEGMENT( *segment );
|
|
|
|
}
|
|
|
|
|
2014-03-18 14:46:38 +00:00
|
|
|
newSegment->ClearSelected();
|
|
|
|
newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
|
|
|
|
newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
|
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
if( moduleEdge )
|
|
|
|
{
|
|
|
|
static_cast<EDGE_MODULE*>( newSegment )->SetLocalCoord();
|
|
|
|
getModel<BOARD>()->m_Modules->Add( newSegment );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
getModel<BOARD>()->Add( newSegment );
|
|
|
|
}
|
|
|
|
|
2014-03-18 14:46:38 +00:00
|
|
|
getView()->Add( newSegment );
|
|
|
|
}
|
|
|
|
}
|
2014-03-18 13:52:22 +00:00
|
|
|
}
|
2014-07-09 14:50:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
void POINT_EDITOR::setTransitions()
|
|
|
|
{
|
|
|
|
Go( &POINT_EDITOR::OnSelectionChange, m_selectionTool->SelectedEvent );
|
|
|
|
Go( &POINT_EDITOR::OnSelectionChange, m_selectionTool->DeselectedEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool POINT_EDITOR::breakOutlineCondition( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
if( aSelection.Size() != 1 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
BOARD_ITEM* item = aSelection.Item<BOARD_ITEM>( 0 );
|
|
|
|
|
|
|
|
// Works only for zones and line segments
|
|
|
|
return item->Type() == PCB_ZONE_AREA_T ||
|
|
|
|
( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
|
|
|
|
static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
|
|
|
|
}
|