예제 #1
0
  void
  double_slide_holder::
set_values
 (  value_type  val
 ,  value_type  min
 ,  value_type  max
 ,  value_type  ss   // -1 means use existing value
 ,  value_type  ps   // -1 means use existing value
 )
{
    d_assert( ! is_setting( ));

    // We generate our own signals instead of relying on the inner object.
    while_setting_value_wrapper_type wrapper( this, false);
    d_assert( is_setting( ));

    // Remember the old values.
    value_type const  old_val  =  get_value( );
    value_type const  old_min  =  get_min_value( );
    value_type const  old_max  =  get_max_value( );
    value_type const  old_ss   =  get_single_step( );
    value_type const  old_ps   =  get_page_step( );

    // Must do this before the conversions that follow.
    setup_conversions( min, max);

    // Send the values to the inner holder.
    p_inner_holder_->
      set_values
       (  convert_outer_to_inner( val)
        , convert_outer_to_inner( min)
        , convert_outer_to_inner( max)
        , convert_outer_to_inner_distance( ss)
        , convert_outer_to_inner_distance( ps)
       );

    // Find the new values. These may be slightly different due to rounding etc.
    value_type const  new_val  =  get_value( );
    value_type const  new_min  =  get_min_value( );
    value_type const  new_max  =  get_max_value( );
    value_type const  new_ss   =  get_single_step( );
    value_type const  new_ps   =  get_page_step( );

    // Emit the value signals.
    if ( (new_ss != old_ss) || (new_ps != old_ps) ) {
        emit has_changed__steps( new_ss, new_ps);
        wrapper.request_signal( );
    }
    if ( (new_min != old_min) || (new_max != old_max) ) {
        emit has_changed__range( new_min, new_max);
        wrapper.request_signal( );
    }
    if ( new_val != old_val ) {
        emit has_changed( new_val);
        wrapper.request_signal( );
    }

    // The wrapper dtor will signal has_changed( ) if appropriate.
    wrapper.done_with_no_throws( );
}
예제 #2
0
  void
  int_range_steps_holder::
set_value( value_type new_value)
{
    // set_value_base( this, value_, new_value);
    set_values( new_value, get_min_value( ), get_max_value( ));
}
예제 #3
0
  void
  int_range_steps_holder::
set_max_value( value_type new_max_value)
{
    // set_value_base( this, max_value_, new_max_value, & int_range_steps_holder::has_changed__max_value);
    set_values( get_value( ), get_min_value( ), new_max_value);
}
예제 #4
0
float test_min_max_enhancement_old(int y,int x,int kernel_radius,IplImage * image){
	vector<int> kernel_values;
	for(int i=y-kernel_radius;i<=y+kernel_radius;i++){
		for(int j=x-kernel_radius;j<=x+kernel_radius;j++){
			if(is_coordinate_inside_boundaries(i,j,image)){
				int value = get_pixel(image,i,j);
				kernel_values.push_back(value);
			}

		}
	}
	float median = get_median(kernel_values);
	int max_val = get_max_value(kernel_values);
	int min_val = get_min_value(kernel_values);
	
	int e = .001;
	//float new_value = (float)(max_val - min_val)/(max_val + min_val + e);
	//float new_value = (float)(max_val - min_val)/(median + e);
	//float new_value = (float)(max_val - min_val)/(max_val + e);//seems better
	float new_value = (float)(max_val - min_val)/(min_val + e);
	//float new_value = (float)(max_val - min_val)/((max_val + min_val)/2 + e);
	//int rvalue = (int)ceil(new_value);
	//return rvalue ;
	return new_value;
}
예제 #5
0
  void
  int_range_steps_holder::
set_page_step( value_type new_page_step)
{
    // set_value_base( this, page_step_, new_page_step, & int_range_steps_holder::has_changed__page_step);
    set_values( get_value( ), get_min_value( ), get_max_value( ), get_single_step( ), new_page_step);
}
예제 #6
0
  /* slot */
  void
  double_slide_holder::
set_value( value_type new_value)
{
    // set_value_base( this, value_, new_value);
    set_values( new_value, get_min_value( ), get_max_value( ));
}
예제 #7
0
파일: walb_util.c 프로젝트: herumi/walb
/**
 * Write multiple logical sectors at an offset.
 * Logical block size is 512 bytes.
 *
 * @fd file descriptor of the target storage device.
 * @offset_lb storage offset [logical block].
 * @sect_ary input sector data array.
 * @idx_lb start offset in sect_ary [logical block].
 * @n_lb number of sectors to write [logical block].
 *
 * RETURN:
 *   true in success, or false.
 */
