Skip to content
pcbnew.py_back 585 KiB
Newer Older
nats's avatar
nats committed
3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, base_seqVect, name)
    __repr__ = _swig_repr

    def iterator(self):
        """iterator(base_seqVect self) -> SwigPyIterator"""
        return _pcbnew.base_seqVect_iterator(self)

    def __iter__(self):
        return self.iterator()

    def __nonzero__(self):
        """__nonzero__(base_seqVect self) -> bool"""
        return _pcbnew.base_seqVect___nonzero__(self)


    def __bool__(self):
        """__bool__(base_seqVect self) -> bool"""
        return _pcbnew.base_seqVect___bool__(self)


    def __len__(self):
        """__len__(base_seqVect self) -> std::vector< enum LAYER_ID >::size_type"""
        return _pcbnew.base_seqVect___len__(self)


    def pop(self):
        """pop(base_seqVect self) -> std::vector< enum LAYER_ID >::value_type"""
        return _pcbnew.base_seqVect_pop(self)


    def __getslice__(self, i, j):
        """__getslice__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i, std::vector< enum LAYER_ID >::difference_type j) -> base_seqVect"""
        return _pcbnew.base_seqVect___getslice__(self, i, j)


    def __setslice__(self, *args):
        """
        __setslice__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i, std::vector< enum LAYER_ID >::difference_type j, base_seqVect v)
        __setslice__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i, std::vector< enum LAYER_ID >::difference_type j)
        """
        return _pcbnew.base_seqVect___setslice__(self, *args)


    def __delslice__(self, i, j):
        """__delslice__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i, std::vector< enum LAYER_ID >::difference_type j)"""
        return _pcbnew.base_seqVect___delslice__(self, i, j)


    def __delitem__(self, *args):
        """
        __delitem__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i)
        __delitem__(base_seqVect self, PySliceObject * slice)
        """
        return _pcbnew.base_seqVect___delitem__(self, *args)


    def __getitem__(self, *args):
        """
        __getitem__(base_seqVect self, PySliceObject * slice) -> base_seqVect
        __getitem__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i) -> std::vector< enum LAYER_ID >::value_type const &
        """
        return _pcbnew.base_seqVect___getitem__(self, *args)


    def __setitem__(self, *args):
        """
        __setitem__(base_seqVect self, PySliceObject * slice, base_seqVect v)
        __setitem__(base_seqVect self, PySliceObject * slice)
        __setitem__(base_seqVect self, std::vector< enum LAYER_ID >::difference_type i, std::vector< enum LAYER_ID >::value_type const & x)
        """
        return _pcbnew.base_seqVect___setitem__(self, *args)


    def append(self, x):
        """append(base_seqVect self, std::vector< enum LAYER_ID >::value_type const & x)"""
        return _pcbnew.base_seqVect_append(self, x)


    def empty(self):
        """empty(base_seqVect self) -> bool"""
        return _pcbnew.base_seqVect_empty(self)


    def size(self):
        """size(base_seqVect self) -> std::vector< enum LAYER_ID >::size_type"""
        return _pcbnew.base_seqVect_size(self)


    def clear(self):
        """clear(base_seqVect self)"""
        return _pcbnew.base_seqVect_clear(self)


    def swap(self, v):
        """swap(base_seqVect self, base_seqVect v)"""
        return _pcbnew.base_seqVect_swap(self, v)


    def get_allocator(self):
        """get_allocator(base_seqVect self) -> std::vector< enum LAYER_ID >::allocator_type"""
        return _pcbnew.base_seqVect_get_allocator(self)


    def begin(self):
        """begin(base_seqVect self) -> std::vector< enum LAYER_ID >::iterator"""
        return _pcbnew.base_seqVect_begin(self)


    def end(self):
        """end(base_seqVect self) -> std::vector< enum LAYER_ID >::iterator"""
        return _pcbnew.base_seqVect_end(self)


    def rbegin(self):
        """rbegin(base_seqVect self) -> std::vector< enum LAYER_ID >::reverse_iterator"""
        return _pcbnew.base_seqVect_rbegin(self)


    def rend(self):
        """rend(base_seqVect self) -> std::vector< enum LAYER_ID >::reverse_iterator"""
        return _pcbnew.base_seqVect_rend(self)


    def pop_back(self):
        """pop_back(base_seqVect self)"""
        return _pcbnew.base_seqVect_pop_back(self)


    def erase(self, *args):
        """
        erase(base_seqVect self, std::vector< enum LAYER_ID >::iterator pos) -> std::vector< enum LAYER_ID >::iterator
        erase(base_seqVect self, std::vector< enum LAYER_ID >::iterator first, std::vector< enum LAYER_ID >::iterator last) -> std::vector< enum LAYER_ID >::iterator
        """
        return _pcbnew.base_seqVect_erase(self, *args)


    def __init__(self, *args):
        """
        __init__(std::vector<(enum LAYER_ID)> self) -> base_seqVect
        __init__(std::vector<(enum LAYER_ID)> self, base_seqVect arg2) -> base_seqVect
        __init__(std::vector<(enum LAYER_ID)> self, std::vector< enum LAYER_ID >::size_type size) -> base_seqVect
        __init__(std::vector<(enum LAYER_ID)> self, std::vector< enum LAYER_ID >::size_type size, std::vector< enum LAYER_ID >::value_type const & value) -> base_seqVect
        """
        this = _pcbnew.new_base_seqVect(*args)
        try:
            self.this.append(this)
        except:
            self.this = this

    def push_back(self, x):
        """push_back(base_seqVect self, std::vector< enum LAYER_ID >::value_type const & x)"""
        return _pcbnew.base_seqVect_push_back(self, x)


    def front(self):
        """front(base_seqVect self) -> std::vector< enum LAYER_ID >::value_type const &"""
        return _pcbnew.base_seqVect_front(self)


    def back(self):
        """back(base_seqVect self) -> std::vector< enum LAYER_ID >::value_type const &"""
        return _pcbnew.base_seqVect_back(self)


    def assign(self, n, x):
        """assign(base_seqVect self, std::vector< enum LAYER_ID >::size_type n, std::vector< enum LAYER_ID >::value_type const & x)"""
        return _pcbnew.base_seqVect_assign(self, n, x)


    def resize(self, *args):
        """
        resize(base_seqVect self, std::vector< enum LAYER_ID >::size_type new_size)
        resize(base_seqVect self, std::vector< enum LAYER_ID >::size_type new_size, std::vector< enum LAYER_ID >::value_type const & x)
        """
        return _pcbnew.base_seqVect_resize(self, *args)


    def insert(self, *args):
        """
        insert(base_seqVect self, std::vector< enum LAYER_ID >::iterator pos, std::vector< enum LAYER_ID >::value_type const & x) -> std::vector< enum LAYER_ID >::iterator
        insert(base_seqVect self, std::vector< enum LAYER_ID >::iterator pos, std::vector< enum LAYER_ID >::size_type n, std::vector< enum LAYER_ID >::value_type const & x)
        """
        return _pcbnew.base_seqVect_insert(self, *args)


    def reserve(self, n):
        """reserve(base_seqVect self, std::vector< enum LAYER_ID >::size_type n)"""
        return _pcbnew.base_seqVect_reserve(self, n)


    def capacity(self):
        """capacity(base_seqVect self) -> std::vector< enum LAYER_ID >::size_type"""
        return _pcbnew.base_seqVect_capacity(self)

    __swig_destroy__ = _pcbnew.delete_base_seqVect
    __del__ = lambda self: None
