Beispiel #1
0
IPTR Register__MUIM_Layout(struct IClass *cl, Object *obj, struct MUIP_Layout *msg)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    ULONG retval = 1;
    IPTR active;

    get(obj, MUIA_Group_ActivePage, &active);

    if (active != data->active)
    {
        data->oldactive = data->active;
        data->active = active;
    }
    SetHardCoord(obj,data);
    DoMethod(obj, MUIM_UpdateInnerSizes);

    DoSuperMethodA(cl, obj, (Msg)msg);

    data->left        = _left(obj);
    data->top         = _top(obj);
    data->framewidth  = _width(obj);
    data->frameheight = _height(obj) - data->tab_height;

    LayoutTabItems(obj,data);

    /*      D(bug("Register_Layout : left=%d, top=%d / framewidth=%d, frameheight=%d\n", */
    /*   	  data->left, data->top, data->framewidth, data->frameheight)); */

    return retval;
}
Beispiel #2
0
/**************************************************************************
 Layout Tab Items
**************************************************************************/
static void LayoutTabItems(Object *obj, struct Register_DATA *data)
{
    WORD extra_space;
    WORD fitwidth;
    WORD x = 0;
    WORD y = - data->tab_height;
    WORD item_width; /* from vertical line left to v l right */
    int i;
    int tabs_on_bottom = 0;

    item_width  = (_width(obj) - data->total_hspacing) / data->columns;//data->numitems;
    extra_space = (_width(obj) - data->total_hspacing) % data->columns;//data->numitems;

    D(bug("LayoutTabItems(%lx) : width = %d, mwidth = %d, max item width = %d, remainder = %d\n",
          obj, _width(obj), _mwidth(obj), item_width, extra_space));

    for (i = 0; i < data->numitems; i++)
    {
        struct RegisterTabItem *ri = &data->items[i];

        if (i % data->columns == 0)
        {
            x = INTERTAB - 1;
            if (i > data->active && !tabs_on_bottom)
            {
                y = _height(obj) - muiAreaData(obj)->mad_InnerBottom;
                tabs_on_bottom = 1;
            } else y += data->tab_height;
        }

        ri->x1 = x;
        ri->x2 = ri->x1 + item_width - 1;
        if (extra_space > 0)
        {
            ri->x2++;
            extra_space--;
        }
        fitwidth = ri->x2 - ri->x1 + 1 - TEXTSPACING;
        x += fitwidth + TEXTSPACING + INTERTAB;

        ri->y1 = y;
        ri->y2 = y + data->tab_height - 1;
    }
}
Beispiel #3
0
IPTR Register__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct Register_DATA *data = INST_DATA(cl, obj);

    /* Before all the current page is drawn erase the part of the area covered
     * by tabs which is not erased (between _left(obj) and _mleft(obj) and so on */
    if (data->oldactive != data->active && (msg->flags & MADF_DRAWUPDATE) && (data->active/data->columns != data->oldactive/data->columns))
    {
        int left,top,width,height;

        left = _mright(obj)+1;
        top = _mtop(obj);
        width = _right(obj) - left; /* +1 - 1*/
        height = _mheight(obj);

        DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);

        left = _left(obj)+1; /* +1 because the register frame shouldn't be ereased */
        width = _mleft(obj) - left; /* + 1 - 1 */

        DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);

        top = _top(obj) + data->tab_height;
        height = _mtop(obj) - top; /* + 1 - 1 */
        width = _width(obj)-2;

        if (height > 0 && width > 0)
            DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);

        top = _mbottom(obj);
        height = _bottom(obj) - top; /* + 1 - 1 */

        if (height > 0 && width > 0)
            DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);
    }

    DoSuperMethodA(cl,obj,(Msg)msg);

    /*      D(bug("Register_Draw : flags = %d\n", msg->flags)); */
    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return(0);

    RenderRegisterTab(cl, obj, msg->flags);

    data->oldactive = data->active;
    return TRUE;
}
Beispiel #4
0
    /*
    ** Layout function. Here, we have to call MUI_Layout() for each
    ** our children. MUI wants us to place them in a rectangle
    ** defined by (0,0,lm->lm_Layout.Width-1,lm->lm_Layout.Height-1)
    ** You are free to put the children anywhere in this rectangle.
    */
