/*
 * Import Arc entities.
 */
void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
{
    DRAWSEGMENT* segm = ( m_useModuleItems ) ?
                        static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;

    segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
    segm->SetShape( S_ARC );

    // Init arc centre:
    wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    segm->SetCenter( center );

    // Init arc start point
    double  arcStartx   = data.radious;
    double  arcStarty   = 0;
    double  startangle = data.staangle;
    double  endangle = data.endangle;

    RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) );
    wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
                      mapY( arcStarty + data.basePoint.y ) );
    segm->SetArcStart( arcStart );

    // calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
    double angle = -RAD2DECIDEG( endangle - startangle );

    if( angle > 0.0 )
        angle -= 3600.0;

    segm->SetAngle( angle );

    segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness : data.thickness ) );
    m_newItemsList.push_back( segm );
}
/*
 * Import Arc entities.
 */
void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
{
    DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );

    segm->SetLayer( m_brdLayer );
    segm->SetShape( S_ARC );

    // Init arc centre:
    wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    segm->SetCenter( center );

    // Init arc start point
    double  arcStartx   = data.radious;
    double  arcStarty   = 0;
    double  startangle = data.staangle;
    double  endangle = data.endangle;

    RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) );
    wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
                      mapY( arcStarty + data.basePoint.y ) );
    segm->SetArcStart( arcStart );

    // calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
    double angle = -RAD2DECIDEG( endangle - startangle );

    if( angle > 0.0 )
        angle -= 3600.0;

    segm->SetAngle( angle );

    segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
                            : data.thickness ) );
    appendToBoard( segm );
}
void DXF2BRD_CONVERTER::addLine( const DRW_Line& aData )
{
    DRAWSEGMENT* segm = ( m_useModuleItems ) ?
                        static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;

    segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
    wxPoint start( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
    segm->SetStart( start );
    wxPoint end( mapX( aData.secPoint.x ), mapY( aData.secPoint.y ) );
    segm->SetEnd( end );
    segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
    m_newItemsList.push_back( segm );
}
/*
 * Import line entities.
 */
void DXF2BRD_CONVERTER::addLine( const DRW_Line& data )
{
    DRAWSEGMENT*    segm = new DRAWSEGMENT( m_brd );

    segm->SetLayer( m_brdLayer );
    wxPoint         start( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    segm->SetStart( start );
    wxPoint         end( mapX( data.secPoint.x ), mapY( data.secPoint.y ) );
    segm->SetEnd( end );
    segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
                            : data.thickness ) );
    appendToBoard( segm );
}
void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData )
{
    // Currently, Pcbnew does not know polylines, for boards.
    // So we have to convert a polyline to a set of segments.
    // Obviously, the z coordinate is ignored

    wxPoint polyline_startpoint;
    wxPoint segment_startpoint;

    for( unsigned ii = 0; ii < aData.vertlist.size(); ii++ )
    {
        DRW_Vertex* vertex = aData.vertlist[ii];

        if( ii == 0 )
        {
            segment_startpoint.x = mapX( vertex->basePoint.x );
            segment_startpoint.y = mapY( vertex->basePoint.y );
            polyline_startpoint  = segment_startpoint;
            continue;
        }

        DRAWSEGMENT* segm = ( m_useModuleItems ) ?
                            static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
                            new DRAWSEGMENT;

        segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
        segm->SetStart( segment_startpoint );
        wxPoint segment_endpoint( mapX( vertex->basePoint.x ), mapY( vertex->basePoint.y ) );
        segm->SetEnd( segment_endpoint );
        segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness
                                : aData.thickness ) );
        m_newItemsList.push_back( segm );
        segment_startpoint = segment_endpoint;
    }

    // Polyline flags bit 0 indicates closed (1) or open (0) polyline
    if( aData.flags & 1 )
    {
        DRAWSEGMENT* closing_segm = ( m_useModuleItems ) ?
                                    static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
                                    new DRAWSEGMENT;

        closing_segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
        closing_segm->SetStart( segment_startpoint );
        closing_segm->SetEnd( polyline_startpoint );
        closing_segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness
                                : aData.thickness ) );
        m_newItemsList.push_back( closing_segm );
    }
}
void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& aData )
{
    DRAWSEGMENT* segm = ( m_useModuleItems ) ?
                        static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;

    segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
    segm->SetShape( S_CIRCLE );
    wxPoint center( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
    segm->SetCenter( center );
    wxPoint circle_start( mapX( aData.basePoint.x + aData.radious ), mapY( aData.basePoint.y ) );
    segm->SetArcStart( circle_start );
    segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
    m_newItemsList.push_back( segm );
}
/*
 * Import Circle entities.
 */
void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& data )
{
    DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );

    segm->SetLayer( m_brdLayer );
    segm->SetShape( S_CIRCLE );
    wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    segm->SetCenter( center );
    wxPoint circle_start( mapX( data.basePoint.x + data.radious ),
                          mapY( data.basePoint.y ) );
    segm->SetArcStart( circle_start );
    segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
                            : data.thickness ) );
    appendToBoard( segm );
}
Пример #8
0
/* public methods */
void ThinPlateSplineShapeTransformerImpl::warpImage(InputArray transformingImage, OutputArray output,
                                      int flags, int borderMode, const Scalar& borderValue) const
{
    CV_Assert(tpsComputed==true);

    Mat theinput = transformingImage.getMat();
    Mat mapX(theinput.rows, theinput.cols, CV_32FC1);
    Mat mapY(theinput.rows, theinput.cols, CV_32FC1);

    for (int row = 0; row < theinput.rows; row++)
    {
        for (int col = 0; col < theinput.cols; col++)
        {
            Point2f pt = _applyTransformation(shapeReference, Point2f(float(col), float(row)), tpsParameters);
            mapX.at<float>(row, col) = pt.x;
            mapY.at<float>(row, col) = pt.y;
        }
    }
    remap(transformingImage, output, mapX, mapY, flags, borderMode, borderValue);
}
Пример #9
0
cv::Mat DLP3000InterpImage(cv::Mat I){
    //DLP3000INTERPIMAGE Interpolates a 684 x 608 image for projection on the DLP3000
    //diamond pixel array from a FWVGA image at 853 x 480.
    //
    //  Input parameter:
    //      C (853 x 480 pixels): input image of type double
    //
    //  Output parameter:
    //      I (684 x 608 matrix): output image
    //
    //  Note that using a 853 x 480 provides the correct aspect ratio for projecting on the DLP3000.
    //  Note that the code assumes that the image is projected 1:1 aka "short-axis flip".
    //
    //  DTU 2013, Jakob Wilm

    cv::Mat ret(684, 608, CV_8U);

    if(I.rows != 480 || I.cols != 853){
        std::cerr << "Input image has wrong dimensions" << std::endl;
        return ret;
    }

    // interpolation points
    float mdiag = 853.0/607.5; // mirror diagonal in input pixels

    cv::Mat mapX(684, 608, CV_32F), mapY(684, 608, CV_32F);

    for(unsigned int row=0; row<684; row++){
        for(unsigned int col=0; col<608; col++){
            mapY.at<float>(row,col) = row * 479.0/683.0;
            mapX.at<float>(row,col) = col*(852.0-0.5*mdiag)/607.0 + (row%2)*0.5*mdiag;
        }
    }

    cv::remap(I, ret, mapX, mapY, cv::INTER_LINEAR);

    return ret;
}
Пример #10
0
void
Transform::apply( double & x, double & y ) const
{
  x = mapX( x );
  y = mapY( y );
}
Пример #11
0
ofPoint mapPoint(ofPoint pNorm, ofRectangle rect, bool updatePosition) {
    ofPoint res;
    res.x = mapX(pNorm, rect, updatePosition);
    res.y = mapY(pNorm, rect, updatePosition);
    return res;
}
void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
{
    wxString    text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
    wxString    attrib, tmp;

    /* Some texts start by '\' and have formating chars (font name, font option...)
     *  ending with ';'
     *  Here are some mtext formatting codes:
     *  Format code        Purpose
     * \0...\o            Turns overline on and off
     *  \L...\l            Turns underline on and off
     * \~                 Inserts a nonbreaking space
     \\                 Inserts a backslash
     \\\{...\}            Inserts an opening and closing brace
     \\ \File name;        Changes to the specified font file
     \\ \Hvalue;           Changes to the text height specified in drawing units
     \\ \Hvaluex;          Changes the text height to a multiple of the current text height
     \\ \S...^...;         Stacks the subsequent text at the \, #, or ^ symbol
     \\ \Tvalue;           Adjusts the space between characters, from.75 to 4 times
     \\ \Qangle;           Changes obliquing angle
     \\ \Wvalue;           Changes width factor to produce wide text
     \\ \A                 Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top)    while( text.StartsWith( wxT("\\") ) )
     */
    while( text.StartsWith( wxT( "\\" ) ) )
    {
        attrib << text.BeforeFirst( ';' );
        tmp     = text.AfterFirst( ';' );
        text    = tmp;
    }

    BOARD_ITEM* brdItem;
    EDA_TEXT* textItem;

    if( m_useModuleItems )
    {
        TEXTE_MODULE* modText = new TEXTE_MODULE( NULL );
        brdItem = static_cast< BOARD_ITEM* >( modText );
        textItem = static_cast< EDA_TEXT* >( modText );
    }
    else
    {
        TEXTE_PCB* pcbText = new TEXTE_PCB( NULL );
        brdItem = static_cast< BOARD_ITEM* >( pcbText );
        textItem = static_cast< EDA_TEXT* >( pcbText );
    }

    brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) );
    wxPoint     textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );

    textItem->SetTextPos( textpos );
    textItem->SetTextAngle( aData.angle * 10 );

    // The 0.8 factor gives a better height/width ratio with our font
    textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
    textItem->SetTextHeight( mapDim( aData.height ) );
    textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
    textItem->SetText( text );

    // Initialize text justifications:
    if( aData.textgen <= 3 )
    {
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
    }
    else if( aData.textgen <= 6 )
    {
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
    }
    else
    {
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
    }

    if( aData.textgen % 3 == 1 )
    {
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
    }
    else if( aData.textgen % 3 == 2 )
    {
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
    }
    else
    {
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
    }

