Commits
Akeem Wells authored 59f50e3f4b6 Merge
60 60 | */ |
61 61 | |
62 62 | |
63 63 | |
64 64 | |
65 65 | |
66 66 | |
67 67 | |
68 68 | |
69 69 | |
70 - | |
70 + | |
71 71 | |
72 72 | |
73 73 | |
74 74 | // for executable_path( ) |
75 75 | |
76 76 | |
77 77 | // for executable_path( ) |
78 78 | std::string read_link( const std::string &path ) { |
79 79 | int buffer_size = 128; |
80 80 | char *buffer = new char[buffer_size+1]; |
220 220 | } catch ( ... ) { |
221 221 | qWarning("unhandled exception... "); |
222 222 | qDebug() << "from" << receiver->objectName() << "from event type" << e->type(); |
223 223 | qFatal("exiting..."); |
224 224 | exit(1); |
225 225 | } |
226 226 | return true; |
227 227 | } |
228 228 | |
229 229 | |
230 - | class ViewerDataState: public casacore::AppState { |
230 + | class ViewerDataState: public casatools::State { |
231 231 | public: |
232 232 | |
233 233 | ViewerDataState(const std::list<std::string> &path ) : data_path(path) { } |
234 234 | virtual bool initialized( ) const { return true; } |
235 235 | virtual std::list<std::string> dataPath( ) const { return data_path; } |
236 236 | private: |
237 237 | std::list<std::string> data_path; |
238 238 | }; |
239 239 | |
240 240 | |
303 303 | if ( ends_with(exepath, "Contents/MacOS/CASAviewer") || |
304 304 | ends_with(exepath, "Contents/MacOS/casaviewer") ) { |
305 305 | // initialize CASAviewer app data... |
306 306 | if ( ! casacore::AppStateSource::fetch( ).initialized( ) ) { |
307 307 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
308 308 | // Mac OSX -- path is specific to package format |
309 309 | // - - - - - - - - - - - - - - - - - - - - - - - - - |
310 310 | // initialize CASAviewer app data... |
311 311 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
312 312 | // generate path to data... |
313 - | std::string datapath; |
314 - | if ( command_line_data_path ) |
315 - | datapath = command_line_data_path; |
316 - | else { |
317 - | datapath = exepath; |
318 - | datapath.erase( datapath.end( ) - 16, datapath.end( ) ); |
319 - | datapath += "Resources/casa-data"; |
320 - | } |
321 - | // initialize casacore... |
313 + | // |
322 314 | std::list<std::string> datadirs; |
315 + | if ( command_line_data_path ) |
316 + | datadirs.push_back(command_line_data_path); |
317 + | |
318 + | std::string datapath; |
319 + | datapath = exepath; |
320 + | datapath.erase( datapath.end( ) - 16, datapath.end( ) ); |
321 + | datapath += "Resources/data"; |
323 322 | datadirs.push_back(datapath); |
323 + | |
324 + | char *home = getenv("HOME"); |
325 + | datadirs.push_back( std::string(home) + "/.casa/data" ); |
326 + | |
327 + | // initialize casacore... |
324 328 | casacore::AppStateSource::initialize(new ViewerDataState(datadirs)); |
325 329 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
326 330 | // initialize CASAviewer app data... |
327 331 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
328 332 | // configure pgpplot... |
329 333 | std::string pgplotpath(exepath); |
330 334 | pgplotpath.erase( pgplotpath.end( ) - 16, pgplotpath.end( ) ); |
331 335 | std::string pluginpath = pgplotpath; // save for later... |
332 336 | std::string rgbpath = std::string("PGPLOT_RGB=") + pgplotpath + "Resources/pgplot/rgb.txt"; |
333 337 | std::string fontpath = std::string("PGPLOT_FONT=") + pgplotpath + "Resources/pgplot/grfont.dat"; |
348 352 | // linux -- path is specific to package format |
349 353 | // |
350 354 | // .../AppRun implies AppImage bash script startup, e.g. from an unpacked AppImage |
351 355 | // .../usr/bin/CASAviewer implies debugging or running from the |
352 356 | // build tree before it has been packaged |
353 357 | // |
354 358 | // - - - - - - - - - - - - - - - - - - - - - - - - - |
355 359 | // initialize CASAviewer app data... |
356 360 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
357 361 | // generate path to data... |
362 + | std::list<std::string> datadirs; |
358 363 | bool packed_app = ends_with(exepath, "/AppRun"); |
359 364 | std::string datapath; |
360 365 | if ( command_line_data_path ) |
361 - | datapath = command_line_data_path; |
362 - | else { |
363 - | datapath = exepath; |
364 - | // packed_app -> .../AppRun |
365 - | // not packed_app -> .../usr/bin/CASAviewer |
366 - | datapath.erase( datapath.end( ) - (packed_app ? 6 : 18), datapath.end( ) ); |
367 - | datapath += "data"; |
368 - | } |
369 - | // initialize casacore... |
370 - | std::list<std::string> datadirs; |
366 + | datadirs.push_back(command_line_data_path); |
367 + | |
368 + | datapath = exepath; |
369 + | // packed_app -> .../AppRun |
370 + | // not packed_app -> .../usr/bin/CASAviewer |
371 + | datapath.erase( datapath.end( ) - (packed_app ? 6 : 18), datapath.end( ) ); |
372 + | datapath += "data"; |
371 373 | datadirs.push_back(datapath); |
374 + | |
375 + | char *home = getenv("HOME"); |
376 + | datadirs.push_back( std::string(home) + "/.casa/data" ); |
377 + | |
378 + | // initialize casacore... |
372 379 | casacore::AppStateSource::initialize(new ViewerDataState(datadirs)); |
373 380 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
374 381 | // initialize CASAviewer app data... |
375 382 | // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- |
376 383 | // configure pgpplot... |
377 384 | std::string pgplotpath(exepath); |
378 385 | // packed_app -> .../AppRun |
379 386 | // not packed_app -> .../usr/bin/CASAviewer |
380 387 | pgplotpath.erase( pgplotpath.end( ) - (packed_app ? 6 : 18), pgplotpath.end( ) ); |
381 388 | std::string pluginpath = pgplotpath; // save for later... |