├── .envrc ├── .gitignore ├── .gitlab-ci.yml ├── LICENSE.txt ├── MiniZincIDE.pro ├── MiniZincIDE ├── CHANGES ├── MiniZincIDE.pri ├── MiniZincIDE.pro ├── README.txt ├── cheat_sheet.mzn ├── checkupdatedialog.cpp ├── checkupdatedialog.h ├── checkupdatedialog.ui ├── codechecker.cpp ├── codechecker.h ├── codeeditor.cpp ├── codeeditor.h ├── configwindow.cpp ├── configwindow.h ├── configwindow.ui ├── dark_mode.css ├── darkmodenotifier.cpp ├── darkmodenotifier.h ├── darkmodenotifier_macos.mm ├── elapsedtimer.cpp ├── elapsedtimer.h ├── esclineedit.cpp ├── esclineedit.h ├── exception.h ├── extraparamdialog.cpp ├── extraparamdialog.h ├── extraparamdialog.ui ├── fzndoc.cpp ├── fzndoc.h ├── gotolinedialog.cpp ├── gotolinedialog.h ├── gotolinedialog.ui ├── highlighter.cpp ├── highlighter.h ├── history.cpp ├── history.h ├── ide.cpp ├── ide.h ├── ideutils.cpp ├── ideutils.h ├── images │ ├── about.html │ ├── application-certificate.png │ ├── applications-system.png │ ├── coursera.png │ ├── coursera@2x.png │ ├── document-new.png │ ├── document-open.png │ ├── document-save.png │ ├── edit-copy.png │ ├── edit-cut.png │ ├── edit-find-replace.png │ ├── edit-paste.png │ ├── edit-redo.png │ ├── edit-undo.png │ ├── folder.png │ ├── format-indent-less.png │ ├── format-indent-more.png │ ├── media-playback-start.png │ ├── media-playback-stop.png │ ├── mznicon.png │ ├── package-x-generic.png │ └── process-stop.png ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── minizincide.qrc ├── moocsubmission.cpp ├── moocsubmission.h ├── moocsubmission.ui ├── mznide-makefile.plist ├── mznide-xcode.plist ├── mznide.icns ├── mznide.ico ├── outputdockwidget.cpp ├── outputdockwidget.h ├── outputwidget.cpp ├── outputwidget.h ├── outputwidget.ui ├── paramdialog.cpp ├── paramdialog.h ├── paramdialog.ui ├── preferencesdialog.cpp ├── preferencesdialog.h ├── preferencesdialog.ui ├── process.cpp ├── process.h ├── profilecompilation.cpp ├── profilecompilation.h ├── project.cpp ├── project.h ├── projectbrowser.cpp ├── projectbrowser.h ├── projectbrowser.ui ├── server.cpp ├── server.h ├── server │ ├── connector.js │ └── index.html ├── solver.cpp ├── solver.h ├── theme.cpp └── theme.h ├── README.md ├── TODO.txt ├── cp-profiler ├── README.md ├── cp-profiler.pri ├── cp-profiler.pro ├── docs │ └── images │ │ ├── doc_conductor1.png │ │ ├── doc_ss_analysis.png │ │ ├── doc_ss_analysis_hist.png │ │ ├── doc_traditional_collapsed.png │ │ └── doc_traditional_interface.png └── src │ ├── cpp-integration │ ├── README.md │ ├── connector.hpp │ └── message.hpp │ ├── cpprofiler │ ├── analysis │ │ ├── histogram_scene.cpp │ │ ├── histogram_scene.hh │ │ ├── merge_window.cpp │ │ ├── merge_window.hh │ │ ├── merging │ │ │ ├── merge_result.hh │ │ │ ├── pentagon_list_widget.hh │ │ │ ├── pentagon_rect.cpp │ │ │ └── pentagon_rect.hh │ │ ├── nogood_analysis_dialog.hh │ │ ├── path_comp.cpp │ │ ├── path_comp.hh │ │ ├── pattern_rect.cpp │ │ ├── pattern_rect.hh │ │ ├── pentagon_counter.hpp │ │ ├── similar_subtree_analysis.cpp │ │ ├── similar_subtree_analysis.hh │ │ ├── similar_subtree_window.cpp │ │ ├── similar_subtree_window.hh │ │ ├── subtree_pattern.hh │ │ ├── tree_merger.cpp │ │ └── tree_merger.hh │ ├── command_line_parser.cpp │ ├── command_line_parser.hh │ ├── conductor.cpp │ ├── conductor.hh │ ├── config.hh │ ├── core.cpp │ ├── core.hh │ ├── db_handler.cpp │ ├── db_handler.hh │ ├── execution.cpp │ ├── execution.hh │ ├── execution_list.cpp │ ├── execution_list.hh │ ├── execution_window.cpp │ ├── execution_window.hh │ ├── message_wrapper.hh │ ├── name_map.cpp │ ├── name_map.hh │ ├── nogood_dialog.cpp │ ├── nogood_dialog.hh │ ├── options.hh │ ├── pixel_views │ │ ├── icicle_canvas.cpp │ │ ├── icicle_canvas.hh │ │ ├── pixel_image.cpp │ │ ├── pixel_image.hh │ │ ├── pixel_item.hh │ │ ├── pixel_widget.cpp │ │ ├── pixel_widget.hh │ │ ├── pt_canvas.cpp │ │ └── pt_canvas.hh │ ├── receiver_thread.cpp │ ├── receiver_thread.hh │ ├── receiver_worker.cpp │ ├── receiver_worker.hh │ ├── settings.hh │ ├── solver_data.cpp │ ├── solver_data.hh │ ├── solver_id.hh │ ├── stats_bar.hpp │ ├── tcp_server.cpp │ ├── tcp_server.hh │ ├── tests │ │ ├── execution_test.cpp │ │ ├── execution_test.hh │ │ ├── tree_test.cpp │ │ └── tree_test.hh │ ├── tree │ │ ├── cursors │ │ │ ├── drawing_cursor.cpp │ │ │ ├── drawing_cursor.hh │ │ │ ├── hide_failed_cursor.cpp │ │ │ ├── hide_failed_cursor.hh │ │ │ ├── hide_not_highlighted_cursor.cpp │ │ │ ├── hide_not_highlighted_cursor.hh │ │ │ ├── layout_cursor.cpp │ │ │ ├── layout_cursor.hh │ │ │ ├── node_cursor.cpp │ │ │ ├── node_cursor.hh │ │ │ ├── nodevisitor.hh │ │ │ └── nodevisitor.hpp │ │ ├── layout.cpp │ │ ├── layout.hh │ │ ├── layout_computer.cpp │ │ ├── layout_computer.hh │ │ ├── node.cpp │ │ ├── node.hh │ │ ├── node_drawing.cpp │ │ ├── node_drawing.hh │ │ ├── node_id.cpp │ │ ├── node_id.hh │ │ ├── node_info.cpp │ │ ├── node_info.hh │ │ ├── node_stats.hh │ │ ├── node_tree.cpp │ │ ├── node_tree.hh │ │ ├── node_widget.hh │ │ ├── shape.cpp │ │ ├── shape.hh │ │ ├── structure.cpp │ │ ├── structure.hh │ │ ├── subtree_view.hh │ │ ├── traditional_view.cpp │ │ ├── traditional_view.hh │ │ ├── tree_scroll_area.cpp │ │ ├── tree_scroll_area.hh │ │ ├── visual_flags.cpp │ │ └── visual_flags.hh │ ├── tree_builder.cpp │ ├── tree_builder.hh │ ├── user_data.cpp │ ├── user_data.hh │ └── utils │ │ ├── array.cpp │ │ ├── array.hh │ │ ├── debug.hh │ │ ├── debug_mutex.hh │ │ ├── maybe_caller.cpp │ │ ├── maybe_caller.hh │ │ ├── path_utils.cpp │ │ ├── path_utils.hh │ │ ├── perf_helper.cpp │ │ ├── perf_helper.hh │ │ ├── std_ext.cpp │ │ ├── std_ext.hh │ │ ├── string_utils.cpp │ │ ├── string_utils.hh │ │ ├── tree_utils.cpp │ │ ├── tree_utils.hh │ │ ├── utils.cpp │ │ └── utils.hh │ └── main_cpprofiler.cpp ├── default.nix ├── flake.lock ├── flake.nix ├── resources ├── README.md ├── icon.png ├── misc │ ├── COMBINED_LICENSE.txt │ ├── MiniZincIDE.desktop │ ├── README │ ├── entitlements.xml │ ├── minizinc.desktop │ ├── osx-gecode-qt.conf │ └── win-gecode-qt.conf ├── pkg_config │ ├── Dockerfile │ ├── minizinc-bundle.iss │ └── snapcraft.yaml └── scripts │ ├── AppRun │ └── MiniZincIDE.sh └── tests ├── data ├── mooc │ ├── TestProject │ │ ├── TestProject.mzp │ │ ├── _mooc │ │ ├── data │ │ │ ├── n1.dzn │ │ │ └── n2.dzn │ │ └── models │ │ │ ├── submission.mzc │ │ │ └── submission.mzn │ └── TestTerms │ │ ├── TestTerms.mzp │ │ ├── _mooc │ │ ├── data │ │ ├── n1.dzn │ │ └── n2.dzn │ │ └── models │ │ ├── submission.mzc │ │ └── submission.mzn └── project │ ├── configs │ ├── solver1.mpc │ ├── solver2.mpc │ └── solver3.mpc │ ├── data │ ├── data1.dzn │ └── data2.dzn │ ├── models │ ├── model1.mzn │ └── model2.mzn │ ├── project-105-bad.mzp │ ├── project-105-good.mzp │ ├── project-106-bad.mzp │ └── project-106-good.mzp ├── testcpprofier.cpp ├── testdiff.cpp ├── testeditor.cpp ├── testide.cpp ├── testide.h ├── testmooc.cpp ├── testproject.cpp └── tests.pro /.envrc: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pro.user 2 | result 3 | -------------------------------------------------------------------------------- /MiniZincIDE.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS = \ 4 | MiniZincIDE \ 5 | tests 6 | 7 | libminizinc { 8 | SUBDIRS += libminizinc 9 | MiniZincIDE.depends = libminizinc 10 | } 11 | -------------------------------------------------------------------------------- /MiniZincIDE/MiniZincIDE.pro: -------------------------------------------------------------------------------- 1 | TARGET = MiniZincIDE 2 | TEMPLATE = app 3 | 4 | INCLUDEPATH += $$PWD/../ 5 | 6 | SOURCES += main.cpp 7 | 8 | include($$PWD/MiniZincIDE.pri) 9 | 10 | target.path = $$PREFIX/bin 11 | INSTALLS += target 12 | -------------------------------------------------------------------------------- /MiniZincIDE/README.txt: -------------------------------------------------------------------------------- 1 | ================================================================ 2 | MiniZinc IDE 3 | ================================================================ 4 | 5 | http://www.minizinc.org 6 | 7 | The MiniZinc IDE is copyright 2013-2019 Monash University, NICTA, Data61/CSIRO. 8 | Please see LICENSE.txt for license information. 9 | Detailed installation instructions for Windows, Linux and macOS can be found 10 | at https://www.minizinc.org/doc-latest/en/installation.html. 11 | -------------------------------------------------------------------------------- /MiniZincIDE/checkupdatedialog.cpp: -------------------------------------------------------------------------------- 1 | #include "checkupdatedialog.h" 2 | #include "ui_checkupdatedialog.h" 3 | 4 | #include 5 | 6 | CheckUpdateDialog::CheckUpdateDialog(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::CheckUpdateDialog) 9 | { 10 | ui->setupUi(this); 11 | } 12 | 13 | CheckUpdateDialog::~CheckUpdateDialog() 14 | { 15 | delete ui; 16 | } 17 | -------------------------------------------------------------------------------- /MiniZincIDE/checkupdatedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKUPDATEDIALOG_H 2 | #define CHECKUPDATEDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class CheckUpdateDialog; 8 | } 9 | 10 | class CheckUpdateDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CheckUpdateDialog(QWidget *parent = 0); 16 | ~CheckUpdateDialog(); 17 | private: 18 | Ui::CheckUpdateDialog *ui; 19 | }; 20 | 21 | #endif // CHECKUPDATEDIALOG_H 22 | -------------------------------------------------------------------------------- /MiniZincIDE/codechecker.cpp: -------------------------------------------------------------------------------- 1 | #include "codechecker.h" 2 | #include "process.h" 3 | 4 | CodeChecker::~CodeChecker() 5 | { 6 | cancel(); 7 | } 8 | 9 | void CodeChecker::connectSignals() 10 | { 11 | connect(&p, &MznProcess::started, this, &CodeChecker::onStarted); 12 | connect(&p, &MznProcess::outputStdOut, this, &CodeChecker::onLine); 13 | connect(&p, &MznProcess::outputStdError, this, &CodeChecker::onLine); 14 | connect(&p, &MznProcess::finished, this, &CodeChecker::onFinished); 15 | } 16 | 17 | void CodeChecker::start(const QString& modelContents, SolverConfiguration& sc, const QString& wd) 18 | { 19 | cancel(); 20 | connectSignals(); 21 | inRelevantError = false; 22 | curError = MiniZincError(); 23 | mznErrors.clear(); 24 | SolverConfiguration checkSc(sc.solverDefinition); 25 | checkSc.additionalData = sc.additionalData; 26 | checkSc.extraOptions = sc.extraOptions; 27 | QStringList args; 28 | args << "--model-check-only" << "-"; 29 | input = modelContents; 30 | p.start(checkSc, args, wd); 31 | } 32 | 33 | void CodeChecker::cancel() 34 | { 35 | p.disconnect(); 36 | p.terminate(); 37 | } 38 | 39 | void CodeChecker::onStarted() 40 | { 41 | p.writeStdIn(input); 42 | p.closeStdIn(); 43 | } 44 | 45 | void CodeChecker::onLine(const QString& l) 46 | { 47 | QJsonParseError error; 48 | auto json = QJsonDocument::fromJson(l.toUtf8(), &error); 49 | if (json.isNull()) { 50 | return; 51 | } 52 | auto msg = json.object(); 53 | if (msg["type"] != "error" && msg["type"] != "warning") { 54 | return; 55 | } 56 | if (!msg["location"].isObject()) { 57 | return; 58 | } 59 | auto loc = msg["location"].toObject(); 60 | MiniZincError e; 61 | e.isWarning = msg["type"] == "warning"; 62 | e.filename = loc["filename"].toString(); 63 | e.first_line = loc["firstLine"].toInt(); 64 | e.first_col = loc["firstColumn"].toInt(); 65 | e.last_line = loc["lastLine"].toInt(); 66 | e.last_col = loc["lastColumn"].toInt(); 67 | e.msg = msg["message"].toString(); 68 | if (e.filename == "stdin") { 69 | // Ignore errors that aren't from this file 70 | mznErrors.push_back(e); 71 | } 72 | } 73 | 74 | void CodeChecker::onFinished() 75 | { 76 | emit finished(mznErrors); 77 | } 78 | -------------------------------------------------------------------------------- /MiniZincIDE/codechecker.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKCODE_H 2 | #define CHECKCODE_H 3 | 4 | #include 5 | 6 | #include "codeeditor.h" 7 | #include "process.h" 8 | 9 | class CodeChecker : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit CodeChecker(QObject *parent = nullptr) : QObject(parent), p(this) {} 14 | ~CodeChecker(); 15 | 16 | void start(const QString& modelContents, SolverConfiguration& sc, const QString& wd); 17 | void cancel(void); 18 | signals: 19 | void finished(const QVector& mznErrors); 20 | 21 | private slots: 22 | void onStarted(void); 23 | void onLine(const QString& data); 24 | void onFinished(); 25 | 26 | private: 27 | MznProcess p; 28 | QString input; 29 | 30 | bool inRelevantError = false; 31 | MiniZincError curError; 32 | QVector mznErrors; 33 | 34 | void connectSignals(); 35 | }; 36 | 37 | #endif // CHECKCODE_H 38 | -------------------------------------------------------------------------------- /MiniZincIDE/darkmodenotifier.h: -------------------------------------------------------------------------------- 1 | #ifndef DARKMODENOTIFIER_H 2 | #define DARKMODENOTIFIER_H 3 | 4 | #include 5 | 6 | class DarkModeNotifier : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit DarkModeNotifier(QObject *parent = nullptr); 11 | ~DarkModeNotifier(); 12 | bool hasSystemSetting() const; 13 | bool hasNativeDarkMode() const; 14 | bool darkMode() const { return _darkMode; } 15 | public slots: 16 | void requestChangeDarkMode(bool enable); 17 | 18 | signals: 19 | void darkModeChanged(bool darkMode); 20 | private: 21 | void init(); 22 | class Internal; 23 | Internal* _internal = nullptr; 24 | bool _darkMode = false; 25 | }; 26 | 27 | #endif // DARKMODENOTIFIER_H 28 | -------------------------------------------------------------------------------- /MiniZincIDE/elapsedtimer.cpp: -------------------------------------------------------------------------------- 1 | #include "elapsedtimer.h" 2 | 3 | ElapsedTimer::ElapsedTimer(QObject* parent) : QObject(parent) { 4 | connect(&_interval, &QTimer::timeout, this, [=] () { 5 | emit timeElapsed(_elapsed.elapsed()); 6 | }); 7 | } 8 | 9 | qint64 ElapsedTimer::elapsed() 10 | { 11 | if (_elapsed.isValid()) { 12 | return _elapsed.elapsed(); 13 | } 14 | return finalTime; 15 | } 16 | 17 | bool ElapsedTimer::isRunning() { 18 | return _elapsed.isValid(); 19 | } 20 | 21 | void ElapsedTimer::start(int updateRate) { 22 | _interval.start(updateRate); 23 | _elapsed.start(); 24 | } 25 | 26 | void ElapsedTimer::stop() { 27 | _interval.stop(); 28 | if (_elapsed.isValid()) { 29 | finalTime = _elapsed.elapsed(); 30 | _elapsed.invalidate(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MiniZincIDE/elapsedtimer.h: -------------------------------------------------------------------------------- 1 | #ifndef ELAPSEDTIMER_H 2 | #define ELAPSEDTIMER_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | class ElapsedTimer: public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | ElapsedTimer(QObject* parent = nullptr); 14 | 15 | qint64 elapsed(); 16 | bool isRunning(); 17 | 18 | signals: 19 | void timeElapsed(qint64 time); 20 | 21 | public slots: 22 | void start(int updateRate); 23 | void stop(); 24 | 25 | private: 26 | QTimer _interval; 27 | QElapsedTimer _elapsed; 28 | qint64 finalTime; 29 | }; 30 | 31 | #endif // ELAPSEDTIMER_H 32 | -------------------------------------------------------------------------------- /MiniZincIDE/esclineedit.cpp: -------------------------------------------------------------------------------- 1 | #include "esclineedit.h" 2 | 3 | #include 4 | #include 5 | 6 | EscLineEdit::EscLineEdit(QWidget* parent) : QLineEdit(parent) 7 | { 8 | 9 | } 10 | 11 | void EscLineEdit::keyReleaseEvent(QKeyEvent* event) 12 | { 13 | if(event->key() == Qt::Key_Escape) { 14 | emit(escPressed()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MiniZincIDE/esclineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef ESCLINEEDIT_H 2 | #define ESCLINEEDIT_H 3 | 4 | #include 5 | 6 | class EscLineEdit : public QLineEdit 7 | { 8 | Q_OBJECT 9 | public: 10 | EscLineEdit(QWidget* parent = 0); 11 | signals: 12 | void escPressed(void); 13 | protected: 14 | void keyReleaseEvent(QKeyEvent *); 15 | }; 16 | 17 | #endif // ESCLINEEDIT_H 18 | -------------------------------------------------------------------------------- /MiniZincIDE/exception.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPTION_H 2 | #define EXCEPTION_H 3 | 4 | #include 5 | 6 | class Exception : public QException 7 | { 8 | public: 9 | Exception(const QString& _msg) : msg(_msg) {} 10 | 11 | const QString& message(void) const { return msg; } 12 | 13 | void raise() const override { throw *this; } 14 | Exception *clone() const override { return new Exception(*this); } 15 | 16 | protected: 17 | QString msg; 18 | }; 19 | 20 | class InternalError : public Exception 21 | { 22 | public: 23 | InternalError(const QString& _msg) : Exception(_msg) {} 24 | 25 | void raise() const override { throw *this; } 26 | Exception *clone() const override { return new InternalError(*this); } 27 | }; 28 | 29 | class ProcessError : public Exception 30 | { 31 | public: 32 | ProcessError(const QString& _msg) : Exception(_msg) {} 33 | 34 | void raise() const override { throw *this; } 35 | Exception *clone() const override { return new ProcessError(*this); } 36 | }; 37 | 38 | class ProjectError : public Exception 39 | { 40 | public: 41 | ProjectError(const QString& _msg) : Exception(_msg) {} 42 | 43 | void raise() const override { throw *this; } 44 | Exception *clone() const override { return new ProjectError(*this); } 45 | }; 46 | 47 | class MoocError : public Exception 48 | { 49 | public: 50 | MoocError(const QString& _msg) : Exception(_msg) {} 51 | 52 | void raise() const override { throw *this; } 53 | Exception *clone() const override { return new MoocError(*this); } 54 | }; 55 | 56 | class ConfigError : public Exception 57 | { 58 | public: 59 | ConfigError(const QString& _msg) : Exception(_msg) {} 60 | 61 | void raise() const override { throw *this; } 62 | Exception *clone() const override { return new ConfigError(*this); } 63 | }; 64 | 65 | class DriverError : public Exception 66 | { 67 | public: 68 | DriverError(const QString& _msg) : Exception(_msg) {} 69 | 70 | void raise() const override { throw *this; } 71 | Exception *clone() const override { return new DriverError(*this); } 72 | }; 73 | 74 | class FileError : public Exception 75 | { 76 | public: 77 | FileError(const QString& _msg) : Exception(_msg) {} 78 | 79 | void raise() const override { throw *this; } 80 | Exception *clone() const override { return new FileError(*this); } 81 | }; 82 | 83 | class ServerError : public Exception 84 | { 85 | public: 86 | ServerError(const QString& _msg) : Exception(_msg) {} 87 | 88 | void raise() const override { throw *this; } 89 | Exception *clone() const override { return new ServerError(*this); } 90 | }; 91 | 92 | #endif // EXCEPTION_H 93 | -------------------------------------------------------------------------------- /MiniZincIDE/extraparamdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTRAPARAMDIALOG_H 2 | #define EXTRAPARAMDIALOG_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "solver.h" 9 | 10 | namespace Ui { 11 | class ExtraParamDialog; 12 | } 13 | 14 | class ExtraParamDialog : public QWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit ExtraParamDialog(QWidget* parent = nullptr); 20 | ~ExtraParamDialog() override; 21 | 22 | void showEvent(QShowEvent* event) override; 23 | 24 | signals: 25 | void addParams(const QList& params); 26 | void addCustomParam(); 27 | 28 | public slots: 29 | void setParams(const QList& params); 30 | void setParamEnabled(const SolverFlag& param, bool enabled); 31 | 32 | protected: 33 | void mousePressEvent(QMouseEvent* event) override; 34 | void mouseReleaseEvent(QMouseEvent* event) override; 35 | 36 | private slots: 37 | void on_filter_lineEdit_textEdited(const QString& pattern); 38 | void on_selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); 39 | 40 | void on_addAll_pushButton_clicked(); 41 | 42 | void on_customParameter_pushButton_clicked(); 43 | 44 | void on_add_pushButton_clicked(); 45 | 46 | void resetControls(); 47 | 48 | void on_params_listView_activated(const QModelIndex &index); 49 | 50 | private: 51 | Ui::ExtraParamDialog* ui; 52 | QStandardItemModel* _sourceModel; 53 | QSortFilterProxyModel* _filterModel; 54 | }; 55 | 56 | #endif // EXTRAPARAMDIALOG_H 57 | -------------------------------------------------------------------------------- /MiniZincIDE/extraparamdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExtraParamDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 371 10 | 352 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | Filter 21 | 22 | 23 | 24 | 25 | 26 | 27 | QAbstractItemView::NoEditTriggers 28 | 29 | 30 | true 31 | 32 | 33 | QAbstractItemView::ExtendedSelection 34 | 35 | 36 | QAbstractItemView::SelectRows 37 | 38 | 39 | true 40 | 41 | 42 | 43 | 44 | 45 | 46 | false 47 | 48 | 49 | Add the selected parameters. 50 | 51 | 52 | Add parameter 53 | 54 | 55 | 56 | 57 | 58 | 59 | Add all available parameters. 60 | 61 | 62 | Add all known parameters 63 | 64 | 65 | 66 | 67 | 68 | 69 | Add a custom command line parameter to the minizinc command or to the solver executable. 70 | 71 | 72 | Add custom parameter 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /MiniZincIDE/fzndoc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Guido Tack 4 | * 5 | * Copyright: 6 | * NICTA 2013 7 | */ 8 | 9 | /* This Source Code Form is subject to the terms of the Mozilla Public 10 | * License, v. 2.0. If a copy of the MPL was not distributed with this 11 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 | 13 | #include "fzndoc.h" 14 | 15 | FznDoc::FznDoc(QObject *parent) : 16 | QObject(parent) 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /MiniZincIDE/fzndoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Guido Tack 4 | * 5 | * Copyright: 6 | * NICTA 2013 7 | */ 8 | 9 | /* This Source Code Form is subject to the terms of the Mozilla Public 10 | * License, v. 2.0. If a copy of the MPL was not distributed with this 11 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 | 13 | #ifndef FZNDOC_H 14 | #define FZNDOC_H 15 | 16 | #include 17 | 18 | class FznDoc : public QObject 19 | { 20 | Q_OBJECT 21 | Q_PROPERTY(QString str READ str WRITE setstr) 22 | public: 23 | explicit FznDoc(QObject *parent = 0); 24 | 25 | void setstr(const QString& s) { 26 | m_str =s ; 27 | } 28 | QString str(void) { 29 | return m_str; 30 | } 31 | 32 | private: 33 | QString m_str; 34 | }; 35 | 36 | #endif // FZNDOC_H 37 | -------------------------------------------------------------------------------- /MiniZincIDE/gotolinedialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Guido Tack 4 | * 5 | * Copyright: 6 | * NICTA 2013 7 | */ 8 | 9 | /* This Source Code Form is subject to the terms of the Mozilla Public 10 | * License, v. 2.0. If a copy of the MPL was not distributed with this 11 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 | 13 | #include "gotolinedialog.h" 14 | #include "ui_gotolinedialog.h" 15 | 16 | GoToLineDialog::GoToLineDialog(QWidget *parent) : 17 | QDialog(parent), 18 | ui(new Ui::GoToLineDialog) 19 | { 20 | ui->setupUi(this); 21 | ui->line->setFocus(); 22 | } 23 | 24 | GoToLineDialog::~GoToLineDialog() 25 | { 26 | delete ui; 27 | } 28 | 29 | int GoToLineDialog::getLine(bool *ok) { 30 | return ui->line->text().toInt(ok); 31 | } 32 | -------------------------------------------------------------------------------- /MiniZincIDE/gotolinedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Guido Tack 4 | * 5 | * Copyright: 6 | * NICTA 2013 7 | */ 8 | 9 | /* This Source Code Form is subject to the terms of the Mozilla Public 10 | * License, v. 2.0. If a copy of the MPL was not distributed with this 11 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 | 13 | #ifndef GOTOLINEDIALOG_H 14 | #define GOTOLINEDIALOG_H 15 | 16 | #include 17 | 18 | namespace Ui { 19 | class GoToLineDialog; 20 | } 21 | 22 | class GoToLineDialog : public QDialog 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit GoToLineDialog(QWidget *parent = 0); 28 | ~GoToLineDialog(); 29 | 30 | int getLine(bool* ok); 31 | 32 | private: 33 | Ui::GoToLineDialog *ui; 34 | }; 35 | 36 | #endif // GOTOLINEDIALOG_H 37 | -------------------------------------------------------------------------------- /MiniZincIDE/gotolinedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GoToLineDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 179 10 | 78 11 | 12 | 13 | 14 | Go to line 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 10 23 | 40 24 | 161 25 | 32 26 | 27 | 28 | 29 | Qt::Horizontal 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 10 39 | 10 40 | 161 41 | 21 42 | 43 | 44 | 45 | 46 | 47 | line 48 | buttonBox 49 | 50 | 51 | 52 | 53 | buttonBox 54 | accepted() 55 | GoToLineDialog 56 | accept() 57 | 58 | 59 | 248 60 | 254 61 | 62 | 63 | 157 64 | 274 65 | 66 | 67 | 68 | 69 | buttonBox 70 | rejected() 71 | GoToLineDialog 72 | reject() 73 | 74 | 75 | 316 76 | 260 77 | 78 | 79 | 286 80 | 274 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /MiniZincIDE/history.h: -------------------------------------------------------------------------------- 1 | #ifndef HISTORY_H 2 | #define HISTORY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class FileDiff 13 | { 14 | public: 15 | enum class EntryType { 16 | Insertion, 17 | Deletion 18 | }; 19 | 20 | struct Entry { 21 | EntryType kind; 22 | qsizetype line; 23 | QString text; 24 | 25 | Entry() {} 26 | 27 | Entry(EntryType _kind, qsizetype _line, const QString& _text): 28 | kind(_kind), 29 | line(_line), 30 | text(_text) {} 31 | }; 32 | 33 | FileDiff(const QString& origText, const QString& newText); 34 | 35 | QVector diff(); 36 | 37 | static QString apply(const QString& source, const QVector& diff); 38 | 39 | private: 40 | QStringList _orig; 41 | QStringList _new; 42 | 43 | qsizetype _offset; 44 | qsizetype _origLength; 45 | qsizetype _newLength; 46 | }; 47 | 48 | class History : public QObject { 49 | Q_OBJECT 50 | 51 | public: 52 | /// 53 | /// \brief Create a new history tracker 54 | /// \param doc The JSON history data 55 | /// \param parent The parent object 56 | /// 57 | explicit History(const QJsonObject& obj, const QDir& relativeTo, QObject* parent = nullptr); 58 | 59 | explicit History(const QString& uuid, QObject* parent = nullptr); 60 | 61 | /// 62 | /// \brief Output history as JSON 63 | /// \return The JSON document 64 | /// 65 | QJsonObject toJSON() const; 66 | 67 | void addFile(const QString& file, const QString& contents); 68 | signals: 69 | /// 70 | /// \brief Emitted when the history has changed 71 | /// 72 | void historyChanged(); 73 | 74 | public slots: 75 | /// 76 | /// \brief Update the history of the given file if it is currently being tracked 77 | /// \param file The file path 78 | /// \param contents The new file contents 79 | /// 80 | void updateFileContents(const QString& file, const QString& contents); 81 | 82 | /// 83 | /// \brief Remove stored changes and create new history node 84 | /// 85 | void commit(); 86 | 87 | private: 88 | struct Change { 89 | double timestamp; 90 | QVector edits; 91 | }; 92 | 93 | struct FileHistory { 94 | QString snapshot; 95 | QVector changes; 96 | }; 97 | 98 | QString _uuid; 99 | QString _parent; 100 | QMap _history; 101 | QDir _rootDir; 102 | }; 103 | 104 | #endif // HISTORY_H 105 | -------------------------------------------------------------------------------- /MiniZincIDE/ideutils.h: -------------------------------------------------------------------------------- 1 | #ifndef IDEUTILS_H 2 | #define IDEUTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace IDEUtils { 11 | QString formatTime(qint64 time); 12 | bool isChildPath(const QString& parent, const QString& child); 13 | void watchChildChanges(QWidget* target, QObject* receiver, std::function action); 14 | template 15 | void watchChildChanges(QWidget* target, T* receiver, void (T::* action)()) { 16 | watchChildChanges(target, receiver, std::bind(action, receiver)); 17 | } 18 | QFont fontFromString(const QString& s); 19 | 20 | class MimeDataExporter : public QTextEdit { 21 | public: 22 | QMimeData* md(void) const { 23 | QMimeData* mymd = createMimeDataFromSelection(); 24 | mymd->removeFormat("text/plain"); 25 | return mymd; 26 | } 27 | }; 28 | 29 | } 30 | 31 | #endif // IDEUTILS_H 32 | -------------------------------------------------------------------------------- /MiniZincIDE/images/about.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 10 |
11 | 12 |
13 |
14 |