base_seqVect_swigregister = _pcbnew.base_seqVect_swigregister
base_seqVect_swigregister(base_seqVect)



KICAD_PLUGINS={}

def ReloadPlugin(name):
    if not KICAD_PLUGINS.has_key(name):
        return False

    KICAD_PLUGINS[name]["object"].deregister()
    mod = reload(KICAD_PLUGINS[name]["module"])
    KICAD_PLUGINS[name]["object"]= mod.register()


def ReloadPlugins():
    import os.path
    for k in KICAD_PLUGINS.keys():
        plugin = KICAD_PLUGINS[k]

        filename = plugin["filename"]
        mtime = plugin["modification_time"]
        now_mtime = os.path.getmtime(filename)

        if mtime!=now_mtime:
            print filename, " is modified, reloading"
            KICAD_PLUGINS[k]["modification_time"]=now_mtime
            ReloadPlugin(k)


def LoadPlugins( plugpath ):
    import os
    import sys

    kicad_path = os.environ.get('KICAD_PATH')
    plugin_directories=[]

    if plugpath and os.path.isdir( plugpath ):
        plugin_directories.append( plugpath )

    if kicad_path and os.path.isdir(kicad_path):
        plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins'))

    if sys.platform.startswith('linux'):
        plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/')
        plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/')

    if sys.platform.startswith('darwin'):
        for singlepath in sys.path:
            if os.path.isdir( os.path.join( singlepath, 'scripting', 'plugins') ):
                plugin_directories.append( os.path.join( singlepath, 'scripting', 'plugins') )

    for plugins_dir in plugin_directories:
        sys.path.append(plugins_dir)

        if not os.path.isdir(plugins_dir):
            continue

        for module in os.listdir(plugins_dir):
            if os.path.isdir(plugins_dir+module):
                __import__(module, locals(), globals())

            if module == '__init__.py' or module[-3:] != '.py':
                continue

            mod = __import__(module[:-3], locals(), globals())

            module_filename = plugins_dir+"/"+module
            mtime = os.path.getmtime(module_filename)
            if hasattr(mod,'register'):
                KICAD_PLUGINS[module]={"filename":module_filename,
                                       "modification_time":mtime,
                                       "object":mod.register(),
                                       "module":mod}



