mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
Added Stereo and StereoDense base classes (with Stereo->StereoOpticalFlow and StereoDense->StereoBM) to handle easily stereo parameters. Added stereoEval tool to test Stereo/OpticalFlow=false or true. Added StereoBM parameters. Refactoring of the Preferences dialog (tree view order and some titles)
This commit is contained in:
@@ -36,12 +36,114 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QGraphicsEffect>
|
||||
#include <QInputDialog>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGraphicsRectItem>
|
||||
#include "rtabmap/utilite/ULogger.h"
|
||||
#include "rtabmap/gui/KeypointItem.h"
|
||||
#include "rtabmap/core/util2d.h"
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
//LineItem
|
||||
class LineItem : public QGraphicsLineItem
|
||||
{
|
||||
public:
|
||||
LineItem(float x1, float y1, float x2, float y2, const QString & text = QString(), QGraphicsItem * parent = 0) :
|
||||
QGraphicsLineItem(x1, y1, x2, y2, parent),
|
||||
_text(text),
|
||||
_placeHolder(0)
|
||||
{
|
||||
this->setAcceptHoverEvents(true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||
_width = pen().width();
|
||||
}
|
||||
virtual ~LineItem()
|
||||
{
|
||||
if(_placeHolder)
|
||||
{
|
||||
delete _placeHolder;
|
||||
}
|
||||
}
|
||||
|
||||
void setColor(const QColor & color);
|
||||
|
||||
protected:
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
|
||||
{
|
||||
QGraphicsScene * scene = this->scene();
|
||||
if(scene && scene->focusItem() == 0)
|
||||
{
|
||||
this->showDescription();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setPen(QPen(pen().color(), _width+2));
|
||||
}
|
||||
QGraphicsLineItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
|
||||
{
|
||||
if(!this->hasFocus())
|
||||
{
|
||||
this->hideDescription();
|
||||
}
|
||||
QGraphicsLineItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
virtual void focusInEvent ( QFocusEvent * event )
|
||||
{
|
||||
this->showDescription();
|
||||
QGraphicsLineItem::focusInEvent(event);
|
||||
}
|
||||
|
||||
virtual void focusOutEvent ( QFocusEvent * event )
|
||||
{
|
||||
this->hideDescription();
|
||||
QGraphicsLineItem::focusOutEvent(event);
|
||||
}
|
||||
|
||||
private:
|
||||
void showDescription()
|
||||
{
|
||||
if(!_text.isEmpty())
|
||||
{
|
||||
if(!_placeHolder)
|
||||
{
|
||||
_placeHolder = new QGraphicsRectItem (this);
|
||||
_placeHolder->setVisible(false);
|
||||
_placeHolder->setBrush(QBrush(QColor ( 0, 0, 0, 170 ))); // Black transparent background
|
||||
QGraphicsTextItem * text = new QGraphicsTextItem(_placeHolder);
|
||||
text->setDefaultTextColor(this->pen().color().rgb());
|
||||
text->setPlainText(_text);
|
||||
_placeHolder->setRect(text->boundingRect());
|
||||
}
|
||||
|
||||
if(_placeHolder->parentItem())
|
||||
{
|
||||
_placeHolder->setParentItem(0); // Make it a to level item
|
||||
}
|
||||
_placeHolder->setZValue(this->zValue()+1);
|
||||
_placeHolder->setPos(this->mapFromScene(0,0));
|
||||
_placeHolder->setVisible(true);
|
||||
}
|
||||
QPen pen = this->pen();
|
||||
this->setPen(QPen(pen.color(), _width+2));
|
||||
}
|
||||
void hideDescription()
|
||||
{
|
||||
if(_placeHolder)
|
||||
{
|
||||
_placeHolder->setVisible(false);
|
||||
}
|
||||
this->setPen(QPen(pen().color(), _width));
|
||||
}
|
||||
|
||||
private:
|
||||
QString _text;
|
||||
QGraphicsRectItem * _placeHolder;
|
||||
int _width;
|
||||
};
|
||||
|
||||
ImageView::ImageView(QWidget * parent) :
|
||||
QWidget(parent),
|
||||
_savedFileName((QDir::homePath()+ "/") + "picture" + ".png"),
|
||||
@@ -595,10 +697,10 @@ void ImageView::addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor
|
||||
}
|
||||
}
|
||||
|
||||
void ImageView::addLine(float x1, float y1, float x2, float y2, QColor color)
|
||||
void ImageView::addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text)
|
||||
{
|
||||
color.setAlpha(this->getAlpha());
|
||||
QGraphicsLineItem * item = new QGraphicsLineItem(x1, y1, x2, y2);
|
||||
LineItem * item = new LineItem(x1, y1, x2, y2, text);
|
||||
item->setPen(QPen(color));
|
||||
_lines.push_back(item);
|
||||
item->setVisible(isLinesShown());
|
||||
|
||||
Reference in New Issue
Block a user