Skip to content

Commit

Permalink
Make command 'moded3d' (aka 'md3d') a custom command rather than a na…
Browse files Browse the repository at this point in the history
…tive one.
  • Loading branch information
dtschump committed Jan 27, 2023
1 parent 461c67f commit 2bab5c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
23 changes: 2 additions & 21 deletions src/gmic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ const char *gmic::builtin_commands_names[] = {
"k","keep",
"l","l3d","label","le","light3d","line","local","log","log10","log2","lt",
"m","m*","m/","m3d","mandelbrot","map","matchpatch","max","maxabs","md3d","mdiv","median","min","minabs","mirror",
"mmul","mod","mode3d","moded3d","move","mproj","mul","mul3d","mutex","mv",
"mmul","mod","mode3d","move","mproj","mul","mul3d","mutex","mv",
"n","name","named","neq","network","nmd","noarg","noise","normalize",
"o","o3d","object3d","onfail","opacity3d","or","output",
"p","parallel","pass","permute","plasma","plot","point","polygon","pow","print","progress",
Expand Down Expand Up @@ -5928,10 +5928,7 @@ gmic& gmic::_run(const CImgList<char>& commands_line, unsigned int& position,
// Four-chars shortcuts (ending with '3d').
if (command0=='d' && command1=='b') {
if (!is_get && !is_selection) CImg<char>::string("double3d").move_to(_item);
} else if (command0=='m' && command1=='d') {
if (!is_get && !is_selection) CImg<char>::string("moded3d").move_to(_item);
}
else if (command0=='r' && command1=='v') std::strcpy(command,"reverse3d");
} else if (command0=='r' && command1=='v') std::strcpy(command,"reverse3d");
else if (command0=='s' && command1=='l') {
if (!is_get && !is_selection) CImg<char>::string("specl3d").move_to(_item);
}
Expand Down Expand Up @@ -9539,22 +9536,6 @@ gmic& gmic::_run(const CImgList<char>& commands_line, unsigned int& position,
continue;
}

if (!is_get && !std::strcmp("moded3d",item)) {
gmic_substitute_args(false);
float mode = -1;
if (cimg_sscanf(argument,"%f%c",
&mode,&end)==1 &&
(mode=cimg::round(mode))>=-1 && mode<=5) ++position;
else mode = -1;
renderd3d = (int)mode;
print(images,0,"Set dynamic 3D rendering mode to %s.",
renderd3d==-1?"bounding-box":
renderd3d==0?"pointwise":renderd3d==1?"linear":renderd3d==2?"flat":
renderd3d==3?"flat-shaded":renderd3d==4?"Gouraud-shaded":
renderd3d==5?"Phong-shaded":"none");
continue;
}

// Get patch-matching correspondence map.
if (!std::strcmp("matchpatch",command)) {
gmic_substitute_args(true);
Expand Down
12 changes: 10 additions & 2 deletions src/gmic_stdlib.gmic
Original file line number Diff line number Diff line change
Expand Up @@ -21863,14 +21863,22 @@ lathe3d : check "${1=128}>0 && ${2=0.5%}>=0 && ${3=361}>=0"
#@cli : $ (0,1,2,3,4,5) double3d 0 repeat w { torus3d 100,30 rotate3d[-1] 1,1,0,60 mode3d {0,@$>} \
# snapshot3d[-1] 300 } remove[0]

#@cli md3d : eq. to 'moded3d'. : (+)
#@cli md3d : eq. to 'moded3d'.
md3d :
_gmic_s="$?" v + _moded3d $"*"

#@cli moded3d : _mode : (+)
#@cli moded3d : _mode
#@cli : Set dynamic 3D rendering mode for interactive 3D viewer.
#@cli : (eq. to 'md3d').\n
#@cli : 'mode' can be { -1=bounding-box | 0=dots | 1=wireframe | 2=flat | 3=flat-shaded | 4=gouraud-shaded | \
# 5=phong-shaded }.
#@cli : Default value: 'mode=-1'.
moded3d :
_gmic_s="$?" v + _moded3d $"*"

_moded3d : check "isint(${1=-1}) && inrange($1,-1,5)"
e[0--3] "Set dynamic 3D rendering mode to "${s$1}"."
_moded3d=$1

#@cli *3d : eq. to 'mul3d'. : (+)

Expand Down

0 comments on commit 2bab5c7

Please sign in to comment.