summaryrefslogtreecommitdiffstats
path: root/Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp')
-rw-r--r--Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp b/Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp
new file mode 100644
index 0000000..5392621
--- /dev/null
+++ b/Master/Modellbildung_und_Simulation/Aufgabenblatt1/Superposition/src/SuperpositionController.cpp
@@ -0,0 +1,104 @@
+/*
+ * SuperpositionController.cpp
+ *
+ * Created on: 01.04.2011
+ * Author: sven
+ */
+#ifndef SUPERPOSITIONCONTROLLER_H_
+ #include "SuperpositionController.h"
+#endif
+
+#ifndef _GLIBCXX_IOSTREAM
+ #include <iostream>
+#endif
+
+#ifndef WAVEFILESUPERPOSITION_H_
+ #include "WavefileSuperposition.h"
+#endif
+
+const char* SuperpositionController::UI_FILENAME = "ui/superpos.glade";
+
+SuperpositionController::SuperpositionController()
+{
+ Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file(UI_FILENAME);
+ builder->get_widget("mainwindow",mPtrMainWin);
+ builder->get_widget("sourcefile1",mPtrSrcFile1);
+ builder->get_widget("sourcefile2",mPtrSrcFile2);
+ builder->get_widget("destinationfile",mPtrDstFile);
+ builder->get_widget("src1btn",mPtrOpenBtnSrc1);
+ builder->get_widget("src2btn",mPtrOpenBtnSrc2);
+ builder->get_widget("dstbtn",mPtrOpenBtnDst);
+ builder->get_widget("startbtn",mPtrStartBtn);
+
+ mPtrMainWin->signal_hide().connect(sigc::ptr_fun(&Gtk::Main::quit));
+ mPtrOpenBtnSrc1->signal_clicked().connect(sigc::mem_fun(this,&SuperpositionController::on_button_src1));
+ mPtrOpenBtnSrc2->signal_clicked().connect(sigc::mem_fun(this,&SuperpositionController::on_button_src2));
+ mPtrOpenBtnDst->signal_clicked().connect(sigc::mem_fun(this,&SuperpositionController::on_button_dst));
+ mPtrStartBtn->signal_clicked().connect(sigc::mem_fun(this,&SuperpositionController::on_button_start));
+}
+
+SuperpositionController::~SuperpositionController() {
+}
+
+void SuperpositionController::startApp(Gtk::Main& kit)
+{
+ kit.run(*mPtrMainWin);
+}
+
+void SuperpositionController::on_button_src1()
+{
+ std::string filename;
+ choose_file(filename);
+ mParams.setSourceFileOne(filename);
+ mPtrSrcFile1->set_text(mParams.getSourceFileOne());
+}
+
+void SuperpositionController::on_button_src2()
+{
+ std::string filename;
+ choose_file(filename);
+ mParams.setSourceFileTwo(filename);
+ mPtrSrcFile2->set_text(mParams.getSourceFileTwo());
+}
+
+void SuperpositionController::on_button_dst()
+{
+ std::string filename;
+ choose_file(filename);
+ mParams.setDestinationFile(filename);
+ mPtrDstFile->set_text(mParams.getDestinationFile());
+}
+
+void SuperpositionController::choose_file(std::string& filename)
+{
+ Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file(UI_FILENAME);
+ Gtk::FileChooserDialog* ptrFilechooser;
+ builder->get_widget("filechooserdlg",ptrFilechooser);
+ Gtk::FileFilter waveFilter;
+ waveFilter.set_name("Wave files");
+ waveFilter.add_pattern("*.wav");
+ ptrFilechooser->add_filter(waveFilter);
+ ptrFilechooser->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ ptrFilechooser->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+ ptrFilechooser->set_transient_for(*mPtrMainWin);
+ int result = ptrFilechooser->run();
+ switch (result)
+ {
+ case Gtk::RESPONSE_OK:
+ filename = ptrFilechooser->get_filename();
+ break;
+ default:
+ break;
+ }
+ delete ptrFilechooser;
+}
+
+void SuperpositionController::on_button_start()
+{
+ if(!mParams.validate())
+ {
+ std::cout << "Please specify 3 different files" << std::endl;
+ return;
+ }
+ WavefileSuperposition superPos(mParams);
+}