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