Exemple #1
0
void
BBox::Draw(BRect updateRect)
{
	if (!IsVisible() || fBorder == B_NO_BORDER) return;

	e_theme_engine *theme = get_current_theme_engine();
	if (theme == NULL || theme->get_border_margins == NULL || theme->draw_border == NULL) return;

	float l = 0, t = 0, r = 0, b = 0;
	theme->get_border_margins(theme, this, &l, &t, &r, &b, fBorder, PenSize());

	BRect rect = Frame().OffsetToSelf(B_ORIGIN);
	if (!(fLabelView == NULL || fLabelView->Frame().Width() <= 0 || fLabelView->Frame().Height() < t))
		rect.top += (fLabelView->Frame().Height() - t) / 2.f;

	PushState();

	BRegion clipping(updateRect);
	if (!(fLabelView == NULL || fLabelView->Frame().IsValid() == false)) clipping.Exclude(fLabelView->Frame());
	ConstrainClippingRegion(&clipping);

	if (clipping.CountRects() > 0) theme->draw_border(theme, this, rect, fBorder, PenSize());

	PopState();
}
Exemple #2
0
std::vector<SceneItem *> PortalMap::cull(int frame, FrustumPlanes &frustum, const Mat4f &world_to_projection)
{
	std::vector<SceneItem *> pvs;
	PortalClipping clipping(frustum, world_to_projection);
	int camera_sector = find_camera_sector(clipping);
	if (camera_sector != -1)
		cull_sector(clipping, sectors[camera_sector], frame, pvs);
	return pvs;
}
Exemple #3
0
void
WorkspacesView::_ExcludeFromParentClipping()
{
	// Prevent the parent view to draw over us. Do so in a way that allows
	// restoring the parent to the previous state.
	fParentWhichDrawsOnChildren->PushState();

	BRegion clipping(fParentWhichDrawsOnChildren->Bounds());
	clipping.Exclude(Frame());
	fParentWhichDrawsOnChildren->ConstrainClippingRegion(&clipping);
}
void InverseKinematics::calcLegJoints(const Pose3D& positionLeft, const Pose3D& positionRight, Joints jointAngles, const RobotDimensions& robotDimensions, float ratio)
{
    calcLegJoints(positionLeft, jointAngles, true, robotDimensions);
    calcLegJoints(positionRight, jointAngles, false, robotDimensions);
    Range<float> clipping(0.0f, 1.0f);
    ratio = clipping.limit(ratio);
    // the hip joints of both legs must be equal, so it is computed as weighted mean and the foot positions are
    // recomputed with fixed joint0 and left open foot rotation (as possible failure)
    float joint0 = jointAngles[LHipYawPitch] * ratio + jointAngles[RHipYawPitch] * (1 - ratio);
    calcLegJoints(positionLeft, jointAngles, joint0, true, robotDimensions);
    calcLegJoints(positionRight, jointAngles, joint0, false, robotDimensions);
}
Exemple #5
0
static void
calcul_masques(vpColVector &angle, // definitions des angles theta
	       unsigned int n,             // taille masques (PAIRE ou IMPAIRE Ok)
         vpMatrix *M)        // resultat M[theta](n,n)
{
  // Le coef |a| = |1/2n| n'est pas incorpore dans M(i,j) (=> que des int)

  unsigned int i_theta,  // indice (boucle sur les masques)
       i,j;      // indices de boucle sur M(i,j)
  double X,Y,   // point correspondant/centre du masque
    theta, cos_theta, sin_theta, tan_theta,
    moitie = ((double)n)/2.0; // moitie REELLE du masque
  point P1,Q1,P,Q;  // clippe Droite(theta) P1,Q1 -> P,Q
  int    sgn;       // signe de M(i,j)
  double v;         // ponderation de M(i,j)

 unsigned int nb_theta = angle.getRows() ;

 for(i_theta=0; i_theta<nb_theta; i_theta++)
 {
   theta = M_PI/180*angle[i_theta]; // indice i -> theta(i) en radians
   																//  angle[] dans [0,180[
   cos_theta = cos(theta);        // vecteur directeur de l'ECM
   sin_theta = sin(theta);        //  associe au masque

   // PRE-CALCULE 2 POINTS DE D(theta) BIEN EN DEHORS DU MASQUE
   // =========================================================
   //if( angle[i_theta]==90 )                     // => tan(theta) infinie !
   if( std::fabs(angle[i_theta]-90) <= vpMath::maximum(std::fabs(angle[i_theta]), 90.)*std::numeric_limits<double>::epsilon() )                     // => tan(theta) infinie !
   {
     P1.x=0; P1.y=-(int)n;
     Q1.x=0; Q1.y= n;
   }
   else
   {
     tan_theta = sin_theta/cos_theta;       // pente de la droite D(theta)
     P1.x=-(int)n; P1.y=tan_theta*(-(int)n);
     Q1.x=n;  Q1.y=tan_theta*n;
   }

   // CALCULE MASQUE M(theta)
   // ======================
   M[i_theta].resize(n,n);  // allocation (si necessaire)

   for(i=0,Y=-moitie+0.5 ;   i<n  ; i++,Y++)
   {
     for(j=0,X=-moitie+0.5 ;   j<n  ; j++,X++)
     {
       // produit vectoriel dir_droite*(X,Y)
       sgn = vpMath::sign(cos_theta*Y - sin_theta*X);

       // Resultat = P,Q
       if( clipping(P1,Q1, X-0.5,Y-0.5,X+0.5,Y+0.5, P,Q) )
       {
	 // v dans [0,1]
	 v=S_relative(P,Q, X-0.5,Y-0.5,X+0.5,Y+0.5);
       }
       else
	 v=1; // PQ ne coupe pas le pixel(i,j)

       M[i_theta][i][j] = vpMath::round(100*sgn*v);

       // 2 chiffres significatifs
       // M(i,j) sans incorporer le coef a
     }
   }
 }

}
Exemple #6
0
void QCompressor::process(QSampleBuffer sampleBuffer)
{
    bool isClipping = false;
    bool isActive = false;

    _mutex.lock();
    double threshold = _threshold;
    double ratio = _ratio;
    double attack = _attack;
    double release = _release;
    double inputGain = _inputGain;
    double makeupGain = _makeupGain;
    bool bypass = _bypass;
    _mutex.unlock();

    if(bypass) {
        return;
    }

    // TODO: To be implemented.
    Q_UNUSED(attack);
    Q_UNUSED(release);

    int bufferSize = sampleBuffer.size();
    double inputGainMultiplier = QUnits::dbToLinear(inputGain);
    double makeupGainMultiplier = QUnits::dbToLinear(makeupGain);
    for(int i = 0; i < bufferSize; i++) {
        // Read audio sample
        double sample = sampleBuffer.readAudioSample(i) * inputGainMultiplier;
        // Determine peak in dB
        double peak = QUnits::peak(sample);

        double resultSample = sample;

        // Check if peak is over threshold
        if(peak > QUnits::dbToLinear(threshold)) {
            // Perform signal compression
            isActive = true;
            // Calculate over treshold in linear space
            double overThreshold = peak - QUnits::dbToLinear(threshold);

            // Compress signal in logarithmic space
            double dbOverThresholdCompressed = QUnits::linearToDb(overThreshold) / ratio;

            double resultingPeak = QUnits::dbToLinear(threshold + dbOverThresholdCompressed);

            resultSample = resultingPeak * ( sample > 0.0 ? 1.0 : -1.0 );
        }

        double result = resultSample * makeupGainMultiplier;

        if(result > 1.0) {
            result = 1.0;
            isClipping = true;
        }

        if(result < -1.0) {
            result = -1.0;
            isClipping = true;
        }

        sampleBuffer.writeAudioSample(i, result);
    }

    if(isClipping) {
        emit clipping();
    }

    if(isActive) {
        emit active();
    }
}
Exemple #7
0
void QNoiseGate::process(QSampleBuffer sampleBuffer)
{
    bool isClipping = false;
    bool isActive = false;

    _mutex.lock();
    double threshold = _threshold;
    bool bypass = _bypass;

    int samplesSensitvity = QUnits::msToSamples(_sensitivity);
    int samplesResistance = QUnits::msToSamples(_resistance);
    _mutex.unlock();

    if(bypass) {
        return;
    }

    int bufferSize = sampleBuffer.size();
    for(int i = 0; i < bufferSize; i++) {
        // Read audio sample
        double sample = sampleBuffer.readAudioSample(i);
        // Determine peak in dB
        double peakDb = QUnits::linearToDb(QUnits::peak(sample));
        double result = sample;
        bool peakUnderThreshold = (peakDb < threshold);

        if(_muting) {
            if(peakUnderThreshold) {
                _sampleCount--;
                if(_sampleCount < 0) {
                    _sampleCount = 0;
                }
            } else {
                _sampleCount++;
                if(_sampleCount > samplesResistance) {
                    _muting = false;
                    _sampleCount = 0;
                }
            }
        } else {
            if(peakUnderThreshold) {
                _sampleCount++;
                if(_sampleCount > samplesSensitvity) {
                    _muting = true;
                    _sampleCount = 0;
                }
            } else {
                _sampleCount--;
                if(_sampleCount < 0) {
                    _sampleCount  = 0;
                }
            }
        }

        if(_muting) {
            // Cutoff signal
            isActive = true;
            result = 0.0;
        }

        if(result > 1.0) {
            result = 1.0;
            isClipping = true;
        }

        if(result < -1.0) {
            result = -1.0;
            isClipping = true;
        }

        sampleBuffer.writeAudioSample(i, result);
    }

    if(isClipping) {
        emit clipping();
    }

    if(isActive) {
        emit active();
    }
}