-
Notifications
You must be signed in to change notification settings - Fork 401
Add the so wished option to plot spheres in psxyz. #8844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7c1d2e8
Add the so wished option to plot spheres in psxyz.
joa-quim ed7409f
Change -SQ to -SP for sphere plots. Add a sphere.sh test
joa-quim 757c470
Merge branch 'master' into PS-spheres
joa-quim d64744e
Add the baseline image sphere.ps to dvc
seisman ed1f289
Update src/psxyz.c
joa-quim 3cc5a9f
Fixes and updates to this test.
joa-quim e544ec1
Make the -SP+e & +a work better.
joa-quim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,7 +238,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) { | |
| GMT_Usage (API, -3, "-(xdash), +(plus), st(a)r, (b|B)ar, (c)ircle, (d)iamond, (e)llipse, " | ||
| "(f)ront, octa(g)on, (h)exagon (i)nvtriangle, (j)rotated rectangle, " | ||
| "(k)ustom, (l)etter, (m)athangle, pe(n)tagon, c(o)lumn, (p)oint, " | ||
| "(q)uoted line, (r)ectangle, (R)ounded rectangle, (s)quare, (t)riangle, " | ||
| "s(P)here, (q)uoted line, (r)ectangle, (R)ounded rectangle, (s)quare, (t)riangle, " | ||
| "c(u)be, (v)ector, (w)edge, (x)cross, (y)dash, (z)dash, or " | ||
| "=(geovector, i.e., great or small circle vectors)."); | ||
|
|
||
|
|
@@ -276,6 +276,13 @@ static int usage (struct GMTAPI_CTRL *API, int level) { | |
| GMT_Usage (API, 2, "\n%s 3-D Cube: Give <size> as the length of all sides; append q if <size> " | ||
| "is a quantity in x-units.", GMT_LINE_BULLET); | ||
|
|
||
| GMT_Usage (API, 2, "\n%s 3-D Sphere: Give <size> as sphere diameter [Default unit is cm]. " | ||
| "Sphere is rendered with radial gradient shading from white at light source to fill color. Modifiers:", GMT_LINE_BULLET); | ||
| GMT_Usage (API, 3, "+a Set light source azimuth [0, from the right]."); | ||
| GMT_Usage (API, 3, "+e Set light source elevation [90, perpendicular to viewing plane]."); | ||
|
Comment on lines
+281
to
+282
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| GMT_Usage (API, 3, "+f Use flat/constant fill color (no gradient shading)."); | ||
| GMT_Usage (API, 3, "+n Draw outline only (no fill). Outline color from -W."); | ||
|
|
||
| GMT_Usage (API, 2, "\n%s Ellipse: If not given, we read direction, major, and minor axis from columns 4-6. " | ||
| "If -SE rather than -Se is selected, %s will expect azimuth, and " | ||
| "axes [in km], and convert azimuths based on map projection. " | ||
|
|
@@ -1048,6 +1055,10 @@ EXTERN_MSC int GMT_psxyz (void *V_API, int mode, void *args) { | |
| fill_active = Ctrl->G.active; /* Make copies because we will change the values */ | ||
| outline_active = Ctrl->W.active; | ||
| if (not_line && !outline_active && S.symbol != PSL_WEDGE && !fill_active && !get_rgb && !QR_symbol) outline_active = true; /* If no fill nor outline for symbols then turn outline on */ | ||
| if (S.symbol == PSL_SPHERE && !fill_active && !S.SP_no_fill) { /* Sphere needs a default fill for 3D shading */ | ||
| current_fill.rgb[0] = current_fill.rgb[1] = current_fill.rgb[2] = 0.5; /* Black */ | ||
| fill_active = true; | ||
| } | ||
|
|
||
| if (Ctrl->D.active) { | ||
| /* Shift the plot a bit. This is a bit frustrating, since the only way to do this | ||
|
|
@@ -1892,6 +1903,31 @@ EXTERN_MSC int GMT_psxyz (void *V_API, int mode, void *args) { | |
| gmt_plane_perspective (GMT, GMT_Z, data[i].z); | ||
| PSL_plotsymbol (PSL, xpos[item], data[i].y, data[i].dim, data[i].symbol); | ||
| break; | ||
| case PSL_SPHERE: /* Case created by Claude.ai */ | ||
| gmt_plane_perspective(GMT, GMT_Z, data[i].z); | ||
| if (S.SP_light_set) { /* Calculate and output custom light position for sphere */ | ||
| /* Simple model: azimuth controls horizontal, elevation controls vertical */ | ||
| /* Relative to viewing direction */ | ||
| double dazim = GMT->current.proj.z_project.view_azimuth - S.SP_light_az; | ||
| if (dazim > 90) dazim = 90.0; /* Do let illum from the hidden hemisphere */ | ||
| if (dazim < -90) dazim = -90.0; | ||
| double SP_lx_proj = sind(dazim); | ||
| double SP_ly_proj = sind(S.SP_light_el - GMT->current.proj.z_project.view_elevation); | ||
| PSL_command(PSL, "/SP_lx %.12g def /SP_ly %.12g def\n", SP_lx_proj, SP_ly_proj); | ||
| } | ||
| if (S.SP_flat) /* Output flat/constant color flag for sphere */ | ||
| PSL_command(PSL, "/SP_flat true def\n"); | ||
| if (S.SP_no_fill) /* Output no-fill flag for sphere */ | ||
| PSL_command(PSL, "/SP_no_fill true def\n"); | ||
| PSL_plotsymbol(PSL, xpos[item], data[i].y, data[i].dim, data[i].symbol); | ||
| /* Draw outline circle in user space using pen color */ | ||
| if (data[i].outline) { | ||
| /* The 1/4 factor was obtained by trial-and-error. Couldn't find the true logic. (JL) */ | ||
| PSL_command(PSL, "V /DeviceRGB setcolorspace matrix setmatrix %s " | ||
| "xc_SP_user yc_SP_user T N 0 0 radius_SP_user 0 360 arc S U\n", | ||
| PSL_makepen(PSL, (1.0/4.0) * data[i].p.width, data[i].p.rgb, data[i].p.style, data[i].p.offset)); | ||
| } | ||
| break; | ||
| case PSL_ELLIPSE: | ||
| gmt_plane_perspective (GMT, GMT_Z, data[i].z); | ||
| if (data[i].flag & 2) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| outs: | ||
| - md5: e8300f3b8e45690deb50c78d03d3e548.dir | ||
| nfiles: 28 | ||
| - md5: d294c350ed35533a2b8baf4729953c9d.dir | ||
| nfiles: 29 | ||
| path: psxyz | ||
| hash: md5 | ||
| size: 1205108 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
| # Test -SP sphere symbol | ||
| ps=sphere.ps | ||
| echo 3 3 3 | gmt psxyz -R0/6/0/6/0/6 -JX10c -JZ4c -p135/45 -SP2c -Gblue -W0.2p,red -Ba -Baz -P -K > $ps | ||
| echo 5 2 4 | gmt psxyz -R -J -JZ -p -SP1.5c+f -Ggreen -W0.5p -O -K >> $ps | ||
| echo 2 5 2 | gmt psxyz -R -J -JZ -p -SP1c+n -Gred -W0.3p,black -O >> $ps |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, but should I replace here the
QwithP?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so.