Exemple #1
0
void Oinv_cgrid::refresh() {

    int low=1;
    int high=65535;
    int true_size;


    if( current_property_ && cmap_ ) {
        // recompute the voxel data
        if( !voxel_data_ )
            voxel_data_ = new uint8_t[grid_->size() ];

        float min = cmap_->lower_bound();
        float max = cmap_->upper_bound();


        for( int i=0; i < grid_->size()  ; i++ ) {
            if( current_property_->is_informed( i ) ) {
                // scale all the property values between 1 and 255. 0 is reserved
                // for no-data value
                // ensure that all property values are between min and max by hard thresholding
                float pval= std::max( std::min( current_property_->get_value(i), max ), min );
                uint8_t val = (pval - min) / (max-min)*254+1;
                voxel_data_[i] = val;
            }
            else {
                voxel_data_[i] = 0;
            }
        }

        initialized_ = true;   // voxel_data_ is initialized

        // set the TransferFunctions

        const Color_scale* scale = cmap_->color_scale();
        for( int j=0; j < scale->colors_count(); j++ ) {
            float r,g,b;
            scale->color( j, r,g,b );
            volrend_colormap_->colorMap.set1Value(4*j, r);
            volrend_colormap_->colorMap.set1Value(4*j+1, g);
            volrend_colormap_->colorMap.set1Value(4*j+2, b);
            // the transparency field is omitted on purpose. It will be taken
            // care of by the call to set_transparency(...)

        }
        set_transparency();

    }

    volume_data_->touch();
    full_volume_->update();
    for( SliceList_iterator it = slices_.begin(); it != slices_.end(); ++it ) {
        (*it)->update();
    }

    volrend_colormap_->reMap(low, high);

}
static void
cal_model_calendar_set_value_at (ETableModel *etm,
                                 gint col,
                                 gint row,
                                 gconstpointer value)
{
	ECalModelComponent *comp_data;
	ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
	ECalComponent *comp;
	ECalModelCalendar *model = (ECalModelCalendar *) etm;

	g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model));
	g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST);
	g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm));

	if (col < E_CAL_MODEL_FIELD_LAST) {
		table_model_parent_interface->set_value_at (etm, col, row, value);
		return;
	}

	comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
	if (!comp_data)
		return;

	comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (comp_data->icalcomp));
	if (!comp) {
		return;
	}

	/* ask about mod type */
	if (e_cal_component_is_instance (comp)) {
		if (!e_cal_dialogs_recur_component (comp_data->client, comp, &mod, NULL, FALSE)) {
			g_object_unref (comp);
			return;
		}
	}

	switch (col) {
	case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
		set_dtend ((ECalModel *) model, comp_data, value);
		break;
	case E_CAL_MODEL_CALENDAR_FIELD_LOCATION :
		set_location (comp_data, value);
		break;
	case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY :
		set_transparency (comp_data, value);
		break;
	}

	e_cal_model_modify_component (E_CAL_MODEL (model), comp_data, mod);

	g_object_unref (comp);
}
static void
cal_model_calendar_fill_component_from_values (ECalModel *model,
					       ECalModelComponent *comp_data,
					       GHashTable *values)
{
	g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model));
	g_return_if_fail (comp_data != NULL);
	g_return_if_fail (values != NULL);

	set_dtend (model, comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_CALENDAR_FIELD_DTEND));
	set_location (comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_CALENDAR_FIELD_LOCATION));
	set_transparency (comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY));
}
Exemple #4
0
static GdkPixbuf *
render_icon (GtkStyle               *style,
	     const GtkIconSource    *source,
	     GtkTextDirection        direction,
	     GtkStateType            state,
	     GtkIconSize             size,
	     GtkWidget              *widget,
	     const gchar            *detail)
{
	int width = 1;
	int height = 1;
	GdkPixbuf *scaled;
	GdkPixbuf *stated;
	GdkPixbuf *base_pixbuf;
	GdkScreen *screen;
	GtkSettings *settings;

	/* Oddly, style can be NULL in this function, because
	 * GtkIconSet can be used without a style and if so
	 * it uses this function.
	 */

	base_pixbuf = gtk_icon_source_get_pixbuf (source);

	g_return_val_if_fail (base_pixbuf != NULL, NULL);

	if (widget && gtk_widget_has_screen (widget))
	{
		screen = gtk_widget_get_screen (widget);
		settings = gtk_settings_get_for_screen (screen);
	}
	else if (style->colormap)
	{
		screen = gdk_colormap_get_screen (style->colormap);
		settings = gtk_settings_get_for_screen (screen);
	}
	else
	{
		settings = gtk_settings_get_default ();
		GTK_NOTE (MULTIHEAD,
			  g_warning ("Using the default screen for gtk_default_render_icon()"));
	}

	if (size != (GtkIconSize) -1 && !gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
	{
		g_warning (G_STRLOC ": invalid icon size '%d'", size);
		return NULL;
	}

	/* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
	 * leave it alone.
	 */
	if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source))
		scaled = scale_or_ref (base_pixbuf, width, height);
	else
		scaled = g_object_ref (base_pixbuf);

	/* If the state was wildcarded, then generate a state. */
	if (gtk_icon_source_get_state_wildcarded (source))
	{
		if (state == GTK_STATE_INSENSITIVE)
		{
			stated = set_transparency (scaled, 0.3);
			gdk_pixbuf_saturate_and_pixelate (stated, stated, 0.1, FALSE);

			g_object_unref (scaled);
		}
		else if (state == GTK_STATE_PRELIGHT)
		{
			stated = gdk_pixbuf_copy (scaled);

			gdk_pixbuf_saturate_and_pixelate (scaled, stated, 1.2, FALSE);

			g_object_unref (scaled);
		}
		else
		{
			stated = scaled;
		}
	}
	else
		stated = scaled;

	return stated;
}
Exemple #5
0
gdImagePtr  graph_tpieza_get_gd( Tipopieza* tp, int color ){
    if( !tp->tipojuego->graphdefs ) return NULL;
    int i;
    Graphdef* g = NULL;
    Graphdef* g0 = NULL;


    for( i = 0; i < tp->tipojuego->graphdefs->entradas; i ++ ){
        Graphdef* g2 = tp->tipojuego->graphdefs->data[i];
        if( g2->tipo == TIPOGRAPH_TPIEZA && g2->tpieza == tp  ){
            if( g2->color == color ){
                g = g2;
                break;
            } else if( g2->color == 0 ){
                g0 = g2;
            }
        }
    }

    if( !g && !g0 ){
        LOGPRINT( 2, "No se puede encontrar grafico para %s", tp->nombre );
        return NULL;
    } else if ( !g ) g = g0;

    if( g->gd ) return g->gd;
    if( g->cus ){
        FILE* fpng = fopen( g->cus, "r" );
        if( !fpng ){
            LOGPRINT( 2, "No puede abrir %s", g->cus );
            return NULL;
        }
        g->gd = gdImageCreateFromPng( fpng );
        g->w  = gdImageSX( g->gd );
        g->h  = gdImageSY( g->gd );
        fclose( fpng );
        set_transparency( g->gd );
        return  g->gd;
    }

    char* piece;
    const char* colorname;
    char  size[24];
    char  filename[1024];
    switch( g->std ){
        case  STANDARD_GEM        :
            piece = "gema";
            break;
        case  STANDARD_BISHOP     :
            piece = "alfil";
            break;
        case  STANDARD_KING       :
            piece = "rey";
            break;
        case  STANDARD_KNIGHT     :
            piece = "caballo";
            break;
        case  STANDARD_PAWN       :
            piece = "peon";
            break;
        case  STANDARD_QUEEN      :
            piece = "dama";
            break;
        case  STANDARD_ROOK       :
            piece = "torre";
            break;
        case  STANDARD_CHECKERS_PAWN:
            piece = "peon-damas";
            break;
        case  STANDARD_CHECKERS_KING:
            piece = "dama-damas";
            break;
        case  STANDARD_RECT       :
            piece = NULL;
            break;
        default:
            LOGPRINT( 2, "No esta definido pieza estandar %d", g->std );
            return NULL;
    }

    gdImagePtr gd;
    if( piece ){
        sprintf( size, "%dx%d", g->w, g->h );
        colorname = tipojuego_get_colorname( tp->tipojuego, color );
        sprintf( filename, "%s/%s/%s-%s.png", qgames_image_dir, size, piece, colorname );
        FILE* f = fopen( filename, "r" );
        if( !f ){
            LOGPRINT( 2, "Error al abrir %s (%d - %s)", filename, errno, strerror(errno) );
            return NULL;
        }
        gd = gdImageCreateFromPng( f );
        fclose( f );
    } else {
        gd = gdImageCreateTrueColor( g->w, g->h );
        int col = gdImageColorAllocate( gd, g->f >> 16, ( g->f & 0xFF00 ) >> 8 , g->f & 0xFF );
        gdImageFilledRectangle( gd, 0, 0, g->w, g->h, col );
    }

    // Ahora lo que hago es volver a crear una imagen para ponerlo en la 
    // lista para luego poder tomarla como corresponde, ya que las estandares
    // no tienen color
    g0 = malloc( sizeof( Graphdef ) );
    memset( g0, 0, sizeof( Graphdef ) );
    g0->tipo   = TIPOGRAPH_TPIEZA;
    g0->color  = color;
    g0->tpieza = tp;
    g0->std    = g->std;
    g0->w      = g->w;
    g0->h      = g->h;
    set_transparency( gd );
    g0->gd     = gd;
    
    list_agrega( tp->tipojuego->graphdefs, g0 );
    return gd;
}