c2f2e71a56660f1e78de33ad98e21b9c8f8a0979
[mussa.git] / qui / PathWindow.cxx
1 #include "qui/PathWindow.h"
2
3 #include <QAction>
4 #include <QDir>
5 #include <QFileDialog>
6 #include <QMenuBar>
7 #include <QMessageBox>
8 #include <QStatusBar>
9 #include <QString>
10 #include <QToolBar>
11
12 #include "qui/PathScene.h"
13 #include "qui/ThresholdWidget.h"
14
15 PathWindow::PathWindow(QWidget *) :
16   closeAction(0) // initialize one of the pointers to null as a saftey flag
17 {
18   setupActions();
19   setupMainMenu();
20
21   scene = new PathScene(10000, 10, this);
22   setCentralWidget(scene);
23
24   mussaViewTB = new QToolBar("Path Views");
25   mussaViewTB->addAction(toggleMotifsAction);
26
27   ThresholdWidget *threshold = new ThresholdWidget;
28   threshold->setRange(21, 30);
29   scene->setClipPlane(21);
30   connect(threshold, SIGNAL(thresholdChanged(int)),
31           scene, SLOT(setClipPlane(int)));
32   mussaViewTB->addWidget(threshold);
33   addToolBar(mussaViewTB);
34
35   statusBar()->showMessage("Welcome to mussa", 2000);
36 }
37
38 void PathWindow::setupActions()
39 {
40   // we really don't want to run this more than once.
41   assert (closeAction == 0);
42
43   // the ever popular about box
44   aboutAction = new QAction(tr("&About"), this);
45   connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
46
47   // add exit
48   closeAction = new QAction(tr("&Close"), this);
49   closeAction->setStatusTip(tr("Close this window"));
50   connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
51   
52   createNewAnalysisAction = new QAction(tr("Define Analysis"), this);
53   connect(createNewAnalysisAction, SIGNAL(triggered()), 
54           this, SLOT(createNewAnalysis()));
55   
56   createSubAnalysisAction = new QAction(tr("Define SubAnalysis"), this);
57   connect(createSubAnalysisAction, SIGNAL(triggered()), 
58           this, SLOT(createSubAnalysis()));
59
60   loadMotifListAction = new QAction(tr("Load Motif List"), this);
61   connect(loadMotifListAction, SIGNAL(triggered()), 
62           this, SLOT(loadMotifList()));
63   
64   loadMupaAction = new QAction(tr("Load Mussa Parameters"), this);
65   connect(loadMupaAction, SIGNAL(triggered()), 
66           this, SLOT(loadMupa()));
67
68   loadSavedAnalysisAction = new QAction(tr("Load &Analysis"), this);
69   connect(loadSavedAnalysisAction, SIGNAL(triggered()), 
70           this, SLOT(loadSavedAnalysis()));
71
72   saveMotifListAction = new QAction(tr("Save Motifs"), this);
73   connect(saveMotifListAction, SIGNAL(triggered()), 
74           this, SLOT(saveMotifList()));
75
76   toggleMotifsAction = new QAction(tr("Toggle Motifs"), this);
77   connect(toggleMotifsAction, SIGNAL(triggered()), 
78           this, SLOT(toggleMotifs()));
79 }
80
81 void PathWindow::setupMainMenu()
82 {
83   // we need to run setupActions first
84   assert (closeAction != 0);
85   
86   QMenu *newMenu;
87   newMenu = menuBar()->addMenu(tr("&File"));
88   newMenu->addAction(createNewAnalysisAction);
89   newMenu->addAction(loadMupaAction);
90   newMenu->addAction(loadSavedAnalysisAction);
91   newMenu->addAction(createSubAnalysisAction);
92   newMenu->addSeparator();
93   newMenu->addAction(loadMotifListAction);
94   newMenu->addAction(saveMotifListAction);
95   newMenu->addSeparator();
96   newMenu->addAction(closeAction);
97
98   newMenu = menuBar()->addMenu(tr("&Help"));
99   newMenu->addAction(aboutAction);
100 }
101   
102 void PathWindow::about()
103 {
104   QMessageBox::about(this, tr("About mussa"),
105       tr("Welcome to Multiple Species Sequence Analysis\n"
106          "(c) 2005-2006 California Institute of Technology\n"
107          "Tristan De Buysscher, Diane Trout\n"));
108 }
109
110 void PathWindow::createNewAnalysis()
111 {
112   NotImplementedBox();
113 }
114
115 void PathWindow::createSubAnalysis()
116 {
117   NotImplementedBox();
118 }
119
120 void PathWindow::loadMotifList()
121 {
122   NotImplementedBox();
123 }
124
125 void PathWindow::loadMupa()
126 {
127   QString caption("Load a mussa parameter file");
128   QString filter("Mussa Parameters (*.mupa)");
129   QString mupa_path = QFileDialog::getOpenFileName(this,
130                                                    caption, 
131                                                    QDir::currentPath(),
132                                                    filter);
133   mussaAnalysis.load_mupa_file(mupa_path.toStdString());
134 }
135
136 void PathWindow::loadSavedAnalysis()
137 {
138   NotImplementedBox();
139 }
140
141 void PathWindow::saveMotifList()
142 {
143   NotImplementedBox();
144 }
145
146 void PathWindow::toggleMotifs()
147 {
148   NotImplementedBox();
149 }
150
151 void PathWindow::NotImplementedBox()
152 {
153   QMessageBox::warning(this, QObject::tr("mussa"), QObject::tr("Not implemented yet"));
154 }      
155
156