15 #include "qui/PathScene.hpp"
16 #include "qui/PathWidget.hpp"
17 #include "qui/PathWindow.hpp"
18 #include "qui/ThresholdWidget.hpp"
19 #include "qui/ImageSaveDialog.hpp"
23 PathWindow::PathWindow(Mussa *analysis, QWidget *) :
24 closeAction(0) // initialize one of the pointers to null as a saftey flag
26 scene = new PathScene(analysis, this);
31 //This next setWhatsThis function prevents
32 // a segfault when using WhatsThis feature with
34 scene->setWhatsThis(tr("Mussa in OpenGL!"));
35 // make a widget so we can have a scroll bar
36 PathWidget *path_widget = new PathWidget(scene, this);
37 setCentralWidget(path_widget);
39 mussaViewTB = new QToolBar("Path Views");
40 mussaViewTB->addAction(toggleMotifsAction);
42 QSpinBox *zoom = new QSpinBox();
43 zoom->setWhatsThis("zoom magnification factor");
44 zoom->setRange(2,1000);
45 mussaViewTB->addWidget(zoom);
46 connect(zoom, SIGNAL(valueChanged(int)), scene, SLOT(setZoom(int)));
48 ThresholdWidget *threshold = new ThresholdWidget;
49 threshold->setRange(19, 30);
50 threshold->setThreshold(19);
51 scene->setClipPlane(20);
52 // FIXME: for when we get the paths drawn at the appropriate depth
53 //connect(threshold, SIGNAL(thresholdChanged(int)),
54 // scene, SLOT(setClipPlane(int)));
55 connect(threshold, SIGNAL(thresholdChanged(int)),
56 scene, SLOT(setSoftThreshold(int)));
57 mussaViewTB->addWidget(threshold);
60 imageSaveDialog = new ImageSaveDialog(scene, this);
62 addToolBar(mussaViewTB);
64 statusBar()->showMessage("Welcome to mussa", 2000);
67 void PathWindow::setupActions()
69 // we really don't want to run this more than once.
70 assert (closeAction == 0);
72 // the ever popular about box
73 aboutAction = new QAction(tr("&About"), this);
74 connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
75 aboutAction->setIcon(QIcon("icons/info.png"));
78 closeAction = new QAction(tr("&Close"), this);
79 closeAction->setStatusTip(tr("Close this window"));
80 connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
81 closeAction->setIcon(QIcon("icons/exit.png"));
83 createNewAnalysisAction = new QAction(tr("Define Analysis"), this);
84 connect(createNewAnalysisAction, SIGNAL(triggered()),
85 this, SLOT(createNewAnalysis()));
86 createNewAnalysisAction->setIcon(QIcon("icons/filenew.png"));
88 createSubAnalysisAction = new QAction(tr("Define SubAnalysis"), this);
89 connect(createSubAnalysisAction, SIGNAL(triggered()),
90 this, SLOT(createSubAnalysis()));
92 loadMotifListAction = new QAction(tr("Load Motif List"), this);
93 connect(loadMotifListAction, SIGNAL(triggered()),
94 this, SLOT(loadMotifList()));
96 loadMupaAction = new QAction(tr("Load Mussa Parameters"), this);
97 connect(loadMupaAction, SIGNAL(triggered()),
98 scene, SLOT(loadMupa()));
100 loadSavedAnalysisAction = new QAction(tr("Load &Analysis"), this);
101 connect(loadSavedAnalysisAction, SIGNAL(triggered()),
102 scene, SLOT(loadSavedAnalysis()));
103 loadSavedAnalysisAction->setIcon(QIcon("icons/fileopen.png"));
105 saveMotifListAction = new QAction(tr("Save Motifs"), this);
106 connect(saveMotifListAction, SIGNAL(triggered()),
107 this, SLOT(saveMotifList()));
108 saveMotifListAction->setIcon(QIcon("icons/filesave.png"));
110 showMussaViewToolbarAction = new QAction(tr("Show Toolbar"), this);
111 connect(showMussaViewToolbarAction, SIGNAL(triggered()),
112 this, SLOT(showMussaToolbar()));
113 showMussaViewToolbarAction->setCheckable(true);
114 showMussaViewToolbarAction->setChecked(true);
116 toggleMotifsAction = new QAction(tr("Toggle Motifs"), this);
117 connect(toggleMotifsAction, SIGNAL(triggered()),
118 this, SLOT(toggleMotifs()));
119 toggleMotifsAction->setCheckable(true);
120 toggleMotifsAction->setIcon(QIcon("icons/motif_icon.png"));
121 toggleMotifsAction->setWhatsThis(tr("Toggle motif annotations on/off\n\n"
122 "You can load motif annotations via "
123 "'File->Load Motif List' menu option."));
125 whatsThisAction = QWhatsThis::createAction(this);
126 whatsThisAction->setIcon(QIcon("icons/help.png"));
128 //Save pixel map action
129 saveOpenGlPixmapAction = new QAction(tr("Save to image..."), this);
130 connect(saveOpenGlPixmapAction, (SIGNAL(triggered())),
131 this, SLOT(promptSaveOpenGlPixmap()));
132 saveOpenGlPixmapAction->setIcon(QIcon("icons/image2.png"));
135 void PathWindow::setupMainMenu()
137 // we need to run setupActions first
138 assert (closeAction != 0);
141 newMenu = menuBar()->addMenu(tr("&File"));
142 newMenu->addAction(createNewAnalysisAction);
143 newMenu->addAction(loadMupaAction);
144 newMenu->addAction(loadSavedAnalysisAction);
145 newMenu->addAction(createSubAnalysisAction);
146 newMenu->addSeparator();
147 newMenu->addAction(loadMotifListAction);
148 newMenu->addAction(saveMotifListAction);
149 newMenu->addSeparator();
150 newMenu->addAction(saveOpenGlPixmapAction);
151 newMenu->addSeparator();
152 newMenu->addAction(closeAction);
154 newMenu = menuBar()->addMenu(tr("&View"));
155 newMenu->addAction(showMussaViewToolbarAction);
157 newMenu = menuBar()->addMenu(tr("&Help"));
158 newMenu->addAction(whatsThisAction);
159 newMenu->addSeparator();
160 newMenu->addAction(aboutAction);
163 void PathWindow::about()
165 QMessageBox::about(this, tr("About mussa"),
166 tr("Welcome to Multiple Species Sequence Analysis\n"
167 "(c) 2005-2006 California Institute of Technology\n"
168 "Tristan De Buysscher, Diane Trout\n"));
171 void PathWindow::createNewAnalysis()
176 void PathWindow::createSubAnalysis()
181 void PathWindow::loadMotifList()
186 void PathWindow::saveMotifList()
191 void PathWindow::showMussaToolbar()
193 std::clog << "isVis?" << mussaViewTB->isVisible() <<std::endl;
194 if (mussaViewTB->isVisible())
198 std::clog << "isVis?" << mussaViewTB->isVisible() <<std::endl;
201 void PathWindow::toggleMotifs()
206 void PathWindow::NotImplementedBox()
208 QMessageBox::warning(this, QObject::tr("mussa"), QObject::tr("Not implemented yet"));
211 void PathWindow::promptSaveOpenGlPixmap()
214 size = scene->size();
215 imageSaveDialog->setSize(size.width(), size.height());
216 int result = imageSaveDialog->exec();
217 std::cout << "Result: " << result << "\n";