Skip to content

Commit

Permalink
Merge branch 'release/0.9.2b'
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Jul 10, 2016
2 parents e8480c7 + b9f01e1 commit a6a2c52
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 104 deletions.
6 changes: 3 additions & 3 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ else()
${CMAKE_CURRENT_BINARY_DIR}/sb/fab)

install(TARGETS antimony
DESTINATION /usr/local/bin)
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(DIRECTORY ../py/nodes
DESTINATION /usr/local/share/antimony)
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/antimony)
install(DIRECTORY ../py/fab
DESTINATION /usr/local/share/antimony)
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/antimony)
endif()

target_link_libraries(${ANTIMONY_APP}
Expand Down
44 changes: 23 additions & 21 deletions app/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,42 @@ void App::makeDefaultWindows()
newViewportWindow();
}

QString App::bundledNodePath() const
QStringList App::nodePaths() const
{

QStringList paths;
#if defined Q_OS_MAC
// On Mac, the 'nodes' folder must be at
// Antimony.app/Contents/Resources/nodes
auto path = applicationDirPath().split("/");
path.removeLast(); // Trim the MacOS folder from the path
return path.join("/") + "/Resources/nodes";
paths << path.join("/") + "/Resources/nodes";
#elif defined Q_OS_LINUX
// If we're running Antimony from the build folder, use sb/nodes
auto path = applicationDirPath() + "/sb/nodes";
if (QDir(path).exists())
{
return path;
}
// Otherwise, assume nodes have been installed into
// /usr/local/share/antimony/nodes
else
{
return "/usr/local/share/antimony/nodes";
}
paths << applicationDirPath() + "/sb/nodes";
paths << applicationDirPath() + "/../share/antimony/nodes";
#else
#error "Unknown OS!"
#endif

}
for (auto p : QStandardPaths::standardLocations(
QStandardPaths::AppDataLocation))
{
paths << p + "/nodes";
}