class KiCadPlugin:
    def __init__(self):
        pass

    def register(self):
        if isinstance(self,FilePlugin):
            pass # register to file plugins in C++
        if isinstance(self,FootprintWizardPlugin):
            PYTHON_FOOTPRINT_WIZARDS.register_wizard(self)
            return

        if isinstance(self,ActionPlugin):
            pass # register to action plugins in C++

        return

    def deregister(self):
        if isinstance(self,FilePlugin):
            pass # register to file plugins in C++
        if isinstance(self,FootprintWizardPlugin):
            PYTHON_FOOTPRINT_WIZARDS.deregister_wizard(self)
            return

        if isinstance(self,ActionPlugin):
            pass # register to action plugins in C++

        return




class FilePlugin(KiCadPlugin):
    def __init__(self):
        KiCadPlugin.__init__(self)



class FootprintWizardPlugin(KiCadPlugin):
    def __init__(self):
        KiCadPlugin.__init__(self)
        self.defaults()

    def defaults(self):
        self.module = None
        self.parameters = {}
        self.parameter_errors={}
        self.name = "Undefined Footprint Wizard plugin"
        self.description = ""
        self.image = ""

    def GetName(self):
        return self.name

    def GetImage(self):
        return self.image

    def GetDescription(self):
        return self.description


    def GetNumParameterPages(self):
        return len(self.parameters)

    def GetParameterPageName(self,page_n):
        return self.parameters.keys()[page_n]

    def GetParameterNames(self,page_n):
        name = self.GetParameterPageName(page_n)
        return self.parameters[name].keys()

    def GetParameterValues(self,page_n):
        name = self.GetParameterPageName(page_n)
        values = self.parameters[name].values()
        return map( lambda x: str(x) , values) # list elements as strings

    def GetParameterErrors(self,page_n):
        self.CheckParameters()
        name = self.GetParameterPageName(page_n)
        values = self.parameter_errors[name].values()
        return map( lambda x: str(x) , values) # list elements as strings

    def CheckParameters(self):
        return ""

    def TryConvertToFloat(self,value):
        v = value
        try:
            v = float(value)
        except:
            pass

        return v

    def SetParameterValues(self,page_n,values):
        name = self.GetParameterPageName(page_n)
        keys = self.parameters[name].keys()
        n=0
        for key in keys:
            val = self.TryConvertToFloat(values[n])
            self.parameters[name][key] = val
            print "[%s][%s]<="%(name,key),val
            n+=1


    def ClearErrors(self):
        errs={}

        for page in self.parameters.keys():
            page_dict = self.parameters[page]
            page_params = {}
            for param in page_dict.keys():
                page_params[param]=""

            errs[page]=page_params

        self.parameter_errors = errs


    def GetModule(self):
        self.BuildFootprint()
        return self.module

    def BuildFootprint(self):
        return

    def Show(self):
        print "Footprint Wizard Name:        ",self.GetName()
        print "Footprint Wizard Description: ",self.GetDescription()
        n_pages = self.GetNumParameterPages()
        print " setup pages: ",n_pages
        for page in range(0,n_pages):
            name = self.GetParameterPageName(page)
            values = self.GetParameterValues(page)
            names =  self.GetParameterNames(page)
            print "page %d) %s"%(page,name)
            for n in range (0,len(values)):
                print "\t%s\t:\t%s"%(names[n],values[n])

class ActionPlugin(KiCadPlugin):
    def __init__(self):
        KiCadPlugin.__init__(self)


