Commit fd973478 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Merged kicad-pns-tom.

parents 9ec4520c 979f549e
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
So, finally we've got an integrated interactive, push-and-sometimes-shove router, although with a very limited user interface:

- Edit->Interactive router launches the tool,
- while routing: 'V' key places a via,
- '+' and '-' keys cycle through available layers,
- '/' key switches track posture.

Via/track dimensions are taken from the netclasses. 
There are no other options available for the time being - promise to add them soon :)

Tom
 No newline at end of file
+3 −3
Original line number Original line Diff line number Diff line
@@ -1287,7 +1287,7 @@ int RTREE_QUAL::PickBranch( Rect* a_rect, Node* a_node )
    ELEMTYPEREAL    bestIncr = (ELEMTYPEREAL) -1;
    ELEMTYPEREAL    bestIncr = (ELEMTYPEREAL) -1;
    ELEMTYPEREAL    area;
    ELEMTYPEREAL    area;
    ELEMTYPEREAL    bestArea;
    ELEMTYPEREAL    bestArea;
    int             best;
    int             best = 0;
    Rect            tempRect;
    Rect            tempRect;


    for( int index = 0; index < a_node->m_count; ++index )
    for( int index = 0; index < a_node->m_count; ++index )
@@ -1480,7 +1480,7 @@ void RTREE_QUAL::ChoosePartition( PartitionVars* a_parVars, int a_minFill )
    ASSERT( a_parVars );
    ASSERT( a_parVars );


    ELEMTYPEREAL    biggestDiff;
    ELEMTYPEREAL    biggestDiff;
    int             group, chosen, betterGroup;
    int             group, chosen = 0, betterGroup = 0;


    InitParVars( a_parVars, a_parVars->m_branchCount, a_minFill );
    InitParVars( a_parVars, a_parVars->m_branchCount, a_minFill );
    PickSeeds( a_parVars );
    PickSeeds( a_parVars );
