Skip to content

Commit 2ee7f3d

Browse files
committed
fixed drag-and-drop for import of WSIs. Also continued on adding batch mode support. Need to add signal/slots for catching when pipelines are finished, before continuing to the next WSIs.
1 parent 0771786 commit 2ee7f3d

File tree

1 file changed

+37
-43
lines changed

1 file changed

+37
-43
lines changed

source/MainWindow.cpp

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,45 +1731,11 @@ void MainWindow::selectFile() {
17311731

17321732
void MainWindow::selectFileDrag(const QList<QString> &fileNames) {
17331733

1734-
// check if view object list is empty, if not, prompt to save results or not, if not clear
1735-
if (pageComboBox->count() > 1) {
1736-
// prompt
1737-
QMessageBox mBox;
1738-
mBox.setIcon(QMessageBox::Warning);
1739-
mBox.setStyleSheet(mWidget->styleSheet());
1740-
mBox.setText("There are unsaved results.");
1741-
mBox.setInformativeText("Do you wish to save them?");
1742-
mBox.setDefaultButton(QMessageBox::Save);
1743-
mBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
1744-
int ret = mBox.exec();
1745-
1746-
switch (ret) {
1747-
case QMessageBox::Save:
1748-
std::cout << "Results not saved yet. Just cancelled the switch!" << std::endl;
1749-
// Save was clicked
1750-
return;
1751-
case QMessageBox::Discard:
1752-
// Don't Save was clicked
1753-
std::cout << "Discarded!" << std::endl;
1754-
break;
1755-
case QMessageBox::Cancel:
1756-
// Cancel was clicked
1757-
std::cout << "Cancelled!" << std::endl;
1758-
return;
1759-
default:
1760-
// should never be reached
1761-
break;
1762-
}
1763-
}
1764-
/*
1765-
if (pageComboBox->count() != 0) { // if not empty, clear
1766-
pageComboBox->clear();
1767-
exportComboBox->clear();
1768-
}
1769-
*/
17701734

1735+
// for a new selection of wsi(s), should reset and update these QWidgets
17711736
pageComboBox->clear();
17721737
exportComboBox->clear();
1738+
m_rendererList.clear();
17731739

17741740
auto progDialog = QProgressDialog(mWidget);
17751741
progDialog.setRange(0, fileNames.count()-1);
@@ -1780,6 +1746,20 @@ void MainWindow::selectFileDrag(const QList<QString> &fileNames) {
17801746
progDialog.move(mWidget->width() - progDialog.width() / 2, - mWidget->width() / 2 - progDialog.width() / 2);
17811747
progDialog.show();
17821748

1749+
QCoreApplication::processEvents(QEventLoop::AllEvents, 0);
1750+
auto currentPosition = curr_pos;
1751+
1752+
// need to handle scenario where a WSI is added, but there already exists N WSIs from before
1753+
auto nb_wsis_in_list = wsiList.size();
1754+
if (nb_wsis_in_list != 0)
1755+
currentPosition = nb_wsis_in_list;
1756+
1757+
// Get old view, and remove it from Widget
1758+
currentView = getView(0);
1759+
currentView->stopPipeline();
1760+
currentView->setSynchronizedRendering(false); // Disable synchronized rendering
1761+
currentView->removeAllRenderers(); // VERY IMPORTANT THAT THIS IS DONE AFTER!!!
1762+
17831763
QCoreApplication::processEvents(QEventLoop::AllEvents, 0);
17841764

17851765
int counter = 0;
@@ -3159,7 +3139,7 @@ void MainWindow::runPipeline(std::string path) {
31593139
currentWSIs = m_runForProjectWsis;
31603140
}
31613141
else {
3162-
currentWSIs.push_back(filename); // wsiList[curr_pos]);
3142+
currentWSIs.push_back(filename);
31633143
}
31643144

31653145
auto progDialog = QProgressDialog(mWidget);
@@ -3197,7 +3177,19 @@ void MainWindow::runPipeline(std::string path) {
31973177

31983178
// parse fpl-file, and run pipeline with corresponding input arguments
31993179
auto pipeline = Pipeline(path, arguments);
3200-
pipeline.parse();
3180+
if (m_runForProject) {
3181+
pipeline.parse({}, false);
3182+
}
3183+
else {
3184+
pipeline.parse();
3185+
}
3186+
3187+
if (m_runForProject) {
3188+
auto data = pipeline.getAllPipelineOutputData([](float progress) {
3189+
std::cout << "Progress: " << 100 * progress << "%" << std::endl;
3190+
});
3191+
std::cout << "Done" << std::endl;
3192+
}
32013193

32023194
// get and start running POs
32033195
for (auto&& po : pipeline.getProcessObjects()) {
@@ -3208,11 +3200,13 @@ void MainWindow::runPipeline(std::string path) {
32083200
}
32093201
}
32103202

3211-
// load renderers, if any
3212-
for (const auto& renderer : pipeline.getRenderers()) {
3213-
auto currId = createRandomNumbers_(8);
3214-
insertRenderer("result_" + currId, renderer);
3215-
createDynamicViewWidget("result_" + currId, "result_" + currId);
3203+
if (!m_runForProject) {
3204+
// load renderers, if any
3205+
for (const auto& renderer : pipeline.getRenderers()) {
3206+
auto currId = createRandomNumbers_(8);
3207+
insertRenderer("result_" + currId, renderer);
3208+
createDynamicViewWidget("result_" + currId, "result_" + currId);
3209+
}
32163210
}
32173211

32183212
// update progress bar

0 commit comments

Comments
 (0)