SoundSlider::SoundSlider( QWidget *_parent, int _i_step,
                          char *psz_colors, int max )
                        : QAbstractSlider( _parent )
{
    f_step = (float)(_i_step * 10000)
           / (float)((max - SOUNDMIN) * AOUT_VOLUME_DEFAULT);
    setRange( SOUNDMIN, max);
    setMouseTracking( true );
    isSliding = false;
    b_mouseOutside = true;
    b_isMuted = false;

    pixOutside = QPixmap( ":/toolbar/volslide-outside" );

    const QPixmap temp( ":/toolbar/volslide-inside" );
    const QBitmap mask( temp.createHeuristicMask() );

    setFixedSize( pixOutside.size() );

    pixGradient = QPixmap( mask.size() );
    pixGradient2 = QPixmap( mask.size() );

    /* Gradient building from the preferences */
    QLinearGradient gradient( paddingL, 2, WLENGTH + paddingL , 2 );
    QLinearGradient gradient2( paddingL, 2, WLENGTH + paddingL , 2 );

    QStringList colorList = qfu( psz_colors ).split( ";" );
    free( psz_colors );

    /* Fill with 255 if the list is too short */
    if( colorList.count() < 12 )
        for( int i = colorList.count(); i < 12; i++)
            colorList.append( "255" );

    background = palette().color( QPalette::Active, QPalette::Window );
    foreground = palette().color( QPalette::Active, QPalette::WindowText );
    foreground.setHsv( foreground.hue(),
                    ( background.saturation() + foreground.saturation() ) / 2,
                    ( background.value() + foreground.value() ) / 2 );

    textfont.setPixelSize( 9 );
    textrect.setRect( 0, 0, 34, 15 );

    /* Regular colors */
#define c(i) colorList.at(i).toInt()
#define add_color(gradient, range, c1, c2, c3) \
    gradient.setColorAt( range, QColor( c(c1), c(c2), c(c3) ) );

    /* Desaturated colors */
#define desaturate(c) c->setHsvF( c->hueF(), 0.2 , 0.5, 1.0 )
#define add_desaturated_color(gradient, range, c1, c2, c3) \
    foo = new QColor( c(c1), c(c2), c(c3) );\
    desaturate( foo ); gradient.setColorAt( range, *foo );\
    delete foo;

    /* combine the two helpers */
#define add_colors( gradient1, gradient2, range, c1, c2, c3 )\
    add_color( gradient1, range, c1, c2, c3 ); \
    add_desaturated_color( gradient2, range, c1, c2, c3 );

    float f_mid_point = ( 100.0 / maximum() );
    QColor * foo;
    add_colors( gradient, gradient2, 0.0, 0, 1, 2 );
    add_colors( gradient, gradient2, f_mid_point - 0.05, 3, 4, 5 );
    add_colors( gradient, gradient2, f_mid_point + 0.05, 6, 7, 8 );
    add_colors( gradient, gradient2, 1.0, 9, 10, 11 );

    painter.begin( &pixGradient );
    painter.setPen( Qt::NoPen );
    painter.setBrush( gradient );
    painter.drawRect( pixGradient.rect() );
    painter.end();

    painter.begin( &pixGradient2 );
    painter.setPen( Qt::NoPen );
    painter.setBrush( gradient2 );
    painter.drawRect( pixGradient2.rect() );
    painter.end();

    pixGradient.setMask( mask );
    pixGradient2.setMask( mask );
}
Exemple #2
0
 int maximum(int a,int b) { return maximum(a,b,0,0,N); }