bool sector_array_pwrite_lb(
	int fd, u64 offset_lb,
	const struct sector_data_array *sect_ary,
	unsigned int idx_lb, unsigned int n_lb)
{
	const unsigned int pbs = sect_ary->sector_size;
	unsigned int w_lb = 0;

	ASSERT(fd > 0);
	ASSERT_SECTOR_DATA_ARRAY(sect_ary);
	ASSERT(n_lb > 0);

	while (w_lb < n_lb) {
		unsigned int idx = addr_pb(pbs, idx_lb + w_lb);
		unsigned int off_lb = off_in_pb(pbs, idx_lb + w_lb);
		unsigned int tmp_lb =
			get_min_value(n_lb_in_pb(pbs) - off_lb, n_lb - w_lb);
		if (!sector_write_lb(
				fd, offset_lb + w_lb,
				sect_ary->array[idx],
				off_lb, tmp_lb)) {
			return false;
		}
		w_lb += tmp_lb;
	}
	ASSERT(w_lb == n_lb);
	return true;
}
예제 #8
0
파일: 50.C 프로젝트: JackDrogon/Study
//最短路径长度
int get_min_value (PNODE n) {
    if (n == NULL) return 0;
	if (n->left == NULL) {
	    return n->value;
 	} else {
 	    return get_min_value(n->left);
  	}
}
예제 #9
0
void difmap::output_info(string filename, long double max, long double min, int large_ds){
	ofstream infowrite;
	infowrite.open(filename.c_str(), ofstream::out);

    infowrite << "FILE 1 MAX: " << get_max_value(1) << endl;
    infowrite << "FILE 1 MIN: " << get_min_value(1) << endl;

    infowrite << "FILE 2 MAX: " << get_max_value(2) << endl;
    infowrite << "FILE 2 MIN: " << get_min_value(2) << endl;

	infowrite << "Max Difference: " << max << endl;
	infowrite << "Min Difference: " << min << endl;
	infowrite << "Range: " << (max-min) << endl;

	if(large_ds != -1)
		infowrite << "Dataset with largest values: " << large_ds << endl;

	infowrite << "\n" << "Light green points: Values that could not be interpolated" << endl;
	infowrite << "Dark green points: Divider" << endl;
}
예제 #10
0
  bool
  int_range_steps_holder::
is_valid( ) const
{
    return
        (get_min_value( ) <= get_value( )) &&
        (get_value( ) <= get_max_value( )) &&
        (get_single_step( ) >= 0) &&
        (get_page_step( ) >= 0) &&
        implies(
            (get_page_step( ) > 0),
            (get_page_step( ) >= get_single_step( )));
}
예제 #11
0
  void
  int_range_steps_holder::
move_values_to( QAbstractSlider * p_slider) const
{
    d_assert( p_slider);

    // The step values we store aren't necessarily the ones we give the sliders.
    int page_step_slider   = get_page_step(   );
    int single_step_slider = get_single_step( );
    if ( 0 == page_step_slider ) {
        page_step_slider =
            (0 != single_step_slider) ?
            (10 * single_step_slider) :
            calc_about_an_eighth( get_max_value( ) - get_min_value( ));
    }
    if ( 0 == single_step_slider ) {
        single_step_slider = calc_about_an_eighth( page_step_slider);
    }

    p_slider->setPageStep( page_step_slider);
    p_slider->setSingleStep( single_step_slider);
    p_slider->setRange( get_min_value( ), get_max_value( ));
    p_slider->setValue( get_value( ));
}
예제 #12
0
  void
  int_range_steps_holder::
