mirror of https://github.com/vitalif/openscad
Merge branch 'master' of ../openscad into steelman-bom-tree-std-stack
commit
80e5d42f47
|
@ -190,9 +190,9 @@ Camera get_camera( po::variables_map vm )
|
|||
return camera;
|
||||
}
|
||||
|
||||
int cmdline(const char *deps_output_file, const std::string &filename, Camera &camera, const char *output_file, const fs::path &original_path, Render::type renderer, char ** argv )
|
||||
int cmdline(const std::string &application_path, const char *deps_output_file, const std::string &filename, Camera &camera, const char *output_file, const fs::path &original_path, Render::type renderer, char ** argv )
|
||||
{
|
||||
parser_init(boosty::stringy(boost::filesystem::path( argv[0] ).parent_path()));
|
||||
parser_init(application_path, false);
|
||||
Tree tree;
|
||||
#ifdef ENABLE_CGAL
|
||||
CGALEvaluator cgalevaluator(tree);
|
||||
|
@ -454,7 +454,7 @@ bool QtUseGUI()
|
|||
return useGUI;
|
||||
}
|
||||
|
||||
int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, char ** argv)
|
||||
int gui(const std::string &application_path, vector<string> &inputFiles, const fs::path &original_path, int argc, char ** argv)
|
||||
{
|
||||
QApplication app(argc, argv, true); //useGUI);
|
||||
#ifdef Q_WS_MAC
|
||||
|
@ -465,7 +465,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
|
|||
QCoreApplication::setOrganizationDomain("openscad.org");
|
||||
QCoreApplication::setApplicationName("OpenSCAD");
|
||||
QCoreApplication::setApplicationVersion(TOSTRING(OPENSCAD_VERSION));
|
||||
|
||||
|
||||
QDir exdir(QApplication::instance()->applicationDirPath());
|
||||
QString qexamplesdir;
|
||||
#ifdef Q_WS_MAC
|
||||
|
@ -486,8 +486,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
|
|||
qexamplesdir = exdir.path();
|
||||
}
|
||||
MainWindow::setExamplesDir(qexamplesdir);
|
||||
|
||||
parser_init(QApplication::instance()->applicationDirPath().toLocal8Bit().constData());
|
||||
parser_init(application_path, true);
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
installAppleEventHandlers();
|
||||
|
@ -520,7 +519,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
|
|||
}
|
||||
#else // OPENSCAD_QTGUI
|
||||
bool QtUseGUI() { return false; }
|
||||
int gui(const vector<string> &inputFiles, const fs::path &original_path, int argc, char ** argv)
|
||||
int gui(const std::string &application_path, const vector<string> &inputFiles, const fs::path &original_path, int argc, char ** argv)
|
||||
{
|
||||
fprintf(stderr,"Error: compiled without QT, but trying to run GUI\n");
|
||||
return 1;
|
||||
|
@ -641,12 +640,23 @@ int main(int argc, char **argv)
|
|||
NodeCache nodecache;
|
||||
NodeDumper dumper(nodecache);
|
||||
|
||||
if (output_file) {
|
||||
bool cmdlinemode = false;
|
||||
if (output_file) { // cmd-line mode
|
||||
cmdlinemode = true;
|
||||
if (!inputFiles.size()) help(argv[0]);
|
||||
rc = cmdline(deps_output_file, inputFiles[0], camera, output_file, original_path, renderer, argv);
|
||||
}
|
||||
const std::string application_path =
|
||||
#ifdef OPENSCAD_QTGUI
|
||||
QApplication::instance()->applicationDirPath().toLocal8Bit().constData();
|
||||
#else
|
||||
boosty::stringy(boosty::absolute(boost::filesystem::path(argv[0]).parent_path()));
|
||||
#endif
|
||||
|
||||
if (cmdlinemode) {
|
||||
rc = cmdline(application_path, deps_output_file, inputFiles[0], camera, output_file, original_path, renderer, argv);
|
||||
}
|
||||
else if (QtUseGUI()) {
|
||||
rc = gui(inputFiles, original_path, argc, argv);
|
||||
rc = gui(application_path, inputFiles, original_path, argc, argv);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Requested GUI mode but can't open display!\n");
|
||||
|
|
|
@ -88,7 +88,7 @@ fs::path find_valid_path(const fs::path &sourcepath,
|
|||
return fs::path();
|
||||
}
|
||||
|
||||
void parser_init(const std::string &applicationpath)
|
||||
void parser_init(const std::string &applicationpath, bool isgui)
|
||||
{
|
||||
// Add paths from OPENSCADPATH before adding built-in paths
|
||||
const char *openscadpaths = getenv("OPENSCADPATH");
|
||||
|
@ -116,8 +116,11 @@ void parser_init(const std::string &applicationpath)
|
|||
fs::path libdir(applicationpath);
|
||||
fs::path tmpdir;
|
||||
#ifdef __APPLE__
|
||||
libdir /= "../Resources"; // Libraries can be bundled
|
||||
if (!is_directory(libdir / "libraries")) libdir /= "../../..";
|
||||
// Libraries can be bundled on Mac. If not, fall back to development layout
|
||||
if (isgui) {
|
||||
libdir /= "../Resources";
|
||||
if (!is_directory(libdir / "libraries")) libdir /= "../../..";
|
||||
}
|
||||
#elif !defined(WIN32)
|
||||
if (is_directory(tmpdir = libdir / "../share/openscad/libraries")) {
|
||||
librarydir = boosty::stringy(tmpdir);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
extern int parser_error_pos;
|
||||
|
||||
void parser_init(const std::string &applicationpath);
|
||||
void parser_init(const std::string &applicationpath, bool isgui);
|
||||
void add_librarydir(const std::string &libdir);
|
||||
fs::path search_libs(const fs::path &localpath);
|
||||
fs::path find_valid_path(const fs::path &sourcepath,
|
||||
|
|
|
@ -437,6 +437,9 @@ include_directories(../src)
|
|||
add_definitions(-DOPENSCAD_VERSION=test -DOPENSCAD_YEAR=2011 -DOPENSCAD_MONTH=10)
|
||||
add_definitions(-DOPENSCAD_TESTING)
|
||||
|
||||
# Search for MCAD in correct place
|
||||
set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};OPENSCADPATH=${CMAKE_CURRENT_SOURCE_DIR}/../libraries")
|
||||
|
||||
# Platform specific settings
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
@ -937,31 +940,31 @@ add_cmdline_test(openscad-imgstretch2 EXE ${OPENSCAD_BINPATH}
|
|||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-camdist EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=0,0,0,90,0,90,300 examples/example001.scad -o
|
||||
ARGS --imgsize=500,500 --camera=0,0,0,90,0,90,300 -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-camrot EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=0,0,0,440,337.5,315,300 examples/example001.scad -o
|
||||
ARGS --imgsize=500,500 --camera=0,0,0,440,337.5,315,300 -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-camtrans EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=100,-20,-10,90,0,90,300 examples/example001.scad -o
|
||||
ARGS --imgsize=500,500 --camera=100,-20,-10,90,0,90,300 -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-camortho EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=100,-20,-10,90,0,90,300 examples/example001.scad --projection=o -o
|
||||
ARGS --imgsize=500,500 --camera=100,-20,-10,90,0,90,300 --projection=o -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-cameye EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=60,40,30,0,0,0 examples/example001.scad -o
|
||||
ARGS --imgsize=500,500 --camera=60,40,30,0,0,0 -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-cameye2 EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=160,140,130,0,0,0 examples/example001.scad -o
|
||||
ARGS --imgsize=500,500 --camera=160,140,130,0,0,0 -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-cameyeortho EXE ${OPENSCAD_BINPATH}
|
||||
ARGS --imgsize=500,500 --camera=160,140,130,0,0,0 examples/example001.scad --projection=o -o
|
||||
ARGS --imgsize=500,500 --camera=160,140,130,0,0,0 --projection=o -o
|
||||
SUFFIX png
|
||||
FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
||||
add_cmdline_test(openscad-camcenter EXE ${OPENSCAD_BINPATH}
|
||||
|
|
|
@ -126,7 +126,7 @@ int main(int argc, char **argv)
|
|||
|
||||
currentdir = boosty::stringy(fs::current_path());
|
||||
|
||||
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
|
||||
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()), false);
|
||||
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
|
||||
|
||||
ModuleContext top_ctx;
|
||||
|
|
|
@ -77,7 +77,7 @@ int main(int argc, char **argv)
|
|||
|
||||
currentdir = boosty::stringy( fs::current_path() );
|
||||
|
||||
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
|
||||
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()), false);
|
||||
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
|
||||
|
||||
ModuleContext top_ctx;
|
||||
|
|
|
@ -73,7 +73,7 @@ int main(int argc, char **argv)
|
|||
|
||||
currentdir = boosty::stringy( fs::current_path() );
|
||||
|
||||
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()));
|
||||
parser_init(boosty::stringy(fs::path(argv[0]).branch_path()), false);
|
||||
add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));
|
||||
|
||||
ModuleContext top_ctx;
|
||||
|
|
Loading…
Reference in New Issue