#include <iostream>
-ImageSaveDialog::ImageSaveDialog(QGLWidget *newglwidget, QWidget *parent)
- : QDialog(parent)
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
+
+ImageSaveDialog::ImageSaveDialog(boost::shared_ptr<QDir> default_dir_,
+ QGLWidget *newglwidget,
+ QWidget *parent)
+ : QDialog(parent),
+ default_dir(default_dir_)
{
setWindowTitle(tr("Mussa Save Image"));
setLayout(layout);
}
+QDir ImageSaveDialog::defaultDir() const
+{
+ return *default_dir;
+}
+
void ImageSaveDialog::accept()
{
bool endDialog = true;
QString filePath;
filePath = QFileDialog::getSaveFileName(this,
"Choose a filename to save image",
- ".",
+ default_dir->absolutePath(),
"Images (*.png *.jpg)");
if (filePath.isNull()) {
filePath.append(".png");
pixmap.save(filePath, "PNG");
}
+ fs::path path(filePath.toStdString(), fs::native);
+ default_dir->setPath(path.branch_path().native_directory_string().c_str());
}
}
#ifndef _IMAGESAVEDIALOG_H_
#define _IMAGESAVEDIALOG_H_
+
+#include <boost/shared_ptr.hpp>
#include <QDialog>
+#include <QDir>
class ImageScaler;
class QLabel;
Q_OBJECT
public:
- ImageSaveDialog(QGLWidget *qlwidget = 0, QWidget *parent = 0);
-
+ ImageSaveDialog(boost::shared_ptr<QDir> default_dir_, QGLWidget *qlwidget = 0, QWidget *parent = 0);
+ QDir defaultDir() const;
+
public slots:
void accept();
void reject();
void savePixmap(bool &endDialog);
QSize getOpenGlPixmapSize();
QPixmap renderOpenGlPixmap();
-
+
+ boost::shared_ptr<QDir> default_dir;
ImageScaler *imageScaler;
QPushButton *saveButton;
QPushButton *cancelButton;
#include <iostream>
using namespace std;
-MussaAlignedWindow::MussaAlignedWindow(MussaRef m,
+MussaAlignedWindow::MussaAlignedWindow(MussaRef m,
+ boost::shared_ptr<QDir> default_dir_,
const set<int>& sel_paths,
SubanalysisWindowRef window,
QWidget *parent)
: QMainWindow(parent),
analysis(m),
+ default_dir(default_dir_),
subanalysis_window(window),
+ browser(default_dir),
pick_align_menu(tr("Choose Alignment")),
view_align_menu(tr("View Alignment")),
threshold_widget(0),
#include <boost/shared_ptr.hpp>
+#include <QDir>
#include <QMainWindow>
#include <QMenu>
#include <QToolBar>
* sequence portions from both the mussa window and the sequence view window
* \param parent is the typical Qt pointer to a parent widget
*/
- MussaAlignedWindow(MussaRef analysis, const std::set<int>& paths,
+ MussaAlignedWindow(MussaRef analysis,
+ boost::shared_ptr<QDir> default_dir,
+ const std::set<int>& paths,
SubanalysisWindowRef window, QWidget *parent=0);
public slots:
void setupAlignmentMenus();
void computeMatchLines();
- MussaRef analysis;
+ MussaRef analysis;
+ boost::shared_ptr<QDir> default_dir;
//std::vector<Sequence> sequences;
//const std::set<int>& selected_paths;
std::vector<ConservedPath> selected_paths;
MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
QMainWindow(parent),
analysis(analysis_),
- default_dir(QDir::home().absolutePath()),
+ default_dir(new QDir(QDir::home().absolutePath())),
motif_editor(0),
setup_analysis_dialog(new MussaSetupDialog(this)),
subanalysis_window(new SubanalysisWindow(analysis)),
- browser(new SequenceBrowserWidget(this)),
+ browser(new SequenceBrowserWidget(default_dir, this)),
mussaViewTB(new QToolBar("Path Views")),
zoom(new ZoomWidget),
threshold(new ThresholdWidget),
std::auto_ptr<QFileDialog> dialog(new QFileDialog(this));
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setFileMode(QFileDialog::AnyFile);
- dialog->setDirectory(default_dir);
+ dialog->setDirectory(*default_dir);
QStringList fileNames;
if (not dialog->exec()) {
}
analysis->save(save_path);
fs::path normalized_path = (save_path / "..").normalize();
- default_dir = normalized_path.native_directory_string().c_str();
+ default_dir->setPath(normalized_path.native_directory_string().c_str());
}
bool MussaWindow::isClearingAnalysisSafe()
QString filter("Motif list(*.txt *.mtl)");
QString path = QFileDialog::getOpenFileName(this,
caption,
- default_dir.absolutePath(),
+ default_dir->absolutePath(),
filter);
// user hit cancel?
if (path.isNull())
try {
fs::path converted_path(path.toStdString(), fs::native);
analysis->load_motifs(converted_path);
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
emit changedMotifs();
} catch (runtime_error e) {
QString msg("Unable to load ");
QString filter("Motif list(*.txt *.mtl)");
QString path = QFileDialog::getSaveFileName(this,
caption,
- default_dir.absolutePath(),
+ default_dir->absolutePath(),
filter);
// user hit cancel?
if (path.isNull())
try {
fs::path converted_path(path.toStdString(), fs::native);
analysis->save_motifs(converted_path);
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
} catch (runtime_error e) {
QString msg("Unable to save ");
msg += path;
QString mupa_path = QFileDialog::getOpenFileName(
this,
caption,
- default_dir.absolutePath(),
+ default_dir->absolutePath(),
filter
);
// user hit cancel?
setAnalysis(m);
updateTitle();
// grab the path ignoring the mupa file portion
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
} catch (mussa_load_error e) {
QString msg("Unable to load ");
msg += mupa_path;
QString muway_dir = QFileDialog::getExistingDirectory(
this,
caption,
- default_dir.absolutePath()
+ default_dir->absolutePath()
);
// user hit cancel?
if (muway_dir.isNull())
// our current window is empty so load and replace.
setAnalysis(m);
updateTitle();
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
} else {
MussaWindow *win = new MussaWindow(m);
updateTitle();
- win->default_dir = converted_path.branch_path().native_directory_string().c_str();
+ win->default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
win->show();
}
} catch (mussa_load_error e) {
"first"));
} else {
MussaAlignedWindowRef ma_win(
- new MussaAlignedWindow(analysis, selected_paths, subanalysis_window)
+ new MussaAlignedWindow(analysis, default_dir, selected_paths, subanalysis_window)
);
aligned_windows.push_back(ma_win);
//! shared_ptr to our analysis
MussaRef analysis;
//! the default directory we should loand and save from
- QDir default_dir;
+ boost::shared_ptr<QDir> default_dir;
std::list<boost::shared_ptr<MussaAlignedWindow> > aligned_windows;
MotifEditor *motif_editor;
MussaSetupDialog *setup_analysis_dialog;
#include <math.h>
using namespace std;
-SequenceBrowserWidget::SequenceBrowserWidget(QWidget *parent)
+SequenceBrowserWidget::SequenceBrowserWidget(
+ boost::shared_ptr<QDir> default_dir_,
+ QWidget *parent
+)
: QWidget(parent),
- scrollable_browser(parent)
+ default_dir(default_dir_),
+ scrollable_browser(this)
{
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(&left_sidebar, 0);
QSize size;
size = scrollable_browser.browser().size();
//Image Save Dialog
- ImageSaveDialog imageSaveDialog(&scrollable_browser.browser(), this);
+ ImageSaveDialog imageSaveDialog(default_dir, &scrollable_browser.browser(), this);
imageSaveDialog.setSize(size.width(), size.height());
imageSaveDialog.exec();
}
#include <boost/shared_ptr.hpp>
+#include <QDir>
#include <QWidget>
#include "alg/sequence.hpp"
Q_OBJECT
public:
- SequenceBrowserWidget(QWidget *parent=0);
+ SequenceBrowserWidget(boost::shared_ptr<QDir>, QWidget *parent=0);
//! return the popup menu for the glcanvas (reference stored internally)
QMenu *getPopupMenu();
void update();
private:
+ boost::shared_ptr<QDir> default_dir;
ScrollableSequenceBrowser scrollable_browser;
SequenceBrowserSidebar left_sidebar;
SequenceBrowserSidebar right_sidebar;