Exemple #3
0
int
ACE_Stats::print_summary (const u_int precision,
                          const ACE_UINT32 scale_factor,
                          FILE *file) const
{
  ACE_TCHAR mean_string [128];
  ACE_TCHAR std_dev_string [128];
  ACE_TCHAR min_string [128];
  ACE_TCHAR max_string [128];
  int success = 0;

  for (int tmp_precision = precision;
       ! overflow_  &&  ! success  &&  tmp_precision >= 0;
       --tmp_precision)
    {
      // Build a format string, in case the C library doesn't support %*u.
      ACE_TCHAR format[32];
      if (tmp_precision == 0)
        ACE_OS::sprintf (format, ACE_LIB_TEXT ("%%%d"), tmp_precision);
      else
        ACE_OS::sprintf (format, ACE_LIB_TEXT ("%%d.%%0%du"), tmp_precision);

      ACE_Stats_Value u (tmp_precision);
      ((ACE_Stats *) this)->mean (u, scale_factor);
      ACE_OS::sprintf (mean_string, format, u.whole (), u.fractional ());

      ACE_Stats_Value sd (tmp_precision);
      if (((ACE_Stats *) this)->std_dev (sd, scale_factor))
        {
          success = 0;
          continue;
        }
      else
        {
          success = 1;
        }
      ACE_OS::sprintf (std_dev_string, format, sd.whole (), sd.fractional ());

      ACE_Stats_Value minimum (tmp_precision), maximum (tmp_precision);
      if (min_ != 0)
        {
          const ACE_UINT64 m (min_);
          quotient (m, scale_factor, minimum);
        }
      if (max_ != 0)
        {
          const ACE_UINT64 m (max_);
          quotient (m, scale_factor, maximum);
        }
      ACE_OS::sprintf (min_string, format,
                       minimum.whole (), minimum.fractional ());
      ACE_OS::sprintf (max_string, format,
                       maximum.whole (), maximum.fractional ());
    }

  if (success == 1)
    {
      ACE_OS::fprintf (file, ACE_LIB_TEXT ("samples: %u (%s - %s); mean: ")
                       ACE_LIB_TEXT ("%s; std dev: %s\n"),
                       samples (), min_string, max_string,
                       mean_string, std_dev_string);
      return 0;
    }
  else
    {
#if !defined (ACE_HAS_WINCE)
      ACE_OS::fprintf (file,
                       ACE_LIB_TEXT ("ACE_Stats::print_summary: OVERFLOW: %s\n"),
                       ACE_OS::strerror (overflow_));
#else
      // WinCE doesn't have strerror ;(
      ACE_OS::fprintf (file,
                       ACE_LIB_TEXT ("ACE_Stats::print_summary: OVERFLOW\n"));
#endif /* ACE_HAS_WINCE */
      return -1;
    }
}
Exemple #4
0
void sort_web_statistics()
{
	int NWeb, NType, Ns, i=0, j=0, k=0, l=0;
	int *dm_bin_int, *cum_dm_bin_int;
	double w_gas, w_dm;
	double dmMax, dmMin, *dm_bin, *dm_bin_e; 
	double *dm_bin_T, *dm_bin_alpha, *dm_bin_gas;	
	double *delta_dm, *alpha_dm, *p_alpha_dm;
	double *delta_gas, *T_gas, *alpha_gas, *p_alpha_gas;
	double *delta_tot, *alpha_tot, *p_alpha_tot;
	
	double *param;

	NWeb = Settings.c_web_size;
	w_gas = 0.046 / 0.27;
	w_dm = 1 - w_gas;
	Ns = 5;

	// Do a general statistics of the eigenvalue-types
	eigenvalue_statistics();

	// Now sort statistics per node type
	// i = 0 is the global statistics
	for(i=0; i<5; i++)
	{
		k = 0;
		l = 0;
		NType = WebInfoDm.N[i];
		
		fprintf(stderr, "Found %d nodes of type %d.\n", NType, i);
		dm_bin = malloc((BIN_SIZE+1)*sizeof(double));
		dm_bin_e = malloc((BIN_SIZE)*sizeof(double));
		dm_bin_T = malloc((BIN_SIZE)*sizeof(double));
		dm_bin_alpha = malloc((BIN_SIZE)*sizeof(double));
		dm_bin_gas = malloc((BIN_SIZE)*sizeof(double));
		dm_bin_int = malloc((BIN_SIZE)*sizeof(int));
		cum_dm_bin_int = malloc((BIN_SIZE)*sizeof(int));

		fprintf(stderr, "Allocating %.2f MB for type analysis...", (double) Ns*NType*sizeof(double)/1024/1024);
		alpha_dm  = malloc(NType * sizeof(double));
		delta_dm  = malloc(NType * sizeof(double));
		delta_gas = malloc(NType * sizeof(double));
		delta_tot = malloc(NType * sizeof(double));
		T_gas = malloc(NType * sizeof(double));
		fprintf(stderr, "Done.\n");	 

		param = malloc(2 * sizeof(double));

#	pragma omp parallel for					\
	private(k, j) 						\
	shared(i, alpha_dm, delta_dm, delta_gas, delta_tot) 	\
	shared(TWeb, VWeb, NWeb, w_dm, w_gas, T_gas, WebInfoDm)	
	for(j=0; j<NType; j++)
	{
		if(i == 0)
		{
			delta_dm[j] =  VWeb[j].dens;	
#ifdef GAS
			delta_gas[j] = TWeb[j].dens;	
			delta_tot[j] = w_gas * TWeb[j].dens + w_dm * VWeb[j].dens;	

			T_gas[j] = u2TK(TWeb[j].temp);
#endif	
			if(delta_dm[j]!=0.0)
				alpha_dm[j] = T_gas[j] / delta_dm[j];

		}
		else
		{
			k = WebInfoDm.ids[i-1][j];

			delta_dm[j] = VWeb[k].dens;	
#ifdef GAS
			delta_gas[j] = TWeb[k].dens;	
			delta_tot[j] = w_gas * TWeb[k].dens + w_dm * VWeb[k].dens;	
			T_gas[j] = u2TK(TWeb[k].temp);
#endif
			if(delta_dm[j]!=0.0)
				alpha_dm[j] = T_gas[j] / delta_dm[j];	

		}
	}	

			// Now bin into histograms
			dmMin = F_MIN * nonzero_minimum(delta_dm, NType);
			dmMax = F_MAX * maximum(delta_dm, NType);
	
		//fprintf(stderr, "min=%f, max=%f, dm[1]=%f\n", dmMin, dmMax, delta_dm[1]);

			dm_bin = log_stepper(dmMin, dmMax, BIN_SIZE+1);
			
			lin_bin(delta_dm, dm_bin, BIN_SIZE+1, NType, dm_bin_int);
			cum_bin(dm_bin_int, cum_dm_bin_int, BIN_SIZE);
			average_bin(delta_dm, T_gas, dm_bin, dm_bin_T, dm_bin_e, BIN_SIZE+1, NType);
			average_bin(delta_dm, alpha_dm, dm_bin, dm_bin_alpha, dm_bin_e, BIN_SIZE+1, NType);
			average_bin(delta_dm, delta_gas, dm_bin, dm_bin_gas, dm_bin_e, BIN_SIZE+1, NType);

			param[0] = 1.;
			param[1] = average(T_gas, BIN_SIZE);

			param = best_fit_power_law(delta_gas, T_gas, dm_bin_e, BIN_SIZE, param);
	
			fprintf(stderr, "Best Fit PowerLaw a=%f, A=%f\n", param[0], param[1]);
			WebInfoDm.a[i] = param[0];
			WebInfoDm.A[i] = param[1];

		for(j=0; j<BIN_SIZE; j++)
		{
			//fprintf(stderr, "%d) dm[%d]=%f, T_bin[%d]=%f\n", i, j, dm_bin[j], j, dm_bin_T[j]);
			//fprintf(stderr, "%d) dm[%d]=%f, alpha_bin[%d]=%f\n", i, j, dm_bin[j], j, dm_bin_alpha[j]);
			//fprintf(stderr, "%d) dm[%d]=%f, gas_bin[%d]=%f\n", i, j, dm_bin[j], j, dm_bin_gas[j]);

			// Overdensity values
			WebInfoDm.delta[i][j] = 0.5 * (dm_bin[j] + dm_bin[j+1]);
			WebInfoDm.N_dm[i][j] = dm_bin_int[j];
			WebInfoDm.N_dm_cum[i][j] = cum_dm_bin_int[j];
			WebInfoDm.delta_gas[i][j] = dm_bin_gas[j];
			WebInfoDm.T_vs_delta[i][j] = dm_bin_T[j];
		}

		free(delta_gas);
		free(delta_tot);
		free(delta_dm);
		free(alpha_dm);
		free(T_gas);

		free(dm_bin);
		free(dm_bin_e);
		free(dm_bin_T);
		free(dm_bin_int);
		free(dm_bin_gas);
		free(dm_bin_alpha);
	}
}
Exemple #5
0
int main(int argc , char*argv[])
{



    clrscr();
    couleur("30;47");
    printf("+-----------------------------------------------------------------------------+\n");
    printf("|");couleur("0");
    couleur("42");printf("                                                                             ");couleur("0");
    couleur("30;47");
    printf("|\n");
    printf("+");couleur("0");
    couleur("30;42");printf("                 Bienvenue sur le projet de complexite                       ");couleur("0");
    couleur("30;47");
    printf("+\n");
    printf("|");couleur("0");
    couleur("42");printf("                                                                             ");couleur("0");
    couleur("30;47");
    printf("|\n");
    printf("+-----------------------------------------------------------------------------+\n\n\n\n");couleur("0");

    if(argc<2)
    {
        couleur("31");printf("pas d'option spe \n");couleur("0");
    }
    else
    {
        couleur("32");printf("Ouverture fichier :''");couleur("0");
        couleur("31");printf("%s",argv[1]);couleur("0");
        couleur("32");printf("''");couleur("0");
        couleur("32;5");printf("Appuyez sur entrée\n");couleur("0");
        getchar();

        FILE *fp;
	int i;
        fp=NULL;

        if( (fp=fopen(argv[1],"r")) ) // on regarde si le fichier existe
        {
            //fp=fopen(argv[1],"r");

            parser(fp,&gl,&gm);                        //parser le fichier
            fclose(fp);
          
       printf("CALCUL MAXIMUM \n");
            i=maximum(&gl);
            printf("sortie MAX\n");





            for(i=0;i<gl.n;i++) // efface le graph
            {
                supprimer_liste(&gl.a[i]);
            }


        }
        else
        {
            couleur("31");printf("le fichier demandé: ''");couleur("0");
            couleur("31;47;5");printf("%s",argv[1]);couleur("0");
            couleur("31");printf("'' n'existe pas \n");couleur("0");
        }

    }
    return 0;
}