class CSegment(_object):
    """Proxy of C++ CSegment class"""
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, CSegment, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, CSegment, name)
    __repr__ = _swig_repr
    __swig_setmethods__["m_Start"] = _pcbnew.CSegment_m_Start_set
    __swig_getmethods__["m_Start"] = _pcbnew.CSegment_m_Start_get
    if _newclass:
        m_Start = _swig_property(_pcbnew.CSegment_m_Start_get, _pcbnew.CSegment_m_Start_set)
    __swig_setmethods__["m_End"] = _pcbnew.CSegment_m_End_set
    __swig_getmethods__["m_End"] = _pcbnew.CSegment_m_End_get
    if _newclass:
        m_End = _swig_property(_pcbnew.CSegment_m_End_get, _pcbnew.CSegment_m_End_set)

    def __init__(self, *args):
        """
        __init__(CSegment self) -> CSegment
        __init__(CSegment self, wxPoint aStart, wxPoint aEnd) -> CSegment
        __init__(CSegment self, int x0, int y0, int x1, int y1) -> CSegment
        """
        this = _pcbnew.new_CSegment(*args)
        try:
            self.this.append(this)
        except:
            self.this = this
    __swig_destroy__ = _pcbnew.delete_CSegment
    __del__ = lambda self: None
CSegment_swigregister = _pcbnew.CSegment_swigregister
CSegment_swigregister(CSegment)

class CPolyPt(wxPoint):
    """Proxy of C++ CPolyPt class"""
    __swig_setmethods__ = {}
    for _s in [wxPoint]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, CPolyPt, name, value)
    __swig_getmethods__ = {}
    for _s in [wxPoint]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, CPolyPt, name)
    __repr__ = _swig_repr

    def __init__(self, *args):
        """
        __init__(CPolyPt self, int aX=0, int aY=0, bool aEnd=False, int aUtility=0) -> CPolyPt
        __init__(CPolyPt self, int aX=0, int aY=0, bool aEnd=False) -> CPolyPt
        __init__(CPolyPt self, int aX=0, int aY=0) -> CPolyPt
        __init__(CPolyPt self, int aX=0) -> CPolyPt
        __init__(CPolyPt self) -> CPolyPt
        __init__(CPolyPt self, CPolyPt aPt) -> CPolyPt
        __init__(CPolyPt self, wxPoint aPoint) -> CPolyPt
        """
        this = _pcbnew.new_CPolyPt(*args)
        try:
            self.this.append(this)
        except:
            self.this = this
    __swig_setmethods__["end_contour"] = _pcbnew.CPolyPt_end_contour_set
    __swig_getmethods__["end_contour"] = _pcbnew.CPolyPt_end_contour_get
    if _newclass:
        end_contour = _swig_property(_pcbnew.CPolyPt_end_contour_get, _pcbnew.CPolyPt_end_contour_set)
    __swig_setmethods__["m_flags"] = _pcbnew.CPolyPt_m_flags_set
    __swig_getmethods__["m_flags"] = _pcbnew.CPolyPt_m_flags_get
    if _newclass:
        m_flags = _swig_property(_pcbnew.CPolyPt_m_flags_get, _pcbnew.CPolyPt_m_flags_set)

    def __eq__(self, cpt2):
        """__eq__(CPolyPt self, CPolyPt cpt2) -> bool"""
        return _pcbnew.CPolyPt___eq__(self, cpt2)


    def __ne__(self, cpt2):
        """__ne__(CPolyPt self, CPolyPt cpt2) -> bool"""
        return _pcbnew.CPolyPt___ne__(self, cpt2)

    __swig_destroy__ = _pcbnew.delete_CPolyPt
    __del__ = lambda self: None
CPolyPt_swigregister = _pcbnew.CPolyPt_swigregister
CPolyPt_swigregister(CPolyPt)

