3 #include "MatrixSceneWidget.h" 8 #include <QGraphicsRectItem> 9 #include <QGraphicsSceneMouseEvent> 22 #include "GraphicsView.h" 25 #include "MatrixGraphicsScene.h" 26 #include "MatrixGraphicsView.h" 27 #include "MatrixOptions.h" 28 #include "ProgressBar.h" 36 #include "XmlStackedHandlerReader.h" 38 #include <boost/numeric/ublas/fwd.hpp> 39 #include <boost/numeric/ublas/io.hpp> 40 #include <boost/numeric/ublas/matrix_sparse.hpp> 41 #include <boost/numeric/ublas/matrix_proxy.hpp> 54 MatrixSceneWidget::MatrixSceneWidget(QStatusBar *status,
56 bool internalizeToolBarsAndProgress,
96 QGridLayout * sceneLayout =
new QGridLayout;
97 sceneLayout->setContentsMargins(0, 0, 0, 0);
98 setLayout(sceneLayout);
101 if (!status && internalizeToolBarsAndProgress)
102 status =
new QStatusBar;
106 if (internalizeToolBarsAndProgress) {
110 QHBoxLayout *horizontalStatusLayout =
new QHBoxLayout;
111 horizontalStatusLayout->addWidget(
m_progress);
112 horizontalStatusLayout->addStretch();
113 horizontalStatusLayout->addWidget(status);
115 sceneLayout->addLayout(horizontalStatusLayout, 2, 0, 1, 2);
121 setWhatsThis(
"This is the matrix scene. You can interact with the " 122 "matrix elements shown here. ");
124 getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
125 getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
127 getView()->enableResizeZooming(
false);
129 connect(
getView()->horizontalScrollBar(), SIGNAL( valueChanged(
int) ),
131 connect(
getView()->verticalScrollBar() , SIGNAL( valueChanged(
int) ),
133 connect(
getView()->horizontalScrollBar(), SIGNAL( rangeChanged(
int,
int) ),
135 connect(
getView()->verticalScrollBar() , SIGNAL( rangeChanged(
int,
int) ),
141 getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
142 getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
144 setWhatsThis(
"This is the matrix world view. The matrix will be " 145 "shown here, but you cannot zoom in.");
187 bool handled =
false;
266 boundingRect = boundingRect.united(
m_outlineRect->boundingRect() );
334 QPointF topLeft =
getView()->mapToScene(0, 0);
335 QPointF bottomRight =
338 QRectF visibleRect(topLeft, bottomRight);
361 bool stopProcessingEvent =
true;
363 switch( event->type() ) {
364 case QMouseEvent::GraphicsSceneMousePress: {
365 if (
m_graphicsScene->itemAt( ( (QGraphicsSceneMouseEvent *)event )->scenePos(),
368 ( (QGraphicsSceneMouseEvent *)event )->scenePos(),
369 QTransform() )->toolTip() );
371 stopProcessingEvent =
false;
375 case QMouseEvent::GraphicsSceneMouseDoubleClick:
377 ((QGraphicsSceneMouseEvent *)event)->scenePos());
379 stopProcessingEvent =
false;
383 stopProcessingEvent =
false;
387 return stopProcessingEvent;
416 int elementSize = 10;
427 QBrush fillBrush(Qt::blue);
428 QPen outlinePen(Qt::black);
429 outlinePen.setWidth(0);
437 QMapIterator<int, matrix<double>*> block(blockColumn);
438 bool lastBlock =
true;
441 rowIterator = colIterator;
445 rowIterator.previous();
446 for (
int row = 0; row < (int)block.value()->size1(); row++) {
447 for (
int column = 0; column < (int)block.value()->size2(); column++) {
454 double lowerColorValue = fabs( ( *block.value() )(row, column) ) * 255.0;
455 if (fabs( ( *block.value() )(row, column) ) < .5) {
456 red = lowerColorValue * 2;
460 green = 255 - ( (lowerColorValue - 127.5) * 2 );
463 fillColor = QColor(red, green, 0);
472 else if (column == row) {
473 outlinePen.setColor(Qt::black);
474 fillBrush.setColor(Qt::blue);
477 outlinePen.setColor(Qt::black);
479 if ( fabs( ( *block.value() )(row, column) ) >=
488 fillBrush.setColor(fillColor);
493 outlinePen.setColor(Qt::black);
495 if ( fabs( ( *block.value() )(row, column) ) >=
504 fillBrush.setColor(fillColor);
511 elementSize, elementSize,
512 outlinePen, fillBrush);
513 QString img1 =
"Image 1 : " + colIterator.key() +
"\n";
514 QString param1 =
"Parameter 1: " + colIterator.value().at(column) +
"\n";
515 QString img2 =
"Image 2 : " + rowIterator.key() +
"\n";
516 QString param2 =
"Parameter 2: " + rowIterator.value().at(row);
517 QString toolTip =
"Correlation : " 518 + QString::number( ( *block.value() )(row, column) )
519 +
"\n" + img1 + param1 + img2 + param2;
520 rectangle->setToolTip(toolTip);
529 if ( block.hasPrevious() ) {
530 yOffset += block.peekPrevious().value()->size1() * elementSize;
532 y = startY - yOffset;
534 }
while ( block.hasPrevious() );
536 startX += block.value()->size2() * elementSize;
537 startY += block.value()->size1() * elementSize;
556 int elementSize = 10;
559 int segmentLength = 0;
563 while ( it.hasNext() ) {
565 int numOfParams = it.value().count();
566 segmentLength += numOfParams * elementSize;
567 segments.append(segmentLength);
570 segments.removeLast();
575 pen.setColor(Qt::black);
579 QGraphicsLineItem *hLine;
580 hLine =
new QGraphicsLineItem(startHX, startHY,
581 startHX + segmentLength, startHY);
586 QGraphicsLineItem *vLine;
587 vLine =
new QGraphicsLineItem(startVX + segmentLength, startVY,
588 startVX + segmentLength, startVY + segmentLength);
592 int edge = startVX + segmentLength;
593 int currentLength = segmentLength;
594 int currentVX = startVX;
597 foreach (
int segment, segments) {
598 currentVX = startVX + segment;
599 currentLength = segmentLength - segment;
601 vLine =
new QGraphicsLineItem(currentVX, startVY,
602 currentVX, startVY + segment);
604 hLine =
new QGraphicsLineItem(edge - currentLength, startHY + segment,
605 edge, startHY + segment);
A graphics scene with improved user-interaction for use with the MatrixSceneWidget.
This is a container for the correlation matrix that comes from a bundle adjust.
This class holds the matrix color and focus information.
double colorTolerance()
Threshold for what is considered a bad correlation.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QColor badCorrelationColor()
The color selected for the correlation values that are above the given threshold. ...
A graphics view that resizes in a more friendly way.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Namespace for ISIS/Bullet specific routines.
QList< SparseBlockColumnMatrix > * visibleBlocks()
Get the visible part of the matrix.
bool colorScheme()
Use the green-red gradient if false.
QColor goodCorrelationColor()
The color selected for the correlation values that are below the given threshold. ...
QMap< QString, QStringList > * imagesAndParameters()
Public access for the qmap of images and parameters.