Skip to content

Commit

Permalink
Merge pull request SCIInstitute#1337 from SCIInstitute/studio_export_…
Browse files Browse the repository at this point in the history
…multiple

Studio export multiple files for multiple domains
  • Loading branch information
akenmorris authored Jun 21, 2021
2 parents f989e39 + 9e33de1 commit 1a8a1fa
Show file tree
Hide file tree
Showing 22 changed files with 332 additions and 176 deletions.
1 change: 1 addition & 0 deletions Libs/Mesh/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Mesh& Mesh::write(const std::string &pathname)
auto writer = vtkSmartPointer<vtkPolyDataWriter>::New();
writer->SetFileName(pathname.c_str());
writer->SetInputData(this->mesh);
writer->WriteArrayMetaDataOff(); // needed for older readers to read these files
writer->Update();
return *this;
}
Expand Down
9 changes: 6 additions & 3 deletions Libs/Project/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void Project::store_subjects()
groomed_present = true;
int count = 0;
while (groomed_files.size() > groomed_columns.size()) {
groomed_columns.push_back(this->get_new_file_column(GROOMED_PREFIX, count));
groomed_columns.push_back(this->get_new_file_column(GROOMED_PREFIX, count++));
}
this->set_list(groomed_columns, i, groomed_files);

Expand Down Expand Up @@ -355,6 +355,7 @@ void Project::store_subjects()
this->get_new_file_column(std::string(LOCAL_PARTICLES) + "_", count));
world_columns.push_back(
this->get_new_file_column(std::string(WORLD_PARTICLES) + "_", count));
count++;
}

this->set_list(local_columns, i, local_files);
Expand Down Expand Up @@ -765,11 +766,13 @@ int Project::get_or_create_worksheet(std::string name)
//---------------------------------------------------------------------------
std::string Project::get_new_file_column(std::string name, int idx)
{
return name + std::to_string(idx+1);

if (idx == 0) {
return name + "_file";
return name + "file";
}
else {
return name + "_file_" + std::to_string(idx);
return name + "file_" + std::to_string(idx);
}
}

Expand Down
28 changes: 4 additions & 24 deletions Studio/src/Application/Analysis/AnalysisTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ void AnalysisTool::on_reconstructionButton_clicked()
connect(thread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(result_ready()), this, SLOT(handle_reconstruction_complete()));

connect(worker, &ShapeworksWorker::error_message, this, &AnalysisTool::handle_error);
connect(worker, &ShapeworksWorker::warning_message, this, &AnalysisTool::handle_warning);
connect(worker, &ShapeworksWorker::message, this, &AnalysisTool::handle_message);
connect(worker, &ShapeworksWorker::error_message, this, &AnalysisTool::error);
connect(worker, &ShapeworksWorker::warning_message, this, &AnalysisTool::warning);
connect(worker, &ShapeworksWorker::message, this, &AnalysisTool::message);

connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
thread->start();
Expand Down Expand Up @@ -433,7 +433,7 @@ bool AnalysisTool::compute_stats()
int point_size = points[0].size();
for (auto&& p : points) {
if (p.size() != point_size) {
this->handle_error(
emit error(
"Inconsistency in data, particle files must contain the same number of points");
return false;
}
Expand Down Expand Up @@ -864,26 +864,6 @@ ShapeHandle AnalysisTool::create_shape_from_points(StudioParticles points)
return shape;
}

//---------------------------------------------------------------------------
void AnalysisTool::handle_error(std::string message_string)
{
STUDIO_LOG_ERROR(QString::fromStdString(message_string));
emit error(message_string);
}

//---------------------------------------------------------------------------
void AnalysisTool::handle_warning(std::string message_string)
{
STUDIO_LOG_ERROR(QString::fromStdString(message_string));
emit error(message_string);
}

//---------------------------------------------------------------------------
void AnalysisTool::handle_message(std::string message_string)
{
STUDIO_LOG_MESSAGE(QString::fromStdString(message_string));
emit message(message_string);
}

//---------------------------------------------------------------------------
void AnalysisTool::set_feature_map(const std::string& feature_map)
Expand Down
9 changes: 3 additions & 6 deletions Studio/src/Application/Analysis/AnalysisTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ public Q_SLOTS:
//! Set the currently selected feature map
void set_feature_map(const std::string& feature_map);

void handle_error(std::string message);
void handle_warning(std::string message);
void handle_message(std::string message);

void group_changed();

bool groups_active();
Expand All @@ -150,8 +146,9 @@ public Q_SLOTS:
void update_view();
void pca_update();
void progress(int);
void message(std::string);
void error(std::string);
void message(QString);
void error(QString);
void warning(QString);
void reconstruction_complete();

private:
Expand Down
13 changes: 11 additions & 2 deletions Studio/src/Application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,17 @@ FILE(GLOB STUDIO_ANALYSIS_HDRS Analysis/*.h)
FILE(GLOB STUDIO_GROOM_SRCS Groom/*.cpp)
FILE(GLOB STUDIO_GROOM_HDRS Groom/*.h)

FILE(GLOB STUDIO_UTILS_SRCS Utils/*.cpp)
FILE(GLOB STUDIO_UTILS_HDRS Utils/*.h)
SET(STUDIO_UTILS_SRCS
Utils/StackWalker.cpp
Utils/WindowsCrashHandler.cpp
Utils/StudioUtils.cpp
)

SET(STUDIO_UTILS_HDRS
Utils/StackWalker.h
Utils/WindowsCrashHandler.h
Utils/StudioUtils.h
)

SET(STUDIO_INTERFACE_SRCS
Interface/SplashScreen.cpp
Expand Down
2 changes: 1 addition & 1 deletion Studio/src/Application/Data/MeshManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void MeshManager::check_error_status(MeshHandle mesh)
this->error_emitted_ = true;
std::string message = "Error during mesh construction:\n\n" + mesh->get_error_message()
+ "\n\nFurther messages will be suppressed\n";
emit error_encountered(message);
emit error_encountered(QString::fromStdString(message));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Studio/src/Application/Data/MeshManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public Q_SLOTS:

void new_mesh();

void error_encountered(std::string message);
void error_encountered(QString message);

void progress(int);
void status(std::string);
void status(QString);

private:

Expand Down
8 changes: 2 additions & 6 deletions Studio/src/Application/Data/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void Session::handle_new_mesh()
}

//---------------------------------------------------------------------------
void Session::handle_message(std::string s)
void Session::handle_message(QString s)
{
emit message(s);
}
Expand Down Expand Up @@ -379,14 +379,9 @@ bool Session::load_light_project(QString filename)
}
}

//this->calculate_reconstructed_samples();

this->parameters().set("view_state", Visualizer::MODE_RECONSTRUCTION_C);
this->parameters().set("tool_state", Session::ANALYSIS_C);

//this->preferences_.set_preference("display_state",
// QString::fromStdString(Visualizer::MODE_RECONSTRUCTION_C));
// this->preferences_.set_preference("tool_state", QString::fromStdString(Session::ANALYSIS_C));
this->renumber_shapes();

this->project_->store_subjects();
Expand Down Expand Up @@ -594,6 +589,7 @@ bool Session::load_point_files(std::vector<std::string> local, std::vector<std::
if (this->shapes_.size() <= i) {
auto shape = QSharedPointer<Shape>(new Shape);
std::shared_ptr<Subject> subject = std::make_shared<Subject>();
subject->set_number_of_domains(domains_per_shape);
shape->set_mesh_manager(this->mesh_manager_);
shape->set_subject(subject);
this->project_->get_subjects().push_back(subject);
Expand Down
5 changes: 3 additions & 2 deletions Studio/src/Application/Data/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Q_OBJECT;
public Q_SLOTS:
void handle_clear_cache();
void handle_new_mesh();
void handle_message(std::string s);
void handle_message(QString s);
void handle_thread_complete();

signals:
Expand All @@ -130,7 +130,8 @@ public Q_SLOTS:
void points_changed();
void update_display();
void new_mesh();
void message(std::string s);
void message(QString);
void error(QString);

public:
// constants
Expand Down
7 changes: 3 additions & 4 deletions Studio/src/Application/Groom/GroomTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void GroomTool::on_autopad_checkbox_stateChanged(int state)
}

//---------------------------------------------------------------------------
void GroomTool::handle_error(std::string msg)
void GroomTool::handle_error(QString msg)
{
this->groom_is_running_ = false;
emit error_message(msg);
Expand Down Expand Up @@ -253,7 +253,7 @@ void GroomTool::on_run_groom_button_clicked()
connect(thread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, &ShapeworksWorker::finished, this, &GroomTool::handle_thread_complete);
connect(this->groom_.data(), &QGroom::progress, this, &GroomTool::handle_progress);
connect(worker, SIGNAL(error_message(std::string)), this, SLOT(handle_error(std::string)));
connect(worker, &ShapeworksWorker::error_message, this, &GroomTool::handle_error);
connect(worker, &ShapeworksWorker::message, this, &GroomTool::message);
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
thread->start();
Expand All @@ -267,8 +267,7 @@ void GroomTool::handle_thread_complete()
{
emit progress(95);

std::string duration = QString::number(this->timer_.elapsed() / 1000.0, 'f',
1).toStdString();
QString duration = QString::number(this->timer_.elapsed() / 1000.0, 'f', 1);
emit message("Groom Complete. Duration: " + duration + " seconds");

// trigger reload of meshes
Expand Down
6 changes: 3 additions & 3 deletions Studio/src/Application/Groom/GroomTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Q_OBJECT;
Q_SIGNALS:
void groom_start();
void groom_complete();
void error_message(std::string);
void message(std::string);
void error_message(QString);
void message(QString);
void progress(int);

public Q_SLOTS:
Expand All @@ -74,7 +74,7 @@ public Q_SLOTS:

void handle_thread_complete();
void handle_progress(int val);
void handle_error(std::string msg);
void handle_error(QString msg);

private:

Expand Down
15 changes: 7 additions & 8 deletions Studio/src/Application/Optimize/OptimizeTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ OptimizeTool::~OptimizeTool()
{}

//---------------------------------------------------------------------------
void OptimizeTool::handle_error(std::string msg)
void OptimizeTool::handle_error(QString msg)
{
emit error_message(msg);
this->update_run_button();
}

//---------------------------------------------------------------------------
void OptimizeTool::handle_warning(std::string msg)
void OptimizeTool::handle_warning(QString msg)
{
emit warning_message(msg);
}
Expand All @@ -109,7 +109,7 @@ void OptimizeTool::handle_warning(std::string msg)
void OptimizeTool::handle_progress(int val, QString progress_message)
{
emit progress(val);
emit status(progress_message.toStdString());
emit status(progress_message);

auto particles = this->optimize_->GetParticles();
this->session_->update_particles(particles);
Expand All @@ -126,8 +126,7 @@ void OptimizeTool::handle_optimize_complete()
this->session_->get_project()->store_subjects();
emit progress(100);

std::string duration = QString::number(this->elapsed_timer_.elapsed() / 1000.0, 'f',
1).toStdString();
QString duration = QString::number(this->elapsed_timer_.elapsed() / 1000.0, 'f', 1);
emit message("Optimize Complete. Duration: " + duration + " seconds");
emit optimize_complete();
this->update_run_button();
Expand Down Expand Up @@ -178,8 +177,8 @@ void OptimizeTool::on_run_optimize_button_clicked()
connect(thread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(result_ready()), this, SLOT(handle_optimize_complete()));
connect(this->optimize_.data(), &QOptimize::progress, this, &OptimizeTool::handle_progress);
connect(worker, SIGNAL(error_message(std::string)), this, SLOT(handle_error(std::string)));
connect(worker, SIGNAL(message(std::string)), this, SLOT(handle_message(std::string)));
connect(worker, &ShapeworksWorker::error_message, this, &OptimizeTool::handle_error);
connect(worker, &ShapeworksWorker::message, this, &OptimizeTool::handle_message);
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
Expand All @@ -189,7 +188,7 @@ void OptimizeTool::on_run_optimize_button_clicked()
}

//---------------------------------------------------------------------------
void OptimizeTool::handle_message(std::string s)
void OptimizeTool::handle_message(QString s)
{
emit message(s);
}
Expand Down
14 changes: 7 additions & 7 deletions Studio/src/Application/Optimize/OptimizeTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public Q_SLOTS:
void on_restoreDefaults_clicked();
void handle_optimize_complete();
void handle_progress(int val, QString message);
void handle_error(std::string);
void handle_warning(std::string);
void handle_message(std::string);
void handle_error(QString);
void handle_warning(QString);
void handle_message(QString);

void update_ui_elements();

Expand All @@ -65,11 +65,11 @@ public Q_SLOTS:
void optimize_start();
void optimize_complete();

void error_message(std::string);
void warning_message(std::string);
void error_message(QString);
void warning_message(QString);
void progress(int);
void message(std::string);
void status(std::string);
void message(QString);
void status(QString);

private:

Expand Down
24 changes: 24 additions & 0 deletions Studio/src/Application/Utils/StudioUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <Utils/StudioUtils.h>

#include <QMessageBox>

namespace shapeworks {

bool StudioUtils::ask_multiple_domains_as_single(QWidget* parent, std::shared_ptr<Project> project)
{
bool single = true;
if (project->get_number_of_domains_per_subject() > 0) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(parent, "Multiple Domains",
"This export contains multiple domains.\n\n"
"Would you like each domain exported separately?\n\n"
"Each will be suffixed with the domain name.",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
single = false;
}
}
return single;
}

}
13 changes: 13 additions & 0 deletions Studio/src/Application/Utils/StudioUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <Libs/Project/Project.h>
class QWidget;

namespace shapeworks {

class StudioUtils {
public:
static bool ask_multiple_domains_as_single(QWidget *parent, std::shared_ptr<Project> project);
};

} // namespace shapeworks
Loading

0 comments on commit 1a8a1fa

Please sign in to comment.