class CPOLYGONS_LIST(_object):
    """Proxy of C++ CPOLYGONS_LIST class"""
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, CPOLYGONS_LIST, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, CPOLYGONS_LIST, name)
    __repr__ = _swig_repr

    def __init__(self):
        """__init__(CPOLYGONS_LIST self) -> CPOLYGONS_LIST"""
        this = _pcbnew.new_CPOLYGONS_LIST()
        try:
            self.this.append(this)
        except:
            self.this = this

    def GetList(self):
        """GetList(CPOLYGONS_LIST self) -> std::vector< CPolyPt,std::allocator< CPolyPt > > const &"""
        return _pcbnew.CPOLYGONS_LIST_GetList(self)


    def GetX(self, ic):
        """GetX(CPOLYGONS_LIST self, int ic) -> int"""
        return _pcbnew.CPOLYGONS_LIST_GetX(self, ic)


    def SetX(self, ic, aValue):
        """SetX(CPOLYGONS_LIST self, int ic, int aValue)"""
        return _pcbnew.CPOLYGONS_LIST_SetX(self, ic, aValue)


    def GetY(self, ic):
        """GetY(CPOLYGONS_LIST self, int ic) -> int"""
        return _pcbnew.CPOLYGONS_LIST_GetY(self, ic)


    def SetY(self, ic, aValue):
        """SetY(CPOLYGONS_LIST self, int ic, int aValue)"""
        return _pcbnew.CPOLYGONS_LIST_SetY(self, ic, aValue)


    def IsEndContour(self, ic):
        """IsEndContour(CPOLYGONS_LIST self, int ic) -> bool"""
        return _pcbnew.CPOLYGONS_LIST_IsEndContour(self, ic)


    def GetPos(self, ic):
        """GetPos(CPOLYGONS_LIST self, int ic) -> wxPoint"""
        return _pcbnew.CPOLYGONS_LIST_GetPos(self, ic)


    def GetCorner(self, ic):
        """GetCorner(CPOLYGONS_LIST self, int ic) -> CPolyPt"""
        return _pcbnew.CPOLYGONS_LIST_GetCorner(self, ic)


    def reserve(self, aSize):
        """reserve(CPOLYGONS_LIST self, int aSize)"""
        return _pcbnew.CPOLYGONS_LIST_reserve(self, aSize)


    def RemoveAllContours(self):
        """RemoveAllContours(CPOLYGONS_LIST self)"""
        return _pcbnew.CPOLYGONS_LIST_RemoveAllContours(self)


    def GetLastCorner(self):
        """GetLastCorner(CPOLYGONS_LIST self) -> CPolyPt"""
        return _pcbnew.CPOLYGONS_LIST_GetLastCorner(self)


    def GetCornersCount(self):
        """GetCornersCount(CPOLYGONS_LIST self) -> unsigned int"""
        return _pcbnew.CPOLYGONS_LIST_GetCornersCount(self)


    def DeleteCorner(self, aIdx):
        """DeleteCorner(CPOLYGONS_LIST self, int aIdx)"""
        return _pcbnew.CPOLYGONS_LIST_DeleteCorner(self, aIdx)


    def DeleteCorners(self, aIdFirstCorner, aIdLastCorner):
        """DeleteCorners(CPOLYGONS_LIST self, int aIdFirstCorner, int aIdLastCorner)"""
        return _pcbnew.CPOLYGONS_LIST_DeleteCorners(self, aIdFirstCorner, aIdLastCorner)


    def Append(self, *args):
        """
        Append(CPOLYGONS_LIST self, CPOLYGONS_LIST aList)
        Append(CPOLYGONS_LIST self, CPolyPt aItem)
        Append(CPOLYGONS_LIST self, wxPoint aItem)
        """
        return _pcbnew.CPOLYGONS_LIST_Append(self, *args)


    def InsertCorner(self, aPosition, aItem):
        """InsertCorner(CPOLYGONS_LIST self, int aPosition, CPolyPt aItem)"""
        return _pcbnew.CPOLYGONS_LIST_InsertCorner(self, aPosition, aItem)


    def AddCorner(self, aCorner):
        """AddCorner(CPOLYGONS_LIST self, CPolyPt aCorner)"""
        return _pcbnew.CPOLYGONS_LIST_AddCorner(self, aCorner)


    def CloseLastContour(self):
        """CloseLastContour(CPOLYGONS_LIST self)"""
        return _pcbnew.CPOLYGONS_LIST_CloseLastContour(self)


    def GetContoursCount(self):
        """GetContoursCount(CPOLYGONS_LIST self) -> int"""
        return _pcbnew.CPOLYGONS_LIST_GetContoursCount(self)

    __swig_destroy__ = _pcbnew.delete_CPOLYGONS_LIST
    __del__ = lambda self: None
CPOLYGONS_LIST_swigregister = _pcbnew.CPOLYGONS_LIST_swigregister
CPOLYGONS_LIST_swigregister(CPOLYGONS_LIST)