#if 0   // These setting have no mening in Pcbnew
    if( data.alignH == 1 )
    {
        // Text is left to right;
    }
    else if( data.alignH == 3 )
    {
        // Text is top to bottom;
    }
    else
    {
        // use ByStyle;
    }

    if( aData.alignV == 1 )
    {
        // use AtLeast;
    }
    else
    {
        // useExact;
    }
#endif

    m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
}
void DXF2BRD_CONVERTER::addText( const DRW_Text& aData )
{
    BOARD_ITEM* brdItem;
    EDA_TEXT* textItem;

    if( m_useModuleItems )
    {
        TEXTE_MODULE* modText = new TEXTE_MODULE( NULL );
        brdItem = static_cast< BOARD_ITEM* >( modText );
        textItem = static_cast< EDA_TEXT* >( modText );
    }
    else
    {
        TEXTE_PCB* pcbText = new TEXTE_PCB( NULL );
        brdItem = static_cast< BOARD_ITEM* >( pcbText );
        textItem = static_cast< EDA_TEXT* >( pcbText );
    }

    brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) );

    wxPoint refPoint( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
    wxPoint secPoint( mapX( aData.secPoint.x ), mapY( aData.secPoint.y ) );

    if( aData.alignV != 0 || aData.alignH != 0 || aData.alignH == DRW_Text::HMiddle )
    {
        if( aData.alignH != DRW_Text::HAligned && aData.alignH != DRW_Text::HFit )
        {
            wxPoint tmp = secPoint;
            secPoint = refPoint;
            refPoint = tmp;
        }
    }

    switch( aData.alignV )
    {
    case DRW_Text::VBaseLine:
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
        break;

    case DRW_Text::VBottom:
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
        break;

    case DRW_Text::VMiddle:
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
        break;

    case DRW_Text::VTop:
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
        break;
    }

    switch( aData.alignH )
    {
    case DRW_Text::HLeft:
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
        break;

    case DRW_Text::HCenter:
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
        break;

    case DRW_Text::HRight:
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
        break;

    case DRW_Text::HAligned:
        // no equivalent options in text pcb.
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
        break;

    case DRW_Text::HMiddle:
        // no equivalent options in text pcb.
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
        break;

    case DRW_Text::HFit:
        // no equivalent options in text pcb.
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
        break;
    }

#if 0
    wxString sty = wxString::FromUTF8( aData.style.c_str() );
    sty = sty.ToLower();

    if( aData.textgen == 2 )
    {
        // Text dir = left to right;
    } else if( aData.textgen == 4 )
    {
        // Text dir = top to bottom;
    } else
    {
    }
#endif

    wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );

    textItem->SetTextPos( refPoint );
    textItem->SetTextAngle( aData.angle * 10 );

    // The 0.8 factor gives a better height/width ratio with our font
    textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
    textItem->SetTextHeight( mapDim( aData.height ) );
    textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
    textItem->SetText( text );

    m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
}
Пример #14
0
I2Point GWindow::map(double x, double y) const {
    return I2Point(
        mapX(x), mapY(y)
    );
}
Пример #15
0
/**
 * Import texts (TEXT).
 */