move_values_to( QSpinBox * p_spinb) const
{
    d_assert( p_spinb);

    // The single-step value we store isn't always the one we give to the spinboxes.
    int single_step_spinb = get_single_step( );
    if ( 0 == single_step_spinb ) {
        single_step_spinb = 1;
    }

    p_spinb->setSingleStep( single_step_spinb);
    p_spinb->setRange( get_min_value( ), get_max_value( ));
    p_spinb->setValue( get_value( ));
}
예제 #13
0
SurfaceShellDensityMap::SurfaceShellDensityMap(const ParticlesTemp &ps,
                                               float voxel_size,
                                               IMP::FloatKey mass_key,
                                               int num_shells)
    : SampledDensityMap() {
  set_kernel();
  set_particles(ps, mass_key);
  // update the grid size to contain all of the particles
  determine_grid_size(header_.get_resolution(), voxel_size, 3.);
  // to make
  update_voxel_size(voxel_size);
  num_shells_ = num_shells;
  set_neighbor_mask();
  IMP_LOG_TERSE("going to resample\n");
  resample();
  // update dmin and dmax
  header_.dmin = get_min_value();
  header_.dmax = get_max_value();
}
예제 #14
0
파일: 50.C 프로젝트: JackDrogon/Study
int main() {
	char buf[50];
	int  option;
	PNODE tree = NULL;
    PNODE node = NULL;
    	while (1) {
		printf ("--------------------------\n");
		printf ("Options are:\n\n");
		printf (" 0  Exit\n");
		printf (" 1  Insert node\n");
		printf (" 2  Delete node\n");
		printf (" 3  Find node\n");
		printf (" 4  Pre order traversal\n");
		printf (" 5  In order traversal\n");
		printf (" 6  Post order traversal\n");
		printf (" 7  Max depth\n");
		printf (" 8  Min depth\n");
		printf (" 9  Max value\n");
		printf (" 10 Min value\n");
		printf (" 11 Node Count\n\n");
		printf ("--------------------------\n");
		printf ("Select an option: ");
		fgets (buf, sizeof(buf), stdin);
		sscanf (buf, "%i", &option);
		printf ("--------------------------\n");
		if (option < 0 || option > 11) {
		    fprintf (stderr, "Invalid option");
		    continue;
		}
			switch (option) {
		    case 0:
		        exit (0);
		    case 1:
		        printf ("Enter number to insert: ");
				fgets (buf, sizeof(buf), stdin);
				sscanf (buf, "%i", &option);
				printf ("\n\n");
				insert_node (&tree, option);
				break;
		    case 2:
            	printf ("Enter number to delete: ");
				fgets (buf, sizeof(buf), stdin);
				sscanf (buf, "%i", &option);
				printf ("\n\n");
				delete_node (&tree, option);
				break;
		    case 3:
            	printf ("Enter number to find: ");
				fgets (buf, sizeof(buf), stdin);
				sscanf (buf, "%i", &option);
				printf ("\n\n");
				node = find_node (tree, option);
				if (node != NULL) {
				    printf ("Found node\n\n");
				} else {
				    printf ("Couldn't find node\n\n");
				}
				break;
		    case 4:
				printf ("Pre order traversal: ");
				pre_order_traversal (tree);
				printf ("\n\n");
				break;
		    case 5:
		        printf ("In order traversal: ");
		    	in_order_traversal (tree);
		    	printf ("\n\n");
		    	break;
		    case 6:
		        printf ("Post order traversal: ");
		    	post_order_traversal (tree);
       			printf ("\n\n");
		    	break;
		    case 7:
		        printf ("Max depth is %i\n\n", get_max_depth (tree));
		        break;
		    case 8:
		        printf ("Min depth is %i\n\n", get_min_depth (tree));
		        break;
		    case 9:
		        printf ("Max value is %i\n\n", get_max_value (tree));
		        break;
		    case 10:
		        printf ("Min value is %i\n\n", get_min_value (tree));
		        break;
      		case 11:
		        printf ("Node Count is %i\n\n", get_num_nodes (tree));
		        break;
		}
 	}
	return 0;
}
예제 #15
0
  /* slot */
  void
  double_slide_holder::
set_steps( value_type single_step, value_type page_step)
{
    set_values( get_value( ), get_min_value( ), get_max_value( ), single_step, page_step);
}
예제 #16
0
string colmap::compare(){

	string ret("");

	indexed_points *ds1_ip = dynamic_cast<indexed_points*>(dataset1);
	indexed_points *ds2_ip = dynamic_cast<indexed_points*>(dataset2);

	if(ds1_ip == NULL || ds2_ip == NULL)
		return string("Improper Datasets");

	for(int j=1; j<=2; j++){
				
		long double max = get_max_value(j);
		long double min = get_min_value(j);

		long double range = max - min;

		int x_size = 0;
		int y_size = 0;
		int z_size = 0;

		if(j == 1){
			x_size = ds1_ip->get_dim().sizes[0];
			y_size = ds1_ip->get_dim().sizes[1];
			z_size = ds1_ip->get_dim().sizes[2];
		}	
		else{
			x_size = ds2_ip->get_dim().sizes[0];
			y_size = ds2_ip->get_dim().sizes[1];
			z_size = ds2_ip->get_dim().sizes[2];;
		}

		CImg<unsigned char> imgOut(x_size, y_size, z_size, 3, 0);

		for(int x=0; x<x_size; x++){
			for(int y=0; y<y_size; y++){
				for(int z=0; z<z_size; z++){

					layout loc;
					loc.arr_size = 3;
					loc.sizes = new int[3];
					loc.sizes[0] = x;
					loc.sizes[1] = y;
					loc.sizes[2] = z;

					long double pt_val;

					if(j == 1)
						pt_val = ds1_ip->get_indexed_point(loc).vals[var_ds1];
					else if(j == 2)
						pt_val = ds2_ip->get_indexed_point(loc).vals[var_ds2];

					rgb_color col = get_color_single_sided(pt_val, range, min);

					imgOut(x, y_size - y - 1, z, 0) = col.r;
					imgOut(x, y_size - y - 1, z, 1) = col.g;
					imgOut(x, y_size - y - 1, z, 2) = col.b;
				}
			}
		}

		//Construct file name
		string output_name(outprefix);
		output_name += "_colmap";

		if(j == 1){
			output_name += "_FIRST_";
			output_name += "var1_";
			output_name += itoa(var_ds1);	
		}
		else if(j == 2){
			output_name += "_SECOND_";
			output_name += "var2_";
			output_name += itoa(var_ds2);
		}

		output_name += ".bmp";

		ret += output_name + " ";

		imgOut.save_bmp(output_name.c_str());

	}

	return ret;

}
예제 #17
0
  /* slot */
  void
  double_slide_holder::