BOOL MUI_Layout (Object *obj, LONG left, LONG top, LONG width, LONG height,
		 ULONG flags)
{
    static ULONG method = MUIM_Layout;
    Object *parent = _parent(obj);

/*
 * Called only by groups, never by windows
 */
    g_assert(parent != NULL);

    _left(obj) = left + _mleft(parent);
    _top(obj) = top + _mtop(parent);
    _width(obj) = width;
    _height(obj) = height;

    DoMethodA(obj, (Msg)&method);

    return TRUE;
}
Beispiel #5
0
void Ambix_directional_loudnessAudioProcessor::calcParams()
{
    if (!_initialized)
    {
        
        sph_h.Init(AMBI_ORDER);
        
        const String t_design_txt (t_design::des_3_240_21_txt);
        
        // std::cout << t_design_txt << std::endl;
        
        String::CharPointerType lineChar = t_design_txt.getCharPointer();
        
        int n = 0; // how many characters been read
        int numsamples = 0;
        int i = 0;
        
        int curr_n = 0;
        int max_n = lineChar.length();
        
        while (curr_n < max_n) { // check how many coordinates we have
            double value;
            sscanf(lineChar, "%lf\n%n", &value, &n);
            lineChar += n;
            curr_n += n;
            numsamples++;
        } // end parse numbers
        
        numsamples = numsamples/3; // xyz
        
        Carth_coord.resize(numsamples,3); // positions in cartesian coordinates
        
        curr_n = 0;
        lineChar = t_design_txt.getCharPointer();
        
        // parse line for numbers again and copy to carth coordinate matrix
        while (i < numsamples) {
            
            double x,y,z;
            
            sscanf(lineChar, "%lf%lf%lf%n", &x, &y, &z, &n);
            
            Carth_coord(i,0) = x;
            Carth_coord(i,1) = y;
            Carth_coord(i,2) = z;
            
            lineChar += n;
            
            curr_n += n;
            i++;
            
        } // end parse numbers
        
        // std::cout << "Coordinate size: " << Carth_coord.rows() << " x " << Carth_coord.cols() << std::endl;
        // std::cout << Carth_coord << std::endl;
        
        Sph_coord.resize(numsamples,2); // positions in spherical coordinates
        
        
        Sh_matrix.setZero(numsamples,AMBI_CHANNELS);
        
        for (int i=0; i < numsamples; i++)
        {
            Eigen::VectorXd Ymn(AMBI_CHANNELS); // Ymn result
            
            Sph_coord(i,0) = atan2(Carth_coord(i,1),Carth_coord(i,0)); // azimuth
            Sph_coord(i,1) = atan2(Carth_coord(i,2),sqrt(Carth_coord(i,0)*Carth_coord(i,0) + Carth_coord(i,1)*Carth_coord(i,1))); // elevation
            
            sph_h.Calc(Sph_coord(i,0),Sph_coord(i,1)); // phi theta
            sph_h.Get(Ymn);
            
            // std::cout << "Size: " << Ymn.size() << ": " << Ymn << std::endl;
            
            //Sh_matrix.row(i) = Ymn;
            Sh_matrix.block(i,0,1,AMBI_CHANNELS) = Ymn.transpose();
            // std::cout << "Size: " << Sh_matrix.block(i,0,1,in_ambi_channels).size() << ": " << Sh_matrix.block(i,0,1,in_ambi_channels) << std::endl;
        }
        
        // Sh_matrix_inv.setZero();
        
        //Sh_matrix_inv = (Sh_matrix.transpose()*Sh_matrix).inverse()*Sh_matrix.transpose(); // not working for dynamic input order
        // if input order is different a better solving has to be used for the inverse:
        Sh_matrix_inv = (Sh_matrix.transpose()*Sh_matrix).colPivHouseholderQr().inverse()*Sh_matrix.transpose();
        
        // std::cout << "Size: " << Sh_matrix_inv.rows() << " x " << Sh_matrix_inv.cols() << std::endl;
        // std::cout << Sh_matrix_inv << std::endl;
        
        _initialized = true;
        
    }
    
    if (_param_changed)
    {
        // convert parameters to values for the filter
        // ArrayIntParam _shape = shape;
        
        ArrayParam _width = width * (float)M_PI; // 0...pi
        ArrayParam _height = height * (float)M_PI;
        
        ArrayParam _gain;
        
        for (int i=0; i < gain.rows();i++)
        {
            _gain(i) = ParamToRMS(gain(i));
        }
        
        SphCoordParam _center_sph = (center_sph - 0.5f)*2.f*(float)M_PI;
        
        // std::cout << _center_sph << std::endl;
        
        CarthCoordParam _center_carth;
        
        // convert center spherical coordinates to carthesian
        for (int i=0; i < _center_sph.rows(); i++)
        {
            _center_carth(i,0) = cos(_center_sph(i,0))*cos(_center_sph(i,1)); // x
            _center_carth(i,1) = sin(_center_sph(i,0))*cos(_center_sph(i,1)); // y
            _center_carth(i,2) = sin(_center_sph(i,1)); // z
        }
        
        // scale the SH_matrix and save as Sh_matrix_mod
        Sh_matrix_mod = Sh_matrix;
        
        // iterate over all sample points
        for (int i=0; i < Sh_matrix_mod.rows(); i++)
        {
            double multipl = 1.f;
            
            // iterate over all filters
            for (int k=0; k < NUM_FILTERS; k++)
            {
                Eigen::Vector2d Sph_coord_vec = Sph_coord.row(i);
                Eigen::Vector2d _center_sph_vec = _center_sph.row(k);
                
                multipl *= (double)sph_filter.GetWeight(&Sph_coord_vec, Carth_coord.row(i), &_center_sph_vec, _center_carth.row(k), (int)shape(k), _width(k), _height(k), _gain(k), (window(k) > 0.5f), transition(k));
            }
            
            Sh_matrix_mod.row(i) *= multipl;
            
        }
        
        // calculate new transformation matrix
        Sh_transf = Sh_matrix_inv * Sh_matrix_mod;
        
        // threshold coefficients
        for (int i = 0; i < Sh_transf.size(); i++)
        {
            if (abs(Sh_transf(i)) < 0.00001f)
                Sh_transf(i) = 0.f;
        }
        
        _param_changed = false;
    }
    
    
}
Beispiel #6
0
IPTR Register__MUIM_HandleEvent(struct IClass *cl, Object *obj, struct MUIP_HandleEvent *msg)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    WORD i, x, y;

    if (msg->muikey != MUIKEY_NONE)
    {
        switch (msg->muikey)
        {
        case MUIKEY_PRESS:
        case MUIKEY_RIGHT:
        case MUIKEY_TOGGLE:
            nfset(obj, MUIA_Group_ActivePage, MUIV_Group_ActivePage_Next);
            return MUI_EventHandlerRC_Eat;

        case MUIKEY_LEFT:
            nfset(obj, MUIA_Group_ActivePage, MUIV_Group_ActivePage_Prev);
            return MUI_EventHandlerRC_Eat;

        case MUIKEY_WORDLEFT:
        case MUIKEY_LINESTART:
            nfset(obj, MUIA_Group_ActivePage, MUIV_Group_ActivePage_First);
            return MUI_EventHandlerRC_Eat;

        case MUIKEY_WORDRIGHT:
        case MUIKEY_LINEEND:
            nfset(obj, MUIA_Group_ActivePage, MUIV_Group_ActivePage_Last);
            return MUI_EventHandlerRC_Eat;

        }
    }

    if (msg->imsg)
    {
        if ((msg->imsg->Class == IDCMP_MOUSEBUTTONS) &&
                (msg->imsg->Code == SELECTDOWN))
        {
            x = msg->imsg->MouseX - data->left;
            y = msg->imsg->MouseY - data->top;

            /*  	    D(bug("Register_HandleEvent : %d,%d,%d -- %d,%d,%d\n", 0, x, _width(obj), 0, y, data->tab_height)); */
            if (_between(0, x, _width(obj)))
            {
                /*  		D(bug("Register_HandleEvent : in tab, %d,%d\n", x, y)); */
                for(i = 0; i < data->numitems; i++)
                {
                    if (_between(data->items[i].x1, x, data->items[i].x2) &&
                            _between(data->items[i].y1, y, data->items[i].y2))
                    {
                        if (data->active != i)
                        {
                            nfset(obj, MUIA_Group_ActivePage, i);
                            return MUI_EventHandlerRC_Eat;
                        }
                        break;
                    }

                }
            }

        }
    }

    return 0;
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::configurations::PlaneBoundaryConfiguration::
parseInterval(std::string interval){
  for (int d = 0; d < DIMENSIONS; d++){
    std::string number1("");
    std::string number2("");
    tarch::irr::io::IrrXMLReader* getNumbers = tarch::irr::io::createIrrXMLReaderFromString("");
    size_t closedPos1   = interval.find("[");
    size_t openPos1     = interval.find("(");
    size_t closedPos2   = interval.find("]");
    size_t openPos2     = interval.find(")");
    size_t semicolonPos = interval.find(";");
    size_t first = 0;
    size_t last = 0;

    // determine left bracket position
    if ( (closedPos1 == std::string::npos) && (openPos1 == std::string::npos) ){
      logDebug("parseInterval()", "No left brackets found!");
      assertion(false);
    }
    if (closedPos1 == std::string::npos){
      first = openPos1;
    }
    if (openPos1 == std::string::npos){
      first = closedPos1;
    }
    if ( (closedPos1 != std::string::npos) && (openPos1 != std::string::npos) ){
      first = std::min(closedPos1,openPos1);
    }

    // determine right bracket position
    if ( (closedPos2 == std::string::npos) && (openPos2 == std::string::npos) ){
      logDebug("parseInterval()", "No right brackets found!");
      assertion(false);
    }
    if (closedPos2 == std::string::npos){
      last = openPos2;
    }
    if (openPos2 == std::string::npos){
      last = closedPos2;
    }
    if ( (closedPos2 != std::string::npos) && (openPos2 != std::string::npos) ){
      last = std::min(closedPos2,openPos2);
    }

    // check validity
    if (first >= last){
      logDebug("parseInterval()", "Right brackets before left brackets!");
      assertion(false);
    }
    if ( (semicolonPos <=first) || (semicolonPos >= last) || (semicolonPos == std::string::npos) ){
      logDebug("parseInterval()", "No valid semicolon separation could not be detected!");
      assertion(false);
    }

    // find out type of brackets
    if (first == closedPos1){
      _isOpen(2*d) = false;
    } else {
      _isOpen(2*d) = true;
    }
    if (last == closedPos2){
      _isOpen(2*d+1) = false;
    } else {
      _isOpen(2*d+1) = true;
    }

    // get start and end interval and set offset and width of box range
    number1 = interval.substr(first+1,semicolonPos-1-first);
    number2 = interval.substr(semicolonPos+1,last-1-semicolonPos);
    _offset(d) = getNumbers->convertValueStringToDouble( number1 );
    _width(d) = getNumbers->convertValueStringToDouble(number2) - _offset(d);
    logDebug("parseInterval()", "Number1: " << number1 << " offset " << d << ": " << _offset(d));
    logDebug("parseInterval()", "Number2: " << number2 << " width " << d << ": " << _width(d));

    // remove this part from string
    interval = interval.substr(last+1);

    // find sign 'x' and next left bracket
    if (d < DIMENSIONS-1){
      size_t closedNext = interval.find("[");
      size_t openNext = interval.find("(");
      first = interval.find("x");

      if ( (closedNext == std::string::npos) && (openNext == std::string::npos) ){
        logDebug("parseInterval()", "No new left brackets found!");
        assertion(false);
      }
      if (closedNext == std::string::npos){
        last = openNext;
      }
      if (openNext == std::string::npos){
        last = closedNext;
      }
      if ( (closedNext != std::string::npos) && (openNext != std::string::npos) ){
        last = std::min(closedNext,openNext);
      }

      if (last <= first){
        logDebug("parseInterval()", "No 'x' between intervals could be found!");
        assertion(false);
      }

      // remove all just until the first letter behind 'x'
      interval = interval.substr(first+1);
    }
    logDebug("parseInterval()", "Rest to parse: " << interval);

  }

  // check width
  for (int d = 0; d < DIMENSIONS; d++){
    if (tarch::la::smaller(_width(d),0.0)){
      logDebug("parseInterval()", "Width of box is smaller than zero!");
      assertion(false);
    }
  }
}
Beispiel #8
0
void Ambix_vmicAudioProcessor::calcParams()
{
    if (!_initialized)
    {
        
        sph_h.Init(AMBI_ORDER);
        
        const String t_design_txt (t_design::des_3_240_21_txt);
        
        // std::cout << t_design_txt << std::endl;
        
        String::CharPointerType lineChar = t_design_txt.getCharPointer();
        
        int n = 0; // how many characters been read
        int numsamples = 0;
        int i = 0;
        
        int curr_n = 0;
        int max_n = lineChar.length();
        
        while (curr_n < max_n) { // check how many coordinates we have
            double value;
            sscanf(lineChar, "%lf\n%n", &value, &n);
            lineChar += n;
            curr_n += n;
            numsamples++;
        } // end parse numbers
        
        numsamples = numsamples/3; // xyz
        
        Carth_coord.resize(numsamples,3); // positions in cartesian coordinates
        
        curr_n = 0;
        lineChar = t_design_txt.getCharPointer();
        
        // parse line for numbers again and copy to carth coordinate matrix
        while (i < numsamples) {
            
            double x,y,z;
            
            sscanf(lineChar, "%lf%lf%lf%n", &x, &y, &z, &n);
            
            Carth_coord(i,0) = x;
            Carth_coord(i,1) = y;
            Carth_coord(i,2) = z;
            
            lineChar += n;
            
            curr_n += n;
            i++;
            
        } // end parse numbers
        
        // std::cout << "Coordinate size: " << Carth_coord.rows() << " x " << Carth_coord.cols() << std::endl;
        // std::cout << Carth_coord << std::endl;
        
        Sph_coord.resize(numsamples,2); // positions in spherical coordinates
        
        
        Sh_matrix.setZero(numsamples,AMBI_CHANNELS);
        
        for (int i=0; i < numsamples; i++)
        {
            Eigen::VectorXd Ymn(AMBI_CHANNELS); // Ymn result
            
            Sph_coord(i,0) = atan2(Carth_coord(i,1),Carth_coord(i,0)); // azimuth
            Sph_coord(i,1) = atan2(Carth_coord(i,2),sqrt(Carth_coord(i,0)*Carth_coord(i,0) + Carth_coord(i,1)*Carth_coord(i,1))); // elevation
            
            sph_h.Calc(Sph_coord(i,0),Sph_coord(i,1)); // phi theta
            sph_h.Get(Ymn);
            
            Sh_matrix.block(i,0,1,AMBI_CHANNELS) = Ymn.transpose();
        }
        
        
        _initialized = true;
        
    }
    
    if (_param_changed)
    {
        // convert parameters to values for the filter
        // ArrayIntParam _shape = shape;
        
        ArrayParam _width = width * (float)M_PI; // 0...pi
        ArrayParam _height = height * (float)M_PI;
        
        ArrayParam _gain;
        
        for (int i=0; i < gain.rows();i++)
        {
            _gain(i) = ParamToRMS(gain(i));
        }
        
        SphCoordParam _center_sph = (center_sph - 0.5f)*2.f*M_PI;
        
        // std::cout << _center_sph << std::endl;
        
        CarthCoordParam _center_carth;
        
        // convert center spherical coordinates to carthesian
        for (int i=0; i < _center_sph.rows(); i++)
        {
            _center_carth(i,0) = cos(_center_sph(i,0))*cos(_center_sph(i,1)); // x
            _center_carth(i,1) = sin(_center_sph(i,0))*cos(_center_sph(i,1)); // y
            _center_carth(i,2) = sin(_center_sph(i,1)); // z
        }
        
        Sh_matrix_mod.setZero();
        
        // iterate over all filters
        for (int k=0; k < NUM_FILTERS_VMIC; k++)
        {
            // copy the SH_matrix to 
            Eigen::MatrixXd Sh_matrix_temp = Sh_matrix;
            
            // iterate over all sample points
            for (int i=0; i < Sh_matrix_temp.rows(); i++)
            {
                
                Eigen::Vector2d Sph_coord_vec = Sph_coord.row(i);
                Eigen::Vector2d _center_sph_vec = _center_sph.row(k);
                
                
                double multipl = sph_filter.GetWeight(&Sph_coord_vec, Carth_coord.row(i), &_center_sph_vec, _center_carth.row(k), (int)floor(shape(k)+0.5f), _width(k), _height(k), 1, true, transition(k));
                
                if (multipl < 0.f) // -1.f in case of outside region
                    multipl = 0.f;
                
                Sh_matrix_temp.row(i) *= multipl;
            }
            
            // Sh_matrix_mod row is the sum over the columns
            Sh_matrix_mod.row(k) = Sh_matrix_temp.colwise().sum();
            
            // normalize and apply gain
            if (Sh_matrix_mod.row(k)(0) > 0.f)
                Sh_matrix_mod.row(k) *= 1/Sh_matrix_mod.row(k)(0)*_gain(k); 
        }
        
        // std::cout << "Size Sh_matrix_mod : " << Sh_matrix_mod.rows() << " x " << Sh_matrix_mod.cols() << std::endl;
        
        // std::cout << Sh_matrix_mod << std::endl;
        
        
        // this is the new transformation matrix
        Sh_transf = Sh_matrix_mod;
        
        // threshold coefficients
        for (int i = 0; i < Sh_transf.size(); i++)
        {
            if (abs(Sh_transf(i)) < 0.00001f)
                Sh_transf(i) = 0.f;
        }
        
        _param_changed = false;
    }
    
    
}