Making more recommended xplanet changes and fixing bugs:
ClosedPublic

Authored by lancaster on Aug 20 2018, 5:43 AM.

Details

Summary

File Save QString instead of QUrl
Object Enum comparisons instead of translated strings
Removing FIFO options for Windows computers
Fixing Quote Error in URL for XPlanet Options
Replacing Temp file path code
Solving Translations puzzles

Making the FIFO file thread more reliable with a Future Watcher and timeouts. Also removing debug statements.

Diff Detail

Repository
R321 KStars
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
There are a very large number of changes, so older changes are hidden. Show Older Changes
pino added inline comments.Aug 20 2018, 6:04 AM
kstars/auxiliary/xplanetimageviewer.cpp
695

D14813: Adding XPlanet Viewer adds this option... as string?! if it's a number, then just use the proper type, i.e. Int.

Also, what is the use case to make this configurable? Why should users change/edit it?
Ideally, kstars should just use a proper timeout on its own, possibly doing some estimation based on the data provided to xplanet (i.e. wait more if requesting a bigger image).

714–718

This is synchronous, and ugly.

Instead, use the signal of QFutureWatcher to know when it finishes. To implement a timeout, use a separate QTimer, to start when starting the computation, and stop when the future finishes -- if the timer fires, then cancel the future.

742