class CPolyLine(_object):
    """Proxy of C++ CPolyLine class"""
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, CPolyLine, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, CPolyLine, name)
    __repr__ = _swig_repr
    NO_HATCH = _pcbnew.CPolyLine_NO_HATCH
    DIAGONAL_FULL = _pcbnew.CPolyLine_DIAGONAL_FULL
    DIAGONAL_EDGE = _pcbnew.CPolyLine_DIAGONAL_EDGE

    def __init__(self, *args):
        """
        __init__(CPolyLine self) -> CPolyLine
        __init__(CPolyLine self, CPolyLine aCPolyLine) -> CPolyLine
        """
        this = _pcbnew.new_CPolyLine(*args)
        try:
            self.this.append(this)
        except:
            self.this = this
    __swig_destroy__ = _pcbnew.delete_CPolyLine
    __del__ = lambda self: None

    def ImportSettings(self, aPoly):
        """ImportSettings(CPolyLine self, CPolyLine aPoly)"""
        return _pcbnew.CPolyLine_ImportSettings(self, aPoly)


    def Start(self, layer, x, y, hatch):
        """Start(CPolyLine self, LAYER_NUM layer, int x, int y, int hatch)"""
        return _pcbnew.CPolyLine_Start(self, layer, x, y, hatch)


    def AppendCorner(self, x, y):
        """AppendCorner(CPolyLine self, int x, int y)"""
        return _pcbnew.CPolyLine_AppendCorner(self, x, y)


    def InsertCorner(self, ic, x, y):
        """InsertCorner(CPolyLine self, int ic, int x, int y)"""
        return _pcbnew.CPolyLine_InsertCorner(self, ic, x, y)


    def DeleteCorner(self, ic):
        """DeleteCorner(CPolyLine self, int ic)"""
        return _pcbnew.CPolyLine_DeleteCorner(self, ic)


    def MoveCorner(self, ic, x, y):
        """MoveCorner(CPolyLine self, int ic, int x, int y)"""
        return _pcbnew.CPolyLine_MoveCorner(self, ic, x, y)


    def CloseLastContour(self):
        """CloseLastContour(CPolyLine self)"""
        return _pcbnew.CPolyLine_CloseLastContour(self)


    def RemoveContour(self, icont):
        """RemoveContour(CPolyLine self, int icont)"""
        return _pcbnew.CPolyLine_RemoveContour(self, icont)


    def IsPolygonSelfIntersecting(self):
        """IsPolygonSelfIntersecting(CPolyLine self) -> bool"""
        return _pcbnew.CPolyLine_IsPolygonSelfIntersecting(self)


    def Chamfer(self, aDistance):
        """Chamfer(CPolyLine self, unsigned int aDistance) -> CPolyLine"""
        return _pcbnew.CPolyLine_Chamfer(self, aDistance)


    def Fillet(self, aRadius, aSegments):
        """Fillet(CPolyLine self, unsigned int aRadius, unsigned int aSegments) -> CPolyLine"""
        return _pcbnew.CPolyLine_Fillet(self, aRadius, aSegments)


    def RemoveNullSegments(self):
        """RemoveNullSegments(CPolyLine self) -> int"""
        return _pcbnew.CPolyLine_RemoveNullSegments(self)


    def RemoveAllContours(self):
        """RemoveAllContours(CPolyLine self)"""
        return _pcbnew.CPolyLine_RemoveAllContours(self)


    def UnHatch(self):
        """UnHatch(CPolyLine self)"""
        return _pcbnew.CPolyLine_UnHatch(self)


    def Hatch(self):
        """Hatch(CPolyLine self)"""
        return _pcbnew.CPolyLine_Hatch(self)


    def MoveOrigin(self, x_off, y_off):
        """MoveOrigin(CPolyLine self, int x_off, int y_off)"""
        return _pcbnew.CPolyLine_MoveOrigin(self, x_off, y_off)


    def GetBoundingBox(self, *args):
        """
        GetBoundingBox(CPolyLine self) -> EDA_RECT
        GetBoundingBox(CPolyLine self, int icont) -> EDA_RECT
        """
        return _pcbnew.CPolyLine_GetBoundingBox(self, *args)


    def Copy(self, src):
        """Copy(CPolyLine self, CPolyLine src)"""
        return _pcbnew.CPolyLine_Copy(self, src)


    def TestPointInside(self, x, y):
        """TestPointInside(CPolyLine self, int x, int y) -> bool"""
        return _pcbnew.CPolyLine_TestPointInside(self, x, y)


    def IsCutoutContour(self, aCornerIdx):
        """IsCutoutContour(CPolyLine self, int aCornerIdx) -> bool"""
        return _pcbnew.CPolyLine_IsCutoutContour(self, aCornerIdx)


    def AppendArc(self, xi, yi, xf, yf, xc, yc, num):
        """AppendArc(CPolyLine self, int xi, int yi, int xf, int yf, int xc, int yc, int num)"""
        return _pcbnew.CPolyLine_AppendArc(self, xi, yi, xf, yf, xc, yc, num)


    def SetLayer(self, aLayer):
        """SetLayer(CPolyLine self, LAYER_NUM aLayer)"""
        return _pcbnew.CPolyLine_SetLayer(self, aLayer)


    def GetLayer(self):
        """GetLayer(CPolyLine self) -> LAYER_NUM"""
        return _pcbnew.CPolyLine_GetLayer(self)


    def GetCornersCount(self):
        """GetCornersCount(CPolyLine self) -> int"""
        return _pcbnew.CPolyLine_GetCornersCount(self)


    def GetClosed(self):
        """GetClosed(CPolyLine self) -> bool"""
        return _pcbnew.CPolyLine_GetClosed(self)


    def GetContoursCount(self):
        """GetContoursCount(CPolyLine self) -> int"""
        return _pcbnew.CPolyLine_GetContoursCount(self)


    def GetContour(self, ic):
        """GetContour(CPolyLine self, int ic) -> int"""
        return _pcbnew.CPolyLine_GetContour(self, ic)


    def GetContourStart(self, icont):
        """GetContourStart(CPolyLine self, int icont) -> int"""
        return _pcbnew.CPolyLine_GetContourStart(self, icont)


    def GetContourEnd(self, icont):
        """GetContourEnd(CPolyLine self, int icont) -> int"""
        return _pcbnew.CPolyLine_GetContourEnd(self, icont)


    def GetContourSize(self, icont):
        """GetContourSize(CPolyLine self, int icont) -> int"""
        return _pcbnew.CPolyLine_GetContourSize(self, icont)


    def GetX(self, ic):
        """GetX(CPolyLine self, int ic) -> int"""
        return _pcbnew.CPolyLine_GetX(self, ic)


    def GetY(self, ic):
        """GetY(CPolyLine self, int ic) -> int"""
        return _pcbnew.CPolyLine_GetY(self, ic)


    def IsEndContour(self, ic):
        """IsEndContour(CPolyLine self, int ic) -> bool"""
        return _pcbnew.CPolyLine_IsEndContour(self, ic)


    def GetPos(self, ic):
        """GetPos(CPolyLine self, int ic) -> wxPoint"""
        return _pcbnew.CPolyLine_GetPos(self, ic)


    def GetHatchPitch(self):
        """GetHatchPitch(CPolyLine self) -> int"""
        return _pcbnew.CPolyLine_GetHatchPitch(self)


    def GetDefaultHatchPitchMils():
        """GetDefaultHatchPitchMils() -> int"""
        return _pcbnew.CPolyLine_GetDefaultHatchPitchMils()

    if _newclass:
        GetDefaultHatchPitchMils = staticmethod(GetDefaultHatchPitchMils)
    __swig_getmethods__["GetDefaultHatchPitchMils"] = lambda x: GetDefaultHatchPitchMils

    def GetHatchStyle(self):
        """GetHatchStyle(CPolyLine self) -> enum CPolyLine::HATCH_STYLE"""
        return _pcbnew.CPolyLine_GetHatchStyle(self)


    def SetHatch(self, aHatchStyle, aHatchPitch, aRebuildHatch):
        """SetHatch(CPolyLine self, int aHatchStyle, int aHatchPitch, bool aRebuildHatch)"""
        return _pcbnew.CPolyLine_SetHatch(self, aHatchStyle, aHatchPitch, aRebuildHatch)


    def SetX(self, ic, x):
        """SetX(CPolyLine self, int ic, int x)"""
        return _pcbnew.CPolyLine_SetX(self, ic, x)


    def SetY(self, ic, y):
        """SetY(CPolyLine self, int ic, int y)"""
        return _pcbnew.CPolyLine_SetY(self, ic, y)


    def SetHatchStyle(self, style):
        """SetHatchStyle(CPolyLine self, enum CPolyLine::HATCH_STYLE style)"""
        return _pcbnew.CPolyLine_SetHatchStyle(self, style)


    def SetHatchPitch(self, pitch):
        """SetHatchPitch(CPolyLine self, int pitch)"""
        return _pcbnew.CPolyLine_SetHatchPitch(self, pitch)


    def NormalizeAreaOutlines(self, aNewPolygonList):
        """NormalizeAreaOutlines(CPolyLine self, std::vector< CPolyLine *,std::allocator< CPolyLine * > > * aNewPolygonList) -> int"""
        return _pcbnew.CPolyLine_NormalizeAreaOutlines(self, aNewPolygonList)


    def AppendBezier(self, *args):
        """
        AppendBezier(CPolyLine self, int x1, int y1, int x2, int y2, int x3, int y3)
        AppendBezier(CPolyLine self, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
        """
        return _pcbnew.CPolyLine_AppendBezier(self, *args)


    def Distance(self, *args):
        """
        Distance(CPolyLine self, wxPoint aPoint) -> int
        Distance(CPolyLine self, wxPoint aStart, wxPoint aEnd, int aWidth) -> int
        """
        return _pcbnew.CPolyLine_Distance(self, *args)


    def HitTestForEdge(self, aPos, aDistMax):
        """HitTestForEdge(CPolyLine self, wxPoint aPos, int aDistMax) -> int"""
        return _pcbnew.CPolyLine_HitTestForEdge(self, aPos, aDistMax)


    def HitTestForCorner(self, aPos, aDistMax):
        """HitTestForCorner(CPolyLine self, wxPoint aPos, int aDistMax) -> int"""
        return _pcbnew.CPolyLine_HitTestForCorner(self, aPos, aDistMax)

    __swig_setmethods__["m_CornersList"] = _pcbnew.CPolyLine_m_CornersList_set
    __swig_getmethods__["m_CornersList"] = _pcbnew.CPolyLine_m_CornersList_get
    if _newclass:
        m_CornersList = _swig_property(_pcbnew.CPolyLine_m_CornersList_get, _pcbnew.CPolyLine_m_CornersList_set)
    __swig_setmethods__["m_HatchLines"] = _pcbnew.CPolyLine_m_HatchLines_set
    __swig_getmethods__["m_HatchLines"] = _pcbnew.CPolyLine_m_HatchLines_get
    if _newclass:
        m_HatchLines = _swig_property(_pcbnew.CPolyLine_m_HatchLines_get, _pcbnew.CPolyLine_m_HatchLines_set)
