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" 
   34#include "XmlStackedHandlerReader.h" 
   36#include <boost/numeric/ublas/fwd.hpp> 
   37#include <boost/numeric/ublas/io.hpp> 
   38#include <boost/numeric/ublas/matrix_sparse.hpp> 
   39#include <boost/numeric/ublas/matrix_proxy.hpp> 
   41using namespace boost::numeric::ublas;
 
   54                                       bool internalizeToolBarsAndProgress,
 
   94    QGridLayout * sceneLayout = 
new QGridLayout;
 
   95    sceneLayout->setContentsMargins(0, 0, 0, 0);
 
   96    setLayout(sceneLayout);
 
   99    if (!status && internalizeToolBarsAndProgress)
 
  100      status = 
new QStatusBar;
 
  104      if (internalizeToolBarsAndProgress) {
 
  108        QHBoxLayout *horizontalStatusLayout = 
new QHBoxLayout;
 
  109        horizontalStatusLayout->addWidget(
m_progress);
 
  110        horizontalStatusLayout->addStretch();
 
  111        horizontalStatusLayout->addWidget(status);
 
  113        sceneLayout->addLayout(horizontalStatusLayout, 2, 0, 1, 2);
 
  119      setWhatsThis(
"This is the matrix scene. You can interact with the " 
  120                   "matrix elements shown here. ");
 
  122      getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 
  123      getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 
  125      getView()->enableResizeZooming(
false);
 
  127      connect( 
getView()->horizontalScrollBar(), SIGNAL( valueChanged(
int) ),
 
  129      connect( 
getView()->verticalScrollBar() , SIGNAL( valueChanged(
int) ),
 
  131      connect( 
getView()->horizontalScrollBar(), SIGNAL( rangeChanged(
int, 
int) ),
 
  133      connect( 
getView()->verticalScrollBar() , SIGNAL( rangeChanged(
int, 
int) ),
 
  139      getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
  140      getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
  142      setWhatsThis(
"This is the matrix world view. The matrix will be " 
  143          "shown here, but you cannot zoom in.");
 
 
  185    bool handled = 
false;
 
  187    QList<QGraphicsItem *> selectedGraphicsItems = 
getScene()->selectedItems();
 
 
  264      boundingRect = boundingRect.united( 
m_outlineRect->boundingRect() );
 
 
  286    QList<QAction *> viewActs;
 
 
  304    QList<QAction *> results;
 
 
  332    QPointF topLeft = 
getView()->mapToScene(0, 0);
 
  333    QPointF bottomRight =
 
  336    QRectF visibleRect(topLeft, bottomRight);
 
 
  359    bool stopProcessingEvent = 
true;
 
  361    switch( event->type() ) {
 
  362      case QMouseEvent::GraphicsSceneMousePress: {
 
  363        if (
m_graphicsScene->itemAt( ( (QGraphicsSceneMouseEvent *)event )->scenePos(),
 
  366                                ( (QGraphicsSceneMouseEvent *)event )->scenePos(),
 
  367                                   QTransform() )->toolTip() );
 
  369        stopProcessingEvent = 
false;
 
  373      case QMouseEvent::GraphicsSceneMouseDoubleClick:
 
  375            ((QGraphicsSceneMouseEvent *)event)->scenePos());
 
  377        stopProcessingEvent = 
false;
 
  381        stopProcessingEvent = 
false;
 
  385    return stopProcessingEvent;
 
 
  414    int elementSize = 10;
 
  420    QList<QGraphicsRectItem *> squares;
 
  422    QList<int> paramList;
 
  425    QBrush fillBrush(Qt::blue);
 
  426    QPen outlinePen(Qt::black);
 
  427    outlinePen.setWidth(0);
 
  430    QMapIterator<QString, QStringList> colIterator( *corrMatrix.imagesAndParameters() );
 
  432    QMapIterator<QString, QStringList> rowIterator( *corrMatrix.imagesAndParameters() );
 
  435      QMapIterator<int, matrix<double>*> block(blockColumn);
 
  436      bool lastBlock = 
true;
 
  439      rowIterator = colIterator;
 
  443        rowIterator.previous();
 
  444        for (
int row = 0; row < (int)block.value()->size1(); row++) {
 
  445          for (
int column = 0; column < (int)block.value()->size2(); column++) {
 
  452              double lowerColorValue = fabs( ( *block.value() )(row, column) ) * 255.0;
 
  453              if (fabs( ( *block.value() )(row, column) ) < .5) {
 
  454                red = lowerColorValue * 2;
 
  458                green = 255 - ( (lowerColorValue - 127.5) * 2 );
 
  461               fillColor = QColor(red, green, 0);
 
  470              else if (column == row) {
 
  471                outlinePen.setColor(Qt::black);
 
  472                fillBrush.setColor(Qt::blue); 
 
  475                outlinePen.setColor(Qt::black);
 
  477                  if ( fabs( ( *block.value() )(row, column) ) >=
 
  486                  fillBrush.setColor(fillColor);
 
  491              outlinePen.setColor(Qt::black);
 
  493                  if ( fabs( ( *block.value() )(row, column) ) >=
 
  502                  fillBrush.setColor(fillColor);
 
  509                                                   elementSize, elementSize, 
 
  510                                                   outlinePen, fillBrush);   
 
  511              QString img1 = 
"Image 1       : " + colIterator.key() + 
"\n";
 
  512              QString param1 = 
"Parameter 1: " + colIterator.value().at(column) + 
"\n";
 
  513              QString img2 = 
"Image 2       : " + rowIterator.key() + 
"\n";
 
  514              QString param2 = 
"Parameter 2: " + rowIterator.value().at(row);
 
  515              QString toolTip = 
"Correlation  : "  
  516                  + QString::number( ( *block.value() )(row, column) )
 
  517                  + 
"\n" + img1 + param1 + img2 + param2;
 
  518              rectangle->setToolTip(toolTip);
 
  527        if ( block.hasPrevious() ) {
 
  528          yOffset += block.peekPrevious().value()->size1() * elementSize;
 
  530        y = startY - yOffset;
 
  532      } 
while ( block.hasPrevious() );
 
  534      startX += block.value()->size2() * elementSize;
 
  535      startY += block.value()->size1() * elementSize;
 
 
  554    int elementSize = 10;
 
  557    int segmentLength = 0;
 
  559    QMapIterator<QString, QStringList> it( *corrMatrix.imagesAndParameters() );
 
  561    while ( it.hasNext() ) {
 
  563      int numOfParams = it.value().count();
 
  564      segmentLength += numOfParams * elementSize;
 
  565      segments.append(segmentLength);
 
  568    segments.removeLast();
 
  570    QList<QGraphicsLineItem> lines;
 
  573    pen.setColor(Qt::black);
 
  577    QGraphicsLineItem *hLine;
 
  578    hLine = 
new QGraphicsLineItem(startHX, startHY,
 
  579                                  startHX + segmentLength, startHY);
 
  584    QGraphicsLineItem *vLine;
 
  585    vLine = 
new QGraphicsLineItem(startVX + segmentLength, startVY,
 
  586                                  startVX + segmentLength, startVY + segmentLength);
 
  590    int edge = startVX + segmentLength;
 
  591    int currentLength = segmentLength;
 
  592    int currentVX = startVX;
 
  595    foreach (
int segment, segments) {
 
  596      currentVX = startVX + segment;
 
  597      currentLength = segmentLength - segment;
 
  599      vLine = 
new QGraphicsLineItem(currentVX, startVY,
 
  600                                    currentVX, startVY + segment);
 
  602      hLine = 
new QGraphicsLineItem(edge - currentLength, startHY + segment,
 
  603                                    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.