9#include "ChipViewportsWidget.h"
19#include "Application.h"
21#include "ChipViewport.h"
22#include "ControlMeasureEditWidget.h"
23#include "ControlMeasure.h"
24#include "ControlMeasureLogData.h"
25#include "ControlNet.h"
26#include "ControlPoint.h"
29#include "IException.h"
32#include "MainWindow.h"
33#include "MdiCubeViewport.h"
35#include "PvlEditDialog.h"
36#include "SerialNumber.h"
37#include "SerialNumberList.h"
38#include "SpecialPixel.h"
40#include "ViewportMainWindow.h"
61 m_serialNumberList = NULL;
67 installEventFilter(
this);
74 ChipViewportsWidget::~ChipViewportsWidget () {
90 setWindowTitle(
"ChipViewports");
91 setObjectName(
"ChipViewportsWidget");
92 connect(
this, SIGNAL(destroyed(
QObject *)),
this, SLOT(clearPoint()));
96 m_chipViewportsLayout =
new QGridLayout;
99 centralWidget->setLayout(m_chipViewportsLayout);
101 QScrollArea *scrollArea =
new QScrollArea();
102 scrollArea->setObjectName(
"ChipViewportsWidgetScroll");
103 scrollArea->setWidgetResizable(
true);
104 scrollArea->setWidget(centralWidget);
105 centralWidget->adjustSize();
107 QVBoxLayout *mainLayout =
new QVBoxLayout;
109 m_ptIdValue =
new QLabel();
111 QCheckBox *
showPoints =
new QCheckBox(
"Show control points");
112 showPoints->setToolTip(
"Draw control point crosshairs");
113 showPoints->setWhatsThis(
"This will toggle whether crosshairs are drawn"
114 " for the control points located within the measure''s"
115 " view. For areas of dense measurements, turning this"
116 " off will allow easier viewing of features.");
120 QCheckBox *geomChips =
new QCheckBox(
"Geom Chips to Reference");
121 geomChips->setToolTip(
"Geom Chips to Reference Control Measure");
122 geomChips->setWhatsThis(
"This will toggle whether chips are geomed to"
123 " the reference control measure.");
124 connect(geomChips, SIGNAL(toggled(
bool)),
this, SLOT(geomChips(
bool)));
125 geomChips->setChecked(
false);
127 QHBoxLayout *pointsGeomLayout =
new QHBoxLayout;
129 pointsGeomLayout->addWidget(geomChips);
130 pointsGeomLayout->addStretch();
132 mainLayout->addWidget(m_ptIdValue);
133 mainLayout->addLayout(pointsGeomLayout);
134 mainLayout->addWidget(scrollArea);
135 setLayout(mainLayout);
142 void ChipViewportsWidget::createActions() {
148 void ChipViewportsWidget::setSerialNumberList(SerialNumberList *snList) {
152 m_serialNumberList = snList;
169 m_cnetFileName = cnetFilename;
173 emit newControlNetwork(cnet);
178 void ChipViewportsWidget::setPoint(
ControlPoint *controlPoint) {
191 if (m_chipViewports.size() > 0) clearPoint();
192 m_controlPoint = controlPoint;
195 QString CPId = m_controlPoint->GetId();
196 QString ptId(
"Point ID: ");
197 ptId += (QString) CPId;
198 m_ptIdValue->setText(ptId);
205 if (m_controlPoint->IsReferenceExplicit()) {
209 m_controlPoint->GetRefMeasure()->GetCubeSerialNumber()));
212 chip->
TackCube(measure->GetSample(), measure->GetLine());
213 chip->
Load(*measureCube);
215 measureChipViewport->setChip(chip, measureCube);
216 measureChipViewport->setControlNet(m_controlNet);
217 measureChipViewport->setPoints(
true);
218 m_chipViewports.append(measureChipViewport);
223 for (
int i = 0; i < m_controlPoint->GetNumMeasures(); i++) {
224 ControlMeasure *measure = (*m_controlPoint)[i];
225 if (!m_controlPoint->IsReferenceExplicit() && i == 0) {
230 else if (m_controlPoint->IsReferenceExplicit() &&
231 (QString) measure->GetCubeSerialNumber() == m_controlPoint->GetReferenceSN()) {
237 Cube *measureCube =
new Cube(m_serialNumberList->
fileName(measure->GetCubeSerialNumber()));
240 chip->TackCube(measure->GetSample(), measure->GetLine());
241 chip->Load(*measureCube);
242 ChipViewport *measureChipViewport =
new ChipViewport(
VIEWSIZE,
VIEWSIZE,
this);
243 measureChipViewport->setChip(chip, measureCube);
244 measureChipViewport->setControlNet(m_controlNet);
245 measureChipViewport->setPoints(
true);
246 m_chipViewports.append(measureChipViewport);
252 int gridDimension = sqrt(qreal(m_chipViewports.size())) -1;
255 foreach(ChipViewport *measurechipViewport, m_chipViewports) {
256 if (x > gridDimension) {
260 m_chipViewportsLayout->addWidget(measurechipViewport, y, x);
273 void ChipViewportsWidget::readSettings() {
274 FileName config(
"$HOME/.Isis/qview/ChipViewportsWidget.config");
275 QSettings settings(config.expanded(),
276 QSettings::NativeFormat);
277 QPoint pos = settings.value(
"pos", QPoint(300, 100)).toPoint();
278 QSize size = settings.value(
"size", QSize(900, 500)).toSize();
290 void ChipViewportsWidget::writeSettings()
const {
293 if (!this->isVisible())
return;
294 FileName config(
"$HOME/.Isis/qview/ChipViewportsWidget.config");
295 QSettings settings(config.expanded(),
296 QSettings::NativeFormat);
297 settings.setValue(
"pos", this->pos());
298 settings.setValue(
"size", this->size());
313 void ChipViewportsWidget::geomChips(
bool geomChips) {
316 for (
int i=1; i<m_chipViewports.size(); i++) {
317 m_chipViewports.at(i)->nogeomChip();
322 for (
int i=1; i<m_chipViewports.size(); i++) {
323 m_chipViewports.at(i)->geomChip(m_chipViewports.at(0)->chip(),
324 m_chipViewports.at(0)->chipCube());
331 void ChipViewportsWidget::clearPoint() {
333 if (m_chipViewports.size() > 0) {
334 foreach (ChipViewport *measureChipViewport, m_chipViewports) {
336 delete measureChipViewport;
338 m_chipViewports.clear();
344 bool ChipViewportsWidget::eventFilter(
QObject *
object, QEvent *event) {
346 bool blockEvent =
false;
348 switch (event->type()) {
349 case QEvent::MouseButtonPress: {
350 mousePressEvent(
object, (QMouseEvent *)event);
362 void ChipViewportsWidget::mousePressEvent(
QObject *
object, QMouseEvent *event) {
364 if (event->button() == Qt::RightButton) {
365 qDebug()<<
"ChipViewportsWidget::mousePressEvent right mouse";
367 ChipViewport *chipViewport = qobject_cast<ChipViewport *>(focusWidget());
371 QAction *setReferenceMeasureAction =
new QAction(tr(
"Set as Reference Measure"),
this);
372 contextMenu.addAction(setReferenceMeasureAction);
375 contextMenu.exec(qobject_cast<QWidget *>(
object)->mapToGlobal(event->pos()));
377 if (chosenAction == setReferenceMeasureAction) {
378 qDebug()<<
"ChipViewportsWidget::mousePressEvent setRefMeasureAction chipViewport = "<<chipViewport;
A small chip of data used for pattern matching.
void TackCube(const double cubeSample, const double cubeLine)
This sets which cube position will be located at the chip tack position.
void Load(Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
Load cube data into the Chip.
IO Handler for Isis Cubes.
QString fileName(const QString &sn)
Return a filename given a serial number.
This is free and unencumbered software released into the public domain.
const int VIEWSIZE
Constant representing the length and width of the chip viewports.
Namespace for the standard library.