fd is leaked. Most probably you want to set it for the QFile object? (see QFile::open() that takes a fd.

kstars/auxiliary/xplanetimageviewer.h
139–146

No need to have it as class member, just move it to the cpp file.

This revision now requires changes to proceed.Aug 20 2018, 6:04 AM
mutlaqja added inline comments.Aug 20 2018, 8:09 AM
kstars/xplanet/opsxplanet.ui
431

As noted previously, Requires Maps --> requires maps

Also at least on Linux, there is xplanet-images package, is there more to it than that?

lancaster marked an inline comment as done.Aug 20 2018, 7:55 PM
lancaster added inline comments.
kstars/auxiliary/xplanetimageviewer.cpp
695

Yes, you are correct, it should be int.

I think it is important to make it configurable because I have found that xplanet can take anywhere from a few milliseconds to several seconds to complete. The time is not just dependent on the image size, a lot of it is due to the complexity of a rendering. Jupiter is often very quickly rendered, except when it has a transit of one of its moons, then xplanet takes significantly longer to complete. And we don't know when such events will occur in KStars currently. The other issue would be computers, some computers could take longer to render complex images. I think the user should be allowed to set the timeout based on personal preference. They might want to give a complicated conjunction or transit time to render. Or they might want it to stop before it spends too long trying to calculate a complicated one because it slows down their animation.

714–718

True, that would probably be better

742

Yeah, I wasn't sure what to do with that. It was the way it was in server manager.cpp in KStars. I can re-examine it.

kstars/xplanet/opsxplanet.ui
431

Yes, the user can put any map they want to into this directory. The xplanet-images package you mention is really not adequate. It doesn't include most of the planets let alone the moons. I provided a link to the maps recommended by xplanet. For the MacOS version, I download the ones from from that page under flat planet and include the distributable planet images. The package is called alien. But they are not necessarily the best ones, just the ones I liked. You can install any you like.

lancaster marked 3 inline comments as done.Aug 20 2018, 8:06 PM
lancaster added inline comments.
kstars/auxiliary/xplanetimageviewer.cpp
742

Nope, I just went back and checked. fd here is not a leaked object, it is simply an int, the return value of a computation. It isn't the file or the filename. If it is 0, that means the command succeeded and -1 means it failed.

lancaster updated this revision to Diff 40089.Aug 20 2018, 9:30 PM
lancaster marked 8 inline comments as done.
  • More recommended xplanet changes: changing timeout from string to int in config Making the QFutureWatcher simpler by using the signal
lancaster added inline comments.Aug 20 2018, 9:31 PM
kstars/auxiliary/xplanetimageviewer.h
139–146

Except that I used the enum values in a couple of places, particularly for Earth.

lancaster marked an inline comment as done.Aug 20 2018, 9:31 PM
mutlaqja added inline comments.Aug 20 2018, 9:45 PM
kstars/auxiliary/xplanetimageviewer.cpp
679

uint32_t timeout

kstars/auxiliary/xplanetimageviewer.h
129–130

const QString &

152–159

We better start using m_VariableName convention with everything initialized in header. e.g.

int m_CurrentObjectIndex { 0 };
int m_CurrentOriginIndex { 0 };
...
...
uint32_t m_Radius { 0 }
double m_FOV { 0 }

I am moving slowly to this convention in other files.

231–232

int objectIndex

lancaster updated this revision to Diff 40105.Aug 20 2018, 11:15 PM
lancaster marked 4 inline comments as done.
  • Updating XPlanet with Jasem's Comments: Using uint for timeout' const for string using m_ for member objects changing obj to objectIndex
mutlaqja accepted this revision.Aug 21 2018, 12:35 AM
pino requested changes to this revision.Aug 21 2018, 4:56 AM
pino added inline comments.
kstars/auxiliary/xplanetimageviewer.cpp
89–92

Given what resizeEvent() does, this looks effectively dead code.

191–192

It is already initialized to 0, so there is no need to set it explicitly.

207–217

As I mentioned already in the previous review, I'm pretty sure kstars knows about these names already. Isn't it possible to get them from KStarsData, instead of duplicating them?

241–257

Instead of this sequence of 5 labels (two of which are static ","), it'd be much better to have a single label, updating its text at once. This way, the layout spacing wouldnot make them look like different strings, while in reality this is a single location string. Also, the "," labels are not disabled, making the whole set of widgets look awkward when m_latDisplay/etc are disabled.

250–252

As I mentioned already, hardcoding these attributes is a bad UI. Please remove these three lines in all the buttons, let the style decide (following user preferences, which include accessibility).

383

Needs i18n(), since it is a UI string.

405–406

No contractions please.

686

A single-shot timer here is a bad idea, you must track the timer to propertly stop it when the xplanet execution finishes. Otherwise you can have the following scenario:

  • start a rendering, a single-shot timer is fired
  • the rendering ends, but the timer still runs
  • start a new rendering, a new single-shot timer is fired
  • immediately the first timer fires, the second rendering is cancelled
695

Sure, and this is why I said that kstars can have a longer timeout on its own.
Why e.g. 1 minute as timeout would not be enough, for example? Or make it 5 minutes -- still better than letting the user decide, which means that they can break the rendering for no reason...

725–729

"failed"

742

Then please rename the fd variable to something else, since it is clearly not a file descriptor.

831–832

Needs i18n(), since it is a UI string.

868–869

You can use qBound here...

909–910

As I said in the previous review, this whole method can use toString() provided by KStarsDateTime.

965

Needs i18n(), since it is a UI string.

978

Needs i18n(), since it is a UI string.

1124–1131

This is not needed, QFileDialog can do that already, see setDefaultSuffix(); this means you cannot use the static method though.

1131–1132

QFileDialog does that by default (provided the file name is not changed).

kstars/auxiliary/xplanetimageviewer.h
76

This explicit {} initializer is not needed for Qt classes, since most of them (at least all the ones used here) have a default constructor already.

139–146

This is not what I said. The enum is not referenced anywhere in this .h file, so it can be declared locally in the .cpp file.

kstars/kstars.kcfg
1086

UInt here too

1091

Ditto

1096

Ditto

kstars/xplanet/opsxplanet.ui
431

As noted previously, Requires Maps --> requires maps

Still not changed (yet the comment was marked as "done"...).

Also at least on Linux, there is xplanet-images package, is there more to it than that?

This package split exists only on Debian, and derivatives.

This revision now requires changes to proceed.Aug 21 2018, 4:56 AM
mutlaqja added inline comments.Aug 21 2018, 3:13 PM
kstars/auxiliary/xplanetimageviewer.cpp
207–217

No it's not possible.

250–252

How do you make them look like icon buttons and not just some button with a pixmap on it?

lancaster marked 19 inline comments as done.Aug 21 2018, 6:24 PM
lancaster added inline comments.
kstars/auxiliary/xplanetimageviewer.cpp
89–92

The lines you highlighted are not dead code. I just tried commenting them out to make sure. They are centering the drawing of the planet image in the view. No, they aren't resizing it, as you stated that is already handled in resizeEvent, they are repositioning it.

191–192

Yes that is true now that I changed the header file to set it to zero.

695

The time that xplanet takes to complete a rendering is not predictable because it depends on the positioning of moons, shadows, maps, and many other variables other than size. It will take a different amount of time on different machines too. But we can't make the timeout a really long time because then the user would have to wait for it to finish. The user might want to wait for a complicated render to finish or maybe they don't and just want to get on to the next frame.

868–869

Nice feature, didn't know about it

909–910

I do not believe so. XPlanet requires its date and time to be in a numerical format with a very specific structure. Here is a comparison of what the Date/Time looks like with the toString method and with the above code. There may be a way to get KStarsDateTime to do this, but the toString method does not.

Using toString: "Tue Aug 21 18:16:05 2018 GMT"
Using current code: "20180821.181605"

1124–1131

I just tried to implement this. The code was much longer because I had to add a bunch of lines to give it the same functionality as the static method, but perhaps its better that way I don't know.

1131–1132

ok

kstars/auxiliary/xplanetimageviewer.h
76

Gotcha, I got carried away when making the change Jasem requested

lancaster marked 10 inline comments as done.Aug 21 2018, 6:36 PM
lancaster marked 3 inline comments as done.
lancaster added inline comments.
kstars/xplanet/opsxplanet.ui
431

Oh didn't see the first part of the comment.

lancaster marked 2 inline comments as done.Aug 21 2018, 6:38 PM
lancaster updated this revision to Diff 40168.Aug 21 2018, 6:45 PM
  • Making more xplanet fixes. UInt options, case corrections, i18n, labels, fd rename, contractions, timer, qbound, fileDialog, enum, and initialization
lancaster updated this revision to Diff 40184.Aug 22 2018, 5:51 AM
  • Making some minor XPlanet interface improvements.

Making the slider only update the view when finished scrolling,
rather than trying to update too often.
Making the value of the slider display the result in the spin box,
so the user has feedback on the position before letting go of the mouse.
Giving more ability in the time edit spinbox to set the timeshift above or below the
limits of the slider.

lancaster updated this revision to Diff 40187.Aug 22 2018, 6:57 AM
  • Improving responsiveness and efficiency by eliminating duplicate calls
lancaster updated this revision to Diff 40237.Aug 22 2018, 3:51 PM
  • I just found that sometimes the temp directory doesn't exist yet.

Making for the xplanet fifo if it doesn't.

lancaster updated this revision to Diff 40238.Aug 22 2018, 4:37 PM
  • XPlanet Speed improvements
lancaster updated this revision to Diff 40239.Aug 22 2018, 4:39 PM
  • Oops removing debug statement

Ok guys, I think this is about done unless there is anything else. Its now much snappier and responsive due to some slight tweaks I made today

mutlaqja added inline comments.Aug 22 2018, 5:50 PM
kstars/auxiliary/xplanetimageviewer.cpp
909–910

That does look like ISO 8601. You can format code to ISO 8601 (Qt supports that format) then remove all dashes (-) and colons (:) and replace T with .

lancaster updated this revision to Diff 40244.Aug 22 2018, 6:54 PM
  • Converting complex date structure into ISO 8601.
lancaster marked 3 inline comments as done.Aug 22 2018, 6:55 PM

Jasem's solution to this one worked

mutlaqja accepted this revision.Aug 23 2018, 10:58 AM
This revision was not accepted when it landed; it landed in state Needs Review.Aug 23 2018, 11:00 AM
This revision was automatically updated to reflect the committed changes.