/*

-Procedure dskmi2_c ( DSK, make spatial index for type 2 segment )

-Abstract

   Make spatial index for a DSK type 2 segment. The index is returned
   as a pair of arrays, one of type SpiceInt and one of type
   SpiceDouble. These arrays are suitable for use with the DSK type 2
   writer dskw02_c.

-Disclaimer

   THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
   CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
   GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
   ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
   PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
   TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
   WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
   PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
   SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
   SOFTWARE AND RELATED MATERIALS, HOWEVER USED.

   IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
   BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
   LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
   INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
   REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
   REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.

   RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
   THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
   CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
   ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.

-Required_Reading

   DAS
   DSK

-Keywords

   DAS
   DSK
   FILES
   PLATE
   TOPOGRAPHY

*/

   #include "SpiceUsr.h"
   #include "SpiceZfc.h"
   #undef dskmi2_c

   void dskmi2_c  ( SpiceInt            nv,
                    ConstSpiceDouble    vrtces[][3],
                    SpiceInt            np,
                    ConstSpiceInt       plates[][3],
                    SpiceDouble         finscl,
                    SpiceInt            corscl,
                    SpiceInt            worksz,
                    SpiceInt            voxpsz,
                    SpiceInt            voxlsz,
                    SpiceBoolean        makvtl,
                    SpiceInt            spxisz,
                    SpiceInt            work   [][2],
                    SpiceDouble         spaixd [],
                    SpiceInt            spaixi []    )

