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

input-parameter check for setYRange() #33

Open
furutaka opened this issue Sep 19, 2024 · 14 comments
Open

input-parameter check for setYRange() #33

furutaka opened this issue Sep 19, 2024 · 14 comments

Comments

@furutaka
Copy link
Contributor

furutaka commented Sep 19, 2024

Hi!

I'd like to use the great power of InterSpec to analyze the results of particle-transport simulation such as PHITS. The output data were read after converted to SPC format. I choose the unit "number-of-gamma-detection-in-a-Ge-detector/number-of-primary-particle" for the output data, and the values tend to be very small (e.g., ~1/millons).

When I read such a spectrum with InterSpec and try to change the ordinate scale using setYRange() by, say, setRange(1e-9,1e-4), I got yelled at, as the difference between the named upper/lower boundaries are less than 0.01 (in src/TerminalModel.cpp).

Would it be possible to check the validity of the input parameters without using an absolute value of the difference such as "0.01"(for example, upperBound should be larger than 1.01*lowerBound)?

For the time being, the spectra are scaled by, say, 109.

Thanks in advance,
Kazuyoshi
InterSpec_setYRange_Error

wcjohns added a commit that referenced this issue Oct 12, 2024
Initial solution towards issue #33 - still todo is to detect spectra with all very small counts, and automatically adjust y-range (current app logic expects roughly 1 count per channel as smallest non-zero y-values - roughly)
@wcjohns
Copy link
Collaborator

wcjohns commented Oct 12, 2024

Hello Dr @furutaka,

Sorry, it took me a little while to get around to this!

I just pushed a partial fix to this in commit 95272d4.

Now calling setYRange(lower,upper) should work, but with these very small amplitude spectra, you will have to make this call to have the spectrum be viewable. I've added it to my TODO list to have the app automatically detect this and display things reasonably.

image

Are you able to build the code yourself, or would you like me to create a version of the app with this fix? Linux, right?

sincerely,
-will

@furutaka
Copy link
Contributor Author

Dear Dr. Johnson,

Thanks for the fix!
I'd like to ask you to build the binaries for Linux and Windows, because it's a Japanese national holiday tomorrow and I can't read detailed recipe (= your emails) and the log of my previous builds at work...

Yours,
Kazuyoshi

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 13, 2024

The automated "bleeding edge" Windows build at https://github.com/sandialabs/InterSpec/releases/tag/bleeding-edge should have picked up these changes, and I'll try to find some time to make a Linux build soon.
-will

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 14, 2024

I added a Linux release to https://github.com/sandialabs/InterSpec/releases/tag/v1.0.13_rc2 .
But only very briefly tested it - so there could be basic issues.

For what its worth, if you can use Docker, or similar, the instructions at:
https://github.com/sandialabs/InterSpec/tree/master/target/electron#building-using-a-manylinux-container
worked without issue or modification for me (a real surprise!) - and even without Docker, hopefully the instructions should work reasonably well on Linux.

Btw, I would expect things like peak fitting to totally fail for these small amplitude spectra.

Hopefully I'll get to improving the display more sometime soon.

happy Sports Day!
-will

@furutaka
Copy link
Contributor Author

Dear Dr. Johnson,

Thanks for the linux binary! I'll try it.