@@ -1603,7 +1603,7 @@ void RTREE_QUAL::InitParVars( PartitionVars* a_parVars, int a_maxRects, int a_mi
RTREE_TEMPLATE
RTREE_TEMPLATE
void RTREE_QUAL::PickSeeds( PartitionVars* a_parVars )
void RTREE_QUAL::PickSeeds( PartitionVars* a_parVars )
{
{
    int             seed0, seed1;
    int             seed0 = 0, seed1 = 0;
    ELEMTYPEREAL    worst, waste;
    ELEMTYPEREAL    worst, waste;
    ELEMTYPEREAL    area[MAXNODES + 1];
    ELEMTYPEREAL    area[MAXNODES + 1];


include/profile.h

0 → 100644
+147 −0
Original line number Original line Diff line number Diff line
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2013 CERN
 * @author Tomasz Wlostowski <tomasz.wlostowski@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
 */

/**
 * @file profile.h:
 * @brief Simple profiling functions for measuring code execution time.
 */

#ifndef __TPROFILE_H
#define __TPROFILE_H

#include <sys/time.h>
#include <stdint.h>

/**
 * Function rdtsc
 * Returns processor's time-stamp counter. Main purpose is precise time measuring of code
 * execution time.
 * @return unsigned long long - Value of time-stamp counter.
 */
#if defined(__i386__)
static __inline__ unsigned long long rdtsc()
{
    unsigned long long int x;
    __asm__ volatile ( ".byte 0x0f, 0x31" : "=A" ( x ) );

    return x;
}


#elif defined(__x86_64__)
static __inline__ unsigned long long rdtsc()
{
    unsigned hi, lo;
    __asm__ __volatile__ ( "rdtsc" : "=a" ( lo ), "=d" ( hi ) );

    return ( (unsigned long long) lo ) | ( ( (unsigned long long) hi ) << 32 );
}


#elif defined(__powerpc__)
static __inline__ unsigned long long rdtsc()
{
    unsigned long long int  result = 0;
    unsigned long int       upper, lower, tmp;
    __asm__ volatile (
        "0:                  \n"
        "\tmftbu   %0           \n"
        "\tmftb    %1           \n"
        "\tmftbu   %2           \n"
        "\tcmpw    %2,%0        \n"
        "\tbne     0b         \n"
        : "=r" ( upper ), "=r" ( lower ), "=r" ( tmp )
        );

    result  = upper;
    result  = result << 32;
    result  = result | lower;

    return result;
}


#endif /* __powerpc__ */

// Fixme: OS X version
/**
 * Function get_tics
 * Returns the number of microseconds that have elapsed since the system was started.
 * @return uint64_t Number of microseconds.
 */
static inline uint64_t get_tics()
{
    struct timeval tv;
    gettimeofday( &tv, NULL );

    return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec;
}


/**
 * Structure for storing data related to profiling counters.
 */
struct prof_counter
{
    uint64_t    value;          /// Stored timer value
    bool        use_rdtsc;      /// Method of time measuring (rdtsc or tics)
};

/**
 * Function prof_start
 * Begins code execution time counting for a given profiling counter.
 * @param cnt is the counter which should be started.
 * @param use_rdtsc tells if processor's time-stamp counter should be used for time counting.
 *      Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not
 *      be used on multicore machines executing threaded code.
 */
static inline void prof_start( prof_counter* cnt, bool use_rdtsc )
{
    cnt->use_rdtsc = use_rdtsc;

    if( use_rdtsc )
    {
        cnt->value = rdtsc();
    }
    else
    {
        cnt->value = get_tics();
    }
}


/**
 * Function prof_stop
 * Ends code execution time counting for a given profiling counter.
 * @param cnt is the counter which should be stopped.
 */
static inline void prof_end( prof_counter* cnt )
{
    if( cnt->use_rdtsc )
        cnt->value = rdtsc() - cnt->value;
    else
        cnt->value = get_tics() - cnt->value;
}

#endif
+86 −0
Original line number Original line Diff line number Diff line
#ifndef __TOOL_ACTION_H
#define __TOOL_ACTION_H

#include <string>
#include <wx/wx.h>

#include <tool/tool_base.h>

///> Scope of tool actions
enum TOOL_ActionScope {
	SCOPE_CONTEXT = 1,  ///> Action belongs to a particular tool (i.e. a part of a pop-up menu)
	SCOPE_GLOBAL		///> Global action (toolbar/main menu event, global shortcut)
};

// TOOL_ACTION - represents a single action. For instance:
// - changing layer to top by pressing PgUp
// - running the DRC from the menu
// and so on, and so forth....
class TOOL_ACTION 
{
	public:
	

		TOOL_ACTION
		(
			const std::string& name,
			TOOL_ActionScope scope = SCOPE_GLOBAL,
			int aDefaultHotKey = 0,
			const wxString& menuItem = wxT(""), 
			const wxString& menuDesc = wxT("")
		) :
			m_name(name),
			m_scope(scope),
			m_defaultHotKey(aDefaultHotKey),
			m_currentHotKey(aDefaultHotKey),
			m_menuItem(menuItem),
			m_menuDescription(menuDesc) {}

		bool operator == ( const TOOL_ACTION& rhs ) const
		{
			return m_id	== rhs.m_id;
		}

		bool operator != ( const TOOL_ACTION& rhs ) const
		{
			return m_id	!= rhs.m_id;
		}

		bool hasHotKey() const
		{
			return m_currentHotKey > 0;
		}

	private:
		friend class TOOL_MANAGER;

		void setId ( int aId )
		{
			m_id = aId;
		}


		// name of the action (convention is: app.[tool.]action.name)
		std::string m_name;
		TOOL_ActionScope m_scope;
		int m_defaultHotKey;
		int m_currentHotKey;
		
		// Menu item text
		wxString m_menuItem;
		// Pop-up help
		wxString m_menuDescription;
		
		//KiBitmap m_bitmap;

		// Unique ID for fast matching. Assigned by TOOL_MANAGER
		int m_id;

		// Origin of the action
		TOOL_BASE *m_origin;

		// Originating UI object
		wxWindow *m_uiOrigin;
};

#endif
+50 −0
Original line number Original line Diff line number Diff line
include_directories(BEFORE ${INC_BEFORE})

include_directories(
		./
		../
    ../../include
    ../../pcbnew
    ../../polygon
    ${INC_AFTER}
    )

set(PCBNEW_PNS_SRCS
	direction.h
	pns_via.h
	pns_routing_settings.h
	pns_shove.cpp
	pns_line.cpp
	pns_utils.h
	pns_layerset.h
	trace.h
	pns_line.h
	pns_walkaround.cpp
	pns_node.h
	pns_line_placer.cpp
	pns_utils.cpp
	pns_solid.h
	pns_item.cpp
	pns_via.cpp
	pns_node.cpp
	pns_solid.cpp
	pns_line_placer.h
	pns_optimizer.h
	pns_walkaround.h
	pns_shove.h
	pns_router.h
	pns_router.cpp
	pns_index.h
	pns_item.h
	pns_optimizer.cpp
	pns_joint.h
	pns_segment.h
	pns_itemset.h
	pns_itemset.cpp
	router_tool.cpp
	router_tool.h
	router_preview_item.cpp
	router_preview_item.h
	)

add_library(pnsrouter STATIC ${PCBNEW_PNS_SRCS})
Loading