Added actions "Add object from scene/files..." on right-click in the objects panel (same behavior as those in Edit->...).
Fixed alpha for rectangles. Refactored the naming of private members (_myAtt to myAtt_). git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@96 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
beb855e7ee
commit
8e44f2bedf
@ -8,13 +8,13 @@
|
|||||||
AboutDialog::AboutDialog(QWidget * parent) :
|
AboutDialog::AboutDialog(QWidget * parent) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
{
|
{
|
||||||
_ui = new Ui_aboutDialog();
|
ui_ = new Ui_aboutDialog();
|
||||||
_ui->setupUi(this);
|
ui_->setupUi(this);
|
||||||
_ui->label_version->setText(PROJECT_VERSION);
|
ui_->label_version->setText(PROJECT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
AboutDialog::~AboutDialog()
|
AboutDialog::~AboutDialog()
|
||||||
{
|
{
|
||||||
delete _ui;
|
delete ui_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public:
|
|||||||
virtual ~AboutDialog();
|
virtual ~AboutDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_aboutDialog * _ui;
|
Ui_aboutDialog * ui_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,23 +10,23 @@
|
|||||||
|
|
||||||
KeypointItem::KeypointItem(int id, qreal x, qreal y, int r, const QString & info, const QColor & color, QGraphicsItem * parent) :
|
KeypointItem::KeypointItem(int id, qreal x, qreal y, int r, const QString & info, const QColor & color, QGraphicsItem * parent) :
|
||||||
QGraphicsEllipseItem(x, y, r, r, parent),
|
QGraphicsEllipseItem(x, y, r, r, parent),
|
||||||
_info(info),
|
info_(info),
|
||||||
_placeHolder(0),
|
placeHolder_(0),
|
||||||
_id(id)
|
id_(id)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(color));
|
this->setPen(QPen(color));
|
||||||
this->setBrush(QBrush(color));
|
this->setBrush(QBrush(color));
|
||||||
this->setAcceptsHoverEvents(true);
|
this->setAcceptsHoverEvents(true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
_width = pen().width();
|
width_ = pen().width();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeypointItem::~KeypointItem()
|
KeypointItem::~KeypointItem()
|
||||||
{
|
{
|
||||||
/*if(_placeHolder)
|
/*if(placeHolder_)
|
||||||
{
|
{
|
||||||
delete _placeHolder;
|
delete placeHolder_;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ void KeypointItem::setColor(const QColor & color)
|
|||||||
{
|
{
|
||||||
this->setPen(QPen(color));
|
this->setPen(QPen(color));
|
||||||
this->setBrush(QBrush(color));
|
this->setBrush(QBrush(color));
|
||||||
if(_placeHolder)
|
if(placeHolder_)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> items = _placeHolder->children();
|
QList<QGraphicsItem *> items = placeHolder_->children();
|
||||||
if(items.size())
|
if(items.size())
|
||||||
{
|
{
|
||||||
((QGraphicsTextItem *)items.front())->setDefaultTextColor(this->pen().color().rgb());
|
((QGraphicsTextItem *)items.front())->setDefaultTextColor(this->pen().color().rgb());
|
||||||
@ -46,33 +46,33 @@ void KeypointItem::setColor(const QColor & color)
|
|||||||
|
|
||||||
void KeypointItem::showDescription()
|
void KeypointItem::showDescription()
|
||||||
{
|
{
|
||||||
if(!_placeHolder)
|
if(!placeHolder_)
|
||||||
{
|
{
|
||||||
_placeHolder = new QGraphicsRectItem();
|
placeHolder_ = new QGraphicsRectItem();
|
||||||
_placeHolder->setVisible(false);
|
placeHolder_->setVisible(false);
|
||||||
this->scene()->addItem(_placeHolder);
|
this->scene()->addItem(placeHolder_);
|
||||||
_placeHolder->setBrush(QBrush(QColor ( 0, 0, 0, 170 ))); // Black transparent background
|
placeHolder_->setBrush(QBrush(QColor ( 0, 0, 0, 170 ))); // Black transparent background
|
||||||
QGraphicsTextItem * text = new QGraphicsTextItem(_placeHolder);
|
QGraphicsTextItem * text = new QGraphicsTextItem(placeHolder_);
|
||||||
text->setDefaultTextColor(this->pen().color().rgb());
|
text->setDefaultTextColor(this->pen().color().rgb());
|
||||||
text->setPlainText(_info);
|
text->setPlainText(info_);
|
||||||
_placeHolder->setRect(text->boundingRect());
|
placeHolder_->setRect(text->boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPen pen = this->pen();
|
QPen pen = this->pen();
|
||||||
this->setPen(QPen(pen.color(), _width+2));
|
this->setPen(QPen(pen.color(), width_+2));
|
||||||
_placeHolder->setZValue(this->zValue()+1);
|
placeHolder_->setZValue(this->zValue()+1);
|
||||||
_placeHolder->setPos(this->mapToScene(0,0));
|
placeHolder_->setPos(this->mapToScene(0,0));
|
||||||
_placeHolder->setVisible(true);
|
placeHolder_->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeypointItem::hideDescription()
|
void KeypointItem::hideDescription()
|
||||||
{
|
{
|
||||||
if(_placeHolder)
|
if(placeHolder_)
|
||||||
{
|
{
|
||||||
_placeHolder->setVisible(false);
|
placeHolder_->setVisible(false);
|
||||||
}
|
}
|
||||||
this->setPen(QPen(pen().color(), _width));
|
this->setPen(QPen(pen().color(), width_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeypointItem::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
|
void KeypointItem::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
|
||||||
@ -84,7 +84,7 @@ void KeypointItem::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setPen(QPen(pen().color(), _width+2));
|
this->setPen(QPen(pen().color(), width_+2));
|
||||||
}
|
}
|
||||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public:
|
|||||||
virtual ~KeypointItem();
|
virtual ~KeypointItem();
|
||||||
|
|
||||||
void setColor(const QColor & color);
|
void setColor(const QColor & color);
|
||||||
int id() const {return _id;}
|
int id() const {return id_;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
@ -30,10 +30,10 @@ private:
|
|||||||
void hideDescription();
|
void hideDescription();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _info;
|
QString info_;
|
||||||
QGraphicsRectItem * _placeHolder;
|
QGraphicsRectItem * placeHolder_;
|
||||||
int _width;
|
int width_;
|
||||||
int _id;
|
int id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -92,6 +92,10 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
|||||||
connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
|
connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
|
||||||
connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));
|
connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));
|
||||||
|
|
||||||
|
ui_->objects_area->addAction(ui_->actionAdd_object_from_scene);
|
||||||
|
ui_->objects_area->addAction(ui_->actionAdd_objects_from_files);
|
||||||
|
ui_->objects_area->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
|
||||||
ui_->actionStart_camera->setShortcut(Qt::Key_Space);
|
ui_->actionStart_camera->setShortcut(Qt::Key_Space);
|
||||||
ui_->actionPause_camera->setShortcut(Qt::Key_Space);
|
ui_->actionPause_camera->setShortcut(Qt::Key_Space);
|
||||||
|
|
||||||
|
|||||||
@ -81,33 +81,33 @@ void ObjWidget::setupUi()
|
|||||||
this->layout()->addWidget(label_);
|
this->layout()->addWidget(label_);
|
||||||
this->layout()->setContentsMargins(0,0,0,0);
|
this->layout()->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
_menu = new QMenu(tr(""), this);
|
menu_ = new QMenu(tr(""), this);
|
||||||
_showImage = _menu->addAction(tr("Show image"));
|
showImage_ = menu_->addAction(tr("Show image"));
|
||||||
_showImage->setCheckable(true);
|
showImage_->setCheckable(true);
|
||||||
_showImage->setChecked(true);
|
showImage_->setChecked(true);
|
||||||
_showFeatures = _menu->addAction(tr("Show features"));
|
showFeatures_ = menu_->addAction(tr("Show features"));
|
||||||
_showFeatures->setCheckable(true);
|
showFeatures_->setCheckable(true);
|
||||||
_showFeatures->setChecked(true);
|
showFeatures_->setChecked(true);
|
||||||
_mirrorView = _menu->addAction(tr("Mirror view"));
|
mirrorView_ = menu_->addAction(tr("Mirror view"));
|
||||||
_mirrorView->setCheckable(true);
|
mirrorView_->setCheckable(true);
|
||||||
_mirrorView->setChecked(false);
|
mirrorView_->setChecked(false);
|
||||||
_graphicsViewMode = _menu->addAction(tr("Graphics view"));
|
graphicsViewMode_ = menu_->addAction(tr("Graphics view"));
|
||||||
_graphicsViewMode->setCheckable(true);
|
graphicsViewMode_->setCheckable(true);
|
||||||
_graphicsViewMode->setChecked(false);
|
graphicsViewMode_->setChecked(false);
|
||||||
_autoScale = _menu->addAction(tr("Scale view"));
|
autoScale_ = menu_->addAction(tr("Scale view"));
|
||||||
_autoScale->setCheckable(true);
|
autoScale_->setCheckable(true);
|
||||||
_autoScale->setChecked(true);
|
autoScale_->setChecked(true);
|
||||||
_autoScale->setEnabled(false);
|
autoScale_->setEnabled(false);
|
||||||
_sizedFeatures = _menu->addAction(tr("Sized features"));
|
sizedFeatures_ = menu_->addAction(tr("Sized features"));
|
||||||
_sizedFeatures->setCheckable(true);
|
sizedFeatures_->setCheckable(true);
|
||||||
_sizedFeatures->setChecked(false);
|
sizedFeatures_->setChecked(false);
|
||||||
_menu->addSeparator();
|
menu_->addSeparator();
|
||||||
_setAlpha = _menu->addAction(tr("Set alpha..."));
|
setAlpha_ = menu_->addAction(tr("Set alpha..."));
|
||||||
_menu->addSeparator();
|
menu_->addSeparator();
|
||||||
_saveImage = _menu->addAction(tr("Save picture..."));
|
saveImage_ = menu_->addAction(tr("Save picture..."));
|
||||||
_menu->addSeparator();
|
menu_->addSeparator();
|
||||||
_delete = _menu->addAction(tr("Delete"));
|
delete_ = menu_->addAction(tr("Delete"));
|
||||||
_delete->setEnabled(false);
|
delete_->setEnabled(false);
|
||||||
|
|
||||||
this->setId(id_);
|
this->setId(id_);
|
||||||
|
|
||||||
@ -122,15 +122,15 @@ void ObjWidget::setId(int id)
|
|||||||
id_=id;
|
id_=id;
|
||||||
if(id_)
|
if(id_)
|
||||||
{
|
{
|
||||||
_savedFileName = QString("object_%1.png").arg(id_);
|
savedFileName_ = QString("object_%1.png").arg(id_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjWidget::setGraphicsViewMode(bool on)
|
void ObjWidget::setGraphicsViewMode(bool on)
|
||||||
{
|
{
|
||||||
_graphicsViewMode->setChecked(on);
|
graphicsViewMode_->setChecked(on);
|
||||||
graphicsView_->setVisible(on);
|
graphicsView_->setVisible(on);
|
||||||
_autoScale->setEnabled(on);
|
autoScale_->setEnabled(on);
|
||||||
//update items' color
|
//update items' color
|
||||||
if(on)
|
if(on)
|
||||||
{
|
{
|
||||||
@ -148,7 +148,7 @@ void ObjWidget::setGraphicsViewMode(bool on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_autoScale->isChecked())
|
if(autoScale_->isChecked())
|
||||||
{
|
{
|
||||||
graphicsView_->fitInView(graphicsView_->sceneRect(), Qt::KeepAspectRatio);
|
graphicsView_->fitInView(graphicsView_->sceneRect(), Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
@ -160,8 +160,8 @@ void ObjWidget::setGraphicsViewMode(bool on)
|
|||||||
|
|
||||||
void ObjWidget::setAutoScale(bool autoScale)
|
void ObjWidget::setAutoScale(bool autoScale)
|
||||||
{
|
{
|
||||||
_autoScale->setChecked(autoScale);
|
autoScale_->setChecked(autoScale);
|
||||||
if(_graphicsViewMode)
|
if(graphicsViewMode_)
|
||||||
{
|
{
|
||||||
if(autoScale)
|
if(autoScale)
|
||||||
{
|
{
|
||||||
@ -176,7 +176,7 @@ void ObjWidget::setAutoScale(bool autoScale)
|
|||||||
|
|
||||||
void ObjWidget::setSizedFeatures(bool on)
|
void ObjWidget::setSizedFeatures(bool on)
|
||||||
{
|
{
|
||||||
_sizedFeatures->setChecked(on);
|
sizedFeatures_->setChecked(on);
|
||||||
if(graphicsViewInitialized_)
|
if(graphicsViewInitialized_)
|
||||||
{
|
{
|
||||||
for(unsigned int i=0; i<(unsigned int)keypointItems_.size() && i<keypoints_.size(); ++i)
|
for(unsigned int i=0; i<(unsigned int)keypointItems_.size() && i<keypoints_.size(); ++i)
|
||||||
@ -190,7 +190,7 @@ void ObjWidget::setSizedFeatures(bool on)
|
|||||||
keypointItems_.at(i)->setRect(keypoints_[i].pt.x-radius, keypoints_[i].pt.y-radius, radius*2, radius*2);
|
keypointItems_.at(i)->setRect(keypoints_[i].pt.x-radius, keypoints_[i].pt.y-radius, radius*2, radius*2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!_graphicsViewMode->isChecked())
|
if(!graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
@ -198,13 +198,13 @@ void ObjWidget::setSizedFeatures(bool on)
|
|||||||
|
|
||||||
void ObjWidget::setMirrorView(bool on)
|
void ObjWidget::setMirrorView(bool on)
|
||||||
{
|
{
|
||||||
_mirrorView->setChecked(on);
|
mirrorView_->setChecked(on);
|
||||||
graphicsView_->setTransform(QTransform().scale(this->isMirrorView()?-1.0:1.0, 1.0));
|
graphicsView_->setTransform(QTransform().scale(this->isMirrorView()?-1.0:1.0, 1.0));
|
||||||
if(_graphicsViewMode->isChecked() && _autoScale->isChecked())
|
if(graphicsViewMode_->isChecked() && autoScale_->isChecked())
|
||||||
{
|
{
|
||||||
graphicsView_->fitInView(graphicsView_->sceneRect(), Qt::KeepAspectRatio);
|
graphicsView_->fitInView(graphicsView_->sceneRect(), Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
else if(!_graphicsViewMode->isChecked())
|
else if(!graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
@ -223,6 +223,7 @@ void ObjWidget::setAlpha(int alpha)
|
|||||||
color.setAlpha(alpha_);
|
color.setAlpha(alpha_);
|
||||||
keypointItems_.at(i)->setColor(color);
|
keypointItems_.at(i)->setColor(color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for(int i=0; i<rectItems_.size(); ++i)
|
for(int i=0; i<rectItems_.size(); ++i)
|
||||||
{
|
{
|
||||||
QPen pen = rectItems_.at(i)->pen();
|
QPen pen = rectItems_.at(i)->pen();
|
||||||
@ -231,8 +232,8 @@ void ObjWidget::setAlpha(int alpha)
|
|||||||
pen.setColor(color);
|
pen.setColor(color);
|
||||||
rectItems_.at(i)->setPen(pen);
|
rectItems_.at(i)->setPen(pen);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!_graphicsViewMode->isChecked())
|
if(!graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
@ -279,7 +280,7 @@ void ObjWidget::setData(const std::vector<cv::KeyPoint> & keypoints,
|
|||||||
image_ = QPixmap::fromImage(Ipl2QImage(iplImage_));
|
image_ = QPixmap::fromImage(Ipl2QImage(iplImage_));
|
||||||
//this->setMinimumSize(image_.size());
|
//this->setMinimumSize(image_.size());
|
||||||
}
|
}
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
this->setupGraphicsView();
|
this->setupGraphicsView();
|
||||||
}
|
}
|
||||||
@ -291,7 +292,7 @@ void ObjWidget::resetKptsColor()
|
|||||||
for(int i=0; i<kptColors_.size(); ++i)
|
for(int i=0; i<kptColors_.size(); ++i)
|
||||||
{
|
{
|
||||||
kptColors_[i] = defaultColor();
|
kptColors_[i] = defaultColor();
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
keypointItems_[i]->setColor(this->defaultColor());
|
keypointItems_[i]->setColor(this->defaultColor());
|
||||||
}
|
}
|
||||||
@ -307,7 +308,7 @@ void ObjWidget::setKptColor(int index, const QColor & color)
|
|||||||
kptColors_[index] = color;
|
kptColors_[index] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
if(index < keypointItems_.size())
|
if(index < keypointItems_.size())
|
||||||
{
|
{
|
||||||
@ -340,27 +341,27 @@ QList<QGraphicsItem*> ObjWidget::selectedItems() const
|
|||||||
|
|
||||||
bool ObjWidget::isImageShown() const
|
bool ObjWidget::isImageShown() const
|
||||||
{
|
{
|
||||||
return _showImage->isChecked();
|
return showImage_->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjWidget::isFeaturesShown() const
|
bool ObjWidget::isFeaturesShown() const
|
||||||
{
|
{
|
||||||
return _showFeatures->isChecked();
|
return showFeatures_->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjWidget::isSizedFeatures() const
|
bool ObjWidget::isSizedFeatures() const
|
||||||
{
|
{
|
||||||
return _sizedFeatures->isChecked();
|
return sizedFeatures_->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjWidget::isMirrorView() const
|
bool ObjWidget::isMirrorView() const
|
||||||
{
|
{
|
||||||
return _mirrorView->isChecked();
|
return mirrorView_->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjWidget::setDeletable(bool deletable)
|
void ObjWidget::setDeletable(bool deletable)
|
||||||
{
|
{
|
||||||
_delete->setEnabled(deletable);
|
delete_->setEnabled(deletable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjWidget::save(QDataStream & streamPtr) const
|
void ObjWidget::save(QDataStream & streamPtr) const
|
||||||
@ -468,7 +469,7 @@ void ObjWidget::computeScaleOffsets(float & scale, float & offsetX, float & offs
|
|||||||
|
|
||||||
void ObjWidget::paintEvent(QPaintEvent *event)
|
void ObjWidget::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
QWidget::paintEvent(event);
|
QWidget::paintEvent(event);
|
||||||
}
|
}
|
||||||
@ -481,7 +482,7 @@ void ObjWidget::paintEvent(QPaintEvent *event)
|
|||||||
this->computeScaleOffsets(ratio, offsetX, offsetY);
|
this->computeScaleOffsets(ratio, offsetX, offsetY);
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
if(_mirrorView->isChecked())
|
if(mirrorView_->isChecked())
|
||||||
{
|
{
|
||||||
painter.translate(offsetX+image_.width()*ratio, offsetY);
|
painter.translate(offsetX+image_.width()*ratio, offsetY);
|
||||||
painter.scale(-ratio, ratio);
|
painter.scale(-ratio, ratio);
|
||||||
@ -492,12 +493,12 @@ void ObjWidget::paintEvent(QPaintEvent *event)
|
|||||||
painter.scale(ratio, ratio);
|
painter.scale(ratio, ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_showImage->isChecked())
|
if(showImage_->isChecked())
|
||||||
{
|
{
|
||||||
painter.drawPixmap(QPoint(0,0), image_);
|
painter.drawPixmap(QPoint(0,0), image_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_showFeatures->isChecked())
|
if(showFeatures_->isChecked())
|
||||||
{
|
{
|
||||||
drawKeypoints(&painter);
|
drawKeypoints(&painter);
|
||||||
}
|
}
|
||||||
@ -519,7 +520,7 @@ void ObjWidget::paintEvent(QPaintEvent *event)
|
|||||||
top = mousePressedPos_.y() < mouseCurrentPos_.y() ? mousePressedPos_.y():mouseCurrentPos_.y();
|
top = mousePressedPos_.y() < mouseCurrentPos_.y() ? mousePressedPos_.y():mouseCurrentPos_.y();
|
||||||
right = mousePressedPos_.x() > mouseCurrentPos_.x() ? mousePressedPos_.x():mouseCurrentPos_.x();
|
right = mousePressedPos_.x() > mouseCurrentPos_.x() ? mousePressedPos_.x():mouseCurrentPos_.x();
|
||||||
bottom = mousePressedPos_.y() > mouseCurrentPos_.y() ? mousePressedPos_.y():mouseCurrentPos_.y();
|
bottom = mousePressedPos_.y() > mouseCurrentPos_.y() ? mousePressedPos_.y():mouseCurrentPos_.y();
|
||||||
if(_mirrorView->isChecked())
|
if(mirrorView_->isChecked())
|
||||||
{
|
{
|
||||||
int l = left;
|
int l = left;
|
||||||
left = qAbs(right - image_.width());
|
left = qAbs(right - image_.width());
|
||||||
@ -540,7 +541,7 @@ void ObjWidget::paintEvent(QPaintEvent *event)
|
|||||||
void ObjWidget::resizeEvent(QResizeEvent* event)
|
void ObjWidget::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
if(_graphicsViewMode->isChecked() && _autoScale->isChecked())
|
if(graphicsViewMode_->isChecked() && autoScale_->isChecked())
|
||||||
{
|
{
|
||||||
graphicsView_->fitInView(graphicsView_->sceneRect(), Qt::KeepAspectRatio);
|
graphicsView_->fitInView(graphicsView_->sceneRect(), Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
@ -578,7 +579,7 @@ void ObjWidget::mouseReleaseEvent(QMouseEvent * event)
|
|||||||
right = mousePressedPos_.x() > mouseCurrentPos_.x() ? mousePressedPos_.x():mouseCurrentPos_.x();
|
right = mousePressedPos_.x() > mouseCurrentPos_.x() ? mousePressedPos_.x():mouseCurrentPos_.x();
|
||||||
bottom = mousePressedPos_.y() > mouseCurrentPos_.y() ? mousePressedPos_.y():mouseCurrentPos_.y();
|
bottom = mousePressedPos_.y() > mouseCurrentPos_.y() ? mousePressedPos_.y():mouseCurrentPos_.y();
|
||||||
|
|
||||||
if(_mirrorView->isChecked())
|
if(mirrorView_->isChecked())
|
||||||
{
|
{
|
||||||
int l = left;
|
int l = left;
|
||||||
left = qAbs(right - image_.width());
|
left = qAbs(right - image_.width());
|
||||||
@ -592,28 +593,28 @@ void ObjWidget::mouseReleaseEvent(QMouseEvent * event)
|
|||||||
|
|
||||||
void ObjWidget::contextMenuEvent(QContextMenuEvent * event)
|
void ObjWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
{
|
{
|
||||||
QAction * action = _menu->exec(event->globalPos());
|
QAction * action = menu_->exec(event->globalPos());
|
||||||
if(action == _saveImage)
|
if(action == saveImage_)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
if(_savedFileName.isEmpty())
|
if(savedFileName_.isEmpty())
|
||||||
{
|
{
|
||||||
_savedFileName=Settings::workingDirectory()+"/figure.png";
|
savedFileName_=Settings::workingDirectory()+"/figure.png";
|
||||||
}
|
}
|
||||||
text = QFileDialog::getSaveFileName(this, tr("Save figure to ..."), _savedFileName, "*.png *.xpm *.jpg *.pdf");
|
text = QFileDialog::getSaveFileName(this, tr("Save figure to ..."), savedFileName_, "*.png *.xpm *.jpg *.pdf");
|
||||||
if(!text.isEmpty())
|
if(!text.isEmpty())
|
||||||
{
|
{
|
||||||
if(!text.endsWith(".png") && !text.endsWith(".xpm") && !text.endsWith(".jpg") && !text.endsWith(".pdf"))
|
if(!text.endsWith(".png") && !text.endsWith(".xpm") && !text.endsWith(".jpg") && !text.endsWith(".pdf"))
|
||||||
{
|
{
|
||||||
text.append(".png");//default
|
text.append(".png");//default
|
||||||
}
|
}
|
||||||
_savedFileName = text;
|
savedFileName_ = text;
|
||||||
getSceneAsPixmap().save(text);
|
getSceneAsPixmap().save(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(action == _showFeatures || action == _showImage)
|
else if(action == showFeatures_ || action == showImage_)
|
||||||
{
|
{
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
this->updateItemsShown();
|
this->updateItemsShown();
|
||||||
}
|
}
|
||||||
@ -622,27 +623,27 @@ void ObjWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(action == _mirrorView)
|
else if(action == mirrorView_)
|
||||||
{
|
{
|
||||||
this->setMirrorView(_mirrorView->isChecked());
|
this->setMirrorView(mirrorView_->isChecked());
|
||||||
}
|
}
|
||||||
else if(action == _delete)
|
else if(action == delete_)
|
||||||
{
|
{
|
||||||
emit removalTriggered(this);
|
emit removalTriggered(this);
|
||||||
}
|
}
|
||||||
else if(action == _graphicsViewMode)
|
else if(action == graphicsViewMode_)
|
||||||
{
|
{
|
||||||
this->setGraphicsViewMode(_graphicsViewMode->isChecked());
|
this->setGraphicsViewMode(graphicsViewMode_->isChecked());
|
||||||
}
|
}
|
||||||
else if(action == _autoScale)
|
else if(action == autoScale_)
|
||||||
{
|
{
|
||||||
this->setAutoScale(_autoScale->isChecked());
|
this->setAutoScale(autoScale_->isChecked());
|
||||||
}
|
}
|
||||||
else if(action == _sizedFeatures)
|
else if(action == sizedFeatures_)
|
||||||
{
|
{
|
||||||
this->setSizedFeatures(_sizedFeatures->isChecked());
|
this->setSizedFeatures(sizedFeatures_->isChecked());
|
||||||
}
|
}
|
||||||
else if(action == _setAlpha)
|
else if(action == setAlpha_)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int newAlpha = QInputDialog::getInt(this, tr("Set alpha"), tr("Alpha:"), alpha_, 0, 255, 5, &ok);
|
int newAlpha = QInputDialog::getInt(this, tr("Set alpha"), tr("Alpha:"), alpha_, 0, 255, 5, &ok);
|
||||||
@ -651,12 +652,11 @@ void ObjWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
this->setAlpha(newAlpha);
|
this->setAlpha(newAlpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QWidget::contextMenuEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap ObjWidget::getSceneAsPixmap()
|
QPixmap ObjWidget::getSceneAsPixmap()
|
||||||
{
|
{
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
QPixmap img(graphicsView_->sceneRect().width(), graphicsView_->sceneRect().height());
|
QPixmap img(graphicsView_->sceneRect().width(), graphicsView_->sceneRect().height());
|
||||||
QPainter p(&img);
|
QPainter p(&img);
|
||||||
@ -676,11 +676,11 @@ void ObjWidget::updateItemsShown()
|
|||||||
{
|
{
|
||||||
if(qgraphicsitem_cast<KeypointItem*>(items.at(i)))
|
if(qgraphicsitem_cast<KeypointItem*>(items.at(i)))
|
||||||
{
|
{
|
||||||
items.at(i)->setVisible(_showFeatures->isChecked());
|
items.at(i)->setVisible(showFeatures_->isChecked());
|
||||||
}
|
}
|
||||||
else if(qgraphicsitem_cast<QGraphicsPixmapItem*>(items.at(i)))
|
else if(qgraphicsitem_cast<QGraphicsPixmapItem*>(items.at(i)))
|
||||||
{
|
{
|
||||||
items.at(i)->setVisible(_showImage->isChecked());
|
items.at(i)->setVisible(showImage_->isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -695,13 +695,13 @@ void ObjWidget::drawKeypoints(QPainter * painter)
|
|||||||
{
|
{
|
||||||
const cv::KeyPoint & r = *iter;
|
const cv::KeyPoint & r = *iter;
|
||||||
float size = 14;
|
float size = 14;
|
||||||
if(r.size>14.0f && _sizedFeatures->isChecked())
|
if(r.size>14.0f && sizedFeatures_->isChecked())
|
||||||
{
|
{
|
||||||
size = r.size;
|
size = r.size;
|
||||||
}
|
}
|
||||||
float radius = size*1.2f/9.0f*2.0f;
|
float radius = size*1.2f/9.0f*2.0f;
|
||||||
QColor color(kptColors_.at(i).red(), kptColors_.at(i).green(), kptColors_.at(i).blue(), alpha_);
|
QColor color(kptColors_.at(i).red(), kptColors_.at(i).green(), kptColors_.at(i).blue(), alpha_);
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
QString info = QString( "ID = %1\n"
|
QString info = QString( "ID = %1\n"
|
||||||
"Response = %2\n"
|
"Response = %2\n"
|
||||||
@ -738,7 +738,7 @@ QColor ObjWidget::defaultColor() const
|
|||||||
std::vector<cv::KeyPoint> ObjWidget::selectedKeypoints() const
|
std::vector<cv::KeyPoint> ObjWidget::selectedKeypoints() const
|
||||||
{
|
{
|
||||||
std::vector<cv::KeyPoint> selected;
|
std::vector<cv::KeyPoint> selected;
|
||||||
if(_graphicsViewMode->isChecked())
|
if(graphicsViewMode_->isChecked())
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem*> items = graphicsView_->scene()->selectedItems();
|
QList<QGraphicsItem*> items = graphicsView_->scene()->selectedItems();
|
||||||
for(int i=0; i<items.size(); ++i)
|
for(int i=0; i<items.size(); ++i)
|
||||||
@ -771,7 +771,7 @@ void ObjWidget::setupGraphicsView()
|
|||||||
graphicsView_->scene()->addItem(rectItems_.at(i));
|
graphicsView_->scene()->addItem(rectItems_.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_autoScale->isChecked())
|
if(autoScale_->isChecked())
|
||||||
{
|
{
|
||||||
graphicsView_->fitInView(sceneRect, Qt::KeepAspectRatio);
|
graphicsView_->fitInView(sceneRect, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,17 +109,17 @@ private:
|
|||||||
QLabel * label_;
|
QLabel * label_;
|
||||||
|
|
||||||
// menu stuff
|
// menu stuff
|
||||||
QString _savedFileName;
|
QString savedFileName_;
|
||||||
QMenu * _menu;
|
QMenu * menu_;
|
||||||
QAction * _showImage;
|
QAction * showImage_;
|
||||||
QAction * _showFeatures;
|
QAction * showFeatures_;
|
||||||
QAction * _saveImage;
|
QAction * saveImage_;
|
||||||
QAction * _mirrorView;
|
QAction * mirrorView_;
|
||||||
QAction * _delete;
|
QAction * delete_;
|
||||||
QAction * _graphicsViewMode;
|
QAction * graphicsViewMode_;
|
||||||
QAction * _autoScale;
|
QAction * autoScale_;
|
||||||
QAction * _sizedFeatures;
|
QAction * sizedFeatures_;
|
||||||
QAction * _setAlpha;
|
QAction * setAlpha_;
|
||||||
|
|
||||||
// selection stuff
|
// selection stuff
|
||||||
QPoint mousePressedPos_;
|
QPoint mousePressedPos_;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user