Exemplo n.º 1
0
bool fit_in_rules(size_t lmix,size_t lmax,size_t rmix,size_t rmax,size_t new_x,size_t new_w,size_t delta_x)
{
    update_me(lmix,lmax,rmix,rmax,new_x,new_w);
    if((lmax-lmix)>delta_x || (rmax-rmix)>delta_x)
        return false;
    else
        return true;
}
Exemplo n.º 2
0
bool extract_rectangles(const v_block_decomp_t& block,std::vector<rectangle_t>& r,size_t delta_x,
    rectangle_filter_t rf,rectangle_comp_t rc)
{
    // brute force
    for(size_t y=0;y<block.seg.size();y++)
    {
        size_t left_min_x=block.seg[y].x;
        size_t left_max_x=block.seg[y].x;
        size_t right_min_x=block.seg[y].x+block.seg[y].w;
        size_t right_max_x=block.seg[y].x+block.seg[y].w;

        size_t oy=y+1;
        while(oy<block.seg.size() &&
            fit_in_rules(left_min_x,left_max_x,right_min_x,right_max_x,
                        block.seg[oy].x,block.seg[oy].w,delta_x))
        {
            update_me(left_min_x,left_max_x,right_min_x,right_max_x,
                        block.seg[oy].x,block.seg[oy].w);
            oy++;
        }
        // we now have a beautiful rectangle:
        size_t avmix=(left_min_x+left_max_x)/2;
        size_t avmax=(right_min_x+right_max_x)/2;
        rectangle_t temp;
        temp.x=avmix;
        temp.y=y+block.y;
        temp.w=avmax-avmix;
        temp.h=oy-y;

        // filter it
        if(!rf(temp))
            continue;
        // compare it to others
        bool keep=true;
        for(int i=0;i<int(r.size());i++)
        {
            bool k1,k2;
            rc(r[i],k1,temp,k2);
            if(!k2)
            {
                keep=false;
                break;
            }
            if(!k1)
            {
                fast_vector_erase(r,i);
                i--;
            }
        }
        if(keep)
            r.push_back(temp);
    }

    return true;
}
Exemplo n.º 3
0
/******************************************
 ***************   SLOTS   ****************
 *****************************************/
void Device::readData()
{
    data= socket->readAll();
    QString host_address=socket->peerAddress().toString();
    qDebug()<<host_address;

    qDebug()<<"data="<<data;
    if(data.contains("###STATUS"))
    {
        emit data_available(this->dev_id,data); ///< signal is emmitted when "###STATUS" is received
    }
    if(data.contains("#IPSUBNET CHANGED"))
    {
        emit update_me(this->dev_id);   ///< signal is emmitted when "#IPSUBNET CHANGED" is received
    }
}