1 #include "qui/PathWindow.h"
15 #include "qui/PathScene.h"
16 #include "qui/ThresholdWidget.h"
17 #include "qui/ImageSaveDialog.h"
21 PathWindow::PathWindow(Mussa *analysis, QWidget *) :
22 closeAction(0) // initialize one of the pointers to null as a saftey flag
24 scene = new PathScene(analysis, this);
29 //This next setWhatsThis function prevents
30 // a segfault when using WhatsThis feature with
32 scene->setWhatsThis(tr("Mussa in OpenGL!"));
33 setCentralWidget(scene);
35 mussaViewTB = new QToolBar("Path Views");
36 mussaViewTB->addAction(toggleMotifsAction);
38 QSpinBox *zoom = new QSpinBox();
39 zoom->setWhatsThis("zoom magnification factor");
40 mussaViewTB->addWidget(zoom);
41 connect(zoom, SIGNAL(valueChanged(int)), scene, SLOT(setZoom(int)));
43 ThresholdWidget *threshold = new ThresholdWidget;
44 threshold->setRange(19, 30);
45 threshold->setThreshold(19);
46 scene->setClipPlane(20);
47 // FIXME: for when we get the paths drawn at the appropriate depth
48 //connect(threshold, SIGNAL(thresholdChanged(int)),
49 // scene, SLOT(setClipPlane(int)));
50 connect(threshold, SIGNAL(thresholdChanged(int)),
51 scene, SLOT(setSoftThreshold(int)));
52 mussaViewTB->addWidget(threshold);
55 imageSaveDialog = new ImageSaveDialog(scene, this);
57 addToolBar(mussaViewTB);
59 statusBar()->showMessage("Welcome to mussa", 2000);
62 void PathWindow::setupActions()
64 // we really don't want to run this more than once.
65 assert (closeAction == 0);
67 // the ever popular about box
68 aboutAction = new QAction(tr("&About"), this);
69 connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
70 aboutAction->setIcon(QIcon("icons/info.png"));
73 closeAction = new QAction(tr("&Close"), this);
74 closeAction->setStatusTip(tr("Close this window"));
75 connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
76 closeAction->setIcon(QIcon("icons/exit.png"));
78 createNewAnalysisAction = new QAction(tr("Define Analysis"), this);
79 connect(createNewAnalysisAction, SIGNAL(triggered()),
80 this, SLOT(createNewAnalysis()));
81 createNewAnalysisAction->setIcon(QIcon("icons/filenew.png"));
83 createSubAnalysisAction = new QAction(tr("Define SubAnalysis"), this);
84 connect(createSubAnalysisAction, SIGNAL(triggered()),
85 this, SLOT(createSubAnalysis()));
87 loadMotifListAction = new QAction(tr("Load Motif List"), this);
88 connect(loadMotifListAction, SIGNAL(triggered()),
89 this, SLOT(loadMotifList()));
91 loadMupaAction = new QAction(tr("Load Mussa Parameters"), this);
92 connect(loadMupaAction, SIGNAL(triggered()),
93 scene, SLOT(loadMupa()));
95 loadSavedAnalysisAction = new QAction(tr("Load &Analysis"), this);
96 connect(loadSavedAnalysisAction, SIGNAL(triggered()),
97 scene, SLOT(loadSavedAnalysis()));
98 loadSavedAnalysisAction->setIcon(QIcon("icons/fileopen.png"));
100 saveMotifListAction = new QAction(tr("Save Motifs"), this);
101 connect(saveMotifListAction, SIGNAL(triggered()),
102 this, SLOT(saveMotifList()));
103 saveMotifListAction->setIcon(QIcon("icons/filesave.png"));
105 showMussaViewToolbarAction = new QAction(tr("Show Toolbar"), this);
106 connect(showMussaViewToolbarAction, SIGNAL(triggered()),
107 this, SLOT(showMussaToolbar()));
108 showMussaViewToolbarAction->setCheckable(true);
109 showMussaViewToolbarAction->setChecked(true);
111 toggleMotifsAction = new QAction(tr("Toggle Motifs"), this);
112 connect(toggleMotifsAction, SIGNAL(triggered()),
113 this, SLOT(toggleMotifs()));
114 toggleMotifsAction->setCheckable(true);
115 toggleMotifsAction->setIcon(QIcon("icons/motif_icon.png"));
116 toggleMotifsAction->setWhatsThis(tr("Toggle motif annotations on/off\n\n"
117 "You can load motif annotations via "
118 "'File->Load Motif List' menu option."));
120 whatsThisAction = QWhatsThis::createAction(this);
121 whatsThisAction->setIcon(QIcon("icons/help.png"));
123 //Save pixel map action
124 saveOpenGlPixmapAction = new QAction(tr("Save to image..."), this);
125 connect(saveOpenGlPixmapAction, (SIGNAL(triggered())),
126 this, SLOT(promptSaveOpenGlPixmap()));
127 saveOpenGlPixmapAction->setIcon(QIcon("icons/image2.png"));
130 void PathWindow::setupMainMenu()
132 // we need to run setupActions first
133 assert (closeAction != 0);
136 newMenu = menuBar()->addMenu(tr("&File"));
137 newMenu->addAction(createNewAnalysisAction);
138 newMenu->addAction(loadMupaAction);
139 newMenu->addAction(loadSavedAnalysisAction);
140 newMenu->addAction(createSubAnalysisAction);
141 newMenu->addSeparator();
142 newMenu->addAction(loadMotifListAction);
143 newMenu->addAction(saveMotifListAction);
144 newMenu->addSeparator();
145 newMenu->addAction(saveOpenGlPixmapAction);
146 newMenu->addSeparator();
147 newMenu->addAction(closeAction);
149 newMenu = menuBar()->addMenu(tr("&View"));
150 newMenu->addAction(showMussaViewToolbarAction);
152 newMenu = menuBar()->addMenu(tr("&Help"));
153 newMenu->addAction(whatsThisAction);
154 newMenu->addSeparator();
155 newMenu->addAction(aboutAction);
158 void PathWindow::about()
160 QMessageBox::about(this, tr("About mussa"),
161 tr("Welcome to Multiple Species Sequence Analysis\n"
162 "(c) 2005-2006 California Institute of Technology\n"
163 "Tristan De Buysscher, Diane Trout\n"));
166 void PathWindow::createNewAnalysis()
171 void PathWindow::createSubAnalysis()
176 void PathWindow::loadMotifList()
181 void PathWindow::saveMotifList()
186 void PathWindow::showMussaToolbar()
188 std::clog << "isVis?" << mussaViewTB->isVisible() <<std::endl;
189 if (mussaViewTB->isVisible())
193 std::clog << "isVis?" << mussaViewTB->isVisible() <<std::endl;
196 void PathWindow::toggleMotifs()
201 void PathWindow::NotImplementedBox()
203 QMessageBox::warning(this, QObject::tr("mussa"), QObject::tr("Not implemented yet"));
206 void PathWindow::promptSaveOpenGlPixmap()
209 size = scene->size();
210 imageSaveDialog->setSize(size.width(), size.height());
211 int result = imageSaveDialog->exec();
212 std::cout << "Result: " << result << "\n";