1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * Tecorrec is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Tecorrec is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
21 * @file tcMainWindow.h
22 * @brief Main application window.
25 #include "tcMainWindow.h"
26 #include "tcViewportWidget.h"
27 #include "tcColourMapWidget.h"
29 #include <tcSrtmCache.h>
30 #include <tcGeoImageData.h>
31 #include <tcChannelManager.h>
32 #include <tcChannel.h>
33 #include <tcChannelConfigWidget.h>
34 #include <tcExportText.h>
36 #include <QHBoxLayout>
41 #include <QDockWidget>
43 #include <QRadioButton>
45 #include <QPushButton>
48 * Constructors + destructor
51 /// Default constructor.
52 tcMainWindow::tcMainWindow()
54 , m_viewport(new tcViewportWidget(this))
55 , m_colourMap(new tcColourMapWidget(QStringList()
56 << tr("Red") << tr("Green") << tr("Blue"), this))
57 , m_globe(new tcGlobe(6378.137e3
))
60 m_viewport
->setGlobe(m_globe
);
61 setCentralWidget(m_viewport
);
65 QMenuBar
* menus
= menuBar();
67 QMenu
* menuFile
= menus
->addMenu(tr("File", "The menu"));
69 QMenu
* menuFileExport
= menuFile
->addMenu(tr("Export", "The menu"));
71 QAction
* menuFileExportText
= menuFileExport
->addAction(tr("Export as Text"),
72 this, SLOT(exportText()));
75 QMenu
* menuView
= menus
->addMenu(tr("View", "The menu"));
77 QMenu
* menuViewQuality
= menuView
->addMenu(tr("Elevation Quality", "The menu"));
79 QAction
* menuViewQualityAdaptive
= menuViewQuality
->addAction(tr("Adaptive Resolution"),
80 m_viewport
, SLOT(setQualityAdaptive()));
81 QAction
* menuViewQualityFull
= menuViewQuality
->addAction(tr("Full Resolution"),
82 m_viewport
, SLOT(setQualityFull()));
84 QMenu
* menuViewRender
= menuView
->addMenu(tr("Render Options", "The menu"));
86 QAction
* menuViewRenderNormal
= menuViewRender
->addAction(tr("Normal", "Polygon mode"),
87 m_viewport
, SLOT(setPolygonModeNormal()));
88 QAction
* menuViewRenderWireframe
= menuViewRender
->addAction(tr("Wireframe", "Polygon mode"),
89 m_viewport
, SLOT(setPolygonModeWireframe()));
91 QMenu
* menuViewRenderColour
= menuView
->addMenu(tr("Colour Coding", "The menu"));
93 QAction
* menuViewRenderColourNone
= menuViewRenderColour
->addAction(tr("No colour coding"),
94 m_viewport
, SLOT(setColourCodingNone()));
95 QAction
* menuViewRenderColourElevationSampleAlignment
= menuViewRenderColour
->addAction(tr("Alignment of elevation samples"),
96 m_viewport
, SLOT(setColourCodingElevationSampleAlignment()));
104 QStatusBar
* statusBar
= new QStatusBar(this);
105 connect(m_viewport
, SIGNAL(mouseGeoTextChanged(const QString
&)),
106 statusBar
, SLOT(showMessage(const QString
&)));
107 connect(m_globe
->imagery()->channelManager(), SIGNAL(progressing(const QString
&)),
108 statusBar
, SLOT(showMessage(const QString
&)));
109 connect(m_globe
->dem(), SIGNAL(progressing(const QString
&)),
110 statusBar
, SLOT(showMessage(const QString
&)));
111 setStatusBar(statusBar
);
114 QDockWidget
* dockElevation
;
116 // Docker for elevation data settings
117 QDockWidget
* docker
= new QDockWidget(tr("Elevation Data"), this);
118 dockElevation
= docker
;
119 QWidget
* dockerWidget
= new QWidget(docker
);
120 QVBoxLayout
* layout
= new QVBoxLayout(dockerWidget
);
121 docker
->setWidget(dockerWidget
);
122 addDockWidget(Qt::LeftDockWidgetArea
, docker
);
124 // Combo box to select data set
125 QComboBox
* elevDataSet
= new QComboBox(dockerWidget
);
126 layout
->addWidget(elevDataSet
);
127 QStringList elevDataSets
= tcSrtmCache::dataSets();
128 foreach (QString dataSet
, elevDataSets
)
130 elevDataSet
->addItem(dataSet
);
132 connect(elevDataSet
, SIGNAL(currentIndexChanged(const QString
&)), m_viewport
, SLOT(setElevationDataSet(const QString
&)));
133 if (-1 != elevDataSet
->currentIndex())
135 m_viewport
->setElevationDataSet(elevDataSet
->currentText());
139 QRadioButton
* elevFlat
= new QRadioButton(tr("Don't Show Elevation (Flat)"), dockerWidget
);
140 layout
->addWidget(elevFlat
);
141 connect(elevFlat
, SIGNAL(pressed()), m_viewport
, SLOT(setElevationFlat()));
142 QRadioButton
* elevRaw
= new QRadioButton(tr("Raw SRTM Elevation Data"), dockerWidget
);
143 layout
->addWidget(elevRaw
);
144 connect(elevRaw
, SIGNAL(pressed()), m_viewport
, SLOT(setElevationRaw()));
145 QRadioButton
* elevCorrected
= new QRadioButton(tr("Corrected SRTM Elevation Data"), dockerWidget
);
146 layout
->addWidget(elevCorrected
);
147 elevCorrected
->setChecked(true);
148 connect(elevCorrected
, SIGNAL(pressed()), m_viewport
, SLOT(setElevationCorrected()));
149 QSlider
* elevCorrectionLevel
= new QSlider(Qt::Horizontal
, dockerWidget
);
150 layout
->addWidget(elevCorrectionLevel
);
151 elevCorrectionLevel
->setRange(0,100);
152 connect(elevCorrectionLevel
, SIGNAL(valueChanged(int)), m_viewport
, SLOT(setElevationCorrection(int)));
155 layout
->addStretch();
159 // Docker for satellite imagery
160 QDockWidget
* docker
= new QDockWidget(tr("Imagery Data"), this);
161 QWidget
* dockerWidget
= new QWidget(docker
);
162 QVBoxLayout
* layout
= new QVBoxLayout(dockerWidget
);
163 docker
->setWidget(dockerWidget
);
164 tabifyDockWidget(dockElevation
, docker
);
166 // Button to go to sun view
167 QPushButton
* btnSunView
= new QPushButton(tr("Sun View"), this);
168 layout
->addWidget(btnSunView
);
169 connect(btnSunView
, SIGNAL(clicked(bool)), m_viewport
, SLOT(sunView()));
172 layout
->addWidget(m_colourMap
);
173 const tcChannelManager
* manager
= m_globe
->imagery()->channelManager();
174 int numChannels
= manager
->numChannels();
175 for (int i
= 0; i
< numChannels
; ++i
)
177 tcChannel
* channel
= manager
->channel(i
);
178 m_colourMap
->addInputBand(channel
->name(), channel
->description());
180 for (int i
= 0; i
< 3; ++i
)
182 m_colourMap
->setInputBand(i
, 2-i
);
184 connect(m_colourMap
, SIGNAL(inputBandClicked(int)), this, SLOT(configureChannel(int)));
185 connect(m_colourMap
, SIGNAL(inputBandChanged(int, int)), m_viewport
, SLOT(setColourMapping(int,int)));
189 // Docker for processing
190 QDockWidget
* docker
= new QDockWidget(tr("Processing"), this);
191 QWidget
* dockerWidget
= new QWidget(docker
);
192 QVBoxLayout
* layout
= new QVBoxLayout(dockerWidget
);
193 docker
->setWidget(dockerWidget
);
194 tabifyDockWidget(dockElevation
, docker
);
197 layout
->addStretch();
202 tcMainWindow::~tcMainWindow()
211 /// Show configuration for a channel.
212 void tcMainWindow::configureChannel(int channel
)
214 tcChannelManager
* manager
= m_globe
->imagery()->channelManager();
215 tcChannelConfigWidget
* configWidget
= manager
->channel(channel
)->configWidget();
216 if (0 != configWidget
)
218 connect(configWidget
, SIGNAL(updated()),
219 m_viewport
, SLOT(updateGL()));
220 connect(configWidget
, SIGNAL(texturePointRequested(QObject
*, const char*)),
221 m_viewport
, SLOT(texturePointMode(QObject
*, const char*)));
222 configWidget
->setWindowFlags(Qt::Tool
| Qt::WindowStaysOnTopHint
);
223 configWidget
->show();
228 void tcMainWindow::exportText()
230 if (0 == m_exportText
)
232 m_exportText
= new tcExportText(m_globe
->imagery(), this);
234 m_exportText
->setWindowFlags(Qt::Dialog
| Qt::WindowStaysOnTopHint
);
235 m_exportText
->show();