QString App::userNodePath() const
{
auto path = QStandardPaths::writableLocation(
QStandardPaths::AppDataLocation) + "/nodes";
QDir(path).mkpath(".");
return path;
// Filter paths to canonical forms, keeping only the paths that actually
// exist as real folders
QSet<QString> existing_paths;
for (auto p : paths)
{
auto d = QDir(p);
if (d.exists())
{
existing_paths.insert(d.canonicalPath());
}
}

return existing_paths.toList();
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 1 addition & 2 deletions app/app/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class App : public QApplication
* Returns the path to the node directories
* (which varies depending on OS).
*/
QString bundledNodePath() const;
QString userNodePath() const;
QStringList nodePaths() const;

/*
* Returns the top-level graph proxy object
Expand Down
15 changes: 11 additions & 4 deletions app/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QDebug>

#include <QCommandLineParser>
#include <QStandardPaths>
#include <QMainWindow>
#include <QCoreApplication>
#include <QSurfaceFormat>
Expand Down Expand Up @@ -47,10 +48,16 @@ int main(int argc, char *argv[])
path << "Resources";
fab::postInit({path.join("/").toStdString()});
#elif defined Q_OS_LINUX
QCoreApplication::applicationDirPath() + "/sb";
fab::postInit(
{(QCoreApplication::applicationDirPath() + "/sb").toStdString(),
"/usr/local/share/antimony"});
auto dir = QCoreApplication::applicationDirPath();
std::vector<std::string> fab_paths =
{(dir + "/sb").toStdString(),
(dir + "/../share/antimony/").toStdString()};
for (auto p : QStandardPaths::standardLocations(
QStandardPaths::AppDataLocation))
{
fab_paths.push_back(p.toStdString());
}
fab::postInit(fab_paths);
#else
#error "Unknown OS!"
#endif
Expand Down
11 changes: 4 additions & 7 deletions app/graph/constructor/populate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,17 @@ static void addNodeToMenu(QMenu* menu, QStringList category, QString name,
static void populateFromFiles(QMenu* menu, Graph* g,
std::function<void(Node*)> callback)
{
QDirIterator bitr(App::instance()->bundledNodePath(),
QDirIterator::Subdirectories);
QDirIterator uitr(App::instance()->userNodePath(),
QDirIterator::Subdirectories);
QList<QRegExp> title_regexs= {QRegExp(".*title\\('+([^']+)'+\\).*"),
QRegExp(".*title\\(\"+([^\"]+)\"+\\).*")};

// Extract all of valid filenames into a QStringList.
QStringList node_filenames;
for (auto itr : {&bitr, &uitr})
for (auto path : App::instance()->nodePaths())
{
while (itr->hasNext())
QDirIterator itr(path, QDirIterator::Subdirectories);
while (itr.hasNext())
{
auto n = itr->next();
auto n = itr.next();
if (n.endsWith(".node"))
node_filenames.append(n);
}
Expand Down
2 changes: 1 addition & 1 deletion app/window/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ bool BaseWindow::askClose()
if(window_count <= 1 && !App::instance()->isUndoStackClean())
{
auto res = QMessageBox::question(
this, "APP_NAME", "There are unsaved changes!\n"
this, "Antimony", "There are unsaved changes!\n"
"Do you still want to close this window?\n",
QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes);

Expand Down
7 changes: 7 additions & 0 deletions app/window/canvas.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#include <Python.h>

#include "window/canvas.h"
#include "canvas/scene.h"
#include "canvas/canvas_view.h"

#include "graph/constructor/populate.h"

CanvasWindow::CanvasWindow(CanvasView* view)
: BaseWindow("Graph")
{
setCentralWidget(view);

populateNodeMenu(ui->menuAdd,
static_cast<CanvasScene*>(view->scene())->getGraph());

// Connect copy / paste actions
connect(ui->actionCopy, &QAction::triggered,
view, &CanvasView::onCopy);
Expand Down
2 changes: 2 additions & 0 deletions lib/fab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mark_as_advanced(LEMON_EXECUTABLE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/v2syntax.lemon.hpp
${CMAKE_CURRENT_BINARY_DIR}/v2syntax.lemon.cpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/tree/v2syntax.y
COMMAND ${LEMON_EXECUTABLE} -q -c -s ${CMAKE_CURRENT_SOURCE_DIR}/src/tree/v2syntax.y
COMMAND mv ${CMAKE_CURRENT_SOURCE_DIR}/src/tree/v2syntax.c ${CMAKE_CURRENT_BINARY_DIR}/v2syntax.lemon.cpp
COMMAND mv ${CMAKE_CURRENT_SOURCE_DIR}/src/tree/v2syntax.h ${CMAKE_CURRENT_BINARY_DIR}/v2syntax.lemon.hpp)
Expand All @@ -19,6 +20,7 @@ mark_as_advanced(FLEX_EXECUTABLE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/v2syntax.yy.hpp
${CMAKE_CURRENT_BINARY_DIR}/v2syntax.yy.cpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/tree/v2syntax.l
COMMAND ${FLEX_EXECUTABLE} --outfile=${CMAKE_CURRENT_BINARY_DIR}/v2syntax.yy.cpp
--header-file=${CMAKE_CURRENT_BINARY_DIR}/v2syntax.yy.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/tree/v2syntax.l)
Expand Down
32 changes: 0 additions & 32 deletions lib/fab/flex.pri

This file was deleted.

33 changes: 0 additions & 33 deletions lib/fab/lemon.pri

This file was deleted.

2 changes: 1 addition & 1 deletion lib/fab/src/formats/stl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void save_stl(float* verts, unsigned count, const char* filename)
FILE* stl = fopen(filename, "wb");

// 80-character header
fprintf(stl, "This is a binary STL file made in kokopelli \n(github.com/mkeeter/kokopelli)\n\n");
fprintf(stl, "This is a binary STL file made in Antimony \n(github.com/mkeeter/antimony)\n\n");

int tris = count / 9;
for (unsigned i=0; i < sizeof(float); ++i) {
Expand Down
2 changes: 2 additions & 0 deletions lib/fab/src/tree/v2syntax.y
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
%syntax_error
{
environment->valid = false;
#ifndef NDEBUG
int n = sizeof(yyTokenName) / sizeof(yyTokenName[0]);
for (int i = 0; i < n; ++i) {
int a = yy_find_shift_action(yypParser, (YYCODETYPE)i);
if (a < YYNSTATE + YYNRULE) {
printf("possible token: %s\n", yyTokenName[i]);
}
}
#endif
}


Expand Down

0 comments on commit a6a2c52

Please sign in to comment.