I suddenly made up my mind to try to build a linux binary also by myself at home, as a holiday project (it's a Japanese national holiday).
Do we need "Ceres something" to be installed now? (which is refered in NOTICE.html)

Yours,
Kazuyoshi

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 14, 2024

Ceres Solver and Eigen were added for the Relative Efficiency analysis tools, a few releases ago.

There are some instructions for building the pre-requisites, including these libraries, for Linux at: https://github.com/sandialabs/InterSpec/tree/master/target/patches#building-dependencies-on-linux
But, I have not checked them for a little while - so something could be out of date.

However, if you specify -DInterSpec_FETCH_DEPENDENCIES=ON to CMake, then it will download and compile all the prerequisites, and it all stays in your local build directory, so as to not affect your system, and hopefully save some trouble - much easier than manually building the dependencies.

Hope you make it outside to enjoy the holiday!!!

best luck, and please accept my apologies for the build process being a bit rough,
-will

@furutaka
Copy link
Contributor Author

furutaka commented Oct 14, 2024

I tried to build v1.0.13_rc2 on my linux box at home (Fedora 40 (x86_64)):

  1. $ git checkout -b v1.0.13_rc2 v1.0.13_rc2
  2. $ git submodule sync
  3. $ git submodule update --recursive
  4. $ mkdir ../v1.0.13_rc2-bld && cd ../v1.0.13_rc2-bld
  5. $ cmake ../InterSpec.git/ -DInterSpec_FETCH_DEPENDENCIES=on -DBUILD_AS_ELECTRON_APP=on

The last command stopped with:

-- Configuring done (332.1s)
CMake Error at CMakeLists.txt:744 (target_link_libraries):
Target "InterSpecLib" links to:

Eigen3::Eigen

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

-- Generating done (0.2s)
CMake Generate step failed. Build files cannot be regenerated correctly.

although an rpm package named eigen3-devel is installed.

It seems to me that Eigen3 is a template library and there's no need to link its compiled library, and I've modified the CMakeLists.txt for InterSpec:


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b37893c..8fecc5a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -741,7 +741,7 @@ endif(WIN32)
 
 
 if( USE_REL_ACT_TOOL )
-  target_link_libraries(InterSpecLib PUBLIC Eigen3::Eigen Ceres::ceres )
+  target_link_libraries(InterSpecLib PUBLIC Ceres::ceres )
 endif( USE_REL_ACT_TOOL )

Then, another cmake command

$ cmake ../InterSpec.git/ -DInterSpec_FETCH_DEPENDENCIES=on -DBUILD_AS_ELECTRON_APP=on -DOpenGL_GL_PREFERENCE=GLVND

finished with a warning which I've ignored because it seems to be in Wt,

CMake Warning (dev) at /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/CMakeLists.txt:96 (EXEC_PROGRAM):
  Policy CMP0153 is not set: The exec_program command should not be called.
  Run "cmake --help-policy CMP0153" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Use execute_process() instead.
This warning is for project developers.  Use -Wno-dev to suppress it.

Finally, the make stopped with the following error:

[ 48%] Building CXX object _deps/wt-build/src/CMakeFiles/wt.dir/Wt/WPdfImage.C.o
In file included from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/boost-src/libs/smart_ptr/include/boost/smart_ptr/detail/requires_cxx11.hpp:9,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/boost-src/libs/smart_ptr/include/boost/smart_ptr/shared_ptr.hpp:17,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/boost-src/libs/smart_ptr/include/boost/shared_ptr.hpp:17,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/Http/Request:15,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WObject:12,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WResource:10,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage:12,
                 from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C:13:
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/boost-src/libs/config/include/boost/config/pragma_message.hpp:24:34: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
   24 | # define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x)))
      |                                  ^~~~~~~
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/boost-src/libs/bind/include/boost/bind.hpp:36:1: note: in expansion of macro ‘BOOST_PRAGMA_MESSAGE’
   36 | BOOST_PRAGMA_MESSAGE(
      | ^~~~~~~~~~~~~~~~~~~~
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C: In member function ‘virtual void Wt::WPdfImage::setChanged(Wt::WFlags<Wt::WPaintDevice::ChangeFlag>)’:
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C:232:37: error: ‘HPDF_PROJECTING_SCUARE_END’ was not declared in this scope; did you mean ‘HPDF_PROJECTING_SQUARE_END’?
  232 |         HPDF_Page_SetLineCap(page_, HPDF_PROJECTING_SCUARE_END); // scuary !
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                     HPDF_PROJECTING_SQUARE_END
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C:259:34: error: cannot convert ‘const HPDF_UINT16*’ {aka ‘const short unsigned int*’} to ‘const HPDF_REAL*’ {aka ‘const float*’}
  259 |         HPDF_Page_SetDash(page_, dash_ptn, 2, 0);
      |                                  ^~~~~~~~
      |                                  |
      |                                  const HPDF_UINT16* {aka const short unsigned int*}
In file included from /home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage:17:
/usr/include/hpdf.h:1192:39: note:   initializing argument 2 of ‘HPDF_STATUS HPDF_Page_SetDash(HPDF_Page, const HPDF_REAL*, HPDF_UINT, HPDF_REAL)’
 1192 |                     const HPDF_REAL  *dash_ptn,
      |                     ~~~~~~~~~~~~~~~~~~^~~~~~~~
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C:264:34: error: cannot convert ‘const HPDF_UINT16*’ {aka ‘const short unsigned int*’} to ‘const HPDF_REAL*’ {aka ‘const float*’}
  264 |         HPDF_Page_SetDash(page_, dash_ptn, 2, 0);
      |                                  ^~~~~~~~
      |                                  |
      |                                  const HPDF_UINT16* {aka const short unsigned int*}
/usr/include/hpdf.h:1192:39: note:   initializing argument 2 of ‘HPDF_STATUS HPDF_Page_SetDash(HPDF_Page, const HPDF_REAL*, HPDF_UINT, HPDF_REAL)’
 1192 |                     const HPDF_REAL  *dash_ptn,
      |                     ~~~~~~~~~~~~~~~~~~^~~~~~~~
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C:269:34: error: cannot convert ‘const HPDF_UINT16*’ {aka ‘const short unsigned int*’} to ‘const HPDF_REAL*’ {aka ‘const float*’}
  269 |         HPDF_Page_SetDash(page_, dash_ptn, 4, 0);
      |                                  ^~~~~~~~
      |                                  |
      |                                  const HPDF_UINT16* {aka const short unsigned int*}
/usr/include/hpdf.h:1192:39: note:   initializing argument 2 of ‘HPDF_STATUS HPDF_Page_SetDash(HPDF_Page, const HPDF_REAL*, HPDF_UINT, HPDF_REAL)’
 1192 |                     const HPDF_REAL  *dash_ptn,
      |                     ~~~~~~~~~~~~~~~~~~^~~~~~~~
/home/furutaka/res/InterSpec/v1.0.13_rc2-bld/_deps/wt-src/src/Wt/WPdfImage.C:274:34: error: cannot convert ‘const HPDF_UINT16*’ {aka ‘const short unsigned int*’} to ‘const HPDF_REAL*’ {aka ‘const float*’}
  274 |         HPDF_Page_SetDash(page_, dash_ptn, 6, 0);
      |                                  ^~~~~~~~
      |                                  |
      |                                  const HPDF_UINT16* {aka const short unsigned int*}
/usr/include/hpdf.h:1192:39: note:   initializing argument 2 of ‘HPDF_STATUS HPDF_Page_SetDash(HPDF_Page, const HPDF_REAL*, HPDF_UINT, HPDF_REAL)’
 1192 |                     const HPDF_REAL  *dash_ptn,
      |                     ~~~~~~~~~~~~~~~~~~^~~~~~~~
make[2]: *** [_deps/wt-build/src/CMakeFiles/wt.dir/build.make:4800: _deps/wt-build/src/CMakeFiles/wt.dir/Wt/WPdfImage.C.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4665: _deps/wt-build/src/CMakeFiles/wt.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I'll try to build individual dependencies later...

Kazuyoshi

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 14, 2024

Compiling other peoples C++ is the worst :p

Hmmm, it looks like CMake is finding HARU PDF that is installed through your package manager, which is causing Wt to compile with PDF support - but then maybe the system HARU is older or newer than Wt expects/needs.

You could try setting the CMake variable ENABLE_HARU to OFF, and then maybe Wt wont try to compile with HARU support - which isn't needed for InterSpec. Or if you don't use lib HARU for anything else, you could uninstall it through your package manager.

It looks like I could probably either set all the un-needed Wt option/libraries/features to off, around line 88 of cmake/FetchInterSpecDeps.txt (e.g., add set( ENABLE_HARU OFF)), or modify the file that patches Wt to do this, to avoid issues like this.

I'm sorry you've hit this Dr @furutaka !
I was really hoping I had gotten things a bit easier for others to compile from scratch, but obviously it needs a little more work. I'll also bump up adding a "bleeding edge" Linux build to GitHub CI process, on my TODO list.

@furutaka
Copy link
Contributor Author

furutaka commented Oct 15, 2024

Continued trying to build the v1.0.13_rc2 at work.

After cmake'ing with the following command,

$ cmake ../InterSpec.git/ -DInterSpec_FETCH_DEPENDENCIES=on -DBUILD_AS_ELECTRON_APP=on -DOpenGL_GL_PREFERENCE=GLVND -DENABLE_HARU=off -DUSE_REL_ACT_TOOL=on

the make stopped at about 80% with the following message:

[ 81%] Building CXX object external_libs/SpecUtils/CMakeFiles/SpecUtils.dir/src/ParseUtils.cpp.o
/home/furutaka/res/InterSpec/InterSpec.git/external_libs/SpecUtils/src/ParseUtils.cpp: In function ‘float SpecUtils::dose_units_usvPerH(const char*, size_t)’:
/home/furutaka/res/InterSpec/InterSpec.git/external_libs/SpecUtils/src/ParseUtils.cpp:559:26: error: ‘uint8_t’ does not name a type
  559 |          || (static_cast<uint8_t>(str[0]) == 194)) )
      |                          ^~~~~~~
/home/furutaka/res/InterSpec/InterSpec.git/external_libs/SpecUtils/src/ParseUtils.cpp:31:1: note: ‘uint8_t’ is defined in header ‘<cstdint>’; this is probably fixable by adding ‘#include <cstdint>’
   30 | #include "SpecUtils/StringAlgo.h"
  +++ |+#include <cstdint>
   31 | 
make[2]: *** [external_libs/SpecUtils/CMakeFiles/SpecUtils.dir/build.make:496: external_libs/SpecUtils/CMakeFiles/SpecUtils.dir/src/ParseUtils.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:5084: external_libs/SpecUtils/CMakeFiles/SpecUtils.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

So I've also modified the ParseUtils.cpp:

index 3b37893c..8fecc5a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -741,7 +741,7 @@ endif(WIN32)
 
 
 if( USE_REL_ACT_TOOL )
-  target_link_libraries(InterSpecLib PUBLIC Eigen3::Eigen Ceres::ceres )
+  target_link_libraries(InterSpecLib PUBLIC Ceres::ceres )
 endif( USE_REL_ACT_TOOL )
 
 
Submodule external_libs/SpecUtils contains modified content
diff --git a/external_libs/SpecUtils/src/ParseUtils.cpp b/external_libs/SpecUtils/src/ParseUtils.cpp
index 163d1ab..6c0309f 100644
--- a/external_libs/SpecUtils/src/ParseUtils.cpp
+++ b/external_libs/SpecUtils/src/ParseUtils.cpp
@@ -28,6 +28,7 @@
 
 #include "SpecUtils/ParseUtils.h"
 #include "SpecUtils/StringAlgo.h"
+#include <cstdint>
 
 
 using namespace std;

After that, the make seemed to be finishing but stopped at the final linking step...

[100%] Building CXX object CMakeFiles/InterSpecExe.dir/main.cpp.o
[100%] Linking CXX executable InterSpec
/usr/bin/ld: InterSpec.a(InterSpec.cpp.o): in function `boost::detail::function::void_function_obj_invoker<std::_Bind<InterSpec::addViewMenu(Wt::WWidget*)::{lambda()#7} ()>, void, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>::invoke(boost::detail::function::function_buffer&, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass)':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpec.cpp:7176:(.text+0x95f6): undefined reference to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: InterSpec.a(InterSpec.cpp.o): in function `boost::detail::function::void_function_obj_invoker<std::_Bind<InterSpec::addViewMenu(Wt::WWidget*)::{lambda()#2} ()>, void, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>::invoke(boost::detail::function::function_buffer&, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass)':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpec.cpp:7095:(.text+0x96cb): undefined reference to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: InterSpec.a(InterSpec.cpp.o): in function `boost::detail::function::void_function_obj_invoker<std::_Bind<InterSpec::addViewMenu(Wt::WWidget*)::{lambda()#1} ()>, void, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>::invoke(boost::detail::function::function_buffer&, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass)':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpec.cpp:7081:(.text+0x977f): undefined reference to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: InterSpec.a(InterSpec.cpp.o): in function `boost::detail::function::void_function_obj_invoker<std::_Bind<InterSpec::addFileMenu(Wt::WWidget*, bool)::{lambda()#1} ()>, void, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>::invoke(boost::detail::function::function_buffer&, Wt::WMenuItem*, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass)':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpec.cpp:861:(.text+0x982f): undefined reference to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: InterSpec.a(InterSpec.cpp.o): in function `boost::detail::function::void_function_obj_invoker<std::_Bind<InterSpec::InterSpec(Wt::WContainerWidget*)::{lambda()#2} ()>, void, Wt::WMouseEvent>::invoke(boost::detail::function::function_buffer&, Wt::WMouseEvent)':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpec.cpp:857:(.text+0x98e6): undefined reference to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: InterSpec.a(InterSpec.cpp.o):/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpec.cpp:816: more undefined references to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' follow
/usr/bin/ld: InterSpec.a(SpecFileQueryWidget.cpp.o): in function `boost::detail::function::void_function_obj_invoker<std::_Bind<SpecFileQueryWidget::init()::{lambda()#1} ()>, void, Wt::WMouseEvent>::invoke(boost::detail::function::function_buffer&, Wt::WMouseEvent)':
/home/furutaka/res/InterSpec/InterSpec.git/src/SpecFileQueryWidget.cpp:1557:(.text+0x1c2f): undefined reference to `ElectronUtils::browse_for_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)>)'
/usr/bin/ld: InterSpec.a(InterSpecApp.cpp.o): in function `InterSpecApp::loadSuccesfullCallback()':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpecApp.cpp:1817:(.text+0x25c1): undefined reference to `ElectronUtils::notifyNodeJsOfNewSessionLoad()'
/usr/bin/ld: /home/furutaka/res/InterSpec/InterSpec.git/src/InterSpecApp.cpp:1818:(.text+0x25ea): undefined reference to `ElectronUtils::send_nodejs_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: InterSpec.a(InterSpecApp.cpp.o): in function `InterSpecApp::clearSession()':
/home/furutaka/res/InterSpec/InterSpec.git/src/InterSpecApp.cpp:1454:(.text+0x7595): undefined reference to `ElectronUtils::requestNewCleanSession()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/InterSpecExe.dir/build.make:127: InterSpec] Error 1
make[1]: *** [CMakeFiles/Makefile2:3477: CMakeFiles/InterSpecExe.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Is it due to some misconfiguration of CMake?

By the way, I also used the provided binaries (Win & Linux) and tried to change ordinate scale, but couldn't do it: sometimes it says "Setting to count range [A, B] not fully be fulfilled" and nothing is displayed, and sometimes "Now setting count range to [C, D] counts" but the scale is not changed... (animated gif attached).

I'm afraid the commands issued might be wrong...

What does it mean by "... not fully be fulfilled"?

Kazuyoshi
setYRange

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 15, 2024

Getting closer!
I just pushed your cstdint fix - thanks for noting that.

Are you pointing CMake to the top-level InterSpec code directory, or to InterSpec/target/electron?
It should be the later, and cmake-js used to drive CMake.

i.e., the build commands should be similar to:

cd InterSpec/target/electron

npm install -g cmake-js
npm install --save-dev node-addon-api --arch=x64
npm install electron --arch=x64
npm install electron-packager

cmake-js --architecture x64 --arch=x64 --CDInterSpec_FETCH_DEPENDENCIES=ON --CDOpenGL_GL_PREFERENCE=GLVND --CDENABLE_HARU=OFF --out=build_linux --target install

npm run package-linux

And if all was successful the built app should be in release-builds.

As for the setYRange command not working (all the time?) - I'll take a look at the logic now - I probably messed something up. I'll also take a look at not needing to use this command just to see the spectrum.
If you could email me an example spectrum, I will use that to test things out - but if not, no problem, I can try to make one up.

@furutaka
Copy link
Contributor Author

furutaka commented Oct 15, 2024

Dear Dr. Johnson,

Thanks for the procedure...
Should all of this be done in the directory where all the source files reside? (or the cmake-js commad only?)
In my case, the build is usually done in another directory at the same level as the cloned git repo to keep the repo clean.

Well, more than 2 years have passed and I'm not yet accustomed to using JavaScript and CMake...

As for the spectrum, I've emailed one!

Kazuyoshi

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 16, 2024

Thanks for the spectrum!
I adjusted the spectrum display code so it should be a bit more friendly to these low-amplitude spectra - and also setting the y-axis range manually should be a bit better, although maybe not totally finished.
The Windows "bleeding edge" build should pick this up shortly.

I think you do need to run all the commands from the previous post in the InterSpec/target/electron directory.
I checked for how to use a out-of-source-tree directory to do the building, and it seems between cmake-js and the various npm packages, they get a bit confused and things are a bit hard otherwise.

This did inspire me to start the 'feature/LinuxCiBuild' branch, which is a work-in-progress, to add an automated Linux build for code pushes. Its currently building the app, but there is still a little ways to go for updating the bleeding edge release with the results.

@wcjohns
Copy link
Collaborator

wcjohns commented Oct 18, 2024

Btw, you can replace SpectrumChartD3.js in a older version of InterSpec to get better display these small amplitude spectra. The fix to setYRange(...) needs the total update.

@furutaka
Copy link
Contributor Author

furutaka commented Oct 19, 2024

Hi,

Btw, you can replace SpectrumChartD3.js in a older version of InterSpec to get better display these small amplitude spectra. The fix to setYRange(...) needs the total update.

It seems that a related(?) file, SpectrumChartD3StandAlone.css, has already been removed in commit c9ea44e, and cause the installation failure at the final stage.

In addition, according to this article, recent standard c++ library does not have ios::streampos...

So I did the following modification.

--- a/src/ZipArchive.cpp
+++ b/src/ZipArchive.cpp
@@ -231,7 +231,7 @@ std::map<std::string, std::shared_ptr<const ZipFileHeader> >
 {
   //Assumes the header is at the end of the file
   instrm.seekg( 0, ios_base::end );
-  const ios::streampos end_position = instrm.tellg();
+  const ios::pos_type end_position = instrm.tellg();
   const size_t max_comment_size = 0xffff; // max size of header, 65535
   const size_t read_size_before_comment = 22;
   std::streamoff read_start = max_comment_size + read_size_before_comment;
diff --git a/target/electron/CMakeLists.txt b/target/electron/CMakeLists.txt
index f5d8d952..077c1cb7 100644
--- a/target/electron/CMakeLists.txt
+++ b/target/electron/CMakeLists.txt
@@ -67,7 +67,6 @@ install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../InterSpec_resources DESTINA
 install( FILES ${CMAKE_CURRENT_BINARY_DIR}/LibInterSpec/InterSpec_resources/d3.v3.min.js
         ${CMAKE_CURRENT_BINARY_DIR}/LibInterSpec/InterSpec_resources/SpectrumChartD3.css
         ${CMAKE_CURRENT_BINARY_DIR}/LibInterSpec/InterSpec_resources/SpectrumChartD3.js
-        ${CMAKE_CURRENT_BINARY_DIR}/LibInterSpec/InterSpec_resources/SpectrumChartD3StandAlone.css
          DESTINATION ${PROJECT_BINARY_DIR}/app/InterSpec_resources/ )
 install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../example_spectra DESTINATION ${PROJECT_BINARY_DIR}/app/ )
 install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/app/loading.html

With the above modification as well as manual preparation of boost_1_78_0 and the patched Wt-3.7.1, I finally succeeded in building an electron-app InterSpec (commit a8bd58b) on a linux box (Fedora 40):

  1. copy the contents of the repo to a directory,
  2. cd to a directory/target/electron,
  3. npm install --save-dev node-addon-api --arch=x64 && npm install electron --arch=x64 && npm install electron-packager
  4. cmake-js --architecture x64 --arch=x64 --CDOpenGL_GL_PREFERENCE=GLVND --CDENABLE_HARU=OFF --out=build_linux --target install --CDCMAKE_PREFIX_PATH=the/directory/where/boost1.78.0/and/Wt-3.7.1patched/are/installed --CDCMAKE_CXX_FLAGS=-fPIC --CDBUILD_SHARED_LIBS=on --CDTRY_TO_STATIC_LINK=off

Wt was compiled with -DENABLE_HARU=off.

The only remaining issue in building is the use of cmake-js through proxy/firewall at work...

Yours,
Kazuyoshi

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

No branches or pull requests

2 participants