1 #include "qui/PathWindow.h"
14 #include "qui/PathScene.h"
15 #include "qui/ThresholdWidget.h"
16 #include "qui/ImageSaveDialog.h"
20 PathWindow::PathWindow(QWidget *) :
21 closeAction(0) // initialize one of the pointers to null as a saftey flag
26 scene = new PathScene(10000, 10, this);
27 //This next setWhatsThis function prevents
28 // a segfault when using WhatsThis feature with
30 scene->setWhatsThis(tr("Mussa in OpenGL!"));
31 setCentralWidget(scene);
33 mussaViewTB = new QToolBar("Path Views");
34 mussaViewTB->addAction(toggleMotifsAction);
36 ThresholdWidget *threshold = new ThresholdWidget;
37 threshold->setRange(21, 30);
38 scene->setClipPlane(21);
39 connect(threshold, SIGNAL(thresholdChanged(int)),
40 scene, SLOT(setClipPlane(int)));
41 mussaViewTB->addWidget(threshold);
44 imageSaveDialog = new ImageSaveDialog(scene, this);
46 addToolBar(mussaViewTB);
48 statusBar()->showMessage("Welcome to mussa", 2000);
51 void PathWindow::setupActions()
53 // we really don't want to run this more than once.
54 assert (closeAction == 0);
56 // the ever popular about box
57 aboutAction = new QAction(tr("&About"), this);
58 connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
59 aboutAction->setIcon(QIcon("icons/info.png"));
62 closeAction = new QAction(tr("&Close"), this);
63 closeAction->setStatusTip(tr("Close this window"));
64 connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
65 closeAction->setIcon(QIcon("icons/exit.png"));
67 createNewAnalysisAction = new QAction(tr("Define Analysis"), this);
68 connect(createNewAnalysisAction, SIGNAL(triggered()),
69 this, SLOT(createNewAnalysis()));
70 createNewAnalysisAction->setIcon(QIcon("icons/filenew.png"));
72 createSubAnalysisAction = new QAction(tr("Define SubAnalysis"), this);
73 connect(createSubAnalysisAction, SIGNAL(triggered()),
74 this, SLOT(createSubAnalysis()));
76 loadMotifListAction = new QAction(tr("Load Motif List"), this);
77 connect(loadMotifListAction, SIGNAL(triggered()),
78 this, SLOT(loadMotifList()));
80 loadMupaAction = new QAction(tr("Load Mussa Parameters"), this);
81 connect(loadMupaAction, SIGNAL(triggered()),
82 this, SLOT(loadMupa()));
84 loadSavedAnalysisAction = new QAction(tr("Load &Analysis"), this);
85 connect(loadSavedAnalysisAction, SIGNAL(triggered()),
86 this, SLOT(loadSavedAnalysis()));
87 loadSavedAnalysisAction->setIcon(QIcon("icons/fileopen.png"));
89 saveMotifListAction = new QAction(tr("Save Motifs"), this);
90 connect(saveMotifListAction, SIGNAL(triggered()),
91 this, SLOT(saveMotifList()));
92 saveMotifListAction->setIcon(QIcon("icons/filesave.png"));
94 showMussaViewToolbarAction = new QAction(tr("Show Toolbar"), this);
95 connect(showMussaViewToolbarAction, SIGNAL(triggered()),
96 this, SLOT(showMussaToolbar()));
97 showMussaViewToolbarAction->setCheckable(true);
98 showMussaViewToolbarAction->setChecked(true);
100 toggleMotifsAction = new QAction(tr("Toggle Motifs"), this);
101 connect(toggleMotifsAction, SIGNAL(triggered()),
102 this, SLOT(toggleMotifs()));
103 toggleMotifsAction->setCheckable(true);
104 toggleMotifsAction->setIcon(QIcon("icons/motif_icon.png"));
105 toggleMotifsAction->setWhatsThis(tr("Toggle motif annotations on/off\n\n"
106 "You can load motif annotations via "
107 "'File->Load Motif List' menu option."));
109 whatsThisAction = QWhatsThis::createAction(this);
110 whatsThisAction->setIcon(QIcon("icons/help.png"));
112 //Save pixel map action
113 saveOpenGlPixmapAction = new QAction(tr("Save to image..."), this);
114 connect(saveOpenGlPixmapAction, (SIGNAL(triggered())),
115 this, SLOT(promptSaveOpenGlPixmap()));
116 saveOpenGlPixmapAction->setIcon(QIcon("icons/image2.png"));
119 void PathWindow::setupMainMenu()
121 // we need to run setupActions first
122 assert (closeAction != 0);
125 newMenu = menuBar()->addMenu(tr("&File"));
126 newMenu->addAction(createNewAnalysisAction);
127 newMenu->addAction(loadMupaAction);
128 newMenu->addAction(loadSavedAnalysisAction);
129 newMenu->addAction(createSubAnalysisAction);
130 newMenu->addSeparator();
131 newMenu->addAction(loadMotifListAction);
132 newMenu->addAction(saveMotifListAction);
133 newMenu->addSeparator();
134 newMenu->addAction(saveOpenGlPixmapAction);
135 newMenu->addSeparator();
136 newMenu->addAction(closeAction);
138 newMenu = menuBar()->addMenu(tr("&View"));
139 newMenu->addAction(showMussaViewToolbarAction);
141 newMenu = menuBar()->addMenu(tr("&Help"));
142 newMenu->addAction(whatsThisAction);
143 newMenu->addSeparator();
144 newMenu->addAction(aboutAction);
147 void PathWindow::about()
149 QMessageBox::about(this, tr("About mussa"),
150 tr("Welcome to Multiple Species Sequence Analysis\n"
151 "(c) 2005-2006 California Institute of Technology\n"
152 "Tristan De Buysscher, Diane Trout\n"));
155 void PathWindow::createNewAnalysis()
160 void PathWindow::createSubAnalysis()
165 void PathWindow::loadMotifList()
170 void PathWindow::loadMupa()
172 QString caption("Load a mussa parameter file");
173 QString filter("Mussa Parameters (*.mupa)");
174 QString mupa_path = QFileDialog::getOpenFileName(this,
178 scene->mussaAnalysis.load_mupa_file(mupa_path.toStdString());
181 void PathWindow::loadSavedAnalysis()
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";