/*

-Brief_I/O

   Variable  I/O  Description
   --------  ---  --------------------------------------------------
   SPICE_DSK02_IXDFIX
              P   Size of fixed-size portion of d.p. index component.
   SPICE_DSK02_IXIFIX
              P   Size of fixed-size portion of integer index
                  component.
   nv         I   Number of vertices.
   vrtces     I   Vertices.
   np         I   Number of plates.
   plates     I   Plates.
   finscl     I   Fine voxel scale.
   corscl     I   Coarse voxel scale.
   worksz     I   Workspace size.
   voxpsz     I   Voxel-plate pointer array size.
   voxlsz     I   Voxel-plate list array size.
   makvtl     I   Vertex-plate list flag.
   spxisz     I   Spatial index integer component size.
   work       I   Workspace.
   spaixd     I   Double precision component of spatial index.
   spaixi     I   Integer component of spatial index.

-Detailed_Input

   nv          is the number of vertices belonging to the input
               set of plates.

   vrtces      is an array of coordinates of the vertices. Vertex
               indices, also called "vertex numbers," are 1-based in
               all languages supported by SPICE, and range from 1 to
               `nv'. The ith vertex occupies elements [i-1][0:2] of
               this array.

   np          is the number of plates in the input plate set.

   plates      is an array representing the triangular plates of a
               shape model. The elements of `plates' are vertex
               indices; vertex indices, as well as plate indices, are
               1-based in all languages supported by SPICE. The vertex
               indices of the ith plate occupy elements [i-1][0:2] of
               this array.

   finscl      is the fine voxel scale. This scale determines the
               edge length of the cubical voxels comprising the fine
               voxel grid: the edge length `voxsiz' is approximately

                   finscl * {average plate extent}

               where the extents of a plate are the respective
               differences between the maximum and minimum
               coordinate values of the plate's vertices.

               The relationship between `voxsiz' and the average plate
               extent is approximate because the `voxsiz' is adjusted
               so that each dimension of the fine voxel grid is an
               integer multiple of the coarse voxel scale.

               See the Particulars section below for further
               information on voxel scales.

   corscl      is the coarse voxel scale. This integer scale is the
               ratio of the edge length of coarse voxels to that of
               fine voxels. The coarse scale must be large enough so
               that the total number of coarse voxels does not exceed
               SPICE_DSK02_MAXCGR (see the Parameters section below).

   worksz      is the second dimension of the workspace array `work'.
               `worksz' must be at least as large as the greater of

                  - the number of fine voxel-plate associations

                    This number is equal to

                       np * {average number of fine voxels
                             intersected by each plate}

                  - the number of vertex-plate associations, if
                    the vertex-plate mapping is constructed.

                    This number is equal to

                       nv + ( 3 * np )

   voxpsz      is the size of the fine voxel-plate pointer array.
               This array maps fine voxels to lists of plates that
               intersect those voxels. `voxpsz' must be at least as
               large as

                        3
                  corscl  * {number of non-empty coarse voxels}

   voxlsz      is the size of the fine voxel-plate list array. This
               array contains, for each non-empty fine voxel, the
               count of plates that intersect that voxel and the
               IDs of those plates. `voxlsz' must be at least as large
               as

                       `np' * {average number of fine voxels
                             intersected by each plate}

                   +   {number of non-empty fine voxels}

   makvtl      is a logical flag that, when set to SPICETRUE, indicates
               that a  vertex-plate association list is to be
               constructed.

               The amount of workspace that is needed may depend on
               whether a vertex-plate association list is
               constructed. When this list is constructed, the size
               of the integer component of the spatial index is
               increased by the size of the list and the size of a
               vertex-plate pointer array; the total of these sizes
               is

                  ( 2 * nv ) + ( 3 * np )

   spxisz      is the declared size of the output array SPAIXI. This
               size must be at least as large as the sum of

                  - the fixed-size part of the integer component of
                    the index, which includes the coarse voxel grid;
                    this value is

                       SPICE_DSK02_IDXFIX

                  - the size `voxpsz' of the voxel-plate pointer array

                  - the size `voxlsz' of the voxel-plate association
                    list

               plus, if the vertex-plate association list is
               constructed,

                  - the size `nv' of the vertex-plate pointer array

                  - the size of the vertex-plate association list;
                    this size is

                       nv + ( 3 * np )

   work        is the workspace array. The array should be declared
               with dimensions

                  (2, worksz)

               See the description of `worksz' above.

-Detailed_Output

   work        is the workspace array, modified by the operations
               performed by this routine.

   spaixd,
   spaixi      are, respectively, the double precision and integer
               components of the spatial index of the segment.

               `spaixd' must be declared with size at least
               SPICE_DSK02_IXDFIX.

               `spaixi' must be declared with size at least `spxisz'.

-Parameters

   SPICE_DSK02_IXDFIX

               is the size of the double precision component
               of the spatial index.

   SPICE_DSK02_IXIFIX

               is the size of the fixed-size portion of the integer
               component of the spatial index.

   See the header file SpiceDSK.h for declarations of the public DSK
   type 2 parameters used by this routine.

-Exceptions

   1)  If the fine voxel scale is non-positive, the error
       SPICE(BADFINEVOXELSCALE) is signaled.

   2)  If the coarse voxel scale is less than 1, the error
       SPICE(BADCOARSEVOXSCALE) is signaled.

   3)  If `nv' is less than 3 or greater than MAXVRT, the error
       SPICE(BADVERTEXCOUNT) is signaled.

   4)  If `np' is less than 1 or greater than MAXPLT, the error
       SPICE(BADPLATECOUNT) is signaled.

   5)  If the workspace size `worksz' is less than np+1, the error
       SPICE(WORKSPACETOOSMALL) is signaled. This is merely a
       sanity check; normally the workspace will need to be
       substantially larger than this reference value. See the
       description of `worksz' in the header section Detailed_Input
       above.

   6)  If the voxel-plate pointer array size `voxpsz' is less than 1,
       the error SPICE(PTRARRAYTOOSMALL) is signaled. This is merely
       a sanity check; normally this pointer array will need to be
       substantially larger than this reference value. See the
       description of `voxpsz' in the header section Detailed_Input
       above.

   7)  If the voxel-plate list array size `voxlsz' is less than np+1,
       the error SPICE(PLATELISTTOOSMALL) is signaled. This is
       merely a sanity check; normally this array will need to be
       substantially larger than this reference value. See the
       description of `voxlsz' in the header section Detailed_Input
       above.

   8)  If the size `spxisz' of the integer array SPAIXI is too small
       to contain its constituent structures, where the sizes
       of these structures are derived from the inputs

           `nv', `np', `voxpsz', `voxlsz'

       the error SPICE(INTINDEXTOOSMALL) will be signaled.

   9)  If there is insufficient room to create any of the data
       structures contained in the spatial index, the error
       will be diagnosed and signaled by a routine in the call
       tree of this routine.

-Files

   None.

-Particulars

   Users planning to create DSK files should consider whether the
   SPICE DSK creation utility MKDSK may be suitable for their needs.

   This routine supports use of the DSK type 2 segment writer dskw02_c
   by creating the "spatial index" arrays required as inputs to that
   routine.

   A spatial index is a group of data structures that facilitates
   rapid high-level computations involving sets of plates. The data
   structures created by this routine are aggregated into arrays
   of type SpiceInt and type SpiceDouble.

   Voxel grids
   ===========

   A key geometric computation---probably the most important, as it
   serves as a foundation for other high-level computations---is
   finding the intersection of a ray with the plate set. DSK type 2
   segments use data structures called "voxel grids" as part of
   their indexing mechanism. There is a "coarse grid": a box that
   completely encloses a DSK type 2 segment's plate set, and which
   is composed of identically-sized cubes called "coarse voxels."
   Each coarse voxel in composed of smaller cubes called "fine
   voxels." When the term "voxel" is used without qualification, it
   refers to fine voxels.

   Type 2 DSK segments contain data structures that associate plates
   with the fine voxels intersected by those plates. These
   structures enable the type 2 DSK software to rapidly find plates
   in a given region of space.

   Voxel scales
   ============

   There are two voxel scales:

      - The coarse voxel scale is the integer ratio of the
        edge length of a coarse voxel to the edge length of
        a fine voxel

      - The fine voxel scale is the double precision ratio
        of the edge length of a fine voxel to the average
        extent of the plates in the input plate set. "Extents"
        of a plate are the absolute values of the differences
        between the respective maximum and minimum X, Y, and Z
        coordinates of the plate's vertices.

   Voxel scales determine the resolution of the voxel grid.
   Voxel scales must be chosen to satisfy size constraints and
   provide reasonable plate lookup performance.

   The following considerations apply to spatial indexes of
   type 2 DSK segments:

      1)  The maximum number of coarse voxels is fixed at
          SPICE_DSK02_MAXCGR (declared in SpiceDSK.h).

      2)  If there are too few fine voxels, the average number of
          plates per fine voxel will be very large. This largely
          negates the performance improvement afforded by having an
          index. Also, the number of plates per voxel may exceed
          limits imposed by DSK subroutines that use static arrays.

      3)  If there are too many fine voxels, the average number of
          voxels intersected by a given plate may be too large for
          all the plate-voxel associations to be stored. In
          addition, the time needed to examine the plate lists for
          each voxel (including the empty ones) may become quite
          large, again negating the value of the index.

   In many cases, voxel scales yielding optimum performance must be
   determined by experiment. However, the following heuristics can
   provide reasonable starting values:

      Let `np' be the number of plates. Let `fs' be the fine voxel
      scale. Then a reasonable value of `fs' may be

                 (0.25)
         fs =  np       / 8.

      In general, `fs' should not smaller than 1.

-Examples

   The numerical results shown for this example may differ across
   platforms. The results depend on the SPICE kernels used as
   input, the compiler and supporting libraries, and the machine
   specific arithmetic implementation.

   1) Create a three-segment DSK file using plate model data for
      Phobos. Use latitudinal, rectangular, and planetodetic
      coordinates in the respective segments. This is not a
      realistic example, but it serves to demonstrate use of
      the supported coordinate systems.

      For simplicity, use an existing DSK file to provide the
      input plate and vertex data. The selected input file has one
      segment.

         /.

         Example program for dskw02_c, dskmi2_c, and dskrb2_c

         Create a three-segment DSK file using plate model data for
         Phobos. Use latitudinal, rectangular, and planetodetic
         coordinates in the respective segments.

         For simplicity, use an existing DSK file to provide the
         input plate and vertex data. The selected input file has one
         segment.

            Version 1.0.0 22-JAN-2016 (NJB)

         ./

         #include <stdio.h>
         #include "SpiceUsr.h"

         int main()
         {

            /.
            Local constants
            ./
            #define FILSIZ          256
            #define LNSIZE           81
            #define NCOR              4
            #define NSEG              3
            #define NAMLEN           21

            /.
            Local variables
            ./

            /.
            Below, we declare large arrays static to avoid stack
            overflow problems.
            ./

            SpiceBoolean            found;

            SpiceChar               cornam [ NCOR ][ NAMLEN ] =
                                    { "radius",
                                      "Z-coordinate",
                                      "Z-coordinate",
                                      "altitude" };

            SpiceChar             * dsk;
            SpiceChar             * frame;
            SpiceChar             * indsk;

            SpiceDLADescr           dladsc;

            SpiceDouble             corpar [ SPICE_DSK_NSYPAR ];
            SpiceDouble             f;
            SpiceDouble             finscl;
            SpiceDouble             first;
            SpiceDouble             last;
            SpiceDouble             mncor1;
            SpiceDouble             mncor2;
            SpiceDouble             mncor3;
            SpiceDouble             mxcor1;
            SpiceDouble             mxcor2;
            SpiceDouble             mxcor3;
            SpiceDouble             re;
            SpiceDouble             rp;

            /.
            Note: the values of SPICE_DSK02_MAXVRT and
            SPICE_DSK02_MAXPLT declared in SpiceDSK.h,
            integer spatial index dimension SPICE_DSK02_SPAISZ,
            and the workspace dimension SPICE_DSK02_MAXCEL
            are very large. Smaller buffers can be used for most
            applications.
            ./
            static SpiceDouble      spaixd [ SPICE_DSK02_SPADSZ ];
            static SpiceDouble      vrtces [ SPICE_DSK02_MAXVRT ][3];

            SpiceInt                center;
            SpiceInt                corscl;
            SpiceInt                corsys;
            SpiceInt                dclass;
            SpiceInt                handle;
            SpiceInt                i;
            SpiceInt                inhan;
            SpiceInt                np;
            SpiceInt                nv;
            static SpiceInt         plates [ SPICE_DSK02_MAXPLT ][3];
            SpiceInt                segno;
            static SpiceInt         spaixi [ SPICE_DSK02_SPAISZ ];
            SpiceInt                spaisz;
            SpiceInt                surfid;
            SpiceInt                voxpsz;
            SpiceInt                voxlsz;
            static SpiceInt         work   [ SPICE_DSK02_MAXCEL ][2];
            SpiceInt                worksz;

            /.
            Assign names of input and output DSK files.
            ./
            indsk = "phobos_3_3.bds";
            dsk   = "phobos_3_3_3seg.bds";

            /.
            Open input DSK for read access; find first segment.
            ./
            dasopr_c ( indsk, &inhan );
            dlabfs_c ( inhan, &dladsc, &found );

            /.
            Fetch vertices and plates from input DSK file.

            Note that vertex and plate indices are 1-based.
            ./
            printf ( "Reading input data...\n" );

            dskv02_c ( inhan, &dladsc, 1, SPICE_DSK02_MAXVRT,
                       &nv,   vrtces                           );
            dskp02_c ( inhan, &dladsc, 1, SPICE_DSK02_MAXPLT,
                       &np,   plates                           );

            printf ( "Done.\n" );

            /.
            Set input array sizes required by dskmi2_c.
            ./
            voxpsz = SPICE_DSK02_MAXVXP;
            voxlsz = SPICE_DSK02_MXNVLS;
            worksz = SPICE_DSK02_MAXCEL;
            spaisz = SPICE_DSK02_SPAISZ;

            /.
            Set fine and coarse voxel scales. (These usually
            need to determined by experimentation.)
            ./
            finscl = 5.0;
            corscl = 4;

            /.
            Open a new DSK file.
            ./
            dskopn_c ( dsk, dsk, 0, &handle );

            /.
            Create three segments and add them to the file.
            ./
            for ( segno = 1;  segno <= NSEG;  segno++ )
            {
               /.
               Create spatial index. We won't generate a
               vertex-plate mapping, so we set the flag
               for creating this map to "false."
               ./
               printf ( "Creating segment %d\n", (int)segno );
               printf ( "Creating spatial index...\n" );

               dskmi2_c ( nv,     vrtces,     np,     plates,
                          finscl, corscl,     worksz, voxpsz,
                          voxlsz, SPICEFALSE, spaisz, work,
                          spaixd, spaixi                    );

               printf ( "Done.\n" );

               /.
               Set up inputs describing segment attributes:

               - Central body: Phobos
               - Surface ID code: user's choice.
                 We use the segment number here.
               - Data class: general (arbitrary) shape
               - Body-fixed reference frame
               - Time coverage bounds (TBD)
               ./
               center = 401;
               surfid = segno;
               dclass = SPICE_DSK_GENCLS;
               frame  = "IAU_PHOBOS";

               first = -50 * jyear_c();
               last  =  50 * jyear_c();

               /.
               Set the coordinate system and coordinate system
               bounds based on the segment index.

               Zero out the coordinate parameters to start.
               ./
               for ( i = 0;  i < SPICE_DSK_NSYPAR;  i++ )
               {
                  corpar[i] = 0.0;
               }

               if ( segno == 1 )
               {
                  /.
                  Use planetocentric latitudinal coordinates. Set
                  the longitude and latitude bounds.
                  ./
                  corsys = SPICE_DSK_LATSYS;

                  mncor1 = -pi_c();
                  mxcor1 =  pi_c();
                  mncor2 = -pi_c()/2;
                  mxcor2 =  pi_c()/2;
               }
               else if ( segno == 2 )
               {

                  /.
                  Use rectangular coordinates. Set the
                  X and Y bounds.

                  The bounds shown here were derived from
                  the plate data. They lie slightly outside
                  of the range spanned by the plates.
                  ./
                  corsys = SPICE_DSK_RECSYS;

                  mncor1 = -1.3;
                  mxcor1 =  1.31;
                  mncor2 = -1.21;
                  mxcor2 =  1.2;
               }
               else
               {
                  /.
                  Set the coordinate system to planetodetic.
                  ./
                  corsys    = SPICE_DSK_PDTSYS;

                  mncor1    = -pi_c();
                  mxcor1    =  pi_c();
                  mncor2    = -pi_c()/2;
                  mxcor2    =  pi_c()/2;

                  /.
                  We'll use equatorial and polar radii from
                  pck00010.tpc. These normally would be fetched
                  at run time, but for simplicity, we'll use
                  hard-coded values.
                  ./
                  re        = 13.0;
                  rp        =  9.1;
                  f         = ( re - rp ) / re;

                  corpar[0] = re;
                  corpar[1] = f;
               }
               /.
               Compute plate model radius bounds.
               ./
               printf ( "Computing %s bounds of plate set...\n",
                        cornam[corsys-1]                        );

               dskrb2_c ( nv,     vrtces, np,      plates,
                          corsys, corpar, &mncor3, &mxcor3 );

               printf ( "Done.\n" );

               /.
               Write the segment to the file.
               ./
               printf ( "Writing segment...\n" );

               dskw02_c ( handle,
                          center, surfid, dclass, frame,  corsys,
                          corpar, mncor1, mxcor1, mncor2, mxcor2,
                          mncor3, mxcor3, first,  last,   nv,
                          vrtces, np,     plates, spaixd, spaixi );

               printf ( "Done.\n" );
            }

            /.
            Segregate the data records in the DSK file and
            close the file.
            ./
            printf ( "Segregating and closing DSK file...\n" );

            dskcls_c ( handle, SPICETRUE );

            printf ( "Done.\n" );

            return ( 0 );
         }

-Restrictions

   None.

-Literature_References

   None.

-Author_and_Institution

   N.J. Bachman    (JPL)

-Version

   -CSPICE Version 1.0.0, 13-DEC-2016 (NJB)

-Index_Entries

   make spatial index for type 2 dsk segment

-&
*/

