// Draw the color legend
void legend(void) {
	int i, j;
	double px, py;
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	for (j = 0; j < winHeight - 1; j++)
	{
		glBegin(GL_TRIANGLE_STRIP);
		i = 0;
		px = i;
		py = j;
		glVertex2f(px, py);
		for (i = 0; i < 20 - 1; i++)
		{
			px = i;
			py = (j + 1);
			set_colormap(j * clamp_param / winHeight, clamp_param, scalar_col, inv_scalar, disc_scalar_col);
			glVertex2f(px, py);
			px = (i + 1);
			py = j;
			set_colormap(j * clamp_param / winHeight, clamp_param, scalar_col, inv_scalar, disc_scalar_col);
			glVertex2f(px, py);
		}
		glVertex2f(px, py);
		glEnd();
	}
}
Example #2
0
int
main(int argc, char **argv) {
	int c;
	const char *file;
	FILE *fd;

	set_progname(argv[0]);

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE_NAME, LOCALEDIR);
	textdomain(PACKAGE_NAME);

	while ((c = getopt(argc, argv, "hV")) != EOF) {
		switch (c) {
			case 'V':
				print_version_and_exit();
				break;
			case 'h':
				usage(EXIT_SUCCESS);
				break;
		}
	}

	if (optind == argc)
		usage(EXIT_FAILURE);

	file = argv[optind];

	if (!strcmp(file, "vga")) {
		set_colormap(vga_colors);
		return EXIT_SUCCESS;

	} else if (!strcmp(file, "-")) {
		parse_file(stdin, "stdin");

	} else {
		if ((fd = fopen(file, "r")) == NULL)
			error(EXIT_FAILURE, errno, "fopen");

		parse_file(fd, file);
		fclose(fd);
	}

	set_colormap(cmap);
	free(cmap);

	return EXIT_SUCCESS;
}
Example #3
0
File: lutmenu.c Project: E-LLP/QuIP
static COMMAND_FUNC( do_setlut )
{
	Data_Obj *dp;
	
	dp=PICK_LB("");
	if( dp==NO_OBJ ) return;

	set_colormap(dp);
}
Example #4
0
static void create_app_main_window(MainWindow *main_window, const gchar *title)
{
  main_window->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(main_window->window), title);
  gint w, h, x, y;
  if (get_preferences_manager_window_maximized(main_window->prefmg)) {
    gtk_window_maximize(GTK_WINDOW(main_window->window));
  } else {
    get_preferences_manager_window_size (main_window->prefmg, &w, &h);
    gtk_window_set_default_size(GTK_WINDOW(main_window->window), w, h);
    get_preferences_manager_window_position (main_window->prefmg, &y, &x);
    gtk_window_move(GTK_WINDOW(main_window->window), x, y);
  }
  g_set_application_name (title);
  gtk_window_set_default_icon_name ("gphpedit");
  /* set RGBA colormap */        
  set_colormap(main_window->window);
}
color_render_ESWC_dialog::color_render_ESWC_dialog(V3DPluginCallback2 * cb, V3dR_MainWindow* inwin, int nid)
{
    v3dwin=inwin;
    callback=cb;

    //load neuron tree
    nt=(NeuronTree*)&(callback->getHandleNeuronTrees_Any3DViewer(v3dwin)->at(nid));
    feaNum=nt->listNeuron.at(0).fea_val.size();
    if(feaNum<=0.1){
        v3d_msg("Cannot identify feature value for the selected neuron");
        return;
    }
    //back up type
    bk_type.clear();
    for(int i=0; i<nt->listNeuron.size(); i++){
        bk_type.push_back(nt->listNeuron.at(i).type);
    }

    //create
    this->setWindowTitle(nt->file);
    cb_feature = new QComboBox();
    for(int i=0; i<feaNum; i++)
        cb_feature->addItem(QString::number(i+1));

    cb_colormap= new QComboBox();
    cb_colormap->addItem(QString("heatmap"));
    cb_colormap->addItem(QString("rainbow"));

    spin_min = new QDoubleSpinBox();
    spin_max = new QDoubleSpinBox();
    spin_black = new QDoubleSpinBox();
    spin_white = new QDoubleSpinBox();
    spin_meg = new QDoubleSpinBox();
    check_black = new QCheckBox("black threshold (<=)");
    check_white = new QCheckBox("white threshold (<=)");
    check_meg = new QCheckBox("magenta threshold (>=)");
    btn_update = new QPushButton("update");
    btn_quit = new QPushButton("quit");
    btn_reset = new QPushButton("reset");

    connect(check_black, SIGNAL(clicked()),this,SLOT(set_black()));
    connect(check_white, SIGNAL(clicked()),this,SLOT(set_white()));
    connect(check_meg, SIGNAL(clicked()),this,SLOT(set_magenta()));
    connect(btn_update, SIGNAL(clicked()),this,SLOT(update()));
    connect(btn_quit, SIGNAL(clicked()),this,SLOT(reject()));
    connect(btn_reset, SIGNAL(clicked()),this,SLOT(reset()));
    connect(cb_feature, SIGNAL(currentIndexChanged(int)),this,SLOT(set_span()));
    connect(cb_colormap, SIGNAL(currentIndexChanged(int)),this,SLOT(set_colormap()));

    //layout
    QGridLayout * gridLayout = new QGridLayout();

    QLabel* label_feature = new QLabel("feature id:");
    gridLayout->addWidget(label_feature,1,0,1,2);
    gridLayout->addWidget(cb_feature,1,2,1,1);

    QLabel* label_colormap= new QLabel("colormap:");
    gridLayout->addWidget(label_colormap,2,0,1,2);
    gridLayout->addWidget(cb_colormap,2,2,1,1);

    QLabel* label_min = new QLabel("color bar low:");
    gridLayout->addWidget(label_min,3,0,1,2);
    gridLayout->addWidget(spin_min,3,2,1,1);

    QLabel* label_max = new QLabel("color bar high:");
    gridLayout->addWidget(label_max,4,0,1,2);
    gridLayout->addWidget(spin_max,4,2,1,1);

    QFrame *line_2 = new QFrame();
    line_2->setFrameShape(QFrame::HLine);
    line_2->setFrameShadow(QFrame::Sunken);
    gridLayout->addWidget(line_2,5,0,1,3);
    QLabel* label_color = new QLabel("special color");
    QLabel* label_val = new QLabel("value");
    gridLayout->addWidget(label_color,6,0,1,2);
    gridLayout->addWidget(label_val,6,2,1,1);
    gridLayout->addWidget(check_black,7,0,1,2);
    gridLayout->addWidget(spin_black,7,2,1,1);
    gridLayout->addWidget(check_white,8,0,1,2);
    gridLayout->addWidget(spin_white,8,2,1,1);
    gridLayout->addWidget(check_meg,9,0,1,2);
    gridLayout->addWidget(spin_meg,9,2,1,1);

    QFrame *line_3 = new QFrame();
    line_3->setFrameShape(QFrame::HLine);
    line_3->setFrameShadow(QFrame::Sunken);
    gridLayout->addWidget(line_3,13,0,1,3);
    gridLayout->addWidget(btn_update,14,2,1,1);
    gridLayout->addWidget(btn_reset,15,2,1,1);
    gridLayout->addWidget(btn_quit,16,2,1,1);

    setLayout(gridLayout);

    set_black();
    set_white();
    set_magenta();
    set_span();
    set_colormap();
}
void smoke(void) {
	int i, j, k, idx;
	double px, py;
	fftw_real  wn = (fftw_real)winWidth / (fftw_real)(DIM + 1);   // Grid cell width
	fftw_real  hn = (fftw_real)winHeight / (fftw_real)(DIM + 1);  // Grid cell heigh

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	fftw_real values[(DIM- 1) * (DIM - 1)];
	if (draw_rho){
		for (i = 0; i < (DIM- 1) * (DIM - 1); i++){
			values[i] = rho[i];
		}
	} else {
		for (i = 0; i < (DIM- 1) * (DIM - 1); i++){
			values[i] = vx[i]*vx[i] + vy[i]+vy[i];
			values[i] = (values[i] == 0) ? 0 : sqrt(values[i]);
		}		
	}
		
	// Find max(rho)
	fftw_real max = 0.0f;
	for (k = 0; k < (DIM - 1) * (DIM - 1); k++) {
		max = (values[k] > max) ? values[k] : max;
	}
	
	for (j = 0; j < DIM - 1; j += 1)			//draw smoke
	{
		glBegin(GL_QUAD_STRIP);
		i = 0;
		px = wn + (fftw_real)i * wn;
		py = hn + (fftw_real)j * hn;
		idx = (j * DIM) + i;
		if (!color_dir) {
			set_colormap(values[idx], max, scalar_col, inv_scalar, disc_scalar_col);
		} else {
			hue( ( atan2(vy[idx] , vx[idx]) + 3.14) / 6.28 );
		}
		glVertex2f(px, py);

		for (i = 0; i < DIM - 1; i++)
		{
			px = wn + (fftw_real)i * wn;
			py = hn + (fftw_real)(j + 1) * hn;
			idx = ((j + 1) * DIM) + i;
			if (!color_dir) {
				set_colormap(values[idx], max, scalar_col, inv_scalar, disc_scalar_col);
			} else {
				hue( ( atan2(vy[idx] , vx[idx]) + 3.14) / 6.28 );
			}
			glVertex2f(px, py);
			px = wn + (fftw_real)(i + 1) * wn;
			py = hn + (fftw_real)j * hn;
			idx = (j * DIM) + (i + 1);
			if (!color_dir) {
				set_colormap( values[idx] , max, scalar_col, inv_scalar, disc_scalar_col);
			} else {
				hue( ( atan2(vy[idx] , vx[idx]) + 3.14) / 6.28 );
			}
			glVertex2f(px, py);
		}


		px = wn + (fftw_real)(DIM - 1) * wn;
		py = hn + (fftw_real)(j + 1) * hn;
		idx = ((j + 1) * DIM) + (DIM - 1);
		if (!color_dir) {
			set_colormap(values[idx], max, scalar_col, inv_scalar, disc_scalar_col);
		} else {
			hue( ( atan2(vy[idx] , vx[idx]) + 3.14) / 6.28 );
		}
		glVertex2f(px, py);
		glEnd();
	}
}