void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
{
    TEXTE_PCB*  pcb_text = new TEXTE_PCB( m_brd );
    pcb_text->SetLayer( m_brdLayer );

    wxPoint refPoint( mapX(data.basePoint.x), mapY(data.basePoint.y) );
    wxPoint secPoint( mapX(data.secPoint.x), mapY(data.secPoint.y) );

    if (data.alignV !=0 || data.alignH !=0 ||data.alignH ==DRW_Text::HMiddle)
    {
        if (data.alignH !=DRW_Text::HAligned && data.alignH !=DRW_Text::HFit)
        {
            wxPoint tmp = secPoint;
            secPoint = refPoint;
            refPoint = tmp;
        }
    }

    switch( data.alignV )
    {
        case DRW_Text::VBaseLine:
            pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
            break;

        case DRW_Text::VBottom:
            pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
            break;

        case DRW_Text::VMiddle:
            pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
            break;

        case DRW_Text::VTop:
            pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
            break;
    }

    switch( data.alignH )
    {
        case DRW_Text::HLeft:
            pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
            break;

        case DRW_Text::HCenter:
            pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
            break;

        case DRW_Text::HRight:
            pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
            break;

        case DRW_Text::HAligned:
            // no equivalent options in text pcb.
            pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
            break;

        case DRW_Text::HMiddle:
            // no equivalent options in text pcb.
            pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
            break;

        case DRW_Text::HFit:
            // no equivalent options in text pcb.
            pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
            break;
    }

#if 0
    wxString sty = wxString::FromUTF8(data.style.c_str());
    sty=sty.ToLower();

    if (data.textgen==2)
    {
        // Text dir = left to right;
    } else if (data.textgen==4)
    {
        / Text dir = top to bottom;
    } else
    {
    }
Пример #16
0
void RgbEffects::RenderSingleStrandSkips(int Skips_BandSize, int Skips_SkipSize, int Skips_StartPos, const wxString & Skips_Direction)
{
    int x = Skips_StartPos - 1;
    xlColour color, black(0,0,0);
    int second = 0;
    int max = BufferWi;
    int direction = mapDirection(Skips_Direction);
    if (direction > 1) {
        max /= 2;
    }



    size_t colorcnt = GetColorCount();
    if (fitToTime) {
        int position = (GetEffectTimeIntervalPosition() * speed);
        x += position * Skips_BandSize;
    } else if (speed > 1) {
        int cur = state / 10;
        x += cur * Skips_BandSize;
    }
    while (x > max) {
        x -= (Skips_BandSize +  Skips_SkipSize) * colorcnt;
    }

    int firstX = x;
    int colorIdx = 0;

    while (x < max) {
        palette.GetColor(colorIdx, color);
        colorIdx++;
        if (colorIdx >= colorcnt) {
            colorIdx = 0;
        }
        for (int cnt = 0; cnt < Skips_BandSize && x < max; cnt++) {
            int mappedX = mapX(x, max, direction, second);
            if (mappedX >= 0 && mappedX < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(mappedX, y, color);
                }
            }
            if (second >= 0 && second < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(second, y, color);
                }
            }
            x++;
        }
        x += Skips_SkipSize;
    }
    colorIdx = GetColorCount() - 1;
    x = firstX - 1;
    while (x >= 0) {
        x -= Skips_SkipSize;

        palette.GetColor(colorIdx, color);
        colorIdx--;
        if (colorIdx < 0) {
            colorIdx = GetColorCount() - 1;
        }
        for (int cnt = 0; cnt < Skips_BandSize && x >= 0; cnt++) {
            int mappedX = mapX(x, max, direction, second);
            if (mappedX >= 0 && mappedX < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(mappedX, y, color);
                }
            }
            if (second >= 0 && second < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(second, y, color);
                }
            }
            x--;
        }
    }
}
Пример #17
0
I2Point GWindow::map(const R2Point& p) const {
    return I2Point(
        mapX(p.x), mapY(p.y)
    );
}