{ /* Begin dskmi2_c */

   /*
   Local variables
   */
   logical                 vtlflg;

   /*
   Participate in error tracing.
   */
   chkin_c ( "dskmi2_c" );

   /*
   Cast input "make vertex list" flag to type logical.
   */
   vtlflg = (logical) makvtl;

   dskmi2_ ( ( integer     * ) &nv,
             ( doublereal  * ) vrtces,
             ( integer     * ) &np,
             ( integer     * ) plates,
             ( doublereal  * ) &finscl,
             ( integer     * ) &corscl,
             ( integer     * ) &worksz,
             ( integer     * ) &voxpsz,
             ( integer     * ) &voxlsz,
             ( logical     * ) &vtlflg,
             ( integer     * ) &spxisz,
             ( integer     * ) work,
             ( doublereal  * ) spaixd,
             ( integer     * ) spaixi   );

   chkout_c ( "dskmi2_c" );

} /* End dskmi2_c */

{'repo_name': 'esa/pykep', 'stars': '175', 'repo_language': 'C++', 'file_name': 'planets.rst', 'mime_type': 'text/plain', 'hash': 9007883550115273664, 'source_dataset': 'data'}


# netlink - netlink library for go #

[![Build Status](https://travis-ci.org/vishvananda/netlink.png?branch=master)](https://travis-ci.org/vishvananda/netlink) [![GoDoc](https://godoc.org/github.com/vishvananda/netlink?status.svg)](https://godoc.org/github.com/vishvananda/netlink)

The netlink package provides a simple netlink library for go. Netlink
is the interface a user-space program in linux uses to communicate with
the kernel. It can be used to add and remove interfaces, set ip addresses
and routes, and configure ipsec. Netlink communication requires elevated
privileges, so in most cases this code needs to be run as root. Since
low-level netlink messages are inscrutable at best, the library attempts
to provide an api that is loosely modeled on the CLI provided by iproute2.
Actions like `ip link add` will be accomplished via a similarly named
function like AddLink(). This library began its life as a fork of the
netlink functionality in
[docker/libcontainer](https://github.com/docker/libcontainer) but was
heavily rewritten to improve testability, performance, and to add new
functionality like ipsec xfrm handling.

## Local Build and Test ##

You can use go get command:

    go get github.com/vishvananda/netlink

Testing dependencies:

    go get github.com/vishvananda/netns

Testing (requires root):

    sudo -E go test github.com/vishvananda/netlink

## Examples ##

Add a new bridge and add eth1 into it:

```go
package main

import (
    "fmt"
    "github.com/vishvananda/netlink"
)

func main() {
    la := netlink.NewLinkAttrs()
    la.Name = "foo"
    mybridge := &netlink.Bridge{LinkAttrs: la}
    err := netlink.LinkAdd(mybridge)
    if err != nil  {
        fmt.Printf("could not add %s: %v\n", la.Name, err)
    }
    eth1, _ := netlink.LinkByName("eth1")
    netlink.LinkSetMaster(eth1, mybridge)
}

```
Note `NewLinkAttrs` constructor, it sets default values in structure. For now
it sets only `TxQLen` to `-1`, so kernel will set default by itself. If you're
using simple initialization(`LinkAttrs{Name: "foo"}`) `TxQLen` will be set to
`0` unless you specify it like `LinkAttrs{Name: "foo", TxQLen: 1000}`.

Add a new ip address to loopback:

```go
package main

import (
    "github.com/vishvananda/netlink"
)

func main() {
    lo, _ := netlink.LinkByName("lo")
    addr, _ := netlink.ParseAddr("169.254.169.254/32")
    netlink.AddrAdd(lo, addr)
}

```

## Future Work ##

Many pieces of netlink are not yet fully supported in the high-level
interface. Aspects of virtually all of the high-level objects don't exist.
Many of the underlying primitives are there, so its a matter of putting
the right fields into the high-level objects and making sure that they
are serialized and deserialized correctly in the Add and List methods.

There are also a few pieces of low level netlink functionality that still
need to be implemented. Routing rules are not in place and some of the
more advanced link types. Hopefully there is decent structure and testing
in place to make these fairly straightforward to add.

{'repo_name': 'weaveworks/scope', 'stars': '4447', 'repo_language': 'Go', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 640331858257878507, 'source_dataset': 'data'}


import * as path from 'path'

import { Repository } from '../../../src/models/repository'
import {
  listSubmodules,
  resetSubmodulePaths,
} from '../../../src/lib/git/submodule'
import { checkoutBranch, getBranches } from '../../../src/lib/git'
import { setupFixtureRepository } from '../../helpers/repositories'

describe('git/submodule', () => {
  describe('listSubmodules', () => {
    it('returns the submodule entry', async () => {
      const testRepoPath = await setupFixtureRepository('submodule-basic-setup')
      const repository = new Repository(testRepoPath, -1, null, false, [])
      const result = await listSubmodules(repository)
      expect(result).toHaveLength(1)
      expect(result[0].sha).toBe('c59617b65080863c4ca72c1f191fa1b423b92223')
      expect(result[0].path).toBe('foo/submodule')
      expect(result[0].describe).toBe('first-tag~2')
    })

    it('returns the expected tag', async () => {
      const testRepoPath = await setupFixtureRepository('submodule-basic-setup')
      const repository = new Repository(testRepoPath, -1, null, false, [])

      const submodulePath = path.join(testRepoPath, 'foo', 'submodule')
      const submoduleRepository = new Repository(
        submodulePath,
        -1,
        null,
        false,
        []
      )

      const branches = await getBranches(
        submoduleRepository,
        'refs/remotes/origin/feature-branch'
      )

      if (branches.length === 0) {
        throw new Error(`Could not find branch: feature-branch`)
      }

      await checkoutBranch(submoduleRepository, null, branches[0])

      const result = await listSubmodules(repository)
      expect(result).toHaveLength(1)
      expect(result[0].sha).toBe('14425bb2a4ee361af7f789a81b971f8466ae521d')
      expect(result[0].path).toBe('foo/submodule')
      expect(result[0].describe).toBe('heads/feature-branch')
    })
  })

  describe('resetSubmodulePaths', () => {
    it('update submodule to original commit', async () => {
      const testRepoPath = await setupFixtureRepository('submodule-basic-setup')
      const repository = new Repository(testRepoPath, -1, null, false, [])

      const submodulePath = path.join(testRepoPath, 'foo', 'submodule')
      const submoduleRepository = new Repository(
        submodulePath,
        -1,
        null,
        false,
        []
      )

      const branches = await getBranches(
        submoduleRepository,
        'refs/remotes/origin/feature-branch'
      )

      if (branches.length === 0) {
        throw new Error(`Could not find branch: feature-branch`)
      }

      await checkoutBranch(submoduleRepository, null, branches[0])

      let result = await listSubmodules(repository)
      expect(result[0].describe).toBe('heads/feature-branch')

      await resetSubmodulePaths(repository, ['foo/submodule'])

      result = await listSubmodules(repository)
      expect(result[0].describe).toBe('first-tag~2')
    })
  })
})

{'repo_name': 'kactus-io/kactus', 'stars': '1410', 'repo_language': 'TypeScript', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 4453607413598537042, 'source_dataset': 'data'}


/*
 * Copyright (C) 2008 TopCoder Inc., All Rights Reserved.
 */
package com.topcoder.gui.trees.document.stresstests;

import com.topcoder.uml.model.core.ModelElement;
import com.topcoder.uml.projectconfiguration.InitialElementFormatter;
import com.topcoder.uml.projectconfiguration.ProjectConfigurationException;

/**
 *

 * This is a mock implementation of InitialElementFormatter interface.
 * It is only used for testing.
 *

 *
 * @author yinzi
 * @author FireIce
 * @version 1.1
 */
public class MockInitialElementFormatter implements InitialElementFormatter {
    /**
     *

     * Implements the format(ModelElement) method.
     *

     *
     * @param element the model element
     * @return true always.
     *
     * @throws ActionExecutionException if the value of system property
     * "exception" is "ActionExecutionException"
     */
    public boolean format(ModelElement element) throws ProjectConfigurationException {
        if ("ActionExecutionException".equals(System.getProperty("exception"))) {
            throw new ProjectConfigurationException("ActionExecutionException.");
        }
        element.setSpecification(true);
        return true;
    }

}

{'repo_name': 'topcoder-platform/topcoder-UML-Tool', 'stars': '213', 'repo_language': 'Java', 'file_name': 'Diagram_UML_Sequence_Elements_Component_Specification.rtf', 'mime_type': 'text/rtf', 'hash': 742142737668329937, 'source_dataset': 'data'}


# frozen_string_literal: true
class PersonalAccessTokenValidator < ActiveModel::Validator

  ERRORS = {
    invalid_token: [:personal_access_token, 'is not a valid token for this github user'],
    missing_notifications_scope: [:personal_access_token, 'does not include the notifications scope'],
    missing_read_org_scope: [:personal_access_token, 'does not include the read:org scope'],
    disallowed_tokens: [:personal_access_token, 'is not allowed in this instance'],
  }.freeze

  def validate(record)
    return if record.personal_access_token.blank?
    validate_tokens_are_enabled(record)
    validate_token_credentials(record)
    validate_github_id(record)
    validate_github_client_notifications_scope(record)
    validate_github_client_read_scope(record)
  end

  private

  def validate_tokens_are_enabled(record)
    unless Octobox.personal_access_tokens_enabled?
      record.errors.add(*ERRORS[:disallowed_tokens])
    end
  end

  def validate_token_credentials(record)
    valid_credentials = Octokit::Client.new.validate_credentials(
      access_token: record.effective_access_token)
    record.errors.add(*ERRORS[:invalid_token]) unless valid_credentials
  end

  def validate_github_id(record)
    unless record.github_id == record.github_client.user.id
      record.errors.add(*ERRORS[:invalid_token])
    end
  end

  def validate_github_client_notifications_scope(record)
    unless record.github_client.scopes.include? 'notifications'
      record.errors.add(*ERRORS[:missing_notifications_scope])
    end
  end

  def validate_github_client_read_scope(record)
    if Octobox.restricted_access_enabled? && !record.github_client.scopes.include?('read:org')
      record.errors.add(*ERRORS[:missing_read_org_scope])
    end
  end
end

{'repo_name': 'octobox/octobox', 'stars': '3950', 'repo_language': 'Ruby', 'file_name': 'manifest.json', 'mime_type': 'text/plain', 'hash': 6015653647312586573, 'source_dataset': 'data'}


/*
 *   Pure Data Packet system implementation. : 8 bit image packet implementation
 *   Copyright (c) by Tom Schouten <tom@zwizwa.be>
 *
 *   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, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <stdio.h>
#include <string.h>
#include "pdp_packet.h"
#include "pdp_type.h"
#include "pdp_llconv.h"
#include "pdp_internals.h"
#include "pdp_post.h"

/* the class object */
static t_pdp_class* bitmap_class;

t_bitmap *pdp_packet_bitmap_info(int packet)
{
    return (t_bitmap *)pdp_packet_subheader(packet);
}

/* check if packet is a valid image packet */
int pdp_packet_bitmap_isvalid(int packet)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *image = pdp_packet_bitmap_info(packet);
    if (!header) return 0;
    if (PDP_BITMAP != header->type) return 0;

    return 1;

}

/* bitmap constructors */
t_pdp_symbol *pdp_packet_bitmap_get_description(int packet)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    char description[1024];
    char *c = description;
    int encoding;

    if (!header) return pdp_gensym("invalid");
    else if (!header->desc){
	/* if description is not defined, try to reconstruct it (for backwards compat) */
	if (header->type == PDP_BITMAP){
	    c += sprintf(c, "bitmap");
	    encoding = bitmap->encoding;
	    switch(encoding){
	    case PDP_BITMAP_RGB: c += sprintf(c, "/rgb"); break;
	    case PDP_BITMAP_RGBA: c += sprintf(c, "/rgba"); break;
	    case PDP_BITMAP_GREY: c += sprintf(c, "/grey"); break;
	    case PDP_BITMAP_YV12: c += sprintf(c, "/yv12"); break;
	    case PDP_BITMAP_I420: c += sprintf(c, "/i420"); break;
	    default:
		c += sprintf(c, "/unknown"); goto exit;
	    }
	    c += sprintf(c, "/%dx%d",
			 bitmap->width,
			 bitmap->height);
	exit:
	    return pdp_gensym(description);
	}
	else return pdp_gensym("unknown");
    }
    else return header->desc;
}

int pdp_packet_new_bitmap_yv12(u32 w, u32 h)
{
    t_pdp *header;
    t_bitmap *bitmap;
    int packet;

    u32 size = w*h;
    u32 totalnbpixels = size;
    u32 packet_size = size + (size >> 1);

    packet = pdp_packet_new(PDP_BITMAP, packet_size);
    header = pdp_packet_header(packet);
    bitmap = pdp_packet_bitmap_info(packet);
    if (!header) return -1;

    bitmap->encoding = PDP_BITMAP_YV12;
    bitmap->width = w;
    bitmap->height = h;
    header->desc = pdp_packet_bitmap_get_description(packet);
    header->theclass = bitmap_class;

    return packet;
}

int pdp_packet_new_bitmap_i420(u32 w, u32 h){
    int p = pdp_packet_new_bitmap_yv12(w,h);
    if (-1 == p) return -1;
    t_pdp *header    = pdp_packet_header(p);
    t_bitmap *bitmap = pdp_packet_subheader(p);
    bitmap->encoding = PDP_BITMAP_I420;
    header->desc = 0; // structured programming.. ha!
    header->desc = pdp_packet_bitmap_get_description(p);
    return p;
}

int pdp_packet_new_bitmap_grey(u32 w, u32 h)
{
    t_pdp *header;
    t_bitmap *bitmap;
    int packet;

    u32 size = w*h;
    u32 totalnbpixels = size;
    u32 packet_size = totalnbpixels;

    packet = pdp_packet_new(PDP_BITMAP, packet_size);
    header = pdp_packet_header(packet);
    bitmap = pdp_packet_bitmap_info(packet);
    if (!header) return -1;

    bitmap->encoding = PDP_BITMAP_GREY;
    bitmap->width = w;
    bitmap->height = h;
    header->desc = pdp_packet_bitmap_get_description(packet);
    header->theclass = bitmap_class;

    return packet;
}

int pdp_packet_new_bitmap_rgb(u32 w, u32 h)
{
    t_pdp *header;
    t_bitmap *bitmap;
    int packet;

    u32 size = w*h;
    u32 totalnbpixels = size;
    u32 packet_size = totalnbpixels * 3;

    packet = pdp_packet_new(PDP_BITMAP, packet_size);
    header = pdp_packet_header(packet);
    bitmap = pdp_packet_bitmap_info(packet);
    if (!header) return -1;

    bitmap->encoding = PDP_BITMAP_RGB;
    bitmap->width = w;
    bitmap->height = h;
    header->desc = pdp_packet_bitmap_get_description(packet);
    header->theclass = bitmap_class;

    return packet;
}

int pdp_packet_new_bitmap_rgba(u32 w, u32 h)
{
    t_pdp *header;
    t_bitmap *bitmap;
    int packet;

    u32 size = w*h;
    u32 totalnbpixels = size;
    u32 packet_size = totalnbpixels * 4;

    packet = pdp_packet_new(PDP_BITMAP, packet_size);
    header = pdp_packet_header(packet);
    bitmap = pdp_packet_bitmap_info(packet);
    if (!header) return -1;

    bitmap->encoding = PDP_BITMAP_RGBA;
    bitmap->width = w;
    bitmap->height = h;
    header->desc = pdp_packet_bitmap_get_description(packet);
    header->theclass = bitmap_class;

    return packet;
}

int pdp_packet_new_bitmap(int type, u32 w, u32 h)
{
    switch(type){
    case PDP_BITMAP_GREY: return pdp_packet_new_bitmap_grey(w,h);
    case PDP_BITMAP_YV12: return pdp_packet_new_bitmap_yv12(w,h);
    case PDP_BITMAP_I420: return pdp_packet_new_bitmap_i420(w,h);
    case PDP_BITMAP_RGB:  return pdp_packet_new_bitmap_rgb(w,h);
    case PDP_BITMAP_RGBA: return pdp_packet_new_bitmap_rgba(w,h);
    default: return -1;
    }
}

/* some utility methods */
void pdp_llconv_flip_top_bottom(char *data, int width, int height, int pixelsize);

/* flip top & bottom */
void pdp_packet_bitmap_flip_top_bottom(int packet)
{
    t_bitmap *b = (t_bitmap *)pdp_packet_subheader(packet);
    char *d = (char *)pdp_packet_data(packet);
    int w,h;
    if (!pdp_packet_bitmap_isvalid(packet)) return;
    if (!b) return;
    w = b->width;
    h = b->height;

    switch(b->encoding){
    case PDP_BITMAP_GREY: pdp_llconv_flip_top_bottom(d,w,h,1); break;
    case PDP_BITMAP_RGB:  pdp_llconv_flip_top_bottom(d,w,h,3); break;
    case PDP_BITMAP_RGBA: pdp_llconv_flip_top_bottom(d,w,h,4); break;
    default: break;
    }

}

/* conversion methods */
// image/grey/* -> bitmap/grey/*
static int _pdp_packet_bitmap_convert_grey_to_grey8(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_image *image = pdp_packet_image_info(packet);
    s16 *data = (s16 *)pdp_packet_data(packet);
    u8 *new_data;
    u32 w,h;
    int new_p;

    if (!pdp_packet_image_isvalid(packet)) return -1;
    w = image->width;
    h = image->height;

    if (!((image->encoding == PDP_IMAGE_GREY) ||
	(image->encoding == PDP_IMAGE_YV12))) return -1;

    new_p = pdp_packet_new_bitmap_grey(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    /* convert image to greyscale 8 bit */
    pdp_llconv(data,RIF_GREY______S16, new_data, RIF_GREY______U8, w, h);

    return new_p;
}

static int _pdp_packet_bitmap_convert_YCrCb_to_rgb8(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_image *image = pdp_packet_image_info(packet);
    s16 *data = (s16 *)pdp_packet_data(packet);
    u8 *new_data;
    u32 w,h;
    int new_p;

    if (!pdp_packet_image_isvalid(packet)) return -1;
    w = image->width;
    h = image->height;

    if (!((image->encoding == PDP_IMAGE_YV12))) return -1;

    new_p = pdp_packet_new_bitmap_rgb(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    /* convert image to greyscale 8 bit */
    pdp_llconv(data,RIF_YVU__P411_S16, new_data, RIF_RGB__P____U8, w, h);

    return new_p;
}

static int _pdp_packet_bitmap_convert_image_to_yv12(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_image *image = pdp_packet_image_info(packet);
    s16 *data = (s16 *)pdp_packet_data(packet);
    u8 *new_data;
    u32 w,h, nbpixels;
    int new_p;
    int encoding = image->encoding;

    if (!pdp_packet_image_isvalid(packet)) return -1;
    w = image->width;
    h = image->height;
    nbpixels = w*h;

    new_p = pdp_packet_new_bitmap_yv12(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    switch (encoding){
    case PDP_IMAGE_YV12:
	pdp_llconv(data, RIF_YVU__P411_S16, new_data, RIF_YVU__P411_U8, w, h);
	break;
    case PDP_IMAGE_GREY:
	pdp_llconv(data, RIF_GREY______S16, new_data, RIF_GREY______U8, w, h);
	memset(new_data + nbpixels, 0x80, nbpixels>>1);
	break;
    default:
	/* not supported, $$$TODO add more */
	pdp_packet_mark_unused(new_p);
	new_p = -1;
	break;
    }

    return new_p;

}

static int _pdp_packet_bitmap_convert_rgb8_to_YCrCb(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    u8 *data = (u8 *)pdp_packet_data(packet);
    s16 *new_data;
    u32 w,h;
    int new_p;

    w = bitmap->width;
    h = bitmap->height;
    new_p = pdp_packet_new_image_YCrCb(w,h);
    if (-1 == new_p) return -1;
    new_data = (s16 *)pdp_packet_data(new_p);

    /* convert image to greyscale 8 bit */
    pdp_llconv(data, RIF_RGB__P____U8, new_data, RIF_YVU__P411_S16, w, h);

    return new_p;
}

static int _pdp_packet_bitmap_convert_rgb8_to_bitmap_YCrCb(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    u8 *data = (u8 *)pdp_packet_data(packet);
    u8 *new_data;
    u32 w,h;
    int new_p;

    w = bitmap->width;
    h = bitmap->height;
    new_p = pdp_packet_new_bitmap_yv12(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    /* convert image to greyscale 8 bit */
    pdp_llconv(data, RIF_RGB__P____U8, new_data, RIF_YVU__P411_U8, w, h);

    return new_p;
}

static int _pdp_packet_bitmap_convert_grey8_to_grey(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    s16 *data = (s16 *)pdp_packet_data(packet);
    u8 *new_data;
    u32 w,h;
    int new_p;

    w = bitmap->width;
    h = bitmap->height;
    new_p = pdp_packet_new_image_grey(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    /* convert image to greyscale 8 bit */
    pdp_llconv(data, RIF_GREY______U8, new_data, RIF_GREY______S16, w, h);

    return new_p;
}
static int _pdp_packet_bitmap_convert_rgb8_to_rgba8(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    u8 *data = (u8 *)pdp_packet_data(packet);
    u8 *new_data;
    int w,h, new_p, i;

    w = bitmap->width;
    h = bitmap->height;
    new_p = pdp_packet_new_bitmap_rgba(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    for(i=0; i<w*h; i++){
	new_data[4*i+0]    = data[3*i + 0];
	new_data[4*i+1]    = data[3*i + 1];
	new_data[4*i+2]    = data[3*i + 2];
	new_data[4*i+3]    = 0;
    }

    return new_p;
}
static int _pdp_packet_bitmap_convert_rgba8_to_rgb8(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    u8 *data = (u8 *)pdp_packet_data(packet);
    u8 *new_data;
    int w,h, new_p, i;

    w = bitmap->width;
    h = bitmap->height;
    new_p = pdp_packet_new_bitmap_rgb(w,h);
    if (-1 == new_p) return -1;
    new_data = (u8 *)pdp_packet_data(new_p);

    for(i=0; i<w*h; i++){
	new_data[3*i+0]    = data[4*i + 0];
	new_data[3*i+1]    = data[4*i + 1];
	new_data[3*i+2]    = data[4*i + 2];
    }

    return new_p;
}
static int _pdp_packet_bitmap_convert_rgb8_to_mchp(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    u8 *data = (u8 *)pdp_packet_data(packet);
    s16 *new_data;
    int w,h;
    int new_p, i, plane;

    w = bitmap->width;
    h = bitmap->height;
    plane = w*h;
    new_p = pdp_packet_new_image_multi(w,h,3);
    if (-1 == new_p) return -1;
    new_data = (s16 *)pdp_packet_data(new_p);

    for(i=0; i<w*h; i++){
	new_data[i]          = ((u32)data[3*i + 0]) << 7;
	new_data[i+plane]    = ((u32)data[3*i + 1]) << 7;
	new_data[i+plane*2]  = ((u32)data[3*i + 2]) << 7;
    }

    return new_p;
}

static int _pdp_packet_bitmap_convert_yv12_tofrom_i420(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *in = pdp_packet_bitmap_info(packet);
    int w = in->width;
    int h = in->height;
    int out_encoding;
    if (in->encoding == PDP_BITMAP_YV12)      out_encoding = PDP_BITMAP_I420;
    else if (in->encoding == PDP_BITMAP_I420) out_encoding = PDP_BITMAP_YV12;
    else return -1;

    int new_p = pdp_packet_new_bitmap(out_encoding, w,h);
    // t_pdp *out_h = pdp_packet_header(new_p);
    // pdp_post("%x %s", out_encoding, out_h->desc->s_name);

    if (-1 == new_p) return -1;
    unsigned char *in_d = pdp_packet_data(packet);
    unsigned char *out_d = pdp_packet_data(new_p);
    int plane = w*h;
    memcpy(out_d, in_d, plane);
    out_d += plane;
    in_d += plane;
    plane /= 4;
    memcpy(out_d, in_d+plane, plane);
    memcpy(out_d+plane, in_d, plane);

   return new_p;
}

static int _pdp_packet_bitmap_convert_yv12_to_image(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_bitmap *bitmap = pdp_packet_bitmap_info(packet);
    u8 *data = (u8 *)pdp_packet_data(packet);
    s16 *new_data;
    int w,h;
    int new_p;

    w = bitmap->width;
    h = bitmap->height;
    new_p = pdp_packet_new_image_YCrCb(w,h);
    new_data = pdp_packet_data(new_p);
    if (-1 == new_p || !new_data) return -1;
    pdp_llconv(data, RIF_YVU__P411_U8, new_data, RIF_YVU__P411_S16, w, h);

    return new_p;
}

    inline u8 _map(s32 pixel){
	s32 mask = ~(pixel>>16);
	return ((pixel >> 7) & mask);
    }

static int _pdp_packet_bitmap_convert_mchp_to_rgb8(int packet, t_pdp_symbol *dest_template)
{
    t_pdp *header = pdp_packet_header(packet);
    t_image *image = (t_image *)pdp_packet_subheader(packet);
    s16 *data = (s16 *)pdp_packet_data(packet);
    u8 *new_data;
    int w = image->width;
    int h = image->height;
    int plane = w*h;
    int nb_channels = image->depth;
    int new_p, i;

    //    static inline u8 _map(s32 pixel){

    switch(nb_channels){
    default: return -1;
    case 1:
	if (-1 == (new_p = pdp_packet_new_bitmap_grey(w,h))) return -1;
	new_data = (u8*)pdp_packet_data(new_p);
	for(i=0; i<plane; i++) new_data[i] = _map(data[i]);
	break;
    case 3:
	if (-1 == (new_p = pdp_packet_new_bitmap_rgb(w,h)))  return -1;
	new_data = (u8*)pdp_packet_data(new_p);
	for(i=0; i<plane; i++){
	    new_data[3*i+0] = _map(data[i]);
	    new_data[3*i+1] = _map(data[i+plane]);
	    new_data[3*i+2] = _map(data[i+plane*2]);
	}
	break;
    case 4:
	if (-1 == (new_p = pdp_packet_new_bitmap_rgba(w,h))) return -1;
	new_data = (u8*)pdp_packet_data(new_p);
	for(i=0; i<plane; i++){
	    new_data[4*i+0] = _map(data[i]);
	    new_data[4*i+1] = _map(data[i+plane]);
	    new_data[4*i+2] = _map(data[i+plane*2]);
	    new_data[4*i+3] = _map(data[i+plane*3]);
	}
	break;

    }

    return new_p;

}

static int _pdp_packet_bitmap_convert_fallback(int packet, t_pdp_symbol *dest_template)
{
    pdp_post("can't convert image type %s to %s",
	 pdp_packet_get_description(packet)->s_name, dest_template->s_name);

    return -1;
}

static int pdp_bitmap_factory(t_pdp_symbol *type)
{
    t_pdp_list *l;
    t_pdp_symbol *s;
    int t;
    int w = 0;
    int h = 0;
    int d = 0;
    int p = -1;
    int n = 0;
    int m = 0;
    char *garbage = 0;

    //pdp_post("creating:");
    //pdp_post("%s", type->s_name);

    l = pdp_type_to_list(type);
    s = pdp_list_pop(l).w_symbol; // first element is "bitmap"
    s = pdp_list_pop(l).w_symbol;

    /* get image type */
    if (s == pdp_gensym("grey")) t = PDP_BITMAP_GREY;
    else if (s == pdp_gensym("yv12")) t = PDP_BITMAP_YV12;
    else if (s == pdp_gensym("rgb")) t = PDP_BITMAP_RGB;
    else goto exit;

    /* get image dimensions and create image */
    s = pdp_list_pop(l).w_symbol;
    sscanf(s->s_name, "%dx%d", &w, &h);
    p = pdp_packet_new_bitmap(t,w,h);

    if (p != -1){
	t_pdp *header = pdp_packet_header(p);
	/* if type is not exact, delete the packet */
	if (type != header->desc) {
	    pdp_packet_delete(p);
	    p = -1;
	}
    }
 exit:
    pdp_list_free(l);
    return p;
}

void pdp_bitmap_setup(void)
{
    t_pdp_conversion_program *program;

    /* setup class object */
    bitmap_class = pdp_class_new(pdp_gensym("bitmap/*/*"), pdp_bitmap_factory);

    /* setup conversion programs */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_grey_to_grey8, 0);
    pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/grey/*"), program);

    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_grey8_to_grey, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/grey/*"), pdp_gensym("image/grey/*"), program);

    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_YCrCb_to_rgb8, 0);
    pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/rgb/*"), program);

    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_image_to_yv12, 0);
    pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/yv12/*"), program);
    pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/yv12/*"), program);
    pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/*"), program);
    pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/*"), program);

    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_yv12_to_image, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/yv12/*"), pdp_gensym("image/YCrCb/*"), program);

    /* rgb->YCrCb converts the colour space */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_YCrCb, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("image/YCrCb/*"), program);

    /* rgb <-> multi does not convert the colour space */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_mchp, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("image/multi/*"), program);

    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_mchp_to_rgb8, 0);
    pdp_type_register_conversion(pdp_gensym("image/multi/*"), pdp_gensym("bitmap/*/*"), program);

    /* yv12 <-> i420 */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_yv12_tofrom_i420, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/yv12/*"), pdp_gensym("bitmap/i420/*"), program);
    pdp_type_register_conversion(pdp_gensym("bitmap/i420/*"), pdp_gensym("bitmap/yv12/*"), program);

    /* rgb <-> rgba */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_rgba8, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("bitmap/rgba/*"), program);
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgba8_to_rgb8, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/rgba/*"), pdp_gensym("bitmap/rgb/*"), program);

    /* fallback rgb convertor */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_YCrCb, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("image/*/*"), program);

    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_bitmap_YCrCb, 0);
    pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("bitmap/yv12/*"), program);

    /* fallbacks */
    program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_fallback, 0);
    pdp_type_register_conversion(pdp_gensym("image/*/*"), pdp_gensym("bitmap/*/*"), program);
    pdp_type_register_conversion(pdp_gensym("bitmap/*/*"), pdp_gensym("image/*/*"), program);
    pdp_type_register_conversion(pdp_gensym("bitmap/*/*"), pdp_gensym("bitmap/*/*"), program);

}

