Skip to content

Commit

Permalink
Merge pull request swri-robotics#417 from pjreed/414/arrow-scaling-jade
Browse files Browse the repository at this point in the history
Add option to not scale arrows with zoom level (Jade)
  • Loading branch information
pjreed committed Aug 16, 2016
2 parents 70d5509 + d4de63f commit c70d2c1
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 114 deletions.
7 changes: 6 additions & 1 deletion mapviz_plugins/include/mapviz_plugins/point_drawing_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace mapviz_plugins
{
}
virtual void Transform();
virtual bool DrawPoints();
virtual bool DrawPoints(double scale);
virtual bool DrawArrows();
virtual bool DrawArrow(const StampedPoint& point);
virtual bool DrawLaps();
Expand All @@ -94,8 +94,11 @@ namespace mapviz_plugins
protected Q_SLOTS:
virtual void DrawIcon();
virtual void SetDrawStyle(QString style);
virtual void SetStaticArrowSizes(bool isChecked);
virtual void SetArrowSize(int arrowSize);

protected:
int arrow_size_;
DrawStyle draw_style_;
StampedPoint cur_point_;
std::list<StampedPoint> points_;
Expand All @@ -106,6 +109,8 @@ namespace mapviz_plugins
QColor color_;
bool lap_checked_;
int buffer_holder_;
double scale_;
bool static_arrow_sizes_;

private:
std::vector<std::list<StampedPoint> > laps_;
Expand Down
67 changes: 60 additions & 7 deletions mapviz_plugins/src/navsat_config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<height>197</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -23,7 +23,34 @@
<property name="margin">
<number>2</number>
</property>
<item row="7" column="0">
<item row="5" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="static_arrow_sizes">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="arrow_size">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>25</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
Expand All @@ -36,7 +63,7 @@
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<item row="9" column="1" colspan="2">
<widget class="QLabel" name="status">
<property name="font">
<font>
Expand Down Expand Up @@ -113,7 +140,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
Expand All @@ -126,7 +153,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="positiontolerance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand Down Expand Up @@ -164,7 +191,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
Expand All @@ -177,7 +204,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QSpinBox" name="buffersize">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
Expand Down Expand Up @@ -226,6 +253,32 @@
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Static Arrow Sizes:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
Expand Down
22 changes: 21 additions & 1 deletion mapviz_plugins/src/navsat_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ namespace mapviz_plugins
SLOT(BufferSizeChanged(int)));
QObject::connect(ui_.drawstyle, SIGNAL(activated(QString)), this,
SLOT(SetDrawStyle(QString)));
QObject::connect(ui_.static_arrow_sizes, SIGNAL(clicked(bool)),
this, SLOT(SetStaticArrowSizes(bool)));
QObject::connect(ui_.arrow_size, SIGNAL(valueChanged(int)),
this, SLOT(SetArrowSize(int)));
connect(ui_.color, SIGNAL(colorEdited(const QColor&)), this,
SLOT(DrawIcon()));
}
Expand Down Expand Up @@ -229,7 +233,7 @@ namespace mapviz_plugins
void NavSatPlugin::Draw(double x, double y, double scale)
{
color_ = ui_.color->color();
if (DrawPoints())
if (DrawPoints(scale))
{
PrintInfo("OK");
}
Expand Down Expand Up @@ -280,6 +284,18 @@ namespace mapviz_plugins
ui_.buffersize->setValue(buffer_size_);
}

if (node["static_arrow_sizes"])
{
bool static_arrow_sizes = node["static_arrow_sizes"].as<bool>();
ui_.static_arrow_sizes->setChecked(static_arrow_sizes);
SetStaticArrowSizes(static_arrow_sizes);
}

if (node["arrow_size"])
{
ui_.arrow_size->setValue(node["arrow_size"].as<int>());
}

TopicEdited();
}

Expand All @@ -298,5 +314,9 @@ namespace mapviz_plugins
YAML::Value << position_tolerance_;

emitter << YAML::Key << "buffer_size" << YAML::Value << buffer_size_;

emitter << YAML::Key << "static_arrow_sizes" << YAML::Value << ui_.static_arrow_sizes->isChecked();

emitter << YAML::Key << "arrow_size" << YAML::Value << ui_.arrow_size->value();
}
}
Loading

0 comments on commit c70d2c1

Please sign in to comment.