31 #ifdef OW_BOOST_PROGRAM_OPTIONS_FIX
35 namespace program_options
42 #include <boost/program_options.hpp>
43 #include <boost/filesystem.hpp>
45 #include "core/common/WLogger.h"
46 #include "core/common/WIOTools.h"
47 #include "core/common/WLogStream.h"
48 #include "core/common/WThreadedRunner.h"
49 #include "core/common/WSegmentationFault.h"
52 #include "core/WVersion.h"
69 std::cout <<
"OpenWalnut -- Version: " << W_VERSION <<
" ( http://www.openwalnut.org )"
74 "Copyright 2009-2022 The OpenWalnut Community\n"
75 " 2015-2022 Hochschule Worms\n"
76 " 2009-2022 BSV at Universitaet Leipzig\n"
77 " 2012-2017 Nemtics & Sebastian Eichelbaum\n"
78 " 2009-2013 MPI CBS, Leipzig, Germany\n"
79 "For more information see http://www.openwalnut.org/copying\n"
80 "This program comes with ABSOLUTELY NO WARRANTY.\n"
81 "This is free software, and you are welcome to redistribute it\n"
82 "under the terms of the GNU Lesser General Public License.\n"
83 "You should have received a copy of the GNU Lesser General Public License\n"
84 "along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>." << std::endl;
85 std::cout << std::endl;
87 std::cout <<
"Written by the OpenWalnut Community, Hochschule Worms, Nemtics, BSV@Uni-Leipzig and CNCF@MPI-CBS." << std::endl;
93 int main(
int argc,
char** argv )
98 std::string logFile =
"openwalnut.log";
101 namespace po = boost::program_options;
102 po::options_description desc(
"Options" );
107 (
"help,h",
"Prints this help message" )
108 (
"version,v",
"Prints the version information" )
109 (
"log,l", po::value< std::string >(), ( std::string(
"The log-file to use. If not specified, \"" ) + logFile +
110 std::string(
"\" is used in the current directory." ) ).c_str() )
111 (
"project,p", po::value< std::string >(),
"Project file to be loaded on startup." )
112 (
"input,i", po::value< std::vector< std::string > >(),
"Input data files that should be loaded automatically" );
114 po::positional_options_description pOptDesc;
115 pOptDesc.add(
"input", -1 );
117 boost::program_options::variables_map optionsMap;
120 po::store( po::command_line_parser( argc, argv ).options( desc ).positional( pOptDesc ).run(), optionsMap );
122 catch(
const po::error &e )
124 std::cerr << e.what() << std::endl;
128 po::notify( optionsMap );
131 if( optionsMap.count(
"help" ) )
135 std::cout <<
"OpenWalnut is a highly expansible visualization system with focus on brain- and neurological data." << std::endl
137 <<
"Usage: openwalnut [OPTION]... [FILE]..." << std::endl
141 <<
"Examples:" << std::endl
142 <<
" openwalnut\t\t\t\tStart OpenWalnut." << std::endl
143 <<
" openwalnut -p myproject.owp\t\tStart OpenWalnut and load the project." << std::endl
144 <<
" openwalnut t1.nii.gz fibers.fib\tStart OpenWalnut and load the two datasets." << std::endl
148 else if( optionsMap.count(
"version" ) )
163 if( optionsMap.count(
"log" ) )
165 logFile = optionsMap[
"log"].as< std::string >();
169 boost::filesystem::path logPath( logFile );
170 logPath = boost::filesystem::system_complete( logPath );
171 bool fallbackLog =
false;
172 boost::filesystem::path fallbackLogFile = tempFilename(
"OpenWalnutLog-%%%%%%%%.log" );
175 std::ofstream crashLogFile( logPath.string().c_str() );
176 if( !crashLogFile.is_open() )
179 crashLogFile.open( fallbackLogFile.string().c_str() );
184 if( crashLogFile.is_open() )
193 wlog::info(
"Walnut" ) <<
"Using the file \"" << logPath.string() <<
"\" for logging.";
197 wlog::info(
"Walnut" ) <<
"Using the fallback file \"" << fallbackLogFile.string() <<
"\" for logging.";
202 wlog::warn(
"Walnut" ) <<
"Could not open \"" << logPath.string() <<
"\" for writing. You will have no log-file.";
206 wlog::info(
"Walnut" ) <<
"Version: " << W_VERSION;
210 QCoreApplication::addLibraryPath(
"../libExt/qtPlugins" );
211 QCoreApplication::addLibraryPath(
"libExt/qtPlugins" );
216 std::shared_ptr< WQtGui > gui(
new WQtGui( optionsMap, argc, argv ) );
219 int result = gui->run();
221 std::cout <<
"Closed OpenWalnut smoothly. Goodbye!" << std::endl;
Class implementing a capsule for an output stream and the needed level and format information.
std::shared_ptr< WLogStream > SharedPtr
shared pointer type
static void startup(std::ostream &output=std::cout, LogLevel level=LL_DEBUG)
Create the first and only instance of the logger as it is a singleton.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
void addStream(WLogStream::SharedPtr s)
Adds a new stream to the logger.
The QT Based GUI implementation.
static void installSignalHandler()
Installs this exception as signal handler for SIGSEGV.
static void setThisThreadName(std::string name)
Static function to set the name of the calling thread.
WStreamedLogger warn(const std::string &source)
Logging a warning message.
WStreamedLogger info(const std::string &source)
Logging an information message.