Skip to content

Commit

Permalink
Merge branch 'release/0.7.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Mar 5, 2015
2 parents 654cc0b + aebda7e commit 770f5aa
Show file tree
Hide file tree
Showing 92 changed files with 942 additions and 1,469 deletions.
17 changes: 17 additions & 0 deletions doc/release-notes/0.7.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Antimony 0.7.7
--------------

**Features:**
- Allow `fab.types.Shape` input text box to be edited.
- This required a file format change.
- Older files will be automatically upgraded.
- Warn when unsaved changes will be lost.
- Drag functions can now be specified for `fab.ui.wireframe` objects.
- `Set Color` node allows shapes to be rendered in custom colors.
- Add button that shows hidden datums (i.e. datums prefixed with `_`).
- Tooltips for buttons in inspector.
- Remove `Alt` as the *Hide UI* shortcut and added View menu option.

**Bugfixes:**
- Close script editor when datum is deleted.
- Fixed subtle bug in `Control` construction.
6 changes: 5 additions & 1 deletion gl/height.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ uniform float dz_local;
uniform float zmin_global;
uniform float dz_global;

uniform vec3 color;

void main() {
vec4 depth = texture2D(depth_tex, texture_coord);

Expand All @@ -17,5 +19,7 @@ void main() {
if (depth.r == 0.0f)
fd_global = 0.0f;

gl_FragColor = vec4(fd_global, fd_global, fd_global, 1.0f);
gl_FragColor = vec4(color.r * fd_global,
color.g * fd_global,
color.b * fd_global, 1.0f);
}
6 changes: 4 additions & 2 deletions gl/shaded.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ uniform float dz_local;
uniform float zmin_global;
uniform float dz_global;

uniform vec3 color;

vec4 shade(vec4 norm)
{
vec3 light = vec3(0.99, 0.96, 0.89);
vec3 dark = vec3(0.20, 0.25, 0.3);
vec3 light = vec3(0.99 * color.r, 0.96 * color.g, 0.89 * color.b);
vec3 dark = vec3(0.20 * color.r, 0.25 * color.g, 0.3 * color.b);

float a = dot(norm.xyz, vec3(0.57, 0.57, 0.57));
float b = dot(norm.xyz, vec3(-0.57, -0.57, 0.57));
Expand Down
7 changes: 7 additions & 0 deletions py/fab/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def shell(a, o):
def buffer(a):
return a

def set_color(a, r, g, b):
""" Applies a given color to an input shape a and returns it.
"""
q = Shape(a.math, a.bounds)
q._r, q._g, q._b = r, g, b
return q

################################################################################

def circle(x0, y0, r):
Expand Down
5 changes: 5 additions & 0 deletions py/nodes/CSG/hide.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fab

title('Hide')

input('shape',fab.types.Shape)
10 changes: 10 additions & 0 deletions py/nodes/Color/set_color.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fab

title('Set color (RGB)')

input("shape", fab.types.Shape)
input("r", int, 255)
input("g", int, 255)
input("b", int, 255)

output("out", fab.shapes.set_color(shape, r, g, b))
10 changes: 6 additions & 4 deletions qt/antimony.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += core gui widgets opengl
QT += core gui widgets opengl network

TARGET = antimony
TEMPLATE = app
Expand Down Expand Up @@ -42,9 +42,10 @@ SOURCES += \
../src/ui/canvas/canvas.cpp \
../src/ui/canvas/graph_scene.cpp \
../src/ui/canvas/inspector/inspector.cpp \
../src/ui/canvas/inspector/inspector_title.cpp \
../src/ui/canvas/inspector/inspector_text.cpp \
../src/ui/canvas/inspector/inspector_row.cpp \
../src/ui/canvas/inspector/inspector_menu.cpp \
../src/ui/canvas/inspector/inspector_buttons.cpp \
../src/ui/canvas/connection.cpp \
../src/ui/canvas/port.cpp \
../src/ui/viewport/viewport.cpp \
Expand Down Expand Up @@ -80,9 +81,10 @@ HEADERS += \
../src/ui/canvas/canvas.h \
../src/ui/canvas/graph_scene.h \
../src/ui/canvas/inspector/inspector.h \
../src/ui/canvas/inspector/inspector_title.h \
../src/ui/canvas/inspector/inspector_text.h \
../src/ui/canvas/inspector/inspector_row.h \
../src/ui/canvas/inspector/inspector_menu.h \
../src/ui/canvas/inspector/inspector_buttons.h \
../src/ui/canvas/port.h \
../src/ui/canvas/connection.h \
../src/ui/viewport/viewport.h \
Expand Down Expand Up @@ -122,6 +124,6 @@ linux {
nodes_folder.path = /usr/local/bin/sb/nodes
nodes_folder.files = ../py/nodes/*
fab_folder.path = /usr/local/bin/sb/fab
fab_folder.files = ../py/nodes/*
fab_folder.files = ../py/fab/*
INSTALLS += executable nodes_folder fab_folder
}
10 changes: 2 additions & 8 deletions qt/datums.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,25 @@ SOURCES += \
../src/graph/datum/datum.cpp \
../src/graph/datum/types/eval_datum.cpp \
../src/graph/datum/types/output_datum.cpp \
../src/graph/datum/types/function_datum.cpp \
../src/graph/datum/types/input_datum.cpp \
../src/graph/datum/datums/float_datum.cpp \
../src/graph/datum/datums/float_output_datum.cpp \
../src/graph/datum/datums/int_datum.cpp \
../src/graph/datum/datums/name_datum.cpp \
../src/graph/datum/datums/script_datum.cpp \
../src/graph/datum/datums/string_datum.cpp \
../src/graph/datum/datums/shape_output_datum.cpp \
../src/graph/datum/datums/shape_input_datum.cpp \
../src/graph/datum/datums/shape_function_datum.cpp \
../src/graph/datum/datums/shape_datum.cpp \

HEADERS += \
../src/graph/datum/datum.h \
../src/graph/datum/types/eval_datum.h \
../src/graph/datum/types/output_datum.h \
../src/graph/datum/types/function_datum.h \
../src/graph/datum/types/input_datum.h \
../src/graph/datum/datums/float_datum.h \
../src/graph/datum/datums/float_output_datum.h \
../src/graph/datum/datums/int_datum.h \
../src/graph/datum/datums/name_datum.h \
../src/graph/datum/datums/script_datum.h \
../src/graph/datum/datums/string_datum.h \
../src/graph/datum/datums/shape_output_datum.h \
../src/graph/datum/datums/shape_input_datum.h \
../src/graph/datum/datums/shape_function_datum.h \
../src/graph/datum/datums/shape_datum.h \

13 changes: 0 additions & 13 deletions qt/nodes.pri
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
SOURCES += \
../src/graph/node/node.cpp \
../src/graph/node/nodes/2d.cpp \
../src/graph/node/nodes/3d.cpp \
../src/graph/node/nodes/deform.cpp \
../src/graph/node/nodes/meta.cpp \
../src/graph/node/nodes/transforms.cpp \
../src/graph/node/nodes/iterate.cpp \

HEADERS += \
../src/graph/node/node.h \
../src/graph/node/nodes/2d.h \
../src/graph/node/nodes/3d.h \
../src/graph/node/nodes/deform.h \
../src/graph/node/nodes/meta.h \
../src/graph/node/nodes/transforms.h \
../src/graph/node/nodes/iterate.h \

96 changes: 91 additions & 5 deletions src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
#include <QThread>
#include <QGridLayout>
#include <QDesktopWidget>
#include <QNetworkRequest>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QRegularExpression>

#include <cmath>

#include "app.h"
#include "app/app.h"
#include "app/undo/stack.h"
#include "app/undo/undo_command.h"

Expand Down Expand Up @@ -45,7 +50,8 @@ App::App(int& argc, char** argv) :
QApplication(argc, argv),
graph_scene(new GraphScene()),
view_scene(new ViewportScene()),
root(new NodeRoot()), stack(new UndoStack(this))
root(new NodeRoot()), stack(new UndoStack(this)),
network(new QNetworkAccessManager(this))
{
setGlobalStyle();

Expand All @@ -67,6 +73,9 @@ App::App(int& argc, char** argv) :
graph_scene, &GraphScene::onGlowChange);
connect(graph_scene, &GraphScene::glowChanged,
view_scene, &ViewportScene::onGlowChange);

connect(network, &QNetworkAccessManager::finished,
this, &App::onUpdateCheckFinished);
}

App::~App()
Expand Down Expand Up @@ -160,9 +169,20 @@ void App::onSaveAs()

void App::onOpen()
{
QString f = QFileDialog::getOpenFileName(NULL, "Open", "", "*.sb");
if (!f.isEmpty())
loadFile(f);
if (stack->isClean() || QMessageBox::question(NULL, "Discard unsaved changes?",
"Discard unsaved changes?") == QMessageBox::Yes)
{
QString f = QFileDialog::getOpenFileName(NULL, "Open", "", "*.sb");
if (!f.isEmpty())
loadFile(f);
}
}

void App::onQuit()
{
if (stack->isClean() || QMessageBox::question(NULL, "Discard unsaved changes?",
"Discard unsaved changes?") == QMessageBox::Yes)
quit();
}

void App::loadFile(QString f)
Expand Down Expand Up @@ -407,6 +427,72 @@ void App::onExportJSON()
delete exporting_dialog;
}

void App::startUpdateCheck()
{
QNetworkRequest request;
request.setUrl(QUrl("https://api.github.com/repos/mkeeter/antimony/releases"));
network->get(request);
}

void App::onUpdateCheckFinished(QNetworkReply* reply)
{
QRegularExpression ver("(\\d+)\\.(\\d+)\\.(\\d+)([a-z]|)");
if (!ver.match(GITTAG).hasMatch())
{
QMessageBox::critical(NULL, "Update error",
"<b>Update error:</b><br>"
"Current build is not tagged to any particular version.");
return;
}
auto current = ver.match(GITTAG).capturedTexts();

if (reply->error() != QNetworkReply::NoError)
{
QMessageBox::critical(NULL, "Update error",
"<b>Update error:</b><br>"
"Connection failed.");
return;
}

QJsonParseError err;
auto out = QJsonDocument::fromJson(reply->readAll(), &err);

if (err.error != QJsonParseError::NoError)
{
QMessageBox::critical(NULL, "Update error",
"<b>Update error:</b><br>"
"Could not parse JSON file.");
return;
}

auto latest = out.array()[0].toObject();
auto update = ver.match(latest["tag_name"].toString()).capturedTexts();

bool available = false;

// Check for numerical superiority
for (int i=1; i < 4; ++i)
if (current[i].toInt() < update[i].toInt())
available = true;

// Check for bug-fix release
if (!update[4].isEmpty() && (current[4].isEmpty() ||
current[4] < update[4]))
available = true;

if (available)
QMessageBox::information(NULL, "Update available", QString(
"<b>Update available:</b><br>"
"This is version %1<br>"
"Version "
"<a href=\"https://github.com/mkeeter/antimony/releases/%2\">"
"%2</a> is available.").arg(current[0])
.arg(update[0]));
else
QMessageBox::information(NULL, "No update available",
"No update is available at this time.");
}

bool App::event(QEvent *event)
{
switch (event->type()) {
Expand Down
8 changes: 8 additions & 0 deletions src/app/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <QApplication>
#include <QAction>
#include <QNetworkAccessManager>
#include <QNetworkReply>

class GraphScene;
class ViewportScene;
Expand Down Expand Up @@ -104,11 +106,15 @@ public slots:
void onSave();
void onSaveAs();
void onOpen();
void onQuit();

void onExportSTL();
void onExportHeightmap();
void onExportJSON();

void startUpdateCheck();
void onUpdateCheckFinished(QNetworkReply* reply);

private:

bool event(QEvent* event);
Expand All @@ -120,6 +126,8 @@ public slots:
QString filename;
NodeRoot* root;
UndoStack* stack;

QNetworkAccessManager* network;
};

#endif // APP_H
15 changes: 14 additions & 1 deletion src/control/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include "app/undo/undo_delete_multi.h"

Control::Control(Node* node, PyObject* drag_func)
: QObject(), node(node), drag_func(drag_func), glow(false), relative(true)
: QObject(), node(node), drag_func(drag_func), glow(false),
relative(true), delete_scheduled(false)
{
connect(node, &Node::clearControlTouchedFlag,
this, &Control::clearTouchedFlag);
Expand All @@ -25,11 +26,23 @@ Control::Control(Node* node, PyObject* drag_func)
connect(node, &Node::destroyed, this, &Control::deleteLater);
}

void Control::deleteLater()
{
delete_scheduled = true;
QObject::deleteLater();
}

Control::~Control()
{
Py_XDECREF(drag_func);
}

void Control::setDragFunc(PyObject* new_drag_func)
{
Py_XDECREF(drag_func);
drag_func = new_drag_func;
}

QRectF Control::bounds(QMatrix4x4 m) const
{
// Default implementation is the bounding rect of shape().
Expand Down
Loading

0 comments on commit 770f5aa

Please sign in to comment.