7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 17:39:17 +00:00

Merge selection tool branch.

This commit is contained in:
Maciej Suminski 2014-03-11 20:45:01 -04:00 committed by Wayne Stambaugh
commit f0251ebdb6
144 changed files with 3519 additions and 2517 deletions
CMakeLists.txt
common
cvpcb
eeschema
gerbview
include
pcbnew
CMakeLists.txtattribut.cpp
autorouter
board_undo_redo.cppclass_board.cppclass_board.hclass_board_connected_item.cppclass_board_connected_item.hclass_board_design_settings.cppclass_drawsegment.cppclass_drawsegment.hclass_module.cppclass_module.hclass_netclass.cppclass_netinfo.hclass_netinfo_item.cppclass_netinfolist.cppclass_pad.cppclass_pad.hclass_pad_draw_functions.cppclass_text_mod.cppclass_text_mod.hclass_track.cppclass_zone.cppclass_zone.hclass_zone_settings.cppclean.cppconnect.cppcross-probing.cppdeltrack.cpp
dialogs
dragsegm.cppdrc.cppdrc_clearance_test_functions.cppeagle_plugin.cppedit.cppedit_track_width.cppeditrack-part2.cppeditrack.cpp
exporters
footprint_wizard_frame.hhighlight.cppkicad_plugin.cppkicad_plugin.hlegacy_plugin.cpplegacy_plugin.hmagnetic_tracks_functions.cppmenubar_pcbframe.cppminimun_spanning_tree.cppmodedit_undo_redo.cppmodule_editor_frame.hmodview_frame.hmove_or_drag_track.cpppad_edition_functions.cpp
pcad2kicadpcb_plugin
pcb_netlist.hpcb_painter.cpppcb_parser.cpppcb_parser.hpcbframe.cpppcbnew_id.hratsnest.cppratsnest_data.cppratsnest_data.hratsnest_viewitem.cpp
router
specctra_export.cppspecctra_import.cpp
tools
tr_modif.cpptracepcb.cppxchgmod.cppzones_by_polygon.cppzones_by_polygon_fill_functions.cppzones_convert_brd_items_to_polygons_with_Boost.cppzones_convert_to_polygons_aux_functions.cppzones_functions_for_undo_redo.cppzones_polygons_insulated_copper_islands.cppzones_polygons_test_connections.cppzones_test_and_combine_areas.cpp

View File

@ -149,6 +149,13 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" )
endif()
find_package( OpenMP QUIET )
if( OPENMP_FOUND )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
add_definitions( -DUSE_OPENMP )
endif()
if( MINGW )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )

View File

@ -219,6 +219,8 @@ set( PCB_COMMON_SRCS
../pcbnew/class_zone.cpp
../pcbnew/class_zone_settings.cpp
../pcbnew/classpcb.cpp
../pcbnew/ratsnest_data.cpp
../pcbnew/ratsnest_viewitem.cpp
../pcbnew/collectors.cpp
../pcbnew/netlist_reader.cpp
../pcbnew/legacy_netlist_reader.cpp

View File

@ -50,7 +50,7 @@ PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()
}
void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem )
void PICKED_ITEMS_LIST::PushItem( const ITEM_PICKER& aItem )
{
m_ItemsList.push_back( aItem );
}
@ -70,7 +70,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem()
}
bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
bool PICKED_ITEMS_LIST::ContainsItem( const EDA_ITEM* aItem ) const
{
for( size_t i = 0; i < m_ItemsList.size(); i++ )
{
@ -82,6 +82,18 @@ bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
}
int PICKED_ITEMS_LIST::FindItem( const EDA_ITEM* aItem ) const
{
for( size_t i = 0; i < m_ItemsList.size(); i++ )
{
if( m_ItemsList[i].GetItem() == aItem )
return i;
}
return -1;
}
void PICKED_ITEMS_LIST::ClearItemsList()
{
m_ItemsList.clear();
@ -157,7 +169,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
}
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) const
{
ITEM_PICKER picker;
@ -168,7 +180,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
}
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetItem();
@ -177,7 +189,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
}
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetLink();
@ -186,7 +198,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
}
UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetStatus();
@ -195,7 +207,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
}
STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetFlags();

View File

@ -78,18 +78,21 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
/* Generic events for the Tool Dispatcher */
Connect( wxEVT_MOTION, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) );
Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( wxEVT_MOTION, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_DCLICK, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_DCLICK, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DCLICK, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) );
Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE,
wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );

View File

@ -57,15 +57,18 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
// Mouse events are skipped to the parent
Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
#if defined _WIN32 || defined _WIN64
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
#endif
SetSize( aParent->GetSize() );

View File

@ -34,11 +34,11 @@
#include <typeinfo>
#include <wx/msgdlg.h>
#include <confirm.h>
#ifdef __WXDEBUG__
#ifdef PROFILE
#include <profile.h>
#include <wx/debug.h>
#include <wx/log.h>
#endif
#endif /* PROFILE */
using namespace KIGFX;
@ -187,10 +187,10 @@ void GPU_CACHED_MANAGER::EndDrawing()
void GPU_CACHED_MANAGER::uploadToGpu()
{
#ifdef __WXDEBUG__
#ifdef PROFILE
prof_counter totalTime;
prof_start( &totalTime );
#endif /* __WXDEBUG__ */
#endif /* PROFILE */
if( !m_buffersInitialized )
Initialize();
@ -207,15 +207,13 @@ void GPU_CACHED_MANAGER::uploadToGpu()
m_indices.reset( new GLuint[bufferSize] );
if( glGetError() != GL_NO_ERROR )
{
DisplayError( NULL, wxT( "Error during data upload to the GPU memory" ) );
}
#ifdef __WXDEBUG__
#ifdef PROFILE
prof_end( &totalTime );
wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* PROFILE */
}

View File

