├── VERSION ├── AUTHORS ├── icon.ico ├── lithomaker.rc ├── default.png ├── icons ├── icon.png ├── quit.png ├── save.png ├── about.png ├── render.png ├── mainconfig.png ├── preferences.png ├── exportconfig.png └── renderconfig.png ├── examples ├── cheetah.png ├── elephant.png └── hummingbird.png ├── default.desktop ├── lithomaker.qrc ├── lithomaker.pro ├── src ├── configpages.h ├── checkbox.h ├── lineedit.h ├── combobox.h ├── aboutbox.h ├── main.cpp ├── configdialog.h ├── slider.h ├── lineedit.cpp ├── checkbox.cpp ├── combobox.cpp ├── mainwindow.h ├── slider.cpp ├── configdialog.cpp ├── aboutbox.cpp ├── configpages.cpp └── mainwindow.cpp ├── 0.2mm QUALITY @MK3 - Lithophane optimized.ini ├── README.md └── LICENSE /VERSION: -------------------------------------------------------------------------------- 1 | VERSION=0.7.1 -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Developer: 2 | Lars Muldjord (muldjordlars@gmail.comm) 3 | -------------------------------------------------------------------------------- /icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icon.ico -------------------------------------------------------------------------------- /lithomaker.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "icon.ico" -------------------------------------------------------------------------------- /default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/default.png -------------------------------------------------------------------------------- /icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/icon.png -------------------------------------------------------------------------------- /icons/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/quit.png -------------------------------------------------------------------------------- /icons/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/save.png -------------------------------------------------------------------------------- /icons/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/about.png -------------------------------------------------------------------------------- /icons/render.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/render.png -------------------------------------------------------------------------------- /examples/cheetah.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/examples/cheetah.png -------------------------------------------------------------------------------- /examples/elephant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/examples/elephant.png -------------------------------------------------------------------------------- /icons/mainconfig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/mainconfig.png -------------------------------------------------------------------------------- /icons/preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/preferences.png -------------------------------------------------------------------------------- /examples/hummingbird.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/examples/hummingbird.png -------------------------------------------------------------------------------- /icons/exportconfig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/exportconfig.png -------------------------------------------------------------------------------- /icons/renderconfig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muldjord/lithomaker/HEAD/icons/renderconfig.png -------------------------------------------------------------------------------- /default.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=LithoMaker 4 | Exec=AppRun %F 5 | Icon=default 6 | Comment=Lithophane 3D mesh renderer and exporter 7 | Terminal=true 8 | Categories=Graphics; 9 | X-AppImage-Version=0.7.0 10 | -------------------------------------------------------------------------------- /lithomaker.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LICENSE 5 | AUTHORS 6 | icons/icon.png 7 | icons/quit.png 8 | icons/about.png 9 | icons/preferences.png 10 | icons/render.png 11 | icons/mainconfig.png 12 | icons/renderconfig.png 13 | icons/exportconfig.png 14 | 15 | 16 | -------------------------------------------------------------------------------- /lithomaker.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | TARGET = LithoMaker 3 | DEPENDPATH += . 4 | INCLUDEPATH += . 5 | CONFIG += 6 | RESOURCES += lithomaker.qrc 7 | RC_FILE = lithomaker.rc 8 | QT += widgets 9 | TRANSLATIONS = lithomaker_da_DK.ts 10 | QMAKE_CXXFLAGS += -fopenmp 11 | LIBS += -fopenmp 12 | 13 | include(./VERSION) 14 | DEFINES+=VERSION=\\\"$$VERSION\\\" 15 | 16 | # Input 17 | HEADERS += src/mainwindow.h \ 18 | src/lineedit.h \ 19 | src/slider.h \ 20 | src/combobox.h \ 21 | src/checkbox.h \ 22 | src/configpages.h \ 23 | src/configdialog.h \ 24 | src/aboutbox.h 25 | 26 | SOURCES += src/main.cpp \ 27 | src/mainwindow.cpp \ 28 | src/lineedit.cpp \ 29 | src/slider.cpp \ 30 | src/combobox.cpp \ 31 | src/checkbox.cpp \ 32 | src/configpages.cpp \ 33 | src/configdialog.cpp \ 34 | src/aboutbox.cpp 35 | -------------------------------------------------------------------------------- /src/configpages.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * configpages.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __CONFIGPAGES_H__ 28 | #define __CONFIGPAGES_H__ 29 | 30 | #include 31 | 32 | class MainPage : public QWidget 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | MainPage(QWidget *parent = 0); 38 | }; 39 | 40 | class RenderPage : public QWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | RenderPage(QWidget *parent = 0); 46 | }; 47 | 48 | class ExportPage : public QWidget 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | ExportPage(QWidget *parent = 0); 54 | }; 55 | 56 | #endif // __CONFIGPAGES_H__ 57 | -------------------------------------------------------------------------------- /src/checkbox.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * checkbox.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __CHECKBOX_H__ 28 | #define __CHECKBOX_H__ 29 | 30 | #include 31 | 32 | class CheckBox : public QCheckBox 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | CheckBox(const QString &title, const QString &group, 38 | const QString &name, 39 | const bool &stdValue); 40 | ~CheckBox(); 41 | void refreshState(); 42 | 43 | public slots: 44 | void resetToDefault(); 45 | 46 | private slots: 47 | void saveToConfig(int); 48 | 49 | private: 50 | QString key; 51 | bool stdValue; 52 | }; 53 | 54 | #endif // __CHECKBOX_H__ 55 | -------------------------------------------------------------------------------- /src/lineedit.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * lineedit.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __LINEEDIT_H__ 28 | #define __LINEEDIT_H__ 29 | 30 | #include 31 | 32 | class LineEdit : public QLineEdit 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | LineEdit(const QString &group, const QString &name, const QString &stdValue, 38 | const bool &isText = false); 39 | ~LineEdit(); 40 | 41 | public slots: 42 | void resetToDefault(); 43 | 44 | protected: 45 | 46 | private slots: 47 | void saveToConfig(const QString &); 48 | 49 | private: 50 | QString key; 51 | QString stdValue; 52 | bool isText; 53 | }; 54 | 55 | #endif // __LINEEDIT_H__ 56 | -------------------------------------------------------------------------------- /src/combobox.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * combobox.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __COMBOBOX_H__ 28 | #define __COMBOBOX_H__ 29 | 30 | #include 31 | 32 | class ComboBox : public QComboBox 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | ComboBox(const QString &group, const QString &name, 38 | const QString &stdValue); 39 | ~ComboBox(); 40 | void addConfigItem(const QString &text, const QString &value); 41 | void setFromConfig(); 42 | 43 | public slots: 44 | void resetToDefault(); 45 | 46 | private slots: 47 | void saveToConfig(int); 48 | 49 | private: 50 | QString key; 51 | QString stdValue; 52 | QString configValue; 53 | }; 54 | 55 | #endif // __COMBOBOX_H__ 56 | -------------------------------------------------------------------------------- /src/aboutbox.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * aboutbox.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __ABOUTBOX_H__ 28 | #define __ABOUTBOX_H__ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | class AboutBox : public QDialog 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | AboutBox(QWidget *parent); 41 | 42 | public slots: 43 | void scroll(); 44 | void noMoreScroll(); 45 | void checkTab(int tabIndex); 46 | 47 | signals: 48 | 49 | private: 50 | void mousePressEvent(QMouseEvent * event); 51 | QScrollArea *licenseScroll; 52 | QTimer *scrollTimer; 53 | int scrollState; 54 | QTabWidget *tabs; 55 | }; 56 | 57 | 58 | #endif // __ABOUTBOX_H__ 59 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * main.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "mainwindow.h" 34 | 35 | QSettings *settings; 36 | 37 | int main(int argc, char *argv[]) 38 | { 39 | QApplication app(argc, argv); 40 | app.setStyle(QStyleFactory::create("Fusion")); 41 | 42 | QTranslator translator; 43 | translator.load("lithomaker_" + QLocale::system().name()); 44 | app.installTranslator(&translator); 45 | 46 | QDir::setCurrent(QApplication::applicationDirPath()); 47 | 48 | QSettings s("LithoMaker"); 49 | settings = &s; 50 | 51 | MainWindow window; 52 | window.show(); 53 | return app.exec(); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/configdialog.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * configdialog.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __CONFIGDIALOG_H__ 28 | #define __CONFIGDIALOG_H__ 29 | 30 | #include "configpages.h" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | class ConfigDialog : public QDialog 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | ConfigDialog(QWidget *parent); 43 | 44 | public slots: 45 | void changePage(QListWidgetItem *current, QListWidgetItem *previous); 46 | 47 | private: 48 | void createIcons(); 49 | QListWidget *contentsWidget; 50 | QStackedWidget *pagesWidget; 51 | MainPage *mainPage; 52 | RenderPage *renderPage; 53 | ExportPage *exportPage; 54 | }; 55 | 56 | #endif // __CONFIGDIALOG_H__ 57 | -------------------------------------------------------------------------------- /src/slider.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * slider.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __SLIDER_H__ 28 | #define __SLIDER_H__ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | class Slider : public QWidget 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | Slider(const QString &group, const QString &name, 40 | const int &minValue, const int &maxValue, const int &stdValue, const int &exponent); 41 | ~Slider(); 42 | 43 | public slots: 44 | void resetToDefault(); 45 | 46 | protected: 47 | 48 | private slots: 49 | void saveToConfig(); 50 | void setSlider(); 51 | 52 | private: 53 | QSlider *slider; 54 | QLineEdit *lineEdit; 55 | 56 | QString key; 57 | 58 | int stdValue; 59 | int exponent; 60 | }; 61 | 62 | #endif // __SLIDER_H__ 63 | -------------------------------------------------------------------------------- /src/lineedit.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * lineedit.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #define DEBUG 28 | 29 | #include 30 | #include 31 | 32 | #include "lineedit.h" 33 | 34 | extern QSettings *settings; 35 | 36 | LineEdit::LineEdit(const QString &group, const QString &name, const QString &stdValue, 37 | const bool &isText) 38 | : stdValue(stdValue), isText(isText) 39 | { 40 | key = (group != "General"?group + "/":"") + name; 41 | 42 | if(!settings->contains(key)) { 43 | settings->setValue(key, stdValue); 44 | } 45 | setText(settings->value(key, stdValue).toString()); 46 | setToolTip(tr("Default value: ") + stdValue); 47 | 48 | connect(this, &QLineEdit::textChanged, this, &LineEdit::saveToConfig); 49 | } 50 | 51 | LineEdit::~LineEdit() 52 | { 53 | } 54 | 55 | void LineEdit::resetToDefault() 56 | { 57 | setText(stdValue); 58 | } 59 | 60 | void LineEdit::saveToConfig(const QString &) 61 | { 62 | if(!isText && text().contains(",")) { 63 | setText(text().replace(",", ".")); 64 | } 65 | 66 | settings->setValue(key, text()); 67 | qDebug("Key '%s' saved to config with value '%s'\n", key.toStdString().c_str(), text().toStdString().c_str()); 68 | } 69 | -------------------------------------------------------------------------------- /src/checkbox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * checkbox.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #define DEBUG 28 | 29 | #include 30 | #include 31 | 32 | #include "checkbox.h" 33 | 34 | extern QSettings *settings; 35 | 36 | CheckBox::CheckBox(const QString &group, const QString &name, 37 | const QString &title, 38 | const bool &stdValue) 39 | : QCheckBox(title), stdValue(stdValue) 40 | { 41 | key = (group != "General"?group + "/":"") + name; 42 | 43 | if(!settings->contains(key)) { 44 | settings->setValue(key, (stdValue?"true":"false")); 45 | } 46 | setChecked(settings->value(key, stdValue).toBool()); 47 | 48 | setToolTip(tr("Default state: ") + (stdValue?tr("True"):tr("False"))); 49 | 50 | connect(this, &QCheckBox::stateChanged, this, &CheckBox::saveToConfig); 51 | } 52 | 53 | CheckBox::~CheckBox() 54 | { 55 | } 56 | 57 | void CheckBox::refreshState() 58 | { 59 | toggle(); 60 | toggle(); 61 | } 62 | 63 | void CheckBox::resetToDefault() 64 | { 65 | setChecked(stdValue); 66 | } 67 | 68 | void CheckBox::saveToConfig(int) 69 | { 70 | if(isChecked()) { 71 | settings->setValue(key, "true"); 72 | } else { 73 | settings->setValue(key, "false"); 74 | } 75 | 76 | qDebug("Key '%s' saved to config with value '%s'\n", key.toStdString().c_str(), (isChecked()?"true":"false")); 77 | } 78 | -------------------------------------------------------------------------------- /src/combobox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * combobox.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #define DEBUG 28 | 29 | #include 30 | #include 31 | 32 | #include "combobox.h" 33 | 34 | extern QSettings *settings; 35 | 36 | ComboBox::ComboBox(const QString &group, const QString &name, 37 | const QString &stdValue) 38 | : stdValue(stdValue) 39 | { 40 | key = (group != "General"?group + "/":"") + name; 41 | 42 | if(!settings->contains(key)) { 43 | settings->setValue(key, stdValue); 44 | } 45 | configValue = settings->value(key, "1").toString(); 46 | 47 | setToolTip(tr("Default value: ") + stdValue); 48 | 49 | connect(this, QOverload::of(&QComboBox::currentIndexChanged), this, &ComboBox::saveToConfig); 50 | } 51 | 52 | ComboBox::~ComboBox() 53 | { 54 | } 55 | 56 | void ComboBox::addConfigItem(const QString &text, const QString &value) 57 | { 58 | addItem(text, value); 59 | } 60 | 61 | void ComboBox::setFromConfig() 62 | { 63 | for(int i = 0; i < count(); ++i) { 64 | if(itemData(i).toString() == configValue) { 65 | setCurrentIndex(i); 66 | } 67 | } 68 | } 69 | 70 | void ComboBox::resetToDefault() 71 | { 72 | for(int i = 0; i < count(); ++i) { 73 | if(itemData(i).toString() == stdValue) { 74 | setCurrentIndex(i); 75 | } 76 | } 77 | } 78 | 79 | void ComboBox::saveToConfig(int) 80 | { 81 | settings->setValue(key, currentData().toString()); 82 | 83 | qDebug("Key '%s' saved to config with value '%s'\n", key.toStdString().c_str(), currentData().toString().toStdString().c_str()); 84 | } 85 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * mainwindow.h 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #ifndef __MAINWINDOW_H__ 28 | #define __MAINWINDOW_H__ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "slider.h" 39 | 40 | class MainWindow : public QMainWindow 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | MainWindow(); 46 | ~MainWindow(); 47 | 48 | public slots: 49 | 50 | protected: 51 | 52 | signals: 53 | 54 | private slots: 55 | void showAbout(); 56 | void showPreferences(); 57 | void inputSelect(); 58 | void outputSelect(); 59 | 60 | private: 61 | void enableUi(); 62 | void disableUi(); 63 | void createMesh(); 64 | void exportStl(); 65 | int getPixel(const QImage &image, const int &x, const int &y); 66 | void createActions(); 67 | void createMenus(); 68 | //QByteArray stlString; 69 | QList polygons; 70 | Slider *minThicknessSlider; 71 | //QLineEdit *minThicknessLineEdit; 72 | Slider *totalThicknessSlider; 73 | //QLineEdit *totalThicknessLineEdit; 74 | Slider *borderSlider; 75 | //QLineEdit *borderLineEdit; 76 | Slider *widthSlider; 77 | //QLineEdit *widthLineEdit; 78 | QPushButton *inputButton; 79 | QLineEdit *inputLineEdit; 80 | QPushButton *outputButton; 81 | QProgressBar *renderProgress; 82 | QPushButton *renderButton; 83 | QLineEdit *outputLineEdit; 84 | QAction *quitAct; 85 | QAction *preferencesAct; 86 | QAction *aboutAct; 87 | QMenu *fileMenu; 88 | QMenu *optionsMenu; 89 | QMenu *helpMenu; 90 | QMenuBar *menuBar; 91 | 92 | float depthFactor = -1.0; 93 | float widthFactor = -1.0; 94 | float border = -1.0; 95 | 96 | QVector3D getVertex(float x, float y, float z, const bool &scale = false); 97 | 98 | QList addFrame(const float &width, const float &height); 99 | QList addHangers(const float &width, const float &height); 100 | QList addStabilizer(const float &x, const float &height); 101 | }; 102 | 103 | #endif // __MAINWINDOW_H__ 104 | -------------------------------------------------------------------------------- /src/slider.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * slider.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #define DEBUG 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include "slider.h" 34 | 35 | extern QSettings *settings; 36 | 37 | Slider::Slider(const QString &group, const QString &name, 38 | const int &minValue, const int &maxValue, const int &stdValue, const int &exponent) 39 | : stdValue(stdValue), exponent(exponent) 40 | { 41 | lineEdit = new QLineEdit(); 42 | lineEdit->setMaximumWidth(50); 43 | slider = new QSlider(Qt::Horizontal); 44 | slider->setMinimum(minValue); 45 | slider->setMaximum(maxValue); 46 | slider->setTickInterval(1); 47 | slider->setSingleStep(1); 48 | slider->setPageStep(1); 49 | slider->setToolTip(tr("Default value: ") + QString::number((float)stdValue / exponent)); 50 | 51 | key = (group != "General"?group + "/":"") + name; 52 | 53 | if(!settings->contains(key)) { 54 | settings->setValue(key, QString::number((float)stdValue / exponent)); 55 | } 56 | slider->setValue(settings->value(key).toFloat() * exponent); 57 | lineEdit->setText(QString::number((float)slider->value() / exponent)); 58 | lineEdit->setToolTip(tr("Default value: ") + QString::number((float)stdValue / exponent)); 59 | 60 | QHBoxLayout *layout = new QHBoxLayout(); 61 | layout->addWidget(lineEdit); 62 | layout->addWidget(slider); 63 | 64 | setLayout(layout); 65 | 66 | connect(slider, &QSlider::valueChanged, this, &Slider::saveToConfig); 67 | connect(lineEdit, &QLineEdit::editingFinished, this, &Slider::setSlider); 68 | } 69 | 70 | Slider::~Slider() 71 | { 72 | } 73 | 74 | void Slider::resetToDefault() 75 | { 76 | slider->setValue((float)stdValue * exponent); 77 | lineEdit->setText(QString::number((float)stdValue / exponent)); 78 | } 79 | 80 | void Slider::saveToConfig() 81 | { 82 | lineEdit->setText(QString::number((float)slider->value() / exponent)); 83 | 84 | settings->setValue(key, lineEdit->text()); 85 | qDebug("Key '%s' saved to config with value '%s'\n", key.toStdString().c_str(), lineEdit->text().toStdString().c_str()); 86 | } 87 | 88 | void Slider::setSlider() 89 | { 90 | slider->setValue(lineEdit->text().toFloat() * exponent); 91 | } 92 | -------------------------------------------------------------------------------- /0.2mm QUALITY @MK3 - Lithophane optimized.ini: -------------------------------------------------------------------------------- 1 | # generated by PrusaSlicer 2.3.3+linux-x64 on 2021-11-15 at 17:12:55 UTC 2 | avoid_crossing_perimeters = 1 3 | avoid_crossing_perimeters_max_detour = 0 4 | bottom_fill_pattern = monotonic 5 | bottom_solid_layers = 5 6 | bottom_solid_min_thickness = 0.5 7 | bridge_acceleration = 1000 8 | bridge_angle = 0 9 | bridge_flow_ratio = 0.8 10 | bridge_speed = 30 11 | brim_width = 5 12 | clip_multipart_objects = 1 13 | compatible_printers = 14 | compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/ and nozzle_diameter[0]==0.4 15 | complete_objects = 0 16 | default_acceleration = 1000 17 | dont_support_bridges = 1 18 | draft_shield = 0 19 | elefant_foot_compensation = 0.2 20 | ensure_vertical_shell_thickness = 0 21 | external_perimeter_extrusion_width = 0.45 22 | external_perimeter_speed = 25 23 | external_perimeters_first = 0 24 | extra_perimeters = 0 25 | extruder_clearance_height = 20 26 | extruder_clearance_radius = 45 27 | extrusion_width = 0.45 28 | fill_angle = 45 29 | fill_density = 15% 30 | fill_pattern = gyroid 31 | first_layer_acceleration = 1000 32 | first_layer_extrusion_width = 0.42 33 | first_layer_height = 0.2 34 | first_layer_speed = 20 35 | gap_fill_speed = 40 36 | gcode_comments = 0 37 | gcode_label_objects = 1 38 | infill_acceleration = 1000 39 | infill_anchor = 2.5 40 | infill_anchor_max = 12 41 | infill_every_layers = 1 42 | infill_extruder = 1 43 | infill_extrusion_width = 0.45 44 | infill_first = 0 45 | infill_only_where_needed = 0 46 | infill_overlap = 25% 47 | infill_speed = 80 48 | inherits = 0.15mm QUALITY @MK3 49 | interface_shells = 0 50 | ironing = 0 51 | ironing_flowrate = 15% 52 | ironing_spacing = 0.1 53 | ironing_speed = 15 54 | ironing_type = top 55 | layer_height = 0.2 56 | max_print_speed = 200 57 | max_volumetric_speed = 0 58 | min_skirt_length = 4 59 | notes = 60 | only_retract_when_crossing_perimeters = 0 61 | ooze_prevention = 0 62 | output_filename_format = {input_filename_base}_{layer_height}mm_{filament_type[0]}_{printer_model}_{print_time}.gcode 63 | overhangs = 0 64 | perimeter_acceleration = 800 65 | perimeter_extruder = 1 66 | perimeter_extrusion_width = 0.45 67 | perimeter_speed = 45 68 | perimeters = 20 69 | post_process = 70 | print_settings_id = 71 | raft_layers = 0 72 | resolution = 0 73 | seam_position = nearest 74 | single_extruder_multi_material_priming = 0 75 | skirt_distance = 2 76 | skirt_height = 3 77 | skirts = 1 78 | slice_closing_radius = 0.049 79 | small_perimeter_speed = 25 80 | solid_infill_below_area = 0 81 | solid_infill_every_layers = 0 82 | solid_infill_extruder = 1 83 | solid_infill_extrusion_width = 0.45 84 | solid_infill_speed = 80 85 | spiral_vase = 0 86 | standby_temperature_delta = -5 87 | support_material = 0 88 | support_material_angle = 0 89 | support_material_auto = 1 90 | support_material_buildplate_only = 0 91 | support_material_contact_distance = 0.1 92 | support_material_enforce_layers = 0 93 | support_material_extruder = 0 94 | support_material_extrusion_width = 0.35 95 | support_material_interface_contact_loops = 0 96 | support_material_interface_extruder = 0 97 | support_material_interface_layers = 2 98 | support_material_interface_spacing = 0.2 99 | support_material_interface_speed = 80% 100 | support_material_pattern = rectilinear 101 | support_material_spacing = 2 102 | support_material_speed = 50 103 | support_material_synchronize_layers = 0 104 | support_material_threshold = 55 105 | support_material_with_sheath = 0 106 | support_material_xy_spacing = 50% 107 | thin_walls = 0 108 | threads = 24 109 | top_fill_pattern = monotonic 110 | top_infill_extrusion_width = 0.4 111 | top_solid_infill_speed = 40 112 | top_solid_layers = 7 113 | top_solid_min_thickness = 0.7 114 | travel_speed = 50 115 | wipe_tower = 1 116 | wipe_tower_bridging = 10 117 | wipe_tower_no_sparse_layers = 0 118 | wipe_tower_rotation_angle = 0 119 | wipe_tower_width = 60 120 | wipe_tower_x = 170 121 | wipe_tower_y = 125 122 | xy_size_compensation = 0 123 | -------------------------------------------------------------------------------- /src/configdialog.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * configdialog.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #include 28 | 29 | #include "configdialog.h" 30 | 31 | ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) 32 | { 33 | setFixedSize(600, 500); 34 | contentsWidget = new QListWidget; 35 | contentsWidget->setViewMode(QListView::IconMode); 36 | contentsWidget->setIconSize(QSize(64, 64)); 37 | contentsWidget->setMovement(QListView::Static); 38 | contentsWidget->setMaximumWidth(100); 39 | contentsWidget->setMinimumWidth(100); 40 | contentsWidget->setSpacing(12); 41 | 42 | mainPage = new MainPage(); 43 | renderPage = new RenderPage(); 44 | exportPage = new ExportPage(); 45 | 46 | pagesWidget = new QStackedWidget; 47 | //pagesWidget->addWidget(mainPage); 48 | pagesWidget->addWidget(renderPage); 49 | pagesWidget->addWidget(exportPage); 50 | 51 | QPushButton *okButton = new QPushButton(tr("Ok")); 52 | 53 | createIcons(); 54 | contentsWidget->setCurrentRow(0); 55 | 56 | connect(okButton, &QPushButton::clicked, this, &ConfigDialog::accept); 57 | 58 | QHBoxLayout *horizontalLayout = new QHBoxLayout; 59 | horizontalLayout->addWidget(contentsWidget); 60 | horizontalLayout->addWidget(pagesWidget, 1); 61 | 62 | QHBoxLayout *buttonsLayout = new QHBoxLayout; 63 | buttonsLayout->addStretch(1); 64 | buttonsLayout->addWidget(okButton); 65 | 66 | QVBoxLayout *mainLayout = new QVBoxLayout; 67 | mainLayout->addLayout(horizontalLayout); 68 | mainLayout->addLayout(buttonsLayout); 69 | setLayout(mainLayout); 70 | 71 | setWindowTitle(tr("Preferences")); 72 | } 73 | 74 | void ConfigDialog::createIcons() 75 | { 76 | /* 77 | QListWidgetItem *mainButton = new QListWidgetItem(contentsWidget); 78 | mainButton->setIcon(QIcon(":mainconfig.png")); 79 | mainButton->setText(tr("Main")); 80 | mainButton->setTextAlignment(Qt::AlignHCenter); 81 | mainButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); 82 | */ 83 | 84 | QListWidgetItem *renderButton = new QListWidgetItem(contentsWidget); 85 | renderButton->setIcon(QIcon(":renderconfig.png")); 86 | renderButton->setText(tr("Render")); 87 | renderButton->setTextAlignment(Qt::AlignHCenter); 88 | renderButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); 89 | 90 | QListWidgetItem *exportButton = new QListWidgetItem(contentsWidget); 91 | exportButton->setIcon(QIcon(":exportconfig.png")); 92 | exportButton->setText(tr("Export")); 93 | exportButton->setTextAlignment(Qt::AlignHCenter); 94 | exportButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); 95 | 96 | connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage); 97 | } 98 | 99 | void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) 100 | { 101 | if(!current) { 102 | current = previous; 103 | } 104 | 105 | pagesWidget->setCurrentIndex(contentsWidget->row(current)); 106 | } 107 | -------------------------------------------------------------------------------- /src/aboutbox.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * aboutbox.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #include "aboutbox.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | AboutBox::AboutBox(QWidget *parent): QDialog(parent) 39 | { 40 | setWindowTitle(tr("About LithoMaker")); 41 | setFixedSize(750,500); 42 | 43 | // Read AUTHORS data from file 44 | QFile file(":AUTHORS"); 45 | QByteArray authorsText; 46 | if(file.open(QIODevice::ReadOnly)) { 47 | authorsText = file.readAll(); 48 | file.close(); 49 | } else { 50 | printf("ERROR: Couldn't find AUTHORS file at the expected location.\n"); 51 | authorsText = "ERROR: File not found..."; 52 | } 53 | 54 | // Read COPYING data from file 55 | file.setFileName(":LICENSE"); 56 | QByteArray gplText; 57 | if(file.open(QIODevice::ReadOnly)) { 58 | gplText = file.readAll(); 59 | file.close(); 60 | } else { 61 | printf("ERROR: Couldn't find LICENSE file at the expected location.\n"); 62 | gplText = "ERROR: File not found..."; 63 | } 64 | 65 | QVBoxLayout *layout = new QVBoxLayout(); 66 | 67 | QHBoxLayout *topLayout = new QHBoxLayout(); 68 | QLabel *logo = new QLabel(); 69 | logo->setPixmap(QPixmap(":icon.png")); 70 | QLabel *title = new QLabel; 71 | title->setWordWrap(true); 72 | title->setText(tr("

LithoMaker

" 73 | "

Version " VERSION "

" 74 | "Copyright (C) 2021 Lars Muldjord
" 75 | "LithoMaker is free software released under the terms " 76 | "of the GNU General Public License. Click the license " 77 | "tab for full license information.")); 78 | topLayout->addWidget(logo); 79 | topLayout->addWidget(title); 80 | topLayout->setStretch(1, 1); 81 | topLayout->setStretch(2, 2); 82 | 83 | QLabel *releaseInfo = new QLabel(authorsText); 84 | releaseInfo->setStyleSheet("QLabel { background-color : white; }"); 85 | 86 | QScrollArea *releaseInfoScroll = new QScrollArea(); 87 | releaseInfoScroll->setWidget(releaseInfo); 88 | releaseInfoScroll->setStyleSheet("QScrollArea { background-color : white; }"); 89 | 90 | QLabel *license = new QLabel(gplText); 91 | license->setStyleSheet("QLabel { font-family : monospace; " 92 | "background-color : white; }"); 93 | licenseScroll = new QScrollArea(); 94 | licenseScroll->setStyleSheet("QScrollArea { background-color : white; }"); 95 | licenseScroll->setWidget(license); 96 | 97 | connect(licenseScroll->verticalScrollBar(), &QScrollBar::sliderPressed, this, &AboutBox::noMoreScroll); 98 | tabs = new QTabWidget(); 99 | connect(tabs, &QTabWidget::currentChanged, this, &AboutBox::checkTab); 100 | tabs->addTab(releaseInfoScroll, "Release Info"); 101 | tabs->addTab(licenseScroll, "License"); 102 | 103 | layout->addLayout(topLayout); 104 | layout->addWidget(tabs); 105 | setLayout(layout); 106 | 107 | scrollState = 0; // 0 = initial state 108 | // 1 = initiate scroll 109 | // 2 = scroll 1 step 110 | // 3 = no more scroll 111 | 112 | scrollTimer = new QTimer(); 113 | scrollTimer->setSingleShot(true); 114 | connect(scrollTimer, &QTimer::timeout, this, &AboutBox::scroll); 115 | } 116 | 117 | void AboutBox::mousePressEvent(QMouseEvent * event) 118 | { 119 | if(event) { // TODO: Perhaps do a mouse click check on the event 120 | accept(); 121 | } 122 | } 123 | 124 | void AboutBox::scroll() 125 | { 126 | switch(scrollState) { 127 | case 0 : // 0 = initial state 128 | scrollState = 1; 129 | scrollTimer->setInterval(5000); 130 | scrollTimer->start(); 131 | break; 132 | case 1 : // 1 = initiate scroll 133 | scrollState = 2; 134 | licenseScroll->verticalScrollBar()->setValue(0); 135 | scrollTimer->setInterval(200); 136 | scrollTimer->start(); 137 | break; 138 | case 2 : // 2 = scroll 1 step 139 | licenseScroll->verticalScrollBar()-> 140 | setValue(licenseScroll->verticalScrollBar()->value() + 2); 141 | if(licenseScroll->verticalScrollBar()->value() >= 142 | licenseScroll->verticalScrollBar()->maximum()) { 143 | scrollState = 0; 144 | } 145 | scrollTimer->start(); 146 | break; 147 | case 3 : // 3 = no more scroll 148 | scrollTimer->stop(); 149 | break; 150 | } 151 | } 152 | 153 | void AboutBox::noMoreScroll() 154 | { 155 | scrollState = 3; 156 | } 157 | 158 | void AboutBox::checkTab(int tabIndex) 159 | { 160 | if(tabIndex == 1) { 161 | scrollState = 0; 162 | scrollTimer->stop(); 163 | scroll(); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /src/configpages.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * configpages.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #include 28 | 29 | #include "configpages.h" 30 | #include "lineedit.h" 31 | #include "combobox.h" 32 | #include "checkbox.h" 33 | #include "slider.h" 34 | 35 | extern QSettings *settings; 36 | 37 | MainPage::MainPage(QWidget *parent) : QWidget(parent) 38 | { 39 | QPushButton *resetButton = new QPushButton(tr("Reset all to defaults")); 40 | 41 | QVBoxLayout *layout = new QVBoxLayout(); 42 | layout->addWidget(resetButton); 43 | layout->addStretch(); 44 | setLayout(layout); 45 | } 46 | 47 | RenderPage::RenderPage(QWidget *parent) : QWidget(parent) 48 | { 49 | QPushButton *resetButton = new QPushButton(tr("Reset all to defaults")); 50 | 51 | CheckBox *enableStabilizersCheckBox = new CheckBox("render", "enableStabilizers", tr("Enable stabilizers"), true); 52 | connect(resetButton, &QPushButton::clicked, enableStabilizersCheckBox, &CheckBox::resetToDefault); 53 | 54 | CheckBox *permanentStabilizersCheckBox = new CheckBox("render", "permanentStabilizers", tr("Make stabilizers permanent"), false); 55 | connect(resetButton, &QPushButton::clicked, permanentStabilizersCheckBox, &CheckBox::resetToDefault); 56 | 57 | QLabel *stabilizerThresholdLabel = new QLabel(tr("Minimum height before adding stabilizers (mm):")); 58 | LineEdit *stabilizerThresholdLineEdit = new LineEdit("render", "stabilizerThreshold", "60.0"); 59 | connect(resetButton, &QPushButton::clicked, stabilizerThresholdLineEdit, &LineEdit::resetToDefault); 60 | 61 | QLabel *stabilizerHeightFactorLabel = new QLabel(tr("Stabilizer height factor:")); 62 | LineEdit *stabilizerHeightFactorLineEdit = new LineEdit("render", "stabilizerHeightFactor", "0.15"); 63 | connect(resetButton, &QPushButton::clicked, stabilizerHeightFactorLineEdit, &LineEdit::resetToDefault); 64 | 65 | QLabel *frameSlopeFactorLabel = new QLabel(tr("Frame slope factor:")); 66 | LineEdit *frameSlopeFactorLineEdit = new LineEdit("render", "frameSlopeFactor", "0.75"); 67 | connect(resetButton, &QPushButton::clicked, frameSlopeFactorLineEdit, &LineEdit::resetToDefault); 68 | 69 | CheckBox *enableHangersCheckBox = new CheckBox("render", "enableHangers", tr("Enable hangers"), true); 70 | connect(resetButton, &QPushButton::clicked, enableHangersCheckBox, &CheckBox::resetToDefault); 71 | 72 | QLabel *hangersLabel = new QLabel(tr("Number of hangers:")); 73 | Slider *hangersSlider = new Slider("render", "hangers", 1, 4, 2, 1); 74 | connect(resetButton, &QPushButton::clicked, hangersSlider, &Slider::resetToDefault); 75 | 76 | QVBoxLayout *layout = new QVBoxLayout(); 77 | layout->addWidget(resetButton); 78 | layout->addWidget(enableStabilizersCheckBox); 79 | layout->addWidget(permanentStabilizersCheckBox); 80 | layout->addWidget(stabilizerThresholdLabel); 81 | layout->addWidget(stabilizerThresholdLineEdit); 82 | layout->addWidget(stabilizerHeightFactorLabel); 83 | layout->addWidget(stabilizerHeightFactorLineEdit); 84 | layout->addWidget(frameSlopeFactorLabel); 85 | layout->addWidget(frameSlopeFactorLineEdit); 86 | layout->addWidget(enableHangersCheckBox); 87 | layout->addWidget(hangersLabel); 88 | layout->addWidget(hangersSlider); 89 | layout->addStretch(); 90 | setLayout(layout); 91 | } 92 | 93 | ExportPage::ExportPage(QWidget *parent) : QWidget(parent) 94 | { 95 | QPushButton *resetButton = new QPushButton(tr("Reset all to defaults")); 96 | 97 | QLabel *stlFormatLabel = new QLabel(tr("STL format:")); 98 | ComboBox *stlFormatComboBox = new ComboBox("export", "stlFormat", "binary"); 99 | stlFormatComboBox->addConfigItem("Ascii", "ascii"); 100 | stlFormatComboBox->addConfigItem("Binary", "binary"); 101 | stlFormatComboBox->setFromConfig(); 102 | connect(resetButton, &QPushButton::clicked, stlFormatComboBox, &ComboBox::resetToDefault); 103 | 104 | CheckBox *alwaysOverwriteCheckBox = new CheckBox("export", "alwaysOverwrite", tr("Always overwrite existing file"), false); 105 | connect(resetButton, &QPushButton::clicked, alwaysOverwriteCheckBox, &CheckBox::resetToDefault); 106 | /* 107 | QLabel *delimiterLabel = new QLabel(tr("Delimiter:")); 108 | ComboBox *delimiterComboBox = new ComboBox("Export", "delimiter", "tab"); 109 | delimiterComboBox->addConfigItem("Tab", "tab"); 110 | delimiterComboBox->addConfigItem("Semicolon", "semicolon"); 111 | delimiterComboBox->addConfigItem("Comma", "comma"); 112 | delimiterComboBox->setFromConfig(); 113 | connect(resetButton, SIGNAL(clicked()), delimiterComboBox, SLOT(resetToDefault())); 114 | 115 | QLabel *distanceUnitLabel = new QLabel(tr("Distance unit:")); 116 | LineEdit *distanceUnitLineEdit = new LineEdit("Export", "distanceUnit", "μm"); 117 | connect(resetButton, SIGNAL(clicked()), distanceUnitLineEdit, SLOT(resetToDefault())); 118 | 119 | QLabel *timeUnitLabel = new QLabel(tr("Time unit:")); 120 | LineEdit *timeUnitLineEdit = new LineEdit("Export", "timeUnit", "s"); 121 | connect(resetButton, SIGNAL(clicked()), timeUnitLineEdit, SLOT(resetToDefault())); 122 | */ 123 | 124 | QVBoxLayout *layout = new QVBoxLayout(); 125 | layout->addWidget(resetButton); 126 | layout->addWidget(stlFormatLabel); 127 | layout->addWidget(stlFormatComboBox); 128 | layout->addWidget(alwaysOverwriteCheckBox); 129 | /* 130 | layout->addWidget(delimiterLabel); 131 | layout->addWidget(delimiterComboBox); 132 | layout->addWidget(distanceUnitLabel); 133 | layout->addWidget(distanceUnitLineEdit); 134 | layout->addWidget(timeUnitLabel); 135 | layout->addWidget(timeUnitLineEdit); 136 | */ 137 | layout->addStretch(); 138 | setLayout(layout); 139 | } 140 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LithoMaker 2 | Open source, easy to use, Lithophane software. Creates 3D lithophanes from PNG image files and exports them to STL files, ready for slicing and 3D printing. 3 | 4 | Download the latest release [here](https://github.com/muldjord/lithomaker/releases) (Appimage for Linux, Zip file for Windows). 5 | 6 | I've made a quick video tutorial. Check that out [here](https://youtu.be/Bjbdk0XiiNY). 7 | 8 | For an example lithophane sliced with PrusaSlicer and printed on a Prusa i3 MK3S+ go [here](https://youtu.be/mxQnZgb7caI). 9 | 10 | LithoMaker DOES NOT upload or process your image files online. All processing is done on your own computer requiring no internet access. I basically made this tool because most Youtube lithophane 3D printing instructions included a step that required me to upload my images to a private company for processing. I am not a fan of that, so I scratched the itch and created LithoMaker. 11 | 12 | LithoMaker is a fairly simple piece of software. It reads the input PNG image, inverts it and creates a height-mapped 3D mesh from the grayscale values. It then creates the remaining triangles needed for a 3D printable lithophane with a frame and optional hangers and printing stabilizers. The mesh is then exported as an STL file, ready for importing into a 3D printing slicer. 13 | 14 | ## Running LithoMaker 15 | ### Ubuntu Linux 16 | * Download the latest LithoMaker AppImage from [here](https://github.com/muldjord/lithomaker/releases). 17 | * Right-click the AppImage file, choose Properties, Permissions, and check "Allow executing file as program". 18 | * Double-click the AppImage file to run it. 19 | 20 | The AppImage will probably work with many other distributions as well. Download and try it out. 21 | 22 | ### Windows 23 | * Download the latest win32 zip file from [here](https://github.com/muldjord/lithomaker/releases). 24 | * Unpack the zip file. 25 | * Run the LithoMaker.exe program. 26 | 27 | ## Using LithoMaker 28 | Most of the options in LithoMaker should be pretty self-explanatory. But here are some pointers to get you started: 29 | * Options relating to the physical dimensions of the lithophane are directly visible in the main UI when starting LithoMaker. 30 | * Options that require change less often are placed under **Options->Edit Preferences...**. 31 | 32 | The default settings when running LithoMaker for the first time are great as a starting point. Adjust if needed: 33 | * *Minimum thickness* does exactly what it says. It defines the thickness of the lithophane in places where the image is brightest. The minimum is 0.8 mm. Thinner would compromize the print structure. 34 | * *Total thickness* is the *total* thickness of the lithophane *including* the minimum thickness. So basically this is the thickness that make up the darkest areas of the lithophane, corresponding to the darkest tones of the input image. I would never go above 5.0 mm on this. But you can if you absolutely insist! 35 | * *Frame border* is simply the width of the frame border in millimeters. 36 | * *Width* defines the total width of the lithophane, including the frame borders. The height is adjusted relative to this automatically using the dimensions of the input image. 37 | * *Input image filename* is the PNG image you want to convert to a lithophane. 38 | * *Output STL filename* is the export STL filename that you will later import into the 3d printing slicer. 39 | 40 | ### Render preferences 41 | * *Stabilizers* are sloped pieces of plastic that lean against the lithophane from the front and back. They provide support when printing to avoid wobbling which increases the risk of print failure. Unless you configure them to be permanent, they can be easily removed after the print is finished. 42 | * Stabilizers will only be added if the lithophane is higher than *Minimum height before adding stabilizers*. 43 | * Stabilizer height factor decides the height of the stabilizers in relation to the total height of the frame. 44 | * The frame slope factor decides how sloped the connection between the front inside of the frame is to the back inside of the frame inwards towards the image. 45 | * *Hangers* are tiny plastic loops that are placed on top of the lithophane, allowing you to thread them and suspend the print in a window frame or in front of a light source. 46 | 47 | ### Export preferences 48 | * The STL 3D mesh file format supports both an ascii and a binary format. If you don't know what that means, just leave it on *Binary*. *Binary* takes up less space and the result is exactly the same when importing the file into a slicer. 49 | * *Always overwrite existing file* simply does what it says. Normally LithoMaker asks you if you want to overwrite an existing file. Checking this will disable that dialog and simply *always* overwrite it without asking. 50 | 51 | ### Preparing a photo for conversion 52 | First of all, make sure your image is of high quality. Low quality JPEG's, often grabbed from the internet, look terrible as lithophanes due to their many JPEG artifacts. So make sure you use a high quality image with no artifacts to begin with. 53 | 54 | To get the best results, you need to do a bit of work on your photo to ensure it is optimal for conversion. The following describes a workflow which will give you optimal results using the open source image editor [Gimp](https://www.gimp.org/). 55 | * Open the photo you want to convert. 56 | * Choose **Filters->Enhance->Noise Reduction**. Set *Strength* so that it removes noisy prickling pixels without loosing too much detail. For a large image a value of 4 is good. For smaller images you need to go lower. Experiment! There are no wrong answers. The point is to smooth over surfaces of the subject, but keep details. 57 | * Choose **Colors->Auto->White balance**. This stretches the color dynamics of the image as far as it can go, meaning it will have the best possible contrast. This is hugely important to get the best looking lithophane. Don't worry if the colors look slightly odd. We remedy that in the next steps. 58 | * Now select and crop the image if you want to using the select tool and **Image->Crop to Selection**. 59 | * If your image is wider than 1500 pixels, I recommend now scaling it to 1500 pixels width using **Image->Scale Image...** and adjusting *Width* to 1500. **Don't scale it if it's already lower than 1500 pixels in width**. This step is optional of course, but keep in mind that more pixels means a more complex 3D mesh, and at some point the details are simply too tiny to print anyway, so the lithophane will just take longer to process, take up more space on your disk, and take up more memory when importing into the slicer. 60 | * Now convert the image to grayscale using **Image->Mode->Grayscale** and voila! It suddenly looks really good! 61 | * The final step is to export the image as a PNG using **File->Export As...**. 62 | 63 | ## Release notes 64 | 65 | #### Version 0.7.1 (25th Nov 2021) 66 | * Added 'PNG' to main UI input filename label 67 | * Now always converts to grayscale if color image is detected 68 | * Added default values as tooltips for all config widgets 69 | 70 | #### Version 0.7.0 (14th Nov 2021) 71 | * Added optional hangers to top of frame 72 | * Added config options for hangers 73 | * Fixed resetToDefault for sliders 74 | * Added 'elephant.png', 'hummingbird.png' and 'cheetah.png' to repository. All 3 images under public domain (I took them myself) 75 | * Now shows preferences on first run 76 | 77 | #### Version 0.6.1 (13th Nov 2021) 78 | * Corrected frame front side distance from backside 79 | * Fixed config key to 'LithoMaker' 80 | * Changed lineedits to sliders to avoid decimal locale conversion issues and for ease of use 81 | * Moved some configs from 'main' to 'render' 82 | 83 | #### Version 0.6.0 (11th Nov 2021) 84 | * Added validators for variable lineedits 85 | * Added tooltips for variable lineedits 86 | * Now checks for grayscale input image and suggests to convert if input image is in color 87 | * Now checks image resolution and suggests resizing before processing 88 | * Now disables UI buttons when processing to avoid queing multiple clicks 89 | * Fixed stabilizer meshes 90 | * Fixed lithophane backside mesh 91 | * Made it possible to make stabilizers permanent 92 | * Made more mesh variables / factors configurable 93 | 94 | #### Version 0.5.0 (7th Nov 2021) 95 | * First public release 96 | 97 | #### Version 0.0.1 (Unreleased) 98 | * Internal prototype development release 99 | 100 | #### Todo 101 | * Segment / manifold backside of lithophane to allow bending in third-party software 102 | * Segment frame to allow bending in third-party software 103 | * Move mesh related functions to separate files / classes 104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /src/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /*************************************************************************** 3 | * mainwindow.cpp 4 | * 5 | * Wed Nov 3 09:03:00 CEST 2021 6 | * Copyright 2021 Lars Muldjord 7 | * muldjordlars@gmail.com 8 | ****************************************************************************/ 9 | /* 10 | * This file is part of LithoMaker. 11 | * 12 | * LithoMaker is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * LithoMaker is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with LithoMaker; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "mainwindow.h" 33 | #include "aboutbox.h" 34 | #include "configdialog.h" 35 | #include "slider.h" 36 | 37 | extern QSettings *settings; 38 | 39 | constexpr int maxSize = 2000; 40 | 41 | MainWindow::MainWindow() 42 | { 43 | if(settings->contains("main/windowState")) { 44 | restoreGeometry(settings->value("main/windowState", "").toByteArray()); 45 | } else { 46 | setMinimumWidth(640); 47 | } 48 | 49 | if(settings->allKeys().count() == 0) { 50 | showPreferences(); 51 | } 52 | 53 | setWindowTitle("LithoMaker v" VERSION); 54 | 55 | createActions(); 56 | createMenus(); 57 | 58 | QLabel *minThicknessLabel = new QLabel(tr("Minimum thickness (mm):")); 59 | minThicknessSlider = new Slider("render", "minThickness", 8, 100, 8, 10); 60 | 61 | QLabel *totalThicknessLabel = new QLabel(tr("Total thickness (mm):")); 62 | totalThicknessSlider = new Slider("render", "totalThickness", 20, 150, 40, 10); 63 | 64 | QLabel *borderLabel = new QLabel(tr("Frame border (mm):")); 65 | borderSlider = new Slider("render", "frameBorder", 20, 500, 30, 10); 66 | 67 | QLabel *widthLabel = new QLabel(tr("Width, including frame borders (mm):")); 68 | widthSlider = new Slider("render", "width", 200, 4000, 2000, 10); 69 | 70 | QLabel *inputLabel = new QLabel(tr("Input PNG image filename:")); 71 | inputLineEdit = new QLineEdit(settings->value("main/inputFilePath", "examples/hummingbird.png").toString()); 72 | inputButton = new QPushButton(tr("...")); 73 | connect(inputButton, &QPushButton::clicked, this, &MainWindow::inputSelect); 74 | QHBoxLayout *inputLayout = new QHBoxLayout(); 75 | inputLayout->addWidget(inputLineEdit); 76 | inputLayout->addWidget(inputButton); 77 | 78 | QLabel *outputLabel = new QLabel(tr("Output STL filename:")); 79 | outputLineEdit = new QLineEdit(settings->value("main/outputFilePath", "lithophane.stl").toString()); 80 | outputButton = new QPushButton(tr("...")); 81 | connect(outputButton, &QPushButton::clicked, this, &MainWindow::outputSelect); 82 | QHBoxLayout *outputLayout = new QHBoxLayout(); 83 | outputLayout->addWidget(outputLineEdit); 84 | outputLayout->addWidget(outputButton); 85 | 86 | renderButton = new QPushButton(tr("Render and export")); 87 | connect(renderButton, &QPushButton::clicked, this, &MainWindow::createMesh); 88 | renderProgress = new QProgressBar(this); 89 | renderProgress->setMinimum(0); 90 | 91 | QVBoxLayout *layout = new QVBoxLayout(); 92 | layout->addWidget(minThicknessLabel); 93 | layout->addWidget(minThicknessSlider); 94 | layout->addWidget(totalThicknessLabel); 95 | layout->addWidget(totalThicknessSlider); 96 | layout->addWidget(borderLabel); 97 | layout->addWidget(borderSlider); 98 | layout->addWidget(widthLabel); 99 | layout->addWidget(widthSlider); 100 | layout->addWidget(inputLabel); 101 | layout->addLayout(inputLayout); 102 | layout->addWidget(outputLabel); 103 | layout->addLayout(outputLayout); 104 | layout->addWidget(renderButton); 105 | layout->addWidget(renderProgress); 106 | 107 | setCentralWidget(new QWidget()); 108 | centralWidget()->setLayout(layout); 109 | 110 | show(); 111 | } 112 | 113 | MainWindow::~MainWindow() 114 | { 115 | settings->setValue("main/windowState", saveGeometry()); 116 | settings->setValue("main/inputFilePath", inputLineEdit->text()); 117 | settings->setValue("main/outputFilePath", outputLineEdit->text()); 118 | } 119 | 120 | void MainWindow::createActions() 121 | { 122 | quitAct = new QAction("&Quit", this); 123 | quitAct->setIcon(QIcon(":quit.png")); 124 | connect(quitAct, &QAction::triggered, qApp, &QApplication::quit); 125 | 126 | preferencesAct = new QAction(tr("Edit &Preferences..."), this); 127 | preferencesAct->setIcon(QIcon(":preferences.png")); 128 | connect(preferencesAct, &QAction::triggered, this, &MainWindow::showPreferences); 129 | 130 | aboutAct = new QAction(tr("&About..."), this); 131 | aboutAct->setIcon(QIcon(":about.png")); 132 | connect(aboutAct, &QAction::triggered, this, &MainWindow::showAbout); 133 | } 134 | 135 | void MainWindow::createMenus() 136 | { 137 | fileMenu = new QMenu(tr("&File"), this); 138 | fileMenu->addAction(quitAct); 139 | 140 | optionsMenu = new QMenu(tr("&Options"), this); 141 | optionsMenu->addAction(preferencesAct); 142 | 143 | helpMenu = new QMenu(tr("&Help"), this); 144 | helpMenu->addAction(aboutAct); 145 | 146 | menuBar = new QMenuBar(); 147 | menuBar->addMenu(fileMenu); 148 | menuBar->addMenu(optionsMenu); 149 | menuBar->addMenu(helpMenu); 150 | 151 | setMenuBar(menuBar); 152 | } 153 | 154 | void MainWindow::showAbout() 155 | { 156 | // Spawn about window 157 | AboutBox aboutBox(this); 158 | aboutBox.exec(); 159 | } 160 | 161 | void MainWindow::showPreferences() 162 | { 163 | // Spawn preferences dialog 164 | ConfigDialog preferences(this); 165 | preferences.exec(); 166 | } 167 | 168 | void MainWindow::createMesh() 169 | { 170 | if(!QFileInfo::exists(inputLineEdit->text())) { 171 | QMessageBox::warning(this, tr("File not found"), tr("Input file doesn't exist. Please check filename and permissions.")); 172 | return; 173 | } 174 | 175 | if(settings->value("render/frameBorder").toFloat() * 2 > settings->value("render/width").toFloat()) { 176 | QMessageBox::warning(this, tr("Border too thick"), tr("The chosen frame border size exceeds the size of the total lithophane width. Please correct this.")); 177 | return; 178 | } 179 | 180 | disableUi(); 181 | 182 | printf("Rendering STL...\n"); 183 | polygons.clear(); 184 | QImage image(inputLineEdit->text()); 185 | if((image.width() > maxSize || image.height() > maxSize) && 186 | QMessageBox::question(this, tr("Large image"), tr("The input image is quite large. It is recommended to keep it at a resolution lower or equal to ") + QString::number(maxSize) + " x " + QString::number(maxSize) + tr(" pixels to avoid an unnecessarily complex 3D mesh. Do you want LithoMaker to resize the image before processing it?")) == QMessageBox::Yes) { 187 | if(image.width() > image.height()) { 188 | image = image.scaledToWidth(maxSize); 189 | } else { 190 | image = image.scaledToHeight(maxSize); 191 | } 192 | } 193 | if(!image.isGrayscale()) { 194 | printf("Converting image to grayscale.\n"); 195 | image = image.convertToFormat(QImage::Format_Grayscale8); 196 | } 197 | image.invertPixels(); 198 | border = settings->value("render/frameBorder").toFloat(); 199 | depthFactor = (settings->value("render/totalThickness").toFloat() - settings->value("render/minThickness").toFloat()) / 255.0; 200 | widthFactor = (settings->value("render/width").toFloat() - (border * 2)) / image.width(); 201 | float minThickness = settings->value("render/minThickness").toFloat() * -1; 202 | renderProgress->setMaximum(image.height() - 1); 203 | renderProgress->setValue(0); 204 | renderProgress->setFormat(tr("Rendering %p%")); 205 | for(int y = 0; y < image.height() - 1; ++y) { 206 | // Close left side 207 | polygons.append(getVertex(0, y, minThickness, true)); 208 | polygons.append(getVertex(0, y, getPixel(image, 0, y) * depthFactor, true)); 209 | polygons.append(getVertex(0, y + 1, getPixel(image, 0, y + 1) * depthFactor, true)); 210 | 211 | polygons.append(getVertex(0, y + 1, getPixel(image, 0, y + 1) * depthFactor, true)); 212 | polygons.append(getVertex(0, y + 1, minThickness, true)); 213 | polygons.append(getVertex(0, y, minThickness, true)); 214 | for(int x = 0; x < image.width() - 1; ++x) { 215 | if(y == 0) { 216 | // Close top 217 | polygons.append(getVertex(x + 1, 0, getPixel(image, x + 1, 0) * depthFactor, true)); 218 | polygons.append(getVertex(x, 0, getPixel(image, x, 0) * depthFactor, true)); 219 | polygons.append(getVertex(x, 0, minThickness, true)); 220 | 221 | polygons.append(getVertex(x, 0, minThickness, true)); 222 | polygons.append(getVertex(x + 1, 0, minThickness, true)); 223 | polygons.append(getVertex(x + 1, 0, getPixel(image, x + 1, 0) * depthFactor, true)); 224 | 225 | // Close bottom 226 | polygons.append(getVertex(x, image.height() - 1, minThickness, true)); 227 | polygons.append(getVertex(x, image.height() - 1, getPixel(image, x, image.height() - 1) * depthFactor, true)); 228 | polygons.append(getVertex(x + 1, image.height() - 1, getPixel(image, x + 1, image.height() - 1) * depthFactor, true)); 229 | 230 | polygons.append(getVertex(x + 1, image.height() - 1, getPixel(image, x + 1, image.height() - 1) * depthFactor, true)); 231 | polygons.append(getVertex(x + 1, image.height() - 1, minThickness, true)); 232 | polygons.append(getVertex(x, image.height() - 1, minThickness, true)); 233 | } 234 | // The lithophane heightmap 235 | polygons.append(getVertex(x, y, getPixel(image, x, y) * depthFactor, true)); 236 | polygons.append(getVertex(x + 1, y + 1, getPixel(image, x + 1, y + 1) * depthFactor, true)); 237 | polygons.append(getVertex(x, y + 1, getPixel(image, x, y + 1) * depthFactor, true)); 238 | 239 | polygons.append(getVertex(x, y, getPixel(image, x, y) * depthFactor, true)); 240 | polygons.append(getVertex(x + 1, y, getPixel(image, x + 1, y) * depthFactor, true)); 241 | polygons.append(getVertex(x + 1, y + 1, getPixel(image, x + 1, y + 1) * depthFactor, true)); 242 | } 243 | // Close right side 244 | polygons.append(getVertex(image.width() - 1, y + 1, getPixel(image, image.width() - 1, y + 1) * depthFactor, true)); 245 | polygons.append(getVertex(image.width() - 1, y, getPixel(image, image.width() - 1, y) * depthFactor, true)); 246 | polygons.append(getVertex(image.width() - 1, y, minThickness, true)); 247 | 248 | polygons.append(getVertex(image.width() - 1, y, minThickness, true)); 249 | polygons.append(getVertex(image.width() - 1, y + 1, minThickness, true)); 250 | polygons.append(getVertex(image.width() - 1, y + 1, getPixel(image, image.width() - 1, y + 1) * depthFactor, true)); 251 | renderProgress->setValue(renderProgress->value() + 1); 252 | } 253 | renderProgress->setValue(renderProgress->maximum()); 254 | renderProgress->setFormat("Ready!"); 255 | 256 | // Backside 257 | polygons.append(getVertex(0, image.height() - 1, minThickness, true)); 258 | polygons.append(getVertex(image.width() - 1, image.height() - 1, minThickness, true)); 259 | polygons.append(getVertex(0, 0, minThickness, true)); 260 | 261 | polygons.append(getVertex(image.width() - 1, image.height() - 1, minThickness, true)); 262 | polygons.append(getVertex(image.width() - 1, 0, minThickness, true)); 263 | polygons.append(getVertex(0, 0, minThickness, true)); 264 | 265 | // Stabilizers 266 | double totalHeight = ((border * 2) + (image.height() * widthFactor)); 267 | double stabilizerHeightFactor = settings->value("render/stabilizerHeightFactor", 0.15).toDouble(); 268 | if(settings->value("render/enableStabilizers", true).toBool() && 269 | totalHeight > settings->value("render/stabilizerThreshold", 60.0).toDouble()) { 270 | polygons.append(addStabilizer(0, ((border * 2) + (image.height() * widthFactor)) * stabilizerHeightFactor)); 271 | polygons.append(addStabilizer(settings->value("render/width").toFloat() - (border < 4?border:4), totalHeight * stabilizerHeightFactor)); 272 | } 273 | 274 | // Frame 275 | polygons.append(addFrame(settings->value("render/width").toFloat(), (border * 2) + (image.height() * widthFactor))); 276 | 277 | // Hanger(s) 278 | if(settings->value("render/enableHangers", true).toBool()) { 279 | polygons.append(addHangers(settings->value("render/width").toFloat(), (border * 2) + (image.height() * widthFactor))); 280 | } 281 | 282 | printf("Rendering finished...\n"); 283 | exportStl(); 284 | } 285 | 286 | void MainWindow::exportStl() 287 | { 288 | if(polygons.isEmpty()) { 289 | QMessageBox::warning(this, tr("Empty STL buffer"), tr("There is currently no rendered lithophane in the STL buffer. You need to render one before you can export it.")); 290 | enableUi(); 291 | return; 292 | } 293 | if(QFileInfo::exists(outputLineEdit->text()) && !settings->value("export/alwaysOverwrite", false).toBool() && QMessageBox::question(this, tr("Overwrite file?"), tr("The output STL file already exists. Do you want to overwrite it?")) != QMessageBox::Yes) { 294 | enableUi(); 295 | return; 296 | } 297 | 298 | printf("Exporting to file: '%s'... ", outputLineEdit->text().toStdString().c_str()); 299 | 300 | if(settings->value("export/stlFormat", "binary").toString() == "binary") { 301 | // Export as binary 302 | std::ofstream out(outputLineEdit->text().toStdString(), std::ios::binary); 303 | if(out.good()) { 304 | char title[80]; 305 | memset(title, 0, 80); 306 | strcpy(title, "lithophane"); 307 | out.write((char *)&title, 80); 308 | quint32 polCount = polygons.length() / 3; 309 | out.write((char *)&polCount, sizeof(quint32));; 310 | quint16 attrByteCount = 0; 311 | for(int a = 0; a < polygons.length(); a += 3) { 312 | float normal = 0.0; 313 | out.write((char *)&normal, sizeof(float)); 314 | out.write((char *)&normal, sizeof(float)); 315 | out.write((char *)&normal, sizeof(float)); 316 | float x, y, z; 317 | x = polygons.at(a).x(); 318 | y = polygons.at(a).y(); 319 | z = polygons.at(a).z(); 320 | out.write((char *)&x, sizeof(float)); 321 | out.write((char *)&y, sizeof(float)); 322 | out.write((char *)&z, sizeof(float)); 323 | x = polygons.at(a + 1).x(); 324 | y = polygons.at(a + 1).y(); 325 | z = polygons.at(a + 1).z(); 326 | out.write((char *)&x, sizeof(float)); 327 | out.write((char *)&y, sizeof(float)); 328 | out.write((char *)&z, sizeof(float)); 329 | x = polygons.at(a + 2).x(); 330 | y = polygons.at(a + 2).y(); 331 | z = polygons.at(a + 2).z(); 332 | out.write((char *)&x, sizeof(float)); 333 | out.write((char *)&y, sizeof(float)); 334 | out.write((char *)&z, sizeof(float)); 335 | out.write((char *)&attrByteCount, sizeof(quint16)); 336 | } 337 | out.close(); 338 | printf("Success!\n"); 339 | QMessageBox::information(this, tr("Export succeeded"), tr("The binary STL was successfully exported. You can now import it in your preferred 3D printing slicer.")); 340 | } else { 341 | printf("Failed!\n"); 342 | QMessageBox::warning(this, tr("Export failed"), tr("File could not be opened for writing. Please check export filename and try again.")); 343 | } 344 | } else if(settings->value("export/stlFormat", "binary").toString() == "ascii") { 345 | // Export as ascii 346 | QFile stlFile(outputLineEdit->text()); 347 | if(stlFile.open(QIODevice::WriteOnly)) { 348 | stlFile.write("solid lithophane\n"); 349 | for(int a = 0; a < polygons.length(); a += 3) { 350 | stlFile.write("facet normal 0.0 0.0 0.0\n"); 351 | stlFile.write("\touter loop\n"); 352 | stlFile.write("\t\tvertex " + QByteArray::number(polygons.at(a).x(), 'g') + " " + QByteArray::number(polygons.at(a).y(), 'g') + " " + QByteArray::number(polygons.at(a).z(), 'g') + "\n"); 353 | stlFile.write("\t\tvertex " + QByteArray::number(polygons.at(a + 1).x(), 'g') + " " + QByteArray::number(polygons.at(a + 1).y(), 'g') + " " + QByteArray::number(polygons.at(a + 1).z(), 'g') + "\n"); 354 | stlFile.write("\t\tvertex " + QByteArray::number(polygons.at(a + 2).x(), 'g') + " " + QByteArray::number(polygons.at(a + 2).y(), 'g') + " " + QByteArray::number(polygons.at(a + 2).z(), 'g') + "\n"); 355 | stlFile.write("\tendloop\n"); 356 | stlFile.write("endfacet\n"); 357 | } 358 | stlFile.write("endsolid\n"); 359 | stlFile.close(); 360 | printf("Success!\n"); 361 | QMessageBox::information(this, tr("Export succeeded"), tr("The ascii STL was successfully exported. You can now import it in your preferred 3D printing slicer.")); 362 | } else { 363 | printf("Failed!\n"); 364 | QMessageBox::warning(this, tr("Export failed"), tr("File could not be opened for writing. Please check export filename and try again.")); 365 | } 366 | } 367 | enableUi(); 368 | } 369 | 370 | QList MainWindow::addFrame(const float &width, const float &height) 371 | { 372 | float minThickness = settings->value("render/minThickness").toFloat(); 373 | float depth = settings->value("render/totalThickness").toFloat() - minThickness; 374 | float frameSlope = depth * settings->value("render/frameSlopeFactor", "0.75").toFloat(); 375 | 376 | QList frame; 377 | frame.append(getVertex(width, height, - minThickness)); 378 | frame.append(getVertex(0.000000, height, - minThickness)); 379 | frame.append(getVertex(0.000000, height, depth)); 380 | 381 | frame.append(getVertex(width, height, - minThickness)); 382 | frame.append(getVertex(0.000000, height, depth)); 383 | frame.append(getVertex(width, height, depth)); 384 | 385 | frame.append(getVertex(width - border - frameSlope, border + frameSlope, 0.000000)); 386 | frame.append(getVertex(width - border - frameSlope, height - border - frameSlope, 0.000000)); 387 | frame.append(getVertex(border + frameSlope, height - border - frameSlope, 0.000000)); 388 | 389 | frame.append(getVertex(width - border - frameSlope, border + frameSlope, 0.000000)); 390 | frame.append(getVertex(border + frameSlope, height - border - frameSlope, 0.000000)); 391 | frame.append(getVertex(border + frameSlope, border + frameSlope, 0.000000)); 392 | 393 | frame.append(getVertex(0.000000, 0.000000, depth)); 394 | frame.append(getVertex(0.000000, height, depth)); 395 | frame.append(getVertex(0.000000, height, - minThickness)); 396 | 397 | frame.append(getVertex(0.000000, 0.000000, depth)); 398 | frame.append(getVertex(0.000000, height, - minThickness)); 399 | frame.append(getVertex(0.000000, 0.000000, - minThickness)); 400 | 401 | frame.append(getVertex(0.000000, 0.000000, - minThickness)); 402 | frame.append(getVertex(width, 0.000000, - minThickness)); 403 | frame.append(getVertex(width, 0.000000, depth)); 404 | 405 | frame.append(getVertex(0.000000, 0.000000, - minThickness)); 406 | frame.append(getVertex(width, 0.000000, depth)); 407 | frame.append(getVertex(0.000000, 0.000000, depth)); 408 | 409 | frame.append(getVertex(width, 0.000000, - minThickness)); 410 | frame.append(getVertex(width, height, - minThickness)); 411 | frame.append(getVertex(width, height, depth)); 412 | 413 | frame.append(getVertex(width, 0.000000, - minThickness)); 414 | frame.append(getVertex(width, height, depth)); 415 | frame.append(getVertex(width, 0.000000, depth)); 416 | 417 | frame.append(getVertex(0.000000, 0.000000, - minThickness)); 418 | frame.append(getVertex(0.000000, height, - minThickness)); 419 | frame.append(getVertex(width, height, - minThickness)); 420 | 421 | frame.append(getVertex(0.000000, 0.000000, - minThickness)); 422 | frame.append(getVertex(width, height, - minThickness)); 423 | frame.append(getVertex(width, 0.000000, - minThickness)); 424 | 425 | frame.append(getVertex(border, border, depth)); 426 | frame.append(getVertex(border, height - border, depth)); 427 | frame.append(getVertex(0.000000, height, depth)); 428 | 429 | frame.append(getVertex(border, border, depth)); 430 | frame.append(getVertex(0.000000, height, depth)); 431 | frame.append(getVertex(0.000000, 0.000000, depth)); 432 | 433 | frame.append(getVertex(width - border, height - border, depth)); 434 | frame.append(getVertex(width - border, border, depth)); 435 | frame.append(getVertex(width, 0.000000, depth)); 436 | 437 | frame.append(getVertex(width - border, height - border, depth)); 438 | frame.append(getVertex(width, 0.000000, depth)); 439 | frame.append(getVertex(width, height, depth)); 440 | 441 | frame.append(getVertex(border, height - border, depth)); 442 | frame.append(getVertex(width - border, height - border, depth)); 443 | frame.append(getVertex(width, height, depth)); 444 | 445 | frame.append(getVertex(border, height - border, depth)); 446 | frame.append(getVertex(width, height, depth)); 447 | frame.append(getVertex(0.000000, height, depth)); 448 | 449 | frame.append(getVertex(width - border, border, depth)); 450 | frame.append(getVertex(border, border, depth)); 451 | frame.append(getVertex(0.000000, 0.000000, depth)); 452 | 453 | frame.append(getVertex(width - border, border, depth)); 454 | frame.append(getVertex(0.000000, 0.000000, depth)); 455 | frame.append(getVertex(width, 0.000000, depth)); 456 | 457 | frame.append(getVertex(border + frameSlope, border + frameSlope, 0.000000)); 458 | frame.append(getVertex(border + frameSlope, height - border - frameSlope, 0.000000)); 459 | frame.append(getVertex(border, height - border, depth)); 460 | 461 | frame.append(getVertex(border + frameSlope, border + frameSlope, 0.000000)); 462 | frame.append(getVertex(border, height - border, depth)); 463 | frame.append(getVertex(border, border, depth)); 464 | 465 | frame.append(getVertex(width - border - frameSlope, height - border - frameSlope, 0.000000)); 466 | frame.append(getVertex(width - border - frameSlope, border + frameSlope, 0.000000)); 467 | frame.append(getVertex(width - border, border, depth)); 468 | 469 | frame.append(getVertex(width - border - frameSlope, height - border - frameSlope, 0.000000)); 470 | frame.append(getVertex(width - border, border, depth)); 471 | frame.append(getVertex(width - border, height - border, depth)); 472 | 473 | frame.append(getVertex(border + frameSlope, height - border - frameSlope, 0.000000)); 474 | frame.append(getVertex(width - border - frameSlope, height - border - frameSlope, 0.000000)); 475 | frame.append(getVertex(width - border, height - border, depth)); 476 | 477 | frame.append(getVertex(border + frameSlope, height - border - frameSlope, 0.000000)); 478 | frame.append(getVertex(width - border, height - border, depth)); 479 | frame.append(getVertex(border, height - border, depth)); 480 | 481 | frame.append(getVertex(width - border - frameSlope, border + frameSlope, 0.000000)); 482 | frame.append(getVertex(border + frameSlope, border + frameSlope, 0.000000)); 483 | frame.append(getVertex(border, border, depth)); 484 | 485 | frame.append(getVertex(width - border - frameSlope, border + frameSlope, 0.000000)); 486 | frame.append(getVertex(border, border, depth)); 487 | frame.append(getVertex(width - border, border, depth)); 488 | 489 | return frame; 490 | } 491 | 492 | QList MainWindow::addHangers(const float &width, const float &height) 493 | { 494 | int noOfHangers = settings->value("render/hangers").toInt(); 495 | float xDelta = (width / noOfHangers) / 2.0; 496 | float x = xDelta - 4.5; // 4.5 is half the width of a hanger 497 | 498 | QList hangers; 499 | for(int a = 0; a < noOfHangers; a++) { 500 | hangers.append(getVertex(x + 3, height, 0.000000)); 501 | hangers.append(getVertex(x, height, 0.000000)); 502 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 503 | 504 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 505 | hangers.append(getVertex(x + 6, height + 3, 0.000000)); 506 | hangers.append(getVertex(x + 9, height, 0.000000)); 507 | 508 | hangers.append(getVertex(x + 9, height, 0.000000)); 509 | hangers.append(getVertex(x + 6, height, 0.000000)); 510 | hangers.append(getVertex(x + 5, height + 1, 0.000000)); 511 | 512 | hangers.append(getVertex(x + 4, height + 1, 0.000000)); 513 | hangers.append(getVertex(x + 3, height, 0.000000)); 514 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 515 | 516 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 517 | hangers.append(getVertex(x + 9, height, 0.000000)); 518 | hangers.append(getVertex(x + 5, height + 1, 0.000000)); 519 | 520 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 521 | hangers.append(getVertex(x + 5, height + 1, 0.000000)); 522 | hangers.append(getVertex(x + 4, height + 1, 0.000000)); 523 | 524 | hangers.append(getVertex(x + 3, height + 3, 2)); 525 | hangers.append(getVertex(x, height, 2)); 526 | hangers.append(getVertex(x + 3, height, 2)); 527 | 528 | hangers.append(getVertex(x + 3, height + 3, 2)); 529 | hangers.append(getVertex(x + 3, height, 2)); 530 | hangers.append(getVertex(x + 4, height + 1, 2)); 531 | 532 | hangers.append(getVertex(x + 9, height, 2)); 533 | hangers.append(getVertex(x + 6, height + 3, 2)); 534 | hangers.append(getVertex(x + 3, height + 3, 2)); 535 | 536 | hangers.append(getVertex(x + 5, height + 1, 2)); 537 | hangers.append(getVertex(x + 6, height, 2)); 538 | hangers.append(getVertex(x + 9, height, 2)); 539 | 540 | hangers.append(getVertex(x + 3, height + 3, 2)); 541 | hangers.append(getVertex(x + 4, height + 1, 2)); 542 | hangers.append(getVertex(x + 5, height + 1, 2)); 543 | 544 | hangers.append(getVertex(x + 5, height + 1, 2)); 545 | hangers.append(getVertex(x + 9, height, 2)); 546 | hangers.append(getVertex(x + 3, height + 3, 2)); 547 | 548 | hangers.append(getVertex(x + 5, height + 1, 0.000000)); 549 | hangers.append(getVertex(x + 6, height, 0.000000)); 550 | hangers.append(getVertex(x + 6, height, 2)); 551 | 552 | hangers.append(getVertex(x + 5, height + 1, 0.000000)); 553 | hangers.append(getVertex(x + 6, height, 2)); 554 | hangers.append(getVertex(x + 5, height + 1, 2)); 555 | 556 | hangers.append(getVertex(x + 9, height, 0.000000)); 557 | hangers.append(getVertex(x + 6, height + 3, 0.000000)); 558 | hangers.append(getVertex(x + 6, height + 3, 2)); 559 | 560 | hangers.append(getVertex(x + 9, height, 0.000000)); 561 | hangers.append(getVertex(x + 6, height + 3, 2)); 562 | hangers.append(getVertex(x + 9, height, 2)); 563 | 564 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 565 | hangers.append(getVertex(x, height, 0.000000)); 566 | hangers.append(getVertex(x, height, 2)); 567 | 568 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 569 | hangers.append(getVertex(x, height, 2)); 570 | hangers.append(getVertex(x + 3, height + 3, 2)); 571 | 572 | hangers.append(getVertex(x, height, 0.000000)); 573 | hangers.append(getVertex(x + 3, height, 0.000000)); 574 | hangers.append(getVertex(x + 3, height, 2)); 575 | 576 | hangers.append(getVertex(x, height, 0.000000)); 577 | hangers.append(getVertex(x + 3, height, 2)); 578 | hangers.append(getVertex(x, height, 2)); 579 | 580 | hangers.append(getVertex(x + 4, height + 1, 0.000000)); 581 | hangers.append(getVertex(x + 5, height + 1, 0.000000)); 582 | hangers.append(getVertex(x + 5, height + 1, 2)); 583 | 584 | hangers.append(getVertex(x + 4, height + 1, 0.000000)); 585 | hangers.append(getVertex(x + 5, height + 1, 2)); 586 | hangers.append(getVertex(x + 4, height + 1, 2)); 587 | 588 | hangers.append(getVertex(x + 6, height, 0.000000)); 589 | hangers.append(getVertex(x + 9, height, 0.000000)); 590 | hangers.append(getVertex(x + 9, height, 2)); 591 | 592 | hangers.append(getVertex(x + 6, height, 0.000000)); 593 | hangers.append(getVertex(x + 9, height, 2)); 594 | hangers.append(getVertex(x + 6, height, 2)); 595 | 596 | hangers.append(getVertex(x + 6, height + 3, 0.000000)); 597 | hangers.append(getVertex(x + 3, height + 3, 0.000000)); 598 | hangers.append(getVertex(x + 3, height + 3, 2)); 599 | 600 | hangers.append(getVertex(x + 6, height + 3, 0.000000)); 601 | hangers.append(getVertex(x + 3, height + 3, 2)); 602 | hangers.append(getVertex(x + 6, height + 3, 2)); 603 | 604 | hangers.append(getVertex(x + 3, height, 0.000000)); 605 | hangers.append(getVertex(x + 4, height + 1, 0.000000)); 606 | hangers.append(getVertex(x + 4, height + 1, 2)); 607 | 608 | hangers.append(getVertex(x + 3, height, 0.000000)); 609 | hangers.append(getVertex(x + 4, height + 1, 2)); 610 | hangers.append(getVertex(x + 3, height, 2)); 611 | 612 | // Move over to the next hanger placement 613 | x += xDelta * 2; 614 | } 615 | 616 | return hangers; 617 | } 618 | 619 | QList MainWindow::addStabilizer(const float &x, const float &height) 620 | { 621 | float depth = height * 0.5; 622 | float z; 623 | 624 | QList stabilizer; 625 | 626 | double zDelta = (settings->value("render/permanentStabilizers", false).toBool()?1.0:0.0); 627 | 628 | // Front 629 | z = settings->value("render/totalThickness").toFloat() - settings->value("render/minThickness").toFloat(); 630 | stabilizer.append(getVertex(x, 0.000000, z + 1 - zDelta)); 631 | stabilizer.append(getVertex(x, 0.000000, z + depth)); 632 | stabilizer.append(getVertex(x, height, z + 3)); 633 | 634 | stabilizer.append(getVertex(x, height, z + 3)); 635 | stabilizer.append(getVertex(x, height, z + 1 - zDelta)); 636 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 637 | 638 | stabilizer.append(getVertex(x, height, z + 3)); 639 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 640 | stabilizer.append(getVertex(x, 0.000000, z + 1 - zDelta)); 641 | 642 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 3)); 643 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + depth)); 644 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 645 | 646 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z + 1 - zDelta)); 647 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 1 - zDelta)); 648 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 3)); 649 | 650 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 651 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z + 1 - zDelta)); 652 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 3)); 653 | 654 | stabilizer.append(getVertex(x + 1, height, z + 1 - zDelta)); 655 | stabilizer.append(getVertex(x, height, z + 1 - zDelta)); 656 | stabilizer.append(getVertex(x, height, z + 3)); 657 | 658 | stabilizer.append(getVertex(x, height, z + 3)); 659 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 3)); 660 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 1 - zDelta)); 661 | 662 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 663 | stabilizer.append(getVertex(x + 1, height, z + 1 - zDelta)); 664 | stabilizer.append(getVertex(x, height, z + 3)); 665 | 666 | stabilizer.append(getVertex(x, height, z + 3)); 667 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 1 - zDelta)); 668 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 669 | 670 | stabilizer.append(getVertex(x, 0.000000, z + depth)); 671 | stabilizer.append(getVertex(x, 0.000000, z + 1 - zDelta)); 672 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 673 | 674 | stabilizer.append(getVertex(x, 0.000000, z + depth)); 675 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 676 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + depth)); 677 | 678 | stabilizer.append(getVertex(x, height, z + 3)); 679 | stabilizer.append(getVertex(x, 0.000000, z + depth)); 680 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + depth)); 681 | 682 | stabilizer.append(getVertex(x, height, z + 3)); 683 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + depth)); 684 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 3)); 685 | 686 | stabilizer.append(getVertex(x + 1, height - 1, z + 1 - zDelta)); 687 | stabilizer.append(getVertex(x + 1, height, z + 1 - zDelta)); 688 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 689 | 690 | stabilizer.append(getVertex(x + 1, height - 1, z + 1 - zDelta)); 691 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 692 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 693 | 694 | stabilizer.append(getVertex(x + 1, height - 1, z)); 695 | stabilizer.append(getVertex(x + 1, height, z)); 696 | stabilizer.append(getVertex(x, height, z)); 697 | 698 | stabilizer.append(getVertex(x + 1, height - 1, z)); 699 | stabilizer.append(getVertex(x, height, z)); 700 | stabilizer.append(getVertex(x, height - 1, z)); 701 | 702 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 703 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 704 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 705 | 706 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 707 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 708 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 709 | 710 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 1 - zDelta)); 711 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z + 1 - zDelta)); 712 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 713 | 714 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 1 - zDelta)); 715 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 716 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 717 | 718 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 719 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z + 1 - zDelta)); 720 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 721 | 722 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 723 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 724 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 725 | 726 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 727 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z + 1 - zDelta)); 728 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 729 | 730 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 731 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 732 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 733 | 734 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 735 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 736 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z + 1 - zDelta)); 737 | 738 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 739 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z + 1 - zDelta)); 740 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 741 | 742 | stabilizer.append(getVertex(x, height, z + 1 - zDelta)); 743 | stabilizer.append(getVertex(x + 1, height, z + 1 - zDelta)); 744 | stabilizer.append(getVertex(x + 1, height, z)); 745 | 746 | stabilizer.append(getVertex(x, height, z + 1 - zDelta)); 747 | stabilizer.append(getVertex(x + 1, height, z)); 748 | stabilizer.append(getVertex(x, height, z)); 749 | 750 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 751 | stabilizer.append(getVertex(x, height, z + 1 - zDelta)); 752 | stabilizer.append(getVertex(x, height, z)); 753 | 754 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 755 | stabilizer.append(getVertex(x, height, z)); 756 | stabilizer.append(getVertex(x, height - 1, z)); 757 | 758 | stabilizer.append(getVertex(x + 1, height, z + 1 - zDelta)); 759 | stabilizer.append(getVertex(x + 1, height - 1, z + 1 - zDelta)); 760 | stabilizer.append(getVertex(x + 1, height - 1, z)); 761 | 762 | stabilizer.append(getVertex(x + 1, height, z + 1 - zDelta)); 763 | stabilizer.append(getVertex(x + 1, height - 1, z)); 764 | stabilizer.append(getVertex(x + 1, height, z)); 765 | 766 | stabilizer.append(getVertex(x + 1, height - 1, z)); 767 | stabilizer.append(getVertex(x + 1, height - 1, z + 1 - zDelta)); 768 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 769 | 770 | stabilizer.append(getVertex(x + 1, height - 1, z)); 771 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 772 | stabilizer.append(getVertex(x, height - 1, z)); 773 | 774 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 775 | stabilizer.append(getVertex(x, 0.000000, z + 1 - zDelta)); 776 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 777 | 778 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 779 | stabilizer.append(getVertex(x + 1, height - 1, z + 1 - zDelta)); 780 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 781 | 782 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 783 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z + 1 - zDelta)); 784 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 785 | 786 | stabilizer.append(getVertex(x, height - 1, z + 1 - zDelta)); 787 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z + 1 - zDelta)); 788 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z + 1 - zDelta)); 789 | 790 | // Back 791 | z = (settings->value("render/minThickness").toFloat() * -1); 792 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - 1 + zDelta)); 793 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - depth)); 794 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 795 | 796 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 797 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 1 + zDelta)); 798 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 799 | 800 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 801 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 802 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - 1 + zDelta)); 803 | 804 | stabilizer.append(getVertex(x, height, z - 3)); 805 | stabilizer.append(getVertex(x, 0.000000, z - depth)); 806 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 807 | 808 | stabilizer.append(getVertex(x, height - 1, z - 1 + zDelta)); 809 | stabilizer.append(getVertex(x, height, z - 1 + zDelta)); 810 | stabilizer.append(getVertex(x, height, z - 3)); 811 | 812 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 813 | stabilizer.append(getVertex(x, height - 1, z - 1 + zDelta)); 814 | stabilizer.append(getVertex(x, height, z - 3)); 815 | 816 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z - 1 + zDelta)); 817 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 1 + zDelta)); 818 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 819 | 820 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 821 | stabilizer.append(getVertex(x, height, z - 3)); 822 | stabilizer.append(getVertex(x, height, z - 1 + zDelta)); 823 | 824 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 825 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z - 1 + zDelta)); 826 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 827 | 828 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 829 | stabilizer.append(getVertex(x, height, z - 1 + zDelta)); 830 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 831 | 832 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - depth)); 833 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - 1 + zDelta)); 834 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 835 | 836 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - depth)); 837 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 838 | stabilizer.append(getVertex(x, 0.000000, z - depth)); 839 | 840 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 841 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - depth)); 842 | stabilizer.append(getVertex(x, 0.000000, z - depth)); 843 | 844 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 3)); 845 | stabilizer.append(getVertex(x, 0.000000, z - depth)); 846 | stabilizer.append(getVertex(x, height, z - 3)); 847 | 848 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z - 1 + zDelta)); 849 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z - 1 + zDelta)); 850 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 851 | 852 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z - 1 + zDelta)); 853 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 854 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 855 | 856 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 857 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 858 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 859 | 860 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 861 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 862 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 863 | 864 | stabilizer.append(getVertex(x + 1, height - 1, z)); 865 | stabilizer.append(getVertex(x, height - 1, z)); 866 | stabilizer.append(getVertex(x, height, z)); 867 | 868 | stabilizer.append(getVertex(x + 1, height - 1, z)); 869 | stabilizer.append(getVertex(x, height, z)); 870 | stabilizer.append(getVertex(x + 1, height, z)); 871 | 872 | stabilizer.append(getVertex(x, height, z - 1 + zDelta)); 873 | stabilizer.append(getVertex(x, height - 1, z - 1 + zDelta)); 874 | stabilizer.append(getVertex(x, height - 1, z)); 875 | 876 | stabilizer.append(getVertex(x, height, z - 1 + zDelta)); 877 | stabilizer.append(getVertex(x, height - 1, z)); 878 | stabilizer.append(getVertex(x, height, z)); 879 | 880 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 881 | stabilizer.append(getVertex(x, height, z - 1 + zDelta)); 882 | stabilizer.append(getVertex(x, height, z)); 883 | 884 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 885 | stabilizer.append(getVertex(x, height, z)); 886 | stabilizer.append(getVertex(x + 1, height, z)); 887 | 888 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 889 | stabilizer.append(getVertex(x + 1, height, z - 1 + zDelta)); 890 | stabilizer.append(getVertex(x + 1, height, z)); 891 | 892 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 893 | stabilizer.append(getVertex(x + 1, height, z)); 894 | stabilizer.append(getVertex(x + 1, height - 1, z)); 895 | 896 | stabilizer.append(getVertex(x + 1, height - 1, z)); 897 | stabilizer.append(getVertex(x, height - 1, z)); 898 | stabilizer.append(getVertex(x, height - 1, z - 1 + zDelta)); 899 | 900 | stabilizer.append(getVertex(x + 1, height - 1, z)); 901 | stabilizer.append(getVertex(x, height - 1, z - 1 + zDelta)); 902 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 903 | 904 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 1 + zDelta)); 905 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z - 1 + zDelta)); 906 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 907 | 908 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 1 + zDelta)); 909 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 910 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 911 | 912 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 913 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z - 1 + zDelta)); 914 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 915 | 916 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 917 | stabilizer.append(getVertex(x + (border < 4?border:4), height, z)); 918 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 919 | 920 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z - 1 + zDelta)); 921 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z - 1 + zDelta)); 922 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 923 | 924 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z - 1 + zDelta)); 925 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 926 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height, z)); 927 | 928 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 929 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z - 1 + zDelta)); 930 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 931 | 932 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z)); 933 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 934 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z)); 935 | 936 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 937 | stabilizer.append(getVertex(x + (border < 4?border:4), 0.000000, z - 1 + zDelta)); 938 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 939 | 940 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 941 | stabilizer.append(getVertex(x + (border < 4?border:4) - 1, height - 1, z - 1 + zDelta)); 942 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 943 | 944 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 945 | stabilizer.append(getVertex(x, height - 1, z - 1 + zDelta)); 946 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 947 | 948 | stabilizer.append(getVertex(x + (border < 4?border:4), height - 1, z - 1 + zDelta)); 949 | stabilizer.append(getVertex(x + 1, height - 1, z - 1 + zDelta)); 950 | stabilizer.append(getVertex(x, 0.000000, z - 1 + zDelta)); 951 | 952 | return stabilizer; 953 | } 954 | 955 | int MainWindow::getPixel(const QImage &image, const int &x, const int &y) 956 | { 957 | return image.pixelColor(x, image.height() - 1 - y).red(); 958 | } 959 | 960 | QVector3D MainWindow::getVertex(float x, float y, float z, const bool &scale) 961 | { 962 | float add = 0.0; 963 | if(scale) { 964 | x = x * widthFactor; 965 | y = y * widthFactor; 966 | //z = z * widthFactor; 967 | add = border; 968 | } 969 | return QVector3D(x + add, y + add, z); 970 | } 971 | 972 | void MainWindow::inputSelect() 973 | { 974 | QString selectedFile = QFileDialog::getOpenFileName(this, tr("Select input file"), QFileInfo(inputLineEdit->text()).absolutePath(), "*.png"); 975 | if(selectedFile != QByteArray()) { 976 | inputLineEdit->setText(selectedFile); 977 | } 978 | } 979 | 980 | void MainWindow::outputSelect() 981 | { 982 | QString selectedFile = QFileDialog::getSaveFileName(this, tr("Enter output file"), QFileInfo(outputLineEdit->text()).absolutePath(), "*.stl"); 983 | if(selectedFile != QByteArray()) { 984 | if(selectedFile.right(4).toLower() != ".stl") { 985 | selectedFile.append(".stl"); 986 | } 987 | outputLineEdit->setText(selectedFile); 988 | } 989 | } 990 | 991 | void MainWindow::enableUi() 992 | { 993 | inputButton->setEnabled(true); 994 | outputButton->setEnabled(true); 995 | renderButton->setEnabled(true); 996 | } 997 | 998 | void MainWindow::disableUi() 999 | { 1000 | inputButton->setEnabled(false); 1001 | outputButton->setEnabled(false); 1002 | renderButton->setEnabled(false); 1003 | } 1004 | --------------------------------------------------------------------------------