CPolyLine_swigregister = _pcbnew.CPolyLine_swigregister
CPolyLine_swigregister(CPolyLine)

def CPolyLine_GetDefaultHatchPitchMils():
    """CPolyLine_GetDefaultHatchPitchMils() -> int"""
    return _pcbnew.CPolyLine_GetDefaultHatchPitchMils()


def ConvertPolyListToPolySet(aList):
    """ConvertPolyListToPolySet(CPOLYGONS_LIST aList) -> SHAPE_POLY_SET const"""
    return _pcbnew.ConvertPolyListToPolySet(aList)

def ConvertPolySetToPolyList(aPolyset):
    """ConvertPolySetToPolyList(SHAPE_POLY_SET const & aPolyset) -> CPOLYGONS_LIST"""
    return _pcbnew.ConvertPolySetToPolyList(aPolyset)
class UTF8(string):
    """Proxy of C++ UTF8 class"""
    __swig_setmethods__ = {}
    for _s in [string]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, UTF8, name, value)
    __swig_getmethods__ = {}
    for _s in [string]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, UTF8, name)
    __repr__ = _swig_repr

    def __init__(self, *args):
        """
        __init__(UTF8 self, wxString const & o) -> UTF8
        __init__(UTF8 self, char const * txt) -> UTF8
        __init__(UTF8 self, wchar_t const * txt) -> UTF8
        __init__(UTF8 self, string o) -> UTF8
        __init__(UTF8 self) -> UTF8
        """
        this = _pcbnew.new_UTF8(*args)
        try:
            self.this.append(this)
        except:
            self.this = this
    __swig_destroy__ = _pcbnew.delete_UTF8
    __del__ = lambda self: None

    def substr(self, *args):
        """
        substr(UTF8 self, size_t pos=0, size_t len) -> UTF8
        substr(UTF8 self, size_t pos=0) -> UTF8
        substr(UTF8 self) -> UTF8
        """
        return _pcbnew.UTF8_substr(self, *args)


    def utf8_to_wxstring(self):
        """utf8_to_wxstring(UTF8 self) -> wxString"""
        return _pcbnew.UTF8_utf8_to_wxstring(self)


    def utf8_to_charptr(self):
        """utf8_to_charptr(UTF8 self) -> char *"""
        return _pcbnew.UTF8_utf8_to_charptr(self)


    def uni_forward(aSequence, aResult=None):
        """
        uni_forward(unsigned char const * aSequence, unsigned int * aResult=None) -> int
        uni_forward(unsigned char const * aSequence) -> int
        """
        return _pcbnew.UTF8_uni_forward(aSequence, aResult)

    if _newclass:
        uni_forward = staticmethod(uni_forward)
    __swig_getmethods__["uni_forward"] = lambda x: uni_forward

    def ubegin(self):
        """ubegin(UTF8 self) -> UTF8::uni_iter"""
        return _pcbnew.UTF8_ubegin(self)


    def uend(self):
        """uend(UTF8 self) -> UTF8::uni_iter"""
        return _pcbnew.UTF8_uend(self)


    def Cast_to_CChar(self):
        """Cast_to_CChar(UTF8 self) -> char const *"""
        return _pcbnew.UTF8_Cast_to_CChar(self)



        # Get the char buffer of the UTF8 string
    def GetChars(self):
        return self.Cast_to_CChar()

    # Convert the UTF8 string to a python string
    # Same as GetChars(), but more easy to use in print command
    def __str__(self):
        return self.GetChars()


UTF8_swigregister = _pcbnew.UTF8_swigregister
UTF8_swigregister(UTF8)

def UTF8_uni_forward(aSequence, aResult=None):