Commit 535f8e67 authored by roangel's avatar roangel
Browse files

added QPointF constructor for marker added

parent 90f246d2
......@@ -109,8 +109,6 @@ private:
std::vector<Marker*> markers_vector;
Marker* marker;
#ifdef CATKIN_MAKE
rosNodeThread* _rosNodeThread;
#endif
......
......@@ -14,7 +14,7 @@
class Marker : public QGraphicsEllipseItem
{
public:
explicit Marker(qreal x, qreal y, QGraphicsItem *parent = 0);
explicit Marker(QPointF p, QGraphicsItem *parent = 0);
~Marker();
void setHighlighted(void);
......
......@@ -67,9 +67,6 @@ void MainGUIWindow::_init()
scene = new myGraphicsScene(ui->frame_drawing);
scene->setSceneRect(-100 * FROM_METERS_TO_UNITS, -100 * FROM_METERS_TO_UNITS, 200 * FROM_METERS_TO_UNITS, 200 * FROM_METERS_TO_UNITS);
marker = new Marker(1 * FROM_METERS_TO_UNITS, - 1 * FROM_METERS_TO_UNITS);
marker->setPos(100, -200);
ui->graphicsView->setScene(scene);
QObject::connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), scene, SLOT(removeCrazyFlyZone(int)));
......@@ -109,7 +106,8 @@ void MainGUIWindow::setPosMarkers(const ptrToMessage& p_msg) //connected to newV
if(i >= markers_vector.size()) //some new markers coming
{
ROS_INFO_STREAM("element index: " << i << " added");
Marker* tmp_p_marker = new Marker(p_msg->markers[i].x * FROM_METERS_TO_UNITS, p_msg->markers[i].y * FROM_METERS_TO_UNITS);
QPointF p(p_msg->markers[i].x * FROM_METERS_TO_UNITS, p_msg->markers[i].y * FROM_METERS_TO_UNITS);
Marker* tmp_p_marker = new Marker(scene->mapFromWorldToScene(p));
markers_vector.push_back(tmp_p_marker); // what happens with the new indexes? check if this is correct
if(ui->checkBox_vicon_markers->checkState() == Qt::Checked) //only if markers checkbox info is checked..
......@@ -124,7 +122,7 @@ void MainGUIWindow::setPosMarkers(const ptrToMessage& p_msg) //connected to newV
else
{
ROS_INFO_STREAM("element index: " << i << " moved, already existed");
markers_vector[i]->setPosMarker(QPointF(p_msg->markers[i].x * FROM_METERS_TO_UNITS, p_msg->markers[i].y * FROM_METERS_TO_UNITS));
markers_vector[i]->setPosMarker(scene->mapFromWorldToScene(QPointF(p_msg->markers[i].x * FROM_METERS_TO_UNITS, p_msg->markers[i].y * FROM_METERS_TO_UNITS)));
}
}
}
......
......@@ -4,15 +4,15 @@
#include <QBrush>
Marker::Marker(qreal x, qreal y, QGraphicsItem * parent)
Marker::Marker(QPointF p, QGraphicsItem * parent)
: QGraphicsEllipseItem(-MARKER_DIAMETER/2, - MARKER_DIAMETER/2, MARKER_DIAMETER, MARKER_DIAMETER, parent)
{
_highlighted = false;
_highlight_diameter = HIGHLIGHT_DIAMETER;
// save original x and y
_center_x = x;
_center_y = y;
_center_x = p.x();
_center_y = p.y();
_diameter = MARKER_DIAMETER; // x and y are top left coordinates
this->setPos(_center_x, _center_y); //where it is now, it is the center
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment