Skip to content
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

Enforce mode setting from GMT_Create_Session in API-driven programs #4525

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

PaulWessel
Copy link
Member

Description of proposed changes

See #4518 for background, as reported by @sarzeaud.

The key problem was that when modules are not driven by gmt.c (i.e., command-line calls), the single GMT_Create_Session call must set the type of the session. Pass GMT_SESSION_NORMAL and you create a classic session, and pass GMT_SESSION_RUNMODE to select modern mode. Apart from the wrappers (MATLAB, Julia, Python), stand-alone C/C++ programs must follow that rule. Now, sessions started as classic cannot later call modern-mode only modules such as begin, figure, subplot, inset, and end.

I have added a new testapi_map.c program derived from the example in #4518. By default it creates a PostScript plot and the test for this passes, but if testapi_map is run manually on the command line with a valid graphics extension (e.g., testapi_map jpg) then it will now produce the cropped JPG missing from the original posting.

I suggest @joa-quim and @seisman test this branch in GMT.jl and PyGMT before approving.

@PaulWessel PaulWessel self-assigned this Dec 1, 2020
@sarzeaud
Copy link
Contributor

sarzeaud commented Dec 1, 2020

Hi Paul,
I have just tested your patch here with the GMT_SESSION_RUNMODE flag. It works BUT options that could follow after the file extension are not taken into account. I have tested with A+m0.2c to have a thin margin around the crop but it is not done.
Can you imagine a way to do that, or must I forget it?

@PaulWessel
Copy link
Member Author

Will have a look. GMT modern mode was invented way after the API was designed.

@joa-quim
Copy link
Member

joa-quim commented Dec 2, 2020

It looks a bit scary but didn't affect GMT.jl

@PaulWessel
Copy link
Member Author

It is a bit tricky with starting the modern mode at the GMT_Create_Session in this case, since that means the session is created before the args to gmt begin is processed. We need to rethink what role the mode has in the use of the API.

@sarzeaud
Copy link
Contributor

Do you plan to merge this branch into master before 6.2?

@PaulWessel
Copy link
Member Author

I am not sure as I am not happy with it overall. I think I want to revisit this but I am juggling several other branches with the team right now. Still want to fix this one before 6.2 though but only 24 hours per day, still.

@sarzeaud
Copy link
Contributor

Thank you. Tell me if I can help.

@maxrjones maxrjones added this to the 6.4.0 milestone Mar 23, 2022
@seisman seisman modified the milestones: 6.4.0, 6.5.0 Jun 25, 2022
@seisman seisman modified the milestones: 6.5.0, 6.6.0 Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants