From 7e21aa1ef4c9ab472ed5248c7816f3251c7a7dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 14 Mar 2018 09:44:45 +0100 Subject: [PATCH 01/14] init work with the tab widget. --- .../win_make_vc14_x64_abreheret_qt5.10.bat | 8 ++ src/image_canvas.cpp | 5 +- src/image_canvas.h | 6 +- src/main_window.cpp | 86 ++++++++++---- src/main_window.h | 15 ++- src/main_window.ui | 111 +++++++++++++++++- 6 files changed, 195 insertions(+), 36 deletions(-) create mode 100644 scripts_to_build/win_make_vc14_x64_abreheret_qt5.10.bat diff --git a/scripts_to_build/win_make_vc14_x64_abreheret_qt5.10.bat b/scripts_to_build/win_make_vc14_x64_abreheret_qt5.10.bat new file mode 100644 index 0000000..b46d7f8 --- /dev/null +++ b/scripts_to_build/win_make_vc14_x64_abreheret_qt5.10.bat @@ -0,0 +1,8 @@ +mkdir build +cd build +mkdir x64 +cd x64 +cmake -DQT5_DIR=D:/dev/Qt/5.10.0/msvc2015_64/lib/cmake -DCMAKE_PREFIX_PATH="D:/DEV/git/pl_all/pl_3rdparty/package" -G "Visual Studio 14 Win64" ../../.. +REM cmake --build . --config Release + +PAUSE \ No newline at end of file diff --git a/src/image_canvas.cpp b/src/image_canvas.cpp index 1c7ed3a..833d26c 100644 --- a/src/image_canvas.cpp +++ b/src/image_canvas.cpp @@ -5,8 +5,9 @@ #include #include -ImageCanvas::ImageCanvas(QWidget * parent, MainWindow *ui) : - QLabel(parent) , +ImageCanvas::ImageCanvas(QScrollArea * scroll_parent, MainWindow *ui) : + QLabel(scroll_parent) , + _scroll_parent(scroll_parent), _ui(ui), _alpha(0.5), _pen_size(30) { diff --git a/src/image_canvas.h b/src/image_canvas.h index be9b464..510fde6 100644 --- a/src/image_canvas.h +++ b/src/image_canvas.h @@ -6,6 +6,7 @@ #include #include +#include class MainWindow; @@ -14,7 +15,7 @@ class ImageCanvas : public QLabel { public: - ImageCanvas(QWidget * parent, MainWindow *ui); + ImageCanvas(QScrollArea * scroll_parent, MainWindow *ui); void setId(int id); void setMask(const ImageMask & mask); @@ -26,6 +27,7 @@ class ImageCanvas : public QLabel { void refresh(); void updateMaskColor(const Id2Labels & labels) { _mask.updateColor(labels); } void loadImage(const QString &file); + QScrollArea * getScrollParent() const { return _scroll_parent; } protected: void mouseMoveEvent(QMouseEvent * event) override; @@ -46,9 +48,11 @@ public slots : private: MainWindow *_ui; + void _initPixmap(); void _drawFillCircle(QMouseEvent * e); + QScrollArea *_scroll_parent ; double _scale ; double _alpha ; QImage _image ; diff --git a/src/main_window.cpp b/src/main_window.cpp index 4cd08e9..64b619a 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -15,6 +15,7 @@ #include #include #include "pixel_annotation_tool_version.h" +#include #include "about_dialog.h" @@ -25,8 +26,6 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) setWindowTitle(QApplication::translate("MainWindow", "PixelAnnotationTool " PIXEL_ANNOTATION_TOOL_GIT_TAG, Q_NULLPTR)); list_label->setSpacing(1); - scroll_area = new QScrollArea; - image_canvas = new ImageCanvas(scroll_area, this); save_action = new QAction(tr("&Save current image"), this); undo_action = new QAction(tr("&Undo"), this); redo_action = new QAction(tr("&Redo"), this); @@ -40,28 +39,13 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) menuEdit->addAction(undo_action); menuEdit->addAction(redo_action); - image_canvas->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - image_canvas->setScaledContents(true); - - scroll_area->setBackgroundRole(QPalette::Dark); - scroll_area->setWidget(image_canvas); - - setCentralWidget(scroll_area); - - connect(spinbox_scale, SIGNAL(valueChanged(double)), image_canvas, SLOT(scaleChanged(double))); - connect(spinbox_alpha, SIGNAL(valueChanged(double)), image_canvas, SLOT(alphaChanged(double))); - connect(spinbox_pen_size, SIGNAL(valueChanged(int)), image_canvas, SLOT(setSizePen(int))); - connect(button_watershed, SIGNAL(released()), this, SLOT(runWatershed())); - connect(checkbox_watershed_mask, SIGNAL(clicked()), image_canvas, SLOT(update())); - connect(checkbox_manuel_mask, SIGNAL(clicked()), image_canvas, SLOT(update())); - connect(actionClear, SIGNAL(triggered()), image_canvas, SLOT(clearMask())); - - connect(actionOpen_config_file, SIGNAL(triggered()), this, SLOT(loadConfigFile())); - connect(actionSave_config_file, SIGNAL(triggered()), this, SLOT(saveConfigFile())); + tabWidget->clear(); - connect(undo_action, SIGNAL(triggered()), image_canvas, SLOT(undo())); - connect(redo_action, SIGNAL(triggered()), image_canvas, SLOT(redo())); - connect(save_action, SIGNAL(triggered()), image_canvas, SLOT(saveMask())); + connect(button_watershed , SIGNAL(released()) , this, SLOT(runWatershed() )); + connect(actionOpen_config_file, SIGNAL(triggered()) , this, SLOT(loadConfigFile())); + connect(actionSave_config_file, SIGNAL(triggered()) , this, SLOT(saveConfigFile())); + connect(tabWidget , SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int) )); + connect(tabWidget , SIGNAL(currentChanged(int)) , this, SLOT(updateConnect(int))); labels = defaulfLabels(); @@ -71,7 +55,13 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) connect(list_label, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(changeColor(QListWidgetItem*))); + } + +void MainWindow::closeTab(int index) { + tabWidget->removeTab(index); +} + void MainWindow::loadConfigLabels() { list_label->clear(); QMapIterator it(labels); @@ -138,6 +128,53 @@ void MainWindow::runWatershed() { image_canvas->update(); } +void MainWindow::updateConnect() { + connect(spinbox_scale, SIGNAL(valueChanged(double)), image_canvas, SLOT(scaleChanged(double))); + connect(spinbox_alpha, SIGNAL(valueChanged(double)), image_canvas, SLOT(alphaChanged(double))); + connect(spinbox_pen_size, SIGNAL(valueChanged(int)), image_canvas, SLOT(setSizePen(int))); + connect(checkbox_watershed_mask, SIGNAL(clicked()), image_canvas, SLOT(update())); + connect(checkbox_manuel_mask, SIGNAL(clicked()), image_canvas, SLOT(update())); + connect(actionClear, SIGNAL(triggered()), image_canvas, SLOT(clearMask())); + connect(undo_action, SIGNAL(triggered()), image_canvas, SLOT(undo())); + connect(redo_action, SIGNAL(triggered()), image_canvas, SLOT(redo())); + connect(save_action, SIGNAL(triggered()), image_canvas, SLOT(saveMask())); +} + +ImageCanvas * MainWindow::newImageCanvas() { + scroll_area = new QScrollArea; + image_canvas = new ImageCanvas(scroll_area, this); + image_canvas->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + image_canvas->setScaledContents(true); + scroll_area->setBackgroundRole(QPalette::Dark); + scroll_area->setWidget(image_canvas); + updateConnect(); + return image_canvas; +} + +void MainWindow::updateConnect(int index) { + image_canvas = static_cast(tabWidget->widget(index)); + scroll_area = image_canvas->getScrollParent(); + updateConnect(); +} + +ImageCanvas * MainWindow::getImageCanvas(QString name) { + for (int i = 0; i < tabWidget->count(); i++) { + if (tabWidget->tabText(i) == name) { + image_canvas = static_cast(tabWidget->widget(i)); + updateConnect(); + scroll_area = image_canvas->getScrollParent(); + return image_canvas; + } + } + image_canvas = newImageCanvas(); + scroll_area = image_canvas->getScrollParent(); + QString iDir = currentDir(); + QString filepath(iDir + "/" + name); + image_canvas->loadImage(filepath); + tabWidget->addTab(scroll_area, name); + return image_canvas; +} + QString MainWindow::currentDir() const { QTreeWidgetItem *current = tree_widget_img->currentItem(); if (!current || !current->parent()) @@ -160,8 +197,7 @@ void MainWindow::on_tree_widget_img_currentItemChanged(QTreeWidgetItem *current, if (iFile.isEmpty() || iDir.isEmpty()) return; - QString filepath(iDir + "/" + iFile); - image_canvas->loadImage(filepath); + image_canvas = getImageCanvas(iFile); } void MainWindow::on_actionOpenDir_triggered() { diff --git a/src/main_window.h b/src/main_window.h index e1f4a71..1e37516 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -30,12 +30,15 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); private: - ImageCanvas * image_canvas; + void loadConfigLabels(); - + ImageCanvas * newImageCanvas(); + ImageCanvas * getImageCanvas(QString name) ; + public: + ImageCanvas * image_canvas ; + QScrollArea * scroll_area ; - QScrollArea * scroll_area ; Name2Labels labels ; Id2Labels id_labels ; QAction * save_action ; @@ -45,6 +48,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { public: QString currentDir() const; QString currentFile() const; + void updateConnect(); + public slots: @@ -55,8 +60,10 @@ public slots: void runWatershed(); void on_tree_widget_img_currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); void on_actionOpenDir_triggered(); + //void on_actionOpen_jsq_triggered(); void on_actionAbout_triggered(); - + void closeTab(int index); + void updateConnect(int index); }; #endif diff --git a/src/main_window.ui b/src/main_window.ui index 16a6247..10b9ba6 100644 --- a/src/main_window.ui +++ b/src/main_window.ui @@ -6,20 +6,88 @@ 0 0 - 1524 - 786 + 1511 + 967 PixelAnnotationTool - + + Qt::ToolButtonIconOnly + + + true + + + true + + + true + + + QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::ForceTabbedDocks|QMainWindow::GroupedDragging|QMainWindow::VerticalTabs + + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + QTabWidget::Triangular + + + 0 + + + Qt::ElideLeft + + + false + + + false + + + true + + + true + + + + Tab 1 + + + + + Tab 2 + + + + + + 0 0 - 1524 + 1511 21 @@ -65,6 +133,21 @@ + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + @@ -183,6 +266,21 @@ + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + @@ -251,6 +349,11 @@ About + + + Open JSQ + + From 33b5f7cfc21a80af9bb6eceb64b091979160f797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 11:05:47 +0200 Subject: [PATCH 02/14] remove scrollAera in MainWindow --- src/image_canvas.cpp | 22 +++++++++++++++------- src/image_canvas.h | 3 ++- src/main_window.cpp | 26 +++++++++++++++----------- src/main_window.h | 5 +++-- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/image_canvas.cpp b/src/image_canvas.cpp index 833d26c..f230860 100644 --- a/src/image_canvas.cpp +++ b/src/image_canvas.cpp @@ -5,13 +5,14 @@ #include #include -ImageCanvas::ImageCanvas(QScrollArea * scroll_parent, MainWindow *ui) : - QLabel(scroll_parent) , - _scroll_parent(scroll_parent), +ImageCanvas::ImageCanvas(MainWindow *ui) : + QLabel() , _ui(ui), _alpha(0.5), _pen_size(30) { + _scroll_parent = new QScrollArea(ui); + setParent(_scroll_parent); resize(800,600); _scale = 1.0; _initPixmap(); @@ -22,6 +23,14 @@ ImageCanvas::ImageCanvas(QScrollArea * scroll_parent, MainWindow *ui) : _undo_list.clear(); _undo_index = 0; _undo = false; + + _scroll_parent->setBackgroundRole(QPalette::Dark); + _scroll_parent->setWidget(this); + +} + +ImageCanvas::~ImageCanvas() { + delete _scroll_parent; } void ImageCanvas::_initPixmap() { @@ -209,15 +218,14 @@ void ImageCanvas::clearMask() { void ImageCanvas::wheelEvent(QWheelEvent * event) { int delta = event->delta() > 0 ? 1 : -1; if (Qt::ShiftModifier == event->modifiers()) { - _ui->scroll_area->verticalScrollBar()->setEnabled(false); + _scroll_parent->verticalScrollBar()->setEnabled(false); int value = _ui->spinbox_pen_size->value() + delta * _ui->spinbox_pen_size->singleStep(); _ui->spinbox_pen_size->setValue(value); emit(_ui->spinbox_pen_size->valueChanged(value)); setSizePen(value); repaint(); } else if (Qt::ControlModifier == event->modifiers()) { - QScrollArea * sc = _ui->scroll_area; - sc->verticalScrollBar()->setEnabled(false); + _scroll_parent->verticalScrollBar()->setEnabled(false); double value = _ui->spinbox_scale->value() + delta * _ui->spinbox_scale->singleStep(); value = std::min(_ui->spinbox_scale->maximum(),value); value = std::max(_ui->spinbox_scale->minimum(), value); @@ -226,7 +234,7 @@ void ImageCanvas::wheelEvent(QWheelEvent * event) { scaleChanged(value); repaint(); } else { - _ui->scroll_area->verticalScrollBar()->setEnabled(true); + _scroll_parent->verticalScrollBar()->setEnabled(true); } } diff --git a/src/image_canvas.h b/src/image_canvas.h index 510fde6..be0b03a 100644 --- a/src/image_canvas.h +++ b/src/image_canvas.h @@ -15,7 +15,8 @@ class ImageCanvas : public QLabel { public: - ImageCanvas(QScrollArea * scroll_parent, MainWindow *ui); + ImageCanvas(MainWindow *ui); + ~ImageCanvas(); void setId(int id); void setMask(const ImageMask & mask); diff --git a/src/main_window.cpp b/src/main_window.cpp index 64b619a..893ffd4 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -40,13 +40,15 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) menuEdit->addAction(redo_action); tabWidget->clear(); - + connect(button_watershed , SIGNAL(released()) , this, SLOT(runWatershed() )); connect(actionOpen_config_file, SIGNAL(triggered()) , this, SLOT(loadConfigFile())); connect(actionSave_config_file, SIGNAL(triggered()) , this, SLOT(saveConfigFile())); connect(tabWidget , SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int) )); connect(tabWidget , SIGNAL(currentChanged(int)) , this, SLOT(updateConnect(int))); + //disconnect(button_watershed, SIGNAL(released()), this, SLOT(runWatershed())); + labels = defaulfLabels(); loadConfigLabels(); @@ -59,6 +61,8 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) } void MainWindow::closeTab(int index) { + ImageCanvas * ic = static_cast(tabWidget->widget(index)); + delete ic; tabWidget->removeTab(index); } @@ -124,7 +128,6 @@ void MainWindow::changeLabel(QListWidgetItem* current, QListWidgetItem* previous void MainWindow::runWatershed() { image_canvas->setWatershedMask(watershed(image_canvas->getImage(), image_canvas->getMask().id)); checkbox_watershed_mask->setCheckState(Qt::CheckState::Checked); - //checkbox_manuel_mask->setCheckState(Qt::CheckState::Unchecked); image_canvas->update(); } @@ -141,37 +144,38 @@ void MainWindow::updateConnect() { } ImageCanvas * MainWindow::newImageCanvas() { - scroll_area = new QScrollArea; - image_canvas = new ImageCanvas(scroll_area, this); + //scroll_area = new QScrollArea; + image_canvas = new ImageCanvas( this); image_canvas->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); image_canvas->setScaledContents(true); - scroll_area->setBackgroundRole(QPalette::Dark); - scroll_area->setWidget(image_canvas); updateConnect(); return image_canvas; } void MainWindow::updateConnect(int index) { image_canvas = static_cast(tabWidget->widget(index)); - scroll_area = image_canvas->getScrollParent(); +// scroll_area = image_canvas->getScrollParent(); updateConnect(); } ImageCanvas * MainWindow::getImageCanvas(QString name) { + //ImageCanvas * image_canvas = NULL; for (int i = 0; i < tabWidget->count(); i++) { if (tabWidget->tabText(i) == name) { - image_canvas = static_cast(tabWidget->widget(i)); + QScrollArea * scroll_area = static_cast(tabWidget->widget(i)); + image_canvas = static_cast(scroll_area->widget()); + //image_canvas = static_cast(tabWidget->widget(i)); updateConnect(); - scroll_area = image_canvas->getScrollParent(); return image_canvas; } } image_canvas = newImageCanvas(); - scroll_area = image_canvas->getScrollParent(); + //scroll_area = image_canvas->getScrollParent(); QString iDir = currentDir(); QString filepath(iDir + "/" + name); image_canvas->loadImage(filepath); - tabWidget->addTab(scroll_area, name); + //tabWidget->addTab(scroll_area, name); + tabWidget->addTab(image_canvas->getScrollParent(), name); return image_canvas; } diff --git a/src/main_window.h b/src/main_window.h index 1e37516..6935a5d 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -37,7 +37,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { public: ImageCanvas * image_canvas ; - QScrollArea * scroll_area ; + //std::vector _image_canvas; + //QScrollArea * scroll_area ; Name2Labels labels ; Id2Labels id_labels ; @@ -49,7 +50,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { QString currentDir() const; QString currentFile() const; void updateConnect(); - + public slots: From 8198cec508b1e07b28a327f2f9b9fcbf31bb2558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 11:59:52 +0200 Subject: [PATCH 03/14] manage better connect/disconnect --- src/image_canvas.cpp | 2 +- src/main_window.cpp | 89 ++++++++++++++++++++++++++------------------ src/main_window.h | 6 ++- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/image_canvas.cpp b/src/image_canvas.cpp index f230860..bbdbd35 100644 --- a/src/image_canvas.cpp +++ b/src/image_canvas.cpp @@ -62,7 +62,7 @@ void ImageCanvas::loadImage(const QString &filename) { _undo_index = 0; if (QFile(_mask_file).exists()) { _mask = ImageMask(_mask_file,_ui->id_labels); - emit(_ui->button_watershed->released()); + _ui->runWatershed(this);// button_watershed->released()); _ui->checkbox_manuel_mask->setChecked(true); _undo_list.push_back(_mask); _undo_index++; diff --git a/src/main_window.cpp b/src/main_window.cpp index 893ffd4..1547b48 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -25,7 +25,7 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) setupUi(this); setWindowTitle(QApplication::translate("MainWindow", "PixelAnnotationTool " PIXEL_ANNOTATION_TOOL_GIT_TAG, Q_NULLPTR)); list_label->setSpacing(1); - + image_canvas = NULL; save_action = new QAction(tr("&Save current image"), this); undo_action = new QAction(tr("&Undo"), this); redo_action = new QAction(tr("&Redo"), this); @@ -125,58 +125,73 @@ void MainWindow::changeLabel(QListWidgetItem* current, QListWidgetItem* previous image_canvas->setId(labels[key].id); } -void MainWindow::runWatershed() { - image_canvas->setWatershedMask(watershed(image_canvas->getImage(), image_canvas->getMask().id)); +void MainWindow::runWatershed(ImageCanvas * ic) { + ic->setWatershedMask(watershed(ic->getImage(), ic->getMask().id)); checkbox_watershed_mask->setCheckState(Qt::CheckState::Checked); - image_canvas->update(); + ic->update(); +} + +void MainWindow::runWatershed() { + ImageCanvas * ic = image_canvas; + if( ic != NULL) + runWatershed(ic); } -void MainWindow::updateConnect() { - connect(spinbox_scale, SIGNAL(valueChanged(double)), image_canvas, SLOT(scaleChanged(double))); - connect(spinbox_alpha, SIGNAL(valueChanged(double)), image_canvas, SLOT(alphaChanged(double))); - connect(spinbox_pen_size, SIGNAL(valueChanged(int)), image_canvas, SLOT(setSizePen(int))); - connect(checkbox_watershed_mask, SIGNAL(clicked()), image_canvas, SLOT(update())); - connect(checkbox_manuel_mask, SIGNAL(clicked()), image_canvas, SLOT(update())); - connect(actionClear, SIGNAL(triggered()), image_canvas, SLOT(clearMask())); - connect(undo_action, SIGNAL(triggered()), image_canvas, SLOT(undo())); - connect(redo_action, SIGNAL(triggered()), image_canvas, SLOT(redo())); - connect(save_action, SIGNAL(triggered()), image_canvas, SLOT(saveMask())); +void MainWindow::updateConnect(const ImageCanvas * ic) { + if (ic == NULL) return; + connect(spinbox_scale, SIGNAL(valueChanged(double)), ic, SLOT(scaleChanged(double))); + connect(spinbox_alpha, SIGNAL(valueChanged(double)), ic, SLOT(alphaChanged(double))); + connect(spinbox_pen_size, SIGNAL(valueChanged(int)), ic, SLOT(setSizePen(int))); + connect(checkbox_watershed_mask, SIGNAL(clicked()), ic, SLOT(update())); + connect(checkbox_manuel_mask, SIGNAL(clicked()), ic, SLOT(update())); + connect(actionClear, SIGNAL(triggered()), ic, SLOT(clearMask())); + connect(undo_action, SIGNAL(triggered()), ic, SLOT(undo())); + connect(redo_action, SIGNAL(triggered()), ic, SLOT(redo())); + connect(save_action, SIGNAL(triggered()), ic, SLOT(saveMask())); +} + +void MainWindow::allDisconnnect(const ImageCanvas * ic) { + if (ic == NULL) return; + disconnect(spinbox_scale, SIGNAL(valueChanged(double)), ic, SLOT(scaleChanged(double))); + disconnect(spinbox_alpha, SIGNAL(valueChanged(double)), ic, SLOT(alphaChanged(double))); + disconnect(spinbox_pen_size, SIGNAL(valueChanged(int)), ic, SLOT(setSizePen(int))); + disconnect(checkbox_watershed_mask, SIGNAL(clicked()), ic, SLOT(update())); + disconnect(checkbox_manuel_mask, SIGNAL(clicked()), ic, SLOT(update())); + disconnect(actionClear, SIGNAL(triggered()), ic, SLOT(clearMask())); + disconnect(undo_action, SIGNAL(triggered()), ic, SLOT(undo())); + disconnect(redo_action, SIGNAL(triggered()), ic, SLOT(redo())); + disconnect(save_action, SIGNAL(triggered()), ic, SLOT(saveMask())); } ImageCanvas * MainWindow::newImageCanvas() { - //scroll_area = new QScrollArea; - image_canvas = new ImageCanvas( this); - image_canvas->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - image_canvas->setScaledContents(true); - updateConnect(); - return image_canvas; + ImageCanvas * ic = new ImageCanvas( this); + ic->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + ic->setScaledContents(true); + updateConnect(ic); + return ic; } void MainWindow::updateConnect(int index) { + allDisconnnect(image_canvas); image_canvas = static_cast(tabWidget->widget(index)); -// scroll_area = image_canvas->getScrollParent(); - updateConnect(); + updateConnect(image_canvas); } -ImageCanvas * MainWindow::getImageCanvas(QString name) { - //ImageCanvas * image_canvas = NULL; +int MainWindow::getImageCanvas(QString name, ImageCanvas * ic) { for (int i = 0; i < tabWidget->count(); i++) { if (tabWidget->tabText(i) == name) { QScrollArea * scroll_area = static_cast(tabWidget->widget(i)); - image_canvas = static_cast(scroll_area->widget()); - //image_canvas = static_cast(tabWidget->widget(i)); - updateConnect(); - return image_canvas; + ic = static_cast(scroll_area->widget()); + return i; } } - image_canvas = newImageCanvas(); - //scroll_area = image_canvas->getScrollParent(); + ic = newImageCanvas(); QString iDir = currentDir(); QString filepath(iDir + "/" + name); - image_canvas->loadImage(filepath); - //tabWidget->addTab(scroll_area, name); - tabWidget->addTab(image_canvas->getScrollParent(), name); - return image_canvas; + ic->loadImage(filepath); + int index = tabWidget->addTab(ic->getScrollParent(), name); + + return index; } QString MainWindow::currentDir() const { @@ -200,8 +215,10 @@ void MainWindow::on_tree_widget_img_currentItemChanged(QTreeWidgetItem *current, QString iDir = currentDir(); if (iFile.isEmpty() || iDir.isEmpty()) return; - - image_canvas = getImageCanvas(iFile); + allDisconnnect(image_canvas); + int index = getImageCanvas(iFile, image_canvas); + updateConnect(image_canvas); + tabWidget->setCurrentIndex(index); } void MainWindow::on_actionOpenDir_triggered() { diff --git a/src/main_window.h b/src/main_window.h index 6935a5d..777f573 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -33,7 +33,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { void loadConfigLabels(); ImageCanvas * newImageCanvas(); - ImageCanvas * getImageCanvas(QString name) ; + int getImageCanvas(QString name, ImageCanvas *ic) ; public: ImageCanvas * image_canvas ; @@ -49,7 +49,9 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { public: QString currentDir() const; QString currentFile() const; - void updateConnect(); + void updateConnect(const ImageCanvas * ic); + void allDisconnnect(const ImageCanvas * ic); + void runWatershed(ImageCanvas * ic); public slots: From 48391c66e8bb2339ea1369d4cc44b545f8f7514d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 12:48:53 +0200 Subject: [PATCH 04/14] fix static cast ImageCanvas --- src/main_window.cpp | 13 +++++++++---- src/main_window.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 1547b48..d70e458 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -61,7 +61,7 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) } void MainWindow::closeTab(int index) { - ImageCanvas * ic = static_cast(tabWidget->widget(index)); + ImageCanvas * ic = getImageCanvas(index); delete ic; tabWidget->removeTab(index); } @@ -173,15 +173,20 @@ ImageCanvas * MainWindow::newImageCanvas() { void MainWindow::updateConnect(int index) { allDisconnnect(image_canvas); - image_canvas = static_cast(tabWidget->widget(index)); + image_canvas = getImageCanvas(index); updateConnect(image_canvas); } +ImageCanvas * MainWindow::getImageCanvas(int index) { + QScrollArea * scroll_area = static_cast(tabWidget->widget(index)); + ImageCanvas * ic = static_cast(scroll_area->widget()); + return ic; +} + int MainWindow::getImageCanvas(QString name, ImageCanvas * ic) { for (int i = 0; i < tabWidget->count(); i++) { if (tabWidget->tabText(i) == name) { - QScrollArea * scroll_area = static_cast(tabWidget->widget(i)); - ic = static_cast(scroll_area->widget()); + ic = getImageCanvas(i); return i; } } diff --git a/src/main_window.h b/src/main_window.h index 777f573..9dc03ad 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -34,7 +34,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { void loadConfigLabels(); ImageCanvas * newImageCanvas(); int getImageCanvas(QString name, ImageCanvas *ic) ; - + ImageCanvas * getImageCanvas(int index); + public: ImageCanvas * image_canvas ; //std::vector _image_canvas; From dfbe649a0f86cd2c4eb383ae7176d8452354996d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 13:40:25 +0200 Subject: [PATCH 05/14] fix crash when right clicked. --- src/image_canvas.cpp | 2 +- src/main_window.cpp | 37 +++++++++++++++++++++++++------------ src/main_window.h | 1 + 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/image_canvas.cpp b/src/image_canvas.cpp index bbdbd35..15263bd 100644 --- a/src/image_canvas.cpp +++ b/src/image_canvas.cpp @@ -30,7 +30,7 @@ ImageCanvas::ImageCanvas(MainWindow *ui) : } ImageCanvas::~ImageCanvas() { - delete _scroll_parent; + _scroll_parent->deleteLater(); } void ImageCanvas::_initPixmap() { diff --git a/src/main_window.cpp b/src/main_window.cpp index d70e458..22241d6 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -41,11 +41,12 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) tabWidget->clear(); - connect(button_watershed , SIGNAL(released()) , this, SLOT(runWatershed() )); - connect(actionOpen_config_file, SIGNAL(triggered()) , this, SLOT(loadConfigFile())); - connect(actionSave_config_file, SIGNAL(triggered()) , this, SLOT(saveConfigFile())); - connect(tabWidget , SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int) )); - connect(tabWidget , SIGNAL(currentChanged(int)) , this, SLOT(updateConnect(int))); + connect(button_watershed , SIGNAL(released()) , this, SLOT(runWatershed() )); + connect(actionOpen_config_file, SIGNAL(triggered()) , this, SLOT(loadConfigFile())); + connect(actionSave_config_file, SIGNAL(triggered()) , this, SLOT(saveConfigFile())); + connect(tabWidget , SIGNAL(tabCloseRequested(int)) , this, SLOT(closeTab(int) )); + connect(tabWidget , SIGNAL(currentChanged(int)) , this, SLOT(updateConnect(int))); + connect(tree_widget_img , SIGNAL(itemClicked(QTreeWidgetItem *,int)), this, SLOT(treeWidgetClicked())); //disconnect(button_watershed, SIGNAL(released()), this, SLOT(runWatershed())); @@ -62,8 +63,11 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) void MainWindow::closeTab(int index) { ImageCanvas * ic = getImageCanvas(index); + tabWidget->removeTab(index); delete ic; - tabWidget->removeTab(index); + if (tabWidget->count() == 0 ) { + image_canvas = NULL; + } } void MainWindow::loadConfigLabels() { @@ -172,6 +176,8 @@ ImageCanvas * MainWindow::newImageCanvas() { } void MainWindow::updateConnect(int index) { + if (index < 0 || index >= tabWidget->count()) + return; allDisconnnect(image_canvas); image_canvas = getImageCanvas(index); updateConnect(image_canvas); @@ -215,15 +221,22 @@ QString MainWindow::currentFile() const { return current->text(0); } -void MainWindow::on_tree_widget_img_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) { - QString iFile = currentFile(); - QString iDir = currentDir(); - if (iFile.isEmpty() || iDir.isEmpty()) - return; + + +void MainWindow::treeWidgetClicked() { + QString iFile = currentFile(); + QString iDir = currentDir(); + if (iFile.isEmpty() || iDir.isEmpty()) + return; allDisconnnect(image_canvas); - int index = getImageCanvas(iFile, image_canvas); + int index = getImageCanvas(iFile, image_canvas); updateConnect(image_canvas); tabWidget->setCurrentIndex(index); + +} + +void MainWindow::on_tree_widget_img_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) { + treeWidgetClicked(); } void MainWindow::on_actionOpenDir_triggered() { diff --git a/src/main_window.h b/src/main_window.h index 9dc03ad..d926144 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -68,6 +68,7 @@ public slots: void on_actionAbout_triggered(); void closeTab(int index); void updateConnect(int index); + void treeWidgetClicked(); }; #endif From 3be2334e878c75ff384e8a0b58affbb5691b99e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 14:38:18 +0200 Subject: [PATCH 06/14] add check save before close tab. --- src/image_canvas.cpp | 4 ++++ src/image_canvas.h | 1 + src/main_window.cpp | 35 ++++++++++++++++++++++++++++------- src/main_window.h | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/image_canvas.cpp b/src/image_canvas.cpp index 15263bd..92f34ce 100644 --- a/src/image_canvas.cpp +++ b/src/image_canvas.cpp @@ -88,6 +88,9 @@ void ImageCanvas::saveMask() { QString color_file = file.dir().absolutePath() + "/" + file.baseName() + "_color_mask.png"; idToColor(watershed_without_border, _ui->id_labels).save(color_file); } + _undo_list.clear(); + _undo_index = 0; + _ui->setStarAtNameOfTab(false); } void ImageCanvas::scaleChanged(double scale) { @@ -164,6 +167,7 @@ void ImageCanvas::mouseReleaseEvent(QMouseEvent * e) { } _undo_list.push_back(_mask); _undo_index++; + _ui->setStarAtNameOfTab(true); _ui->undo_action->setEnabled(true); } diff --git a/src/image_canvas.h b/src/image_canvas.h index be0b03a..3d3322d 100644 --- a/src/image_canvas.h +++ b/src/image_canvas.h @@ -29,6 +29,7 @@ class ImageCanvas : public QLabel { void updateMaskColor(const Id2Labels & labels) { _mask.updateColor(labels); } void loadImage(const QString &file); QScrollArea * getScrollParent() const { return _scroll_parent; } + bool isNotSaved() const { return _undo_list.size() > 1; } protected: void mouseMoveEvent(QMouseEvent * event) override; diff --git a/src/main_window.cpp b/src/main_window.cpp index 22241d6..7125c31 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -1,6 +1,6 @@ #include "main_window.h" #include "utils.h" - +#include #include #include #include @@ -48,21 +48,27 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) connect(tabWidget , SIGNAL(currentChanged(int)) , this, SLOT(updateConnect(int))); connect(tree_widget_img , SIGNAL(itemClicked(QTreeWidgetItem *,int)), this, SLOT(treeWidgetClicked())); - //disconnect(button_watershed, SIGNAL(released()), this, SLOT(runWatershed())); - labels = defaulfLabels(); loadConfigLabels(); connect(list_label, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeLabel(QListWidgetItem*, QListWidgetItem*))); connect(list_label, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(changeColor(QListWidgetItem*))); - - - } void MainWindow::closeTab(int index) { ImageCanvas * ic = getImageCanvas(index); + if (ic == NULL) + throw std::exception("error index"); + + if (ic->isNotSaved()) { + QMessageBox::StandardButton reply = QMessageBox::question(this, "Current image is not saved", + "You will close the current image, Would you like saved image before ?", QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::Yes) { + ic->saveMask(); + } + } + tabWidget->removeTab(index); delete ic; if (tabWidget->count() == 0 ) { @@ -141,6 +147,21 @@ void MainWindow::runWatershed() { runWatershed(ic); } +void MainWindow::setStarAtNameOfTab(bool star) { + if (tabWidget->count() > 0) { + int index = tabWidget->currentIndex(); + QString name = tabWidget->tabText(index); + if (star && !name.endsWith("*")) { //add star + name += "*"; + tabWidget->setTabText(index, name); + } else if (!star && name.endsWith("*")) { //remove star + int pos = name.lastIndexOf('*'); + name = name.left(pos); + tabWidget->setTabText(index, name); + } + } +} + void MainWindow::updateConnect(const ImageCanvas * ic) { if (ic == NULL) return; connect(spinbox_scale, SIGNAL(valueChanged(double)), ic, SLOT(scaleChanged(double))); @@ -191,7 +212,7 @@ ImageCanvas * MainWindow::getImageCanvas(int index) { int MainWindow::getImageCanvas(QString name, ImageCanvas * ic) { for (int i = 0; i < tabWidget->count(); i++) { - if (tabWidget->tabText(i) == name) { + if (tabWidget->tabText(i).startsWith(name) ) { ic = getImageCanvas(i); return i; } diff --git a/src/main_window.h b/src/main_window.h index d926144..50c2233 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -53,7 +53,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { void updateConnect(const ImageCanvas * ic); void allDisconnnect(const ImageCanvas * ic); void runWatershed(ImageCanvas * ic); - + void setStarAtNameOfTab(bool star); public slots: From 362ea65be60e191531fd2b2540a2df1cdbbdc3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 15:00:40 +0200 Subject: [PATCH 07/14] remove include unused --- src/main_window.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 7125c31..1b7bfad 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -15,7 +15,6 @@ #include #include #include "pixel_annotation_tool_version.h" -#include #include "about_dialog.h" From f72947f6fbd86ccf26670c890f98fbc94d7e346e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 15:38:03 +0200 Subject: [PATCH 08/14] add shortcut CTRL+W to remove tab. --- src/main_window.cpp | 10 +++++++++- src/main_window.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 1b7bfad..2df7809 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -26,15 +26,18 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) list_label->setSpacing(1); image_canvas = NULL; save_action = new QAction(tr("&Save current image"), this); + close_tab_action = new QAction(tr("&Close current tab"), this); undo_action = new QAction(tr("&Undo"), this); redo_action = new QAction(tr("&Redo"), this); undo_action->setShortcuts(QKeySequence::Undo); redo_action->setShortcuts(QKeySequence::Redo); save_action->setShortcut(Qt::CTRL+Qt::Key_S); + close_tab_action->setShortcut(Qt::CTRL + Qt::Key_W); undo_action->setEnabled(false); redo_action->setEnabled(false); menuFile->addAction(save_action); + menuFile->addAction(close_tab_action); menuEdit->addAction(undo_action); menuEdit->addAction(redo_action); @@ -43,10 +46,11 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) connect(button_watershed , SIGNAL(released()) , this, SLOT(runWatershed() )); connect(actionOpen_config_file, SIGNAL(triggered()) , this, SLOT(loadConfigFile())); connect(actionSave_config_file, SIGNAL(triggered()) , this, SLOT(saveConfigFile())); + connect(close_tab_action , SIGNAL(triggered()) , this, SLOT(closeCurrentTab())); connect(tabWidget , SIGNAL(tabCloseRequested(int)) , this, SLOT(closeTab(int) )); connect(tabWidget , SIGNAL(currentChanged(int)) , this, SLOT(updateConnect(int))); connect(tree_widget_img , SIGNAL(itemClicked(QTreeWidgetItem *,int)), this, SLOT(treeWidgetClicked())); - + labels = defaulfLabels(); loadConfigLabels(); @@ -55,6 +59,10 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) connect(list_label, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(changeColor(QListWidgetItem*))); } +void MainWindow::closeCurrentTab() { + closeTab(tabWidget->currentIndex()); +} + void MainWindow::closeTab(int index) { ImageCanvas * ic = getImageCanvas(index); if (ic == NULL) diff --git a/src/main_window.h b/src/main_window.h index 50c2233..e354ec8 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -44,6 +44,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow { Name2Labels labels ; Id2Labels id_labels ; QAction * save_action ; + QAction * close_tab_action; QAction * undo_action ; QAction * redo_action ; QString curr_open_dir; @@ -67,6 +68,7 @@ public slots: //void on_actionOpen_jsq_triggered(); void on_actionAbout_triggered(); void closeTab(int index); + void closeCurrentTab(); void updateConnect(int index); void treeWidgetClicked(); }; From a56e6a00fae2f7439d2702a58d28a0ba287a7bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 15:58:51 +0200 Subject: [PATCH 09/14] update Qt path of appveyoer --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e42d9f5..476eff0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,7 @@ environment: - CMAKE_BUILD_TYPE: Release install: - - cmd: set QT5_DIR=C:\Qt\5.9.3\msvc2015_64\lib\cmake + - cmd: set QT5_DIR=C:\Qt\5.10.1\msvc2015_64\lib\cmake - cmd: choco install OpenCV - cmd: choco install curl - cmd: set OPENCV_DIR=C:\tools\opencv\build From 49d2bd4672655f36e4767fe6cb52123f6455e62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 16:14:34 +0200 Subject: [PATCH 10/14] add travis on dev branch --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9178eca..78586fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,11 @@ os: env: - CONFIG=Release + +branches: + only: + - master + - dev before_install: - QT_VERSION_MM=59 From 993e62cbc8e85b502c7927391d7078c69f2cb418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 17:32:04 +0200 Subject: [PATCH 11/14] fix compile on linux --- src/main_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 2df7809..6b76ba3 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -66,7 +66,7 @@ void MainWindow::closeCurrentTab() { void MainWindow::closeTab(int index) { ImageCanvas * ic = getImageCanvas(index); if (ic == NULL) - throw std::exception("error index"); + throw std::logic_error("error index"); if (ic->isNotSaved()) { QMessageBox::StandardButton reply = QMessageBox::question(this, "Current image is not saved", From 7e25725ea3da0dc570e371e48227dbf936794099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 18:05:14 +0200 Subject: [PATCH 12/14] add checkbox to keep or not the border provide by watershed. --- src/image_canvas.cpp | 9 ++++++--- src/main_window.cpp | 3 +++ src/main_window.ui | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/image_canvas.cpp b/src/image_canvas.cpp index 92f34ce..b1d5e15 100644 --- a/src/image_canvas.cpp +++ b/src/image_canvas.cpp @@ -82,11 +82,14 @@ void ImageCanvas::saveMask() { _mask.id.save(_mask_file); if (!_watershed.id.isNull()) { - QImage watershed_without_border = removeBorder(_watershed.id, _ui->id_labels); - watershed_without_border.save(_watershed_file); + QImage watershed = _watershed.id; + if (!_ui->checkbox_border_ws->isChecked()) { + watershed = removeBorder(_watershed.id, _ui->id_labels); + } + watershed.save(_watershed_file); QFileInfo file(_img_file); QString color_file = file.dir().absolutePath() + "/" + file.baseName() + "_color_mask.png"; - idToColor(watershed_without_border, _ui->id_labels).save(color_file); + idToColor(watershed, _ui->id_labels).save(color_file); } _undo_list.clear(); _undo_index = 0; diff --git a/src/main_window.cpp b/src/main_window.cpp index 6b76ba3..923616a 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -180,6 +180,8 @@ void MainWindow::updateConnect(const ImageCanvas * ic) { connect(undo_action, SIGNAL(triggered()), ic, SLOT(undo())); connect(redo_action, SIGNAL(triggered()), ic, SLOT(redo())); connect(save_action, SIGNAL(triggered()), ic, SLOT(saveMask())); + connect(checkbox_border_ws, SIGNAL(clicked()), ic, SLOT(update())); + } void MainWindow::allDisconnnect(const ImageCanvas * ic) { @@ -193,6 +195,7 @@ void MainWindow::allDisconnnect(const ImageCanvas * ic) { disconnect(undo_action, SIGNAL(triggered()), ic, SLOT(undo())); disconnect(redo_action, SIGNAL(triggered()), ic, SLOT(redo())); disconnect(save_action, SIGNAL(triggered()), ic, SLOT(saveMask())); + disconnect(checkbox_border_ws, SIGNAL(clicked()), ic, SLOT(update())); } ImageCanvas * MainWindow::newImageCanvas() { diff --git a/src/main_window.ui b/src/main_window.ui index 10b9ba6..ddecd81 100644 --- a/src/main_window.ui +++ b/src/main_window.ui @@ -228,6 +228,13 @@ + + + + keep border provide by the watershed + + + From 98e9c619c5bfad9c637dbf630d4e93cbc167cedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 18:13:37 +0200 Subject: [PATCH 13/14] fix close tab action --- src/main_window.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 923616a..653470e 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -37,7 +37,7 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) redo_action->setEnabled(false); menuFile->addAction(save_action); - menuFile->addAction(close_tab_action); + menuEdit->addAction(close_tab_action); menuEdit->addAction(undo_action); menuEdit->addAction(redo_action); @@ -60,7 +60,9 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) } void MainWindow::closeCurrentTab() { - closeTab(tabWidget->currentIndex()); + int index = tabWidget->currentIndex(); + if(index>=0) + closeTab(index); } void MainWindow::closeTab(int index) { From a7106b4d8bb6697a33078b48af1ef0605ab4771a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Br=C3=A9h=C3=A9ret?= Date: Wed, 9 May 2018 18:13:47 +0200 Subject: [PATCH 14/14] add make bat file --- scripts_to_build/make.bat | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 scripts_to_build/make.bat diff --git a/scripts_to_build/make.bat b/scripts_to_build/make.bat new file mode 100644 index 0000000..7aacb31 --- /dev/null +++ b/scripts_to_build/make.bat @@ -0,0 +1,6 @@ +cd build +cd x64 +cmake --build . --config Release +cmake --build . --config Release --target make_zip + +PAUSE \ No newline at end of file