allow changing number of colors in colorbar

This commit is contained in:
Christopher Lackner 2021-10-06 16:01:48 +02:00
parent 98d5c8a8aa
commit f04040f409
5 changed files with 18 additions and 17 deletions

View File

@ -494,8 +494,6 @@ namespace netgen
void VisualScene :: CreateTexture (int ncols, int linear, double alpha, int typ) void VisualScene :: CreateTexture (int ncols, int linear, double alpha, int typ)
{ {
if (linear) ncols = 32; if (linear) ncols = 32;
else ncols = 8;
if (ntexcols != ncols) if (ntexcols != ncols)
{ {
@ -576,7 +574,7 @@ namespace netgen
{ {
if (!vispar.drawcolorbar) return; if (!vispar.drawcolorbar) return;
CreateTexture (8, linear, 1, GL_DECAL); CreateTexture (GetVSSolution().numtexturecols, linear, 1, GL_DECAL);
if (logscale && maxval <= 0) maxval = 1; if (logscale && maxval <= 0) maxval = 1;
if (logscale && minval <= 0) minval = 1e-4 * maxval; if (logscale && minval <= 0) minval = 1e-4 * maxval;

View File

@ -61,6 +61,7 @@ namespace netgen
clipplane_isolinelist = 0; clipplane_isolinelist = 0;
surface_vector_list = 0; surface_vector_list = 0;
isosurface_list = 0; isosurface_list = 0;
numtexturecols = 8;
fieldlineslist = 0; fieldlineslist = 0;
pointcurvelist = 0; pointcurvelist = 0;
@ -387,7 +388,7 @@ namespace netgen
BuildScene(); BuildScene();
CreateTexture (numtexturecols, lineartexture, 0.5, GL_MODULATE); CreateTexture (GetVSSolution().numtexturecols, lineartexture, 0.5, GL_MODULATE);
glClearColor(backcolor, backcolor, backcolor, 1); glClearColor(backcolor, backcolor, backcolor, 1);
// glClearColor(backcolor, backcolor, backcolor, 0); // glClearColor(backcolor, backcolor, backcolor, 0);

View File

@ -1282,6 +1282,13 @@ proc visual_dialog { } {
-validatecommand "Ng_Vis_Set parameters; redraw;my_validatespinbox %W %P 10" \ -validatecommand "Ng_Vis_Set parameters; redraw;my_validatespinbox %W %P 10" \
-command "Ng_Vis_Set parameters; redraw;" \ -command "Ng_Vis_Set parameters; redraw;" \
-invalidcommand "my_invalidspinbox %W;Ng_Vis_Set parameters; redraw" -from -1e10 -to 1e10 -increment 0.001 -invalidcommand "my_invalidspinbox %W;Ng_Vis_Set parameters; redraw" -from -1e10 -to 1e10 -increment 0.001
ttk::label $w.as.lncols -text "N Colors"
ttk::spinbox $w.as.snumcols -textvariable visoptions.numtexturecols -width 5 -validate focus \
-command "Ng_Vis_Set parameters; redraw;" \
-from 2 -to 31 -increment 1
#tixControl $w.as.minval -label "Min-value: " -integer false \ #tixControl $w.as.minval -label "Min-value: " -integer false \
-variable visoptions.mminval \ -variable visoptions.mminval \
@ -1301,7 +1308,7 @@ proc visual_dialog { } {
# } # }
pack $w.as -fill x -pady 5 -ipady 3 pack $w.as -fill x -pady 5 -ipady 3
grid $w.as.autoscale $w.as.lmin $w.as.smin $w.as.lmax $w.as.smax -sticky nw -padx 4 grid $w.as.autoscale $w.as.lmin $w.as.smin $w.as.lmax $w.as.smax $w.as.lncols $w.as.snumcols -sticky nw -padx 4
grid columnconfigure $w.as 0 -pad 20 grid columnconfigure $w.as 0 -pad 20
grid columnconfigure $w.as 2 -pad 20 grid columnconfigure $w.as 2 -pad 20
grid anchor $w.as center grid anchor $w.as center
@ -1592,11 +1599,6 @@ proc visual_dialog { } {
ttk::checkbutton $w.fcb.cb.lineartexture -text "Use Linear Texture" \ ttk::checkbutton $w.fcb.cb.lineartexture -text "Use Linear Texture" \
-variable visoptions.lineartexture \ -variable visoptions.lineartexture \
-command { Ng_Vis_Set parameters; redraw } -command { Ng_Vis_Set parameters; redraw }
scale $w.numcols -orient horizontal -length 100 -from 0 -to 50 \
-resolution 1 \
-variable visoptions.numtexturecols \
-command { popupcheckredraw visual_dialog_pop1 }
ttk::checkbutton $w.fcb.cb.showclipsolution -text "Draw Clipping Plane Solution" \ ttk::checkbutton $w.fcb.cb.showclipsolution -text "Draw Clipping Plane Solution" \
-variable visoptions.showclipsolution \ -variable visoptions.showclipsolution \

View File

@ -279,7 +279,7 @@ DLL_HEADER const char * ngscript[] = {""
,"set visoptions.invcolor 0\n" ,"set visoptions.invcolor 0\n"
,"set visoptions.imaginary 0\n" ,"set visoptions.imaginary 0\n"
,"set visoptions.lineartexture 0\n" ,"set visoptions.lineartexture 0\n"
,"set visoptions.numtexturecols 16\n" ,"set visoptions.numtexturecols 8\n"
,"set visoptions.showclipsolution 1\n" ,"set visoptions.showclipsolution 1\n"
,"set visoptions.showsurfacesolution 0\n" ,"set visoptions.showsurfacesolution 0\n"
,"set visoptions.drawfieldlines 0\n" ,"set visoptions.drawfieldlines 0\n"
@ -5218,8 +5218,12 @@ DLL_HEADER const char * ngscript[] = {""
,"-validatecommand \"Ng_Vis_Set parameters; redraw;my_validatespinbox %W %P 10\" \\\n" ,"-validatecommand \"Ng_Vis_Set parameters; redraw;my_validatespinbox %W %P 10\" \\\n"
,"-command \"Ng_Vis_Set parameters; redraw;\" \\\n" ,"-command \"Ng_Vis_Set parameters; redraw;\" \\\n"
,"-invalidcommand \"my_invalidspinbox %W;Ng_Vis_Set parameters; redraw\" -from -1e10 -to 1e10 -increment 0.001\n" ,"-invalidcommand \"my_invalidspinbox %W;Ng_Vis_Set parameters; redraw\" -from -1e10 -to 1e10 -increment 0.001\n"
,"ttk::label $w.as.lncols -text \"N Colors\"\n"
,"ttk::spinbox $w.as.snumcols -textvariable visoptions.numtexturecols -width 5 -validate focus \\\n"
,"-command \"Ng_Vis_Set parameters; redraw;\" \\\n"
,"-from 2 -to 31 -increment 1\n"
,"pack $w.as -fill x -pady 5 -ipady 3\n" ,"pack $w.as -fill x -pady 5 -ipady 3\n"
,"grid $w.as.autoscale $w.as.lmin $w.as.smin $w.as.lmax $w.as.smax -sticky nw -padx 4\n" ,"grid $w.as.autoscale $w.as.lmin $w.as.smin $w.as.lmax $w.as.smax $w.as.lncols $w.as.snumcols -sticky nw -padx 4\n"
,"grid columnconfigure $w.as 0 -pad 20\n" ,"grid columnconfigure $w.as 0 -pad 20\n"
,"grid columnconfigure $w.as 2 -pad 20\n" ,"grid columnconfigure $w.as 2 -pad 20\n"
,"grid anchor $w.as center\n" ,"grid anchor $w.as center\n"
@ -5410,10 +5414,6 @@ DLL_HEADER const char * ngscript[] = {""
,"ttk::checkbutton $w.fcb.cb.lineartexture -text \"Use Linear Texture\" \\\n" ,"ttk::checkbutton $w.fcb.cb.lineartexture -text \"Use Linear Texture\" \\\n"
,"-variable visoptions.lineartexture \\\n" ,"-variable visoptions.lineartexture \\\n"
,"-command { Ng_Vis_Set parameters; redraw }\n" ,"-command { Ng_Vis_Set parameters; redraw }\n"
,"scale $w.numcols -orient horizontal -length 100 -from 0 -to 50 \\\n"
,"-resolution 1 \\\n"
,"-variable visoptions.numtexturecols \\\n"
,"-command { popupcheckredraw visual_dialog_pop1 }\n"
,"ttk::checkbutton $w.fcb.cb.showclipsolution -text \"Draw Clipping Plane Solution\" \\\n" ,"ttk::checkbutton $w.fcb.cb.showclipsolution -text \"Draw Clipping Plane Solution\" \\\n"
,"-variable visoptions.showclipsolution \\\n" ,"-variable visoptions.showclipsolution \\\n"
,"-command { Ng_Vis_Set parameters; redraw }\n" ,"-command { Ng_Vis_Set parameters; redraw }\n"

View File

@ -273,7 +273,7 @@ set visoptions.usetexture 1
set visoptions.invcolor 0 set visoptions.invcolor 0
set visoptions.imaginary 0 set visoptions.imaginary 0
set visoptions.lineartexture 0 set visoptions.lineartexture 0
set visoptions.numtexturecols 16 set visoptions.numtexturecols 8
set visoptions.showclipsolution 1 set visoptions.showclipsolution 1
set visoptions.showsurfacesolution 0 set visoptions.showsurfacesolution 0
set visoptions.drawfieldlines 0 set visoptions.drawfieldlines 0