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