@ -70,15 +70,18 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) );
// Mouse events are skipped to the parent
Connect( wxEVT_MOTION, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_MOTION, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
#if defined _WIN32 || defined _WIN64
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
#endif
SetSize( aParent->GetSize() );

View File

@ -45,14 +45,14 @@
#include <algorithm>
#include <fstream>
#include <limits>
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
using namespace hed;
using namespace std;
Triangulation* TTLtraits::triang_ = NULL;
#ifdef TTL_USE_NODE_ID
int Node::id_count = 0;
#endif
@ -117,28 +117,27 @@ EdgePtr Triangulation::initTwoEnclosingTriangles(NodesContainer::iterator first,
double dx = (xmax-xmin)/fac;
double dy = (ymax-ymin)/fac;
NodePtr n1(new Node(xmin-dx,ymin-dy));
NodePtr n2(new Node(xmax+dx,ymin-dy));
NodePtr n3(new Node(xmax+dx,ymax+dy));
NodePtr n4(new Node(xmin-dx,ymax+dy));
NodePtr n1 = boost::make_shared<Node>(xmin-dx, ymin-dy);
NodePtr n2 = boost::make_shared<Node>(xmax+dx, ymin-dy);
NodePtr n3 = boost::make_shared<Node>(xmax+dx, ymax+dy);
NodePtr n4 = boost::make_shared<Node>(xmin-dx, ymax+dy);
// diagonal
EdgePtr e1d(new Edge); // lower
EdgePtr e2d(new Edge); // upper, the twin edge
EdgePtr e1d = boost::make_shared<Edge>();
EdgePtr e2d = boost::make_shared<Edge>();
// lower triangle
EdgePtr e11(new Edge);
EdgePtr e12(new Edge);
EdgePtr e11 = boost::make_shared<Edge>();
EdgePtr e12 = boost::make_shared<Edge>();
// upper triangle
EdgePtr e21(new Edge); // upper upper
EdgePtr e22(new Edge);
EdgePtr e21 = boost::make_shared<Edge>();
EdgePtr e22 = boost::make_shared<Edge>();
// lower triangle
e1d->setSourceNode(n3);
e1d->setNextEdgeInFace(e11);
e1d->setTwinEdge(e2d);
e1d->setAsLeadingEdge();
addLeadingEdge(e1d);
e11->setSourceNode(n1);
@ -151,7 +150,6 @@ EdgePtr Triangulation::initTwoEnclosingTriangles(NodesContainer::iterator first,
e2d->setSourceNode(n1);
e2d->setNextEdgeInFace(e21);
e2d->setTwinEdge(e1d);
e2d->setAsLeadingEdge();
addLeadingEdge(e2d);
e21->setSourceNode(n3);
@ -164,11 +162,30 @@ EdgePtr Triangulation::initTwoEnclosingTriangles(NodesContainer::iterator first,
}
//--------------------------------------------------------------------------------------------------
Triangulation::Triangulation() {
helper = new ttl::TriangulationHelper( *this );
}
//--------------------------------------------------------------------------------------------------
Triangulation::Triangulation(const Triangulation& tr) {
std::cout << "Triangulation: Copy constructor not present - EXIT.";
exit(-1);
}
//--------------------------------------------------------------------------------------------------
Triangulation::~Triangulation() {
cleanAll();
delete helper;
}
//--------------------------------------------------------------------------------------------------
void Triangulation::createDelaunay(NodesContainer::iterator first,
NodesContainer::iterator last) {
TTLtraits::triang_ = this;
cleanAll();
EdgePtr bedge = initTwoEnclosingTriangles(first, last);
@ -178,7 +195,7 @@ void Triangulation::createDelaunay(NodesContainer::iterator first,
NodesContainer::iterator it;
for (it = first; it != last; ++it) {
ttl::insertNode<TTLtraits>(d_iter, *it);
helper->insertNode<TTLtraits>(d_iter, *it);
}
// In general (e.g. for the triangle based data structure), the initial dart
@ -189,7 +206,7 @@ void Triangulation::createDelaunay(NodesContainer::iterator first,
// triangle "outside" the triangulation.)
// Assumes rectangular domain
ttl::removeRectangularBoundary<TTLtraits>(dc);
helper->removeRectangularBoundary<TTLtraits>(dc);
}
@ -206,15 +223,12 @@ void Triangulation::removeTriangle(EdgePtr& edge) {
removeLeadingEdgeFromList(e1);
// cout << "No leading edges = " << leadingEdges_.size() << endl;
// Remove the triangle
EdgePtr e2 = e1->getNextEdgeInFace();
EdgePtr e3 = e2->getNextEdgeInFace();
if (e1->getTwinEdge())
e1->getTwinEdge()->setTwinEdge(EdgePtr());
if (e2->getTwinEdge())
e2->getTwinEdge()->setTwinEdge(EdgePtr());
if (e3->getTwinEdge())
e3->getTwinEdge()->setTwinEdge(EdgePtr());
EdgePtr e2(e1->getNextEdgeInFace());
EdgePtr e3(e2->getNextEdgeInFace());
e1->clear();
e2->clear();
e3->clear();
}
@ -223,15 +237,15 @@ void Triangulation::reverse_splitTriangle(EdgePtr& edge) {
// Reverse operation of splitTriangle
EdgePtr e1 = edge->getNextEdgeInFace();
EdgePtr le = getLeadingEdgeInTriangle(e1);
EdgePtr e1(edge->getNextEdgeInFace());
EdgePtr le(getLeadingEdgeInTriangle(e1));
#ifdef DEBUG_HE
if (!le)
errorAndExit("Triangulation::removeTriangle: could not find leading edge");
#endif
removeLeadingEdgeFromList(le);
EdgePtr e2 = e1->getNextEdgeInFace()->getTwinEdge()->getNextEdgeInFace();
EdgePtr e2(e1->getNextEdgeInFace()->getTwinEdge()->getNextEdgeInFace());
le = getLeadingEdgeInTriangle(e2);
#ifdef DEBUG_HE
if (!le)
@ -239,7 +253,7 @@ void Triangulation::reverse_splitTriangle(EdgePtr& edge) {
#endif
removeLeadingEdgeFromList(le);
EdgePtr e3 = edge->getTwinEdge()->getNextEdgeInFace()->getNextEdgeInFace();
EdgePtr e3(edge->getTwinEdge()->getNextEdgeInFace()->getNextEdgeInFace());
le = getLeadingEdgeInTriangle(e3);
#ifdef DEBUG_HE
if (!le)
@ -251,6 +265,19 @@ void Triangulation::reverse_splitTriangle(EdgePtr& edge) {
// from the triangulation, but the arcs have not been deleted.
// Next delete the 6 half edges radiating from the node
// The node is maintained by handle and need not be deleted explicitly
EdgePtr estar = edge;
EdgePtr enext = estar->getTwinEdge()->getNextEdgeInFace();
estar->getTwinEdge()->clear();
estar->clear();
estar = enext;
enext = estar->getTwinEdge()->getNextEdgeInFace();
estar->getTwinEdge()->clear();
estar->clear();
enext->getTwinEdge()->clear();
enext->clear();
// Create the new triangle
e1->setNextEdgeInFace(e2);
@ -260,25 +287,6 @@ void Triangulation::reverse_splitTriangle(EdgePtr& edge) {
}
//--------------------------------------------------------------------------------------------------
// This is a "template" for iterating the boundary
/*
static void iterateBoundary(const Dart& dart) {
cout << "Iterate boundary 2" << endl;
// input is a dart at the boundary
Dart dart_iter = dart;
do {
if (ttl::isBoundaryEdge(dart_iter))
dart_iter.alpha0().alpha1();
else
dart_iter.alpha2().alpha1();
} while(dart_iter != dart);
}
*/
//--------------------------------------------------------------------------------------------------
Dart Triangulation::createDart() {
@ -305,20 +313,43 @@ bool Triangulation::removeLeadingEdgeFromList(EdgePtr& leadingEdge) {
edge->setAsLeadingEdge(false);
it = leadingEdges_.erase(it);
break;
return true;
}
}
if (it == leadingEdges_.end())
return false;
return true;
return false;
}
//--------------------------------------------------------------------------------------------------
void Triangulation::cleanAll() {
leadingEdges_.clear();
BOOST_FOREACH(EdgePtr& edge, leadingEdges_)
edge->setNextEdgeInFace(EdgePtr());
}
//--------------------------------------------------------------------------------------------------
void Triangulation::swapEdge(Dart& dart) {
swapEdge(dart.getEdge());
}
//--------------------------------------------------------------------------------------------------
void Triangulation::splitTriangle(Dart& dart, const NodePtr& point) {
EdgePtr edge = splitTriangle(dart.getEdge(), point);
dart.init(edge);
}
//--------------------------------------------------------------------------------------------------
void Triangulation::reverse_splitTriangle(Dart& dart) {
reverse_splitTriangle(dart.getEdge());
}
//--------------------------------------------------------------------------------------------------
void Triangulation::removeBoundaryTriangle(Dart& d) {
removeTriangle(d.getEdge());
}
@ -390,7 +421,7 @@ list<EdgePtr>* Triangulation::getEdges(bool skip_boundary_edges) const {
//--------------------------------------------------------------------------------------------------
EdgePtr Triangulation::splitTriangle(EdgePtr& edge, NodePtr& point) {
EdgePtr Triangulation::splitTriangle(EdgePtr& edge, const NodePtr& point) {
// Add a node by just splitting a triangle into three triangles
// Assumes the half edge is located in the triangle
@ -409,21 +440,21 @@ EdgePtr Triangulation::splitTriangle(EdgePtr& edge, NodePtr& point) {
// Add the node to the structure
//NodePtr new_node(new Node(x,y,z));
NodePtr n1 = edge->getSourceNode();
EdgePtr e1 = edge;
NodePtr n1(edge->getSourceNode());
EdgePtr e1(edge);
EdgePtr e2 = edge->getNextEdgeInFace();
NodePtr n2 = e2->getSourceNode();
EdgePtr e2(edge->getNextEdgeInFace());
NodePtr n2(e2->getSourceNode());
EdgePtr e3 = e2->getNextEdgeInFace();
NodePtr n3 = e3->getSourceNode();
EdgePtr e3(e2->getNextEdgeInFace());
NodePtr n3(e3->getSourceNode());
EdgePtr e1_n(new Edge);
EdgePtr e11_n(new Edge);
EdgePtr e2_n(new Edge);
EdgePtr e22_n(new Edge);
EdgePtr e3_n(new Edge);
EdgePtr e33_n(new Edge);
EdgePtr e1_n = boost::make_shared<Edge>();
EdgePtr e11_n = boost::make_shared<Edge>();
EdgePtr e2_n = boost::make_shared<Edge>();
EdgePtr e22_n = boost::make_shared<Edge>();
EdgePtr e3_n = boost::make_shared<Edge>();
EdgePtr e33_n = boost::make_shared<Edge>();
e1_n->setSourceNode(n1);
e11_n->setSourceNode(point);
@ -447,7 +478,6 @@ EdgePtr Triangulation::splitTriangle(EdgePtr& edge, NodePtr& point) {
e22_n->setNextEdgeInFace(e2);
e33_n->setNextEdgeInFace(e3);
// and update old's next edge
e1->setNextEdgeInFace(e2_n);
e2->setNextEdgeInFace(e3_n);
@ -458,18 +488,14 @@ EdgePtr Triangulation::splitTriangle(EdgePtr& edge, NodePtr& point) {
// Use the field telling if an edge is a leading edge
// NOTE: Must search in the list!!!
EdgePtr leadingEdge;
if (e1->isLeadingEdge())
leadingEdge = e1;
removeLeadingEdgeFromList(e1);
else if (e2->isLeadingEdge())
leadingEdge = e2;
removeLeadingEdgeFromList(e2);
else if(e3->isLeadingEdge())
leadingEdge = e3;
removeLeadingEdgeFromList(e3);
else
return EdgePtr();
removeLeadingEdgeFromList(leadingEdge);
assert( false ); // one of the edges should be leading
addLeadingEdge(e1_n);
addLeadingEdge(e2_n);
@ -486,20 +512,20 @@ void Triangulation::swapEdge(EdgePtr& diagonal) {
// Note that diagonal is both input and output and it is always
// kept in counterclockwise direction (this is not required by all
// finctions in ttl:: now)
// functions in TriangulationHelper now)
// Swap by rotating counterclockwise
// Use the same objects - no deletion or new objects
EdgePtr eL = diagonal;
EdgePtr eR = eL->getTwinEdge();
EdgePtr eL_1 = eL->getNextEdgeInFace();
EdgePtr eL_2 = eL_1->getNextEdgeInFace();
EdgePtr eR_1 = eR->getNextEdgeInFace();
EdgePtr eR_2 = eR_1->getNextEdgeInFace();
EdgePtr eL(diagonal);
EdgePtr eR(eL->getTwinEdge());
EdgePtr eL_1(eL->getNextEdgeInFace());
EdgePtr eL_2(eL_1->getNextEdgeInFace());
EdgePtr eR_1(eR->getNextEdgeInFace());
EdgePtr eR_2(eR_1->getNextEdgeInFace());
// avoid node to be dereferenced to zero and deleted
NodePtr nR = eR_2->getSourceNode();
NodePtr nL = eL_2->getSourceNode();
NodePtr nR(eR_2->getSourceNode());
NodePtr nL(eL_2->getSourceNode());
eL->setSourceNode(nR);
eR->setSourceNode(nL);
@ -513,24 +539,20 @@ void Triangulation::swapEdge(EdgePtr& diagonal) {
eR_2->setNextEdgeInFace(eL_1);
eL_1->setNextEdgeInFace(eR);
EdgePtr leL;
if (eL->isLeadingEdge())
leL = eL;
removeLeadingEdgeFromList(eL);
else if (eL_1->isLeadingEdge())
leL = eL_1;
removeLeadingEdgeFromList(eL_1);
else if (eL_2->isLeadingEdge())
leL = eL_2;
removeLeadingEdgeFromList(eL_2);
EdgePtr leR;
if (eR->isLeadingEdge())
leR = eR;
removeLeadingEdgeFromList(eR);
else if (eR_1->isLeadingEdge())
leR = eR_1;
removeLeadingEdgeFromList(eR_1);
else if (eR_2->isLeadingEdge())
leR = eR_2;
removeLeadingEdgeFromList(eR_2);
removeLeadingEdgeFromList(leL);
removeLeadingEdgeFromList(leR);
addLeadingEdge(eL);
addLeadingEdge(eR);
}
@ -567,7 +589,7 @@ bool Triangulation::checkDelaunay() const {
// only one of the half-edges
if (!twinedge || (size_t)edge.get() > (size_t)twinedge.get()) {
Dart dart(edge);
if (ttl::swapTestDelaunay<TTLtraits>(dart)) {
if (helper->swapTestDelaunay<TTLtraits>(dart)) {
noNotDelaunay++;
//printEdge(dart,os); os << "\n";
@ -610,7 +632,7 @@ void Triangulation::optimizeDelaunay() {
Dart dart(edge);
// Constrained edges should not be swapped
if (!edge->isConstrained() && ttl::swapTestDelaunay<TTLtraits>(dart, cycling_check)) {
if (helper->swapTestDelaunay<TTLtraits>(dart, cycling_check)) {
optimal = false;
swapEdge(edge);
}
@ -632,7 +654,7 @@ EdgePtr Triangulation::getInteriorNode() const {
for (int i = 0; i < 3; ++i) {
if (edge->getTwinEdge()) {
if (!ttl::isBoundaryNode(Dart(edge)))
if (!helper->isBoundaryNode(Dart(edge)))
return edge;
}
edge = edge->getNextEdgeInFace();
@ -643,18 +665,18 @@ EdgePtr Triangulation::getInteriorNode() const {
//--------------------------------------------------------------------------------------------------
static EdgePtr getBoundaryEdgeInTriangle(const EdgePtr& e) {
EdgePtr Triangulation::getBoundaryEdgeInTriangle(const EdgePtr& e) const {
EdgePtr edge = e;
if (ttl::isBoundaryEdge(Dart(edge)))
if (helper->isBoundaryEdge(Dart(edge)))
return edge;
edge = edge->getNextEdgeInFace();
if (ttl::isBoundaryEdge(Dart(edge)))
if (helper->isBoundaryEdge(Dart(edge)))
return edge;
edge = edge->getNextEdgeInFace();
if (ttl::isBoundaryEdge(Dart(edge)))
if (helper->isBoundaryEdge(Dart(edge)))
return edge;
return EdgePtr();

View File

@ -34,9 +34,18 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
}
ACTION_MANAGER::~ACTION_MANAGER()
{
while( !m_actionIdIndex.empty() )
UnregisterAction( m_actionIdIndex.begin()->second );
}
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
{
assert( aAction->GetId() == -1 ); // Check if the TOOL_ACTION was not registered before
assert( m_actionNameIndex.find( aAction->m_name ) == m_actionNameIndex.end() );
assert( m_actionIdIndex.find( aAction->m_id ) == m_actionIdIndex.end() );
aAction->setId( MakeActionId( aAction->m_name ) );
@ -44,7 +53,13 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
m_actionIdIndex[aAction->m_id] = aAction;
if( aAction->HasHotKey() )
{
// Duplication of hot keys leads to unexpected behaviour
// The right way to change a hotkey is to use ACTION_MANAGER::ClearHotKey() first
assert( m_actionHotKeys.find( aAction->m_currentHotKey ) == m_actionHotKeys.end() );
m_actionHotKeys[aAction->m_currentHotKey] = aAction;
}
aAction->setActionMgr( this );
}
@ -52,13 +67,13 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
{
m_actionNameIndex.erase( aAction->m_name );
m_actionIdIndex.erase( aAction->m_id );
// Indicate that the ACTION_MANAGER no longer care about the object
aAction->setActionMgr( NULL );
aAction->setId( -1 );
m_actionNameIndex.erase( aAction->m_name );
m_actionIdIndex.erase( aAction->m_id );
if( aAction->HasHotKey() )
m_actionHotKeys.erase( aAction->m_currentHotKey );
}
@ -98,6 +113,12 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
}
void ACTION_MANAGER::ClearHotKey( int aHotKey )
{
m_actionHotKeys.erase( aHotKey );
}
void ACTION_MANAGER::runAction( const TOOL_ACTION* aAction ) const
{
TOOL_EVENT event = aAction->MakeEvent();

View File

@ -29,7 +29,7 @@
#include <cassert>
CONTEXT_MENU::CONTEXT_MENU() :
m_titleSet( false ), m_handler( this ), m_tool( NULL )
m_titleSet( false ), m_selected( -1 ), m_handler( this ), m_tool( NULL )
{
m_menu.Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CMEventHandler::onEvent ),
NULL, &m_handler );
@ -43,7 +43,7 @@ CONTEXT_MENU::CONTEXT_MENU() :
CONTEXT_MENU::CONTEXT_MENU( const CONTEXT_MENU& aMenu ) :
m_titleSet( aMenu.m_titleSet ), m_handler( this ), m_tool( aMenu.m_tool )
m_titleSet( aMenu.m_titleSet ), m_selected( -1 ), m_handler( this ), m_tool( aMenu.m_tool )
{
m_menu.Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CMEventHandler::onEvent ),
NULL, &m_handler );
@ -164,6 +164,9 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
// One of menu entries was selected..
else if( type == wxEVT_COMMAND_MENU_SELECTED )
{
// Store the selected position
m_menu->m_selected = aEvent.GetId();
// Check if there is a TOOL_ACTION for the given ID
if( m_menu->m_toolActions.count( aEvent.GetId() ) == 1 )
{

View File

@ -43,10 +43,11 @@ using boost::optional;
struct TOOL_DISPATCHER::BUTTON_STATE
{
BUTTON_STATE( TOOL_MOUSE_BUTTONS aButton, const wxEventType& aDownEvent,
const wxEventType& aUpEvent ) :
const wxEventType& aUpEvent, const wxEventType& aDblClickEvent ) :
button( aButton ),
downEvent( aDownEvent ),
upEvent( aUpEvent )
upEvent( aUpEvent ),
dblClickEvent( aDblClickEvent )
{};
///> Flag indicating that dragging is active for the given button.
@ -74,6 +75,9 @@ struct TOOL_DISPATCHER::BUTTON_STATE
///> The type of wxEvent that determines mouse button release.
wxEventType upEvent;
///> The type of wxEvent that determines mouse button double click.
wxEventType dblClickEvent;
///> Time stamp for the last mouse button press event.
wxLongLong downTimestamp;
@ -89,9 +93,12 @@ struct TOOL_DISPATCHER::BUTTON_STATE
TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditFrame ) :
m_toolMgr( aToolMgr ), m_editFrame( aEditFrame )
{
m_buttons.push_back( new BUTTON_STATE( BUT_LEFT, wxEVT_LEFT_DOWN, wxEVT_LEFT_UP ) );
m_buttons.push_back( new BUTTON_STATE( BUT_RIGHT, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_UP ) );
m_buttons.push_back( new BUTTON_STATE( BUT_MIDDLE, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_UP ) );
m_buttons.push_back( new BUTTON_STATE( BUT_LEFT, wxEVT_LEFT_DOWN,
wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) );
m_buttons.push_back( new BUTTON_STATE( BUT_RIGHT, wxEVT_RIGHT_DOWN,
wxEVT_RIGHT_UP, wxEVT_RIGHT_DCLICK ) );
m_buttons.push_back( new BUTTON_STATE( BUT_MIDDLE, wxEVT_MIDDLE_DOWN,
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DCLICK ) );
ResetState();
}
@ -126,6 +133,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
bool up = type == st->upEvent;
bool down = type == st->downEvent;
bool dblClick = type == st->dblClickEvent;
int mods = decodeModifiers<wxMouseEvent>( static_cast<wxMouseEvent*>( &aEvent ) );
int args = st->button | mods;
@ -139,7 +147,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st->pressed = true;
evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_DOWN, args );
}
else if( up ) // Handle mouse button release
else if( up ) // Handle mouse button release
{
st->pressed = false;
@ -162,6 +170,10 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st->dragging = false;
}
else if( dblClick )
{
evt = TOOL_EVENT( TC_MOUSE, TA_MOUSE_DBLCLICK, args );
}
if( st->pressed && aMotion )
{
@ -204,14 +216,15 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP ||
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK ||
// Event issued whem mouse retains position in screen coordinates,
// but changes in world coordinates (eg. autopanning)
// but changes in world coordinates (e.g. autopanning)
type == KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
{
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetCursorPosition();
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetMousePosition();
VECTOR2D pos = getView()->ToWorld( screenPos );
if( pos != m_lastMousePos || type == KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE )
if( pos != m_lastMousePos )
{
motion = true;
m_lastMousePos = pos;
@ -267,11 +280,6 @@ void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent )
toolName = "pcbnew.InteractiveRouter";
activateTool = true;
break;
case ID_SELECTION_TOOL:
toolName = "pcbnew.InteractiveSelection";
activateTool = true;
break;
}
// do nothing if the legacy view is active

View File

@ -75,6 +75,7 @@ const std::string TOOL_EVENT::Format() const
const FlagString actions[] =
{
{ TA_MOUSE_CLICK, "click" },
{ TA_MOUSE_DBLCLICK, "double click" },
{ TA_MOUSE_UP, "button-up" },
{ TA_MOUSE_DOWN, "button-down" },
{ TA_MOUSE_DRAG, "drag" },
@ -90,6 +91,7 @@ const std::string TOOL_EVENT::Format() const
{ TA_CANCEL_TOOL, "cancel-tool" },
{ TA_CONTEXT_MENU_UPDATE, "context-menu-update" },
{ TA_CONTEXT_MENU_CHOICE, "context-menu-choice" },
{ TA_UNDO_REDO, "undo-redo" },
{ TA_ACTION, "action" },
{ 0, "" }
};
@ -100,7 +102,7 @@ const std::string TOOL_EVENT::Format() const
{ BUT_LEFT, "left" },
{ BUT_RIGHT, "right" },
{ BUT_MIDDLE, "middle" },
{ 0, "" }
{ 0, "" }
};
const FlagString modifiers[] =

View File

@ -96,7 +96,7 @@ struct TOOL_MANAGER::TOOL_STATE
TOOL_MANAGER::TOOL_MANAGER() :
m_model( NULL ), m_view( NULL )
m_model( NULL ), m_view( NULL ), m_viewControls( NULL ), m_editFrame( NULL )
{
m_actionMgr = new ACTION_MANAGER( this );
}
@ -119,10 +119,14 @@ TOOL_MANAGER::~TOOL_MANAGER()
void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
{
wxASSERT_MSG( m_toolNameIndex.find( aTool->GetName() ) == m_toolNameIndex.end(),
wxT( "Adding two tools with the same name may result in unexpected behaviour.") );
wxASSERT_MSG( m_toolIdIndex.find( aTool->GetId() ) == m_toolIdIndex.end(),
wxT( "Adding two tools with the same ID may result in unexpected behaviour.") );
TOOL_STATE* st = new TOOL_STATE;
st->theTool = aTool;
st->idle = true;
st->pendingWait = false;
st->pendingContextMenu = false;
st->cofunc = NULL;
@ -134,22 +138,20 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
aTool->m_toolMgr = this;
if( aTool->GetType() == INTERACTIVE )
if( !aTool->Init() )
{
if( !static_cast<TOOL_INTERACTIVE*>( aTool )->Init() )
{
std::string msg = StrPrintf( "Initialization of the %s tool failed", aTool->GetName().c_str() );
std::string msg = StrPrintf( "Initialization of the %s tool failed",
aTool->GetName().c_str() );
DisplayError( NULL, wxString::FromUTF8( msg.c_str() ) );
DisplayError( NULL, wxString::FromUTF8( msg.c_str() ) );
// Unregister the tool
m_toolState.erase( aTool );
m_toolNameIndex.erase( aTool->GetName() );
m_toolIdIndex.erase( aTool->GetId() );
// Unregister the tool
m_toolState.erase( aTool );
m_toolNameIndex.erase( aTool->GetName() );
m_toolIdIndex.erase( aTool->GetId() );
delete st;
delete aTool;
}
delete st;
delete aTool;
}
}
@ -188,6 +190,12 @@ void TOOL_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
}
bool TOOL_MANAGER::RunAction( const std::string& aActionName )
{
return m_actionMgr->RunAction( aActionName );
}
bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
{
wxASSERT( aTool != NULL );
@ -226,17 +234,16 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
wxASSERT( aTool != NULL );
if( !isRegistered( aTool ) )
{
wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
return false;
TOOL_STATE* state = m_toolState[aTool];
}
// If the tool is already active, do not invoke it again
if( state->idle == false )
if( isActive( aTool ) )
return false;
state->idle = false;
static_cast<TOOL_INTERACTIVE*>( aTool )->Reset();
aTool->Reset( TOOL_INTERACTIVE::RUN );
// Add the tool on the front of the processing queue (it gets events first)
m_activeTools.push_front( aTool->GetId() );
@ -267,6 +274,13 @@ TOOL_BASE* TOOL_MANAGER::FindTool( const std::string& aName ) const
}
void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
{
BOOST_FOREACH( TOOL_BASE* tool, m_toolState | boost::adaptors::map_keys )
tool->Reset( aReason );
}
void TOOL_MANAGER::ScheduleNextState( TOOL_BASE* aTool, TOOL_STATE_FUNC& aHandler,
const TOOL_EVENT_LIST& aConditions )
{
@ -333,10 +347,11 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
// Go() method that match the event.
if( st->transitions.size() )
{
BOOST_FOREACH( TRANSITION tr, st->transitions )
BOOST_FOREACH( TRANSITION& tr, st->transitions )
{
if( tr.first.Matches( aEvent ) )
{
// as the state changes, the transition table has to be set up again
st->transitions.clear();
// no tool context allocated yet? Create one.
@ -350,6 +365,9 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
if( !st->cofunc->Running() )
finishTool( st ); // The couroutine has finished immediately?
// there is no point in further checking, as transitions got cleared
break;
}
}
}
@ -394,21 +412,18 @@ bool TOOL_MANAGER::dispatchActivation( TOOL_EVENT& aEvent )
void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
{
// Find the tool to be deactivated
std::deque<TOOL_ID>::iterator it, it_end;
std::deque<TOOL_ID>::iterator it, itEnd;
for( it = m_activeTools.begin(), it_end = m_activeTools.end(); it != it_end; ++it )
// Find the tool and deactivate it
for( it = m_activeTools.begin(), itEnd = m_activeTools.end(); it != itEnd; ++it )
{
if( aState == m_toolIdIndex[*it] )
{
m_activeTools.erase( it );
break;
}
}
if( it != m_activeTools.end() )
m_activeTools.erase( it );
else
wxLogWarning( wxT( "Tried to finish inactive tool" ) );
aState->idle = true;
delete aState->cofunc;
aState->cofunc = NULL;
}
@ -445,9 +460,12 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
boost::scoped_ptr<CONTEXT_MENU> menu( new CONTEXT_MENU( *st->contextMenu ) );
GetEditFrame()->PopupMenu( menu->GetMenu() );
//
TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CHOICE );
dispatchInternal( evt );
// If nothing was chosen from the context menu, we must notify the tool as well
if( menu->GetSelected() < 0 )
{
TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CHOICE );
dispatchInternal( evt );
}
break;
}
@ -456,7 +474,8 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
if( m_view->IsDirty() )
{
PCB_EDIT_FRAME* f = static_cast<PCB_EDIT_FRAME*>( GetEditFrame() );
f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
if( f->IsGalCanvasActive() )
f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
}
return false;
@ -492,15 +511,6 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
m_view = aView;
m_viewControls = aViewControls;
m_editFrame = aFrame;
// Reset state of the registered tools
BOOST_FOREACH( TOOL_ID toolId, m_activeTools )
{
TOOL_BASE* tool = m_toolIdIndex[toolId]->theTool;
if( tool->GetType() == INTERACTIVE )
static_cast<TOOL_INTERACTIVE*>( tool )->Reset();
}
}
@ -509,5 +519,6 @@ bool TOOL_MANAGER::isActive( TOOL_BASE* aTool )
if( !isRegistered( aTool ) )
return false;
return !m_toolState[aTool]->idle;
// Just check if the tool is on the active tools stack
return std::find( m_activeTools.begin(), m_activeTools.end(), aTool->GetId() ) != m_activeTools.end();
}

View File

@ -34,9 +34,9 @@
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#ifdef __WXDEBUG__
#ifdef PROFILE
#include <profile.h>
#endif /* __WXDEBUG__ */
#endif /* PROFILE */
using namespace KIGFX;
@ -122,6 +122,12 @@ void VIEW::Remove( VIEW_ITEM* aItem )
{
VIEW_LAYER& l = m_layers[layers[i]];
l.items->Remove( aItem );
MarkTargetDirty( l.target );
// Clear the GAL cache
int prevGroup = aItem->getGroup( layers[i] );
if( prevGroup >= 0 )
m_gal->DeleteGroup( prevGroup );
}
}
@ -833,7 +839,7 @@ void VIEW::clearGroupCache()
}
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
void VIEW::InvalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
{
// updateLayers updates geometry too, so we do not have to update both of them at the same time
if( aUpdateFlags & VIEW_ITEM::LAYERS )
@ -944,6 +950,12 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
VIEW_LAYER& l = m_layers[layers[i]];
l.items->Remove( aItem );
MarkTargetDirty( l.target );
// Redraw the item from scratch
int prevGroup = aItem->getGroup( layers[i] );
if( prevGroup >= 0 )
m_gal->DeleteGroup( prevGroup );
}
// Add the item to new layer set
@ -983,10 +995,10 @@ void VIEW::RecacheAllItems( bool aImmediately )
r.SetMaximum();
#ifdef __WXDEBUG__
#ifdef PROFILE
prof_counter totalRealTime;
prof_start( &totalRealTime );
#endif /* __WXDEBUG__ */
#endif /* PROFILE */
for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
{
@ -1002,12 +1014,12 @@ void VIEW::RecacheAllItems( bool aImmediately )
}
}
#ifdef __WXDEBUG__
#ifdef PROFILE
prof_end( &totalRealTime );
wxLogDebug( wxT( "RecacheAllItems::immediately: %u %.1f ms" ),
aImmediately, totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* PROFILE */
}

View File

@ -34,17 +34,13 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
bool update = false;
if( m_visible != aIsVisible )
{
update = true;
}
m_visible = aIsVisible;
// update only if the visibility has really changed
if( update )
{
ViewUpdate( APPEARANCE );
}
}
@ -53,16 +49,14 @@ void VIEW_ITEM::ViewUpdate( int aUpdateFlags )
if( !m_view )
return;
m_view->invalidateItem( this, aUpdateFlags );
m_view->InvalidateItem( this, aUpdateFlags );
}
void VIEW_ITEM::ViewRelease()
{
if( m_view && m_view->IsDynamic() )
{
m_view->Remove( this );
}
}

View File

@ -73,19 +73,12 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
m_mousePosition.x = aEvent.GetX();
m_mousePosition.y = aEvent.GetY();
if( m_forceCursorPosition )
m_cursorPosition = m_view->ToScreen( m_forcedPosition );
else if( m_snappingEnabled )
m_cursorPosition = m_view->GetGAL()->GetGridPoint( m_mousePosition );
else
m_cursorPosition = m_mousePosition;
updateCursor();
bool isAutoPanning = false;
if( m_autoPanEnabled )
{
isAutoPanning = handleAutoPanning( aEvent );
}
if( !isAutoPanning && aEvent.Dragging() )
{
@ -168,17 +161,13 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
}
if( aEvent.LeftUp() )
{
m_state = IDLE; // Stop autopanning when user release left mouse button
}
break;
case DRAG_PANNING:
if( aEvent.MiddleUp() )
{
m_state = IDLE;
}
break;
}
@ -210,8 +199,23 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir = m_view->ToWorld( dir, false );
m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed );
updateCursor();
// Notify tools that the cursor position has changed in the world coordinates
wxCommandEvent moveEvent( EVT_REFRESH_MOUSE );
wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
// Set the modifiers state
#if wxCHECK_VERSION( 3, 0, 0 )
moveEvent.SetControlDown( wxGetKeyState( WXK_CONTROL ) );
moveEvent.SetShiftDown( wxGetKeyState( WXK_SHIFT ) );
moveEvent.SetAltDown( wxGetKeyState( WXK_ALT) );
#else
// wx <3.0 do not have accessors, but the fields are exposed
moveEvent.m_controlDown = wxGetKeyState( WXK_CONTROL );
moveEvent.m_shiftDown = wxGetKeyState( WXK_SHIFT );
moveEvent.m_altDown = wxGetKeyState( WXK_ALT );
#endif
wxPostEvent( m_parentPanel, moveEvent );
}
break;
@ -225,7 +229,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
{
m_grabMouse = aEnabled;
VIEW_CONTROLS::SetGrabMouse( aEnabled );
if( aEnabled )
m_parentPanel->CaptureMouse();
@ -243,15 +247,6 @@ const VECTOR2D WX_VIEW_CONTROLS::GetMousePosition() const
}
const VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
{
if( m_snappingEnabled )
return m_view->GetGAL()->GetGridPoint( GetMousePosition() );
else
return GetMousePosition();
}
bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
{
VECTOR2D p( aEvent.GetX(), aEvent.GetY() );
@ -309,3 +304,14 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
wxASSERT_MSG( false, wxT( "This line should never be reached" ) );
return false; // Should not be reached, just avoid the compiler warnings..
}
void WX_VIEW_CONTROLS::updateCursor()
{
if( m_forceCursorPosition )
m_cursorPosition = m_view->ToScreen( m_forcedPosition );
else if( m_snappingEnabled )
m_cursorPosition = m_view->GetGAL()->GetGridPoint( m_mousePosition );
else
m_cursorPosition = m_mousePosition;
}

View File

@ -36,10 +36,8 @@
using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_fileName( aFileName ), m_sheetName( aSheetName ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}

View File

@ -124,7 +124,7 @@ public:
* @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
{

View File

@ -160,7 +160,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
}
void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{

View File

@ -676,7 +676,7 @@ public:
* @param aTransformPoint = the reference point of the transformation,
* for commands like move
*/
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
{

View File

@ -83,8 +83,7 @@ protected:
public:
BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
EDA_ITEM( aParent, idtype )
, m_Layer( FIRST_LAYER )
EDA_ITEM( aParent, idtype ), m_Layer( FIRST_LAYER )
{
}
@ -94,6 +93,16 @@ public:
virtual void SetPosition( const wxPoint& aPos ) = 0;
/**
* Function IsConnected()
* Returns information if the object is derived from BOARD_CONNECTED_ITEM.
* @return True if the object is of BOARD_CONNECTED_ITEM type, false otherwise.
*/
virtual bool IsConnected() const
{
return false;
}
/**
* A value of wxPoint(0,0) which can be passed to the Draw() functions.
*/

View File

@ -111,7 +111,7 @@ public:
void SetStatus( UNDO_REDO_T aStatus ) { m_undoRedoStatus = aStatus; }
UNDO_REDO_T GetStatus() { return m_undoRedoStatus; }
UNDO_REDO_T GetStatus() const { return m_undoRedoStatus; }
void SetFlags( STATUS_FLAGS aFlags ) { m_pickerFlags = aFlags; }
@ -148,7 +148,7 @@ public:
* pushes \a aItem to the top of the list
* @param aItem Picker to push on to the list.
*/
void PushItem( ITEM_PICKER& aItem );
void PushItem( const ITEM_PICKER& aItem );
/**
* Function PopItem
@ -160,7 +160,14 @@ public:
* Function IsItemInList
* @return True if \a aItem is found in the pick list.
*/
bool ContainsItem( EDA_ITEM* aItem ) const;
bool ContainsItem( const EDA_ITEM* aItem ) const;
/**
* Function FindItem
* @return Index of the searched item. If the item is not stored in the list, negative value
* is returned.
*/
int FindItem( const EDA_ITEM* aItem ) const;
/**
* Function ClearItemsList
@ -201,21 +208,21 @@ public:
* if this picker does not exist, a picker is returned,
* with its members set to 0 or NULL
*/
ITEM_PICKER GetItemWrapper( unsigned int aIdx );
ITEM_PICKER GetItemWrapper( unsigned int aIdx ) const;
/**
* Function GetPickedItem
* @return A pointer to the picked item
* @param aIdx Index of the picked item in the picked list
*/
EDA_ITEM* GetPickedItem( unsigned int aIdx );
EDA_ITEM* GetPickedItem( unsigned int aIdx ) const;
/**
* Function GetPickedItemLink
* @return link of the picked item, or null if does not exist
* @param aIdx Index of the picked item in the picked list
*/
EDA_ITEM* GetPickedItemLink( unsigned int aIdx );
EDA_ITEM* GetPickedItemLink( unsigned int aIdx ) const;
/**
* Function GetPickedItemStatus
@ -223,7 +230,7 @@ public:
* or UR_UNSPECIFIED if does not exist
* @param aIdx Index of the picked item in the picked list
*/
UNDO_REDO_T GetPickedItemStatus( unsigned int aIdx );
UNDO_REDO_T GetPickedItemStatus( unsigned int aIdx ) const;
/**
* Function GetPickerFlags
@ -231,7 +238,7 @@ public:
* @param aIdx Index of the picker in the picked list
* @return The value stored in the picker, if the picker exists, or 0 if does not exist
*/
STATUS_FLAGS GetPickerFlags( unsigned aIdx );
STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const;
/**
* Function SetPickedItem

View File

@ -136,7 +136,7 @@ public:
* Function Brightened
* Returns a color that is brighter by a given factor, without modifying object.
* @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0).
* @return COLOR4D Highlightedd color.
* @return COLOR4D Highlighted color.
*/
COLOR4D Brightened( double aFactor ) const
{

View File

@ -98,6 +98,24 @@ struct fnv_1a
};
/// Hash function for wxString, counterpart of std::string hash
struct WXSTRING_HASH : std::unary_function<wxString, std::size_t>
{
std::size_t operator()( const wxString& aString ) const
{
std::size_t hash = 2166136261u;
for( wxString::const_iterator it = aString.begin(); it != aString.end(); ++it )
{
hash ^= (unsigned char) *it;
hash *= 16777619;
}
return hash;
}
};
/**
* Type KEYWORD_MAP
* is a hashtable made of a const char* and an int. Note that use of this

View File

@ -31,6 +31,7 @@
#include <climits>
#include <iostream>
#include <sstream>
#include <cmath>
#include <math/math_util.h>

Some files were not shown because too many files have changed in this diff Show More