The MiniZinc IDE

15 |
16 |
17 | Version $VERSION
18 | Author: Guido Tack
19 | Copyright Monash University and NICTA 2013, 2014, 2015 20 |
21 |
22 | This program is provided under the terms of the Mozilla Public License Version 2.0. 23 | It uses the Qt toolkit, available from qt-project.org. 24 |
25 |
lala 26 |
27 | 28 | -------------------------------------------------------------------------------- /MiniZincIDE/images/application-certificate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/application-certificate.png -------------------------------------------------------------------------------- /MiniZincIDE/images/applications-system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/applications-system.png -------------------------------------------------------------------------------- /MiniZincIDE/images/coursera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/coursera.png -------------------------------------------------------------------------------- /MiniZincIDE/images/coursera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/coursera@2x.png -------------------------------------------------------------------------------- /MiniZincIDE/images/document-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/document-new.png -------------------------------------------------------------------------------- /MiniZincIDE/images/document-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/document-open.png -------------------------------------------------------------------------------- /MiniZincIDE/images/document-save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/document-save.png -------------------------------------------------------------------------------- /MiniZincIDE/images/edit-copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/edit-copy.png -------------------------------------------------------------------------------- /MiniZincIDE/images/edit-cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/edit-cut.png -------------------------------------------------------------------------------- /MiniZincIDE/images/edit-find-replace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/edit-find-replace.png -------------------------------------------------------------------------------- /MiniZincIDE/images/edit-paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/edit-paste.png -------------------------------------------------------------------------------- /MiniZincIDE/images/edit-redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/edit-redo.png -------------------------------------------------------------------------------- /MiniZincIDE/images/edit-undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/edit-undo.png -------------------------------------------------------------------------------- /MiniZincIDE/images/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/folder.png -------------------------------------------------------------------------------- /MiniZincIDE/images/format-indent-less.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/format-indent-less.png -------------------------------------------------------------------------------- /MiniZincIDE/images/format-indent-more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/format-indent-more.png -------------------------------------------------------------------------------- /MiniZincIDE/images/media-playback-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/media-playback-start.png -------------------------------------------------------------------------------- /MiniZincIDE/images/media-playback-stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/media-playback-stop.png -------------------------------------------------------------------------------- /MiniZincIDE/images/mznicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/mznicon.png -------------------------------------------------------------------------------- /MiniZincIDE/images/package-x-generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/package-x-generic.png -------------------------------------------------------------------------------- /MiniZincIDE/images/process-stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/images/process-stop.png -------------------------------------------------------------------------------- /MiniZincIDE/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Guido Tack 4 | * 5 | * Copyright: 6 | * NICTA 2013 7 | */ 8 | 9 | /* This Source Code Form is subject to the terms of the Mozilla Public 10 | * License, v. 2.0. If a copy of the MPL was not distributed with this 11 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 | 13 | #include "ide.h" 14 | #include "mainwindow.h" 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | IDE a(argc, argv); 19 | QStringList args = QApplication::arguments(); 20 | QStringList files; 21 | bool hadProject = false; 22 | for (int i=1; ishow(); 26 | hadProject = true; 27 | } else { 28 | files << args[i]; 29 | } 30 | } 31 | if (!hadProject) { 32 | MainWindow* w = new MainWindow(files); 33 | w->show(); 34 | } 35 | #ifdef Q_OS_MAC 36 | a.setQuitOnLastWindowClosed(false); 37 | #endif 38 | return a.exec(); 39 | } 40 | -------------------------------------------------------------------------------- /MiniZincIDE/minizincide.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/about.html 4 | images/mznicon.png 5 | cheat_sheet.mzn 6 | mznide.ico 7 | dark_mode.css 8 | 9 | 10 | images/document-new.png 11 | images/document-open.png 12 | images/document-save.png 13 | images/edit-find-replace.png 14 | images/edit-paste.png 15 | images/edit-redo.png 16 | images/edit-undo.png 17 | images/format-indent-less.png 18 | images/format-indent-more.png 19 | images/process-stop.png 20 | images/edit-copy.png 21 | images/edit-cut.png 22 | images/folder.png 23 | images/package-x-generic.png 24 | images/coursera.png 25 | images/coursera@2x.png 26 | images/application-certificate.png 27 | images/media-playback-start.png 28 | images/media-playback-stop.png 29 | images/applications-system.png 30 | 31 | 32 | server/index.html 33 | server/connector.js 34 | 35 | 36 | -------------------------------------------------------------------------------- /MiniZincIDE/mznide.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/mznide.icns -------------------------------------------------------------------------------- /MiniZincIDE/mznide.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/MiniZincIDE/mznide.ico -------------------------------------------------------------------------------- /MiniZincIDE/outputdockwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "outputdockwidget.h" 2 | #include 3 | 4 | void OutputDockWidget::closeEvent(QCloseEvent *event) { 5 | if (isFloating()) 6 | setFloating(false); 7 | else 8 | hide(); 9 | event->ignore(); 10 | } 11 | -------------------------------------------------------------------------------- /MiniZincIDE/outputdockwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef OUTPUTDOCKWIDGET_H 2 | #define OUTPUTDOCKWIDGET_H 3 | 4 | #include 5 | 6 | class OutputDockWidget : public QDockWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit OutputDockWidget(QWidget *parent = 0) 11 | : QDockWidget(parent) {} 12 | 13 | signals: 14 | 15 | public slots: 16 | protected: 17 | void closeEvent(QCloseEvent *event); 18 | }; 19 | 20 | #endif // OUTPUTDOCKWIDGET_H 21 | -------------------------------------------------------------------------------- /MiniZincIDE/paramdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Guido Tack 4 | * 5 | * Copyright: 6 | * NICTA 2013 7 | */ 8 | 9 | /* This Source Code Form is subject to the terms of the Mozilla Public 10 | * License, v. 2.0. If a copy of the MPL was not distributed with this 11 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 12 | 13 | #ifndef PARAMDIALOG_H 14 | #define PARAMDIALOG_H 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace Ui { 22 | class ParamDialog; 23 | } 24 | 25 | class ParamDialog : public QDialog 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit ParamDialog(QWidget *parent = 0); 31 | ~ParamDialog(); 32 | void getParams(QStringList params, const QStringList& dataFiles, QStringList& values, QStringList& additionalDataFiles); 33 | int getModel(const QStringList& modelFiles); 34 | private: 35 | Ui::ParamDialog *ui; 36 | QListWidget* selectedFiles; 37 | QStringList previousParams; 38 | QStringList previousValues; 39 | QStringList previousDataFiles; 40 | QString previousModelFile; 41 | bool previousWasManual; 42 | }; 43 | 44 | #endif // PARAMDIALOG_H 45 | -------------------------------------------------------------------------------- /MiniZincIDE/paramdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParamDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 84 11 | 12 | 13 | 14 | Model Parameters 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | QFrame::NoFrame 24 | 25 | 26 | QFrame::Raised 27 | 28 | 29 | 30 | 31 | 32 | 33 | Qt::Horizontal 34 | 35 | 36 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | buttonBox 46 | accepted() 47 | ParamDialog 48 | accept() 49 | 50 | 51 | 248 52 | 254 53 | 54 | 55 | 157 56 | 274 57 | 58 | 59 | 60 | 61 | buttonBox 62 | rejected() 63 | ParamDialog 64 | reject() 65 | 66 | 67 | 316 68 | 260 69 | 70 | 71 | 286 72 | 274 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /MiniZincIDE/preferencesdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef PREFERENCESDIALOG_H 2 | #define PREFERENCESDIALOG_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "codeeditor.h" 8 | 9 | namespace Ui { 10 | class PreferencesDialog; 11 | } 12 | 13 | class PreferencesDialog : public QDialog 14 | { 15 | Q_OBJECT 16 | friend class TestIDE; 17 | 18 | public: 19 | explicit PreferencesDialog(bool addNewSolver, QWidget *parent = nullptr); 20 | ~PreferencesDialog(); 21 | 22 | void accept() Q_DECL_OVERRIDE; 23 | 24 | private slots: 25 | void on_fontComboBox_currentFontChanged(const QFont &f); 26 | 27 | void on_fontSize_spinBox_valueChanged(int arg1); 28 | 29 | void on_lineWrapping_checkBox_stateChanged(int arg1); 30 | 31 | void on_theme_comboBox_currentIndexChanged(int index); 32 | 33 | void on_solvers_combo_currentIndexChanged(int index); 34 | 35 | void on_tabWidget_currentChanged(int index); 36 | 37 | void on_PreferencesDialog_rejected(); 38 | 39 | void on_deleteButton_clicked(); 40 | 41 | void on_mznpath_select_clicked(); 42 | 43 | void on_exec_select_clicked(); 44 | 45 | void on_PreferencesDialog_accepted(); 46 | 47 | void on_mznDistribPath_returnPressed(); 48 | 49 | void on_check_solver_clicked(); 50 | 51 | void on_mznlib_select_clicked(); 52 | 53 | void on_extraSearchPathAdd_pushButton_clicked(); 54 | 55 | void on_extraSearchPathEdit_pushButton_clicked(); 56 | 57 | void on_extraSearchPathDelete_pushButton_clicked(); 58 | 59 | void on_extraSearchPath_listWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous); 60 | 61 | void updateSolverLabel(); 62 | 63 | void on_darkMode_checkBox_stateChanged(int arg1); 64 | 65 | void on_zoom_spinBox_valueChanged(int arg1); 66 | 67 | private: 68 | Ui::PreferencesDialog *ui; 69 | 70 | CodeEditor* _ce = nullptr; 71 | bool _solversPopulated = false; 72 | int _editingSolverIndex = -1; 73 | bool _extraSearchPathsChanged = false; 74 | QMap _restore; 75 | QSet _remove; 76 | QString _origMznDistribPath; 77 | 78 | bool _origDarkMode = false; 79 | int _origThemeIndex = 0; 80 | 81 | QMultiMap _userDefaultFlags; 82 | 83 | QByteArray allowFileRestore(const QString& path); 84 | void loadDriver(bool showError); 85 | void populateSolvers(); 86 | bool updateSolver(); 87 | void updateSearchPaths(); 88 | void showMessageBox(const QString& message); 89 | void updateCodeEditorFont(); 90 | }; 91 | 92 | #endif // PREFERENCESDIALOG_H 93 | -------------------------------------------------------------------------------- /MiniZincIDE/profilecompilation.cpp: -------------------------------------------------------------------------------- 1 | #include "profilecompilation.h" 2 | #include 3 | 4 | Path::Path(const QString& path) 5 | { 6 | auto items = path.split(';'); 7 | for (auto& it : items) { 8 | auto parts = it.split('|'); 9 | if (parts.size() < 5) { 10 | continue; 11 | } 12 | Path::Segment segment; 13 | QFileInfo fi(parts[0]); 14 | segment.filename = fi.canonicalFilePath(); 15 | segment.firstLine = parts[1].toInt(); 16 | segment.firstColumn = parts[2].toInt(); 17 | segment.lastLine = parts[3].toInt(); 18 | segment.lastColumn = parts[4].toInt(); 19 | QStringList rest; 20 | for (auto i = 5; i < parts.size(); i++) { 21 | segment.parts << parts[i]; 22 | } 23 | _segments << segment; 24 | } 25 | } 26 | 27 | PathEntry::PathEntry(const QJsonObject& obj) : _path(obj["path"].toString()) 28 | { 29 | if (obj["constraintIndex"].isUndefined()) { 30 | _flatZincName = obj["flatZincName"].toString(); 31 | _niceName = obj["niceName"].toString(); 32 | } else { 33 | _constraintIndex = obj["constraintIndex"].toInt(); 34 | } 35 | } 36 | 37 | TimingEntry::TimingEntry(const QJsonObject& obj) 38 | { 39 | QFileInfo fi(obj["filename"].toString()); 40 | _filename = fi.canonicalFilePath(); 41 | _line = obj["line"].toInt(); 42 | _time = obj["time"].toInt(); 43 | } 44 | -------------------------------------------------------------------------------- /MiniZincIDE/profilecompilation.h: -------------------------------------------------------------------------------- 1 | #ifndef PROFILE_COMPILATION_H 2 | #define PROFILE_COMPILATION_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "highlighter.h" 10 | 11 | class Path 12 | { 13 | public: 14 | struct Segment 15 | { 16 | QString filename; 17 | int firstLine; 18 | int firstColumn; 19 | int lastLine; 20 | int lastColumn; 21 | QStringList parts; 22 | }; 23 | 24 | Path(const QString& path); 25 | Path() {} 26 | 27 | const QVector& segments() const { return _segments; } 28 | 29 | private: 30 | QVector _segments; 31 | }; 32 | 33 | class PathEntry 34 | { 35 | public: 36 | PathEntry(const QJsonObject& obj); 37 | PathEntry() {} 38 | 39 | const QString& flatZincName() const {return _flatZincName; } 40 | const QString& niceName() const { return _niceName; } 41 | int constraintIndex() const { return _constraintIndex; } 42 | const Path& path() const { return _path; } 43 | private: 44 | QString _flatZincName; 45 | QString _niceName; 46 | int _constraintIndex = -1; 47 | Path _path; 48 | }; 49 | 50 | class TimingEntry 51 | { 52 | public: 53 | TimingEntry(const QJsonObject& obj); 54 | TimingEntry() {} 55 | 56 | const QString& filename() const { return _filename; } 57 | int line() const { return _line; } 58 | int time() const { return _time; } 59 | 60 | private: 61 | QString _filename; 62 | int _line; 63 | int _time; 64 | }; 65 | 66 | #endif // PROFILE_COMPILATION_H 67 | -------------------------------------------------------------------------------- /MiniZincIDE/projectbrowser.h: -------------------------------------------------------------------------------- 1 | #ifndef PROJECTBROWSER_H 2 | #define PROJECTBROWSER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "project.h" 11 | #include "moocsubmission.h" 12 | 13 | namespace Ui { 14 | class ProjectBrowser; 15 | } 16 | 17 | class ProjectBrowser : public QWidget 18 | { 19 | Q_OBJECT 20 | friend class TestIDE; 21 | 22 | public: 23 | explicit ProjectBrowser(QWidget *parent = nullptr); 24 | ~ProjectBrowser(); 25 | 26 | /// 27 | /// \brief Gets the project associated with this project browser 28 | /// \return A pointer to the project 29 | /// 30 | Project* project(void) 31 | { 32 | return proj; 33 | } 34 | /// 35 | /// \brief Sets the project associated with this project browser 36 | /// \param project The new project 37 | /// 38 | void project(Project* project); 39 | 40 | signals: 41 | void runRequested(const QStringList& files); 42 | void openRequested(const QStringList& files); 43 | void removeRequested(const QStringList& files); 44 | 45 | private slots: 46 | void on_treeView_activated(const QModelIndex &index); 47 | 48 | private: 49 | Ui::ProjectBrowser *ui; 50 | 51 | void setupContextMenu(void); 52 | 53 | Project* proj = nullptr; 54 | }; 55 | 56 | #endif // PROJECTBROWSER_H 57 | -------------------------------------------------------------------------------- /MiniZincIDE/projectbrowser.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ProjectBrowser 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | Qt::CustomContextMenu 33 | 34 | 35 | QAbstractItemView::EditKeyPressed 36 | 37 | 38 | QAbstractItemView::ExtendedSelection 39 | 40 | 41 | 10 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /MiniZincIDE/server.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_H 2 | #define SERVER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class VisConnector : public QObject { 11 | Q_OBJECT 12 | 13 | private: 14 | QString _label; 15 | QStringList _roots; 16 | QList _clients; 17 | 18 | QJsonObject _windows; 19 | QMap _solutions; 20 | QJsonValue _finalStatus; 21 | int _solutionCount = 0; 22 | qint64 _finishTime = -1; 23 | 24 | QUrl _url; 25 | 26 | friend class Server; 27 | public: 28 | explicit VisConnector(QObject *parent = nullptr) : QObject(parent) {} 29 | ~VisConnector(); 30 | 31 | QUrl url() const { return _url; } 32 | 33 | signals: 34 | void solveRequested(const QString& modelFile, bool dataFilesGiven, const QStringList& dataFiles, const QVariantMap& options); 35 | 36 | public slots: 37 | void addWindow(const QString& key, const QString& url, const QJsonValue& userData); 38 | void addSolution(const QJsonObject& solution, qint64 time); 39 | void setFinalStatus(const QString& status, qint64 time); 40 | void setFinished(qint64 time); 41 | 42 | private slots: 43 | void newWebSocketClient(QWebSocket* s); 44 | void webSocketClientDisconnected(); 45 | void webSocketMessageReceived(const QString& message); 46 | void broadcastMessage(const QJsonDocument& message); 47 | }; 48 | 49 | /// 50 | /// \brief HTTP and WebSocket server for web visualisation 51 | /// 52 | class Server : public QObject 53 | { 54 | Q_OBJECT 55 | public: 56 | explicit Server(QObject *parent = nullptr); 57 | ~Server(); 58 | 59 | void listen(quint16 httpPort = 3000, quint16 wsPort = 3100); 60 | 61 | QString address() const { return http->serverAddress().toString(); } 62 | quint16 port() const { return http->serverPort(); } 63 | quint16 desiredHttpPort() const { return initialHttpPort; } 64 | quint16 desiredWsPort() const { return initialWsPort; } 65 | 66 | VisConnector* addConnector(const QString& label, const QStringList& roots); 67 | void clear(); 68 | 69 | bool sendToLastClient(const QJsonDocument& doc); 70 | 71 | signals: 72 | void solve(const QString& model, const QStringList& data, const QVariantMap& options); 73 | 74 | private slots: 75 | void newHttpClient(); 76 | void newWebSocketClient(); 77 | void webSocketClientDisconnected(); 78 | void handleHttpRequest(); 79 | 80 | private: 81 | QTcpServer* http; 82 | QWebSocketServer* ws; 83 | QList connectors; 84 | QList clients; 85 | quint16 initialHttpPort; 86 | quint16 initialWsPort; 87 | }; 88 | 89 | #endif // SERVER_H 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Logo 4 | 5 | 6 |

MiniZinc IDE

7 | 8 |

9 | Integrated development environment for the high-level constraint modelling language 10 | MiniZinc. 11 |
12 |
13 | MiniZinc Compiler 14 | · 15 | Documentation 16 | · 17 | Report Bug 18 |

19 | 20 |

21 | The MiniZinc IDE 22 |

23 |

24 | 25 | ## Getting started 26 | 27 | Packages for Linux, macOS and Windows can be found in the [releases](https://github.com/MiniZinc/MiniZincIDE/releases) or from [the MiniZinc 28 | website](http://www.minizinc.org/software.html). 29 | 30 | These packages contain the MiniZinc IDE, the MiniZinc compiler toolchain, as well as several solvers. 31 | 32 | For more detailed installation instructions, see the [documentation](https://www.minizinc.org/doc-latest/en/installation.html). 33 | 34 | ## Building from source 35 | 36 | The MiniZinc IDE is a [Qt](https://www.qt.io/) project and requires: 37 | - A recent C++ compiler 38 | - [Qt](https://www.qt.io/) (we target the latest LTS Qt version) 39 | - We also require the [Qt WebSockets](https://doc.qt.io/qt-6/qtwebsockets-index.html) module 40 | - [Make](https://www.gnu.org/software/make/) 41 | 42 | Ensure you clone the repository including submodules: 43 | 44 | ```sh 45 | git clone --recurse-submodules https://github.com/MiniZinc/MiniZincIDE 46 | cd MiniZincIDE 47 | ``` 48 | 49 | Then either build open the project (`MiniZincIDE.pro`) in Qt Creator and build, or from the command line: 50 | 51 | ```sh 52 | mkdir build 53 | cd build 54 | qmake -makefile ../MiniZincIDE/MiniZincIDE.pro 55 | make -j4 56 | ``` 57 | 58 | See the [MiniZinc compiler project](https://github.com/MiniZinc/libminizinc) for instructions on how to build the compiler toolchain. 59 | 60 | ### Running tests 61 | 62 | The IDE has a test suite which can be compiled and run with: 63 | 64 | ```sh 65 | mkdir test 66 | cd test 67 | qmake -makefile ../tests/tests.pro 68 | make -j4 69 | make check 70 | ``` 71 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | Features that would be nice to have: 2 | * Show types 3 | * Integrated global constraint library browser 4 | * Save all data files before running 5 | * Auto indent 6 | * Column selection 7 | 8 | Done 9 | * Focus 10 | * Make dzn selection in Configuration tab work 11 | * Clear output window 12 | * Font size 13 | * Tabs-to-spaces (without messing up the undo buffer) 14 | * About dialog 15 | * Click on error location to jump to position in editor 16 | * Configuration dialog for adding other solvers 17 | * Global solver configurations stored somewhere system wide 18 | * Find/replace 19 | * Font selection 20 | * Go to line 21 | * Configure paths 22 | * Time outs 23 | * Mac application icon 24 | * Indent/outdent selection 25 | * Report solve time 26 | * Basic help 27 | * Windows application icon 28 | * Multiple windows ("projects") 29 | * Saving/loading projects (i.e. the contents of the Configuration tab + all 30 | open files) 31 | * Do not load really large files (show button instead to load on demand) 32 | * Save before running 33 | * Remove LGPL find/replace dialog 34 | * Correct copyright headers 35 | * Handle duplicate open files 36 | * Save all 37 | * Change font also for output 38 | * Correct handling of open constraint graph windows 39 | * Packaging 40 | * Run fzn files 41 | * Use mzn2fzn and implement the solutions processing internally 42 | * Comment/uncomment selection 43 | * Detach solver (to be able to run Gecode w/ Gist) 44 | * Dialog for missing model parameters 45 | * Detect when files change on disk (auto reload + dialog if changed) 46 | * Colour selection 47 | -------------------------------------------------------------------------------- /cp-profiler/cp-profiler.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | TARGET = cp-profiler 4 | 5 | QT += widgets network sql 6 | 7 | CONFIG += c++11 8 | 9 | include(cp-profiler.pri) 10 | SOURCES += $$PWD/src/main_cpprofiler.cpp 11 | -------------------------------------------------------------------------------- /cp-profiler/docs/images/doc_conductor1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/cp-profiler/docs/images/doc_conductor1.png -------------------------------------------------------------------------------- /cp-profiler/docs/images/doc_ss_analysis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/cp-profiler/docs/images/doc_ss_analysis.png -------------------------------------------------------------------------------- /cp-profiler/docs/images/doc_ss_analysis_hist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/cp-profiler/docs/images/doc_ss_analysis_hist.png -------------------------------------------------------------------------------- /cp-profiler/docs/images/doc_traditional_collapsed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/cp-profiler/docs/images/doc_traditional_collapsed.png -------------------------------------------------------------------------------- /cp-profiler/docs/images/doc_traditional_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniZinc/MiniZincIDE/b768c16aed36e9144a33da742fd9ae062288c9b4/cp-profiler/docs/images/doc_traditional_interface.png -------------------------------------------------------------------------------- /cp-profiler/src/cpp-integration/README.md: -------------------------------------------------------------------------------- 1 | 2 | #### 1. Create a connector instance 3 | 4 | ```c++ 5 | unsigned int port = 6565; 6 | ``` 7 | 8 | ```c++ 9 | Connector c(port); 10 | ``` 11 | 12 | #### 2. Establish a connection and start a new search tree 13 | 14 | ```c++ 15 | /// Establishes a socket connection using the port specified above 16 | c.connect(); 17 | 18 | /// Tells the profiler to start a new tree 19 | c.restart("example"); 20 | 21 | /// Also used in case of a restart with restart id specified 22 | c.restart("example", 1); 23 | ``` 24 | 25 | #### 3. Send data every time the solver branches/fails/finds a solution 26 | 27 | ```c++ 28 | /// Create a node on a stack with mandatory fields 29 | Node node = c.createNode(node_id, parent_id, alt, kids, status); 30 | ``` 31 | 32 | ```c++ 33 | // Specify optional fields (whichever available) 34 | node.set_label("b"); 35 | ``` 36 | 37 | ```c++ 38 | // Send the node 39 | c.sendNode(node); 40 | ``` 41 | 42 | Or all in one line: 43 | 44 | ```c++ 45 | c.createNode(node_id, parent_id, alt, kids, status).set_label("b").send(); 46 | ``` 47 | 48 | 49 | The parameters are: 50 | 51 | field | type | description 52 | ------ | ---- | ----------- 53 | node_id | int | current node's identifier 54 | parent_id | int | identifier of node's parent 55 | alt | int | which of its siblings the node is (0 for the left-most) 56 | kids | int | number of children 57 | status | Profiling::NodeStatus | determines the node's type (solution, failure, branching etc) 58 | label | std::string | some text-based information to go along with the node (ie branching decision 59 | 60 | #### 4. Finish the tree and release the socket 61 | 62 | ```c++ 63 | c.done(); 64 | c.disconnect(); 65 | ``` -------------------------------------------------------------------------------- /cp-profiler/src/cpprofiler/analysis/histogram_scene.hh: -------------------------------------------------------------------------------- 1 | #ifndef CPPROFILER_ANALYSES_HISTOGRAM_SCENE 2 | #define CPPROFILER_ANALYSES_HISTOGRAM_SCENE 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "../core.hh" 10 | #include "subtree_pattern.hh" 11 | 12 | namespace cpprofiler 13 | { 14 | namespace analysis 15 | { 16 | 17 | /// vertical distance between two shape rectangles 18 | static constexpr int V_DISTANCE = 2; 19 | 20 | class PatternRect; 21 | enum class PatternProp; 22 | 23 | using PatternRectPtr = std::shared_ptr; 24 | using PatternPtr = std::shared_ptr; 25 | 26 | class HistogramScene : public QObject 27 | { 28 | Q_OBJECT 29 | /// Scene used for drawing 30 | std::unique_ptr scene_; 31 | 32 | /// Selected pattern rectangle (nullptr if no selected) 33 | PatternRect *selected_rect_ = nullptr; 34 | /// Index of the selected pattern 35 | int selected_idx_ = -1; 36 | 37 | /// A list of visual elements for patterns (used for navigation); 38 | std::vector rects_; 39 | 40 | /// The result of the analysis in a form of a list of patterns 41 | std::vector patterns_; 42 | 43 | /// Mapping from a visual element to the pattern it represents 44 | std::unordered_map rect2pattern_; 45 | 46 | /// Find the possition of the rectangle representing `pattern` 47 | int findPatternIdx(PatternRect *pattern) const; 48 | 49 | /// Select `idx` unselecting the previous pattern 50 | void changeSelectedPattern(int idx); 51 | 52 | PatternPtr rectToPattern(PatternRectPtr prect) const; 53 | 54 | public: 55 | HistogramScene() 56 | { 57 | scene_.reset(new QGraphicsScene()); 58 | } 59 | 60 | /// Prepare the GUI for new patterns 61 | void reset(); 62 | 63 | /// Expose underlying scene 64 | QGraphicsScene *scene() 65 | { 66 | return scene_.get(); 67 | } 68 | 69 | /// Find the pattern's id and select it 70 | void findAndSelect(PatternRect *prect); 71 | 72 | /// Draw the patterns onto the scene 73 | void drawPatterns(PatternProp prop); 74 | 75 | /// Initialize patterns based on the analysis results 76 | void setPatterns(std::vector &&patterns); 77 | 78 | signals: 79 | 80 | void pattern_selected(NodeID); 81 | void should_be_highlighted(const std::vector &); 82 | 83 | public slots: 84 | 85 | void prevPattern(); 86 | void nextPattern(); 87 | }; 88 | 89 | } // namespace analysis 90 | } // namespace cpprofiler 91 | 92 | #endif -------------------------------------------------------------------------------- /cp-profiler/src/cpprofiler/analysis/merge_window.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../tree/node_tree.hh" 5 | #include "merging/merge_result.hh" 6 | 7 | namespace cpprofiler 8 | { 9 | namespace tree 10 | { 11 | class TraditionalView; 12 | } 13 | 14 | class Execution; 15 | class UserData; 16 | } // namespace cpprofiler 17 | 18 | namespace cpprofiler 19 | { 20 | namespace analysis 21 | { 22 | 23 | class PentagonCounter; 24 | class PentagonListWidget; 25 | 26 | /// Original location for a node; 27 | struct OriginalLoc 28 | { 29 | NodeID nid; 30 | }; 31 | 32 | class MergeWindow : public QMainWindow 33 | { 34 | Q_OBJECT 35 | 36 | /// The two executions merged 37 | Execution &ex_l_; 38 | Execution &ex_r_; 39 | 40 | std::shared_ptr nt_; 41 | std::shared_ptr merge_result_; 42 | 43 | /// Dummy user data (required for traditional view) 44 | std::unique_ptr user_data_; 45 | 46 | /// Dummy solver data (required for traditional view) 47 | std::unique_ptr solver_data_; 48 | 49 | std::unique_ptr view_; 50 | 51 | PentagonCounter *pentagon_bar; 52 | 53 | PentagonListWidget *pent_list; 54 | 55 | /// Original locations for node `i` (used for nogoods/labels etc) 56 | std::vector orig_locations_; 57 | 58 | private: 59 | /// find the right data for a node 60 | Nogood getNogood(); 61 | 62 | /// traverse the merged tree to find origins for all nodes 63 | void initOrigLocations(); 64 | /// Find id for a node `nid` of a merged tree 65 | // NodeID findOriginalId(NodeID nid) const; 66 | 67 | /// Hide all failed subtrees under pentagons 68 | void hideFailed(); 69 | 70 | public: 71 | MergeWindow(Execution &ex_l, Execution &ex_r, std::shared_ptr nt, std::shared_ptr res, QWidget* parent = nullptr); 72 | ~MergeWindow(); 73 | 74 | tree::NodeTree &getTree(); 75 | 76 | MergeResult &mergeResult(); 77 | 78 | public slots: 79 | 80 | void runNogoodAnalysis() const; 81 | }; 82 | 83 | } // namespace analysis 84 | } // namespace cpprofiler -------------------------------------------------------------------------------- /cp-profiler/src/cpprofiler/analysis/merging/merge_result.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../core.hh" 4 | #include 5 | 6 | namespace cpprofiler 7 | { 8 | namespace analysis 9 | { 10 | 11 | struct PentagonItem 12 | { 13 | /// pentagon node 14 | NodeID pen_nid; 15 | /// left subtree size 16 | int size_l; 17 | /// right subtree size 18 | int size_r; 19 | }; 20 | 21 | using MergeResult = std::vector; 22 | 23 | } // namespace analysis 24 | } // namespace cpprofiler -------------------------------------------------------------------------------- /cp-profiler/src/cpprofiler/analysis/merging/pentagon_rect.cpp: -------------------------------------------------------------------------------- 1 | #include "pentagon_rect.hh" 2 | 3 | #include "merge_result.hh" 4 | #include "pentagon_list_widget.hh" 5 | 6 | #include 7 | #include 8 | 9 | namespace cpprofiler 10 | { 11 | namespace analysis 12 | { 13 | 14 | PentagonRect::PentagonRect(QGraphicsScene *scene, PentagonListWidget &listw, const PentagonItem &pen, int y, int max_val, bool selected) 15 | : QGraphicsRectItem(pent_config::PADDING, y, listw.viewWidth() - 1, pent_config::HEIGHT), 16 | m_pen_list_widget(listw), 17 | m_node(pen.pen_nid) 18 | { 19 | using namespace pent_config; 20 | 21 | const int PENT_WIDTH = listw.viewWidth() - 1; 22 | const int HALF_WIDTH = PENT_WIDTH / 2; 23 | 24 | const float scale_x = (float)HALF_WIDTH / max_val; 25 | 26 | const int value_l = pen.size_l; 27 | const int value_r = pen.size_r; 28 | 29 | const int width_l = value_l * scale_x; 30 | const int width_r = value_r * scale_x; 31 | 32 | const int cx = PADDING + listw.viewWidth() / 2; 33 | 34 | if (selected) 35 | { 36 | setBrush(sel_color); 37 | } 38 | 39 | auto left = new QGraphicsRectItem(cx - width_l, y, width_l, HEIGHT); 40 | left->setBrush(left_color); 41 | // left->setPen(Qt::NoPen); 42 | auto right = new QGraphicsRectItem(cx, y, width_r, HEIGHT); 43 | right->setBrush(right_color); 44 | // right->setPen(Qt::NoPen); 45 | 46 | scene->addItem(this); 47 | scene->addItem(left); 48 | scene->addItem(right); 49 | 50 | { 51 | auto text_item = new QGraphicsSimpleTextItem{QString::number(value_l)}; 52 | text_item->setPos(TEXT_PAD, y); 53 | scene->addItem(text_item); 54 | } 55 | 56 | { 57 | auto text_item = new QGraphicsSimpleTextItem{QString::number(value_r)}; 58 | const int item_width = text_item->boundingRect().width(); 59 | const int x = PENT_WIDTH - TEXT_PAD - item_width; 60 | text_item->setPos(x, y); 61 | scene->addItem(text_item); 62 | } 63 | } 64 | 65 | void PentagonRect::mousePressEvent(QGraphicsSceneMouseEvent *) 66 | { 67 | m_pen_list_widget.handleClick(m_node); 68 | } 69 | 70 | } // namespace analysis 71 | } // namespace cpprofiler -------------------------------------------------------------------------------- /cp-profiler/src/cpprofiler/analysis/merging/pentagon_rect.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../../core.hh" 5 | 6 | namespace cpprofiler 7 | { 8 | namespace analysis 9 | { 10 | 11 | class PentagonListWidget; 12 | struct PentagonItem; 13 | 14 | namespace pent_config 15 | { 16 | constexpr int HEIGHT = 16; 17 | constexpr int PADDING = 0; 18 | constexpr int VIEW_WIDTH = 150; 19 | // constexpr int PENT_WIDTH = VIEW_WIDTH - PADDING * 2 - 3; 20 | // constexpr int HALF_WIDTH = PENT_WIDTH / 2; 21 | 22 | constexpr int TEXT_PAD = 10; 23 | 24 | static QColor left_color{153, 204, 255}; 25 | static QColor right_color{255, 153, 204}; 26 | 27 | /// color for selected pentagon item 28 | static QColor sel_color{150, 150, 150}; 29 | } // namespace pent_config 30 | 31 | class PentagonRect : public QGraphicsRectItem 32 | { 33 | 34 | private: 35 | PentagonListWidget &m_pen_list_widget; 36 | /// Pentagon node associated with this item 37 | NodeID m_node; 38 | 39 | void mousePressEvent(QGraphicsSceneMouseEvent *) override; 40 | 41 | public: 42 | PentagonRect(QGraphicsScene *scene, PentagonListWidget &listw, const PentagonItem &pen, int y, int max_val, bool selected); 43 | }; 44 | 45 | } // namespace analysis 46 | } // namespace cpprofiler -------------------------------------------------------------------------------- /cp-profiler/src/cpprofiler/analysis/path_comp.cpp: -------------------------------------------------------------------------------- 1 | #include "path_comp.hh" 2 | #include 3 | 4 | using std::vector; 5 | 6 | namespace cpprofiler 7 | { 8 | namespace analysis 9 | { 10 | 11 | /// A wrapper around std::set_intersection; copying is intended 12 | static vector