1#include "MatrixSceneWidget.h" 
    6#include <QGraphicsRectItem> 
    7#include <QGraphicsSceneMouseEvent> 
   16#include "CorrelationMatrix.h" 
   20#include "GraphicsView.h" 
   21#include "IException.h" 
   23#include "MatrixGraphicsScene.h" 
   24#include "MatrixGraphicsView.h" 
   25#include "MatrixOptions.h" 
   26#include "ProgressBar.h" 
   30#include "SparseBlockMatrix.h" 
   35#include <boost/numeric/ublas/fwd.hpp> 
   36#include <boost/numeric/ublas/io.hpp> 
   37#include <boost/numeric/ublas/matrix_sparse.hpp> 
   38#include <boost/numeric/ublas/matrix_proxy.hpp> 
   40using namespace boost::numeric::ublas;
 
   53                                       bool internalizeToolBarsAndProgress,
 
   93    QGridLayout * sceneLayout = 
new QGridLayout;
 
   94    sceneLayout->setContentsMargins(0, 0, 0, 0);
 
   95    setLayout(sceneLayout);
 
   98    if (!status && internalizeToolBarsAndProgress)
 
   99      status = 
new QStatusBar;
 
  103      if (internalizeToolBarsAndProgress) {
 
  107        QHBoxLayout *horizontalStatusLayout = 
new QHBoxLayout;
 
  108        horizontalStatusLayout->addWidget(
m_progress);
 
  109        horizontalStatusLayout->addStretch();
 
  110        horizontalStatusLayout->addWidget(status);
 
  112        sceneLayout->addLayout(horizontalStatusLayout, 2, 0, 1, 2);
 
  118      setWhatsThis(
"This is the matrix scene. You can interact with the " 
  119                   "matrix elements shown here. ");
 
  121      getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 
  122      getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 
  124      getView()->enableResizeZooming(
false);
 
  126      connect( 
getView()->horizontalScrollBar(), SIGNAL( valueChanged(
int) ),
 
  128      connect( 
getView()->verticalScrollBar() , SIGNAL( valueChanged(
int) ),
 
  130      connect( 
getView()->horizontalScrollBar(), SIGNAL( rangeChanged(
int, 
int) ),
 
  132      connect( 
getView()->verticalScrollBar() , SIGNAL( rangeChanged(
int, 
int) ),
 
  138      getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
  139      getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
  141      setWhatsThis(
"This is the matrix world view. The matrix will be " 
  142          "shown here, but you cannot zoom in.");
 
 
  184    bool handled = 
false;
 
  186    QList<QGraphicsItem *> selectedGraphicsItems = 
getScene()->selectedItems();
 
 
  257      boundingRect = boundingRect.united( 
m_outlineRect->boundingRect() );
 
 
  279    QList<QAction *> viewActs;
 
 
  297    QList<QAction *> results;
 
 
  325    QPointF topLeft = 
getView()->mapToScene(0, 0);
 
  326    QPointF bottomRight =
 
  329    QRectF visibleRect(topLeft, bottomRight);
 
 
  352    bool stopProcessingEvent = 
true;
 
  354    switch( event->type() ) {
 
  355      case QMouseEvent::GraphicsSceneMousePress: {
 
  356        if (
m_graphicsScene->itemAt( ( (QGraphicsSceneMouseEvent *)event )->scenePos(),
 
  359                                ( (QGraphicsSceneMouseEvent *)event )->scenePos(),
 
  360                                   QTransform() )->toolTip() );
 
  362        stopProcessingEvent = 
false;
 
  366      case QMouseEvent::GraphicsSceneMouseDoubleClick:
 
  368            ((QGraphicsSceneMouseEvent *)event)->scenePos());
 
  370        stopProcessingEvent = 
false;
 
  374        stopProcessingEvent = 
false;
 
  378    return stopProcessingEvent;
 
 
  407    int elementSize = 10;
 
  413    QList<QGraphicsRectItem *> squares;
 
  415    QList<int> paramList;
 
  418    QBrush fillBrush(Qt::blue);
 
  419    QPen outlinePen(Qt::black);
 
  420    outlinePen.setWidth(0);
 
  423    QMapIterator<QString, QStringList> colIterator( *corrMatrix.imagesAndParameters() );
 
  425    QMapIterator<QString, QStringList> rowIterator( *corrMatrix.imagesAndParameters() );
 
  428      QMapIterator<int, matrix<double>*> block(blockColumn);
 
  429      bool lastBlock = 
true;
 
  432      rowIterator = colIterator;
 
  436        rowIterator.previous();
 
  437        for (
int row = 0; row < (int)block.value()->size1(); row++) {
 
  438          for (
int column = 0; column < (int)block.value()->size2(); column++) {
 
  445              double lowerColorValue = fabs( ( *block.value() )(row, column) ) * 255.0;
 
  446              if (fabs( ( *block.value() )(row, column) ) < .5) {
 
  447                red = lowerColorValue * 2;
 
  451                green = 255 - ( (lowerColorValue - 127.5) * 2 );
 
  454               fillColor = QColor(red, green, 0);
 
  463              else if (column == row) {
 
  464                outlinePen.setColor(Qt::black);
 
  465                fillBrush.setColor(Qt::blue); 
 
  468                outlinePen.setColor(Qt::black);
 
  470                  if ( fabs( ( *block.value() )(row, column) ) >=
 
  479                  fillBrush.setColor(fillColor);
 
  484              outlinePen.setColor(Qt::black);
 
  486                  if ( fabs( ( *block.value() )(row, column) ) >=
 
  495                  fillBrush.setColor(fillColor);
 
  502                                                   elementSize, elementSize, 
 
  503                                                   outlinePen, fillBrush);   
 
  504              QString img1 = 
"Image 1       : " + colIterator.key() + 
"\n";
 
  505              QString param1 = 
"Parameter 1: " + colIterator.value().at(column) + 
"\n";
 
  506              QString img2 = 
"Image 2       : " + rowIterator.key() + 
"\n";
 
  507              QString param2 = 
"Parameter 2: " + rowIterator.value().at(row);
 
  508              QString toolTip = 
"Correlation  : "  
  509                  + QString::number( ( *block.value() )(row, column) )
 
  510                  + 
"\n" + img1 + param1 + img2 + param2;
 
  511              rectangle->setToolTip(toolTip);
 
  520        if ( block.hasPrevious() ) {
 
  521          yOffset += block.peekPrevious().value()->size1() * elementSize;
 
  523        y = startY - yOffset;
 
  525      } 
while ( block.hasPrevious() );
 
  527      startX += block.value()->size2() * elementSize;
 
  528      startY += block.value()->size1() * elementSize;
 
 
  547    int elementSize = 10;
 
  550    int segmentLength = 0;
 
  552    QMapIterator<QString, QStringList> it( *corrMatrix.imagesAndParameters() );
 
  554    while ( it.hasNext() ) {
 
  556      int numOfParams = it.value().count();
 
  557      segmentLength += numOfParams * elementSize;
 
  558      segments.append(segmentLength);
 
  561    segments.removeLast();
 
  563    QList<QGraphicsLineItem> lines;
 
  566    pen.setColor(Qt::black);
 
  570    QGraphicsLineItem *hLine;
 
  571    hLine = 
new QGraphicsLineItem(startHX, startHY,
 
  572                                  startHX + segmentLength, startHY);
 
  577    QGraphicsLineItem *vLine;
 
  578    vLine = 
new QGraphicsLineItem(startVX + segmentLength, startVY,
 
  579                                  startVX + segmentLength, startVY + segmentLength);
 
  583    int edge = startVX + segmentLength;
 
  584    int currentLength = segmentLength;
 
  585    int currentVX = startVX;
 
  588    foreach (
int segment, segments) {
 
  589      currentVX = startVX + segment;
 
  590      currentLength = segmentLength - segment;
 
  592      vLine = 
new QGraphicsLineItem(currentVX, startVY,
 
  593                                    currentVX, startVY + segment);
 
  595      hLine = 
new QGraphicsLineItem(edge - currentLength, startHY + segment,
 
  596                                    edge, startHY + segment);
 
 
This is a container for the correlation matrix that comes from a bundle adjust.
 
A graphics scene with improved user-interaction for use with the MatrixSceneWidget.
 
A graphics view that resizes in a more friendly way.
 
This class holds the matrix color and focus information.
 
QColor badCorrelationColor()
The color selected for the correlation values that are above the given threshold.
 
QColor goodCorrelationColor()
The color selected for the correlation values that are below the given threshold.
 
double colorTolerance()
Threshold for what is considered a bad correlation.
 
bool colorScheme()
Use the green-red gradient if false.
 
This is free and unencumbered software released into the public domain.