set_max_value( value_type new_max_value)
{
    set_values( get_value( ), get_min_value( ), new_max_value);
}
예제 #18
0
  /* slot */
  void
  double_slide_holder::
set_page_step( value_type new_page_step)
{
    set_values( get_value( ), get_min_value( ), get_max_value( ), get_single_step( ), new_page_step);
}
예제 #19
0
  void
  int_range_steps_holder::
set_steps( value_type single_step, value_type page_step)
{
    set_values( get_value( ), get_min_value( ), get_max_value( ), single_step, page_step);
}
예제 #20
0
  void
  int_range_steps_holder::
set_values
 (  value_type  val
  , value_type  min
  , value_type  max
  , value_type  ss   // = -1
  , value_type  ps   // = -1
 )
{
    d_assert( is_valid( ));

    // Use existing values if negative steps specified.
    if ( ss < 0 ) { ss = get_single_step( ); }
    if ( ps < 0 ) { ps = get_page_step(   ); }

    // Make sure the new values are valid. Min and single-step never change here.
    if ( max < min ) { max = min; }
    if ( val < min ) { val = min; }
    if ( val > max ) { val = max; }
    if ( (0 != ps) && (ps < ss) ) { ps = ss; }

    // Find out what's going to change.
    bool const  is_changed__val  = (value_       != val);
    bool const  is_changed__min  = (min_value_   != min);
    bool const  is_changed__max  = (max_value_   != max);
    bool const  is_changed__ss   = (single_step_ != ss );
    bool const  is_changed__ps   = (page_step_   != ps );

    // We're done if nothing is changing.
    if ( is_changed__val ||
         is_changed__min ||
         is_changed__max ||
         is_changed__ss  ||
         is_changed__ps  )
    {
        if ( is_setting( ) ) {
            d_assert( false);
        } else {
            while_setting_value_wrapper_type wrapper( this);

            // Set the values in this holder.
            if ( is_changed__val ) { value_       = val; }
            if ( is_changed__min ) { min_value_   = min; }
            if ( is_changed__max ) { max_value_   = max; }
            if ( is_changed__ss  ) { single_step_ = ss ; }
            if ( is_changed__ps  ) { page_step_   = ps ; }
            d_assert( is_valid( ));

            // Loop thru all the attached widgets (spinboxes and sliders).
            // We don't have to relay our has_changed.. signals to these ctrls because we
            // keep them in sync here.
            list_type::iterator        iter        = attached_widgets_.begin( );
            list_type::iterator const  iter_limit  = attached_widgets_.end( );
            while ( iter != iter_limit ) {
                QWidget * p_widget = *iter;
                d_assert( p_widget);

                QSpinBox * p_spinb = qobject_cast< QSpinBox * >( p_widget);
                if ( p_spinb ) {
                    move_values_to( p_spinb);
                } else {
                    QAbstractSlider * p_slider = qobject_cast< QAbstractSlider * >( p_widget);
                    d_assert( p_slider);
                    move_values_to( p_slider);
                }
                
                ++ iter;
            }

            // Emit the value signals. The has_changed( ) signal with no args will be emitted last.
            if ( is_changed__ss || is_changed__ps ) {
                emit has_changed__steps( get_single_step( ), get_page_step( ));
            }
            if ( is_changed__min || is_changed__max ) {
                emit has_changed__range( get_min_value( ), get_max_value( ));
            }
            if ( is_changed__val ) {
                emit has_changed( get_value( ));
            }

            // The dtor for this wrapper emits the has_changed( ) signal.
            wrapper.done_with_no_throws( );
        }
    }
    d_assert( is_valid( ));
}