11 #include "ChipViewportsWidget.h"
18 #include <QMessageBox>
19 #include <QMouseEvent>
21 #include "Application.h"
23 #include "ChipViewport.h"
24 #include "ControlMeasureEditWidget.h"
25 #include "ControlMeasure.h"
26 #include "ControlMeasureLogData.h"
27 #include "ControlNet.h"
28 #include "ControlPoint.h"
31 #include "IException.h"
33 #include "Longitude.h"
34 #include "MainWindow.h"
35 #include "MdiCubeViewport.h"
37 #include "PvlEditDialog.h"
38 #include "SerialNumber.h"
39 #include "SerialNumberList.h"
40 #include "SpecialPixel.h"
42 #include "ViewportMainWindow.h"
43 #include "Workspace.h"
56 ChipViewportsWidget::ChipViewportsWidget (
QWidget *parent) :
QWidget(parent) {
63 m_serialNumberList = NULL;
69 installEventFilter(
this);
76 ChipViewportsWidget::~ChipViewportsWidget () {
92 setWindowTitle(
"ChipViewports");
93 setObjectName(
"ChipViewportsWidget");
94 connect(
this, SIGNAL(destroyed(
QObject *)),
this, SLOT(clearPoint()));
98 m_chipViewportsLayout =
new QGridLayout;
101 centralWidget->setLayout(m_chipViewportsLayout);
103 QScrollArea *scrollArea =
new QScrollArea();
104 scrollArea->setObjectName(
"ChipViewportsWidgetScroll");
105 scrollArea->setWidgetResizable(
true);
106 scrollArea->setWidget(centralWidget);
107 centralWidget->adjustSize();
109 QVBoxLayout *mainLayout =
new QVBoxLayout;
111 m_ptIdValue =
new QLabel();
113 QCheckBox *
showPoints =
new QCheckBox(
"Show control points");
114 showPoints->setToolTip(
"Draw control point crosshairs");
115 showPoints->setWhatsThis(
"This will toggle whether crosshairs are drawn"
116 " for the control points located within the measure''s"
117 " view. For areas of dense measurements, turning this"
118 " off will allow easier viewing of features.");
122 QCheckBox *geomChips =
new QCheckBox(
"Geom Chips to Reference");
123 geomChips->setToolTip(
"Geom Chips to Reference Control Measure");
124 geomChips->setWhatsThis(
"This will toggle whether chips are geomed to"
125 " the reference control measure.");
126 connect(geomChips, SIGNAL(toggled(
bool)),
this, SLOT(geomChips(
bool)));
127 geomChips->setChecked(
false);
129 QHBoxLayout *pointsGeomLayout =
new QHBoxLayout;
131 pointsGeomLayout->addWidget(geomChips);
132 pointsGeomLayout->addStretch();
134 mainLayout->addWidget(m_ptIdValue);
135 mainLayout->addLayout(pointsGeomLayout);
136 mainLayout->addWidget(scrollArea);
137 setLayout(mainLayout);
144 void ChipViewportsWidget::createActions() {
150 void ChipViewportsWidget::setSerialNumberList(SerialNumberList *snList) {
154 m_serialNumberList = snList;
171 m_cnetFileName = cnetFilename;
175 emit newControlNetwork(cnet);
180 void ChipViewportsWidget::setPoint(
ControlPoint *controlPoint) {
193 if (m_chipViewports.size() > 0) clearPoint();
194 m_controlPoint = controlPoint;
197 QString CPId = m_controlPoint->GetId();
198 QString ptId(
"Point ID: ");
199 ptId += (QString) CPId;
200 m_ptIdValue->setText(ptId);
207 if (m_controlPoint->IsReferenceExplicit()) {
211 m_controlPoint->GetRefMeasure()->GetCubeSerialNumber()));
214 chip->
TackCube(measure->GetSample(), measure->GetLine());
215 chip->
Load(*measureCube);
217 measureChipViewport->
setChip(chip, measureCube);
220 m_chipViewports.append(measureChipViewport);
225 for (
int i = 0; i < m_controlPoint->GetNumMeasures(); i++) {
226 ControlMeasure *measure = (*m_controlPoint)[i];
227 if (!m_controlPoint->IsReferenceExplicit() && i == 0) {
232 else if (m_controlPoint->IsReferenceExplicit() &&
233 (QString) measure->GetCubeSerialNumber() == m_controlPoint->GetReferenceSN()) {
239 Cube *measureCube =
new Cube(m_serialNumberList->
fileName(measure->GetCubeSerialNumber()));
242 chip->TackCube(measure->GetSample(), measure->GetLine());
243 chip->Load(*measureCube);
244 ChipViewport *measureChipViewport =
new ChipViewport(
VIEWSIZE,
VIEWSIZE,
this);
245 measureChipViewport->setChip(chip, measureCube);
246 measureChipViewport->setControlNet(m_controlNet);
247 measureChipViewport->setPoints(
true);
248 m_chipViewports.append(measureChipViewport);
254 int gridDimension = sqrt(qreal(m_chipViewports.size())) -1;
257 foreach(ChipViewport *measurechipViewport, m_chipViewports) {
258 if (x > gridDimension) {
262 m_chipViewportsLayout->addWidget(measurechipViewport, y, x);
275 void ChipViewportsWidget::readSettings() {
276 FileName config(
"$HOME/.Isis/qview/ChipViewportsWidget.config");
277 QSettings settings(config.expanded(),
278 QSettings::NativeFormat);
279 QPoint pos = settings.value(
"pos", QPoint(300, 100)).toPoint();
280 QSize size = settings.value(
"size", QSize(900, 500)).toSize();
292 void ChipViewportsWidget::writeSettings()
const {
295 if (!this->isVisible())
return;
296 FileName config(
"$HOME/.Isis/qview/ChipViewportsWidget.config");
297 QSettings settings(config.expanded(),
298 QSettings::NativeFormat);
299 settings.setValue(
"pos", this->pos());
300 settings.setValue(
"size", this->size());
315 void ChipViewportsWidget::geomChips(
bool geomChips) {
318 for (
int i=1; i<m_chipViewports.size(); i++) {
319 m_chipViewports.at(i)->nogeomChip();
324 for (
int i=1; i<m_chipViewports.size(); i++) {
325 m_chipViewports.at(i)->geomChip(m_chipViewports.at(0)->chip(),
326 m_chipViewports.at(0)->chipCube());
333 void ChipViewportsWidget::clearPoint() {
335 if (m_chipViewports.size() > 0) {
336 foreach (ChipViewport *measureChipViewport, m_chipViewports) {
338 delete measureChipViewport;
340 m_chipViewports.clear();
346 bool ChipViewportsWidget::eventFilter(
QObject *
object, QEvent *event) {
348 bool blockEvent =
false;
350 switch (event->type()) {
351 case QEvent::MouseButtonPress: {
352 mousePressEvent(
object, (QMouseEvent *)event);
364 void ChipViewportsWidget::mousePressEvent(
QObject *
object, QMouseEvent *event) {
366 if (event->button() == Qt::RightButton) {
367 qDebug()<<
"ChipViewportsWidget::mousePressEvent right mouse";
369 ChipViewport *chipViewport = qobject_cast<ChipViewport *>(focusWidget());
373 QAction *setReferenceMeasureAction =
new QAction(tr(
"Set as Reference Measure"),
this);
374 contextMenu.addAction(setReferenceMeasureAction);
377 contextMenu.exec(qobject_cast<QWidget *>(
object)->mapToGlobal(event->pos()));
379 if (chosenAction == setReferenceMeasureAction) {
380 qDebug()<<
"ChipViewportsWidget::mousePressEvent setRefMeasureAction chipViewport = "<<chipViewport;