{'repo_name': 'agraef/purr-data', 'stars': '332', 'repo_language': 'C', 'file_name': 'entries', 'mime_type': 'text/plain', 'hash': 1388301795732459955, 'source_dataset': 'data'}


from __future__ import print_function
from tables import *
import numarray

class Particle(IsDescription):
    name = StringCol(16) # 16-character String
    idnumber = Int64Col() # Signed 64-bit integer
    ADCcount = UInt16Col() # Unsigned short integer
    TDCcount = UInt8Col() # Unsigned byte
    grid_i = Int32Col() # Integer
    grid_j = IntCol() # Integer (equivalent to Int32Col)
    pressure = Float32Col() # Float (single-precision)
    energy = FloatCol() # Double (double-precision)

h5file = openFile("tutorial.h5", mode="w", title="Test file")
group = h5file.createGroup("/", "detector", "Detector information")
table = h5file.createTable(group, "readout", Particle, "Readout example")

print(h5file)

particle = table.row

for i in xrange(10):
    particle['name'] = 'Particle: %6d' % i
    particle['TDCcount'] = i % 256
    particle['ADCcount'] = (i*256) % (1<<16)
    particle['grid_i'] = i
    particle['grid_j'] = 10 - i
    particle['pressure'] = float(i*i)
    particle['energy'] = float(particle['pressure']**4)
    particle['idnumber'] = i * (2**34)
    particle.append()

table.flush()

table = h5file.root.detector.readout
pressure = [x['pressure'] for x in table.iterrows() if x['TDCcount']>3 and
                                                       20<=x['pressure']<50]

print(pressure)

h5file.close()

{'repo_name': 'PyTables/PyTables', 'stars': '951', 'repo_language': 'C', 'file_name': '__init__.py', 'mime_type': 'text/plain', 'hash': -2950045706822121221, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>qSlicerAnnotationModulePropertyDialog</class>
 <widget class="QDialog" name="qSlicerAnnotationModulePropertyDialog">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>741</width>
    <height>486</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Modify Annotation Properties</string>
  </property>
  <layout class="QVBoxLayout" name="verticalLayout">
   <item>
    <layout class="QGridLayout" name="gridLayout_5" columnstretch="0,0,0,0,0">
     <item row="0" column="0">
      <widget class="QLabel" name="typeLabel">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Fixed" vsizetype="Minimum">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <property name="text">
        <string>Type:</string>
       </property>
      </widget>
     </item>
     <item row="0" column="3">
      <widget class="QLabel" name="ColorLabel">
       <property name="text">
        <string>Color:</string>
       </property>
      </widget>
     </item>
     <item row="0" column="4">
      <layout class="QHBoxLayout" name="horizontalLayout_2">
       <item>
        <widget class="ctkColorPickerButton" name="allColorPickerButton">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <property name="text">
          <string/>
         </property>
         <property name="displayColorName">
          <bool>false</bool>
         </property>
        </widget>
       </item>
       <item>
        <widget class="QCheckBox" name="hierarchyPushCheckBox">
         <property name="toolTip">
          <string>Propagate changes to all nodes in this list. If not checked, only when the hierarchy is collapsed will the nodes below it use these display properties.</string>
         </property>
         <property name="layoutDirection">
          <enum>Qt::RightToLeft</enum>
         </property>
         <property name="text">
          <string>Apply to List</string>
         </property>
         <property name="checked">
          <bool>true</bool>
         </property>
        </widget>
       </item>
       <item>
        <spacer name="horizontalSpacer_2">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
         <property name="sizeHint" stdset="0">
          <size>
           <width>40</width>
           <height>20</height>
          </size>
         </property>
        </spacer>
       </item>
       <item>
        <widget class="QPushButton" name="visibleInvisibleButton">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <property name="toolTip">
          <string>Toggle visibility</string>
         </property>
         <property name="text">
          <string/>
         </property>
         <property name="icon">
          <iconset resource="../qSlicerAnnotationModule.qrc">
           <normaloff>:/Icons/AnnotationVisibility.png</normaloff>
           <normalon>:/Icons/AnnotationInvisible.png</normalon>:/Icons/AnnotationVisibility.png</iconset>
         </property>
        </widget>
       </item>
       <item>
        <widget class="QPushButton" name="lockUnlockButton">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <property name="toolTip">
          <string>Toggle un-/locked</string>
         </property>
         <property name="text">
          <string/>
         </property>
         <property name="icon">
          <iconset resource="../qSlicerAnnotationModule.qrc">
           <normaloff>:/Icons/AnnotationLock.png</normaloff>:/Icons/AnnotationLock.png</iconset>
         </property>
        </widget>
       </item>
      </layout>
     </item>
     <item row="1" column="0">
      <widget class="QLabel" name="nameLabel">
       <property name="text">
        <string>Name: </string>
       </property>
      </widget>
     </item>
     <item row="1" column="1" colspan="2">
      <widget class="QLineEdit" name="nameLineEdit"/>
     </item>
     <item row="3" column="0">
      <widget class="QLabel" name="DescriptionLabel">
       <property name="text">
        <string>Description:</string>
       </property>
      </widget>
     </item>
     <item row="4" column="0" colspan="5">
      <widget class="QTextEdit" name="DescriptionTextEdit">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <property name="maximumSize">
        <size>
         <width>16777215</width>
         <height>71</height>
        </size>
       </property>
      </widget>
     </item>
     <item row="0" column="2">
      <widget class="QLabel" name="typeNameLabel">
       <property name="text">
        <string/>
       </property>
      </widget>
     </item>
     <item row="0" column="1">
      <widget class="QLabel" name="typeIcon">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <property name="text">
        <string/>
       </property>
       <property name="pixmap">
        <pixmap resource="../qSlicerAnnotationModule.qrc">:/Icons/AnnotationText.png</pixmap>
       </property>
       <property name="scaledContents">
        <bool>false</bool>
       </property>
      </widget>
     </item>
     <item row="1" column="3">
      <widget class="QLabel" name="sizeLabel">
       <property name="text">
        <string>Size:</string>
       </property>
      </widget>
     </item>
     <item row="1" column="4">
      <layout class="QHBoxLayout" name="horizontalLayout_4">
       <item>
        <widget class="QPushButton" name="sizeSmallPushButton">
         <property name="toolTip">
          <string>Change the annotation size to small by setting the scale on all components of the annotation (text, point, line) to half of the large scale</string>
         </property>
         <property name="text">
          <string>small</string>
         </property>
        </widget>
       </item>
       <item>
        <widget class="QPushButton" name="sizeMediumPushButton">
         <property name="toolTip">
          <string>Change the annotation size to medium by setting the scale on all components of the annotation (text, point, line) to three quarters of the large scale</string>
         </property>
         <property name="text">
          <string>Medium</string>
         </property>
        </widget>
       </item>
       <item>
        <widget class="QPushButton" name="sizeLargePushButton">
         <property name="toolTip">
          <string>Change the annotation size to large (default) by setting the scale on all components of the annotation (text, point, line)</string>
         </property>
         <property name="text">
          <string>LARGE</string>
         </property>
        </widget>
       </item>
      </layout>
     </item>
     <item row="2" column="3">
      <widget class="QLabel" name="RASLabel">
       <property name="text">
        <string>RAS:</string>
       </property>
      </widget>
     </item>
     <item row="2" column="4">
      <widget class="qMRMLCoordinatesWidget" name="RASCoordinatesWidget">
       <property name="quantity">
        <string>length</string>
       </property>
       <property name="unitAwareProperties">
        <set>qMRMLCoordinatesWidget::MaximumValue|qMRMLCoordinatesWidget::MinimumValue|qMRMLCoordinatesWidget::Precision|qMRMLCoordinatesWidget::Prefix|qMRMLCoordinatesWidget::Scaling|qMRMLCoordinatesWidget::Suffix</set>
       </property>
      </widget>
     </item>
    </layout>
   </item>
   <item>
    <layout class="QGridLayout" name="gridLayout_7">
     <item row="0" column="0">
      <layout class="QGridLayout" name="gridLayout_11" columnstretch="0,1,0">
       <item row="0" column="0">
        <widget class="QLabel" name="hierarchyTextScaleLabel">
         <property name="toolTip">
          <string>Apply text scale to all annotations in this hierarchy</string>
         </property>
         <property name="text">
          <string>List Text Scale:</string>
         </property>
        </widget>
       </item>
       <item row="0" column="1">
        <widget class="ctkSliderWidget" name="hierarchyTextScaleSlider">
         <property name="toolTip">
          <string>Apply text scale to all annotations in this hierarchy (current setting may not reflect text scales, this is a push to list only setting, use default button to get back to standard size)</string>
         </property>
         <property name="singleStep">
          <double>0.100000000000000</double>
         </property>
         <property name="maximum">
          <double>20.000000000000000</double>
         </property>
        </widget>
       </item>
       <item row="0" column="2">
        <widget class="QPushButton" name="hierarchyTextScaleDefaultButton">
         <property name="toolTip">
          <string>Set to default</string>
         </property>
         <property name="text">
          <string>Default</string>
         </property>
        </widget>
       </item>
      </layout>
     </item>
     <item row="1" column="0">
      <layout class="QGridLayout" name="gridLayout_10" columnstretch="0,1,0">
       <item row="0" column="0">
        <widget class="QLabel" name="hierarchyPointSizeLabel">
         <property name="toolTip">
          <string>Apply glyph scale to all annotations in this hierarchy</string>
         </property>
         <property name="text">
          <string>List Glyph Scale:</string>
         </property>
        </widget>
       </item>
       <item row="0" column="1">
        <widget class="ctkSliderWidget" name="hierarchyPointSizeSlider">
         <property name="toolTip">
          <string>Apply glyph scale to all annotations in this hierarchy (current setting may not reflect glyph scales, this is a push to list only setting, use default button to get back to standard size)</string>
         </property>
         <property name="singleStep">
          <double>0.100000000000000</double>
         </property>
         <property name="maximum">
          <double>20.000000000000000</double>
         </property>
        </widget>
       </item>
       <item row="0" column="2">
        <widget class="QPushButton" name="hierarchyPointSizeDefaultButton">
         <property name="toolTip">
          <string>Set to default</string>
         </property>
         <property name="text">
          <string>Default</string>
         </property>
        </widget>
       </item>
      </layout>
     </item>
     <item row="2" column="0">
      <layout class="QGridLayout" name="gridLayout_9" columnstretch="0,1,0">
       <item row="0" column="0">
        <widget class="QLabel" name="hierarchyGlyphTypeLabel">
         <property name="toolTip">
          <string>Apply glyph type to all annotations in this hierarchy</string>
         </property>
         <property name="text">
          <string>List Glyph Type:</string>
         </property>
        </widget>
       </item>
       <item row="0" column="1">
        <widget class="QComboBox" name="hierarchyPointGlyphTypeComboBox">
         <property name="toolTip">
          <string>Apply glyph type to all annotations in this hierarchy (current setting may not reflect glyph types, this is a push to list only setting, use default button to get back to standard glyph)</string>
         </property>
         <property name="accessibleDescription">
          <string>Glyph type combo box</string>
         </property>
         <property name="layoutDirection">
          <enum>Qt::LeftToRight</enum>
         </property>
        </widget>
       </item>
       <item row="0" column="2">
        <widget class="QPushButton" name="hierarchyPointGlyphTypeDefaultButton">
         <property name="toolTip">
          <string>Set to default</string>
         </property>
         <property name="text">
          <string>Default</string>
         </property>
        </widget>
       </item>
      </layout>
     </item>
    </layout>
   </item>
   <item>
    <widget class="ctkCollapsibleButton" name="advancedCollapsibleButton">
     <property name="text">
      <string>Advanced</string>
     </property>
     <property name="collapsed">
      <bool>true</bool>
     </property>
     <property name="contentsFrameShape">
      <enum>QFrame::NoFrame</enum>
     </property>
     <layout class="QVBoxLayout" name="verticalLayout_2">
      <item>
       <widget class="QTabWidget" name="tabWidget">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
        <property name="currentIndex">
         <number>1</number>
        </property>
        <widget class="QWidget" name="tab">
         <attribute name="title">
          <string>Text</string>
         </attribute>
         <layout class="QGridLayout" name="gridLayout_8">
          <item row="0" column="0" rowspan="3" colspan="2">
           <widget class="QTextEdit" name="annotationTextEdit">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
           </widget>
          </item>
          <item row="0" column="2">
           <widget class="ctkColorPickerButton" name="textUnselectedColorPickerButton">
            <property name="text">
             <string>Unselected Color</string>
            </property>
           </widget>
          </item>
          <item row="1" column="2">
           <widget class="ctkColorPickerButton" name="textSelectedColorPickerButton">
            <property name="text">
             <string>Selected Color</string>
            </property>
           </widget>
          </item>
          <item row="2" column="2">
           <layout class="QGridLayout" name="gridLayout">
            <item row="1" column="0">
             <widget class="QLabel" name="textScaleLabel">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
              <property name="text">
               <string>Text Scale:</string>
              </property>
              <property name="alignment">
               <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
              </property>
             </widget>
            </item>
            <item row="2" column="0">
             <widget class="QLabel" name="textOpacityLabel">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
              <property name="text">
               <string>Opacity:</string>
              </property>
             </widget>
            </item>
            <item row="3" column="0">
             <widget class="QLabel" name="textVisibilityLabel">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
              <property name="text">
               <string>Visibility:</string>
              </property>
             </widget>
            </item>
            <item row="1" column="1">
             <widget class="ctkSliderWidget" name="textScaleSliderSpinBoxWidget">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>20.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="2" column="1">
             <widget class="ctkSliderWidget" name="textOpacitySliderSpinBoxWidget">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="3" column="1">
             <widget class="ctkCheckBox" name="textVisibilityCheckBox">
               <property name="toolTip">
                 <string>Turn on/off visualization of text (when off, overrides ruler label visibility)</string>
               </property>
               <property name="indicatorIcon">
                 <iconset resource="../../../../../../Base/QTGUI/Resources/qSlicerBaseQTGUI.qrc">
                   <normaloff>:/Icons/XLarge/SlicerVisible.png</normaloff>
                 <normalon>:/Icons/XLarge/SlicerInvisible.png</normalon>:/Icons/XLarge/SlicerVisible.png</iconset>
               </property>
               <property name="indicatorIconSize">
                 <size>
                   <width>23</width>
                   <height>23</height>
                 </size>
               </property>
             </widget>
            </item>
            <item row="4" column="0">
             <spacer name="verticalSpacer">
              <property name="orientation">
               <enum>Qt::Vertical</enum>
              </property>
              <property name="sizeHint" stdset="0">
               <size>
                <width>20</width>
                <height>40</height>
               </size>
              </property>
             </spacer>
            </item>
           </layout>
          </item>
          <item row="3" column="0">
           <widget class="QLabel" name="label">
            <property name="text">
             <string>Measurement value:</string>
            </property>
           </widget>
          </item>
          <item row="3" column="1">
           <widget class="QLineEdit" name="measurementLineEdit">
            <property name="sizePolicy">
             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
            <property name="readOnly">
             <bool>true</bool>
            </property>
           </widget>
          </item>
         </layout>
        </widget>
        <widget class="QWidget" name="tab_2">
         <attribute name="title">
          <string>Points</string>
         </attribute>
         <layout class="QGridLayout" name="gridLayout_4">
          <item row="0" column="0" rowspan="3" colspan="2">
           <widget class="QTableWidget" name="pointsTableWidget">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
            <property name="minimumSize">
             <size>
              <width>457</width>
              <height>0</height>
             </size>
            </property>
            <property name="selectionMode">
             <enum>QAbstractItemView::SingleSelection</enum>
            </property>
            <property name="columnCount">
             <number>3</number>
            </property>
            <attribute name="horizontalHeaderMinimumSectionSize">
             <number>4</number>
            </attribute>
            <attribute name="horizontalHeaderStretchLastSection">
             <bool>true</bool>
            </attribute>
            <column>
             <property name="text">
              <string>X</string>
             </property>
             <property name="font">
              <font>
               <weight>75</weight>
               <bold>true</bold>
              </font>
             </property>
            </column>
            <column>
             <property name="text">
              <string>Y</string>
             </property>
             <property name="font">
              <font>
               <weight>75</weight>
               <bold>true</bold>
              </font>
             </property>
            </column>
            <column>
             <property name="text">
              <string>Z</string>
             </property>
             <property name="font">
              <font>
               <weight>75</weight>
               <bold>true</bold>
              </font>
             </property>
            </column>
           </widget>
          </item>
          <item row="0" column="2">
           <widget class="ctkColorPickerButton" name="pointUnselectedColorPickerButton">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
            <property name="text">
             <string>Unselected Color</string>
            </property>
           </widget>
          </item>
          <item row="1" column="2">
           <widget class="ctkColorPickerButton" name="pointSelectedColorPickerButton">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
            <property name="text">
             <string>Selected Color</string>
            </property>
           </widget>
          </item>
          <item row="2" column="2">
           <layout class="QGridLayout" name="gridLayout_2">
            <item row="0" column="0">
             <widget class="QLabel" name="pointGlyphScaleLabel">
              <property name="text">
               <string>Size:</string>
              </property>
             </widget>
            </item>
            <item row="2" column="0">
             <widget class="QLabel" name="opacityLabel">
              <property name="text">
               <string>Opacity:</string>
              </property>
             </widget>
            </item>
            <item row="3" column="0">
             <widget class="QLabel" name="ambientLabel">
              <property name="text">
               <string>Ambient:</string>
              </property>
             </widget>
            </item>
            <item row="4" column="0">
             <widget class="QLabel" name="diffuseLabel">
              <property name="text">
               <string>Diffuse:</string>
              </property>
             </widget>
            </item>
            <item row="5" column="0">
             <widget class="QLabel" name="specularLabel">
              <property name="text">
               <string>Specular:</string>
              </property>
             </widget>
            </item>
            <item row="2" column="1">
             <widget class="ctkSliderWidget" name="pointOpacitySliderSpinBoxWidget">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="3" column="1">
             <widget class="ctkSliderWidget" name="pointAmbientSliderSpinBoxWidget">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="4" column="1">
             <widget class="ctkSliderWidget" name="pointDiffuseSliderSpinBoxWidget">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="5" column="1">
             <widget class="ctkSliderWidget" name="pointSpecularSliderSpinBoxWidget">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="0" column="1">
             <widget class="ctkSliderWidget" name="pointSizeSliderSpinBoxWidget">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>20.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="1" column="1">
             <widget class="QComboBox" name="pointGlyphTypeComboBox">
              <property name="accessibleDescription">
               <string>Glyph type combo box</string>
              </property>
              <property name="layoutDirection">
               <enum>Qt::LeftToRight</enum>
              </property>
             </widget>
            </item>
            <item row="1" column="0">
             <widget class="QLabel" name="pointGlyphTypeLabel">
              <property name="text">
               <string>Type:</string>
              </property>
             </widget>
            </item>
           </layout>
          </item>
          <item row="3" column="2">
           <widget class="ctkCollapsibleGroupBox" name="pointFiducialProjectionPropertiesGroupBox">
            <property name="title">
             <string>Fiducial Projection</string>
            </property>
            <property name="collapsed">
             <bool>true</bool>
            </property>
            <layout class="QVBoxLayout" name="verticalLayout_3">
             <item>
              <widget class="qMRMLAnnotationFiducialProjectionPropertyWidget" name="pointFiducialProjectionWidget"/>
             </item>
            </layout>
           </widget>
          </item>
          <item row="4" column="2">
           <spacer name="verticalSpacer_8">
            <property name="orientation">
             <enum>Qt::Vertical</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>20</width>
              <height>40</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </widget>
        <widget class="QWidget" name="tab_3">
         <attribute name="title">
          <string>Lines</string>
         </attribute>
         <layout class="QGridLayout" name="gridLayout_3">
          <item row="0" column="1">
           <widget class="ctkColorPickerButton" name="lineUnselectedColorPickerButton">
            <property name="text">
             <string>Unselected Color</string>
            </property>
           </widget>
          </item>
          <item row="1" column="1">
           <widget class="ctkColorPickerButton" name="lineSelectedColorPickerButton">
            <property name="text">
             <string>Selected Color</string>
            </property>
           </widget>
          </item>
          <item row="2" column="1">
           <layout class="QGridLayout" name="gridLayout_6">
            <item row="0" column="0">
             <widget class="QLabel" name="widthLabel_2">
              <property name="text">
               <string>Width:</string>
              </property>
             </widget>
            </item>
            <item row="0" column="2">
             <widget class="ctkSliderWidget" name="lineWidthSliderSpinBoxWidget_2">
              <property name="decimals">
               <number>0</number>
              </property>
              <property name="maximum">
               <double>20.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="5" column="0">
             <widget class="QLabel" name="opacityLabel_3">
              <property name="text">
               <string>Opacity:</string>
              </property>
             </widget>
            </item>
            <item row="5" column="2">
             <widget class="ctkSliderWidget" name="lineOpacitySliderSpinBoxWidget_2">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="6" column="0">
             <widget class="QLabel" name="ambientLabel_3">
              <property name="text">
               <string>Ambient:</string>
              </property>
             </widget>
            </item>
            <item row="6" column="2">
             <widget class="ctkSliderWidget" name="lineAmbientSliderSpinBoxWidget_2">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="7" column="0">
             <widget class="QLabel" name="diffuseLabel_3">
              <property name="text">
               <string>Diffuse:</string>
              </property>
             </widget>
            </item>
            <item row="7" column="2">
             <widget class="ctkSliderWidget" name="lineDiffuseSliderSpinBoxWidget_2">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="8" column="0">
             <widget class="QLabel" name="specularLabel_3">
              <property name="text">
               <string>Specular:</string>
              </property>
             </widget>
            </item>
            <item row="8" column="2">
             <widget class="ctkSliderWidget" name="lineSpecularSliderSpinBoxWidget_2">
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="2" column="0">
             <widget class="QLabel" name="label_4">
              <property name="text">
               <string>Label Position:</string>
              </property>
             </widget>
            </item>
            <item row="2" column="2">
             <widget class="ctkSliderWidget" name="lineLabelPositionSliderSpinBoxWidget">
              <property name="toolTip">
               <string>Position the label along the line</string>
              </property>
              <property name="singleStep">
               <double>0.100000000000000</double>
              </property>
              <property name="maximum">
               <double>1.000000000000000</double>
              </property>
             </widget>
            </item>
            <item row="1" column="0" colspan="3">
             <widget class="QCheckBox" name="lineLabelVisibilityCheckBox">
              <property name="toolTip">
               <string>Show or hide the tick mark labels in 2D</string>
              </property>
              <property name="layoutDirection">
               <enum>Qt::RightToLeft</enum>
              </property>
              <property name="text">
               <string>Label Visibility</string>
              </property>
              <property name="checked">
               <bool>true</bool>
              </property>
             </widget>
            </item>
            <item row="3" column="0">
             <widget class="QLabel" name="label_5">
              <property name="toolTip">
               <string>Distance between major ticks</string>
              </property>
              <property name="text">
               <string>Tick Spacing:</string>
              </property>
             </widget>
            </item>
            <item row="3" column="2">
             <widget class="qMRMLSliderWidget" name="lineTickSpacingSlider">
              <property name="quantity">
               <string>length</string>
              </property>
              <property name="unitAwareProperties">
               <set>qMRMLSliderWidget::Prefix|qMRMLSliderWidget::Suffix|qMRMLSliderWidget::Scaling</set>
              </property>
             </widget>
            </item>
            <item row="4" column="0">
             <widget class="QLabel" name="label_6">
              <property name="text">
               <string>Max # of Ticks:</string>
              </property>
             </widget>
            </item>
            <item row="4" column="2">
             <widget class="ctkSliderWidget" name="lineMaxTicksSliderSpinBoxWidget">
              <property name="maximum">
               <double>99.000000000000000</double>
              </property>
             </widget>
            </item>
           </layout>
          </item>
          <item row="0" column="0">
           <spacer name="horizontalSpacer">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
             </size>
            </property>
           </spacer>
          </item>
          <item row="3" column="1">
           <widget class="ctkCollapsibleGroupBox" name="lineRulerProjectionPropertiesGroupBox">
            <property name="title">
             <string>Ruler Projection</string>
            </property>
            <property name="collapsed">
             <bool>true</bool>
            </property>
            <layout class="QVBoxLayout" name="verticalLayout_4">
             <item>
              <widget class="qMRMLAnnotationRulerProjectionPropertyWidget" name="lineRulerProjectionWidget"/>
             </item>
            </layout>
           </widget>
          </item>
          <item row="5" column="1">
           <spacer name="verticalSpacer_4">
            <property name="orientation">
             <enum>Qt::Vertical</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>20</width>
              <height>40</height>
             </size>
            </property>
           </spacer>
          </item>
          <item row="4" column="1">
           <spacer name="verticalSpacer_7">
            <property name="orientation">
             <enum>Qt::Vertical</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>20</width>
              <height>40</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </widget>
        <widget class="QWidget" name="ROI">
         <attribute name="title">
          <string>ROI</string>
         </attribute>
         <layout class="QHBoxLayout" name="horizontalLayout">
          <item>
           <widget class="qMRMLAnnotationROIWidget" name="ROIWidget"/>
          </item>
         </layout>
        </widget>
       </widget>
      </item>
     </layout>
    </widget>
   </item>
   <item>
    <spacer name="verticalSpacer_5">
     <property name="orientation">
      <enum>Qt::Vertical</enum>
     </property>
     <property name="sizeHint" stdset="0">
      <size>
       <width>20</width>
       <height>40</height>
      </size>
     </property>
    </spacer>
   </item>
   <item>
    <widget class="QDialogButtonBox" name="ButtonBox">
     <property name="orientation">
      <enum>Qt::Horizontal</enum>
     </property>
     <property name="standardButtons">
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
     </property>
     <property name="centerButtons">
      <bool>false</bool>
     </property>
    </widget>
   </item>
  </layout>
 </widget>
 <customwidgets>
  <customwidget>
   <class>qMRMLCoordinatesWidget</class>
   <extends>ctkCoordinatesWidget</extends>
   <header>qMRMLCoordinatesWidget.h</header>
  </customwidget>
  <customwidget>
   <class>qMRMLSliderWidget</class>
   <extends>ctkSliderWidget</extends>
   <header>qMRMLSliderWidget.h</header>
  </customwidget>
  <customwidget>
   <class>qMRMLWidget</class>
   <extends>QWidget</extends>
   <header>qMRMLWidget.h</header>
   <container>1</container>
  </customwidget>
  <customwidget>
   <class>qMRMLAnnotationFiducialProjectionPropertyWidget</class>
   <extends>qMRMLWidget</extends>
   <header>qMRMLAnnotationFiducialProjectionPropertyWidget.h</header>
  </customwidget>
  <customwidget>
   <class>qMRMLAnnotationROIWidget</class>
   <extends>QWidget</extends>
   <header>qMRMLAnnotationROIWidget.h</header>
   <container>1</container>
  </customwidget>
  <customwidget>
   <class>qMRMLAnnotationRulerProjectionPropertyWidget</class>
   <extends>qMRMLWidget</extends>
   <header>qMRMLAnnotationRulerProjectionPropertyWidget.h</header>
  </customwidget>
  <customwidget>
   <class>ctkCheckBox</class>
   <extends>QCheckBox</extends>
   <header>ctkCheckBox.h</header>
  </customwidget>
  <customwidget>
   <class>ctkCollapsibleButton</class>
   <extends>QWidget</extends>
   <header>ctkCollapsibleButton.h</header>
   <container>1</container>
  </customwidget>
  <customwidget>
   <class>ctkCollapsibleGroupBox</class>
   <extends>QGroupBox</extends>
   <header>ctkCollapsibleGroupBox.h</header>
   <container>1</container>
  </customwidget>
  <customwidget>
   <class>ctkColorPickerButton</class>
   <extends>QPushButton</extends>
   <header>ctkColorPickerButton.h</header>
  </customwidget>
  <customwidget>
   <class>ctkCoordinatesWidget</class>
   <extends>QWidget</extends>
   <header>ctkCoordinatesWidget.h</header>
  </customwidget>
  <customwidget>
   <class>ctkSliderWidget</class>
   <extends>QWidget</extends>
   <header>ctkSliderWidget.h</header>
  </customwidget>
 </customwidgets>
 <resources>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
  <include location="../qSlicerAnnotationModule.qrc"/>
 </resources>
 <connections>
  <connection>
   <sender>ButtonBox</sender>
   <signal>rejected()</signal>
   <receiver>qSlicerAnnotationModulePropertyDialog</receiver>
   <slot>reject()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>316</x>
     <y>260</y>
    </hint>
    <hint type="destinationlabel">
     <x>286</x>
     <y>274</y>
    </hint>
   </hints>
  </connection>
  <connection>
   <sender>ButtonBox</sender>
   <signal>accepted()</signal>
   <receiver>qSlicerAnnotationModulePropertyDialog</receiver>
   <slot>accept()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>248</x>
     <y>254</y>
    </hint>
    <hint type="destinationlabel">
     <x>157</x>
     <y>274</y>
    </hint>
   </hints>
  </connection>
 </connections>
</ui>

{'repo_name': 'Slicer/Slicer', 'stars': '115', 'repo_language': 'C++', 'file_name': 'itkFactoryRegistrationConfigure.h.in', 'mime_type': 'text/x-c', 'hash': -2377480111477817387, 'source_dataset': 'data'}


# Popper.js scripts

This package is a list of scripts used by Popper.js and Tooltip.js to
test the packages.

It's not intended to be used outside of Popper.js repository.

{'repo_name': 'learn-awesome/learn', 'stars': '151', 'repo_language': 'HTML', 'file_name': 'main.js', 'mime_type': 'text/plain', 'hash': -2715222299066192296, 'source_dataset': 'data'}